@@ -3,6 +3,7 @@ package rdb
33import (
44 "context"
55 "reflect"
6+ "strings"
67 "time"
78
89 "github.com/scaleway/scaleway-cli/internal/core"
@@ -76,6 +77,60 @@ func backupScheduleMarshalerFunc(i interface{}, opt *human.MarshalOpt) (string,
7677 return str , nil
7778}
7879
80+ func instanceCloneBuilder (c * core.Command ) * core.Command {
81+ c .WaitFunc = func (ctx context.Context , argsI , respI interface {}) (interface {}, error ) {
82+ api := rdb .NewAPI (core .ExtractClient (ctx ))
83+ return api .WaitForInstance (& rdb.WaitForInstanceRequest {
84+ InstanceID : respI .(* rdb.Instance ).ID ,
85+ Region : respI .(* rdb.Instance ).Region ,
86+ Timeout : scw .TimeDurationPtr (instanceActionTimeout ),
87+ RetryInterval : core .DefaultRetryInterval ,
88+ })
89+ }
90+
91+ return c
92+ }
93+
94+ func instanceCreateBuilder (c * core.Command ) * core.Command {
95+ c .ArgSpecs .GetByName ("node-type" ).Default = core .DefaultValueSetter ("DB-DEV-S" )
96+ c .ArgSpecs .GetByName ("node-type" ).EnumValues = nodeTypes
97+
98+ c .WaitFunc = func (ctx context.Context , argsI , respI interface {}) (interface {}, error ) {
99+ api := rdb .NewAPI (core .ExtractClient (ctx ))
100+ return api .WaitForInstance (& rdb.WaitForInstanceRequest {
101+ InstanceID : respI .(* rdb.Instance ).ID ,
102+ Region : respI .(* rdb.Instance ).Region ,
103+ Timeout : scw .TimeDurationPtr (instanceActionTimeout ),
104+ RetryInterval : core .DefaultRetryInterval ,
105+ })
106+ }
107+
108+ // Waiting for API to accept uppercase node-type
109+ c .Interceptor = func (ctx context.Context , argsI interface {}, runner core.CommandRunner ) (interface {}, error ) {
110+ args := argsI .(* rdb.CreateInstanceRequest )
111+ args .NodeType = strings .ToLower (args .NodeType )
112+ return runner (ctx , args )
113+ }
114+
115+ return c
116+ }
117+
118+ func instanceUpgradeBuilder (c * core.Command ) * core.Command {
119+ c .ArgSpecs .GetByName ("node-type" ).EnumValues = nodeTypes
120+
121+ c .WaitFunc = func (ctx context.Context , argsI , respI interface {}) (interface {}, error ) {
122+ api := rdb .NewAPI (core .ExtractClient (ctx ))
123+ return api .WaitForInstance (& rdb.WaitForInstanceRequest {
124+ InstanceID : respI .(* rdb.Instance ).ID ,
125+ Region : respI .(* rdb.Instance ).Region ,
126+ Timeout : scw .TimeDurationPtr (instanceActionTimeout ),
127+ RetryInterval : core .DefaultRetryInterval ,
128+ })
129+ }
130+
131+ return c
132+ }
133+
79134func instanceWaitCommand () * core.Command {
80135 return & core.Command {
81136 Short : `Wait for an instance to reach a stable state` ,
0 commit comments