From 35ebe5219448990b0c8e134b416bddfc2696d6e2 Mon Sep 17 00:00:00 2001 From: Deatcu Andrei-Cristian Date: Thu, 1 Aug 2024 17:35:23 +0300 Subject: [PATCH] feat: Add InMemoryDB resources and data sources (#564) * add client * doc: remove Required/Optional datasource * doc: required location * test: Add tests for replica set resource * feat: Add data source for Snapshots, add documentation, fix version in user agent * test: Fix 500 error for tests, use constant for time layout * refactor: Use the recently released SDK * doc: Add docs references in 'summary.md' * refactor: Resolve linter errors --------- Co-authored-by: Alexandru Claudius Virtopeanu --- CHANGELOG.md | 1 + .../dbaas_inmemorydb_replica_set.md | 73 ++ .../data-sources/dbaas_inmemorydb_snapshot.md | 35 + .../resources/dbaas_inmemorydb_replica_set.md | 128 ++ gitbook_docs/summary.md | 7 + go.mod | 1 + go.sum | 2 + ...data_source_dbaas_inmemorydb_replicaset.go | 204 ++++ .../data_source_dbaas_inmemorydb_snapshot.go | 82 ++ ...mport_dbaas_inmemorydb_replica_set_test.go | 50 + ionoscloud/provider.go | 8 + .../resource_dbaas_inmemorydb_replicaset.go | 292 +++++ ...source_dbaas_inmemorydb_replicaset_test.go | 472 ++++++++ .../resource_dbaas_mariadb_cluster_test.go | 2 +- ionoscloud/test_constants.go | 2 + services/clients.go | 2 + services/dbaas/inmemorydb/client.go | 39 + services/dbaas/inmemorydb/replica_set.go | 427 +++++++ utils/constant/constants.go | 7 + .../sdk-go-dbaas-in-memory-db/.gitignore | 24 + .../sdk-go-dbaas-in-memory-db/.travis.yml | 8 + .../sdk-go-dbaas-in-memory-db/LICENSE | 201 ++++ .../sdk-go-dbaas-in-memory-db/README.md | 152 +++ .../api_replica_set.go | 1026 +++++++++++++++++ .../sdk-go-dbaas-in-memory-db/api_restore.go | 634 ++++++++++ .../sdk-go-dbaas-in-memory-db/api_snapshot.go | 408 +++++++ .../sdk-go-dbaas-in-memory-db/client.go | 749 ++++++++++++ .../configuration.go | 328 ++++++ .../sdk-go-dbaas-in-memory-db/logger.go | 81 ++ .../model_connection.go | 215 ++++ .../model_day_of_the_week.go | 89 ++ .../sdk-go-dbaas-in-memory-db/model_error.go | 167 +++ .../model_error_messages.go | 167 +++ .../model_eviction_policy.go | 90 ++ .../model_hashed_password.go | 168 +++ .../sdk-go-dbaas-in-memory-db/model_links.go | 211 ++++ .../model_maintenance_window.go | 169 +++ .../model_metadata.go | 402 +++++++ .../model_pagination.go | 214 ++++ .../model_persistence_mode.go | 86 ++ .../model_replica_set.go | 527 +++++++++ .../model_replica_set_create.go | 168 +++ .../model_replica_set_ensure.go | 213 ++++ .../model_replica_set_metadata.go | 536 +++++++++ .../model_replica_set_metadata_all_of.go | 125 ++ .../model_replica_set_read.go | 303 +++++ .../model_replica_set_read_list.go | 393 +++++++ .../model_replica_set_read_list_all_of.go | 259 +++++ .../model_resource_state.go | 168 +++ .../model_resources.go | 215 ++++ .../model_restore.go | 213 ++++ .../model_restore_create.go | 168 +++ .../model_restore_metadata.go | 586 ++++++++++ .../model_restore_metadata_all_of.go | 175 +++ .../model_restore_read.go | 303 +++++ .../model_restore_read_list.go | 393 +++++++ .../model_restore_read_list_all_of.go | 259 +++++ .../model_snapshot_create.go | 169 +++ .../model_snapshot_ensure.go | 214 ++++ .../model_snapshot_metadata.go | 632 ++++++++++ .../model_snapshot_metadata_all_of.go | 222 ++++ .../model_snapshot_read.go | 304 +++++ .../model_snapshot_read_list.go | 393 +++++++ .../model_snapshot_read_list_all_of.go | 259 +++++ .../sdk-go-dbaas-in-memory-db/model_user.go | 169 +++ .../model_user_password.go | 139 +++ .../sdk-go-dbaas-in-memory-db/response.go | 74 ++ .../sdk-go-dbaas-in-memory-db/utils.go | 777 +++++++++++++ vendor/modules.txt | 3 + 69 files changed, 15781 insertions(+), 1 deletion(-) create mode 100644 docs/data-sources/dbaas_inmemorydb_replica_set.md create mode 100644 docs/data-sources/dbaas_inmemorydb_snapshot.md create mode 100644 docs/resources/dbaas_inmemorydb_replica_set.md create mode 100644 ionoscloud/data_source_dbaas_inmemorydb_replicaset.go create mode 100644 ionoscloud/data_source_dbaas_inmemorydb_snapshot.go create mode 100644 ionoscloud/import_dbaas_inmemorydb_replica_set_test.go create mode 100644 ionoscloud/resource_dbaas_inmemorydb_replicaset.go create mode 100644 ionoscloud/resource_dbaas_inmemorydb_replicaset_test.go create mode 100644 services/dbaas/inmemorydb/client.go create mode 100644 services/dbaas/inmemorydb/replica_set.go create mode 100644 vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/.gitignore create mode 100644 vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/.travis.yml create mode 100644 vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/LICENSE create mode 100644 vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/README.md create mode 100644 vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/api_replica_set.go create mode 100644 vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/api_restore.go create mode 100644 vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/api_snapshot.go create mode 100644 vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/client.go create mode 100644 vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/configuration.go create mode 100644 vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/logger.go create mode 100644 vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_connection.go create mode 100644 vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_day_of_the_week.go create mode 100644 vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_error.go create mode 100644 vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_error_messages.go create mode 100644 vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_eviction_policy.go create mode 100644 vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_hashed_password.go create mode 100644 vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_links.go create mode 100644 vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_maintenance_window.go create mode 100644 vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_metadata.go create mode 100644 vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_pagination.go create mode 100644 vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_persistence_mode.go create mode 100644 vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_replica_set.go create mode 100644 vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_replica_set_create.go create mode 100644 vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_replica_set_ensure.go create mode 100644 vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_replica_set_metadata.go create mode 100644 vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_replica_set_metadata_all_of.go create mode 100644 vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_replica_set_read.go create mode 100644 vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_replica_set_read_list.go create mode 100644 vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_replica_set_read_list_all_of.go create mode 100644 vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_resource_state.go create mode 100644 vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_resources.go create mode 100644 vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_restore.go create mode 100644 vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_restore_create.go create mode 100644 vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_restore_metadata.go create mode 100644 vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_restore_metadata_all_of.go create mode 100644 vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_restore_read.go create mode 100644 vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_restore_read_list.go create mode 100644 vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_restore_read_list_all_of.go create mode 100644 vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_snapshot_create.go create mode 100644 vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_snapshot_ensure.go create mode 100644 vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_snapshot_metadata.go create mode 100644 vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_snapshot_metadata_all_of.go create mode 100644 vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_snapshot_read.go create mode 100644 vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_snapshot_read_list.go create mode 100644 vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_snapshot_read_list_all_of.go create mode 100644 vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_user.go create mode 100644 vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_user_password.go create mode 100644 vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/response.go create mode 100644 vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/utils.go diff --git a/CHANGELOG.md b/CHANGELOG.md index cb4014386..c9c4b3125 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ - Add new attributes `central_logging` and `logging_format` to `application_loadbalancer` resource and data source - Add support for Event Streams for Apache Kafka - Add support for Certificate Manager providers and auto-certificates +- Add support for In-Memory DB - Add support for API Gateway - Add support for VPN Gateway diff --git a/docs/data-sources/dbaas_inmemorydb_replica_set.md b/docs/data-sources/dbaas_inmemorydb_replica_set.md new file mode 100644 index 000000000..0b87fbdb7 --- /dev/null +++ b/docs/data-sources/dbaas_inmemorydb_replica_set.md @@ -0,0 +1,73 @@ +--- +subcategory: "Database as a Service - InMemoryDB" +layout: "ionoscloud" +page_title: "IonosCloud: ionoscloud_inmemorydb_replicaset" +sidebar_current: "docs-datasource-inmemorydb_replicaset" +description: |- + Gets information about an existing InMemoryDB Replica Set. +--- + +# ionoscloud_inmemorydb_replicaset + +The `ionoscloud_inmemorydb_replicaset` data source can be used to retrieve information about an existing InMemoryDB Replica Set. + +## Example Usage + +### By id +```hcl +data "ionoscloud_inmemorydb_replicaset" "example" { + id = "example-id" + location = "es/vit" +} +``` + +### By display_name +```hcl +data "ionoscloud_inmemorydb_replicaset" "example" { + display_name = "example-id" + location = "us/las" +} +``` + +## Argument Reference + +* `id` - (Optional) The ID of the InMemoryDB Replica Set. +* `display_name` - (Optional) The display name of the InMemoryDB Replica Set. +* `location` - (Required) The location of the InMemoryDB Replica Set. + +> **Note:** Either `id` or `display_name` must be provided. If none, or both are provided, the datasource will return an error. + +## Attributes Reference + +The following attributes are returned by the datasource: + +* `dns_name` - [string] The DNS name pointing to your replica set. Will be used to connect to the active/standalone instance. +* `connections` - [object] The network connection for your replica set. Only one connection is allowed. It includes: + * `cidr` - [string] The IP and subnet for your instance. Note the following unavailable IP ranges: 10.233.64.0/18, 10.233.0.0/18, 10.233.114.0/24. + * `datacenter_id` - [string] The datacenter to connect your instance to. + * `lan_id` - [string] The numeric LAN ID to connect your instance to. +* `credentials` - [object] Credentials for the InMemoryDB replicaset, only one type of password can be used since they are mutually exclusive. It includes: + * `username` - [string] The username for the initial InMemoryDB user. Some system usernames are restricted (e.g. 'admin', 'standby'). +* `eviction_policy` - [string] The eviction policy for the replica set, possible values are: + * `noeviction` - No eviction policy is used. InMemoryDB will never remove any data. If the memory limit is reached, an error will be returned on write operations. + * `allkeys-lru` - The least recently used keys will be removed first. + * `allkeys-lfu` - The least frequently used keys will be removed first. + * `allkeys-random` - Random keys will be removed. + * `volatile-lru` - The least recently used keys will be removed first, but only among keys with the `expire` field set to `true`. + * `volatile-lfu` - The least frequently used keys will be removed first, but only among keys with the `expire` field set to `true`. + * `volatile-random` - Random keys will be removed, but only among keys with the `expire` field set to `true`. + * `volatile-ttl` - The key with the nearest time to live will be removed first, but only among keys with the `expire` field set to `true`. +* `maintenance_window` - A weekly 4 hour-long window, during which maintenance might occur. It includes: + * `time` - [string] Start of the maintenance window in UTC time. + * `day_of_the_week` - [string] The name of the week day. +* `persistence_mode` - [string] Specifies How and If data is persisted, possible values are: + * `None` - Data is inMemory only and will not be persisted. Useful for cache only applications. + * `AOF` - (Append Only File) AOF persistence logs every write operation received by the server. These operations can then be replayed again at server startup, reconstructing the original dataset. Commands are logged using the same format as the InMemoryDB protocol itself. + * `RDB` - RDB persistence performs snapshots of the current in memory state. + * `RDB_AOF` - Both, RDB and AOF persistence are enabled. +* `version` - [string] The InMemoryDB version of your replica set. +* `replicas` - [int] The total number of replicas in the replica set (one active and n-1 passive). In case of a standalone instance, the value is 1. In all other cases, the value is > 1. The replicas will not be available as read replicas, they are only standby for a failure of the active instance. +* `resources` - [object] The resources of the individual replicas. It includes: + * `cores` - [int] The number of CPU cores per instance. + * `ram` - [int] The amount of memory per instance in gigabytes (GB). + * `storage` - [int] The size of the storage in GB. The size is derived from the amount of RAM and the persistence mode and is not configurable. diff --git a/docs/data-sources/dbaas_inmemorydb_snapshot.md b/docs/data-sources/dbaas_inmemorydb_snapshot.md new file mode 100644 index 000000000..7fc135fd3 --- /dev/null +++ b/docs/data-sources/dbaas_inmemorydb_snapshot.md @@ -0,0 +1,35 @@ +--- +subcategory: "Database as a Service - InMemoryDB" +layout: "ionoscloud" +page_title: "IonosCloud: ionoscloud_inmemorydb_snapshot" +sidebar_current: "docs-datasource-inmemorydb_snapshot" +description: |- + Gets information about an existing InMemoryDB Snapshot. +--- + +# ionoscloud_inmemorydb_snapshot + +The `ionoscloud_inmemorydb_snapshot` data source can be used to retrieve information about an existing InMemoryDB Snapshot. + +## Example Usage + +```hcl +data "ionoscloud_inmemorydb_snapshot" "example" { + id = "snapshot-id" + location = "de/txl" +} +``` + +## Argument Reference + +* `id` - (Required) The ID of the InMemoryDB Snapshot. +* `location` - (Required) The location of the InMemoryDB Snapshot. + +## Attributes Reference + +* `metadata` - Metadata of the snapshot. + * `created_date` - The ISO 8601 creation timestamp. + * `datacenter_id` - The ID of the datacenter in which the snapshot is located. + * `last_modified_date` - The ISO 8601 modified timestamp. + * `replica_set_id` - The ID of the replica set from which the snapshot was created. + * `snapshot_time` - The time at which the snapshot was taken. \ No newline at end of file diff --git a/docs/resources/dbaas_inmemorydb_replica_set.md b/docs/resources/dbaas_inmemorydb_replica_set.md new file mode 100644 index 000000000..eadc4cf2e --- /dev/null +++ b/docs/resources/dbaas_inmemorydb_replica_set.md @@ -0,0 +1,128 @@ +--- +subcategory: "Database as a Service - InMemoryDB" +layout: "ionoscloud" +page_title: "IonosCloud: ionoscloud_inmemorydb_replicaset" +sidebar_current: "docs-resource-inmemorydb_replicaset" +description: |- + Creates and manages DBaaS InMemoryDB Replica Set objects. +--- + +# ionoscloud_inmemorydb_replicaset + +Manages a **DBaaS InMemoryDB Replica Set**. + +## Example Usage + +```hcl +resource "ionoscloud_datacenter" "example" { + name = "example" + location = "de/txl" + description = "Datacenter for DBaaS InMemoryDB replica sets" +} + +resource "ionoscloud_lan" "example" { + datacenter_id = ionoscloud_datacenter.example.id + public = false + name = "example" +} + +resource "ionoscloud_server" "example" { + name = "example" + datacenter_id = ionoscloud_datacenter.example.id + cores = 2 + ram = 2048 + availability_zone = "ZONE_1" + cpu_family = "INTEL_SKYLAKE" + image_name = "rockylinux-8-GenericCloud-20230518" + image_password = "password" + volume { + name = "example" + size = 6 + disk_type = "SSD Standard" + } + nic { + lan = ionoscloud_lan.example.id + name = "example" + dhcp = true + } +} + +locals { + prefix = format("%s/%s", ionoscloud_server.example.nic[0].ips[0], "24") + database_ip = cidrhost(local.prefix, 1) + database_ip_cidr = format("%s/%s", local.database_ip, "24") +} + +resource "ionoscloud_inmemorydb_replicaset" "example" { + location = ionoscloud_datacenter.example.location + display_name = "ExampleReplicaSet" + version = "7.2" + replicas = 4 + resources { + cores = 1 + ram = 6 + } + persistence_mode = "RDB" + eviction_policy = "noeviction" + connections { + datacenter_id = ionoscloud_datacenter.example.id + lan_id = ionoscloud_lan.example.id + cidr = local.database_ip_cidr + } + maintenance_window { + day_of_the_week = "Monday" + time = "10:00:00" + } + credentials { + username = "myuser" + plain_text_password = "testpassword" + } +} +``` + +## Argument Reference +* `display_name` - (Required)[string] The human readable name of your replica set. +* `location` - (Required)[string] The location of your replica set. Updates to the value of the field force the replica set to be re-created. +* `version` - (Required)[string] The InMemoryDB version of your replica set. +* `replicas` - (Required)[int] The total number of replicas in the replica set (one active and n-1 passive). In case of a standalone instance, the value is 1. In all other cases, the value is > 1. The replicas will not be available as read replicas, they are only standby for a failure of the active instance. +* `resources` - (Required)[object] The resources of the individual replicas. + * `cores` - (Required)[int] The number of CPU cores per instance. + * `ram` - (Required)[int] The amount of memory per instance in gigabytes (GB). + * `storage` - (Computed)[int] The size of the storage in GB. The size is derived from the amount of RAM and the persistence mode and is not configurable. +* `persistence_mode` - (Required)[string] Specifies How and If data is persisted, possible values are: + * `None` - Data is inMemory only and will not be persisted. Useful for cache only applications. + * `AOF` - (Append Only File) AOF persistence logs every write operation received by the server. These operations can then be replayed again at server startup, reconstructing the original dataset. Commands are logged using the same format as the InMemoryDB protocol itself. + * `RDB` - RDB persistence performs snapshots of the current in memory state. + * `RDB_AOF` - Booth, RDB and AOF persistence are enabled. +* `eviction_policy` - (Required)[string] The eviction policy for the replica set, possible values are: + * `noeviction` - No eviction policy is used. InMemoryDB will never remove any data. If the memory limit is reached, an error will be returned on write operations. + * `allkeys-lru` - The least recently used keys will be removed first. + * `allkeys-lfu` - The least frequently used keys will be removed first. + * `allkeys-random` - Random keys will be removed. + * `volatile-lru` - The least recently used keys will be removed first, but only among keys with the `expire` field set to `true`. + * `volatile-lfu` - The least frequently used keys will be removed first, but only among keys with the `expire` field set to `true`. + * `volatile-random` - Random keys will be removed, but only among keys with the `expire` field set to `true`. + * `volatile-ttl` - The key with the nearest time to live will be removed first, but only among keys with the `expire` field set to `true`. +* `connections` - (Required)[object] The network connection for your replica set. Only one connection is allowed. + * `datacenter_id` - (Required)[string] The datacenter to connect your instance to. + * `lan_id` - (Required)[string] The numeric LAN ID to connect your instance to. + * `cidr` - (Required)[string] The IP and subnet for your instance. Note the following unavailable IP ranges: 10.233.64.0/18, 10.233.0.0/18, 10.233.114.0/24. +* `credentials` - (Required)[object] Credentials for the InMemoryDB replicaset, only one type of password can be used since they are mutually exclusive + * `username` - (Required)[string] The username for the initial InMemoryDB user. Some system usernames are restricted (e.g. 'admin', 'standby'). + * `plain_text_password` - (Optional)[string] The password for a InMemoryDB user, this is a field that is marked as `Sensitive`. + * `hashed_password` - (Optional)[object] The hashed password for a InMemoryDB user. + * `algorithm` - (Required)[string] The value can be only: "SHA-256". + * `hash` - (Required)[string] The hashed password. +* `maintenance_window` - (Optional)(Computed) A weekly 4 hour-long window, during which maintenance might occur. + * `time` - (Required)[string] Start of the maintenance window in UTC time. + * `day_of_the_week` - (Required)[string] The name of the week day. +* `initial_snapshot_id` - (Optional)[string] The ID of a snapshot to restore the replica set from. If set, the replica set will be created from the snapshot. +* `dns_name` - (Computed)[string] The DNS name pointing to your replica set. Will be used to connect to the active/standalone instance. + +## Import + +Resource DBaaS InMemoryDB Replica Set can be imported using the `replicaset_id` and the `location`, separated by `:`, e.g: + +```shell +terraform import ionoscloud_inmemorydb_replicaset.example {location}:{replicaSet UUID} +``` \ No newline at end of file diff --git a/gitbook_docs/summary.md b/gitbook_docs/summary.md index a8f0934bf..042e8d3fd 100644 --- a/gitbook_docs/summary.md +++ b/gitbook_docs/summary.md @@ -116,6 +116,13 @@ * [DBaaS MongoDB Cluster](../docs/data-sources/dbaas_mariadb_cluster.md) * [DBaaS MongoDB Backups](../docs/data-sources/dbaas_mariadb_backups.md) +* Database as a Service - InMemory-DB + * Resources + * [DBaaS InMemoryDB ReplicaSet](../docs/resources/dbaas_inmemorydb_replica_set.md) + * Data sources + * [DBaaS InMemoryDB ReplicaSet](../docs/data-sources/dbaas_inmemorydb_replica_set.md) + * [DBaaS InMemoryDB Snapshot](../docs/data-sources/dbaas_inmemorydb_snapshot.md) + * Application Load Balancer * Resources * [Application Load Balancer](../docs/resources/application_loadbalancer.md) diff --git a/go.mod b/go.mod index 6bf640e42..d3350c4d9 100644 --- a/go.mod +++ b/go.mod @@ -22,6 +22,7 @@ require ( github.com/ionos-cloud/sdk-go-cert-manager v1.1.0 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-mongo v1.3.1 github.com/ionos-cloud/sdk-go-dbaas-postgres v1.1.2 diff --git a/go.sum b/go.sum index b1ae46136..5f5203283 100644 --- a/go.sum +++ b/go.sum @@ -124,6 +124,8 @@ github.com/ionos-cloud/sdk-go-container-registry v1.2.0 h1:C5r2XleKLbSFw9kmb4N8I github.com/ionos-cloud/sdk-go-container-registry v1.2.0/go.mod h1:woBP1+A4N0KXiRj9jG4y/hEXgrVjJv0CUlAvc24mCeo= github.com/ionos-cloud/sdk-go-dataplatform v1.0.3 h1:eaZITgPaLHbK4d/nVaImvP19a5yAumI5hprjM/B1qSE= 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-mongo v1.3.1 h1:+tDoZ8IEPxYwJd6fDIpWksNJs9Zzw7Pu5A39jTew058= diff --git a/ionoscloud/data_source_dbaas_inmemorydb_replicaset.go b/ionoscloud/data_source_dbaas_inmemorydb_replicaset.go new file mode 100644 index 000000000..52602f9a4 --- /dev/null +++ b/ionoscloud/data_source_dbaas_inmemorydb_replicaset.go @@ -0,0 +1,204 @@ +package ionoscloud + +import ( + "context" + "fmt" + "strings" + + "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" + inMemoryDB "github.com/ionos-cloud/sdk-go-dbaas-in-memory-db" + + "github.com/ionos-cloud/terraform-provider-ionoscloud/v6/services" + "github.com/ionos-cloud/terraform-provider-ionoscloud/v6/utils/constant" +) + +func dataSourceDBaaSInMemoryDBReplicaSet() *schema.Resource { + return &schema.Resource{ + ReadContext: dataSourceReplicaSetRead, + Schema: map[string]*schema.Schema{ + "id": { + Type: schema.TypeString, + Description: "The ID of the InMemoryDB Replicaset.", + Optional: true, + }, + "location": { + Type: schema.TypeString, + Description: "The replica set location", + Required: true, + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice(constant.Locations, false)), + }, + "display_name": { + Type: schema.TypeString, + Description: "The display name of the InMemoryDB Replicaset.", + Optional: true, + }, + "dns_name": { + Type: schema.TypeString, + Description: "The DNS name of the InMemoryDB Replicaset.", + Computed: true, + }, + "connections": { + Type: schema.TypeList, + Description: "The network connection for your Replicaset. Only one connection is allowed.", + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "cidr": { + Type: schema.TypeString, + Description: "The IP and subnet for your Replicaset.", + Computed: true, + }, + "datacenter_id": { + Type: schema.TypeString, + Description: "The datacenter to connect your Replicaset to.", + Computed: true, + }, + "lan_id": { + Type: schema.TypeString, + Description: "The numeric LAN ID to connect your Replicaset to.", + Computed: true, + }, + }, + }, + }, + "credentials": { + Type: schema.TypeList, + Description: "The credentials for your Replicaset.", + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "username": { + Type: schema.TypeString, + Description: "The username for your Replicaset.", + Computed: true, + }, + }, + }, + }, + "eviction_policy": { + Type: schema.TypeString, + Description: "The eviction policy of the InMemoryDB Replicaset.", + Computed: true, + }, + "maintenance_window": { + Type: schema.TypeList, + Description: "A weekly 4 hour-long window, during which maintenance might occur.", + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "time": { + Type: schema.TypeString, + Description: "Start of the maintenance window in UTC time.", + Computed: true, + }, + "day_of_the_week": { + Type: schema.TypeString, + Description: "The name of the week day.", + Computed: true, + }, + }, + }, + }, + "persistence_mode": { + Type: schema.TypeString, + Description: "The persistence mode of the InMemoryDB Replicaset.", + Computed: true, + }, + "version": { + Type: schema.TypeString, + Description: "The version of InMemoryDB used in the Replicaset.", + Computed: true, + }, + "replicas": { + Type: schema.TypeInt, + Description: "The number of replicas in the Replicaset.", + Computed: true, + }, + "resources": { + Type: schema.TypeList, + Description: "The resources allocated to the Replicaset.", + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "cores": { + Type: schema.TypeInt, + Description: "The number of CPU cores per instance.", + Computed: true, + }, + "ram": { + Type: schema.TypeInt, + Description: "The amount of memory per instance in gigabytes (GB).", + Computed: true, + }, + "storage": { + Type: schema.TypeInt, + Description: "The amount of storage per instance in gigabytes (GB).", + Computed: true, + }, + }, + }, + }, + }, + Timeouts: &resourceDefaultTimeouts, + } +} + +func dataSourceReplicaSetRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { + client := meta.(services.SdkBundle).InMemoryDBClient + id, idOk := d.GetOk("id") + displayName, displayNameOk := d.GetOk("display_name") + location := d.Get("location").(string) + + if idOk && displayNameOk { + return diag.FromErr(fmt.Errorf("ID and display_name cannot be both specified at the same time")) + } + if !idOk && !displayNameOk { + return diag.FromErr(fmt.Errorf("please provide either the InMemoryDB replicaset ID or display_name")) + } + + var replica inMemoryDB.ReplicaSetRead + var err error + + if idOk { + // search by ID + replica, _, err = client.GetReplicaSet(ctx, id.(string), location) + if err != nil { + return diag.FromErr(fmt.Errorf("an error occurred while fetching the InMemoryDB replica set with ID %v: %w", id.(string), err)) + } + } else { + // list, then filter by name + clusters, _, err := client.ListReplicaSets(ctx, displayName.(string), location) + if err != nil { + return diag.FromErr(fmt.Errorf("an error occurred while fetching InMemoryDB replica sets: %w", err)) + } + + var results []inMemoryDB.ReplicaSetRead + + if clusters.Items != nil { + for _, clusterItem := range *clusters.Items { + if clusterItem.Properties != nil && clusterItem.Properties.DisplayName != nil && strings.EqualFold(*clusterItem.Properties.DisplayName, displayName.(string)) { + results = append(results, clusterItem) + } + } + } + + if len(results) == 0 { + return diag.FromErr(fmt.Errorf("no InMemoryDB replica set found with the specified display name: %v", displayName)) + } + if len(results) > 1 { + var ids []string + for _, r := range results { + ids = append(ids, *r.Id) + } + return diag.FromErr(fmt.Errorf("more than one InMemoryDB replica set found with the specified criteria name '%v': (%v)", displayName, strings.Join(ids, ", "))) + } + replica = results[0] + } + + if err := client.SetReplicaSetData(d, replica); err != nil { + return diag.FromErr(err) + } + return nil +} diff --git a/ionoscloud/data_source_dbaas_inmemorydb_snapshot.go b/ionoscloud/data_source_dbaas_inmemorydb_snapshot.go new file mode 100644 index 000000000..2f3585c8f --- /dev/null +++ b/ionoscloud/data_source_dbaas_inmemorydb_snapshot.go @@ -0,0 +1,82 @@ +package ionoscloud + +import ( + "context" + "fmt" + + "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" + + "github.com/ionos-cloud/terraform-provider-ionoscloud/v6/services" + "github.com/ionos-cloud/terraform-provider-ionoscloud/v6/utils/constant" +) + +func dataSourceDBaaSInMemoryDBSnapshot() *schema.Resource { + return &schema.Resource{ + ReadContext: dataSourceInMemoryDBSnapshotRead, + Schema: map[string]*schema.Schema{ + "id": { + Type: schema.TypeString, + Description: "The ID of the snapshot.", + Required: true, + }, + "location": { + Type: schema.TypeString, + Description: "The location of the snapshot.", + Required: true, + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice(constant.Locations, false)), + }, + "metadata": { + Type: schema.TypeList, + Description: "The metadata of the snapshot.", + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "created_date": { + Type: schema.TypeString, + Description: "The ISO 8601 creation timestamp.", + Computed: true, + }, + "last_modified_date": { + Type: schema.TypeString, + Description: "The ISO 8601 modified timestamp.", + Computed: true, + }, + "replica_set_id": { + Type: schema.TypeString, + Description: "The ID of the InMemoryDB replica set the snapshot is taken from.", + Computed: true, + }, + "snapshot_time": { + Type: schema.TypeString, + Description: "The time the snapshot was dumped from the replica set.", + Computed: true, + }, + "datacenter_id": { + Type: schema.TypeString, + Description: "The ID of the datacenter the snapshot was created in. Please mind, that the snapshot is not available in other datacenters.", + Computed: true, + }, + }, + }, + }, + }, + Timeouts: &resourceDefaultTimeouts, + } +} + +func dataSourceInMemoryDBSnapshotRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { + client := meta.(services.SdkBundle).InMemoryDBClient + id := d.Get("id").(string) + location := d.Get("location").(string) + + snapshot, _, err := client.GetSnapshot(ctx, id, location) + if err != nil { + return diag.FromErr(fmt.Errorf("an error occurred while fetching the InMemoryDB snapshot with ID: %v, error: %w", id, err)) + } + if err := client.SetSnapshotData(d, snapshot); err != nil { + return diag.FromErr(err) + } + return nil +} diff --git a/ionoscloud/import_dbaas_inmemorydb_replica_set_test.go b/ionoscloud/import_dbaas_inmemorydb_replica_set_test.go new file mode 100644 index 000000000..cfbf38f39 --- /dev/null +++ b/ionoscloud/import_dbaas_inmemorydb_replica_set_test.go @@ -0,0 +1,50 @@ +//go:build all || dbaas || inMemoryDB +// +build all dbaas inMemoryDB + +package ionoscloud + +import ( + "fmt" + "testing" + + "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/terraform" + "github.com/ionos-cloud/terraform-provider-ionoscloud/v6/utils/constant" +) + +func TestAccDBaaSInMemoryDBReplicaSetImportBasic(t *testing.T) { + resource.Test(t, resource.TestCase{ + PreCheck: func() { + testAccPreCheck(t) + }, + ExternalProviders: randomProviderVersion343(), + ProtoV6ProviderFactories: testAccProtoV6ProviderFactoriesInternal(t, &testAccProvider), + CheckDestroy: testAccCheckDBaaSInMemoryDBReplicaSetDestroyCheck, + Steps: []resource.TestStep{ + { + Config: inMemoryDBReplicaSetConfigHashedPassword, + }, + { + ResourceName: constant.DBaaSInMemoryDBReplicaSetResource + "." + constant.DBaaSReplicaSetTestResource, + ImportState: true, + ImportStateIdFunc: testAccDBaaSInMemoryDBReplicaSetImportStateID, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"credentials"}, + }, + }, + }) +} + +func testAccDBaaSInMemoryDBReplicaSetImportStateID(s *terraform.State) (string, error) { + var importID = "" + + for _, rs := range s.RootModule().Resources { + if rs.Type != constant.DBaaSInMemoryDBReplicaSetResource { + continue + } + + importID = fmt.Sprintf("%s:%s", rs.Primary.Attributes["location"], rs.Primary.Attributes["id"]) + } + + return importID, nil +} diff --git a/ionoscloud/provider.go b/ionoscloud/provider.go index 4258b12e2..bd6063aeb 100644 --- a/ionoscloud/provider.go +++ b/ionoscloud/provider.go @@ -26,6 +26,7 @@ import ( crService "github.com/ionos-cloud/terraform-provider-ionoscloud/v6/services/containerregistry" dataplatformService "github.com/ionos-cloud/terraform-provider-ionoscloud/v6/services/dataplatform" dbaasService "github.com/ionos-cloud/terraform-provider-ionoscloud/v6/services/dbaas" + "github.com/ionos-cloud/terraform-provider-ionoscloud/v6/services/dbaas/inmemorydb" "github.com/ionos-cloud/terraform-provider-ionoscloud/v6/services/dbaas/mariadb" dnsService "github.com/ionos-cloud/terraform-provider-ionoscloud/v6/services/dns" kafkaService "github.com/ionos-cloud/terraform-provider-ionoscloud/v6/services/kafka" @@ -139,6 +140,7 @@ func Provider() *schema.Provider { constant.DBaaSMariaDBClusterResource: resourceDBaaSMariaDBCluster(), constant.DBaasMongoClusterResource: resourceDbaasMongoDBCluster(), constant.DBaasMongoUserResource: resourceDbaasMongoUser(), + constant.DBaaSInMemoryDBReplicaSetResource: resourceDBaaSInMemoryDBReplicaSet(), constant.ALBResource: resourceApplicationLoadBalancer(), constant.ALBForwardingRuleResource: resourceApplicationLoadBalancerForwardingRule(), constant.TargetGroupResource: resourceTargetGroup(), @@ -211,6 +213,8 @@ func Provider() *schema.Provider { constant.ALBForwardingRuleResource: dataSourceApplicationLoadBalancerForwardingRule(), constant.TargetGroupResource: dataSourceTargetGroup(), constant.DBaasMongoUserResource: dataSourceDbaasMongoUser(), + constant.DBaaSInMemoryDBReplicaSetResource: dataSourceDBaaSInMemoryDBReplicaSet(), + constant.DBaaSInMemoryDBSnapshotResource: dataSourceDBaaSInMemoryDBSnapshot(), constant.CertificateResource: dataSourceCertificate(), constant.AutoCertificateProviderResource: dataSourceCertificateManagerProvider(), constant.AutoCertificateResource: dataSourceCertificateManagerAutoCertificate(), @@ -308,6 +312,7 @@ func providerConfigure(d *schema.ResourceData, terraformVersion string) (interfa KafkaClient: NewClientByType(clientOpts, kafkaClient).(*kafkaService.Client), APIGatewayClient: NewClientByType(clientOpts, apiGatewayClient).(*apiGatewayService.Client), VPNClient: NewClientByType(clientOpts, vpnClient).(*vpn.Client), + InMemoryDBClient: NewClientByType(clientOpts, inMemoryDBClient).(*inmemorydb.InMemoryDBClient), }, nil } @@ -330,6 +335,7 @@ const ( kafkaClient apiGatewayClient vpnClient + inMemoryDBClient ) func NewClientByType(clientOpts ClientOptions, clientType clientType) interface{} { @@ -381,6 +387,8 @@ func NewClientByType(clientOpts ClientOptions, clientType clientType) interface{ ) case vpnClient: return vpn.NewClient(clientOpts.Username, clientOpts.Password, clientOpts.Token, clientOpts.Url, clientOpts.Username) + case inMemoryDBClient: + return inmemorydb.NewInMemoryDBClient(clientOpts.Username, clientOpts.Password, clientOpts.Token, clientOpts.Url, clientOpts.Version, clientOpts.Username) default: log.Fatalf("[ERROR] unknown client type %d", clientType) } diff --git a/ionoscloud/resource_dbaas_inmemorydb_replicaset.go b/ionoscloud/resource_dbaas_inmemorydb_replicaset.go new file mode 100644 index 000000000..f85f0ccb1 --- /dev/null +++ b/ionoscloud/resource_dbaas_inmemorydb_replicaset.go @@ -0,0 +1,292 @@ +package ionoscloud + +import ( + "context" + "fmt" + "log" + "slices" + "strings" + "time" + + "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" + + "github.com/ionos-cloud/terraform-provider-ionoscloud/v6/services" + "github.com/ionos-cloud/terraform-provider-ionoscloud/v6/services/dbaas/inmemorydb" + "github.com/ionos-cloud/terraform-provider-ionoscloud/v6/utils" + "github.com/ionos-cloud/terraform-provider-ionoscloud/v6/utils/constant" +) + +func resourceDBaaSInMemoryDBReplicaSet() *schema.Resource { + return &schema.Resource{ + CreateContext: replicaSetCreate, + DeleteContext: replicaSetDelete, + ReadContext: replicaSetRead, + UpdateContext: replicaSetUpdate, + Importer: &schema.ResourceImporter{ + StateContext: replicaSetImport, + }, + Schema: map[string]*schema.Schema{ + "display_name": { + Type: schema.TypeString, + Description: "The human readable name of your replica set.", + Required: true, + }, + "location": { + Type: schema.TypeString, + Description: "The replica set location", + Required: true, + ForceNew: true, + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice(constant.Locations, false)), + }, + "version": { + Type: schema.TypeString, + Description: "The InMemoryDB version of your replica set.", + Required: true, + }, + "replicas": { + Type: schema.TypeInt, + Description: "The total number of replicas in the replica set (one active and n-1 passive). In case of a standalone instance, the value is 1. In all other cases, the value is > 1. The replicas will not be available as read replicas, they are only standby for a failure of the active instance.", + Required: true, + }, + "resources": { + Type: schema.TypeList, + Description: "The resources of the individual replicas.", + Required: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "cores": { + Type: schema.TypeInt, + Description: "The number of CPU cores per instance.", + Required: true, + }, + "ram": { + Type: schema.TypeInt, + Description: "The amount of memory per instance in gigabytes (GB).", + Required: true, + }, + "storage": { + Type: schema.TypeInt, + Description: "The size of the storage in GB. The size is derived from the amount of RAM and the persistence mode and is not configurable.", + Computed: true, + }, + }, + }, + }, + "persistence_mode": { + Type: schema.TypeString, + Description: "Specifies How and If data is persisted.", + Required: true, + }, + "eviction_policy": { + Type: schema.TypeString, + Description: "The eviction policy for the replica set.", + Required: true, + }, + "connections": { + Type: schema.TypeList, + Description: "The network connection for your replica set. Only one connection is allowed.", + Required: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "datacenter_id": { + Type: schema.TypeString, + Description: "The datacenter to connect your instance to.", + Required: true, + }, + "lan_id": { + Type: schema.TypeString, + Description: "The numeric LAN ID to connect your instance to.", + Required: true, + }, + "cidr": { + Type: schema.TypeString, + Description: "The IP and subnet for your instance. Note the following unavailable IP ranges: 10.233.64.0/18, 10.233.0.0/18, 10.233.114.0/24", + Required: true, + }, + }, + }, + }, + "credentials": { + Type: schema.TypeList, + Description: "Credentials for the InMemoryDB replicaset.", + Required: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "username": { + Type: schema.TypeString, + Description: "The username for the initial InMemoryDB user. Some system usernames are restricted (e.g. 'admin', 'standby').", + Required: true, + }, + "plain_text_password": { + Type: schema.TypeString, + Description: "The password for a InMemoryDB user.", + Optional: true, + Sensitive: true, + ExactlyOneOf: []string{"credentials.0.plain_text_password", "credentials.0.hashed_password"}, + }, + "hashed_password": { + Type: schema.TypeList, + Description: "The hashed password for a InMemoryDB user.", + Optional: true, + ExactlyOneOf: []string{"credentials.0.hashed_password", "credentials.0.plain_text_password"}, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "algorithm": { + Type: schema.TypeString, + Required: true, + }, + "hash": { + Type: schema.TypeString, + Required: true, + }, + }, + }, + }, + }, + }, + }, + "maintenance_window": { + Type: schema.TypeList, + Description: "A weekly 4 hour-long window, during which maintenance might occur.", + Optional: true, + Computed: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "time": { + Type: schema.TypeString, + Description: "Start of the maintenance window in UTC time.", + Required: true, + }, + "day_of_the_week": { + Type: schema.TypeString, + Description: "The name of the week day.", + Required: true, + }, + }, + }, + }, + "initial_snapshot_id": { + Type: schema.TypeString, + Description: "The ID of a snapshot to restore the replica set from. If set, the replica set will be created from the snapshot.", + Optional: true, + }, + "dns_name": { + Type: schema.TypeString, + Description: "The DNS name pointing to your replica set. Will be used to connect to the active/standalone instance.", + Computed: true, + }, + }, + Timeouts: &resourceDefaultTimeouts, + } +} + +func replicaSetCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { + client := meta.(services.SdkBundle).InMemoryDBClient + + replicaSet := inmemorydb.GetReplicaSetDataCreate(d) + response, _, err := client.CreateReplicaSet(ctx, replicaSet, d.Get("location").(string)) + if err != nil { + return diag.FromErr(fmt.Errorf("an error occurred while creating an InMemoryDB replica set: %w", err)) + } + replicaSetID := *response.Id + d.SetId(replicaSetID) + err = utils.WaitForResourceToBeReady(ctx, d, client.IsReplicaSetReady) + if err != nil { + return diag.FromErr(fmt.Errorf("error occurred while checking the status for InMemoryDB replica set with ID: %v, error: %w", replicaSetID, err)) + } + // Call the read function to save the DNS name in the state (DNS name is not present in the creation response). + return replicaSetRead(ctx, d, meta) +} + +func replicaSetDelete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { + client := meta.(services.SdkBundle).InMemoryDBClient + replicaSetID := d.Id() + apiResponse, err := client.DeleteReplicaSet(ctx, replicaSetID, d.Get("location").(string)) + if err != nil { + if apiResponse.HttpNotFound() { + d.SetId("") + return nil + } + return diag.FromErr(fmt.Errorf("error while deleting InMemoryDB replica set with ID: %v, error: %w", replicaSetID, err)) + } + err = utils.WaitForResourceToBeDeleted(ctx, d, client.IsReplicaSetDeleted) + if err != nil { + return diag.FromErr(fmt.Errorf("deletion check failed for InMemoryDB replica set with ID: %v, error: %w", replicaSetID, err)) + } + + // wait for the lan to be freed after the deletion of the replica set + time.Sleep(constant.SleepInterval * 10) + return nil +} + +func replicaSetRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { + client := meta.(services.SdkBundle).InMemoryDBClient + replicaSetID := d.Id() + replicaSet, apiResponse, err := client.GetReplicaSet(ctx, replicaSetID, d.Get("location").(string)) + if err != nil { + if apiResponse.HttpNotFound() { + d.SetId("") + return nil + } + return diag.FromErr(fmt.Errorf("error while fetching InMemoryDB replica set with ID: %v, error: %w", replicaSetID, err)) + } + log.Printf("[INFO] Successfully retrieved InMemoryDB replica set with ID: %v, replica set info: %+v", replicaSetID, replicaSet) + if err := client.SetReplicaSetData(d, replicaSet); err != nil { + return diag.FromErr(err) + } + return nil +} + +func replicaSetUpdate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { + client := meta.(services.SdkBundle).InMemoryDBClient + replicaSetID := d.Id() + replicaSet := inmemorydb.GetReplicaSetDataUpdate(d) + response, _, err := client.UpdateReplicaSet(ctx, replicaSetID, d.Get("location").(string), replicaSet) + if err != nil { + return diag.FromErr(fmt.Errorf("an error occurred while updating InMemoryDB replica set with ID: %v, error: %w", replicaSetID, err)) + } + err = utils.WaitForResourceToBeReady(ctx, d, client.IsReplicaSetReady) + if err != nil { + return diag.FromErr(fmt.Errorf("error occurred while checking the status for InMemoryDB replica set after update, replica set ID: %v, error: %w", replicaSetID, err)) + } + if err := client.SetReplicaSetData(d, response); err != nil { + return diag.FromErr(err) + } + return nil +} + +func replicaSetImport(ctx context.Context, d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { + client := meta.(services.SdkBundle).InMemoryDBClient + parts := strings.Split(d.Id(), ":") + if len(parts) != 2 { + return nil, fmt.Errorf("invalid import ID: %q, expected ID in the format ':'", d.Id()) + } + location := parts[0] + if !slices.Contains(constant.Locations, location) { + return nil, fmt.Errorf("invalid import ID: %q, location must be one of %v", d.Id(), constant.Locations) + } + replicaSetID := parts[1] + replicaSet, apiResponse, err := client.GetReplicaSet(ctx, replicaSetID, location) + if err != nil { + if apiResponse.HttpNotFound() { + d.SetId("") + return nil, fmt.Errorf("InMemoryDB replica set does not exist, error: %w", err) + } + return nil, fmt.Errorf("an error occurred while trying to import InMemoryDB replica set with ID: %v, error: %w", replicaSetID, err) + } + log.Printf("[INFO] InMemoryDB replica set found: %+v", replicaSet) + if err := d.Set("location", location); err != nil { + return nil, utils.GenerateSetError("InMemoryDB replica set", "location", err) + } + if err := client.SetReplicaSetData(d, replicaSet); err != nil { + return nil, err + } + return []*schema.ResourceData{d}, nil +} diff --git a/ionoscloud/resource_dbaas_inmemorydb_replicaset_test.go b/ionoscloud/resource_dbaas_inmemorydb_replicaset_test.go new file mode 100644 index 000000000..304a8c28d --- /dev/null +++ b/ionoscloud/resource_dbaas_inmemorydb_replicaset_test.go @@ -0,0 +1,472 @@ +//go:build all || dbaas || inMemoryDB +// +build all dbaas inMemoryDB + +package ionoscloud + +import ( + "context" + "fmt" + "regexp" + "testing" + + "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/terraform" + inMemoryDB "github.com/ionos-cloud/sdk-go-dbaas-in-memory-db" + + "github.com/ionos-cloud/terraform-provider-ionoscloud/v6/services" + "github.com/ionos-cloud/terraform-provider-ionoscloud/v6/utils/constant" +) + +func TestAccDBaaSInMemoryDBReplicaSetBasic(t *testing.T) { + var replicaSet inMemoryDB.ReplicaSetRead + resource.Test(t, resource.TestCase{ + PreCheck: func() { + testAccPreCheck(t) + }, + ExternalProviders: map[string]resource.ExternalProvider{ + "random": { + VersionConstraint: "3.4.3", + Source: "hashicorp/random", + }, + }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactoriesInternal(t, &testAccProvider), + CheckDestroy: testAccCheckDBaaSInMemoryDBReplicaSetDestroyCheck, + // The tests contain multiple constants that are reused in other DBaaS tests, especially attributes like 'lan_id', 'datacenter_id' for + // which there is no need to create new constants (there is a high probability that these attributes will remain the same in the future). + Steps: []resource.TestStep{ + // This step tests a configuration that uses a hashed password. + { + Config: inMemoryDBReplicaSetConfigHashedPassword, + Check: resource.ComposeTestCheckFunc( + testAccCheckDBaaSInMemoryDBReplicaSetExists(constant.DBaaSInMemoryDBReplicaSetResource+"."+constant.DBaaSReplicaSetTestResource, &replicaSet), + resource.TestCheckResourceAttr(constant.DBaaSInMemoryDBReplicaSetResource+"."+constant.DBaaSReplicaSetTestResource, clusterDisplayNameAttribute, replicaSetDisplayNameValue), + resource.TestCheckResourceAttr(constant.DBaaSInMemoryDBReplicaSetResource+"."+constant.DBaaSReplicaSetTestResource, replicaSetLocationAttribute, replicaSetLocationValue), + resource.TestCheckResourceAttr(constant.DBaaSInMemoryDBReplicaSetResource+"."+constant.DBaaSReplicaSetTestResource, replicaSetVersionAttribute, replicaSetVersionValue), + resource.TestCheckResourceAttr(constant.DBaaSInMemoryDBReplicaSetResource+"."+constant.DBaaSReplicaSetTestResource, replicaSetReplicasAttribute, replicaSetReplicasValue), + resource.TestCheckTypeSetElemNestedAttrs(constant.DBaaSInMemoryDBReplicaSetResource+"."+constant.DBaaSReplicaSetTestResource, replicaSetResourcesAttribute+".*", map[string]string{ + clusterCoresAttribute: replicaSetCoresValue, + clusterRamAttribute: replicaSetRAMValue, + }), + resource.TestCheckResourceAttrSet(constant.DBaaSInMemoryDBReplicaSetResource+"."+constant.DBaaSReplicaSetTestResource, replicaSetResourcesAttribute+".0.storage"), + resource.TestCheckResourceAttr(constant.DBaaSInMemoryDBReplicaSetResource+"."+constant.DBaaSReplicaSetTestResource, replicaSetPersistenceModeAttribute, replicaSetPersistenceModeValue), + resource.TestCheckResourceAttr(constant.DBaaSInMemoryDBReplicaSetResource+"."+constant.DBaaSReplicaSetTestResource, replicaSetEvictionPolicyAttribute, replicaSetEvictionPolicyValue), + resource.TestCheckResourceAttrSet(constant.DBaaSInMemoryDBReplicaSetResource+"."+constant.DBaaSReplicaSetTestResource, clusterConnectionsAttribute+".0."+clusterConnectionsDatacenterIDAttribute), + resource.TestCheckResourceAttrSet(constant.DBaaSInMemoryDBReplicaSetResource+"."+constant.DBaaSReplicaSetTestResource, clusterConnectionsAttribute+".0."+clusterConnectionsLanIDAttribute), + resource.TestCheckResourceAttrSet(constant.DBaaSInMemoryDBReplicaSetResource+"."+constant.DBaaSReplicaSetTestResource, clusterConnectionsAttribute+".0."+clusterConnectionsCidrAttribute), + resource.TestCheckTypeSetElemNestedAttrs(constant.DBaaSInMemoryDBReplicaSetResource+"."+constant.DBaaSReplicaSetTestResource, clusterCredentialsAttribute+".0."+replicaSetHashedPasswordAttribute+".*", map[string]string{ + replicaSetHashAttribute: replicaSetHashValue, + replicaSetAlgorithmAttribute: replicaSetAlgorithmValue, + }), + resource.TestCheckTypeSetElemNestedAttrs(constant.DBaaSInMemoryDBReplicaSetResource+"."+constant.DBaaSReplicaSetTestResource, clusterMaintenanceWindowAttribute+".*", map[string]string{ + clusterMaintenanceWindowTimeAttribute: clusterMaintenanceWindowTimeValue, + clusterMaintenanceWindowDayOfTheWeekAttribute: clusterMaintenanceWindowDayOfTheWeekValue, + }), + resource.TestCheckResourceAttrSet(constant.DBaaSInMemoryDBReplicaSetResource+"."+constant.DBaaSReplicaSetTestResource, replicaSetDNSNameAttribute), + ), + }, + // This step deletes the replica set that was previously created, in order to make place + // for another replica set with different credentials. + // TODO -- Uncomment this when the API problem will be fixed + //{ + // Config: inMemoryDBReplicaSetConfigSetup, + //}, + // TODO -- Remove this when the API problem will be fixed. + { + Config: temporaryConfigSetup, + }, + // This step tests a configuration that uses the plain text password, this configuration + // will be also used for 'update' tests. + { + Config: inMemoryDBReplicaSetConfigPlainTextPassword, + Check: resource.ComposeTestCheckFunc( + testAccCheckDBaaSInMemoryDBReplicaSetExists(constant.DBaaSInMemoryDBReplicaSetResource+"."+constant.DBaaSReplicaSetTestResource, &replicaSet), + resource.TestCheckResourceAttr(constant.DBaaSInMemoryDBReplicaSetResource+"."+constant.DBaaSReplicaSetTestResource, clusterDisplayNameAttribute, replicaSetDisplayNameValue), + resource.TestCheckResourceAttr(constant.DBaaSInMemoryDBReplicaSetResource+"."+constant.DBaaSReplicaSetTestResource, replicaSetLocationAttribute, replicaSetLocationValue), + resource.TestCheckResourceAttr(constant.DBaaSInMemoryDBReplicaSetResource+"."+constant.DBaaSReplicaSetTestResource, replicaSetVersionAttribute, replicaSetVersionValue), + resource.TestCheckResourceAttr(constant.DBaaSInMemoryDBReplicaSetResource+"."+constant.DBaaSReplicaSetTestResource, replicaSetReplicasAttribute, replicaSetReplicasValue), + resource.TestCheckTypeSetElemNestedAttrs(constant.DBaaSInMemoryDBReplicaSetResource+"."+constant.DBaaSReplicaSetTestResource, replicaSetResourcesAttribute+".*", map[string]string{ + clusterCoresAttribute: replicaSetCoresValue, + clusterRamAttribute: replicaSetRAMValue, + }), + resource.TestCheckResourceAttrSet(constant.DBaaSInMemoryDBReplicaSetResource+"."+constant.DBaaSReplicaSetTestResource, replicaSetResourcesAttribute+".0.storage"), + resource.TestCheckResourceAttr(constant.DBaaSInMemoryDBReplicaSetResource+"."+constant.DBaaSReplicaSetTestResource, replicaSetPersistenceModeAttribute, replicaSetPersistenceModeValue), + resource.TestCheckResourceAttr(constant.DBaaSInMemoryDBReplicaSetResource+"."+constant.DBaaSReplicaSetTestResource, replicaSetEvictionPolicyAttribute, replicaSetEvictionPolicyValue), + resource.TestCheckResourceAttrSet(constant.DBaaSInMemoryDBReplicaSetResource+"."+constant.DBaaSReplicaSetTestResource, clusterConnectionsAttribute+".0."+clusterConnectionsDatacenterIDAttribute), + resource.TestCheckResourceAttrSet(constant.DBaaSInMemoryDBReplicaSetResource+"."+constant.DBaaSReplicaSetTestResource, clusterConnectionsAttribute+".0."+clusterConnectionsLanIDAttribute), + resource.TestCheckResourceAttrSet(constant.DBaaSInMemoryDBReplicaSetResource+"."+constant.DBaaSReplicaSetTestResource, clusterConnectionsAttribute+".0."+clusterConnectionsCidrAttribute), + resource.TestCheckResourceAttr(constant.DBaaSInMemoryDBReplicaSetResource+"."+constant.DBaaSReplicaSetTestResource, clusterCredentialsAttribute+".0."+clusterCredentialsUsernameAttribute, clusterCredentialsUsernameValue), + resource.TestCheckResourceAttrSet(constant.DBaaSInMemoryDBReplicaSetResource+"."+constant.DBaaSReplicaSetTestResource, clusterCredentialsAttribute+".0."+replicaSetPlainTextPasswordAttribute), + resource.TestCheckTypeSetElemNestedAttrs(constant.DBaaSInMemoryDBReplicaSetResource+"."+constant.DBaaSReplicaSetTestResource, clusterMaintenanceWindowAttribute+".*", map[string]string{ + clusterMaintenanceWindowTimeAttribute: clusterMaintenanceWindowTimeValue, + clusterMaintenanceWindowDayOfTheWeekAttribute: clusterMaintenanceWindowDayOfTheWeekValue, + }), + resource.TestCheckResourceAttrSet(constant.DBaaSInMemoryDBReplicaSetResource+"."+constant.DBaaSReplicaSetTestResource, replicaSetDNSNameAttribute), + ), + }, + { + Config: inMemoryDBReplicaSetDataSourceMatchID, + Check: resource.ComposeTestCheckFunc( + testAccCheckDBaaSInMemoryDBReplicaSetExists(constant.DBaaSInMemoryDBReplicaSetResource+"."+constant.DBaaSReplicaSetTestResource, &replicaSet), + resource.TestCheckResourceAttr(constant.DataSource+"."+constant.DBaaSInMemoryDBReplicaSetResource+"."+constant.DBaaSReplicaSetTestDataSourceByID, replicaSetLocationAttribute, replicaSetLocationValue), + resource.TestCheckResourceAttr(constant.DataSource+"."+constant.DBaaSInMemoryDBReplicaSetResource+"."+constant.DBaaSReplicaSetTestDataSourceByID, replicaSetVersionAttribute, replicaSetVersionValue), + resource.TestCheckResourceAttr(constant.DataSource+"."+constant.DBaaSInMemoryDBReplicaSetResource+"."+constant.DBaaSReplicaSetTestDataSourceByID, replicaSetReplicasAttribute, replicaSetReplicasValue), + resource.TestCheckResourceAttr(constant.DataSource+"."+constant.DBaaSInMemoryDBReplicaSetResource+"."+constant.DBaaSReplicaSetTestDataSourceByID, replicaSetResourcesAttribute+".0."+clusterCoresAttribute, replicaSetCoresValue), + resource.TestCheckResourceAttr(constant.DataSource+"."+constant.DBaaSInMemoryDBReplicaSetResource+"."+constant.DBaaSReplicaSetTestDataSourceByID, replicaSetResourcesAttribute+".0."+clusterRamAttribute, replicaSetRAMValue), + resource.TestCheckResourceAttr(constant.DataSource+"."+constant.DBaaSInMemoryDBReplicaSetResource+"."+constant.DBaaSReplicaSetTestDataSourceByID, clusterDisplayNameAttribute, replicaSetDisplayNameValue), + // TODO -- Replace lan_id and datacenter_id checks with the ones from the setup configuration once the API is fixed. + resource.TestCheckResourceAttrPair(constant.DataSource+"."+constant.DBaaSInMemoryDBReplicaSetResource+"."+constant.DBaaSReplicaSetTestDataSourceByID, clusterConnectionsAttribute+".0."+clusterConnectionsDatacenterIDAttribute, "data.ionoscloud_datacenter.datacenterDS", "id"), + resource.TestCheckResourceAttrPair(constant.DataSource+"."+constant.DBaaSInMemoryDBReplicaSetResource+"."+constant.DBaaSReplicaSetTestDataSourceByID, clusterConnectionsAttribute+".0."+clusterConnectionsLanIDAttribute, "data.ionoscloud_lan.lanDS", "id"), + resource.TestCheckResourceAttr(constant.DataSource+"."+constant.DBaaSInMemoryDBReplicaSetResource+"."+constant.DBaaSReplicaSetTestDataSourceByID, clusterMaintenanceWindowAttribute+".0."+clusterMaintenanceWindowDayOfTheWeekAttribute, clusterMaintenanceWindowDayOfTheWeekValue), + resource.TestCheckResourceAttr(constant.DataSource+"."+constant.DBaaSInMemoryDBReplicaSetResource+"."+constant.DBaaSReplicaSetTestDataSourceByID, clusterMaintenanceWindowAttribute+".0."+clusterMaintenanceWindowTimeAttribute, clusterMaintenanceWindowTimeValue), + ), + }, + { + Config: inMemoryDBReplicaSetDataSourceMatchName, + Check: resource.ComposeTestCheckFunc( + testAccCheckDBaaSInMemoryDBReplicaSetExists(constant.DBaaSInMemoryDBReplicaSetResource+"."+constant.DBaaSReplicaSetTestResource, &replicaSet), + resource.TestCheckResourceAttr(constant.DataSource+"."+constant.DBaaSInMemoryDBReplicaSetResource+"."+constant.DBaaSReplicaSetTestDataSourceByName, replicaSetLocationAttribute, replicaSetLocationValue), + resource.TestCheckResourceAttr(constant.DataSource+"."+constant.DBaaSInMemoryDBReplicaSetResource+"."+constant.DBaaSReplicaSetTestDataSourceByName, replicaSetVersionAttribute, replicaSetVersionValue), + resource.TestCheckResourceAttr(constant.DataSource+"."+constant.DBaaSInMemoryDBReplicaSetResource+"."+constant.DBaaSReplicaSetTestDataSourceByName, replicaSetReplicasAttribute, replicaSetReplicasValue), + resource.TestCheckResourceAttr(constant.DataSource+"."+constant.DBaaSInMemoryDBReplicaSetResource+"."+constant.DBaaSReplicaSetTestDataSourceByName, replicaSetResourcesAttribute+".0."+clusterCoresAttribute, replicaSetCoresValue), + resource.TestCheckResourceAttr(constant.DataSource+"."+constant.DBaaSInMemoryDBReplicaSetResource+"."+constant.DBaaSReplicaSetTestDataSourceByName, replicaSetResourcesAttribute+".0."+clusterRamAttribute, replicaSetRAMValue), + resource.TestCheckResourceAttr(constant.DataSource+"."+constant.DBaaSInMemoryDBReplicaSetResource+"."+constant.DBaaSReplicaSetTestDataSourceByName, clusterDisplayNameAttribute, replicaSetDisplayNameValue), + // TODO -- Replace lan_id and datacenter_id checks with the ones from the setup configuration once the API is fixed. + resource.TestCheckResourceAttrPair(constant.DataSource+"."+constant.DBaaSInMemoryDBReplicaSetResource+"."+constant.DBaaSReplicaSetTestDataSourceByName, clusterConnectionsAttribute+".0."+clusterConnectionsDatacenterIDAttribute, "data.ionoscloud_datacenter.datacenterDS", "id"), + resource.TestCheckResourceAttrPair(constant.DataSource+"."+constant.DBaaSInMemoryDBReplicaSetResource+"."+constant.DBaaSReplicaSetTestDataSourceByName, clusterConnectionsAttribute+".0."+clusterConnectionsLanIDAttribute, "data.ionoscloud_lan.lanDS", "id"), + resource.TestCheckResourceAttr(constant.DataSource+"."+constant.DBaaSInMemoryDBReplicaSetResource+"."+constant.DBaaSReplicaSetTestDataSourceByName, clusterMaintenanceWindowAttribute+".0."+clusterMaintenanceWindowDayOfTheWeekAttribute, clusterMaintenanceWindowDayOfTheWeekValue), + resource.TestCheckResourceAttr(constant.DataSource+"."+constant.DBaaSInMemoryDBReplicaSetResource+"."+constant.DBaaSReplicaSetTestDataSourceByName, clusterMaintenanceWindowAttribute+".0."+clusterMaintenanceWindowTimeAttribute, clusterMaintenanceWindowTimeValue)), + }, + // This step tests for basic updates for different attributes. + // TODO -- Check what fields can actually be updated since for some of them it seems + // that we are receiving API errors. + { + Config: inMemoryDBReplicaSetConfigUpdate, + Check: resource.ComposeTestCheckFunc( + testAccCheckDBaaSInMemoryDBReplicaSetExists(constant.DBaaSInMemoryDBReplicaSetResource+"."+constant.DBaaSReplicaSetTestResource, &replicaSet), + resource.TestCheckResourceAttr(constant.DBaaSInMemoryDBReplicaSetResource+"."+constant.DBaaSReplicaSetTestResource, clusterDisplayNameAttribute, replicaSetDisplayNameUpdateValue), + resource.TestCheckResourceAttr(constant.DBaaSInMemoryDBReplicaSetResource+"."+constant.DBaaSReplicaSetTestResource, replicaSetLocationAttribute, replicaSetLocationValue), + resource.TestCheckResourceAttr(constant.DBaaSInMemoryDBReplicaSetResource+"."+constant.DBaaSReplicaSetTestResource, replicaSetVersionAttribute, replicaSetVersionValue), + resource.TestCheckResourceAttr(constant.DBaaSInMemoryDBReplicaSetResource+"."+constant.DBaaSReplicaSetTestResource, replicaSetReplicasAttribute, replicaSetReplicasUpdateValue), + resource.TestCheckTypeSetElemNestedAttrs(constant.DBaaSInMemoryDBReplicaSetResource+"."+constant.DBaaSReplicaSetTestResource, replicaSetResourcesAttribute+".*", map[string]string{ + clusterCoresAttribute: replicaSetCoresValueUpdate, + clusterRamAttribute: replicaSetRAMValueUpdate, + }), + resource.TestCheckResourceAttrSet(constant.DBaaSInMemoryDBReplicaSetResource+"."+constant.DBaaSReplicaSetTestResource, replicaSetResourcesAttribute+".0.storage"), + resource.TestCheckResourceAttr(constant.DBaaSInMemoryDBReplicaSetResource+"."+constant.DBaaSReplicaSetTestResource, replicaSetPersistenceModeAttribute, replicaSetPersistenceModeUpdateValue), + resource.TestCheckResourceAttr(constant.DBaaSInMemoryDBReplicaSetResource+"."+constant.DBaaSReplicaSetTestResource, replicaSetEvictionPolicyAttribute, replicaSetEvictionPolicyUpdateValue), + resource.TestCheckResourceAttrSet(constant.DBaaSInMemoryDBReplicaSetResource+"."+constant.DBaaSReplicaSetTestResource, clusterConnectionsAttribute+".0."+clusterConnectionsDatacenterIDAttribute), + resource.TestCheckResourceAttrSet(constant.DBaaSInMemoryDBReplicaSetResource+"."+constant.DBaaSReplicaSetTestResource, clusterConnectionsAttribute+".0."+clusterConnectionsLanIDAttribute), + resource.TestCheckResourceAttrSet(constant.DBaaSInMemoryDBReplicaSetResource+"."+constant.DBaaSReplicaSetTestResource, clusterConnectionsAttribute+".0."+clusterConnectionsCidrAttribute), + resource.TestCheckResourceAttr(constant.DBaaSInMemoryDBReplicaSetResource+"."+constant.DBaaSReplicaSetTestResource, clusterCredentialsAttribute+".0."+clusterCredentialsUsernameAttribute, clusterCredentialsUsernameValue), + resource.TestCheckResourceAttrSet(constant.DBaaSInMemoryDBReplicaSetResource+"."+constant.DBaaSReplicaSetTestResource, clusterCredentialsAttribute+".0."+replicaSetPlainTextPasswordAttribute), + resource.TestCheckTypeSetElemNestedAttrs(constant.DBaaSInMemoryDBReplicaSetResource+"."+constant.DBaaSReplicaSetTestResource, clusterMaintenanceWindowAttribute+".*", map[string]string{ + clusterMaintenanceWindowTimeAttribute: clusterMaintenanceWindowTimeUpdateValue, + clusterMaintenanceWindowDayOfTheWeekAttribute: clusterMaintenanceWindowDayOfTheWeekUpdateValue, + }), + resource.TestCheckResourceAttrSet(constant.DBaaSInMemoryDBReplicaSetResource+"."+constant.DBaaSReplicaSetTestResource, replicaSetDNSNameAttribute), + ), + }, + { + Config: inMemoryDBReplicaSetDataSourceWrongName, + ExpectError: regexp.MustCompile("no InMemoryDB replica set found with the specified display name"), + }, + { + Config: inMemoryDBReplicaSetDataSourceWrongID, + ExpectError: regexp.MustCompile("an error occurred while fetching the InMemoryDB replica set with ID"), + }, + }, + }) +} + +func testAccCheckDBaaSInMemoryDBReplicaSetDestroyCheck(s *terraform.State) error { + client := testAccProvider.Meta().(services.SdkBundle).InMemoryDBClient + ctx, cancel := context.WithTimeout(context.Background(), *resourceDefaultTimeouts.Default) + defer cancel() + for _, rs := range s.RootModule().Resources { + if rs.Type != constant.DBaaSInMemoryDBReplicaSetResource { + continue + } + _, apiResponse, err := client.GetReplicaSet(ctx, rs.Primary.ID, rs.Primary.Attributes[clusterLocationAttribute]) + if err != nil { + if apiResponse == nil || apiResponse.StatusCode != 404 { + return fmt.Errorf("an error occured while checking the destruction of InMemoryDB replica set with ID: %v, error: %w", rs.Primary.ID, err) + } + } else { + return fmt.Errorf("InMemoryDB replica set with ID: %v still exists", rs.Primary.ID) + } + } + return nil +} + +func testAccCheckDBaaSInMemoryDBReplicaSetExists(n string, replicaSet *inMemoryDB.ReplicaSetRead) resource.TestCheckFunc { + return func(s *terraform.State) error { + client := testAccProvider.Meta().(services.SdkBundle).InMemoryDBClient + rs, ok := s.RootModule().Resources[n] + if !ok { + return fmt.Errorf("resource not found: %s", n) + } + if rs.Primary.ID == "" { + return fmt.Errorf("no ID is set") + } + ctx, cancel := context.WithTimeout(context.Background(), *resourceDefaultTimeouts.Default) + defer cancel() + + foundReplicaSet, _, err := client.GetReplicaSet(ctx, rs.Primary.ID, rs.Primary.Attributes[clusterLocationAttribute]) + if err != nil { + return fmt.Errorf("an error occurred while fetching InMemoryDB replica set with ID: %v, error: %w", rs.Primary.ID, err) + } + if *foundReplicaSet.Id != rs.Primary.ID { + return fmt.Errorf("resource not found") + } + replicaSet = &foundReplicaSet + return nil + } +} + +// This configuration contains the resources that need to be created before creating a InMemoryDB replica set +// This configuration will be used when the API will be fixed. +const inMemoryDBReplicaSetConfigSetup = ` +resource ` + constant.DatacenterResource + ` ` + datacenterResourceName + ` { + name = "in_memory_db_datacenter_example" + location = "` + replicaSetLocationValue + `" + description = "Datacenter for testing InMemoryDB replica set" +} + +resource ` + constant.LanResource + ` ` + lanResourceName + ` { + datacenter_id = ` + constant.DatacenterResource + `.` + datacenterResourceName + `.id + public = false + name = "inMemorydb_lan_example" +} + +resource ` + constant.ServerResource + ` ` + constant.ServerTestResource + ` { + name = "example" + datacenter_id = ` + constant.DatacenterResource + `.` + datacenterResourceName + `.id + cores = 2 + ram = 2048 + availability_zone = "ZONE_1" + cpu_family = "INTEL_SKYLAKE" + image_name = "rockylinux-8-GenericCloud-20230518" + image_password = ` + constant.RandomPassword + `.server_image_password.result + volume { + name = "example" + size = 20 + disk_type = "SSD Standard" + } + nic { + lan = ` + constant.LanResource + `.` + lanResourceName + `.id + name = "example" + dhcp = true + } +} + +locals { + prefix = format("%s/%s", ` + constant.ServerResource + `.` + constant.ServerTestResource + `.nic[0].ips[0], "24") + database_ip = cidrhost(local.prefix, 1) + database_ip_cidr = format("%s/%s", local.database_ip, "24") +} + +resource ` + constant.RandomPassword + ` "replicaset_password" { + length = 16 + special = true + override_special = "!#$%&*()-_=+[]{}<>:?" +} +` + ServerImagePassword + +// This configuration is used because there are some problems with the API and the creation/deletion +// of the setup resources (datacenter, lan, server) is not possible (there are some problems with +// LAN deletion). Because of that, for the moment, only to test the InMemoryDB functionality, we +// will use data sources for already existing setup resources. + +const temporaryConfigSetup = ` +data "ionoscloud_datacenter" "datacenterDS" { + id = "88eeae0d-515d-44c1-b142-d9293c20e676" +} + +data "ionoscloud_lan" "lanDS" { + id = "1" + datacenter_id = data.ionoscloud_datacenter.datacenterDS.id +} + +data "ionoscloud_server" "serverDS" { + id = "1f77a37e-2b38-49f2-b2e1-61a47ccf5f15" + datacenter_id = data.ionoscloud_datacenter.datacenterDS.id +} + +locals { + prefix = format("%s/%s", data.ionoscloud_server.serverDS.nics[0].ips[0], "24") + database_ip = cidrhost(local.prefix, 1) + database_ip_cidr = format("%s/%s", local.database_ip, "24") +} + +resource ` + constant.RandomPassword + ` "replicaset_password" { + length = 16 + special = true + override_special = "!#$%&*()-_=+[]{}<>:?" +} +` + +// TODO -- Replace temporaryConfigSetup with inMemoryDBReplicaSetConfigSetup when the API problem +// will be fixed. +const inMemoryDBReplicaSetConfigHashedPassword = temporaryConfigSetup + ` +resource ` + constant.DBaaSInMemoryDBReplicaSetResource + ` ` + constant.DBaaSReplicaSetTestResource + ` { + ` + clusterLocationAttribute + ` = "` + replicaSetLocationValue + `" + ` + replicaSetVersionAttribute + ` = "` + replicaSetVersionValue + `" + ` + clusterDisplayNameAttribute + ` = "` + replicaSetDisplayNameValue + `" + ` + replicaSetReplicasAttribute + ` = "` + replicaSetReplicasValue + `" + ` + replicaSetPersistenceModeAttribute + ` = "` + replicaSetPersistenceModeValue + `" + ` + replicaSetEvictionPolicyAttribute + ` = "` + replicaSetEvictionPolicyValue + `" + ` + resources + ` + ` + temporaryReplicaSetConnections + ` + ` + replicaSetMaintenanceWindow + ` + ` + credentialsHashedPassword + ` +} +` + +// TODO -- Replace temporaryConfigSetup with inMemoryDBReplicaSetConfigSetup when the API problem +// will be fixed. +const inMemoryDBReplicaSetConfigPlainTextPassword = temporaryConfigSetup + ` +resource ` + constant.DBaaSInMemoryDBReplicaSetResource + ` ` + constant.DBaaSReplicaSetTestResource + ` { + ` + clusterLocationAttribute + ` = "` + replicaSetLocationValue + `" + ` + replicaSetVersionAttribute + ` = "` + replicaSetVersionValue + `" + ` + clusterDisplayNameAttribute + ` = "` + replicaSetDisplayNameValue + `" + ` + replicaSetReplicasAttribute + ` = "` + replicaSetReplicasValue + `" + ` + replicaSetPersistenceModeAttribute + ` = "` + replicaSetPersistenceModeValue + `" + ` + replicaSetEvictionPolicyAttribute + ` = "` + replicaSetEvictionPolicyValue + `" + ` + resources + ` + ` + temporaryReplicaSetConnections + ` + ` + replicaSetMaintenanceWindow + ` + ` + credentialsPlainTextPassword + ` +} +` + +// TODO -- Replace temporaryConfigSetup with inMemoryDBReplicaSetConfigSetup when the API problem +// will be fixed. +const inMemoryDBReplicaSetConfigUpdate = temporaryConfigSetup + ` +resource ` + constant.DBaaSInMemoryDBReplicaSetResource + ` ` + constant.DBaaSReplicaSetTestResource + ` { + ` + clusterLocationAttribute + ` = "` + replicaSetLocationValue + `" + ` + replicaSetVersionAttribute + ` = "` + replicaSetVersionValue + `" + ` + clusterDisplayNameAttribute + ` = "` + replicaSetDisplayNameUpdateValue + `" + ` + replicaSetReplicasAttribute + ` = "` + replicaSetReplicasUpdateValue + `" + ` + replicaSetPersistenceModeAttribute + ` = "` + replicaSetPersistenceModeUpdateValue + `" + ` + replicaSetEvictionPolicyAttribute + ` = "` + replicaSetEvictionPolicyUpdateValue + `" + ` + resourcesUpdate + ` + ` + temporaryReplicaSetConnections + ` + ` + maintenanceWindowUpdate + ` + ` + credentialsPlainTextPassword + ` +} +` + +// Internal resources +const resources = replicaSetResourcesAttribute + `{ + ` + clusterCoresAttribute + ` = "` + replicaSetCoresValue + `" + ` + clusterRamAttribute + ` = "` + replicaSetRAMValue + `" +}` + +const resourcesUpdate = replicaSetResourcesAttribute + `{ + ` + clusterCoresAttribute + ` = "` + replicaSetCoresValueUpdate + `" + ` + clusterRamAttribute + ` = "` + replicaSetRAMValueUpdate + `" +}` + +// For testing data source match by ID +const inMemoryDBReplicaSetDataSourceMatchID = inMemoryDBReplicaSetConfigPlainTextPassword + ` +data ` + constant.DBaaSInMemoryDBReplicaSetResource + ` ` + constant.DBaaSReplicaSetTestDataSourceByID + ` { + id = ` + constant.DBaaSInMemoryDBReplicaSetResource + `.` + constant.DBaaSReplicaSetTestResource + `.id + ` + clusterLocationAttribute + ` = "` + replicaSetLocationValue + `" +}` + +// For testing data source match by name +const inMemoryDBReplicaSetDataSourceMatchName = inMemoryDBReplicaSetConfigPlainTextPassword + ` +data ` + constant.DBaaSInMemoryDBReplicaSetResource + ` ` + constant.DBaaSReplicaSetTestDataSourceByName + ` { + display_name = "` + replicaSetDisplayNameValue + `" + ` + clusterLocationAttribute + ` = "` + replicaSetLocationValue + `" +}` + +// For negative case of data source match by name +const inMemoryDBReplicaSetDataSourceWrongName = inMemoryDBReplicaSetConfigPlainTextPassword + ` +data ` + constant.DBaaSInMemoryDBReplicaSetResource + ` ` + constant.DBaaSReplicaSetTestDataSourceByName + ` { + display_name = "wrong_name" + ` + clusterLocationAttribute + ` = "` + replicaSetLocationValue + `" +}` + +// For negative case of data source match by ID - use a 0000 uuidv4 +const inMemoryDBReplicaSetDataSourceWrongID = inMemoryDBReplicaSetConfigPlainTextPassword + ` +data ` + constant.DBaaSInMemoryDBReplicaSetResource + ` ` + constant.DBaaSReplicaSetTestDataSourceByID + ` { + id = "00000000-0000-0000-0000-000000000000" + ` + clusterLocationAttribute + ` = "` + replicaSetLocationValue + `" +}` + +const replicaSetConnections = clusterConnectionsAttribute + `{ + ` + clusterConnectionsDatacenterIDAttribute + ` = ` + constant.DatacenterResource + `.` + datacenterResourceName + `.id + ` + clusterConnectionsLanIDAttribute + ` = ` + constant.LanResource + `.` + lanResourceName + `.id + ` + clusterConnectionsCidrAttribute + ` = ` + replicaSetConnectionsCidrValue + ` +}` + +// All the constants marked with 'temporary' will be used until the API problem is fixed. Search +// in this file using 'API' to find the description of the problem. +const temporaryReplicaSetConnections = clusterConnectionsAttribute + `{ + ` + clusterConnectionsDatacenterIDAttribute + ` = data.ionoscloud_datacenter.datacenterDS.id + ` + clusterConnectionsLanIDAttribute + ` = data.ionoscloud_lan.lanDS.id + ` + clusterConnectionsCidrAttribute + ` = ` + replicaSetConnectionsCidrValue + ` +}` + +const replicaSetMaintenanceWindow = clusterMaintenanceWindowAttribute + `{ + ` + clusterMaintenanceWindowDayOfTheWeekAttribute + ` = "` + clusterMaintenanceWindowDayOfTheWeekValue + `" + ` + clusterMaintenanceWindowTimeAttribute + ` = "` + clusterMaintenanceWindowTimeValue + `" +}` + +const maintenanceWindowUpdate = clusterMaintenanceWindowAttribute + `{ + ` + clusterMaintenanceWindowDayOfTheWeekAttribute + ` = "` + clusterMaintenanceWindowDayOfTheWeekUpdateValue + `" + ` + clusterMaintenanceWindowTimeAttribute + ` = "` + clusterMaintenanceWindowTimeUpdateValue + `" +}` +const credentialsPlainTextPassword = clusterCredentialsAttribute + `{ + ` + clusterCredentialsUsernameAttribute + ` = "` + clusterCredentialsUsernameValue + `" + ` + replicaSetPlainTextPasswordAttribute + ` = ` + constant.RandomPassword + `.replicaset_password.result +}` + +const credentialsHashedPassword = clusterCredentialsAttribute + `{ + ` + clusterCredentialsUsernameAttribute + ` = "` + clusterCredentialsUsernameValue + `" + ` + hashedPasswordObject + ` +}` + +const hashedPasswordObject = replicaSetHashedPasswordAttribute + `{ + ` + replicaSetHashAttribute + ` = "` + replicaSetHashValue + `" + ` + replicaSetAlgorithmAttribute + ` = "` + replicaSetAlgorithmValue + `" +} +` + +// Attributes +const ( + replicaSetLocationAttribute = "location" + replicaSetVersionAttribute = "version" + replicaSetDNSNameAttribute = "dns_name" + replicaSetReplicasAttribute = "replicas" + replicaSetPersistenceModeAttribute = "persistence_mode" + replicaSetEvictionPolicyAttribute = "eviction_policy" + replicaSetResourcesAttribute = "resources" + replicaSetPlainTextPasswordAttribute = "plain_text_password" + replicaSetHashedPasswordAttribute = "hashed_password" + replicaSetAlgorithmAttribute = "algorithm" + replicaSetHashAttribute = "hash" +) + +// Values +const ( + replicaSetLocationValue = "es/vit" + replicaSetLocationUpdateValue = "de/txl" + replicaSetVersionValue = "7.2" + replicaSetDisplayNameValue = "MyReplicaSet" + replicaSetDisplayNameUpdateValue = "UpdatedReplicaSet" + replicaSetReplicasValue = "4" + replicaSetReplicasUpdateValue = "5" + replicaSetPersistenceModeValue = "RDB" + replicaSetPersistenceModeUpdateValue = "AOF" + replicaSetEvictionPolicyValue = "noeviction" + replicaSetEvictionPolicyUpdateValue = "allkeys-lru" + replicaSetCoresValue = "1" + replicaSetCoresValueUpdate = "2" + replicaSetRAMValue = "6" + replicaSetRAMValueUpdate = "8" + replicaSetConnectionsCidrValue = "local.database_ip_cidr" + replicaSetHashValue = "492f3f38d6b5d3ca859514e250e25ba65935bcdd9f4f40c124b773fe536fee7d" + replicaSetAlgorithmValue = "SHA-256" +) diff --git a/ionoscloud/resource_dbaas_mariadb_cluster_test.go b/ionoscloud/resource_dbaas_mariadb_cluster_test.go index 0368f5f6c..7d6c6a461 100644 --- a/ionoscloud/resource_dbaas_mariadb_cluster_test.go +++ b/ionoscloud/resource_dbaas_mariadb_cluster_test.go @@ -227,8 +227,8 @@ data ` + constant.DBaaSMariaDBClusterResource + ` ` + constant.DBaaSClusterTestD id = ` + constant.DBaaSMariaDBClusterResource + `.` + constant.DBaaSClusterTestResource + `.id ` + clusterLocationAttribute + ` = "` + clusterLocationValue + `" } -` +` const mariaDBClusterDataSourceMatchName = mariaDBClusterConfigBasic + ` data ` + constant.DBaaSMariaDBClusterResource + ` ` + constant.DBaaSClusterTestDataSourceByName + ` { display_name = "` + clusterDisplayNameValue + `" diff --git a/ionoscloud/test_constants.go b/ionoscloud/test_constants.go index af3f36d70..5377ea44b 100644 --- a/ionoscloud/test_constants.go +++ b/ionoscloud/test_constants.go @@ -1860,7 +1860,9 @@ const clusterCredentialsPasswordAttribute = "password" // Values const clusterMaintenanceWindowDayOfTheWeekValue = "Sunday" +const clusterMaintenanceWindowDayOfTheWeekUpdateValue = "Monday" const clusterMaintenanceWindowTimeValue = "09:00:00" +const clusterMaintenanceWindowTimeUpdateValue = "10:00:00" const wireguardGatewayConfig = ` resource "ionoscloud_datacenter" "datacenter_example" { diff --git a/services/clients.go b/services/clients.go index c9e9d25cb..f84227ef3 100644 --- a/services/clients.go +++ b/services/clients.go @@ -10,6 +10,7 @@ import ( "github.com/ionos-cloud/terraform-provider-ionoscloud/v6/services/containerregistry" "github.com/ionos-cloud/terraform-provider-ionoscloud/v6/services/dataplatform" "github.com/ionos-cloud/terraform-provider-ionoscloud/v6/services/dbaas" + "github.com/ionos-cloud/terraform-provider-ionoscloud/v6/services/dbaas/inmemorydb" "github.com/ionos-cloud/terraform-provider-ionoscloud/v6/services/dbaas/mariadb" "github.com/ionos-cloud/terraform-provider-ionoscloud/v6/services/dns" "github.com/ionos-cloud/terraform-provider-ionoscloud/v6/services/kafka" @@ -20,6 +21,7 @@ import ( type SdkBundle struct { CloudApiClient *ionoscloud.APIClient + InMemoryDBClient *inmemorydb.InMemoryDBClient PsqlClient *dbaas.PsqlClient MongoClient *dbaas.MongoClient MariaDBClient *mariadb.MariaDBClient diff --git a/services/dbaas/inmemorydb/client.go b/services/dbaas/inmemorydb/client.go new file mode 100644 index 000000000..a81756877 --- /dev/null +++ b/services/dbaas/inmemorydb/client.go @@ -0,0 +1,39 @@ +package inmemorydb + +import ( + "fmt" + "net/http" + "os" + "runtime" + + "github.com/hashicorp/terraform-plugin-sdk/v2/meta" + inMemoryDB "github.com/ionos-cloud/sdk-go-dbaas-in-memory-db" + + "github.com/ionos-cloud/terraform-provider-ionoscloud/v6/utils" + "github.com/ionos-cloud/terraform-provider-ionoscloud/v6/utils/constant" +) + +//nolint:golint +type InMemoryDBClient struct { + sdkClient *inMemoryDB.APIClient +} + +//nolint:golint +func NewInMemoryDBClient(username, password, token, url, version, terraformVersion string) *InMemoryDBClient { + newConfigDbaas := inMemoryDB.NewConfiguration(username, password, token, url) + + if os.Getenv(constant.IonosDebug) != "" { + newConfigDbaas.Debug = true + } + newConfigDbaas.MaxRetries = constant.MaxRetries + newConfigDbaas.MaxWaitTime = constant.MaxWaitTime + + newConfigDbaas.HTTPClient = &http.Client{Transport: utils.CreateTransport()} + newConfigDbaas.UserAgent = fmt.Sprintf( + "terraform-provider/%s_ionos-cloud-sdk-go-dbaas-in-memory-db/%s_hashicorp-terraform/%s_terraform-plugin-sdk/%s_os/%s_arch/%s", + version, inMemoryDB.Version, terraformVersion, meta.SDKVersionString(), runtime.GOOS, runtime.GOARCH) //nolint:staticcheck + + return &InMemoryDBClient{ + sdkClient: inMemoryDB.NewAPIClient(newConfigDbaas), + } +} diff --git a/services/dbaas/inmemorydb/replica_set.go b/services/dbaas/inmemorydb/replica_set.go new file mode 100644 index 000000000..201eb702f --- /dev/null +++ b/services/dbaas/inmemorydb/replica_set.go @@ -0,0 +1,427 @@ +package inmemorydb + +import ( + "context" + "fmt" + "log" + "strings" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + inMemoryDB "github.com/ionos-cloud/sdk-go-dbaas-in-memory-db" + + "github.com/ionos-cloud/terraform-provider-ionoscloud/v6/utils" + "github.com/ionos-cloud/terraform-provider-ionoscloud/v6/utils/constant" +) + +var locationToURL = map[string]string{ + "de/fra": "https://in-memory-db.de-fra.ionos.com", + "de/txl": "https://in-memory-db.de-txl.ionos.com", + "es/vit": "https://in-memory-db.es-vit.ionos.com", + "gb/lhr": "https://in-memory-db.gb-lhr.ionos.com", + "us/ewr": "https://in-memory-db.us-ewr.ionos.com", + "us/las": "https://in-memory-db.us-las.ionos.com", + "us/mci": "https://in-memory-db.us-mci.ionos.com", + "fr/par": "https://in-memory-db.fr-par.ionos.com", +} + +// modifyConfigURL modifies the URL inside the client configuration. +// This function is required in order to make requests to different endpoints based on location. +func (c *InMemoryDBClient) modifyConfigURL(location string) { + clientConfig := c.sdkClient.GetConfig() + clientConfig.Servers = inMemoryDB.ServerConfigurations{ + { + URL: locationToURL[location], + }, + } +} + +// CreateReplicaSet sends a 'POST' request to the API to create a replica set. +func (c *InMemoryDBClient) CreateReplicaSet(ctx context.Context, replicaSet inMemoryDB.ReplicaSetCreate, location string) (inMemoryDB.ReplicaSetRead, *inMemoryDB.APIResponse, error) { + c.modifyConfigURL(location) + replicaSetResponse, apiResponse, err := c.sdkClient.ReplicaSetApi.ReplicasetsPost(ctx).ReplicaSetCreate(replicaSet).Execute() + apiResponse.LogInfo() + return replicaSetResponse, apiResponse, err +} + +//nolint:golint +func (c *InMemoryDBClient) IsReplicaSetReady(ctx context.Context, d *schema.ResourceData) (bool, error) { + replicaSetID := d.Id() + location := d.Get("location").(string) + replicaSet, _, err := c.GetReplicaSet(ctx, replicaSetID, location) + if err != nil { + return false, fmt.Errorf("status check failed for InMemoryDB replica set with ID: %v, error: %w", replicaSetID, err) + } + if replicaSet.Metadata == nil || replicaSet.Metadata.State == nil { + return false, fmt.Errorf("metadata or state is empty for InMemoryDB replica set with ID: %v", replicaSetID) + } + log.Printf("[INFO] state of the InMemoryDB replica set with ID: %v is: %v", replicaSetID, *replicaSet.Metadata.State) + return strings.EqualFold(*replicaSet.Metadata.State, constant.Available), nil +} + +//nolint:golint +func (c *InMemoryDBClient) DeleteReplicaSet(ctx context.Context, replicaSetID, location string) (*inMemoryDB.APIResponse, error) { + c.modifyConfigURL(location) + apiResponse, err := c.sdkClient.ReplicaSetApi.ReplicasetsDelete(ctx, replicaSetID).Execute() + apiResponse.LogInfo() + return apiResponse, err +} + +//nolint:golint +func (c *InMemoryDBClient) UpdateReplicaSet(ctx context.Context, replicaSetID, location string, replicaSet inMemoryDB.ReplicaSetEnsure) (inMemoryDB.ReplicaSetRead, *inMemoryDB.APIResponse, error) { + c.modifyConfigURL(location) + replicaSetResponse, apiResponse, err := c.sdkClient.ReplicaSetApi.ReplicasetsPut(ctx, replicaSetID).ReplicaSetEnsure(replicaSet).Execute() + apiResponse.LogInfo() + return replicaSetResponse, apiResponse, err +} + +//nolint:golint +func (c *InMemoryDBClient) IsReplicaSetDeleted(ctx context.Context, d *schema.ResourceData) (bool, error) { + replicaSetID := d.Id() + _, apiResponse, err := c.GetReplicaSet(ctx, replicaSetID, d.Get("location").(string)) + if err != nil { + if apiResponse.HttpNotFound() { + return true, nil + } + return false, fmt.Errorf("check failed for InMemoryDB replica set with ID: %v, error: %w", replicaSetID, err) + } + return false, nil +} + +//nolint:golint +func (c *InMemoryDBClient) GetReplicaSet(ctx context.Context, replicaSetID, location string) (inMemoryDB.ReplicaSetRead, *inMemoryDB.APIResponse, error) { + c.modifyConfigURL(location) + replicaSet, apiResponse, err := c.sdkClient.ReplicaSetApi.ReplicasetsFindById(ctx, replicaSetID).Execute() + apiResponse.LogInfo() + return replicaSet, apiResponse, err +} + +//nolint:golint +func (c *InMemoryDBClient) GetSnapshot(ctx context.Context, snapshotID, location string) (inMemoryDB.SnapshotRead, *inMemoryDB.APIResponse, error) { + c.modifyConfigURL(location) + snapshot, apiResponse, err := c.sdkClient.SnapshotApi.SnapshotsFindById(ctx, snapshotID).Execute() + apiResponse.LogInfo() + return snapshot, apiResponse, err +} + +//nolint:golint +func (c *InMemoryDBClient) ListReplicaSets(ctx context.Context, filterName, location string) (inMemoryDB.ReplicaSetReadList, *inMemoryDB.APIResponse, error) { + c.modifyConfigURL(location) + request := c.sdkClient.ReplicaSetApi.ReplicasetsGet(ctx) + if filterName != "" { + request = request.FilterName(filterName) + } + replicaSets, apiResponse, err := c.sdkClient.ReplicaSetApi.ReplicasetsGetExecute(request) + apiResponse.LogInfo() + return replicaSets, apiResponse, err +} + +// GetReplicaSetDataProperties reads all the properties from the configuration file and returns +// a structure that will be used to populate update/create requests. +func GetReplicaSetDataProperties(d *schema.ResourceData) *inMemoryDB.ReplicaSet { + replicaSet := inMemoryDB.ReplicaSet{} + + if displayName, ok := d.GetOk("display_name"); ok { + displayName := displayName.(string) + replicaSet.DisplayName = &displayName + } + + if inMemoryDBVersion, ok := d.GetOk("version"); ok { + inMemoryDBVersion := inMemoryDBVersion.(string) + replicaSet.Version = &inMemoryDBVersion + } + + if replicas, ok := d.GetOk("replicas"); ok { + replicas := int32(replicas.(int)) + replicaSet.Replicas = &replicas + } + + if persistenceMode, ok := d.GetOk("persistence_mode"); ok { + persistenceMode := inMemoryDB.PersistenceMode(persistenceMode.(string)) + replicaSet.PersistenceMode = &persistenceMode + } + + if evictionPolicy, ok := d.GetOk("eviction_policy"); ok { + evictionPolicy := inMemoryDB.EvictionPolicy(evictionPolicy.(string)) + replicaSet.EvictionPolicy = &evictionPolicy + } + + if initialSnapshotID, ok := d.GetOk("initial_snapshot_id"); ok { + initialSnapshotID := initialSnapshotID.(string) + replicaSet.InitialSnapshotId = &initialSnapshotID + } + + if _, ok := d.GetOk("resources"); ok { + replicaSet.Resources = getResources(d) + } + + if _, ok := d.GetOk("connections"); ok { + replicaSet.Connections = getConnections(d) + } + + if _, ok := d.GetOk("credentials"); ok { + replicaSet.Credentials = getCredentials(d) + } + + if _, ok := d.GetOk("maintenance_window"); ok { + replicaSet.MaintenanceWindow = getMaintenanceWindow(d) + } + + return &replicaSet +} + +// GetReplicaSetDataCreate reads the data from the tf configuration files and populates a +// create request. +func GetReplicaSetDataCreate(d *schema.ResourceData) inMemoryDB.ReplicaSetCreate { + return inMemoryDB.ReplicaSetCreate{ + Properties: GetReplicaSetDataProperties(d), + } +} + +// GetReplicaSetDataUpdate reads the data from the tf configuration files and populates an +// update request. +func GetReplicaSetDataUpdate(d *schema.ResourceData) inMemoryDB.ReplicaSetEnsure { + replicaStateID := d.Id() + return inMemoryDB.ReplicaSetEnsure{ + Id: &replicaStateID, + Properties: GetReplicaSetDataProperties(d), + } +} + +//nolint:all +func (c *InMemoryDBClient) SetReplicaSetData(d *schema.ResourceData, replicaSet inMemoryDB.ReplicaSetRead) error { + resourceName := "InMemoryDB replica set" + if replicaSet.Id != nil { + d.SetId(*replicaSet.Id) + } + + if replicaSet.Metadata == nil { + return fmt.Errorf("response metadata should not be empty for InMemoryDB replica set with ID: %v", *replicaSet.Id) + } + + if replicaSet.Properties == nil { + return fmt.Errorf("response properties should not be empty for InMemoryDB replica set with ID: %v", *replicaSet.Id) + } + + if replicaSet.Properties.DisplayName != nil { + if err := d.Set("display_name", *replicaSet.Properties.DisplayName); err != nil { + return utils.GenerateSetError(resourceName, "display_name", err) + } + } + + if replicaSet.Properties.Version != nil { + if err := d.Set("version", *replicaSet.Properties.Version); err != nil { + return utils.GenerateSetError(resourceName, "version", err) + } + } + + if replicaSet.Properties.Replicas != nil { + if err := d.Set("replicas", *replicaSet.Properties.Replicas); err != nil { + return utils.GenerateSetError(resourceName, "replicas", err) + } + } + + if replicaSet.Properties.PersistenceMode != nil { + if err := d.Set("persistence_mode", *replicaSet.Properties.PersistenceMode); err != nil { + return utils.GenerateSetError(resourceName, "persistence_mode", err) + } + } + + if replicaSet.Properties.EvictionPolicy != nil { + if err := d.Set("eviction_policy", *replicaSet.Properties.EvictionPolicy); err != nil { + return utils.GenerateSetError(resourceName, "eviction_policy", err) + } + } + + if replicaSet.Properties.InitialSnapshotId != nil { + if err := d.Set("initial_snapshot_id", *replicaSet.Properties.InitialSnapshotId); err != nil { + return utils.GenerateSetError(resourceName, "initial_snapshot_id", err) + } + } + + if replicaSet.Metadata.DnsName != nil { + if err := d.Set("dns_name", *replicaSet.Metadata.DnsName); err != nil { + return utils.GenerateSetError(resourceName, "dns_name", err) + } + } + + if replicaSet.Properties.Resources != nil { + var resources []interface{} + resourceEntry := setResourceProperties(*replicaSet.Properties.Resources) + resources = append(resources, resourceEntry) + if err := d.Set("resources", resources); err != nil { + return utils.GenerateSetError(resourceName, "resources", err) + } + } + + if replicaSet.Properties.Connections != nil { + var connections []interface{} + for _, connection := range *replicaSet.Properties.Connections { + connectionEntry := setConnectionProperties(connection) + connections = append(connections, connectionEntry) + } + if err := d.Set("connections", connections); err != nil { + return utils.GenerateSetError(resourceName, "connections", err) + } + } + + if replicaSet.Properties.MaintenanceWindow != nil { + var maintenanceWindow []interface{} + maintenanceWindowEntry := setMaintenanceWindowProperties(*replicaSet.Properties.MaintenanceWindow) + maintenanceWindow = append(maintenanceWindow, maintenanceWindowEntry) + if err := d.Set("maintenance_window", maintenanceWindow); err != nil { + return utils.GenerateSetError(resourceName, "maintenance_window", err) + } + } + + if replicaSet.Metadata != nil && replicaSet.Metadata.DnsName != nil { + if err := d.Set("dns_name", *replicaSet.Metadata.DnsName); err != nil { + return utils.GenerateSetError(resourceName, "dns_name", err) + } + } + + return nil +} + +//nolint:golint +func (c *InMemoryDBClient) SetSnapshotData(d *schema.ResourceData, snapshot inMemoryDB.SnapshotRead) error { + if snapshot.Id == nil { + return fmt.Errorf("expected a valid ID for InMemoryDB snapshot, but got 'nil' instead") + } + d.SetId(*snapshot.Id) + if snapshot.Metadata == nil { + return fmt.Errorf("response metadata should not be empty for InMemoryDB snapshot with ID: %v", *snapshot.Id) + } + var metadata []interface{} + metadataEntry := make(map[string]interface{}) + if snapshot.Metadata.CreatedDate != nil { + metadataEntry["created_date"] = (snapshot.Metadata.CreatedDate).Time.Format(constant.DatetimeZLayout) + } + if snapshot.Metadata.LastModifiedDate != nil { + metadataEntry["last_modified_date"] = (snapshot.Metadata.LastModifiedDate).Time.Format(constant.DatetimeZLayout) + } + if snapshot.Metadata.ReplicasetId != nil { + metadataEntry["replica_set_id"] = *snapshot.Metadata.ReplicasetId + } + if snapshot.Metadata.SnapshotTime != nil { + metadataEntry["snapshot_time"] = (snapshot.Metadata.SnapshotTime).Time.Format(constant.DatetimeZLayout) + } + if snapshot.Metadata.DatacenterId != nil { + metadataEntry["datacenter_id"] = *snapshot.Metadata.DatacenterId + } + metadata = append(metadata, metadataEntry) + if err := d.Set("metadata", metadata); err != nil { + return utils.GenerateSetError(constant.DBaaSInMemoryDBSnapshotResource, "metadata", err) + } + return nil +} + +// getResources returns information about the 'resources' attribute defined in the tf configuration +// for the ReplicaSet resource, this information will be latter used to populate the request. +func getResources(d *schema.ResourceData) *inMemoryDB.Resources { + var resources inMemoryDB.Resources + if cores, ok := d.GetOk("resources.0.cores"); ok { + cores := int32(cores.(int)) + resources.Cores = &cores + } + if ram, ok := d.GetOk("resources.0.ram"); ok { + ram := int32(ram.(int)) + resources.Ram = &ram + } + return &resources +} + +// getConnections returns information about the 'connections' attribute defined in the tf configuration. +func getConnections(d *schema.ResourceData) *[]inMemoryDB.Connection { + var connections []inMemoryDB.Connection + var connection inMemoryDB.Connection + if datacenterID, ok := d.GetOk("connections.0.datacenter_id"); ok { + datacenterID := datacenterID.(string) + connection.DatacenterId = &datacenterID + } + if lanID, ok := d.GetOk("connections.0.lan_id"); ok { + lanID := lanID.(string) + connection.LanId = &lanID + } + if cidr, ok := d.GetOk("connections.0.cidr"); ok { + cidr := cidr.(string) + connection.Cidr = &cidr + } + connections = append(connections, connection) + return &connections +} + +// getCredentials returns information about the 'credentials' attribute defined in the tf configuration. +func getCredentials(d *schema.ResourceData) *inMemoryDB.User { + var user inMemoryDB.User + var password inMemoryDB.UserPassword + if username, ok := d.GetOk("credentials.0.username"); ok { + username := username.(string) + user.Username = &username + } + if plainTextPassword, ok := d.GetOk("credentials.0.plain_text_password"); ok { + plainTextPassword := plainTextPassword.(string) + password.PlainTextPassword = &plainTextPassword + } + if _, ok := d.GetOk("credentials.0.hashed_password"); ok { + password.HashedPassword = getHashPasswordInfo(d) + } + user.Password = &password + return &user +} + +// getHashPasswordInfo returns information about the 'hashed_password' attribute defined in the tf configuration. +func getHashPasswordInfo(d *schema.ResourceData) *inMemoryDB.HashedPassword { + var hashedPassword inMemoryDB.HashedPassword + if algorithm, ok := d.GetOk("credentials.0.hashed_password.0.algorithm"); ok { + algorithm := algorithm.(string) + hashedPassword.Algorithm = &algorithm + } + if hash, ok := d.GetOk("credentials.0.hashed_password.0.hash"); ok { + hash := hash.(string) + hashedPassword.Hash = &hash + } + return &hashedPassword +} + +// getMaintenanceWindow returns information about the 'maintenance_window' attribute defined in the tf configuration. +func getMaintenanceWindow(d *schema.ResourceData) *inMemoryDB.MaintenanceWindow { + var maintenanceWindow inMemoryDB.MaintenanceWindow + if dayOfTheWeek, ok := d.GetOk("maintenance_window.0.day_of_the_week"); ok { + dayOfTheWeek := inMemoryDB.DayOfTheWeek(dayOfTheWeek.(string)) + maintenanceWindow.DayOfTheWeek = &dayOfTheWeek + } + if time, ok := d.GetOk("maintenance_window.0.time"); ok { + time := time.(string) + maintenanceWindow.Time = &time + } + return &maintenanceWindow +} + +func setConnectionProperties(connection inMemoryDB.Connection) map[string]interface{} { + connectionMap := make(map[string]interface{}) + + utils.SetPropWithNilCheck(connectionMap, "datacenter_id", connection.DatacenterId) + utils.SetPropWithNilCheck(connectionMap, "lan_id", connection.LanId) + utils.SetPropWithNilCheck(connectionMap, "cidr", connection.Cidr) + + return connectionMap +} + +func setResourceProperties(resource inMemoryDB.Resources) map[string]interface{} { + resourceMap := make(map[string]interface{}) + + utils.SetPropWithNilCheck(resourceMap, "cores", resource.Cores) + utils.SetPropWithNilCheck(resourceMap, "ram", resource.Ram) + utils.SetPropWithNilCheck(resourceMap, "storage", resource.Storage) + + return resourceMap +} + +func setMaintenanceWindowProperties(maintenanceWindow inMemoryDB.MaintenanceWindow) map[string]interface{} { + maintenanceWindowMap := make(map[string]interface{}) + + utils.SetPropWithNilCheck(maintenanceWindowMap, "day_of_the_week", maintenanceWindow.DayOfTheWeek) + utils.SetPropWithNilCheck(maintenanceWindowMap, "time", maintenanceWindow.Time) + + return maintenanceWindowMap +} diff --git a/utils/constant/constants.go b/utils/constant/constants.go index baec1c52e..7cbfd8736 100644 --- a/utils/constant/constants.go +++ b/utils/constant/constants.go @@ -245,6 +245,7 @@ const ( DBaaSClusterTestDataSourceById = "test_dbaas_cluster_id" DBaaSClusterTestResource = "test_dbaas_cluster" DBaaSClusterTestDataSourceByName = "test_dbaas_cluster_name" + DBaaSReplicaSetTestResource = "test_dbaas_replicaset" // PgSql constants PsqlClusterResource = "ionoscloud_pg_cluster" @@ -268,6 +269,12 @@ const ( DBaasMongoUserResource = "ionoscloud_mongo_user" DBaaSMongoTemplateResource = "ionoscloud_mongo_template" DBaaSMongoTemplateTestDataSource = "test_dbaas_mongo_template" + + // InMemoryDB constants + DBaaSReplicaSetTestDataSourceByID = "test_dbaas_replicaset_id" + DBaaSReplicaSetTestDataSourceByName = "test_dbaas_replicaset_name" + DBaaSInMemoryDBReplicaSetResource = "ionoscloud_inmemorydb_replicaset" + DBaaSInMemoryDBSnapshotResource = "ionoscloud_inmemorydb_snapshot" ) // Locations slice represents the locations in which services are available. diff --git a/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/.gitignore b/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/.gitignore new file mode 100644 index 000000000..daf913b1b --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/.gitignore @@ -0,0 +1,24 @@ +# Compiled Object files, Static and Dynamic libs (Shared Objects) +*.o +*.a +*.so + +# Folders +_obj +_test + +# Architecture specific extensions/prefixes +*.[568vq] +[568vq].out + +*.cgo1.go +*.cgo2.c +_cgo_defun.c +_cgo_gotypes.go +_cgo_export.* + +_testmain.go + +*.exe +*.test +*.prof diff --git a/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/.travis.yml b/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/.travis.yml new file mode 100644 index 000000000..f5cb2ce9a --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/.travis.yml @@ -0,0 +1,8 @@ +language: go + +install: + - go get -d -v . + +script: + - go build -v ./ + diff --git a/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/LICENSE b/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/LICENSE new file mode 100644 index 000000000..261eeb9e9 --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/README.md b/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/README.md new file mode 100644 index 000000000..49e6d5c1b --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/README.md @@ -0,0 +1,152 @@ +# Go API client for ionoscloud + +API description for the IONOS In-Memory DB + +## Overview +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: 1.0.0 +- Package version: 1.0.0 +- Build package: org.openapitools.codegen.languages.GoClientCodegen +For more information, please visit [https://docs.ionos.com/support/general-information/contact-information](https://docs.ionos.com/support/general-information/contact-information) + +## Installation + +Install the following dependencies: + +```shell +go get github.com/stretchr/testify/assert +go get golang.org/x/net/context +``` + +Put the package under your project folder and add the following in import: + +```golang +import ionoscloud "github.com/ionos-cloud/sdk-go-dbaas-in-memory-db" +``` + +To use a proxy, set the environment variable `HTTP_PROXY`: + +```golang +os.Setenv("HTTP_PROXY", "http://proxy_name:proxy_port") +``` + +## Configuration of Server URL + +Default configuration comes with `Servers` field that contains server objects as defined in the OpenAPI specification. + +### Select Server Configuration + +For using other server than the one defined on index 0 set context value `sw.ContextServerIndex` of type `int`. + +```golang +ctx := context.WithValue(context.Background(), ionoscloud.ContextServerIndex, 1) +``` + +### Templated Server URL + +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. + +## Documentation for API Endpoints + +All URIs are relative to *https://in-memory-db.de-fra.ionos.com* + +Class | Method | HTTP request | Description +------------ | ------------- | ------------- | ------------- +*ReplicaSetApi* | [**ReplicasetsDelete**](docs/api/ReplicaSetApi.md#replicasetsdelete) | **Delete** /replicasets/{replicasetId} | Delete ReplicaSet +*ReplicaSetApi* | [**ReplicasetsFindById**](docs/api/ReplicaSetApi.md#replicasetsfindbyid) | **Get** /replicasets/{replicasetId} | Retrieve ReplicaSet +*ReplicaSetApi* | [**ReplicasetsGet**](docs/api/ReplicaSetApi.md#replicasetsget) | **Get** /replicasets | Retrieve all ReplicaSet +*ReplicaSetApi* | [**ReplicasetsPost**](docs/api/ReplicaSetApi.md#replicasetspost) | **Post** /replicasets | Create ReplicaSet +*ReplicaSetApi* | [**ReplicasetsPut**](docs/api/ReplicaSetApi.md#replicasetsput) | **Put** /replicasets/{replicasetId} | Ensure ReplicaSet +*RestoreApi* | [**SnapshotsRestoresFindById**](docs/api/RestoreApi.md#snapshotsrestoresfindbyid) | **Get** /snapshots/{snapshotId}/restores/{restoreId} | Retrieve Restore +*RestoreApi* | [**SnapshotsRestoresGet**](docs/api/RestoreApi.md#snapshotsrestoresget) | **Get** /snapshots/{snapshotId}/restores | Retrieve all Restore +*RestoreApi* | [**SnapshotsRestoresPost**](docs/api/RestoreApi.md#snapshotsrestorespost) | **Post** /snapshots/{snapshotId}/restores | Create Restore +*SnapshotApi* | [**SnapshotsFindById**](docs/api/SnapshotApi.md#snapshotsfindbyid) | **Get** /snapshots/{snapshotId} | Retrieve Snapshot +*SnapshotApi* | [**SnapshotsGet**](docs/api/SnapshotApi.md#snapshotsget) | **Get** /snapshots | Retrieve all Snapshot + + +## Documentation For Models + + - [Connection](docs/models/Connection.md) + - [DayOfTheWeek](docs/models/DayOfTheWeek.md) + - [Error](docs/models/Error.md) + - [ErrorMessages](docs/models/ErrorMessages.md) + - [EvictionPolicy](docs/models/EvictionPolicy.md) + - [HashedPassword](docs/models/HashedPassword.md) + - [Links](docs/models/Links.md) + - [MaintenanceWindow](docs/models/MaintenanceWindow.md) + - [Metadata](docs/models/Metadata.md) + - [Pagination](docs/models/Pagination.md) + - [PersistenceMode](docs/models/PersistenceMode.md) + - [ReplicaSet](docs/models/ReplicaSet.md) + - [ReplicaSetCreate](docs/models/ReplicaSetCreate.md) + - [ReplicaSetEnsure](docs/models/ReplicaSetEnsure.md) + - [ReplicaSetMetadata](docs/models/ReplicaSetMetadata.md) + - [ReplicaSetMetadataAllOf](docs/models/ReplicaSetMetadataAllOf.md) + - [ReplicaSetRead](docs/models/ReplicaSetRead.md) + - [ReplicaSetReadList](docs/models/ReplicaSetReadList.md) + - [ReplicaSetReadListAllOf](docs/models/ReplicaSetReadListAllOf.md) + - [ResourceState](docs/models/ResourceState.md) + - [Resources](docs/models/Resources.md) + - [Restore](docs/models/Restore.md) + - [RestoreCreate](docs/models/RestoreCreate.md) + - [RestoreMetadata](docs/models/RestoreMetadata.md) + - [RestoreMetadataAllOf](docs/models/RestoreMetadataAllOf.md) + - [RestoreRead](docs/models/RestoreRead.md) + - [RestoreReadList](docs/models/RestoreReadList.md) + - [RestoreReadListAllOf](docs/models/RestoreReadListAllOf.md) + - [SnapshotCreate](docs/models/SnapshotCreate.md) + - [SnapshotEnsure](docs/models/SnapshotEnsure.md) + - [SnapshotMetadata](docs/models/SnapshotMetadata.md) + - [SnapshotMetadataAllOf](docs/models/SnapshotMetadataAllOf.md) + - [SnapshotRead](docs/models/SnapshotRead.md) + - [SnapshotReadList](docs/models/SnapshotReadList.md) + - [SnapshotReadListAllOf](docs/models/SnapshotReadListAllOf.md) + - [User](docs/models/User.md) + - [UserPassword](docs/models/UserPassword.md) + + +## Documentation For Authorization + + +Authentication schemes defined for the API: +### tokenAuth + +- **Type**: HTTP Bearer token authentication + +Example + +```golang +auth := context.WithValue(context.Background(), sw.ContextAccessToken, "BEARER_TOKEN_STRING") +r, err := client.Service.Operation(auth, args) +``` + + +## Documentation for Utility Methods + +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: + +* `PtrBool` +* `PtrInt` +* `PtrInt32` +* `PtrInt64` +* `PtrFloat` +* `PtrFloat32` +* `PtrFloat64` +* `PtrString` +* `PtrTime` + +## Author + +support@cloud.ionos.com + diff --git a/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/api_replica_set.go b/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/api_replica_set.go new file mode 100644 index 000000000..84d230d96 --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/api_replica_set.go @@ -0,0 +1,1026 @@ +/* + * In-Memory DB API + * + * API description for the IONOS In-Memory DB + * + * API version: 1.0.0 + * Contact: support@cloud.ionos.com + */ + +// 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 +) + +// ReplicaSetApiService ReplicaSetApi service +type ReplicaSetApiService service + +type ApiReplicasetsDeleteRequest struct { + ctx _context.Context + ApiService *ReplicaSetApiService + replicasetId string +} + +func (r ApiReplicasetsDeleteRequest) Execute() (*APIResponse, error) { + return r.ApiService.ReplicasetsDeleteExecute(r) +} + +/* + * ReplicasetsDelete Delete ReplicaSet + * Deletes the specified ReplicaSet. + * @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param replicasetId The ID (UUID) of the ReplicaSet. + * @return ApiReplicasetsDeleteRequest + */ +func (a *ReplicaSetApiService) ReplicasetsDelete(ctx _context.Context, replicasetId string) ApiReplicasetsDeleteRequest { + return ApiReplicasetsDeleteRequest{ + ApiService: a, + ctx: ctx, + replicasetId: replicasetId, + } +} + +/* + * Execute executes the request + */ +func (a *ReplicaSetApiService) ReplicasetsDeleteExecute(r ApiReplicasetsDeleteRequest) (*APIResponse, error) { + var ( + localVarHTTPMethod = _nethttp.MethodDelete + localVarPostBody interface{} + localVarFormFileName string + localVarFileName string + localVarFileBytes []byte + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "ReplicaSetApiService.ReplicasetsDelete") + if err != nil { + return nil, GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/replicasets/{replicasetId}" + localVarPath = strings.Replace(localVarPath, "{"+"replicasetId"+"}", _neturl.PathEscape(parameterToString(r.replicasetId, "")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + + // to determine the Content-Type header + localVarHTTPContentTypes := []string{} + + // 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 + } + 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: "ReplicasetsDelete", + } + + 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 Error + 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 Error + 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 Error + 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 Error + 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 Error + 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 Error + 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 Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarAPIResponse, newErr + } + newErr.model = v + } + var v Error + 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 +} + +type ApiReplicasetsFindByIdRequest struct { + ctx _context.Context + ApiService *ReplicaSetApiService + replicasetId string +} + +func (r ApiReplicasetsFindByIdRequest) Execute() (ReplicaSetRead, *APIResponse, error) { + return r.ApiService.ReplicasetsFindByIdExecute(r) +} + +/* + * ReplicasetsFindById Retrieve ReplicaSet + * Returns the ReplicaSet by ID. + * @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param replicasetId The ID (UUID) of the ReplicaSet. + * @return ApiReplicasetsFindByIdRequest + */ +func (a *ReplicaSetApiService) ReplicasetsFindById(ctx _context.Context, replicasetId string) ApiReplicasetsFindByIdRequest { + return ApiReplicasetsFindByIdRequest{ + ApiService: a, + ctx: ctx, + replicasetId: replicasetId, + } +} + +/* + * Execute executes the request + * @return ReplicaSetRead + */ +func (a *ReplicaSetApiService) ReplicasetsFindByIdExecute(r ApiReplicasetsFindByIdRequest) (ReplicaSetRead, *APIResponse, error) { + var ( + localVarHTTPMethod = _nethttp.MethodGet + localVarPostBody interface{} + localVarFormFileName string + localVarFileName string + localVarFileBytes []byte + localVarReturnValue ReplicaSetRead + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "ReplicaSetApiService.ReplicasetsFindById") + if err != nil { + return localVarReturnValue, nil, GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/replicasets/{replicasetId}" + localVarPath = strings.Replace(localVarPath, "{"+"replicasetId"+"}", _neturl.PathEscape(parameterToString(r.replicasetId, "")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + + // to determine the Content-Type header + localVarHTTPContentTypes := []string{} + + // 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 + } + 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: "ReplicasetsFindById", + } + + 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 Error + 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 Error + 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 Error + 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 Error + 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 Error + 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 Error + 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 Error + 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 + } + var v Error + 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 ApiReplicasetsGetRequest struct { + ctx _context.Context + ApiService *ReplicaSetApiService + offset *int32 + limit *int32 + filterName *string +} + +func (r ApiReplicasetsGetRequest) Offset(offset int32) ApiReplicasetsGetRequest { + r.offset = &offset + return r +} +func (r ApiReplicasetsGetRequest) Limit(limit int32) ApiReplicasetsGetRequest { + r.limit = &limit + return r +} +func (r ApiReplicasetsGetRequest) FilterName(filterName string) ApiReplicasetsGetRequest { + r.filterName = &filterName + return r +} + +func (r ApiReplicasetsGetRequest) Execute() (ReplicaSetReadList, *APIResponse, error) { + return r.ApiService.ReplicasetsGetExecute(r) +} + +/* + - ReplicasetsGet Retrieve all ReplicaSet + - This endpoint enables retrieving all ReplicaSet using + +pagination and optional filters. + + - @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + - @return ApiReplicasetsGetRequest +*/ +func (a *ReplicaSetApiService) ReplicasetsGet(ctx _context.Context) ApiReplicasetsGetRequest { + return ApiReplicasetsGetRequest{ + ApiService: a, + ctx: ctx, + } +} + +/* + * Execute executes the request + * @return ReplicaSetReadList + */ +func (a *ReplicaSetApiService) ReplicasetsGetExecute(r ApiReplicasetsGetRequest) (ReplicaSetReadList, *APIResponse, error) { + var ( + localVarHTTPMethod = _nethttp.MethodGet + localVarPostBody interface{} + localVarFormFileName string + localVarFileName string + localVarFileBytes []byte + localVarReturnValue ReplicaSetReadList + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "ReplicaSetApiService.ReplicasetsGet") + if err != nil { + return localVarReturnValue, nil, GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/replicasets" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + + if r.offset != nil { + localVarQueryParams.Add("offset", parameterToString(*r.offset, "")) + } + if r.limit != nil { + localVarQueryParams.Add("limit", parameterToString(*r.limit, "")) + } + if r.filterName != nil { + localVarQueryParams.Add("filter.name", parameterToString(*r.filterName, "")) + } + // to determine the Content-Type header + localVarHTTPContentTypes := []string{} + + // 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 + } + 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: "ReplicasetsGet", + } + + 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 Error + 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 Error + 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 Error + 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 Error + 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 Error + 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 Error + 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 + } + var v Error + 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 ApiReplicasetsPostRequest struct { + ctx _context.Context + ApiService *ReplicaSetApiService + replicaSetCreate *ReplicaSetCreate +} + +func (r ApiReplicasetsPostRequest) ReplicaSetCreate(replicaSetCreate ReplicaSetCreate) ApiReplicasetsPostRequest { + r.replicaSetCreate = &replicaSetCreate + return r +} + +func (r ApiReplicasetsPostRequest) Execute() (ReplicaSetRead, *APIResponse, error) { + return r.ApiService.ReplicasetsPostExecute(r) +} + +/* + - ReplicasetsPost Create ReplicaSet + - Creates a new ReplicaSet. + +The full ReplicaSet needs to be provided to create the object. +Optional data will be filled with defaults or left empty. + + - @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + - @return ApiReplicasetsPostRequest +*/ +func (a *ReplicaSetApiService) ReplicasetsPost(ctx _context.Context) ApiReplicasetsPostRequest { + return ApiReplicasetsPostRequest{ + ApiService: a, + ctx: ctx, + } +} + +/* + * Execute executes the request + * @return ReplicaSetRead + */ +func (a *ReplicaSetApiService) ReplicasetsPostExecute(r ApiReplicasetsPostRequest) (ReplicaSetRead, *APIResponse, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPost + localVarPostBody interface{} + localVarFormFileName string + localVarFileName string + localVarFileBytes []byte + localVarReturnValue ReplicaSetRead + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "ReplicaSetApiService.ReplicasetsPost") + if err != nil { + return localVarReturnValue, nil, GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/replicasets" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + if r.replicaSetCreate == nil { + return localVarReturnValue, nil, reportError("replicaSetCreate 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.replicaSetCreate + 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: "ReplicasetsPost", + } + + 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 Error + 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 Error + 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 Error + 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 Error + 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 Error + 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 Error + 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 Error + 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 Error + 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 + } + var v Error + 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 ApiReplicasetsPutRequest struct { + ctx _context.Context + ApiService *ReplicaSetApiService + replicasetId string + replicaSetEnsure *ReplicaSetEnsure +} + +func (r ApiReplicasetsPutRequest) ReplicaSetEnsure(replicaSetEnsure ReplicaSetEnsure) ApiReplicasetsPutRequest { + r.replicaSetEnsure = &replicaSetEnsure + return r +} + +func (r ApiReplicasetsPutRequest) Execute() (ReplicaSetRead, *APIResponse, error) { + return r.ApiService.ReplicasetsPutExecute(r) +} + +/* + - ReplicasetsPut Ensure ReplicaSet + - Ensures that the ReplicaSet with the provided ID is created or modified. + +The full ReplicaSet needs to be provided to ensure +(either update or create) the ReplicaSet. Non present data will +only be filled with defaults or left empty, but not take +previous values into consideration. + + - @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + - @param replicasetId The ID (UUID) of the ReplicaSet. + - @return ApiReplicasetsPutRequest +*/ +func (a *ReplicaSetApiService) ReplicasetsPut(ctx _context.Context, replicasetId string) ApiReplicasetsPutRequest { + return ApiReplicasetsPutRequest{ + ApiService: a, + ctx: ctx, + replicasetId: replicasetId, + } +} + +/* + * Execute executes the request + * @return ReplicaSetRead + */ +func (a *ReplicaSetApiService) ReplicasetsPutExecute(r ApiReplicasetsPutRequest) (ReplicaSetRead, *APIResponse, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPut + localVarPostBody interface{} + localVarFormFileName string + localVarFileName string + localVarFileBytes []byte + localVarReturnValue ReplicaSetRead + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "ReplicaSetApiService.ReplicasetsPut") + if err != nil { + return localVarReturnValue, nil, GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/replicasets/{replicasetId}" + localVarPath = strings.Replace(localVarPath, "{"+"replicasetId"+"}", _neturl.PathEscape(parameterToString(r.replicasetId, "")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + if r.replicaSetEnsure == nil { + return localVarReturnValue, nil, reportError("replicaSetEnsure 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.replicaSetEnsure + 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: "ReplicasetsPut", + } + + 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 Error + 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 Error + 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 Error + 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 Error + 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 == 409 { + var v Error + 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 Error + 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 Error + 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 Error + 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 Error + 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 Error + 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 + } + var v Error + 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 +} diff --git a/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/api_restore.go b/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/api_restore.go new file mode 100644 index 000000000..42ab594b0 --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/api_restore.go @@ -0,0 +1,634 @@ +/* + * In-Memory DB API + * + * API description for the IONOS In-Memory DB + * + * API version: 1.0.0 + * Contact: support@cloud.ionos.com + */ + +// 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 ApiSnapshotsRestoresFindByIdRequest struct { + ctx _context.Context + ApiService *RestoreApiService + snapshotId string + restoreId string +} + +func (r ApiSnapshotsRestoresFindByIdRequest) Execute() (RestoreRead, *APIResponse, error) { + return r.ApiService.SnapshotsRestoresFindByIdExecute(r) +} + +/* + * SnapshotsRestoresFindById Retrieve Restore + * Returns the Restore by ID. + * @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param snapshotId The ID (UUID) of the Snapshot. + * @param restoreId The ID (UUID) of the Restore. + * @return ApiSnapshotsRestoresFindByIdRequest + */ +func (a *RestoreApiService) SnapshotsRestoresFindById(ctx _context.Context, snapshotId string, restoreId string) ApiSnapshotsRestoresFindByIdRequest { + return ApiSnapshotsRestoresFindByIdRequest{ + ApiService: a, + ctx: ctx, + snapshotId: snapshotId, + restoreId: restoreId, + } +} + +/* + * Execute executes the request + * @return RestoreRead + */ +func (a *RestoreApiService) SnapshotsRestoresFindByIdExecute(r ApiSnapshotsRestoresFindByIdRequest) (RestoreRead, *APIResponse, error) { + var ( + localVarHTTPMethod = _nethttp.MethodGet + localVarPostBody interface{} + localVarFormFileName string + localVarFileName string + localVarFileBytes []byte + localVarReturnValue RestoreRead + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "RestoreApiService.SnapshotsRestoresFindById") + if err != nil { + return localVarReturnValue, nil, GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/snapshots/{snapshotId}/restores/{restoreId}" + localVarPath = strings.Replace(localVarPath, "{"+"snapshotId"+"}", _neturl.PathEscape(parameterToString(r.snapshotId, "")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"restoreId"+"}", _neturl.PathEscape(parameterToString(r.restoreId, "")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + + // to determine the Content-Type header + localVarHTTPContentTypes := []string{} + + // 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 + } + 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: "SnapshotsRestoresFindById", + } + + 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 Error + 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 Error + 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 Error + 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 Error + 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 Error + 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 Error + 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 Error + 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 + } + var v Error + 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 ApiSnapshotsRestoresGetRequest struct { + ctx _context.Context + ApiService *RestoreApiService + snapshotId string + offset *int32 + limit *int32 + filterName *string +} + +func (r ApiSnapshotsRestoresGetRequest) Offset(offset int32) ApiSnapshotsRestoresGetRequest { + r.offset = &offset + return r +} +func (r ApiSnapshotsRestoresGetRequest) Limit(limit int32) ApiSnapshotsRestoresGetRequest { + r.limit = &limit + return r +} +func (r ApiSnapshotsRestoresGetRequest) FilterName(filterName string) ApiSnapshotsRestoresGetRequest { + r.filterName = &filterName + return r +} + +func (r ApiSnapshotsRestoresGetRequest) Execute() (RestoreReadList, *APIResponse, error) { + return r.ApiService.SnapshotsRestoresGetExecute(r) +} + +/* + - SnapshotsRestoresGet Retrieve all Restore + - This endpoint enables retrieving all Restore using + +pagination and optional filters. + + - @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + - @param snapshotId The ID (UUID) of the Snapshot. + - @return ApiSnapshotsRestoresGetRequest +*/ +func (a *RestoreApiService) SnapshotsRestoresGet(ctx _context.Context, snapshotId string) ApiSnapshotsRestoresGetRequest { + return ApiSnapshotsRestoresGetRequest{ + ApiService: a, + ctx: ctx, + snapshotId: snapshotId, + } +} + +/* + * Execute executes the request + * @return RestoreReadList + */ +func (a *RestoreApiService) SnapshotsRestoresGetExecute(r ApiSnapshotsRestoresGetRequest) (RestoreReadList, *APIResponse, error) { + var ( + localVarHTTPMethod = _nethttp.MethodGet + localVarPostBody interface{} + localVarFormFileName string + localVarFileName string + localVarFileBytes []byte + localVarReturnValue RestoreReadList + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "RestoreApiService.SnapshotsRestoresGet") + if err != nil { + return localVarReturnValue, nil, GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/snapshots/{snapshotId}/restores" + localVarPath = strings.Replace(localVarPath, "{"+"snapshotId"+"}", _neturl.PathEscape(parameterToString(r.snapshotId, "")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + + if r.offset != nil { + localVarQueryParams.Add("offset", parameterToString(*r.offset, "")) + } + if r.limit != nil { + localVarQueryParams.Add("limit", parameterToString(*r.limit, "")) + } + if r.filterName != nil { + localVarQueryParams.Add("filter.name", parameterToString(*r.filterName, "")) + } + // to determine the Content-Type header + localVarHTTPContentTypes := []string{} + + // 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 + } + 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: "SnapshotsRestoresGet", + } + + 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 Error + 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 Error + 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 Error + 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 Error + 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 Error + 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 Error + 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 + } + var v Error + 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 ApiSnapshotsRestoresPostRequest struct { + ctx _context.Context + ApiService *RestoreApiService + snapshotId string + restoreCreate *RestoreCreate +} + +func (r ApiSnapshotsRestoresPostRequest) RestoreCreate(restoreCreate RestoreCreate) ApiSnapshotsRestoresPostRequest { + r.restoreCreate = &restoreCreate + return r +} + +func (r ApiSnapshotsRestoresPostRequest) Execute() (RestoreRead, *APIResponse, error) { + return r.ApiService.SnapshotsRestoresPostExecute(r) +} + +/* + - SnapshotsRestoresPost Create Restore + - Creates a new Restore. + +The full Restore needs to be provided to create the object. +Optional data will be filled with defaults or left empty. + + - @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + - @param snapshotId The ID (UUID) of the Snapshot. + - @return ApiSnapshotsRestoresPostRequest +*/ +func (a *RestoreApiService) SnapshotsRestoresPost(ctx _context.Context, snapshotId string) ApiSnapshotsRestoresPostRequest { + return ApiSnapshotsRestoresPostRequest{ + ApiService: a, + ctx: ctx, + snapshotId: snapshotId, + } +} + +/* + * Execute executes the request + * @return RestoreRead + */ +func (a *RestoreApiService) SnapshotsRestoresPostExecute(r ApiSnapshotsRestoresPostRequest) (RestoreRead, *APIResponse, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPost + localVarPostBody interface{} + localVarFormFileName string + localVarFileName string + localVarFileBytes []byte + localVarReturnValue RestoreRead + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "RestoreApiService.SnapshotsRestoresPost") + if err != nil { + return localVarReturnValue, nil, GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/snapshots/{snapshotId}/restores" + localVarPath = strings.Replace(localVarPath, "{"+"snapshotId"+"}", _neturl.PathEscape(parameterToString(r.snapshotId, "")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + if r.restoreCreate == nil { + return localVarReturnValue, nil, reportError("restoreCreate 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.restoreCreate + 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: "SnapshotsRestoresPost", + } + + 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 Error + 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 Error + 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 Error + 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 Error + 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 Error + 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 Error + 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 Error + 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 Error + 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 + } + var v Error + 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 +} diff --git a/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/api_snapshot.go b/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/api_snapshot.go new file mode 100644 index 000000000..bddbaabdb --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/api_snapshot.go @@ -0,0 +1,408 @@ +/* + * In-Memory DB API + * + * API description for the IONOS In-Memory DB + * + * API version: 1.0.0 + * Contact: support@cloud.ionos.com + */ + +// 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 +) + +// SnapshotApiService SnapshotApi service +type SnapshotApiService service + +type ApiSnapshotsFindByIdRequest struct { + ctx _context.Context + ApiService *SnapshotApiService + snapshotId string +} + +func (r ApiSnapshotsFindByIdRequest) Execute() (SnapshotRead, *APIResponse, error) { + return r.ApiService.SnapshotsFindByIdExecute(r) +} + +/* + * SnapshotsFindById Retrieve Snapshot + * Returns the Snapshot by ID. + * @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param snapshotId The ID (UUID) of the Snapshot. + * @return ApiSnapshotsFindByIdRequest + */ +func (a *SnapshotApiService) SnapshotsFindById(ctx _context.Context, snapshotId string) ApiSnapshotsFindByIdRequest { + return ApiSnapshotsFindByIdRequest{ + ApiService: a, + ctx: ctx, + snapshotId: snapshotId, + } +} + +/* + * Execute executes the request + * @return SnapshotRead + */ +func (a *SnapshotApiService) SnapshotsFindByIdExecute(r ApiSnapshotsFindByIdRequest) (SnapshotRead, *APIResponse, error) { + var ( + localVarHTTPMethod = _nethttp.MethodGet + localVarPostBody interface{} + localVarFormFileName string + localVarFileName string + localVarFileBytes []byte + localVarReturnValue SnapshotRead + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "SnapshotApiService.SnapshotsFindById") + if err != nil { + return localVarReturnValue, nil, GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/snapshots/{snapshotId}" + localVarPath = strings.Replace(localVarPath, "{"+"snapshotId"+"}", _neturl.PathEscape(parameterToString(r.snapshotId, "")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + + // to determine the Content-Type header + localVarHTTPContentTypes := []string{} + + // 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 + } + 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: "SnapshotsFindById", + } + + 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 Error + 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 Error + 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 Error + 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 Error + 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 Error + 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 Error + 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 Error + 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 + } + var v Error + 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 ApiSnapshotsGetRequest struct { + ctx _context.Context + ApiService *SnapshotApiService + offset *int32 + limit *int32 +} + +func (r ApiSnapshotsGetRequest) Offset(offset int32) ApiSnapshotsGetRequest { + r.offset = &offset + return r +} +func (r ApiSnapshotsGetRequest) Limit(limit int32) ApiSnapshotsGetRequest { + r.limit = &limit + return r +} + +func (r ApiSnapshotsGetRequest) Execute() (SnapshotReadList, *APIResponse, error) { + return r.ApiService.SnapshotsGetExecute(r) +} + +/* + - SnapshotsGet Retrieve all Snapshot + - This endpoint enables retrieving all Snapshot using + +pagination and optional filters. + + - @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + - @return ApiSnapshotsGetRequest +*/ +func (a *SnapshotApiService) SnapshotsGet(ctx _context.Context) ApiSnapshotsGetRequest { + return ApiSnapshotsGetRequest{ + ApiService: a, + ctx: ctx, + } +} + +/* + * Execute executes the request + * @return SnapshotReadList + */ +func (a *SnapshotApiService) SnapshotsGetExecute(r ApiSnapshotsGetRequest) (SnapshotReadList, *APIResponse, error) { + var ( + localVarHTTPMethod = _nethttp.MethodGet + localVarPostBody interface{} + localVarFormFileName string + localVarFileName string + localVarFileBytes []byte + localVarReturnValue SnapshotReadList + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "SnapshotApiService.SnapshotsGet") + if err != nil { + return localVarReturnValue, nil, GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/snapshots" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + + if r.offset != nil { + localVarQueryParams.Add("offset", parameterToString(*r.offset, "")) + } + if r.limit != nil { + localVarQueryParams.Add("limit", parameterToString(*r.limit, "")) + } + // to determine the Content-Type header + localVarHTTPContentTypes := []string{} + + // 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 + } + 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: "SnapshotsGet", + } + + 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 Error + 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 Error + 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 Error + 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 Error + 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 Error + 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 Error + 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 + } + var v Error + 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 +} diff --git a/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/client.go b/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/client.go new file mode 100644 index 000000000..8a88d8493 --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/client.go @@ -0,0 +1,749 @@ +/* + * In-Memory DB API + * + * API description for the IONOS In-Memory DB + * + * API version: 1.0.0 + * Contact: support@cloud.ionos.com + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package ionoscloud + +import ( + "bytes" + "context" + "crypto/sha256" + "crypto/tls" + "crypto/x509" + "encoding/hex" + "encoding/json" + "encoding/xml" + "errors" + "fmt" + "io" + "mime/multipart" + "net" + "net/http" + "net/http/httputil" + "net/url" + "os" + "path/filepath" + "reflect" + "regexp" + "strconv" + "strings" + "time" + "unicode/utf8" + + "golang.org/x/oauth2" +) + +var ( + jsonCheck = regexp.MustCompile(`(?i:(?:application|text)\/(?:vnd\.[^;]+|problem\+)?json)`) + xmlCheck = regexp.MustCompile(`(?i:(?:application|text)/xml)`) +) + +const ( + RequestStatusQueued = "QUEUED" + RequestStatusRunning = "RUNNING" + RequestStatusFailed = "FAILED" + RequestStatusDone = "DONE" + + Version = "1.0.0" +) + +// APIClient manages communication with the In-Memory DB API API v1.0.0 +// In most cases there should be only one, shared, APIClient. +type APIClient struct { + cfg *Configuration + common service // Reuse a single struct instead of allocating one for each service on the heap. + + // API Services + + ReplicaSetApi *ReplicaSetApiService + + RestoreApi *RestoreApiService + + SnapshotApi *SnapshotApiService +} + +type service struct { + client *APIClient +} + +// NewAPIClient creates a new API client. Requires a userAgent string describing your application. +// optionally a custom http.Client to allow for advanced features such as caching. +func NewAPIClient(cfg *Configuration) *APIClient { + if cfg.HTTPClient == nil { + cfg.HTTPClient = http.DefaultClient + } + //enable certificate pinning if the env variable is set + pkFingerprint := os.Getenv(IonosPinnedCertEnvVar) + if pkFingerprint != "" { + httpTransport := &http.Transport{} + AddPinnedCert(httpTransport, pkFingerprint) + cfg.HTTPClient.Transport = httpTransport + } + + c := &APIClient{} + c.cfg = cfg + c.common.client = c + + // API Services + c.ReplicaSetApi = (*ReplicaSetApiService)(&c.common) + c.RestoreApi = (*RestoreApiService)(&c.common) + c.SnapshotApi = (*SnapshotApiService)(&c.common) + + return c +} + +// AddPinnedCert - enables pinning of the sha256 public fingerprint to the http client's transport +func AddPinnedCert(transport *http.Transport, pkFingerprint string) { + if pkFingerprint != "" { + transport.DialTLSContext = addPinnedCertVerification([]byte(pkFingerprint), new(tls.Config)) + } +} + +// TLSDial can be assigned to a http.Transport's DialTLS field. +type TLSDial func(ctx context.Context, network, addr string) (net.Conn, error) + +// addPinnedCertVerification returns a TLSDial function which checks that +// the remote server provides a certificate whose SHA256 fingerprint matches +// the provided value. +// +// The returned dialer function can be plugged into a http.Transport's DialTLS +// field to allow for certificate pinning. +func addPinnedCertVerification(fingerprint []byte, tlsConfig *tls.Config) TLSDial { + return func(ctx context.Context, network, addr string) (net.Conn, error) { + //fingerprints can be added with ':', we need to trim + fingerprint = bytes.ReplaceAll(fingerprint, []byte(":"), []byte("")) + fingerprint = bytes.ReplaceAll(fingerprint, []byte(" "), []byte("")) + //we are manually checking a certificate, so we need to enable insecure + tlsConfig.InsecureSkipVerify = true + + // Dial the connection to get certificates to check + conn, err := tls.Dial(network, addr, tlsConfig) + if err != nil { + return nil, err + } + + if err := verifyPinnedCert(fingerprint, conn.ConnectionState().PeerCertificates); err != nil { + _ = conn.Close() + return nil, err + } + + return conn, nil + } +} + +// verifyPinnedCert iterates the list of peer certificates and attempts to +// locate a certificate that is not a CA and whose public key fingerprint matches pkFingerprint. +func verifyPinnedCert(pkFingerprint []byte, peerCerts []*x509.Certificate) error { + for _, cert := range peerCerts { + fingerprint := sha256.Sum256(cert.Raw) + + var bytesFingerPrint = make([]byte, hex.EncodedLen(len(fingerprint[:]))) + hex.Encode(bytesFingerPrint, fingerprint[:]) + + // we have a match, and it's not an authority certificate + if cert.IsCA == false && bytes.EqualFold(bytesFingerPrint, pkFingerprint) { + return nil + } + } + + return fmt.Errorf("remote server presented a certificate which does not match the provided fingerprint") +} + +func atoi(in string) (int, error) { + return strconv.Atoi(in) +} + +// selectHeaderContentType select a content type from the available list. +func selectHeaderContentType(contentTypes []string) string { + if len(contentTypes) == 0 { + return "" + } + if contains(contentTypes, "application/json") { + return "application/json" + } + return contentTypes[0] // use the first content type specified in 'consumes' +} + +// selectHeaderAccept join all accept types and return +func selectHeaderAccept(accepts []string) string { + if len(accepts) == 0 { + return "" + } + + if contains(accepts, "application/json") { + return "application/json" + } + + return strings.Join(accepts, ",") +} + +// contains is a case insenstive match, finding needle in a haystack +func contains(haystack []string, needle string) bool { + for _, a := range haystack { + if strings.ToLower(a) == strings.ToLower(needle) { + return true + } + } + return false +} + +// Verify optional parameters are of the correct type. +func typeCheckParameter(obj interface{}, expected string, name string) error { + // Make sure there is an object. + if obj == nil { + return nil + } + + // Check the type is as expected. + if reflect.TypeOf(obj).String() != expected { + return fmt.Errorf("Expected %s to be of type %s but received %s.", name, expected, reflect.TypeOf(obj).String()) + } + return nil +} + +// parameterToString convert interface{} parameters to string, using a delimiter if format is provided. +func parameterToString(obj interface{}, collectionFormat string) string { + var delimiter string + + switch collectionFormat { + case "pipes": + delimiter = "|" + case "ssv": + delimiter = " " + case "tsv": + delimiter = "\t" + case "csv": + delimiter = "," + } + + if reflect.TypeOf(obj).Kind() == reflect.Slice { + return strings.Trim(strings.Replace(fmt.Sprint(obj), " ", delimiter, -1), "[]") + } else if t, ok := obj.(time.Time); ok { + return t.Format(time.RFC3339) + } + + return fmt.Sprintf("%v", obj) +} + +// helper for converting interface{} parameters to json strings +func parameterToJson(obj interface{}) (string, error) { + jsonBuf, err := json.Marshal(obj) + if err != nil { + return "", err + } + return string(jsonBuf), err +} + +// callAPI do the request. +func (c *APIClient) callAPI(request *http.Request) (*http.Response, time.Duration, error) { + retryCount := 0 + + var resp *http.Response + var httpRequestTime time.Duration + var err error + + for { + + retryCount++ + + /* we need to clone the request with every retry time because Body closes after the request */ + var clonedRequest *http.Request = request.Clone(request.Context()) + if request.Body != nil { + clonedRequest.Body, err = request.GetBody() + if err != nil { + return nil, httpRequestTime, err + } + } + + if c.cfg.Debug || c.cfg.LogLevel.Satisfies(Trace) { + dump, err := httputil.DumpRequestOut(clonedRequest, true) + if err == nil { + c.cfg.Logger.Printf(" DumpRequestOut : %s\n", string(dump)) + } else { + c.cfg.Logger.Printf(" DumpRequestOut err: %+v", err) + } + c.cfg.Logger.Printf("\n try no: %d\n", retryCount) + } + + httpRequestStartTime := time.Now() + clonedRequest.Close = true + resp, err = c.cfg.HTTPClient.Do(clonedRequest) + httpRequestTime = time.Since(httpRequestStartTime) + if err != nil { + return resp, httpRequestTime, err + } + + if c.cfg.Debug || c.cfg.LogLevel.Satisfies(Trace) { + dump, err := httputil.DumpResponse(resp, true) + if err == nil { + c.cfg.Logger.Printf("\n DumpResponse : %s\n", string(dump)) + } else { + c.cfg.Logger.Printf(" DumpResponse err %+v", err) + } + } + + var backoffTime time.Duration + + switch resp.StatusCode { + case http.StatusServiceUnavailable, + http.StatusGatewayTimeout, + http.StatusBadGateway: + if request.Method == http.MethodPost { + return resp, httpRequestTime, err + } + backoffTime = c.GetConfig().WaitTime + + case http.StatusTooManyRequests: + if retryAfterSeconds := resp.Header.Get("Retry-After"); retryAfterSeconds != "" { + waitTime, err := time.ParseDuration(retryAfterSeconds + "s") + if err != nil { + return resp, httpRequestTime, err + } + backoffTime = waitTime + } else { + backoffTime = c.GetConfig().WaitTime + } + default: + return resp, httpRequestTime, err + + } + + if retryCount >= c.GetConfig().MaxRetries { + if c.cfg.Debug || c.cfg.LogLevel.Satisfies(Debug) { + c.cfg.Logger.Printf(" Number of maximum retries exceeded (%d retries)\n", c.cfg.MaxRetries) + } + break + } else { + c.backOff(request.Context(), backoffTime) + } + } + + return resp, httpRequestTime, err +} + +func (c *APIClient) backOff(ctx context.Context, t time.Duration) { + if t > c.GetConfig().MaxWaitTime { + t = c.GetConfig().MaxWaitTime + } + if c.cfg.Debug || c.cfg.LogLevel.Satisfies(Debug) { + c.cfg.Logger.Printf(" Sleeping %s before retrying request\n", t.String()) + } + if t <= 0 { + return + } + + timer := time.NewTimer(t) + defer timer.Stop() + + select { + case <-ctx.Done(): + case <-timer.C: + } +} + +// Allow modification of underlying config for alternate implementations and testing +// Caution: modifying the configuration while live can cause data races and potentially unwanted behavior +func (c *APIClient) GetConfig() *Configuration { + return c.cfg +} + +// prepareRequest build the request +func (c *APIClient) prepareRequest( + ctx context.Context, + path string, method string, + postBody interface{}, + headerParams map[string]string, + queryParams url.Values, + formParams url.Values, + formFileName string, + fileName string, + fileBytes []byte) (localVarRequest *http.Request, err error) { + + var body *bytes.Buffer + + // Detect postBody type and post. + if postBody != nil { + contentType := headerParams["Content-Type"] + if contentType == "" { + contentType = detectContentType(postBody) + headerParams["Content-Type"] = contentType + } + + body, err = setBody(postBody, contentType) + if err != nil { + return nil, err + } + } + + // add form parameters and file if available. + if strings.HasPrefix(headerParams["Content-Type"], "multipart/form-data") && len(formParams) > 0 || (len(fileBytes) > 0 && fileName != "") { + if body != nil { + return nil, errors.New("Cannot specify postBody and multipart form at the same time.") + } + body = &bytes.Buffer{} + w := multipart.NewWriter(body) + + for k, v := range formParams { + for _, iv := range v { + if strings.HasPrefix(k, "@") { // file + err = addFile(w, k[1:], iv) + if err != nil { + return nil, err + } + } else { // form value + w.WriteField(k, iv) + } + } + } + if len(fileBytes) > 0 && fileName != "" { + w.Boundary() + //_, fileNm := filepath.Split(fileName) + part, err := w.CreateFormFile(formFileName, filepath.Base(fileName)) + if err != nil { + return nil, err + } + _, err = part.Write(fileBytes) + if err != nil { + return nil, err + } + } + + // Set the Boundary in the Content-Type + headerParams["Content-Type"] = w.FormDataContentType() + + // Set Content-Length + headerParams["Content-Length"] = fmt.Sprintf("%d", body.Len()) + w.Close() + } + + if strings.HasPrefix(headerParams["Content-Type"], "application/x-www-form-urlencoded") && len(formParams) > 0 { + if body != nil { + return nil, errors.New("Cannot specify postBody and x-www-form-urlencoded form at the same time.") + } + body = &bytes.Buffer{} + body.WriteString(formParams.Encode()) + // Set Content-Length + headerParams["Content-Length"] = fmt.Sprintf("%d", body.Len()) + } + + // Setup path and query parameters + url, err := url.Parse(path) + if err != nil { + return nil, err + } + + // Override request host, if applicable + if c.cfg.Host != "" { + url.Host = c.cfg.Host + } + + // Override request scheme, if applicable + if c.cfg.Scheme != "" { + url.Scheme = c.cfg.Scheme + } + + // Adding Query Param + query := url.Query() + /* adding default query params */ + for k, v := range c.cfg.DefaultQueryParams { + if _, ok := queryParams[k]; !ok { + queryParams[k] = v + } + } + for k, v := range queryParams { + for _, iv := range v { + query.Add(k, iv) + } + } + + // Encode the parameters. + url.RawQuery = query.Encode() + + // Generate a new request + if body != nil { + localVarRequest, err = http.NewRequest(method, url.String(), body) + } else { + localVarRequest, err = http.NewRequest(method, url.String(), nil) + } + if err != nil { + return nil, err + } + + // add header parameters, if any + if len(headerParams) > 0 { + headers := http.Header{} + for h, v := range headerParams { + headers.Set(h, v) + } + localVarRequest.Header = headers + } + + // Add the user agent to the request. + localVarRequest.Header.Add("User-Agent", c.cfg.UserAgent) + + if c.cfg.Token != "" { + localVarRequest.Header.Add("Authorization", "Bearer "+c.cfg.Token) + } else { + if c.cfg.Username != "" { + localVarRequest.SetBasicAuth(c.cfg.Username, c.cfg.Password) + } + } + + if ctx != nil { + // add context to the request + localVarRequest = localVarRequest.WithContext(ctx) + + // Walk through any authentication. + + // OAuth2 authentication + if tok, ok := ctx.Value(ContextOAuth2).(oauth2.TokenSource); ok { + // We were able to grab an oauth2 token from the context + var latestToken *oauth2.Token + if latestToken, err = tok.Token(); err != nil { + return nil, err + } + + latestToken.SetAuthHeader(localVarRequest) + } + + // Basic HTTP Authentication + if auth, ok := ctx.Value(ContextBasicAuth).(BasicAuth); ok { + localVarRequest.SetBasicAuth(auth.UserName, auth.Password) + } + + // AccessToken Authentication + if auth, ok := ctx.Value(ContextAccessToken).(string); ok { + localVarRequest.Header.Add("Authorization", "Bearer "+auth) + } + + } + + for header, value := range c.cfg.DefaultHeader { + localVarRequest.Header.Add(header, value) + } + return localVarRequest, nil +} + +func (c *APIClient) decode(v interface{}, b []byte, contentType string) (err error) { + if len(b) == 0 { + return nil + } + if s, ok := v.(*string); ok { + *s = string(b) + return nil + } + if xmlCheck.MatchString(contentType) { + if err = xml.Unmarshal(b, v); err != nil { + return err + } + return nil + } + if jsonCheck.MatchString(contentType) { + if actualObj, ok := v.(interface{ GetActualInstance() interface{} }); ok { // oneOf, anyOf schemas + if unmarshalObj, ok := actualObj.(interface{ UnmarshalJSON([]byte) error }); ok { // make sure it has UnmarshalJSON defined + if err = unmarshalObj.UnmarshalJSON(b); err != nil { + return err + } + } else { + return errors.New("unknown type with GetActualInstance but no unmarshalObj.UnmarshalJSON defined") + } + } else if err = json.Unmarshal(b, v); err != nil { // simple model + return err + } + return nil + } + return fmt.Errorf("undefined response type for content %s", contentType) +} + +// Add a file to the multipart request +func addFile(w *multipart.Writer, fieldName, path string) error { + file, err := os.Open(path) + if err != nil { + return err + } + defer file.Close() + + part, err := w.CreateFormFile(fieldName, filepath.Base(path)) + if err != nil { + return err + } + _, err = io.Copy(part, file) + + return err +} + +// Prevent trying to import "fmt" +func reportError(format string, a ...interface{}) error { + return fmt.Errorf(format, a...) +} + +// Set request body from an interface{} +func setBody(body interface{}, contentType string) (bodyBuf *bytes.Buffer, err error) { + if bodyBuf == nil { + bodyBuf = &bytes.Buffer{} + } + + if reader, ok := body.(io.Reader); ok { + _, err = bodyBuf.ReadFrom(reader) + } else if b, ok := body.([]byte); ok { + _, err = bodyBuf.Write(b) + } else if s, ok := body.(string); ok { + _, err = bodyBuf.WriteString(s) + } else if s, ok := body.(*string); ok { + _, err = bodyBuf.WriteString(*s) + } else if jsonCheck.MatchString(contentType) { + err = json.NewEncoder(bodyBuf).Encode(body) + } else if xmlCheck.MatchString(contentType) { + err = xml.NewEncoder(bodyBuf).Encode(body) + } + + if err != nil { + return nil, err + } + + if bodyBuf.Len() == 0 { + err = fmt.Errorf("Invalid body type %s\n", contentType) + return nil, err + } + return bodyBuf, nil +} + +// detectContentType method is used to figure out `Request.Body` content type for request header +func detectContentType(body interface{}) string { + contentType := "text/plain; charset=utf-8" + kind := reflect.TypeOf(body).Kind() + + switch kind { + case reflect.Struct, reflect.Map, reflect.Ptr: + contentType = "application/json; charset=utf-8" + case reflect.String: + contentType = "text/plain; charset=utf-8" + default: + if b, ok := body.([]byte); ok { + contentType = http.DetectContentType(b) + } else if kind == reflect.Slice { + contentType = "application/json; charset=utf-8" + } + } + + return contentType +} + +// Ripped from https://github.com/gregjones/httpcache/blob/master/httpcache.go +type cacheControl map[string]string + +func parseCacheControl(headers http.Header) cacheControl { + cc := cacheControl{} + ccHeader := headers.Get("Cache-Control") + for _, part := range strings.Split(ccHeader, ",") { + part = strings.Trim(part, " ") + if part == "" { + continue + } + if strings.ContainsRune(part, '=') { + keyval := strings.Split(part, "=") + cc[strings.Trim(keyval[0], " ")] = strings.Trim(keyval[1], ",") + } else { + cc[part] = "" + } + } + return cc +} + +// CacheExpires helper function to determine remaining time before repeating a request. +func CacheExpires(r *http.Response) time.Time { + // Figure out when the cache expires. + var expires time.Time + now, err := time.Parse(time.RFC1123, r.Header.Get("date")) + if err != nil { + return time.Now() + } + respCacheControl := parseCacheControl(r.Header) + + if maxAge, ok := respCacheControl["max-age"]; ok { + lifetime, err := time.ParseDuration(maxAge + "s") + if err != nil { + expires = now + } else { + expires = now.Add(lifetime) + } + } else { + expiresHeader := r.Header.Get("Expires") + if expiresHeader != "" { + expires, err = time.Parse(time.RFC1123, expiresHeader) + if err != nil { + expires = now + } + } + } + return expires +} + +func strlen(s string) int { + return utf8.RuneCountInString(s) +} + +// GenericOpenAPIError Provides access to the body, error and model on returned errors. +type GenericOpenAPIError struct { + statusCode int + body []byte + error string + model interface{} +} + +// NewGenericOpenAPIError - constructor for GenericOpenAPIError +func NewGenericOpenAPIError(message string, body []byte, model interface{}, statusCode int) *GenericOpenAPIError { + return &GenericOpenAPIError{ + statusCode: statusCode, + body: body, + error: message, + model: model, + } +} + +// Error returns non-empty string if there was an error. +func (e GenericOpenAPIError) Error() string { + return e.error +} + +// SetError sets the error string +func (e *GenericOpenAPIError) SetError(error string) { + e.error = error +} + +// Body returns the raw bytes of the response +func (e GenericOpenAPIError) Body() []byte { + return e.body +} + +// SetBody sets the raw body of the error +func (e *GenericOpenAPIError) SetBody(body []byte) { + e.body = body +} + +// Model returns the unpacked model of the error +func (e GenericOpenAPIError) Model() interface{} { + return e.model +} + +// SetModel sets the model of the error +func (e *GenericOpenAPIError) SetModel(model interface{}) { + e.model = model +} + +// StatusCode returns the status code of the error +func (e GenericOpenAPIError) StatusCode() int { + return e.statusCode +} + +// SetStatusCode sets the status code of the error +func (e *GenericOpenAPIError) SetStatusCode(statusCode int) { + e.statusCode = statusCode +} diff --git a/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/configuration.go b/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/configuration.go new file mode 100644 index 000000000..5317d48c0 --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/configuration.go @@ -0,0 +1,328 @@ +/* + * In-Memory DB API + * + * API description for the IONOS In-Memory DB + * + * API version: 1.0.0 + * Contact: support@cloud.ionos.com + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package ionoscloud + +import ( + "context" + "fmt" + "net/http" + "net/url" + "os" + "strings" + "time" +) + +const ( + IonosUsernameEnvVar = "IONOS_USERNAME" + IonosPasswordEnvVar = "IONOS_PASSWORD" + IonosTokenEnvVar = "IONOS_TOKEN" + IonosApiUrlEnvVar = "IONOS_API_URL" + IonosPinnedCertEnvVar = "IONOS_PINNED_CERT" + IonosLogLevelEnvVar = "IONOS_LOG_LEVEL" + DefaultIonosServerUrl = "https://in-memory-db.de-fra.ionos.com" + DefaultIonosBasePath = "" + defaultMaxRetries = 3 + defaultWaitTime = time.Duration(100) * time.Millisecond + defaultMaxWaitTime = time.Duration(2000) * time.Millisecond +) + +var ( + IonosServerUrls = []string{ + "https://in-memory-db.de-fra.ionos.com", + "https://in-memory-db.de-txl.ionos.com", + "https://in-memory-db.es-vit.ionos.com", + "https://in-memory-db.gb-lhr.ionos.com", + "https://in-memory-db.us-ewr.ionos.com", + "https://in-memory-db.us-las.ionos.com", + "https://in-memory-db.us-mci.ionos.com", + "https://in-memory-db.fr-par.ionos.com", + } +) + +// contextKeys are used to identify the type of value in the context. +// Since these are string, it is possible to get a short description of the +// context key for logging and debugging using key.String(). + +type contextKey string + +func (c contextKey) String() string { + return "auth " + string(c) +} + +var ( + // ContextOAuth2 takes an oauth2.TokenSource as authentication for the request. + ContextOAuth2 = contextKey("token") + + // ContextBasicAuth takes BasicAuth as authentication for the request. + ContextBasicAuth = contextKey("basic") + + // ContextAccessToken takes a string oauth2 access token as authentication for the request. + ContextAccessToken = contextKey("accesstoken") + + // ContextAPIKeys takes a string apikey as authentication for the request + ContextAPIKeys = contextKey("apiKeys") + + // ContextHttpSignatureAuth takes HttpSignatureAuth as authentication for the request. + ContextHttpSignatureAuth = contextKey("httpsignature") + + // ContextServerIndex uses a server configuration from the index. + ContextServerIndex = contextKey("serverIndex") + + // ContextOperationServerIndices uses a server configuration from the index mapping. + ContextOperationServerIndices = contextKey("serverOperationIndices") + + // ContextServerVariables overrides a server configuration variables. + ContextServerVariables = contextKey("serverVariables") + + // ContextOperationServerVariables overrides a server configuration variables using operation specific values. + ContextOperationServerVariables = contextKey("serverOperationVariables") +) + +// BasicAuth provides basic http authentication to a request passed via context using ContextBasicAuth +type BasicAuth struct { + UserName string `json:"userName,omitempty"` + Password string `json:"password,omitempty"` +} + +// APIKey provides API key based authentication to a request passed via context using ContextAPIKey +type APIKey struct { + Key string + Prefix string +} + +// ServerVariable stores the information about a server variable +type ServerVariable struct { + Description string + DefaultValue string + EnumValues []string +} + +// ServerConfiguration stores the information about a server +type ServerConfiguration struct { + URL string + Description string + Variables map[string]ServerVariable +} + +// ServerConfigurations stores multiple ServerConfiguration items +type ServerConfigurations []ServerConfiguration + +// Configuration stores the configuration of the API client +type Configuration struct { + Host string `json:"host,omitempty"` + Scheme string `json:"scheme,omitempty"` + DefaultHeader map[string]string `json:"defaultHeader,omitempty"` + DefaultQueryParams url.Values `json:"defaultQueryParams,omitempty"` + UserAgent string `json:"userAgent,omitempty"` + Debug bool `json:"debug,omitempty"` + Servers ServerConfigurations + OperationServers map[string]ServerConfigurations + HTTPClient *http.Client + LogLevel LogLevel + Logger Logger + Username string `json:"username,omitempty"` + Password string `json:"password,omitempty"` + Token string `json:"token,omitempty"` + MaxRetries int `json:"maxRetries,omitempty"` + WaitTime time.Duration `json:"waitTime,omitempty"` + MaxWaitTime time.Duration `json:"maxWaitTime,omitempty"` +} + +// NewConfiguration returns a new Configuration object +func NewConfiguration(username, password, token, hostUrl string) *Configuration { + cfg := &Configuration{ + DefaultHeader: make(map[string]string), + DefaultQueryParams: url.Values{}, + UserAgent: "ionos-cloud-sdk-go-dbaas-in-memory-db/v1.0.0", + Debug: false, + Username: username, + Password: password, + Token: token, + MaxRetries: defaultMaxRetries, + MaxWaitTime: defaultMaxWaitTime, + WaitTime: defaultWaitTime, + Logger: NewDefaultLogger(), + LogLevel: getLogLevelFromEnv(), + Servers: ServerConfigurations{ + { + URL: getServerUrl(hostUrl), + Description: "Production de-fra", + }, + { + URL: getServerUrl(hostUrl), + Description: "Production de-txl", + }, + { + URL: getServerUrl(hostUrl), + Description: "Production es-vit", + }, + { + URL: getServerUrl(hostUrl), + Description: "Production gb-lhr", + }, + { + URL: getServerUrl(hostUrl), + Description: "Production us-ewr", + }, + { + URL: getServerUrl(hostUrl), + Description: "Production us-las", + }, + { + URL: getServerUrl(hostUrl), + Description: "Production us-mci", + }, + { + URL: getServerUrl(hostUrl), + Description: "Production fr-par", + }, + }, + OperationServers: map[string]ServerConfigurations{}, + } + return cfg +} + +func NewConfigurationFromEnv() *Configuration { + return NewConfiguration(os.Getenv(IonosUsernameEnvVar), os.Getenv(IonosPasswordEnvVar), os.Getenv(IonosTokenEnvVar), os.Getenv(IonosApiUrlEnvVar)) +} + +// AddDefaultHeader adds a new HTTP header to the default header in the request +func (c *Configuration) AddDefaultHeader(key string, value string) { + c.DefaultHeader[key] = value +} + +func (c *Configuration) AddDefaultQueryParam(key string, value string) { + c.DefaultQueryParams[key] = []string{value} +} + +// URL formats template on a index using given variables +func (sc ServerConfigurations) URL(index int, variables map[string]string) (string, error) { + if index < 0 || len(sc) <= index { + return "", fmt.Errorf("Index %v out of range %v", index, len(sc)-1) + } + server := sc[index] + url := server.URL + + // go through variables and replace placeholders + for name, variable := range server.Variables { + if value, ok := variables[name]; ok { + found := bool(len(variable.EnumValues) == 0) + for _, enumValue := range variable.EnumValues { + if value == enumValue { + found = true + } + } + if !found { + return "", fmt.Errorf("The variable %s in the server URL has invalid value %v. Must be %v", name, value, variable.EnumValues) + } + url = strings.Replace(url, "{"+name+"}", value, -1) + } else { + url = strings.Replace(url, "{"+name+"}", variable.DefaultValue, -1) + } + } + return url, nil +} + +// ServerURL returns URL based on server settings +func (c *Configuration) ServerURL(index int, variables map[string]string) (string, error) { + return c.Servers.URL(index, variables) +} + +func getServerIndex(ctx context.Context) (int, error) { + si := ctx.Value(ContextServerIndex) + if si != nil { + if index, ok := si.(int); ok { + return index, nil + } + return 0, reportError("Invalid type %T should be int", si) + } + return 0, nil +} + +func getServerOperationIndex(ctx context.Context, endpoint string) (int, error) { + osi := ctx.Value(ContextOperationServerIndices) + if osi != nil { + if operationIndices, ok := osi.(map[string]int); !ok { + return 0, reportError("Invalid type %T should be map[string]int", osi) + } else { + index, ok := operationIndices[endpoint] + if ok { + return index, nil + } + } + } + return getServerIndex(ctx) +} + +func getServerVariables(ctx context.Context) (map[string]string, error) { + sv := ctx.Value(ContextServerVariables) + if sv != nil { + if variables, ok := sv.(map[string]string); ok { + return variables, nil + } + return nil, reportError("ctx value of ContextServerVariables has invalid type %T should be map[string]string", sv) + } + return nil, nil +} + +func getServerOperationVariables(ctx context.Context, endpoint string) (map[string]string, error) { + osv := ctx.Value(ContextOperationServerVariables) + if osv != nil { + if operationVariables, ok := osv.(map[string]map[string]string); !ok { + return nil, reportError("ctx value of ContextOperationServerVariables has invalid type %T should be map[string]map[string]string", osv) + } else { + variables, ok := operationVariables[endpoint] + if ok { + return variables, nil + } + } + } + return getServerVariables(ctx) +} + +func getServerUrl(serverUrl string) string { + if serverUrl == "" { + return DefaultIonosServerUrl + } + // Support both HTTPS & HTTP schemas + if !strings.HasPrefix(serverUrl, "https://") && !strings.HasPrefix(serverUrl, "http://") { + serverUrl = fmt.Sprintf("https://%s", serverUrl) + } + if !strings.HasSuffix(serverUrl, DefaultIonosBasePath) { + serverUrl = fmt.Sprintf("%s%s", serverUrl, DefaultIonosBasePath) + } + return serverUrl +} + +// ServerURLWithContext returns a new server URL given an endpoint +func (c *Configuration) ServerURLWithContext(ctx context.Context, endpoint string) (string, error) { + sc, ok := c.OperationServers[endpoint] + if !ok { + sc = c.Servers + } + + if ctx == nil { + return sc.URL(0, nil) + } + + index, err := getServerOperationIndex(ctx, endpoint) + if err != nil { + return "", err + } + + variables, err := getServerOperationVariables(ctx, endpoint) + if err != nil { + return "", err + } + + return sc.URL(index, variables) +} diff --git a/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/logger.go b/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/logger.go new file mode 100644 index 000000000..ec0b6d055 --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/logger.go @@ -0,0 +1,81 @@ +/* + * In-Memory DB API + * + * API description for the IONOS In-Memory DB + * + * API version: 1.0.0 + * Contact: support@cloud.ionos.com + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package ionoscloud + +import ( + "log" + "os" + "strings" +) + +type LogLevel uint + +func (l *LogLevel) Get() LogLevel { + if l != nil { + return *l + } + return Off +} + +// Satisfies returns true if this LogLevel is at least high enough for v +func (l *LogLevel) Satisfies(v LogLevel) bool { + return l.Get() >= v +} + +const ( + Off LogLevel = 0x100 * iota + Debug + // Trace We recommend you only set this field for debugging purposes. + // Disable it in your production environments because it can log sensitive data. + // It logs the full request and response without encryption, even for an HTTPS call. + // Verbose request and response logging can also significantly impact your application's performance. + Trace +) + +var LogLevelMap = map[string]LogLevel{ + "off": Off, + "debug": Debug, + "trace": Trace, +} + +// getLogLevelFromEnv - gets LogLevel type from env variable IONOS_LOG_LEVEL +// returns Off if an invalid log level is encountered +func getLogLevelFromEnv() LogLevel { + strLogLevel := "off" + if os.Getenv(IonosLogLevelEnvVar) != "" { + strLogLevel = os.Getenv(IonosLogLevelEnvVar) + } + + logLevel, ok := LogLevelMap[strings.ToLower(strLogLevel)] + if !ok { + log.Printf("Cannot set logLevel for value: %s, setting loglevel to Off", strLogLevel) + } + return logLevel +} + +type Logger interface { + Printf(format string, args ...interface{}) +} + +func NewDefaultLogger() Logger { + return &defaultLogger{ + logger: log.New(os.Stderr, "IONOSLOG ", log.LstdFlags), + } +} + +type defaultLogger struct { + logger *log.Logger +} + +func (l defaultLogger) Printf(format string, args ...interface{}) { + l.logger.Printf(format, args...) +} diff --git a/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_connection.go b/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_connection.go new file mode 100644 index 000000000..e2266e5ae --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_connection.go @@ -0,0 +1,215 @@ +/* + * In-Memory DB API + * + * API description for the IONOS In-Memory DB + * + * API version: 1.0.0 + * Contact: support@cloud.ionos.com + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package ionoscloud + +import ( + "encoding/json" +) + +// Connection Details about the network connection for your instance. +type Connection struct { + // The datacenter to connect your instance to. + DatacenterId *string `json:"datacenterId"` + // The numeric LAN ID to connect your instance to. + LanId *string `json:"lanId"` + // The IP and subnet for your instance. Note the following unavailable IP ranges: 10.210.0.0/16 10.212.0.0/14 + Cidr *string `json:"cidr"` +} + +// NewConnection instantiates a new Connection 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 NewConnection(datacenterId string, lanId string, cidr string) *Connection { + this := Connection{} + + this.DatacenterId = &datacenterId + this.LanId = &lanId + this.Cidr = &cidr + + return &this +} + +// NewConnectionWithDefaults instantiates a new Connection 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 NewConnectionWithDefaults() *Connection { + this := Connection{} + return &this +} + +// GetDatacenterId returns the DatacenterId field value +// If the value is explicit nil, the zero value for string will be returned +func (o *Connection) GetDatacenterId() *string { + if o == nil { + return nil + } + + return o.DatacenterId + +} + +// GetDatacenterIdOk returns a tuple with the DatacenterId 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 *Connection) GetDatacenterIdOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.DatacenterId, true +} + +// SetDatacenterId sets field value +func (o *Connection) SetDatacenterId(v string) { + + o.DatacenterId = &v + +} + +// HasDatacenterId returns a boolean if a field has been set. +func (o *Connection) HasDatacenterId() bool { + if o != nil && o.DatacenterId != nil { + return true + } + + return false +} + +// GetLanId returns the LanId field value +// If the value is explicit nil, the zero value for string will be returned +func (o *Connection) GetLanId() *string { + if o == nil { + return nil + } + + return o.LanId + +} + +// GetLanIdOk returns a tuple with the LanId 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 *Connection) GetLanIdOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.LanId, true +} + +// SetLanId sets field value +func (o *Connection) SetLanId(v string) { + + o.LanId = &v + +} + +// HasLanId returns a boolean if a field has been set. +func (o *Connection) HasLanId() bool { + if o != nil && o.LanId != nil { + return true + } + + return false +} + +// GetCidr returns the Cidr field value +// If the value is explicit nil, the zero value for string will be returned +func (o *Connection) GetCidr() *string { + if o == nil { + return nil + } + + return o.Cidr + +} + +// GetCidrOk returns a tuple with the Cidr 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 *Connection) GetCidrOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.Cidr, true +} + +// SetCidr sets field value +func (o *Connection) SetCidr(v string) { + + o.Cidr = &v + +} + +// HasCidr returns a boolean if a field has been set. +func (o *Connection) HasCidr() bool { + if o != nil && o.Cidr != nil { + return true + } + + return false +} + +func (o Connection) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.DatacenterId != nil { + toSerialize["datacenterId"] = o.DatacenterId + } + + if o.LanId != nil { + toSerialize["lanId"] = o.LanId + } + + if o.Cidr != nil { + toSerialize["cidr"] = o.Cidr + } + + return json.Marshal(toSerialize) +} + +type NullableConnection struct { + value *Connection + isSet bool +} + +func (v NullableConnection) Get() *Connection { + return v.value +} + +func (v *NullableConnection) Set(val *Connection) { + v.value = val + v.isSet = true +} + +func (v NullableConnection) IsSet() bool { + return v.isSet +} + +func (v *NullableConnection) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableConnection(val *Connection) *NullableConnection { + return &NullableConnection{value: val, isSet: true} +} + +func (v NullableConnection) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableConnection) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_day_of_the_week.go b/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_day_of_the_week.go new file mode 100644 index 000000000..86b46c2df --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_day_of_the_week.go @@ -0,0 +1,89 @@ +/* + * In-Memory DB API + * + * API description for the IONOS In-Memory DB + * + * API version: 1.0.0 + * Contact: support@cloud.ionos.com + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package ionoscloud + +import ( + "encoding/json" + "fmt" +) + +// DayOfTheWeek The name of the week day. +type DayOfTheWeek string + +// List of DayOfTheWeek +const ( + DAYOFTHEWEEK_SUNDAY DayOfTheWeek = "Sunday" + DAYOFTHEWEEK_MONDAY DayOfTheWeek = "Monday" + DAYOFTHEWEEK_TUESDAY DayOfTheWeek = "Tuesday" + DAYOFTHEWEEK_WEDNESDAY DayOfTheWeek = "Wednesday" + DAYOFTHEWEEK_THURSDAY DayOfTheWeek = "Thursday" + DAYOFTHEWEEK_FRIDAY DayOfTheWeek = "Friday" + DAYOFTHEWEEK_SATURDAY DayOfTheWeek = "Saturday" +) + +func (v *DayOfTheWeek) UnmarshalJSON(src []byte) error { + var value string + err := json.Unmarshal(src, &value) + if err != nil { + return err + } + enumTypeValue := DayOfTheWeek(value) + for _, existing := range []DayOfTheWeek{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"} { + if existing == enumTypeValue { + *v = enumTypeValue + return nil + } + } + + return fmt.Errorf("%+v is not a valid DayOfTheWeek", value) +} + +// Ptr returns reference to DayOfTheWeek value +func (v DayOfTheWeek) Ptr() *DayOfTheWeek { + return &v +} + +type NullableDayOfTheWeek struct { + value *DayOfTheWeek + isSet bool +} + +func (v NullableDayOfTheWeek) Get() *DayOfTheWeek { + return v.value +} + +func (v *NullableDayOfTheWeek) Set(val *DayOfTheWeek) { + v.value = val + v.isSet = true +} + +func (v NullableDayOfTheWeek) IsSet() bool { + return v.isSet +} + +func (v *NullableDayOfTheWeek) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableDayOfTheWeek(val *DayOfTheWeek) *NullableDayOfTheWeek { + return &NullableDayOfTheWeek{value: val, isSet: true} +} + +func (v NullableDayOfTheWeek) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableDayOfTheWeek) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_error.go b/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_error.go new file mode 100644 index 000000000..192c981fe --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_error.go @@ -0,0 +1,167 @@ +/* + * In-Memory DB API + * + * API description for the IONOS In-Memory DB + * + * API version: 1.0.0 + * Contact: support@cloud.ionos.com + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package ionoscloud + +import ( + "encoding/json" +) + +// Error The Error object is used to represent an error response from the API. +type Error struct { + // The HTTP status code of the operation. + HttpStatus *int32 `json:"httpStatus,omitempty"` + // A list of error messages. + Messages *[]ErrorMessages `json:"messages,omitempty"` +} + +// NewError instantiates a new Error 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 NewError() *Error { + this := Error{} + + return &this +} + +// NewErrorWithDefaults instantiates a new Error 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 NewErrorWithDefaults() *Error { + this := Error{} + return &this +} + +// GetHttpStatus returns the HttpStatus field value +// If the value is explicit nil, the zero value for int32 will be returned +func (o *Error) GetHttpStatus() *int32 { + if o == nil { + return nil + } + + return o.HttpStatus + +} + +// GetHttpStatusOk returns a tuple with the HttpStatus 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 *Error) GetHttpStatusOk() (*int32, bool) { + if o == nil { + return nil, false + } + + return o.HttpStatus, true +} + +// SetHttpStatus sets field value +func (o *Error) SetHttpStatus(v int32) { + + o.HttpStatus = &v + +} + +// HasHttpStatus returns a boolean if a field has been set. +func (o *Error) HasHttpStatus() bool { + if o != nil && o.HttpStatus != nil { + return true + } + + return false +} + +// GetMessages returns the Messages field value +// If the value is explicit nil, the zero value for []ErrorMessages will be returned +func (o *Error) GetMessages() *[]ErrorMessages { + if o == nil { + return nil + } + + return o.Messages + +} + +// GetMessagesOk returns a tuple with the Messages 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 *Error) GetMessagesOk() (*[]ErrorMessages, bool) { + if o == nil { + return nil, false + } + + return o.Messages, true +} + +// SetMessages sets field value +func (o *Error) SetMessages(v []ErrorMessages) { + + o.Messages = &v + +} + +// HasMessages returns a boolean if a field has been set. +func (o *Error) HasMessages() bool { + if o != nil && o.Messages != nil { + return true + } + + return false +} + +func (o Error) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.HttpStatus != nil { + toSerialize["httpStatus"] = o.HttpStatus + } + + if o.Messages != nil { + toSerialize["messages"] = o.Messages + } + + return json.Marshal(toSerialize) +} + +type NullableError struct { + value *Error + isSet bool +} + +func (v NullableError) Get() *Error { + return v.value +} + +func (v *NullableError) Set(val *Error) { + v.value = val + v.isSet = true +} + +func (v NullableError) IsSet() bool { + return v.isSet +} + +func (v *NullableError) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableError(val *Error) *NullableError { + return &NullableError{value: val, isSet: true} +} + +func (v NullableError) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableError) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_error_messages.go b/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_error_messages.go new file mode 100644 index 000000000..d8c614567 --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_error_messages.go @@ -0,0 +1,167 @@ +/* + * In-Memory DB API + * + * API description for the IONOS In-Memory DB + * + * API version: 1.0.0 + * Contact: support@cloud.ionos.com + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package ionoscloud + +import ( + "encoding/json" +) + +// ErrorMessages struct for ErrorMessages +type ErrorMessages struct { + // Application internal error code + ErrorCode *string `json:"errorCode,omitempty"` + // A human readable explanation specific to this occurrence of the problem. + Message *string `json:"message,omitempty"` +} + +// NewErrorMessages instantiates a new ErrorMessages 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 NewErrorMessages() *ErrorMessages { + this := ErrorMessages{} + + return &this +} + +// NewErrorMessagesWithDefaults instantiates a new ErrorMessages 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 NewErrorMessagesWithDefaults() *ErrorMessages { + this := ErrorMessages{} + return &this +} + +// GetErrorCode returns the ErrorCode field value +// If the value is explicit nil, the zero value for string will be returned +func (o *ErrorMessages) GetErrorCode() *string { + if o == nil { + return nil + } + + return o.ErrorCode + +} + +// GetErrorCodeOk returns a tuple with the ErrorCode 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 *ErrorMessages) GetErrorCodeOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.ErrorCode, true +} + +// SetErrorCode sets field value +func (o *ErrorMessages) SetErrorCode(v string) { + + o.ErrorCode = &v + +} + +// HasErrorCode returns a boolean if a field has been set. +func (o *ErrorMessages) HasErrorCode() bool { + if o != nil && o.ErrorCode != nil { + return true + } + + return false +} + +// GetMessage returns the Message field value +// If the value is explicit nil, the zero value for string will be returned +func (o *ErrorMessages) GetMessage() *string { + if o == nil { + return nil + } + + return o.Message + +} + +// GetMessageOk returns a tuple with the Message 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 *ErrorMessages) GetMessageOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.Message, true +} + +// SetMessage sets field value +func (o *ErrorMessages) SetMessage(v string) { + + o.Message = &v + +} + +// HasMessage returns a boolean if a field has been set. +func (o *ErrorMessages) HasMessage() bool { + if o != nil && o.Message != nil { + return true + } + + return false +} + +func (o ErrorMessages) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.ErrorCode != nil { + toSerialize["errorCode"] = o.ErrorCode + } + + if o.Message != nil { + toSerialize["message"] = o.Message + } + + return json.Marshal(toSerialize) +} + +type NullableErrorMessages struct { + value *ErrorMessages + isSet bool +} + +func (v NullableErrorMessages) Get() *ErrorMessages { + return v.value +} + +func (v *NullableErrorMessages) Set(val *ErrorMessages) { + v.value = val + v.isSet = true +} + +func (v NullableErrorMessages) IsSet() bool { + return v.isSet +} + +func (v *NullableErrorMessages) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableErrorMessages(val *ErrorMessages) *NullableErrorMessages { + return &NullableErrorMessages{value: val, isSet: true} +} + +func (v NullableErrorMessages) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableErrorMessages) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_eviction_policy.go b/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_eviction_policy.go new file mode 100644 index 000000000..7e43f3f5f --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_eviction_policy.go @@ -0,0 +1,90 @@ +/* + * In-Memory DB API + * + * API description for the IONOS In-Memory DB + * + * API version: 1.0.0 + * Contact: support@cloud.ionos.com + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package ionoscloud + +import ( + "encoding/json" + "fmt" +) + +// EvictionPolicy The eviction policy for the replica set. The default value is `allkeys-lru`. | Policy | Description | |-----------------------|-------------| | **noeviction** | No eviction policy is used. In-Memory DB will never remove any data. If the memory limit is reached, an error will be returned on write operations. | | **allkeys-lru** | The least recently used keys will be removed first. | | **allkeys-lfu** | The least frequently used keys will be removed first. | | **allkeys-random** | Random keys will be removed. | | **volatile-lru** | The least recently used keys will be removed first, but only among keys with the `expire` field set to `true`. | | **volatile-lfu** | The least frequently used keys will be removed first, but only among keys with the `expire` field set to `true`. | | **volatile-random** | Random keys will be removed, but only among keys with the `expire` field set to `true`. | | **volatile-ttl** | The key with the nearest time to live will be removed first, but only among keys with the `expire` field set to `true`. | +type EvictionPolicy string + +// List of EvictionPolicy +const ( + EVICTIONPOLICY_NOEVICTION EvictionPolicy = "noeviction" + EVICTIONPOLICY_ALLKEYS_LRU EvictionPolicy = "allkeys-lru" + EVICTIONPOLICY_ALLKEYS_LFU EvictionPolicy = "allkeys-lfu" + EVICTIONPOLICY_ALLKEYS_RANDOM EvictionPolicy = "allkeys-random" + EVICTIONPOLICY_VOLATILE_LRU EvictionPolicy = "volatile-lru" + EVICTIONPOLICY_VOLATILE_LFU EvictionPolicy = "volatile-lfu" + EVICTIONPOLICY_VOLATILE_RANDOM EvictionPolicy = "volatile-random" + EVICTIONPOLICY_VOLATILE_TTL EvictionPolicy = "volatile-ttl" +) + +func (v *EvictionPolicy) UnmarshalJSON(src []byte) error { + var value string + err := json.Unmarshal(src, &value) + if err != nil { + return err + } + enumTypeValue := EvictionPolicy(value) + for _, existing := range []EvictionPolicy{"noeviction", "allkeys-lru", "allkeys-lfu", "allkeys-random", "volatile-lru", "volatile-lfu", "volatile-random", "volatile-ttl"} { + if existing == enumTypeValue { + *v = enumTypeValue + return nil + } + } + + return fmt.Errorf("%+v is not a valid EvictionPolicy", value) +} + +// Ptr returns reference to EvictionPolicy value +func (v EvictionPolicy) Ptr() *EvictionPolicy { + return &v +} + +type NullableEvictionPolicy struct { + value *EvictionPolicy + isSet bool +} + +func (v NullableEvictionPolicy) Get() *EvictionPolicy { + return v.value +} + +func (v *NullableEvictionPolicy) Set(val *EvictionPolicy) { + v.value = val + v.isSet = true +} + +func (v NullableEvictionPolicy) IsSet() bool { + return v.isSet +} + +func (v *NullableEvictionPolicy) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableEvictionPolicy(val *EvictionPolicy) *NullableEvictionPolicy { + return &NullableEvictionPolicy{value: val, isSet: true} +} + +func (v NullableEvictionPolicy) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableEvictionPolicy) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_hashed_password.go b/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_hashed_password.go new file mode 100644 index 000000000..547022cc9 --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_hashed_password.go @@ -0,0 +1,168 @@ +/* + * In-Memory DB API + * + * API description for the IONOS In-Memory DB + * + * API version: 1.0.0 + * Contact: support@cloud.ionos.com + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package ionoscloud + +import ( + "encoding/json" +) + +// HashedPassword The hashed password for a In-Memory DB user. +type HashedPassword struct { + Algorithm *string `json:"algorithm"` + Hash *string `json:"hash"` +} + +// NewHashedPassword instantiates a new HashedPassword 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 NewHashedPassword(algorithm string, hash string) *HashedPassword { + this := HashedPassword{} + + this.Algorithm = &algorithm + this.Hash = &hash + + return &this +} + +// NewHashedPasswordWithDefaults instantiates a new HashedPassword 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 NewHashedPasswordWithDefaults() *HashedPassword { + this := HashedPassword{} + return &this +} + +// GetAlgorithm returns the Algorithm field value +// If the value is explicit nil, the zero value for string will be returned +func (o *HashedPassword) GetAlgorithm() *string { + if o == nil { + return nil + } + + return o.Algorithm + +} + +// GetAlgorithmOk returns a tuple with the Algorithm 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 *HashedPassword) GetAlgorithmOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.Algorithm, true +} + +// SetAlgorithm sets field value +func (o *HashedPassword) SetAlgorithm(v string) { + + o.Algorithm = &v + +} + +// HasAlgorithm returns a boolean if a field has been set. +func (o *HashedPassword) HasAlgorithm() bool { + if o != nil && o.Algorithm != nil { + return true + } + + return false +} + +// GetHash returns the Hash field value +// If the value is explicit nil, the zero value for string will be returned +func (o *HashedPassword) GetHash() *string { + if o == nil { + return nil + } + + return o.Hash + +} + +// GetHashOk returns a tuple with the Hash 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 *HashedPassword) GetHashOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.Hash, true +} + +// SetHash sets field value +func (o *HashedPassword) SetHash(v string) { + + o.Hash = &v + +} + +// HasHash returns a boolean if a field has been set. +func (o *HashedPassword) HasHash() bool { + if o != nil && o.Hash != nil { + return true + } + + return false +} + +func (o HashedPassword) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.Algorithm != nil { + toSerialize["algorithm"] = o.Algorithm + } + + if o.Hash != nil { + toSerialize["hash"] = o.Hash + } + + return json.Marshal(toSerialize) +} + +type NullableHashedPassword struct { + value *HashedPassword + isSet bool +} + +func (v NullableHashedPassword) Get() *HashedPassword { + return v.value +} + +func (v *NullableHashedPassword) Set(val *HashedPassword) { + v.value = val + v.isSet = true +} + +func (v NullableHashedPassword) IsSet() bool { + return v.isSet +} + +func (v *NullableHashedPassword) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableHashedPassword(val *HashedPassword) *NullableHashedPassword { + return &NullableHashedPassword{value: val, isSet: true} +} + +func (v NullableHashedPassword) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableHashedPassword) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_links.go b/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_links.go new file mode 100644 index 000000000..b3e6781a7 --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_links.go @@ -0,0 +1,211 @@ +/* + * In-Memory DB API + * + * API description for the IONOS In-Memory DB + * + * API version: 1.0.0 + * Contact: support@cloud.ionos.com + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package ionoscloud + +import ( + "encoding/json" +) + +// Links URLs to navigate the different pages. As of now we always only return a single page. +type Links struct { + // URL (with offset and limit parameters) of the previous page; only present if offset is greater than 0. + Prev *string `json:"prev,omitempty"` + // URL (with offset and limit parameters) of the current page. + Self *string `json:"self,omitempty"` + // URL (with offset and limit parameters) of the next page; only present if offset + limit is less than the total number of elements. + Next *string `json:"next,omitempty"` +} + +// NewLinks instantiates a new Links 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 NewLinks() *Links { + this := Links{} + + return &this +} + +// NewLinksWithDefaults instantiates a new Links 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 NewLinksWithDefaults() *Links { + this := Links{} + return &this +} + +// GetPrev returns the Prev field value +// If the value is explicit nil, the zero value for string will be returned +func (o *Links) GetPrev() *string { + if o == nil { + return nil + } + + return o.Prev + +} + +// GetPrevOk returns a tuple with the Prev 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 *Links) GetPrevOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.Prev, true +} + +// SetPrev sets field value +func (o *Links) SetPrev(v string) { + + o.Prev = &v + +} + +// HasPrev returns a boolean if a field has been set. +func (o *Links) HasPrev() bool { + if o != nil && o.Prev != nil { + return true + } + + return false +} + +// GetSelf returns the Self field value +// If the value is explicit nil, the zero value for string will be returned +func (o *Links) GetSelf() *string { + if o == nil { + return nil + } + + return o.Self + +} + +// GetSelfOk returns a tuple with the Self 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 *Links) GetSelfOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.Self, true +} + +// SetSelf sets field value +func (o *Links) SetSelf(v string) { + + o.Self = &v + +} + +// HasSelf returns a boolean if a field has been set. +func (o *Links) HasSelf() bool { + if o != nil && o.Self != nil { + return true + } + + return false +} + +// GetNext returns the Next field value +// If the value is explicit nil, the zero value for string will be returned +func (o *Links) GetNext() *string { + if o == nil { + return nil + } + + return o.Next + +} + +// GetNextOk returns a tuple with the Next 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 *Links) GetNextOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.Next, true +} + +// SetNext sets field value +func (o *Links) SetNext(v string) { + + o.Next = &v + +} + +// HasNext returns a boolean if a field has been set. +func (o *Links) HasNext() bool { + if o != nil && o.Next != nil { + return true + } + + return false +} + +func (o Links) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.Prev != nil { + toSerialize["prev"] = o.Prev + } + + if o.Self != nil { + toSerialize["self"] = o.Self + } + + if o.Next != nil { + toSerialize["next"] = o.Next + } + + return json.Marshal(toSerialize) +} + +type NullableLinks struct { + value *Links + isSet bool +} + +func (v NullableLinks) Get() *Links { + return v.value +} + +func (v *NullableLinks) Set(val *Links) { + v.value = val + v.isSet = true +} + +func (v NullableLinks) IsSet() bool { + return v.isSet +} + +func (v *NullableLinks) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableLinks(val *Links) *NullableLinks { + return &NullableLinks{value: val, isSet: true} +} + +func (v NullableLinks) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableLinks) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_maintenance_window.go b/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_maintenance_window.go new file mode 100644 index 000000000..ada8bd864 --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_maintenance_window.go @@ -0,0 +1,169 @@ +/* + * In-Memory DB API + * + * API description for the IONOS In-Memory DB + * + * API version: 1.0.0 + * Contact: support@cloud.ionos.com + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package ionoscloud + +import ( + "encoding/json" +) + +// MaintenanceWindow A weekly 4 hour-long window, during which maintenance might occur. +type MaintenanceWindow struct { + // Start of the maintenance window in UTC time. + Time *string `json:"time"` + DayOfTheWeek *DayOfTheWeek `json:"dayOfTheWeek"` +} + +// NewMaintenanceWindow instantiates a new MaintenanceWindow 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 NewMaintenanceWindow(time string, dayOfTheWeek DayOfTheWeek) *MaintenanceWindow { + this := MaintenanceWindow{} + + this.Time = &time + this.DayOfTheWeek = &dayOfTheWeek + + return &this +} + +// NewMaintenanceWindowWithDefaults instantiates a new MaintenanceWindow 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 NewMaintenanceWindowWithDefaults() *MaintenanceWindow { + this := MaintenanceWindow{} + return &this +} + +// GetTime returns the Time field value +// If the value is explicit nil, the zero value for string will be returned +func (o *MaintenanceWindow) GetTime() *string { + if o == nil { + return nil + } + + return o.Time + +} + +// GetTimeOk returns a tuple with the Time 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 *MaintenanceWindow) GetTimeOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.Time, true +} + +// SetTime sets field value +func (o *MaintenanceWindow) SetTime(v string) { + + o.Time = &v + +} + +// HasTime returns a boolean if a field has been set. +func (o *MaintenanceWindow) HasTime() bool { + if o != nil && o.Time != nil { + return true + } + + return false +} + +// GetDayOfTheWeek returns the DayOfTheWeek field value +// If the value is explicit nil, the zero value for DayOfTheWeek will be returned +func (o *MaintenanceWindow) GetDayOfTheWeek() *DayOfTheWeek { + if o == nil { + return nil + } + + return o.DayOfTheWeek + +} + +// GetDayOfTheWeekOk returns a tuple with the DayOfTheWeek 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 *MaintenanceWindow) GetDayOfTheWeekOk() (*DayOfTheWeek, bool) { + if o == nil { + return nil, false + } + + return o.DayOfTheWeek, true +} + +// SetDayOfTheWeek sets field value +func (o *MaintenanceWindow) SetDayOfTheWeek(v DayOfTheWeek) { + + o.DayOfTheWeek = &v + +} + +// HasDayOfTheWeek returns a boolean if a field has been set. +func (o *MaintenanceWindow) HasDayOfTheWeek() bool { + if o != nil && o.DayOfTheWeek != nil { + return true + } + + return false +} + +func (o MaintenanceWindow) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.Time != nil { + toSerialize["time"] = o.Time + } + + if o.DayOfTheWeek != nil { + toSerialize["dayOfTheWeek"] = o.DayOfTheWeek + } + + return json.Marshal(toSerialize) +} + +type NullableMaintenanceWindow struct { + value *MaintenanceWindow + isSet bool +} + +func (v NullableMaintenanceWindow) Get() *MaintenanceWindow { + return v.value +} + +func (v *NullableMaintenanceWindow) Set(val *MaintenanceWindow) { + v.value = val + v.isSet = true +} + +func (v NullableMaintenanceWindow) IsSet() bool { + return v.isSet +} + +func (v *NullableMaintenanceWindow) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableMaintenanceWindow(val *MaintenanceWindow) *NullableMaintenanceWindow { + return &NullableMaintenanceWindow{value: val, isSet: true} +} + +func (v NullableMaintenanceWindow) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableMaintenanceWindow) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_metadata.go b/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_metadata.go new file mode 100644 index 000000000..aac88d282 --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_metadata.go @@ -0,0 +1,402 @@ +/* + * In-Memory DB API + * + * API description for the IONOS In-Memory DB + * + * API version: 1.0.0 + * Contact: support@cloud.ionos.com + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package ionoscloud + +import ( + "encoding/json" + "time" +) + +// Metadata Metadata of the resource. +type Metadata struct { + // The ISO 8601 creation timestamp. + CreatedDate *IonosTime `json:"createdDate,omitempty"` + // Unique name of the identity that created the resource. + CreatedBy *string `json:"createdBy,omitempty"` + // Unique id of the identity that created the resource. + CreatedByUserId *string `json:"createdByUserId,omitempty"` + // The ISO 8601 modified timestamp. + LastModifiedDate *IonosTime `json:"lastModifiedDate,omitempty"` + // Unique name of the identity that last modified the resource. + LastModifiedBy *string `json:"lastModifiedBy,omitempty"` + // Unique id of the identity that last modified the resource. + LastModifiedByUserId *string `json:"lastModifiedByUserId,omitempty"` + // Unique name of the resource. + ResourceURN *string `json:"resourceURN,omitempty"` +} + +// NewMetadata instantiates a new Metadata 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 NewMetadata() *Metadata { + this := Metadata{} + + return &this +} + +// NewMetadataWithDefaults instantiates a new Metadata 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 NewMetadataWithDefaults() *Metadata { + this := Metadata{} + return &this +} + +// GetCreatedDate returns the CreatedDate field value +// If the value is explicit nil, the zero value for time.Time will be returned +func (o *Metadata) GetCreatedDate() *time.Time { + if o == nil { + return nil + } + + if o.CreatedDate == nil { + return nil + } + return &o.CreatedDate.Time + +} + +// GetCreatedDateOk returns a tuple with the CreatedDate 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 *Metadata) GetCreatedDateOk() (*time.Time, bool) { + if o == nil { + return nil, false + } + + if o.CreatedDate == nil { + return nil, false + } + return &o.CreatedDate.Time, true + +} + +// SetCreatedDate sets field value +func (o *Metadata) SetCreatedDate(v time.Time) { + + o.CreatedDate = &IonosTime{v} + +} + +// HasCreatedDate returns a boolean if a field has been set. +func (o *Metadata) HasCreatedDate() bool { + if o != nil && o.CreatedDate != nil { + return true + } + + return false +} + +// GetCreatedBy returns the CreatedBy field value +// If the value is explicit nil, the zero value for string will be returned +func (o *Metadata) GetCreatedBy() *string { + if o == nil { + return nil + } + + return o.CreatedBy + +} + +// GetCreatedByOk returns a tuple with the CreatedBy 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 *Metadata) GetCreatedByOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.CreatedBy, true +} + +// SetCreatedBy sets field value +func (o *Metadata) SetCreatedBy(v string) { + + o.CreatedBy = &v + +} + +// HasCreatedBy returns a boolean if a field has been set. +func (o *Metadata) HasCreatedBy() bool { + if o != nil && o.CreatedBy != nil { + return true + } + + return false +} + +// GetCreatedByUserId returns the CreatedByUserId field value +// If the value is explicit nil, the zero value for string will be returned +func (o *Metadata) GetCreatedByUserId() *string { + if o == nil { + return nil + } + + return o.CreatedByUserId + +} + +// GetCreatedByUserIdOk returns a tuple with the CreatedByUserId 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 *Metadata) GetCreatedByUserIdOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.CreatedByUserId, true +} + +// SetCreatedByUserId sets field value +func (o *Metadata) SetCreatedByUserId(v string) { + + o.CreatedByUserId = &v + +} + +// HasCreatedByUserId returns a boolean if a field has been set. +func (o *Metadata) HasCreatedByUserId() bool { + if o != nil && o.CreatedByUserId != nil { + return true + } + + return false +} + +// GetLastModifiedDate returns the LastModifiedDate field value +// If the value is explicit nil, the zero value for time.Time will be returned +func (o *Metadata) GetLastModifiedDate() *time.Time { + if o == nil { + return nil + } + + if o.LastModifiedDate == nil { + return nil + } + return &o.LastModifiedDate.Time + +} + +// GetLastModifiedDateOk returns a tuple with the LastModifiedDate 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 *Metadata) GetLastModifiedDateOk() (*time.Time, bool) { + if o == nil { + return nil, false + } + + if o.LastModifiedDate == nil { + return nil, false + } + return &o.LastModifiedDate.Time, true + +} + +// SetLastModifiedDate sets field value +func (o *Metadata) SetLastModifiedDate(v time.Time) { + + o.LastModifiedDate = &IonosTime{v} + +} + +// HasLastModifiedDate returns a boolean if a field has been set. +func (o *Metadata) HasLastModifiedDate() bool { + if o != nil && o.LastModifiedDate != nil { + return true + } + + return false +} + +// GetLastModifiedBy returns the LastModifiedBy field value +// If the value is explicit nil, the zero value for string will be returned +func (o *Metadata) GetLastModifiedBy() *string { + if o == nil { + return nil + } + + return o.LastModifiedBy + +} + +// GetLastModifiedByOk returns a tuple with the LastModifiedBy 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 *Metadata) GetLastModifiedByOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.LastModifiedBy, true +} + +// SetLastModifiedBy sets field value +func (o *Metadata) SetLastModifiedBy(v string) { + + o.LastModifiedBy = &v + +} + +// HasLastModifiedBy returns a boolean if a field has been set. +func (o *Metadata) HasLastModifiedBy() bool { + if o != nil && o.LastModifiedBy != nil { + return true + } + + return false +} + +// GetLastModifiedByUserId returns the LastModifiedByUserId field value +// If the value is explicit nil, the zero value for string will be returned +func (o *Metadata) GetLastModifiedByUserId() *string { + if o == nil { + return nil + } + + return o.LastModifiedByUserId + +} + +// GetLastModifiedByUserIdOk returns a tuple with the LastModifiedByUserId 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 *Metadata) GetLastModifiedByUserIdOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.LastModifiedByUserId, true +} + +// SetLastModifiedByUserId sets field value +func (o *Metadata) SetLastModifiedByUserId(v string) { + + o.LastModifiedByUserId = &v + +} + +// HasLastModifiedByUserId returns a boolean if a field has been set. +func (o *Metadata) HasLastModifiedByUserId() bool { + if o != nil && o.LastModifiedByUserId != nil { + return true + } + + return false +} + +// GetResourceURN returns the ResourceURN field value +// If the value is explicit nil, the zero value for string will be returned +func (o *Metadata) GetResourceURN() *string { + if o == nil { + return nil + } + + return o.ResourceURN + +} + +// GetResourceURNOk returns a tuple with the ResourceURN 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 *Metadata) GetResourceURNOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.ResourceURN, true +} + +// SetResourceURN sets field value +func (o *Metadata) SetResourceURN(v string) { + + o.ResourceURN = &v + +} + +// HasResourceURN returns a boolean if a field has been set. +func (o *Metadata) HasResourceURN() bool { + if o != nil && o.ResourceURN != nil { + return true + } + + return false +} + +func (o Metadata) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.CreatedDate != nil { + toSerialize["createdDate"] = o.CreatedDate + } + + if o.CreatedBy != nil { + toSerialize["createdBy"] = o.CreatedBy + } + + if o.CreatedByUserId != nil { + toSerialize["createdByUserId"] = o.CreatedByUserId + } + + if o.LastModifiedDate != nil { + toSerialize["lastModifiedDate"] = o.LastModifiedDate + } + + if o.LastModifiedBy != nil { + toSerialize["lastModifiedBy"] = o.LastModifiedBy + } + + if o.LastModifiedByUserId != nil { + toSerialize["lastModifiedByUserId"] = o.LastModifiedByUserId + } + + if o.ResourceURN != nil { + toSerialize["resourceURN"] = o.ResourceURN + } + + return json.Marshal(toSerialize) +} + +type NullableMetadata struct { + value *Metadata + isSet bool +} + +func (v NullableMetadata) Get() *Metadata { + return v.value +} + +func (v *NullableMetadata) Set(val *Metadata) { + v.value = val + v.isSet = true +} + +func (v NullableMetadata) IsSet() bool { + return v.isSet +} + +func (v *NullableMetadata) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableMetadata(val *Metadata) *NullableMetadata { + return &NullableMetadata{value: val, isSet: true} +} + +func (v NullableMetadata) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableMetadata) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_pagination.go b/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_pagination.go new file mode 100644 index 000000000..fbec09d0f --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_pagination.go @@ -0,0 +1,214 @@ +/* + * In-Memory DB API + * + * API description for the IONOS In-Memory DB + * + * API version: 1.0.0 + * Contact: support@cloud.ionos.com + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package ionoscloud + +import ( + "encoding/json" +) + +// Pagination Pagination information. The offset and limit parameters are used to navigate the list of elements. The _links object contains URLs to navigate the different pages. +type Pagination struct { + // The offset specified in the request (if none was specified, the default offset is 0). + Offset *int32 `json:"offset"` + // The limit specified in the request (if none was specified, use the endpoint's default pagination limit). + Limit *int32 `json:"limit"` + Links *Links `json:"_links"` +} + +// NewPagination instantiates a new Pagination 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 NewPagination(offset int32, limit int32, links Links) *Pagination { + this := Pagination{} + + this.Offset = &offset + this.Limit = &limit + this.Links = &links + + return &this +} + +// NewPaginationWithDefaults instantiates a new Pagination 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 NewPaginationWithDefaults() *Pagination { + this := Pagination{} + return &this +} + +// GetOffset returns the Offset field value +// If the value is explicit nil, the zero value for int32 will be returned +func (o *Pagination) GetOffset() *int32 { + if o == nil { + return nil + } + + return o.Offset + +} + +// GetOffsetOk returns a tuple with the Offset 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 *Pagination) GetOffsetOk() (*int32, bool) { + if o == nil { + return nil, false + } + + return o.Offset, true +} + +// SetOffset sets field value +func (o *Pagination) SetOffset(v int32) { + + o.Offset = &v + +} + +// HasOffset returns a boolean if a field has been set. +func (o *Pagination) HasOffset() bool { + if o != nil && o.Offset != nil { + return true + } + + return false +} + +// GetLimit returns the Limit field value +// If the value is explicit nil, the zero value for int32 will be returned +func (o *Pagination) GetLimit() *int32 { + if o == nil { + return nil + } + + return o.Limit + +} + +// GetLimitOk returns a tuple with the Limit 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 *Pagination) GetLimitOk() (*int32, bool) { + if o == nil { + return nil, false + } + + return o.Limit, true +} + +// SetLimit sets field value +func (o *Pagination) SetLimit(v int32) { + + o.Limit = &v + +} + +// HasLimit returns a boolean if a field has been set. +func (o *Pagination) HasLimit() bool { + if o != nil && o.Limit != nil { + return true + } + + return false +} + +// GetLinks returns the Links field value +// If the value is explicit nil, the zero value for Links will be returned +func (o *Pagination) GetLinks() *Links { + if o == nil { + return nil + } + + return o.Links + +} + +// GetLinksOk returns a tuple with the Links 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 *Pagination) GetLinksOk() (*Links, bool) { + if o == nil { + return nil, false + } + + return o.Links, true +} + +// SetLinks sets field value +func (o *Pagination) SetLinks(v Links) { + + o.Links = &v + +} + +// HasLinks returns a boolean if a field has been set. +func (o *Pagination) HasLinks() bool { + if o != nil && o.Links != nil { + return true + } + + return false +} + +func (o Pagination) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.Offset != nil { + toSerialize["offset"] = o.Offset + } + + if o.Limit != nil { + toSerialize["limit"] = o.Limit + } + + if o.Links != nil { + toSerialize["_links"] = o.Links + } + + return json.Marshal(toSerialize) +} + +type NullablePagination struct { + value *Pagination + isSet bool +} + +func (v NullablePagination) Get() *Pagination { + return v.value +} + +func (v *NullablePagination) Set(val *Pagination) { + v.value = val + v.isSet = true +} + +func (v NullablePagination) IsSet() bool { + return v.isSet +} + +func (v *NullablePagination) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullablePagination(val *Pagination) *NullablePagination { + return &NullablePagination{value: val, isSet: true} +} + +func (v NullablePagination) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullablePagination) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_persistence_mode.go b/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_persistence_mode.go new file mode 100644 index 000000000..9cd6e479d --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_persistence_mode.go @@ -0,0 +1,86 @@ +/* + * In-Memory DB API + * + * API description for the IONOS In-Memory DB + * + * API version: 1.0.0 + * Contact: support@cloud.ionos.com + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package ionoscloud + +import ( + "encoding/json" + "fmt" +) + +// PersistenceMode Specifies How and If data is persisted. | Mode | Description | |-------------------------------|-------------| | **None** | Data is inMemory only and will not be persisted. Useful for cache only applications. | | **AOF** (Append Only File) | AOF persistence logs every write operation received by the server. These operations can then be replayed again at server startup, reconstructing the original dataset. Commands are logged using the same format as the In-Memory DB protocol itself. | | **RDB** | RDB persistence performs snapshots of the current in memory state. | | **RDB_AOF** | Booth, RDB and AOF persistence are enabled. | +type PersistenceMode string + +// List of PersistenceMode +const ( + PERSISTENCEMODE_NONE PersistenceMode = "None" + PERSISTENCEMODE_AOF PersistenceMode = "AOF" + PERSISTENCEMODE_RDB PersistenceMode = "RDB" + PERSISTENCEMODE_RDB_AOF PersistenceMode = "RDB_AOF" +) + +func (v *PersistenceMode) UnmarshalJSON(src []byte) error { + var value string + err := json.Unmarshal(src, &value) + if err != nil { + return err + } + enumTypeValue := PersistenceMode(value) + for _, existing := range []PersistenceMode{"None", "AOF", "RDB", "RDB_AOF"} { + if existing == enumTypeValue { + *v = enumTypeValue + return nil + } + } + + return fmt.Errorf("%+v is not a valid PersistenceMode", value) +} + +// Ptr returns reference to PersistenceMode value +func (v PersistenceMode) Ptr() *PersistenceMode { + return &v +} + +type NullablePersistenceMode struct { + value *PersistenceMode + isSet bool +} + +func (v NullablePersistenceMode) Get() *PersistenceMode { + return v.value +} + +func (v *NullablePersistenceMode) Set(val *PersistenceMode) { + v.value = val + v.isSet = true +} + +func (v NullablePersistenceMode) IsSet() bool { + return v.isSet +} + +func (v *NullablePersistenceMode) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullablePersistenceMode(val *PersistenceMode) *NullablePersistenceMode { + return &NullablePersistenceMode{value: val, isSet: true} +} + +func (v NullablePersistenceMode) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullablePersistenceMode) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_replica_set.go b/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_replica_set.go new file mode 100644 index 000000000..67fac04df --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_replica_set.go @@ -0,0 +1,527 @@ +/* + * In-Memory DB API + * + * API description for the IONOS In-Memory DB + * + * API version: 1.0.0 + * Contact: support@cloud.ionos.com + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package ionoscloud + +import ( + "encoding/json" +) + +// ReplicaSet Properties with all data needed to create a new In-Memory DB replication. +type ReplicaSet struct { + // The human readable name of your replica set. + DisplayName *string `json:"displayName"` + // The In-Memory DB version of your replica set. + Version *string `json:"version"` + // The total number of replicas in the replica set (one active and n-1 passive). In case of a standalone instance, the value is 1. In all other cases, the value is >1. The replicas will not be available as read replicas, they are only standby for a failure of the active instance. + Replicas *int32 `json:"replicas"` + Resources *Resources `json:"resources"` + PersistenceMode *PersistenceMode `json:"persistenceMode"` + EvictionPolicy *EvictionPolicy `json:"evictionPolicy"` + // The network connection for your replica set. Only one connection is allowed. + Connections *[]Connection `json:"connections"` + MaintenanceWindow *MaintenanceWindow `json:"maintenanceWindow,omitempty"` + Credentials *User `json:"credentials"` + // The ID of a snapshot to restore the replica set from. If set, the replica set will be created from the snapshot. + InitialSnapshotId *string `json:"initialSnapshotId,omitempty"` +} + +// NewReplicaSet instantiates a new ReplicaSet 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 NewReplicaSet(displayName string, version string, replicas int32, resources Resources, persistenceMode PersistenceMode, evictionPolicy EvictionPolicy, connections []Connection, credentials User) *ReplicaSet { + this := ReplicaSet{} + + this.DisplayName = &displayName + this.Version = &version + this.Replicas = &replicas + this.Resources = &resources + this.PersistenceMode = &persistenceMode + this.EvictionPolicy = &evictionPolicy + this.Connections = &connections + this.Credentials = &credentials + + return &this +} + +// NewReplicaSetWithDefaults instantiates a new ReplicaSet 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 NewReplicaSetWithDefaults() *ReplicaSet { + this := ReplicaSet{} + var persistenceMode PersistenceMode = PERSISTENCEMODE_NONE + this.PersistenceMode = &persistenceMode + var evictionPolicy EvictionPolicy = EVICTIONPOLICY_ALLKEYS_LRU + this.EvictionPolicy = &evictionPolicy + return &this +} + +// GetDisplayName returns the DisplayName field value +// If the value is explicit nil, the zero value for string will be returned +func (o *ReplicaSet) 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 *ReplicaSet) GetDisplayNameOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.DisplayName, true +} + +// SetDisplayName sets field value +func (o *ReplicaSet) SetDisplayName(v string) { + + o.DisplayName = &v + +} + +// HasDisplayName returns a boolean if a field has been set. +func (o *ReplicaSet) HasDisplayName() bool { + if o != nil && o.DisplayName != nil { + return true + } + + return false +} + +// GetVersion returns the Version field value +// If the value is explicit nil, the zero value for string will be returned +func (o *ReplicaSet) GetVersion() *string { + if o == nil { + return nil + } + + return o.Version + +} + +// GetVersionOk returns a tuple with the Version 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 *ReplicaSet) GetVersionOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.Version, true +} + +// SetVersion sets field value +func (o *ReplicaSet) SetVersion(v string) { + + o.Version = &v + +} + +// HasVersion returns a boolean if a field has been set. +func (o *ReplicaSet) HasVersion() bool { + if o != nil && o.Version != nil { + return true + } + + return false +} + +// GetReplicas returns the Replicas field value +// If the value is explicit nil, the zero value for int32 will be returned +func (o *ReplicaSet) GetReplicas() *int32 { + if o == nil { + return nil + } + + return o.Replicas + +} + +// GetReplicasOk returns a tuple with the Replicas 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 *ReplicaSet) GetReplicasOk() (*int32, bool) { + if o == nil { + return nil, false + } + + return o.Replicas, true +} + +// SetReplicas sets field value +func (o *ReplicaSet) SetReplicas(v int32) { + + o.Replicas = &v + +} + +// HasReplicas returns a boolean if a field has been set. +func (o *ReplicaSet) HasReplicas() bool { + if o != nil && o.Replicas != nil { + return true + } + + return false +} + +// GetResources returns the Resources field value +// If the value is explicit nil, the zero value for Resources will be returned +func (o *ReplicaSet) GetResources() *Resources { + if o == nil { + return nil + } + + return o.Resources + +} + +// GetResourcesOk returns a tuple with the Resources 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 *ReplicaSet) GetResourcesOk() (*Resources, bool) { + if o == nil { + return nil, false + } + + return o.Resources, true +} + +// SetResources sets field value +func (o *ReplicaSet) SetResources(v Resources) { + + o.Resources = &v + +} + +// HasResources returns a boolean if a field has been set. +func (o *ReplicaSet) HasResources() bool { + if o != nil && o.Resources != nil { + return true + } + + return false +} + +// GetPersistenceMode returns the PersistenceMode field value +// If the value is explicit nil, the zero value for PersistenceMode will be returned +func (o *ReplicaSet) GetPersistenceMode() *PersistenceMode { + if o == nil { + return nil + } + + return o.PersistenceMode + +} + +// GetPersistenceModeOk returns a tuple with the PersistenceMode 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 *ReplicaSet) GetPersistenceModeOk() (*PersistenceMode, bool) { + if o == nil { + return nil, false + } + + return o.PersistenceMode, true +} + +// SetPersistenceMode sets field value +func (o *ReplicaSet) SetPersistenceMode(v PersistenceMode) { + + o.PersistenceMode = &v + +} + +// HasPersistenceMode returns a boolean if a field has been set. +func (o *ReplicaSet) HasPersistenceMode() bool { + if o != nil && o.PersistenceMode != nil { + return true + } + + return false +} + +// GetEvictionPolicy returns the EvictionPolicy field value +// If the value is explicit nil, the zero value for EvictionPolicy will be returned +func (o *ReplicaSet) GetEvictionPolicy() *EvictionPolicy { + if o == nil { + return nil + } + + return o.EvictionPolicy + +} + +// GetEvictionPolicyOk returns a tuple with the EvictionPolicy 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 *ReplicaSet) GetEvictionPolicyOk() (*EvictionPolicy, bool) { + if o == nil { + return nil, false + } + + return o.EvictionPolicy, true +} + +// SetEvictionPolicy sets field value +func (o *ReplicaSet) SetEvictionPolicy(v EvictionPolicy) { + + o.EvictionPolicy = &v + +} + +// HasEvictionPolicy returns a boolean if a field has been set. +func (o *ReplicaSet) HasEvictionPolicy() bool { + if o != nil && o.EvictionPolicy != nil { + return true + } + + return false +} + +// GetConnections returns the Connections field value +// If the value is explicit nil, the zero value for []Connection will be returned +func (o *ReplicaSet) GetConnections() *[]Connection { + if o == nil { + return nil + } + + return o.Connections + +} + +// GetConnectionsOk returns a tuple with the Connections 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 *ReplicaSet) GetConnectionsOk() (*[]Connection, bool) { + if o == nil { + return nil, false + } + + return o.Connections, true +} + +// SetConnections sets field value +func (o *ReplicaSet) SetConnections(v []Connection) { + + o.Connections = &v + +} + +// HasConnections returns a boolean if a field has been set. +func (o *ReplicaSet) HasConnections() bool { + if o != nil && o.Connections != 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 *ReplicaSet) 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 *ReplicaSet) GetMaintenanceWindowOk() (*MaintenanceWindow, bool) { + if o == nil { + return nil, false + } + + return o.MaintenanceWindow, true +} + +// SetMaintenanceWindow sets field value +func (o *ReplicaSet) SetMaintenanceWindow(v MaintenanceWindow) { + + o.MaintenanceWindow = &v + +} + +// HasMaintenanceWindow returns a boolean if a field has been set. +func (o *ReplicaSet) HasMaintenanceWindow() bool { + if o != nil && o.MaintenanceWindow != nil { + return true + } + + return false +} + +// GetCredentials returns the Credentials field value +// If the value is explicit nil, the zero value for User will be returned +func (o *ReplicaSet) GetCredentials() *User { + if o == nil { + return nil + } + + return o.Credentials + +} + +// GetCredentialsOk returns a tuple with the Credentials 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 *ReplicaSet) GetCredentialsOk() (*User, bool) { + if o == nil { + return nil, false + } + + return o.Credentials, true +} + +// SetCredentials sets field value +func (o *ReplicaSet) SetCredentials(v User) { + + o.Credentials = &v + +} + +// HasCredentials returns a boolean if a field has been set. +func (o *ReplicaSet) HasCredentials() bool { + if o != nil && o.Credentials != nil { + return true + } + + return false +} + +// GetInitialSnapshotId returns the InitialSnapshotId field value +// If the value is explicit nil, the zero value for string will be returned +func (o *ReplicaSet) GetInitialSnapshotId() *string { + if o == nil { + return nil + } + + return o.InitialSnapshotId + +} + +// GetInitialSnapshotIdOk returns a tuple with the InitialSnapshotId 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 *ReplicaSet) GetInitialSnapshotIdOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.InitialSnapshotId, true +} + +// SetInitialSnapshotId sets field value +func (o *ReplicaSet) SetInitialSnapshotId(v string) { + + o.InitialSnapshotId = &v + +} + +// HasInitialSnapshotId returns a boolean if a field has been set. +func (o *ReplicaSet) HasInitialSnapshotId() bool { + if o != nil && o.InitialSnapshotId != nil { + return true + } + + return false +} + +func (o ReplicaSet) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.DisplayName != nil { + toSerialize["displayName"] = o.DisplayName + } + + if o.Version != nil { + toSerialize["version"] = o.Version + } + + if o.Replicas != nil { + toSerialize["replicas"] = o.Replicas + } + + if o.Resources != nil { + toSerialize["resources"] = o.Resources + } + + if o.PersistenceMode != nil { + toSerialize["persistenceMode"] = o.PersistenceMode + } + + if o.EvictionPolicy != nil { + toSerialize["evictionPolicy"] = o.EvictionPolicy + } + + if o.Connections != nil { + toSerialize["connections"] = o.Connections + } + + if o.MaintenanceWindow != nil { + toSerialize["maintenanceWindow"] = o.MaintenanceWindow + } + + if o.Credentials != nil { + toSerialize["credentials"] = o.Credentials + } + + if o.InitialSnapshotId != nil { + toSerialize["initialSnapshotId"] = o.InitialSnapshotId + } + + return json.Marshal(toSerialize) +} + +type NullableReplicaSet struct { + value *ReplicaSet + isSet bool +} + +func (v NullableReplicaSet) Get() *ReplicaSet { + return v.value +} + +func (v *NullableReplicaSet) Set(val *ReplicaSet) { + v.value = val + v.isSet = true +} + +func (v NullableReplicaSet) IsSet() bool { + return v.isSet +} + +func (v *NullableReplicaSet) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableReplicaSet(val *ReplicaSet) *NullableReplicaSet { + return &NullableReplicaSet{value: val, isSet: true} +} + +func (v NullableReplicaSet) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableReplicaSet) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_replica_set_create.go b/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_replica_set_create.go new file mode 100644 index 000000000..c977f6001 --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_replica_set_create.go @@ -0,0 +1,168 @@ +/* + * In-Memory DB API + * + * API description for the IONOS In-Memory DB + * + * API version: 1.0.0 + * Contact: support@cloud.ionos.com + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package ionoscloud + +import ( + "encoding/json" +) + +// ReplicaSetCreate struct for ReplicaSetCreate +type ReplicaSetCreate struct { + // Metadata + Metadata *map[string]interface{} `json:"metadata,omitempty"` + Properties *ReplicaSet `json:"properties"` +} + +// NewReplicaSetCreate instantiates a new ReplicaSetCreate 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 NewReplicaSetCreate(properties ReplicaSet) *ReplicaSetCreate { + this := ReplicaSetCreate{} + + this.Properties = &properties + + return &this +} + +// NewReplicaSetCreateWithDefaults instantiates a new ReplicaSetCreate 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 NewReplicaSetCreateWithDefaults() *ReplicaSetCreate { + this := ReplicaSetCreate{} + return &this +} + +// GetMetadata returns the Metadata field value +// If the value is explicit nil, the zero value for map[string]interface{} will be returned +func (o *ReplicaSetCreate) GetMetadata() *map[string]interface{} { + 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 *ReplicaSetCreate) GetMetadataOk() (*map[string]interface{}, bool) { + if o == nil { + return nil, false + } + + return o.Metadata, true +} + +// SetMetadata sets field value +func (o *ReplicaSetCreate) SetMetadata(v map[string]interface{}) { + + o.Metadata = &v + +} + +// HasMetadata returns a boolean if a field has been set. +func (o *ReplicaSetCreate) 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 ReplicaSet will be returned +func (o *ReplicaSetCreate) GetProperties() *ReplicaSet { + 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 *ReplicaSetCreate) GetPropertiesOk() (*ReplicaSet, bool) { + if o == nil { + return nil, false + } + + return o.Properties, true +} + +// SetProperties sets field value +func (o *ReplicaSetCreate) SetProperties(v ReplicaSet) { + + o.Properties = &v + +} + +// HasProperties returns a boolean if a field has been set. +func (o *ReplicaSetCreate) HasProperties() bool { + if o != nil && o.Properties != nil { + return true + } + + return false +} + +func (o ReplicaSetCreate) 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 NullableReplicaSetCreate struct { + value *ReplicaSetCreate + isSet bool +} + +func (v NullableReplicaSetCreate) Get() *ReplicaSetCreate { + return v.value +} + +func (v *NullableReplicaSetCreate) Set(val *ReplicaSetCreate) { + v.value = val + v.isSet = true +} + +func (v NullableReplicaSetCreate) IsSet() bool { + return v.isSet +} + +func (v *NullableReplicaSetCreate) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableReplicaSetCreate(val *ReplicaSetCreate) *NullableReplicaSetCreate { + return &NullableReplicaSetCreate{value: val, isSet: true} +} + +func (v NullableReplicaSetCreate) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableReplicaSetCreate) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_replica_set_ensure.go b/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_replica_set_ensure.go new file mode 100644 index 000000000..96d23ac96 --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_replica_set_ensure.go @@ -0,0 +1,213 @@ +/* + * In-Memory DB API + * + * API description for the IONOS In-Memory DB + * + * API version: 1.0.0 + * Contact: support@cloud.ionos.com + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package ionoscloud + +import ( + "encoding/json" +) + +// ReplicaSetEnsure struct for ReplicaSetEnsure +type ReplicaSetEnsure struct { + // The ID (UUID) of the ReplicaSet. + Id *string `json:"id"` + // Metadata + Metadata *map[string]interface{} `json:"metadata,omitempty"` + Properties *ReplicaSet `json:"properties"` +} + +// NewReplicaSetEnsure instantiates a new ReplicaSetEnsure 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 NewReplicaSetEnsure(id string, properties ReplicaSet) *ReplicaSetEnsure { + this := ReplicaSetEnsure{} + + this.Id = &id + this.Properties = &properties + + return &this +} + +// NewReplicaSetEnsureWithDefaults instantiates a new ReplicaSetEnsure 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 NewReplicaSetEnsureWithDefaults() *ReplicaSetEnsure { + this := ReplicaSetEnsure{} + return &this +} + +// GetId returns the Id field value +// If the value is explicit nil, the zero value for string will be returned +func (o *ReplicaSetEnsure) GetId() *string { + if o == nil { + return nil + } + + return o.Id + +} + +// GetIdOk returns a tuple with the Id 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 *ReplicaSetEnsure) GetIdOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.Id, true +} + +// SetId sets field value +func (o *ReplicaSetEnsure) SetId(v string) { + + o.Id = &v + +} + +// HasId returns a boolean if a field has been set. +func (o *ReplicaSetEnsure) HasId() bool { + if o != nil && o.Id != nil { + return true + } + + return false +} + +// GetMetadata returns the Metadata field value +// If the value is explicit nil, the zero value for map[string]interface{} will be returned +func (o *ReplicaSetEnsure) GetMetadata() *map[string]interface{} { + 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 *ReplicaSetEnsure) GetMetadataOk() (*map[string]interface{}, bool) { + if o == nil { + return nil, false + } + + return o.Metadata, true +} + +// SetMetadata sets field value +func (o *ReplicaSetEnsure) SetMetadata(v map[string]interface{}) { + + o.Metadata = &v + +} + +// HasMetadata returns a boolean if a field has been set. +func (o *ReplicaSetEnsure) 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 ReplicaSet will be returned +func (o *ReplicaSetEnsure) GetProperties() *ReplicaSet { + 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 *ReplicaSetEnsure) GetPropertiesOk() (*ReplicaSet, bool) { + if o == nil { + return nil, false + } + + return o.Properties, true +} + +// SetProperties sets field value +func (o *ReplicaSetEnsure) SetProperties(v ReplicaSet) { + + o.Properties = &v + +} + +// HasProperties returns a boolean if a field has been set. +func (o *ReplicaSetEnsure) HasProperties() bool { + if o != nil && o.Properties != nil { + return true + } + + return false +} + +func (o ReplicaSetEnsure) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.Id != nil { + toSerialize["id"] = o.Id + } + + if o.Metadata != nil { + toSerialize["metadata"] = o.Metadata + } + + if o.Properties != nil { + toSerialize["properties"] = o.Properties + } + + return json.Marshal(toSerialize) +} + +type NullableReplicaSetEnsure struct { + value *ReplicaSetEnsure + isSet bool +} + +func (v NullableReplicaSetEnsure) Get() *ReplicaSetEnsure { + return v.value +} + +func (v *NullableReplicaSetEnsure) Set(val *ReplicaSetEnsure) { + v.value = val + v.isSet = true +} + +func (v NullableReplicaSetEnsure) IsSet() bool { + return v.isSet +} + +func (v *NullableReplicaSetEnsure) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableReplicaSetEnsure(val *ReplicaSetEnsure) *NullableReplicaSetEnsure { + return &NullableReplicaSetEnsure{value: val, isSet: true} +} + +func (v NullableReplicaSetEnsure) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableReplicaSetEnsure) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_replica_set_metadata.go b/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_replica_set_metadata.go new file mode 100644 index 000000000..75a62af1e --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_replica_set_metadata.go @@ -0,0 +1,536 @@ +/* + * In-Memory DB API + * + * API description for the IONOS In-Memory DB + * + * API version: 1.0.0 + * Contact: support@cloud.ionos.com + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package ionoscloud + +import ( + "encoding/json" + "time" +) + +// ReplicaSetMetadata struct for ReplicaSetMetadata +type ReplicaSetMetadata struct { + // The ISO 8601 creation timestamp. + CreatedDate *IonosTime `json:"createdDate,omitempty"` + // Unique name of the identity that created the resource. + CreatedBy *string `json:"createdBy,omitempty"` + // Unique id of the identity that created the resource. + CreatedByUserId *string `json:"createdByUserId,omitempty"` + // The ISO 8601 modified timestamp. + LastModifiedDate *IonosTime `json:"lastModifiedDate,omitempty"` + // Unique name of the identity that last modified the resource. + LastModifiedBy *string `json:"lastModifiedBy,omitempty"` + // Unique id of the identity that last modified the resource. + LastModifiedByUserId *string `json:"lastModifiedByUserId,omitempty"` + // Unique name of the resource. + ResourceURN *string `json:"resourceURN,omitempty"` + State *string `json:"state"` + // A human readable message describing the current state. In case of an error, the message will contain a detailed error message. + Message *string `json:"message,omitempty"` + // The DNS name pointing to your replica set. Will be used to connect to the active/standalone instance. + DnsName *string `json:"dnsName"` +} + +// NewReplicaSetMetadata instantiates a new ReplicaSetMetadata 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 NewReplicaSetMetadata(state string, dnsName string) *ReplicaSetMetadata { + this := ReplicaSetMetadata{} + + this.State = &state + this.DnsName = &dnsName + + return &this +} + +// NewReplicaSetMetadataWithDefaults instantiates a new ReplicaSetMetadata 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 NewReplicaSetMetadataWithDefaults() *ReplicaSetMetadata { + this := ReplicaSetMetadata{} + return &this +} + +// GetCreatedDate returns the CreatedDate field value +// If the value is explicit nil, the zero value for time.Time will be returned +func (o *ReplicaSetMetadata) GetCreatedDate() *time.Time { + if o == nil { + return nil + } + + if o.CreatedDate == nil { + return nil + } + return &o.CreatedDate.Time + +} + +// GetCreatedDateOk returns a tuple with the CreatedDate 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 *ReplicaSetMetadata) GetCreatedDateOk() (*time.Time, bool) { + if o == nil { + return nil, false + } + + if o.CreatedDate == nil { + return nil, false + } + return &o.CreatedDate.Time, true + +} + +// SetCreatedDate sets field value +func (o *ReplicaSetMetadata) SetCreatedDate(v time.Time) { + + o.CreatedDate = &IonosTime{v} + +} + +// HasCreatedDate returns a boolean if a field has been set. +func (o *ReplicaSetMetadata) HasCreatedDate() bool { + if o != nil && o.CreatedDate != nil { + return true + } + + return false +} + +// GetCreatedBy returns the CreatedBy field value +// If the value is explicit nil, the zero value for string will be returned +func (o *ReplicaSetMetadata) GetCreatedBy() *string { + if o == nil { + return nil + } + + return o.CreatedBy + +} + +// GetCreatedByOk returns a tuple with the CreatedBy 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 *ReplicaSetMetadata) GetCreatedByOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.CreatedBy, true +} + +// SetCreatedBy sets field value +func (o *ReplicaSetMetadata) SetCreatedBy(v string) { + + o.CreatedBy = &v + +} + +// HasCreatedBy returns a boolean if a field has been set. +func (o *ReplicaSetMetadata) HasCreatedBy() bool { + if o != nil && o.CreatedBy != nil { + return true + } + + return false +} + +// GetCreatedByUserId returns the CreatedByUserId field value +// If the value is explicit nil, the zero value for string will be returned +func (o *ReplicaSetMetadata) GetCreatedByUserId() *string { + if o == nil { + return nil + } + + return o.CreatedByUserId + +} + +// GetCreatedByUserIdOk returns a tuple with the CreatedByUserId 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 *ReplicaSetMetadata) GetCreatedByUserIdOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.CreatedByUserId, true +} + +// SetCreatedByUserId sets field value +func (o *ReplicaSetMetadata) SetCreatedByUserId(v string) { + + o.CreatedByUserId = &v + +} + +// HasCreatedByUserId returns a boolean if a field has been set. +func (o *ReplicaSetMetadata) HasCreatedByUserId() bool { + if o != nil && o.CreatedByUserId != nil { + return true + } + + return false +} + +// GetLastModifiedDate returns the LastModifiedDate field value +// If the value is explicit nil, the zero value for time.Time will be returned +func (o *ReplicaSetMetadata) GetLastModifiedDate() *time.Time { + if o == nil { + return nil + } + + if o.LastModifiedDate == nil { + return nil + } + return &o.LastModifiedDate.Time + +} + +// GetLastModifiedDateOk returns a tuple with the LastModifiedDate 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 *ReplicaSetMetadata) GetLastModifiedDateOk() (*time.Time, bool) { + if o == nil { + return nil, false + } + + if o.LastModifiedDate == nil { + return nil, false + } + return &o.LastModifiedDate.Time, true + +} + +// SetLastModifiedDate sets field value +func (o *ReplicaSetMetadata) SetLastModifiedDate(v time.Time) { + + o.LastModifiedDate = &IonosTime{v} + +} + +// HasLastModifiedDate returns a boolean if a field has been set. +func (o *ReplicaSetMetadata) HasLastModifiedDate() bool { + if o != nil && o.LastModifiedDate != nil { + return true + } + + return false +} + +// GetLastModifiedBy returns the LastModifiedBy field value +// If the value is explicit nil, the zero value for string will be returned +func (o *ReplicaSetMetadata) GetLastModifiedBy() *string { + if o == nil { + return nil + } + + return o.LastModifiedBy + +} + +// GetLastModifiedByOk returns a tuple with the LastModifiedBy 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 *ReplicaSetMetadata) GetLastModifiedByOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.LastModifiedBy, true +} + +// SetLastModifiedBy sets field value +func (o *ReplicaSetMetadata) SetLastModifiedBy(v string) { + + o.LastModifiedBy = &v + +} + +// HasLastModifiedBy returns a boolean if a field has been set. +func (o *ReplicaSetMetadata) HasLastModifiedBy() bool { + if o != nil && o.LastModifiedBy != nil { + return true + } + + return false +} + +// GetLastModifiedByUserId returns the LastModifiedByUserId field value +// If the value is explicit nil, the zero value for string will be returned +func (o *ReplicaSetMetadata) GetLastModifiedByUserId() *string { + if o == nil { + return nil + } + + return o.LastModifiedByUserId + +} + +// GetLastModifiedByUserIdOk returns a tuple with the LastModifiedByUserId 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 *ReplicaSetMetadata) GetLastModifiedByUserIdOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.LastModifiedByUserId, true +} + +// SetLastModifiedByUserId sets field value +func (o *ReplicaSetMetadata) SetLastModifiedByUserId(v string) { + + o.LastModifiedByUserId = &v + +} + +// HasLastModifiedByUserId returns a boolean if a field has been set. +func (o *ReplicaSetMetadata) HasLastModifiedByUserId() bool { + if o != nil && o.LastModifiedByUserId != nil { + return true + } + + return false +} + +// GetResourceURN returns the ResourceURN field value +// If the value is explicit nil, the zero value for string will be returned +func (o *ReplicaSetMetadata) GetResourceURN() *string { + if o == nil { + return nil + } + + return o.ResourceURN + +} + +// GetResourceURNOk returns a tuple with the ResourceURN 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 *ReplicaSetMetadata) GetResourceURNOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.ResourceURN, true +} + +// SetResourceURN sets field value +func (o *ReplicaSetMetadata) SetResourceURN(v string) { + + o.ResourceURN = &v + +} + +// HasResourceURN returns a boolean if a field has been set. +func (o *ReplicaSetMetadata) HasResourceURN() bool { + if o != nil && o.ResourceURN != nil { + return true + } + + return false +} + +// GetState returns the State field value +// If the value is explicit nil, the zero value for string will be returned +func (o *ReplicaSetMetadata) GetState() *string { + if o == nil { + return nil + } + + return o.State + +} + +// GetStateOk returns a tuple with the State 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 *ReplicaSetMetadata) GetStateOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.State, true +} + +// SetState sets field value +func (o *ReplicaSetMetadata) SetState(v string) { + + o.State = &v + +} + +// HasState returns a boolean if a field has been set. +func (o *ReplicaSetMetadata) HasState() bool { + if o != nil && o.State != nil { + return true + } + + return false +} + +// GetMessage returns the Message field value +// If the value is explicit nil, the zero value for string will be returned +func (o *ReplicaSetMetadata) GetMessage() *string { + if o == nil { + return nil + } + + return o.Message + +} + +// GetMessageOk returns a tuple with the Message 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 *ReplicaSetMetadata) GetMessageOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.Message, true +} + +// SetMessage sets field value +func (o *ReplicaSetMetadata) SetMessage(v string) { + + o.Message = &v + +} + +// HasMessage returns a boolean if a field has been set. +func (o *ReplicaSetMetadata) HasMessage() bool { + if o != nil && o.Message != nil { + return true + } + + return false +} + +// GetDnsName returns the DnsName field value +// If the value is explicit nil, the zero value for string will be returned +func (o *ReplicaSetMetadata) GetDnsName() *string { + if o == nil { + return nil + } + + return o.DnsName + +} + +// GetDnsNameOk returns a tuple with the DnsName 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 *ReplicaSetMetadata) GetDnsNameOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.DnsName, true +} + +// SetDnsName sets field value +func (o *ReplicaSetMetadata) SetDnsName(v string) { + + o.DnsName = &v + +} + +// HasDnsName returns a boolean if a field has been set. +func (o *ReplicaSetMetadata) HasDnsName() bool { + if o != nil && o.DnsName != nil { + return true + } + + return false +} + +func (o ReplicaSetMetadata) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.CreatedDate != nil { + toSerialize["createdDate"] = o.CreatedDate + } + + if o.CreatedBy != nil { + toSerialize["createdBy"] = o.CreatedBy + } + + if o.CreatedByUserId != nil { + toSerialize["createdByUserId"] = o.CreatedByUserId + } + + if o.LastModifiedDate != nil { + toSerialize["lastModifiedDate"] = o.LastModifiedDate + } + + if o.LastModifiedBy != nil { + toSerialize["lastModifiedBy"] = o.LastModifiedBy + } + + if o.LastModifiedByUserId != nil { + toSerialize["lastModifiedByUserId"] = o.LastModifiedByUserId + } + + if o.ResourceURN != nil { + toSerialize["resourceURN"] = o.ResourceURN + } + + if o.State != nil { + toSerialize["state"] = o.State + } + + if o.Message != nil { + toSerialize["message"] = o.Message + } + + if o.DnsName != nil { + toSerialize["dnsName"] = o.DnsName + } + + return json.Marshal(toSerialize) +} + +type NullableReplicaSetMetadata struct { + value *ReplicaSetMetadata + isSet bool +} + +func (v NullableReplicaSetMetadata) Get() *ReplicaSetMetadata { + return v.value +} + +func (v *NullableReplicaSetMetadata) Set(val *ReplicaSetMetadata) { + v.value = val + v.isSet = true +} + +func (v NullableReplicaSetMetadata) IsSet() bool { + return v.isSet +} + +func (v *NullableReplicaSetMetadata) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableReplicaSetMetadata(val *ReplicaSetMetadata) *NullableReplicaSetMetadata { + return &NullableReplicaSetMetadata{value: val, isSet: true} +} + +func (v NullableReplicaSetMetadata) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableReplicaSetMetadata) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_replica_set_metadata_all_of.go b/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_replica_set_metadata_all_of.go new file mode 100644 index 000000000..f41d6dff0 --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_replica_set_metadata_all_of.go @@ -0,0 +1,125 @@ +/* + * In-Memory DB API + * + * API description for the IONOS In-Memory DB + * + * API version: 1.0.0 + * Contact: support@cloud.ionos.com + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package ionoscloud + +import ( + "encoding/json" +) + +// ReplicaSetMetadataAllOf struct for ReplicaSetMetadataAllOf +type ReplicaSetMetadataAllOf struct { + // The DNS name pointing to your replica set. Will be used to connect to the active/standalone instance. + DnsName *string `json:"dnsName"` +} + +// NewReplicaSetMetadataAllOf instantiates a new ReplicaSetMetadataAllOf 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 NewReplicaSetMetadataAllOf(dnsName string) *ReplicaSetMetadataAllOf { + this := ReplicaSetMetadataAllOf{} + + this.DnsName = &dnsName + + return &this +} + +// NewReplicaSetMetadataAllOfWithDefaults instantiates a new ReplicaSetMetadataAllOf 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 NewReplicaSetMetadataAllOfWithDefaults() *ReplicaSetMetadataAllOf { + this := ReplicaSetMetadataAllOf{} + return &this +} + +// GetDnsName returns the DnsName field value +// If the value is explicit nil, the zero value for string will be returned +func (o *ReplicaSetMetadataAllOf) GetDnsName() *string { + if o == nil { + return nil + } + + return o.DnsName + +} + +// GetDnsNameOk returns a tuple with the DnsName 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 *ReplicaSetMetadataAllOf) GetDnsNameOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.DnsName, true +} + +// SetDnsName sets field value +func (o *ReplicaSetMetadataAllOf) SetDnsName(v string) { + + o.DnsName = &v + +} + +// HasDnsName returns a boolean if a field has been set. +func (o *ReplicaSetMetadataAllOf) HasDnsName() bool { + if o != nil && o.DnsName != nil { + return true + } + + return false +} + +func (o ReplicaSetMetadataAllOf) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.DnsName != nil { + toSerialize["dnsName"] = o.DnsName + } + + return json.Marshal(toSerialize) +} + +type NullableReplicaSetMetadataAllOf struct { + value *ReplicaSetMetadataAllOf + isSet bool +} + +func (v NullableReplicaSetMetadataAllOf) Get() *ReplicaSetMetadataAllOf { + return v.value +} + +func (v *NullableReplicaSetMetadataAllOf) Set(val *ReplicaSetMetadataAllOf) { + v.value = val + v.isSet = true +} + +func (v NullableReplicaSetMetadataAllOf) IsSet() bool { + return v.isSet +} + +func (v *NullableReplicaSetMetadataAllOf) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableReplicaSetMetadataAllOf(val *ReplicaSetMetadataAllOf) *NullableReplicaSetMetadataAllOf { + return &NullableReplicaSetMetadataAllOf{value: val, isSet: true} +} + +func (v NullableReplicaSetMetadataAllOf) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableReplicaSetMetadataAllOf) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_replica_set_read.go b/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_replica_set_read.go new file mode 100644 index 000000000..73d23c0b8 --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_replica_set_read.go @@ -0,0 +1,303 @@ +/* + * In-Memory DB API + * + * API description for the IONOS In-Memory DB + * + * API version: 1.0.0 + * Contact: support@cloud.ionos.com + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package ionoscloud + +import ( + "encoding/json" +) + +// ReplicaSetRead struct for ReplicaSetRead +type ReplicaSetRead struct { + // The ID (UUID) of the ReplicaSet. + Id *string `json:"id"` + // The type of the resource. + Type *string `json:"type"` + // The URL of the ReplicaSet. + Href *string `json:"href"` + Metadata *ReplicaSetMetadata `json:"metadata"` + Properties *ReplicaSet `json:"properties"` +} + +// NewReplicaSetRead instantiates a new ReplicaSetRead 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 NewReplicaSetRead(id string, type_ string, href string, metadata ReplicaSetMetadata, properties ReplicaSet) *ReplicaSetRead { + this := ReplicaSetRead{} + + this.Id = &id + this.Type = &type_ + this.Href = &href + this.Metadata = &metadata + this.Properties = &properties + + return &this +} + +// NewReplicaSetReadWithDefaults instantiates a new ReplicaSetRead 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 NewReplicaSetReadWithDefaults() *ReplicaSetRead { + this := ReplicaSetRead{} + return &this +} + +// GetId returns the Id field value +// If the value is explicit nil, the zero value for string will be returned +func (o *ReplicaSetRead) GetId() *string { + if o == nil { + return nil + } + + return o.Id + +} + +// GetIdOk returns a tuple with the Id 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 *ReplicaSetRead) GetIdOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.Id, true +} + +// SetId sets field value +func (o *ReplicaSetRead) SetId(v string) { + + o.Id = &v + +} + +// HasId returns a boolean if a field has been set. +func (o *ReplicaSetRead) HasId() bool { + if o != nil && o.Id != nil { + return true + } + + return false +} + +// GetType returns the Type field value +// If the value is explicit nil, the zero value for string will be returned +func (o *ReplicaSetRead) GetType() *string { + if o == nil { + return nil + } + + return o.Type + +} + +// GetTypeOk returns a tuple with the Type 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 *ReplicaSetRead) GetTypeOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.Type, true +} + +// SetType sets field value +func (o *ReplicaSetRead) SetType(v string) { + + o.Type = &v + +} + +// HasType returns a boolean if a field has been set. +func (o *ReplicaSetRead) HasType() bool { + if o != nil && o.Type != nil { + return true + } + + return false +} + +// GetHref returns the Href field value +// If the value is explicit nil, the zero value for string will be returned +func (o *ReplicaSetRead) GetHref() *string { + if o == nil { + return nil + } + + return o.Href + +} + +// GetHrefOk returns a tuple with the Href 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 *ReplicaSetRead) GetHrefOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.Href, true +} + +// SetHref sets field value +func (o *ReplicaSetRead) SetHref(v string) { + + o.Href = &v + +} + +// HasHref returns a boolean if a field has been set. +func (o *ReplicaSetRead) HasHref() bool { + if o != nil && o.Href != nil { + return true + } + + return false +} + +// GetMetadata returns the Metadata field value +// If the value is explicit nil, the zero value for ReplicaSetMetadata will be returned +func (o *ReplicaSetRead) GetMetadata() *ReplicaSetMetadata { + 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 *ReplicaSetRead) GetMetadataOk() (*ReplicaSetMetadata, bool) { + if o == nil { + return nil, false + } + + return o.Metadata, true +} + +// SetMetadata sets field value +func (o *ReplicaSetRead) SetMetadata(v ReplicaSetMetadata) { + + o.Metadata = &v + +} + +// HasMetadata returns a boolean if a field has been set. +func (o *ReplicaSetRead) 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 ReplicaSet will be returned +func (o *ReplicaSetRead) GetProperties() *ReplicaSet { + 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 *ReplicaSetRead) GetPropertiesOk() (*ReplicaSet, bool) { + if o == nil { + return nil, false + } + + return o.Properties, true +} + +// SetProperties sets field value +func (o *ReplicaSetRead) SetProperties(v ReplicaSet) { + + o.Properties = &v + +} + +// HasProperties returns a boolean if a field has been set. +func (o *ReplicaSetRead) HasProperties() bool { + if o != nil && o.Properties != nil { + return true + } + + return false +} + +func (o ReplicaSetRead) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.Id != nil { + toSerialize["id"] = o.Id + } + + if o.Type != nil { + toSerialize["type"] = o.Type + } + + if o.Href != nil { + toSerialize["href"] = o.Href + } + + if o.Metadata != nil { + toSerialize["metadata"] = o.Metadata + } + + if o.Properties != nil { + toSerialize["properties"] = o.Properties + } + + return json.Marshal(toSerialize) +} + +type NullableReplicaSetRead struct { + value *ReplicaSetRead + isSet bool +} + +func (v NullableReplicaSetRead) Get() *ReplicaSetRead { + return v.value +} + +func (v *NullableReplicaSetRead) Set(val *ReplicaSetRead) { + v.value = val + v.isSet = true +} + +func (v NullableReplicaSetRead) IsSet() bool { + return v.isSet +} + +func (v *NullableReplicaSetRead) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableReplicaSetRead(val *ReplicaSetRead) *NullableReplicaSetRead { + return &NullableReplicaSetRead{value: val, isSet: true} +} + +func (v NullableReplicaSetRead) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableReplicaSetRead) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_replica_set_read_list.go b/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_replica_set_read_list.go new file mode 100644 index 000000000..91ef16738 --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_replica_set_read_list.go @@ -0,0 +1,393 @@ +/* + * In-Memory DB API + * + * API description for the IONOS In-Memory DB + * + * API version: 1.0.0 + * Contact: support@cloud.ionos.com + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package ionoscloud + +import ( + "encoding/json" +) + +// ReplicaSetReadList struct for ReplicaSetReadList +type ReplicaSetReadList struct { + // ID of the list of ReplicaSet resources. + Id *string `json:"id"` + // The type of the resource. + Type *string `json:"type"` + // The URL of the list of ReplicaSet resources. + Href *string `json:"href"` + // The list of ReplicaSet resources. + Items *[]ReplicaSetRead `json:"items,omitempty"` + // The offset specified in the request (if none was specified, the default offset is 0). + Offset *int32 `json:"offset"` + // The limit specified in the request (if none was specified, use the endpoint's default pagination limit). + Limit *int32 `json:"limit"` + Links *Links `json:"_links"` +} + +// NewReplicaSetReadList instantiates a new ReplicaSetReadList 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 NewReplicaSetReadList(id string, type_ string, href string, offset int32, limit int32, links Links) *ReplicaSetReadList { + this := ReplicaSetReadList{} + + this.Id = &id + this.Type = &type_ + this.Href = &href + this.Offset = &offset + this.Limit = &limit + this.Links = &links + + return &this +} + +// NewReplicaSetReadListWithDefaults instantiates a new ReplicaSetReadList 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 NewReplicaSetReadListWithDefaults() *ReplicaSetReadList { + this := ReplicaSetReadList{} + return &this +} + +// GetId returns the Id field value +// If the value is explicit nil, the zero value for string will be returned +func (o *ReplicaSetReadList) GetId() *string { + if o == nil { + return nil + } + + return o.Id + +} + +// GetIdOk returns a tuple with the Id 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 *ReplicaSetReadList) GetIdOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.Id, true +} + +// SetId sets field value +func (o *ReplicaSetReadList) SetId(v string) { + + o.Id = &v + +} + +// HasId returns a boolean if a field has been set. +func (o *ReplicaSetReadList) HasId() bool { + if o != nil && o.Id != nil { + return true + } + + return false +} + +// GetType returns the Type field value +// If the value is explicit nil, the zero value for string will be returned +func (o *ReplicaSetReadList) GetType() *string { + if o == nil { + return nil + } + + return o.Type + +} + +// GetTypeOk returns a tuple with the Type 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 *ReplicaSetReadList) GetTypeOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.Type, true +} + +// SetType sets field value +func (o *ReplicaSetReadList) SetType(v string) { + + o.Type = &v + +} + +// HasType returns a boolean if a field has been set. +func (o *ReplicaSetReadList) HasType() bool { + if o != nil && o.Type != nil { + return true + } + + return false +} + +// GetHref returns the Href field value +// If the value is explicit nil, the zero value for string will be returned +func (o *ReplicaSetReadList) GetHref() *string { + if o == nil { + return nil + } + + return o.Href + +} + +// GetHrefOk returns a tuple with the Href 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 *ReplicaSetReadList) GetHrefOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.Href, true +} + +// SetHref sets field value +func (o *ReplicaSetReadList) SetHref(v string) { + + o.Href = &v + +} + +// HasHref returns a boolean if a field has been set. +func (o *ReplicaSetReadList) HasHref() bool { + if o != nil && o.Href != nil { + return true + } + + return false +} + +// GetItems returns the Items field value +// If the value is explicit nil, the zero value for []ReplicaSetRead will be returned +func (o *ReplicaSetReadList) GetItems() *[]ReplicaSetRead { + if o == nil { + return nil + } + + return o.Items + +} + +// GetItemsOk returns a tuple with the Items 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 *ReplicaSetReadList) GetItemsOk() (*[]ReplicaSetRead, bool) { + if o == nil { + return nil, false + } + + return o.Items, true +} + +// SetItems sets field value +func (o *ReplicaSetReadList) SetItems(v []ReplicaSetRead) { + + o.Items = &v + +} + +// HasItems returns a boolean if a field has been set. +func (o *ReplicaSetReadList) HasItems() bool { + if o != nil && o.Items != nil { + return true + } + + return false +} + +// GetOffset returns the Offset field value +// If the value is explicit nil, the zero value for int32 will be returned +func (o *ReplicaSetReadList) GetOffset() *int32 { + if o == nil { + return nil + } + + return o.Offset + +} + +// GetOffsetOk returns a tuple with the Offset 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 *ReplicaSetReadList) GetOffsetOk() (*int32, bool) { + if o == nil { + return nil, false + } + + return o.Offset, true +} + +// SetOffset sets field value +func (o *ReplicaSetReadList) SetOffset(v int32) { + + o.Offset = &v + +} + +// HasOffset returns a boolean if a field has been set. +func (o *ReplicaSetReadList) HasOffset() bool { + if o != nil && o.Offset != nil { + return true + } + + return false +} + +// GetLimit returns the Limit field value +// If the value is explicit nil, the zero value for int32 will be returned +func (o *ReplicaSetReadList) GetLimit() *int32 { + if o == nil { + return nil + } + + return o.Limit + +} + +// GetLimitOk returns a tuple with the Limit 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 *ReplicaSetReadList) GetLimitOk() (*int32, bool) { + if o == nil { + return nil, false + } + + return o.Limit, true +} + +// SetLimit sets field value +func (o *ReplicaSetReadList) SetLimit(v int32) { + + o.Limit = &v + +} + +// HasLimit returns a boolean if a field has been set. +func (o *ReplicaSetReadList) HasLimit() bool { + if o != nil && o.Limit != nil { + return true + } + + return false +} + +// GetLinks returns the Links field value +// If the value is explicit nil, the zero value for Links will be returned +func (o *ReplicaSetReadList) GetLinks() *Links { + if o == nil { + return nil + } + + return o.Links + +} + +// GetLinksOk returns a tuple with the Links 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 *ReplicaSetReadList) GetLinksOk() (*Links, bool) { + if o == nil { + return nil, false + } + + return o.Links, true +} + +// SetLinks sets field value +func (o *ReplicaSetReadList) SetLinks(v Links) { + + o.Links = &v + +} + +// HasLinks returns a boolean if a field has been set. +func (o *ReplicaSetReadList) HasLinks() bool { + if o != nil && o.Links != nil { + return true + } + + return false +} + +func (o ReplicaSetReadList) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.Id != nil { + toSerialize["id"] = o.Id + } + + if o.Type != nil { + toSerialize["type"] = o.Type + } + + if o.Href != nil { + toSerialize["href"] = o.Href + } + + if o.Items != nil { + toSerialize["items"] = o.Items + } + + if o.Offset != nil { + toSerialize["offset"] = o.Offset + } + + if o.Limit != nil { + toSerialize["limit"] = o.Limit + } + + if o.Links != nil { + toSerialize["_links"] = o.Links + } + + return json.Marshal(toSerialize) +} + +type NullableReplicaSetReadList struct { + value *ReplicaSetReadList + isSet bool +} + +func (v NullableReplicaSetReadList) Get() *ReplicaSetReadList { + return v.value +} + +func (v *NullableReplicaSetReadList) Set(val *ReplicaSetReadList) { + v.value = val + v.isSet = true +} + +func (v NullableReplicaSetReadList) IsSet() bool { + return v.isSet +} + +func (v *NullableReplicaSetReadList) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableReplicaSetReadList(val *ReplicaSetReadList) *NullableReplicaSetReadList { + return &NullableReplicaSetReadList{value: val, isSet: true} +} + +func (v NullableReplicaSetReadList) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableReplicaSetReadList) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_replica_set_read_list_all_of.go b/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_replica_set_read_list_all_of.go new file mode 100644 index 000000000..d276ee1d8 --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_replica_set_read_list_all_of.go @@ -0,0 +1,259 @@ +/* + * In-Memory DB API + * + * API description for the IONOS In-Memory DB + * + * API version: 1.0.0 + * Contact: support@cloud.ionos.com + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package ionoscloud + +import ( + "encoding/json" +) + +// ReplicaSetReadListAllOf struct for ReplicaSetReadListAllOf +type ReplicaSetReadListAllOf struct { + // ID of the list of ReplicaSet resources. + Id *string `json:"id"` + // The type of the resource. + Type *string `json:"type"` + // The URL of the list of ReplicaSet resources. + Href *string `json:"href"` + // The list of ReplicaSet resources. + Items *[]ReplicaSetRead `json:"items,omitempty"` +} + +// NewReplicaSetReadListAllOf instantiates a new ReplicaSetReadListAllOf 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 NewReplicaSetReadListAllOf(id string, type_ string, href string) *ReplicaSetReadListAllOf { + this := ReplicaSetReadListAllOf{} + + this.Id = &id + this.Type = &type_ + this.Href = &href + + return &this +} + +// NewReplicaSetReadListAllOfWithDefaults instantiates a new ReplicaSetReadListAllOf 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 NewReplicaSetReadListAllOfWithDefaults() *ReplicaSetReadListAllOf { + this := ReplicaSetReadListAllOf{} + return &this +} + +// GetId returns the Id field value +// If the value is explicit nil, the zero value for string will be returned +func (o *ReplicaSetReadListAllOf) GetId() *string { + if o == nil { + return nil + } + + return o.Id + +} + +// GetIdOk returns a tuple with the Id 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 *ReplicaSetReadListAllOf) GetIdOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.Id, true +} + +// SetId sets field value +func (o *ReplicaSetReadListAllOf) SetId(v string) { + + o.Id = &v + +} + +// HasId returns a boolean if a field has been set. +func (o *ReplicaSetReadListAllOf) HasId() bool { + if o != nil && o.Id != nil { + return true + } + + return false +} + +// GetType returns the Type field value +// If the value is explicit nil, the zero value for string will be returned +func (o *ReplicaSetReadListAllOf) GetType() *string { + if o == nil { + return nil + } + + return o.Type + +} + +// GetTypeOk returns a tuple with the Type 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 *ReplicaSetReadListAllOf) GetTypeOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.Type, true +} + +// SetType sets field value +func (o *ReplicaSetReadListAllOf) SetType(v string) { + + o.Type = &v + +} + +// HasType returns a boolean if a field has been set. +func (o *ReplicaSetReadListAllOf) HasType() bool { + if o != nil && o.Type != nil { + return true + } + + return false +} + +// GetHref returns the Href field value +// If the value is explicit nil, the zero value for string will be returned +func (o *ReplicaSetReadListAllOf) GetHref() *string { + if o == nil { + return nil + } + + return o.Href + +} + +// GetHrefOk returns a tuple with the Href 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 *ReplicaSetReadListAllOf) GetHrefOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.Href, true +} + +// SetHref sets field value +func (o *ReplicaSetReadListAllOf) SetHref(v string) { + + o.Href = &v + +} + +// HasHref returns a boolean if a field has been set. +func (o *ReplicaSetReadListAllOf) HasHref() bool { + if o != nil && o.Href != nil { + return true + } + + return false +} + +// GetItems returns the Items field value +// If the value is explicit nil, the zero value for []ReplicaSetRead will be returned +func (o *ReplicaSetReadListAllOf) GetItems() *[]ReplicaSetRead { + if o == nil { + return nil + } + + return o.Items + +} + +// GetItemsOk returns a tuple with the Items 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 *ReplicaSetReadListAllOf) GetItemsOk() (*[]ReplicaSetRead, bool) { + if o == nil { + return nil, false + } + + return o.Items, true +} + +// SetItems sets field value +func (o *ReplicaSetReadListAllOf) SetItems(v []ReplicaSetRead) { + + o.Items = &v + +} + +// HasItems returns a boolean if a field has been set. +func (o *ReplicaSetReadListAllOf) HasItems() bool { + if o != nil && o.Items != nil { + return true + } + + return false +} + +func (o ReplicaSetReadListAllOf) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.Id != nil { + toSerialize["id"] = o.Id + } + + if o.Type != nil { + toSerialize["type"] = o.Type + } + + if o.Href != nil { + toSerialize["href"] = o.Href + } + + if o.Items != nil { + toSerialize["items"] = o.Items + } + + return json.Marshal(toSerialize) +} + +type NullableReplicaSetReadListAllOf struct { + value *ReplicaSetReadListAllOf + isSet bool +} + +func (v NullableReplicaSetReadListAllOf) Get() *ReplicaSetReadListAllOf { + return v.value +} + +func (v *NullableReplicaSetReadListAllOf) Set(val *ReplicaSetReadListAllOf) { + v.value = val + v.isSet = true +} + +func (v NullableReplicaSetReadListAllOf) IsSet() bool { + return v.isSet +} + +func (v *NullableReplicaSetReadListAllOf) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableReplicaSetReadListAllOf(val *ReplicaSetReadListAllOf) *NullableReplicaSetReadListAllOf { + return &NullableReplicaSetReadListAllOf{value: val, isSet: true} +} + +func (v NullableReplicaSetReadListAllOf) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableReplicaSetReadListAllOf) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_resource_state.go b/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_resource_state.go new file mode 100644 index 000000000..96d3d76d4 --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_resource_state.go @@ -0,0 +1,168 @@ +/* + * In-Memory DB API + * + * API description for the IONOS In-Memory DB + * + * API version: 1.0.0 + * Contact: support@cloud.ionos.com + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package ionoscloud + +import ( + "encoding/json" +) + +// ResourceState The current status of the resource. +type ResourceState struct { + State *string `json:"state"` + // A human readable message describing the current state. In case of an error, the message will contain a detailed error message. + Message *string `json:"message,omitempty"` +} + +// NewResourceState instantiates a new ResourceState 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 NewResourceState(state string) *ResourceState { + this := ResourceState{} + + this.State = &state + + return &this +} + +// NewResourceStateWithDefaults instantiates a new ResourceState 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 NewResourceStateWithDefaults() *ResourceState { + this := ResourceState{} + return &this +} + +// GetState returns the State field value +// If the value is explicit nil, the zero value for string will be returned +func (o *ResourceState) GetState() *string { + if o == nil { + return nil + } + + return o.State + +} + +// GetStateOk returns a tuple with the State 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 *ResourceState) GetStateOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.State, true +} + +// SetState sets field value +func (o *ResourceState) SetState(v string) { + + o.State = &v + +} + +// HasState returns a boolean if a field has been set. +func (o *ResourceState) HasState() bool { + if o != nil && o.State != nil { + return true + } + + return false +} + +// GetMessage returns the Message field value +// If the value is explicit nil, the zero value for string will be returned +func (o *ResourceState) GetMessage() *string { + if o == nil { + return nil + } + + return o.Message + +} + +// GetMessageOk returns a tuple with the Message 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 *ResourceState) GetMessageOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.Message, true +} + +// SetMessage sets field value +func (o *ResourceState) SetMessage(v string) { + + o.Message = &v + +} + +// HasMessage returns a boolean if a field has been set. +func (o *ResourceState) HasMessage() bool { + if o != nil && o.Message != nil { + return true + } + + return false +} + +func (o ResourceState) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.State != nil { + toSerialize["state"] = o.State + } + + if o.Message != nil { + toSerialize["message"] = o.Message + } + + return json.Marshal(toSerialize) +} + +type NullableResourceState struct { + value *ResourceState + isSet bool +} + +func (v NullableResourceState) Get() *ResourceState { + return v.value +} + +func (v *NullableResourceState) Set(val *ResourceState) { + v.value = val + v.isSet = true +} + +func (v NullableResourceState) IsSet() bool { + return v.isSet +} + +func (v *NullableResourceState) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableResourceState(val *ResourceState) *NullableResourceState { + return &NullableResourceState{value: val, isSet: true} +} + +func (v NullableResourceState) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableResourceState) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_resources.go b/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_resources.go new file mode 100644 index 000000000..4da25872a --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_resources.go @@ -0,0 +1,215 @@ +/* + * In-Memory DB API + * + * API description for the IONOS In-Memory DB + * + * API version: 1.0.0 + * Contact: support@cloud.ionos.com + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package ionoscloud + +import ( + "encoding/json" +) + +// Resources The resources of the individual replicas. +type Resources struct { + // The number of CPU cores per instance. + Cores *int32 `json:"cores"` + // The amount of memory per instance in gigabytes (GB). + Ram *int32 `json:"ram"` + // The size of the storage in GB. The size is derived from the amount of RAM and the persistence mode and is not configurable. + Storage *int32 `json:"storage"` +} + +// NewResources instantiates a new Resources 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 NewResources(cores int32, ram int32, storage int32) *Resources { + this := Resources{} + + this.Cores = &cores + this.Ram = &ram + this.Storage = &storage + + return &this +} + +// NewResourcesWithDefaults instantiates a new Resources 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 NewResourcesWithDefaults() *Resources { + this := Resources{} + return &this +} + +// GetCores returns the Cores field value +// If the value is explicit nil, the zero value for int32 will be returned +func (o *Resources) 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 *Resources) GetCoresOk() (*int32, bool) { + if o == nil { + return nil, false + } + + return o.Cores, true +} + +// SetCores sets field value +func (o *Resources) SetCores(v int32) { + + o.Cores = &v + +} + +// HasCores returns a boolean if a field has been set. +func (o *Resources) 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 *Resources) 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 *Resources) GetRamOk() (*int32, bool) { + if o == nil { + return nil, false + } + + return o.Ram, true +} + +// SetRam sets field value +func (o *Resources) SetRam(v int32) { + + o.Ram = &v + +} + +// HasRam returns a boolean if a field has been set. +func (o *Resources) HasRam() bool { + if o != nil && o.Ram != nil { + return true + } + + return false +} + +// GetStorage returns the Storage field value +// If the value is explicit nil, the zero value for int32 will be returned +func (o *Resources) GetStorage() *int32 { + if o == nil { + return nil + } + + return o.Storage + +} + +// GetStorageOk returns a tuple with the Storage 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 *Resources) GetStorageOk() (*int32, bool) { + if o == nil { + return nil, false + } + + return o.Storage, true +} + +// SetStorage sets field value +func (o *Resources) SetStorage(v int32) { + + o.Storage = &v + +} + +// HasStorage returns a boolean if a field has been set. +func (o *Resources) HasStorage() bool { + if o != nil && o.Storage != nil { + return true + } + + return false +} + +func (o Resources) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.Cores != nil { + toSerialize["cores"] = o.Cores + } + + if o.Ram != nil { + toSerialize["ram"] = o.Ram + } + + if o.Storage != nil { + toSerialize["storage"] = o.Storage + } + + return json.Marshal(toSerialize) +} + +type NullableResources struct { + value *Resources + isSet bool +} + +func (v NullableResources) Get() *Resources { + return v.value +} + +func (v *NullableResources) Set(val *Resources) { + v.value = val + v.isSet = true +} + +func (v NullableResources) IsSet() bool { + return v.isSet +} + +func (v *NullableResources) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableResources(val *Resources) *NullableResources { + return &NullableResources{value: val, isSet: true} +} + +func (v NullableResources) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableResources) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_restore.go b/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_restore.go new file mode 100644 index 000000000..6e77ea1c4 --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_restore.go @@ -0,0 +1,213 @@ +/* + * In-Memory DB API + * + * API description for the IONOS In-Memory DB + * + * API version: 1.0.0 + * Contact: support@cloud.ionos.com + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package ionoscloud + +import ( + "encoding/json" +) + +// Restore A point in time snapshot of a In-Memory DB replica set. +type Restore struct { + // The ID of the replica set the restore was applied on. + ReplicasetId *string `json:"replicasetId"` + // The human readable name of your snapshot. + DisplayName *string `json:"displayName,omitempty"` + // A description of the snapshot. + Description *string `json:"description,omitempty"` +} + +// NewRestore instantiates a new Restore 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 NewRestore(replicasetId string) *Restore { + this := Restore{} + + this.ReplicasetId = &replicasetId + + return &this +} + +// NewRestoreWithDefaults instantiates a new Restore 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 NewRestoreWithDefaults() *Restore { + this := Restore{} + return &this +} + +// GetReplicasetId returns the ReplicasetId field value +// If the value is explicit nil, the zero value for string will be returned +func (o *Restore) GetReplicasetId() *string { + if o == nil { + return nil + } + + return o.ReplicasetId + +} + +// GetReplicasetIdOk returns a tuple with the ReplicasetId 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 *Restore) GetReplicasetIdOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.ReplicasetId, true +} + +// SetReplicasetId sets field value +func (o *Restore) SetReplicasetId(v string) { + + o.ReplicasetId = &v + +} + +// HasReplicasetId returns a boolean if a field has been set. +func (o *Restore) HasReplicasetId() bool { + if o != nil && o.ReplicasetId != 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 *Restore) 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 *Restore) GetDisplayNameOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.DisplayName, true +} + +// SetDisplayName sets field value +func (o *Restore) SetDisplayName(v string) { + + o.DisplayName = &v + +} + +// HasDisplayName returns a boolean if a field has been set. +func (o *Restore) HasDisplayName() bool { + if o != nil && o.DisplayName != nil { + return true + } + + return false +} + +// GetDescription returns the Description field value +// If the value is explicit nil, the zero value for string will be returned +func (o *Restore) GetDescription() *string { + if o == nil { + return nil + } + + return o.Description + +} + +// GetDescriptionOk returns a tuple with the Description 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 *Restore) GetDescriptionOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.Description, true +} + +// SetDescription sets field value +func (o *Restore) SetDescription(v string) { + + o.Description = &v + +} + +// HasDescription returns a boolean if a field has been set. +func (o *Restore) HasDescription() bool { + if o != nil && o.Description != nil { + return true + } + + return false +} + +func (o Restore) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.ReplicasetId != nil { + toSerialize["replicasetId"] = o.ReplicasetId + } + + if o.DisplayName != nil { + toSerialize["displayName"] = o.DisplayName + } + + if o.Description != nil { + toSerialize["description"] = o.Description + } + + return json.Marshal(toSerialize) +} + +type NullableRestore struct { + value *Restore + isSet bool +} + +func (v NullableRestore) Get() *Restore { + return v.value +} + +func (v *NullableRestore) Set(val *Restore) { + v.value = val + v.isSet = true +} + +func (v NullableRestore) IsSet() bool { + return v.isSet +} + +func (v *NullableRestore) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableRestore(val *Restore) *NullableRestore { + return &NullableRestore{value: val, isSet: true} +} + +func (v NullableRestore) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableRestore) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_restore_create.go b/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_restore_create.go new file mode 100644 index 000000000..494793066 --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_restore_create.go @@ -0,0 +1,168 @@ +/* + * In-Memory DB API + * + * API description for the IONOS In-Memory DB + * + * API version: 1.0.0 + * Contact: support@cloud.ionos.com + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package ionoscloud + +import ( + "encoding/json" +) + +// RestoreCreate struct for RestoreCreate +type RestoreCreate struct { + // Metadata + Metadata *map[string]interface{} `json:"metadata,omitempty"` + Properties *Restore `json:"properties"` +} + +// NewRestoreCreate instantiates a new RestoreCreate 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 NewRestoreCreate(properties Restore) *RestoreCreate { + this := RestoreCreate{} + + this.Properties = &properties + + return &this +} + +// NewRestoreCreateWithDefaults instantiates a new RestoreCreate 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 NewRestoreCreateWithDefaults() *RestoreCreate { + this := RestoreCreate{} + return &this +} + +// GetMetadata returns the Metadata field value +// If the value is explicit nil, the zero value for map[string]interface{} will be returned +func (o *RestoreCreate) GetMetadata() *map[string]interface{} { + 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 *RestoreCreate) GetMetadataOk() (*map[string]interface{}, bool) { + if o == nil { + return nil, false + } + + return o.Metadata, true +} + +// SetMetadata sets field value +func (o *RestoreCreate) SetMetadata(v map[string]interface{}) { + + o.Metadata = &v + +} + +// HasMetadata returns a boolean if a field has been set. +func (o *RestoreCreate) 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 Restore will be returned +func (o *RestoreCreate) GetProperties() *Restore { + 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 *RestoreCreate) GetPropertiesOk() (*Restore, bool) { + if o == nil { + return nil, false + } + + return o.Properties, true +} + +// SetProperties sets field value +func (o *RestoreCreate) SetProperties(v Restore) { + + o.Properties = &v + +} + +// HasProperties returns a boolean if a field has been set. +func (o *RestoreCreate) HasProperties() bool { + if o != nil && o.Properties != nil { + return true + } + + return false +} + +func (o RestoreCreate) 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 NullableRestoreCreate struct { + value *RestoreCreate + isSet bool +} + +func (v NullableRestoreCreate) Get() *RestoreCreate { + return v.value +} + +func (v *NullableRestoreCreate) Set(val *RestoreCreate) { + v.value = val + v.isSet = true +} + +func (v NullableRestoreCreate) IsSet() bool { + return v.isSet +} + +func (v *NullableRestoreCreate) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableRestoreCreate(val *RestoreCreate) *NullableRestoreCreate { + return &NullableRestoreCreate{value: val, isSet: true} +} + +func (v NullableRestoreCreate) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableRestoreCreate) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_restore_metadata.go b/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_restore_metadata.go new file mode 100644 index 000000000..122a1c1a4 --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_restore_metadata.go @@ -0,0 +1,586 @@ +/* + * In-Memory DB API + * + * API description for the IONOS In-Memory DB + * + * API version: 1.0.0 + * Contact: support@cloud.ionos.com + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package ionoscloud + +import ( + "encoding/json" + "time" +) + +// RestoreMetadata struct for RestoreMetadata +type RestoreMetadata struct { + // The ISO 8601 creation timestamp. + CreatedDate *IonosTime `json:"createdDate,omitempty"` + // Unique name of the identity that created the resource. + CreatedBy *string `json:"createdBy,omitempty"` + // Unique id of the identity that created the resource. + CreatedByUserId *string `json:"createdByUserId,omitempty"` + // The ISO 8601 modified timestamp. + LastModifiedDate *IonosTime `json:"lastModifiedDate,omitempty"` + // Unique name of the identity that last modified the resource. + LastModifiedBy *string `json:"lastModifiedBy,omitempty"` + // Unique id of the identity that last modified the resource. + LastModifiedByUserId *string `json:"lastModifiedByUserId,omitempty"` + // Unique name of the resource. + ResourceURN *string `json:"resourceURN,omitempty"` + State *string `json:"state"` + // A human readable message describing the current state. In case of an error, the message will contain a detailed error message. + Message *string `json:"message,omitempty"` + // The time the snapshot was dumped from the replica set. + RestoreTime *IonosTime `json:"restoreTime,omitempty"` + // The ID of the snapshot that was restored. + RestoredSnapshotId *string `json:"restoredSnapshotId,omitempty"` +} + +// NewRestoreMetadata instantiates a new RestoreMetadata 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 NewRestoreMetadata(state string) *RestoreMetadata { + this := RestoreMetadata{} + + this.State = &state + + return &this +} + +// NewRestoreMetadataWithDefaults instantiates a new RestoreMetadata 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 NewRestoreMetadataWithDefaults() *RestoreMetadata { + this := RestoreMetadata{} + return &this +} + +// GetCreatedDate returns the CreatedDate field value +// If the value is explicit nil, the zero value for time.Time will be returned +func (o *RestoreMetadata) GetCreatedDate() *time.Time { + if o == nil { + return nil + } + + if o.CreatedDate == nil { + return nil + } + return &o.CreatedDate.Time + +} + +// GetCreatedDateOk returns a tuple with the CreatedDate 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 *RestoreMetadata) GetCreatedDateOk() (*time.Time, bool) { + if o == nil { + return nil, false + } + + if o.CreatedDate == nil { + return nil, false + } + return &o.CreatedDate.Time, true + +} + +// SetCreatedDate sets field value +func (o *RestoreMetadata) SetCreatedDate(v time.Time) { + + o.CreatedDate = &IonosTime{v} + +} + +// HasCreatedDate returns a boolean if a field has been set. +func (o *RestoreMetadata) HasCreatedDate() bool { + if o != nil && o.CreatedDate != nil { + return true + } + + return false +} + +// GetCreatedBy returns the CreatedBy field value +// If the value is explicit nil, the zero value for string will be returned +func (o *RestoreMetadata) GetCreatedBy() *string { + if o == nil { + return nil + } + + return o.CreatedBy + +} + +// GetCreatedByOk returns a tuple with the CreatedBy 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 *RestoreMetadata) GetCreatedByOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.CreatedBy, true +} + +// SetCreatedBy sets field value +func (o *RestoreMetadata) SetCreatedBy(v string) { + + o.CreatedBy = &v + +} + +// HasCreatedBy returns a boolean if a field has been set. +func (o *RestoreMetadata) HasCreatedBy() bool { + if o != nil && o.CreatedBy != nil { + return true + } + + return false +} + +// GetCreatedByUserId returns the CreatedByUserId field value +// If the value is explicit nil, the zero value for string will be returned +func (o *RestoreMetadata) GetCreatedByUserId() *string { + if o == nil { + return nil + } + + return o.CreatedByUserId + +} + +// GetCreatedByUserIdOk returns a tuple with the CreatedByUserId 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 *RestoreMetadata) GetCreatedByUserIdOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.CreatedByUserId, true +} + +// SetCreatedByUserId sets field value +func (o *RestoreMetadata) SetCreatedByUserId(v string) { + + o.CreatedByUserId = &v + +} + +// HasCreatedByUserId returns a boolean if a field has been set. +func (o *RestoreMetadata) HasCreatedByUserId() bool { + if o != nil && o.CreatedByUserId != nil { + return true + } + + return false +} + +// GetLastModifiedDate returns the LastModifiedDate field value +// If the value is explicit nil, the zero value for time.Time will be returned +func (o *RestoreMetadata) GetLastModifiedDate() *time.Time { + if o == nil { + return nil + } + + if o.LastModifiedDate == nil { + return nil + } + return &o.LastModifiedDate.Time + +} + +// GetLastModifiedDateOk returns a tuple with the LastModifiedDate 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 *RestoreMetadata) GetLastModifiedDateOk() (*time.Time, bool) { + if o == nil { + return nil, false + } + + if o.LastModifiedDate == nil { + return nil, false + } + return &o.LastModifiedDate.Time, true + +} + +// SetLastModifiedDate sets field value +func (o *RestoreMetadata) SetLastModifiedDate(v time.Time) { + + o.LastModifiedDate = &IonosTime{v} + +} + +// HasLastModifiedDate returns a boolean if a field has been set. +func (o *RestoreMetadata) HasLastModifiedDate() bool { + if o != nil && o.LastModifiedDate != nil { + return true + } + + return false +} + +// GetLastModifiedBy returns the LastModifiedBy field value +// If the value is explicit nil, the zero value for string will be returned +func (o *RestoreMetadata) GetLastModifiedBy() *string { + if o == nil { + return nil + } + + return o.LastModifiedBy + +} + +// GetLastModifiedByOk returns a tuple with the LastModifiedBy 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 *RestoreMetadata) GetLastModifiedByOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.LastModifiedBy, true +} + +// SetLastModifiedBy sets field value +func (o *RestoreMetadata) SetLastModifiedBy(v string) { + + o.LastModifiedBy = &v + +} + +// HasLastModifiedBy returns a boolean if a field has been set. +func (o *RestoreMetadata) HasLastModifiedBy() bool { + if o != nil && o.LastModifiedBy != nil { + return true + } + + return false +} + +// GetLastModifiedByUserId returns the LastModifiedByUserId field value +// If the value is explicit nil, the zero value for string will be returned +func (o *RestoreMetadata) GetLastModifiedByUserId() *string { + if o == nil { + return nil + } + + return o.LastModifiedByUserId + +} + +// GetLastModifiedByUserIdOk returns a tuple with the LastModifiedByUserId 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 *RestoreMetadata) GetLastModifiedByUserIdOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.LastModifiedByUserId, true +} + +// SetLastModifiedByUserId sets field value +func (o *RestoreMetadata) SetLastModifiedByUserId(v string) { + + o.LastModifiedByUserId = &v + +} + +// HasLastModifiedByUserId returns a boolean if a field has been set. +func (o *RestoreMetadata) HasLastModifiedByUserId() bool { + if o != nil && o.LastModifiedByUserId != nil { + return true + } + + return false +} + +// GetResourceURN returns the ResourceURN field value +// If the value is explicit nil, the zero value for string will be returned +func (o *RestoreMetadata) GetResourceURN() *string { + if o == nil { + return nil + } + + return o.ResourceURN + +} + +// GetResourceURNOk returns a tuple with the ResourceURN 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 *RestoreMetadata) GetResourceURNOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.ResourceURN, true +} + +// SetResourceURN sets field value +func (o *RestoreMetadata) SetResourceURN(v string) { + + o.ResourceURN = &v + +} + +// HasResourceURN returns a boolean if a field has been set. +func (o *RestoreMetadata) HasResourceURN() bool { + if o != nil && o.ResourceURN != nil { + return true + } + + return false +} + +// GetState returns the State field value +// If the value is explicit nil, the zero value for string will be returned +func (o *RestoreMetadata) GetState() *string { + if o == nil { + return nil + } + + return o.State + +} + +// GetStateOk returns a tuple with the State 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 *RestoreMetadata) GetStateOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.State, true +} + +// SetState sets field value +func (o *RestoreMetadata) SetState(v string) { + + o.State = &v + +} + +// HasState returns a boolean if a field has been set. +func (o *RestoreMetadata) HasState() bool { + if o != nil && o.State != nil { + return true + } + + return false +} + +// GetMessage returns the Message field value +// If the value is explicit nil, the zero value for string will be returned +func (o *RestoreMetadata) GetMessage() *string { + if o == nil { + return nil + } + + return o.Message + +} + +// GetMessageOk returns a tuple with the Message 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 *RestoreMetadata) GetMessageOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.Message, true +} + +// SetMessage sets field value +func (o *RestoreMetadata) SetMessage(v string) { + + o.Message = &v + +} + +// HasMessage returns a boolean if a field has been set. +func (o *RestoreMetadata) HasMessage() bool { + if o != nil && o.Message != nil { + return true + } + + return false +} + +// GetRestoreTime returns the RestoreTime field value +// If the value is explicit nil, the zero value for time.Time will be returned +func (o *RestoreMetadata) GetRestoreTime() *time.Time { + if o == nil { + return nil + } + + if o.RestoreTime == nil { + return nil + } + return &o.RestoreTime.Time + +} + +// GetRestoreTimeOk returns a tuple with the RestoreTime 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 *RestoreMetadata) GetRestoreTimeOk() (*time.Time, bool) { + if o == nil { + return nil, false + } + + if o.RestoreTime == nil { + return nil, false + } + return &o.RestoreTime.Time, true + +} + +// SetRestoreTime sets field value +func (o *RestoreMetadata) SetRestoreTime(v time.Time) { + + o.RestoreTime = &IonosTime{v} + +} + +// HasRestoreTime returns a boolean if a field has been set. +func (o *RestoreMetadata) HasRestoreTime() bool { + if o != nil && o.RestoreTime != nil { + return true + } + + return false +} + +// GetRestoredSnapshotId returns the RestoredSnapshotId field value +// If the value is explicit nil, the zero value for string will be returned +func (o *RestoreMetadata) GetRestoredSnapshotId() *string { + if o == nil { + return nil + } + + return o.RestoredSnapshotId + +} + +// GetRestoredSnapshotIdOk returns a tuple with the RestoredSnapshotId 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 *RestoreMetadata) GetRestoredSnapshotIdOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.RestoredSnapshotId, true +} + +// SetRestoredSnapshotId sets field value +func (o *RestoreMetadata) SetRestoredSnapshotId(v string) { + + o.RestoredSnapshotId = &v + +} + +// HasRestoredSnapshotId returns a boolean if a field has been set. +func (o *RestoreMetadata) HasRestoredSnapshotId() bool { + if o != nil && o.RestoredSnapshotId != nil { + return true + } + + return false +} + +func (o RestoreMetadata) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.CreatedDate != nil { + toSerialize["createdDate"] = o.CreatedDate + } + + if o.CreatedBy != nil { + toSerialize["createdBy"] = o.CreatedBy + } + + if o.CreatedByUserId != nil { + toSerialize["createdByUserId"] = o.CreatedByUserId + } + + if o.LastModifiedDate != nil { + toSerialize["lastModifiedDate"] = o.LastModifiedDate + } + + if o.LastModifiedBy != nil { + toSerialize["lastModifiedBy"] = o.LastModifiedBy + } + + if o.LastModifiedByUserId != nil { + toSerialize["lastModifiedByUserId"] = o.LastModifiedByUserId + } + + if o.ResourceURN != nil { + toSerialize["resourceURN"] = o.ResourceURN + } + + if o.State != nil { + toSerialize["state"] = o.State + } + + if o.Message != nil { + toSerialize["message"] = o.Message + } + + if o.RestoreTime != nil { + toSerialize["restoreTime"] = o.RestoreTime + } + + if o.RestoredSnapshotId != nil { + toSerialize["restoredSnapshotId"] = o.RestoredSnapshotId + } + + return json.Marshal(toSerialize) +} + +type NullableRestoreMetadata struct { + value *RestoreMetadata + isSet bool +} + +func (v NullableRestoreMetadata) Get() *RestoreMetadata { + return v.value +} + +func (v *NullableRestoreMetadata) Set(val *RestoreMetadata) { + v.value = val + v.isSet = true +} + +func (v NullableRestoreMetadata) IsSet() bool { + return v.isSet +} + +func (v *NullableRestoreMetadata) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableRestoreMetadata(val *RestoreMetadata) *NullableRestoreMetadata { + return &NullableRestoreMetadata{value: val, isSet: true} +} + +func (v NullableRestoreMetadata) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableRestoreMetadata) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_restore_metadata_all_of.go b/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_restore_metadata_all_of.go new file mode 100644 index 000000000..5d4eba9f2 --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_restore_metadata_all_of.go @@ -0,0 +1,175 @@ +/* + * In-Memory DB API + * + * API description for the IONOS In-Memory DB + * + * API version: 1.0.0 + * Contact: support@cloud.ionos.com + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package ionoscloud + +import ( + "encoding/json" + "time" +) + +// RestoreMetadataAllOf struct for RestoreMetadataAllOf +type RestoreMetadataAllOf struct { + // The time the snapshot was dumped from the replica set. + RestoreTime *IonosTime `json:"restoreTime,omitempty"` + // The ID of the snapshot that was restored. + RestoredSnapshotId *string `json:"restoredSnapshotId,omitempty"` +} + +// NewRestoreMetadataAllOf instantiates a new RestoreMetadataAllOf 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 NewRestoreMetadataAllOf() *RestoreMetadataAllOf { + this := RestoreMetadataAllOf{} + + return &this +} + +// NewRestoreMetadataAllOfWithDefaults instantiates a new RestoreMetadataAllOf 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 NewRestoreMetadataAllOfWithDefaults() *RestoreMetadataAllOf { + this := RestoreMetadataAllOf{} + return &this +} + +// GetRestoreTime returns the RestoreTime field value +// If the value is explicit nil, the zero value for time.Time will be returned +func (o *RestoreMetadataAllOf) GetRestoreTime() *time.Time { + if o == nil { + return nil + } + + if o.RestoreTime == nil { + return nil + } + return &o.RestoreTime.Time + +} + +// GetRestoreTimeOk returns a tuple with the RestoreTime 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 *RestoreMetadataAllOf) GetRestoreTimeOk() (*time.Time, bool) { + if o == nil { + return nil, false + } + + if o.RestoreTime == nil { + return nil, false + } + return &o.RestoreTime.Time, true + +} + +// SetRestoreTime sets field value +func (o *RestoreMetadataAllOf) SetRestoreTime(v time.Time) { + + o.RestoreTime = &IonosTime{v} + +} + +// HasRestoreTime returns a boolean if a field has been set. +func (o *RestoreMetadataAllOf) HasRestoreTime() bool { + if o != nil && o.RestoreTime != nil { + return true + } + + return false +} + +// GetRestoredSnapshotId returns the RestoredSnapshotId field value +// If the value is explicit nil, the zero value for string will be returned +func (o *RestoreMetadataAllOf) GetRestoredSnapshotId() *string { + if o == nil { + return nil + } + + return o.RestoredSnapshotId + +} + +// GetRestoredSnapshotIdOk returns a tuple with the RestoredSnapshotId 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 *RestoreMetadataAllOf) GetRestoredSnapshotIdOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.RestoredSnapshotId, true +} + +// SetRestoredSnapshotId sets field value +func (o *RestoreMetadataAllOf) SetRestoredSnapshotId(v string) { + + o.RestoredSnapshotId = &v + +} + +// HasRestoredSnapshotId returns a boolean if a field has been set. +func (o *RestoreMetadataAllOf) HasRestoredSnapshotId() bool { + if o != nil && o.RestoredSnapshotId != nil { + return true + } + + return false +} + +func (o RestoreMetadataAllOf) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.RestoreTime != nil { + toSerialize["restoreTime"] = o.RestoreTime + } + + if o.RestoredSnapshotId != nil { + toSerialize["restoredSnapshotId"] = o.RestoredSnapshotId + } + + return json.Marshal(toSerialize) +} + +type NullableRestoreMetadataAllOf struct { + value *RestoreMetadataAllOf + isSet bool +} + +func (v NullableRestoreMetadataAllOf) Get() *RestoreMetadataAllOf { + return v.value +} + +func (v *NullableRestoreMetadataAllOf) Set(val *RestoreMetadataAllOf) { + v.value = val + v.isSet = true +} + +func (v NullableRestoreMetadataAllOf) IsSet() bool { + return v.isSet +} + +func (v *NullableRestoreMetadataAllOf) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableRestoreMetadataAllOf(val *RestoreMetadataAllOf) *NullableRestoreMetadataAllOf { + return &NullableRestoreMetadataAllOf{value: val, isSet: true} +} + +func (v NullableRestoreMetadataAllOf) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableRestoreMetadataAllOf) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_restore_read.go b/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_restore_read.go new file mode 100644 index 000000000..38982b88a --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_restore_read.go @@ -0,0 +1,303 @@ +/* + * In-Memory DB API + * + * API description for the IONOS In-Memory DB + * + * API version: 1.0.0 + * Contact: support@cloud.ionos.com + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package ionoscloud + +import ( + "encoding/json" +) + +// RestoreRead struct for RestoreRead +type RestoreRead struct { + // The ID (UUID) of the Restore. + Id *string `json:"id"` + // The type of the resource. + Type *string `json:"type"` + // The URL of the Restore. + Href *string `json:"href"` + Metadata *RestoreMetadata `json:"metadata"` + Properties *Restore `json:"properties"` +} + +// NewRestoreRead instantiates a new RestoreRead 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 NewRestoreRead(id string, type_ string, href string, metadata RestoreMetadata, properties Restore) *RestoreRead { + this := RestoreRead{} + + this.Id = &id + this.Type = &type_ + this.Href = &href + this.Metadata = &metadata + this.Properties = &properties + + return &this +} + +// NewRestoreReadWithDefaults instantiates a new RestoreRead 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 NewRestoreReadWithDefaults() *RestoreRead { + this := RestoreRead{} + return &this +} + +// GetId returns the Id field value +// If the value is explicit nil, the zero value for string will be returned +func (o *RestoreRead) GetId() *string { + if o == nil { + return nil + } + + return o.Id + +} + +// GetIdOk returns a tuple with the Id 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 *RestoreRead) GetIdOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.Id, true +} + +// SetId sets field value +func (o *RestoreRead) SetId(v string) { + + o.Id = &v + +} + +// HasId returns a boolean if a field has been set. +func (o *RestoreRead) HasId() bool { + if o != nil && o.Id != nil { + return true + } + + return false +} + +// GetType returns the Type field value +// If the value is explicit nil, the zero value for string will be returned +func (o *RestoreRead) GetType() *string { + if o == nil { + return nil + } + + return o.Type + +} + +// GetTypeOk returns a tuple with the Type 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 *RestoreRead) GetTypeOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.Type, true +} + +// SetType sets field value +func (o *RestoreRead) SetType(v string) { + + o.Type = &v + +} + +// HasType returns a boolean if a field has been set. +func (o *RestoreRead) HasType() bool { + if o != nil && o.Type != nil { + return true + } + + return false +} + +// GetHref returns the Href field value +// If the value is explicit nil, the zero value for string will be returned +func (o *RestoreRead) GetHref() *string { + if o == nil { + return nil + } + + return o.Href + +} + +// GetHrefOk returns a tuple with the Href 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 *RestoreRead) GetHrefOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.Href, true +} + +// SetHref sets field value +func (o *RestoreRead) SetHref(v string) { + + o.Href = &v + +} + +// HasHref returns a boolean if a field has been set. +func (o *RestoreRead) HasHref() bool { + if o != nil && o.Href != nil { + return true + } + + return false +} + +// GetMetadata returns the Metadata field value +// If the value is explicit nil, the zero value for RestoreMetadata will be returned +func (o *RestoreRead) GetMetadata() *RestoreMetadata { + 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 *RestoreRead) GetMetadataOk() (*RestoreMetadata, bool) { + if o == nil { + return nil, false + } + + return o.Metadata, true +} + +// SetMetadata sets field value +func (o *RestoreRead) SetMetadata(v RestoreMetadata) { + + o.Metadata = &v + +} + +// HasMetadata returns a boolean if a field has been set. +func (o *RestoreRead) 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 Restore will be returned +func (o *RestoreRead) GetProperties() *Restore { + 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 *RestoreRead) GetPropertiesOk() (*Restore, bool) { + if o == nil { + return nil, false + } + + return o.Properties, true +} + +// SetProperties sets field value +func (o *RestoreRead) SetProperties(v Restore) { + + o.Properties = &v + +} + +// HasProperties returns a boolean if a field has been set. +func (o *RestoreRead) HasProperties() bool { + if o != nil && o.Properties != nil { + return true + } + + return false +} + +func (o RestoreRead) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.Id != nil { + toSerialize["id"] = o.Id + } + + if o.Type != nil { + toSerialize["type"] = o.Type + } + + if o.Href != nil { + toSerialize["href"] = o.Href + } + + if o.Metadata != nil { + toSerialize["metadata"] = o.Metadata + } + + if o.Properties != nil { + toSerialize["properties"] = o.Properties + } + + return json.Marshal(toSerialize) +} + +type NullableRestoreRead struct { + value *RestoreRead + isSet bool +} + +func (v NullableRestoreRead) Get() *RestoreRead { + return v.value +} + +func (v *NullableRestoreRead) Set(val *RestoreRead) { + v.value = val + v.isSet = true +} + +func (v NullableRestoreRead) IsSet() bool { + return v.isSet +} + +func (v *NullableRestoreRead) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableRestoreRead(val *RestoreRead) *NullableRestoreRead { + return &NullableRestoreRead{value: val, isSet: true} +} + +func (v NullableRestoreRead) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableRestoreRead) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_restore_read_list.go b/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_restore_read_list.go new file mode 100644 index 000000000..ed2bb0b21 --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_restore_read_list.go @@ -0,0 +1,393 @@ +/* + * In-Memory DB API + * + * API description for the IONOS In-Memory DB + * + * API version: 1.0.0 + * Contact: support@cloud.ionos.com + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package ionoscloud + +import ( + "encoding/json" +) + +// RestoreReadList struct for RestoreReadList +type RestoreReadList struct { + // ID of the list of Restore resources. + Id *string `json:"id"` + // The type of the resource. + Type *string `json:"type"` + // The URL of the list of Restore resources. + Href *string `json:"href"` + // The list of Restore resources. + Items *[]RestoreRead `json:"items,omitempty"` + // The offset specified in the request (if none was specified, the default offset is 0). + Offset *int32 `json:"offset"` + // The limit specified in the request (if none was specified, use the endpoint's default pagination limit). + Limit *int32 `json:"limit"` + Links *Links `json:"_links"` +} + +// NewRestoreReadList instantiates a new RestoreReadList 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 NewRestoreReadList(id string, type_ string, href string, offset int32, limit int32, links Links) *RestoreReadList { + this := RestoreReadList{} + + this.Id = &id + this.Type = &type_ + this.Href = &href + this.Offset = &offset + this.Limit = &limit + this.Links = &links + + return &this +} + +// NewRestoreReadListWithDefaults instantiates a new RestoreReadList 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 NewRestoreReadListWithDefaults() *RestoreReadList { + this := RestoreReadList{} + return &this +} + +// GetId returns the Id field value +// If the value is explicit nil, the zero value for string will be returned +func (o *RestoreReadList) GetId() *string { + if o == nil { + return nil + } + + return o.Id + +} + +// GetIdOk returns a tuple with the Id 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 *RestoreReadList) GetIdOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.Id, true +} + +// SetId sets field value +func (o *RestoreReadList) SetId(v string) { + + o.Id = &v + +} + +// HasId returns a boolean if a field has been set. +func (o *RestoreReadList) HasId() bool { + if o != nil && o.Id != nil { + return true + } + + return false +} + +// GetType returns the Type field value +// If the value is explicit nil, the zero value for string will be returned +func (o *RestoreReadList) GetType() *string { + if o == nil { + return nil + } + + return o.Type + +} + +// GetTypeOk returns a tuple with the Type 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 *RestoreReadList) GetTypeOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.Type, true +} + +// SetType sets field value +func (o *RestoreReadList) SetType(v string) { + + o.Type = &v + +} + +// HasType returns a boolean if a field has been set. +func (o *RestoreReadList) HasType() bool { + if o != nil && o.Type != nil { + return true + } + + return false +} + +// GetHref returns the Href field value +// If the value is explicit nil, the zero value for string will be returned +func (o *RestoreReadList) GetHref() *string { + if o == nil { + return nil + } + + return o.Href + +} + +// GetHrefOk returns a tuple with the Href 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 *RestoreReadList) GetHrefOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.Href, true +} + +// SetHref sets field value +func (o *RestoreReadList) SetHref(v string) { + + o.Href = &v + +} + +// HasHref returns a boolean if a field has been set. +func (o *RestoreReadList) HasHref() bool { + if o != nil && o.Href != nil { + return true + } + + return false +} + +// GetItems returns the Items field value +// If the value is explicit nil, the zero value for []RestoreRead will be returned +func (o *RestoreReadList) GetItems() *[]RestoreRead { + if o == nil { + return nil + } + + return o.Items + +} + +// GetItemsOk returns a tuple with the Items 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 *RestoreReadList) GetItemsOk() (*[]RestoreRead, bool) { + if o == nil { + return nil, false + } + + return o.Items, true +} + +// SetItems sets field value +func (o *RestoreReadList) SetItems(v []RestoreRead) { + + o.Items = &v + +} + +// HasItems returns a boolean if a field has been set. +func (o *RestoreReadList) HasItems() bool { + if o != nil && o.Items != nil { + return true + } + + return false +} + +// GetOffset returns the Offset field value +// If the value is explicit nil, the zero value for int32 will be returned +func (o *RestoreReadList) GetOffset() *int32 { + if o == nil { + return nil + } + + return o.Offset + +} + +// GetOffsetOk returns a tuple with the Offset 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 *RestoreReadList) GetOffsetOk() (*int32, bool) { + if o == nil { + return nil, false + } + + return o.Offset, true +} + +// SetOffset sets field value +func (o *RestoreReadList) SetOffset(v int32) { + + o.Offset = &v + +} + +// HasOffset returns a boolean if a field has been set. +func (o *RestoreReadList) HasOffset() bool { + if o != nil && o.Offset != nil { + return true + } + + return false +} + +// GetLimit returns the Limit field value +// If the value is explicit nil, the zero value for int32 will be returned +func (o *RestoreReadList) GetLimit() *int32 { + if o == nil { + return nil + } + + return o.Limit + +} + +// GetLimitOk returns a tuple with the Limit 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 *RestoreReadList) GetLimitOk() (*int32, bool) { + if o == nil { + return nil, false + } + + return o.Limit, true +} + +// SetLimit sets field value +func (o *RestoreReadList) SetLimit(v int32) { + + o.Limit = &v + +} + +// HasLimit returns a boolean if a field has been set. +func (o *RestoreReadList) HasLimit() bool { + if o != nil && o.Limit != nil { + return true + } + + return false +} + +// GetLinks returns the Links field value +// If the value is explicit nil, the zero value for Links will be returned +func (o *RestoreReadList) GetLinks() *Links { + if o == nil { + return nil + } + + return o.Links + +} + +// GetLinksOk returns a tuple with the Links 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 *RestoreReadList) GetLinksOk() (*Links, bool) { + if o == nil { + return nil, false + } + + return o.Links, true +} + +// SetLinks sets field value +func (o *RestoreReadList) SetLinks(v Links) { + + o.Links = &v + +} + +// HasLinks returns a boolean if a field has been set. +func (o *RestoreReadList) HasLinks() bool { + if o != nil && o.Links != nil { + return true + } + + return false +} + +func (o RestoreReadList) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.Id != nil { + toSerialize["id"] = o.Id + } + + if o.Type != nil { + toSerialize["type"] = o.Type + } + + if o.Href != nil { + toSerialize["href"] = o.Href + } + + if o.Items != nil { + toSerialize["items"] = o.Items + } + + if o.Offset != nil { + toSerialize["offset"] = o.Offset + } + + if o.Limit != nil { + toSerialize["limit"] = o.Limit + } + + if o.Links != nil { + toSerialize["_links"] = o.Links + } + + return json.Marshal(toSerialize) +} + +type NullableRestoreReadList struct { + value *RestoreReadList + isSet bool +} + +func (v NullableRestoreReadList) Get() *RestoreReadList { + return v.value +} + +func (v *NullableRestoreReadList) Set(val *RestoreReadList) { + v.value = val + v.isSet = true +} + +func (v NullableRestoreReadList) IsSet() bool { + return v.isSet +} + +func (v *NullableRestoreReadList) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableRestoreReadList(val *RestoreReadList) *NullableRestoreReadList { + return &NullableRestoreReadList{value: val, isSet: true} +} + +func (v NullableRestoreReadList) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableRestoreReadList) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_restore_read_list_all_of.go b/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_restore_read_list_all_of.go new file mode 100644 index 000000000..90097ddc9 --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_restore_read_list_all_of.go @@ -0,0 +1,259 @@ +/* + * In-Memory DB API + * + * API description for the IONOS In-Memory DB + * + * API version: 1.0.0 + * Contact: support@cloud.ionos.com + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package ionoscloud + +import ( + "encoding/json" +) + +// RestoreReadListAllOf struct for RestoreReadListAllOf +type RestoreReadListAllOf struct { + // ID of the list of Restore resources. + Id *string `json:"id"` + // The type of the resource. + Type *string `json:"type"` + // The URL of the list of Restore resources. + Href *string `json:"href"` + // The list of Restore resources. + Items *[]RestoreRead `json:"items,omitempty"` +} + +// NewRestoreReadListAllOf instantiates a new RestoreReadListAllOf 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 NewRestoreReadListAllOf(id string, type_ string, href string) *RestoreReadListAllOf { + this := RestoreReadListAllOf{} + + this.Id = &id + this.Type = &type_ + this.Href = &href + + return &this +} + +// NewRestoreReadListAllOfWithDefaults instantiates a new RestoreReadListAllOf 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 NewRestoreReadListAllOfWithDefaults() *RestoreReadListAllOf { + this := RestoreReadListAllOf{} + return &this +} + +// GetId returns the Id field value +// If the value is explicit nil, the zero value for string will be returned +func (o *RestoreReadListAllOf) GetId() *string { + if o == nil { + return nil + } + + return o.Id + +} + +// GetIdOk returns a tuple with the Id 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 *RestoreReadListAllOf) GetIdOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.Id, true +} + +// SetId sets field value +func (o *RestoreReadListAllOf) SetId(v string) { + + o.Id = &v + +} + +// HasId returns a boolean if a field has been set. +func (o *RestoreReadListAllOf) HasId() bool { + if o != nil && o.Id != nil { + return true + } + + return false +} + +// GetType returns the Type field value +// If the value is explicit nil, the zero value for string will be returned +func (o *RestoreReadListAllOf) GetType() *string { + if o == nil { + return nil + } + + return o.Type + +} + +// GetTypeOk returns a tuple with the Type 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 *RestoreReadListAllOf) GetTypeOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.Type, true +} + +// SetType sets field value +func (o *RestoreReadListAllOf) SetType(v string) { + + o.Type = &v + +} + +// HasType returns a boolean if a field has been set. +func (o *RestoreReadListAllOf) HasType() bool { + if o != nil && o.Type != nil { + return true + } + + return false +} + +// GetHref returns the Href field value +// If the value is explicit nil, the zero value for string will be returned +func (o *RestoreReadListAllOf) GetHref() *string { + if o == nil { + return nil + } + + return o.Href + +} + +// GetHrefOk returns a tuple with the Href 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 *RestoreReadListAllOf) GetHrefOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.Href, true +} + +// SetHref sets field value +func (o *RestoreReadListAllOf) SetHref(v string) { + + o.Href = &v + +} + +// HasHref returns a boolean if a field has been set. +func (o *RestoreReadListAllOf) HasHref() bool { + if o != nil && o.Href != nil { + return true + } + + return false +} + +// GetItems returns the Items field value +// If the value is explicit nil, the zero value for []RestoreRead will be returned +func (o *RestoreReadListAllOf) GetItems() *[]RestoreRead { + if o == nil { + return nil + } + + return o.Items + +} + +// GetItemsOk returns a tuple with the Items 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 *RestoreReadListAllOf) GetItemsOk() (*[]RestoreRead, bool) { + if o == nil { + return nil, false + } + + return o.Items, true +} + +// SetItems sets field value +func (o *RestoreReadListAllOf) SetItems(v []RestoreRead) { + + o.Items = &v + +} + +// HasItems returns a boolean if a field has been set. +func (o *RestoreReadListAllOf) HasItems() bool { + if o != nil && o.Items != nil { + return true + } + + return false +} + +func (o RestoreReadListAllOf) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.Id != nil { + toSerialize["id"] = o.Id + } + + if o.Type != nil { + toSerialize["type"] = o.Type + } + + if o.Href != nil { + toSerialize["href"] = o.Href + } + + if o.Items != nil { + toSerialize["items"] = o.Items + } + + return json.Marshal(toSerialize) +} + +type NullableRestoreReadListAllOf struct { + value *RestoreReadListAllOf + isSet bool +} + +func (v NullableRestoreReadListAllOf) Get() *RestoreReadListAllOf { + return v.value +} + +func (v *NullableRestoreReadListAllOf) Set(val *RestoreReadListAllOf) { + v.value = val + v.isSet = true +} + +func (v NullableRestoreReadListAllOf) IsSet() bool { + return v.isSet +} + +func (v *NullableRestoreReadListAllOf) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableRestoreReadListAllOf(val *RestoreReadListAllOf) *NullableRestoreReadListAllOf { + return &NullableRestoreReadListAllOf{value: val, isSet: true} +} + +func (v NullableRestoreReadListAllOf) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableRestoreReadListAllOf) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_snapshot_create.go b/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_snapshot_create.go new file mode 100644 index 000000000..1004638b7 --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_snapshot_create.go @@ -0,0 +1,169 @@ +/* + * In-Memory DB API + * + * API description for the IONOS In-Memory DB + * + * API version: 1.0.0 + * Contact: support@cloud.ionos.com + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package ionoscloud + +import ( + "encoding/json" +) + +// SnapshotCreate struct for SnapshotCreate +type SnapshotCreate struct { + // Metadata + Metadata *map[string]interface{} `json:"metadata,omitempty"` + // A point in time snapshot of a In-Memory DB replica set. + Properties *map[string]interface{} `json:"properties"` +} + +// NewSnapshotCreate instantiates a new SnapshotCreate 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 NewSnapshotCreate(properties map[string]interface{}) *SnapshotCreate { + this := SnapshotCreate{} + + this.Properties = &properties + + return &this +} + +// NewSnapshotCreateWithDefaults instantiates a new SnapshotCreate 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 NewSnapshotCreateWithDefaults() *SnapshotCreate { + this := SnapshotCreate{} + return &this +} + +// GetMetadata returns the Metadata field value +// If the value is explicit nil, the zero value for map[string]interface{} will be returned +func (o *SnapshotCreate) GetMetadata() *map[string]interface{} { + 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 *SnapshotCreate) GetMetadataOk() (*map[string]interface{}, bool) { + if o == nil { + return nil, false + } + + return o.Metadata, true +} + +// SetMetadata sets field value +func (o *SnapshotCreate) SetMetadata(v map[string]interface{}) { + + o.Metadata = &v + +} + +// HasMetadata returns a boolean if a field has been set. +func (o *SnapshotCreate) 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 map[string]interface{} will be returned +func (o *SnapshotCreate) GetProperties() *map[string]interface{} { + 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 *SnapshotCreate) GetPropertiesOk() (*map[string]interface{}, bool) { + if o == nil { + return nil, false + } + + return o.Properties, true +} + +// SetProperties sets field value +func (o *SnapshotCreate) SetProperties(v map[string]interface{}) { + + o.Properties = &v + +} + +// HasProperties returns a boolean if a field has been set. +func (o *SnapshotCreate) HasProperties() bool { + if o != nil && o.Properties != nil { + return true + } + + return false +} + +func (o SnapshotCreate) 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 NullableSnapshotCreate struct { + value *SnapshotCreate + isSet bool +} + +func (v NullableSnapshotCreate) Get() *SnapshotCreate { + return v.value +} + +func (v *NullableSnapshotCreate) Set(val *SnapshotCreate) { + v.value = val + v.isSet = true +} + +func (v NullableSnapshotCreate) IsSet() bool { + return v.isSet +} + +func (v *NullableSnapshotCreate) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableSnapshotCreate(val *SnapshotCreate) *NullableSnapshotCreate { + return &NullableSnapshotCreate{value: val, isSet: true} +} + +func (v NullableSnapshotCreate) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableSnapshotCreate) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_snapshot_ensure.go b/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_snapshot_ensure.go new file mode 100644 index 000000000..c5953fe68 --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_snapshot_ensure.go @@ -0,0 +1,214 @@ +/* + * In-Memory DB API + * + * API description for the IONOS In-Memory DB + * + * API version: 1.0.0 + * Contact: support@cloud.ionos.com + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package ionoscloud + +import ( + "encoding/json" +) + +// SnapshotEnsure struct for SnapshotEnsure +type SnapshotEnsure struct { + // The ID (UUID) of the Snapshot. + Id *string `json:"id"` + // Metadata + Metadata *map[string]interface{} `json:"metadata,omitempty"` + // A point in time snapshot of a In-Memory DB replica set. + Properties *map[string]interface{} `json:"properties"` +} + +// NewSnapshotEnsure instantiates a new SnapshotEnsure 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 NewSnapshotEnsure(id string, properties map[string]interface{}) *SnapshotEnsure { + this := SnapshotEnsure{} + + this.Id = &id + this.Properties = &properties + + return &this +} + +// NewSnapshotEnsureWithDefaults instantiates a new SnapshotEnsure 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 NewSnapshotEnsureWithDefaults() *SnapshotEnsure { + this := SnapshotEnsure{} + return &this +} + +// GetId returns the Id field value +// If the value is explicit nil, the zero value for string will be returned +func (o *SnapshotEnsure) GetId() *string { + if o == nil { + return nil + } + + return o.Id + +} + +// GetIdOk returns a tuple with the Id 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 *SnapshotEnsure) GetIdOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.Id, true +} + +// SetId sets field value +func (o *SnapshotEnsure) SetId(v string) { + + o.Id = &v + +} + +// HasId returns a boolean if a field has been set. +func (o *SnapshotEnsure) HasId() bool { + if o != nil && o.Id != nil { + return true + } + + return false +} + +// GetMetadata returns the Metadata field value +// If the value is explicit nil, the zero value for map[string]interface{} will be returned +func (o *SnapshotEnsure) GetMetadata() *map[string]interface{} { + 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 *SnapshotEnsure) GetMetadataOk() (*map[string]interface{}, bool) { + if o == nil { + return nil, false + } + + return o.Metadata, true +} + +// SetMetadata sets field value +func (o *SnapshotEnsure) SetMetadata(v map[string]interface{}) { + + o.Metadata = &v + +} + +// HasMetadata returns a boolean if a field has been set. +func (o *SnapshotEnsure) 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 map[string]interface{} will be returned +func (o *SnapshotEnsure) GetProperties() *map[string]interface{} { + 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 *SnapshotEnsure) GetPropertiesOk() (*map[string]interface{}, bool) { + if o == nil { + return nil, false + } + + return o.Properties, true +} + +// SetProperties sets field value +func (o *SnapshotEnsure) SetProperties(v map[string]interface{}) { + + o.Properties = &v + +} + +// HasProperties returns a boolean if a field has been set. +func (o *SnapshotEnsure) HasProperties() bool { + if o != nil && o.Properties != nil { + return true + } + + return false +} + +func (o SnapshotEnsure) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.Id != nil { + toSerialize["id"] = o.Id + } + + if o.Metadata != nil { + toSerialize["metadata"] = o.Metadata + } + + if o.Properties != nil { + toSerialize["properties"] = o.Properties + } + + return json.Marshal(toSerialize) +} + +type NullableSnapshotEnsure struct { + value *SnapshotEnsure + isSet bool +} + +func (v NullableSnapshotEnsure) Get() *SnapshotEnsure { + return v.value +} + +func (v *NullableSnapshotEnsure) Set(val *SnapshotEnsure) { + v.value = val + v.isSet = true +} + +func (v NullableSnapshotEnsure) IsSet() bool { + return v.isSet +} + +func (v *NullableSnapshotEnsure) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableSnapshotEnsure(val *SnapshotEnsure) *NullableSnapshotEnsure { + return &NullableSnapshotEnsure{value: val, isSet: true} +} + +func (v NullableSnapshotEnsure) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableSnapshotEnsure) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_snapshot_metadata.go b/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_snapshot_metadata.go new file mode 100644 index 000000000..0486c6377 --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_snapshot_metadata.go @@ -0,0 +1,632 @@ +/* + * In-Memory DB API + * + * API description for the IONOS In-Memory DB + * + * API version: 1.0.0 + * Contact: support@cloud.ionos.com + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package ionoscloud + +import ( + "encoding/json" + "time" +) + +// SnapshotMetadata struct for SnapshotMetadata +type SnapshotMetadata struct { + // The ISO 8601 creation timestamp. + CreatedDate *IonosTime `json:"createdDate,omitempty"` + // Unique name of the identity that created the resource. + CreatedBy *string `json:"createdBy,omitempty"` + // Unique id of the identity that created the resource. + CreatedByUserId *string `json:"createdByUserId,omitempty"` + // The ISO 8601 modified timestamp. + LastModifiedDate *IonosTime `json:"lastModifiedDate,omitempty"` + // Unique name of the identity that last modified the resource. + LastModifiedBy *string `json:"lastModifiedBy,omitempty"` + // Unique id of the identity that last modified the resource. + LastModifiedByUserId *string `json:"lastModifiedByUserId,omitempty"` + // Unique name of the resource. + ResourceURN *string `json:"resourceURN,omitempty"` + State *string `json:"state"` + // A human readable message describing the current state. In case of an error, the message will contain a detailed error message. + Message *string `json:"message,omitempty"` + // The ID of the In-Memory DB replica set the snapshot is taken from. + ReplicasetId *string `json:"replicasetId"` + // The time the snapshot was dumped from the replica set. + SnapshotTime *IonosTime `json:"snapshotTime,omitempty"` + // The ID of the datacenter the snapshot was created in. Please mind, that the snapshot is not available in other datacenters. + DatacenterId *string `json:"datacenterId"` +} + +// NewSnapshotMetadata instantiates a new SnapshotMetadata 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 NewSnapshotMetadata(state string, replicasetId string, datacenterId string) *SnapshotMetadata { + this := SnapshotMetadata{} + + this.State = &state + this.ReplicasetId = &replicasetId + this.DatacenterId = &datacenterId + + return &this +} + +// NewSnapshotMetadataWithDefaults instantiates a new SnapshotMetadata 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 NewSnapshotMetadataWithDefaults() *SnapshotMetadata { + this := SnapshotMetadata{} + return &this +} + +// GetCreatedDate returns the CreatedDate field value +// If the value is explicit nil, the zero value for time.Time will be returned +func (o *SnapshotMetadata) GetCreatedDate() *time.Time { + if o == nil { + return nil + } + + if o.CreatedDate == nil { + return nil + } + return &o.CreatedDate.Time + +} + +// GetCreatedDateOk returns a tuple with the CreatedDate 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 *SnapshotMetadata) GetCreatedDateOk() (*time.Time, bool) { + if o == nil { + return nil, false + } + + if o.CreatedDate == nil { + return nil, false + } + return &o.CreatedDate.Time, true + +} + +// SetCreatedDate sets field value +func (o *SnapshotMetadata) SetCreatedDate(v time.Time) { + + o.CreatedDate = &IonosTime{v} + +} + +// HasCreatedDate returns a boolean if a field has been set. +func (o *SnapshotMetadata) HasCreatedDate() bool { + if o != nil && o.CreatedDate != nil { + return true + } + + return false +} + +// GetCreatedBy returns the CreatedBy field value +// If the value is explicit nil, the zero value for string will be returned +func (o *SnapshotMetadata) GetCreatedBy() *string { + if o == nil { + return nil + } + + return o.CreatedBy + +} + +// GetCreatedByOk returns a tuple with the CreatedBy 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 *SnapshotMetadata) GetCreatedByOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.CreatedBy, true +} + +// SetCreatedBy sets field value +func (o *SnapshotMetadata) SetCreatedBy(v string) { + + o.CreatedBy = &v + +} + +// HasCreatedBy returns a boolean if a field has been set. +func (o *SnapshotMetadata) HasCreatedBy() bool { + if o != nil && o.CreatedBy != nil { + return true + } + + return false +} + +// GetCreatedByUserId returns the CreatedByUserId field value +// If the value is explicit nil, the zero value for string will be returned +func (o *SnapshotMetadata) GetCreatedByUserId() *string { + if o == nil { + return nil + } + + return o.CreatedByUserId + +} + +// GetCreatedByUserIdOk returns a tuple with the CreatedByUserId 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 *SnapshotMetadata) GetCreatedByUserIdOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.CreatedByUserId, true +} + +// SetCreatedByUserId sets field value +func (o *SnapshotMetadata) SetCreatedByUserId(v string) { + + o.CreatedByUserId = &v + +} + +// HasCreatedByUserId returns a boolean if a field has been set. +func (o *SnapshotMetadata) HasCreatedByUserId() bool { + if o != nil && o.CreatedByUserId != nil { + return true + } + + return false +} + +// GetLastModifiedDate returns the LastModifiedDate field value +// If the value is explicit nil, the zero value for time.Time will be returned +func (o *SnapshotMetadata) GetLastModifiedDate() *time.Time { + if o == nil { + return nil + } + + if o.LastModifiedDate == nil { + return nil + } + return &o.LastModifiedDate.Time + +} + +// GetLastModifiedDateOk returns a tuple with the LastModifiedDate 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 *SnapshotMetadata) GetLastModifiedDateOk() (*time.Time, bool) { + if o == nil { + return nil, false + } + + if o.LastModifiedDate == nil { + return nil, false + } + return &o.LastModifiedDate.Time, true + +} + +// SetLastModifiedDate sets field value +func (o *SnapshotMetadata) SetLastModifiedDate(v time.Time) { + + o.LastModifiedDate = &IonosTime{v} + +} + +// HasLastModifiedDate returns a boolean if a field has been set. +func (o *SnapshotMetadata) HasLastModifiedDate() bool { + if o != nil && o.LastModifiedDate != nil { + return true + } + + return false +} + +// GetLastModifiedBy returns the LastModifiedBy field value +// If the value is explicit nil, the zero value for string will be returned +func (o *SnapshotMetadata) GetLastModifiedBy() *string { + if o == nil { + return nil + } + + return o.LastModifiedBy + +} + +// GetLastModifiedByOk returns a tuple with the LastModifiedBy 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 *SnapshotMetadata) GetLastModifiedByOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.LastModifiedBy, true +} + +// SetLastModifiedBy sets field value +func (o *SnapshotMetadata) SetLastModifiedBy(v string) { + + o.LastModifiedBy = &v + +} + +// HasLastModifiedBy returns a boolean if a field has been set. +func (o *SnapshotMetadata) HasLastModifiedBy() bool { + if o != nil && o.LastModifiedBy != nil { + return true + } + + return false +} + +// GetLastModifiedByUserId returns the LastModifiedByUserId field value +// If the value is explicit nil, the zero value for string will be returned +func (o *SnapshotMetadata) GetLastModifiedByUserId() *string { + if o == nil { + return nil + } + + return o.LastModifiedByUserId + +} + +// GetLastModifiedByUserIdOk returns a tuple with the LastModifiedByUserId 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 *SnapshotMetadata) GetLastModifiedByUserIdOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.LastModifiedByUserId, true +} + +// SetLastModifiedByUserId sets field value +func (o *SnapshotMetadata) SetLastModifiedByUserId(v string) { + + o.LastModifiedByUserId = &v + +} + +// HasLastModifiedByUserId returns a boolean if a field has been set. +func (o *SnapshotMetadata) HasLastModifiedByUserId() bool { + if o != nil && o.LastModifiedByUserId != nil { + return true + } + + return false +} + +// GetResourceURN returns the ResourceURN field value +// If the value is explicit nil, the zero value for string will be returned +func (o *SnapshotMetadata) GetResourceURN() *string { + if o == nil { + return nil + } + + return o.ResourceURN + +} + +// GetResourceURNOk returns a tuple with the ResourceURN 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 *SnapshotMetadata) GetResourceURNOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.ResourceURN, true +} + +// SetResourceURN sets field value +func (o *SnapshotMetadata) SetResourceURN(v string) { + + o.ResourceURN = &v + +} + +// HasResourceURN returns a boolean if a field has been set. +func (o *SnapshotMetadata) HasResourceURN() bool { + if o != nil && o.ResourceURN != nil { + return true + } + + return false +} + +// GetState returns the State field value +// If the value is explicit nil, the zero value for string will be returned +func (o *SnapshotMetadata) GetState() *string { + if o == nil { + return nil + } + + return o.State + +} + +// GetStateOk returns a tuple with the State 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 *SnapshotMetadata) GetStateOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.State, true +} + +// SetState sets field value +func (o *SnapshotMetadata) SetState(v string) { + + o.State = &v + +} + +// HasState returns a boolean if a field has been set. +func (o *SnapshotMetadata) HasState() bool { + if o != nil && o.State != nil { + return true + } + + return false +} + +// GetMessage returns the Message field value +// If the value is explicit nil, the zero value for string will be returned +func (o *SnapshotMetadata) GetMessage() *string { + if o == nil { + return nil + } + + return o.Message + +} + +// GetMessageOk returns a tuple with the Message 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 *SnapshotMetadata) GetMessageOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.Message, true +} + +// SetMessage sets field value +func (o *SnapshotMetadata) SetMessage(v string) { + + o.Message = &v + +} + +// HasMessage returns a boolean if a field has been set. +func (o *SnapshotMetadata) HasMessage() bool { + if o != nil && o.Message != nil { + return true + } + + return false +} + +// GetReplicasetId returns the ReplicasetId field value +// If the value is explicit nil, the zero value for string will be returned +func (o *SnapshotMetadata) GetReplicasetId() *string { + if o == nil { + return nil + } + + return o.ReplicasetId + +} + +// GetReplicasetIdOk returns a tuple with the ReplicasetId 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 *SnapshotMetadata) GetReplicasetIdOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.ReplicasetId, true +} + +// SetReplicasetId sets field value +func (o *SnapshotMetadata) SetReplicasetId(v string) { + + o.ReplicasetId = &v + +} + +// HasReplicasetId returns a boolean if a field has been set. +func (o *SnapshotMetadata) HasReplicasetId() bool { + if o != nil && o.ReplicasetId != nil { + return true + } + + return false +} + +// GetSnapshotTime returns the SnapshotTime field value +// If the value is explicit nil, the zero value for time.Time will be returned +func (o *SnapshotMetadata) GetSnapshotTime() *time.Time { + if o == nil { + return nil + } + + if o.SnapshotTime == nil { + return nil + } + return &o.SnapshotTime.Time + +} + +// GetSnapshotTimeOk returns a tuple with the SnapshotTime 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 *SnapshotMetadata) GetSnapshotTimeOk() (*time.Time, bool) { + if o == nil { + return nil, false + } + + if o.SnapshotTime == nil { + return nil, false + } + return &o.SnapshotTime.Time, true + +} + +// SetSnapshotTime sets field value +func (o *SnapshotMetadata) SetSnapshotTime(v time.Time) { + + o.SnapshotTime = &IonosTime{v} + +} + +// HasSnapshotTime returns a boolean if a field has been set. +func (o *SnapshotMetadata) HasSnapshotTime() bool { + if o != nil && o.SnapshotTime != nil { + return true + } + + return false +} + +// GetDatacenterId returns the DatacenterId field value +// If the value is explicit nil, the zero value for string will be returned +func (o *SnapshotMetadata) GetDatacenterId() *string { + if o == nil { + return nil + } + + return o.DatacenterId + +} + +// GetDatacenterIdOk returns a tuple with the DatacenterId 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 *SnapshotMetadata) GetDatacenterIdOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.DatacenterId, true +} + +// SetDatacenterId sets field value +func (o *SnapshotMetadata) SetDatacenterId(v string) { + + o.DatacenterId = &v + +} + +// HasDatacenterId returns a boolean if a field has been set. +func (o *SnapshotMetadata) HasDatacenterId() bool { + if o != nil && o.DatacenterId != nil { + return true + } + + return false +} + +func (o SnapshotMetadata) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.CreatedDate != nil { + toSerialize["createdDate"] = o.CreatedDate + } + + if o.CreatedBy != nil { + toSerialize["createdBy"] = o.CreatedBy + } + + if o.CreatedByUserId != nil { + toSerialize["createdByUserId"] = o.CreatedByUserId + } + + if o.LastModifiedDate != nil { + toSerialize["lastModifiedDate"] = o.LastModifiedDate + } + + if o.LastModifiedBy != nil { + toSerialize["lastModifiedBy"] = o.LastModifiedBy + } + + if o.LastModifiedByUserId != nil { + toSerialize["lastModifiedByUserId"] = o.LastModifiedByUserId + } + + if o.ResourceURN != nil { + toSerialize["resourceURN"] = o.ResourceURN + } + + if o.State != nil { + toSerialize["state"] = o.State + } + + if o.Message != nil { + toSerialize["message"] = o.Message + } + + if o.ReplicasetId != nil { + toSerialize["replicasetId"] = o.ReplicasetId + } + + if o.SnapshotTime != nil { + toSerialize["snapshotTime"] = o.SnapshotTime + } + + if o.DatacenterId != nil { + toSerialize["datacenterId"] = o.DatacenterId + } + + return json.Marshal(toSerialize) +} + +type NullableSnapshotMetadata struct { + value *SnapshotMetadata + isSet bool +} + +func (v NullableSnapshotMetadata) Get() *SnapshotMetadata { + return v.value +} + +func (v *NullableSnapshotMetadata) Set(val *SnapshotMetadata) { + v.value = val + v.isSet = true +} + +func (v NullableSnapshotMetadata) IsSet() bool { + return v.isSet +} + +func (v *NullableSnapshotMetadata) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableSnapshotMetadata(val *SnapshotMetadata) *NullableSnapshotMetadata { + return &NullableSnapshotMetadata{value: val, isSet: true} +} + +func (v NullableSnapshotMetadata) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableSnapshotMetadata) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_snapshot_metadata_all_of.go b/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_snapshot_metadata_all_of.go new file mode 100644 index 000000000..7b62ef9f6 --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_snapshot_metadata_all_of.go @@ -0,0 +1,222 @@ +/* + * In-Memory DB API + * + * API description for the IONOS In-Memory DB + * + * API version: 1.0.0 + * Contact: support@cloud.ionos.com + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package ionoscloud + +import ( + "encoding/json" + "time" +) + +// SnapshotMetadataAllOf struct for SnapshotMetadataAllOf +type SnapshotMetadataAllOf struct { + // The ID of the In-Memory DB replica set the snapshot is taken from. + ReplicasetId *string `json:"replicasetId"` + // The time the snapshot was dumped from the replica set. + SnapshotTime *IonosTime `json:"snapshotTime,omitempty"` + // The ID of the datacenter the snapshot was created in. Please mind, that the snapshot is not available in other datacenters. + DatacenterId *string `json:"datacenterId"` +} + +// NewSnapshotMetadataAllOf instantiates a new SnapshotMetadataAllOf 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 NewSnapshotMetadataAllOf(replicasetId string, datacenterId string) *SnapshotMetadataAllOf { + this := SnapshotMetadataAllOf{} + + this.ReplicasetId = &replicasetId + this.DatacenterId = &datacenterId + + return &this +} + +// NewSnapshotMetadataAllOfWithDefaults instantiates a new SnapshotMetadataAllOf 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 NewSnapshotMetadataAllOfWithDefaults() *SnapshotMetadataAllOf { + this := SnapshotMetadataAllOf{} + return &this +} + +// GetReplicasetId returns the ReplicasetId field value +// If the value is explicit nil, the zero value for string will be returned +func (o *SnapshotMetadataAllOf) GetReplicasetId() *string { + if o == nil { + return nil + } + + return o.ReplicasetId + +} + +// GetReplicasetIdOk returns a tuple with the ReplicasetId 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 *SnapshotMetadataAllOf) GetReplicasetIdOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.ReplicasetId, true +} + +// SetReplicasetId sets field value +func (o *SnapshotMetadataAllOf) SetReplicasetId(v string) { + + o.ReplicasetId = &v + +} + +// HasReplicasetId returns a boolean if a field has been set. +func (o *SnapshotMetadataAllOf) HasReplicasetId() bool { + if o != nil && o.ReplicasetId != nil { + return true + } + + return false +} + +// GetSnapshotTime returns the SnapshotTime field value +// If the value is explicit nil, the zero value for time.Time will be returned +func (o *SnapshotMetadataAllOf) GetSnapshotTime() *time.Time { + if o == nil { + return nil + } + + if o.SnapshotTime == nil { + return nil + } + return &o.SnapshotTime.Time + +} + +// GetSnapshotTimeOk returns a tuple with the SnapshotTime 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 *SnapshotMetadataAllOf) GetSnapshotTimeOk() (*time.Time, bool) { + if o == nil { + return nil, false + } + + if o.SnapshotTime == nil { + return nil, false + } + return &o.SnapshotTime.Time, true + +} + +// SetSnapshotTime sets field value +func (o *SnapshotMetadataAllOf) SetSnapshotTime(v time.Time) { + + o.SnapshotTime = &IonosTime{v} + +} + +// HasSnapshotTime returns a boolean if a field has been set. +func (o *SnapshotMetadataAllOf) HasSnapshotTime() bool { + if o != nil && o.SnapshotTime != nil { + return true + } + + return false +} + +// GetDatacenterId returns the DatacenterId field value +// If the value is explicit nil, the zero value for string will be returned +func (o *SnapshotMetadataAllOf) GetDatacenterId() *string { + if o == nil { + return nil + } + + return o.DatacenterId + +} + +// GetDatacenterIdOk returns a tuple with the DatacenterId 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 *SnapshotMetadataAllOf) GetDatacenterIdOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.DatacenterId, true +} + +// SetDatacenterId sets field value +func (o *SnapshotMetadataAllOf) SetDatacenterId(v string) { + + o.DatacenterId = &v + +} + +// HasDatacenterId returns a boolean if a field has been set. +func (o *SnapshotMetadataAllOf) HasDatacenterId() bool { + if o != nil && o.DatacenterId != nil { + return true + } + + return false +} + +func (o SnapshotMetadataAllOf) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.ReplicasetId != nil { + toSerialize["replicasetId"] = o.ReplicasetId + } + + if o.SnapshotTime != nil { + toSerialize["snapshotTime"] = o.SnapshotTime + } + + if o.DatacenterId != nil { + toSerialize["datacenterId"] = o.DatacenterId + } + + return json.Marshal(toSerialize) +} + +type NullableSnapshotMetadataAllOf struct { + value *SnapshotMetadataAllOf + isSet bool +} + +func (v NullableSnapshotMetadataAllOf) Get() *SnapshotMetadataAllOf { + return v.value +} + +func (v *NullableSnapshotMetadataAllOf) Set(val *SnapshotMetadataAllOf) { + v.value = val + v.isSet = true +} + +func (v NullableSnapshotMetadataAllOf) IsSet() bool { + return v.isSet +} + +func (v *NullableSnapshotMetadataAllOf) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableSnapshotMetadataAllOf(val *SnapshotMetadataAllOf) *NullableSnapshotMetadataAllOf { + return &NullableSnapshotMetadataAllOf{value: val, isSet: true} +} + +func (v NullableSnapshotMetadataAllOf) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableSnapshotMetadataAllOf) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_snapshot_read.go b/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_snapshot_read.go new file mode 100644 index 000000000..a467b84b5 --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_snapshot_read.go @@ -0,0 +1,304 @@ +/* + * In-Memory DB API + * + * API description for the IONOS In-Memory DB + * + * API version: 1.0.0 + * Contact: support@cloud.ionos.com + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package ionoscloud + +import ( + "encoding/json" +) + +// SnapshotRead struct for SnapshotRead +type SnapshotRead struct { + // The ID (UUID) of the Snapshot. + Id *string `json:"id"` + // The type of the resource. + Type *string `json:"type"` + // The URL of the Snapshot. + Href *string `json:"href"` + Metadata *SnapshotMetadata `json:"metadata"` + // A point in time snapshot of a In-Memory DB replica set. + Properties *map[string]interface{} `json:"properties"` +} + +// NewSnapshotRead instantiates a new SnapshotRead 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 NewSnapshotRead(id string, type_ string, href string, metadata SnapshotMetadata, properties map[string]interface{}) *SnapshotRead { + this := SnapshotRead{} + + this.Id = &id + this.Type = &type_ + this.Href = &href + this.Metadata = &metadata + this.Properties = &properties + + return &this +} + +// NewSnapshotReadWithDefaults instantiates a new SnapshotRead 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 NewSnapshotReadWithDefaults() *SnapshotRead { + this := SnapshotRead{} + return &this +} + +// GetId returns the Id field value +// If the value is explicit nil, the zero value for string will be returned +func (o *SnapshotRead) GetId() *string { + if o == nil { + return nil + } + + return o.Id + +} + +// GetIdOk returns a tuple with the Id 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 *SnapshotRead) GetIdOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.Id, true +} + +// SetId sets field value +func (o *SnapshotRead) SetId(v string) { + + o.Id = &v + +} + +// HasId returns a boolean if a field has been set. +func (o *SnapshotRead) HasId() bool { + if o != nil && o.Id != nil { + return true + } + + return false +} + +// GetType returns the Type field value +// If the value is explicit nil, the zero value for string will be returned +func (o *SnapshotRead) GetType() *string { + if o == nil { + return nil + } + + return o.Type + +} + +// GetTypeOk returns a tuple with the Type 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 *SnapshotRead) GetTypeOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.Type, true +} + +// SetType sets field value +func (o *SnapshotRead) SetType(v string) { + + o.Type = &v + +} + +// HasType returns a boolean if a field has been set. +func (o *SnapshotRead) HasType() bool { + if o != nil && o.Type != nil { + return true + } + + return false +} + +// GetHref returns the Href field value +// If the value is explicit nil, the zero value for string will be returned +func (o *SnapshotRead) GetHref() *string { + if o == nil { + return nil + } + + return o.Href + +} + +// GetHrefOk returns a tuple with the Href 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 *SnapshotRead) GetHrefOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.Href, true +} + +// SetHref sets field value +func (o *SnapshotRead) SetHref(v string) { + + o.Href = &v + +} + +// HasHref returns a boolean if a field has been set. +func (o *SnapshotRead) HasHref() bool { + if o != nil && o.Href != nil { + return true + } + + return false +} + +// GetMetadata returns the Metadata field value +// If the value is explicit nil, the zero value for SnapshotMetadata will be returned +func (o *SnapshotRead) GetMetadata() *SnapshotMetadata { + 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 *SnapshotRead) GetMetadataOk() (*SnapshotMetadata, bool) { + if o == nil { + return nil, false + } + + return o.Metadata, true +} + +// SetMetadata sets field value +func (o *SnapshotRead) SetMetadata(v SnapshotMetadata) { + + o.Metadata = &v + +} + +// HasMetadata returns a boolean if a field has been set. +func (o *SnapshotRead) 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 map[string]interface{} will be returned +func (o *SnapshotRead) GetProperties() *map[string]interface{} { + 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 *SnapshotRead) GetPropertiesOk() (*map[string]interface{}, bool) { + if o == nil { + return nil, false + } + + return o.Properties, true +} + +// SetProperties sets field value +func (o *SnapshotRead) SetProperties(v map[string]interface{}) { + + o.Properties = &v + +} + +// HasProperties returns a boolean if a field has been set. +func (o *SnapshotRead) HasProperties() bool { + if o != nil && o.Properties != nil { + return true + } + + return false +} + +func (o SnapshotRead) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.Id != nil { + toSerialize["id"] = o.Id + } + + if o.Type != nil { + toSerialize["type"] = o.Type + } + + if o.Href != nil { + toSerialize["href"] = o.Href + } + + if o.Metadata != nil { + toSerialize["metadata"] = o.Metadata + } + + if o.Properties != nil { + toSerialize["properties"] = o.Properties + } + + return json.Marshal(toSerialize) +} + +type NullableSnapshotRead struct { + value *SnapshotRead + isSet bool +} + +func (v NullableSnapshotRead) Get() *SnapshotRead { + return v.value +} + +func (v *NullableSnapshotRead) Set(val *SnapshotRead) { + v.value = val + v.isSet = true +} + +func (v NullableSnapshotRead) IsSet() bool { + return v.isSet +} + +func (v *NullableSnapshotRead) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableSnapshotRead(val *SnapshotRead) *NullableSnapshotRead { + return &NullableSnapshotRead{value: val, isSet: true} +} + +func (v NullableSnapshotRead) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableSnapshotRead) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_snapshot_read_list.go b/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_snapshot_read_list.go new file mode 100644 index 000000000..1c31dc738 --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_snapshot_read_list.go @@ -0,0 +1,393 @@ +/* + * In-Memory DB API + * + * API description for the IONOS In-Memory DB + * + * API version: 1.0.0 + * Contact: support@cloud.ionos.com + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package ionoscloud + +import ( + "encoding/json" +) + +// SnapshotReadList struct for SnapshotReadList +type SnapshotReadList struct { + // ID of the list of Snapshot resources. + Id *string `json:"id"` + // The type of the resource. + Type *string `json:"type"` + // The URL of the list of Snapshot resources. + Href *string `json:"href"` + // The list of Snapshot resources. + Items *[]SnapshotRead `json:"items,omitempty"` + // The offset specified in the request (if none was specified, the default offset is 0). + Offset *int32 `json:"offset"` + // The limit specified in the request (if none was specified, use the endpoint's default pagination limit). + Limit *int32 `json:"limit"` + Links *Links `json:"_links"` +} + +// NewSnapshotReadList instantiates a new SnapshotReadList 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 NewSnapshotReadList(id string, type_ string, href string, offset int32, limit int32, links Links) *SnapshotReadList { + this := SnapshotReadList{} + + this.Id = &id + this.Type = &type_ + this.Href = &href + this.Offset = &offset + this.Limit = &limit + this.Links = &links + + return &this +} + +// NewSnapshotReadListWithDefaults instantiates a new SnapshotReadList 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 NewSnapshotReadListWithDefaults() *SnapshotReadList { + this := SnapshotReadList{} + return &this +} + +// GetId returns the Id field value +// If the value is explicit nil, the zero value for string will be returned +func (o *SnapshotReadList) GetId() *string { + if o == nil { + return nil + } + + return o.Id + +} + +// GetIdOk returns a tuple with the Id 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 *SnapshotReadList) GetIdOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.Id, true +} + +// SetId sets field value +func (o *SnapshotReadList) SetId(v string) { + + o.Id = &v + +} + +// HasId returns a boolean if a field has been set. +func (o *SnapshotReadList) HasId() bool { + if o != nil && o.Id != nil { + return true + } + + return false +} + +// GetType returns the Type field value +// If the value is explicit nil, the zero value for string will be returned +func (o *SnapshotReadList) GetType() *string { + if o == nil { + return nil + } + + return o.Type + +} + +// GetTypeOk returns a tuple with the Type 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 *SnapshotReadList) GetTypeOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.Type, true +} + +// SetType sets field value +func (o *SnapshotReadList) SetType(v string) { + + o.Type = &v + +} + +// HasType returns a boolean if a field has been set. +func (o *SnapshotReadList) HasType() bool { + if o != nil && o.Type != nil { + return true + } + + return false +} + +// GetHref returns the Href field value +// If the value is explicit nil, the zero value for string will be returned +func (o *SnapshotReadList) GetHref() *string { + if o == nil { + return nil + } + + return o.Href + +} + +// GetHrefOk returns a tuple with the Href 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 *SnapshotReadList) GetHrefOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.Href, true +} + +// SetHref sets field value +func (o *SnapshotReadList) SetHref(v string) { + + o.Href = &v + +} + +// HasHref returns a boolean if a field has been set. +func (o *SnapshotReadList) HasHref() bool { + if o != nil && o.Href != nil { + return true + } + + return false +} + +// GetItems returns the Items field value +// If the value is explicit nil, the zero value for []SnapshotRead will be returned +func (o *SnapshotReadList) GetItems() *[]SnapshotRead { + if o == nil { + return nil + } + + return o.Items + +} + +// GetItemsOk returns a tuple with the Items 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 *SnapshotReadList) GetItemsOk() (*[]SnapshotRead, bool) { + if o == nil { + return nil, false + } + + return o.Items, true +} + +// SetItems sets field value +func (o *SnapshotReadList) SetItems(v []SnapshotRead) { + + o.Items = &v + +} + +// HasItems returns a boolean if a field has been set. +func (o *SnapshotReadList) HasItems() bool { + if o != nil && o.Items != nil { + return true + } + + return false +} + +// GetOffset returns the Offset field value +// If the value is explicit nil, the zero value for int32 will be returned +func (o *SnapshotReadList) GetOffset() *int32 { + if o == nil { + return nil + } + + return o.Offset + +} + +// GetOffsetOk returns a tuple with the Offset 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 *SnapshotReadList) GetOffsetOk() (*int32, bool) { + if o == nil { + return nil, false + } + + return o.Offset, true +} + +// SetOffset sets field value +func (o *SnapshotReadList) SetOffset(v int32) { + + o.Offset = &v + +} + +// HasOffset returns a boolean if a field has been set. +func (o *SnapshotReadList) HasOffset() bool { + if o != nil && o.Offset != nil { + return true + } + + return false +} + +// GetLimit returns the Limit field value +// If the value is explicit nil, the zero value for int32 will be returned +func (o *SnapshotReadList) GetLimit() *int32 { + if o == nil { + return nil + } + + return o.Limit + +} + +// GetLimitOk returns a tuple with the Limit 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 *SnapshotReadList) GetLimitOk() (*int32, bool) { + if o == nil { + return nil, false + } + + return o.Limit, true +} + +// SetLimit sets field value +func (o *SnapshotReadList) SetLimit(v int32) { + + o.Limit = &v + +} + +// HasLimit returns a boolean if a field has been set. +func (o *SnapshotReadList) HasLimit() bool { + if o != nil && o.Limit != nil { + return true + } + + return false +} + +// GetLinks returns the Links field value +// If the value is explicit nil, the zero value for Links will be returned +func (o *SnapshotReadList) GetLinks() *Links { + if o == nil { + return nil + } + + return o.Links + +} + +// GetLinksOk returns a tuple with the Links 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 *SnapshotReadList) GetLinksOk() (*Links, bool) { + if o == nil { + return nil, false + } + + return o.Links, true +} + +// SetLinks sets field value +func (o *SnapshotReadList) SetLinks(v Links) { + + o.Links = &v + +} + +// HasLinks returns a boolean if a field has been set. +func (o *SnapshotReadList) HasLinks() bool { + if o != nil && o.Links != nil { + return true + } + + return false +} + +func (o SnapshotReadList) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.Id != nil { + toSerialize["id"] = o.Id + } + + if o.Type != nil { + toSerialize["type"] = o.Type + } + + if o.Href != nil { + toSerialize["href"] = o.Href + } + + if o.Items != nil { + toSerialize["items"] = o.Items + } + + if o.Offset != nil { + toSerialize["offset"] = o.Offset + } + + if o.Limit != nil { + toSerialize["limit"] = o.Limit + } + + if o.Links != nil { + toSerialize["_links"] = o.Links + } + + return json.Marshal(toSerialize) +} + +type NullableSnapshotReadList struct { + value *SnapshotReadList + isSet bool +} + +func (v NullableSnapshotReadList) Get() *SnapshotReadList { + return v.value +} + +func (v *NullableSnapshotReadList) Set(val *SnapshotReadList) { + v.value = val + v.isSet = true +} + +func (v NullableSnapshotReadList) IsSet() bool { + return v.isSet +} + +func (v *NullableSnapshotReadList) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableSnapshotReadList(val *SnapshotReadList) *NullableSnapshotReadList { + return &NullableSnapshotReadList{value: val, isSet: true} +} + +func (v NullableSnapshotReadList) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableSnapshotReadList) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_snapshot_read_list_all_of.go b/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_snapshot_read_list_all_of.go new file mode 100644 index 000000000..f9b3630ac --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_snapshot_read_list_all_of.go @@ -0,0 +1,259 @@ +/* + * In-Memory DB API + * + * API description for the IONOS In-Memory DB + * + * API version: 1.0.0 + * Contact: support@cloud.ionos.com + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package ionoscloud + +import ( + "encoding/json" +) + +// SnapshotReadListAllOf struct for SnapshotReadListAllOf +type SnapshotReadListAllOf struct { + // ID of the list of Snapshot resources. + Id *string `json:"id"` + // The type of the resource. + Type *string `json:"type"` + // The URL of the list of Snapshot resources. + Href *string `json:"href"` + // The list of Snapshot resources. + Items *[]SnapshotRead `json:"items,omitempty"` +} + +// NewSnapshotReadListAllOf instantiates a new SnapshotReadListAllOf 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 NewSnapshotReadListAllOf(id string, type_ string, href string) *SnapshotReadListAllOf { + this := SnapshotReadListAllOf{} + + this.Id = &id + this.Type = &type_ + this.Href = &href + + return &this +} + +// NewSnapshotReadListAllOfWithDefaults instantiates a new SnapshotReadListAllOf 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 NewSnapshotReadListAllOfWithDefaults() *SnapshotReadListAllOf { + this := SnapshotReadListAllOf{} + return &this +} + +// GetId returns the Id field value +// If the value is explicit nil, the zero value for string will be returned +func (o *SnapshotReadListAllOf) GetId() *string { + if o == nil { + return nil + } + + return o.Id + +} + +// GetIdOk returns a tuple with the Id 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 *SnapshotReadListAllOf) GetIdOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.Id, true +} + +// SetId sets field value +func (o *SnapshotReadListAllOf) SetId(v string) { + + o.Id = &v + +} + +// HasId returns a boolean if a field has been set. +func (o *SnapshotReadListAllOf) HasId() bool { + if o != nil && o.Id != nil { + return true + } + + return false +} + +// GetType returns the Type field value +// If the value is explicit nil, the zero value for string will be returned +func (o *SnapshotReadListAllOf) GetType() *string { + if o == nil { + return nil + } + + return o.Type + +} + +// GetTypeOk returns a tuple with the Type 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 *SnapshotReadListAllOf) GetTypeOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.Type, true +} + +// SetType sets field value +func (o *SnapshotReadListAllOf) SetType(v string) { + + o.Type = &v + +} + +// HasType returns a boolean if a field has been set. +func (o *SnapshotReadListAllOf) HasType() bool { + if o != nil && o.Type != nil { + return true + } + + return false +} + +// GetHref returns the Href field value +// If the value is explicit nil, the zero value for string will be returned +func (o *SnapshotReadListAllOf) GetHref() *string { + if o == nil { + return nil + } + + return o.Href + +} + +// GetHrefOk returns a tuple with the Href 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 *SnapshotReadListAllOf) GetHrefOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.Href, true +} + +// SetHref sets field value +func (o *SnapshotReadListAllOf) SetHref(v string) { + + o.Href = &v + +} + +// HasHref returns a boolean if a field has been set. +func (o *SnapshotReadListAllOf) HasHref() bool { + if o != nil && o.Href != nil { + return true + } + + return false +} + +// GetItems returns the Items field value +// If the value is explicit nil, the zero value for []SnapshotRead will be returned +func (o *SnapshotReadListAllOf) GetItems() *[]SnapshotRead { + if o == nil { + return nil + } + + return o.Items + +} + +// GetItemsOk returns a tuple with the Items 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 *SnapshotReadListAllOf) GetItemsOk() (*[]SnapshotRead, bool) { + if o == nil { + return nil, false + } + + return o.Items, true +} + +// SetItems sets field value +func (o *SnapshotReadListAllOf) SetItems(v []SnapshotRead) { + + o.Items = &v + +} + +// HasItems returns a boolean if a field has been set. +func (o *SnapshotReadListAllOf) HasItems() bool { + if o != nil && o.Items != nil { + return true + } + + return false +} + +func (o SnapshotReadListAllOf) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.Id != nil { + toSerialize["id"] = o.Id + } + + if o.Type != nil { + toSerialize["type"] = o.Type + } + + if o.Href != nil { + toSerialize["href"] = o.Href + } + + if o.Items != nil { + toSerialize["items"] = o.Items + } + + return json.Marshal(toSerialize) +} + +type NullableSnapshotReadListAllOf struct { + value *SnapshotReadListAllOf + isSet bool +} + +func (v NullableSnapshotReadListAllOf) Get() *SnapshotReadListAllOf { + return v.value +} + +func (v *NullableSnapshotReadListAllOf) Set(val *SnapshotReadListAllOf) { + v.value = val + v.isSet = true +} + +func (v NullableSnapshotReadListAllOf) IsSet() bool { + return v.isSet +} + +func (v *NullableSnapshotReadListAllOf) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableSnapshotReadListAllOf(val *SnapshotReadListAllOf) *NullableSnapshotReadListAllOf { + return &NullableSnapshotReadListAllOf{value: val, isSet: true} +} + +func (v NullableSnapshotReadListAllOf) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableSnapshotReadListAllOf) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_user.go b/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_user.go new file mode 100644 index 000000000..5f62ab653 --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_user.go @@ -0,0 +1,169 @@ +/* + * In-Memory DB API + * + * API description for the IONOS In-Memory DB + * + * API version: 1.0.0 + * Contact: support@cloud.ionos.com + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package ionoscloud + +import ( + "encoding/json" +) + +// User Credentials for the In-Memory DB replicaset. +type User struct { + // The username for the initial In-Memory DB user. Some system usernames are restricted (e.g. `\"admin\"`, `\"standby\"`). + Username *string `json:"username"` + Password *UserPassword `json:"password"` +} + +// NewUser instantiates a new User 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 NewUser(username string, password UserPassword) *User { + this := User{} + + this.Username = &username + this.Password = &password + + return &this +} + +// NewUserWithDefaults instantiates a new User 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 NewUserWithDefaults() *User { + this := User{} + return &this +} + +// GetUsername returns the Username field value +// If the value is explicit nil, the zero value for string will be returned +func (o *User) GetUsername() *string { + if o == nil { + return nil + } + + return o.Username + +} + +// GetUsernameOk returns a tuple with the Username 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 *User) GetUsernameOk() (*string, bool) { + if o == nil { + return nil, false + } + + return o.Username, true +} + +// SetUsername sets field value +func (o *User) SetUsername(v string) { + + o.Username = &v + +} + +// HasUsername returns a boolean if a field has been set. +func (o *User) HasUsername() bool { + if o != nil && o.Username != nil { + return true + } + + return false +} + +// GetPassword returns the Password field value +// If the value is explicit nil, the zero value for UserPassword will be returned +func (o *User) GetPassword() *UserPassword { + if o == nil { + return nil + } + + return o.Password + +} + +// GetPasswordOk returns a tuple with the Password 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 *User) GetPasswordOk() (*UserPassword, bool) { + if o == nil { + return nil, false + } + + return o.Password, true +} + +// SetPassword sets field value +func (o *User) SetPassword(v UserPassword) { + + o.Password = &v + +} + +// HasPassword returns a boolean if a field has been set. +func (o *User) HasPassword() bool { + if o != nil && o.Password != nil { + return true + } + + return false +} + +func (o User) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.Username != nil { + toSerialize["username"] = o.Username + } + + if o.Password != nil { + toSerialize["password"] = o.Password + } + + return json.Marshal(toSerialize) +} + +type NullableUser struct { + value *User + isSet bool +} + +func (v NullableUser) Get() *User { + return v.value +} + +func (v *NullableUser) Set(val *User) { + v.value = val + v.isSet = true +} + +func (v NullableUser) IsSet() bool { + return v.isSet +} + +func (v *NullableUser) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableUser(val *User) *NullableUser { + return &NullableUser{value: val, isSet: true} +} + +func (v NullableUser) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableUser) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_user_password.go b/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_user_password.go new file mode 100644 index 000000000..ef6fe51f1 --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/model_user_password.go @@ -0,0 +1,139 @@ +/* + * In-Memory DB API + * + * API description for the IONOS In-Memory DB + * + * API version: 1.0.0 + * Contact: support@cloud.ionos.com + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package ionoscloud + +import ( + "encoding/json" + "fmt" +) + +// UserPassword - struct for UserPassword +type UserPassword struct { + HashedPassword *HashedPassword + PlainTextPassword *string +} + +// HashedPasswordAsUserPassword is a convenience function that returns HashedPassword wrapped in UserPassword +func HashedPasswordAsUserPassword(v *HashedPassword) UserPassword { + return UserPassword{HashedPassword: v} +} + +// PlainTextPasswordAsUserPassword is a convenience function that returns PlainTextPassword wrapped in UserPassword +func PlainTextPasswordAsUserPassword(v *string) UserPassword { + return UserPassword{PlainTextPassword: v} +} + +// Unmarshal JSON data into one of the pointers in the struct +func (dst *UserPassword) UnmarshalJSON(data []byte) error { + var err error + match := 0 + // try to unmarshal data into HashedPassword + err = json.Unmarshal(data, &dst.HashedPassword) + if err == nil { + jsonHashedPassword, _ := json.Marshal(dst.HashedPassword) + if string(jsonHashedPassword) == "{}" { // empty struct + dst.HashedPassword = nil + } else { + match++ + } + } else { + dst.HashedPassword = nil + } + + // try to unmarshal data into PlainTextPassword + err = json.Unmarshal(data, &dst.PlainTextPassword) + if err == nil { + jsonstring, _ := json.Marshal(dst.PlainTextPassword) + if string(jsonstring) == "{}" { // empty struct + dst.PlainTextPassword = nil + } else { + match++ + } + } else { + dst.PlainTextPassword = nil + } + + if match > 1 { // more than 1 match + // reset to nil + dst.HashedPassword = nil + dst.PlainTextPassword = nil + + return fmt.Errorf("Data matches more than one schema in oneOf(UserPassword)") + } else if match == 1 { + return nil // exactly one match + } else { // no match + return fmt.Errorf("Data failed to match schemas in oneOf(UserPassword)") + } +} + +// Marshal data from the first non-nil pointers in the struct to JSON +func (src UserPassword) MarshalJSON() ([]byte, error) { + if src.HashedPassword != nil { + return json.Marshal(&src.HashedPassword) + } + + if src.PlainTextPassword != nil { + return json.Marshal(&src.PlainTextPassword) + } + + return nil, nil // no data in oneOf schemas +} + +// Get the actual instance +func (obj *UserPassword) GetActualInstance() interface{} { + if obj.HashedPassword != nil { + return obj.HashedPassword + } + + if obj.PlainTextPassword != nil { + return obj.PlainTextPassword + } + + // all schemas are nil + return nil +} + +type NullableUserPassword struct { + value *UserPassword + isSet bool +} + +func (v NullableUserPassword) Get() *UserPassword { + return v.value +} + +func (v *NullableUserPassword) Set(val *UserPassword) { + v.value = val + v.isSet = true +} + +func (v NullableUserPassword) IsSet() bool { + return v.isSet +} + +func (v *NullableUserPassword) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableUserPassword(val *UserPassword) *NullableUserPassword { + return &NullableUserPassword{value: val, isSet: true} +} + +func (v NullableUserPassword) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableUserPassword) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/response.go b/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/response.go new file mode 100644 index 000000000..5ff22b9c2 --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/response.go @@ -0,0 +1,74 @@ +/* + * In-Memory DB API + * + * API description for the IONOS In-Memory DB + * + * API version: 1.0.0 + * Contact: support@cloud.ionos.com + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package ionoscloud + +import ( + "log" + "net/http" + "time" +) + +// APIResponse stores the API response returned by the server. +type APIResponse struct { + *http.Response `json:"-"` + Message string `json:"message,omitempty"` + // Operation is the name of the OpenAPI operation. + Operation string `json:"operation,omitempty"` + // RequestURL is the request URL. This value is always available, even if the + // embedded *http.Response is nil. + RequestURL string `json:"url,omitempty"` + // RequestTime is the time duration from the moment the APIClient sends + // the HTTP request to the moment it receives an HTTP response. + RequestTime time.Duration `json:"duration,omitempty"` + // Method is the HTTP method used for the request. This value is always + // available, even if the embedded *http.Response is nil. + Method string `json:"method,omitempty"` + // Payload holds the contents of the response body (which may be nil or empty). + // This is provided here as the raw response.Body() reader will have already + // been drained. + Payload []byte `json:"-"` +} + +// NewAPIResponse returns a new APIResponse object. +func NewAPIResponse(r *http.Response) *APIResponse { + + response := &APIResponse{Response: r} + return response +} + +// NewAPIResponseWithError returns a new APIResponse object with the provided error message. +func NewAPIResponseWithError(errorMessage string) *APIResponse { + + response := &APIResponse{Message: errorMessage} + return response +} + +// HttpNotFound - returns true if a 404 status code was returned +// returns false for nil APIResponse values +func (resp *APIResponse) HttpNotFound() bool { + if resp != nil && resp.Response != nil && resp.StatusCode == http.StatusNotFound { + return true + } + return false +} + +// LogInfo - logs APIResponse values like RequestTime, Operation and StatusCode +// does not print anything for nil APIResponse values +func (resp *APIResponse) LogInfo() { + if resp != nil { + log.Printf("[DEBUG] Request time : %s for operation : %s", + resp.RequestTime, resp.Operation) + if resp.Response != nil { + log.Printf("[DEBUG] response status code : %d\n", resp.StatusCode) + } + } +} diff --git a/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/utils.go b/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/utils.go new file mode 100644 index 000000000..e598a7cf6 --- /dev/null +++ b/vendor/github.com/ionos-cloud/sdk-go-dbaas-in-memory-db/utils.go @@ -0,0 +1,777 @@ +/* + * In-Memory DB API + * + * API description for the IONOS In-Memory DB + * + * API version: 1.0.0 + * Contact: support@cloud.ionos.com + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package ionoscloud + +import ( + "encoding/json" + "reflect" + "time" +) + +// ToPtr - returns a pointer to the given value. +func ToPtr[T any](v T) *T { + return &v +} + +// ToValue - returns the value of the pointer passed in +func ToValue[T any](ptr *T) T { + return *ptr +} + +// ToValueDefault - returns the value of the pointer passed in, or the default type value if the pointer is nil +func ToValueDefault[T any](ptr *T) T { + var defaultVal T + if ptr == nil { + return defaultVal + } + return *ptr +} + +func SliceToValueDefault[T any](ptrSlice *[]T) []T { + return append([]T{}, *ptrSlice...) +} + +// PtrBool - returns a pointer to given boolean value. +func PtrBool(v bool) *bool { return &v } + +// PtrInt - returns a pointer to given integer value. +func PtrInt(v int) *int { return &v } + +// PtrInt32 - returns a pointer to given integer value. +func PtrInt32(v int32) *int32 { return &v } + +// PtrInt64 - returns a pointer to given integer value. +func PtrInt64(v int64) *int64 { return &v } + +// PtrFloat32 - returns a pointer to given float value. +func PtrFloat32(v float32) *float32 { return &v } + +// PtrFloat64 - returns a pointer to given float value. +func PtrFloat64(v float64) *float64 { return &v } + +// PtrString - returns a pointer to given string value. +func PtrString(v string) *string { return &v } + +// PtrTime - returns a pointer to given Time value. +func PtrTime(v time.Time) *time.Time { return &v } + +// ToBool - returns the value of the bool pointer passed in +func ToBool(ptr *bool) bool { + return *ptr +} + +// ToBoolDefault - returns the value of the bool pointer passed in, or false if the pointer is nil +func ToBoolDefault(ptr *bool) bool { + var defaultVal bool + if ptr == nil { + return defaultVal + } + return *ptr +} + +// ToBoolSlice - returns a bool slice of the pointer passed in +func ToBoolSlice(ptrSlice *[]bool) []bool { + valSlice := make([]bool, len(*ptrSlice)) + for i, v := range *ptrSlice { + valSlice[i] = v + } + + return valSlice +} + +// ToByte - returns the value of the byte pointer passed in +func ToByte(ptr *byte) byte { + return *ptr +} + +// ToByteDefault - returns the value of the byte pointer passed in, or 0 if the pointer is nil +func ToByteDefault(ptr *byte) byte { + var defaultVal byte + if ptr == nil { + return defaultVal + } + + return *ptr +} + +// ToByteSlice - returns a byte slice of the pointer passed in +func ToByteSlice(ptrSlice *[]byte) []byte { + valSlice := make([]byte, len(*ptrSlice)) + for i, v := range *ptrSlice { + valSlice[i] = v + } + + return valSlice +} + +// ToString - returns the value of the string pointer passed in +func ToString(ptr *string) string { + return *ptr +} + +// ToStringDefault - returns the value of the string pointer passed in, or "" if the pointer is nil +func ToStringDefault(ptr *string) string { + var defaultVal string + if ptr == nil { + return defaultVal + } + + return *ptr +} + +// ToStringSlice - returns a string slice of the pointer passed in +func ToStringSlice(ptrSlice *[]string) []string { + valSlice := make([]string, len(*ptrSlice)) + for i, v := range *ptrSlice { + valSlice[i] = v + } + + return valSlice +} + +// ToInt - returns the value of the int pointer passed in +func ToInt(ptr *int) int { + return *ptr +} + +// ToIntDefault - returns the value of the int pointer passed in, or 0 if the pointer is nil +func ToIntDefault(ptr *int) int { + var defaultVal int + if ptr == nil { + return defaultVal + } + return *ptr +} + +// ToIntSlice - returns a int slice of the pointer passed in +func ToIntSlice(ptrSlice *[]int) []int { + valSlice := make([]int, len(*ptrSlice)) + for i, v := range *ptrSlice { + valSlice[i] = v + } + + return valSlice +} + +// ToInt8 - returns the value of the int8 pointer passed in +func ToInt8(ptr *int8) int8 { + return *ptr +} + +// ToInt8Default - returns the value of the int8 pointer passed in, or 0 if the pointer is nil +func ToInt8Default(ptr *int8) int8 { + var defaultVal int8 + if ptr == nil { + return defaultVal + } + return *ptr +} + +// ToInt8Slice - returns a int8 slice of the pointer passed in +func ToInt8Slice(ptrSlice *[]int8) []int8 { + valSlice := make([]int8, len(*ptrSlice)) + for i, v := range *ptrSlice { + valSlice[i] = v + } + + return valSlice +} + +// ToInt16 - returns the value of the int16 pointer passed in +func ToInt16(ptr *int16) int16 { + return *ptr +} + +// ToInt16Default - returns the value of the int16 pointer passed in, or 0 if the pointer is nil +func ToInt16Default(ptr *int16) int16 { + var defaultVal int16 + if ptr == nil { + return defaultVal + } + return *ptr +} + +// ToInt16Slice - returns a int16 slice of the pointer passed in +func ToInt16Slice(ptrSlice *[]int16) []int16 { + valSlice := make([]int16, len(*ptrSlice)) + for i, v := range *ptrSlice { + valSlice[i] = v + } + + return valSlice +} + +// ToInt32 - returns the value of the int32 pointer passed in +func ToInt32(ptr *int32) int32 { + return *ptr +} + +// ToInt32Default - returns the value of the int32 pointer passed in, or 0 if the pointer is nil +func ToInt32Default(ptr *int32) int32 { + var defaultVal int32 + if ptr == nil { + return defaultVal + } + return *ptr +} + +// ToInt32Slice - returns a int32 slice of the pointer passed in +func ToInt32Slice(ptrSlice *[]int32) []int32 { + valSlice := make([]int32, len(*ptrSlice)) + for i, v := range *ptrSlice { + valSlice[i] = v + } + + return valSlice +} + +// ToInt64 - returns the value of the int64 pointer passed in +func ToInt64(ptr *int64) int64 { + return *ptr +} + +// ToInt64Default - returns the value of the int64 pointer passed in, or 0 if the pointer is nil +func ToInt64Default(ptr *int64) int64 { + var defaultVal int64 + if ptr == nil { + return defaultVal + } + return *ptr +} + +// ToInt64Slice - returns a int64 slice of the pointer passed in +func ToInt64Slice(ptrSlice *[]int64) []int64 { + valSlice := make([]int64, len(*ptrSlice)) + for i, v := range *ptrSlice { + valSlice[i] = v + } + + return valSlice +} + +// ToUint - returns the value of the uint pointer passed in +func ToUint(ptr *uint) uint { + return *ptr +} + +// ToUintDefault - returns the value of the uint pointer passed in, or 0 if the pointer is nil +func ToUintDefault(ptr *uint) uint { + var defaultVal uint + if ptr == nil { + return defaultVal + } + return *ptr +} + +// ToUintSlice - returns a uint slice of the pointer passed in +func ToUintSlice(ptrSlice *[]uint) []uint { + valSlice := make([]uint, len(*ptrSlice)) + for i, v := range *ptrSlice { + valSlice[i] = v + } + + return valSlice +} + +// ToUint8 -returns the value of the uint8 pointer passed in +func ToUint8(ptr *uint8) uint8 { + return *ptr +} + +// ToUint8Default - returns the value of the uint8 pointer passed in, or 0 if the pointer is nil +func ToUint8Default(ptr *uint8) uint8 { + var defaultVal uint8 + if ptr == nil { + return defaultVal + } + return *ptr +} + +// ToUint8Slice - returns a uint8 slice of the pointer passed in +func ToUint8Slice(ptrSlice *[]uint8) []uint8 { + valSlice := make([]uint8, len(*ptrSlice)) + for i, v := range *ptrSlice { + valSlice[i] = v + } + + return valSlice +} + +// ToUint16 - returns the value of the uint16 pointer passed in +func ToUint16(ptr *uint16) uint16 { + return *ptr +} + +// ToUint16Default - returns the value of the uint16 pointer passed in, or 0 if the pointer is nil +func ToUint16Default(ptr *uint16) uint16 { + var defaultVal uint16 + if ptr == nil { + return defaultVal + } + return *ptr +} + +// ToUint16Slice - returns a uint16 slice of the pointer passed in +func ToUint16Slice(ptrSlice *[]uint16) []uint16 { + valSlice := make([]uint16, len(*ptrSlice)) + for i, v := range *ptrSlice { + valSlice[i] = v + } + + return valSlice +} + +// ToUint32 - returns the value of the uint32 pointer passed in +func ToUint32(ptr *uint32) uint32 { + return *ptr +} + +// ToUint32Default - returns the value of the uint32 pointer passed in, or 0 if the pointer is nil +func ToUint32Default(ptr *uint32) uint32 { + var defaultVal uint32 + if ptr == nil { + return defaultVal + } + return *ptr +} + +// ToUint32Slice - returns a uint32 slice of the pointer passed in +func ToUint32Slice(ptrSlice *[]uint32) []uint32 { + valSlice := make([]uint32, len(*ptrSlice)) + for i, v := range *ptrSlice { + valSlice[i] = v + } + + return valSlice +} + +// ToUint64 - returns the value of the uint64 pointer passed in +func ToUint64(ptr *uint64) uint64 { + return *ptr +} + +// ToUint64Default - returns the value of the uint64 pointer passed in, or 0 if the pointer is nil +func ToUint64Default(ptr *uint64) uint64 { + var defaultVal uint64 + if ptr == nil { + return defaultVal + } + return *ptr +} + +// ToUint64Slice - returns a uint63 slice of the pointer passed in +func ToUint64Slice(ptrSlice *[]uint64) []uint64 { + valSlice := make([]uint64, len(*ptrSlice)) + for i, v := range *ptrSlice { + valSlice[i] = v + } + + return valSlice +} + +// ToFloat32 - returns the value of the float32 pointer passed in +func ToFloat32(ptr *float32) float32 { + return *ptr +} + +// ToFloat32Default - returns the value of the float32 pointer passed in, or 0 if the pointer is nil +func ToFloat32Default(ptr *float32) float32 { + var defaultVal float32 + if ptr == nil { + return defaultVal + } + return *ptr +} + +// ToFloat32Slice - returns a float32 slice of the pointer passed in +func ToFloat32Slice(ptrSlice *[]float32) []float32 { + valSlice := make([]float32, len(*ptrSlice)) + for i, v := range *ptrSlice { + valSlice[i] = v + } + + return valSlice +} + +// ToFloat64 - returns the value of the float64 pointer passed in +func ToFloat64(ptr *float64) float64 { + return *ptr +} + +// ToFloat64Default - returns the value of the float64 pointer passed in, or 0 if the pointer is nil +func ToFloat64Default(ptr *float64) float64 { + var defaultVal float64 + if ptr == nil { + return defaultVal + } + return *ptr +} + +// ToFloat64Slice - returns a float64 slice of the pointer passed in +func ToFloat64Slice(ptrSlice *[]float64) []float64 { + valSlice := make([]float64, len(*ptrSlice)) + for i, v := range *ptrSlice { + valSlice[i] = v + } + + return valSlice +} + +// ToTime - returns the value of the Time pointer passed in +func ToTime(ptr *time.Time) time.Time { + return *ptr +} + +// ToTimeDefault - returns the value of the Time pointer passed in, or 0001-01-01 00:00:00 +0000 UTC if the pointer is nil +func ToTimeDefault(ptr *time.Time) time.Time { + var defaultVal time.Time + if ptr == nil { + return defaultVal + } + return *ptr +} + +// ToTimeSlice - returns a Time slice of the pointer passed in +func ToTimeSlice(ptrSlice *[]time.Time) []time.Time { + valSlice := make([]time.Time, len(*ptrSlice)) + for i, v := range *ptrSlice { + valSlice[i] = v + } + + return valSlice +} + +type NullableBool struct { + value *bool + isSet bool +} + +func (v NullableBool) Get() *bool { + return v.value +} + +func (v *NullableBool) Set(val *bool) { + v.value = val + v.isSet = true +} + +func (v NullableBool) IsSet() bool { + return v.isSet +} + +func (v *NullableBool) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableBool(val *bool) *NullableBool { + return &NullableBool{value: val, isSet: true} +} + +func (v NullableBool) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableBool) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} + +type NullableInt struct { + value *int + isSet bool +} + +func (v NullableInt) Get() *int { + return v.value +} + +func (v *NullableInt) Set(val *int) { + v.value = val + v.isSet = true +} + +func (v NullableInt) IsSet() bool { + return v.isSet +} + +func (v *NullableInt) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableInt(val *int) *NullableInt { + return &NullableInt{value: val, isSet: true} +} + +func (v NullableInt) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableInt) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} + +type NullableInt32 struct { + value *int32 + isSet bool +} + +func (v NullableInt32) Get() *int32 { + return v.value +} + +func (v *NullableInt32) Set(val *int32) { + v.value = val + v.isSet = true +} + +func (v NullableInt32) IsSet() bool { + return v.isSet +} + +func (v *NullableInt32) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableInt32(val *int32) *NullableInt32 { + return &NullableInt32{value: val, isSet: true} +} + +func (v NullableInt32) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableInt32) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} + +type NullableInt64 struct { + value *int64 + isSet bool +} + +func (v NullableInt64) Get() *int64 { + return v.value +} + +func (v *NullableInt64) Set(val *int64) { + v.value = val + v.isSet = true +} + +func (v NullableInt64) IsSet() bool { + return v.isSet +} + +func (v *NullableInt64) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableInt64(val *int64) *NullableInt64 { + return &NullableInt64{value: val, isSet: true} +} + +func (v NullableInt64) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableInt64) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} + +type NullableFloat32 struct { + value *float32 + isSet bool +} + +func (v NullableFloat32) Get() *float32 { + return v.value +} + +func (v *NullableFloat32) Set(val *float32) { + v.value = val + v.isSet = true +} + +func (v NullableFloat32) IsSet() bool { + return v.isSet +} + +func (v *NullableFloat32) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableFloat32(val *float32) *NullableFloat32 { + return &NullableFloat32{value: val, isSet: true} +} + +func (v NullableFloat32) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableFloat32) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} + +type NullableFloat64 struct { + value *float64 + isSet bool +} + +func (v NullableFloat64) Get() *float64 { + return v.value +} + +func (v *NullableFloat64) Set(val *float64) { + v.value = val + v.isSet = true +} + +func (v NullableFloat64) IsSet() bool { + return v.isSet +} + +func (v *NullableFloat64) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableFloat64(val *float64) *NullableFloat64 { + return &NullableFloat64{value: val, isSet: true} +} + +func (v NullableFloat64) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableFloat64) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} + +type NullableString struct { + value *string + isSet bool +} + +func (v NullableString) Get() *string { + return v.value +} + +func (v *NullableString) Set(val *string) { + v.value = val + v.isSet = true +} + +func (v NullableString) IsSet() bool { + return v.isSet +} + +func (v *NullableString) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableString(val *string) *NullableString { + return &NullableString{value: val, isSet: true} +} + +func (v NullableString) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableString) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} + +type NullableTime struct { + value *time.Time + isSet bool +} + +func (v NullableTime) Get() *time.Time { + return v.value +} + +func (v *NullableTime) Set(val *time.Time) { + v.value = val + v.isSet = true +} + +func (v NullableTime) IsSet() bool { + return v.isSet +} + +func (v *NullableTime) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableTime(val *time.Time) *NullableTime { + return &NullableTime{value: val, isSet: true} +} + +func (v NullableTime) MarshalJSON() ([]byte, error) { + return v.value.MarshalJSON() +} + +func (v *NullableTime) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} + +type IonosTime struct { + time.Time +} + +func (t *IonosTime) UnmarshalJSON(data []byte) error { + str := string(data) + if strlen(str) == 0 { + t = nil + return nil + } + if str[0] == '"' { + str = str[1:] + } + if str[len(str)-1] == '"' { + str = str[:len(str)-1] + } + tt, err := time.Parse(time.RFC3339, str) + if err != nil { + return err + } + *t = IonosTime{tt} + return nil +} + +// IsNil checks if an input is nil +func IsNil(i interface{}) bool { + if i == nil { + return true + } + switch reflect.TypeOf(i).Kind() { + case reflect.Chan, reflect.Func, reflect.Map, reflect.Ptr, reflect.UnsafePointer, reflect.Interface, reflect.Slice: + return reflect.ValueOf(i).IsNil() + case reflect.Array: + return reflect.ValueOf(i).IsZero() + } + return false +} diff --git a/vendor/modules.txt b/vendor/modules.txt index d42afa289..c4eb38b39 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -316,6 +316,9 @@ github.com/ionos-cloud/sdk-go-container-registry # github.com/ionos-cloud/sdk-go-dataplatform v1.0.3 ## explicit; go 1.18 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 ## explicit; go 1.18 github.com/ionos-cloud/sdk-go-dbaas-mariadb