diff --git a/CHANGELOG.md b/CHANGELOG.md index 01015fc3..a73f3c8a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,18 +1,42 @@ # Changelog + All notable changes to this project will be documented in this file. See updating [Changelog example here](https://keepachangelog.com/en/1.0.0/) +## 1.7.0 (29th April 2024) + +### Changed + +- Deprecated datasources: `rediscloud_subscription`, `rediscloud_database` +- Deprecated + resources: `rediscloud_subscription`, `rediscloud_subscription_database`, `rediscloud_active_active_subscription_database` + +### Added + +- To replace the deprecated datasources: `rediscloud_flexible_subscription`, `rediscloud_flexible_database` +- To replace the deprecated + resources: `rediscloud_flexible_subscription`, `rediscloud_flexible_database`, `rediscloud_active_active_database` +- Datasources for Active Active features: `rediscloud_active_active_subscription`, `rediscloud_active_active_database` +- Datasources for Essentials + features: `rediscloud_essentials_plan`, `rediscloud_essentials_subscription`, `rediscloud_essentials_database` +- Resources for Essentials features: `rediscloud_essentials_subscription`, `rediscloud_essentials_database` +- `modules`/`global_modules` can be specified on Active Active Subscription/Database resources, enabling `RedisJSON` +- All Subscription resources include the `pricing` attribute +- All Database resources include `latest_backup_status` and `latest_import_status` attributes as appropriate + ## 1.6.0 (12 April 2024) ### Fixed - using the `rediscloud_database` datasource no longer crashes when pointed to an ActiveActive database but offers -limited data. A specific datasource type will be coming soon. + limited data. A specific datasource type will be coming soon. ### Changed -- A subscription's `payment_method` can no longer be updated. It is ignored after resource creation (as with `creation_plan`). -This means if it has been changed behind the scenes, reapplying the same Terraform configuration should not change anything. +- A subscription's `payment_method` can no longer be updated. It is ignored after resource creation (as + with `creation_plan`). + This means if it has been changed behind the scenes, reapplying the same Terraform configuration should not change + anything. ## 1.5.0 (24 November 2023) @@ -41,90 +65,107 @@ This means if it has been changed behind the scenes, reapplying the same Terrafo ### Removed - The `REDISCLOUD_SUBSCRIPTION_TIMEOUT` environment variable is gone. Subscription creation times out after the user's -setting (or 30 minutes by default). Note there is a 6-hour cap, regardless of the user's setting. + setting (or 30 minutes by default). Note there is a 6-hour cap, regardless of the user's setting. ## 1.3.2 (9 October 2023) ### Added + - Added a new environment variable `REDISCLOUD_SUBSCRIPTION_TIMEOUT` to allow - configuring timeouts for subscriptions at the provider level. - This is a **TEMPORARY** solution and will be deleted in the next releases. + configuring timeouts for subscriptions at the provider level. + This is a **TEMPORARY** solution and will be deleted in the next releases. ## 1.3.1 (10 August 2023) ### Fixed + - Documentation fixes ## 1.3.0 (7 August 2023) ### Added + - Added ACL resources and data sources (users, roles, rules) ## 1.2.0 (9 June 2023) ### Added + - Add support for using a custom port number in normal or active/active databases - Add support for configuring backups for normal or active/active databases - Add support for peering normal or active/active subscriptions with AWS VPCs that use multiple CIDR ranges ### Fixed + - Documentation fixes - Make CI runs stream test output rather than batching it up at the end ### Changed + - `rediscloud_subscription.preferred_availability_zones` changed to optional - `rediscloud_subscription.modules` changed to optional - `rediscloud_subscription_database.protocol` changed to default to `redis` - Mark `rediscloud_subscription_database.periodic_backup_path` as deprecated - use `remote_backup` instead. -- Emit a warning if `average_item_size_in_bytes` has been specified when `memory_storage` is set to `ram` as this attribute is only applicable with `ram-and-flash` storage. +- Emit a warning if `average_item_size_in_bytes` has been specified when `memory_storage` is set to `ram` as this + attribute is only applicable with `ram-and-flash` storage. ## 1.1.1 (6 March 2023) ### Fixed + - Documentation fixes ## 1.1.0 (6 March 2023) ### Added + - Added support for active/active databases ### Fixed + - Documentation fixes ## 1.0.3 (1 February 2023) ### Fixed + - Documentation fixes ## 1.0.2 (16 January 2023) ### Fixed + - Documentation fixes ## 1.0.1 (12 September 2022) ### Changed -- Changed the `average_item_size_in_bytes` attribute of the creation_plan block to send a “null” value to the API if omitted. + +- Changed the `average_item_size_in_bytes` attribute of the creation_plan block to send a “null” value to the API if + omitted. ### Fixed -- Various documentation fixes -- Fixed an issue where the `source_ips` and `enable_tls` attributes were not being provisioned correctly on the `rediscloud_subscription_database` resource +- Various documentation fixes +- Fixed an issue where the `source_ips` and `enable_tls` attributes were not being provisioned correctly on + the `rediscloud_subscription_database` resource ## 1.0.0 (30 August 2022) ### Added + - Added the creation_plan block in the subscription resource schema. - Added a new resource type: `rediscloud_subscription_database`. - Added the migration guide to help users with migrating their old Terraform configuration files to v1.0.0. -- Multi-modules: Added the "modules" attribute into the creation_plan block -and the database resource schema +- Multi-modules: Added the "modules" attribute into the creation_plan block + and the database resource schema ### Changed - Updates to dependencies and CI related actions ### Removed + - Removed the database block from the subscription resource schema. ## 0.3.0 (May 24 2022) @@ -136,7 +177,7 @@ and the database resource schema ### Removed -- Removed a deprecated attribute: persistent_storage_encryption +- Removed a deprecated attribute: persistent_storage_encryption ### Changed @@ -184,7 +225,8 @@ and the database resource schema ### Fixed -- Redis Cloud subscription update is failing due to missing payment method id [#149](https://github.com/RedisLabs/terraform-provider-rediscloud/pull/149) +- Redis Cloud subscription update is failing due to missing payment method + id [#149](https://github.com/RedisLabs/terraform-provider-rediscloud/pull/149) - Wrong syntax in example. [#153](https://github.com/RedisLabs/terraform-provider-rediscloud/pull/153) ## 0.2.4 (July 24, 2021) @@ -192,13 +234,16 @@ and the database resource schema ### Changed - Updates additional dependencies contributing to build, (includes tfproviderlint v0.27.1) -- Updates location of compiled provider as well as go and terraform versions [#129](https://github.com/RedisLabs/terraform-provider-rediscloud/pull/129) +- Updates location of compiled provider as well as go and terraform + versions [#129](https://github.com/RedisLabs/terraform-provider-rediscloud/pull/129) - Updates Terraform Plugin SDK to v2.7.0 -- Updates the subscription timeout value for update function to 30 minutes [#133](https://github.com/RedisLabs/terraform-provider-rediscloud/pull/133) +- Updates the subscription timeout value for update function to 30 + minutes [#133](https://github.com/RedisLabs/terraform-provider-rediscloud/pull/133) ### Fixed -- Fixed parsing of log-levels by removing date/time prefix [#132](https://github.com/RedisLabs/terraform-provider-rediscloud/pull/132) +- Fixed parsing of log-levels by removing date/time + prefix [#132](https://github.com/RedisLabs/terraform-provider-rediscloud/pull/132) ## 0.2.3 (June 22, 2021) @@ -208,7 +253,8 @@ and the database resource schema ### Fixed -- replicaOf setting cannot be disabled from terraform [#121](https://github.com/RedisLabs/terraform-provider-rediscloud/issues/121) +- replicaOf setting cannot be disabled from + terraform [#121](https://github.com/RedisLabs/terraform-provider-rediscloud/issues/121) ## 0.2.2 (April 27, 2021) @@ -219,9 +265,13 @@ and the database resource schema - Updates additional dependencies contributing to build ### Fixed -- Terraform wants to replace fresh imported peering [#102](https://github.com/RedisLabs/terraform-provider-rediscloud/issues/102) -- Need validation for length of the database name [#99](https://github.com/RedisLabs/terraform-provider-rediscloud/issues/99) -- Modules not included when creating DB on existing subscription in GCP [#98](https://github.com/RedisLabs/terraform-provider-rediscloud/issues/98) + +- Terraform wants to replace fresh imported + peering [#102](https://github.com/RedisLabs/terraform-provider-rediscloud/issues/102) +- Need validation for length of the database + name [#99](https://github.com/RedisLabs/terraform-provider-rediscloud/issues/99) +- Modules not included when creating DB on existing subscription in + GCP [#98](https://github.com/RedisLabs/terraform-provider-rediscloud/issues/98) ## 0.2.1 (December 7, 2020) @@ -242,9 +292,11 @@ and the database resource schema - Website documentation and HCL examples to correct spelling and update content - Changelog to record released content -- `network_deployment_cidr` is now required and to resolve issues with plan convergence after a successful Terraform apply -- `network_deployment_cidr` and `networking_vpc_id` were excluded from the hash calculation as -- `networks` added to the `region` block in subscription resource and data source to allow reading all different CIDR and subnets in Multi-AZ subscription +- `network_deployment_cidr` is now required and to resolve issues with plan convergence after a successful Terraform + apply +- `network_deployment_cidr` and `networking_vpc_id` were excluded from the hash calculation as +- `networks` added to the `region` block in subscription resource and data source to allow reading all different CIDR + and subnets in Multi-AZ subscription - Fixed issues when creating a subscription without a payment method ### Removed @@ -257,7 +309,6 @@ and the database resource schema - Released through `registry.terraform.io` RedisLabs/rediscloud - ## 0.1.0 (November 24, 2020) ### Added diff --git a/docs/data-sources/rediscloud_active_active_database.md b/docs/data-sources/rediscloud_active_active_database.md index d1a1d9bc..792a0dee 100644 --- a/docs/data-sources/rediscloud_active_active_database.md +++ b/docs/data-sources/rediscloud_active_active_database.md @@ -49,4 +49,22 @@ data "rediscloud_active_active_database" "example" { * `global_modules` - A list of modules to be enabled on all deployments of this database. * `public_endpoint` - Public endpoint to access the database. * `private_endpoint` - Private endpoint to access the database. -* `latest_import_status` - An object containing the JSON-formatted response detailing the latest import status (or an error if the lookup failed). +* `latest_import_status` - A latest_import_status object, documented below. + +The `latest_import_status` block contains: + +* `error` - An error block, in case this lookup failed, documented below. +* `response` - A detail block, documented below. + +The `error` block in `latest_import_status` contains: + +* `type` - The type of error encountered while looking up the status of the last import. +* `description` - A description of the error encountered while looking up the status of the last import. +* `status` - Any particular HTTP status code associated with the erroneous status check. + +The `response` block `latest_import_status` contains: + +* `status` - The status of the last import operation. +* `last_import_time` - When the last import operation occurred. +* `failure_reason` - If a failure, why the import operation failed. +* `failure_reason_params` - Parameters of the failure, if appropriate, in the form of a list of objects each with a `key` entry and a `value` entry. diff --git a/docs/data-sources/rediscloud_essentials_database.md b/docs/data-sources/rediscloud_essentials_database.md index 2bc00fc5..b6db184c 100644 --- a/docs/data-sources/rediscloud_essentials_database.md +++ b/docs/data-sources/rediscloud_essentials_database.md @@ -56,8 +56,8 @@ data "rediscloud_essentials_database" "example" { * `enable_default_user` - When `true` enables connecting to the database with the default user. * `alert` - Set of alerts to enable on the database, documented below. * `modules` A list of database modules, documented below. -* `latest_backup_status` - An object containing the JSON-formatted response detailing the latest backup status (or an error if the lookup failed). -* `latest_import_status` - An object containing the JSON-formatted response detailing the latest import status (or an error if the lookup failed). +* `latest_backup_status` - A latest_backup_status object, documented below. +* `latest_import_status` - A latest_import_status object, documented below. The `replica` block supports: @@ -77,3 +77,27 @@ The `alert` block supports: Each `modules` entry provides the following attributes: * `name` - The identifier assigned by the database module. + +The `latest_backup_status` and `latest_import_status` blocks contain: + +* `error` - An error block, in case this lookup failed, documented below. +* `response` - A detail block, documented below. + +The `error` block in both `latest_backup_status` and `latest_import_status` contains: + +* `type` - The type of error encountered while looking up the status of the last backup/import. +* `description` - A description of the error encountered while looking up the status of the last backup/import. +* `status` - Any particular HTTP status code associated with the erroneous status check. + +The `response` block `latest_backup_status` contains: + +* `status` - The status of the last backup operation. +* `last_backup_time` - When the last backup operation occurred. +* `failure_reason` - If a failure, why the backup operation failed. + +The `response` block `latest_import_status` contains: + +* `status` - The status of the last import operation. +* `last_import_time` - When the last import operation occurred. +* `failure_reason` - If a failure, why the import operation failed. +* `failure_reason_params` - Parameters of the failure, if appropriate, in the form of a list of objects each with a `key` entry and a `value` entry. diff --git a/docs/data-sources/rediscloud_flexible_database.md b/docs/data-sources/rediscloud_flexible_database.md index 6f355211..692b64d0 100644 --- a/docs/data-sources/rediscloud_flexible_database.md +++ b/docs/data-sources/rediscloud_flexible_database.md @@ -59,10 +59,34 @@ data "rediscloud_flexible_database" "example" { * `private_endpoint` - Private endpoint to access the database * `enable_tls` - Enable TLS for database, default is `false` * `enable_default_user` - When `true` enables connecting to the database with the default user. Default `true`. -* `latest_backup_status` - An object containing the JSON-formatted response detailing the latest backup status (or an error if the lookup failed). -* `latest_import_status` - An object containing the JSON-formatted response detailing the latest import status (or an error if the lookup failed). +* `latest_backup_status` - A latest_backup_status object, documented below. +* `latest_import_status` - A latest_import_status object, documented below. The `alert` block supports: * `name` - The alert name * `value` - The alert value + +The `latest_backup_status` and `latest_import_status` blocks contain: + +* `error` - An error block, in case this lookup failed, documented below. +* `response` - A detail block, documented below. + +The `error` block in both `latest_backup_status` and `latest_import_status` contains: + +* `type` - The type of error encountered while looking up the status of the last backup/import. +* `description` - A description of the error encountered while looking up the status of the last backup/import. +* `status` - Any particular HTTP status code associated with the erroneous status check. + +The `response` block `latest_backup_status` contains: + +* `status` - The status of the last backup operation. +* `last_backup_time` - When the last backup operation occurred. +* `failure_reason` - If a failure, why the backup operation failed. + +The `response` block `latest_import_status` contains: + +* `status` - The status of the last import operation. +* `last_import_time` - When the last import operation occurred. +* `failure_reason` - If a failure, why the import operation failed. +* `failure_reason_params` - Parameters of the failure, if appropriate, in the form of a list of objects each with a `key` entry and a `value` entry. diff --git a/docs/resources/rediscloud_active_active_database.md b/docs/resources/rediscloud_active_active_database.md index 5386086e..8633127c 100644 --- a/docs/resources/rediscloud_active_active_database.md +++ b/docs/resources/rediscloud_active_active_database.md @@ -133,7 +133,25 @@ The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/l * `db_id` - Identifier of the database created * `public_endpoint` - A map of which public endpoints can to access the database per region, uses region name as key. * `private_endpoint` - A map of which private endpoints can to access the database per region, uses region name as key. -* `latest_import_status` - An object containing the JSON-formatted response detailing the latest import status (or an error if the lookup failed). +* `latest_import_status` - A latest_import_status object, documented below. + +The `latest_import_status` block contains: + +* `error` - An error block, in case this lookup failed, documented below. +* `response` - A detail block, documented below. + +The `error` block in `latest_import_status` contains: + +* `type` - The type of error encountered while looking up the status of the last import. +* `description` - A description of the error encountered while looking up the status of the last import. +* `status` - Any particular HTTP status code associated with the erroneous status check. + +The `response` block `latest_import_status` contains: + +* `status` - The status of the last import operation. +* `last_import_time` - When the last import operation occurred. +* `failure_reason` - If a failure, why the import operation failed. +* `failure_reason_params` - Parameters of the failure, if appropriate, in the form of a list of objects each with a `key` entry and a `value` entry. ## Import `rediscloud_active_active_database` can be imported using the ID of the Active-Active subscription and the ID of the database in the format {subscription ID}/{database ID}, e.g. diff --git a/docs/resources/rediscloud_active_active_subscription_database.md b/docs/resources/rediscloud_active_active_subscription_database.md index 6562deef..5e209cc5 100644 --- a/docs/resources/rediscloud_active_active_subscription_database.md +++ b/docs/resources/rediscloud_active_active_subscription_database.md @@ -136,7 +136,25 @@ The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/l * `db_id` - Identifier of the database created * `public_endpoint` - A map of which public endpoints can to access the database per region, uses region name as key. * `private_endpoint` - A map of which private endpoints can to access the database per region, uses region name as key. -* `latest_import_status` - An object containing the JSON-formatted response detailing the latest import status (or an error if the lookup failed). +* `latest_import_status` - A latest_import_status object, documented below. + +The `latest_import_status` block contains: + +* `error` - An error block, in case this lookup failed, documented below. +* `response` - A detail block, documented below. + +The `error` block in `latest_import_status` contains: + +* `type` - The type of error encountered while looking up the status of the last import. +* `description` - A description of the error encountered while looking up the status of the last import. +* `status` - Any particular HTTP status code associated with the erroneous status check. + +The `response` block `latest_import_status` contains: + +* `status` - The status of the last import operation. +* `last_import_time` - When the last import operation occurred. +* `failure_reason` - If a failure, why the import operation failed. +* `failure_reason_params` - Parameters of the failure, if appropriate, in the form of a list of objects each with a `key` entry and a `value` entry. ## Import `rediscloud_active_active_subscription_database` can be imported using the ID of the Active-Active subscription and the ID of the database in the format {subscription ID}/{database ID}, e.g. diff --git a/docs/resources/rediscloud_active_active_subscription_regions.md b/docs/resources/rediscloud_active_active_subscription_regions.md index 756e2f48..925841b8 100644 --- a/docs/resources/rediscloud_active_active_subscription_regions.md +++ b/docs/resources/rediscloud_active_active_subscription_regions.md @@ -68,7 +68,24 @@ The `database` block supports: ## Attribute Reference -* `latest_backup_status` - An object containing the JSON-formatted response detailing the latest backup status (or an error if the lookup failed). +* `latest_backup_status` - A latest_backup_status object, documented below. + +The `latest_backup_status` block contains: + +* `error` - An error block, in case this lookup failed, documented below. +* `response` - A detail block, documented below. + +The `error` block in both `latest_backup_status` contains: + +* `type` - The type of error encountered while looking up the status of the last import. +* `description` - A description of the error encountered while looking up the status of the last import. +* `status` - Any particular HTTP status code associated with the erroneous status check. + +The `response` block `latest_backup_status` contains: + +* `status` - The status of the last backup operation. +* `last_backup_time` - When the last backup operation occurred. +* `failure_reason` - If a failure, why the backup operation failed. ### Timeouts diff --git a/docs/resources/rediscloud_essentials_database.md b/docs/resources/rediscloud_essentials_database.md index 2eace53e..f5aa25f8 100644 --- a/docs/resources/rediscloud_essentials_database.md +++ b/docs/resources/rediscloud_essentials_database.md @@ -88,5 +88,29 @@ Each `modules` entry provides the following attributes: * `activated_on` - When this database was activated. * `public_endpoint` - Public endpoint to access the database. * `private_endpoint` - Private endpoint to access the database. -* `latest_backup_status` - An object containing the JSON-formatted response detailing the latest backup status (or an error if the lookup failed). -* `latest_import_status` - An object containing the JSON-formatted response detailing the latest import status (or an error if the lookup failed). +* `latest_backup_status` - A latest_backup_status object, documented below. +* `latest_import_status` - A latest_import_status object, documented below. + +The `latest_backup_status` and `latest_import_status` blocks contain: + +* `error` - An error block, in case this lookup failed, documented below. +* `response` - A detail block, documented below. + +The `error` block in both `latest_backup_status` and `latest_import_status` contains: + +* `type` - The type of error encountered while looking up the status of the last backup/import. +* `description` - A description of the error encountered while looking up the status of the last backup/import. +* `status` - Any particular HTTP status code associated with the erroneous status check. + +The `response` block `latest_backup_status` contains: + +* `status` - The status of the last backup operation. +* `last_backup_time` - When the last backup operation occurred. +* `failure_reason` - If a failure, why the backup operation failed. + +The `response` block `latest_import_status` contains: + +* `status` - The status of the last import operation. +* `last_import_time` - When the last import operation occurred. +* `failure_reason` - If a failure, why the import operation failed. +* `failure_reason_params` - Parameters of the failure, if appropriate, in the form of a list of objects each with a `key` entry and a `value` entry. diff --git a/docs/resources/rediscloud_flexible_database.md b/docs/resources/rediscloud_flexible_database.md index 60823c5a..20cd465e 100644 --- a/docs/resources/rediscloud_flexible_database.md +++ b/docs/resources/rediscloud_flexible_database.md @@ -141,8 +141,32 @@ The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/l * `db_id` - Identifier of the database created * `public_endpoint` - Public endpoint to access the database * `private_endpoint` - Private endpoint to access the database -* `latest_backup_status` - An object containing the JSON-formatted response detailing the latest backup status (or an error if the lookup failed). -* `latest_import_status` - An object containing the JSON-formatted response detailing the latest import status (or an error if the lookup failed). +* `latest_backup_status` - A latest_backup_status object, documented below. +* `latest_import_status` - A latest_import_status object, documented below. + +The `latest_backup_status` and `latest_import_status` blocks contain: + +* `error` - An error block, in case this lookup failed, documented below. +* `response` - A detail block, documented below. + +The `error` block in both `latest_backup_status` and `latest_import_status` contains: + +* `type` - The type of error encountered while looking up the status of the last backup/import. +* `description` - A description of the error encountered while looking up the status of the last backup/import. +* `status` - Any particular HTTP status code associated with the erroneous status check. + +The `response` block `latest_backup_status` contains: + +* `status` - The status of the last backup operation. +* `last_backup_time` - When the last backup operation occurred. +* `failure_reason` - If a failure, why the backup operation failed. + +The `response` block `latest_import_status` contains: + +* `status` - The status of the last import operation. +* `last_import_time` - When the last import operation occurred. +* `failure_reason` - If a failure, why the import operation failed. +* `failure_reason_params` - Parameters of the failure, if appropriate, in the form of a list of objects each with a `key` entry and a `value` entry. ## Import `rediscloud_flexible_database` can be imported using the ID of the subscription and the ID of the database in the format {subscription ID}/{database ID}, e.g. diff --git a/docs/resources/rediscloud_subscription_database.md b/docs/resources/rediscloud_subscription_database.md index e7c4ea5c..e4d5b798 100644 --- a/docs/resources/rediscloud_subscription_database.md +++ b/docs/resources/rediscloud_subscription_database.md @@ -150,8 +150,32 @@ The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/l * `db_id` - Identifier of the database created * `public_endpoint` - Public endpoint to access the database * `private_endpoint` - Private endpoint to access the database -* `latest_backup_status` - An object containing the JSON-formatted response detailing the latest backup status (or an error if the lookup failed). -* `latest_import_status` - An object containing the JSON-formatted response detailing the latest import status (or an error if the lookup failed). +* `latest_backup_status` - A latest_backup_status object, documented below. +* `latest_import_status` - A latest_import_status object, documented below. + +The `latest_backup_status` and `latest_import_status` blocks contain: + +* `error` - An error block, in case this lookup failed, documented below. +* `response` - A detail block, documented below. + +The `error` block in both `latest_backup_status` and `latest_import_status` contains: + +* `type` - The type of error encountered while looking up the status of the last backup/import. +* `description` - A description of the error encountered while looking up the status of the last backup/import. +* `status` - Any particular HTTP status code associated with the erroneous status check. + +The `response` block `latest_backup_status` contains: + +* `status` - The status of the last backup operation. +* `last_backup_time` - When the last backup operation occurred. +* `failure_reason` - If a failure, why the backup operation failed. + +The `response` block `latest_import_status` contains: + +* `status` - The status of the last import operation. +* `last_import_time` - When the last import operation occurred. +* `failure_reason` - If a failure, why the import operation failed. +* `failure_reason_params` - Parameters of the failure, if appropriate, in the form of a list of objects each with a `key` entry and a `value` entry. ## Import `rediscloud_subscription_database` can be imported using the ID of the subscription and the ID of the database in the format {subscription ID}/{database ID}, e.g. diff --git a/go.mod b/go.mod index c18d241b..d5efe469 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/RedisLabs/terraform-provider-rediscloud go 1.19 require ( - github.com/RedisLabs/rediscloud-go-api v0.14.2 + github.com/RedisLabs/rediscloud-go-api v0.15.0 github.com/bflad/tfproviderlint v0.29.0 github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 github.com/hashicorp/terraform-plugin-sdk/v2 v2.28.0 diff --git a/go.sum b/go.sum index 8e4b54f1..a0566304 100644 --- a/go.sum +++ b/go.sum @@ -1,8 +1,8 @@ github.com/Microsoft/go-winio v0.5.2 h1:a9IhgEQBCUEk6QCdml9CiJGhAws+YwffDHEMp1VMrpA= github.com/ProtonMail/go-crypto v0.0.0-20230217124315-7d5c6f04bbb8 h1:wPbRQzjjwFc0ih8puEVAOFGELsn1zoIIYdxvML7mDxA= github.com/ProtonMail/go-crypto v0.0.0-20230217124315-7d5c6f04bbb8/go.mod h1:I0gYDMZ6Z5GRU7l58bNFSkPTFN6Yl12dsUlAZ8xy98g= -github.com/RedisLabs/rediscloud-go-api v0.14.2 h1:zHP1m+SMauRt3aDuJkg+kMSCfQO8+/2Y4VESdiw74Oc= -github.com/RedisLabs/rediscloud-go-api v0.14.2/go.mod h1:LTnlcUHd+NU25dXGikLk1hbyROjaaGHvfMbzdNLX8to= +github.com/RedisLabs/rediscloud-go-api v0.15.0 h1:+aTIBYTZMqe+WIFsMsRsRknEyERN22JMjVnierT+nhQ= +github.com/RedisLabs/rediscloud-go-api v0.15.0/go.mod h1:LTnlcUHd+NU25dXGikLk1hbyROjaaGHvfMbzdNLX8to= github.com/acomagu/bufpipe v1.0.4 h1:e3H4WUzM3npvo5uv95QuJM3cQspFNtFBzvJ2oNjKIDQ= github.com/agext/levenshtein v1.2.2 h1:0S/Yg6LYmFJ5stwQeRp6EeOcCbj7xiqQSdNelsXvaqE= github.com/agext/levenshtein v1.2.2/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= diff --git a/provider/datasource_rediscloud_active_active_database.go b/provider/datasource_rediscloud_active_active_database.go index 202c2079..31ce4c2e 100644 --- a/provider/datasource_rediscloud_active_active_database.go +++ b/provider/datasource_rediscloud_active_active_database.go @@ -88,9 +88,46 @@ func dataSourceRedisCloudActiveActiveDatabase() *schema.Resource { Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "response": { - Description: "JSON-style details about the last import", - Computed: true, - Type: schema.TypeString, + Computed: true, + Type: schema.TypeSet, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "status": { + Description: "The status of the last import operation", + Computed: true, + Type: schema.TypeString, + }, + "last_import_time": { + Description: "When the last import operation occurred", + Computed: true, + Type: schema.TypeString, + }, + "failure_reason": { + Description: "If a failure, why the import operation failed", + Computed: true, + Type: schema.TypeString, + }, + "failure_reason_params": { + Description: "Parameters of the failure, if appropriate", + Computed: true, + Type: schema.TypeList, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "key": { + Description: "", + Computed: true, + Type: schema.TypeString, + }, + "value": { + Description: "", + Computed: true, + Type: schema.TypeString, + }, + }, + }, + }, + }, + }, }, "error": { Computed: true, diff --git a/provider/datasource_rediscloud_essentials_database.go b/provider/datasource_rediscloud_essentials_database.go index b275950e..5e99d9d7 100644 --- a/provider/datasource_rediscloud_essentials_database.go +++ b/provider/datasource_rediscloud_essentials_database.go @@ -195,9 +195,27 @@ func dataSourceRedisCloudEssentialsDatabase() *schema.Resource { Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "response": { - Description: "JSON-style details about the last backup", - Computed: true, - Type: schema.TypeString, + Computed: true, + Type: schema.TypeSet, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "status": { + Description: "The status of the last backup operation", + Computed: true, + Type: schema.TypeString, + }, + "last_backup_time": { + Description: "When the last backup operation occurred", + Computed: true, + Type: schema.TypeString, + }, + "failure_reason": { + Description: "If a failure, why the backup operation failed", + Computed: true, + Type: schema.TypeString, + }, + }, + }, }, "error": { Computed: true, @@ -226,15 +244,52 @@ func dataSourceRedisCloudEssentialsDatabase() *schema.Resource { }, }, "latest_import_status": { - Description: "Details about the last import that took place for this database", + Description: "Details about the last import that took place for this active-active database", Computed: true, Type: schema.TypeSet, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "response": { - Description: "JSON-style details about the last import", - Computed: true, - Type: schema.TypeString, + Computed: true, + Type: schema.TypeSet, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "status": { + Description: "The status of the last import operation", + Computed: true, + Type: schema.TypeString, + }, + "last_import_time": { + Description: "When the last import operation occurred", + Computed: true, + Type: schema.TypeString, + }, + "failure_reason": { + Description: "If a failure, why the import operation failed", + Computed: true, + Type: schema.TypeString, + }, + "failure_reason_params": { + Description: "Parameters of the failure, if appropriate", + Computed: true, + Type: schema.TypeList, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "key": { + Description: "", + Computed: true, + Type: schema.TypeString, + }, + "value": { + Description: "", + Computed: true, + Type: schema.TypeString, + }, + }, + }, + }, + }, + }, }, "error": { Computed: true, diff --git a/provider/datasource_rediscloud_flexible_database.go b/provider/datasource_rediscloud_flexible_database.go index 8a860116..e8c95212 100644 --- a/provider/datasource_rediscloud_flexible_database.go +++ b/provider/datasource_rediscloud_flexible_database.go @@ -165,9 +165,27 @@ func dataSourceRedisCloudFlexibleDatabase() *schema.Resource { Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "response": { - Description: "JSON-style details about the last backup", - Computed: true, - Type: schema.TypeString, + Computed: true, + Type: schema.TypeSet, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "status": { + Description: "The status of the last backup operation", + Computed: true, + Type: schema.TypeString, + }, + "last_backup_time": { + Description: "When the last backup operation occurred", + Computed: true, + Type: schema.TypeString, + }, + "failure_reason": { + Description: "If a failure, why the backup operation failed", + Computed: true, + Type: schema.TypeString, + }, + }, + }, }, "error": { Computed: true, @@ -196,15 +214,52 @@ func dataSourceRedisCloudFlexibleDatabase() *schema.Resource { }, }, "latest_import_status": { - Description: "Details about the last import that took place for this database", + Description: "Details about the last import that took place for this active-active database", Computed: true, Type: schema.TypeSet, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "response": { - Description: "JSON-style details about the last import", - Computed: true, - Type: schema.TypeString, + Computed: true, + Type: schema.TypeSet, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "status": { + Description: "The status of the last import operation", + Computed: true, + Type: schema.TypeString, + }, + "last_import_time": { + Description: "When the last import operation occurred", + Computed: true, + Type: schema.TypeString, + }, + "failure_reason": { + Description: "If a failure, why the import operation failed", + Computed: true, + Type: schema.TypeString, + }, + "failure_reason_params": { + Description: "Parameters of the failure, if appropriate", + Computed: true, + Type: schema.TypeList, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "key": { + Description: "", + Computed: true, + Type: schema.TypeString, + }, + "value": { + Description: "", + Computed: true, + Type: schema.TypeString, + }, + }, + }, + }, + }, + }, }, "error": { Computed: true, diff --git a/provider/resource_rediscloud_active_active_database.go b/provider/resource_rediscloud_active_active_database.go index 16df0c7f..e39115ff 100644 --- a/provider/resource_rediscloud_active_active_database.go +++ b/provider/resource_rediscloud_active_active_database.go @@ -306,9 +306,46 @@ func resourceRedisCloudActiveActiveDatabase() *schema.Resource { Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "response": { - Description: "JSON-style details about the last import", - Computed: true, - Type: schema.TypeString, + Computed: true, + Type: schema.TypeSet, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "status": { + Description: "The status of the last import operation", + Computed: true, + Type: schema.TypeString, + }, + "last_import_time": { + Description: "When the last import operation occurred", + Computed: true, + Type: schema.TypeString, + }, + "failure_reason": { + Description: "If a failure, why the import operation failed", + Computed: true, + Type: schema.TypeString, + }, + "failure_reason_params": { + Description: "Parameters of the failure, if appropriate", + Computed: true, + Type: schema.TypeList, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "key": { + Description: "", + Computed: true, + Type: schema.TypeString, + }, + "value": { + Description: "", + Computed: true, + Type: schema.TypeString, + }, + }, + }, + }, + }, + }, }, "error": { Computed: true, diff --git a/provider/resource_rediscloud_active_active_subscription_database.go b/provider/resource_rediscloud_active_active_subscription_database.go index 843a2ad2..128fb77b 100644 --- a/provider/resource_rediscloud_active_active_subscription_database.go +++ b/provider/resource_rediscloud_active_active_subscription_database.go @@ -305,9 +305,46 @@ func resourceRedisCloudActiveActiveSubscriptionDatabase() *schema.Resource { Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "response": { - Description: "JSON-style details about the last import", - Computed: true, - Type: schema.TypeString, + Computed: true, + Type: schema.TypeSet, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "status": { + Description: "The status of the last import operation", + Computed: true, + Type: schema.TypeString, + }, + "last_import_time": { + Description: "When the last import operation occurred", + Computed: true, + Type: schema.TypeString, + }, + "failure_reason": { + Description: "If a failure, why the import operation failed", + Computed: true, + Type: schema.TypeString, + }, + "failure_reason_params": { + Description: "Parameters of the failure, if appropriate", + Computed: true, + Type: schema.TypeList, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "key": { + Description: "", + Computed: true, + Type: schema.TypeString, + }, + "value": { + Description: "", + Computed: true, + Type: schema.TypeString, + }, + }, + }, + }, + }, + }, }, "error": { Computed: true, diff --git a/provider/resource_rediscloud_active_active_subscription_regions.go b/provider/resource_rediscloud_active_active_subscription_regions.go index 69dffd7a..a65d2f13 100644 --- a/provider/resource_rediscloud_active_active_subscription_regions.go +++ b/provider/resource_rediscloud_active_active_subscription_regions.go @@ -117,15 +117,33 @@ func resourceRedisCloudActiveActiveSubscriptionRegions() *schema.Resource { Required: true, }, "latest_backup_status": { - Description: "Details about the last backup that took place for this database instance", + Description: "Details about the last backup that took place for this database", Computed: true, Type: schema.TypeSet, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "response": { - Description: "JSON-style details about the last backup", - Computed: true, - Type: schema.TypeString, + Computed: true, + Type: schema.TypeSet, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "status": { + Description: "The status of the last backup operation", + Computed: true, + Type: schema.TypeString, + }, + "last_backup_time": { + Description: "When the last backup operation occurred", + Computed: true, + Type: schema.TypeString, + }, + "failure_reason": { + Description: "If a failure, why the backup operation failed", + Computed: true, + Type: schema.TypeString, + }, + }, + }, }, "error": { Computed: true, diff --git a/provider/resource_rediscloud_essentials_database.go b/provider/resource_rediscloud_essentials_database.go index ba3296c7..fd956197 100644 --- a/provider/resource_rediscloud_essentials_database.go +++ b/provider/resource_rediscloud_essentials_database.go @@ -243,9 +243,27 @@ func resourceRedisCloudEssentialsDatabase() *schema.Resource { Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "response": { - Description: "JSON-style details about the last backup", - Computed: true, - Type: schema.TypeString, + Computed: true, + Type: schema.TypeSet, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "status": { + Description: "The status of the last backup operation", + Computed: true, + Type: schema.TypeString, + }, + "last_backup_time": { + Description: "When the last backup operation occurred", + Computed: true, + Type: schema.TypeString, + }, + "failure_reason": { + Description: "If a failure, why the backup operation failed", + Computed: true, + Type: schema.TypeString, + }, + }, + }, }, "error": { Computed: true, @@ -274,15 +292,52 @@ func resourceRedisCloudEssentialsDatabase() *schema.Resource { }, }, "latest_import_status": { - Description: "Details about the last import that took place for this database", + Description: "Details about the last import that took place for this active-active database", Computed: true, Type: schema.TypeSet, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "response": { - Description: "JSON-style details about the last import", - Computed: true, - Type: schema.TypeString, + Computed: true, + Type: schema.TypeSet, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "status": { + Description: "The status of the last import operation", + Computed: true, + Type: schema.TypeString, + }, + "last_import_time": { + Description: "When the last import operation occurred", + Computed: true, + Type: schema.TypeString, + }, + "failure_reason": { + Description: "If a failure, why the import operation failed", + Computed: true, + Type: schema.TypeString, + }, + "failure_reason_params": { + Description: "Parameters of the failure, if appropriate", + Computed: true, + Type: schema.TypeList, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "key": { + Description: "", + Computed: true, + Type: schema.TypeString, + }, + "value": { + Description: "", + Computed: true, + Type: schema.TypeString, + }, + }, + }, + }, + }, + }, }, "error": { Computed: true, diff --git a/provider/resource_rediscloud_flexible_database.go b/provider/resource_rediscloud_flexible_database.go index 495bd0b7..7bdcc956 100644 --- a/provider/resource_rediscloud_flexible_database.go +++ b/provider/resource_rediscloud_flexible_database.go @@ -2,7 +2,6 @@ package provider import ( "context" - "encoding/json" "fmt" "strconv" "strings" @@ -10,8 +9,6 @@ import ( "github.com/RedisLabs/rediscloud-go-api/redis" "github.com/RedisLabs/rediscloud-go-api/service/databases" - "github.com/RedisLabs/rediscloud-go-api/service/latest_backups" - "github.com/RedisLabs/rediscloud-go-api/service/latest_imports" "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" @@ -299,9 +296,27 @@ func resourceRedisCloudFlexibleDatabase() *schema.Resource { Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "response": { - Description: "JSON-style details about the last backup", - Computed: true, - Type: schema.TypeString, + Computed: true, + Type: schema.TypeSet, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "status": { + Description: "The status of the last backup operation", + Computed: true, + Type: schema.TypeString, + }, + "last_backup_time": { + Description: "When the last backup operation occurred", + Computed: true, + Type: schema.TypeString, + }, + "failure_reason": { + Description: "If a failure, why the backup operation failed", + Computed: true, + Type: schema.TypeString, + }, + }, + }, }, "error": { Computed: true, @@ -330,15 +345,52 @@ func resourceRedisCloudFlexibleDatabase() *schema.Resource { }, }, "latest_import_status": { - Description: "Details about the last import that took place for this database", + Description: "Details about the last import that took place for this active-active database", Computed: true, Type: schema.TypeSet, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "response": { - Description: "JSON-style details about the last import", - Computed: true, - Type: schema.TypeString, + Computed: true, + Type: schema.TypeSet, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "status": { + Description: "The status of the last import operation", + Computed: true, + Type: schema.TypeString, + }, + "last_import_time": { + Description: "When the last import operation occurred", + Computed: true, + Type: schema.TypeString, + }, + "failure_reason": { + Description: "If a failure, why the import operation failed", + Computed: true, + Type: schema.TypeString, + }, + "failure_reason_params": { + Description: "Parameters of the failure, if appropriate", + Computed: true, + Type: schema.TypeList, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "key": { + Description: "", + Computed: true, + Type: schema.TypeString, + }, + "value": { + Description: "", + Computed: true, + Type: schema.TypeString, + }, + }, + }, + }, + }, + }, }, "error": { Computed: true, @@ -896,55 +948,3 @@ func remoteBackupIntervalSetCorrectly(key string) schema.CustomizeDiffFunc { } } - -func parseLatestBackupStatus(latestBackupStatus *latest_backups.LatestBackupStatus) ([]map[string]interface{}, error) { - lbs := map[string]interface{}{ - "response": nil, - "error": nil, - } - - if latestBackupStatus.Response.Resource != nil { - j, err := json.Marshal(latestBackupStatus.Response.Resource) - if err != nil { - return nil, err - } - lbs["response"] = string(j) - } - - if latestBackupStatus.Response.Error != nil { - err := map[string]interface{}{ - "type": redis.StringValue(latestBackupStatus.Response.Error.Type), - "description": redis.StringValue(latestBackupStatus.Response.Error.Description), - "status": redis.StringValue(latestBackupStatus.Response.Error.Status), - } - lbs["error"] = []map[string]interface{}{err} - } - - return []map[string]interface{}{lbs}, nil -} - -func parseLatestImportStatus(latestImportStatus *latest_imports.LatestImportStatus) ([]map[string]interface{}, error) { - lis := map[string]interface{}{ - "response": nil, - "error": nil, - } - - if latestImportStatus.Response.Resource != nil { - j, err := json.Marshal(latestImportStatus.Response.Resource) - if err != nil { - return nil, err - } - lis["response"] = string(j) - } - - if latestImportStatus.Response.Error != nil { - err := map[string]interface{}{ - "type": redis.StringValue(latestImportStatus.Response.Error.Type), - "description": redis.StringValue(latestImportStatus.Response.Error.Description), - "status": redis.StringValue(latestImportStatus.Response.Error.Status), - } - lis["error"] = []map[string]interface{}{err} - } - - return []map[string]interface{}{lis}, nil -} diff --git a/provider/resource_rediscloud_subscription_database.go b/provider/resource_rediscloud_subscription_database.go index ef6e43cf..db3f36fb 100644 --- a/provider/resource_rediscloud_subscription_database.go +++ b/provider/resource_rediscloud_subscription_database.go @@ -294,9 +294,27 @@ func resourceRedisCloudSubscriptionDatabase() *schema.Resource { Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "response": { - Description: "JSON-style details about the last backup", - Computed: true, - Type: schema.TypeString, + Computed: true, + Type: schema.TypeSet, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "status": { + Description: "The status of the last backup operation", + Computed: true, + Type: schema.TypeString, + }, + "last_backup_time": { + Description: "When the last backup operation occurred", + Computed: true, + Type: schema.TypeString, + }, + "failure_reason": { + Description: "If a failure, why the backup operation failed", + Computed: true, + Type: schema.TypeString, + }, + }, + }, }, "error": { Computed: true, @@ -325,15 +343,52 @@ func resourceRedisCloudSubscriptionDatabase() *schema.Resource { }, }, "latest_import_status": { - Description: "Details about the last import that took place for this database", + Description: "Details about the last import that took place for this active-active database", Computed: true, Type: schema.TypeSet, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "response": { - Description: "JSON-style details about the last import", - Computed: true, - Type: schema.TypeString, + Computed: true, + Type: schema.TypeSet, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "status": { + Description: "The status of the last import operation", + Computed: true, + Type: schema.TypeString, + }, + "last_import_time": { + Description: "When the last import operation occurred", + Computed: true, + Type: schema.TypeString, + }, + "failure_reason": { + Description: "If a failure, why the import operation failed", + Computed: true, + Type: schema.TypeString, + }, + "failure_reason_params": { + Description: "Parameters of the failure, if appropriate", + Computed: true, + Type: schema.TypeList, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "key": { + Description: "", + Computed: true, + Type: schema.TypeString, + }, + "value": { + Description: "", + Computed: true, + Type: schema.TypeString, + }, + }, + }, + }, + }, + }, }, "error": { Computed: true, diff --git a/provider/utils.go b/provider/utils.go index 59156914..33bae89f 100644 --- a/provider/utils.go +++ b/provider/utils.go @@ -3,6 +3,8 @@ package provider import ( "fmt" "github.com/RedisLabs/rediscloud-go-api/redis" + "github.com/RedisLabs/rediscloud-go-api/service/latest_backups" + "github.com/RedisLabs/rediscloud-go-api/service/latest_imports" "github.com/hashicorp/go-cty/cty" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -91,3 +93,75 @@ func isTime() schema.SchemaValidateDiagFunc { return diags } } + +func parseLatestBackupStatus(latestBackupStatus *latest_backups.LatestBackupStatus) ([]map[string]interface{}, error) { + lbs := map[string]interface{}{ + "response": nil, + "error": nil, + } + + if latestBackupStatus.Response.Resource != nil { + res := map[string]interface{}{ + "status": redis.StringValue(latestBackupStatus.Response.Resource.Status), + "last_backup_time": nil, + "failure_reason": redis.StringValue(latestBackupStatus.Response.Resource.FailureReason), + } + if latestBackupStatus.Response.Resource.LastBackupTime != nil { + res["last_backup_time"] = latestBackupStatus.Response.Resource.LastBackupTime.String() + } + lbs["response"] = []map[string]interface{}{res} + } + + if latestBackupStatus.Response.Error != nil { + err := map[string]interface{}{ + "type": redis.StringValue(latestBackupStatus.Response.Error.Type), + "description": redis.StringValue(latestBackupStatus.Response.Error.Description), + "status": redis.StringValue(latestBackupStatus.Response.Error.Status), + } + lbs["error"] = []map[string]interface{}{err} + } + + return []map[string]interface{}{lbs}, nil +} + +func parseLatestImportStatus(latestImportStatus *latest_imports.LatestImportStatus) ([]map[string]interface{}, error) { + lis := map[string]interface{}{ + "response": nil, + "error": nil, + } + + if latestImportStatus.Response.Resource != nil { + res := map[string]interface{}{ + "status": redis.StringValue(latestImportStatus.Response.Resource.Status), + "last_import_time": nil, + "failure_reason": redis.StringValue(latestImportStatus.Response.Resource.FailureReason), + "failure_reason_params": parseFailureReasonParams(latestImportStatus.Response.Resource.FailureReasonParams), + } + if latestImportStatus.Response.Resource.LastImportTime != nil { + res["last_import_time"] = latestImportStatus.Response.Resource.LastImportTime.String() + } + lis["response"] = []map[string]interface{}{res} + } + + if latestImportStatus.Response.Error != nil { + err := map[string]interface{}{ + "type": redis.StringValue(latestImportStatus.Response.Error.Type), + "description": redis.StringValue(latestImportStatus.Response.Error.Description), + "status": redis.StringValue(latestImportStatus.Response.Error.Status), + } + lis["error"] = []map[string]interface{}{err} + } + + return []map[string]interface{}{lis}, nil +} + +func parseFailureReasonParams(params []*latest_imports.FailureReasonParam) []map[string]interface{} { + writableParams := make([]map[string]interface{}, 0) + for _, param := range params { + writableParams = append(writableParams, map[string]interface{}{ + "key": redis.StringValue(param.Key), + "value": redis.StringValue(param.Value), + }) + } + return writableParams +}