diff --git a/cmd/scw/testdata/test-all-usage-cockpit-alert-disable-usage.golden b/cmd/scw/testdata/test-all-usage-cockpit-alert-disable-usage.golden new file mode 100644 index 0000000000..a49027a3ee --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-cockpit-alert-disable-usage.golden @@ -0,0 +1,18 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +πŸŸ₯πŸŸ₯πŸŸ₯ STDERR️️ πŸŸ₯πŸŸ₯πŸŸ₯️ +Disable managed alerts. + +USAGE: + scw cockpit alert disable [arg=value ...] + +ARGS: + [project-id] Project ID to use. If none is passed the default project ID will be used + +FLAGS: + -h, --help help for disable + +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-cockpit-alert-enable-usage.golden b/cmd/scw/testdata/test-all-usage-cockpit-alert-enable-usage.golden new file mode 100644 index 0000000000..58879150d9 --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-cockpit-alert-enable-usage.golden @@ -0,0 +1,18 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +πŸŸ₯πŸŸ₯πŸŸ₯ STDERR️️ πŸŸ₯πŸŸ₯πŸŸ₯️ +Enable managed alerts. + +USAGE: + scw cockpit alert enable [arg=value ...] + +ARGS: + [project-id] Project ID to use. If none is passed the default project ID will be used + +FLAGS: + -h, --help help for enable + +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-cockpit-alert-test-usage.golden b/cmd/scw/testdata/test-all-usage-cockpit-alert-test-usage.golden new file mode 100644 index 0000000000..6d11347b1f --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-cockpit-alert-test-usage.golden @@ -0,0 +1,18 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +πŸŸ₯πŸŸ₯πŸŸ₯ STDERR️️ πŸŸ₯πŸŸ₯πŸŸ₯️ +Trigger a test alert to all receivers. + +USAGE: + scw cockpit alert test [arg=value ...] + +ARGS: + [project-id] Project ID to use. If none is passed the default project ID will be used + +FLAGS: + -h, --help help for test + +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-cockpit-alert-usage.golden b/cmd/scw/testdata/test-all-usage-cockpit-alert-usage.golden new file mode 100644 index 0000000000..2cadb0fe85 --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-cockpit-alert-usage.golden @@ -0,0 +1,22 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +πŸŸ₯πŸŸ₯πŸŸ₯ STDERR️️ πŸŸ₯πŸŸ₯πŸŸ₯️ +Managed alerts management commands. + +USAGE: + scw cockpit alert + +AVAILABLE COMMANDS: + disable Disable managed alerts + enable Enable managed alerts + test Trigger a test alert + +FLAGS: + -h, --help help for alert + +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 cockpit alert [command] --help" for more information about a command. diff --git a/cmd/scw/testdata/test-all-usage-cockpit-contact-create-usage.golden b/cmd/scw/testdata/test-all-usage-cockpit-contact-create-usage.golden new file mode 100644 index 0000000000..15e9cf4b26 --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-cockpit-contact-create-usage.golden @@ -0,0 +1,19 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +πŸŸ₯πŸŸ₯πŸŸ₯ STDERR️️ πŸŸ₯πŸŸ₯πŸŸ₯️ +Create an alert contact point for the default receiver. + +USAGE: + scw cockpit contact create [arg=value ...] + +ARGS: + [project-id] Project ID to use. If none is passed the default project ID will be used + [contact-point.email.to] + +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-cockpit-contact-delete-usage.golden b/cmd/scw/testdata/test-all-usage-cockpit-contact-delete-usage.golden new file mode 100644 index 0000000000..280a844ab8 --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-cockpit-contact-delete-usage.golden @@ -0,0 +1,19 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +πŸŸ₯πŸŸ₯πŸŸ₯ STDERR️️ πŸŸ₯πŸŸ₯πŸŸ₯️ +Delete an alert contact point for the default receiver. + +USAGE: + scw cockpit contact delete [arg=value ...] + +ARGS: + [project-id] Project ID to use. If none is passed the default project ID will be used + [contact-point.email.to] + +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-cockpit-contact-list-usage.golden b/cmd/scw/testdata/test-all-usage-cockpit-contact-list-usage.golden new file mode 100644 index 0000000000..15d6431f6f --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-cockpit-contact-list-usage.golden @@ -0,0 +1,18 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +πŸŸ₯πŸŸ₯πŸŸ₯ STDERR️️ πŸŸ₯πŸŸ₯πŸŸ₯️ +List alert contact points associated with the given cockpit ID. + +USAGE: + scw cockpit contact list [arg=value ...] + +ARGS: + [project-id] Project ID to use. If none is passed the default project ID will be used + +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-cockpit-contact-usage.golden b/cmd/scw/testdata/test-all-usage-cockpit-contact-usage.golden new file mode 100644 index 0000000000..d5d3197a30 --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-cockpit-contact-usage.golden @@ -0,0 +1,22 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +πŸŸ₯πŸŸ₯πŸŸ₯ STDERR️️ πŸŸ₯πŸŸ₯πŸŸ₯️ +Contacts management commands. + +USAGE: + scw cockpit contact + +AVAILABLE COMMANDS: + create Create an alert contact point + delete Delete an alert contact point + list List alert contact points + +FLAGS: + -h, --help help for contact + +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 cockpit contact [command] --help" for more information about a command. diff --git a/cmd/scw/testdata/test-all-usage-cockpit-usage.golden b/cmd/scw/testdata/test-all-usage-cockpit-usage.golden index 48eaffbd76..9784e31b36 100644 --- a/cmd/scw/testdata/test-all-usage-cockpit-usage.golden +++ b/cmd/scw/testdata/test-all-usage-cockpit-usage.golden @@ -6,7 +6,9 @@ USAGE: scw cockpit AVAILABLE COMMANDS: + alert Managed alerts management commands cockpit Cockpit management commands + contact Contacts management commands grafana-user Grafana user management commands token Token management commands diff --git a/cmd/scw/testdata/test-all-usage-marketplace-category-get-usage.golden b/cmd/scw/testdata/test-all-usage-marketplace-category-get-usage.golden new file mode 100644 index 0000000000..11f6ab84a3 --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-marketplace-category-get-usage.golden @@ -0,0 +1,18 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +πŸŸ₯πŸŸ₯πŸŸ₯ STDERR️️ πŸŸ₯πŸŸ₯πŸŸ₯️ +Get marketplace resources. + +USAGE: + scw marketplace category get [arg=value ...] + +ARGS: + category-id + +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-marketplace-category-list-usage.golden b/cmd/scw/testdata/test-all-usage-marketplace-category-list-usage.golden new file mode 100644 index 0000000000..ac4905564e --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-marketplace-category-list-usage.golden @@ -0,0 +1,15 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +πŸŸ₯πŸŸ₯πŸŸ₯ STDERR️️ πŸŸ₯πŸŸ₯πŸŸ₯️ +List marketplace resources. + +USAGE: + scw marketplace category list + +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-marketplace-category-usage.golden b/cmd/scw/testdata/test-all-usage-marketplace-category-usage.golden new file mode 100644 index 0000000000..1703d430f6 --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-marketplace-category-usage.golden @@ -0,0 +1,21 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +πŸŸ₯πŸŸ₯πŸŸ₯ STDERR️️ πŸŸ₯πŸŸ₯πŸŸ₯️ +Marketplace category management commands. + +USAGE: + scw marketplace category + +AVAILABLE COMMANDS: + get Get marketplace resources + list List marketplace resources + +FLAGS: + -h, --help help for category + +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 marketplace category [command] --help" for more information about a command. diff --git a/cmd/scw/testdata/test-all-usage-marketplace-local-image-get-usage.golden b/cmd/scw/testdata/test-all-usage-marketplace-local-image-get-usage.golden new file mode 100644 index 0000000000..898a3563f9 --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-marketplace-local-image-get-usage.golden @@ -0,0 +1,18 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +πŸŸ₯πŸŸ₯πŸŸ₯ STDERR️️ πŸŸ₯πŸŸ₯πŸŸ₯️ +Get marketplace resources. + +USAGE: + scw marketplace local-image get [arg=value ...] + +ARGS: + local-image-id + +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-marketplace-local-image-usage.golden b/cmd/scw/testdata/test-all-usage-marketplace-local-image-usage.golden index 546e678c9f..58684ab19d 100644 --- a/cmd/scw/testdata/test-all-usage-marketplace-local-image-usage.golden +++ b/cmd/scw/testdata/test-all-usage-marketplace-local-image-usage.golden @@ -6,6 +6,7 @@ USAGE: scw marketplace local-image AVAILABLE COMMANDS: + get Get marketplace resources list List local images from a specific image or version FLAGS: diff --git a/cmd/scw/testdata/test-all-usage-marketplace-usage.golden b/cmd/scw/testdata/test-all-usage-marketplace-usage.golden index df21e4fdea..18ec6b6da1 100644 --- a/cmd/scw/testdata/test-all-usage-marketplace-usage.golden +++ b/cmd/scw/testdata/test-all-usage-marketplace-usage.golden @@ -6,8 +6,10 @@ USAGE: scw marketplace AVAILABLE COMMANDS: + category Marketplace category management commands image Marketplace images management commands local-image Marketplace Local Images management commands + version Marketplace version management commands FLAGS: -h, --help help for marketplace diff --git a/cmd/scw/testdata/test-all-usage-marketplace-version-get-usage.golden b/cmd/scw/testdata/test-all-usage-marketplace-version-get-usage.golden new file mode 100644 index 0000000000..19fcb21171 --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-marketplace-version-get-usage.golden @@ -0,0 +1,18 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +πŸŸ₯πŸŸ₯πŸŸ₯ STDERR️️ πŸŸ₯πŸŸ₯πŸŸ₯️ +Get marketplace resources. + +USAGE: + scw marketplace version get [arg=value ...] + +ARGS: + version-id + +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-marketplace-version-list-usage.golden b/cmd/scw/testdata/test-all-usage-marketplace-version-list-usage.golden new file mode 100644 index 0000000000..28c02d1987 --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-marketplace-version-list-usage.golden @@ -0,0 +1,19 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +πŸŸ₯πŸŸ₯πŸŸ₯ STDERR️️ πŸŸ₯πŸŸ₯πŸŸ₯️ +List marketplace resources. + +USAGE: + scw marketplace version list [arg=value ...] + +ARGS: + [image-id] + [order-by] (created_at_asc | created_at_desc) + +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-marketplace-version-usage.golden b/cmd/scw/testdata/test-all-usage-marketplace-version-usage.golden new file mode 100644 index 0000000000..e6afa2c1c6 --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-marketplace-version-usage.golden @@ -0,0 +1,21 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +πŸŸ₯πŸŸ₯πŸŸ₯ STDERR️️ πŸŸ₯πŸŸ₯πŸŸ₯️ +Marketplace version management commands. + +USAGE: + scw marketplace version + +AVAILABLE COMMANDS: + get Get marketplace resources + list List marketplace resources + +FLAGS: + -h, --help help for version + +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 marketplace version [command] --help" for more information about a command. diff --git a/docs/commands/cockpit.md b/docs/commands/cockpit.md index 2492dac166..0285da2032 100644 --- a/docs/commands/cockpit.md +++ b/docs/commands/cockpit.md @@ -2,12 +2,20 @@ # Documentation for `scw cockpit` Cockpit API. +- [Managed alerts management commands](#managed-alerts-management-commands) + - [Disable managed alerts](#disable-managed-alerts) + - [Enable managed alerts](#enable-managed-alerts) + - [Trigger a test alert](#trigger-a-test-alert) - [Cockpit management commands](#cockpit-management-commands) - [Activate a cockpit](#activate-a-cockpit) - [Deactivate a cockpit](#deactivate-a-cockpit) - [Get cockpit](#get-cockpit) - [Reset Grafana](#reset-grafana) - [Wait for a cockpit to reach a stable state (installation)](#wait-for-a-cockpit-to-reach-a-stable-state-(installation)) +- [Contacts management commands](#contacts-management-commands) + - [Create an alert contact point](#create-an-alert-contact-point) + - [Delete an alert contact point](#delete-an-alert-contact-point) + - [List alert contact points](#list-alert-contact-points) - [Grafana user management commands](#grafana-user-management-commands) - [Create a grafana user](#create-a-grafana-user) - [Delete a grafana user](#delete-a-grafana-user) @@ -20,6 +28,68 @@ Cockpit API. - [List tokens](#list-tokens) +## Managed alerts management commands + +Managed alerts management commands. + + +### Disable managed alerts + +Disable managed alerts. + +**Usage:** + +``` +scw cockpit alert disable [arg=value ...] +``` + + +**Args:** + +| Name | | Description | +|------|---|-------------| +| project-id | | Project ID to use. If none is passed the default project ID will be used | + + + +### Enable managed alerts + +Enable managed alerts. + +**Usage:** + +``` +scw cockpit alert enable [arg=value ...] +``` + + +**Args:** + +| Name | | Description | +|------|---|-------------| +| project-id | | Project ID to use. If none is passed the default project ID will be used | + + + +### Trigger a test alert + +Trigger a test alert to all receivers. + +**Usage:** + +``` +scw cockpit alert test [arg=value ...] +``` + + +**Args:** + +| Name | | Description | +|------|---|-------------| +| project-id | | Project ID to use. If none is passed the default project ID will be used | + + + ## Cockpit management commands Cockpit management commands. @@ -130,6 +200,70 @@ scw cockpit cockpit wait 11111111-1111-1111-1111-111111111111 +## Contacts management commands + +Contacts management commands. + + +### Create an alert contact point + +Create an alert contact point for the default receiver. + +**Usage:** + +``` +scw cockpit contact create [arg=value ...] +``` + + +**Args:** + +| Name | | Description | +|------|---|-------------| +| project-id | | Project ID to use. If none is passed the default project ID will be used | +| contact-point.email.to | | | + + + +### Delete an alert contact point + +Delete an alert contact point for the default receiver. + +**Usage:** + +``` +scw cockpit contact delete [arg=value ...] +``` + + +**Args:** + +| Name | | Description | +|------|---|-------------| +| project-id | | Project ID to use. If none is passed the default project ID will be used | +| contact-point.email.to | | | + + + +### List alert contact points + +List alert contact points associated with the given cockpit ID. + +**Usage:** + +``` +scw cockpit contact list [arg=value ...] +``` + + +**Args:** + +| Name | | Description | +|------|---|-------------| +| project-id | | Project ID to use. If none is passed the default project ID will be used | + + + ## Grafana user management commands Grafana user management commands. diff --git a/docs/commands/marketplace.md b/docs/commands/marketplace.md index 74b2f8e8b1..b094903ee0 100644 --- a/docs/commands/marketplace.md +++ b/docs/commands/marketplace.md @@ -2,13 +2,56 @@ # Documentation for `scw marketplace` Marketplace API. +- [Marketplace category management commands](#marketplace-category-management-commands) + - [Get marketplace resources](#get-marketplace-resources) + - [List marketplace resources](#list-marketplace-resources) - [Marketplace images management commands](#marketplace-images-management-commands) - [Get a specific marketplace image](#get-a-specific-marketplace-image) - [List marketplace images](#list-marketplace-images) - [Marketplace Local Images management commands](#marketplace-local-images-management-commands) + - [Get marketplace resources](#get-marketplace-resources) - [List local images from a specific image or version](#list-local-images-from-a-specific-image-or-version) +- [Marketplace version management commands](#marketplace-version-management-commands) + - [Get marketplace resources](#get-marketplace-resources) + - [List marketplace resources](#list-marketplace-resources) +## Marketplace category management commands + +Marketplace category management commands. + + +### Get marketplace resources + +Get marketplace resources. + +**Usage:** + +``` +scw marketplace category get [arg=value ...] +``` + + +**Args:** + +| Name | | Description | +|------|---|-------------| +| category-id | Required | | + + + +### List marketplace resources + +List marketplace resources. + +**Usage:** + +``` +scw marketplace category list +``` + + + ## Marketplace images management commands Marketplace images management commands. @@ -60,6 +103,25 @@ scw marketplace image list [arg=value ...] Marketplace Local Images management commands. +### Get marketplace resources + +Get marketplace resources. + +**Usage:** + +``` +scw marketplace local-image get [arg=value ...] +``` + + +**Args:** + +| Name | | Description | +|------|---|-------------| +| local-image-id | Required | | + + + ### List local images from a specific image or version List local images from a specific image or version. @@ -83,3 +145,47 @@ scw marketplace local-image list [arg=value ...] +## Marketplace version management commands + +Marketplace version management commands. + + +### Get marketplace resources + +Get marketplace resources. + +**Usage:** + +``` +scw marketplace version get [arg=value ...] +``` + + +**Args:** + +| Name | | Description | +|------|---|-------------| +| version-id | Required | | + + + +### List marketplace resources + +List marketplace resources. + +**Usage:** + +``` +scw marketplace version list [arg=value ...] +``` + + +**Args:** + +| Name | | Description | +|------|---|-------------| +| image-id | | | +| order-by | One of: `created_at_asc`, `created_at_desc` | | + + + diff --git a/go.mod b/go.mod index f42a3b7ba7..d165d5249b 100644 --- a/go.mod +++ b/go.mod @@ -21,7 +21,7 @@ require ( github.com/moby/buildkit v0.11.4 github.com/opencontainers/go-digest v1.0.0 github.com/pkg/errors v0.9.1 - github.com/scaleway/scaleway-sdk-go v1.0.0-beta.15.0.20230322194848-b93be9bb5355 + github.com/scaleway/scaleway-sdk-go v1.0.0-beta.15.0.20230323101524-c017498bf616 github.com/spf13/cobra v1.6.1 github.com/spf13/pflag v1.0.5 github.com/stretchr/testify v1.8.2 diff --git a/go.sum b/go.sum index 44814d7a06..dfeb00a174 100644 --- a/go.sum +++ b/go.sum @@ -192,8 +192,8 @@ github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1: github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/russross/blackfriday v1.6.0/go.mod h1:ti0ldHuxg49ri4ksnFxlkCfN+hvslNlmVHqNRXXJNAY= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= -github.com/scaleway/scaleway-sdk-go v1.0.0-beta.15.0.20230322194848-b93be9bb5355 h1:aHNVwBytdB7wkPgNiHnIHEPTkiRbMiCo6LnGIpPdg3k= -github.com/scaleway/scaleway-sdk-go v1.0.0-beta.15.0.20230322194848-b93be9bb5355/go.mod h1:fCa7OJZ/9DRTnOKmxvT6pn+LPWUptQAmHF/SBJUGEcg= +github.com/scaleway/scaleway-sdk-go v1.0.0-beta.15.0.20230323101524-c017498bf616 h1:7zcfy2f51uoLQyFzguQXa5rxDzyy8md6eWTuwFn3sis= +github.com/scaleway/scaleway-sdk-go v1.0.0-beta.15.0.20230323101524-c017498bf616/go.mod h1:fCa7OJZ/9DRTnOKmxvT6pn+LPWUptQAmHF/SBJUGEcg= github.com/secure-systems-lab/go-securesystemslib v0.4.0 h1:b23VGrQhTA8cN2CbBw7/FulN9fTtqYUdS5+Oxzt+DUE= github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ= github.com/sergi/go-diff v1.2.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= diff --git a/internal/namespaces/cockpit/v1beta1/cockpit_cli.go b/internal/namespaces/cockpit/v1beta1/cockpit_cli.go index a1a284c41d..4125062c0d 100644 --- a/internal/namespaces/cockpit/v1beta1/cockpit_cli.go +++ b/internal/namespaces/cockpit/v1beta1/cockpit_cli.go @@ -23,6 +23,8 @@ func GetGeneratedCommands() *core.Commands { cockpitCockpit(), cockpitToken(), cockpitGrafanaUser(), + cockpitAlert(), + cockpitContact(), cockpitCockpitActivate(), cockpitCockpitGet(), cockpitCockpitDeactivate(), @@ -31,6 +33,12 @@ func GetGeneratedCommands() *core.Commands { cockpitTokenList(), cockpitTokenGet(), cockpitTokenDelete(), + cockpitContactCreate(), + cockpitContactList(), + cockpitContactDelete(), + cockpitAlertEnable(), + cockpitAlertDisable(), + cockpitAlertTest(), cockpitGrafanaUserCreate(), cockpitGrafanaUserList(), cockpitGrafanaUserDelete(), @@ -72,6 +80,24 @@ func cockpitGrafanaUser() *core.Command { } } +func cockpitAlert() *core.Command { + return &core.Command{ + Short: `Managed alerts management commands`, + Long: `Managed alerts management commands.`, + Namespace: "cockpit", + Resource: "alert", + } +} + +func cockpitContact() *core.Command { + return &core.Command{ + Short: `Contacts management commands`, + Long: `Contacts management commands.`, + Namespace: "cockpit", + Resource: "contact", + } +} + func cockpitCockpitActivate() *core.Command { return &core.Command{ Short: `Activate a cockpit`, @@ -332,6 +358,185 @@ func cockpitTokenDelete() *core.Command { } } +func cockpitContactCreate() *core.Command { + return &core.Command{ + Short: `Create an alert contact point`, + Long: `Create an alert contact point for the default receiver.`, + Namespace: "cockpit", + Resource: "contact", + Verb: "create", + // Deprecated: false, + ArgsType: reflect.TypeOf(cockpit.CreateContactPointRequest{}), + ArgSpecs: core.ArgSpecs{ + core.ProjectIDArgSpec(), + { + Name: "contact-point.email.to", + Required: false, + Deprecated: false, + Positional: false, + }, + }, + Run: func(ctx context.Context, args interface{}) (i interface{}, e error) { + request := args.(*cockpit.CreateContactPointRequest) + + client := core.ExtractClient(ctx) + api := cockpit.NewAPI(client) + return api.CreateContactPoint(request) + + }, + } +} + +func cockpitContactList() *core.Command { + return &core.Command{ + Short: `List alert contact points`, + Long: `List alert contact points associated with the given cockpit ID.`, + Namespace: "cockpit", + Resource: "contact", + Verb: "list", + // Deprecated: false, + ArgsType: reflect.TypeOf(cockpit.ListContactPointsRequest{}), + ArgSpecs: core.ArgSpecs{ + core.ProjectIDArgSpec(), + }, + Run: func(ctx context.Context, args interface{}) (i interface{}, e error) { + request := args.(*cockpit.ListContactPointsRequest) + + client := core.ExtractClient(ctx) + api := cockpit.NewAPI(client) + opts := []scw.RequestOption{scw.WithAllPages()} + resp, err := api.ListContactPoints(request, opts...) + if err != nil { + return nil, err + } + return resp.ContactPoints, nil + + }, + } +} + +func cockpitContactDelete() *core.Command { + return &core.Command{ + Short: `Delete an alert contact point`, + Long: `Delete an alert contact point for the default receiver.`, + Namespace: "cockpit", + Resource: "contact", + Verb: "delete", + // Deprecated: false, + ArgsType: reflect.TypeOf(cockpit.DeleteContactPointRequest{}), + ArgSpecs: core.ArgSpecs{ + core.ProjectIDArgSpec(), + { + Name: "contact-point.email.to", + Required: false, + Deprecated: false, + Positional: false, + }, + }, + Run: func(ctx context.Context, args interface{}) (i interface{}, e error) { + request := args.(*cockpit.DeleteContactPointRequest) + + client := core.ExtractClient(ctx) + api := cockpit.NewAPI(client) + e = api.DeleteContactPoint(request) + if e != nil { + return nil, e + } + return &core.SuccessResult{ + Resource: "contact", + Verb: "delete", + }, nil + }, + } +} + +func cockpitAlertEnable() *core.Command { + return &core.Command{ + Short: `Enable managed alerts`, + Long: `Enable managed alerts.`, + Namespace: "cockpit", + Resource: "alert", + Verb: "enable", + // Deprecated: false, + ArgsType: reflect.TypeOf(cockpit.EnableManagedAlertsRequest{}), + ArgSpecs: core.ArgSpecs{ + core.ProjectIDArgSpec(), + }, + Run: func(ctx context.Context, args interface{}) (i interface{}, e error) { + request := args.(*cockpit.EnableManagedAlertsRequest) + + client := core.ExtractClient(ctx) + api := cockpit.NewAPI(client) + e = api.EnableManagedAlerts(request) + if e != nil { + return nil, e + } + return &core.SuccessResult{ + Resource: "alert", + Verb: "enable", + }, nil + }, + } +} + +func cockpitAlertDisable() *core.Command { + return &core.Command{ + Short: `Disable managed alerts`, + Long: `Disable managed alerts.`, + Namespace: "cockpit", + Resource: "alert", + Verb: "disable", + // Deprecated: false, + ArgsType: reflect.TypeOf(cockpit.DisableManagedAlertsRequest{}), + ArgSpecs: core.ArgSpecs{ + core.ProjectIDArgSpec(), + }, + Run: func(ctx context.Context, args interface{}) (i interface{}, e error) { + request := args.(*cockpit.DisableManagedAlertsRequest) + + client := core.ExtractClient(ctx) + api := cockpit.NewAPI(client) + e = api.DisableManagedAlerts(request) + if e != nil { + return nil, e + } + return &core.SuccessResult{ + Resource: "alert", + Verb: "disable", + }, nil + }, + } +} + +func cockpitAlertTest() *core.Command { + return &core.Command{ + Short: `Trigger a test alert`, + Long: `Trigger a test alert to all receivers.`, + Namespace: "cockpit", + Resource: "alert", + Verb: "test", + // Deprecated: false, + ArgsType: reflect.TypeOf(cockpit.TriggerTestAlertRequest{}), + ArgSpecs: core.ArgSpecs{ + core.ProjectIDArgSpec(), + }, + Run: func(ctx context.Context, args interface{}) (i interface{}, e error) { + request := args.(*cockpit.TriggerTestAlertRequest) + + client := core.ExtractClient(ctx) + api := cockpit.NewAPI(client) + e = api.TriggerTestAlert(request) + if e != nil { + return nil, e + } + return &core.SuccessResult{ + Resource: "alert", + Verb: "test", + }, nil + }, + } +} + func cockpitGrafanaUserCreate() *core.Command { return &core.Command{ Short: `Create a grafana user`,