@@ -131,20 +131,20 @@ func (r *OrganizationTagResource) Create(ctx context.Context, req resource.Creat
131
131
132
132
organizationTagResponse , err := r .client .Do (organizationTagRequest )
133
133
if err != nil {
134
- resp .Diagnostics .AddError ("Error executing organization tag resource request" , fmt .Sprintf ("Error executing organization tag resource request: %s" , err ))
134
+ resp .Diagnostics .AddError ("Error executing organization tag resource request" , fmt .Sprintf ("Error executing organization tag resource request, response status : %s, response body: %s, body: %s" , organizationTagResponse . Status , organizationTagResponse . Body , err ))
135
135
return
136
136
}
137
137
138
138
bodyResponse , err := io .ReadAll (organizationTagResponse .Body )
139
139
if err != nil {
140
- tflog .Error (ctx , "Error reading organization tag resource response" )
140
+ tflog .Error (ctx , fmt . Sprintf ( "Error reading organization tag resource response, response status: %s, response body: %s, body: %s" , organizationTagResponse . Status , organizationTagResponse . Body , err ) )
141
141
}
142
142
newOrganizationTag := & client.OrganizationTagEntity {}
143
143
144
144
err = jsonapi .UnmarshalPayload (strings .NewReader (string (bodyResponse )), newOrganizationTag )
145
145
146
146
if err != nil {
147
- resp .Diagnostics .AddError ("Error unmarshal payload response" , fmt .Sprintf ("Error unmarshal payload response: %s" , err ))
147
+ resp .Diagnostics .AddError ("Error unmarshal payload response" , fmt .Sprintf ("Error unmarshal payload response, response status : %s, response body: %s, body: %s" , organizationTagResponse . Status , organizationTagResponse . Body , err ))
148
148
return
149
149
}
150
150
@@ -176,21 +176,21 @@ func (r *OrganizationTagResource) Read(ctx context.Context, req resource.ReadReq
176
176
177
177
organizationTagResponse , err := r .client .Do (organizationTagRequest )
178
178
if err != nil {
179
- resp .Diagnostics .AddError ("Error executing organization tag resource request" , fmt .Sprintf ("Error executing organization tag resource request: %s" , err ))
179
+ resp .Diagnostics .AddError ("Error executing organization tag resource request" , fmt .Sprintf ("Error executing organization tag resource request, response status : %s, response body: %s, body: %s" , organizationTagResponse . Status , organizationTagResponse . Body , err ))
180
180
return
181
181
}
182
182
183
183
bodyResponse , err := io .ReadAll (organizationTagResponse .Body )
184
184
if err != nil {
185
- tflog .Error (ctx , "Error reading organization tag resource response" )
185
+ tflog .Error (ctx , fmt . Sprintf ( "Error reading organization tag resource response, response status: %s, response body: %s, body: %s" , organizationTagResponse . Status , organizationTagResponse . Body , err ) )
186
186
}
187
187
organizationTag := & client.OrganizationTagEntity {}
188
188
189
189
tflog .Info (ctx , "Body Response" , map [string ]any {"bodyResponse" : string (bodyResponse )})
190
190
err = jsonapi .UnmarshalPayload (strings .NewReader (string (bodyResponse )), organizationTag )
191
191
192
192
if err != nil {
193
- resp .Diagnostics .AddError ("Error unmarshal payload response" , fmt .Sprintf ("Error unmarshal payload response: %s" , err ))
193
+ resp .Diagnostics .AddError ("Error unmarshal payload response" , fmt .Sprintf ("Error unmarshal payload response, response status : %s, response body: %s, body: %s" , organizationTagResponse . Status , organizationTagResponse . Body , err ))
194
194
return
195
195
}
196
196
@@ -241,13 +241,13 @@ func (r *OrganizationTagResource) Update(ctx context.Context, req resource.Updat
241
241
242
242
organizationTagResponse , err := r .client .Do (organizationTagRequest )
243
243
if err != nil {
244
- resp .Diagnostics .AddError ("Error executing organization tag resource request" , fmt .Sprintf ("Error executing organization tag resource request: %s" , err ))
244
+ resp .Diagnostics .AddError ("Error executing organization tag resource request" , fmt .Sprintf ("Error executing organization tag resource request, response status : %s, response body: %s, body: %s" , organizationTagResponse . Status , organizationTagResponse . Body , err ))
245
245
return
246
246
}
247
247
248
248
bodyResponse , err := io .ReadAll (organizationTagResponse .Body )
249
249
if err != nil {
250
- tflog .Error (ctx , "Error reading organization tag resource response" )
250
+ tflog .Error (ctx , fmt . Sprintf ( "Error reading organization tag resource response, response status: %s, response body: %s, body: %s" , organizationTagResponse . Status , organizationTagResponse . Body , err ) )
251
251
}
252
252
253
253
tflog .Info (ctx , "Body Response" , map [string ]any {"success" : string (bodyResponse )})
@@ -262,13 +262,13 @@ func (r *OrganizationTagResource) Update(ctx context.Context, req resource.Updat
262
262
263
263
organizationTagResponse , err = r .client .Do (organizationTagRequest )
264
264
if err != nil {
265
- resp .Diagnostics .AddError ("Error executing organization tag resource request" , fmt .Sprintf ("Error executing organization tag resource request: %s" , err ))
265
+ resp .Diagnostics .AddError ("Error executing organization tag resource request" , fmt .Sprintf ("Error executing organization tag resource request, response status : %s, response body: %s, body: %s" , organizationTagResponse . Status , organizationTagResponse . Body , err ))
266
266
return
267
267
}
268
268
269
269
bodyResponse , err = io .ReadAll (organizationTagResponse .Body )
270
270
if err != nil {
271
- resp .Diagnostics .AddError ("Error reading organization tag resource response body" , fmt .Sprintf ("Error reading organization tag resource response body: %s" , err ))
271
+ resp .Diagnostics .AddError ("Error reading organization tag resource response body" , fmt .Sprintf ("Error reading organization tag resource response body, response status : %s, response body: %s, body: %s" , organizationTagResponse . Status , organizationTagResponse . Body , err ))
272
272
}
273
273
274
274
tflog .Info (ctx , "Body Response" , map [string ]any {"bodyResponse" : string (bodyResponse )})
@@ -304,13 +304,24 @@ func (r *OrganizationTagResource) Delete(ctx context.Context, req resource.Delet
304
304
return
305
305
}
306
306
307
- _ , err = r .client .Do (reqOrg )
308
- if err != nil {
309
- resp .Diagnostics .AddError ("Error executing organization tag resource request" , fmt .Sprintf ("Error executing organization tag resource request: %s" , err ))
307
+ organizationTagResponse , err : = r .client .Do (reqOrg )
308
+ if err != nil || organizationTagResponse . StatusCode != http . StatusNoContent {
309
+ resp .Diagnostics .AddError ("Error executing organization tag resource request" , fmt .Sprintf ("Error executing organization tag resource request, response status : %s, response body: %s, body: %s" , organizationTagResponse . Status , organizationTagResponse . Body , err ))
310
310
return
311
311
}
312
312
}
313
313
314
314
func (r * OrganizationTagResource ) ImportState (ctx context.Context , req resource.ImportStateRequest , resp * resource.ImportStateResponse ) {
315
- resource .ImportStatePassthroughID (ctx , path .Root ("id" ), req , resp )
315
+ idParts := strings .Split (req .ID , "," )
316
+
317
+ if len (idParts ) != 2 || idParts [0 ] == "" || idParts [1 ] == "" {
318
+ resp .Diagnostics .AddError (
319
+ "Unexpected Import Identifier" ,
320
+ fmt .Sprintf ("Expected import identifier with format: 'organization_ID,ID', Got: %q" , req .ID ),
321
+ )
322
+ return
323
+ }
324
+
325
+ resp .Diagnostics .Append (resp .State .SetAttribute (ctx , path .Root ("organization_id" ), idParts [0 ])... )
326
+ resp .Diagnostics .Append (resp .State .SetAttribute (ctx , path .Root ("id" ), idParts [1 ])... )
316
327
}
0 commit comments