Skip to content

Commit d1bc4d9

Browse files
feat: regenerate CLI from OpenAPI spec
1 parent 8e3fc76 commit d1bc4d9

10 files changed

Lines changed: 708 additions & 8 deletions

File tree

client/client.gen.go

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

cmd/mail/mail.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package mail
2+
3+
import (
4+
"github.com/hostinger/api-cli/cmd/mail/orders"
5+
6+
"github.com/spf13/cobra"
7+
)
8+
9+
var GroupCmd = &cobra.Command{
10+
Use: "mail",
11+
Short: "Mail commands",
12+
}
13+
14+
func init() {
15+
GroupCmd.AddCommand(orders.GroupCmd)
16+
}

cmd/mail/orders/list.go

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
package orders
2+
3+
import (
4+
"context"
5+
"log"
6+
7+
"github.com/hostinger/api-cli/api"
8+
"github.com/hostinger/api-cli/client"
9+
"github.com/hostinger/api-cli/output"
10+
"github.com/hostinger/api-cli/utils"
11+
"github.com/spf13/cobra"
12+
)
13+
14+
var ListCmd = &cobra.Command{
15+
Use: "list",
16+
Short: "Get mail order list",
17+
Long: "Retrieve a paginated list of mail orders associated with your account.\n\nUse this endpoint to monitor your mail services, including their status,\nplan, attached domain, and expiration details.",
18+
Run: func(cmd *cobra.Command, args []string) {
19+
utils.EnumCheck(cmd, "status", []string{"pending_setup", "active", "suspended"})
20+
utils.EnumCheck(cmd, "sort", []string{"created_at", "-created_at", "expires_at", "-expires_at"})
21+
r, err := api.Request().MailGetMailOrderListV1WithResponse(context.TODO(), listParams(cmd))
22+
if err != nil {
23+
log.Fatal(err)
24+
}
25+
26+
output.Format(cmd, r.Body, r.StatusCode())
27+
},
28+
}
29+
30+
func init() {
31+
ListCmd.Flags().StringP("domain", "", "", "Filter orders by domain name (exact match)")
32+
ListCmd.Flags().StringP("status", "", "", "Filter orders by status (one of: pending_setup, active, suspended)")
33+
ListCmd.Flags().BoolP("is-trial", "", false, "Filter orders by trial state")
34+
ListCmd.Flags().StringP("sort", "", "-created_at", "Sort orders by field. Prefix with `-` for descending order. (one of: created_at, -created_at, expires_at, -expires_at)")
35+
ListCmd.Flags().IntP("page", "", 0, "Page number")
36+
ListCmd.Flags().IntP("per-page", "", 25, "Number of items per page")
37+
}
38+
39+
func listParams(cmd *cobra.Command) *client.MailGetMailOrderListV1Params {
40+
params := &client.MailGetMailOrderListV1Params{}
41+
if cmd.Flags().Changed("domain") {
42+
v, _ := cmd.Flags().GetString("domain")
43+
params.Domain = &v
44+
}
45+
if cmd.Flags().Changed("status") {
46+
v, _ := cmd.Flags().GetString("status")
47+
e := client.MailGetMailOrderListV1ParamsStatus(v)
48+
params.Status = &e
49+
}
50+
if cmd.Flags().Changed("is-trial") {
51+
v, _ := cmd.Flags().GetBool("is-trial")
52+
params.IsTrial = &v
53+
}
54+
if cmd.Flags().Changed("sort") {
55+
v, _ := cmd.Flags().GetString("sort")
56+
e := client.MailGetMailOrderListV1ParamsSort(v)
57+
params.Sort = &e
58+
}
59+
if cmd.Flags().Changed("page") {
60+
v, _ := cmd.Flags().GetInt("page")
61+
params.Page = &v
62+
}
63+
if cmd.Flags().Changed("per-page") {
64+
v, _ := cmd.Flags().GetInt("per-page")
65+
params.PerPage = &v
66+
}
67+
return params
68+
}

cmd/mail/orders/orders.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package orders
2+
3+
import (
4+
"github.com/spf13/cobra"
5+
)
6+
7+
var GroupCmd = &cobra.Command{
8+
Use: "orders",
9+
Short: "Orders commands",
10+
}
11+
12+
func init() {
13+
GroupCmd.AddCommand(ListCmd)
14+
}

