Skip to content

Commit 04cc17d

Browse files
feat: regenerate CLI from OpenAPI spec
1 parent 104b65f commit 04cc17d

8 files changed

Lines changed: 513 additions & 8 deletions

File tree

client/client.gen.go

Lines changed: 375 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: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package mail
22

33
import (
4+
"github.com/hostinger/api-cli/cmd/mail/mailboxes"
45
"github.com/hostinger/api-cli/cmd/mail/orders"
56

67
"github.com/spf13/cobra"
@@ -12,5 +13,6 @@ var GroupCmd = &cobra.Command{
1213
}
1314

1415
func init() {
16+
GroupCmd.AddCommand(mailboxes.GroupCmd)
1517
GroupCmd.AddCommand(orders.GroupCmd)
1618
}

cmd/mail/mailboxes/mailbox.go

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
package mailboxes
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 MailboxCmd = &cobra.Command{
15+
Use: "mailbox <order-id>",
16+
Short: "Get mailbox list",
17+
Long: "Retrieve a paginated list of mailboxes belonging to a mail order.\n\nUse this endpoint to monitor mailboxes of your mail service, including\ntheir status, enabled protocols, attached resource counts, and\nperiodically synced usage numbers (usage may lag behind live values).",
18+
Args: cobra.MatchAll(cobra.ExactArgs(1)),
19+
Run: func(cmd *cobra.Command, args []string) {
20+
utils.EnumCheck(cmd, "sort", []string{"address", "-address"})
21+
r, err := api.Request().MailGetMailboxListV1WithResponse(context.TODO(), args[0], mailboxParams(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+
MailboxCmd.Flags().StringP("search", "", "", "Filter mailboxes whose email address contains the given string")
32+
MailboxCmd.Flags().StringP("sort", "", "address", "Sort mailboxes by field. Prefix with `-` for descending order. (one of: address, -address)")
33+
MailboxCmd.Flags().IntP("page", "", 0, "Page number")
34+
MailboxCmd.Flags().IntP("per-page", "", 25, "Number of items per page")
35+
}
36+
37+
func mailboxParams(cmd *cobra.Command) *client.MailGetMailboxListV1Params {
38+
params := &client.MailGetMailboxListV1Params{}
39+
if cmd.Flags().Changed("search") {
40+
v, _ := cmd.Flags().GetString("search")
41+
params.Search = &v
42+
}
43+
if cmd.Flags().Changed("sort") {
44+
v, _ := cmd.Flags().GetString("sort")
45+
e := client.MailGetMailboxListV1ParamsSort(v)
46+
params.Sort = &e
47+
}
48+
if cmd.Flags().Changed("page") {
49+
v, _ := cmd.Flags().GetInt("page")
50+
params.Page = &v
51+
}
52+
if cmd.Flags().Changed("per-page") {
53+
v, _ := cmd.Flags().GetInt("per-page")
54+
params.PerPage = &v
55+
}
56+
return params
57+
}

cmd/mail/mailboxes/mailboxes.go

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

docs/hostinger_mail.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,6 @@ Mail commands
1818
### SEE ALSO
1919

2020
* [hostinger](hostinger.md) - Hostinger API Command Line Interface
21+
* [hostinger mail mailboxes](hostinger_mail_mailboxes.md) - Mailboxes commands
2122
* [hostinger mail orders](hostinger_mail_orders.md) - Orders commands
2223

docs/hostinger_mail_mailboxes.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
## hostinger mail mailboxes
2+
3+
Mailboxes commands
4+
5+
### Options
6+
7+
```
8+
-h, --help help for mailboxes
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 mailboxes mailbox](hostinger_mail_mailboxes_mailbox.md) - Get mailbox list
22+
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
## hostinger mail mailboxes mailbox
2+
3+
Get mailbox list
4+
5+
### Synopsis
6+
7+
Retrieve a paginated list of mailboxes belonging to a mail order.
8+
9+
Use this endpoint to monitor mailboxes of your mail service, including
10+
their status, enabled protocols, attached resource counts, and
11+
periodically synced usage numbers (usage may lag behind live values).
12+
13+
```
14+
hostinger mail mailboxes mailbox <order-id> [flags]
15+
```
16+
17+
### Options
18+
19+
```
20+
-h, --help help for mailbox
21+
--page int Page number
22+
--per-page int Number of items per page (default 25)
23+
--search string Filter mailboxes whose email address contains the given string
24+
--sort - Sort mailboxes by field. Prefix with - for descending order. (one of: address, -address) (default "address")
25+
```
26+
27+
### Options inherited from parent commands
28+
29+
```
30+
--config string Config file (default is $HOME/.hostinger.yaml)
31+
--format string Output format type (json|table|tree), default: table
32+
```
33+
34+
### SEE ALSO
35+
36+
* [hostinger mail mailboxes](hostinger_mail_mailboxes.md) - Mailboxes commands
37+

manifest.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1054,6 +1054,11 @@
10541054
"method": "GET",
10551055
"path": "/api/mail/v1/orders"
10561056
},
1057+
"mail_getMailboxListV1": {
1058+
"command": "hostinger mail mailboxes mailbox",
1059+
"method": "GET",
1060+
"path": "/api/mail/v1/orders/{orderId}/mailboxes"
1061+
},
10571062
"reach_createANewContactSegmentV1": {
10581063
"command": "hostinger reach segments create",
10591064
"method": "POST",

0 commit comments

Comments
 (0)