Skip to content

Commit 176e682

Browse files
committed
feat: update generated APIs
1 parent dbbe692 commit 176e682

File tree

3 files changed

+215
-0
lines changed

3 files changed

+215
-0
lines changed

api/lb/v1/lb_sdk.go

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,18 @@ import (
1515
"time"
1616

1717
"github.com/scaleway/scaleway-sdk-go/errors"
18+
"github.com/scaleway/scaleway-sdk-go/internal/async"
1819
"github.com/scaleway/scaleway-sdk-go/marshaler"
1920
"github.com/scaleway/scaleway-sdk-go/namegenerator"
2021
"github.com/scaleway/scaleway-sdk-go/parameter"
2122
"github.com/scaleway/scaleway-sdk-go/scw"
2223
)
2324

25+
const (
26+
defaultLBRetryInterval = 15 * time.Second
27+
defaultLBTimeout = 5 * time.Minute
28+
)
29+
2430
// always import dependencies
2531
var (
2632
_ fmt.Stringer
@@ -4741,6 +4747,57 @@ func (s *ZonedAPI) GetLB(req *ZonedAPIGetLBRequest, opts ...scw.RequestOption) (
47414747
return &resp, nil
47424748
}
47434749

4750+
// WaitForLBRequest is used by WaitForLB method.
4751+
type WaitForLBRequest struct {
4752+
ZonedAPIGetLBRequest
4753+
Timeout *time.Duration
4754+
RetryInterval *time.Duration
4755+
}
4756+
4757+
// WaitForLB waits for the LB to reach a terminal state.
4758+
func (s *ZonedAPI) WaitForLB(req *WaitForLBRequest, opts ...scw.RequestOption) (*LB, error) {
4759+
timeout := defaultLBTimeout
4760+
if req.Timeout != nil {
4761+
timeout = *req.Timeout
4762+
}
4763+
4764+
retryInterval := defaultLBRetryInterval
4765+
if req.RetryInterval != nil {
4766+
retryInterval = *req.RetryInterval
4767+
}
4768+
transientStatuses := map[LBStatus]struct{}{
4769+
LBStatusPending: {},
4770+
LBStatusMigrating: {},
4771+
LBStatusToCreate: {},
4772+
LBStatusCreating: {},
4773+
LBStatusToDelete: {},
4774+
LBStatusDeleting: {},
4775+
}
4776+
4777+
res, err := async.WaitSync(&async.WaitSyncConfig{
4778+
Get: func() (interface{}, bool, error) {
4779+
res, err := s.GetLB(&ZonedAPIGetLBRequest{
4780+
Zone: req.Zone,
4781+
LBID: req.LBID,
4782+
}, opts...)
4783+
if err != nil {
4784+
return nil, false, err
4785+
}
4786+
4787+
_, isTransient := transientStatuses[res.Status]
4788+
4789+
return res, !isTransient, nil
4790+
},
4791+
IntervalStrategy: async.LinearIntervalStrategy(retryInterval),
4792+
Timeout: timeout,
4793+
})
4794+
if err != nil {
4795+
return nil, errors.Wrap(err, "waiting for LB failed")
4796+
}
4797+
4798+
return res.(*LB), nil
4799+
}
4800+
47444801
// UpdateLB: Update the parameters of an existing Load Balancer, specified by its Load Balancer ID. Note that the request type is PUT and not PATCH. You must set all parameters.
47454802
func (s *ZonedAPI) UpdateLB(req *ZonedAPIUpdateLBRequest, opts ...scw.RequestOption) (*LB, error) {
47464803
var err error
@@ -6101,6 +6158,52 @@ func (s *ZonedAPI) GetCertificate(req *ZonedAPIGetCertificateRequest, opts ...sc
61016158
return &resp, nil
61026159
}
61036160

6161+
// WaitForCertificateRequest is used by WaitForCertificate method.
6162+
type WaitForCertificateRequest struct {
6163+
ZonedAPIGetCertificateRequest
6164+
Timeout *time.Duration
6165+
RetryInterval *time.Duration
6166+
}
6167+
6168+
// WaitForCertificate waits for the Certificate to reach a terminal state.
6169+
func (s *ZonedAPI) WaitForCertificate(req *WaitForCertificateRequest, opts ...scw.RequestOption) (*Certificate, error) {
6170+
timeout := defaultLBTimeout
6171+
if req.Timeout != nil {
6172+
timeout = *req.Timeout
6173+
}
6174+
6175+
retryInterval := defaultLBRetryInterval
6176+
if req.RetryInterval != nil {
6177+
retryInterval = *req.RetryInterval
6178+
}
6179+
transientStatuses := map[CertificateStatus]struct{}{
6180+
CertificateStatusPending: {},
6181+
}
6182+
6183+
res, err := async.WaitSync(&async.WaitSyncConfig{
6184+
Get: func() (interface{}, bool, error) {
6185+
res, err := s.GetCertificate(&ZonedAPIGetCertificateRequest{
6186+
Zone: req.Zone,
6187+
CertificateID: req.CertificateID,
6188+
}, opts...)
6189+
if err != nil {
6190+
return nil, false, err
6191+
}
6192+
6193+
_, isTransient := transientStatuses[res.Status]
6194+
6195+
return res, !isTransient, nil
6196+
},
6197+
IntervalStrategy: async.LinearIntervalStrategy(retryInterval),
6198+
Timeout: timeout,
6199+
})
6200+
if err != nil {
6201+
return nil, errors.Wrap(err, "waiting for Certificate failed")
6202+
}
6203+
6204+
return res.(*Certificate), nil
6205+
}
6206+
61046207
// UpdateCertificate: Update the name of a particular SSL/TLS certificate, specified by its certificate ID.
61056208
func (s *ZonedAPI) UpdateCertificate(req *ZonedAPIUpdateCertificateRequest, opts ...scw.RequestOption) (*Certificate, error) {
61066209
var err error

api/mongodb/v1/mongodb_sdk.go

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,18 @@ import (
1515
"time"
1616

1717
"github.com/scaleway/scaleway-sdk-go/errors"
18+
"github.com/scaleway/scaleway-sdk-go/internal/async"
1819
"github.com/scaleway/scaleway-sdk-go/marshaler"
1920
"github.com/scaleway/scaleway-sdk-go/namegenerator"
2021
"github.com/scaleway/scaleway-sdk-go/parameter"
2122
"github.com/scaleway/scaleway-sdk-go/scw"
2223
)
2324

25+
const (
26+
defaultMongodbRetryInterval = 15 * time.Second
27+
defaultMongodbTimeout = 15 * time.Minute
28+
)
29+
2430
// always import dependencies
2531
var (
2632
_ fmt.Stringer
@@ -1364,6 +1370,56 @@ func (s *API) GetInstance(req *GetInstanceRequest, opts ...scw.RequestOption) (*
13641370
return &resp, nil
13651371
}
13661372

1373+
// WaitForInstanceRequest is used by WaitForInstance method.
1374+
type WaitForInstanceRequest struct {
1375+
GetInstanceRequest
1376+
Timeout *time.Duration
1377+
RetryInterval *time.Duration
1378+
}
1379+
1380+
// WaitForInstance waits for the Instance to reach a terminal state.
1381+
func (s *API) WaitForInstance(req *WaitForInstanceRequest, opts ...scw.RequestOption) (*Instance, error) {
1382+
timeout := defaultMongodbTimeout
1383+
if req.Timeout != nil {
1384+
timeout = *req.Timeout
1385+
}
1386+
1387+
retryInterval := defaultMongodbRetryInterval
1388+
if req.RetryInterval != nil {
1389+
retryInterval = *req.RetryInterval
1390+
}
1391+
transientStatuses := map[InstanceStatus]struct{}{
1392+
InstanceStatusProvisioning: {},
1393+
InstanceStatusConfiguring: {},
1394+
InstanceStatusDeleting: {},
1395+
InstanceStatusInitializing: {},
1396+
InstanceStatusSnapshotting: {},
1397+
}
1398+
1399+
res, err := async.WaitSync(&async.WaitSyncConfig{
1400+
Get: func() (interface{}, bool, error) {
1401+
res, err := s.GetInstance(&GetInstanceRequest{
1402+
Region: req.Region,
1403+
InstanceID: req.InstanceID,
1404+
}, opts...)
1405+
if err != nil {
1406+
return nil, false, err
1407+
}
1408+
1409+
_, isTransient := transientStatuses[res.Status]
1410+
1411+
return res, !isTransient, nil
1412+
},
1413+
IntervalStrategy: async.LinearIntervalStrategy(retryInterval),
1414+
Timeout: timeout,
1415+
})
1416+
if err != nil {
1417+
return nil, errors.Wrap(err, "waiting for Instance failed")
1418+
}
1419+
1420+
return res.(*Instance), nil
1421+
}
1422+
13671423
// CreateInstance: Create a new MongoDB® Database Instance.
13681424
func (s *API) CreateInstance(req *CreateInstanceRequest, opts ...scw.RequestOption) (*Instance, error) {
13691425
var err error

api/mongodb/v1alpha1/mongodb_sdk.go

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,18 @@ import (
1515
"time"
1616

1717
"github.com/scaleway/scaleway-sdk-go/errors"
18+
"github.com/scaleway/scaleway-sdk-go/internal/async"
1819
"github.com/scaleway/scaleway-sdk-go/marshaler"
1920
"github.com/scaleway/scaleway-sdk-go/namegenerator"
2021
"github.com/scaleway/scaleway-sdk-go/parameter"
2122
"github.com/scaleway/scaleway-sdk-go/scw"
2223
)
2324

25+
const (
26+
defaultMongodbRetryInterval = 15 * time.Second
27+
defaultMongodbTimeout = 15 * time.Minute
28+
)
29+
2430
// always import dependencies
2531
var (
2632
_ fmt.Stringer
@@ -1382,6 +1388,56 @@ func (s *API) GetInstance(req *GetInstanceRequest, opts ...scw.RequestOption) (*
13821388
return &resp, nil
13831389
}
13841390

1391+
// WaitForInstanceRequest is used by WaitForInstance method.
1392+
type WaitForInstanceRequest struct {
1393+
GetInstanceRequest
1394+
Timeout *time.Duration
1395+
RetryInterval *time.Duration
1396+
}
1397+
1398+
// WaitForInstance waits for the Instance to reach a terminal state.
1399+
func (s *API) WaitForInstance(req *WaitForInstanceRequest, opts ...scw.RequestOption) (*Instance, error) {
1400+
timeout := defaultMongodbTimeout
1401+
if req.Timeout != nil {
1402+
timeout = *req.Timeout
1403+
}
1404+
1405+
retryInterval := defaultMongodbRetryInterval
1406+
if req.RetryInterval != nil {
1407+
retryInterval = *req.RetryInterval
1408+
}
1409+
transientStatuses := map[InstanceStatus]struct{}{
1410+
InstanceStatusProvisioning: {},
1411+
InstanceStatusConfiguring: {},
1412+
InstanceStatusDeleting: {},
1413+
InstanceStatusInitializing: {},
1414+
InstanceStatusSnapshotting: {},
1415+
}
1416+
1417+
res, err := async.WaitSync(&async.WaitSyncConfig{
1418+
Get: func() (interface{}, bool, error) {
1419+
res, err := s.GetInstance(&GetInstanceRequest{
1420+
Region: req.Region,
1421+
InstanceID: req.InstanceID,
1422+
}, opts...)
1423+
if err != nil {
1424+
return nil, false, err
1425+
}
1426+
1427+
_, isTransient := transientStatuses[res.Status]
1428+
1429+
return res, !isTransient, nil
1430+
},
1431+
IntervalStrategy: async.LinearIntervalStrategy(retryInterval),
1432+
Timeout: timeout,
1433+
})
1434+
if err != nil {
1435+
return nil, errors.Wrap(err, "waiting for Instance failed")
1436+
}
1437+
1438+
return res.(*Instance), nil
1439+
}
1440+
13851441
// CreateInstance: Create a new MongoDB® Database Instance.
13861442
func (s *API) CreateInstance(req *CreateInstanceRequest, opts ...scw.RequestOption) (*Instance, error) {
13871443
var err error

0 commit comments

Comments
 (0)