From 7135aaf9799abeb98514a1148b1f269c681785a2 Mon Sep 17 00:00:00 2001 From: Deatcu Andrei-Cristian Date: Fri, 29 Nov 2024 12:36:58 +0200 Subject: [PATCH] feat: Implement 'update' method for MariaDB clusters (#718) --- CHANGELOG.md | 58 +-- docs/resources/dbaas_mariadb_cluster.md | 2 +- go.mod | 4 +- go.sum | 4 +- ionoscloud/resource_dbaas_mariadb_cluster.go | 56 ++- .../resource_dbaas_mariadb_cluster_test.go | 73 +++- services/dbaas/mariadb/cluster.go | 56 +++ .../sdk-go-dbaas-mariadb/README.md | 195 ++++----- .../sdk-go-dbaas-mariadb/api_clusters.go | 231 +++++++++++ .../sdk-go-dbaas-mariadb/api_restore.go | 252 ++++++++++++ .../sdk-go-dbaas-mariadb/client.go | 5 +- .../sdk-go-dbaas-mariadb/configuration.go | 37 +- .../model_create_cluster_properties.go | 43 ++ .../model_patch_cluster_properties.go | 384 ++++++++++++++++++ .../model_patch_cluster_request.go | 164 ++++++++ .../model_restore_request.go | 176 ++++++++ vendor/modules.txt | 2 +- 17 files changed, 1590 insertions(+), 152 deletions(-) create mode 100644 vendor/github.com/ionos-cloud/sdk-go-dbaas-mariadb/api_restore.go create mode 100644 vendor/github.com/ionos-cloud/sdk-go-dbaas-mariadb/model_patch_cluster_properties.go create mode 100644 vendor/github.com/ionos-cloud/sdk-go-dbaas-mariadb/model_patch_cluster_request.go create mode 100644 vendor/github.com/ionos-cloud/sdk-go-dbaas-mariadb/model_restore_request.go diff --git a/CHANGELOG.md b/CHANGELOG.md index 111d3c9c7..24eab926f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,6 @@ ## 6.6.5 -- upcoming release +### Features +- Resource `ionoscloud_mariadb_cluster` now supports updates ### Testing - Add import tests for MariaDB clusters @@ -188,7 +190,7 @@ - Add s3 bucket, object, policy resources with base functionality ### Enhancements - Move to `sdk-go-bundle` for logging sdk -### Fixes +### Fixes - Fixes #607. Container registry should wait until the resource is ready before returning the ID. - Move tests from AMD_OPTERON to INTEL_XEON - Data source `ionoscloud_mongo_template` should have id `computed` and `optional` @@ -226,7 +228,7 @@ - Fix documentation for `ionoscloud_server`, `ionoscloud_volume`, `ionoscloud_lan` resources and `ionoscloud_image` data sources ### Enhancements -- Add configurable fields to `ionoscloud_share` resource. Fields that can be set on creation: `description`, `sec_auth_protection`, `licence_type`. +- Add configurable fields to `ionoscloud_share` resource. Fields that can be set on creation: `description`, `sec_auth_protection`, `licence_type`. Updatable fields: `description`, `licence_type`, `nic_hot_plug`, `cpu_hot_plug`, `nic_hot_unplug`, `disc_virtio_hot_plug`, `disc_virtio_hot_unplug`, `ram_hot_plug`. - Allow MariaDB cluster creation in other zones than `de/txl` by adding `location` parameter to resources and data sources @@ -324,7 +326,7 @@ Updatable fields: `description`, `licence_type`, `nic_hot_plug`, `cpu_hot_plug`, - #412 add support to set power state of Enterprise and Cube servers, by adding the new field `vm_state` in `ionoscloud_server`, `ionoscloud_cube_server` and `ionoscloud_vcpu_server `resources ### Fixes - #467 removing an inline `nic` of the `server` resource from dcd should not throw 404 when running plan or apply after -- #432 Now it is possible to create and delete multiple `ionoscloud_ipfailover` resources at the same time. The UUID is generated based on the IP of the +- #432 Now it is possible to create and delete multiple `ionoscloud_ipfailover` resources at the same time. The UUID is generated based on the IP of the failover group. The resources that are created using Terraform cannot be modified/deleted outside Terraform. - Fix `nil` deref error on list for nic datasource - #470 fix image name searching in `ionoscloud_image` and `ionoscloud_volume`. Exact matches are returned correctly now if they exist. @@ -394,7 +396,7 @@ failover group. The resources that are created using Terraform cannot be modifie ## 6.4.2 ### Fixes -- Fix `ssh_keys` field upgrade `ionoscloud_server` from `6.3.3` to higher versions should not replace server. `ssh_keys` and `ssh_key_path` fields no longer forceNew. +- Fix `ssh_keys` field upgrade `ionoscloud_server` from `6.3.3` to higher versions should not replace server. `ssh_keys` and `ssh_key_path` fields no longer forceNew. `ssh_keys` is no longer computed. - Fix `ssh_keys` suppress diff on upgrade for `ionoscloud_server` when having `volume.0.ssh_keys` - Add validation to `label` `key` and `value` fields for `ionoscloud_server` resource @@ -508,7 +510,7 @@ Please contact your sales representative or support for more information. - [ionoscloud_container_registry](docs/data-sources/container_registry.md) - [ionoscloud_container_registry_token](docs/data-sources/container_registry_token.md) - [ionoscloud_container_registry_locations](docs/data-sources/container_registry_locations.md) - + ⚠️ **Note:** Container Registry is currently in the Early Access (EA) phase. We recommend keeping usage and testing to non-production critical applications. Please contact your sales representative or support for more information. ### Fixes @@ -543,7 +545,7 @@ Please contact your sales representative or support for more information. - `ssh_key_path` will now allow the keys to be passed directly also. In the future, will be renamed to `ssh_keys`. ### Fixes -- Reproduces rarely: sometimes the `nic` resource is not found after creation. As a fix we added a retry for 5 minutes to be able to get the NIC. The retry will keep trying if the response +- Reproduces rarely: sometimes the `nic` resource is not found after creation. As a fix we added a retry for 5 minutes to be able to get the NIC. The retry will keep trying if the response is `not found`(404) - Fix cube server creation. Some attributes were not populated - name, boot_cdrom, availability_zone - Crash on update of k8s version when we have a value without `.` @@ -579,12 +581,12 @@ is `not found`(404) ## 6.2.5 ### Enhancement -- Update sdk-go dependency to v6.0.3. +- Update sdk-go dependency to v6.0.3. * enable certificate pinning, by setting IONOS_PINNED_CERT env variable - Temporarily removed `gateway_ip` and `public` fields for k8s - Introduced error when trying to set `max_node_count` equal to `min_node_count` in `k8s_node_pool` -### Fixes +### Fixes - Crash when trying to disable `autoscaling` on `k8s_node_pool` ## 6.2.4 @@ -617,7 +619,7 @@ is `not found`(404) ## 6.2.1 ### Documentation -- Improved all the examples to be ready to use +- Improved all the examples to be ready to use - Added units where missing - Added example for adding a secondary NIC to an IP Failover - Updated provider version to the latest release in main registry page @@ -631,17 +633,17 @@ is `not found`(404) - Update terraform-plugin-sdk to v2.12.0 - Token and username+password does not conflict anymore, all three can be set, the token having priority -### Features +### Features - Added `backup_location` property for `ionoscloud_pg_cluster`. For more details refer to the [documentation](docs/resources/dbaas_pgsql_cluster.md) ### Fixes - Fixed image data-source bug when `name` not provided - data-source returned 0 results -- When you try to change an immutable field, you get an error, but before that the tf state is changed. -Before applying a real change you need to `apply` it back with an error again. +- When you try to change an immutable field, you get an error, but before that the tf state is changed. +Before applying a real change you need to `apply` it back with an error again. To fix, when you try to change immutable fields they will throw an error in the plan phase. - Reintroduced in group resource the `user_id` argument, as deprecated, to provide a period of transition - Check slice length to prevent crash -- Fixed k8s_cluster data_source bug when searching by name +- Fixed k8s_cluster data_source bug when searching by name - Fix lan deletion error, when trying to delete it immediately after the deletion of the DBaaS cluster that contained it ## 6.2.0 @@ -671,16 +673,16 @@ To fix, when you try to change immutable fields they will throw an error in the ### Enhancements: - Improved lookup in data_sources by using filters -- Improved tests duration by moving steps from data_source test files in the corresponding resource test files -- Added workflow to run tests from GitHub actions +- Improved tests duration by moving steps from data_source test files in the corresponding resource test files +- Added workflow to run tests from GitHub actions - Split tests with build tags - Improve http client performance and timeouts -### Documentations: +### Documentations: - A more accurate example on how can the cidr be set automatically on a DBaaS Cluster - Update doc of how to dump kube_config into a file in yaml format. -### Fixes: +### Fixes: - Fix on creating a DBaaS Cluster without specifying the maintenance window - Solve #204 - targets in nlb forwarding rule(switched to Set instead of List), lb_private_ips(set to computed), features in datacenter resources(switched to Set instead of List) - Fix of plugin crash when updating k8s_node_pool node_count @@ -710,13 +712,13 @@ To fix, when you try to change immutable fields they will throw an error in the ## 6.1.1 ### Docs: -- Fix documentation in terraform registry +- Fix documentation in terraform registry ## 6.1.0 ### Features: -- New Product: **Database as a Service**: - - Resources: +- New Product: **Database as a Service**: + - Resources: - resource_dbaas_pgsql_cluster - Data Sources: - data_source_dbaas_pgsql_backups @@ -752,7 +754,7 @@ To fix, when you try to change immutable fields they will throw an error in the ## 6.0.1 -### Fixes: +### Fixes: - Fixed rebuild k8 nodes with the same lan - order of lans is ignored now at diff - Fixed conversion coming from a v5 state - added nil check in lans interface conversion @@ -810,7 +812,7 @@ To fix, when you try to change immutable fields they will throw an error in the - made tests comprehensive - optimized test duration by including both match by id and by name in the same test - removed duplicated code from import, data_source and resource files (set parameters) - + ## 6.0.0-beta.12 ### Fixes: - `server`: can not create cube server, firewall not updated @@ -882,7 +884,7 @@ To fix, when you try to change immutable fields they will throw an error in the ## 6.0.0-beta.2 -- Updated dependencies +- Updated dependencies - Updated server, nic and volume resources with the missing arguments ## 6.0.0-beta.1 @@ -928,21 +930,21 @@ To fix, when you try to change immutable fields they will throw an error in the ## 5.1.4 -- Error handling improvements +- Error handling improvements - Always displaying the full response body from the API in case of an error ## 5.1.3 -- Bug fix: correctly checking for nil the image volume +- Bug fix: correctly checking for nil the image volume ## 5.1.2 -- Bug fix: avoid sending an empty image password to the API if +- Bug fix: avoid sending an empty image password to the API if no image password is set ## 5.1.1 -- Bug fix: nil check for image password when creating a server +- Bug fix: nil check for image password when creating a server ## 5.1.0 @@ -963,7 +965,7 @@ FEATURES: BUG FIXES: -- Correctly updating ips on a nic embedded in a server config +- Correctly updating ips on a nic embedded in a server config ## 5.0.1 diff --git a/docs/resources/dbaas_mariadb_cluster.md b/docs/resources/dbaas_mariadb_cluster.md index a92a082e9..a42d9a734 100644 --- a/docs/resources/dbaas_mariadb_cluster.md +++ b/docs/resources/dbaas_mariadb_cluster.md @@ -84,7 +84,7 @@ resource "random_password" "cluster_password" { ## Argument reference -* `mariadb_version` - (Required)[string] The MariaDB version of your cluster. +* `mariadb_version` - (Required)[string] The MariaDB version of your cluster. Cannot be downgraded. * `instances` - (Required)[int] The total number of instances in the cluster (one primary and n-1 secondary). * `location`- (Optional)[string] The location in which the cluster will be created. Different service endpoints are used based on location, possible options are: "de/fra", "de/txl", "es/vit", "fr/par", "gb/lhr", "us/ewr", "us/las", "us/mci". If not set, the endpoint will be the one corresponding to "de/txl". * `cores` - (Required)[int] The number of CPU cores per instance. diff --git a/go.mod b/go.mod index 7b8c8cb37..abb61655b 100644 --- a/go.mod +++ b/go.mod @@ -24,7 +24,7 @@ require ( github.com/ionos-cloud/sdk-go-container-registry v1.2.0 github.com/ionos-cloud/sdk-go-dataplatform v1.0.3 github.com/ionos-cloud/sdk-go-dbaas-in-memory-db v1.0.1 - github.com/ionos-cloud/sdk-go-dbaas-mariadb v1.0.1 + github.com/ionos-cloud/sdk-go-dbaas-mariadb v1.1.1 github.com/ionos-cloud/sdk-go-dbaas-mongo v1.3.1 github.com/ionos-cloud/sdk-go-dbaas-postgres v1.1.3 github.com/ionos-cloud/sdk-go-dns v1.2.1 @@ -69,7 +69,7 @@ require ( github.com/hashicorp/go-multierror v1.1.1 // indirect github.com/hashicorp/go-plugin v1.6.1 // indirect github.com/hashicorp/go-uuid v1.0.3 - github.com/hashicorp/go-version v1.7.0 // indirect + github.com/hashicorp/go-version v1.7.0 github.com/hashicorp/hc-install v0.8.0 // indirect github.com/hashicorp/hcl/v2 v2.22.0 // indirect github.com/hashicorp/logutils v1.0.0 // indirect diff --git a/go.sum b/go.sum index 47fa8919a..047eca2bb 100644 --- a/go.sum +++ b/go.sum @@ -130,8 +130,8 @@ github.com/ionos-cloud/sdk-go-dataplatform v1.0.3 h1:eaZITgPaLHbK4d/nVaImvP19a5y github.com/ionos-cloud/sdk-go-dataplatform v1.0.3/go.mod h1:LXJGnUwLLiJhKgApv7TIPGy7WOuGbYIzBPFxGpNfqN0= github.com/ionos-cloud/sdk-go-dbaas-in-memory-db v1.0.1 h1:vd3SCqZ1OI5l7Tzql7NDb5Zlpna8e2SsfEYZRGHOkOo= github.com/ionos-cloud/sdk-go-dbaas-in-memory-db v1.0.1/go.mod h1:JLbyt5wj7+f/njy7pnWD6K+cCfe32p8VrjmKks055+w= -github.com/ionos-cloud/sdk-go-dbaas-mariadb v1.0.1 h1:EBsHfY/Bt7CcSsP7W7ohVsnhFAtMEcil3Aa/Q5MBq/Y= -github.com/ionos-cloud/sdk-go-dbaas-mariadb v1.0.1/go.mod h1:627dsH56YGQD7x0g2FGdVsxNtBySvQ3QU0uG+d6/Evk= +github.com/ionos-cloud/sdk-go-dbaas-mariadb v1.1.1 h1:dZLxaH2n0nxCOKMkt49TibOiY1hkaHThpXEgJL0oZng= +github.com/ionos-cloud/sdk-go-dbaas-mariadb v1.1.1/go.mod h1:NuUqBA9DyP4PB3MtKy/R9XRHY1RZcwVP6E3tP4FwI7I= github.com/ionos-cloud/sdk-go-dbaas-mongo v1.3.1 h1:+tDoZ8IEPxYwJd6fDIpWksNJs9Zzw7Pu5A39jTew058= github.com/ionos-cloud/sdk-go-dbaas-mongo v1.3.1/go.mod h1:rxOAeyAU6BTfghJibSRDdRNrKm2cIXMpSMe7JIWewJ8= github.com/ionos-cloud/sdk-go-dbaas-postgres v1.1.3 h1:T05nbKqBIw2zmPwaV2pWyFcUVjblLMoShPM9nAYQjLM= diff --git a/ionoscloud/resource_dbaas_mariadb_cluster.go b/ionoscloud/resource_dbaas_mariadb_cluster.go index bcc0e7538..d9d81163f 100644 --- a/ionoscloud/resource_dbaas_mariadb_cluster.go +++ b/ionoscloud/resource_dbaas_mariadb_cluster.go @@ -8,8 +8,7 @@ import ( "strings" "time" - "github.com/ionos-cloud/terraform-provider-ionoscloud/v6/utils/constant" - + semversion "github.com/hashicorp/go-version" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" @@ -17,6 +16,7 @@ import ( "github.com/ionos-cloud/terraform-provider-ionoscloud/v6/services" "github.com/ionos-cloud/terraform-provider-ionoscloud/v6/services/dbaas/mariadb" "github.com/ionos-cloud/terraform-provider-ionoscloud/v6/utils" + "github.com/ionos-cloud/terraform-provider-ionoscloud/v6/utils/constant" ) func resourceDBaaSMariaDBCluster() *schema.Resource { @@ -28,11 +28,13 @@ func resourceDBaaSMariaDBCluster() *schema.Resource { Importer: &schema.ResourceImporter{ StateContext: mariaDBClusterImport, }, + CustomizeDiff: errorOnVersionDowngrade, Schema: map[string]*schema.Schema{ "mariadb_version": { - Type: schema.TypeString, - Description: "The MariaDB version of your cluster.", - Required: true, + Type: schema.TypeString, + Description: "The MariaDB version of your cluster. Cannot be downgraded.", + Required: true, + ValidateDiagFunc: validation.ToDiagFunc(validation.StringIsNotEmpty), }, "location": { Type: schema.TypeString, @@ -153,6 +155,30 @@ func resourceDBaaSMariaDBCluster() *schema.Resource { } } +func errorOnVersionDowngrade(_ context.Context, diff *schema.ResourceDiff, _ interface{}) error { + // we do not want to check in case of resource creation + if diff.Id() == "" { + return nil + } + if diff.HasChange("mariadb_version") { + oldValue, newValue := diff.GetChange("mariadb_version") + oldVersionStr := oldValue.(string) + newVersionStr := newValue.(string) + oldVersion, err := semversion.NewVersion(oldVersionStr) + if err != nil { + return err + } + newVersion, err := semversion.NewVersion(newVersionStr) + if err != nil { + return err + } + if newVersion.LessThan(oldVersion) { + return fmt.Errorf("downgrade is not supported from %s to %s", oldVersionStr, newVersionStr) + } + } + return nil +} + func mariaDBClusterCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { client := meta.(services.SdkBundle).MariaDBClient @@ -254,5 +280,25 @@ func mariaDBClusterRead(ctx context.Context, d *schema.ResourceData, meta interf } func mariaDBClusterUpdate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { + client := meta.(services.SdkBundle).MariaDBClient + + clusterID := d.Id() + cluster, err := mariadb.GetMariaDBClusterDataUpdate(d) + if err != nil { + return diag.FromErr(err) + } + location := d.Get("location").(string) + response, _, err := client.UpdateCluster(ctx, *cluster, clusterID, location) + if err != nil { + return diag.FromErr(fmt.Errorf("an error occurred while updating DBaaS MariaDB cluster with ID: %v in location %s, error: %w", clusterID, location, err)) + } + + err = utils.WaitForResourceToBeReady(ctx, d, client.IsClusterReady) + if err != nil { + return diag.FromErr(fmt.Errorf("error occurred while checking the status for MariaDB cluster with ID: %v in location %s, error: %w", clusterID, location, err)) + } + if err := client.SetMariaDBClusterData(d, response); err != nil { + return diag.FromErr(err) + } return nil } diff --git a/ionoscloud/resource_dbaas_mariadb_cluster_test.go b/ionoscloud/resource_dbaas_mariadb_cluster_test.go index ba87d000a..857bba06a 100644 --- a/ionoscloud/resource_dbaas_mariadb_cluster_test.go +++ b/ionoscloud/resource_dbaas_mariadb_cluster_test.go @@ -105,6 +105,23 @@ func TestAccDBaaSMariaDBClusterBasic(t *testing.T) { Config: mariaDBClusterDataSourceWrongId, ExpectError: regexp.MustCompile("an error occurred while fetching the MariaDB cluster with ID"), }, + { + Config: mariaDBClusterUpdateConfig, + Check: resource.ComposeTestCheckFunc( + testAccCheckDBaaSMariaDBClusterExists(constant.DBaaSMariaDBClusterResource+"."+constant.DBaaSClusterTestResource, &cluster), + resource.TestCheckResourceAttr(constant.DBaaSMariaDBClusterResource+"."+constant.DBaaSClusterTestResource, clusterVersionAttribute, clusterVersionUpdatedValue), + resource.TestCheckResourceAttr(constant.DBaaSMariaDBClusterResource+"."+constant.DBaaSClusterTestResource, clusterInstancesAttribute, clusterInstancesUpdatedValue), + resource.TestCheckResourceAttr(constant.DBaaSMariaDBClusterResource+"."+constant.DBaaSClusterTestResource, clusterCoresAttribute, clusterCoresUpdatedValue), + resource.TestCheckResourceAttr(constant.DBaaSMariaDBClusterResource+"."+constant.DBaaSClusterTestResource, clusterRamAttribute, clusterRamUpdatedValue), + resource.TestCheckResourceAttr(constant.DBaaSMariaDBClusterResource+"."+constant.DBaaSClusterTestResource, clusterStorageSizeAttribute, clusterStorageSizeUpdatedValue), + resource.TestCheckResourceAttr(constant.DBaaSMariaDBClusterResource+"."+constant.DBaaSClusterTestResource, clusterMaintenanceWindowAttribute+".0."+clusterMaintenanceWindowDayOfTheWeekAttribute, clusterMaintenanceWindowDayOfTheWeekUpdateValue), + resource.TestCheckResourceAttr(constant.DBaaSMariaDBClusterResource+"."+constant.DBaaSClusterTestResource, clusterMaintenanceWindowAttribute+".0."+clusterMaintenanceWindowTimeAttribute, clusterMaintenanceWindowTimeUpdateValue), + ), + }, + { + Config: mariaDBClusterInvalidUpdateConfig, + ExpectError: regexp.MustCompile("downgrade is not supported from"), + }, }, }) } @@ -156,7 +173,7 @@ func testAccCheckDBaaSMariaDBClusterExists(n string, cluster *mariadb.ClusterRes } } -const mariaDBClusterConfigBasic = ` +const mariaDBTestInfraConfig = ` resource ` + constant.DatacenterResource + ` ` + datacenterResourceName + ` { name = "mariadb_datacenter_example" location = "fr/par" @@ -196,6 +213,14 @@ locals { database_ip_cidr = format("%s/%s", local.database_ip, "24") } +resource ` + constant.RandomPassword + ` "cluster_password" { + length = 16 + special = true + override_special = "!#$%&*()-_=+[]{}<>:?" +} +` + ServerImagePassword + +const mariaDBClusterConfigBasic = mariaDBTestInfraConfig + ` resource ` + constant.DBaaSMariaDBClusterResource + ` ` + constant.DBaaSClusterTestResource + ` { ` + clusterVersionAttribute + ` = "` + clusterVersionValue + `" ` + clusterInstancesAttribute + ` = "` + clusterInstancesValue + `" @@ -214,13 +239,39 @@ resource "time_sleep" "wait_30_seconds" { depends_on = [` + constant.DBaaSMariaDBClusterResource + `.` + constant.DBaaSClusterTestResource + `] create_duration = "30s" } +` -resource ` + constant.RandomPassword + ` "cluster_password" { - length = 16 - special = true - override_special = "!#$%&*()-_=+[]{}<>:?" +const mariaDBClusterUpdateConfig = mariaDBTestInfraConfig + ` +resource ` + constant.DBaaSMariaDBClusterResource + ` ` + constant.DBaaSClusterTestResource + ` { + ` + clusterVersionAttribute + ` = "` + clusterVersionUpdatedValue + `" + ` + clusterInstancesAttribute + ` = "` + clusterInstancesUpdatedValue + `" + ` + clusterLocationAttribute + ` = "` + clusterLocationValue + `" + ` + clusterCoresAttribute + ` = "` + clusterCoresUpdatedValue + `" + ` + clusterRamAttribute + ` = "` + clusterRamUpdatedValue + `" + ` + clusterStorageSizeAttribute + ` = "` + clusterStorageSizeUpdatedValue + `" + ` + clusterDisplayNameAttribute + ` = "` + clusterDisplayNameValue + `" + ` + connections + ` + ` + maintenanceWindowUpdated + ` + ` + credentials + ` } -` + ServerImagePassword +` + +// This update is invalid because version downgrade is not allowed. +const mariaDBClusterInvalidUpdateConfig = mariaDBTestInfraConfig + ` +resource ` + constant.DBaaSMariaDBClusterResource + ` ` + constant.DBaaSClusterTestResource + ` { + + ` + clusterVersionAttribute + ` = "10.1" + ` + clusterInstancesAttribute + ` = "` + clusterInstancesUpdatedValue + `" + ` + clusterLocationAttribute + ` = "` + clusterLocationValue + `" + ` + clusterCoresAttribute + ` = "` + clusterCoresUpdatedValue + `" + ` + clusterRamAttribute + ` = "` + clusterRamUpdatedValue + `" + ` + clusterStorageSizeAttribute + ` = "` + clusterStorageSizeUpdatedValue + `" + ` + clusterDisplayNameAttribute + ` = "` + clusterDisplayNameValue + `" + ` + connections + ` + ` + maintenanceWindowUpdated + ` + ` + credentials + ` +} +` const mariaDBClusterDataSourceMatchId = mariaDBClusterConfigBasic + ` data ` + constant.DBaaSMariaDBClusterResource + ` ` + constant.DBaaSClusterTestDataSourceById + ` { @@ -271,6 +322,11 @@ const maintenanceWindow = clusterMaintenanceWindowAttribute + `{ ` + clusterMaintenanceWindowTimeAttribute + ` = "` + clusterMaintenanceWindowTimeValue + `" }` +const maintenanceWindowUpdated = clusterMaintenanceWindowAttribute + `{ + ` + clusterMaintenanceWindowDayOfTheWeekAttribute + ` = "` + clusterMaintenanceWindowDayOfTheWeekUpdateValue + `" + ` + clusterMaintenanceWindowTimeAttribute + ` = "` + clusterMaintenanceWindowTimeUpdateValue + `" +}` + const credentials = clusterCredentialsAttribute + `{ ` + clusterCredentialsUsernameAttribute + ` = "` + clusterCredentialsUsernameValue + `" ` + clusterCredentialsPasswordAttribute + ` = ` + constant.RandomPassword + `.cluster_password.result @@ -282,11 +338,16 @@ const clusterVersionAttribute = "mariadb_version" // Values const ( clusterVersionValue = "10.6" + clusterVersionUpdatedValue = "10.11" clusterInstancesValue = "1" + clusterInstancesUpdatedValue = "2" clusterLocationValue = "fr/par" clusterCoresValue = "4" + clusterCoresUpdatedValue = "5" clusterRamValue = "4" + clusterRamUpdatedValue = "5" clusterStorageSizeValue = "10" + clusterStorageSizeUpdatedValue = "11" clusterConnectionsCidrValue = "local.database_ip_cidr" clusterDisplayNameValue = constant.DBaaSClusterTestResource clusterCredentialsUsernameValue = "username" diff --git a/services/dbaas/mariadb/cluster.go b/services/dbaas/mariadb/cluster.go index 49431b7de..6c10128a3 100644 --- a/services/dbaas/mariadb/cluster.go +++ b/services/dbaas/mariadb/cluster.go @@ -74,6 +74,14 @@ func (c *MariaDBClient) CreateCluster(ctx context.Context, cluster mariadb.Creat return clusterResponse, apiResponse, err } +// UpdateCluster updates a cluster by its ID and the location in which the cluster is created. +func (c *MariaDBClient) UpdateCluster(ctx context.Context, cluster mariadb.PatchClusterRequest, clusterID, location string) (mariadb.ClusterResponse, *mariadb.APIResponse, error) { + c.modifyConfigURL(location) + clusterResponse, apiResponse, err := c.sdkClient.ClustersApi.ClustersPatch(ctx, clusterID).PatchClusterRequest(cluster).Execute() + apiResponse.LogInfo() + return clusterResponse, apiResponse, err +} + // DeleteCluster deletes a cluster by its ID and the location in which the cluster is created. func (c *MariaDBClient) DeleteCluster(ctx context.Context, clusterID, location string) (mariadb.ClusterResponse, *mariadb.APIResponse, error) { c.modifyConfigURL(location) @@ -158,6 +166,54 @@ func GetMariaDBClusterDataCreate(d *schema.ResourceData) (*mariadb.CreateCluster return &cluster, nil } +// GetMariaDBClusterDataUpdate retrieves the data from the terraform resource and sets it in the MariaDB cluster struct. +func GetMariaDBClusterDataUpdate(d *schema.ResourceData) (*mariadb.PatchClusterRequest, error) { + cluster := mariadb.PatchClusterRequest{ + Properties: &mariadb.PatchClusterProperties{}, + } + + if d.HasChange("mariadb_version") { + _, newValue := d.GetChange("mariadb_version") + newVersion := newValue.(string) + cluster.Properties.MariadbVersion = (*mariadb.MariadbVersion)(&newVersion) + } + + if d.HasChange("instances") { + _, n := d.GetChange("instances") + nInt := int32(n.(int)) + cluster.Properties.Instances = &nInt + } + + if d.HasChange("cores") { + _, n := d.GetChange("cores") + nInt := int32(n.(int)) + cluster.Properties.Cores = &nInt + } + + if d.HasChange("ram") { + _, n := d.GetChange("ram") + nInt := int32(n.(int)) + cluster.Properties.Ram = &nInt + } + + if d.HasChange("storage_size") { + _, n := d.GetChange("storage_size") + nInt := int32(n.(int)) + cluster.Properties.StorageSize = &nInt + } + + if d.HasChange("display_name") { + _, n := d.GetChange("display_name") + nString := n.(string) + cluster.Properties.DisplayName = &nString + } + + if d.HasChange("maintenance_window") { + cluster.Properties.MaintenanceWindow = GetMariaClusterMaintenanceWindowData(d) + } + return &cluster, nil +} + func GetMariaClusterConnectionsData(d *schema.ResourceData) *[]mariadb.Connection { connections := make([]mariadb.Connection, 0) diff --git a/vendor/github.com/ionos-cloud/sdk-go-dbaas-mariadb/README.md b/vendor/github.com/ionos-cloud/sdk-go-dbaas-mariadb/README.md index bd3a50950..e3b0342ce 100644 --- a/vendor/github.com/ionos-cloud/sdk-go-dbaas-mariadb/README.md +++ b/vendor/github.com/ionos-cloud/sdk-go-dbaas-mariadb/README.md @@ -1,3 +1,5 @@ +[![Gitter](https://img.shields.io/gitter/room/ionos-cloud/sdk-general)](https://gitter.im/ionos-cloud/sdk-general) + # Go API client for ionoscloud An enterprise-grade Database is provided as a Service (DBaaS) solution that @@ -14,7 +16,7 @@ their concepts and lend well to making the experience smooth and intuitive. This API client was generated by the [OpenAPI Generator](https://openapi-generator.tech) project. By using the [OpenAPI-spec](https://www.openapis.org/) from a remote server, you can easily generate an API client. - API version: 0.1.0 -- Package version: 1.0.1 +- Package version: 1.1.1 - Build package: org.openapitools.codegen.languages.GoClientCodegen ## Installation @@ -23,138 +25,121 @@ Install the following dependencies: ```shell go get github.com/stretchr/testify/assert +go get golang.org/x/oauth2 go get golang.org/x/net/context +go get github.com/antihax/optional ``` Put the package under your project folder and add the following in import: ```golang -import ionoscloud "github.com/ionos-cloud/sdk-go-dbaas-mariadb" +import "./ionoscloud" ``` -To use a proxy, set the environment variable `HTTP_PROXY`: +## Authentication -```golang -os.Setenv("HTTP_PROXY", "http://proxy_name:proxy_port") -``` +All available server URLs are: -## Configuration of Server URL +- *https://mariadb.de-txl.ionos.com* - Berlin, Germany +- *https://mariadb.de-fra.ionos.com* - Frankfurt, Germany +- *https://mariadb.es-vit.ionos.com* - Logroño, Spain +- *https://mariadb.fr-par.ionos.com* - Paris, France +- *https://mariadb.gb-lhr.ionos.com* - London, Great Britain +- *https://mariadb.us-ewr.ionos.com* - Newark, USA +- *https://mariadb.us-las.ionos.com* - Las Vegas, USA +- *https://mariadb.us-mci.ionos.com* - Lenexa, USA -Default configuration comes with `Servers` field that contains server objects as defined in the OpenAPI specification. +By default, *https://mariadb.de-txl.ionos.com* is used, however this can be overriden at authentication, either +by setting the `IONOS_API_URL` environment variable or by specifying the `hostUrl` parameter when +initializing the sdk client. -### Select Server Configuration - -For using other server than the one defined on index 0 set context value `sw.ContextServerIndex` of type `int`. +The username and password or the authentication token can be manually specified when initializing +the sdk client: ```golang -ctx := context.WithValue(context.Background(), ionoscloud.ContextServerIndex, 1) -``` -### Templated Server URL +client := ionoscloud.NewAPIClient(ionoscloud.NewConfiguration(username, password, token, hostUrl)) -Templated server URL is formatted using default variables from configuration or from context value `sw.ContextServerVariables` of type `map[string]string`. - -```golang -ctx := context.WithValue(context.Background(), ionoscloud.ContextServerVariables, map[string]string{ - "basePath": "v2", -}) ``` -Note, enum values are always validated and all unused variables are silently ignored. +Environment variables can also be used. The sdk uses the following variables: +- IONOS_TOKEN - login via token. This is the recommended way to authenticate. +- IONOS_USERNAME - to specify the username used to login +- IONOS_PASSWORD - to specify the password +- IONOS_API_URL - to specify the API server URL -## Documentation for API Endpoints - -All URIs are relative to *https://mariadb.de-txl.ionos.com* +In this case, the client configuration needs to be initialized using `NewConfigurationFromEnv()`. -Class | Method | HTTP request | Description ------------- | ------------- | ------------- | ------------- -*BackupsApi* | [**BackupsFindById**](docs/api/BackupsApi.md#backupsfindbyid) | **Get** /backups/{backupId} | Fetch backups -*BackupsApi* | [**BackupsGet**](docs/api/BackupsApi.md#backupsget) | **Get** /backups | List of backups. -*BackupsApi* | [**ClusterBackupsGet**](docs/api/BackupsApi.md#clusterbackupsget) | **Get** /clusters/{clusterId}/backups | List backups of cluster -*ClustersApi* | [**ClustersDelete**](docs/api/ClustersApi.md#clustersdelete) | **Delete** /clusters/{clusterId} | Delete a cluster -*ClustersApi* | [**ClustersFindById**](docs/api/ClustersApi.md#clustersfindbyid) | **Get** /clusters/{clusterId} | Fetch a cluster -*ClustersApi* | [**ClustersGet**](docs/api/ClustersApi.md#clustersget) | **Get** /clusters | List clusters -*ClustersApi* | [**ClustersPost**](docs/api/ClustersApi.md#clusterspost) | **Post** /clusters | Create a cluster - - -## Documentation For Models +```golang - - [Backup](docs/models/Backup.md) - - [BackupList](docs/models/BackupList.md) - - [BackupListAllOf](docs/models/BackupListAllOf.md) - - [BackupResponse](docs/models/BackupResponse.md) - - [BaseBackup](docs/models/BaseBackup.md) - - [ClusterList](docs/models/ClusterList.md) - - [ClusterListAllOf](docs/models/ClusterListAllOf.md) - - [ClusterMetadata](docs/models/ClusterMetadata.md) - - [ClusterProperties](docs/models/ClusterProperties.md) - - [ClusterResponse](docs/models/ClusterResponse.md) - - [ClustersGet400Response](docs/models/ClustersGet400Response.md) - - [ClustersGet401Response](docs/models/ClustersGet401Response.md) - - [ClustersGet403Response](docs/models/ClustersGet403Response.md) - - [ClustersGet404Response](docs/models/ClustersGet404Response.md) - - [ClustersGet405Response](docs/models/ClustersGet405Response.md) - - [ClustersGet415Response](docs/models/ClustersGet415Response.md) - - [ClustersGet422Response](docs/models/ClustersGet422Response.md) - - [ClustersGet429Response](docs/models/ClustersGet429Response.md) - - [ClustersGet500Response](docs/models/ClustersGet500Response.md) - - [ClustersGet503Response](docs/models/ClustersGet503Response.md) - - [Connection](docs/models/Connection.md) - - [CreateClusterProperties](docs/models/CreateClusterProperties.md) - - [CreateClusterRequest](docs/models/CreateClusterRequest.md) - - [DBUser](docs/models/DBUser.md) - - [DayOfTheWeek](docs/models/DayOfTheWeek.md) - - [ErrorMessage](docs/models/ErrorMessage.md) - - [MaintenanceWindow](docs/models/MaintenanceWindow.md) - - [MariadbVersion](docs/models/MariadbVersion.md) - - [Pagination](docs/models/Pagination.md) - - [PaginationLinks](docs/models/PaginationLinks.md) - - [State](docs/models/State.md) - - -## Documentation For Authorization - - -Authentication schemes defined for the API: -### tokenAuth - -- **Type**: API key -- **API key parameter name**: Authorization -- **Location**: HTTP header - -Note, each API key must be added to a map of `map[string]APIKey` where the key is: Authorization and passed in as the auth context for each request. - -Example +client := ionoscloud.NewAPIClient(ionoscloud.NewConfigurationFromEnv()) -```golang -auth := context.WithValue( - context.Background(), - sw.ContextAPIKeys, - map[string]sw.APIKey{ - "Authorization": {Key: "API_KEY_STRING"}, - }, - ) -r, err := client.Service.Operation(auth, args) ``` -## Documentation for Utility Methods +## Documentation for API Endpoints -Due to the fact that model structure members are all pointers, this package contains -a number of utility functions to easily obtain pointers to values of basic types. -Each of these functions takes a value of the given basic type and returns a pointer to it: +All URIs are relative to *https://mariadb.de-txl.ionos.com* +
+ API Endpoints table -* `PtrBool` -* `PtrInt` -* `PtrInt32` -* `PtrInt64` -* `PtrFloat` -* `PtrFloat32` -* `PtrFloat64` -* `PtrString` -* `PtrTime` -## Author +| Class | Method | HTTP request | Description | +| ------------- | ------------- | ------------- | ------------- | +| BackupsApi | [**BackupsFindById**](docs/api/BackupsApi.md#BackupsFindById) | **Get** /backups/{backupId} | Fetch backups | +| BackupsApi | [**BackupsGet**](docs/api/BackupsApi.md#BackupsGet) | **Get** /backups | List of backups. | +| BackupsApi | [**ClusterBackupsGet**](docs/api/BackupsApi.md#ClusterBackupsGet) | **Get** /clusters/{clusterId}/backups | List backups of cluster | +| ClustersApi | [**ClustersDelete**](docs/api/ClustersApi.md#ClustersDelete) | **Delete** /clusters/{clusterId} | Delete a cluster | +| ClustersApi | [**ClustersFindById**](docs/api/ClustersApi.md#ClustersFindById) | **Get** /clusters/{clusterId} | Fetch a cluster | +| ClustersApi | [**ClustersGet**](docs/api/ClustersApi.md#ClustersGet) | **Get** /clusters | List clusters | +| ClustersApi | [**ClustersPatch**](docs/api/ClustersApi.md#ClustersPatch) | **Patch** /clusters/{clusterId} | Update a cluster | +| ClustersApi | [**ClustersPost**](docs/api/ClustersApi.md#ClustersPost) | **Post** /clusters | Create a cluster | +| RestoreApi | [**ClustersRestore**](docs/api/RestoreApi.md#ClustersRestore) | **Post** /clusters/{clusterId}/restore | In-place restore of a cluster. | +
+## Documentation For Models +All URIs are relative to *https://mariadb.de-txl.ionos.com* +
+API models list + + - [Backup](docs/models/Backup) + - [BackupList](docs/models/BackupList) + - [BackupListAllOf](docs/models/BackupListAllOf) + - [BackupResponse](docs/models/BackupResponse) + - [BaseBackup](docs/models/BaseBackup) + - [ClusterList](docs/models/ClusterList) + - [ClusterListAllOf](docs/models/ClusterListAllOf) + - [ClusterMetadata](docs/models/ClusterMetadata) + - [ClusterProperties](docs/models/ClusterProperties) + - [ClusterResponse](docs/models/ClusterResponse) + - [ClustersGet400Response](docs/models/ClustersGet400Response) + - [ClustersGet401Response](docs/models/ClustersGet401Response) + - [ClustersGet403Response](docs/models/ClustersGet403Response) + - [ClustersGet404Response](docs/models/ClustersGet404Response) + - [ClustersGet405Response](docs/models/ClustersGet405Response) + - [ClustersGet415Response](docs/models/ClustersGet415Response) + - [ClustersGet422Response](docs/models/ClustersGet422Response) + - [ClustersGet429Response](docs/models/ClustersGet429Response) + - [ClustersGet500Response](docs/models/ClustersGet500Response) + - [ClustersGet503Response](docs/models/ClustersGet503Response) + - [Connection](docs/models/Connection) + - [CreateClusterProperties](docs/models/CreateClusterProperties) + - [CreateClusterRequest](docs/models/CreateClusterRequest) + - [DBUser](docs/models/DBUser) + - [DayOfTheWeek](docs/models/DayOfTheWeek) + - [ErrorMessage](docs/models/ErrorMessage) + - [MaintenanceWindow](docs/models/MaintenanceWindow) + - [MariadbVersion](docs/models/MariadbVersion) + - [Pagination](docs/models/Pagination) + - [PaginationLinks](docs/models/PaginationLinks) + - [PatchClusterProperties](docs/models/PatchClusterProperties) + - [PatchClusterRequest](docs/models/PatchClusterRequest) + - [RestoreRequest](docs/models/RestoreRequest) + - [State](docs/models/State) + + +[[Back to API list]](#documentation-for-api-endpoints) [[Back to Model list]](#documentation-for-models) + +
diff --git a/vendor/github.com/ionos-cloud/sdk-go-dbaas-mariadb/api_clusters.go b/vendor/github.com/ionos-cloud/sdk-go-dbaas-mariadb/api_clusters.go index bb1edb057..a1a9f4080 100644 --- a/vendor/github.com/ionos-cloud/sdk-go-dbaas-mariadb/api_clusters.go +++ b/vendor/github.com/ionos-cloud/sdk-go-dbaas-mariadb/api_clusters.go @@ -712,6 +712,237 @@ func (a *ClustersApiService) ClustersGetExecute(r ApiClustersGetRequest) (Cluste return localVarReturnValue, localVarAPIResponse, nil } +type ApiClustersPatchRequest struct { + ctx _context.Context + ApiService *ClustersApiService + clusterId string + patchClusterRequest *PatchClusterRequest +} + +func (r ApiClustersPatchRequest) PatchClusterRequest(patchClusterRequest PatchClusterRequest) ApiClustersPatchRequest { + r.patchClusterRequest = &patchClusterRequest + return r +} + +func (r ApiClustersPatchRequest) Execute() (ClusterResponse, *APIResponse, error) { + return r.ApiService.ClustersPatchExecute(r) +} + +/* + * ClustersPatch Update a cluster + * Updates mutable attributes on a MariaDB cluster. + * @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param clusterId The unique ID of the cluster. + * @return ApiClustersPatchRequest + */ +func (a *ClustersApiService) ClustersPatch(ctx _context.Context, clusterId string) ApiClustersPatchRequest { + return ApiClustersPatchRequest{ + ApiService: a, + ctx: ctx, + clusterId: clusterId, + } +} + +/* + * Execute executes the request + * @return ClusterResponse + */ +func (a *ClustersApiService) ClustersPatchExecute(r ApiClustersPatchRequest) (ClusterResponse, *APIResponse, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPatch + localVarPostBody interface{} + localVarFormFileName string + localVarFileName string + localVarFileBytes []byte + localVarReturnValue ClusterResponse + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "ClustersApiService.ClustersPatch") + if err != nil { + return localVarReturnValue, nil, GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/clusters/{clusterId}" + localVarPath = strings.Replace(localVarPath, "{"+"clusterId"+"}", _neturl.PathEscape(parameterToString(r.clusterId, "")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + if r.patchClusterRequest == nil { + return localVarReturnValue, nil, reportError("patchClusterRequest is required and must be specified") + } + + // to determine the Content-Type header + localVarHTTPContentTypes := []string{"application/json"} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{"application/json"} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + // body params + localVarPostBody = r.patchClusterRequest + if r.ctx != nil { + // API Key Authentication + if auth, ok := r.ctx.Value(ContextAPIKeys).(map[string]APIKey); ok { + if apiKey, ok := auth["tokenAuth"]; ok { + var key string + if apiKey.Prefix != "" { + key = apiKey.Prefix + " " + apiKey.Key + } else { + key = apiKey.Key + } + localVarHeaderParams["Authorization"] = key + } + } + } + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFormFileName, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, httpRequestTime, err := a.client.callAPI(req) + + localVarAPIResponse := &APIResponse{ + Response: localVarHTTPResponse, + Method: localVarHTTPMethod, + RequestTime: httpRequestTime, + RequestURL: localVarPath, + Operation: "ClustersPatch", + } + + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarAPIResponse, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarAPIResponse.Payload = localVarBody + if err != nil { + return localVarReturnValue, localVarAPIResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := GenericOpenAPIError{ + statusCode: localVarHTTPResponse.StatusCode, + body: localVarBody, + error: fmt.Sprintf("%s: %s", localVarHTTPResponse.Status, string(localVarBody)), + } + if localVarHTTPResponse.StatusCode == 400 { + var v ClustersGet400Response + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 401 { + var v ClustersGet401Response + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 403 { + var v ClustersGet403Response + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 404 { + var v ClustersGet404Response + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 405 { + var v ClustersGet405Response + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 415 { + var v ClustersGet415Response + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 422 { + var v ClustersGet422Response + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 429 { + var v ClustersGet429Response + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 500 { + var v ClustersGet500Response + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 503 { + var v ClustersGet503Response + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarAPIResponse, newErr + } + newErr.model = v + } + return localVarReturnValue, localVarAPIResponse, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := GenericOpenAPIError{ + statusCode: localVarHTTPResponse.StatusCode, + body: localVarBody, + error: err.Error(), + } + return localVarReturnValue, localVarAPIResponse, newErr + } + + return localVarReturnValue, localVarAPIResponse, nil +} + type ApiClustersPostRequest struct { ctx _context.Context ApiService *ClustersApiService diff --git a/vendor/github.com/ionos-cloud/sdk-go-dbaas-mariadb/api_restore.go b/vendor/github.com/ionos-cloud/sdk-go-dbaas-mariadb/api_restore.go new file mode 100644 index 000000000..62b8f1816 --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-dbaas-mariadb/api_restore.go @@ -0,0 +1,252 @@ +/* + * IONOS DBaaS MariaDB REST API + * + * An enterprise-grade Database is provided as a Service (DBaaS) solution that can be managed through a browser-based \"Data Center Designer\" (DCD) tool or via an easy to use API. The API allows you to create additional MariaDB database clusters or modify existing ones. It is designed to allow users to leverage the same power and flexibility found within the DCD visual tool. Both tools are consistent with their concepts and lend well to making the experience smooth and intuitive. + * + * API version: 0.1.0 + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package ionoscloud + +import ( + _context "context" + "fmt" + "io" + _nethttp "net/http" + _neturl "net/url" + "strings" +) + +// Linger please +var ( + _ _context.Context +) + +// RestoreApiService RestoreApi service +type RestoreApiService service + +type ApiClustersRestoreRequest struct { + ctx _context.Context + ApiService *RestoreApiService + clusterId string + restoreRequest *RestoreRequest +} + +func (r ApiClustersRestoreRequest) RestoreRequest(restoreRequest RestoreRequest) ApiClustersRestoreRequest { + r.restoreRequest = &restoreRequest + return r +} + +func (r ApiClustersRestoreRequest) Execute() (*APIResponse, error) { + return r.ApiService.ClustersRestoreExecute(r) +} + +/* + - ClustersRestore In-place restore of a cluster. + - Restore a MariaDB cluster from a backup. + +Conditions: + - The backup must belong to the MariaDB cluster to + be restored. + - The cluster must be in the state "AVAILABLE". + - @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + - @param clusterId The unique ID of the cluster. + - @return ApiClustersRestoreRequest +*/ +func (a *RestoreApiService) ClustersRestore(ctx _context.Context, clusterId string) ApiClustersRestoreRequest { + return ApiClustersRestoreRequest{ + ApiService: a, + ctx: ctx, + clusterId: clusterId, + } +} + +/* + * Execute executes the request + */ +func (a *RestoreApiService) ClustersRestoreExecute(r ApiClustersRestoreRequest) (*APIResponse, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPost + localVarPostBody interface{} + localVarFormFileName string + localVarFileName string + localVarFileBytes []byte + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "RestoreApiService.ClustersRestore") + if err != nil { + return nil, GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/clusters/{clusterId}/restore" + localVarPath = strings.Replace(localVarPath, "{"+"clusterId"+"}", _neturl.PathEscape(parameterToString(r.clusterId, "")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + if r.restoreRequest == nil { + return nil, reportError("restoreRequest is required and must be specified") + } + + // to determine the Content-Type header + localVarHTTPContentTypes := []string{"application/json"} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{"application/json"} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + // body params + localVarPostBody = r.restoreRequest + if r.ctx != nil { + // API Key Authentication + if auth, ok := r.ctx.Value(ContextAPIKeys).(map[string]APIKey); ok { + if apiKey, ok := auth["tokenAuth"]; ok { + var key string + if apiKey.Prefix != "" { + key = apiKey.Prefix + " " + apiKey.Key + } else { + key = apiKey.Key + } + localVarHeaderParams["Authorization"] = key + } + } + } + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFormFileName, localVarFileName, localVarFileBytes) + if err != nil { + return nil, err + } + + localVarHTTPResponse, httpRequestTime, err := a.client.callAPI(req) + + localVarAPIResponse := &APIResponse{ + Response: localVarHTTPResponse, + Method: localVarHTTPMethod, + RequestTime: httpRequestTime, + RequestURL: localVarPath, + Operation: "ClustersRestore", + } + + if err != nil || localVarHTTPResponse == nil { + return localVarAPIResponse, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarAPIResponse.Payload = localVarBody + if err != nil { + return localVarAPIResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := GenericOpenAPIError{ + statusCode: localVarHTTPResponse.StatusCode, + body: localVarBody, + error: fmt.Sprintf("%s: %s", localVarHTTPResponse.Status, string(localVarBody)), + } + if localVarHTTPResponse.StatusCode == 400 { + var v ClustersGet400Response + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 401 { + var v ClustersGet401Response + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 403 { + var v ClustersGet403Response + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 404 { + var v ClustersGet404Response + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 405 { + var v ClustersGet405Response + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 415 { + var v ClustersGet415Response + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 422 { + var v ClustersGet422Response + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 429 { + var v ClustersGet429Response + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 500 { + var v ClustersGet500Response + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarAPIResponse, newErr + } + newErr.model = v + } + if localVarHTTPResponse.StatusCode == 503 { + var v ClustersGet503Response + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarAPIResponse, newErr + } + newErr.model = v + } + return localVarAPIResponse, newErr + } + + return localVarAPIResponse, nil +} diff --git a/vendor/github.com/ionos-cloud/sdk-go-dbaas-mariadb/client.go b/vendor/github.com/ionos-cloud/sdk-go-dbaas-mariadb/client.go index d97bb1a2c..e5d662fa0 100644 --- a/vendor/github.com/ionos-cloud/sdk-go-dbaas-mariadb/client.go +++ b/vendor/github.com/ionos-cloud/sdk-go-dbaas-mariadb/client.go @@ -50,7 +50,7 @@ const ( RequestStatusFailed = "FAILED" RequestStatusDone = "DONE" - Version = "1.0.1" + Version = "1.1.1" ) // APIClient manages communication with the IONOS DBaaS MariaDB REST API API v0.1.0 @@ -64,6 +64,8 @@ type APIClient struct { BackupsApi *BackupsApiService ClustersApi *ClustersApiService + + RestoreApi *RestoreApiService } type service struct { @@ -91,6 +93,7 @@ func NewAPIClient(cfg *Configuration) *APIClient { // API Services c.BackupsApi = (*BackupsApiService)(&c.common) c.ClustersApi = (*ClustersApiService)(&c.common) + c.RestoreApi = (*RestoreApiService)(&c.common) return c } diff --git a/vendor/github.com/ionos-cloud/sdk-go-dbaas-mariadb/configuration.go b/vendor/github.com/ionos-cloud/sdk-go-dbaas-mariadb/configuration.go index 933f6fdce..6f3be7ffc 100644 --- a/vendor/github.com/ionos-cloud/sdk-go-dbaas-mariadb/configuration.go +++ b/vendor/github.com/ionos-cloud/sdk-go-dbaas-mariadb/configuration.go @@ -37,6 +37,13 @@ const ( var ( IonosServerUrls = []string{ "https://mariadb.de-txl.ionos.com", + "https://mariadb.de-fra.ionos.com", + "https://mariadb.es-vit.ionos.com", + "https://mariadb.fr-par.ionos.com", + "https://mariadb.gb-lhr.ionos.com", + "https://mariadb.us-ewr.ionos.com", + "https://mariadb.us-las.ionos.com", + "https://mariadb.us-mci.ionos.com", } ) @@ -134,7 +141,7 @@ func NewConfiguration(username, password, token, hostUrl string) *Configuration cfg := &Configuration{ DefaultHeader: make(map[string]string), DefaultQueryParams: url.Values{}, - UserAgent: "ionos-cloud-sdk-go-dbaas-mariadb/v1.0.1", + UserAgent: "ionos-cloud-sdk-go-dbaas-mariadb/v1.1.1", Debug: false, Username: username, Password: password, @@ -149,6 +156,34 @@ func NewConfiguration(username, password, token, hostUrl string) *Configuration URL: getServerUrl(hostUrl), Description: "Berlin, Germany", }, + { + URL: getServerUrl(hostUrl), + Description: "Frankfurt, Germany", + }, + { + URL: getServerUrl(hostUrl), + Description: "Logroño, Spain", + }, + { + URL: getServerUrl(hostUrl), + Description: "Paris, France", + }, + { + URL: getServerUrl(hostUrl), + Description: "London, Great Britain", + }, + { + URL: getServerUrl(hostUrl), + Description: "Newark, USA", + }, + { + URL: getServerUrl(hostUrl), + Description: "Las Vegas, USA", + }, + { + URL: getServerUrl(hostUrl), + Description: "Lenexa, USA", + }, }, OperationServers: map[string]ServerConfigurations{}, } diff --git a/vendor/github.com/ionos-cloud/sdk-go-dbaas-mariadb/model_create_cluster_properties.go b/vendor/github.com/ionos-cloud/sdk-go-dbaas-mariadb/model_create_cluster_properties.go index 0428937c6..64f4c72c4 100644 --- a/vendor/github.com/ionos-cloud/sdk-go-dbaas-mariadb/model_create_cluster_properties.go +++ b/vendor/github.com/ionos-cloud/sdk-go-dbaas-mariadb/model_create_cluster_properties.go @@ -31,6 +31,7 @@ type CreateClusterProperties struct { DisplayName *string `json:"displayName"` MaintenanceWindow *MaintenanceWindow `json:"maintenanceWindow,omitempty"` Credentials *DBUser `json:"credentials"` + FromBackup *RestoreRequest `json:"fromBackup,omitempty"` } // NewCreateClusterProperties instantiates a new CreateClusterProperties object @@ -402,6 +403,44 @@ func (o *CreateClusterProperties) HasCredentials() bool { return false } +// GetFromBackup returns the FromBackup field value +// If the value is explicit nil, the zero value for RestoreRequest will be returned +func (o *CreateClusterProperties) GetFromBackup() *RestoreRequest { + if o == nil { + return nil + } + + return o.FromBackup + +} + +// GetFromBackupOk returns a tuple with the FromBackup field value +// and a boolean to check if the value has been set. +// NOTE: If the value is an explicit nil, `nil, true` will be returned +func (o *CreateClusterProperties) GetFromBackupOk() (*RestoreRequest, bool) { + if o == nil { + return nil, false + } + + return o.FromBackup, true +} + +// SetFromBackup sets field value +func (o *CreateClusterProperties) SetFromBackup(v RestoreRequest) { + + o.FromBackup = &v + +} + +// HasFromBackup returns a boolean if a field has been set. +func (o *CreateClusterProperties) HasFromBackup() bool { + if o != nil && o.FromBackup != nil { + return true + } + + return false +} + func (o CreateClusterProperties) MarshalJSON() ([]byte, error) { toSerialize := map[string]interface{}{} if o.MariadbVersion != nil { @@ -440,6 +479,10 @@ func (o CreateClusterProperties) MarshalJSON() ([]byte, error) { toSerialize["credentials"] = o.Credentials } + if o.FromBackup != nil { + toSerialize["fromBackup"] = o.FromBackup + } + return json.Marshal(toSerialize) } diff --git a/vendor/github.com/ionos-cloud/sdk-go-dbaas-mariadb/model_patch_cluster_properties.go b/vendor/github.com/ionos-cloud/sdk-go-dbaas-mariadb/model_patch_cluster_properties.go new file mode 100644 index 000000000..96e5071da --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-dbaas-mariadb/model_patch_cluster_properties.go @@ -0,0 +1,384 @@ +/* + * IONOS DBaaS MariaDB REST API + * + * An enterprise-grade Database is provided as a Service (DBaaS) solution that can be managed through a browser-based \"Data Center Designer\" (DCD) tool or via an easy to use API. The API allows you to create additional MariaDB database clusters or modify existing ones. It is designed to allow users to leverage the same power and flexibility found within the DCD visual tool. Both tools are consistent with their concepts and lend well to making the experience smooth and intuitive. + * + * API version: 0.1.0 + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package ionoscloud + +import ( + "encoding/json" +) + +// PatchClusterProperties Properties of the payload to change a cluster: - instances can only be increased (3, 5, 7), - mariadbVersion can only be increased (no downgrade) - storageSize can only be increased, - ram and cores can be both increased and decreased. +type PatchClusterProperties struct { + MariadbVersion *MariadbVersion `json:"mariadbVersion,omitempty"` + // The total number of instances in the cluster (one primary and n-1 secondary). + Instances *int32 `json:"instances,omitempty"` + // The number of CPU cores per instance. + Cores *int32 `json:"cores,omitempty"` + // The amount of memory per instance in gigabytes (GB). + Ram *int32 `json:"ram,omitempty"` + // The amount of storage per instance in gigabytes (GB). + StorageSize *int32 `json:"storageSize,omitempty"` + // The friendly name of your cluster. + DisplayName *string `json:"displayName,omitempty"` + MaintenanceWindow *MaintenanceWindow `json:"maintenanceWindow,omitempty"` +} + +// NewPatchClusterProperties instantiates a new PatchClusterProperties object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewPatchClusterProperties() *PatchClusterProperties { + this := PatchClusterProperties{} + + return &this +} + +// NewPatchClusterPropertiesWithDefaults instantiates a new PatchClusterProperties object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewPatchClusterPropertiesWithDefaults() *PatchClusterProperties { + this := PatchClusterProperties{} + return &this +} + +// GetMariadbVersion returns the MariadbVersion field value +// If the value is explicit nil, the zero value for MariadbVersion will be returned +func (o *PatchClusterProperties) GetMariadbVersion() *MariadbVersion { + if o == nil { + return nil + } + + return o.MariadbVersion + +} + +// GetMariadbVersionOk returns a tuple with the MariadbVersion field value +// and a boolean to check if the value has been set. +// NOTE: If the value is an explicit nil, `nil, true` will be returned +func (o *PatchClusterProperties) GetMariadbVersionOk() (*MariadbVersion, bool) { + if o == nil { + return nil, false + } + + return o.MariadbVersion, true +} + +// SetMariadbVersion sets field value +func (o *PatchClusterProperties) SetMariadbVersion(v MariadbVersion) { + + o.MariadbVersion = &v + +} + +// HasMariadbVersion returns a boolean if a field has been set. +func (o *PatchClusterProperties) HasMariadbVersion() bool { + if o != nil && o.MariadbVersion != nil { + return true + } + + return false +} + +// GetInstances returns the Instances field value +// If the value is explicit nil, the zero value for int32 will be returned +func (o *PatchClusterProperties) GetInstances() *int32 { + if o == nil { + return nil + } + + return o.Instances + +} + +// GetInstancesOk returns a tuple with the Instances field value +// and a boolean to check if the value has been set. +// NOTE: If the value is an explicit nil, `nil, true` will be returned +func (o *PatchClusterProperties) GetInstancesOk() (*int32, bool) { + if o == nil { + return nil, false + } + + return o.Instances, true +} + +// SetInstances sets field value +func (o *PatchClusterProperties) SetInstances(v int32) { + + o.Instances = &v + +} + +// HasInstances returns a boolean if a field has been set. +func (o *PatchClusterProperties) HasInstances() bool { + if o != nil && o.Instances != nil { + return true + } + + return false +} + +// GetCores returns the Cores field value +// If the value is explicit nil, the zero value for int32 will be returned +func (o *PatchClusterProperties) GetCores() *int32 { + if o == nil { + return nil + } + + return o.Cores + +} + +// GetCoresOk returns a tuple with the Cores field value +// and a boolean to check if the value has been set. +// NOTE: If the value is an explicit nil, `nil, true` will be returned +func (o *PatchClusterProperties) GetCoresOk() (*int32, bool) { + if o == nil { + return nil, false + } + + return o.Cores, true +} + +// SetCores sets field value +func (o *PatchClusterProperties) SetCores(v int32) { + + o.Cores = &v + +} + +// HasCores returns a boolean if a field has been set. +func (o *PatchClusterProperties) HasCores() bool { + if o != nil && o.Cores != nil { + return true + } + + return false +} + +// GetRam returns the Ram field value +// If the value is explicit nil, the zero value for int32 will be returned +func (o *PatchClusterProperties) GetRam() *int32 { + if o == nil { + return nil + } + + return o.Ram + +} + +// GetRamOk returns a tuple with the Ram field value +// and a boolean to check if the value has been set. +// NOTE: If the value is an explicit nil, `nil, true` will be returned +func (o *PatchClusterProperties) GetRamOk() (*int32, bool) { + if o == nil { + return nil, false + } + + return o.Ram, true +} + +// SetRam sets field value +func (o *PatchClusterProperties) SetRam(v int32) { + + o.Ram = &v + +} + +// HasRam returns a boolean if a field has been set. +func (o *PatchClusterProperties) HasRam() bool { + if o != nil && o.Ram != nil { + return true + } + + return false +} + +// GetStorageSize returns the StorageSize field value +// If the value is explicit nil, the zero value for int32 will be returned +func (o *PatchClusterProperties) GetStorageSize() *int32 { + if o == nil { + return nil + } + + return o.StorageSize + +} + +// GetStorageSizeOk returns a tuple with the StorageSize field value +// and a boolean to check if the value has been set. +// NOTE: If the value is an explicit nil, `nil, true` will be returned +func (o *PatchClusterProperties) GetStorageSizeOk() (*int32, bool) { + if o == nil { + return nil, false + } + + return o.StorageSize, true +} + +// SetStorageSize sets field value +func (o *PatchClusterProperties) SetStorageSize(v int32) { + + o.StorageSize = &v + +} + +// HasStorageSize returns a boolean if a field has been set. +func (o *PatchClusterProperties) HasStorageSize() bool { + if o != nil && o.StorageSize != nil { + return true + } + + return false +} + +// GetDisplayName returns the DisplayName field value +// If the value is explicit nil, the zero value for string will be returned +func (o *PatchClusterProperties) GetDisplayName() *string { + if o == nil { + return nil + } + + return o.DisplayName + +} + +// GetDisplayNameOk returns a tuple with the DisplayName field value +// and a boolean to check if the value has been set. +// NOTE: If the value is an explicit nil, `nil, true` will be returned +func (o *PatchClusterProperties) GetDisplayNameOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.DisplayName, true +} + +// SetDisplayName sets field value +func (o *PatchClusterProperties) SetDisplayName(v string) { + + o.DisplayName = &v + +} + +// HasDisplayName returns a boolean if a field has been set. +func (o *PatchClusterProperties) HasDisplayName() bool { + if o != nil && o.DisplayName != nil { + return true + } + + return false +} + +// GetMaintenanceWindow returns the MaintenanceWindow field value +// If the value is explicit nil, the zero value for MaintenanceWindow will be returned +func (o *PatchClusterProperties) GetMaintenanceWindow() *MaintenanceWindow { + if o == nil { + return nil + } + + return o.MaintenanceWindow + +} + +// GetMaintenanceWindowOk returns a tuple with the MaintenanceWindow field value +// and a boolean to check if the value has been set. +// NOTE: If the value is an explicit nil, `nil, true` will be returned +func (o *PatchClusterProperties) GetMaintenanceWindowOk() (*MaintenanceWindow, bool) { + if o == nil { + return nil, false + } + + return o.MaintenanceWindow, true +} + +// SetMaintenanceWindow sets field value +func (o *PatchClusterProperties) SetMaintenanceWindow(v MaintenanceWindow) { + + o.MaintenanceWindow = &v + +} + +// HasMaintenanceWindow returns a boolean if a field has been set. +func (o *PatchClusterProperties) HasMaintenanceWindow() bool { + if o != nil && o.MaintenanceWindow != nil { + return true + } + + return false +} + +func (o PatchClusterProperties) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.MariadbVersion != nil { + toSerialize["mariadbVersion"] = o.MariadbVersion + } + + if o.Instances != nil { + toSerialize["instances"] = o.Instances + } + + if o.Cores != nil { + toSerialize["cores"] = o.Cores + } + + if o.Ram != nil { + toSerialize["ram"] = o.Ram + } + + if o.StorageSize != nil { + toSerialize["storageSize"] = o.StorageSize + } + + if o.DisplayName != nil { + toSerialize["displayName"] = o.DisplayName + } + + if o.MaintenanceWindow != nil { + toSerialize["maintenanceWindow"] = o.MaintenanceWindow + } + + return json.Marshal(toSerialize) +} + +type NullablePatchClusterProperties struct { + value *PatchClusterProperties + isSet bool +} + +func (v NullablePatchClusterProperties) Get() *PatchClusterProperties { + return v.value +} + +func (v *NullablePatchClusterProperties) Set(val *PatchClusterProperties) { + v.value = val + v.isSet = true +} + +func (v NullablePatchClusterProperties) IsSet() bool { + return v.isSet +} + +func (v *NullablePatchClusterProperties) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullablePatchClusterProperties(val *PatchClusterProperties) *NullablePatchClusterProperties { + return &NullablePatchClusterProperties{value: val, isSet: true} +} + +func (v NullablePatchClusterProperties) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullablePatchClusterProperties) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/vendor/github.com/ionos-cloud/sdk-go-dbaas-mariadb/model_patch_cluster_request.go b/vendor/github.com/ionos-cloud/sdk-go-dbaas-mariadb/model_patch_cluster_request.go new file mode 100644 index 000000000..2bc625e9a --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-dbaas-mariadb/model_patch_cluster_request.go @@ -0,0 +1,164 @@ +/* + * IONOS DBaaS MariaDB REST API + * + * An enterprise-grade Database is provided as a Service (DBaaS) solution that can be managed through a browser-based \"Data Center Designer\" (DCD) tool or via an easy to use API. The API allows you to create additional MariaDB database clusters or modify existing ones. It is designed to allow users to leverage the same power and flexibility found within the DCD visual tool. Both tools are consistent with their concepts and lend well to making the experience smooth and intuitive. + * + * API version: 0.1.0 + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package ionoscloud + +import ( + "encoding/json" +) + +// PatchClusterRequest Request payload to change a cluster. +type PatchClusterRequest struct { + Metadata *ClusterMetadata `json:"metadata,omitempty"` + Properties *PatchClusterProperties `json:"properties,omitempty"` +} + +// NewPatchClusterRequest instantiates a new PatchClusterRequest object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewPatchClusterRequest() *PatchClusterRequest { + this := PatchClusterRequest{} + + return &this +} + +// NewPatchClusterRequestWithDefaults instantiates a new PatchClusterRequest object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewPatchClusterRequestWithDefaults() *PatchClusterRequest { + this := PatchClusterRequest{} + return &this +} + +// GetMetadata returns the Metadata field value +// If the value is explicit nil, the zero value for ClusterMetadata will be returned +func (o *PatchClusterRequest) GetMetadata() *ClusterMetadata { + if o == nil { + return nil + } + + return o.Metadata + +} + +// GetMetadataOk returns a tuple with the Metadata field value +// and a boolean to check if the value has been set. +// NOTE: If the value is an explicit nil, `nil, true` will be returned +func (o *PatchClusterRequest) GetMetadataOk() (*ClusterMetadata, bool) { + if o == nil { + return nil, false + } + + return o.Metadata, true +} + +// SetMetadata sets field value +func (o *PatchClusterRequest) SetMetadata(v ClusterMetadata) { + + o.Metadata = &v + +} + +// HasMetadata returns a boolean if a field has been set. +func (o *PatchClusterRequest) HasMetadata() bool { + if o != nil && o.Metadata != nil { + return true + } + + return false +} + +// GetProperties returns the Properties field value +// If the value is explicit nil, the zero value for PatchClusterProperties will be returned +func (o *PatchClusterRequest) GetProperties() *PatchClusterProperties { + if o == nil { + return nil + } + + return o.Properties + +} + +// GetPropertiesOk returns a tuple with the Properties field value +// and a boolean to check if the value has been set. +// NOTE: If the value is an explicit nil, `nil, true` will be returned +func (o *PatchClusterRequest) GetPropertiesOk() (*PatchClusterProperties, bool) { + if o == nil { + return nil, false + } + + return o.Properties, true +} + +// SetProperties sets field value +func (o *PatchClusterRequest) SetProperties(v PatchClusterProperties) { + + o.Properties = &v + +} + +// HasProperties returns a boolean if a field has been set. +func (o *PatchClusterRequest) HasProperties() bool { + if o != nil && o.Properties != nil { + return true + } + + return false +} + +func (o PatchClusterRequest) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.Metadata != nil { + toSerialize["metadata"] = o.Metadata + } + + if o.Properties != nil { + toSerialize["properties"] = o.Properties + } + + return json.Marshal(toSerialize) +} + +type NullablePatchClusterRequest struct { + value *PatchClusterRequest + isSet bool +} + +func (v NullablePatchClusterRequest) Get() *PatchClusterRequest { + return v.value +} + +func (v *NullablePatchClusterRequest) Set(val *PatchClusterRequest) { + v.value = val + v.isSet = true +} + +func (v NullablePatchClusterRequest) IsSet() bool { + return v.isSet +} + +func (v *NullablePatchClusterRequest) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullablePatchClusterRequest(val *PatchClusterRequest) *NullablePatchClusterRequest { + return &NullablePatchClusterRequest{value: val, isSet: true} +} + +func (v NullablePatchClusterRequest) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullablePatchClusterRequest) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/vendor/github.com/ionos-cloud/sdk-go-dbaas-mariadb/model_restore_request.go b/vendor/github.com/ionos-cloud/sdk-go-dbaas-mariadb/model_restore_request.go new file mode 100644 index 000000000..c2c1b1fb8 --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-dbaas-mariadb/model_restore_request.go @@ -0,0 +1,176 @@ +/* + * IONOS DBaaS MariaDB REST API + * + * An enterprise-grade Database is provided as a Service (DBaaS) solution that can be managed through a browser-based \"Data Center Designer\" (DCD) tool or via an easy to use API. The API allows you to create additional MariaDB database clusters or modify existing ones. It is designed to allow users to leverage the same power and flexibility found within the DCD visual tool. Both tools are consistent with their concepts and lend well to making the experience smooth and intuitive. + * + * API version: 0.1.0 + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package ionoscloud + +import ( + "encoding/json" + "time" +) + +// RestoreRequest Request payload to restore a cluster from a backup. +type RestoreRequest struct { + // The unique ID of the resource. + BackupId *string `json:"backupId"` + // The timestamp to which the cluster should be restored. If empty, the backup will be applied to the latest timestamp. This value must be supplied as ISO 8601 timestamp, the backup will be replayed up until the given timestamp. If empty, the backup will be applied completely. Must be within the earliestRecoveryTargetTime and now. The earliestRecoveryTargetTime can be looked up in the backup object. + RecoveryTargetTime *IonosTime `json:"recoveryTargetTime,omitempty"` +} + +// NewRestoreRequest instantiates a new RestoreRequest object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewRestoreRequest(backupId string) *RestoreRequest { + this := RestoreRequest{} + + this.BackupId = &backupId + + return &this +} + +// NewRestoreRequestWithDefaults instantiates a new RestoreRequest object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewRestoreRequestWithDefaults() *RestoreRequest { + this := RestoreRequest{} + return &this +} + +// GetBackupId returns the BackupId field value +// If the value is explicit nil, the zero value for string will be returned +func (o *RestoreRequest) GetBackupId() *string { + if o == nil { + return nil + } + + return o.BackupId + +} + +// GetBackupIdOk returns a tuple with the BackupId field value +// and a boolean to check if the value has been set. +// NOTE: If the value is an explicit nil, `nil, true` will be returned +func (o *RestoreRequest) GetBackupIdOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.BackupId, true +} + +// SetBackupId sets field value +func (o *RestoreRequest) SetBackupId(v string) { + + o.BackupId = &v + +} + +// HasBackupId returns a boolean if a field has been set. +func (o *RestoreRequest) HasBackupId() bool { + if o != nil && o.BackupId != nil { + return true + } + + return false +} + +// GetRecoveryTargetTime returns the RecoveryTargetTime field value +// If the value is explicit nil, the zero value for time.Time will be returned +func (o *RestoreRequest) GetRecoveryTargetTime() *time.Time { + if o == nil { + return nil + } + + if o.RecoveryTargetTime == nil { + return nil + } + return &o.RecoveryTargetTime.Time + +} + +// GetRecoveryTargetTimeOk returns a tuple with the RecoveryTargetTime field value +// and a boolean to check if the value has been set. +// NOTE: If the value is an explicit nil, `nil, true` will be returned +func (o *RestoreRequest) GetRecoveryTargetTimeOk() (*time.Time, bool) { + if o == nil { + return nil, false + } + + if o.RecoveryTargetTime == nil { + return nil, false + } + return &o.RecoveryTargetTime.Time, true + +} + +// SetRecoveryTargetTime sets field value +func (o *RestoreRequest) SetRecoveryTargetTime(v time.Time) { + + o.RecoveryTargetTime = &IonosTime{v} + +} + +// HasRecoveryTargetTime returns a boolean if a field has been set. +func (o *RestoreRequest) HasRecoveryTargetTime() bool { + if o != nil && o.RecoveryTargetTime != nil { + return true + } + + return false +} + +func (o RestoreRequest) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.BackupId != nil { + toSerialize["backupId"] = o.BackupId + } + + if o.RecoveryTargetTime != nil { + toSerialize["recoveryTargetTime"] = o.RecoveryTargetTime + } + + return json.Marshal(toSerialize) +} + +type NullableRestoreRequest struct { + value *RestoreRequest + isSet bool +} + +func (v NullableRestoreRequest) Get() *RestoreRequest { + return v.value +} + +func (v *NullableRestoreRequest) Set(val *RestoreRequest) { + v.value = val + v.isSet = true +} + +func (v NullableRestoreRequest) IsSet() bool { + return v.isSet +} + +func (v *NullableRestoreRequest) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableRestoreRequest(val *RestoreRequest) *NullableRestoreRequest { + return &NullableRestoreRequest{value: val, isSet: true} +} + +func (v NullableRestoreRequest) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableRestoreRequest) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/vendor/modules.txt b/vendor/modules.txt index de5e474fe..32895a307 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -334,7 +334,7 @@ github.com/ionos-cloud/sdk-go-dataplatform # github.com/ionos-cloud/sdk-go-dbaas-in-memory-db v1.0.1 ## explicit; go 1.18 github.com/ionos-cloud/sdk-go-dbaas-in-memory-db -# github.com/ionos-cloud/sdk-go-dbaas-mariadb v1.0.1 +# github.com/ionos-cloud/sdk-go-dbaas-mariadb v1.1.1 ## explicit; go 1.18 github.com/ionos-cloud/sdk-go-dbaas-mariadb # github.com/ionos-cloud/sdk-go-dbaas-mongo v1.3.1