cmd/root.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"github.com/hostinger/api-cli/cmd/ecommerce"
1010
"github.com/hostinger/api-cli/cmd/horizons"
1111
"github.com/hostinger/api-cli/cmd/hosting"
12+
"github.com/hostinger/api-cli/cmd/mail"
1213
"github.com/hostinger/api-cli/cmd/reach"
1314
"github.com/hostinger/api-cli/cmd/vps"
1415
"github.com/hostinger/api-cli/cmd/wordpress"
@@ -60,6 +61,7 @@ func init() {
6061
RootCmd.AddCommand(ecommerce.GroupCmd)
6162
RootCmd.AddCommand(horizons.GroupCmd)
6263
RootCmd.AddCommand(hosting.GroupCmd)
64+
RootCmd.AddCommand(mail.GroupCmd)
6365
RootCmd.AddCommand(reach.GroupCmd)
6466
RootCmd.AddCommand(vps.GroupCmd)
6567
RootCmd.AddCommand(wordpress.GroupCmd)

docs/hostinger.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Hostinger API Command Line Interface
1919
* [hostinger ecommerce](hostinger_ecommerce.md) - Ecommerce commands
2020
* [hostinger horizons](hostinger_horizons.md) - Horizons commands
2121
* [hostinger hosting](hostinger_hosting.md) - Hosting commands
22+
* [hostinger mail](hostinger_mail.md) - Mail commands
2223
* [hostinger reach](hostinger_reach.md) - Reach commands
2324
* [hostinger version](hostinger_version.md) - Show the current version
2425
* [hostinger vps](hostinger_vps.md) - VPS commands

docs/hostinger_mail.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
## hostinger mail
2+
3+
Mail commands
4+
5+
### Options
6+
7+
```
8+
-h, --help help for mail
9+
```
10+
11+
### Options inherited from parent commands
12+
13+
```
14+
--config string Config file (default is $HOME/.hostinger.yaml)
15+
--format string Output format type (json|table|tree), default: table
16+
```
17+
18+
### SEE ALSO
19+
20+
* [hostinger](hostinger.md) - Hostinger API Command Line Interface
21+
* [hostinger mail orders](hostinger_mail_orders.md) - Orders commands
22+

docs/hostinger_mail_orders.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
## hostinger mail orders
2+
3+
Orders commands
4+
5+
### Options
6+
7+
```
8+
-h, --help help for orders
9+
```
10+
11+
### Options inherited from parent commands
12+
13+
```
14+
--config string Config file (default is $HOME/.hostinger.yaml)
15+
--format string Output format type (json|table|tree), default: table
16+
```
17+
18+
### SEE ALSO
19+
20+
* [hostinger mail](hostinger_mail.md) - Mail commands
21+
* [hostinger mail orders list](hostinger_mail_orders_list.md) - Get mail order list
22+

docs/hostinger_mail_orders_list.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
## hostinger mail orders list
2+
3+
Get mail order list
4+
5+
### Synopsis
6+
7+
Retrieve a paginated list of mail orders associated with your account.
8+
9+
Use this endpoint to monitor your mail services, including their status,
10+
plan, attached domain, and expiration details.
11+
12+
```
13+
hostinger mail orders list [flags]
14+
```
15+
16+
### Options
17+
18+
```
19+
--domain string Filter orders by domain name (exact match)
20+
-h, --help help for list
21+
--is-trial Filter orders by trial state
22+
--page int Page number
23+
--per-page int Number of items per page (default 25)
24+
--sort - Sort orders by field. Prefix with - for descending order. (one of: created_at, -created_at, expires_at, -expires_at) (default "-created_at")
25+
--status string Filter orders by status (one of: pending_setup, active, suspended)
26+
```
27+
28+
### Options inherited from parent commands
29+
30+
```
31+
--config string Config file (default is $HOME/.hostinger.yaml)
32+
--format string Output format type (json|table|tree), default: table
33+
```
34+
35+
### SEE ALSO
36+
37+
* [hostinger mail orders](hostinger_mail_orders.md) - Orders commands
38+

manifest.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1004,6 +1004,11 @@
10041004
"method": "POST",
10051005
"path": "/api/hosting/v1/domains/verify-ownership"
10061006
},
1007+
"mail_getMailOrderListV1": {
1008+
"command": "hostinger mail orders list",
1009+
"method": "GET",
1010+
"path": "/api/mail/v1/orders"
1011+
},
10071012
"reach_createANewContactSegmentV1": {
10081013
"command": "hostinger reach segments create",
10091014
"method": "POST",

0 commit comments

Comments
 (0)