Skip to content

Commit 5c670d3

Browse files
add mutex to catalystcenter_assign_device_to_site resource (#244)
* add mutex to catalystcenter_assign_device_to_site resource to prevent multiple concurrent operations * update changelog
1 parent eb261a6 commit 5c670d3

File tree

5 files changed

+9
-5
lines changed

5 files changed

+9
-5
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
## 0.2.11 (unreleased)
22

3+
- Add mutex to `catalystcenter_assign_device_to_site` resource to prevent multiple concurrent operations
34
- Add `catalystcenter_sites` data source to retrieve list of all sites
45

56
## 0.2.10

docs/guides/changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ description: |-
99

1010
## 0.2.11 (unreleased)
1111

12+
- Add mutex to `catalystcenter_assign_device_to_site` resource to prevent multiple concurrent operations
1213
- Add `catalystcenter_sites` data source to retrieve list of all sites
1314

1415
## 0.2.10

gen/definitions/assign_device_to_site.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ post_update: true
99
no_import: true
1010
delete_no_id: true
1111
no_data_source: true
12+
mutex: true
1213
test_tags: [INVENTORY]
1314
doc_category: Sites
1415
attributes:

internal/provider/resource_catalystcenter_assign_device_to_site.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ func (r *AssignDeviceToSiteResource) Create(ctx context.Context, req resource.Cr
110110
body := plan.toBody(ctx, AssignDeviceToSite{})
111111

112112
params := ""
113-
res, err := r.client.Post(plan.getPath()+params, body)
113+
res, err := r.client.Post(plan.getPath()+params, body, cc.UseMutex)
114114
if err != nil {
115115
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (%s), got error: %s, %s", "POST", err, res.String()))
116116
return
@@ -222,7 +222,7 @@ func (r *AssignDeviceToSiteResource) Update(ctx context.Context, req resource.Up
222222
}
223223
body, _ = sjson.Set(body, "siteId", plan.SiteId.ValueString())
224224

225-
res, err := r.client.Post(plan.getPath(), body)
225+
res, err := r.client.Post(plan.getPath(), body, cc.UseMutex)
226226
if err != nil {
227227
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (POST), got error: %s, %s", err, res.String()))
228228
return
@@ -237,9 +237,9 @@ func (r *AssignDeviceToSiteResource) Update(ctx context.Context, req resource.Up
237237
body, _ = sjson.Set(body, fmt.Sprintf("deviceIds.%d", i), id)
238238
}
239239

240-
res, err := r.client.Post(plan.getPathDelete(), body)
240+
res, err := r.client.Post(plan.getPathDelete(), body, cc.UseMutex)
241241
if err != nil {
242-
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (POST), got error: %s, %s", err, res.String()))
242+
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (POST2), got error: %s, %s", err, res.String()))
243243
return
244244
}
245245
tflog.Debug(ctx, fmt.Sprintf("Device removed: %s", removed))
@@ -265,7 +265,7 @@ func (r *AssignDeviceToSiteResource) Delete(ctx context.Context, req resource.De
265265

266266
body := state.toBody(ctx, state)
267267
params := ""
268-
res, err := r.client.Post(state.getPathDelete()+params, body)
268+
res, err := r.client.Post(state.getPathDelete()+params, body, cc.UseMutex)
269269
if err != nil {
270270
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (POST), got error: %s, %s", err, res.String()))
271271
return

templates/guides/changelog.md.tmpl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ description: |-
99

1010
## 0.2.11 (unreleased)
1111

12+
- Add mutex to `catalystcenter_assign_device_to_site` resource to prevent multiple concurrent operations
1213
- Add `catalystcenter_sites` data source to retrieve list of all sites
1314

1415
## 0.2.10

0 commit comments

Comments
 (0)