Skip to content

Commit

Permalink
[CBR] new data_source/opentelekomcloud_cbr_backup_v3, data_source/ope…
Browse files Browse the repository at this point in the history
…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
artem-lifshits committed Jul 6, 2022
1 parent ba2898c commit f5871e8
Show file tree
Hide file tree
Showing 10 changed files with 611 additions and 3 deletions.
49 changes: 49 additions & 0 deletions docs/data-sources/cbr_backup_ids_v3.md
@@ -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.
77 changes: 77 additions & 0 deletions docs/data-sources/cbr_backup_v3.md
@@ -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.
2 changes: 1 addition & 1 deletion go.mod
Expand Up @@ -13,7 +13,7 @@ require (
github.com/jen20/awspolicyequivalence v1.1.0
github.com/jinzhu/copier v0.3.5
github.com/mitchellh/go-homedir v1.1.0
github.com/opentelekomcloud/gophertelekomcloud v0.5.14
github.com/opentelekomcloud/gophertelekomcloud v0.5.15-0.20220706063853-36a17543d6f9
github.com/unknwon/com v1.0.1
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9
gopkg.in/yaml.v2 v2.4.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Expand Up @@ -201,8 +201,8 @@ github.com/nsf/jsondiff v0.0.0-20200515183724-f29ed568f4ce h1:RPclfga2SEJmgMmz2k
github.com/nsf/jsondiff v0.0.0-20200515183724-f29ed568f4ce/go.mod h1:uFMI8w+ref4v2r9jz+c9i1IfIttS/OkmLfrk1jne5hs=
github.com/oklog/run v1.0.0 h1:Ru7dDtJNOyC66gQ5dQmaCa0qIsAUFY3sFpK1Xk8igrw=
github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA=
github.com/opentelekomcloud/gophertelekomcloud v0.5.14 h1:6qnaY47xzzH79zsA8axQj2hNwv/hHQsHGZPCnnGmeJ0=
github.com/opentelekomcloud/gophertelekomcloud v0.5.14/go.mod h1:pzEP1kduNwv+hrI9R6/DFU/NiX7Kr9NiFjpQ7kJQTsM=
github.com/opentelekomcloud/gophertelekomcloud v0.5.15-0.20220706063853-36a17543d6f9 h1:XKv+sTANU9vjZStqYQy9LUCUsvxesItv59QVVqCoA9k=
github.com/opentelekomcloud/gophertelekomcloud v0.5.15-0.20220706063853-36a17543d6f9/go.mod h1:pzEP1kduNwv+hrI9R6/DFU/NiX7Kr9NiFjpQ7kJQTsM=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
Expand Down
@@ -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)
}
@@ -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)
}
2 changes: 2 additions & 0 deletions opentelekomcloud/provider.go
Expand Up @@ -230,6 +230,8 @@ func Provider() *schema.Provider {

DataSourcesMap: map[string]*schema.Resource{
"opentelekomcloud_antiddos_v1": antiddos.DataSourceAntiDdosV1(),
"opentelekomcloud_cbr_backup_v3": cbr.DataSourceCBRBackupsV3(),
"opentelekomcloud_cbr_backup_ids_v3": cbr.DataSourceCBRBackupsIdsV3(),
"opentelekomcloud_cce_cluster_v3": cce.DataSourceCCEClusterV3(),
"opentelekomcloud_cce_cluster_kubeconfig_v3": cce.DataSourceCCEClusterKubeConfigV3(),
"opentelekomcloud_cce_node_ids_v3": cce.DataSourceCceNodeIdsV3(),
Expand Down

0 comments on commit f5871e8

Please sign in to comment.