Skip to content

Commit

Permalink
Chrome Policy API support (#97)
Browse files Browse the repository at this point in the history
* Implement chrome policy schema datasources

* Add missing lines

* make diffsuppressfunc, revert export of org_unit_id to contain prefix for consistency

* Implement chrome policy resource

* Fix ordering

* Add resource

* Implement update

* add validations and get tests to pass

* Fix implementation and write tests

* make test more complex

* Write even more thorough test, fix description

* Add datasource test

* Add examples

* generate examples

* return early if error

* add some nil checks

* add more nil checks

Co-authored-by: Megan Bang <[email protected]>
  • Loading branch information
appilon and megan07 authored Jul 7, 2021
1 parent f039416 commit 4a497b1
Show file tree
Hide file tree
Showing 15 changed files with 1,408 additions and 25 deletions.
6 changes: 6 additions & 0 deletions .github/infra/gcp.tf
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,9 @@ resource "google_project_service" "group-settings" {
project = data.google_project.project.project_id
service = "groupssettings.googleapis.com"
}

// Enable the chrome policy api service
resource "google_project_service" "chrome-policy" {
project = data.google_project.project.project_id
service = "chromepolicy.googleapis.com"
}
95 changes: 95 additions & 0 deletions docs/data-sources/chrome_policy_schema.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "googleworkspace_chrome_policy_schema Data Source - terraform-provider-googleworkspace"
subcategory: ""
description: |-
Chrome Policy Schema data source in the Terraform Googleworkspace provider.
---

# googleworkspace_chrome_policy_schema (Data Source)

Chrome Policy Schema data source in the Terraform Googleworkspace provider.

## Example Usage

```terraform
data "googleworkspace_chrome_policy_schema" "example" {
schema_name = "chrome.printers.AllowForUsers"
}
output "field_descriptions" {
value = data.googleworkspace_chrome_policy_schema.example.field_descriptions
}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Required

- **schema_name** (String) The full qualified name of the policy schema

### Optional

- **id** (String) The ID of this resource.

### Read-Only

- **access_restrictions** (List of String) Specific access restrictions related to this policy.
- **additional_target_key_names** (List of Object) Additional key names that will be used to identify the target of the policy value. When specifying a policyTargetKey, each of the additional keys specified here will have to be included in the additionalTargetKeys map. (see [below for nested schema](#nestedatt--additional_target_key_names))
- **definition** (List of Object) Schema definition using proto descriptor. (see [below for nested schema](#nestedatt--definition))
- **field_descriptions** (String) Detailed description of each field that is part of the schema, represented as a JSON string.
- **notices** (List of Object) Special notice messages related to setting certain values in certain fields in the schema. (see [below for nested schema](#nestedatt--notices))
- **policy_description** (String) Description about the policy schema for user consumption.
- **support_uri** (String) URI to related support article for this schema.

<a id="nestedatt--additional_target_key_names"></a>
### Nested Schema for `additional_target_key_names`

Read-Only:

- **key** (String)
- **key_description** (String)


<a id="nestedatt--definition"></a>
### Nested Schema for `definition`

Read-Only:

- **enum_type** (List of Object) (see [below for nested schema](#nestedobjatt--definition--enum_type))
- **message_type** (String)
- **name** (String)
- **package** (String)
- **syntax** (String)

<a id="nestedobjatt--definition--enum_type"></a>
### Nested Schema for `definition.enum_type`

Read-Only:

- **name** (String)
- **value** (List of Object) (see [below for nested schema](#nestedobjatt--definition--enum_type--value))

<a id="nestedobjatt--definition--enum_type--value"></a>
### Nested Schema for `definition.enum_type.value`

Read-Only:

- **name** (String)
- **number** (Number)




<a id="nestedatt--notices"></a>
### Nested Schema for `notices`

Read-Only:

- **acknowledgement_required** (Boolean)
- **field** (String)
- **notice_message** (String)
- **notice_value** (String)


52 changes: 52 additions & 0 deletions docs/resources/chrome_policy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "googleworkspace_chrome_policy Resource - terraform-provider-googleworkspace"
subcategory: ""
description: |-
Chrome Policy resource in the Terraform Googleworkspace provider. Currently only supports policies not requiring additionalTargetKeys.
---

# googleworkspace_chrome_policy (Resource)

Chrome Policy resource in the Terraform Googleworkspace provider. Currently only supports policies not requiring additionalTargetKeys.

## Example Usage

```terraform
resource "googleworkspace_org_unit" "example" {
name = "example"
parent_org_unit_path = "/"
}
resource "googleworkspace_chrome_policy" "example" {
org_unit_id = googleworkspace_org_unit.test.id
policies {
schema_name = "chrome.users.MaxConnectionsPerProxy"
schema_values = {
maxConnectionsPerProxy = jsonencode(34)
}
}
}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Required

- **org_unit_id** (String) The target org unit on which this policy is applied.
- **policies** (Block List, Min: 1) Policies to set for the org unit (see [below for nested schema](#nestedblock--policies))

### Optional

- **id** (String) The ID of this resource.

<a id="nestedblock--policies"></a>
### Nested Schema for `policies`

Required:

- **schema_name** (String) The full qualified name of the policy schema.
- **schema_values** (Map of String) JSON encoded map that represents key/value pairs that correspond to the given schema.


Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
data "googleworkspace_chrome_policy_schema" "example" {
schema_name = "chrome.printers.AllowForUsers"
}

output "field_descriptions" {
value = data.googleworkspace_chrome_policy_schema.example.field_descriptions
}
14 changes: 14 additions & 0 deletions examples/resources/googleworkspace_chrome_policy/resource.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
resource "googleworkspace_org_unit" "example" {
name = "example"
parent_org_unit_path = "/"
}

resource "googleworkspace_chrome_policy" "example" {
org_unit_id = googleworkspace_org_unit.test.id
policies {
schema_name = "chrome.users.MaxConnectionsPerProxy"
schema_values = {
maxConnectionsPerProxy = jsonencode(34)
}
}
}
Loading

0 comments on commit 4a497b1

Please sign in to comment.