Skip to content

Commit 3cd1098

Browse files
tmp
1 parent e0f439e commit 3cd1098

File tree

4 files changed

+2
-50
lines changed

4 files changed

+2
-50
lines changed

docs/resources/fabric_ewlc.md

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,3 @@ resource "catalystcenter_fabric_ewlc" "example" {
4040
### Read-Only
4141

4242
- `id` (String) The id of the object
43-
44-
## Import
45-
46-
Import is supported using the following syntax:
47-
48-
The [`terraform import` command](https://developer.hashicorp.com/terraform/cli/commands/import) can be used, for example:
49-
50-
```shell
51-
terraform import catalystcenter_fabric_ewlc.example "<fabric_id>,<network_device_id>,<id>"
52-
```

examples/resources/catalystcenter_fabric_ewlc/import.sh

Lines changed: 0 additions & 1 deletion
This file was deleted.

gen/definitions/fabric_ewlc.yaml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@ name: Fabric EWLC
33
rest_endpoint: /dna/intent/api/v1/sda/fabrics/%v/switchWirelessSetting
44
get_rest_endpoint: /dna/intent/api/v1/sda/fabricDevices
55
res_description: This resource is used to enable or disable wireless capabilities on switch devices, along with configuring rolling AP upgrades on the fabric site. Reboot action is required to remove wireless configurations.
6-
# no_import: true
7-
# no_update: true
8-
# no_read: true
6+
no_import: true
7+
no_read: true
98
delete_no_id: true
109
no_data_source: true
1110
put_create: true

internal/provider/resource_catalystcenter_fabric_ewlc.go

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,10 @@ package provider
2121
import (
2222
"context"
2323
"fmt"
24-
"net/url"
2524
"strings"
2625

2726
"github.com/CiscoDevNet/terraform-provider-catalystcenter/internal/provider/helpers"
2827
"github.com/hashicorp/terraform-plugin-framework-validators/int64validator"
29-
"github.com/hashicorp/terraform-plugin-framework/path"
3028
"github.com/hashicorp/terraform-plugin-framework/resource"
3129
"github.com/hashicorp/terraform-plugin-framework/resource/schema"
3230
"github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier"
@@ -43,7 +41,6 @@ import (
4341

4442
// Ensure provider defined types fully satisfy framework interfaces
4543
var _ resource.Resource = &FabricEWLCResource{}
46-
var _ resource.ResourceWithImportState = &FabricEWLCResource{}
4744

4845
func NewFabricEWLCResource() resource.Resource {
4946
return &FabricEWLCResource{}
@@ -167,24 +164,6 @@ func (r *FabricEWLCResource) Read(ctx context.Context, req resource.ReadRequest,
167164

168165
tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Read", state.Id.String()))
169166

170-
params := ""
171-
params += "?fabricId=" + url.QueryEscape(state.FabricId.ValueString()) + "&networkDeviceId=" + url.QueryEscape(state.NetworkDeviceId.ValueString())
172-
res, err := r.client.Get("/dna/intent/api/v1/sda/fabricDevices" + params)
173-
if err != nil && (strings.Contains(err.Error(), "StatusCode 404") || strings.Contains(err.Error(), "StatusCode 406") || strings.Contains(err.Error(), "StatusCode 500") || strings.Contains(err.Error(), "StatusCode 400")) {
174-
resp.State.RemoveResource(ctx)
175-
return
176-
} else if err != nil {
177-
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (GET), got error: %s, %s", err, res.String()))
178-
return
179-
}
180-
181-
// If every attribute is set to null we are dealing with an import operation and therefore reading all attributes
182-
if state.isNull(ctx, res) {
183-
state.fromBody(ctx, res)
184-
} else {
185-
state.updateFromBody(ctx, res)
186-
}
187-
188167
tflog.Debug(ctx, fmt.Sprintf("%s: Read finished successfully", state.Id.ValueString()))
189168

190169
diags = resp.State.Set(ctx, &state)
@@ -268,19 +247,4 @@ func (r *FabricEWLCResource) Delete(ctx context.Context, req resource.DeleteRequ
268247
// End of section. //template:end delete
269248

270249
// Section below is generated&owned by "gen/generator.go". //template:begin import
271-
func (r *FabricEWLCResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) {
272-
idParts := strings.Split(req.ID, ",")
273-
274-
if len(idParts) != 3 || idParts[0] == "" || idParts[1] == "" || idParts[2] == "" {
275-
resp.Diagnostics.AddError(
276-
"Unexpected Import Identifier",
277-
fmt.Sprintf("Expected import identifier with format: <fabric_id>,<network_device_id>,<id>. Got: %q", req.ID),
278-
)
279-
return
280-
}
281-
resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("fabric_id"), idParts[0])...)
282-
resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("network_device_id"), idParts[1])...)
283-
resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("id"), idParts[2])...)
284-
}
285-
286250
// End of section. //template:end import

0 commit comments

Comments
 (0)