Skip to content

Commit 80ae264

Browse files
chore: regenerate CLI from OpenAPI spec
1 parent 5d55c3f commit 80ae264

12 files changed

Lines changed: 812 additions & 0 deletions

client/client.gen.go

Lines changed: 540 additions & 0 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
@@ -1,6 +1,7 @@
11
package agency_hosting
22

33
import (
4+
"github.com/hostinger/api-cli/cmd/agency_hosting/cron_jobs"
45
"github.com/hostinger/api-cli/cmd/agency_hosting/datacenters"
56
"github.com/hostinger/api-cli/cmd/agency_hosting/domains"
67
"github.com/hostinger/api-cli/cmd/agency_hosting/files"
@@ -16,6 +17,7 @@ var GroupCmd = &cobra.Command{
1617
}
1718

1819
func init() {
20+
GroupCmd.AddCommand(cron_jobs.GroupCmd)
1921
GroupCmd.AddCommand(datacenters.GroupCmd)
2022
GroupCmd.AddCommand(domains.GroupCmd)
2123
GroupCmd.AddCommand(files.GroupCmd)
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
package cron_jobs
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 CreatePlanWebsiteCmd = &cobra.Command{
15+
Use: "create-plan-website <website_uid>",
16+
Short: "Create Agency Plan website cron job",
17+
Long: "Creates a cron job for an Agency Plan website from a schedule expression and a command.\n\nReturns the created cron job, including its uuid, which is required to delete the cron job.",
18+
Args: cobra.MatchAll(cobra.ExactArgs(1)),
19+
Run: func(cmd *cobra.Command, args []string) {
20+
payload, err := json.Marshal(createPlanWebsiteBody(cmd))
21+
if err != nil {
22+
log.Fatal(err)
23+
}
24+
r, err := api.Request().AgencyHostingCreateAgencyPlanWebsiteCronJobV1WithBodyWithResponse(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+
CreatePlanWebsiteCmd.Flags().StringP("command", "", "", "Command to run on the schedule. Must not contain pipe (|) or redirection (<, >) characters.")
35+
CreatePlanWebsiteCmd.Flags().StringP("time", "", "", "Cron schedule expression (standard 5-field crontab syntax).")
36+
CreatePlanWebsiteCmd.MarkFlagRequired("command")
37+
CreatePlanWebsiteCmd.MarkFlagRequired("time")
38+
}
39+
40+
func createPlanWebsiteBody(cmd *cobra.Command) map[string]any {
41+
body := map[string]any{}
42+
commandVal, _ := cmd.Flags().GetString("command")
43+
body["command"] = commandVal
44+
timeVal, _ := cmd.Flags().GetString("time")
45+
body["time"] = timeVal
46+
return body
47+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package cron_jobs
2+
3+
import (
4+
"github.com/spf13/cobra"
5+
)
6+
7+
var GroupCmd = &cobra.Command{
8+
Use: "cron-jobs",
9+
Short: "Cron Jobs commands",
10+
}
11+
12+
func init() {
13+
GroupCmd.AddCommand(CreatePlanWebsiteCmd)
14+
GroupCmd.AddCommand(DeletePlanWebsiteCmd)
15+
GroupCmd.AddCommand(ListPlanWebsiteCmd)
16+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package cron_jobs
2+
3+
import (
4+
"context"
5+
"log"
6+
7+
"github.com/google/uuid"
8+
"github.com/hostinger/api-cli/api"
9+
"github.com/hostinger/api-cli/output"
10+
"github.com/spf13/cobra"
11+
)
12+
13+
var DeletePlanWebsiteCmd = &cobra.Command{
14+
Use: "delete-plan-website <website_uid> <uuid>",
15+
Short: "Delete Agency Plan website cron job",
16+
Long: "Permanently deletes the cron job identified by its uuid from an Agency Plan website.\n\nThe operation is idempotent: deleting a cron job that does not exist succeeds without error.",
17+
Args: cobra.MatchAll(cobra.ExactArgs(2)),
18+
Run: func(cmd *cobra.Command, args []string) {
19+
r, err := api.Request().AgencyHostingDeleteAgencyPlanWebsiteCronJobV1WithResponse(context.TODO(), args[0], uuid.MustParse(args[1]))
20+
if err != nil {
21+
log.Fatal(err)
22+
}
23+
24+
output.Format(cmd, r.Body, r.StatusCode())
25+
},
26+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package cron_jobs
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 ListPlanWebsiteCmd = &cobra.Command{
14+
Use: "list-plan-website <website_uid>",
15+
Short: "List Agency Plan website cron jobs",
16+
Long: "Returns a paginated list of cron jobs configured for an Agency Plan website.\n\nEach entry includes the schedule expression and the command executed on that schedule.",
17+
Args: cobra.MatchAll(cobra.ExactArgs(1)),
18+
Run: func(cmd *cobra.Command, args []string) {
19+
r, err := api.Request().AgencyHostingListAgencyPlanWebsiteCronJobsV1WithResponse(context.TODO(), args[0], listPlanWebsiteParams(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+
ListPlanWebsiteCmd.Flags().IntP("page", "", 0, "Page number")
30+
ListPlanWebsiteCmd.Flags().IntP("per-page", "", 25, "Number of items per page")
31+
}
32+
33+
func listPlanWebsiteParams(cmd *cobra.Command) *client.AgencyHostingListAgencyPlanWebsiteCronJobsV1Params {
34+
params := &client.AgencyHostingListAgencyPlanWebsiteCronJobsV1Params{}
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+
}

docs/hostinger_agency-hosting.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Agency Hosting commands
1818
### SEE ALSO
1919

2020
* [hostinger](hostinger.md) - Hostinger API Command Line Interface
21+
* [hostinger agency-hosting cron-jobs](hostinger_agency-hosting_cron-jobs.md) - Cron Jobs commands
2122
* [hostinger agency-hosting datacenters](hostinger_agency-hosting_datacenters.md) - Datacenters commands
2223
* [hostinger agency-hosting domains](hostinger_agency-hosting_domains.md) - Domains commands
2324
* [hostinger agency-hosting files](hostinger_agency-hosting_files.md) - Files commands
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
## hostinger agency-hosting cron-jobs
2+
3+
Cron Jobs commands
4+
5+
### Options
6+
7+
```
8+
-h, --help help for cron-jobs
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 agency-hosting](hostinger_agency-hosting.md) - Agency Hosting commands
21+
* [hostinger agency-hosting cron-jobs create-plan-website](hostinger_agency-hosting_cron-jobs_create-plan-website.md) - Create Agency Plan website cron job
22+
* [hostinger agency-hosting cron-jobs delete-plan-website](hostinger_agency-hosting_cron-jobs_delete-plan-website.md) - Delete Agency Plan website cron job
23+
* [hostinger agency-hosting cron-jobs list-plan-website](hostinger_agency-hosting_cron-jobs_list-plan-website.md) - List Agency Plan website cron jobs
24+
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
## hostinger agency-hosting cron-jobs create-plan-website
2+
3+
Create Agency Plan website cron job
4+
5+
### Synopsis
6+
7+
Creates a cron job for an Agency Plan website from a schedule expression and a command.
8+
9+
Returns the created cron job, including its uuid, which is required to delete the cron job.
10+
11+
```
12+
hostinger agency-hosting cron-jobs create-plan-website <website_uid> [flags]
13+
```
14+
15+
### Options
16+
17+
```
18+
--command string Command to run on the schedule. Must not contain pipe (|) or redirection (<, >) characters.
19+
-h, --help help for create-plan-website
20+
--time string Cron schedule expression (standard 5-field crontab syntax).
21+
```
22+
23+
### Options inherited from parent commands
24+
25+
```
26+
--config string Config file (default is $HOME/.hostinger.yaml)
27+
--format string Output format type (json|table|tree), default: table
28+
```
29+
30+
### SEE ALSO
31+
32+
* [hostinger agency-hosting cron-jobs](hostinger_agency-hosting_cron-jobs.md) - Cron Jobs commands
33+
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
## hostinger agency-hosting cron-jobs delete-plan-website
2+
3+
Delete Agency Plan website cron job
4+
5+
### Synopsis
6+
7+
Permanently deletes the cron job identified by its uuid from an Agency Plan website.
8+
9+
The operation is idempotent: deleting a cron job that does not exist succeeds without error.
10+
11+
```
12+
hostinger agency-hosting cron-jobs delete-plan-website <website_uid> <uuid> [flags]
13+
```
14+
15+
### Options
16+
17+
```
18+
-h, --help help for delete-plan-website
19+
```
20+
21+
### Options inherited from parent commands
22+
23+
```
24+
--config string Config file (default is $HOME/.hostinger.yaml)
25+
--format string Output format type (json|table|tree), default: table
26+
```
27+
28+
### SEE ALSO
29+
30+
* [hostinger agency-hosting cron-jobs](hostinger_agency-hosting_cron-jobs.md) - Cron Jobs commands
31+

0 commit comments

Comments
 (0)