Skip to content

Commit 49becd6

Browse files
feat: regenerate CLI from OpenAPI spec
1 parent dabe8a5 commit 49becd6

6 files changed

Lines changed: 303 additions & 0 deletions

File tree

client/client.gen.go

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

cmd/hosting/websites/delete.go

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
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/spf13/cobra"
12+
)
13+
14+
var DeleteCmd = &cobra.Command{
15+
Use: "delete <domain>",
16+
Short: "Delete website",
17+
Long: "Permanently deletes a website and all of its data. This action is destructive\nand cannot be undone. Always ask the user for explicit confirmation before\ncalling this endpoint.\n\nAll website files, databases and related configuration will be removed.\nThe hosting plan itself is kept, so a new website can be created on it afterwards.\n\nThe confirm field must be boolean true, otherwise the request is rejected.\n\nSupported websites: main and addon domain websites on web hosting plans, and\nWebsite Builder websites. Parked domains and subdomains cannot be deleted with\nthis endpoint. The domain must be the exact website domain, not a preview\ndomain or an alias.\n\nReturns 404 when the domain does not exist or does not belong to the\nauthenticated client.\n\nWebsite removal is processed asynchronously and can take a few minutes to\ncomplete. The response returns before the removal finishes.",
18+
Args: cobra.MatchAll(cobra.ExactArgs(1)),
19+
Run: func(cmd *cobra.Command, args []string) {
20+
payload, err := json.Marshal(deleteBody(cmd))
21+
if err != nil {
22+
log.Fatal(err)
23+
}
24+
r, err := api.Request().HostingDeleteWebsiteV1WithBodyWithResponse(context.TODO(), args[0], "application/json", bytes.NewReader(payload))
25+
if err != nil {
26+
log.Fatal(err)
27+
}
28+
29+
output.Format(cmd, r.Body, r.StatusCode())
30+
},
31+
}
32+
33+
func init() {
34+
DeleteCmd.Flags().BoolP("confirm", "", false, "Must be boolean true to confirm the permanent deletion of the website. (one of: true)")
35+
DeleteCmd.MarkFlagRequired("confirm")
36+
}
37+
38+
func deleteBody(cmd *cobra.Command) map[string]any {
39+
body := map[string]any{}
40+
confirmVal, _ := cmd.Flags().GetBool("confirm")
41+
body["confirm"] = confirmVal
42+
return body
43+
}

cmd/hosting/websites/websites.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@ var GroupCmd = &cobra.Command{
1111

1212
func init() {
1313
GroupCmd.AddCommand(CreateCmd)
14+
GroupCmd.AddCommand(DeleteCmd)
1415
GroupCmd.AddCommand(ListCmd)
1516
}

docs/hostinger_hosting_websites.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,6 @@ Websites commands
1919

2020
* [hostinger hosting](hostinger_hosting.md) - Hosting commands
2121
* [hostinger hosting websites create](hostinger_hosting_websites_create.md) - Create website
22+
* [hostinger hosting websites delete](hostinger_hosting_websites_delete.md) - Delete website
2223
* [hostinger hosting websites list](hostinger_hosting_websites_list.md) - List websites
2324

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
## hostinger hosting websites delete
2+
3+
Delete website
4+
5+
### Synopsis
6+
7+
Permanently deletes a website and all of its data. This action is destructive
8+
and cannot be undone. Always ask the user for explicit confirmation before
9+
calling this endpoint.
10+
11+
All website files, databases and related configuration will be removed.
12+
The hosting plan itself is kept, so a new website can be created on it afterwards.
13+
14+
The confirm field must be boolean true, otherwise the request is rejected.
15+
16+
Supported websites: main and addon domain websites on web hosting plans, and
17+
Website Builder websites. Parked domains and subdomains cannot be deleted with
18+
this endpoint. The domain must be the exact website domain, not a preview
19+
domain or an alias.
20+
21+
Returns 404 when the domain does not exist or does not belong to the
22+
authenticated client.
23+
24+
Website removal is processed asynchronously and can take a few minutes to
25+
complete. The response returns before the removal finishes.
26+
27+
```
28+
hostinger hosting websites delete <domain> [flags]
29+
```
30+
31+
### Options
32+
33+
```
34+
--confirm Must be boolean true to confirm the permanent deletion of the website. (one of: true)
35+
-h, --help help for delete
36+
```
37+
38+
### Options inherited from parent commands
39+
40+
```
41+
--config string Config file (default is $HOME/.hostinger.yaml)
42+
--format string Output format type (json|table|tree), default: table
43+
```
44+
45+
### SEE ALSO
46+
47+
* [hostinger hosting websites](hostinger_hosting_websites.md) - Websites commands
48+

manifest.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -699,6 +699,11 @@
699699
"method": "DELETE",
700700
"path": "/api/hosting/v1/accounts/{username}/websites/{domain}/subdomains/{subdomain}"
701701
},
702+
"hosting_deleteWebsiteV1": {
703+
"command": "hostinger hosting websites delete",
704+
"method": "DELETE",
705+
"path": "/api/hosting/v1/websites/{domain}"
706+
},
702707
"hosting_deleteWordPressInstallationV1": {
703708
"command": "hostinger wordpress installations delete",
704709
"method": "DELETE",

0 commit comments

Comments
 (0)