From 1cc487acbabbd42e3053e1de11ecacc35cb61161 Mon Sep 17 00:00:00 2001 From: The Magician Date: Tue, 4 May 2021 09:32:17 -0700 Subject: [PATCH] add requireVerifiedChromeOs as optional (#4758) (#9071) * add requireVerifiedChromeOs as optional see https://cloud.google.com/access-context-manager/docs/access-level-attributes * add to tests Signed-off-by: Modular Magician --- .changelog/4758.txt | 3 +++ ...rce_access_context_manager_access_level.go | 25 +++++++++++++++++-- ...ext_manager_access_level_condition_test.go | 1 + ...ccess_context_manager_access_level_test.go | 1 + ...context_manager_access_level.html.markdown | 4 +++ 5 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 .changelog/4758.txt diff --git a/.changelog/4758.txt b/.changelog/4758.txt new file mode 100644 index 00000000000..882e5f70acc --- /dev/null +++ b/.changelog/4758.txt @@ -0,0 +1,3 @@ +```release-note:enhancement +accesscontextmanager: added support for `require_verified_chrome_os` in basic access levels. +``` diff --git a/google/resource_access_context_manager_access_level.go b/google/resource_access_context_manager_access_level.go index b010f4440ca..89d7dda4638 100644 --- a/google/resource_access_context_manager_access_level.go +++ b/google/resource_access_context_manager_access_level.go @@ -126,6 +126,11 @@ An empty list allows all types and all versions.`, of this OS satisfies the constraint. Format: "major.minor.patch" such as "10.5.301", "9.2.1".`, }, + "require_verified_chrome_os": { + Type: schema.TypeBool, + Optional: true, + Description: `If you specify DESKTOP_CHROME_OS for osType, you can optionally include requireVerifiedChromeOs to require Chrome Verified Access.`, + }, }, }, }, @@ -695,8 +700,9 @@ func flattenAccessContextManagerAccessLevelBasicConditionsDevicePolicyOsConstrai continue } transformed = append(transformed, map[string]interface{}{ - "minimum_version": flattenAccessContextManagerAccessLevelBasicConditionsDevicePolicyOsConstraintsMinimumVersion(original["minimumVersion"], d, config), - "os_type": flattenAccessContextManagerAccessLevelBasicConditionsDevicePolicyOsConstraintsOsType(original["osType"], d, config), + "minimum_version": flattenAccessContextManagerAccessLevelBasicConditionsDevicePolicyOsConstraintsMinimumVersion(original["minimumVersion"], d, config), + "require_verified_chrome_os": flattenAccessContextManagerAccessLevelBasicConditionsDevicePolicyOsConstraintsRequireVerifiedChromeOs(original["requireVerifiedChromeOs"], d, config), + "os_type": flattenAccessContextManagerAccessLevelBasicConditionsDevicePolicyOsConstraintsOsType(original["osType"], d, config), }) } return transformed @@ -705,6 +711,10 @@ func flattenAccessContextManagerAccessLevelBasicConditionsDevicePolicyOsConstrai return v } +func flattenAccessContextManagerAccessLevelBasicConditionsDevicePolicyOsConstraintsRequireVerifiedChromeOs(v interface{}, d *schema.ResourceData, config *Config) interface{} { + return v +} + func flattenAccessContextManagerAccessLevelBasicConditionsDevicePolicyOsConstraintsOsType(v interface{}, d *schema.ResourceData, config *Config) interface{} { return v } @@ -967,6 +977,13 @@ func expandAccessContextManagerAccessLevelBasicConditionsDevicePolicyOsConstrain transformed["minimumVersion"] = transformedMinimumVersion } + transformedRequireVerifiedChromeOs, err := expandAccessContextManagerAccessLevelBasicConditionsDevicePolicyOsConstraintsRequireVerifiedChromeOs(original["require_verified_chrome_os"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedRequireVerifiedChromeOs); val.IsValid() && !isEmptyValue(val) { + transformed["requireVerifiedChromeOs"] = transformedRequireVerifiedChromeOs + } + transformedOsType, err := expandAccessContextManagerAccessLevelBasicConditionsDevicePolicyOsConstraintsOsType(original["os_type"], d, config) if err != nil { return nil, err @@ -983,6 +1000,10 @@ func expandAccessContextManagerAccessLevelBasicConditionsDevicePolicyOsConstrain return v, nil } +func expandAccessContextManagerAccessLevelBasicConditionsDevicePolicyOsConstraintsRequireVerifiedChromeOs(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) { + return v, nil +} + func expandAccessContextManagerAccessLevelBasicConditionsDevicePolicyOsConstraintsOsType(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) { return v, nil } diff --git a/google/resource_access_context_manager_access_level_condition_test.go b/google/resource_access_context_manager_access_level_condition_test.go index e1eb4fb9489..7051fe4d60a 100644 --- a/google/resource_access_context_manager_access_level_condition_test.go +++ b/google/resource_access_context_manager_access_level_condition_test.go @@ -115,6 +115,7 @@ resource "google_access_context_manager_access_level" "test-access" { require_screen_lock = true os_constraints { os_type = "DESKTOP_CHROME_OS" + require_verified_chrome_os = true } } regions = [ diff --git a/google/resource_access_context_manager_access_level_test.go b/google/resource_access_context_manager_access_level_test.go index e7718798e18..d2313712c86 100644 --- a/google/resource_access_context_manager_access_level_test.go +++ b/google/resource_access_context_manager_access_level_test.go @@ -192,6 +192,7 @@ resource "google_access_context_manager_access_level" "test-access" { require_corp_owned = true os_constraints { os_type = "DESKTOP_CHROME_OS" + require_verified_chrome_os = true } } regions = [ diff --git a/website/docs/r/access_context_manager_access_level.html.markdown b/website/docs/r/access_context_manager_access_level.html.markdown index 7632d96c989..534b1fdd175 100644 --- a/website/docs/r/access_context_manager_access_level.html.markdown +++ b/website/docs/r/access_context_manager_access_level.html.markdown @@ -223,6 +223,10 @@ The `os_constraints` block supports: of this OS satisfies the constraint. Format: "major.minor.patch" such as "10.5.301", "9.2.1". +* `require_verified_chrome_os` - + (Optional) + If you specify DESKTOP_CHROME_OS for osType, you can optionally include requireVerifiedChromeOs to require Chrome Verified Access. + * `os_type` - (Required) The operating system type of the device.