Skip to content

Commit e4ee57c

Browse files
committed
fix: handle string-format query params and unblock dependabot updates
1 parent 7276e3b commit e4ee57c

109 files changed

Lines changed: 45371 additions & 10254 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: 42053 additions & 10191 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmd/agency_hosting/agency_hosting.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"github.com/hostinger/api-cli/cmd/agency_hosting/datacenters"
88
"github.com/hostinger/api-cli/cmd/agency_hosting/domains"
99
"github.com/hostinger/api-cli/cmd/agency_hosting/files"
10+
"github.com/hostinger/api-cli/cmd/agency_hosting/orders"
1011
"github.com/hostinger/api-cli/cmd/agency_hosting/website_setups"
1112
"github.com/hostinger/api-cli/cmd/agency_hosting/websites"
1213
"github.com/hostinger/api-cli/cmd/agency_hosting/wordpress"
@@ -26,6 +27,7 @@ func init() {
2627
GroupCmd.AddCommand(datacenters.GroupCmd)
2728
GroupCmd.AddCommand(domains.GroupCmd)
2829
GroupCmd.AddCommand(files.GroupCmd)
30+
GroupCmd.AddCommand(orders.GroupCmd)
2931
GroupCmd.AddCommand(website_setups.GroupCmd)
3032
GroupCmd.AddCommand(websites.GroupCmd)
3133
GroupCmd.AddCommand(wordpress.GroupCmd)
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package orders
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 ListPlanCmd = &cobra.Command{
14+
Use: "list-plan",
15+
Short: "List Agency Plan orders",
16+
Long: "Returns a paginated list of Agency Plan orders accessible to the authenticated client.",
17+
Run: func(cmd *cobra.Command, args []string) {
18+
r, err := api.Request().AgencyHostingListAgencyPlanOrdersV1WithResponse(context.TODO(), listPlanParams(cmd))
19+
if err != nil {
20+
log.Fatal(err)
21+
}
22+
23+
output.Format(cmd, r.Body, r.StatusCode())
24+
},
25+
}
26+
27+
func init() {
28+
ListPlanCmd.Flags().IntP("page", "", 0, "Page number")
29+
ListPlanCmd.Flags().IntP("per-page", "", 25, "Number of items per page")
30+
}
31+
32+
func listPlanParams(cmd *cobra.Command) *client.AgencyHostingListAgencyPlanOrdersV1Params {
33+
params := &client.AgencyHostingListAgencyPlanOrdersV1Params{}
34+
if cmd.Flags().Changed("page") {
35+
v, _ := cmd.Flags().GetInt("page")
36+
params.Page = &v
37+
}
38+
if cmd.Flags().Changed("per-page") {
39+
v, _ := cmd.Flags().GetInt("per-page")
40+
params.PerPage = &v
41+
}
42+
return params
43+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package orders
2+
3+
import (
4+
"github.com/spf13/cobra"
5+
)
6+
7+
var GroupCmd = &cobra.Command{
8+
Use: "orders",
9+
Short: "Orders commands",
10+
}
11+
12+
func init() {
13+
GroupCmd.AddCommand(ListPlanCmd)
14+
}

cmd/billing/catalog/list.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ var ListCmd = &cobra.Command{
1616
Short: "Get catalog item list",
1717
Long: "Retrieve catalog items available for order.\n\nPrices in catalog items is displayed as cents (without floating point),\ne.g: float `17.99` is displayed as integer `1799`.\n\nUse this endpoint to view available services and pricing before placing orders.",
1818
Run: func(cmd *cobra.Command, args []string) {
19-
utils.EnumCheck(cmd, "category", []string{"DOMAIN", "VPS"})
19+
utils.EnumCheck(cmd, "category", []string{"DOMAIN", "VPS", "EMAIL"})
2020
r, err := api.Request().BillingGetCatalogItemListV1WithResponse(context.TODO(), listParams(cmd))
2121
if err != nil {
2222
log.Fatal(err)
@@ -27,7 +27,7 @@ var ListCmd = &cobra.Command{
2727
}
2828

2929
func init() {
30-
ListCmd.Flags().StringP("category", "", "", "Filter catalog items by category (one of: DOMAIN, VPS)")
30+
ListCmd.Flags().StringP("category", "", "", "Filter catalog items by category (one of: DOMAIN, VPS, EMAIL)")
3131
ListCmd.Flags().StringP("name", "", "", "Filter catalog items by name. Use `*` for wildcard search, e.g. `.COM*` to find .com domain")
3232
}
3333

cmd/hosting/databases/create_remote_connection.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ import (
1313

1414
var CreateRemoteConnectionCmd = &cobra.Command{
1515
Use: "create-remote-connection <username> <name>",
16-
Short: "Create account database remote connection",
16+
Short: "Create database remote connection",
1717
Long: "Allows a remote host to connect to the specified database.\n\nProvide an IPv4/IPv6 address, or \"%\" to allow any host. The database name must be\nthe full name returned by the list databases endpoint.",
1818
Args: cobra.MatchAll(cobra.ExactArgs(2)),
1919
Run: func(cmd *cobra.Command, args []string) {
2020
payload, err := json.Marshal(createRemoteConnectionBody(cmd))
2121
if err != nil {
2222
log.Fatal(err)
2323
}
24-
r, err := api.Request().HostingCreateAccountDatabaseRemoteConnectionV1WithBodyWithResponse(context.TODO(), args[0], args[1], "application/json", bytes.NewReader(payload))
24+
r, err := api.Request().HostingCreateDatabaseRemoteConnectionV1WithBodyWithResponse(context.TODO(), args[0], args[1], "application/json", bytes.NewReader(payload))
2525
if err != nil {
2626
log.Fatal(err)
2727
}

cmd/hosting/databases/delete_remote_connection.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ import (
1212

1313
var DeleteRemoteConnectionCmd = &cobra.Command{
1414
Use: "delete-remote-connection <username> <name>",
15-
Short: "Delete account database remote connection",
15+
Short: "Delete database remote connection",
1616
Long: "Permanently removes a remote-access rule, revoking the given host's remote access to the database.\n\nIdentify the rule with the required ip query parameter (the IPv4/IPv6 address, or \"%\",\nexactly as returned by the list remote connections endpoint). The database name must be\nthe full name returned by the list databases endpoint.",
1717
Args: cobra.MatchAll(cobra.ExactArgs(2)),
1818
Run: func(cmd *cobra.Command, args []string) {
19-
r, err := api.Request().HostingDeleteAccountDatabaseRemoteConnectionV1WithResponse(context.TODO(), args[0], args[1], deleteRemoteConnectionParams(cmd))
19+
r, err := api.Request().HostingDeleteDatabaseRemoteConnectionV1WithResponse(context.TODO(), args[0], args[1], deleteRemoteConnectionParams(cmd))
2020
if err != nil {
2121
log.Fatal(err)
2222
}
@@ -30,8 +30,8 @@ func init() {
3030
DeleteRemoteConnectionCmd.MarkFlagRequired("ip")
3131
}
3232

33-
func deleteRemoteConnectionParams(cmd *cobra.Command) *client.HostingDeleteAccountDatabaseRemoteConnectionV1Params {
34-
params := &client.HostingDeleteAccountDatabaseRemoteConnectionV1Params{}
33+
func deleteRemoteConnectionParams(cmd *cobra.Command) *client.HostingDeleteDatabaseRemoteConnectionV1Params {
34+
params := &client.HostingDeleteDatabaseRemoteConnectionV1Params{}
3535
ipVal, _ := cmd.Flags().GetString("ip")
3636
params.Ip = ipVal
3737
return params

cmd/hosting/databases/list_remote_connections.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ import (
1212

1313
var ListRemoteConnectionsCmd = &cobra.Command{
1414
Use: "list-remote-connections <username>",
15-
Short: "List account database remote connections",
15+
Short: "List database remote connections",
1616
Long: "Returns the remote-access rules for the specified account: the remote hosts\n(IPv4/IPv6 addresses, or \"%\" for any host) allowed to connect to the account databases.\n\nUse the domain filter to only return rules for databases assigned to a specific domain.",
1717
Args: cobra.MatchAll(cobra.ExactArgs(1)),
1818
Run: func(cmd *cobra.Command, args []string) {
19-
r, err := api.Request().HostingListAccountDatabaseRemoteConnectionsV1WithResponse(context.TODO(), args[0], listRemoteConnectionsParams(cmd))
19+
r, err := api.Request().HostingListDatabaseRemoteConnectionsV1WithResponse(context.TODO(), args[0], listRemoteConnectionsParams(cmd))
2020
if err != nil {
2121
log.Fatal(err)
2222
}
@@ -29,8 +29,8 @@ func init() {
2929
ListRemoteConnectionsCmd.Flags().StringP("domain", "", "", "Filter remote connections by the domain the database is assigned to.\nRules for databases not assigned to any domain are always included.")
3030
}
3131

32-
func listRemoteConnectionsParams(cmd *cobra.Command) *client.HostingListAccountDatabaseRemoteConnectionsV1Params {
33-
params := &client.HostingListAccountDatabaseRemoteConnectionsV1Params{}
32+
func listRemoteConnectionsParams(cmd *cobra.Command) *client.HostingListDatabaseRemoteConnectionsV1Params {
33+
params := &client.HostingListDatabaseRemoteConnectionsV1Params{}
3434
if cmd.Flags().Changed("domain") {
3535
v, _ := cmd.Flags().GetString("domain")
3636
params.Domain = &v

cmd/mail/aliases/aliases.go

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

cmd/mail/aliases/create_alias.go

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package aliases
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 CreateAliasCmd = &cobra.Command{
15+
Use: "create-alias <mailbox-id>",
16+
Short: "Create alias",
17+
Long: "Create an alias for the given mailbox. The alias address is formed\nfrom the given local part and the domain of the mailbox. Messages\nsent to the alias are delivered to the mailbox.",
18+
Args: cobra.MatchAll(cobra.ExactArgs(1)),
19+
Run: func(cmd *cobra.Command, args []string) {
20+
payload, err := json.Marshal(createAliasBody(cmd))
21+
if err != nil {
22+
log.Fatal(err)
23+
}
24+
r, err := api.Request().MailCreateAliasV1WithBodyWithResponse(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+
CreateAliasCmd.Flags().StringP("local-part", "", "", "Local part of the alias address (the part before the @). The domain is taken from the mailbox. Case-insensitive and stored lowercase; must start and end with a letter or digit; single dots, underscores and hyphens are allowed in between.")
35+
CreateAliasCmd.MarkFlagRequired("local-part")
36+
}
37+
38+
func createAliasBody(cmd *cobra.Command) map[string]any {
39+
body := map[string]any{}
40+
localPartVal, _ := cmd.Flags().GetString("local-part")
41+
body["local_part"] = localPartVal
42+
return body
43+
}

0 commit comments

Comments
 (0)