-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
…n user agent
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
--- | ||
subcategory: "Database as a Service - RedisDB" | ||
layout: "ionoscloud" | ||
page_title: "IonosCloud: ionoscloud_redis_snapshot" | ||
sidebar_current: "docs-datasource-redis_snapshot" | ||
description: |- | ||
Gets information about an existing RedisDB Snapshot. | ||
--- | ||
|
||
# ionoscloud_redis_snapshot | ||
|
||
The `ionoscloud_redis_snapshot` data source can be used to retrieve information about an existing RedisDB Snapshot. | ||
|
||
## Example Usage | ||
|
||
```hcl | ||
data "ionoscloud_redis_snapshot" "example" { | ||
id = "snapshot-id" | ||
location = "de/txl" | ||
} | ||
``` | ||
|
||
## Argument Reference | ||
|
||
* `id` - (Required) The ID of the RedisDB Snapshot. | ||
* `location` - (Required) The location of the RedisDB 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. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
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 dataSourceDBaaSRedisDBSnapshot() *schema.Resource { | ||
return &schema.Resource{ | ||
ReadContext: dataSourceDBaaSRedisDBSnapshotRead, | ||
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.DBaaSClusterLocations, 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 Redis 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 dataSourceDBaaSRedisDBSnapshotRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { | ||
client := meta.(services.SdkBundle).RedisDBClient | ||
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 Redis snapshot with ID: %v", id, err)) | ||
} | ||
if err := client.SetSnapshotData(d, snapshot); err != nil { | ||
return diag.FromErr(err) | ||
} | ||
return nil | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.