Skip to content

Commit fe63923

Browse files
authored
feat(instance): Add examples in all instances commands (#667)
1 parent 652154d commit fe63923

File tree

2 files changed

+82
-0
lines changed

2 files changed

+82
-0
lines changed

internal/namespaces/instance/v1/custom_security_group.go

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,12 @@ func securityGroupClearCommand() *core.Command {
243243
Resource: "security-group",
244244
Verb: "clear",
245245
ArgsType: reflect.TypeOf(instanceResetSecurityGroupArgs{}),
246+
Examples: []*core.Example{
247+
{
248+
Short: "Remove all rules of the given security group",
249+
Request: `{"security_group_id": "11111111-1111-1111-1111-111111111111"}`,
250+
},
251+
},
246252
Run: func(ctx context.Context, argsI interface{}) (i interface{}, e error) {
247253
args := argsI.(*instanceResetSecurityGroupArgs)
248254

@@ -324,6 +330,32 @@ func securityGroupUpdateCommand() *core.Command {
324330
Name: "organization-default",
325331
},
326332
},
333+
Examples: []*core.Example{
334+
{
335+
Short: "Set the default outbound policy as drop",
336+
Request: `{"security_group_id": "11111111-1111-1111-1111-111111111111", "outbound_default_policy": "drop"}`,
337+
},
338+
{
339+
Short: "Set the given security group as the default for the organization",
340+
Request: `{"security_group_id": "11111111-1111-1111-1111-111111111111", "organization_default": true}`,
341+
},
342+
{
343+
Short: "Change the name of the given security group",
344+
Request: `{"security_group_id": "11111111-1111-1111-1111-111111111111", "name": "foobar"}`,
345+
},
346+
{
347+
Short: "Change the description of the given security group",
348+
Request: `{"security_group_id": "11111111-1111-1111-1111-111111111111", "description": "foobar"}`,
349+
},
350+
{
351+
Short: "Enable stateful security group",
352+
Request: `{"security_group_id": "11111111-1111-1111-1111-111111111111", "stateful": true}`,
353+
},
354+
{
355+
Short: "Set the default inbound policy as drop",
356+
Request: `{"security_group_id": "11111111-1111-1111-1111-111111111111", "inbound_default_policy": "drop"}`,
357+
},
358+
},
327359
Run: func(ctx context.Context, argsI interface{}) (i interface{}, e error) {
328360
req := argsI.(*instance.UpdateSecurityGroupRequest)
329361

internal/namespaces/instance/v1/custom_server.go

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,16 @@ func serverStartCommand() *core.Command {
299299
Run: getRunServerAction(instance.ServerActionPoweron),
300300
WaitFunc: waitForServerFunc(),
301301
ArgSpecs: serverActionArgSpecs,
302+
Examples: []*core.Example{
303+
{
304+
Short: "Start a server in the default zone with a given id",
305+
Request: `{"server_id": "11111111-1111-1111-1111-111111111111"}`,
306+
},
307+
{
308+
Short: "Start a server in fr-par-1 zone with a given id",
309+
Request: `{"zone":"fr-par-1", "server_id": "11111111-1111-1111-1111-111111111111"}`,
310+
},
311+
},
302312
}
303313
}
304314

@@ -312,6 +322,16 @@ func serverStopCommand() *core.Command {
312322
Run: getRunServerAction(instance.ServerActionPoweroff),
313323
WaitFunc: waitForServerFunc(),
314324
ArgSpecs: serverActionArgSpecs,
325+
Examples: []*core.Example{
326+
{
327+
Short: "Stop a server in the default zone with a given id",
328+
Request: `{"server_id": "11111111-1111-1111-1111-111111111111"}`,
329+
},
330+
{
331+
Short: "Stop a server in fr-par-1 zone with a given id",
332+
Request: `{"zone":"fr-par-1", "server_id": "11111111-1111-1111-1111-111111111111"}`,
333+
},
334+
},
315335
}
316336
}
317337

@@ -325,6 +345,16 @@ func serverStandbyCommand() *core.Command {
325345
Run: getRunServerAction(instance.ServerActionStopInPlace),
326346
WaitFunc: waitForServerFunc(),
327347
ArgSpecs: serverActionArgSpecs,
348+
Examples: []*core.Example{
349+
{
350+
Short: "Put in standby a server in the default zone with a given id",
351+
Request: `{"server_id": "11111111-1111-1111-1111-111111111111"}`,
352+
},
353+
{
354+
Short: "Put in standby a server in fr-par-1 zone with a given id",
355+
Request: `{"zone":"fr-par-1", "server_id": "11111111-1111-1111-1111-111111111111"}`,
356+
},
357+
},
328358
}
329359
}
330360

@@ -338,6 +368,16 @@ func serverRebootCommand() *core.Command {
338368
Run: getRunServerAction(instance.ServerActionReboot),
339369
WaitFunc: waitForServerFunc(),
340370
ArgSpecs: serverActionArgSpecs,
371+
Examples: []*core.Example{
372+
{
373+
Short: "Reboot a server in the default zone with a given id",
374+
Request: `{"server_id": "11111111-1111-1111-1111-111111111111"}`,
375+
},
376+
{
377+
Short: "Reboot a server in fr-par-1 zone with a given id",
378+
Request: `{"zone":"fr-par-1", "server_id": "11111111-1111-1111-1111-111111111111"}`,
379+
},
380+
},
341381
}
342382
}
343383

@@ -402,6 +442,16 @@ func serverDeleteCommand() *core.Command {
402442
Short: "Force shutdown of the instance server before deleting it",
403443
},
404444
},
445+
Examples: []*core.Example{
446+
{
447+
Short: "Delete a server in the default zone with a given id",
448+
Request: `{"server_id": "11111111-1111-1111-1111-111111111111"}`,
449+
},
450+
{
451+
Short: "Delete a server in fr-par-1 zone with a given id",
452+
Request: `{"zone":"fr-par-1", "server_id": "11111111-1111-1111-1111-111111111111"}`,
453+
},
454+
},
405455
SeeAlsos: []*core.SeeAlso{
406456
{
407457
Command: "scw instance server stop",

0 commit comments

Comments
 (0)