Skip to content

Commit

Permalink
Merge pull request #168 from yujiterada/fix-issue-166
Browse files Browse the repository at this point in the history
Fix #166
  • Loading branch information
fmunozmiranda authored Oct 1, 2024
2 parents 8ae7f59 + baa25dc commit a55fce3
Showing 1 changed file with 33 additions and 2 deletions.
35 changes: 33 additions & 2 deletions internal/provider/resource_meraki_networks_appliance_ssids.go
Original file line number Diff line number Diff line change
Expand Up @@ -457,8 +457,39 @@ func (r *NetworksApplianceSSIDsResource) Update(ctx context.Context, req resourc
}

func (r *NetworksApplianceSSIDsResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) {
//missing delete
resp.Diagnostics.AddWarning("Error deleting NetworksApplianceSSIDs", "This resource has no delete method in the meraki lab, the resource was deleted only in terraform.")
resp.Diagnostics.AddWarning("Warning deleting NetworksApplianceSSIDs", "This will restore default config except for VLAN ID")

var data NetworksApplianceSSIDsRs
resp.Diagnostics.Append(req.State.Get(ctx, &data)...)
if resp.Diagnostics.HasError() {
return
}

networkID := data.NetworkID.ValueString()
number := int(data.Number.ValueInt64())

/* Meraki API doesn't provide a delete method so update to default config as much as possible.
DefaultVLANID will not be set as this depends on what VLANs are configured on the appliance.
AuthMode: "open"
Enabled: false
Name: "Unconfigured SSID " + number
*/
disableRequest := &merakigosdk.RequestApplianceUpdateNetworkApplianceSSID{
AuthMode: "open",
Enabled: func() *bool { b := false; return &b }(),
Name: "Unconfigured SSID " + strconv.Itoa(number),
}

_, _, err := r.client.Appliance.UpdateNetworkApplianceSSID(networkID, strconv.Itoa(number), disableRequest)
if err != nil {
resp.Diagnostics.AddError(
"Error disabling NetworksApplianceSSIDs",
"Couldn't disable the SSID: "+err.Error(),
)
return
}

resp.State.RemoveResource(ctx)
}

Expand Down

0 comments on commit a55fce3

Please sign in to comment.