Skip to content

Commit 547cdeb

Browse files
feat: regenerate CLI from OpenAPI spec
1 parent 5e8efc2 commit 547cdeb

12 files changed

Lines changed: 1834 additions & 0 deletions

‎client/client.gen.go‎

Lines changed: 1373 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package profiles
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 ConnectSendingDomainCmd = &cobra.Command{
15+
Use: "connect-sending-domain <profile-uuid>",
16+
Short: "Connect sending domain",
17+
Long: "Connect a sending domain to the profile so emails can be sent from addresses on it.\n\nConnecting does not make the domain ready to send: check the DNS status endpoint next for\nrecords that are still missing. A domain the account owns or has already verified connects\nimmediately. Any other domain starts a TXT ownership verification and returns `409`;\ncomplete the verification in Reach, then retry. Returns `422` when the profile or another\nprofile already has the domain, the domain is blocked, or its ownership cannot be verified.\nAn already connected domain is never replaced.\n\nOn success the sender address of draft and scheduled campaigns, and of published automation\nand double opt-in emails, moves onto the new domain in the background, keeping the part\nbefore the `@`.",
18+
Args: cobra.MatchAll(cobra.ExactArgs(1)),
19+
Run: func(cmd *cobra.Command, args []string) {
20+
payload, err := json.Marshal(connectSendingDomainBody(cmd))
21+
if err != nil {
22+
log.Fatal(err)
23+
}
24+
r, err := api.Request().ReachConnectSendingDomainV1WithBodyWithResponse(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+
ConnectSendingDomainCmd.Flags().StringP("domain", "", "", "")
35+
ConnectSendingDomainCmd.MarkFlagRequired("domain")
36+
}
37+
38+
func connectSendingDomainBody(cmd *cobra.Command) map[string]any {
39+
body := map[string]any{}
40+
domainVal, _ := cmd.Flags().GetString("domain")
41+
body["domain"] = domainVal
42+
return body
43+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package profiles
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 DeleteSendingDomainCmd = &cobra.Command{
15+
Use: "delete-sending-domain <profile-uuid>",
16+
Short: "Delete sending domain",
17+
Long: "Disconnect the sending domain from the profile.\n\nThe domain record is removed, so the profile has no sending domain afterwards and campaigns\ncannot be sent until a domain is connected again. Sender addresses already stored on\ncampaigns, automations and settings are left untouched and keep pointing at the removed\ndomain. A domain that is not connected to the profile also succeeds, so success is not proof\nthat anything was deleted. DNS records at the DNS provider are not removed. To switch\ndomains, delete this one and connect the new one. Confirm the domain with the customer\nbefore calling.",
18+
Args: cobra.MatchAll(cobra.ExactArgs(1)),
19+
Run: func(cmd *cobra.Command, args []string) {
20+
payload, err := json.Marshal(deleteSendingDomainBody(cmd))
21+
if err != nil {
22+
log.Fatal(err)
23+
}
24+
r, err := api.Request().ReachDeleteSendingDomainV1WithBodyWithResponse(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+
DeleteSendingDomainCmd.Flags().StringP("domain", "", "", "")
35+
DeleteSendingDomainCmd.MarkFlagRequired("domain")
36+
}
37+
38+
func deleteSendingDomainBody(cmd *cobra.Command) map[string]any {
39+
body := map[string]any{}
40+
domainVal, _ := cmd.Flags().GetString("domain")
41+
body["domain"] = domainVal
42+
return body
43+
}

‎cmd/reach/profiles/profiles.go‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,13 @@ var GroupCmd = &cobra.Command{
1010
}
1111

1212
func init() {
13+
GroupCmd.AddCommand(ConnectSendingDomainCmd)
1314
GroupCmd.AddCommand(ConnectedSendingDomainCmd)
15+
GroupCmd.AddCommand(DeleteSendingDomainCmd)
1416
GroupCmd.AddCommand(DomainDnsStatusCmd)
1517
GroupCmd.AddCommand(ListCmd)
1618
GroupCmd.AddCommand(ListPlanFeatureAccessCmd)
1719
GroupCmd.AddCommand(RemainingPlanLimitsCmd)
20+
GroupCmd.AddCommand(SettingsCmd)
21+
GroupCmd.AddCommand(UpdateSettingsCmd)
1822
}

‎cmd/reach/profiles/settings.go‎

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 SettingsCmd = &cobra.Command{
13+
Use: "settings <profile-uuid>",
14+
Short: "Get profile settings",
15+
Long: "Get the profile's saved sender identity and brand details.\n\nRead the default sender before creating a campaign instead of asking the customer, and\nreuse the brand fields when generating email content. Any field can be `null` for a profile\nthat never filled its settings in. This does not check that the sending domain is\nverified, use the connected sending domain endpoint for that.",
16+
Args: cobra.MatchAll(cobra.ExactArgs(1)),
17+
Run: func(cmd *cobra.Command, args []string) {
18+
r, err := api.Request().ReachGetProfileSettingsV1WithResponse(context.TODO(), args[0])
19+
if err != nil {
20+
log.Fatal(err)
21+
}
22+
23+
output.Format(cmd, r.Body, r.StatusCode())
24+
},
25+
}
Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
package profiles
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 UpdateSettingsCmd = &cobra.Command{
16+
Use: "update-settings <profile-uuid>",
17+
Short: "Update profile settings",
18+
Long: "Change the profile's default sender and brand details.\n\nSend only the fields to change: every omitted field keeps its value, and `null` or an empty\nstring clears a text field. The default sender is what campaigns created afterwards start\nfrom; existing campaigns keep their own sender. `sender_email` is only the part before the\n`@`, because Reach combines it with the profile's connected sending domain, so an address\noutside that domain cannot be set. Connecting a sending domain is a separate endpoint and\na connected domain cannot be changed here. Returns the settings after the change.",
19+
Args: cobra.MatchAll(cobra.ExactArgs(1)),
20+
Run: func(cmd *cobra.Command, args []string) {
21+
payload, err := json.Marshal(updateSettingsBody(cmd))
22+
if err != nil {
23+
log.Fatal(err)
24+
}
25+
r, err := api.Request().ReachUpdateProfileSettingsV1WithBodyWithResponse(context.TODO(), args[0], "application/json", bytes.NewReader(payload))
26+
if err != nil {
27+
log.Fatal(err)
28+
}
29+
30+
output.Format(cmd, r.Body, r.StatusCode())
31+
},
32+
}
33+
34+
func init() {
35+
UpdateSettingsCmd.Flags().StringP("about", "", "", "")
36+
UpdateSettingsCmd.Flags().StringP("accent-color", "", "", "")
37+
UpdateSettingsCmd.Flags().StringP("background-color", "", "", "")
38+
UpdateSettingsCmd.Flags().StringP("brand-name", "", "", "")
39+
UpdateSettingsCmd.Flags().StringP("business-address", "", "", "")
40+
UpdateSettingsCmd.Flags().StringP("button-color", "", "", "")
41+
UpdateSettingsCmd.Flags().IntP("button-corners", "", 0, "")
42+
UpdateSettingsCmd.Flags().StringP("button-text", "", "", "Button text colour.")
43+
UpdateSettingsCmd.Flags().StringP("font-family", "", "", "")
44+
UpdateSettingsCmd.Flags().StringP("heading-font-family", "", "", "")
45+
UpdateSettingsCmd.Flags().StringSliceP("keywords", "", nil, "")
46+
UpdateSettingsCmd.Flags().StringP("links-color", "", "", "")
47+
UpdateSettingsCmd.Flags().StringP("logo-url", "", "", "Public image URL. Logo uploads are not supported.")
48+
UpdateSettingsCmd.Flags().StringP("privacy-policy-url", "", "", "")
49+
UpdateSettingsCmd.Flags().StringSliceP("selling-points", "", nil, "")
50+
UpdateSettingsCmd.Flags().StringP("sender-email", "", "", "Part of the default sender address before the `@`, for example `hello`. Never send a\nfull address: Reach adds the profile's connected sending domain itself.")
51+
UpdateSettingsCmd.Flags().StringP("sender-name", "", "", "Default sender name. Letters, numbers and spaces only.")
52+
UpdateSettingsCmd.Flags().StringSliceP("social-links", "", nil, "")
53+
UpdateSettingsCmd.Flags().StringP("socials", "", "", "Social profile links keyed by platform. (JSON)")
54+
UpdateSettingsCmd.Flags().StringP("text-color", "", "", "")
55+
UpdateSettingsCmd.Flags().StringSliceP("topics", "", nil, "")
56+
UpdateSettingsCmd.Flags().StringP("website-url", "", "", "")
57+
}
58+
59+
func updateSettingsBody(cmd *cobra.Command) map[string]any {
60+
body := map[string]any{}
61+
if cmd.Flags().Changed("about") {
62+
v, _ := cmd.Flags().GetString("about")
63+
body["about"] = v
64+
}
65+
if cmd.Flags().Changed("accent-color") {
66+
v, _ := cmd.Flags().GetString("accent-color")
67+
body["accent_color"] = v
68+
}
69+
if cmd.Flags().Changed("background-color") {
70+
v, _ := cmd.Flags().GetString("background-color")
71+
body["background_color"] = v
72+
}
73+
if cmd.Flags().Changed("brand-name") {
74+
v, _ := cmd.Flags().GetString("brand-name")
75+
body["brand_name"] = v
76+
}
77+
if cmd.Flags().Changed("business-address") {
78+
v, _ := cmd.Flags().GetString("business-address")
79+
body["business_address"] = v
80+
}
81+
if cmd.Flags().Changed("button-color") {
82+
v, _ := cmd.Flags().GetString("button-color")
83+
body["button_color"] = v
84+
}
85+
if cmd.Flags().Changed("button-corners") {
86+
v, _ := cmd.Flags().GetInt("button-corners")
87+
body["button_corners"] = v
88+
}
89+
if cmd.Flags().Changed("button-text") {
90+
v, _ := cmd.Flags().GetString("button-text")
91+
body["button_text"] = v
92+
}
93+
if cmd.Flags().Changed("font-family") {
94+
v, _ := cmd.Flags().GetString("font-family")
95+
body["font_family"] = v
96+
}
97+
if cmd.Flags().Changed("heading-font-family") {
98+
v, _ := cmd.Flags().GetString("heading-font-family")
99+
body["heading_font_family"] = v
100+
}
101+
if cmd.Flags().Changed("keywords") {
102+
v, _ := cmd.Flags().GetStringSlice("keywords")
103+
body["keywords"] = v
104+
}
105+
if cmd.Flags().Changed("links-color") {
106+
v, _ := cmd.Flags().GetString("links-color")
107+
body["links_color"] = v
108+
}
109+
if cmd.Flags().Changed("logo-url") {
110+
v, _ := cmd.Flags().GetString("logo-url")
111+
body["logo_url"] = v
112+
}
113+
if cmd.Flags().Changed("privacy-policy-url") {
114+
v, _ := cmd.Flags().GetString("privacy-policy-url")
115+
body["privacy_policy_url"] = v
116+
}
117+
if cmd.Flags().Changed("selling-points") {
118+
v, _ := cmd.Flags().GetStringSlice("selling-points")
119+
body["selling_points"] = v
120+
}
121+
if cmd.Flags().Changed("sender-email") {
122+
v, _ := cmd.Flags().GetString("sender-email")
123+
body["sender_email"] = v
124+
}
125+
if cmd.Flags().Changed("sender-name") {
126+
v, _ := cmd.Flags().GetString("sender-name")
127+
body["sender_name"] = v
128+
}
129+
if cmd.Flags().Changed("social-links") {
130+
v, _ := cmd.Flags().GetStringSlice("social-links")
131+
body["social_links"] = v
132+
}
133+
if cmd.Flags().Changed("socials") {
134+
v, _ := cmd.Flags().GetString("socials")
135+
body["socials"] = utils.JSONValue(v, "socials")
136+
}
137+
if cmd.Flags().Changed("text-color") {
138+
v, _ := cmd.Flags().GetString("text-color")
139+
body["text_color"] = v
140+
}
141+
if cmd.Flags().Changed("topics") {
142+
v, _ := cmd.Flags().GetStringSlice("topics")
143+
body["topics"] = v
144+
}
145+
if cmd.Flags().Changed("website-url") {
146+
v, _ := cmd.Flags().GetString("website-url")
147+
body["website_url"] = v
148+
}
149+
return body
150+
}

‎docs/hostinger_reach_profiles.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,13 @@ Profiles commands
1818
### SEE ALSO
1919

2020
* [hostinger reach](hostinger_reach.md) - Reach commands
21+
* [hostinger reach profiles connect-sending-domain](hostinger_reach_profiles_connect-sending-domain.md) - Connect sending domain
2122
* [hostinger reach profiles connected-sending-domain](hostinger_reach_profiles_connected-sending-domain.md) - Get connected sending domain
23+
* [hostinger reach profiles delete-sending-domain](hostinger_reach_profiles_delete-sending-domain.md) - Delete sending domain
2224
* [hostinger reach profiles domain-dns-status](hostinger_reach_profiles_domain-dns-status.md) - Get profile domain DNS status
2325
* [hostinger reach profiles list](hostinger_reach_profiles_list.md) - List Profiles
2426
* [hostinger reach profiles list-plan-feature-access](hostinger_reach_profiles_list-plan-feature-access.md) - List plan feature access
2527
* [hostinger reach profiles remaining-plan-limits](hostinger_reach_profiles_remaining-plan-limits.md) - Get remaining plan limits
28+
* [hostinger reach profiles settings](hostinger_reach_profiles_settings.md) - Get profile settings
29+
* [hostinger reach profiles update-settings](hostinger_reach_profiles_update-settings.md) - Update profile settings
2630

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
## hostinger reach profiles connect-sending-domain
2+
3+
Connect sending domain
4+
5+
### Synopsis
6+
7+
Connect a sending domain to the profile so emails can be sent from addresses on it.
8+
9+
Connecting does not make the domain ready to send: check the DNS status endpoint next for
10+
records that are still missing. A domain the account owns or has already verified connects
11+
immediately. Any other domain starts a TXT ownership verification and returns `409`;
12+
complete the verification in Reach, then retry. Returns `422` when the profile or another
13+
profile already has the domain, the domain is blocked, or its ownership cannot be verified.
14+
An already connected domain is never replaced.
15+
16+
On success the sender address of draft and scheduled campaigns, and of published automation
17+
and double opt-in emails, moves onto the new domain in the background, keeping the part
18+
before the `@`.
19+
20+
```
21+
hostinger reach profiles connect-sending-domain <profile-uuid> [flags]
22+
```
23+
24+
### Options
25+
26+
```
27+
--domain string
28+
-h, --help help for connect-sending-domain
29+
```
30+
31+
### Options inherited from parent commands
32+
33+
```
34+
--config string Config file (default is $HOME/.hostinger.yaml)
35+
--format string Output format type (json|table|tree), default: table
36+
```
37+
38+
### SEE ALSO
39+
40+
* [hostinger reach profiles](hostinger_reach_profiles.md) - Profiles commands
41+
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
## hostinger reach profiles delete-sending-domain
2+
3+
Delete sending domain
4+
5+
### Synopsis
6+
7+
Disconnect the sending domain from the profile.
8+
9+
The domain record is removed, so the profile has no sending domain afterwards and campaigns
10+
cannot be sent until a domain is connected again. Sender addresses already stored on
11+
campaigns, automations and settings are left untouched and keep pointing at the removed
12+
domain. A domain that is not connected to the profile also succeeds, so success is not proof
13+
that anything was deleted. DNS records at the DNS provider are not removed. To switch
14+
domains, delete this one and connect the new one. Confirm the domain with the customer
15+
before calling.
16+
17+
```
18+
hostinger reach profiles delete-sending-domain <profile-uuid> [flags]
19+
```
20+
21+
### Options
22+
23+
```
24+
--domain string
25+
-h, --help help for delete-sending-domain
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 reach profiles](hostinger_reach_profiles.md) - Profiles commands
38+

0 commit comments

Comments
 (0)