diff --git a/docs/stackit_config_set.md b/docs/stackit_config_set.md index 4d351ea33..469a907ed 100644 --- a/docs/stackit_config_set.md +++ b/docs/stackit_config_set.md @@ -29,27 +29,28 @@ stackit config set [flags] ### Options ``` - --argus-custom-endpoint string Argus API base URL, used in calls to this API - --authorization-custom-endpoint string Authorization API base URL, used in calls to this API - --dns-custom-endpoint string DNS API base URL, used in calls to this API - -h, --help Help for "stackit config set" - --identity-provider-custom-endpoint string Identity Provider base URL, used for user authentication - --load-balancer-custom-endpoint string Load Balancer API base URL, used in calls to this API - --logme-custom-endpoint string LogMe API base URL, used in calls to this API - --mariadb-custom-endpoint string MariaDB API base URL, used in calls to this API - --mongodbflex-custom-endpoint string MongoDB Flex API base URL, used in calls to this API - --object-storage-custom-endpoint string Object Storage API base URL, used in calls to this API - --opensearch-custom-endpoint string OpenSearch API base URL, used in calls to this API - --postgresflex-custom-endpoint string PostgreSQL Flex API base URL, used in calls to this API - --rabbitmq-custom-endpoint string RabbitMQ API base URL, used in calls to this API - --redis-custom-endpoint string Redis API base URL, used in calls to this API - --resource-manager-custom-endpoint string Resource Manager API base URL, used in calls to this API - --secrets-manager-custom-endpoint string Secrets Manager API base URL, used in calls to this API - --serverbackup-custom-endpoint string Server Backup API base URL, used in calls to this API - --service-account-custom-endpoint string Service Account API base URL, used in calls to this API - --session-time-limit string Maximum time before authentication is required again. After this time, you will be prompted to login again to execute commands that require authentication. Can't be larger than 24h. Requires authentication after being set to take effect. Examples: 3h, 5h30m40s (BETA: currently values greater than 2h have no effect) - --ske-custom-endpoint string SKE API base URL, used in calls to this API - --sqlserverflex-custom-endpoint string SQLServer Flex API base URL, used in calls to this API + --argus-custom-endpoint string Argus API base URL, used in calls to this API + --authorization-custom-endpoint string Authorization API base URL, used in calls to this API + --dns-custom-endpoint string DNS API base URL, used in calls to this API + -h, --help Help for "stackit config set" + --identity-provider-custom-endpoint string Identity Provider base URL, used for user authentication + --load-balancer-custom-endpoint string Load Balancer API base URL, used in calls to this API + --logme-custom-endpoint string LogMe API base URL, used in calls to this API + --mariadb-custom-endpoint string MariaDB API base URL, used in calls to this API + --mongodbflex-custom-endpoint string MongoDB Flex API base URL, used in calls to this API + --object-storage-custom-endpoint string Object Storage API base URL, used in calls to this API + --opensearch-custom-endpoint string OpenSearch API base URL, used in calls to this API + --postgresflex-custom-endpoint string PostgreSQL Flex API base URL, used in calls to this API + --rabbitmq-custom-endpoint string RabbitMQ API base URL, used in calls to this API + --redis-custom-endpoint string Redis API base URL, used in calls to this API + --resource-manager-custom-endpoint string Resource Manager API base URL, used in calls to this API + --secrets-manager-custom-endpoint string Secrets Manager API base URL, used in calls to this API + --serverbackup-custom-endpoint string Server Backup API base URL, used in calls to this API + --service-account-custom-endpoint string Service Account API base URL, used in calls to this API + --service-enablement-custom-endpoint string Service Enablement API base URL, used in calls to this API + --session-time-limit string Maximum time before authentication is required again. After this time, you will be prompted to login again to execute commands that require authentication. Can't be larger than 24h. Requires authentication after being set to take effect. Examples: 3h, 5h30m40s (BETA: currently values greater than 2h have no effect) + --ske-custom-endpoint string SKE API base URL, used in calls to this API + --sqlserverflex-custom-endpoint string SQLServer Flex API base URL, used in calls to this API ``` ### Options inherited from parent commands diff --git a/docs/stackit_config_unset.md b/docs/stackit_config_unset.md index 65d3e2cc7..f8c1e7b0c 100644 --- a/docs/stackit_config_unset.md +++ b/docs/stackit_config_unset.md @@ -26,31 +26,32 @@ stackit config unset [flags] ### Options ``` - --argus-custom-endpoint Argus API base URL. If unset, uses the default base URL - --async Configuration option to run commands asynchronously - --authorization-custom-endpoint Authorization API base URL. If unset, uses the default base URL - --dns-custom-endpoint DNS API base URL. If unset, uses the default base URL - -h, --help Help for "stackit config unset" - --identity-provider-custom-endpoint Identity Provider base URL. If unset, uses the default base URL - --load-balancer-custom-endpoint Load Balancer API base URL. If unset, uses the default base URL - --logme-custom-endpoint LogMe API base URL. If unset, uses the default base URL - --mariadb-custom-endpoint MariaDB API base URL. If unset, uses the default base URL - --mongodbflex-custom-endpoint MongoDB Flex API base URL. If unset, uses the default base URL - --object-storage-custom-endpoint Object Storage API base URL. If unset, uses the default base URL - --opensearch-custom-endpoint OpenSearch API base URL. If unset, uses the default base URL - --output-format Output format - --postgresflex-custom-endpoint PostgreSQL Flex API base URL. If unset, uses the default base URL - --project-id Project ID - --rabbitmq-custom-endpoint RabbitMQ API base URL. If unset, uses the default base URL - --redis-custom-endpoint Redis API base URL. If unset, uses the default base URL - --resource-manager-custom-endpoint Resource Manager API base URL. If unset, uses the default base URL - --secrets-manager-custom-endpoint Secrets Manager API base URL. If unset, uses the default base URL - --serverbackup-custom-endpoint Server Backup base URL. If unset, uses the default base URL - --service-account-custom-endpoint SKE API base URL. If unset, uses the default base URL - --session-time-limit Maximum time before authentication is required again. If unset, defaults to 2h - --ske-custom-endpoint SKE API base URL. If unset, uses the default base URL - --sqlserverflex-custom-endpoint SQLServer Flex API base URL. If unset, uses the default base URL - --verbosity Verbosity of the CLI + --argus-custom-endpoint Argus API base URL. If unset, uses the default base URL + --async Configuration option to run commands asynchronously + --authorization-custom-endpoint Authorization API base URL. If unset, uses the default base URL + --dns-custom-endpoint DNS API base URL. If unset, uses the default base URL + -h, --help Help for "stackit config unset" + --identity-provider-custom-endpoint Identity Provider base URL. If unset, uses the default base URL + --load-balancer-custom-endpoint Load Balancer API base URL. If unset, uses the default base URL + --logme-custom-endpoint LogMe API base URL. If unset, uses the default base URL + --mariadb-custom-endpoint MariaDB API base URL. If unset, uses the default base URL + --mongodbflex-custom-endpoint MongoDB Flex API base URL. If unset, uses the default base URL + --object-storage-custom-endpoint Object Storage API base URL. If unset, uses the default base URL + --opensearch-custom-endpoint OpenSearch API base URL. If unset, uses the default base URL + --output-format Output format + --postgresflex-custom-endpoint PostgreSQL Flex API base URL. If unset, uses the default base URL + --project-id Project ID + --rabbitmq-custom-endpoint RabbitMQ API base URL. If unset, uses the default base URL + --redis-custom-endpoint Redis API base URL. If unset, uses the default base URL + --resource-manager-custom-endpoint Resource Manager API base URL. If unset, uses the default base URL + --secrets-manager-custom-endpoint Secrets Manager API base URL. If unset, uses the default base URL + --serverbackup-custom-endpoint Server Backup base URL. If unset, uses the default base URL + --service-account-custom-endpoint Service Account API base URL. If unset, uses the default base URL + --service-enablement-custom-endpoint Service Enablement API base URL. If unset, uses the default base URL + --session-time-limit Maximum time before authentication is required again. If unset, defaults to 2h + --ske-custom-endpoint SKE API base URL. If unset, uses the default base URL + --sqlserverflex-custom-endpoint SQLServer Flex API base URL. If unset, uses the default base URL + --verbosity Verbosity of the CLI ``` ### Options inherited from parent commands diff --git a/go.mod b/go.mod index 3a109ac87..2244279de 100644 --- a/go.mod +++ b/go.mod @@ -25,6 +25,7 @@ require ( github.com/stackitcloud/stackit-sdk-go/services/secretsmanager v0.8.0 github.com/stackitcloud/stackit-sdk-go/services/serverbackup v0.1.0 github.com/stackitcloud/stackit-sdk-go/services/serviceaccount v0.4.0 + github.com/stackitcloud/stackit-sdk-go/services/serviceenablement v0.2.0 github.com/stackitcloud/stackit-sdk-go/services/ske v0.18.0 github.com/stackitcloud/stackit-sdk-go/services/sqlserverflex v0.3.0 github.com/zalando/go-keyring v0.2.5 diff --git a/go.sum b/go.sum index bcd424cd0..853f88f74 100644 --- a/go.sum +++ b/go.sum @@ -157,6 +157,8 @@ github.com/stackitcloud/stackit-sdk-go/services/serverbackup v0.1.0 h1:fYCBNvh4t github.com/stackitcloud/stackit-sdk-go/services/serverbackup v0.1.0/go.mod h1:ZYI3wj/NnhhWi25ugbdcniwnY/7mF6zN582c5HPe00o= github.com/stackitcloud/stackit-sdk-go/services/serviceaccount v0.4.0 h1:JB1O0E9+L50ZaO36uz7azurvUuB5JdX5s2ZXuIdb9t8= github.com/stackitcloud/stackit-sdk-go/services/serviceaccount v0.4.0/go.mod h1:Ni9RBJvcaXRIrDIuQBpJcuQvCQSj27crQSyc+WM4p0c= +github.com/stackitcloud/stackit-sdk-go/services/serviceenablement v0.2.0 h1:HAEFciLgeCY+kIcGcb+/zFUF3zt3z326v6JCen6fSjs= +github.com/stackitcloud/stackit-sdk-go/services/serviceenablement v0.2.0/go.mod h1:z6XdA+ndaWzcPW/P0QrUIcTXJzKlajxgGZ5+EwXNS+c= github.com/stackitcloud/stackit-sdk-go/services/ske v0.18.0 h1:gxbOYBpHBLMuzltbOGz7OwRFtjCZ9X56a2apsPP/8uU= github.com/stackitcloud/stackit-sdk-go/services/ske v0.18.0/go.mod h1:0fFs4R7kg+gU7FNAIzzFvlCZJz6gyZ8CFhbK3eSrAwQ= github.com/stackitcloud/stackit-sdk-go/services/sqlserverflex v0.3.0 h1:M6tcXUMNM6XMfHVQeQzB6IjfPdAxnZar3YD+YstRStc= diff --git a/internal/cmd/config/set/set.go b/internal/cmd/config/set/set.go index 887ea342b..e62407792 100644 --- a/internal/cmd/config/set/set.go +++ b/internal/cmd/config/set/set.go @@ -20,24 +20,25 @@ const ( sessionTimeLimitFlag = "session-time-limit" identityProviderCustomEndpointFlag = "identity-provider-custom-endpoint" - argusCustomEndpointFlag = "argus-custom-endpoint" - authorizationCustomEndpointFlag = "authorization-custom-endpoint" - dnsCustomEndpointFlag = "dns-custom-endpoint" - loadBalancerCustomEndpointFlag = "load-balancer-custom-endpoint" - logMeCustomEndpointFlag = "logme-custom-endpoint" - mariaDBCustomEndpointFlag = "mariadb-custom-endpoint" - mongoDBFlexCustomEndpointFlag = "mongodbflex-custom-endpoint" - objectStorageCustomEndpointFlag = "object-storage-custom-endpoint" - openSearchCustomEndpointFlag = "opensearch-custom-endpoint" - postgresFlexCustomEndpointFlag = "postgresflex-custom-endpoint" - rabbitMQCustomEndpointFlag = "rabbitmq-custom-endpoint" - redisCustomEndpointFlag = "redis-custom-endpoint" - resourceManagerCustomEndpointFlag = "resource-manager-custom-endpoint" - secretsManagerCustomEndpointFlag = "secrets-manager-custom-endpoint" - serverBackupCustomEndpointFlag = "serverbackup-custom-endpoint" - serviceAccountCustomEndpointFlag = "service-account-custom-endpoint" - skeCustomEndpointFlag = "ske-custom-endpoint" - sqlServerFlexCustomEndpointFlag = "sqlserverflex-custom-endpoint" + argusCustomEndpointFlag = "argus-custom-endpoint" + authorizationCustomEndpointFlag = "authorization-custom-endpoint" + dnsCustomEndpointFlag = "dns-custom-endpoint" + loadBalancerCustomEndpointFlag = "load-balancer-custom-endpoint" + logMeCustomEndpointFlag = "logme-custom-endpoint" + mariaDBCustomEndpointFlag = "mariadb-custom-endpoint" + mongoDBFlexCustomEndpointFlag = "mongodbflex-custom-endpoint" + objectStorageCustomEndpointFlag = "object-storage-custom-endpoint" + openSearchCustomEndpointFlag = "opensearch-custom-endpoint" + postgresFlexCustomEndpointFlag = "postgresflex-custom-endpoint" + rabbitMQCustomEndpointFlag = "rabbitmq-custom-endpoint" + redisCustomEndpointFlag = "redis-custom-endpoint" + resourceManagerCustomEndpointFlag = "resource-manager-custom-endpoint" + secretsManagerCustomEndpointFlag = "secrets-manager-custom-endpoint" + serverBackupCustomEndpointFlag = "serverbackup-custom-endpoint" + serviceAccountCustomEndpointFlag = "service-account-custom-endpoint" + serviceEnablementCustomEndpointFlag = "service-enablement-custom-endpoint" + skeCustomEndpointFlag = "ske-custom-endpoint" + sqlServerFlexCustomEndpointFlag = "sqlserverflex-custom-endpoint" ) type inputModel struct { @@ -141,6 +142,7 @@ func configureFlags(cmd *cobra.Command) { cmd.Flags().String(resourceManagerCustomEndpointFlag, "", "Resource Manager API base URL, used in calls to this API") cmd.Flags().String(secretsManagerCustomEndpointFlag, "", "Secrets Manager API base URL, used in calls to this API") cmd.Flags().String(serviceAccountCustomEndpointFlag, "", "Service Account API base URL, used in calls to this API") + cmd.Flags().String(serviceEnablementCustomEndpointFlag, "", "Service Enablement API base URL, used in calls to this API") cmd.Flags().String(serverBackupCustomEndpointFlag, "", "Server Backup API base URL, used in calls to this API") cmd.Flags().String(skeCustomEndpointFlag, "", "SKE API base URL, used in calls to this API") cmd.Flags().String(sqlServerFlexCustomEndpointFlag, "", "SQLServer Flex API base URL, used in calls to this API") @@ -182,6 +184,8 @@ func configureFlags(cmd *cobra.Command) { cobra.CheckErr(err) err = viper.BindPFlag(config.ServiceAccountCustomEndpointKey, cmd.Flags().Lookup(serviceAccountCustomEndpointFlag)) cobra.CheckErr(err) + err = viper.BindPFlag(config.ServiceEnablementCustomEndpointKey, cmd.Flags().Lookup(serviceEnablementCustomEndpointFlag)) + cobra.CheckErr(err) err = viper.BindPFlag(config.SKECustomEndpointKey, cmd.Flags().Lookup(skeCustomEndpointFlag)) cobra.CheckErr(err) err = viper.BindPFlag(config.SQLServerFlexCustomEndpointKey, cmd.Flags().Lookup(sqlServerFlexCustomEndpointFlag)) diff --git a/internal/cmd/config/unset/unset.go b/internal/cmd/config/unset/unset.go index 17128a035..46c541af5 100644 --- a/internal/cmd/config/unset/unset.go +++ b/internal/cmd/config/unset/unset.go @@ -23,24 +23,25 @@ const ( sessionTimeLimitFlag = "session-time-limit" identityProviderCustomEndpointFlag = "identity-provider-custom-endpoint" - argusCustomEndpointFlag = "argus-custom-endpoint" - authorizationCustomEndpointFlag = "authorization-custom-endpoint" - dnsCustomEndpointFlag = "dns-custom-endpoint" - loadBalancerCustomEndpointFlag = "load-balancer-custom-endpoint" - logMeCustomEndpointFlag = "logme-custom-endpoint" - mariaDBCustomEndpointFlag = "mariadb-custom-endpoint" - mongoDBFlexCustomEndpointFlag = "mongodbflex-custom-endpoint" - objectStorageCustomEndpointFlag = "object-storage-custom-endpoint" - openSearchCustomEndpointFlag = "opensearch-custom-endpoint" - postgresFlexCustomEndpointFlag = "postgresflex-custom-endpoint" - rabbitMQCustomEndpointFlag = "rabbitmq-custom-endpoint" - redisCustomEndpointFlag = "redis-custom-endpoint" - resourceManagerCustomEndpointFlag = "resource-manager-custom-endpoint" - secretsManagerCustomEndpointFlag = "secrets-manager-custom-endpoint" - serviceAccountCustomEndpointFlag = "service-account-custom-endpoint" - serverBackupCustomEndpointFlag = "serverbackup-custom-endpoint" - skeCustomEndpointFlag = "ske-custom-endpoint" - sqlServerFlexCustomEndpointFlag = "sqlserverflex-custom-endpoint" + argusCustomEndpointFlag = "argus-custom-endpoint" + authorizationCustomEndpointFlag = "authorization-custom-endpoint" + dnsCustomEndpointFlag = "dns-custom-endpoint" + loadBalancerCustomEndpointFlag = "load-balancer-custom-endpoint" + logMeCustomEndpointFlag = "logme-custom-endpoint" + mariaDBCustomEndpointFlag = "mariadb-custom-endpoint" + mongoDBFlexCustomEndpointFlag = "mongodbflex-custom-endpoint" + objectStorageCustomEndpointFlag = "object-storage-custom-endpoint" + openSearchCustomEndpointFlag = "opensearch-custom-endpoint" + postgresFlexCustomEndpointFlag = "postgresflex-custom-endpoint" + rabbitMQCustomEndpointFlag = "rabbitmq-custom-endpoint" + redisCustomEndpointFlag = "redis-custom-endpoint" + resourceManagerCustomEndpointFlag = "resource-manager-custom-endpoint" + secretsManagerCustomEndpointFlag = "secrets-manager-custom-endpoint" + serviceAccountCustomEndpointFlag = "service-account-custom-endpoint" + serviceEnablementCustomEndpointFlag = "service-enablement-custom-endpoint" + serverBackupCustomEndpointFlag = "serverbackup-custom-endpoint" + skeCustomEndpointFlag = "ske-custom-endpoint" + sqlServerFlexCustomEndpointFlag = "sqlserverflex-custom-endpoint" ) type inputModel struct { @@ -52,24 +53,25 @@ type inputModel struct { SessionTimeLimit bool IdentityProviderCustomEndpoint bool - ArgusCustomEndpoint bool - AuthorizationCustomEndpoint bool - DNSCustomEndpoint bool - LoadBalancerCustomEndpoint bool - LogMeCustomEndpoint bool - MariaDBCustomEndpoint bool - MongoDBFlexCustomEndpoint bool - ObjectStorageCustomEndpoint bool - OpenSearchCustomEndpoint bool - PostgresFlexCustomEndpoint bool - RabbitMQCustomEndpoint bool - RedisCustomEndpoint bool - ResourceManagerCustomEndpoint bool - SecretsManagerCustomEndpoint bool - ServerBackupCustomEndpoint bool - ServiceAccountCustomEndpoint bool - SKECustomEndpoint bool - SQLServerFlexCustomEndpoint bool + ArgusCustomEndpoint bool + AuthorizationCustomEndpoint bool + DNSCustomEndpoint bool + LoadBalancerCustomEndpoint bool + LogMeCustomEndpoint bool + MariaDBCustomEndpoint bool + MongoDBFlexCustomEndpoint bool + ObjectStorageCustomEndpoint bool + OpenSearchCustomEndpoint bool + PostgresFlexCustomEndpoint bool + RabbitMQCustomEndpoint bool + RedisCustomEndpoint bool + ResourceManagerCustomEndpoint bool + SecretsManagerCustomEndpoint bool + ServerBackupCustomEndpoint bool + ServiceAccountCustomEndpoint bool + ServiceEnablementCustomEndpoint bool + SKECustomEndpoint bool + SQLServerFlexCustomEndpoint bool } func NewCmd(p *print.Printer) *cobra.Command { @@ -157,6 +159,9 @@ func NewCmd(p *print.Printer) *cobra.Command { if model.ServiceAccountCustomEndpoint { viper.Set(config.ServiceAccountCustomEndpointKey, "") } + if model.ServiceEnablementCustomEndpoint { + viper.Set(config.ServiceEnablementCustomEndpointKey, "") + } if model.ServerBackupCustomEndpoint { viper.Set(config.ServerBackupCustomEndpointKey, "") } @@ -201,7 +206,8 @@ func configureFlags(cmd *cobra.Command) { cmd.Flags().Bool(redisCustomEndpointFlag, false, "Redis API base URL. If unset, uses the default base URL") cmd.Flags().Bool(resourceManagerCustomEndpointFlag, false, "Resource Manager API base URL. If unset, uses the default base URL") cmd.Flags().Bool(secretsManagerCustomEndpointFlag, false, "Secrets Manager API base URL. If unset, uses the default base URL") - cmd.Flags().Bool(serviceAccountCustomEndpointFlag, false, "SKE API base URL. If unset, uses the default base URL") + cmd.Flags().Bool(serviceAccountCustomEndpointFlag, false, "Service Account API base URL. If unset, uses the default base URL") + cmd.Flags().Bool(serviceEnablementCustomEndpointFlag, false, "Service Enablement API base URL. If unset, uses the default base URL") cmd.Flags().Bool(serverBackupCustomEndpointFlag, false, "Server Backup base URL. If unset, uses the default base URL") cmd.Flags().Bool(skeCustomEndpointFlag, false, "SKE API base URL. If unset, uses the default base URL") cmd.Flags().Bool(sqlServerFlexCustomEndpointFlag, false, "SQLServer Flex API base URL. If unset, uses the default base URL") @@ -217,24 +223,25 @@ func parseInput(p *print.Printer, cmd *cobra.Command) *inputModel { SessionTimeLimit: flags.FlagToBoolValue(p, cmd, sessionTimeLimitFlag), IdentityProviderCustomEndpoint: flags.FlagToBoolValue(p, cmd, identityProviderCustomEndpointFlag), - ArgusCustomEndpoint: flags.FlagToBoolValue(p, cmd, argusCustomEndpointFlag), - AuthorizationCustomEndpoint: flags.FlagToBoolValue(p, cmd, authorizationCustomEndpointFlag), - DNSCustomEndpoint: flags.FlagToBoolValue(p, cmd, dnsCustomEndpointFlag), - LoadBalancerCustomEndpoint: flags.FlagToBoolValue(p, cmd, loadBalancerCustomEndpointFlag), - LogMeCustomEndpoint: flags.FlagToBoolValue(p, cmd, logMeCustomEndpointFlag), - MariaDBCustomEndpoint: flags.FlagToBoolValue(p, cmd, mariaDBCustomEndpointFlag), - MongoDBFlexCustomEndpoint: flags.FlagToBoolValue(p, cmd, mongoDBFlexCustomEndpointFlag), - ObjectStorageCustomEndpoint: flags.FlagToBoolValue(p, cmd, objectStorageCustomEndpointFlag), - OpenSearchCustomEndpoint: flags.FlagToBoolValue(p, cmd, openSearchCustomEndpointFlag), - PostgresFlexCustomEndpoint: flags.FlagToBoolValue(p, cmd, postgresFlexCustomEndpointFlag), - RabbitMQCustomEndpoint: flags.FlagToBoolValue(p, cmd, rabbitMQCustomEndpointFlag), - RedisCustomEndpoint: flags.FlagToBoolValue(p, cmd, redisCustomEndpointFlag), - ResourceManagerCustomEndpoint: flags.FlagToBoolValue(p, cmd, resourceManagerCustomEndpointFlag), - SecretsManagerCustomEndpoint: flags.FlagToBoolValue(p, cmd, secretsManagerCustomEndpointFlag), - ServiceAccountCustomEndpoint: flags.FlagToBoolValue(p, cmd, serviceAccountCustomEndpointFlag), - ServerBackupCustomEndpoint: flags.FlagToBoolValue(p, cmd, serverBackupCustomEndpointFlag), - SKECustomEndpoint: flags.FlagToBoolValue(p, cmd, skeCustomEndpointFlag), - SQLServerFlexCustomEndpoint: flags.FlagToBoolValue(p, cmd, sqlServerFlexCustomEndpointFlag), + ArgusCustomEndpoint: flags.FlagToBoolValue(p, cmd, argusCustomEndpointFlag), + AuthorizationCustomEndpoint: flags.FlagToBoolValue(p, cmd, authorizationCustomEndpointFlag), + DNSCustomEndpoint: flags.FlagToBoolValue(p, cmd, dnsCustomEndpointFlag), + LoadBalancerCustomEndpoint: flags.FlagToBoolValue(p, cmd, loadBalancerCustomEndpointFlag), + LogMeCustomEndpoint: flags.FlagToBoolValue(p, cmd, logMeCustomEndpointFlag), + MariaDBCustomEndpoint: flags.FlagToBoolValue(p, cmd, mariaDBCustomEndpointFlag), + MongoDBFlexCustomEndpoint: flags.FlagToBoolValue(p, cmd, mongoDBFlexCustomEndpointFlag), + ObjectStorageCustomEndpoint: flags.FlagToBoolValue(p, cmd, objectStorageCustomEndpointFlag), + OpenSearchCustomEndpoint: flags.FlagToBoolValue(p, cmd, openSearchCustomEndpointFlag), + PostgresFlexCustomEndpoint: flags.FlagToBoolValue(p, cmd, postgresFlexCustomEndpointFlag), + RabbitMQCustomEndpoint: flags.FlagToBoolValue(p, cmd, rabbitMQCustomEndpointFlag), + RedisCustomEndpoint: flags.FlagToBoolValue(p, cmd, redisCustomEndpointFlag), + ResourceManagerCustomEndpoint: flags.FlagToBoolValue(p, cmd, resourceManagerCustomEndpointFlag), + SecretsManagerCustomEndpoint: flags.FlagToBoolValue(p, cmd, secretsManagerCustomEndpointFlag), + ServiceAccountCustomEndpoint: flags.FlagToBoolValue(p, cmd, serviceAccountCustomEndpointFlag), + ServiceEnablementCustomEndpoint: flags.FlagToBoolValue(p, cmd, serviceEnablementCustomEndpointFlag), + ServerBackupCustomEndpoint: flags.FlagToBoolValue(p, cmd, serverBackupCustomEndpointFlag), + SKECustomEndpoint: flags.FlagToBoolValue(p, cmd, skeCustomEndpointFlag), + SQLServerFlexCustomEndpoint: flags.FlagToBoolValue(p, cmd, sqlServerFlexCustomEndpointFlag), } if p.IsVerbosityDebug() { diff --git a/internal/cmd/ske/disable/disable.go b/internal/cmd/ske/disable/disable.go index 23fe45a02..1a05ef2ad 100644 --- a/internal/cmd/ske/disable/disable.go +++ b/internal/cmd/ske/disable/disable.go @@ -10,12 +10,13 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" "github.com/stackitcloud/stackit-cli/internal/pkg/print" "github.com/stackitcloud/stackit-cli/internal/pkg/projectname" - "github.com/stackitcloud/stackit-cli/internal/pkg/services/ske/client" + "github.com/stackitcloud/stackit-cli/internal/pkg/services/service-enablement/client" + "github.com/stackitcloud/stackit-cli/internal/pkg/services/service-enablement/utils" "github.com/stackitcloud/stackit-cli/internal/pkg/spinner" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/ske" - "github.com/stackitcloud/stackit-sdk-go/services/ske/wait" + "github.com/stackitcloud/stackit-sdk-go/services/serviceenablement" + "github.com/stackitcloud/stackit-sdk-go/services/serviceenablement/wait" ) type inputModel struct { @@ -62,7 +63,7 @@ func NewCmd(p *print.Printer) *cobra.Command { // Call API req := buildRequest(ctx, model, apiClient) - _, err = req.Execute() + err = req.Execute() if err != nil { return fmt.Errorf("disable SKE: %w", err) } @@ -71,7 +72,7 @@ func NewCmd(p *print.Printer) *cobra.Command { if !model.Async { s := spinner.New(p) s.Start("Disabling SKE") - _, err = wait.DisableServiceWaitHandler(ctx, apiClient, model.ProjectId).WaitWithContext(ctx) + _, err = wait.DisableServiceWaitHandler(ctx, apiClient, model.ProjectId, utils.SKEServiceId).WaitWithContext(ctx) if err != nil { return fmt.Errorf("wait for SKE disabling: %w", err) } @@ -111,7 +112,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command) (*inputModel, error) { return &model, nil } -func buildRequest(ctx context.Context, model *inputModel, apiClient *ske.APIClient) ske.ApiDisableServiceRequest { - req := apiClient.DisableService(ctx, model.ProjectId) //nolint:staticcheck //command will be removed in a later update +func buildRequest(ctx context.Context, model *inputModel, apiClient *serviceenablement.APIClient) serviceenablement.ApiDisableServiceRequest { + req := apiClient.DisableService(ctx, model.ProjectId, utils.SKEServiceId) return req } diff --git a/internal/cmd/ske/disable/disable_test.go b/internal/cmd/ske/disable/disable_test.go index b3047fe54..cc9a528a6 100644 --- a/internal/cmd/ske/disable/disable_test.go +++ b/internal/cmd/ske/disable/disable_test.go @@ -6,12 +6,13 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" "github.com/stackitcloud/stackit-cli/internal/pkg/print" + "github.com/stackitcloud/stackit-cli/internal/pkg/services/service-enablement/utils" "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/ske" + "github.com/stackitcloud/stackit-sdk-go/services/serviceenablement" ) var projectIdFlag = globalflags.ProjectIdFlag @@ -19,7 +20,7 @@ var projectIdFlag = globalflags.ProjectIdFlag type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &ske.APIClient{} +var testClient = &serviceenablement.APIClient{} var testProjectId = uuid.NewString() func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string { @@ -45,8 +46,8 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { return model } -func fixtureRequest(mods ...func(request *ske.ApiDisableServiceRequest)) ske.ApiDisableServiceRequest { - request := testClient.DisableService(testCtx, testProjectId) //nolint:staticcheck //command will be removed in a later update +func fixtureRequest(mods ...func(request *serviceenablement.ApiDisableServiceRequest)) serviceenablement.ApiDisableServiceRequest { + request := testClient.DisableService(testCtx, testProjectId, utils.SKEServiceId) for _, mod := range mods { mod(&request) } @@ -144,7 +145,7 @@ func TestBuildRequest(t *testing.T) { tests := []struct { description string model *inputModel - expectedRequest ske.ApiDisableServiceRequest + expectedRequest serviceenablement.ApiDisableServiceRequest }{ { description: "base", diff --git a/internal/cmd/ske/enable/enable.go b/internal/cmd/ske/enable/enable.go index d8dd3e814..ab1afb319 100644 --- a/internal/cmd/ske/enable/enable.go +++ b/internal/cmd/ske/enable/enable.go @@ -10,12 +10,13 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" "github.com/stackitcloud/stackit-cli/internal/pkg/print" "github.com/stackitcloud/stackit-cli/internal/pkg/projectname" - "github.com/stackitcloud/stackit-cli/internal/pkg/services/ske/client" + "github.com/stackitcloud/stackit-cli/internal/pkg/services/service-enablement/client" + "github.com/stackitcloud/stackit-cli/internal/pkg/services/service-enablement/utils" "github.com/stackitcloud/stackit-cli/internal/pkg/spinner" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/ske" - "github.com/stackitcloud/stackit-sdk-go/services/ske/wait" + "github.com/stackitcloud/stackit-sdk-go/services/serviceenablement" + "github.com/stackitcloud/stackit-sdk-go/services/serviceenablement/wait" ) type inputModel struct { @@ -62,7 +63,7 @@ func NewCmd(p *print.Printer) *cobra.Command { // Call API req := buildRequest(ctx, model, apiClient) - _, err = req.Execute() + err = req.Execute() if err != nil { return fmt.Errorf("enable SKE: %w", err) } @@ -71,7 +72,7 @@ func NewCmd(p *print.Printer) *cobra.Command { if !model.Async { s := spinner.New(p) s.Start("Enabling SKE") - _, err = wait.EnableServiceWaitHandler(ctx, apiClient, model.ProjectId).WaitWithContext(ctx) + _, err = wait.EnableServiceWaitHandler(ctx, apiClient, model.ProjectId, utils.SKEServiceId).WaitWithContext(ctx) if err != nil { return fmt.Errorf("wait for SKE enabling: %w", err) } @@ -111,7 +112,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command) (*inputModel, error) { return &model, nil } -func buildRequest(ctx context.Context, model *inputModel, apiClient *ske.APIClient) ske.ApiEnableServiceRequest { - req := apiClient.EnableService(ctx, model.ProjectId) //nolint:staticcheck //command will be removed in a later update +func buildRequest(ctx context.Context, model *inputModel, apiClient *serviceenablement.APIClient) serviceenablement.ApiEnableServiceRequest { + req := apiClient.EnableService(ctx, model.ProjectId, utils.SKEServiceId) return req } diff --git a/internal/cmd/ske/enable/enable_test.go b/internal/cmd/ske/enable/enable_test.go index 81103b3ae..e0f93b8fc 100644 --- a/internal/cmd/ske/enable/enable_test.go +++ b/internal/cmd/ske/enable/enable_test.go @@ -6,12 +6,13 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" "github.com/stackitcloud/stackit-cli/internal/pkg/print" + "github.com/stackitcloud/stackit-cli/internal/pkg/services/service-enablement/utils" "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/ske" + "github.com/stackitcloud/stackit-sdk-go/services/serviceenablement" ) var projectIdFlag = globalflags.ProjectIdFlag @@ -19,7 +20,7 @@ var projectIdFlag = globalflags.ProjectIdFlag type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &ske.APIClient{} +var testClient = &serviceenablement.APIClient{} var testProjectId = uuid.NewString() func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string { @@ -45,8 +46,8 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { return model } -func fixtureRequest(mods ...func(request *ske.ApiEnableServiceRequest)) ske.ApiEnableServiceRequest { - request := testClient.EnableService(testCtx, testProjectId) //nolint:staticcheck //command will be removed in a later update +func fixtureRequest(mods ...func(request *serviceenablement.ApiEnableServiceRequest)) serviceenablement.ApiEnableServiceRequest { + request := testClient.EnableService(testCtx, testProjectId, utils.SKEServiceId) for _, mod := range mods { mod(&request) } @@ -144,7 +145,7 @@ func TestBuildRequest(t *testing.T) { tests := []struct { description string model *inputModel - expectedRequest ske.ApiEnableServiceRequest + expectedRequest serviceenablement.ApiEnableServiceRequest }{ { description: "base", diff --git a/internal/pkg/config/config.go b/internal/pkg/config/config.go index 4716fb5db..016b6248a 100644 --- a/internal/pkg/config/config.go +++ b/internal/pkg/config/config.go @@ -19,24 +19,25 @@ const ( IdentityProviderCustomEndpointKey = "identity_provider_custom_endpoint" - ArgusCustomEndpointKey = "argus_custom_endpoint" - AuthorizationCustomEndpointKey = "authorization_custom_endpoint" - DNSCustomEndpointKey = "dns_custom_endpoint" - LoadBalancerCustomEndpointKey = "load_balancer_custom_endpoint" - LogMeCustomEndpointKey = "logme_custom_endpoint" - MariaDBCustomEndpointKey = "mariadb_custom_endpoint" - MongoDBFlexCustomEndpointKey = "mongodbflex_custom_endpoint" - ObjectStorageCustomEndpointKey = "object_storage_custom_endpoint" - OpenSearchCustomEndpointKey = "opensearch_custom_endpoint" - PostgresFlexCustomEndpointKey = "postgresflex_custom_endpoint" - RabbitMQCustomEndpointKey = "rabbitmq_custom_endpoint" - RedisCustomEndpointKey = "redis_custom_endpoint" - ResourceManagerEndpointKey = "resource_manager_custom_endpoint" - SecretsManagerCustomEndpointKey = "secrets_manager_custom_endpoint" - ServiceAccountCustomEndpointKey = "service_account_custom_endpoint" - ServerBackupCustomEndpointKey = "serverbackup_custom_endpoint" - SKECustomEndpointKey = "ske_custom_endpoint" - SQLServerFlexCustomEndpointKey = "sqlserverflex_custom_endpoint" + ArgusCustomEndpointKey = "argus_custom_endpoint" + AuthorizationCustomEndpointKey = "authorization_custom_endpoint" + DNSCustomEndpointKey = "dns_custom_endpoint" + LoadBalancerCustomEndpointKey = "load_balancer_custom_endpoint" + LogMeCustomEndpointKey = "logme_custom_endpoint" + MariaDBCustomEndpointKey = "mariadb_custom_endpoint" + MongoDBFlexCustomEndpointKey = "mongodbflex_custom_endpoint" + ObjectStorageCustomEndpointKey = "object_storage_custom_endpoint" + OpenSearchCustomEndpointKey = "opensearch_custom_endpoint" + PostgresFlexCustomEndpointKey = "postgresflex_custom_endpoint" + RabbitMQCustomEndpointKey = "rabbitmq_custom_endpoint" + RedisCustomEndpointKey = "redis_custom_endpoint" + ResourceManagerEndpointKey = "resource_manager_custom_endpoint" + SecretsManagerCustomEndpointKey = "secrets_manager_custom_endpoint" + ServiceAccountCustomEndpointKey = "service_account_custom_endpoint" + ServiceEnablementCustomEndpointKey = "service_enablement_custom_endpoint" + ServerBackupCustomEndpointKey = "serverbackup_custom_endpoint" + SKECustomEndpointKey = "ske_custom_endpoint" + SQLServerFlexCustomEndpointKey = "sqlserverflex_custom_endpoint" ProjectNameKey = "project_name" DefaultProfileName = "default" @@ -81,6 +82,7 @@ var ConfigKeys = []string{ ResourceManagerEndpointKey, SecretsManagerCustomEndpointKey, ServiceAccountCustomEndpointKey, + ServiceEnablementCustomEndpointKey, ServerBackupCustomEndpointKey, SKECustomEndpointKey, SQLServerFlexCustomEndpointKey, @@ -152,6 +154,7 @@ func setConfigDefaults() { viper.SetDefault(ResourceManagerEndpointKey, "") viper.SetDefault(SecretsManagerCustomEndpointKey, "") viper.SetDefault(ServiceAccountCustomEndpointKey, "") + viper.SetDefault(ServiceEnablementCustomEndpointKey, "") viper.SetDefault(ServerBackupCustomEndpointKey, "") viper.SetDefault(SKECustomEndpointKey, "") viper.SetDefault(SQLServerFlexCustomEndpointKey, "") diff --git a/internal/pkg/services/service-enablement/client/client.go b/internal/pkg/services/service-enablement/client/client.go new file mode 100644 index 000000000..9c260d51b --- /dev/null +++ b/internal/pkg/services/service-enablement/client/client.go @@ -0,0 +1,46 @@ +package client + +import ( + "github.com/spf13/viper" + "github.com/stackitcloud/stackit-cli/internal/pkg/auth" + "github.com/stackitcloud/stackit-cli/internal/pkg/config" + "github.com/stackitcloud/stackit-cli/internal/pkg/errors" + "github.com/stackitcloud/stackit-cli/internal/pkg/print" + + sdkConfig "github.com/stackitcloud/stackit-sdk-go/core/config" + "github.com/stackitcloud/stackit-sdk-go/services/serviceenablement" +) + +func ConfigureClient(p *print.Printer) (*serviceenablement.APIClient, error) { + var err error + var apiClient *serviceenablement.APIClient + var cfgOptions []sdkConfig.ConfigurationOption + + authCfgOption, err := auth.AuthenticationConfig(p, auth.AuthorizeUser) + if err != nil { + p.Debug(print.ErrorLevel, "configure authentication: %v", err) + return nil, &errors.AuthError{} + } + cfgOptions = append(cfgOptions, authCfgOption) + + customEndpoint := viper.GetString(config.ServiceEnablementCustomEndpointKey) + if customEndpoint != "" { + cfgOptions = append(cfgOptions, sdkConfig.WithEndpoint(customEndpoint)) + } else { + cfgOptions = append(cfgOptions, sdkConfig.WithRegion("eu01")) + } + + if p.IsVerbosityDebug() { + cfgOptions = append(cfgOptions, + sdkConfig.WithMiddleware(print.RequestResponseCapturer(p, nil)), + ) + } + + apiClient, err = serviceenablement.NewAPIClient(cfgOptions...) + if err != nil { + p.Debug(print.ErrorLevel, "create new API client: %v", err) + return nil, &errors.AuthError{} + } + + return apiClient, nil +} diff --git a/internal/pkg/services/service-enablement/utils/utils.go b/internal/pkg/services/service-enablement/utils/utils.go new file mode 100644 index 000000000..27952a763 --- /dev/null +++ b/internal/pkg/services/service-enablement/utils/utils.go @@ -0,0 +1,5 @@ +package utils + +const ( + SKEServiceId = "cloud.stackit.ske" +)