Skip to content

Commit

Permalink
GCLOUD2-16683 Update allowed address pairs via v2 endpoint (#157)
Browse files Browse the repository at this point in the history
  • Loading branch information
lapson97 authored Nov 13, 2024
1 parent 146b165 commit 1ee7cb9
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 17 deletions.
23 changes: 19 additions & 4 deletions gcore/resource_gcore_reservedfixedip.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import (
"time"

gcorecloud "github.com/G-Core/gcorelabscloud-go"
"github.com/G-Core/gcorelabscloud-go/gcore/port/v1/ports"
ports1 "github.com/G-Core/gcorelabscloud-go/gcore/port/v1/ports"
ports2 "github.com/G-Core/gcorelabscloud-go/gcore/port/v2/ports"
"github.com/G-Core/gcorelabscloud-go/gcore/reservedfixedip/v1/reservedfixedips"
"github.com/G-Core/gcorelabscloud-go/gcore/task/v1/tasks"
"github.com/hashicorp/go-cty/cty"
Expand Down Expand Up @@ -360,13 +361,27 @@ func resourceReservedFixedIPUpdate(ctx context.Context, d *schema.ResourceData,
}
}

clientPort, err := CreateClient(provider, d, portsPoint, versionPointV1)
clientPort, err := CreateClient(provider, d, portsPoint, versionPointV2)
if err != nil {
return diag.FromErr(err)
}

opts := ports.AllowAddressPairsOpts{AllowedAddressPairs: allowedAddressPairs}
if _, err := ports.AllowAddressPairs(clientPort, id, opts).Extract(); err != nil {
opts := ports1.AllowAddressPairsOpts{AllowedAddressPairs: allowedAddressPairs}
results, err := ports2.AllowAddressPairs(clientPort, id, opts).Extract()
if err != nil {
return diag.FromErr(err)
}
taskID := results.Tasks[0]
_, err = tasks.WaitTaskAndReturnResult(
client, taskID, true, int(d.Timeout(schema.TimeoutUpdate).Seconds()), func(task tasks.TaskID) (interface{}, error) {
_, err := tasks.Get(client, string(task)).Extract()
if err != nil {
return nil, fmt.Errorf("cannot get task with ID: %s. Error: %w", task, err)
}
return nil, nil
})

if err != nil {
return diag.FromErr(err)
}
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ require (
github.com/G-Core/gcore-dns-sdk-go v0.2.9
github.com/G-Core/gcore-storage-sdk-go v0.1.34
github.com/G-Core/gcorelabscdn-go v1.0.19
github.com/G-Core/gcorelabscloud-go v0.8.8
github.com/G-Core/gcorelabscloud-go v0.8.12
github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320
github.com/hashicorp/terraform-plugin-sdk/v2 v2.27.0
github.com/mitchellh/mapstructure v1.5.0
Expand Down
14 changes: 2 additions & 12 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,8 @@ github.com/G-Core/gcorelabscdn-go v1.0.17 h1:g5i53mzPpg513qcXzxuEdL1v/rK3yiAd8LO
github.com/G-Core/gcorelabscdn-go v1.0.17/go.mod h1:iSGXaTvZBzDHQW+rKFS918BgFVpONcyLEijwh8WsXpE=
github.com/G-Core/gcorelabscdn-go v1.0.19 h1:P4qYP+cnO+0DrVftGnL1gt7En8/RYsl20zw4wud9Krs=
github.com/G-Core/gcorelabscdn-go v1.0.19/go.mod h1:iSGXaTvZBzDHQW+rKFS918BgFVpONcyLEijwh8WsXpE=
github.com/G-Core/gcorelabscloud-go v0.8.0 h1:6w+Mikiz+GbHJs1PD+tPD1gIR88Xl3UPkJuvQVuG7bs=
github.com/G-Core/gcorelabscloud-go v0.8.0/go.mod h1:13Z1USxlxPbDFuYQyWqfNexlk4kUvOYTXbnvV/Z1lZo=
github.com/G-Core/gcorelabscloud-go v0.8.4 h1:Yf0c0ZFOTxu0VjMgMVooHp2k2fYYKLLU5jqFRuEVEcg=
github.com/G-Core/gcorelabscloud-go v0.8.4/go.mod h1:13Z1USxlxPbDFuYQyWqfNexlk4kUvOYTXbnvV/Z1lZo=
github.com/G-Core/gcorelabscloud-go v0.8.5 h1:VgzEsTwPRms43E6CUIpVInU2u0x0RbaGJ8D2EYc/g/M=
github.com/G-Core/gcorelabscloud-go v0.8.5/go.mod h1:13Z1USxlxPbDFuYQyWqfNexlk4kUvOYTXbnvV/Z1lZo=
github.com/G-Core/gcorelabscloud-go v0.8.6 h1:4KAtltD/5FA+h9p0KlEnVA9G6qpbrPTvAB5Hxq30x0Q=
github.com/G-Core/gcorelabscloud-go v0.8.6/go.mod h1:13Z1USxlxPbDFuYQyWqfNexlk4kUvOYTXbnvV/Z1lZo=
github.com/G-Core/gcorelabscloud-go v0.8.7 h1:wJSrOz3bf+QrZUOUjk8I69busBVHdCT9NjfZAcf2LtA=
github.com/G-Core/gcorelabscloud-go v0.8.7/go.mod h1:13Z1USxlxPbDFuYQyWqfNexlk4kUvOYTXbnvV/Z1lZo=
github.com/G-Core/gcorelabscloud-go v0.8.8 h1:NZc11W0MYp+4rafraik9+rMavqKSSwPIn/u2ZKR3FqE=
github.com/G-Core/gcorelabscloud-go v0.8.8/go.mod h1:13Z1USxlxPbDFuYQyWqfNexlk4kUvOYTXbnvV/Z1lZo=
github.com/G-Core/gcorelabscloud-go v0.8.12 h1:qT8rrtSCXT+ol1g4zrl5JzWG+8IicHWCn7+U96tdlj4=
github.com/G-Core/gcorelabscloud-go v0.8.12/go.mod h1:13Z1USxlxPbDFuYQyWqfNexlk4kUvOYTXbnvV/Z1lZo=
github.com/Kunde21/markdownfmt/v3 v3.1.0 h1:KiZu9LKs+wFFBQKhrZJrFZwtLnCCWJahL+S+E/3VnM0=
github.com/Kunde21/markdownfmt/v3 v3.1.0/go.mod h1:tPXN1RTyOzJwhfHoon9wUr4HGYmWgVxSQN6VBJDkrVc=
github.com/Masterminds/goutils v1.1.1 h1:5nUrii3FMTL5diU80unEVvNevw1nH4+ZV4DSLVJLSYI=
Expand Down

0 comments on commit 1ee7cb9

Please sign in to comment.