Skip to content

Commit

Permalink
## 0.2.1-alpha (April 16, 2024)
Browse files Browse the repository at this point in the history
BUGFIXES:
* ListAttribute replaced to SetAtrribute.
* NetworksWirelessSSIDsResource attributte marked as `Computed` removed cause were only `Optional` params.
  • Loading branch information
fmunozmiranda committed May 22, 2024
1 parent 362bdc1 commit 7d9c21b
Show file tree
Hide file tree
Showing 37 changed files with 201 additions and 119 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 0.2.1-alpha (April 16, 2024)
BUGFIXES:
* ListAttribute replaced to SetAtrribute.
* NetworksWirelessSSIDsResource attributte marked as `Computed` removed cause were only `Optional` params.

## 0.2.0-alpha (April 16, 2024)
FEATURES:
* Provider supports v1.44.1 of Meraki Dashboard API.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

resource "meraki_networks_wireless_ssids_firewall_l3_firewall_rules" "example" {

allow_lan_access = true
allow_lan_access = false
network_id = "string"
number = "string"
rules = [{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ resource "meraki_networks_syslog_servers" "example" {
network_id = "L_828099381482775375"
servers = [{

host = "1.2.3.4"
host = "1.2.3.42"
port = 443
roles = ["Wireless event log", "URLs"]
}]
Expand Down
27 changes: 15 additions & 12 deletions examples/samples/resources/new/resource.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,26 @@ terraform {
required_providers {
meraki = {
version = "0.2.0-alpha"
source = "hashicorp.com/edu/meraki"
source = "hashicorp.com/edu/meraki"
# "hashicorp.com/edu/meraki" is the local built source, change to "cisco-en-programmability/meraki" to use downloaded version from registry
}
}
}

provider "meraki" {
meraki_debug = "true"
}

variable "my_network_id" {
type = string
default = "*******" # Branch-1234
}
resource "meraki_networks_appliance_vlans" "my_mx" {
appliance_ip = "192.168.14.2"
id = "14"
name = "My VLAN"
network_id = var.my_network_id
subnet = "192.168.14.0/24"
}
resource "meraki_networks_alerts_settings" "example" {
network_id = "L_828099381482775374"
alerts = [{
type = "ampMalwareDetected"
enabled = true
}]
default_destinations = {
all_admins = true
# emails = []
http_server_ids = ["aHR0cHM6Ly93ZWJob29rLnNpdGU="]
snmp = false
}
}
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.1
github.com/hashicorp/terraform-plugin-framework v1.7.0
github.com/hashicorp/terraform-plugin-framework-validators v0.12.0
github.com/meraki/dashboard-api-go/v3 v3.0.0
github.com/meraki/dashboard-api-go/v3 v3.0.1
)

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.0 h1:5P/R/DuAm3XPkryBUVuQ1zmNGSE2OWqvAAhfgXI6YBk=
github.com/meraki/dashboard-api-go/v3 v3.0.0/go.mod h1:ngZmCzPKto29KbttUw7ibrLc+5RHHBKihYFkWFrL1zE=
github.com/meraki/dashboard-api-go/v3 v3.0.1 h1:24CeiQAuQYDoGkwBG7J91es78eB5CtY/TuCn6iYFeJ4=
github.com/meraki/dashboard-api-go/v3 v3.0.1/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 @@ -4,6 +4,7 @@ package provider
import (
"context"
"log"
"strconv"

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

Expand Down Expand Up @@ -138,8 +139,9 @@ func ResponseNetworksGetNetworkSyslogServersItemToBody(state NetworksSyslogServe
result[i] = ResponseNetworksGetNetworkSyslogServersServers{
Host: types.StringValue(servers.Host),
Port: func() types.Int64 {
if servers.Port != nil {
return types.Int64Value(int64(*servers.Port))
if servers.Port != "" {
serverPort, _ := strconv.Atoi(servers.Port)
return types.Int64Value(int64(serverPort))
}
return types.Int64{}
}(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func (r *AdministeredLicensingSubscriptionSubscriptionsBindResource) Schema(_ co
Computed: true,
Attributes: map[string]schema.Attribute{

"errors": schema.ListAttribute{
"errors": schema.SetAttribute{
MarkdownDescription: `Array of errors if failed`,
Computed: true,
ElementType: types.StringType,
Expand Down Expand Up @@ -128,7 +128,7 @@ func (r *AdministeredLicensingSubscriptionSubscriptionsBindResource) Schema(_ co
"parameters": schema.SingleNestedAttribute{
Required: true,
Attributes: map[string]schema.Attribute{
"network_ids": schema.ListAttribute{
"network_ids": schema.SetAttribute{
MarkdownDescription: `List of network ids to bind to the subscription`,
Optional: true,
Computed: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ func (r *AdministeredLicensingSubscriptionSubscriptionsClaimResource) Schema(_ c
MarkdownDescription: `Subscription name`,
Computed: true,
},
"product_types": schema.ListAttribute{
"product_types": schema.SetAttribute{
MarkdownDescription: `Products the subscription has entitlements for`,
Computed: true,
ElementType: types.StringType,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ func (r *AdministeredLicensingSubscriptionSubscriptionsClaimKeyValidateResource)
MarkdownDescription: `Subscription name`,
Computed: true,
},
"product_types": schema.ListAttribute{
"product_types": schema.SetAttribute{
MarkdownDescription: `Products the subscription has entitlements for`,
Computed: true,
ElementType: types.StringType,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func (r *DevicesSwitchPortsCycleResource) Schema(_ context.Context, _ resource.S
Computed: true,
Attributes: map[string]schema.Attribute{

"ports": schema.ListAttribute{
"ports": schema.SetAttribute{
MarkdownDescription: `List of switch ports`,
Computed: true,
ElementType: types.StringType,
Expand All @@ -66,7 +66,7 @@ func (r *DevicesSwitchPortsCycleResource) Schema(_ context.Context, _ resource.S
"parameters": schema.SingleNestedAttribute{
Required: true,
Attributes: map[string]schema.Attribute{
"ports": schema.ListAttribute{
"ports": schema.SetAttribute{
MarkdownDescription: `List of switch ports`,
Optional: true,
Computed: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func (r *DevicesWirelessAlternateManagementInterfaceIPv6Resource) Schema(_ conte
Computed: true,
Attributes: map[string]schema.Attribute{

"addresses": schema.ListAttribute{
"addresses": schema.SetAttribute{
MarkdownDescription: `Up to 2 nameserver addresses to use, ordered in priority from highest to lowest priority.`,
Computed: true,
ElementType: types.StringType,
Expand Down Expand Up @@ -155,7 +155,7 @@ func (r *DevicesWirelessAlternateManagementInterfaceIPv6Resource) Schema(_ conte
Computed: true,
Attributes: map[string]schema.Attribute{

"addresses": schema.ListAttribute{
"addresses": schema.SetAttribute{
MarkdownDescription: `Up to 2 nameserver addresses to use, ordered in priority from highest to lowest priority.`,
Optional: true,
Computed: true,
Expand Down
32 changes: 31 additions & 1 deletion internal/provider/resource_meraki_networks_alerts_settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,36 @@ func (r *NetworksAlertsSettingsResource) Schema(_ context.Context, _ resource.Sc
},
},
},
"muting": schema.SingleNestedAttribute{
MarkdownDescription: `muting`,
Computed: true,
Optional: true,
PlanModifiers: []planmodifier.Object{
objectplanmodifier.UseStateForUnknown(),
},
Attributes: map[string]schema.Attribute{

"by_port_schedules": schema.SingleNestedAttribute{
MarkdownDescription: `by_port_schedules`,
Computed: true,
Optional: true,
PlanModifiers: []planmodifier.Object{
objectplanmodifier.UseStateForUnknown(),
},
Attributes: map[string]schema.Attribute{
"enabled": schema.BoolAttribute{
MarkdownDescription: `enabled`,
Computed: true,
Optional: true,
PlanModifiers: []planmodifier.Bool{
boolplanmodifier.UseStateForUnknown(),
},
Default: booldefault.StaticBool(false),
},
},
},
},
},
"network_id": schema.StringAttribute{
MarkdownDescription: `networkId path parameter. Network ID`,
Required: true,
Expand Down Expand Up @@ -722,7 +752,7 @@ func ResponseNetworksGetNetworkAlertsSettingsItemToBodyRs(state NetworksAlertsSe
}(),
}

// itemState.DefaultDestinations.SNMP = state.DefaultDestinations.SNMP
itemState.DefaultDestinations.SNMP = state.DefaultDestinations.SNMP

itemState.Alerts = state.Alerts
if is_read {
Expand Down
4 changes: 2 additions & 2 deletions internal/provider/resource_meraki_networks_bind.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,12 @@ func (r *NetworksBindResource) Schema(_ context.Context, _ resource.SchemaReques
MarkdownDescription: `Organization ID`,
Computed: true,
},
"product_types": schema.ListAttribute{
"product_types": schema.SetAttribute{
MarkdownDescription: `List of the product types that the network supports`,
Computed: true,
ElementType: types.StringType,
},
"tags": schema.ListAttribute{
"tags": schema.SetAttribute{
MarkdownDescription: `Network tags`,
Computed: true,
ElementType: types.StringType,
Expand Down
4 changes: 2 additions & 2 deletions internal/provider/resource_meraki_networks_devices_claim.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func (r *NetworksDevicesClaimResource) Schema(_ context.Context, _ resource.Sche
Computed: true,
Attributes: map[string]schema.Attribute{

"serials": schema.ListAttribute{
"serials": schema.SetAttribute{
MarkdownDescription: `The serials of the devices`,
Computed: true,
ElementType: types.StringType,
Expand All @@ -66,7 +66,7 @@ func (r *NetworksDevicesClaimResource) Schema(_ context.Context, _ resource.Sche
"parameters": schema.SingleNestedAttribute{
Required: true,
Attributes: map[string]schema.Attribute{
"serials": schema.ListAttribute{
"serials": schema.SetAttribute{
MarkdownDescription: `A list of serials of devices to claim`,
Optional: true,
Computed: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ func (r *NetworksDevicesClaimVmxResource) Schema(_ context.Context, _ resource.S
MarkdownDescription: `Serial number of the device`,
Computed: true,
},
"tags": schema.ListAttribute{
"tags": schema.SetAttribute{
MarkdownDescription: `List of tags assigned to the device`,
Computed: true,
ElementType: types.StringType,
Expand Down
8 changes: 5 additions & 3 deletions internal/provider/resource_meraki_networks_group_policies.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package provider
import (
"context"
"fmt"
"log"
"strings"

merakigosdk "github.com/meraki/dashboard-api-go/v3/sdk"
Expand Down Expand Up @@ -925,9 +926,9 @@ func (r *NetworksGroupPoliciesResource) Create(ctx context.Context, req resource
vvName := data.Name.ValueString()
//Items
responseVerifyItem, restyResp1, err := r.client.Networks.GetNetworkGroupPolicies(vvNetworkID)
//Have Create
// Have Create
if err != nil || restyResp1 == nil {
if restyResp1.StatusCode() != 404 {
if restyResp1.StatusCode() != 404 && restyResp1.StatusCode() != 400 {
resp.Diagnostics.AddError(
"Failure when executing GetNetworkGroupPolicies",
err.Error(),
Expand All @@ -937,6 +938,7 @@ func (r *NetworksGroupPoliciesResource) Create(ctx context.Context, req resource
}
if responseVerifyItem != nil {
responseStruct := structToMap(responseVerifyItem)
log.Printf("[DEBUG] resp: %v", responseStruct)
result := getDictResult(responseStruct, "Name", vvName, simpleCmp)
if result != nil {
result2 := result.(map[string]interface{})
Expand All @@ -962,7 +964,7 @@ func (r *NetworksGroupPoliciesResource) Create(ctx context.Context, req resource
response, restyResp2, err := r.client.Networks.CreateNetworkGroupPolicy(vvNetworkID, dataRequest)

if err != nil || restyResp2 == nil || response == nil {
if restyResp1 != nil {
if restyResp2 != nil {
resp.Diagnostics.AddError(
"Failure when executing CreateNetworkGroupPolicy",
err.Error(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func (r *NetworksSmDevicesInstallAppsResource) Schema(_ context.Context, _ resou
"parameters": schema.SingleNestedAttribute{
Required: true,
Attributes: map[string]schema.Attribute{
"app_ids": schema.ListAttribute{
"app_ids": schema.SetAttribute{
MarkdownDescription: `ids of applications to be installed`,
Optional: true,
Computed: true,
Expand Down
10 changes: 5 additions & 5 deletions internal/provider/resource_meraki_networks_sm_devices_move.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func (r *NetworksSmDevicesMoveResource) Schema(_ context.Context, _ resource.Sch
Computed: true,
Attributes: map[string]schema.Attribute{

"ids": schema.ListAttribute{
"ids": schema.SetAttribute{
MarkdownDescription: `The Meraki Ids of the set of devices.`,
Computed: true,
ElementType: types.StringType,
Expand All @@ -70,7 +70,7 @@ func (r *NetworksSmDevicesMoveResource) Schema(_ context.Context, _ resource.Sch
"parameters": schema.SingleNestedAttribute{
Required: true,
Attributes: map[string]schema.Attribute{
"ids": schema.ListAttribute{
"ids": schema.SetAttribute{
MarkdownDescription: `The ids of the devices to be moved.`,
Optional: true,
Computed: true,
Expand All @@ -84,19 +84,19 @@ func (r *NetworksSmDevicesMoveResource) Schema(_ context.Context, _ resource.Sch
stringplanmodifier.RequiresReplace(),
},
},
"scope": schema.ListAttribute{
"scope": schema.SetAttribute{
MarkdownDescription: `The scope (one of all, none, withAny, withAll, withoutAny, or withoutAll) and a set of tags of the devices to be moved.`,
Optional: true,
Computed: true,
ElementType: types.StringType,
},
"serials": schema.ListAttribute{
"serials": schema.SetAttribute{
MarkdownDescription: `The serials of the devices to be moved.`,
Optional: true,
Computed: true,
ElementType: types.StringType,
},
"wifi_macs": schema.ListAttribute{
"wifi_macs": schema.SetAttribute{
MarkdownDescription: `The wifiMacs of the devices to be moved.`,
Optional: true,
Computed: true,
Expand Down
Loading

0 comments on commit 7d9c21b

Please sign in to comment.