Skip to content

Commit

Permalink
Merge branch 'dev' into DEVTOOLING-625
Browse files Browse the repository at this point in the history
  • Loading branch information
charliecon committed Jul 18, 2024
2 parents 0c2a1d8 + 651e9b8 commit 309125a
Show file tree
Hide file tree
Showing 567 changed files with 12,461 additions and 6,066 deletions.
22 changes: 18 additions & 4 deletions .github/workflows/generate.yml → .github/workflows/go-checks.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
name: Ensure Documentation in Sync
name: Go Checks
on:
push:
paths-ignore:
- 'README.md'
jobs:
# ensure the documentation is up to date
generate:
name: Generate
go-checks:
name: Go Checks
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
Expand Down Expand Up @@ -35,5 +34,20 @@ jobs:
if [[ -n $(git status -s) ]]; then
echo "There are untracked documentation changes:\n"
git status
fi
- name: Tidy
run: |
go mod tidy
if [[ -n $(git status -s) ]]; then
echo "go mod tidy produced changes:\n"
git status
fi
- name: Vet
run: |
if [[ -n $(go vet ./genesyscloud/... 2>&1) ]]; then
echo "go vet highlighted the following:\n"
go vet ./genesyscloud/...
exit 1
fi
4 changes: 2 additions & 2 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Visit https://goreleaser.com for documentation on how to customize this
# behavior.
version: 2

before:
hooks:
# this is just an example and not a requirement for provider building/publishing
Expand Down Expand Up @@ -56,8 +58,6 @@ signs:
release:
draft: true
changelog:
# Defaults to false.
skip: 'false'
use: github
sort: asc
abbrev: -1
Expand Down
5 changes: 4 additions & 1 deletion GNUmakefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
default: build

.PHONY: testacc clean build sideload
.PHONY: testacc clean build docs sideload

DIST_DIR=./dist
BIN_NAME=terraform-provider-genesyscloud
Expand Down Expand Up @@ -29,6 +29,9 @@ testacc:
testunit:
TF_UNIT=1 go test ./... -run TestUnit -cover -count=1 -coverprofile=coverage_unit.out

# Generate docs
docs:
go generate

