Skip to content

Commit daa0b33

Browse files
authored
feat(webhosting): add CreateSession in CLI (#3845)
1 parent 37b9f6c commit daa0b33

File tree

6 files changed

+75
-3
lines changed

6 files changed

+75
-3
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲
2+
🟥🟥🟥 STDERR️️ 🟥🟥🟥️
3+
Create a user session.
4+
5+
USAGE:
6+
scw webhosting hosting create-session [arg=value ...]
7+
8+
ARGS:
9+
hosting-id Hosting ID
10+
[region=fr-par] Region to target. If none is passed will use default region from the config (fr-par | nl-ams)
11+
12+
FLAGS:
13+
-h, --help help for create-session
14+
15+
GLOBAL FLAGS:
16+
-c, --config string The path to the config file
17+
-D, --debug Enable debug mode
18+
-o, --output string Output format: json or human, see 'scw help output' for more info (default "human")
19+
-p, --profile string The config profile to use

cmd/scw/testdata/test-all-usage-webhosting-hosting-usage.golden

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ USAGE:
77

88
AVAILABLE COMMANDS:
99
create Order a Web Hosting plan
10+
create-session Create a user session
1011
delete Delete a Web Hosting plan
1112
get Get a Web Hosting plan
1213
get-dns-records Get DNS records

docs/commands/webhosting.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ This API allows you to manage your Web Hosting services.
66
- ["List the control panels type: cpanel or plesk."](#"list-the-control-panels-type:-cpanel-or-plesk.")
77
- [Hosting management commands](#hosting-management-commands)
88
- [Order a Web Hosting plan](#order-a-web-hosting-plan)
9+
- [Create a user session](#create-a-user-session)
910
- [Delete a Web Hosting plan](#delete-a-web-hosting-plan)
1011
- [Get a Web Hosting plan](#get-a-web-hosting-plan)
1112
- [Get DNS records](#get-dns-records)
@@ -75,6 +76,26 @@ scw webhosting hosting create [arg=value ...]
7576

7677

7778

79+
### Create a user session
80+
81+
Create a user session.
82+
83+
**Usage:**
84+
85+
```
86+
scw webhosting hosting create-session [arg=value ...]
87+
```
88+
89+
90+
**Args:**
91+
92+
| Name | | Description |
93+
|------|---|-------------|
94+
| hosting-id | Required | Hosting ID |
95+
| region | Default: `fr-par`<br />One of: `fr-par`, `nl-ams` | Region to target. If none is passed will use default region from the config |
96+
97+
98+
7899
### Delete a Web Hosting plan
79100

80101
Delete a Web Hosting plan, specified by its `hosting_id`. Note that deletion is not immediate: it will take place at the end of the calendar month, after which time your Web Hosting plan and all its data (files and emails) will be irreversibly lost.

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ require (
2525
github.com/mattn/go-isatty v0.0.20
2626
github.com/moby/buildkit v0.13.2
2727
github.com/opencontainers/go-digest v1.0.0
28-
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.27.0.20240528190933-154da3e5b2e4
28+
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.27.0.20240529160801-7fdc9bb26e13
2929
github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966
3030
github.com/spf13/cobra v1.8.0
3131
github.com/spf13/pflag v1.0.5

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -453,8 +453,8 @@ github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUz
453453
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
454454
github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06 h1:OkMGxebDjyw0ULyrTYWeN0UNCCkmCWfjPnIA2W6oviI=
455455
github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06/go.mod h1:+ePHsJ1keEjQtpvf9HHw0f4ZeJ0TLRsxhunSI2hYJSs=
456-
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.27.0.20240528190933-154da3e5b2e4 h1:fdi2LyED6raOyNM5SsjJF1rS/ufKJ2uVXzAwpZYjVvU=
457-
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.27.0.20240528190933-154da3e5b2e4/go.mod h1:fCa7OJZ/9DRTnOKmxvT6pn+LPWUptQAmHF/SBJUGEcg=
456+
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.27.0.20240529160801-7fdc9bb26e13 h1:uCfsuaQ933EluEYVW2RE81osfcfo8Auo6lcKLxmxAh0=
457+
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.27.0.20240529160801-7fdc9bb26e13/go.mod h1:fCa7OJZ/9DRTnOKmxvT6pn+LPWUptQAmHF/SBJUGEcg=
458458
github.com/sclevine/spec v1.4.0 h1:z/Q9idDcay5m5irkZ28M7PtQM4aOISzOpj4bUPkDee8=
459459
github.com/sclevine/spec v1.4.0/go.mod h1:LvpgJaFyvQzRvc1kaDs0bulYwzC70PbiYjC4QnFHkOM=
460460
github.com/secure-systems-lab/go-securesystemslib v0.8.0 h1:mr5An6X45Kb2nddcFlbmfHkLguCE9laoZCUzEEpIZXA=

internal/namespaces/webhosting/v1alpha1/webhosting_cli.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ func GetGeneratedCommands() *core.Commands {
3232
webhostingHostingGetDNSRecords(),
3333
webhostingOfferList(),
3434
webhostingControlPanelList(),
35+
webhostingHostingCreateSession(),
3536
)
3637
}
3738
func webhostingRoot() *core.Command {
@@ -576,3 +577,33 @@ func webhostingControlPanelList() *core.Command {
576577
},
577578
}
578579
}
580+
581+
func webhostingHostingCreateSession() *core.Command {
582+
return &core.Command{
583+
Short: `Create a user session`,
584+
Long: `Create a user session.`,
585+
Namespace: "webhosting",
586+
Resource: "hosting",
587+
Verb: "create-session",
588+
// Deprecated: false,
589+
ArgsType: reflect.TypeOf(webhosting.CreateSessionRequest{}),
590+
ArgSpecs: core.ArgSpecs{
591+
{
592+
Name: "hosting-id",
593+
Short: `Hosting ID`,
594+
Required: true,
595+
Deprecated: false,
596+
Positional: false,
597+
},
598+
core.RegionArgSpec(scw.RegionFrPar, scw.RegionNlAms),
599+
},
600+
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
601+
request := args.(*webhosting.CreateSessionRequest)
602+
603+
client := core.ExtractClient(ctx)
604+
api := webhosting.NewAPI(client)
605+
return api.CreateSession(request)
606+
607+
},
608+
}
609+
}

0 commit comments

Comments
 (0)