Skip to content

Commit 641b743

Browse files
feat: regenerate CLI from OpenAPI spec
1 parent 180f78a commit 641b743

8 files changed

Lines changed: 752 additions & 38 deletions

‎client/client.gen.go‎

Lines changed: 613 additions & 28 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎cmd/hosting/websites/list_setups.go‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313
var ListSetupsCmd = &cobra.Command{
1414
Use: "list-setups",
1515
Short: "List website setups",
16-
Long: "Returns the website setups started in the last 24 hours for the hosting accounts\naccessible to the authenticated client, newest first.\n\nMeant for polling right after creating a website: the website shows up in the\nwebsites list before its server-side setup has finished, and while the setup is\n`running` endpoints that operate on that website may respond with `404` or `409`.\nPoll this endpoint with the `domain` filter every 10 to 15 seconds and wait for\n`status: completed` before uploading files, deploying or creating databases.\n`failed` means the setup stopped before finishing or has not reported progress for\nover an hour. Setups older than 24 hours are not listed.",
16+
Long: "Returns the website setups started in the last 24 hours for the hosting accounts\naccessible to the authenticated client, newest first. Narrow the list with the\n`order_id`, `subscription_id` or `domain` filters.\n\nMeant for polling right after creating a website or starting a website setup: the\nwebsite shows up in the websites list before its server-side setup has finished, and\nwhile the setup is `running` endpoints that operate on that website may respond with\n`404` or `409`. Poll this endpoint with the `domain` filter every 10 to 15 seconds and\nwait for `status: completed` before uploading files, deploying or creating databases.\n`failed` means the setup stopped before finishing or has not reported progress for\nover an hour. Setups older than 24 hours are not listed.\n\n`type` is the website type the setup was started with (`wordpress`, `headless_wordpress`,\n`headless_ecommerce`, `headless_pocketbase`), or `null` for an empty website.",
1717
Run: func(cmd *cobra.Command, args []string) {
1818
r, err := api.Request().HostingListWebsiteSetupsV1WithResponse(context.TODO(), listSetupsParams(cmd))
1919
if err != nil {
@@ -25,11 +25,21 @@ var ListSetupsCmd = &cobra.Command{
2525
}
2626

2727
func init() {
28+
ListSetupsCmd.Flags().IntP("order-id", "", 0, "Order ID")
29+
ListSetupsCmd.Flags().StringP("subscription-id", "", "", "Filter by hosting order subscription ID")
2830
ListSetupsCmd.Flags().StringP("domain", "", "", "Filter by domain name (exact match)")
2931
}
3032

3133
func listSetupsParams(cmd *cobra.Command) *client.HostingListWebsiteSetupsV1Params {
3234
params := &client.HostingListWebsiteSetupsV1Params{}
35+
if cmd.Flags().Changed("order-id") {
36+
v, _ := cmd.Flags().GetInt("order-id")
37+
params.OrderId = &v
38+
}
39+
if cmd.Flags().Changed("subscription-id") {
40+
v, _ := cmd.Flags().GetString("subscription-id")
41+
params.SubscriptionId = &v
42+
}
3343
if cmd.Flags().Changed("domain") {
3444
v, _ := cmd.Flags().GetString("domain")
3545
params.Domain = &v
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
package websites
2+
3+
import (
4+
"bytes"
5+
"context"
6+
"encoding/json"
7+
"log"
8+
9+
"github.com/hostinger/api-cli/api"
10+
"github.com/hostinger/api-cli/output"
11+
"github.com/hostinger/api-cli/utils"
12+
"github.com/spf13/cobra"
13+
)
14+
15+
var StartSetupCmd = &cobra.Command{
16+
Use: "start-setup <order_id>",
17+
Short: "Start website setup",
18+
Long: "Starts a website setup on a Web or Cloud hosting order and returns the created setup\nright away; the website itself is provisioned asynchronously. Poll the list website\nsetups endpoint with the `domain` filter every 10 to 15 seconds and wait for\n`status: completed` before uploading files, deploying or creating databases.\n\nOmit `type` for an empty website. `type: wordpress` installs WordPress in the website\nroot with the admin user, email and password from `wordpress`, the domain as the site\ntitle, and `en_US` when `wordpress.language` is omitted. The headless types\n(`headless_wordpress`, `headless_ecommerce`, `headless_pocketbase`) create a headless\nwebsite; `headless_wordpress` additionally installs WordPress into the `cms` directory\nof the website root with generated credentials.\n\nOmit `domain` to set the website up on a generated temporary free subdomain.\n\nThe order must already have a hosting account: to create the first website on a new\nhosting plan use the create website endpoint, which takes the `datacenter_code`.\nReturns 404 when the order does not exist or is not accessible to the authenticated\nclient, and 409 with a `Retry-After` header while a setup for the same domain is still\nrunning.",
19+
Args: cobra.MatchAll(cobra.ExactArgs(1)),
20+
Run: func(cmd *cobra.Command, args []string) {
21+
utils.EnumCheck(cmd, "type", []string{"wordpress", "headless_wordpress", "headless_ecommerce", "headless_pocketbase"})
22+
payload, err := json.Marshal(startSetupBody(cmd))
23+
if err != nil {
24+
log.Fatal(err)
25+
}
26+
r, err := api.Request().HostingStartWebsiteSetupV1WithBodyWithResponse(context.TODO(), utils.StringToInt(args[0]), "application/json", bytes.NewReader(payload))
27+
if err != nil {
28+
log.Fatal(err)
29+
}
30+
31+
output.Format(cmd, r.Body, r.StatusCode())
32+
},
33+
}
34+
35+
func init() {
36+
StartSetupCmd.Flags().StringP("domain", "", "", "Customer-owned domain. Cannot start with \"www.\". Omit or `null` to set the website up on a generated temporary free subdomain.")
37+
StartSetupCmd.Flags().StringP("type", "", "", "Website type. Omit or `null` for an empty website. `wordpress` installs WordPress in the website root and requires `wordpress`. The headless types (`headless_wordpress`, `headless_ecommerce`, `headless_pocketbase`) create a headless website; `headless_wordpress` additionally installs WordPress into the `cms` directory with generated credentials. (one of: wordpress, headless_wordpress, headless_ecommerce, headless_pocketbase)")
38+
StartSetupCmd.Flags().StringP("wordpress", "", "", "WordPress install settings. Required when `type` is `wordpress`, not allowed otherwise. The site title is the domain. (JSON)")
39+
}
40+
41+
func startSetupBody(cmd *cobra.Command) map[string]any {
42+
body := map[string]any{}
43+
if cmd.Flags().Changed("domain") {
44+
v, _ := cmd.Flags().GetString("domain")
45+
body["domain"] = v
46+
}
47+
if cmd.Flags().Changed("type") {
48+
v, _ := cmd.Flags().GetString("type")
49+
body["type"] = v
50+
}
51+
if cmd.Flags().Changed("wordpress") {
52+
v, _ := cmd.Flags().GetString("wordpress")
53+
body["wordpress"] = utils.JSONValue(v, "wordpress")
54+
}
55+
return body
56+
}

‎cmd/hosting/websites/websites.go‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,5 @@ func init() {
1515
GroupCmd.AddCommand(DeployStaticSiteArchiveCmd)
1616
GroupCmd.AddCommand(ListCmd)
1717
GroupCmd.AddCommand(ListSetupsCmd)
18+
GroupCmd.AddCommand(StartSetupCmd)
1819
}

‎docs/hostinger_hosting_websites.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,5 @@ Websites commands
2323
* [hostinger hosting websites deploy-static-site-archive](hostinger_hosting_websites_deploy-static-site-archive.md) - Deploy static site archive
2424
* [hostinger hosting websites list](hostinger_hosting_websites_list.md) - List websites
2525
* [hostinger hosting websites list-setups](hostinger_hosting_websites_list-setups.md) - List website setups
26+
* [hostinger hosting websites start-setup](hostinger_hosting_websites_start-setup.md) - Start website setup
2627

‎docs/hostinger_hosting_websites_list-setups.md‎

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,31 @@ List website setups
55
### Synopsis
66

77
Returns the website setups started in the last 24 hours for the hosting accounts
8-
accessible to the authenticated client, newest first.
9-
10-
Meant for polling right after creating a website: the website shows up in the
11-
websites list before its server-side setup has finished, and while the setup is
12-
`running` endpoints that operate on that website may respond with `404` or `409`.
13-
Poll this endpoint with the `domain` filter every 10 to 15 seconds and wait for
14-
`status: completed` before uploading files, deploying or creating databases.
8+
accessible to the authenticated client, newest first. Narrow the list with the
9+
`order_id`, `subscription_id` or `domain` filters.
10+
11+
Meant for polling right after creating a website or starting a website setup: the
12+
website shows up in the websites list before its server-side setup has finished, and
13+
while the setup is `running` endpoints that operate on that website may respond with
14+
`404` or `409`. Poll this endpoint with the `domain` filter every 10 to 15 seconds and
15+
wait for `status: completed` before uploading files, deploying or creating databases.
1516
`failed` means the setup stopped before finishing or has not reported progress for
1617
over an hour. Setups older than 24 hours are not listed.
1718

19+
`type` is the website type the setup was started with (`wordpress`, `headless_wordpress`,
20+
`headless_ecommerce`, `headless_pocketbase`), or `null` for an empty website.
21+
1822
```
1923
hostinger hosting websites list-setups [flags]
2024
```
2125

2226
### Options
2327

2428
```
25-
--domain string Filter by domain name (exact match)
26-
-h, --help help for list-setups
29+
--domain string Filter by domain name (exact match)
30+
-h, --help help for list-setups
31+
--order-id int Order ID
32+
--subscription-id string Filter by hosting order subscription ID
2733
```
2834

2935
### Options inherited from parent commands
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
## hostinger hosting websites start-setup
2+
3+
Start website setup
4+
5+
### Synopsis
6+
7+
Starts a website setup on a Web or Cloud hosting order and returns the created setup
8+
right away; the website itself is provisioned asynchronously. Poll the list website
9+
setups endpoint with the `domain` filter every 10 to 15 seconds and wait for
10+
`status: completed` before uploading files, deploying or creating databases.
11+
12+
Omit `type` for an empty website. `type: wordpress` installs WordPress in the website
13+
root with the admin user, email and password from `wordpress`, the domain as the site
14+
title, and `en_US` when `wordpress.language` is omitted. The headless types
15+
(`headless_wordpress`, `headless_ecommerce`, `headless_pocketbase`) create a headless
16+
website; `headless_wordpress` additionally installs WordPress into the `cms` directory
17+
of the website root with generated credentials.
18+
19+
Omit `domain` to set the website up on a generated temporary free subdomain.
20+
21+
The order must already have a hosting account: to create the first website on a new
22+
hosting plan use the create website endpoint, which takes the `datacenter_code`.
23+
Returns 404 when the order does not exist or is not accessible to the authenticated
24+
client, and 409 with a `Retry-After` header while a setup for the same domain is still
25+
running.
26+
27+
```
28+
hostinger hosting websites start-setup <order_id> [flags]
29+
```
30+
31+
### Options
32+
33+
```
34+
--domain null Customer-owned domain. Cannot start with "www.". Omit or null to set the website up on a generated temporary free subdomain.
35+
-h, --help help for start-setup
36+
--type null Website type. Omit or null for an empty website. `wordpress` installs WordPress in the website root and requires `wordpress`. The headless types (`headless_wordpress`, `headless_ecommerce`, `headless_pocketbase`) create a headless website; `headless_wordpress` additionally installs WordPress into the `cms` directory with generated credentials. (one of: wordpress, headless_wordpress, headless_ecommerce, headless_pocketbase)
37+
--wordpress type WordPress install settings. Required when type is `wordpress`, not allowed otherwise. The site title is the domain. (JSON)
38+
```
39+
40+
### Options inherited from parent commands
41+
42+
```
43+
--config string Config file (default is $HOME/.hostinger.yaml)
44+
--format string Output format type (json|table|tree), default: table
45+
```
46+
47+
### SEE ALSO
48+
49+
* [hostinger hosting websites](hostinger_hosting_websites.md) - Websites commands
50+

‎manifest.json‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1444,6 +1444,11 @@
14441444
"method": "POST",
14451445
"path": "/api/hosting/v1/accounts/{username}/websites/{domain}/nodejs/builds"
14461446
},
1447+
"hosting_startWebsiteSetupV1": {
1448+
"command": "hostinger hosting websites start-setup",
1449+
"method": "POST",
1450+
"path": "/api/hosting/v1/orders/{order_id}/onboardings"
1451+
},
14471452
"hosting_toggleCachelessModeV1": {
14481453
"command": "hostinger hosting cache toggle-cacheless",
14491454
"method": "PATCH",

0 commit comments

Comments
 (0)