diff --git a/.changelog/12363.txt b/.changelog/12363.txt new file mode 100644 index 00000000000..8cb20ddfc12 --- /dev/null +++ b/.changelog/12363.txt @@ -0,0 +1,3 @@ +```release-note:enhancement +accesscontextmanager: added `etag` to `google_access_context_manager_service_perimeter` and `google_access_context_manager_service_perimeters` +``` \ No newline at end of file diff --git a/google/services/accesscontextmanager/resource_access_context_manager_service_perimeter.go b/google/services/accesscontextmanager/resource_access_context_manager_service_perimeter.go index 5f473e2ce90..540fc237bb9 100644 --- a/google/services/accesscontextmanager/resource_access_context_manager_service_perimeter.go +++ b/google/services/accesscontextmanager/resource_access_context_manager_service_perimeter.go @@ -909,6 +909,13 @@ bet set to True if any of the fields in the spec are set to non-default values.` Computed: true, Description: `Time the AccessPolicy was created in UTC.`, }, + "etag": { + Type: schema.TypeString, + Computed: true, + Description: `An opaque identifier for the current version of the ServicePerimeter. This +identifier does not follow any specific format. If an etag is not provided, the +operation will be performed as if a valid etag is provided.`, + }, "update_time": { Type: schema.TypeString, Computed: true, @@ -963,6 +970,12 @@ func resourceAccessContextManagerServicePerimeterCreate(d *schema.ResourceData, } else if v, ok := d.GetOkExists("use_explicit_dry_run_spec"); !tpgresource.IsEmptyValue(reflect.ValueOf(useExplicitDryRunSpecProp)) && (ok || !reflect.DeepEqual(v, useExplicitDryRunSpecProp)) { obj["useExplicitDryRunSpec"] = useExplicitDryRunSpecProp } + etagProp, err := expandAccessContextManagerServicePerimeterEtag(d.Get("etag"), d, config) + if err != nil { + return err + } else if v, ok := d.GetOkExists("etag"); !tpgresource.IsEmptyValue(reflect.ValueOf(etagProp)) && (ok || !reflect.DeepEqual(v, etagProp)) { + obj["etag"] = etagProp + } parentProp, err := expandAccessContextManagerServicePerimeterParent(d.Get("parent"), d, config) if err != nil { return err @@ -1108,6 +1121,9 @@ func resourceAccessContextManagerServicePerimeterRead(d *schema.ResourceData, me if err := d.Set("use_explicit_dry_run_spec", flattenAccessContextManagerServicePerimeterUseExplicitDryRunSpec(res["useExplicitDryRunSpec"], d, config)); err != nil { return fmt.Errorf("Error reading ServicePerimeter: %s", err) } + if err := d.Set("etag", flattenAccessContextManagerServicePerimeterEtag(res["etag"], d, config)); err != nil { + return fmt.Errorf("Error reading ServicePerimeter: %s", err) + } if err := d.Set("name", flattenAccessContextManagerServicePerimeterName(res["name"], d, config)); err != nil { return fmt.Errorf("Error reading ServicePerimeter: %s", err) } @@ -1155,6 +1171,12 @@ func resourceAccessContextManagerServicePerimeterUpdate(d *schema.ResourceData, } else if v, ok := d.GetOkExists("use_explicit_dry_run_spec"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, useExplicitDryRunSpecProp)) { obj["useExplicitDryRunSpec"] = useExplicitDryRunSpecProp } + etagProp, err := expandAccessContextManagerServicePerimeterEtag(d.Get("etag"), d, config) + if err != nil { + return err + } else if v, ok := d.GetOkExists("etag"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, etagProp)) { + obj["etag"] = etagProp + } obj, err = resourceAccessContextManagerServicePerimeterEncoder(d, meta, obj) if err != nil { @@ -1196,12 +1218,21 @@ func resourceAccessContextManagerServicePerimeterUpdate(d *schema.ResourceData, if d.HasChange("use_explicit_dry_run_spec") { updateMask = append(updateMask, "useExplicitDryRunSpec") } + + if d.HasChange("etag") { + updateMask = append(updateMask, "etag") + } // updateMask is a URL parameter but not present in the schema, so ReplaceVars // won't set it url, err = transport_tpg.AddQueryParams(url, map[string]string{"updateMask": strings.Join(updateMask, ",")}) if err != nil { return err } + if _, ok := d.GetOkExists("etag"); ok { + updateMask = append(updateMask, "etag") + + url, err = transport_tpg.AddQueryParams(url, map[string]string{"updateMask": strings.Join(updateMask, ",")}) + } // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { @@ -2085,6 +2116,10 @@ func flattenAccessContextManagerServicePerimeterUseExplicitDryRunSpec(v interfac return v } +func flattenAccessContextManagerServicePerimeterEtag(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { + return v +} + func flattenAccessContextManagerServicePerimeterName(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { return v } @@ -3173,6 +3208,10 @@ func expandAccessContextManagerServicePerimeterUseExplicitDryRunSpec(v interface return v, nil } +func expandAccessContextManagerServicePerimeterEtag(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { + return v, nil +} + func expandAccessContextManagerServicePerimeterParent(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { return v, nil } diff --git a/google/services/accesscontextmanager/resource_access_context_manager_service_perimeter_test.go b/google/services/accesscontextmanager/resource_access_context_manager_service_perimeter_test.go index dfe9c32c541..85a90f58e56 100644 --- a/google/services/accesscontextmanager/resource_access_context_manager_service_perimeter_test.go +++ b/google/services/accesscontextmanager/resource_access_context_manager_service_perimeter_test.go @@ -28,6 +28,7 @@ func testAccAccessContextManagerServicePerimeter_basicTest(t *testing.T) { Steps: []resource.TestStep{ { Config: testAccAccessContextManagerServicePerimeter_basic(org, "my policy", "level", "perimeter"), + Check: resource.TestCheckResourceAttrSet("google_access_context_manager_service_perimeter.test-access", "etag"), }, { ResourceName: "google_access_context_manager_service_perimeter.test-access", diff --git a/google/services/accesscontextmanager/resource_access_context_manager_service_perimeters.go b/google/services/accesscontextmanager/resource_access_context_manager_service_perimeters.go index 21b8e296571..eb251f600f5 100644 --- a/google/services/accesscontextmanager/resource_access_context_manager_service_perimeters.go +++ b/google/services/accesscontextmanager/resource_access_context_manager_service_perimeters.go @@ -715,6 +715,13 @@ bet set to True if any of the fields in the spec are set to non-default values.` Computed: true, Description: `Time the AccessPolicy was created in UTC.`, }, + "etag": { + Type: schema.TypeString, + Computed: true, + Description: `An opaque identifier for the current version of the ServicePerimeter. This +identifier does not follow any specific format. If an etag is not provided, the +operation will be performed as if a valid etag is provided.`, + }, "update_time": { Type: schema.TypeString, Computed: true, @@ -1116,6 +1123,7 @@ func flattenAccessContextManagerServicePerimetersServicePerimeters(v interface{} "perimeter_type": flattenAccessContextManagerServicePerimetersServicePerimetersPerimeterType(original["perimeterType"], d, config), "status": flattenAccessContextManagerServicePerimetersServicePerimetersStatus(original["status"], d, config), "spec": flattenAccessContextManagerServicePerimetersServicePerimetersSpec(original["spec"], d, config), + "etag": flattenAccessContextManagerServicePerimetersServicePerimetersEtag(original["etag"], d, config), "use_explicit_dry_run_spec": flattenAccessContextManagerServicePerimetersServicePerimetersUseExplicitDryRunSpec(original["useExplicitDryRunSpec"], d, config), }) } @@ -1136,6 +1144,10 @@ func flattenAccessContextManagerServicePerimetersServicePerimetersName(v interfa return v } +func flattenAccessContextManagerServicePerimetersServicePerimetersEtag(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { + return v +} + func flattenAccessContextManagerServicePerimetersServicePerimetersTitle(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { return v } @@ -1939,6 +1951,13 @@ func expandAccessContextManagerServicePerimetersServicePerimeters(v interface{}, transformed["description"] = transformedDescription } + transformedEtag, err := expandAccessContextManagerServicePerimetersServicePerimetersEtag(original["etag"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedEtag); val.IsValid() && !tpgresource.IsEmptyValue(val) { + transformed["etag"] = transformedEtag + } + transformedCreateTime, err := expandAccessContextManagerServicePerimetersServicePerimetersCreateTime(original["create_time"], d, config) if err != nil { return nil, err @@ -1998,6 +2017,10 @@ func expandAccessContextManagerServicePerimetersServicePerimetersDescription(v i return v, nil } +func expandAccessContextManagerServicePerimetersServicePerimetersEtag(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { + return v, nil +} + func expandAccessContextManagerServicePerimetersServicePerimetersCreateTime(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { return v, nil } diff --git a/website/docs/r/access_context_manager_service_perimeter.html.markdown b/website/docs/r/access_context_manager_service_perimeter.html.markdown index 77081f9ea17..d3f65bb46a2 100644 --- a/website/docs/r/access_context_manager_service_perimeter.html.markdown +++ b/website/docs/r/access_context_manager_service_perimeter.html.markdown @@ -860,6 +860,11 @@ In addition to the arguments listed above, the following computed attributes are * `update_time` - Time the AccessPolicy was updated in UTC. +* `etag` - + An opaque identifier for the current version of the ServicePerimeter. This + identifier does not follow any specific format. If an etag is not provided, the + operation will be performed as if a valid etag is provided. + ## Timeouts diff --git a/website/docs/r/access_context_manager_service_perimeters.html.markdown b/website/docs/r/access_context_manager_service_perimeters.html.markdown index 9e05bf9462a..ed446be3469 100644 --- a/website/docs/r/access_context_manager_service_perimeters.html.markdown +++ b/website/docs/r/access_context_manager_service_perimeters.html.markdown @@ -119,6 +119,12 @@ The following arguments are supported: Description of the ServicePerimeter and its use. Does not affect behavior. +* `etag` - + (Output) + An opaque identifier for the current version of the ServicePerimeter. This + identifier does not follow any specific format. If an etag is not provided, the + operation will be performed as if a valid etag is provided. + * `create_time` - (Output) Time the AccessPolicy was created in UTC.