Skip to content

Commit a09dee0

Browse files
authored
feat(tem): add support for offer commands (#4592)
1 parent f955c33 commit a09dee0

7 files changed

+201
-6
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲
2+
🟥🟥🟥 STDERR️️ 🟥🟥🟥️
3+
Retrieve the list of the available and free-of-charge offers you can subscribe to.
4+
5+
USAGE:
6+
scw tem offers list [arg=value ...]
7+
8+
ARGS:
9+
[region=fr-par] Region to target. If none is passed will use default region from the config (fr-par)
10+
11+
FLAGS:
12+
-h, --help help for list
13+
14+
GLOBAL FLAGS:
15+
-c, --config string The path to the config file
16+
-D, --debug Enable debug mode
17+
-o, --output string Output format: json or human, see 'scw help output' for more info (default "human")
18+
-p, --profile string The config profile to use
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲
2+
🟥🟥🟥 STDERR️️ 🟥🟥🟥️
3+
Update a subscribed offer.
4+
5+
USAGE:
6+
scw tem offers update [arg=value ...]
7+
8+
ARGS:
9+
[project-id] Project ID to use. If none is passed the default project ID will be used
10+
[name] Name of the offer-subscription (unknown_name | essential | scale)
11+
[region=fr-par] Region to target. If none is passed will use default region from the config (fr-par)
12+
13+
FLAGS:
14+
-h, --help help for update
15+
16+
GLOBAL FLAGS:
17+
-c, --config string The path to the config file
18+
-D, --debug Enable debug mode
19+
-o, --output string Output format: json or human, see 'scw help output' for more info (default "human")
20+
-p, --profile string The config profile to use

cmd/scw/testdata/test-all-usage-tem-offers-usage.golden

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@
33
This section allows you to manage and get get subscribed information about your project email offer.
44

55
USAGE:
6-
scw tem offers
6+
scw tem offers <command>
7+
8+
AVAILABLE COMMANDS:
9+
list List the available offers.
10+
update Update a subscribed offer
711

812
FLAGS:
913
-h, --help help for offers
@@ -13,3 +17,5 @@ GLOBAL FLAGS:
1317
-D, --debug Enable debug mode
1418
-o, --output string Output format: json or human, see 'scw help output' for more info (default "human")
1519
-p, --profile string The config profile to use
20+
21+
Use "scw tem offers [command] --help" for more information about a command.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲
2+
🟥🟥🟥 STDERR️️ 🟥🟥🟥️
3+
Get project resource consumption.
4+
5+
USAGE:
6+
scw tem project-consumption get [arg=value ...]
7+
8+
ARGS:
9+
[project-id] Project ID to use. If none is passed the default project ID will be used
10+
[region=fr-par] Region to target. If none is passed will use default region from the config (fr-par)
11+
12+
FLAGS:
13+
-h, --help help for get
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

cmd/scw/testdata/test-all-usage-tem-project-consumption-usage.golden

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
Project consumption allow you to see your project consumption.
44

55
USAGE:
6-
scw tem project-consumption
6+
scw tem project-consumption <command>
7+
8+
AVAILABLE COMMANDS:
9+
get Get project resource consumption.
710

811
FLAGS:
912
-h, --help help for project-consumption
@@ -13,3 +16,5 @@ GLOBAL FLAGS:
1316
-D, --debug Enable debug mode
1417
-o, --output string Output format: json or human, see 'scw help output' for more info (default "human")
1518
-p, --profile string The config profile to use
19+
20+
Use "scw tem project-consumption [command] --help" for more information about a command.

docs/commands/tem.md

Lines changed: 49 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@ This API allows you to manage your Transactional Email services.
2121
- [Email statuses](#email-statuses)
2222
- [List emails](#list-emails)
2323
- [Project offers management commands](#project-offers-management-commands)
24+
- [List the available offers.](#list-the-available-offers.)
25+
- [Update a subscribed offer](#update-a-subscribed-offer)
2426
- [Project consumption management commands](#project-consumption-management-commands)
27+
- [Get project resource consumption.](#get-project-resource-consumption.)
2528
- [Project settings management commands](#project-settings-management-commands)
2629
- [Webhook management commands](#webhook-management-commands)
2730
- [Create a Webhook](#create-a-webhook)
@@ -398,29 +401,71 @@ scw tem email list [arg=value ...]
398401

399402
This section allows you to manage and get get subscribed information about your project email offer.
400403

401-
This section allows you to manage and get get subscribed information about your project email offer.
404+
405+
### List the available offers.
406+
407+
Retrieve the list of the available and free-of-charge offers you can subscribe to.
408+
409+
**Usage:**
410+
411+
```
412+
scw tem offers list [arg=value ...]
413+
```
414+
415+
416+
**Args:**
417+
418+
| Name | | Description |
419+
|------|---|-------------|
420+
| region | Default: `fr-par`<br />One of: `fr-par` | Region to target. If none is passed will use default region from the config |
421+
422+
423+
424+
### Update a subscribed offer
425+
426+
Update a subscribed offer.
402427

403428
**Usage:**
404429

405430
```
406-
scw tem offers
431+
scw tem offers update [arg=value ...]
407432
```
408433

409434

435+
**Args:**
436+
437+
| Name | | Description |
438+
|------|---|-------------|
439+
| project-id | | Project ID to use. If none is passed the default project ID will be used |
440+
| name | One of: `unknown_name`, `essential`, `scale` | Name of the offer-subscription |
441+
| region | Default: `fr-par`<br />One of: `fr-par` | Region to target. If none is passed will use default region from the config |
442+
443+
410444

411445
## Project consumption management commands
412446

413447
Project consumption allow you to see your project consumption.
414448

415-
Project consumption allow you to see your project consumption.
449+
450+
### Get project resource consumption.
451+
452+
Get project resource consumption.
416453

417454
**Usage:**
418455

419456
```
420-
scw tem project-consumption
457+
scw tem project-consumption get [arg=value ...]
421458
```
422459

423460

461+
**Args:**
462+
463+
| Name | | Description |
464+
|------|---|-------------|
465+
| project-id | | Project ID to use. If none is passed the default project ID will be used |
466+
| region | Default: `fr-par`<br />One of: `fr-par` | Region to target. If none is passed will use default region from the config |
467+
468+
424469

425470
## Project settings management commands
426471

internal/namespaces/tem/v1alpha1/tem_cli.go

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ func GetGeneratedCommands() *core.Commands {
4848
temBlocklistsList(),
4949
temBlocklistsCreate(),
5050
temBlocklistsDelete(),
51+
temOffersUpdate(),
52+
temOffersList(),
53+
temProjectConsumptionGet(),
5154
)
5255
}
5356
func temRoot() *core.Command {
@@ -1250,3 +1253,82 @@ func temBlocklistsDelete() *core.Command {
12501253
},
12511254
}
12521255
}
1256+
1257+
func temOffersUpdate() *core.Command {
1258+
return &core.Command{
1259+
Short: `Update a subscribed offer`,
1260+
Long: `Update a subscribed offer.`,
1261+
Namespace: "tem",
1262+
Resource: "offers",
1263+
Verb: "update",
1264+
// Deprecated: false,
1265+
ArgsType: reflect.TypeOf(tem.UpdateOfferSubscriptionRequest{}),
1266+
ArgSpecs: core.ArgSpecs{
1267+
core.ProjectIDArgSpec(),
1268+
{
1269+
Name: "name",
1270+
Short: `Name of the offer-subscription`,
1271+
Required: false,
1272+
Deprecated: false,
1273+
Positional: false,
1274+
EnumValues: []string{"unknown_name", "essential", "scale"},
1275+
},
1276+
core.RegionArgSpec(scw.RegionFrPar),
1277+
},
1278+
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
1279+
request := args.(*tem.UpdateOfferSubscriptionRequest)
1280+
1281+
client := core.ExtractClient(ctx)
1282+
api := tem.NewAPI(client)
1283+
return api.UpdateOfferSubscription(request)
1284+
1285+
},
1286+
}
1287+
}
1288+
1289+
func temOffersList() *core.Command {
1290+
return &core.Command{
1291+
Short: `List the available offers.`,
1292+
Long: `Retrieve the list of the available and free-of-charge offers you can subscribe to.`,
1293+
Namespace: "tem",
1294+
Resource: "offers",
1295+
Verb: "list",
1296+
// Deprecated: false,
1297+
ArgsType: reflect.TypeOf(tem.ListOffersRequest{}),
1298+
ArgSpecs: core.ArgSpecs{
1299+
core.RegionArgSpec(scw.RegionFrPar),
1300+
},
1301+
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
1302+
request := args.(*tem.ListOffersRequest)
1303+
1304+
client := core.ExtractClient(ctx)
1305+
api := tem.NewAPI(client)
1306+
return api.ListOffers(request)
1307+
1308+
},
1309+
}
1310+
}
1311+
1312+
func temProjectConsumptionGet() *core.Command {
1313+
return &core.Command{
1314+
Short: `Get project resource consumption.`,
1315+
Long: `Get project resource consumption.`,
1316+
Namespace: "tem",
1317+
Resource: "project-consumption",
1318+
Verb: "get",
1319+
// Deprecated: false,
1320+
ArgsType: reflect.TypeOf(tem.GetProjectConsumptionRequest{}),
1321+
ArgSpecs: core.ArgSpecs{
1322+
core.ProjectIDArgSpec(),
1323+
core.RegionArgSpec(scw.RegionFrPar),
1324+
},
1325+
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
1326+
request := args.(*tem.GetProjectConsumptionRequest)
1327+
1328+
client := core.ExtractClient(ctx)
1329+
api := tem.NewAPI(client)
1330+
return api.GetProjectConsumption(request)
1331+
1332+
},
1333+
}
1334+
}

0 commit comments

Comments
 (0)