coverageacc:
go tool cover -func coverage.out | grep "total:" | \
Expand Down
32 changes: 17 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
![tests](https://github.com/MyPureCloud/terraform-provider-genesyscloud/workflows/Tests/badge.svg?branch=main)

# Genesys Cloud Terraform Provider

<img src="https://upload.wikimedia.org/wikipedia/commons/0/04/Terraform_Logo.svg" width="600px" alt="Terraform Logo">

## Requirements

- [Terraform](https://www.terraform.io/downloads.html) >= 1.0.x
- [Go](https://golang.org/doc/install) >= 1.18
- [Terraform](https://www.terraform.io/downloads.html) >= 1.0.x
- [Go](https://golang.org/doc/install) >= 1.18

## Building The Provider

Expand Down Expand Up @@ -45,9 +47,9 @@ GENESYSCLOUD_ACCESS_TOKEN
GENESYSCLOUD_REGION
```

*Note:* If `GENESYSCLOUD_ACCESS_TOKEN` is set, the Oauth client will use the access token instead of client credentials to make requests.
_Note:_ If `GENESYSCLOUD_ACCESS_TOKEN` is set, the Oauth client will use the access token instead of client credentials to make requests.

*Note:* The provider makes Public API calls to perform all of the CRUD operations necessary to manage Genesys Cloud resources. All of these API calls require specific permissions and OAuth scopes. Therefore it is important that you verify your OAuth Client is authorized for all necessary scopes and is assigned an admin role capable of creating, reading, updating, and deleting all resources that your Terraform configuration will manage.
_Note:_ The provider makes Public API calls to perform all of the CRUD operations necessary to manage Genesys Cloud resources. All of these API calls require specific permissions and OAuth scopes. Therefore it is important that you verify your OAuth Client is authorized for all necessary scopes and is assigned an admin role capable of creating, reading, updating, and deleting all resources that your Terraform configuration will manage.

For any issues, questions, or suggestions for the provider, visit the [Genesys Cloud Developer Forum](https://developer.mypurecloud.com/forum/)

Expand All @@ -61,19 +63,19 @@ port - Port of the Proxy server
host - Host Ip or DNS of the proxy server
protocol - Protocol required to connect to the Proxy (http or https)

The 'proxy' has another section which is an optional section.
The 'proxy' has another section which is an optional section.
If the proxy requires authentication to connect to
'auth' needs to be mentioned under the 'Proxy'.

An example of the provider configuration with the proxy:
An example of the provider configuration with the proxy:

```hcl
provider "genesyscloud" {
oauthclient_id = "<client-id>"
oauthclient_secret = "<client-secret>"
aws_region = "<aws-region>"
proxy {
proxy {
host = "example.com"
port = "8443"
protocol = "https"
Expand All @@ -100,11 +102,13 @@ GENESYSCLOUD_PROXY_AUTH_PASSWORD
### Data Sources

There may be cases where you want to reference existing resources in a Terraform configuration file but do not want those resources to be managed by Terraform. This provider supports several data source types that can act as a read-only resource for existing objects in your org. To include one in your configuration, add a `data` block to your configuration file with one of the supported data source types:

```hcl
data "genesyscloud_auth_role" "employee" {
name = "employee"
}
```

The example above will attempt to find a role named "employee" which can be referenced elsewhere in the config. By default, all data sources will allow you to access the `id` attribute which is useful for setting reference attributes that require IDs. Additional attributes may be added to data sources as needs arise.

## Developing the Provider
Expand All @@ -121,32 +125,30 @@ In order to run the full suite of Acceptance tests, run `make testacc`. You can
$ make testacc TESTARGS="-run TestAccResourceUserBasic"
```

All new resources must have passing acceptance tests and docs in order to be merged. Most of the docs are generated automatically from the schema and examples folder by running `go generate`.

All new resources must have passing acceptance tests and docs in order to be merged. Most of the docs are generated automatically from the schema and examples folder by running `make docs`.

To run all of the unit tests:

```sh
$make testunit
```



### Adding a new resource type

1. Create new package inside `genesyscloud` with the following files. The package name should match the name of the resource (minus, the genesyscloud_ prefix).
1. Create new package inside `genesyscloud` with the following files. The package name should match the name of the resource (minus, the genesyscloud\_ prefix).
- `resource_genesyscloud_{resource_name}_schema.go` - The file containing the schema definition for the resource, data source, and exporter. It also contains a constant variable which defines the resource name, and a public function called `SetRegistrar`, which will be called from outside the package to register the resource with the provider. The schema should closely match Public API schemas, but there are some Terraform schema limitations that may require some deviation from the API.
- `resource_genesyscloud_{resource_name}.go` - Contains the create, read, update and delete functions for the resource (the methods for the resource's `CreateContext`, `ReadContext`, `UpdateContext`, and `DeleteContext` attributes.) It also contains the getAll function to be used by the exporter. If you have a few helper functions present in this file, that is fine, but if there are more than 1-2 helper functions you should create a `resource_genesyscloud_{resource_name}_utils.go` to contain the business logic.
- `resource_genesyscloud_{resource_name}_test.go` - Contains the resource tests. Write acceptance test cases that cover all of the attributes and CRUD operations for the resource. Acceptance tests modify real resources in a test org and require an OAuth Client authorized to create, update, and delete the resource type in the org. See existing tests for examples and [Terraform Acceptance Test documentation](https://www.terraform.io/docs/extend/testing/acceptance-tests/index.html) for more details. Unit tests are also encouraged where applicable (for helper functions etc.)
- `resource_genesyscloud_{resource_name}_test.go` - Contains the resource tests. Write acceptance test cases that cover all of the attributes and CRUD operations for the resource. Acceptance tests modify real resources in a test org and require an OAuth Client authorized to create, update, and delete the resource type in the org. See existing tests for examples and [Terraform Acceptance Test documentation](https://www.terraform.io/docs/extend/testing/acceptance-tests/index.html) for more details. Unit tests are also encouraged where applicable (for helper functions etc.)
- `data_source_genesyscloud_{resource_name}.go` - This file contains all of the data source logic for a resource. The data source should call any Genesys Cloud APIs through its API proxy class. All functions and variables in this class should be private.
- `data_source_genesyscloud_{resource_name}_test.go` - Contains the data source tests.
- `genesyscloud_{resource_name}_proxy.go` - This contains all of the API logic for interacting with the Genesys Cloud APIs. This is meant to be an isolated layer from Terraform, so know Terraform objects should be passed back and forth to this code. All functions and variables in this class should be private.
- `genesyscloud_{resource_name}_init_test.go` - This file contains all of the logic needed to initialize a test case for your resource. All functions and variables in this class should be private.
2. Add a new folder for the resource and data source under the `/examples` folder. An example `resource.tf` file for the resource should be added to the folder along with an `apis.md` file listing all of the APIs the resource uses. To generate the documentation, run `go generate`. __Note:__ Everything inside the `docs` directory is generated based off schema data and the content inside `examples`. Do not manually edit anything inside `docs`.
2. Add a new folder for the resource and data source under the `/examples` folder. An example `resource.tf` file for the resource should be added to the folder along with an `apis.md` file listing all of the APIs the resource uses. To generate the documentation, run `go generate`. **Note:** Everything inside the `docs` directory is generated based off schema data and the content inside `examples`. Do not manually edit anything inside `docs`.
3. Import your package to `main.go` at the root of the project and, from the `registerResources` function, call the SetRegistrar function passing in the `regInstance` variable.

If you want to go off of an example, we recommend using the [external contacts](https://github.com/MyPureCloud/terraform-provider-genesyscloud/tree/main/genesyscloud/external_contacts) package.

### Cx As Code Resource Generator
### Cx As Code Resource Generator

[The Cx as Code Resource Generator](https://github.com/MyPureCloud/cxascode-resource-generator) is a tool that can help generate resources for Cx as Code and speed up development. The resource generator will generate resources using the package structure mentioned above. The project can be found [here](https://github.com/MyPureCloud/cxascode-resource-generator) and all usage is documented in the README. Please note that the resource generator is not perfect, it is a tool to help with development and the generated code will require review and the package will still need to be registered manually in `main.go`.

Expand Down
30 changes: 30 additions & 0 deletions docs/data-sources/outbound_contact_list_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "genesyscloud_outbound_contact_list_template Data Source - terraform-provider-genesyscloud"
subcategory: ""
description: |-
Data source for Genesys Cloud Outbound Contact Lists Templates. Select a contact list template by name.
---

# genesyscloud_outbound_contact_list_template (Data Source)

Data source for Genesys Cloud Outbound Contact Lists Templates. Select a contact list template by name.

## Example Usage

```terraform
data "genesyscloud_outbound_contact_list_template" "contact_list_template" {
name = "Example Contact List Template"
}
```

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

### Required

- `name` (String) Contact List Template name.

### Read-Only

- `id` (String) The ID of this resource.
44 changes: 0 additions & 44 deletions docs/data-sources/routing_settings.md

This file was deleted.

4 changes: 0 additions & 4 deletions docs/data-sources/telephony_providers_edges_site.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@ data "genesyscloud_telephony_providers_edges_site" "site" {

- `name` (String) Site name.

### Optional

- `managed` (Boolean) Return entities that are managed by Genesys Cloud. Defaults to `false`.

### Read-Only

- `id` (String) The ID of this resource.
1 change: 1 addition & 0 deletions docs/resources/group.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ resource "genesyscloud_group" "sample_group" {
- `description` (String) Group description.
- `member_ids` (Set of String) IDs of members assigned to the group. If not set, this resource will not manage group members.
- `owner_ids` (List of String) IDs of owners of the group.
- `roles_enabled` (Boolean) Allow roles to be assigned to this group. Defaults to `true`.
- `rules_visible` (Boolean) Are membership rules visible to the person requesting to view the group. Defaults to `true`.
- `type` (String) Group type (official | social). This cannot be modified. Changing type attribute will cause the existing genesys_group object to dropped and recreated with a new ID. Defaults to `official`.
- `visibility` (String) Who can view this group (public | owners | members). Defaults to `public`.
Expand Down
2 changes: 1 addition & 1 deletion docs/resources/idp_adfs.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ resource "genesyscloud_idp_adfs" "adfs" {
- `name` (String) IDP ADFS resource name
- `relying_party_identifier` (String) String used to identify Genesys Cloud to ADFS.
- `slo_binding` (String) Valid values: HTTP Redirect, HTTP Post
- `slo_uri` (String) Provided by ADSF on app creation
- `slo_uri` (String) Provided by ADFS on app creation
- `target_uri` (String) Target URI provided by ADFS.
- `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts))

Expand Down
2 changes: 2 additions & 0 deletions docs/resources/idp_generic.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ resource "genesyscloud_idp_generic" "generic" {
- `logo_image_data` (String) Base64 encoded SVG image.
- `name_identifier_format` (String) SAML name identifier format. (urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified | urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress | urn:oasis:names:tc:SAML:1.1:nameid-format:X509SubjectName | urn:oasis:names:tc:SAML:1.1:nameid-format:WindowsDomainQualifiedName | urn:oasis:names:tc:SAML:2.0:nameid-format:kerberos | urn:oasis:names:tc:SAML:2.0:nameid-format:entity | urn:oasis:names:tc:SAML:2.0:nameid-format:persistent | urn:oasis:names:tc:SAML:2.0:nameid-format:transient) Defaults to `urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified`.
- `relying_party_identifier` (String) String used to identify Genesys Cloud to the identity provider.
- `slo_binding` (String) Valid values: HTTP Redirect, HTTP Post
- `slo_uri` (String) Provided on app creation.
- `target_uri` (String) Target URI provided by the provider.
- `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts))

Expand Down
3 changes: 3 additions & 0 deletions docs/resources/idp_gsuite.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ resource "genesyscloud_idp_gsuite" "gsuite" {
### Optional

- `disabled` (Boolean) True if GSuite is disabled. Defaults to `false`.
- `name` (String) Name of the provider.
- `relying_party_identifier` (String) String used to identify Genesys Cloud to GSuite.
- `slo_binding` (String) Valid values: HTTP Redirect, HTTP Post
- `slo_uri` (String) Provided on app creation.
- `target_uri` (String) Target URI provided by GSuite.
- `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts))

Expand Down
6 changes: 5 additions & 1 deletion docs/resources/idp_onelogin.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,16 @@ resource "genesyscloud_idp_onelogin" "onelogin" {

### Required

- `certificates` (List of String) PEM or DER encoded public X.509 certificates for SAML signature validation.
- `issuer_uri` (String) Issuer URI provided by OneLogin.

### Optional

- `certificates` (List of String) PEM or DER encoded public X.509 certificates for SAML signature validation.
- `disabled` (Boolean) True if OneLogin is disabled. Defaults to `false`.
- `name` (String) IDP OneLogin resource name
- `relying_party_identifier` (String) String used to identify Genesys Cloud to OneLogin.
- `slo_binding` (String) Valid values: HTTP Redirect, HTTP Post
- `slo_uri` (String) Provided by OneLogin on app creation
- `target_uri` (String) Target URI provided by OneLogin.
- `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts))

Expand Down
3 changes: 3 additions & 0 deletions docs/resources/idp_ping.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ resource "genesyscloud_idp_ping" "ping" {
### Optional

- `disabled` (Boolean) True if Ping is disabled. Defaults to `false`.
- `name` (String) Name of the provider
- `relying_party_identifier` (String) String used to identify Genesys Cloud to Ping.
- `slo_binding` (String) Valid values: HTTP Redirect, HTTP Post
- `slo_uri` (String) Provided on app creation.
- `target_uri` (String) Target URI provided by Ping.
- `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts))

Expand Down
Loading

0 comments on commit 309125a

Please sign in to comment.