Skip to content

Commit 58ae6db

Browse files
Converting backupdr data sources from fetch to list (#15645) (#25107)
[upstream:340663512ef178163ed81c12832523e59c97b9f6] Signed-off-by: Modular Magician <magic-modules@google.com>
1 parent 4c0eb0b commit 58ae6db

7 files changed

+21
-27
lines changed

.changelog/15645.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
```release-note:deprecation
2+
backupdr: deprecated `required_type` in `google_backup_dr_backup_plan_associations` and `google_backup_dr_data_source_references`. It no longer has any functionality, and will be removed in the next major release.
3+
```
4+
```release-note:enhancement
5+
backupdr: updated `google_backup_dr_backup_plan_associations` and `google_backup_dr_data_source_references` to use LIST APIs.
6+
```

google/services/backupdr/data_source_backup_dr_backup_plan_association.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ func DataSourceGoogleCloudBackupDRBackupPlanAssociation() *schema.Resource {
3030
// Set 'Required' schema elements
3131
tpgresource.AddRequiredFieldsToSchema(dsSchema, "backup_plan_association_id", "location")
3232

33-
// Set 'Optional' schema elements
3433
tpgresource.AddOptionalFieldsToSchema(dsSchema, "project")
3534
return &schema.Resource{
3635
Read: dataSourceGoogleCloudBackupDRBackupPlanAssociationRead,
@@ -80,10 +79,10 @@ func DataSourceGoogleCloudBackupDRBackupPlanAssociations() *schema.Resource {
8079
},
8180
"resource_type": {
8281
Type: schema.TypeString,
83-
Required: true,
82+
Optional: true,
8483
Description: `The resource type of workload on which backup plan is applied. Examples include, "compute.googleapis.com/Instance", "compute.googleapis.com/Disk".`,
84+
Deprecated: "`resource_type` is deprecated and will be removed in a future major release.",
8585
},
86-
8786
"associations": {
8887
Type: schema.TypeList,
8988
Computed: true,
@@ -173,9 +172,8 @@ func dataSourceGoogleCloudBackupDRBackupPlanAssociationsRead(d *schema.ResourceD
173172
}
174173

175174
location := d.Get("location").(string)
176-
resourceType := d.Get("resource_type").(string)
177175

178-
url := fmt.Sprintf("%sprojects/%s/locations/%s/backupPlanAssociations:fetchForResourceType?resourceType=%s", config.BackupDRBasePath, project, location, resourceType)
176+
url := fmt.Sprintf("%sprojects/%s/locations/%s/backupPlanAssociations", config.BackupDRBasePath, project, location)
179177

180178
res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{
181179
Config: config,

google/services/backupdr/data_source_backup_dr_backup_plan_association_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,6 @@ resource "google_backup_dr_backup_plan_association" "bpa" {
311311
312312
data "google_backup_dr_backup_plan_associations" "bpas" {
313313
location = "us-central1"
314-
resource_type = "compute.googleapis.com/Instance"
315314
depends_on = [google_backup_dr_backup_plan_association.bpa]
316315
}
317316
`, context)

google/services/backupdr/data_source_backup_dr_data_source_reference.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@ func DataSourceGoogleCloudBackupDRDataSourceReferences() *schema.Resource {
4343
},
4444
"resource_type": {
4545
Type: schema.TypeString,
46-
Required: true,
47-
Description: `The resource type to get the data source references for. Examples include, "compute.googleapis.com/Instance", "sqladmin.googleapis.com/Instance".`,
46+
Optional: true,
47+
Description: `The resource type of workload on which backup plan is applied. Examples include, "compute.googleapis.com/Instance", "compute.googleapis.com/Disk".`,
48+
Deprecated: "`resource_type` is deprecated and will be removed in a future major release.",
4849
},
49-
5050
// Output: a computed list of the data source references found
5151
"data_source_references": {
5252
Type: schema.TypeList,
@@ -112,9 +112,8 @@ func dataSourceGoogleCloudBackupDRDataSourceReferencesRead(d *schema.ResourceDat
112112
}
113113

114114
location := d.Get("location").(string)
115-
resourceType := d.Get("resource_type").(string)
116115

117-
url := fmt.Sprintf("%sprojects/%s/locations/%s/dataSourceReferences:fetchForResourceType?resourceType=%s", config.BackupDRBasePath, project, location, resourceType)
116+
url := fmt.Sprintf("%sprojects/%s/locations/%s/dataSourceReferences", config.BackupDRBasePath, project, location)
118117

119118
res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{
120119
Config: config,

google/services/backupdr/data_source_backup_dr_data_source_reference_test.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ func TestAccDataSourceGoogleBackupDRDataSourceReferences_basic(t *testing.T) {
3232
var projectID string
3333
context := map[string]interface{}{
3434
"location": "us-central1",
35-
"resource_type": "sqladmin.googleapis.com/Instance",
3635
"random_suffix": acctest.RandString(t, 10),
3736
}
3837

@@ -54,7 +53,6 @@ func TestAccDataSourceGoogleBackupDRDataSourceReferences_basic(t *testing.T) {
5453
// Basic attribute checks
5554
resource.TestCheckResourceAttr("data.google_backup_dr_data_source_references.default", "project", projectID),
5655
resource.TestCheckResourceAttr("data.google_backup_dr_data_source_references.default", "location", context["location"].(string)),
57-
resource.TestCheckResourceAttr("data.google_backup_dr_data_source_references.default", "resource_type", context["resource_type"].(string)),
5856

5957
// Check that the list itself is populated
6058
resource.TestCheckResourceAttrSet("data.google_backup_dr_data_source_references.default", "data_source_references.#"),
@@ -157,7 +155,6 @@ resource "google_backup_dr_backup_plan_association" "bpa" {
157155
data "google_backup_dr_data_source_references" "default" {
158156
project = data.google_project.project.project_id
159157
location = "%{location}"
160-
resource_type = "%{resource_type}"
161158
depends_on= [ google_backup_dr_backup_plan_association.bpa ]
162159
}
163160
`, context)
@@ -267,7 +264,6 @@ resource "google_backup_dr_backup_plan_association" "bpa" {
267264
data "google_backup_dr_data_source_references" "all_refs" {
268265
project = data.google_project.project.project_id
269266
location = "us-central1"
270-
resource_type = "sqladmin.googleapis.com/Instance"
271267
depends_on = [google_backup_dr_backup_plan_association.bpa]
272268
}
273269

website/docs/d/backup_dr_backup_plan_associations.html.markdown

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,18 @@
1515
# ----------------------------------------------------------------------------
1616
subcategory: "Backup and DR Service"
1717
description: |-
18-
Get information about a list of Backup and DR BackupPlanAssociations for a specific resource type .
18+
Get information about a list of Backup and DR BackupPlanAssociations.
1919
---
2020

2121
# google_backup_dr_backup_plan_associations
2222

23-
Provides a list of Backup and DR BackupPlanAssociations for a specific resource type.
23+
Provides a list of Backup and DR BackupPlanAssociations.
2424

2525
## Example Usage
2626

2727
```hcl
28-
data "google_backup_dr_backup_plan_associations" "compute_instance_associations" {
28+
data "google_backup_dr_backup_plan_associations" "all_associations" {
2929
location = "us-central1"
30-
resource_type = "compute.googleapis.com/Instance"
3130
}
3231
```
3332

@@ -36,8 +35,7 @@ data "google_backup_dr_backup_plan_associations" "compute_instance_associations"
3635
The following arguments are supported:
3736

3837
* `location` - (Required)The location where the Backup Plan Association resources reside.
39-
* `resource_type` - (Required) The resource type of the workload. For example, sqladmin.googleapis.com/Instance or compute.googleapis.com/Instance.
40-
38+
* `resource_type` - (Optional, Deprecated) The resource type of the workload. For example, sqladmin.googleapis.com/Instance or compute.googleapis.com/Instance. `resource_type` is deprecated and will be removed in a future major release.
4139
- - -
4240

4341
* `project` - (Optional) The project in which the resource belongs. If it

website/docs/d/backup_dr_data_source_references.html.markdown

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,12 @@ A list of Backup and DR data source references.
2525
## Example Usage
2626

2727
```hcl
28-
data "google_backup_dr_data_source_references" "csql_data_source_reference" {
28+
data "google_backup_dr_data_source_references" "data_source_reference" {
2929
location = "us-central1"
30-
resource_type = "sqladmin.googleapis.com/Instance"
3130
}
3231
33-
output "all_csql_data_source_references" {
34-
allReferences = data.google_backup_dr_data_source_references.my_sql_references.data_source_references
32+
output "all_data_source_references" {
33+
allReferences = data.google_backup_dr_data_source_references.my_references.data_source_references
3534
}
3635
```
3736

@@ -40,8 +39,7 @@ output "all_csql_data_source_references" {
4039
The following arguments are supported:
4140

4241
* `location `- (Required) The location of the data source references.
43-
44-
* `resource_type` - (Required) The resource type to get the data source references for. Examples include, "sqladmin.googleapis.com/Instance" , "compute.googleapis.com/Instance" (**right now this service not available for compute Instances and disk , it will be added soon**)
42+
* `resource_type` - (Optional, Deprecated) The resource type to get the data source references for. Examples include, "sqladmin.googleapis.com/Instance" , "compute.googleapis.com/Instance". `resource_type` is deprecated and will be removed in a future major release.
4543

4644
* `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
4745

0 commit comments

Comments
 (0)