diff --git a/cmd/scw/testdata/test-all-usage-function-cron-delete-usage.golden b/cmd/scw/testdata/test-all-usage-function-cron-delete-usage.golden new file mode 100644 index 0000000000..e9ce6653d1 --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-function-cron-delete-usage.golden @@ -0,0 +1,19 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +πŸŸ₯πŸŸ₯πŸŸ₯ STDERR️️ πŸŸ₯πŸŸ₯πŸŸ₯️ +Delete the cron associated with the given id. + +USAGE: + scw function cron delete [arg=value ...] + +ARGS: + cron-id + [region=fr-par] Region to target. If none is passed will use default region from the config (fr-par) + +FLAGS: + -h, --help help for delete + +GLOBAL FLAGS: + -c, --config string The path to the config file + -D, --debug Enable debug mode + -o, --output string Output format: json or human, see 'scw help output' for more info (default "human") + -p, --profile string The config profile to use diff --git a/cmd/scw/testdata/test-all-usage-function-cron-get-usage.golden b/cmd/scw/testdata/test-all-usage-function-cron-get-usage.golden new file mode 100644 index 0000000000..0b95d4b346 --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-function-cron-get-usage.golden @@ -0,0 +1,19 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +πŸŸ₯πŸŸ₯πŸŸ₯ STDERR️️ πŸŸ₯πŸŸ₯πŸŸ₯️ +Get the cron associated with the given id. + +USAGE: + scw function cron get [arg=value ...] + +ARGS: + cron-id + [region=fr-par] Region to target. If none is passed will use default region from the config (fr-par) + +FLAGS: + -h, --help help for get + +GLOBAL FLAGS: + -c, --config string The path to the config file + -D, --debug Enable debug mode + -o, --output string Output format: json or human, see 'scw help output' for more info (default "human") + -p, --profile string The config profile to use diff --git a/cmd/scw/testdata/test-all-usage-function-cron-list-usage.golden b/cmd/scw/testdata/test-all-usage-function-cron-list-usage.golden new file mode 100644 index 0000000000..b18f52e736 --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-function-cron-list-usage.golden @@ -0,0 +1,20 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +πŸŸ₯πŸŸ₯πŸŸ₯ STDERR️️ πŸŸ₯πŸŸ₯πŸŸ₯️ +List all your crons. + +USAGE: + scw function cron list [arg=value ...] + +ARGS: + [order-by] (created_at_asc | created_at_desc) + [function-id] + [region=fr-par] Region to target. If none is passed will use default region from the config (fr-par) + +FLAGS: + -h, --help help for list + +GLOBAL FLAGS: + -c, --config string The path to the config file + -D, --debug Enable debug mode + -o, --output string Output format: json or human, see 'scw help output' for more info (default "human") + -p, --profile string The config profile to use diff --git a/cmd/scw/testdata/test-all-usage-function-cron-usage.golden b/cmd/scw/testdata/test-all-usage-function-cron-usage.golden new file mode 100644 index 0000000000..69e1bfdc8d --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-function-cron-usage.golden @@ -0,0 +1,22 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +πŸŸ₯πŸŸ₯πŸŸ₯ STDERR️️ πŸŸ₯πŸŸ₯πŸŸ₯️ +Cron management commands. + +USAGE: + scw function cron + +AVAILABLE COMMANDS: + delete Delete an existing cron + get Get a cron + list List all your crons + +FLAGS: + -h, --help help for cron + +GLOBAL FLAGS: + -c, --config string The path to the config file + -D, --debug Enable debug mode + -o, --output string Output format: json or human, see 'scw help output' for more info (default "human") + -p, --profile string The config profile to use + +Use "scw function cron [command] --help" for more information about a command. diff --git a/cmd/scw/testdata/test-all-usage-function-function-create-usage.golden b/cmd/scw/testdata/test-all-usage-function-function-create-usage.golden new file mode 100644 index 0000000000..c51a2eeaf5 --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-function-function-create-usage.golden @@ -0,0 +1,30 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +πŸŸ₯πŸŸ₯πŸŸ₯ STDERR️️ πŸŸ₯πŸŸ₯πŸŸ₯️ +Create a new function. + +USAGE: + scw function function create [arg=value ...] + +ARGS: + [name=] + [namespace-id] + [environment-variables.value.{key}] + [min-scale] + [max-scale] + [runtime] (unknown_runtime | golang | python | python3 | node8 | node10 | node14) + [memory-limit] + [timeout.seconds] + [timeout.nanos] + [handler] + [privacy] (unknown_privacy | public | private) + [description] + [region=fr-par] Region to target. If none is passed will use default region from the config (fr-par) + +FLAGS: + -h, --help help for create + +GLOBAL FLAGS: + -c, --config string The path to the config file + -D, --debug Enable debug mode + -o, --output string Output format: json or human, see 'scw help output' for more info (default "human") + -p, --profile string The config profile to use diff --git a/cmd/scw/testdata/test-all-usage-function-function-delete-usage.golden b/cmd/scw/testdata/test-all-usage-function-function-delete-usage.golden new file mode 100644 index 0000000000..b4236b29a3 --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-function-function-delete-usage.golden @@ -0,0 +1,19 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +πŸŸ₯πŸŸ₯πŸŸ₯ STDERR️️ πŸŸ₯πŸŸ₯πŸŸ₯️ +Delete the function associated with the given id. + +USAGE: + scw function function delete [arg=value ...] + +ARGS: + function-id + [region=fr-par] Region to target. If none is passed will use default region from the config (fr-par) + +FLAGS: + -h, --help help for delete + +GLOBAL FLAGS: + -c, --config string The path to the config file + -D, --debug Enable debug mode + -o, --output string Output format: json or human, see 'scw help output' for more info (default "human") + -p, --profile string The config profile to use diff --git a/cmd/scw/testdata/test-all-usage-function-function-deploy-usage.golden b/cmd/scw/testdata/test-all-usage-function-function-deploy-usage.golden new file mode 100644 index 0000000000..e3f5b9b074 --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-function-function-deploy-usage.golden @@ -0,0 +1,19 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +πŸŸ₯πŸŸ₯πŸŸ₯ STDERR️️ πŸŸ₯πŸŸ₯πŸŸ₯️ +Deploy a function associated with the given id. + +USAGE: + scw function function deploy [arg=value ...] + +ARGS: + function-id + [region=fr-par] Region to target. If none is passed will use default region from the config (fr-par) + +FLAGS: + -h, --help help for deploy + +GLOBAL FLAGS: + -c, --config string The path to the config file + -D, --debug Enable debug mode + -o, --output string Output format: json or human, see 'scw help output' for more info (default "human") + -p, --profile string The config profile to use diff --git a/cmd/scw/testdata/test-all-usage-function-function-get-download-url-usage.golden b/cmd/scw/testdata/test-all-usage-function-function-get-download-url-usage.golden new file mode 100644 index 0000000000..93e70c5def --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-function-function-get-download-url-usage.golden @@ -0,0 +1,19 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +πŸŸ₯πŸŸ₯πŸŸ₯ STDERR️️ πŸŸ₯πŸŸ₯πŸŸ₯️ +Get a download URL for a function associated with the given id. + +USAGE: + scw function function get-download-url [arg=value ...] + +ARGS: + function-id + [region=fr-par] Region to target. If none is passed will use default region from the config (fr-par) + +FLAGS: + -h, --help help for get-download-url + +GLOBAL FLAGS: + -c, --config string The path to the config file + -D, --debug Enable debug mode + -o, --output string Output format: json or human, see 'scw help output' for more info (default "human") + -p, --profile string The config profile to use diff --git a/cmd/scw/testdata/test-all-usage-function-function-get-upload-url-usage.golden b/cmd/scw/testdata/test-all-usage-function-function-get-upload-url-usage.golden new file mode 100644 index 0000000000..ba8b70abc3 --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-function-function-get-upload-url-usage.golden @@ -0,0 +1,20 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +πŸŸ₯πŸŸ₯πŸŸ₯ STDERR️️ πŸŸ₯πŸŸ₯πŸŸ₯️ +Get an upload URL of a function associated with the given id. + +USAGE: + scw function function get-upload-url [arg=value ...] + +ARGS: + function-id + [content-length] + [region=fr-par] Region to target. If none is passed will use default region from the config (fr-par) + +FLAGS: + -h, --help help for get-upload-url + +GLOBAL FLAGS: + -c, --config string The path to the config file + -D, --debug Enable debug mode + -o, --output string Output format: json or human, see 'scw help output' for more info (default "human") + -p, --profile string The config profile to use diff --git a/cmd/scw/testdata/test-all-usage-function-function-get-usage.golden b/cmd/scw/testdata/test-all-usage-function-function-get-usage.golden new file mode 100644 index 0000000000..cd6125e0ca --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-function-function-get-usage.golden @@ -0,0 +1,19 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +πŸŸ₯πŸŸ₯πŸŸ₯ STDERR️️ πŸŸ₯πŸŸ₯πŸŸ₯️ +Get the function associated with the given id. + +USAGE: + scw function function get [arg=value ...] + +ARGS: + function-id + [region=fr-par] Region to target. If none is passed will use default region from the config (fr-par) + +FLAGS: + -h, --help help for get + +GLOBAL FLAGS: + -c, --config string The path to the config file + -D, --debug Enable debug mode + -o, --output string Output format: json or human, see 'scw help output' for more info (default "human") + -p, --profile string The config profile to use diff --git a/cmd/scw/testdata/test-all-usage-function-function-list-usage.golden b/cmd/scw/testdata/test-all-usage-function-function-list-usage.golden new file mode 100644 index 0000000000..e4da42c879 --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-function-function-list-usage.golden @@ -0,0 +1,23 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +πŸŸ₯πŸŸ₯πŸŸ₯ STDERR️️ πŸŸ₯πŸŸ₯πŸŸ₯️ +List all your functions. + +USAGE: + scw function function list [arg=value ...] + +ARGS: + [order-by] (created_at_asc | created_at_desc | name_asc | name_desc) + [namespace-id] + [name] + [project-id] + [organization-id] + [region=fr-par] Region to target. If none is passed will use default region from the config (fr-par) + +FLAGS: + -h, --help help for list + +GLOBAL FLAGS: + -c, --config string The path to the config file + -D, --debug Enable debug mode + -o, --output string Output format: json or human, see 'scw help output' for more info (default "human") + -p, --profile string The config profile to use diff --git a/cmd/scw/testdata/test-all-usage-function-function-update-usage.golden b/cmd/scw/testdata/test-all-usage-function-function-update-usage.golden new file mode 100644 index 0000000000..d26ad9d94f --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-function-function-update-usage.golden @@ -0,0 +1,29 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +πŸŸ₯πŸŸ₯πŸŸ₯ STDERR️️ πŸŸ₯πŸŸ₯πŸŸ₯️ +Update the function associated with the given id. + +USAGE: + scw function function update [arg=value ...] + +ARGS: + function-id + [environment-variables.value.{key}] + [min-scale] + [max-scale] + [memory-limit] + [timeout.seconds] + [timeout.nanos] + [redeploy] + [handler] + [privacy] (unknown_privacy | public | private) + [description] + [region=fr-par] Region to target. If none is passed will use default region from the config (fr-par) + +FLAGS: + -h, --help help for update + +GLOBAL FLAGS: + -c, --config string The path to the config file + -D, --debug Enable debug mode + -o, --output string Output format: json or human, see 'scw help output' for more info (default "human") + -p, --profile string The config profile to use diff --git a/cmd/scw/testdata/test-all-usage-function-function-usage.golden b/cmd/scw/testdata/test-all-usage-function-function-usage.golden new file mode 100644 index 0000000000..a6f30d7ebd --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-function-function-usage.golden @@ -0,0 +1,27 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +πŸŸ₯πŸŸ₯πŸŸ₯ STDERR️️ πŸŸ₯πŸŸ₯πŸŸ₯️ +Function management commands. + +USAGE: + scw function function + +AVAILABLE COMMANDS: + create Create a new function + delete Delete a function + deploy Deploy a function + get Get a function + get-download-url Get a download URL of a function + get-upload-url Get an upload URL of a function + list List all your functions + update Update an existing function + +FLAGS: + -h, --help help for function + +GLOBAL FLAGS: + -c, --config string The path to the config file + -D, --debug Enable debug mode + -o, --output string Output format: json or human, see 'scw help output' for more info (default "human") + -p, --profile string The config profile to use + +Use "scw function function [command] --help" for more information about a command. diff --git a/cmd/scw/testdata/test-all-usage-function-logs-list-usage.golden b/cmd/scw/testdata/test-all-usage-function-logs-list-usage.golden new file mode 100644 index 0000000000..dd4d48e360 --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-function-logs-list-usage.golden @@ -0,0 +1,20 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +πŸŸ₯πŸŸ₯πŸŸ₯ STDERR️️ πŸŸ₯πŸŸ₯πŸŸ₯️ +List your application logs. + +USAGE: + scw function logs list [arg=value ...] + +ARGS: + function-id + [order-by] (timestamp_desc | timestamp_asc) + [region=fr-par] Region to target. If none is passed will use default region from the config (fr-par) + +FLAGS: + -h, --help help for list + +GLOBAL FLAGS: + -c, --config string The path to the config file + -D, --debug Enable debug mode + -o, --output string Output format: json or human, see 'scw help output' for more info (default "human") + -p, --profile string The config profile to use diff --git a/cmd/scw/testdata/test-all-usage-function-logs-usage.golden b/cmd/scw/testdata/test-all-usage-function-logs-usage.golden new file mode 100644 index 0000000000..1597019290 --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-function-logs-usage.golden @@ -0,0 +1,20 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +πŸŸ₯πŸŸ₯πŸŸ₯ STDERR️️ πŸŸ₯πŸŸ₯πŸŸ₯️ +Logs management commands. + +USAGE: + scw function logs + +AVAILABLE COMMANDS: + list List your application logs + +FLAGS: + -h, --help help for logs + +GLOBAL FLAGS: + -c, --config string The path to the config file + -D, --debug Enable debug mode + -o, --output string Output format: json or human, see 'scw help output' for more info (default "human") + -p, --profile string The config profile to use + +Use "scw function logs [command] --help" for more information about a command. diff --git a/cmd/scw/testdata/test-all-usage-function-namespace-create-usage.golden b/cmd/scw/testdata/test-all-usage-function-namespace-create-usage.golden new file mode 100644 index 0000000000..e55c3c4d84 --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-function-namespace-create-usage.golden @@ -0,0 +1,22 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +πŸŸ₯πŸŸ₯πŸŸ₯ STDERR️️ πŸŸ₯πŸŸ₯πŸŸ₯️ +Create a new namespace. + +USAGE: + scw function namespace create [arg=value ...] + +ARGS: + [name=] + [environment-variables.value.{key}] + [project-id] Project ID to use. If none is passed the default project ID will be used + [description] + [region=fr-par] Region to target. If none is passed will use default region from the config (fr-par) + +FLAGS: + -h, --help help for create + +GLOBAL FLAGS: + -c, --config string The path to the config file + -D, --debug Enable debug mode + -o, --output string Output format: json or human, see 'scw help output' for more info (default "human") + -p, --profile string The config profile to use diff --git a/cmd/scw/testdata/test-all-usage-function-namespace-delete-usage.golden b/cmd/scw/testdata/test-all-usage-function-namespace-delete-usage.golden new file mode 100644 index 0000000000..9c57af3888 --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-function-namespace-delete-usage.golden @@ -0,0 +1,19 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +πŸŸ₯πŸŸ₯πŸŸ₯ STDERR️️ πŸŸ₯πŸŸ₯πŸŸ₯️ +Delete the namespace associated with the given id. + +USAGE: + scw function namespace delete [arg=value ...] + +ARGS: + namespace-id + [region=fr-par] Region to target. If none is passed will use default region from the config (fr-par) + +FLAGS: + -h, --help help for delete + +GLOBAL FLAGS: + -c, --config string The path to the config file + -D, --debug Enable debug mode + -o, --output string Output format: json or human, see 'scw help output' for more info (default "human") + -p, --profile string The config profile to use diff --git a/cmd/scw/testdata/test-all-usage-function-namespace-get-usage.golden b/cmd/scw/testdata/test-all-usage-function-namespace-get-usage.golden new file mode 100644 index 0000000000..8683af49d4 --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-function-namespace-get-usage.golden @@ -0,0 +1,19 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +πŸŸ₯πŸŸ₯πŸŸ₯ STDERR️️ πŸŸ₯πŸŸ₯πŸŸ₯️ +Get the namespace associated with the given id. + +USAGE: + scw function namespace get [arg=value ...] + +ARGS: + namespace-id + [region=fr-par] Region to target. If none is passed will use default region from the config (fr-par) + +FLAGS: + -h, --help help for get + +GLOBAL FLAGS: + -c, --config string The path to the config file + -D, --debug Enable debug mode + -o, --output string Output format: json or human, see 'scw help output' for more info (default "human") + -p, --profile string The config profile to use diff --git a/cmd/scw/testdata/test-all-usage-function-namespace-list-usage.golden b/cmd/scw/testdata/test-all-usage-function-namespace-list-usage.golden new file mode 100644 index 0000000000..2eb69eadb1 --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-function-namespace-list-usage.golden @@ -0,0 +1,22 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +πŸŸ₯πŸŸ₯πŸŸ₯ STDERR️️ πŸŸ₯πŸŸ₯πŸŸ₯️ +List all your namespaces. + +USAGE: + scw function namespace list [arg=value ...] + +ARGS: + [order-by] (created_at_asc | created_at_desc | name_asc | name_desc) + [name] + [project-id] + [organization-id] + [region=fr-par] Region to target. If none is passed will use default region from the config (fr-par) + +FLAGS: + -h, --help help for list + +GLOBAL FLAGS: + -c, --config string The path to the config file + -D, --debug Enable debug mode + -o, --output string Output format: json or human, see 'scw help output' for more info (default "human") + -p, --profile string The config profile to use diff --git a/cmd/scw/testdata/test-all-usage-function-namespace-update-usage.golden b/cmd/scw/testdata/test-all-usage-function-namespace-update-usage.golden new file mode 100644 index 0000000000..4bc1f0c7fe --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-function-namespace-update-usage.golden @@ -0,0 +1,21 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +πŸŸ₯πŸŸ₯πŸŸ₯ STDERR️️ πŸŸ₯πŸŸ₯πŸŸ₯️ +Update the space associated with the given id. + +USAGE: + scw function namespace update [arg=value ...] + +ARGS: + namespace-id + [environment-variables.value.{key}] + [description] + [region=fr-par] Region to target. If none is passed will use default region from the config (fr-par) + +FLAGS: + -h, --help help for update + +GLOBAL FLAGS: + -c, --config string The path to the config file + -D, --debug Enable debug mode + -o, --output string Output format: json or human, see 'scw help output' for more info (default "human") + -p, --profile string The config profile to use diff --git a/cmd/scw/testdata/test-all-usage-function-namespace-usage.golden b/cmd/scw/testdata/test-all-usage-function-namespace-usage.golden new file mode 100644 index 0000000000..cea70255e8 --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-function-namespace-usage.golden @@ -0,0 +1,24 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +πŸŸ₯πŸŸ₯πŸŸ₯ STDERR️️ πŸŸ₯πŸŸ₯πŸŸ₯️ +Function namespace management commands. + +USAGE: + scw function namespace + +AVAILABLE COMMANDS: + create Create a new namespace + delete Delete an existing namespace + get Get a namespace + list List all your namespaces + update Update an existing namespace + +FLAGS: + -h, --help help for namespace + +GLOBAL FLAGS: + -c, --config string The path to the config file + -D, --debug Enable debug mode + -o, --output string Output format: json or human, see 'scw help output' for more info (default "human") + -p, --profile string The config profile to use + +Use "scw function namespace [command] --help" for more information about a command. diff --git a/cmd/scw/testdata/test-all-usage-function-runtime-list-usage.golden b/cmd/scw/testdata/test-all-usage-function-runtime-list-usage.golden new file mode 100644 index 0000000000..643584bf90 --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-function-runtime-list-usage.golden @@ -0,0 +1,18 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +πŸŸ₯πŸŸ₯πŸŸ₯ STDERR️️ πŸŸ₯πŸŸ₯πŸŸ₯️ +List available function runtimes. + +USAGE: + scw function runtime list [arg=value ...] + +ARGS: + [region=fr-par] Region to target. If none is passed will use default region from the config (fr-par) + +FLAGS: + -h, --help help for list + +GLOBAL FLAGS: + -c, --config string The path to the config file + -D, --debug Enable debug mode + -o, --output string Output format: json or human, see 'scw help output' for more info (default "human") + -p, --profile string The config profile to use diff --git a/cmd/scw/testdata/test-all-usage-function-runtime-usage.golden b/cmd/scw/testdata/test-all-usage-function-runtime-usage.golden new file mode 100644 index 0000000000..4ca526acde --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-function-runtime-usage.golden @@ -0,0 +1,20 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +πŸŸ₯πŸŸ₯πŸŸ₯ STDERR️️ πŸŸ₯πŸŸ₯πŸŸ₯️ +Runtime management commands. + +USAGE: + scw function runtime + +AVAILABLE COMMANDS: + list List function runtimes + +FLAGS: + -h, --help help for runtime + +GLOBAL FLAGS: + -c, --config string The path to the config file + -D, --debug Enable debug mode + -o, --output string Output format: json or human, see 'scw help output' for more info (default "human") + -p, --profile string The config profile to use + +Use "scw function runtime [command] --help" for more information about a command. diff --git a/cmd/scw/testdata/test-all-usage-function-usage.golden b/cmd/scw/testdata/test-all-usage-function-usage.golden new file mode 100644 index 0000000000..89063701f3 --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-function-usage.golden @@ -0,0 +1,24 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +πŸŸ₯πŸŸ₯πŸŸ₯ STDERR️️ πŸŸ₯πŸŸ₯πŸŸ₯️ +Function as a Service API + +USAGE: + scw function + +AVAILABLE COMMANDS: + cron Cron management commands + function Function management commands + logs Logs management commands + namespace Function namespace management commands + runtime Runtime management commands + +FLAGS: + -h, --help help for function + +GLOBAL FLAGS: + -c, --config string The path to the config file + -D, --debug Enable debug mode + -o, --output string Output format: json or human, see 'scw help output' for more info (default "human") + -p, --profile string The config profile to use + +Use "scw function [command] --help" for more information about a command. diff --git a/cmd/scw/testdata/test-main-usage-usage.golden b/cmd/scw/testdata/test-main-usage-usage.golden index 9be63a7993..07b54de54a 100644 --- a/cmd/scw/testdata/test-main-usage-usage.golden +++ b/cmd/scw/testdata/test-main-usage-usage.golden @@ -13,6 +13,7 @@ AVAILABLE COMMANDS: dns DNS API feedback Send feedback to the Scaleway CLI Team! fip Flexible IP API + function Function as a Service API help Get help about how the CLI works info Get info about current settings init Initialize the config diff --git a/internal/namespaces/function/v1beta1/custom.go b/internal/namespaces/function/v1beta1/custom.go new file mode 100644 index 0000000000..b0eec9467a --- /dev/null +++ b/internal/namespaces/function/v1beta1/custom.go @@ -0,0 +1,17 @@ +package function + +import ( + "github.com/scaleway/scaleway-cli/internal/core" + "github.com/scaleway/scaleway-cli/internal/human" + function "github.com/scaleway/scaleway-sdk-go/api/function/v1beta1" +) + +func GetCommands() *core.Commands { + cmds := GetGeneratedCommands() + + human.RegisterMarshalerFunc(function.NamespaceStatus(""), human.EnumMarshalFunc(namespaceStatusMarshalSpecs)) + human.RegisterMarshalerFunc(function.FunctionStatus(""), human.EnumMarshalFunc(functionStatusMarshalSpecs)) + human.RegisterMarshalerFunc(function.CronStatus(""), human.EnumMarshalFunc(cronStatusMarshalSpecs)) + + return cmds +} diff --git a/internal/namespaces/function/v1beta1/custom_cron.go b/internal/namespaces/function/v1beta1/custom_cron.go new file mode 100644 index 0000000000..823c45e809 --- /dev/null +++ b/internal/namespaces/function/v1beta1/custom_cron.go @@ -0,0 +1,19 @@ +package function + +import ( + "github.com/fatih/color" + "github.com/scaleway/scaleway-cli/internal/human" + function "github.com/scaleway/scaleway-sdk-go/api/function/v1beta1" +) + +var ( + cronStatusMarshalSpecs = human.EnumMarshalSpecs{ + function.CronStatusCreating: &human.EnumMarshalSpec{Attribute: color.FgBlue}, + function.CronStatusDeleting: &human.EnumMarshalSpec{Attribute: color.FgBlue}, + function.CronStatusError: &human.EnumMarshalSpec{Attribute: color.FgRed}, + function.CronStatusLocked: &human.EnumMarshalSpec{Attribute: color.FgRed}, + function.CronStatusPending: &human.EnumMarshalSpec{Attribute: color.FgBlue}, + function.CronStatusReady: &human.EnumMarshalSpec{Attribute: color.FgGreen}, + function.CronStatusUnknown: &human.EnumMarshalSpec{Attribute: color.Faint}, + } +) diff --git a/internal/namespaces/function/v1beta1/custom_function.go b/internal/namespaces/function/v1beta1/custom_function.go new file mode 100644 index 0000000000..795c70a995 --- /dev/null +++ b/internal/namespaces/function/v1beta1/custom_function.go @@ -0,0 +1,20 @@ +package function + +import ( + "github.com/fatih/color" + "github.com/scaleway/scaleway-cli/internal/human" + function "github.com/scaleway/scaleway-sdk-go/api/function/v1beta1" +) + +var ( + functionStatusMarshalSpecs = human.EnumMarshalSpecs{ + function.FunctionStatusCreated: &human.EnumMarshalSpec{Attribute: color.FgGreen}, + function.FunctionStatusCreating: &human.EnumMarshalSpec{Attribute: color.FgBlue}, + function.FunctionStatusDeleting: &human.EnumMarshalSpec{Attribute: color.FgBlue}, + function.FunctionStatusError: &human.EnumMarshalSpec{Attribute: color.FgRed}, + function.FunctionStatusLocked: &human.EnumMarshalSpec{Attribute: color.FgRed}, + function.FunctionStatusPending: &human.EnumMarshalSpec{Attribute: color.FgBlue}, + function.FunctionStatusReady: &human.EnumMarshalSpec{Attribute: color.FgGreen}, + function.FunctionStatusUnknown: &human.EnumMarshalSpec{Attribute: color.Faint}, + } +) diff --git a/internal/namespaces/function/v1beta1/custom_namespace.go b/internal/namespaces/function/v1beta1/custom_namespace.go new file mode 100644 index 0000000000..e6c1d33d3f --- /dev/null +++ b/internal/namespaces/function/v1beta1/custom_namespace.go @@ -0,0 +1,19 @@ +package function + +import ( + "github.com/fatih/color" + "github.com/scaleway/scaleway-cli/internal/human" + function "github.com/scaleway/scaleway-sdk-go/api/function/v1beta1" +) + +var ( + namespaceStatusMarshalSpecs = human.EnumMarshalSpecs{ + function.NamespaceStatusCreating: &human.EnumMarshalSpec{Attribute: color.FgBlue}, + function.NamespaceStatusDeleting: &human.EnumMarshalSpec{Attribute: color.FgBlue}, + function.NamespaceStatusError: &human.EnumMarshalSpec{Attribute: color.FgRed}, + function.NamespaceStatusLocked: &human.EnumMarshalSpec{Attribute: color.FgRed}, + function.NamespaceStatusPending: &human.EnumMarshalSpec{Attribute: color.FgBlue}, + function.NamespaceStatusReady: &human.EnumMarshalSpec{Attribute: color.FgGreen}, + function.NamespaceStatusUnknown: &human.EnumMarshalSpec{Attribute: color.Faint}, + } +) diff --git a/internal/namespaces/function/v1beta1/function_cli.go b/internal/namespaces/function/v1beta1/function_cli.go new file mode 100644 index 0000000000..0f1c65cb4f --- /dev/null +++ b/internal/namespaces/function/v1beta1/function_cli.go @@ -0,0 +1,886 @@ +// This file was automatically generated. DO NOT EDIT. +// If you have any remark or suggestion do not hesitate to open an issue. + +package function + +import ( + "context" + "reflect" + + "github.com/scaleway/scaleway-cli/internal/core" + "github.com/scaleway/scaleway-sdk-go/api/function/v1beta1" + "github.com/scaleway/scaleway-sdk-go/scw" +) + +// always import dependencies +var ( + _ = scw.RegionFrPar +) + +func GetGeneratedCommands() *core.Commands { + return core.NewCommands( + functionRoot(), + functionNamespace(), + functionFunction(), + functionCron(), + functionRuntime(), + functionLogs(), + functionNamespaceList(), + functionNamespaceGet(), + functionNamespaceCreate(), + functionNamespaceUpdate(), + functionNamespaceDelete(), + functionFunctionList(), + functionFunctionGet(), + functionFunctionCreate(), + functionFunctionUpdate(), + functionFunctionDelete(), + functionFunctionDeploy(), + functionRuntimeList(), + functionFunctionGetUploadURL(), + functionFunctionGetDownloadURL(), + functionCronList(), + functionCronGet(), + functionCronDelete(), + functionLogsList(), + ) +} +func functionRoot() *core.Command { + return &core.Command{ + Short: `Function as a Service API`, + Long: ``, + Namespace: "function", + } +} + +func functionNamespace() *core.Command { + return &core.Command{ + Short: `Function namespace management commands`, + Long: `Function namespace management commands.`, + Namespace: "function", + Resource: "namespace", + } +} + +func functionFunction() *core.Command { + return &core.Command{ + Short: `Function management commands`, + Long: `Function management commands.`, + Namespace: "function", + Resource: "function", + } +} + +func functionCron() *core.Command { + return &core.Command{ + Short: `Cron management commands`, + Long: `Cron management commands.`, + Namespace: "function", + Resource: "cron", + } +} + +func functionRuntime() *core.Command { + return &core.Command{ + Short: `Runtime management commands`, + Long: `Runtime management commands.`, + Namespace: "function", + Resource: "runtime", + } +} + +func functionLogs() *core.Command { + return &core.Command{ + Short: `Logs management commands`, + Long: `Logs management commands.`, + Namespace: "function", + Resource: "logs", + } +} + +func functionNamespaceList() *core.Command { + return &core.Command{ + Short: `List all your namespaces`, + Long: `List all your namespaces.`, + Namespace: "function", + Resource: "namespace", + Verb: "list", + // Deprecated: false, + ArgsType: reflect.TypeOf(function.ListNamespacesRequest{}), + ArgSpecs: core.ArgSpecs{ + { + Name: "order-by", + Required: false, + Deprecated: false, + Positional: false, + EnumValues: []string{"created_at_asc", "created_at_desc", "name_asc", "name_desc"}, + }, + { + Name: "name", + Required: false, + Deprecated: false, + Positional: false, + }, + { + Name: "project-id", + Required: false, + Deprecated: false, + Positional: false, + }, + { + Name: "organization-id", + Required: false, + Deprecated: false, + Positional: false, + }, + core.RegionArgSpec(scw.RegionFrPar), + }, + Run: func(ctx context.Context, args interface{}) (i interface{}, e error) { + request := args.(*function.ListNamespacesRequest) + + client := core.ExtractClient(ctx) + api := function.NewAPI(client) + resp, err := api.ListNamespaces(request, scw.WithAllPages()) + if err != nil { + return nil, err + } + return resp.Namespaces, nil + + }, + View: &core.View{Fields: []*core.ViewField{ + { + FieldName: "ID", + }, + { + FieldName: "Name", + }, + { + FieldName: "Status", + }, + { + FieldName: "RegistryNamespaceID", + }, + { + FieldName: "RegistryEndpoint", + }, + { + FieldName: "EnvironmentVariables", + }, + { + FieldName: "ErrorMessage", + }, + { + FieldName: "Description", + }, + { + FieldName: "Region", + }, + { + FieldName: "ProjectID", + }, + { + FieldName: "OrganizationID", + }, + }}, + } +} + +func functionNamespaceGet() *core.Command { + return &core.Command{ + Short: `Get a namespace`, + Long: `Get the namespace associated with the given id.`, + Namespace: "function", + Resource: "namespace", + Verb: "get", + // Deprecated: false, + ArgsType: reflect.TypeOf(function.GetNamespaceRequest{}), + ArgSpecs: core.ArgSpecs{ + { + Name: "namespace-id", + Required: true, + Deprecated: false, + Positional: true, + }, + core.RegionArgSpec(scw.RegionFrPar), + }, + Run: func(ctx context.Context, args interface{}) (i interface{}, e error) { + request := args.(*function.GetNamespaceRequest) + + client := core.ExtractClient(ctx) + api := function.NewAPI(client) + return api.GetNamespace(request) + + }, + } +} + +func functionNamespaceCreate() *core.Command { + return &core.Command{ + Short: `Create a new namespace`, + Long: `Create a new namespace.`, + Namespace: "function", + Resource: "namespace", + Verb: "create", + // Deprecated: false, + ArgsType: reflect.TypeOf(function.CreateNamespaceRequest{}), + ArgSpecs: core.ArgSpecs{ + { + Name: "name", + Required: false, + Deprecated: false, + Positional: false, + Default: core.RandomValueGenerator("ns"), + }, + { + Name: "environment-variables.value.{key}", + Required: false, + Deprecated: false, + Positional: false, + }, + core.ProjectIDArgSpec(), + { + Name: "description", + Required: false, + Deprecated: false, + Positional: false, + }, + core.RegionArgSpec(scw.RegionFrPar), + }, + Run: func(ctx context.Context, args interface{}) (i interface{}, e error) { + request := args.(*function.CreateNamespaceRequest) + + client := core.ExtractClient(ctx) + api := function.NewAPI(client) + return api.CreateNamespace(request) + + }, + } +} + +func functionNamespaceUpdate() *core.Command { + return &core.Command{ + Short: `Update an existing namespace`, + Long: `Update the space associated with the given id.`, + Namespace: "function", + Resource: "namespace", + Verb: "update", + // Deprecated: false, + ArgsType: reflect.TypeOf(function.UpdateNamespaceRequest{}), + ArgSpecs: core.ArgSpecs{ + { + Name: "namespace-id", + Required: true, + Deprecated: false, + Positional: true, + }, + { + Name: "environment-variables.value.{key}", + Required: false, + Deprecated: false, + Positional: false, + }, + { + Name: "description", + Required: false, + Deprecated: false, + Positional: false, + }, + core.RegionArgSpec(scw.RegionFrPar), + }, + Run: func(ctx context.Context, args interface{}) (i interface{}, e error) { + request := args.(*function.UpdateNamespaceRequest) + + client := core.ExtractClient(ctx) + api := function.NewAPI(client) + return api.UpdateNamespace(request) + + }, + } +} + +func functionNamespaceDelete() *core.Command { + return &core.Command{ + Short: `Delete an existing namespace`, + Long: `Delete the namespace associated with the given id.`, + Namespace: "function", + Resource: "namespace", + Verb: "delete", + // Deprecated: false, + ArgsType: reflect.TypeOf(function.DeleteNamespaceRequest{}), + ArgSpecs: core.ArgSpecs{ + { + Name: "namespace-id", + Required: true, + Deprecated: false, + Positional: true, + }, + core.RegionArgSpec(scw.RegionFrPar), + }, + Run: func(ctx context.Context, args interface{}) (i interface{}, e error) { + request := args.(*function.DeleteNamespaceRequest) + + client := core.ExtractClient(ctx) + api := function.NewAPI(client) + return api.DeleteNamespace(request) + + }, + } +} + +func functionFunctionList() *core.Command { + return &core.Command{ + Short: `List all your functions`, + Long: `List all your functions.`, + Namespace: "function", + Resource: "function", + Verb: "list", + // Deprecated: false, + ArgsType: reflect.TypeOf(function.ListFunctionsRequest{}), + ArgSpecs: core.ArgSpecs{ + { + Name: "order-by", + Required: false, + Deprecated: false, + Positional: false, + EnumValues: []string{"created_at_asc", "created_at_desc", "name_asc", "name_desc"}, + }, + { + Name: "namespace-id", + Required: false, + Deprecated: false, + Positional: false, + }, + { + Name: "name", + Required: false, + Deprecated: false, + Positional: false, + }, + { + Name: "project-id", + Required: false, + Deprecated: false, + Positional: false, + }, + { + Name: "organization-id", + Required: false, + Deprecated: false, + Positional: false, + }, + core.RegionArgSpec(scw.RegionFrPar), + }, + Run: func(ctx context.Context, args interface{}) (i interface{}, e error) { + request := args.(*function.ListFunctionsRequest) + + client := core.ExtractClient(ctx) + api := function.NewAPI(client) + resp, err := api.ListFunctions(request, scw.WithAllPages()) + if err != nil { + return nil, err + } + return resp.Functions, nil + + }, + } +} + +func functionFunctionGet() *core.Command { + return &core.Command{ + Short: `Get a function`, + Long: `Get the function associated with the given id.`, + Namespace: "function", + Resource: "function", + Verb: "get", + // Deprecated: false, + ArgsType: reflect.TypeOf(function.GetFunctionRequest{}), + ArgSpecs: core.ArgSpecs{ + { + Name: "function-id", + Required: true, + Deprecated: false, + Positional: true, + }, + core.RegionArgSpec(scw.RegionFrPar), + }, + Run: func(ctx context.Context, args interface{}) (i interface{}, e error) { + request := args.(*function.GetFunctionRequest) + + client := core.ExtractClient(ctx) + api := function.NewAPI(client) + return api.GetFunction(request) + + }, + } +} + +func functionFunctionCreate() *core.Command { + return &core.Command{ + Short: `Create a new function`, + Long: `Create a new function.`, + Namespace: "function", + Resource: "function", + Verb: "create", + // Deprecated: false, + ArgsType: reflect.TypeOf(function.CreateFunctionRequest{}), + ArgSpecs: core.ArgSpecs{ + { + Name: "name", + Required: false, + Deprecated: false, + Positional: false, + Default: core.RandomValueGenerator("fn"), + }, + { + Name: "namespace-id", + Required: false, + Deprecated: false, + Positional: false, + }, + { + Name: "environment-variables.value.{key}", + Required: false, + Deprecated: false, + Positional: false, + }, + { + Name: "min-scale", + Required: false, + Deprecated: false, + Positional: false, + }, + { + Name: "max-scale", + Required: false, + Deprecated: false, + Positional: false, + }, + { + Name: "runtime", + Required: false, + Deprecated: false, + Positional: false, + EnumValues: []string{"unknown_runtime", "golang", "python", "python3", "node8", "node10", "node14"}, + }, + { + Name: "memory-limit", + Required: false, + Deprecated: false, + Positional: false, + }, + { + Name: "timeout.seconds", + Required: false, + Deprecated: false, + Positional: false, + }, + { + Name: "timeout.nanos", + Required: false, + Deprecated: false, + Positional: false, + }, + { + Name: "handler", + Required: false, + Deprecated: false, + Positional: false, + }, + { + Name: "privacy", + Required: false, + Deprecated: false, + Positional: false, + EnumValues: []string{"unknown_privacy", "public", "private"}, + }, + { + Name: "description", + Required: false, + Deprecated: false, + Positional: false, + }, + core.RegionArgSpec(scw.RegionFrPar), + }, + Run: func(ctx context.Context, args interface{}) (i interface{}, e error) { + request := args.(*function.CreateFunctionRequest) + + client := core.ExtractClient(ctx) + api := function.NewAPI(client) + return api.CreateFunction(request) + + }, + } +} + +func functionFunctionUpdate() *core.Command { + return &core.Command{ + Short: `Update an existing function`, + Long: `Update the function associated with the given id.`, + Namespace: "function", + Resource: "function", + Verb: "update", + // Deprecated: false, + ArgsType: reflect.TypeOf(function.UpdateFunctionRequest{}), + ArgSpecs: core.ArgSpecs{ + { + Name: "function-id", + Required: true, + Deprecated: false, + Positional: true, + }, + { + Name: "environment-variables.value.{key}", + Required: false, + Deprecated: false, + Positional: false, + }, + { + Name: "min-scale", + Required: false, + Deprecated: false, + Positional: false, + }, + { + Name: "max-scale", + Required: false, + Deprecated: false, + Positional: false, + }, + { + Name: "memory-limit", + Required: false, + Deprecated: false, + Positional: false, + }, + { + Name: "timeout.seconds", + Required: false, + Deprecated: false, + Positional: false, + }, + { + Name: "timeout.nanos", + Required: false, + Deprecated: false, + Positional: false, + }, + { + Name: "redeploy", + Required: false, + Deprecated: false, + Positional: false, + }, + { + Name: "handler", + Required: false, + Deprecated: false, + Positional: false, + }, + { + Name: "privacy", + Required: false, + Deprecated: false, + Positional: false, + EnumValues: []string{"unknown_privacy", "public", "private"}, + }, + { + Name: "description", + Required: false, + Deprecated: false, + Positional: false, + }, + core.RegionArgSpec(scw.RegionFrPar), + }, + Run: func(ctx context.Context, args interface{}) (i interface{}, e error) { + request := args.(*function.UpdateFunctionRequest) + + client := core.ExtractClient(ctx) + api := function.NewAPI(client) + return api.UpdateFunction(request) + + }, + } +} + +func functionFunctionDelete() *core.Command { + return &core.Command{ + Short: `Delete a function`, + Long: `Delete the function associated with the given id.`, + Namespace: "function", + Resource: "function", + Verb: "delete", + // Deprecated: false, + ArgsType: reflect.TypeOf(function.DeleteFunctionRequest{}), + ArgSpecs: core.ArgSpecs{ + { + Name: "function-id", + Required: true, + Deprecated: false, + Positional: true, + }, + core.RegionArgSpec(scw.RegionFrPar), + }, + Run: func(ctx context.Context, args interface{}) (i interface{}, e error) { + request := args.(*function.DeleteFunctionRequest) + + client := core.ExtractClient(ctx) + api := function.NewAPI(client) + return api.DeleteFunction(request) + + }, + } +} + +func functionFunctionDeploy() *core.Command { + return &core.Command{ + Short: `Deploy a function`, + Long: `Deploy a function associated with the given id.`, + Namespace: "function", + Resource: "function", + Verb: "deploy", + // Deprecated: false, + ArgsType: reflect.TypeOf(function.DeployFunctionRequest{}), + ArgSpecs: core.ArgSpecs{ + { + Name: "function-id", + Required: true, + Deprecated: false, + Positional: true, + }, + core.RegionArgSpec(scw.RegionFrPar), + }, + Run: func(ctx context.Context, args interface{}) (i interface{}, e error) { + request := args.(*function.DeployFunctionRequest) + + client := core.ExtractClient(ctx) + api := function.NewAPI(client) + return api.DeployFunction(request) + + }, + } +} + +func functionRuntimeList() *core.Command { + return &core.Command{ + Short: `List function runtimes`, + Long: `List available function runtimes.`, + Namespace: "function", + Resource: "runtime", + Verb: "list", + // Deprecated: false, + ArgsType: reflect.TypeOf(function.ListFunctionRuntimesRequest{}), + ArgSpecs: core.ArgSpecs{ + core.RegionArgSpec(scw.RegionFrPar), + }, + Run: func(ctx context.Context, args interface{}) (i interface{}, e error) { + request := args.(*function.ListFunctionRuntimesRequest) + + client := core.ExtractClient(ctx) + api := function.NewAPI(client) + return api.ListFunctionRuntimes(request) + + }, + } +} + +func functionFunctionGetUploadURL() *core.Command { + return &core.Command{ + Short: `Get an upload URL of a function`, + Long: `Get an upload URL of a function associated with the given id.`, + Namespace: "function", + Resource: "function", + Verb: "get-upload-url", + // Deprecated: false, + ArgsType: reflect.TypeOf(function.GetFunctionUploadURLRequest{}), + ArgSpecs: core.ArgSpecs{ + { + Name: "function-id", + Required: true, + Deprecated: false, + Positional: true, + }, + { + Name: "content-length", + Required: false, + Deprecated: false, + Positional: false, + }, + core.RegionArgSpec(scw.RegionFrPar), + }, + Run: func(ctx context.Context, args interface{}) (i interface{}, e error) { + request := args.(*function.GetFunctionUploadURLRequest) + + client := core.ExtractClient(ctx) + api := function.NewAPI(client) + return api.GetFunctionUploadURL(request) + + }, + } +} + +func functionFunctionGetDownloadURL() *core.Command { + return &core.Command{ + Short: `Get a download URL of a function`, + Long: `Get a download URL for a function associated with the given id.`, + Namespace: "function", + Resource: "function", + Verb: "get-download-url", + // Deprecated: false, + ArgsType: reflect.TypeOf(function.GetFunctionDownloadURLRequest{}), + ArgSpecs: core.ArgSpecs{ + { + Name: "function-id", + Required: true, + Deprecated: false, + Positional: true, + }, + core.RegionArgSpec(scw.RegionFrPar), + }, + Run: func(ctx context.Context, args interface{}) (i interface{}, e error) { + request := args.(*function.GetFunctionDownloadURLRequest) + + client := core.ExtractClient(ctx) + api := function.NewAPI(client) + return api.GetFunctionDownloadURL(request) + + }, + } +} + +func functionCronList() *core.Command { + return &core.Command{ + Short: `List all your crons`, + Long: `List all your crons.`, + Namespace: "function", + Resource: "cron", + Verb: "list", + // Deprecated: false, + ArgsType: reflect.TypeOf(function.ListCronsRequest{}), + ArgSpecs: core.ArgSpecs{ + { + Name: "order-by", + Required: false, + Deprecated: false, + Positional: false, + EnumValues: []string{"created_at_asc", "created_at_desc"}, + }, + { + Name: "function-id", + Required: false, + Deprecated: false, + Positional: false, + }, + core.RegionArgSpec(scw.RegionFrPar), + }, + Run: func(ctx context.Context, args interface{}) (i interface{}, e error) { + request := args.(*function.ListCronsRequest) + + client := core.ExtractClient(ctx) + api := function.NewAPI(client) + resp, err := api.ListCrons(request, scw.WithAllPages()) + if err != nil { + return nil, err + } + return resp.Crons, nil + + }, + } +} + +func functionCronGet() *core.Command { + return &core.Command{ + Short: `Get a cron`, + Long: `Get the cron associated with the given id.`, + Namespace: "function", + Resource: "cron", + Verb: "get", + // Deprecated: false, + ArgsType: reflect.TypeOf(function.GetCronRequest{}), + ArgSpecs: core.ArgSpecs{ + { + Name: "cron-id", + Required: true, + Deprecated: false, + Positional: true, + }, + core.RegionArgSpec(scw.RegionFrPar), + }, + Run: func(ctx context.Context, args interface{}) (i interface{}, e error) { + request := args.(*function.GetCronRequest) + + client := core.ExtractClient(ctx) + api := function.NewAPI(client) + return api.GetCron(request) + + }, + } +} + +func functionCronDelete() *core.Command { + return &core.Command{ + Short: `Delete an existing cron`, + Long: `Delete the cron associated with the given id.`, + Namespace: "function", + Resource: "cron", + Verb: "delete", + // Deprecated: false, + ArgsType: reflect.TypeOf(function.DeleteCronRequest{}), + ArgSpecs: core.ArgSpecs{ + { + Name: "cron-id", + Required: true, + Deprecated: false, + Positional: true, + }, + core.RegionArgSpec(scw.RegionFrPar), + }, + Run: func(ctx context.Context, args interface{}) (i interface{}, e error) { + request := args.(*function.DeleteCronRequest) + + client := core.ExtractClient(ctx) + api := function.NewAPI(client) + return api.DeleteCron(request) + + }, + } +} + +func functionLogsList() *core.Command { + return &core.Command{ + Short: `List your application logs`, + Long: `List your application logs.`, + Namespace: "function", + Resource: "logs", + Verb: "list", + // Deprecated: false, + ArgsType: reflect.TypeOf(function.ListLogsRequest{}), + ArgSpecs: core.ArgSpecs{ + { + Name: "function-id", + Required: true, + Deprecated: false, + Positional: false, + }, + { + Name: "order-by", + Required: false, + Deprecated: false, + Positional: false, + EnumValues: []string{"timestamp_desc", "timestamp_asc"}, + }, + core.RegionArgSpec(scw.RegionFrPar), + }, + Run: func(ctx context.Context, args interface{}) (i interface{}, e error) { + request := args.(*function.ListLogsRequest) + + client := core.ExtractClient(ctx) + api := function.NewAPI(client) + resp, err := api.ListLogs(request, scw.WithAllPages()) + if err != nil { + return nil, err + } + return resp.Logs, nil + + }, + } +} diff --git a/internal/namespaces/get_commands.go b/internal/namespaces/get_commands.go index 793230e87c..69b09eb2a8 100644 --- a/internal/namespaces/get_commands.go +++ b/internal/namespaces/get_commands.go @@ -11,6 +11,7 @@ import ( domain "github.com/scaleway/scaleway-cli/internal/namespaces/domain/v2beta1" "github.com/scaleway/scaleway-cli/internal/namespaces/feedback" flexibleip "github.com/scaleway/scaleway-cli/internal/namespaces/flexibleip/v1alpha1" + function "github.com/scaleway/scaleway-cli/internal/namespaces/function/v1beta1" "github.com/scaleway/scaleway-cli/internal/namespaces/help" "github.com/scaleway/scaleway-cli/internal/namespaces/info" initNamespace "github.com/scaleway/scaleway-cli/internal/namespaces/init" @@ -55,5 +56,6 @@ func GetCommands() *core.Commands { commands.Merge(applesilicon.GetCommands()) commands.Merge(flexibleip.GetCommands()) commands.Merge(container.GetCommands()) + commands.Merge(function.GetCommands()) return commands }