Skip to content

Commit 2357ecb

Browse files
feat(rdb): add GetInstanceLogs method (#1220)
Co-authored-by: Rémy Léone <[email protected]>
1 parent 1fde5b3 commit 2357ecb

File tree

4 files changed

+53
-2
lines changed

4 files changed

+53
-2
lines changed
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 specific logs of a given instance.
4+
5+
USAGE:
6+
scw rdb log get <instance-log-id ...> [arg=value ...]
7+
8+
ARGS:
9+
instance-log-id UUID of the instance_log you want
10+
[region=fr-par] Region to target. If none is passed will use default region from the config (fr-par | nl-ams)
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-rdb-log-list-usage.golden

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ USAGE:
66
scw rdb log list <instance-id ...> [arg=value ...]
77

88
ARGS:
9-
instance-id
10-
[order-by] (created_at_asc | created_at_desc)
9+
instance-id UUID of the instance you want logs of
10+
[order-by] Criteria to use when ordering instance logs listing (created_at_asc | created_at_desc)
1111
[region=fr-par] Region to target. If none is passed will use default region from the config (fr-par | nl-ams)
1212

1313
FLAGS:

cmd/scw/testdata/test-all-usage-rdb-log-usage.golden

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ USAGE:
66
scw rdb log <command>
77

88
AVAILABLE COMMANDS:
9+
get Get specific logs of a given instance
910
list List available logs of a given instance
1011
prepare Prepare logs of a given instance
1112

internal/namespaces/rdb/v1/rdb_cli.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ func GetGeneratedCommands() *core.Commands {
4848
rdbInstanceGetCertificate(),
4949
rdbLogPrepare(),
5050
rdbLogList(),
51+
rdbLogGet(),
5152
rdbInstanceGetMetrics(),
5253
rdbSettingsAdd(),
5354
rdbSettingsDelete(),
@@ -887,11 +888,13 @@ func rdbLogList() *core.Command {
887888
ArgSpecs: core.ArgSpecs{
888889
{
889890
Name: "instance-id",
891+
Short: `UUID of the instance you want logs of`,
890892
Required: true,
891893
Positional: true,
892894
},
893895
{
894896
Name: "order-by",
897+
Short: `Criteria to use when ordering instance logs listing`,
895898
Required: false,
896899
Positional: false,
897900
EnumValues: []string{"created_at_asc", "created_at_desc"},
@@ -909,6 +912,34 @@ func rdbLogList() *core.Command {
909912
}
910913
}
911914

915+
func rdbLogGet() *core.Command {
916+
return &core.Command{
917+
Short: `Get specific logs of a given instance`,
918+
Long: `Get specific logs of a given instance.`,
919+
Namespace: "rdb",
920+
Resource: "log",
921+
Verb: "get",
922+
ArgsType: reflect.TypeOf(rdb.GetInstanceLogRequest{}),
923+
ArgSpecs: core.ArgSpecs{
924+
{
925+
Name: "instance-log-id",
926+
Short: `UUID of the instance_log you want`,
927+
Required: true,
928+
Positional: true,
929+
},
930+
core.RegionArgSpec(scw.RegionFrPar, scw.RegionNlAms),
931+
},
932+
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
933+
request := args.(*rdb.GetInstanceLogRequest)
934+
935+
client := core.ExtractClient(ctx)
936+
api := rdb.NewAPI(client)
937+
return api.GetInstanceLog(request)
938+
939+
},
940+
}
941+
}
942+
912943
func rdbInstanceGetMetrics() *core.Command {
913944
return &core.Command{
914945
Short: `Get instance metrics`,

0 commit comments

Comments
 (0)