Skip to content

Commit 8eee72e

Browse files
Add locations field to mirroring deployment group. (#13367) (#9607)
[upstream:91c7e1ca9a393939e37997997c603ff1b69bf371] Signed-off-by: Modular Magician <[email protected]>
1 parent 1bb26f4 commit 8eee72e

4 files changed

+81
-0
lines changed

.changelog/13367.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:enhancement
2+
networksecurity: added `locations` field to `google_network_security_mirroring_deployment_group` resource
3+
```

google-beta/services/networksecurity/resource_network_security_mirroring_deployment_group.go

+58
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,13 @@ See https://google.aip.dev/148#timestamps.`,
121121
Description: `All of labels (key/value pairs) present on the resource in GCP, including the labels configured through Terraform, other clients and services.`,
122122
Elem: &schema.Schema{Type: schema.TypeString},
123123
},
124+
"locations": {
125+
Type: schema.TypeSet,
126+
Computed: true,
127+
Description: `The list of locations where the deployment group is present.`,
128+
Elem: networksecurityMirroringDeploymentGroupLocationsSchema(),
129+
// Default schema.HashSchema is used.
130+
},
124131
"name": {
125132
Type: schema.TypeString,
126133
Computed: true,
@@ -171,6 +178,27 @@ See https://google.aip.dev/148#timestamps.`,
171178
}
172179
}
173180

181+
func networksecurityMirroringDeploymentGroupLocationsSchema() *schema.Resource {
182+
return &schema.Resource{
183+
Schema: map[string]*schema.Schema{
184+
"location": {
185+
Type: schema.TypeString,
186+
Computed: true,
187+
Description: `The cloud location, e.g. 'us-central1-a' or 'asia-south1-b'.`,
188+
},
189+
"state": {
190+
Type: schema.TypeString,
191+
Computed: true,
192+
Description: `The current state of the association in this location.
193+
Possible values:
194+
STATE_UNSPECIFIED
195+
ACTIVE
196+
OUT_OF_SYNC`,
197+
},
198+
},
199+
}
200+
}
201+
174202
func resourceNetworkSecurityMirroringDeploymentGroupCreate(d *schema.ResourceData, meta interface{}) error {
175203
config := meta.(*transport_tpg.Config)
176204
userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent)
@@ -337,6 +365,9 @@ func resourceNetworkSecurityMirroringDeploymentGroupRead(d *schema.ResourceData,
337365
if err := d.Set("description", flattenNetworkSecurityMirroringDeploymentGroupDescription(res["description"], d, config)); err != nil {
338366
return fmt.Errorf("Error reading MirroringDeploymentGroup: %s", err)
339367
}
368+
if err := d.Set("locations", flattenNetworkSecurityMirroringDeploymentGroupLocations(res["locations"], d, config)); err != nil {
369+
return fmt.Errorf("Error reading MirroringDeploymentGroup: %s", err)
370+
}
340371
if err := d.Set("terraform_labels", flattenNetworkSecurityMirroringDeploymentGroupTerraformLabels(res["labels"], d, config)); err != nil {
341372
return fmt.Errorf("Error reading MirroringDeploymentGroup: %s", err)
342373
}
@@ -576,6 +607,33 @@ func flattenNetworkSecurityMirroringDeploymentGroupDescription(v interface{}, d
576607
return v
577608
}
578609

610+
func flattenNetworkSecurityMirroringDeploymentGroupLocations(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
611+
if v == nil {
612+
return v
613+
}
614+
l := v.([]interface{})
615+
transformed := schema.NewSet(schema.HashResource(networksecurityMirroringDeploymentGroupLocationsSchema()), []interface{}{})
616+
for _, raw := range l {
617+
original := raw.(map[string]interface{})
618+
if len(original) < 1 {
619+
// Do not include empty json objects coming back from the api
620+
continue
621+
}
622+
transformed.Add(map[string]interface{}{
623+
"location": flattenNetworkSecurityMirroringDeploymentGroupLocationsLocation(original["location"], d, config),
624+
"state": flattenNetworkSecurityMirroringDeploymentGroupLocationsState(original["state"], d, config),
625+
})
626+
}
627+
return transformed
628+
}
629+
func flattenNetworkSecurityMirroringDeploymentGroupLocationsLocation(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
630+
return v
631+
}
632+
633+
func flattenNetworkSecurityMirroringDeploymentGroupLocationsState(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
634+
return v
635+
}
636+
579637
func flattenNetworkSecurityMirroringDeploymentGroupTerraformLabels(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
580638
if v == nil {
581639
return v

google-beta/services/networksecurity/resource_network_security_mirroring_deployment_group_generated_meta.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ fields:
1313
- field: 'labels'
1414
- field: 'location'
1515
provider_only: true
16+
- field: 'locations.location'
17+
- field: 'locations.state'
1618
- field: 'mirroring_deployment_group_id'
1719
provider_only: true
1820
- field: 'name'

website/docs/r/network_security_mirroring_deployment_group.html.markdown

+18
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,10 @@ In addition to the arguments listed above, the following computed attributes are
135135
operation (e.g. adding a new deployment to the group)
136136
See https://google.aip.dev/128.
137137

138+
* `locations` -
139+
The list of locations where the deployment group is present.
140+
Structure is [documented below](#nested_locations).
141+
138142
* `terraform_labels` -
139143
The combination of labels configured directly on the resource
140144
and default labels configured on the provider.
@@ -151,6 +155,20 @@ In addition to the arguments listed above, the following computed attributes are
151155
`projects/123456789/locations/global/mirroringEndpointGroups/my-eg`.
152156
See https://google.aip.dev/124.
153157

158+
<a name="nested_locations"></a>The `locations` block contains:
159+
160+
* `location` -
161+
(Output)
162+
The cloud location, e.g. `us-central1-a` or `asia-south1-b`.
163+
164+
* `state` -
165+
(Output)
166+
The current state of the association in this location.
167+
Possible values:
168+
STATE_UNSPECIFIED
169+
ACTIVE
170+
OUT_OF_SYNC
171+
154172
## Timeouts
155173

156174
This resource provides the following

0 commit comments

Comments
 (0)