Skip to content

Commit 3dedfbc

Browse files
feat: regenerate CLI from OpenAPI spec
1 parent 697abc2 commit 3dedfbc

16 files changed

Lines changed: 3273 additions & 1815 deletions

client/client.gen.go

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

cmd/reach/forms/delete.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package forms
2+
3+
import (
4+
"context"
5+
"log"
6+
7+
"github.com/hostinger/api-cli/api"
8+
"github.com/hostinger/api-cli/output"
9+
"github.com/spf13/cobra"
10+
)
11+
12+
var DeleteCmd = &cobra.Command{
13+
Use: "delete <profile-uuid> <form-uuid>",
14+
Short: "Delete form",
15+
Long: "Permanently delete a form together with its template.\n\nA form that has already captured submissions cannot be deleted, so that the contacts it collected\nare never silently discarded - pause the form instead to stop it collecting new ones. Views alone\ndo not block deletion.",
16+
Args: cobra.MatchAll(cobra.ExactArgs(2)),
17+
Run: func(cmd *cobra.Command, args []string) {
18+
r, err := api.Request().ReachDeleteFormV1WithResponse(context.TODO(), args[0], args[1])
19+
if err != nil {
20+
log.Fatal(err)
21+
}
22+
23+
output.Format(cmd, r.Body, r.StatusCode())
24+
},
25+
}

cmd/reach/forms/forms.go

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

cmd/reach/forms/get.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package forms
2+
3+
import (
4+
"context"
5+
"log"
6+
7+
"github.com/hostinger/api-cli/api"
8+
"github.com/hostinger/api-cli/output"
9+
"github.com/spf13/cobra"
10+
)
11+
12+
var GetCmd = &cobra.Command{
13+
Use: "get <profile-uuid> <form-uuid>",
14+
Short: "Get form details",
15+
Long: "Get a single form with the URL of its hosted template and the tags it applies to the contacts\nit captures.\n\nThere is no ready-made embed snippet in the response - either serve the template HTML yourself\nor build your own embed around the form uuid.",
16+
Args: cobra.MatchAll(cobra.ExactArgs(2)),
17+
Run: func(cmd *cobra.Command, args []string) {
18+
r, err := api.Request().ReachGetFormDetailsV1WithResponse(context.TODO(), args[0], args[1])
19+
if err != nil {
20+
log.Fatal(err)
21+
}
22+
23+
output.Format(cmd, r.Body, r.StatusCode())
24+
},
25+
}

cmd/reach/forms/list.go

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package forms
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/spf13/cobra"
11+
)
12+
13+
var ListCmd = &cobra.Command{
14+
Use: "list <profile-uuid>",
15+
Short: "List forms",
16+
Long: "Get a paginated list of the signup forms in a profile.\n\nEach form carries a reference to the template that renders it. Get the form details for a\ndirectly usable template URL and for the tags the form puts on the contacts it captures.",
17+
Args: cobra.MatchAll(cobra.ExactArgs(1)),
18+
Run: func(cmd *cobra.Command, args []string) {
19+
r, err := api.Request().ReachListFormsV1WithResponse(context.TODO(), args[0], listParams(cmd))
20+
if err != nil {
21+
log.Fatal(err)
22+
}
23+
24+
output.Format(cmd, r.Body, r.StatusCode())
25+
},
26+
}
27+
28+
func init() {
29+
ListCmd.Flags().IntP("page", "", 0, "Page number")
30+
ListCmd.Flags().IntP("per-page", "", 25, "Number of items per page")
31+
}
32+
33+
func listParams(cmd *cobra.Command) *client.ReachListFormsV1Params {
34+
params := &client.ReachListFormsV1Params{}
35+
if cmd.Flags().Changed("page") {
36+
v, _ := cmd.Flags().GetInt("page")
37+
params.Page = &v
38+
}
39+
if cmd.Flags().Changed("per-page") {
40+
v, _ := cmd.Flags().GetInt("per-page")
41+
params.PerPage = &v
42+
}
43+
return params
44+
}

