Skip to content

Commit

Permalink
meraki_organizations_policy_objects_groups broken, both the data and …
Browse files Browse the repository at this point in the history
…resource #178
  • Loading branch information
fmunozmiranda committed Nov 26, 2024
1 parent 1479fb4 commit 4a09db9
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
terraform {
required_providers {
meraki = {
version = "0.2.12-alpha"
source = "hashicorp.com/edu/meraki"
}
}
}

data "meraki_organizations_policy_objects_groups" "example" {

# ending_before = "string"
# organization_id = "string"
per_page = 1
# starting_after = "string"
}

output "meraki_organizations_policy_objects_groups_example" {
value = data.meraki_organizations_policy_objects_groups.example.item
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ terraform {
source = "hashicorp.com/edu/meraki"
}
}
}
}


provider "meraki" {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
terraform import meraki_organizations_policy_objects_groups.example "organization_id,policy_object_group_id"
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
terraform {
required_providers {
meraki = {
version = "0.2.12-alpha"
source = "hashicorp.com/edu/meraki"
}
}
}

provider "meraki" {
meraki_debug = "true"
}

resource "meraki_organizations_policy_objects_groups" "example" {

category = "NetworkObjectGroup"
name = "Issue 178"
object_ids = [828099381482759082, 828099381482759083]
organization_id = "828099381482762270"
}

output "meraki_organizations_policy_objects_groups_example" {
value = meraki_organizations_policy_objects_groups.example
}
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ func ResponseOrganizationsGetOrganizationPolicyObjectsGroupItemToBody(state Orga
ID: types.StringValue(response.ID),
Name: types.StringValue(response.Name),
NetworkIDs: StringSliceToSet(response.NetworkIDs),
ObjectIDs: StringSliceToSetInt(response.ObjectIDs),
ObjectIDs: StringSliceToSet(*response.ObjectIDs),

Check failure on line 197 in internal/provider/data_source_meraki_organizations_policy_objects_groups.go

View workflow job for this annotation

GitHub Actions / Build

cannot use *response.ObjectIDs (variable of type []int) as []string value in argument to StringSliceToSet
UpdatedAt: types.StringValue(response.UpdatedAt),
}
state.Item = &itemState
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,15 @@ func (r *OrganizationsPolicyObjectsGroupsResource) Schema(_ context.Context, _ r
},
"created_at": schema.StringAttribute{
Computed: true,
PlanModifiers: []planmodifier.String{
stringplanmodifier.UseStateForUnknown(),
},
},
"id": schema.StringAttribute{
Computed: true,
PlanModifiers: []planmodifier.String{
stringplanmodifier.UseStateForUnknown(),
},
},
"name": schema.StringAttribute{
MarkdownDescription: `A name for the group of network addresses, unique within the organization (alphanumeric, space, dash, or underscore characters only)`,
Expand All @@ -71,7 +77,10 @@ func (r *OrganizationsPolicyObjectsGroupsResource) Schema(_ context.Context, _ r
},
},
"network_ids": schema.SetAttribute{
Computed: true,
Computed: true,
PlanModifiers: []planmodifier.Set{
setplanmodifier.UseStateForUnknown(),
},
ElementType: types.StringType,
},
"object_ids": schema.SetAttribute{
Expand Down Expand Up @@ -129,7 +138,7 @@ func (r *OrganizationsPolicyObjectsGroupsResource) Create(ctx context.Context, r
// organization_id
vvName := data.Name.ValueString()
//Items
responseVerifyItem, restyResp1, err := r.client.Organizations.GetOrganizationPolicyObjects(vvOrganizationID, nil)
responseVerifyItem, restyResp1, err := r.client.Organizations.GetOrganizationPolicyObjectsGroups(vvOrganizationID, nil)
//Have Create
if err != nil {
if restyResp1 != nil {
Expand Down Expand Up @@ -183,7 +192,7 @@ func (r *OrganizationsPolicyObjectsGroupsResource) Create(ctx context.Context, r
return
}
//Items
responseGet, restyResp1, err := r.client.Organizations.GetOrganizationPolicyObjects(vvOrganizationID, nil)
responseGet, restyResp1, err := r.client.Organizations.GetOrganizationPolicyObjectsGroups(vvOrganizationID, nil)
// Has item and has items

if err != nil || responseGet == nil {
Expand All @@ -207,8 +216,7 @@ func (r *OrganizationsPolicyObjectsGroupsResource) Create(ctx context.Context, r
vvPolicyObjectGroupID, ok := result2["ID"].(string)
if !ok {
resp.Diagnostics.AddError(
"Failure when parsing path parameter PolicyObjectGroupID",
err.Error(),
"Failure when parsing path parameter PolicyObjectGroupID", "Error",
)
return
}
Expand Down Expand Up @@ -402,8 +410,9 @@ func (r *OrganizationsPolicyObjectsGroupsRs) toSdkApiRequestCreate(ctx context.C
} else {
name = &emptyString
}
var objectIDs *[]int = nil
var objectIDs *[]string = nil
r.ObjectIDs.ElementsAs(ctx, &objectIDs, false)

out := merakigosdk.RequestOrganizationsCreateOrganizationPolicyObjectsGroup{
Category: *category,
Name: *name,
Expand Down Expand Up @@ -436,7 +445,7 @@ func ResponseOrganizationsGetOrganizationPolicyObjectsGroupItemToBodyRs(state Or
ID: types.StringValue(response.ID),
Name: types.StringValue(response.Name),
NetworkIDs: StringSliceToSet(response.NetworkIDs),
ObjectIDs: StringSliceToSetInt(response.ObjectIDs),
ObjectIDs: StringSliceToSet(*response.ObjectIDs),

Check failure on line 448 in internal/provider/resource_meraki_organizations_policy_objects_groups.go

View workflow job for this annotation

GitHub Actions / Build

cannot use *response.ObjectIDs (variable of type []int) as []string value in argument to StringSliceToSet
UpdatedAt: types.StringValue(response.UpdatedAt),
}
if is_read {
Expand Down

0 comments on commit 4a09db9

Please sign in to comment.