Skip to content

Commit

Permalink
Merge pull request #165 from yujiterada/fix-issue-164
Browse files Browse the repository at this point in the history
Fix #164
  • Loading branch information
fmunozmiranda authored Oct 1, 2024
2 parents a55fce3 + 90d1593 commit 928bf98
Showing 1 changed file with 29 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -382,8 +382,35 @@ func (r *NetworksApplianceFirewallL3FirewallRulesResource) Update(ctx context.Co
}

func (r *NetworksApplianceFirewallL3FirewallRulesResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) {
//missing delete
resp.Diagnostics.AddWarning("Error deleting NetworksApplianceFirewallL3FirewallRules", "This resource has no delete method in the meraki lab, the resource was deleted only in terraform.")
resp.Diagnostics.AddWarning("Warning deleting NetworksApplianceFirewallL3FirewallRules", "This will delete all layer 3 firewall rules for the specified appliance.")

var data NetworksApplianceFirewallL3FirewallRulesRs

// Get current state
resp.Diagnostics.Append(req.State.Get(ctx, &data)...)
if resp.Diagnostics.HasError() {
return
}

// Prepare default configuration
defaultConfig := merakigosdk.RequestApplianceUpdateNetworkApplianceFirewallL3FirewallRules{
Rules: &[]merakigosdk.RequestApplianceUpdateNetworkApplianceFirewallL3FirewallRulesRules{},
SyslogDefaultRule: nil,
}

// Update with default configuration
vvNetworkID := data.NetworkID.ValueString()
restyResp, err := r.client.Appliance.UpdateNetworkApplianceFirewallL3FirewallRules(vvNetworkID, &defaultConfig)

if err != nil || restyResp == nil {
resp.Diagnostics.AddError(
"Error resetting NetworksApplianceFirewallL3FirewallRules",
"Could not reset to default configuration, unexpected error: "+err.Error(),
)
return
}

// Remove resource from state
resp.State.RemoveResource(ctx)
}

Expand Down

0 comments on commit 928bf98

Please sign in to comment.