Skip to content

Commit f5525cf

Browse files
feat(product_catalog): add support for cli (#5420)
Co-authored-by: Estelle Soulard <esoulard@scaleway.com>
1 parent df5c76c commit f5525cf

File tree

8 files changed

+266
-0
lines changed

8 files changed

+266
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲
2+
🟥🟥🟥 STDERR️️ 🟥🟥🟥️
3+
List all available products in the Scaleway catalog. Returns a complete list of products with their corresponding description, locations, prices and properties. You can define the `page` number and `page_size` for your query in the request.
4+
5+
USAGE:
6+
scw product-catalog product list [arg=value ...]
7+
8+
ARGS:
9+
[product-types.{index}] The list of filtered product categories. (unknown_product_type | instance | apple_silicon | elastic_metal | dedibox | block_storage | object_storage | managed_inference | generative_apis | load_balancer | secret_manager | key_manager | managed_redis_database | kubernetes | managed_relational_database | managed_mongodb)
10+
[global] Filter global products.
11+
[region] Filter products by region.
12+
[zone] Filter products by zone.
13+
[datacenter] Filter products by datacenter.
14+
[status.{index}] The lists of filtered product status, if empty only products with status public_beta, general_availability, preview, end_of_new_features, end_of_growth, end_of_deployment, end_of_support, end_of_sale, end_of_life or retired will be returned. (unknown_status | public_beta | preview | general_availability | end_of_new_features | end_of_growth | end_of_deployment | end_of_support | end_of_sale | end_of_life | retired)
15+
16+
FLAGS:
17+
-h, --help help for list
18+
--list-sub-commands List all subcommands
19+
20+
GLOBAL FLAGS:
21+
-c, --config string The path to the config file
22+
-D, --debug Enable debug mode
23+
-o, --output string Output format: json or human, see 'scw help output' for more info (default "human")
24+
-p, --profile string The config profile to use
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲
2+
🟥🟥🟥 STDERR️️ 🟥🟥🟥️
3+
Scaleway's Product Catalog is an extensive list of the Scaleway products.
4+
The catalog includes details about each product including: description,
5+
locations, prices and properties.
6+
7+
USAGE:
8+
scw product-catalog product <command>
9+
10+
AVAILABLE COMMANDS:
11+
list List all available products
12+
13+
FLAGS:
14+
-h, --help help for product
15+
--list-sub-commands List all subcommands
16+
17+
GLOBAL FLAGS:
18+
-c, --config string The path to the config file
19+
-D, --debug Enable debug mode
20+
-o, --output string Output format: json or human, see 'scw help output' for more info (default "human")
21+
-p, --profile string The config profile to use
22+
23+
Use "scw product-catalog product [command] --help" for more information about a command.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲
2+
🟥🟥🟥 STDERR️️ 🟥🟥🟥️
3+
Product Catalog API
4+
5+
USAGE:
6+
scw product-catalog <command>
7+
8+
AVAILABLE COMMANDS:
9+
product Scaleway Product Catalog API
10+
11+
FLAGS:
12+
-h, --help help for product-catalog
13+
--list-sub-commands List all subcommands
14+
15+
GLOBAL FLAGS:
16+
-c, --config string The path to the config file
17+
-D, --debug Enable debug mode
18+
-o, --output string Output format: json or human, see 'scw help output' for more info (default "human")
19+
-p, --profile string The config profile to use
20+
21+
Use "scw product-catalog [command] --help" for more information about a command.

cmd/scw/testdata/test-main-usage-usage.golden

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ AVAILABLE COMMANDS:
1010
datalab Data Lab API for Apache Spark™
1111
domain Domains and DNS - Registrar API
1212
environmental-footprint Access and download impact reports and impact data for your Scaleway projects. Our API provides key metrics such as estimated carbon emissions and water usage to help monitor your environmental footprint.
13+
product-catalog Product Catalog API
1314

1415
BAREMETAL COMMANDS:
1516
apple-silicon Apple silicon API

commands/commands.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ import (
4444
mongodb "github.com/scaleway/scaleway-cli/v2/internal/namespaces/mongodb/v1alpha1"
4545
"github.com/scaleway/scaleway-cli/v2/internal/namespaces/object/v1"
4646
"github.com/scaleway/scaleway-cli/v2/internal/namespaces/partner/v1"
47+
product_catalog "github.com/scaleway/scaleway-cli/v2/internal/namespaces/product_catalog/v2alpha1"
4748
"github.com/scaleway/scaleway-cli/v2/internal/namespaces/rdb/v1"
4849
"github.com/scaleway/scaleway-cli/v2/internal/namespaces/redis/v1"
4950
"github.com/scaleway/scaleway-cli/v2/internal/namespaces/registry/v1"
@@ -122,6 +123,7 @@ func GetCommands() *core.Commands {
122123
datawarehouse.GetCommands(),
123124
partner.GetCommands(),
124125
environmental_footprint.GetCommands(),
126+
product_catalog.GetCommands(),
125127
)
126128

127129
if beta {

docs/commands/product-catalog.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<!-- DO NOT EDIT: this file is automatically generated using scw-doc-gen -->
2+
# Documentation for `scw product-catalog`
3+
Product Catalog API
4+
5+
- [Scaleway Product Catalog API](#scaleway-product-catalog-api)
6+
- [List all available products](#list-all-available-products)
7+
8+
9+
## Scaleway Product Catalog API
10+
11+
Scaleway's Product Catalog is an extensive list of the Scaleway products.
12+
The catalog includes details about each product including: description,
13+
locations, prices and properties.
14+
15+
16+
### List all available products
17+
18+
List all available products in the Scaleway catalog. Returns a complete list of products with their corresponding description, locations, prices and properties. You can define the `page` number and `page_size` for your query in the request.
19+
20+
**Usage:**
21+
22+
```
23+
scw product-catalog product list [arg=value ...]
24+
```
25+
26+
27+
**Args:**
28+
29+
| Name | | Description |
30+
|------|---|-------------|
31+
| product-types.{index} | One of: `unknown_product_type`, `instance`, `apple_silicon`, `elastic_metal`, `dedibox`, `block_storage`, `object_storage`, `managed_inference`, `generative_apis`, `load_balancer`, `secret_manager`, `key_manager`, `managed_redis_database`, `kubernetes`, `managed_relational_database`, `managed_mongodb` | The list of filtered product categories. |
32+
| global | | Filter global products. |
33+
| region | | Filter products by region. |
34+
| zone | | Filter products by zone. |
35+
| datacenter | | Filter products by datacenter. |
36+
| status.{index} | One of: `unknown_status`, `public_beta`, `preview`, `general_availability`, `end_of_new_features`, `end_of_growth`, `end_of_deployment`, `end_of_support`, `end_of_sale`, `end_of_life`, `retired` | The lists of filtered product status, if empty only products with status public_beta, general_availability, preview, end_of_new_features, end_of_growth, end_of_deployment, end_of_support, end_of_sale, end_of_life or retired will be returned. |
37+
38+
39+
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package product_catalog
2+
3+
import "github.com/scaleway/scaleway-cli/v2/core"
4+
5+
func GetCommands() *core.Commands {
6+
cmds := GetGeneratedCommands()
7+
8+
return cmds
9+
}
Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
// This file was automatically generated. DO NOT EDIT.
2+
// If you have any remark or suggestion do not hesitate to open an issue.
3+
4+
package product_catalog
5+
6+
import (
7+
"context"
8+
"reflect"
9+
10+
"github.com/scaleway/scaleway-cli/v2/core"
11+
product_catalog "github.com/scaleway/scaleway-sdk-go/api/product_catalog/v2alpha1"
12+
"github.com/scaleway/scaleway-sdk-go/scw"
13+
)
14+
15+
// always import dependencies
16+
var (
17+
_ = scw.RegionFrPar
18+
)
19+
20+
func GetGeneratedCommands() *core.Commands {
21+
return core.NewCommands(
22+
productCatalogRoot(),
23+
productCatalogProduct(),
24+
productCatalogProductList(),
25+
)
26+
}
27+
28+
func productCatalogRoot() *core.Command {
29+
return &core.Command{
30+
Short: `Product Catalog API`,
31+
Long: ``,
32+
Namespace: "product-catalog",
33+
}
34+
}
35+
36+
func productCatalogProduct() *core.Command {
37+
return &core.Command{
38+
Short: `Scaleway Product Catalog API`,
39+
Long: `Scaleway's Product Catalog is an extensive list of the Scaleway products.
40+
The catalog includes details about each product including: description,
41+
locations, prices and properties.`,
42+
Namespace: "product-catalog",
43+
Resource: "product",
44+
}
45+
}
46+
47+
func productCatalogProductList() *core.Command {
48+
return &core.Command{
49+
Short: `List all available products`,
50+
Long: `List all available products in the Scaleway catalog. Returns a complete list of products with their corresponding description, locations, prices and properties. You can define the ` + "`" + `page` + "`" + ` number and ` + "`" + `page_size` + "`" + ` for your query in the request.`,
51+
Namespace: "product-catalog",
52+
Resource: "product",
53+
Verb: "list",
54+
// Deprecated: false,
55+
ArgsType: reflect.TypeOf(
56+
product_catalog.PublicCatalogAPIListPublicCatalogProductsRequest{},
57+
),
58+
ArgSpecs: core.ArgSpecs{
59+
{
60+
Name: "product-types.{index}",
61+
Short: `The list of filtered product categories.`,
62+
Required: false,
63+
Deprecated: false,
64+
Positional: false,
65+
EnumValues: []string{
66+
"unknown_product_type",
67+
"instance",
68+
"apple_silicon",
69+
"elastic_metal",
70+
"dedibox",
71+
"block_storage",
72+
"object_storage",
73+
"managed_inference",
74+
"generative_apis",
75+
"load_balancer",
76+
"secret_manager",
77+
"key_manager",
78+
"managed_redis_database",
79+
"kubernetes",
80+
"managed_relational_database",
81+
"managed_mongodb",
82+
},
83+
},
84+
{
85+
Name: "global",
86+
Short: `Filter global products.`,
87+
Required: false,
88+
Deprecated: false,
89+
Positional: false,
90+
},
91+
{
92+
Name: "region",
93+
Short: `Filter products by region.`,
94+
Required: false,
95+
Deprecated: false,
96+
Positional: false,
97+
},
98+
{
99+
Name: "zone",
100+
Short: `Filter products by zone.`,
101+
Required: false,
102+
Deprecated: false,
103+
Positional: false,
104+
},
105+
{
106+
Name: "datacenter",
107+
Short: `Filter products by datacenter.`,
108+
Required: false,
109+
Deprecated: false,
110+
Positional: false,
111+
},
112+
{
113+
Name: "status.{index}",
114+
Short: `The lists of filtered product status, if empty only products with status public_beta, general_availability, preview, end_of_new_features, end_of_growth, end_of_deployment, end_of_support, end_of_sale, end_of_life or retired will be returned.`,
115+
Required: false,
116+
Deprecated: false,
117+
Positional: false,
118+
EnumValues: []string{
119+
"unknown_status",
120+
"public_beta",
121+
"preview",
122+
"general_availability",
123+
"end_of_new_features",
124+
"end_of_growth",
125+
"end_of_deployment",
126+
"end_of_support",
127+
"end_of_sale",
128+
"end_of_life",
129+
"retired",
130+
},
131+
},
132+
},
133+
Run: func(ctx context.Context, args any) (i any, e error) {
134+
request := args.(*product_catalog.PublicCatalogAPIListPublicCatalogProductsRequest)
135+
136+
client := core.ExtractClient(ctx)
137+
api := product_catalog.NewPublicCatalogAPI(client)
138+
opts := []scw.RequestOption{scw.WithAllPages()}
139+
resp, err := api.ListPublicCatalogProducts(request, opts...)
140+
if err != nil {
141+
return nil, err
142+
}
143+
144+
return resp.Products, nil
145+
},
146+
}
147+
}

0 commit comments

Comments
 (0)