Skip to content

Commit 9fb1d97

Browse files
committed
fix: support format:uuid query params and disambiguate domains move list commands
1 parent d54e073 commit 9fb1d97

100 files changed

Lines changed: 27081 additions & 14401 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

client/client.gen.go

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

cmd/domains/domains.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package domains
33
import (
44
"github.com/hostinger/api-cli/cmd/domains/availability"
55
"github.com/hostinger/api-cli/cmd/domains/forwarding"
6+
"github.com/hostinger/api-cli/cmd/domains/move"
67
"github.com/hostinger/api-cli/cmd/domains/portfolio"
78
"github.com/hostinger/api-cli/cmd/domains/transfer"
89
"github.com/hostinger/api-cli/cmd/domains/verifications"
@@ -19,6 +20,7 @@ var GroupCmd = &cobra.Command{
1920
func init() {
2021
GroupCmd.AddCommand(availability.GroupCmd)
2122
GroupCmd.AddCommand(forwarding.GroupCmd)
23+
GroupCmd.AddCommand(move.GroupCmd)
2224
GroupCmd.AddCommand(portfolio.GroupCmd)
2325
GroupCmd.AddCommand(transfer.GroupCmd)
2426
GroupCmd.AddCommand(verifications.GroupCmd)
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package move
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 AcceptIncomingCmd = &cobra.Command{
16+
Use: "accept-incoming <domain>",
17+
Short: "Accept incoming domain move",
18+
Long: "Accept an incoming move for a specified domain.\n\nThe provided WHOIS profiles become the contacts of the domain, so they must belong\nto your account and satisfy the requirements of the TLD. Only the contact types the\ndomain actually uses are applied, but all four profile IDs have to be provided.\n\nThe move has to still be waiting for your decision, already accepted moves\ncannot be accepted again.\n\nAccepting does not complete the move. A confirmation email is sent to the email address of\nthe new owner contact, and the domain changes hands only after the change is confirmed from it.\nUntil then the move stays in the `activating` status, which can be followed with the\n[incoming move endpoint](#tag/domains-move).\n\nUse this endpoint to take ownership of a domain offered to you.",
19+
Args: cobra.MatchAll(cobra.ExactArgs(1)),
20+
Run: func(cmd *cobra.Command, args []string) {
21+
payload, err := json.Marshal(acceptIncomingBody(cmd))
22+
if err != nil {
23+
log.Fatal(err)
24+
}
25+
r, err := api.Request().DomainsAcceptIncomingDomainMoveV1WithBodyWithResponse(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+
AcceptIncomingCmd.Flags().StringP("domain-contacts", "", "", "WHOIS profiles of the accepting account. Only the contact types required by the TLD are applied, but all four IDs must be provided. (JSON)")
36+
AcceptIncomingCmd.MarkFlagRequired("domain-contacts")
37+
}
38+
39+
func acceptIncomingBody(cmd *cobra.Command) map[string]any {
40+
body := map[string]any{}
41+
domainContactsVal, _ := cmd.Flags().GetString("domain-contacts")
42+
body["domain_contacts"] = utils.JSONValue(domainContactsVal, "domain-contacts")
43+
return body
44+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package move
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 CancelOutgoingCmd = &cobra.Command{
13+
Use: "cancel-outgoing <domain>",
14+
Short: "Cancel outgoing domain move",
15+
Long: "Cancel an outgoing move for a specified domain.\n\nThe move can only be cancelled while the receiving account has not accepted it yet.\nThe domain stays in your account.\n\nUse this endpoint to withdraw a move you no longer want to complete.",
16+
Args: cobra.MatchAll(cobra.ExactArgs(1)),
17+
Run: func(cmd *cobra.Command, args []string) {
18+
r, err := api.Request().DomainsCancelOutgoingDomainMoveV1WithResponse(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/domains/move/incoming.go

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package move
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 IncomingCmd = &cobra.Command{
14+
Use: "incoming <domain>",
15+
Short: "Get incoming domain move",
16+
Long: "Retrieve the incoming move for a specified domain.\n\nReturns 404 when no account is moving this domain to you.\n\nUse this endpoint to check whether a domain addressed to you is still waiting to be accepted.",
17+
Args: cobra.MatchAll(cobra.ExactArgs(1)),
18+
Run: func(cmd *cobra.Command, args []string) {
19+
r, err := api.Request().DomainsGetIncomingDomainMoveV1WithResponse(context.TODO(), args[0], incomingParams(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+
IncomingCmd.Flags().BoolP("force-sync", "", false, "Re-check the move against the registry before responding. Only has an effect while the move is in the `activating` status.")
30+
}
31+
32+
func incomingParams(cmd *cobra.Command) *client.DomainsGetIncomingDomainMoveV1Params {
33+
params := &client.DomainsGetIncomingDomainMoveV1Params{}
34+
if cmd.Flags().Changed("force-sync") {
35+
v, _ := cmd.Flags().GetBool("force-sync")
36+
params.ForceSync = &v
37+
}
38+
return params
39+
}

cmd/domains/move/incoming_list.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package move
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 IncomingListCmd = &cobra.Command{
13+
Use: "incoming-list",
14+
Short: "Get incoming domain move list",
15+
Long: "Retrieve all domains other Hostinger accounts are moving to your account.\n\nMoves of every status are returned, including the ones which already completed.\n\nUse this endpoint to find domains waiting for you to accept them.",
16+
Run: func(cmd *cobra.Command, args []string) {
17+
r, err := api.Request().DomainsGetIncomingDomainMoveListV1WithResponse(context.TODO())
18+
if err != nil {
19+
log.Fatal(err)
20+
}
21+
22+
output.Format(cmd, r.Body, r.StatusCode())
23+
},
24+
}

cmd/domains/move/move.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package move
2+
3+
import (
4+
"github.com/spf13/cobra"
5+
)
6+
7+
var GroupCmd = &cobra.Command{
8+
Use: "move",
9+
Short: "Move commands",
10+
}
11+
12+
func init() {
13+
GroupCmd.AddCommand(AcceptIncomingCmd)
14+
GroupCmd.AddCommand(CancelOutgoingCmd)
15+
GroupCmd.AddCommand(IncomingCmd)
16+
GroupCmd.AddCommand(IncomingListCmd)
17+
GroupCmd.AddCommand(OutgoingCmd)
18+
GroupCmd.AddCommand(OutgoingListCmd)
19+
GroupCmd.AddCommand(RejectIncomingCmd)
20+
GroupCmd.AddCommand(StartOutgoingCmd)
21+
}

cmd/domains/move/outgoing.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package move
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 OutgoingCmd = &cobra.Command{
13+
Use: "outgoing <domain>",
14+
Short: "Get outgoing domain move",
15+
Long: "Retrieve the outgoing move for a specified domain.\n\nReturns 404 when the domain has no move in progress.\n\nUse this endpoint to track the status of a move you have initiated for a single domain.",
16+
Args: cobra.MatchAll(cobra.ExactArgs(1)),
17+
Run: func(cmd *cobra.Command, args []string) {
18+
r, err := api.Request().DomainsGetOutgoingDomainMoveV1WithResponse(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/domains/move/outgoing_list.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package move
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 OutgoingListCmd = &cobra.Command{
13+
Use: "outgoing-list",
14+
Short: "Get outgoing domain move list",
15+
Long: "Retrieve all domains you are moving to other Hostinger accounts.\n\nOnly moves which have not completed yet are returned.\n\nUse this endpoint to track moves you have initiated and the accounts they are addressed to.",
16+
Run: func(cmd *cobra.Command, args []string) {
17+
r, err := api.Request().DomainsGetOutgoingDomainMoveListV1WithResponse(context.TODO())
18+
if err != nil {
19+
log.Fatal(err)
20+
}
21+
22+
output.Format(cmd, r.Body, r.StatusCode())
23+
},
24+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package move
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 RejectIncomingCmd = &cobra.Command{
13+
Use: "reject-incoming <domain>",
14+
Short: "Reject incoming domain move",
15+
Long: "Reject an incoming move for a specified domain.\n\nThe domain stays in the account which initiated the move.\nMoves you have already accepted cannot be rejected anymore.\n\nUse this endpoint to decline a domain you do not want to take over.",
16+
Args: cobra.MatchAll(cobra.ExactArgs(1)),
17+
Run: func(cmd *cobra.Command, args []string) {
18+
r, err := api.Request().DomainsRejectIncomingDomainMoveV1WithResponse(context.TODO(), args[0])
19+
if err != nil {
20+
log.Fatal(err)
21+
}
22+
23+
output.Format(cmd, r.Body, r.StatusCode())
24+
},
25+
}

0 commit comments

Comments
 (0)