Skip to content

Commit 3406635

Browse files
Converting backupdr data sources from fetch to list (#15645)
Co-authored-by: Cameron Thornton <[email protected]>
1 parent be8a2ec commit 3406635

6 files changed

+15
-27
lines changed

mmv1/third_party/terraform/services/backupdr/data_source_backup_dr_backup_plan_association.go

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

17-
// Set 'Optional' schema elements
1817
tpgresource.AddOptionalFieldsToSchema(dsSchema, "project")
1918
return &schema.Resource{
2019
Read: dataSourceGoogleCloudBackupDRBackupPlanAssociationRead,
@@ -64,10 +63,10 @@ func DataSourceGoogleCloudBackupDRBackupPlanAssociations() *schema.Resource {
6463
},
6564
"resource_type": {
6665
Type: schema.TypeString,
67-
Required: true,
66+
Optional: true,
6867
Description: `The resource type of workload on which backup plan is applied. Examples include, "compute.googleapis.com/Instance", "compute.googleapis.com/Disk".`,
68+
Deprecated: "`resource_type` is deprecated and will be removed in a future major release.",
6969
},
70-
7170
"associations": {
7271
Type: schema.TypeList,
7372
Computed: true,
@@ -157,9 +156,8 @@ func dataSourceGoogleCloudBackupDRBackupPlanAssociationsRead(d *schema.ResourceD
157156
}
158157

159158
location := d.Get("location").(string)
160-
resourceType := d.Get("resource_type").(string)
161159

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

164162
res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{
165163
Config: config,

mmv1/third_party/terraform/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
@@ -295,7 +295,6 @@ resource "google_backup_dr_backup_plan_association" "bpa" {
295295
296296
data "google_backup_dr_backup_plan_associations" "bpas" {
297297
location = "us-central1"
298-
resource_type = "compute.googleapis.com/Instance"
299298
depends_on = [google_backup_dr_backup_plan_association.bpa]
300299
}
301300
`, context)

mmv1/third_party/terraform/services/backupdr/data_source_backup_dr_data_source_reference.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ func DataSourceGoogleCloudBackupDRDataSourceReferences() *schema.Resource {
2727
},
2828
"resource_type": {
2929
Type: schema.TypeString,
30-
Required: true,
31-
Description: `The resource type to get the data source references for. Examples include, "compute.googleapis.com/Instance", "sqladmin.googleapis.com/Instance".`,
30+
Optional: true,
31+
Description: `The resource type of workload on which backup plan is applied. Examples include, "compute.googleapis.com/Instance", "compute.googleapis.com/Disk".`,
32+
Deprecated: "`resource_type` is deprecated and will be removed in a future major release.",
3233
},
33-
3434
// Output: a computed list of the data source references found
3535
"data_source_references": {
3636
Type: schema.TypeList,
@@ -96,9 +96,8 @@ func dataSourceGoogleCloudBackupDRDataSourceReferencesRead(d *schema.ResourceDat
9696
}
9797

9898
location := d.Get("location").(string)
99-
resourceType := d.Get("resource_type").(string)
10099

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

103102
res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{
104103
Config: config,

mmv1/third_party/terraform/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
@@ -16,7 +16,6 @@ func TestAccDataSourceGoogleBackupDRDataSourceReferences_basic(t *testing.T) {
1616
var projectID string
1717
context := map[string]interface{}{
1818
"location": "us-central1",
19-
"resource_type": "sqladmin.googleapis.com/Instance",
2019
"random_suffix": acctest.RandString(t, 10),
2120
}
2221

@@ -38,7 +37,6 @@ func TestAccDataSourceGoogleBackupDRDataSourceReferences_basic(t *testing.T) {
3837
// Basic attribute checks
3938
resource.TestCheckResourceAttr("data.google_backup_dr_data_source_references.default", "project", projectID),
4039
resource.TestCheckResourceAttr("data.google_backup_dr_data_source_references.default", "location", context["location"].(string)),
41-
resource.TestCheckResourceAttr("data.google_backup_dr_data_source_references.default", "resource_type", context["resource_type"].(string)),
4240

4341
// Check that the list itself is populated
4442
resource.TestCheckResourceAttrSet("data.google_backup_dr_data_source_references.default", "data_source_references.#"),
@@ -141,7 +139,6 @@ resource "google_backup_dr_backup_plan_association" "bpa" {
141139
data "google_backup_dr_data_source_references" "default" {
142140
project = data.google_project.project.project_id
143141
location = "%{location}"
144-
resource_type = "%{resource_type}"
145142
depends_on= [ google_backup_dr_backup_plan_association.bpa ]
146143
}
147144
`, context)
@@ -251,7 +248,6 @@ resource "google_backup_dr_backup_plan_association" "bpa" {
251248
data "google_backup_dr_data_source_references" "all_refs" {
252249
project = data.google_project.project.project_id
253250
location = "us-central1"
254-
resource_type = "sqladmin.googleapis.com/Instance"
255251
depends_on = [google_backup_dr_backup_plan_association.bpa]
256252
}
257253

mmv1/third_party/terraform/website/docs/d/backup_dr_backup_plan_associations.html.markdown

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
11
---
22
subcategory: "Backup and DR Service"
33
description: |-
4-
Get information about a list of Backup and DR BackupPlanAssociations for a specific resource type .
4+
Get information about a list of Backup and DR BackupPlanAssociations.
55
---
66

77
# google_backup_dr_backup_plan_associations
88

9-
Provides a list of Backup and DR BackupPlanAssociations for a specific resource type.
9+
Provides a list of Backup and DR BackupPlanAssociations.
1010

1111
## Example Usage
1212

1313
```hcl
14-
data "google_backup_dr_backup_plan_associations" "compute_instance_associations" {
14+
data "google_backup_dr_backup_plan_associations" "all_associations" {
1515
location = "us-central1"
16-
resource_type = "compute.googleapis.com/Instance"
1716
}
1817
```
1918

@@ -22,8 +21,7 @@ data "google_backup_dr_backup_plan_associations" "compute_instance_associations"
2221
The following arguments are supported:
2322

2423
* `location` - (Required)The location where the Backup Plan Association resources reside.
25-
* `resource_type` - (Required) The resource type of the workload. For example, sqladmin.googleapis.com/Instance or compute.googleapis.com/Instance.
26-
24+
* `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.
2725
- - -
2826

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

mmv1/third_party/terraform/website/docs/d/backup_dr_data_source_references.html.markdown

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

1313
```hcl
14-
data "google_backup_dr_data_source_references" "csql_data_source_reference" {
14+
data "google_backup_dr_data_source_references" "data_source_reference" {
1515
location = "us-central1"
16-
resource_type = "sqladmin.googleapis.com/Instance"
1716
}
1817
19-
output "all_csql_data_source_references" {
20-
allReferences = data.google_backup_dr_data_source_references.my_sql_references.data_source_references
18+
output "all_data_source_references" {
19+
allReferences = data.google_backup_dr_data_source_references.my_references.data_source_references
2120
}
2221
```
2322

@@ -26,8 +25,7 @@ output "all_csql_data_source_references" {
2625
The following arguments are supported:
2726

2827
* `location `- (Required) The location of the data source references.
29-
30-
* `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**)
28+
* `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.
3129

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

0 commit comments

Comments
 (0)