Skip to content

Commit

Permalink
Appliance Static Routing Resource #182
Browse files Browse the repository at this point in the history
meraki_organizations_policy_objects_groups broken, both the data and resource #178
  • Loading branch information
fmunozmiranda committed Nov 27, 2024
1 parent d75b661 commit 2f7c62b
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
terraform {
required_providers {
meraki = {
source = "hashicorp.com/edu/meraki"
version = "0.2.12-alpha"
}
}

required_version = ">= 1.2.0"
}
resource "meraki_networks_appliance_static_routes" "example" {
provider = meraki
gateway_ip = "1.2.3.5"
name = "My route"
network_id = "string"
network_id = "L_828099381482771185"
subnet = "192.168.1.0/24"
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ resource "meraki_organizations_policy_objects_groups" "example" {

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

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ require (
github.com/hashicorp/terraform-plugin-docs v0.19.4
github.com/hashicorp/terraform-plugin-framework v1.11.0
github.com/hashicorp/terraform-plugin-framework-validators v0.12.0
github.com/meraki/dashboard-api-go/v3 v3.0.9
github.com/meraki/dashboard-api-go/v3 v3.0.10
)

require (
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@ github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWE
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0=
github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
github.com/meraki/dashboard-api-go/v3 v3.0.9 h1:l3VIHu+0Jy1GysHe2sSLxp+wVhY6EB2Ng3e8/ygVBXE=
github.com/meraki/dashboard-api-go/v3 v3.0.9/go.mod h1:ngZmCzPKto29KbttUw7ibrLc+5RHHBKihYFkWFrL1zE=
github.com/meraki/dashboard-api-go/v3 v3.0.10 h1:CqQaPbPA6frSDrCT2SxvBPhtgu8+dVvRwWojza8fmA4=
github.com/meraki/dashboard-api-go/v3 v3.0.10/go.mod h1:ngZmCzPKto29KbttUw7ibrLc+5RHHBKihYFkWFrL1zE=
github.com/mitchellh/copystructure v1.0.0/go.mod h1:SNtv71yrdKgLRyLFxmLdkAbkKEFWgYaq1OVrnRcwhnw=
github.com/mitchellh/copystructure v1.2.0 h1:vpKXTN4ewci03Vljg/q9QvCGUDttBOGBIa15WveJJGw=
github.com/mitchellh/copystructure v1.2.0/go.mod h1:qLl+cE2AmVv+CoeAwDPye/v+N2HKCj9FbZEVFJRxO9s=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,12 @@ package provider
// RESOURCE NORMAL
import (
"context"
"fmt"
"strings"

merakigosdk "github.com/meraki/dashboard-api-go/v3/sdk"

"github.com/hashicorp/terraform-plugin-framework/path"
"github.com/hashicorp/terraform-plugin-framework/resource"
"github.com/hashicorp/terraform-plugin-framework/resource/schema"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/boolplanmodifier"
Expand Down Expand Up @@ -366,6 +369,20 @@ func (r *NetworksApplianceStaticRoutesResource) Read(ctx context.Context, req re
resp.Diagnostics.Append(diags...)
}

func (r *NetworksApplianceStaticRoutesResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) {
idParts := strings.Split(req.ID, ",")
if len(idParts) != 2 || idParts[0] == "" || idParts[1] == "" {
resp.Diagnostics.AddError(
"Unexpected Import Identifier",
fmt.Sprintf("Expected import identifier with format: attr_one,attr_two. Got: %q", req.ID),
)
return
}

resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("network_id"), idParts[0])...)
resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("static_route_id"), idParts[1])...)
}

func (r *NetworksApplianceStaticRoutesResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) {
var data NetworksApplianceStaticRoutesRs
merge(ctx, req, resp, &data)
Expand Down Expand Up @@ -581,11 +598,11 @@ func ResponseApplianceGetNetworkApplianceStaticRouteItemToBodyRs(state NetworksA
Name: types.StringValue(response.FixedIPAssignments.Status223344556677.Name),
}
}
return &ResponseApplianceGetNetworkApplianceStaticRouteFixedIpAssignments223344556677Rs{}
return nil
}(),
}
}
return &ResponseApplianceGetNetworkApplianceStaticRouteFixedIpAssignmentsRs{}
return nil
}(),
GatewayIP: types.StringValue(response.GatewayIP),
GatewayVLANID: func() types.Int64 {
Expand Down Expand Up @@ -615,7 +632,7 @@ func ResponseApplianceGetNetworkApplianceStaticRouteItemToBodyRs(state NetworksA
}
return &result
}
return &[]ResponseApplianceGetNetworkApplianceStaticRouteReservedIpRangesRs{}
return nil
}(),
Subnet: types.StringValue(response.Subnet),
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ func (r *OrganizationsPolicyObjectsGroupsRs) toSdkApiRequestUpdate(ctx context.C
} else {
name = &emptyString
}
var objectIDs *[]int = nil
var objectIDs *[]string = nil
r.ObjectIDs.ElementsAs(ctx, &objectIDs, false)
out := merakigosdk.RequestOrganizationsUpdateOrganizationPolicyObjectsGroup{
Name: *name,
Expand Down

0 comments on commit 2f7c62b

Please sign in to comment.