Skip to content

Commit 85cdac3

Browse files
authored
fix: use updated api operations (#625)
Pulled in the `oxide.go` changes from oxidecomputer/oxide.go#375 and updated the method calls in Terraform accordingly. Relates to SSE-141.
1 parent f84bc22 commit 85cdac3

14 files changed

Lines changed: 73 additions & 70 deletions

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ require (
2020
github.com/hashicorp/terraform-plugin-log v0.10.0
2121
github.com/hashicorp/terraform-plugin-sdk/v2 v2.38.2
2222
github.com/hashicorp/terraform-plugin-testing v1.14.0
23-
github.com/oxidecomputer/oxide.go v0.7.1-0.20260206215021-1401cd9ed09b
23+
github.com/oxidecomputer/oxide.go v0.7.1-0.20260210052317-44dc2f2e0895
2424
github.com/stretchr/testify v1.11.1
2525
)
2626

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -623,8 +623,8 @@ github.com/otiai10/curr v0.0.0-20150429015615-9b4961190c95/go.mod h1:9qAhocn7zKJ
623623
github.com/otiai10/curr v1.0.0/go.mod h1:LskTG5wDwr8Rs+nNQ+1LlxRjAtTZZjtJW4rMXl6j4vs=
624624
github.com/otiai10/mint v1.3.0/go.mod h1:F5AjcsTsWUqX+Na9fpHb52P8pcRX2CI6A3ctIT91xUo=
625625
github.com/otiai10/mint v1.3.1/go.mod h1:/yxELlJQ0ufhjUwhshSj+wFjZ78CnZ48/1wtmBH1OTc=
626-
github.com/oxidecomputer/oxide.go v0.7.1-0.20260206215021-1401cd9ed09b h1:KDUeTr6i0kGdMhs1JB/H1nM0mmd3ZZ9ww2GNpop51hc=
627-
github.com/oxidecomputer/oxide.go v0.7.1-0.20260206215021-1401cd9ed09b/go.mod h1:ZlG5ri4a6ClA/yhDCbQN6m/F3d/m41XHx5s9WbfFLWc=
626+
github.com/oxidecomputer/oxide.go v0.7.1-0.20260210052317-44dc2f2e0895 h1:o46kHstj4v5zH3eRgrhNSdVyOM/0GdwvjxdEIBGJXuk=
627+
github.com/oxidecomputer/oxide.go v0.7.1-0.20260210052317-44dc2f2e0895/go.mod h1:ZlG5ri4a6ClA/yhDCbQN6m/F3d/m41XHx5s9WbfFLWc=
628628
github.com/pelletier/go-toml v1.9.5 h1:4yBQzkHv+7BHq2PQUZF3Mx0IYxG7LsP222s7Agd3ve8=
629629
github.com/pelletier/go-toml v1.9.5/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c=
630630
github.com/pelletier/go-toml/v2 v2.2.4 h1:mye9XuhQ6gvn5h28+VilKrrPoQVanw5PMw/TB0t5Ec4=

internal/provider/data_source_ip_pool.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,10 +122,10 @@ func (d *ipPoolDataSource) Read(
122122
ctx, cancel := context.WithTimeout(ctx, readTimeout)
123123
defer cancel()
124124

125-
params := oxide.ProjectIpPoolViewParams{
125+
params := oxide.IpPoolViewParams{
126126
Pool: oxide.NameOrId(state.Name.ValueString()),
127127
}
128-
ipPool, err := d.client.ProjectIpPoolView(ctx, params)
128+
ipPool, err := d.client.IpPoolView(ctx, params)
129129
if err != nil {
130130
resp.Diagnostics.AddError(
131131
"Unable to read IP pool:",

internal/provider/data_source_subnet_pool.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -147,10 +147,10 @@ func (d *subnetPoolDataSource) Read(
147147
ctx, cancel := context.WithTimeout(ctx, readTimeout)
148148
defer cancel()
149149

150-
params := oxide.SubnetPoolViewParams{
150+
params := oxide.SystemSubnetPoolViewParams{
151151
Pool: oxide.NameOrId(state.Name.ValueString()),
152152
}
153-
pool, err := d.client.SubnetPoolView(ctx, params)
153+
pool, err := d.client.SystemSubnetPoolView(ctx, params)
154154
if err != nil {
155155
resp.Diagnostics.AddError(
156156
"Unable to read subnet pool:",
@@ -174,9 +174,12 @@ func (d *subnetPoolDataSource) Read(
174174
state.TimeModified = types.StringValue(pool.TimeModified.String())
175175

176176
// Read members
177-
members, err := d.client.SubnetPoolMemberListAllPages(ctx, oxide.SubnetPoolMemberListParams{
178-
Pool: oxide.NameOrId(pool.Id),
179-
})
177+
members, err := d.client.SystemSubnetPoolMemberListAllPages(
178+
ctx,
179+
oxide.SystemSubnetPoolMemberListParams{
180+
Pool: oxide.NameOrId(pool.Id),
181+
},
182+
)
180183
if err != nil {
181184
resp.Diagnostics.AddError(
182185
"Unable to read subnet pool members:",

internal/provider/resource_ip_pool.go

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -163,13 +163,13 @@ func (r *ipPoolResource) Create(
163163
ctx, cancel := context.WithTimeout(ctx, createTimeout)
164164
defer cancel()
165165

166-
params := oxide.IpPoolCreateParams{
166+
params := oxide.SystemIpPoolCreateParams{
167167
Body: &oxide.IpPoolCreate{
168168
Description: plan.Description.ValueString(),
169169
Name: oxide.Name(plan.Name.ValueString()),
170170
},
171171
}
172-
ipPool, err := r.client.IpPoolCreate(ctx, params)
172+
ipPool, err := r.client.SystemIpPoolCreate(ctx, params)
173173
if err != nil {
174174
resp.Diagnostics.AddError(
175175
"Error creating IP Pool",
@@ -222,7 +222,7 @@ func (r *ipPoolResource) Read(
222222
ctx, cancel := context.WithTimeout(ctx, readTimeout)
223223
defer cancel()
224224

225-
ipPool, err := r.client.IpPoolView(ctx, oxide.IpPoolViewParams{
225+
ipPool, err := r.client.SystemIpPoolView(ctx, oxide.SystemIpPoolViewParams{
226226
Pool: oxide.NameOrId(state.ID.ValueString()),
227227
})
228228
if err != nil {
@@ -245,11 +245,11 @@ func (r *ipPoolResource) Read(
245245
state.TimeModified = types.StringValue(ipPool.TimeCreated.String())
246246

247247
// Append information about IP Pool ranges
248-
listParams := oxide.IpPoolRangeListParams{
248+
listParams := oxide.SystemIpPoolRangeListParams{
249249
Pool: oxide.NameOrId(ipPool.Id),
250250
Limit: oxide.NewPointer(1000000000),
251251
}
252-
ipPoolRanges, err := r.client.IpPoolRangeList(ctx, listParams)
252+
ipPoolRanges, err := r.client.SystemIpPoolRangeList(ctx, listParams)
253253
if err != nil {
254254
resp.Diagnostics.AddError(
255255
"Unable to read IP Pool ranges:",
@@ -347,15 +347,15 @@ func (r *ipPoolResource) Update(
347347
return
348348
}
349349

350-
params := oxide.IpPoolUpdateParams{
350+
params := oxide.SystemIpPoolUpdateParams{
351351
Pool: oxide.NameOrId(state.ID.ValueString()),
352352
Body: &oxide.IpPoolUpdate{
353353
Description: plan.Description.ValueString(),
354354
Name: oxide.Name(plan.Name.ValueString()),
355355
},
356356
}
357357

358-
ipPool, err := r.client.IpPoolUpdate(ctx, params)
358+
ipPool, err := r.client.SystemIpPoolUpdate(ctx, params)
359359
if err != nil {
360360
resp.Diagnostics.AddError(
361361
"Error updating IP Pool",
@@ -405,9 +405,9 @@ func (r *ipPoolResource) Delete(
405405
defer cancel()
406406

407407
// Remove all IP pool ranges first
408-
ranges, err := r.client.IpPoolRangeList(
408+
ranges, err := r.client.SystemIpPoolRangeList(
409409
ctx,
410-
oxide.IpPoolRangeListParams{
410+
oxide.SystemIpPoolRangeListParams{
411411
Pool: oxide.NameOrId(state.ID.ValueString()),
412412
Limit: oxide.NewPointer(1000000000),
413413
},
@@ -429,11 +429,11 @@ func (r *ipPoolResource) Delete(
429429

430430
for _, item := range ranges.Items {
431431
// item.Range is now a struct with a Value field containing the variant
432-
params := oxide.IpPoolRangeRemoveParams{
432+
params := oxide.SystemIpPoolRangeRemoveParams{
433433
Pool: oxide.NameOrId(state.ID.ValueString()),
434434
Body: &item.Range,
435435
}
436-
if err := r.client.IpPoolRangeRemove(ctx, params); err != nil {
436+
if err := r.client.SystemIpPoolRangeRemove(ctx, params); err != nil {
437437
if !is404(err) {
438438
resp.Diagnostics.AddError(
439439
"Error deleting IP Pool range:",
@@ -449,9 +449,9 @@ func (r *ipPoolResource) Delete(
449449
), map[string]any{"success": true})
450450
}
451451

452-
if err := r.client.IpPoolDelete(
452+
if err := r.client.SystemIpPoolDelete(
453453
ctx,
454-
oxide.IpPoolDeleteParams{
454+
oxide.SystemIpPoolDeleteParams{
455455
Pool: oxide.NameOrId(state.ID.ValueString()),
456456
}); err != nil {
457457
if !is404(err) {
@@ -490,12 +490,12 @@ func addRanges(
490490
return diags
491491
}
492492

493-
params := oxide.IpPoolRangeAddParams{
493+
params := oxide.SystemIpPoolRangeAddParams{
494494
Pool: oxide.NameOrId(poolID),
495495
Body: &body,
496496
}
497497

498-
ipR, err := client.IpPoolRangeAdd(ctx, params)
498+
ipR, err := client.SystemIpPoolRangeAdd(ctx, params)
499499
if err != nil {
500500
diags.AddError(
501501
"Error creating range within IP Pool",
@@ -539,12 +539,12 @@ func removeRanges(
539539
return diags
540540
}
541541

542-
params := oxide.IpPoolRangeRemoveParams{
542+
params := oxide.SystemIpPoolRangeRemoveParams{
543543
Pool: oxide.NameOrId(poolID),
544544
Body: &body,
545545
}
546546

547-
err = client.IpPoolRangeRemove(ctx, params)
547+
err = client.SystemIpPoolRangeRemove(ctx, params)
548548
if err != nil {
549549
diags.AddError(
550550
"Error removing range within IP Pool",

internal/provider/resource_ip_pool_silo_link.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -144,14 +144,14 @@ func (r *ipPoolSiloLinkResource) Create(
144144
ctx, cancel := context.WithTimeout(ctx, createTimeout)
145145
defer cancel()
146146

147-
params := oxide.IpPoolSiloLinkParams{
147+
params := oxide.SystemIpPoolSiloLinkParams{
148148
Pool: oxide.NameOrId(plan.IPPoolID.ValueString()),
149149
Body: &oxide.IpPoolLinkSilo{
150150
IsDefault: plan.IsDefault.ValueBoolPointer(),
151151
Silo: oxide.NameOrId(plan.SiloID.ValueString()),
152152
},
153153
}
154-
link, err := r.client.IpPoolSiloLink(ctx, params)
154+
link, err := r.client.SystemIpPoolSiloLink(ctx, params)
155155
if err != nil {
156156
resp.Diagnostics.AddError(
157157
"Error creating IP pool silo link",
@@ -197,13 +197,13 @@ func (r *ipPoolSiloLinkResource) Read(
197197
ctx, cancel := context.WithTimeout(ctx, readTimeout)
198198
defer cancel()
199199

200-
params := oxide.IpPoolSiloListParams{
200+
params := oxide.SystemIpPoolSiloListParams{
201201
Pool: oxide.NameOrId(state.IPPoolID.ValueString()),
202202
Limit: oxide.NewPointer(1000000000),
203203
SortBy: oxide.IdSortModeIdAscending,
204204
}
205205

206-
links, err := r.client.IpPoolSiloList(ctx, params)
206+
links, err := r.client.SystemIpPoolSiloList(ctx, params)
207207
if err != nil {
208208
if is404(err) {
209209
// Remove resource from state during a refresh
@@ -277,14 +277,14 @@ func (r *ipPoolSiloLinkResource) Update(
277277
ctx, cancel := context.WithTimeout(ctx, updateTimeout)
278278
defer cancel()
279279

280-
params := oxide.IpPoolSiloUpdateParams{
280+
params := oxide.SystemIpPoolSiloUpdateParams{
281281
Pool: oxide.NameOrId(state.IPPoolID.ValueString()),
282282
Silo: oxide.NameOrId(state.SiloID.ValueString()),
283283
Body: &oxide.IpPoolSiloUpdate{
284284
IsDefault: plan.IsDefault.ValueBoolPointer(),
285285
},
286286
}
287-
link, err := r.client.IpPoolSiloUpdate(ctx, params)
287+
link, err := r.client.SystemIpPoolSiloUpdate(ctx, params)
288288
if err != nil {
289289
resp.Diagnostics.AddError(
290290
"Error updating link",
@@ -330,11 +330,11 @@ func (r *ipPoolSiloLinkResource) Delete(
330330
ctx, cancel := context.WithTimeout(ctx, deleteTimeout)
331331
defer cancel()
332332

333-
params := oxide.IpPoolSiloUnlinkParams{
333+
params := oxide.SystemIpPoolSiloUnlinkParams{
334334
Pool: oxide.NameOrId(state.IPPoolID.ValueString()),
335335
Silo: oxide.NameOrId(state.SiloID.ValueString()),
336336
}
337-
if err := r.client.IpPoolSiloUnlink(ctx, params); err != nil {
337+
if err := r.client.SystemIpPoolSiloUnlink(ctx, params); err != nil {
338338
if !is404(err) {
339339
resp.Diagnostics.AddError(
340340
"Error deleting link:",

internal/provider/resource_ip_pool_silo_link_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,13 +194,13 @@ func testAccIPPoolSiloLinkDestroy(s *terraform.State) error {
194194

195195
ipPoolID := rs.Primary.Attributes["ip_pool_id"]
196196
siloID := rs.Primary.Attributes["silo_id"]
197-
params := oxide.IpPoolSiloListParams{
197+
params := oxide.SystemIpPoolSiloListParams{
198198
Pool: oxide.NameOrId(oxide.NameOrId(ipPoolID)),
199199
Limit: oxide.NewPointer(1000000000),
200200
SortBy: oxide.IdSortModeIdAscending,
201201
}
202202

203-
links, err := client.IpPoolSiloList(ctx, params)
203+
links, err := client.SystemIpPoolSiloList(ctx, params)
204204
if err != nil && is404(err) {
205205
continue
206206
}

internal/provider/resource_ip_pool_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -187,17 +187,17 @@ func testAccIPPoolDestroy(s *terraform.State) error {
187187

188188
ctx := context.Background()
189189

190-
res, err := client.IpPoolView(
190+
res, err := client.SystemIpPoolView(
191191
ctx,
192-
oxide.IpPoolViewParams{Pool: "terraform-acc-myippool"},
192+
oxide.SystemIpPoolViewParams{Pool: "terraform-acc-myippool"},
193193
)
194194
if err == nil || !is404(err) {
195195
return fmt.Errorf("ip_pool (%v) still exists", &res.Name)
196196
}
197197

198-
res2, err := client.IpPoolView(
198+
res2, err := client.SystemIpPoolView(
199199
ctx,
200-
oxide.IpPoolViewParams{Pool: "terraform-acc-myippool2"},
200+
oxide.SystemIpPoolViewParams{Pool: "terraform-acc-myippool2"},
201201
)
202202
if err != nil && is404(err) {
203203
continue

internal/provider/resource_subnet_pool.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -152,14 +152,14 @@ func (r *subnetPoolResource) Create(
152152
ctx, cancel := context.WithTimeout(ctx, createTimeout)
153153
defer cancel()
154154

155-
params := oxide.SubnetPoolCreateParams{
155+
params := oxide.SystemSubnetPoolCreateParams{
156156
Body: &oxide.SubnetPoolCreate{
157157
Description: plan.Description.ValueString(),
158158
Name: oxide.Name(plan.Name.ValueString()),
159159
IpVersion: oxide.IpVersion(plan.IpVersion.ValueString()),
160160
},
161161
}
162-
pool, err := r.client.SubnetPoolCreate(ctx, params)
162+
pool, err := r.client.SystemSubnetPoolCreate(ctx, params)
163163
if err != nil {
164164
resp.Diagnostics.AddError(
165165
"Error creating subnet pool",
@@ -207,7 +207,7 @@ func (r *subnetPoolResource) Read(
207207
ctx, cancel := context.WithTimeout(ctx, readTimeout)
208208
defer cancel()
209209

210-
pool, err := r.client.SubnetPoolView(ctx, oxide.SubnetPoolViewParams{
210+
pool, err := r.client.SystemSubnetPoolView(ctx, oxide.SystemSubnetPoolViewParams{
211211
Pool: oxide.NameOrId(state.ID.ValueString()),
212212
})
213213
if err != nil {
@@ -272,15 +272,15 @@ func (r *subnetPoolResource) Update(
272272
ctx, cancel := context.WithTimeout(ctx, updateTimeout)
273273
defer cancel()
274274

275-
params := oxide.SubnetPoolUpdateParams{
275+
params := oxide.SystemSubnetPoolUpdateParams{
276276
Pool: oxide.NameOrId(state.ID.ValueString()),
277277
Body: &oxide.SubnetPoolUpdate{
278278
Description: plan.Description.ValueString(),
279279
Name: oxide.Name(plan.Name.ValueString()),
280280
},
281281
}
282282

283-
pool, err := r.client.SubnetPoolUpdate(ctx, params)
283+
pool, err := r.client.SystemSubnetPoolUpdate(ctx, params)
284284
if err != nil {
285285
resp.Diagnostics.AddError(
286286
"Error updating subnet pool",
@@ -328,9 +328,9 @@ func (r *subnetPoolResource) Delete(
328328
ctx, cancel := context.WithTimeout(ctx, deleteTimeout)
329329
defer cancel()
330330

331-
if err := r.client.SubnetPoolDelete(
331+
if err := r.client.SystemSubnetPoolDelete(
332332
ctx,
333-
oxide.SubnetPoolDeleteParams{
333+
oxide.SystemSubnetPoolDeleteParams{
334334
Pool: oxide.NameOrId(state.ID.ValueString()),
335335
}); err != nil {
336336
if !is404(err) {

internal/provider/resource_subnet_pool_member.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -197,12 +197,12 @@ func (r *subnetPoolMemberResource) Create(
197197
body.MaxPrefixLength = &maxPrefixLen
198198
}
199199

200-
params := oxide.SubnetPoolMemberAddParams{
200+
params := oxide.SystemSubnetPoolMemberAddParams{
201201
Pool: oxide.NameOrId(plan.SubnetPoolID.ValueString()),
202202
Body: body,
203203
}
204204

205-
member, err := r.client.SubnetPoolMemberAdd(ctx, params)
205+
member, err := r.client.SystemSubnetPoolMemberAdd(ctx, params)
206206
if err != nil {
207207
resp.Diagnostics.AddError(
208208
"Error creating subnet pool member",
@@ -253,9 +253,9 @@ func (r *subnetPoolMemberResource) Read(
253253

254254
// The API doesn't have a direct "view" endpoint for a single member by ID.
255255
// We need to list all members and find the one matching our ID.
256-
members, err := r.client.SubnetPoolMemberListAllPages(
256+
members, err := r.client.SystemSubnetPoolMemberListAllPages(
257257
ctx,
258-
oxide.SubnetPoolMemberListParams{
258+
oxide.SystemSubnetPoolMemberListParams{
259259
Pool: oxide.NameOrId(state.SubnetPoolID.ValueString()),
260260
},
261261
)
@@ -352,14 +352,14 @@ func (r *subnetPoolMemberResource) Delete(
352352
return
353353
}
354354

355-
params := oxide.SubnetPoolMemberRemoveParams{
355+
params := oxide.SystemSubnetPoolMemberRemoveParams{
356356
Pool: oxide.NameOrId(state.SubnetPoolID.ValueString()),
357357
Body: &oxide.SubnetPoolMemberRemove{
358358
Subnet: subnet,
359359
},
360360
}
361361

362-
if err := r.client.SubnetPoolMemberRemove(ctx, params); err != nil {
362+
if err := r.client.SystemSubnetPoolMemberRemove(ctx, params); err != nil {
363363
// The API returns 400 with "does not exist" if the member is already gone,
364364
// rather than 404. Handle both cases for idempotent deletes.
365365
//

0 commit comments

Comments
 (0)