Skip to content

Commit 763e604

Browse files
feat: regenerate CLI from OpenAPI spec
BREAKING CHANGE: regenerated from a breaking OpenAPI spec change
1 parent 2e93b64 commit 763e604

8 files changed

Lines changed: 777 additions & 68 deletions

‎client/client.gen.go‎

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

‎cmd/wordpress/ai_content/ai_content.go‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@ var GroupCmd = &cobra.Command{
1111

1212
func init() {
1313
GroupCmd.AddCommand(GenerateImagesCmd)
14+
GroupCmd.AddCommand(GenerationResultCmd)
1415
}

‎cmd/wordpress/ai_content/generate_images.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import (
1515
var GenerateImagesCmd = &cobra.Command{
1616
Use: "generate-images <username> <software>",
1717
Short: "Generate images",
18-
Long: "Generate one or more images from a prompt and an image type for the specified\nWordPress installation. Images are returned inline as base64-encoded PNGs. They match\nthe requested aspect ratio and are never smaller than the requested size; logos are\ntransparent PNGs cropped to the mark.\n\nGeneration is synchronous and can take up to a minute. The endpoint is limited to\n10 requests per minute.\n\nProvide the WordPress installation (software) identifier in the path. It can\nbe obtained from GET /api/hosting/v1/wordpress/installations (the `id` field).",
18+
Long: "Start generating one or more images from a prompt and an image type for the specified\nWordPress installation. The generation runs asynchronously: the response is returned\nright away with `status: in-progress` and a `generation_id`. Poll\nGET /api/hosting/v1/accounts/{username}/wordpress/{software}/content/generations/{generation_id}\nevery few seconds until `status` is `completed` or `failed`.\n\nA completed generation returns temporary image URLs together with the time they expire;\ndownload the images before then. Images match the requested aspect ratio and are never\nsmaller than the requested size; logos are transparent images cropped to the mark.\n\nOnly one image generation can run per installation at a time: while one is still in\nprogress the endpoint returns 409 without the ID of the running generation, so a caller\nthat did not receive the `202` has to wait for it to finish (up to a few minutes) before\nstarting a new one. The endpoint is limited to 10 requests per minute.\n\nProvide the WordPress installation (software) identifier in the path. It can\nbe obtained from GET /api/hosting/v1/wordpress/installations (the `id` field).",
1919
Args: cobra.MatchAll(cobra.ExactArgs(2)),
2020
Run: func(cmd *cobra.Command, args []string) {
2121
utils.EnumCheck(cmd, "image-type", []string{"hero", "background", "inline", "gallery", "product", "logo"})
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package ai_content
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/client"
10+
"github.com/hostinger/api-cli/output"
11+
"github.com/hostinger/api-cli/utils"
12+
"github.com/spf13/cobra"
13+
)
14+
15+
var GenerationResultCmd = &cobra.Command{
16+
Use: "generation-result <username> <software> <generation_id>",
17+
Short: "Get generation result",
18+
Long: "Get the result of an AI content generation started for the specified WordPress\ninstallation, such as an image generation started with\nPOST /api/hosting/v1/accounts/{username}/wordpress/{software}/content/images/generate.\n\nWhile the generation is still running only `status: in-progress` is returned; poll every\nfew seconds. Once `completed`, `result` holds the generated content shaped according to\n`type`: temporary image URLs together with the time they expire for `image-generation`, or\nthe generated website document for `website-generation` (started from the Hostinger\nWordPress plugin). A `failed` generation has no `result`. Unknown or expired generation\nIDs return 404.\n\nProvide the WordPress installation (software) identifier in the path. It can\nbe obtained from GET /api/hosting/v1/wordpress/installations (the `id` field).",
19+
Args: cobra.MatchAll(cobra.ExactArgs(3)),
20+
Run: func(cmd *cobra.Command, args []string) {
21+
utils.EnumCheck(cmd, "type", []string{"website-generation", "image-generation"})
22+
r, err := api.Request().HostingGetGenerationResultV1WithResponse(context.TODO(), args[0], args[1], uuid.MustParse(args[2]), generationResultParams(cmd))
23+
if err != nil {
24+
log.Fatal(err)
25+
}
26+
27+
output.Format(cmd, r.Body, r.StatusCode())
28+
},
29+
}
30+
31+
func init() {
32+
GenerationResultCmd.Flags().StringP("type", "", "", "Generation type to look up. When omitted, every generation type is checked. (one of: website-generation, image-generation)")
33+
}
34+
35+
func generationResultParams(cmd *cobra.Command) *client.HostingGetGenerationResultV1Params {
36+
params := &client.HostingGetGenerationResultV1Params{}
37+
if cmd.Flags().Changed("type") {
38+
v, _ := cmd.Flags().GetString("type")
39+
e := client.HostingGetGenerationResultV1ParamsType(v)
40+
params.Type = &e
41+
}
42+
return params
43+
}

‎docs/hostinger_wordpress_ai-content.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,5 @@ AI Content commands
1919

2020
* [hostinger wordpress](hostinger_wordpress.md) - WordPress commands
2121
* [hostinger wordpress ai-content generate-images](hostinger_wordpress_ai-content_generate-images.md) - Generate images
22+
* [hostinger wordpress ai-content generation-result](hostinger_wordpress_ai-content_generation-result.md) - Get generation result
2223

‎docs/hostinger_wordpress_ai-content_generate-images.md‎

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,20 @@ Generate images
44

55
### Synopsis
66

7-
Generate one or more images from a prompt and an image type for the specified
8-
WordPress installation. Images are returned inline as base64-encoded PNGs. They match
9-
the requested aspect ratio and are never smaller than the requested size; logos are
10-
transparent PNGs cropped to the mark.
11-
12-
Generation is synchronous and can take up to a minute. The endpoint is limited to
13-
10 requests per minute.
7+
Start generating one or more images from a prompt and an image type for the specified
8+
WordPress installation. The generation runs asynchronously: the response is returned
9+
right away with `status: in-progress` and a `generation_id`. Poll
10+
GET /api/hosting/v1/accounts/{username}/wordpress/{software}/content/generations/{generation_id}
11+
every few seconds until `status` is `completed` or `failed`.
12+
13+
A completed generation returns temporary image URLs together with the time they expire;
14+
download the images before then. Images match the requested aspect ratio and are never
15+
smaller than the requested size; logos are transparent images cropped to the mark.
16+
17+
Only one image generation can run per installation at a time: while one is still in
18+
progress the endpoint returns 409 without the ID of the running generation, so a caller
19+
that did not receive the `202` has to wait for it to finish (up to a few minutes) before
20+
starting a new one. The endpoint is limited to 10 requests per minute.
1421

1522
Provide the WordPress installation (software) identifier in the path. It can
1623
be obtained from GET /api/hosting/v1/wordpress/installations (the `id` field).
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
## hostinger wordpress ai-content generation-result
2+
3+
Get generation result
4+
5+
### Synopsis
6+
7+
Get the result of an AI content generation started for the specified WordPress
8+
installation, such as an image generation started with
9+
POST /api/hosting/v1/accounts/{username}/wordpress/{software}/content/images/generate.
10+
11+
While the generation is still running only `status: in-progress` is returned; poll every
12+
few seconds. Once `completed`, `result` holds the generated content shaped according to
13+
`type`: temporary image URLs together with the time they expire for `image-generation`, or
14+
the generated website document for `website-generation` (started from the Hostinger
15+
WordPress plugin). A `failed` generation has no `result`. Unknown or expired generation
16+
IDs return 404.
17+
18+
Provide the WordPress installation (software) identifier in the path. It can
19+
be obtained from GET /api/hosting/v1/wordpress/installations (the `id` field).
20+
21+
```
22+
hostinger wordpress ai-content generation-result <username> <software> <generation_id> [flags]
23+
```
24+
25+
### Options
26+
27+
```
28+
-h, --help help for generation-result
29+
--type string Generation type to look up. When omitted, every generation type is checked. (one of: website-generation, image-generation)
30+
```
31+
32+
### Options inherited from parent commands
33+
34+
```
35+
--config string Config file (default is $HOME/.hostinger.yaml)
36+
--format string Output format type (json|table|tree), default: table
37+
```
38+
39+
### SEE ALSO
40+
41+
* [hostinger wordpress ai-content](hostinger_wordpress_ai-content.md) - AI Content commands
42+

‎manifest.json‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1194,6 +1194,11 @@
11941194
"method": "GET",
11951195
"path": "/api/hosting/v1/accounts/{username}/cron-jobs/{uid}/output"
11961196
},
1197+
"hosting_getGenerationResultV1": {
1198+
"command": "hostinger wordpress ai-content generation-result",
1199+
"method": "GET",
1200+
"path": "/api/hosting/v1/accounts/{username}/wordpress/{software}/content/generations/{generation_id}"
1201+
},
11971202
"hosting_getGitAutoDeploymentSettingsV1": {
11981203
"command": "hostinger hosting git auto-deployment-settings",
11991204
"method": "GET",

0 commit comments

Comments
 (0)