Skip to content

Commit 4e5215f

Browse files
feat: regenerate CLI from OpenAPI spec
1 parent 24258cf commit 4e5215f

6 files changed

Lines changed: 628 additions & 0 deletions

File tree

‎client/client.gen.go‎

Lines changed: 514 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
package portfolio
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 CompleteSetupCmd = &cobra.Command{
16+
Use: "complete-setup <domain>",
17+
Short: "Complete domain setup",
18+
Long: "Register a domain you have already paid for but which has not been set up yet.\n\nUse this endpoint when an order completed without registering the domain, for example when\n`Purchase new domain` returned `202 Accepted` and the domain was added to your account without\nbeing registered, or when an earlier setup attempt failed. No new order is placed and no payment\nis taken: the subscription you already own is used, for the period you already paid for.\n\nA domain is left awaiting setup when the details needed to register it were missing or invalid\nas the order completed. Domains ordered elsewhere can be awaiting setup for the same reason.\nComplete the missing information, then call this endpoint. If the order itself has not completed\nyet, the domain is not on your account, wait until it appears in `Get domain list`.\n\nIf `domain_contacts` is omitted, the default WHOIS profile of that TLD is used for all four\nroles. The profile must exist and be complete for the TLD, an incomplete profile is the most\ncommon reason a domain is left awaiting setup. Create one with `Create WHOIS profile`.\n\nSome TLDs require `additional_details`. These are validated before setup, so a missing or\ninvalid value is rejected without any registration being attempted.\n\nThe domain is set up with the default nameservers and without privacy protection. Use\n`Update domain nameservers` and `Enable privacy protection` afterwards to change either.\n\nA successful response means the setup request was accepted, not that the domain is already\nregistered. Poll `Get domain list` for the outcome, the domain appears in `Get domain details`\nonly once it is registered.\n\nUse this endpoint to finish registering a domain that is awaiting setup on your account.",
19+
Args: cobra.MatchAll(cobra.ExactArgs(1)),
20+
Run: func(cmd *cobra.Command, args []string) {
21+
payload, err := json.Marshal(completeSetupBody(cmd))
22+
if err != nil {
23+
log.Fatal(err)
24+
}
25+
r, err := api.Request().DomainsCompleteDomainSetupV1WithBodyWithResponse(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+
CompleteSetupCmd.Flags().StringP("additional-details", "", "", "Additional registration data, possible values depends on TLD (JSON)")
36+
CompleteSetupCmd.Flags().StringP("domain-contacts", "", "", "Domain contact information (JSON)")
37+
}
38+
39+
func completeSetupBody(cmd *cobra.Command) map[string]any {
40+
body := map[string]any{}
41+
if cmd.Flags().Changed("additional-details") {
42+
v, _ := cmd.Flags().GetString("additional-details")
43+
body["additional_details"] = utils.JSONValue(v, "additional-details")
44+
}
45+
if cmd.Flags().Changed("domain-contacts") {
46+
v, _ := cmd.Flags().GetString("domain-contacts")
47+
body["domain_contacts"] = utils.JSONValue(v, "domain-contacts")
48+
}
49+
return body
50+
}

‎cmd/domains/portfolio/portfolio.go‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ var GroupCmd = &cobra.Command{
1212
func init() {
1313
GroupCmd.AddCommand(AuthorizationCodeCmd)
1414
GroupCmd.AddCommand(ClaimFreeCmd)
15+
GroupCmd.AddCommand(CompleteSetupCmd)
1516
GroupCmd.AddCommand(DisableLockCmd)
1617
GroupCmd.AddCommand(DisablePrivacyProtectionCmd)
1718
GroupCmd.AddCommand(EnableLockCmd)

‎docs/hostinger_domains_portfolio.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ Portfolio commands
2020
* [hostinger domains](hostinger_domains.md) - Domains commands
2121
* [hostinger domains portfolio authorization-code](hostinger_domains_portfolio_authorization-code.md) - Get domain authorization code
2222
* [hostinger domains portfolio claim-free](hostinger_domains_portfolio_claim-free.md) - Claim free domain
23+
* [hostinger domains portfolio complete-setup](hostinger_domains_portfolio_complete-setup.md) - Complete domain setup
2324
* [hostinger domains portfolio disable-lock](hostinger_domains_portfolio_disable-lock.md) - Disable domain lock
2425
* [hostinger domains portfolio disable-privacy-protection](hostinger_domains_portfolio_disable-privacy-protection.md) - Disable privacy protection
2526
* [hostinger domains portfolio enable-lock](hostinger_domains_portfolio_enable-lock.md) - Enable domain lock
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
## hostinger domains portfolio complete-setup
2+
3+
Complete domain setup
4+
5+
### Synopsis
6+
7+
Register a domain you have already paid for but which has not been set up yet.
8+
9+
Use this endpoint when an order completed without registering the domain, for example when
10+
`Purchase new domain` returned `202 Accepted` and the domain was added to your account without
11+
being registered, or when an earlier setup attempt failed. No new order is placed and no payment
12+
is taken: the subscription you already own is used, for the period you already paid for.
13+
14+
A domain is left awaiting setup when the details needed to register it were missing or invalid
15+
as the order completed. Domains ordered elsewhere can be awaiting setup for the same reason.
16+
Complete the missing information, then call this endpoint. If the order itself has not completed
17+
yet, the domain is not on your account, wait until it appears in `Get domain list`.
18+
19+
If `domain_contacts` is omitted, the default WHOIS profile of that TLD is used for all four
20+
roles. The profile must exist and be complete for the TLD, an incomplete profile is the most
21+
common reason a domain is left awaiting setup. Create one with `Create WHOIS profile`.
22+
23+
Some TLDs require `additional_details`. These are validated before setup, so a missing or
24+
invalid value is rejected without any registration being attempted.
25+
26+
The domain is set up with the default nameservers and without privacy protection. Use
27+
`Update domain nameservers` and `Enable privacy protection` afterwards to change either.
28+
29+
A successful response means the setup request was accepted, not that the domain is already
30+
registered. Poll `Get domain list` for the outcome, the domain appears in `Get domain details`
31+
only once it is registered.
32+
33+
Use this endpoint to finish registering a domain that is awaiting setup on your account.
34+
35+
```
36+
hostinger domains portfolio complete-setup <domain> [flags]
37+
```
38+
39+
### Options
40+
41+
```
42+
--additional-details string Additional registration data, possible values depends on TLD (JSON)
43+
--domain-contacts string Domain contact information (JSON)
44+
-h, --help help for complete-setup
45+
```
46+
47+
### Options inherited from parent commands
48+
49+
```
50+
--config string Config file (default is $HOME/.hostinger.yaml)
51+
--format string Output format type (json|table|tree), default: table
52+
```
53+
54+
### SEE ALSO
55+
56+
* [hostinger domains portfolio](hostinger_domains_portfolio.md) - Portfolio commands
57+

‎manifest.json‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -619,6 +619,11 @@
619619
"method": "POST",
620620
"path": "/api/domains/v1/portfolio/claim"
621621
},
622+
"domains_completeDomainSetupV1": {
623+
"command": "hostinger domains portfolio complete-setup",
624+
"method": "POST",
625+
"path": "/api/domains/v1/portfolio/{domain}/setup"
626+
},
622627
"domains_createDomainForwardingV1": {
623628
"command": "hostinger domains forwarding create",
624629
"method": "POST",

0 commit comments

Comments
 (0)