Skip to content

Commit 44a7527

Browse files
authored
chore(baremetal): generate api v3 (#4165)
1 parent 9c59089 commit 44a7527

File tree

3 files changed

+254
-3
lines changed

3 files changed

+254
-3
lines changed

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ require (
2626
github.com/mattn/go-isatty v0.0.20
2727
github.com/moby/buildkit v0.13.2
2828
github.com/opencontainers/go-digest v1.0.0
29-
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.30.0.20241003135237-a80efc7ba222
29+
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.30.0.20241004134157-341bb81754f8
3030
github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966
3131
github.com/spf13/cobra v1.8.1
3232
github.com/spf13/pflag v1.0.5

go.sum

+2-2
Original file line numberDiff line numberDiff line change
@@ -465,8 +465,8 @@ github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUz
465465
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
466466
github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06 h1:OkMGxebDjyw0ULyrTYWeN0UNCCkmCWfjPnIA2W6oviI=
467467
github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06/go.mod h1:+ePHsJ1keEjQtpvf9HHw0f4ZeJ0TLRsxhunSI2hYJSs=
468-
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.30.0.20241003135237-a80efc7ba222 h1:lr/Ewp6Ph3cXaEAyaPJqT7ZvC/wBnm1VoRHVz1FqOkM=
469-
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.30.0.20241003135237-a80efc7ba222/go.mod h1:o/2twhmcz4HlhtuuubCuwQ/fe+zyzoJR85+02gy04yY=
468+
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.30.0.20241004134157-341bb81754f8 h1:8xCVwaQSLX+LnnpeUzJKmvLZJ75IxjNdHLVujXDw3Hc=
469+
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.30.0.20241004134157-341bb81754f8/go.mod h1:o/2twhmcz4HlhtuuubCuwQ/fe+zyzoJR85+02gy04yY=
470470
github.com/sclevine/spec v1.4.0 h1:z/Q9idDcay5m5irkZ28M7PtQM4aOISzOpj4bUPkDee8=
471471
github.com/sclevine/spec v1.4.0/go.mod h1:LvpgJaFyvQzRvc1kaDs0bulYwzC70PbiYjC4QnFHkOM=
472472
github.com/secure-systems-lab/go-securesystemslib v0.8.0 h1:mr5An6X45Kb2nddcFlbmfHkLguCE9laoZCUzEEpIZXA=
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,251 @@
1+
// This file was automatically generated. DO NOT EDIT.
2+
// If you have any remark or suggestion do not hesitate to open an issue.
3+
4+
package baremetal
5+
6+
import (
7+
"context"
8+
"reflect"
9+
10+
"github.com/scaleway/scaleway-cli/v2/core"
11+
"github.com/scaleway/scaleway-sdk-go/api/baremetal/v3"
12+
"github.com/scaleway/scaleway-sdk-go/scw"
13+
)
14+
15+
// always import dependencies
16+
var (
17+
_ = scw.RegionFrPar
18+
)
19+
20+
func GetGeneratedCommands() *core.Commands {
21+
return core.NewCommands(
22+
baremetalRoot(),
23+
baremetalPrivateNetwork(),
24+
baremetalPrivateNetworkAdd(),
25+
baremetalPrivateNetworkSet(),
26+
baremetalPrivateNetworkList(),
27+
baremetalPrivateNetworkDelete(),
28+
)
29+
}
30+
func baremetalRoot() *core.Command {
31+
return &core.Command{
32+
Short: `Elastic Metal - Private Networks API`,
33+
Long: `Elastic Metal - Private Networks API.`,
34+
Namespace: "baremetal",
35+
}
36+
}
37+
38+
func baremetalPrivateNetwork() *core.Command {
39+
return &core.Command{
40+
Short: `Private network management command`,
41+
Long: `A Private Network allows you to interconnect your resources
42+
in an isolated and private
43+
network. Network reachability is limited to the
44+
resources that are on the same Private Network. A VLAN
45+
interface is available on the server and can be freely
46+
managed (adding IP addresses, shutdown interface etc.).
47+
48+
Note that a resource can be a part of multiple Private Networks.`,
49+
Namespace: "baremetal",
50+
Resource: "private-network",
51+
}
52+
}
53+
54+
func baremetalPrivateNetworkAdd() *core.Command {
55+
return &core.Command{
56+
Short: `Add a server to a Private Network`,
57+
Long: `Add an Elastic Metal server to a Private Network.`,
58+
Namespace: "baremetal",
59+
Resource: "private-network",
60+
Verb: "add",
61+
// Deprecated: false,
62+
ArgsType: reflect.TypeOf(baremetal.PrivateNetworkAPIAddServerPrivateNetworkRequest{}),
63+
ArgSpecs: core.ArgSpecs{
64+
{
65+
Name: "server-id",
66+
Short: `UUID of the server`,
67+
Required: true,
68+
Deprecated: false,
69+
Positional: false,
70+
},
71+
{
72+
Name: "private-network-id",
73+
Short: `UUID of the Private Network`,
74+
Required: true,
75+
Deprecated: false,
76+
Positional: false,
77+
},
78+
{
79+
Name: "ipam-ip-ids.{index}",
80+
Short: `IPAM IDs of an IPs to attach to the server`,
81+
Required: false,
82+
Deprecated: false,
83+
Positional: false,
84+
},
85+
core.ZoneArgSpec(scw.ZoneFrPar1, scw.ZoneFrPar2, scw.ZoneNlAms1, scw.ZoneNlAms2, scw.ZonePlWaw2, scw.ZonePlWaw3),
86+
},
87+
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
88+
request := args.(*baremetal.PrivateNetworkAPIAddServerPrivateNetworkRequest)
89+
90+
client := core.ExtractClient(ctx)
91+
api := baremetal.NewPrivateNetworkAPI(client)
92+
return api.AddServerPrivateNetwork(request)
93+
94+
},
95+
}
96+
}
97+
98+
func baremetalPrivateNetworkSet() *core.Command {
99+
return &core.Command{
100+
Short: `Set multiple Private Networks on a server`,
101+
Long: `Configure multiple Private Networks on an Elastic Metal server.`,
102+
Namespace: "baremetal",
103+
Resource: "private-network",
104+
Verb: "set",
105+
// Deprecated: false,
106+
ArgsType: reflect.TypeOf(baremetal.PrivateNetworkAPISetServerPrivateNetworksRequest{}),
107+
ArgSpecs: core.ArgSpecs{
108+
{
109+
Name: "server-id",
110+
Short: `UUID of the server`,
111+
Required: true,
112+
Deprecated: false,
113+
Positional: false,
114+
},
115+
{
116+
Name: "per-private-network-ipam-ip-ids.{key}",
117+
Short: `Object where the keys are the UUIDs of Private Networks and the values are arrays of IPAM IDs representing the IPs to assign to this Elastic Metal server on the Private Network. If the array supplied for a Private Network is empty, the next available IP from the Private Network's CIDR block will automatically be used for attachment.`,
118+
Required: true,
119+
Deprecated: false,
120+
Positional: false,
121+
},
122+
core.ZoneArgSpec(scw.ZoneFrPar1, scw.ZoneFrPar2, scw.ZoneNlAms1, scw.ZoneNlAms2, scw.ZonePlWaw2, scw.ZonePlWaw3),
123+
},
124+
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
125+
request := args.(*baremetal.PrivateNetworkAPISetServerPrivateNetworksRequest)
126+
127+
client := core.ExtractClient(ctx)
128+
api := baremetal.NewPrivateNetworkAPI(client)
129+
return api.SetServerPrivateNetworks(request)
130+
131+
},
132+
}
133+
}
134+
135+
func baremetalPrivateNetworkList() *core.Command {
136+
return &core.Command{
137+
Short: `List the Private Networks of a server`,
138+
Long: `List the Private Networks of an Elastic Metal server.`,
139+
Namespace: "baremetal",
140+
Resource: "private-network",
141+
Verb: "list",
142+
// Deprecated: false,
143+
ArgsType: reflect.TypeOf(baremetal.PrivateNetworkAPIListServerPrivateNetworksRequest{}),
144+
ArgSpecs: core.ArgSpecs{
145+
{
146+
Name: "order-by",
147+
Short: `Sort order for the returned Private Networks`,
148+
Required: false,
149+
Deprecated: false,
150+
Positional: false,
151+
EnumValues: []string{"created_at_asc", "created_at_desc", "updated_at_asc", "updated_at_desc"},
152+
},
153+
{
154+
Name: "server-id",
155+
Short: `Filter Private Networks by server UUID`,
156+
Required: false,
157+
Deprecated: false,
158+
Positional: false,
159+
},
160+
{
161+
Name: "private-network-id",
162+
Short: `Filter Private Networks by Private Network UUID`,
163+
Required: false,
164+
Deprecated: false,
165+
Positional: false,
166+
},
167+
{
168+
Name: "project-id",
169+
Short: `Filter Private Networks by project UUID`,
170+
Required: false,
171+
Deprecated: false,
172+
Positional: false,
173+
},
174+
{
175+
Name: "ipam-ip-ids.{index}",
176+
Short: `Filter Private Networks by IPAM IP UUIDs`,
177+
Required: false,
178+
Deprecated: false,
179+
Positional: false,
180+
},
181+
{
182+
Name: "organization-id",
183+
Short: `Filter Private Networks by organization UUID`,
184+
Required: false,
185+
Deprecated: false,
186+
Positional: false,
187+
},
188+
core.ZoneArgSpec(scw.ZoneFrPar1, scw.ZoneFrPar2, scw.ZoneNlAms1, scw.ZoneNlAms2, scw.ZonePlWaw2, scw.ZonePlWaw3, scw.Zone(core.AllLocalities)),
189+
},
190+
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
191+
request := args.(*baremetal.PrivateNetworkAPIListServerPrivateNetworksRequest)
192+
193+
client := core.ExtractClient(ctx)
194+
api := baremetal.NewPrivateNetworkAPI(client)
195+
opts := []scw.RequestOption{scw.WithAllPages()}
196+
if request.Zone == scw.Zone(core.AllLocalities) {
197+
opts = append(opts, scw.WithZones(api.Zones()...))
198+
request.Zone = ""
199+
}
200+
resp, err := api.ListServerPrivateNetworks(request, opts...)
201+
if err != nil {
202+
return nil, err
203+
}
204+
return resp.ServerPrivateNetworks, nil
205+
206+
},
207+
}
208+
}
209+
210+
func baremetalPrivateNetworkDelete() *core.Command {
211+
return &core.Command{
212+
Short: `Delete a Private Network`,
213+
Long: `Delete a Private Network.`,
214+
Namespace: "baremetal",
215+
Resource: "private-network",
216+
Verb: "delete",
217+
// Deprecated: false,
218+
ArgsType: reflect.TypeOf(baremetal.PrivateNetworkAPIDeleteServerPrivateNetworkRequest{}),
219+
ArgSpecs: core.ArgSpecs{
220+
{
221+
Name: "server-id",
222+
Short: `UUID of the server`,
223+
Required: true,
224+
Deprecated: false,
225+
Positional: false,
226+
},
227+
{
228+
Name: "private-network-id",
229+
Short: `UUID of the Private Network`,
230+
Required: true,
231+
Deprecated: false,
232+
Positional: false,
233+
},
234+
core.ZoneArgSpec(scw.ZoneFrPar1, scw.ZoneFrPar2, scw.ZoneNlAms1, scw.ZoneNlAms2, scw.ZonePlWaw2, scw.ZonePlWaw3),
235+
},
236+
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
237+
request := args.(*baremetal.PrivateNetworkAPIDeleteServerPrivateNetworkRequest)
238+
239+
client := core.ExtractClient(ctx)
240+
api := baremetal.NewPrivateNetworkAPI(client)
241+
e = api.DeleteServerPrivateNetwork(request)
242+
if e != nil {
243+
return nil, e
244+
}
245+
return &core.SuccessResult{
246+
Resource: "private-network",
247+
Verb: "delete",
248+
}, nil
249+
},
250+
}
251+
}

0 commit comments

Comments
 (0)