@@ -21,12 +21,10 @@ package provider
2121import (
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
4543var _ resource.Resource = & FabricEWLCResource {}
46- var _ resource.ResourceWithImportState = & FabricEWLCResource {}
4744
4845func 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