cmd/reach/profiles/profiles.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,5 @@ var GroupCmd = &cobra.Command{
1212
func init() {
1313
GroupCmd.AddCommand(DomainDnsStatusCmd)
1414
GroupCmd.AddCommand(ListCmd)
15+
GroupCmd.AddCommand(RemainingPlanLimitsCmd)
1516
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package profiles
2+
3+
import (
4+
"context"
5+
"log"
6+
7+
"github.com/hostinger/api-cli/api"
8+
"github.com/hostinger/api-cli/output"
9+
"github.com/spf13/cobra"
10+
)
11+
12+
var RemainingPlanLimitsCmd = &cobra.Command{
13+
Use: "remaining-plan-limits <profile-uuid>",
14+
Short: "Get remaining plan limits",
15+
Long: "Get how much of the plan is left for the current period.\n\nTwo things to keep in mind before you build alerting on this. The period is a calendar month\nrather than a billing anniversary, so the counters reset on the 1st no matter when the\nsubscription started. And usage is tracked per order, so every profile on the same order shares\none pool and reports the same numbers here. Only the current period is available, past usage is\nnot kept.",
16+
Args: cobra.MatchAll(cobra.ExactArgs(1)),
17+
Run: func(cmd *cobra.Command, args []string) {
18+
r, err := api.Request().ReachGetRemainingPlanLimitsV1WithResponse(context.TODO(), args[0])
19+
if err != nil {
20+
log.Fatal(err)
21+
}
22+
23+
output.Format(cmd, r.Body, r.StatusCode())
24+
},
25+
}

cmd/reach/reach.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"github.com/hostinger/api-cli/cmd/reach/campaigns"
66
"github.com/hostinger/api-cli/cmd/reach/contact_fields"
77
"github.com/hostinger/api-cli/cmd/reach/contacts"
8+
"github.com/hostinger/api-cli/cmd/reach/forms"
89
"github.com/hostinger/api-cli/cmd/reach/profiles"
910
"github.com/hostinger/api-cli/cmd/reach/segments"
1011
"github.com/hostinger/api-cli/cmd/reach/tags"
@@ -22,6 +23,7 @@ func init() {
2223
GroupCmd.AddCommand(campaigns.GroupCmd)
2324
GroupCmd.AddCommand(contact_fields.GroupCmd)
2425
GroupCmd.AddCommand(contacts.GroupCmd)
26+
GroupCmd.AddCommand(forms.GroupCmd)
2527
GroupCmd.AddCommand(profiles.GroupCmd)
2628
GroupCmd.AddCommand(segments.GroupCmd)
2729
GroupCmd.AddCommand(tags.GroupCmd)

docs/hostinger_reach.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ Reach commands
2222
* [hostinger reach campaigns](hostinger_reach_campaigns.md) - Campaigns commands
2323
* [hostinger reach contact-fields](hostinger_reach_contact-fields.md) - Contact Fields commands
2424
* [hostinger reach contacts](hostinger_reach_contacts.md) - Contacts commands
25+
* [hostinger reach forms](hostinger_reach_forms.md) - Forms commands
2526
* [hostinger reach profiles](hostinger_reach_profiles.md) - Profiles commands
2627
* [hostinger reach segments](hostinger_reach_segments.md) - Segments commands
2728
* [hostinger reach tags](hostinger_reach_tags.md) - Tags commands

docs/hostinger_reach_forms.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
## hostinger reach forms
2+
3+
Forms commands
4+
5+
### Options
6+
7+
```
8+
-h, --help help for forms
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 reach](hostinger_reach.md) - Reach commands
21+
* [hostinger reach forms delete](hostinger_reach_forms_delete.md) - Delete form
22+
* [hostinger reach forms get](hostinger_reach_forms_get.md) - Get form details
23+
* [hostinger reach forms list](hostinger_reach_forms_list.md) - List forms
24+

0 commit comments

Comments
 (0)