Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CBR] new data_source/opentelekomcloud_cbr_backup_v3, data_source/ope…
…ntelekomcloud_cbr_backup_ids_v3 (#1795) [CBR] new data_source/opentelekomcloud_cbr_backup_v3, data_source/opentelekomcloud_cbr_backup_ids_v3 Summary of the Pull Request PR Checklist Closes: #1779 Tests added/passed. Documentation updated. Schema updated. Release notes added. Acceptance Steps Performed === RUN TestAccCBRBackupV3DataSource_basic === PAUSE TestAccCBRBackupV3DataSource_basic === CONT TestAccCBRBackupV3DataSource_basic --- PASS: TestAccCBRBackupV3DataSource_basic (31.63s) PASS Process finished with the exit code 0 === RUN TestAccCBRBackupV3DataSourceIds_basic === PAUSE TestAccCBRBackupV3DataSourceIds_basic === CONT TestAccCBRBackupV3DataSourceIds_basic --- PASS: TestAccCBRBackupV3DataSourceIds_basic (31.86s) PASS Process finished with the exit code 0 Reviewed-by: Anton Sidelnikov <None>
- Loading branch information
1 parent
ba2898c
commit f5871e8
Showing
10 changed files
with
611 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
--- | ||
subcategory: "Cloud Backup and Recovery (CBR)" | ||
--- | ||
|
||
# opentelekomcloud_cbr_backup_ids_v3 | ||
|
||
Use this data source to get details about backup resources from OpenTelekomCloud. | ||
|
||
## Example Usage | ||
|
||
```hcl | ||
variable "checkpoint_id" {} | ||
data "opentelekomcloud_cbr_backup_ids_v3" "cbr_backups" { | ||
checkpoint_id = var.checkpoint_id | ||
} | ||
``` | ||
|
||
## Argument Reference | ||
|
||
The following arguments are supported: | ||
|
||
* `id` - (Optional) Specifies the ID of backup. | ||
|
||
* `chackpoint_id` - (Optional) Specifies the restore point ID. | ||
|
||
* `status` - (Optional) Specifies the backup status. | ||
|
||
* `resource_name` - (Optional) Specifies the backup resource name. | ||
|
||
* `image_type` - (Optional) Specifies the backup type. | ||
|
||
* `resource_type` - (Optional) Specifies the type of backup objects. | ||
|
||
* `resource_id` - (Optional) Specifies the backup object ID. | ||
|
||
* `name` - (Optional) Specifies the backup name | ||
|
||
* `parent_id` - (Optional) Specifies the ID of parent backup. | ||
|
||
* `resource_az` - (Optional) Specifies the AZ of backup. | ||
|
||
* `vault_id` - (Optional) Specifies the ID of backup vault. | ||
|
||
## Attributes Reference | ||
|
||
The following attributes are exported: | ||
|
||
* `ids` - A list of all the backup ids found. This data source will fail if none are found. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
--- | ||
subcategory: "Cloud Backup and Recovery (CBR)" | ||
--- | ||
|
||
# opentelekomcloud_cbr_backup_v3 | ||
|
||
Use this data source to get details about backup resources from OpenTelekomCloud. | ||
|
||
## Example Usage | ||
|
||
```hcl | ||
variable "backup_id" {} | ||
data "opentelekomcloud_cbr_backup_v3" "cbr_backup" { | ||
id = var.backup_id | ||
} | ||
``` | ||
|
||
## Argument Reference | ||
|
||
The following arguments are supported: | ||
|
||
* `id` - (Optional) Specifies the ID of backup. | ||
|
||
* `chackpoint_id` - (Optional) Specifies the restore point ID. | ||
|
||
* `status` - (Optional) Specifies the backup status. | ||
|
||
* `resource_name` - (Optional) Specifies the backup resource name. | ||
|
||
* `image_type` - (Optional) Specifies the backup type. | ||
|
||
* `resource_type` - (Optional) Specifies the type of backup objects. | ||
|
||
* `resource_id` - (Optional) Specifies the backup object ID. | ||
|
||
* `name` - (Optional) Specifies the backup name | ||
|
||
* `parent_id` - (Optional) Specifies the ID of parent backup. | ||
|
||
* `resource_az` - (Optional) Specifies the AZ of backup. | ||
|
||
* `vault_id` - (Optional) Specifies the ID of backup vault. | ||
|
||
## Attributes Reference | ||
|
||
In addition to all arguments above, the following attributes are exported: | ||
|
||
* `created_at` - The time the backup was created. | ||
|
||
* `description` - Backup description. | ||
|
||
* `expired_at` - The time the backup will be expired. | ||
|
||
* `project_id` - The project ID of backup. | ||
|
||
* `resource_size` - Backup size in GB. | ||
|
||
* `updated_at` - Indicates the update time. | ||
|
||
* `provider_id` - Backup provider ID which is used to distinguish backup objects. | ||
|
||
* `auto_trigger` - Specifies whether the backup is automatically generated. | ||
|
||
* `bootable` - Specifies whether the backup is a system disk backup. | ||
|
||
* `incremental` - Specifies whether the backup is an incremental backup. | ||
|
||
* `snapshot_id` - The snapshot ID of the disk backup. | ||
|
||
* `support_lld` - Specifies whether to allow lazyloading for fast restoration. | ||
|
||
* `supported_restore_mode` - Restoration mode of the backup. | ||
|
||
* `encrypted` - Specifies whether the backup is encrypted. | ||
|
||
* `system_disk` - Specifies whether a disk is a system disk. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
opentelekomcloud/acceptance/cbr/data_source_opentelekomcloud_cbr_backup_v3_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package acceptance | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform" | ||
"github.com/opentelekomcloud/terraform-provider-opentelekomcloud/opentelekomcloud/acceptance/common" | ||
) | ||
|
||
const dataBackupName = "data.opentelekomcloud_cbr_backup_v3.cbr" | ||
|
||
func TestAccCBRBackupV3DataSource_basic(t *testing.T) { | ||
if os.Getenv("CBR_DATA") == "" { | ||
t.Skip("this test is not a stable one") | ||
} | ||
vaultId := "insert_vaultId_here" | ||
resource.ParallelTest(t, resource.TestCase{ | ||
PreCheck: func() { | ||
common.TestAccPreCheck(t) | ||
}, | ||
ProviderFactories: common.TestAccProviderFactories, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccCBRBackupV3DataSourceBasic(vaultId), | ||
Check: resource.ComposeTestCheckFunc( | ||
testAccCheckCBRBackupV3DataSourceID(dataBackupName), | ||
), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func testAccCheckCBRBackupV3DataSourceID(n string) resource.TestCheckFunc { | ||
return func(s *terraform.State) error { | ||
rs, ok := s.RootModule().Resources[n] | ||
if !ok { | ||
return fmt.Errorf("can't find backup data source: %s ", n) | ||
} | ||
|
||
if rs.Primary.ID == "" { | ||
return fmt.Errorf("backup data source ID not set ") | ||
} | ||
|
||
return nil | ||
} | ||
} | ||
|
||
func testAccCBRBackupV3DataSourceBasic(vaultId string) string { | ||
return fmt.Sprintf(` | ||
data "opentelekomcloud_cbr_backup_v3" "cbr" { | ||
checkpoint_id = "%s" | ||
} | ||
`, vaultId) | ||
} |
57 changes: 57 additions & 0 deletions
57
opentelekomcloud/acceptance/cbr/data_source_opentelekomcloud_cbr_backups_ids_v3_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package acceptance | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform" | ||
"github.com/opentelekomcloud/terraform-provider-opentelekomcloud/opentelekomcloud/acceptance/common" | ||
) | ||
|
||
const dataBackupIDs = "data.opentelekomcloud_cbr_backup_ids_v3.backup_ids" | ||
|
||
func TestAccCBRBackupV3DataSourceIds_basic(t *testing.T) { | ||
if os.Getenv("CBR_DATA") == "" { | ||
t.Skip("this test is not a stable one") | ||
} | ||
vaultId := "insert_id_here" | ||
resource.ParallelTest(t, resource.TestCase{ | ||
PreCheck: func() { | ||
common.TestAccPreCheck(t) | ||
}, | ||
ProviderFactories: common.TestAccProviderFactories, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccCBRBackupV3DataSourceIDsBasic(vaultId), | ||
Check: resource.ComposeTestCheckFunc( | ||
testAccCheckCBRBackupV3DataSourceIDs(dataBackupIDs), | ||
), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func testAccCheckCBRBackupV3DataSourceIDs(n string) resource.TestCheckFunc { | ||
return func(s *terraform.State) error { | ||
rs, ok := s.RootModule().Resources[n] | ||
if !ok { | ||
return fmt.Errorf("can't find backup data source: %s ", n) | ||
} | ||
|
||
if rs.Primary.ID == "" { | ||
return fmt.Errorf("backup data source ID not set ") | ||
} | ||
|
||
return nil | ||
} | ||
} | ||
|
||
func testAccCBRBackupV3DataSourceIDsBasic(vaultId string) string { | ||
return fmt.Sprintf(` | ||
data "opentelekomcloud_cbr_backup_ids_v3" "backup_ids" { | ||
vault_id = "%s" | ||
} | ||
`, vaultId) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.