-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat/devtooling 655: conversations_messaging_settings resource (#1150)
* Created Resource * Created Resource & added tests * Added examples * Update tf_exporter_resource_test.go
- Loading branch information
1 parent
651e9b8
commit 537b9d8
Showing
16 changed files
with
1,160 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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_conversations_messaging_settings Data Source - terraform-provider-genesyscloud" | ||
subcategory: "" | ||
description: |- | ||
Genesys Cloud conversations messaging settings data source. Select an conversations messaging settings by name | ||
--- | ||
|
||
# genesyscloud_conversations_messaging_settings (Data Source) | ||
|
||
Genesys Cloud conversations messaging settings data source. Select an conversations messaging settings by name | ||
|
||
## Example Usage | ||
|
||
```terraform | ||
data "genesyscloud_conversations_messaging_settings" "example-messaging-settings" { | ||
name = "settings name" | ||
} | ||
``` | ||
|
||
<!-- schema generated by tfplugindocs --> | ||
## Schema | ||
|
||
### Required | ||
|
||
- `name` (String) conversations messaging settings name | ||
|
||
### Read-Only | ||
|
||
- `id` (String) The ID of this resource. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
--- | ||
page_title: "genesyscloud_conversations_messaging_settings Resource - terraform-provider-genesyscloud" | ||
subcategory: "" | ||
description: |- | ||
Genesys Cloud conversations messaging settings | ||
--- | ||
# genesyscloud_conversations_messaging_settings (Resource) | ||
|
||
Genesys Cloud conversations messaging settings | ||
|
||
## API Usage | ||
The following Genesys Cloud APIs are used by this resource. Ensure your OAuth Client has been granted the necessary scopes and permissions to perform these operations: | ||
|
||
* [GET /api/v2/conversations/messaging/settings](https://developer.genesys.cloud/devapps/api-explorer#get-api-v2-conversations-messaging-settings) | ||
* [POST /api/v2/conversations/messaging/settings](https://developer.genesys.cloud/devapps/api-explorer#post-api-v2-conversations-messaging-settings) | ||
* [GET /api/v2/conversations/messaging/settings/{messageSettingId}](https://developer.genesys.cloud/devapps/api-explorer#get-api-v2-conversations-messaging-settings--messageSettingId-) | ||
* [PATCH /api/v2/conversations/messaging/settings/{messageSettingId}](https://developer.genesys.cloud/devapps/api-explorer#patch-api-v2-conversations-messaging-settings--messageSettingId-) | ||
* [DELETE /api/v2/conversations/messaging/settings/{messageSettingId}](https://developer.genesys.cloud/devapps/api-explorer#delete-api-v2-conversations-messaging-settings--messageSettingId-) | ||
|
||
## Example Usage | ||
|
||
```terraform | ||
resource "genesyscloud_conversations_messaging_settings" "example-messaging-settings" { | ||
name = "Sample Messaging Settings" | ||
content { | ||
story { | ||
mention { | ||
inbound = "Enabled" | ||
} | ||
reply { | ||
inbound = "Enabled" | ||
} | ||
} | ||
} | ||
event { | ||
typing { | ||
on { | ||
inbound = "Enabled" | ||
outbound = "Enabled" | ||
} | ||
} | ||
} | ||
} | ||
``` | ||
|
||
<!-- schema generated by tfplugindocs --> | ||
## Schema | ||
|
||
### Required | ||
|
||
- `name` (String) The messaging Setting profile name | ||
|
||
### Optional | ||
|
||
- `content` (Block List, Max: 1) Settings relating to message contents (see [below for nested schema](#nestedblock--content)) | ||
- `event` (Block List, Max: 1) Settings relating to events which may occur (see [below for nested schema](#nestedblock--event)) | ||
|
||
### Read-Only | ||
|
||
- `id` (String) The ID of this resource. | ||
|
||
<a id="nestedblock--content"></a> | ||
### Nested Schema for `content` | ||
|
||
Optional: | ||
|
||
- `story` (Block List, Max: 1) Settings relating to facebook and instagram stories feature (see [below for nested schema](#nestedblock--content--story)) | ||
|
||
<a id="nestedblock--content--story"></a> | ||
### Nested Schema for `content.story` | ||
|
||
Optional: | ||
|
||
- `mention` (Block List, Max: 1) Setting relating to Story Mentions (see [below for nested schema](#nestedblock--content--story--mention)) | ||
- `reply` (Block List, Max: 1) Setting relating to Story Replies (see [below for nested schema](#nestedblock--content--story--reply)) | ||
|
||
<a id="nestedblock--content--story--mention"></a> | ||
### Nested Schema for `content.story.mention` | ||
|
||
Optional: | ||
|
||
- `inbound` (String) Valid values: Enabled, Disabled. | ||
|
||
|
||
<a id="nestedblock--content--story--reply"></a> | ||
### Nested Schema for `content.story.reply` | ||
|
||
Optional: | ||
|
||
- `inbound` (String) Valid values: Enabled, Disabled. | ||
|
||
|
||
|
||
|
||
<a id="nestedblock--event"></a> | ||
### Nested Schema for `event` | ||
|
||
Optional: | ||
|
||
- `typing` (Block List, Max: 1) Settings regarding typing events (see [below for nested schema](#nestedblock--event--typing)) | ||
|
||
<a id="nestedblock--event--typing"></a> | ||
### Nested Schema for `event.typing` | ||
|
||
Optional: | ||
|
||
- `on` (Block List, Max: 1) Should typing indication Events be sent (see [below for nested schema](#nestedblock--event--typing--on)) | ||
|
||
<a id="nestedblock--event--typing--on"></a> | ||
### Nested Schema for `event.typing.on` | ||
|
||
Optional: | ||
|
||
- `inbound` (String) Status for the Inbound Direction. Valid values: Enabled, Disabled. | ||
- `outbound` (String) Status for the outbound Direction. Valid values: Enabled, Disabled. | ||
|
3 changes: 3 additions & 0 deletions
3
examples/data-sources/genesyscloud_conversations_messaging_settings/data-source.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
data "genesyscloud_conversations_messaging_settings" "example-messaging-settings" { | ||
name = "settings name" | ||
} |
5 changes: 5 additions & 0 deletions
5
examples/resources/genesyscloud_conversations_messaging_settings/apis.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
* [GET /api/v2/conversations/messaging/settings](https://developer.genesys.cloud/devapps/api-explorer#get-api-v2-conversations-messaging-settings) | ||
* [POST /api/v2/conversations/messaging/settings](https://developer.genesys.cloud/devapps/api-explorer#post-api-v2-conversations-messaging-settings) | ||
* [GET /api/v2/conversations/messaging/settings/{messageSettingId}](https://developer.genesys.cloud/devapps/api-explorer#get-api-v2-conversations-messaging-settings--messageSettingId-) | ||
* [PATCH /api/v2/conversations/messaging/settings/{messageSettingId}](https://developer.genesys.cloud/devapps/api-explorer#patch-api-v2-conversations-messaging-settings--messageSettingId-) | ||
* [DELETE /api/v2/conversations/messaging/settings/{messageSettingId}](https://developer.genesys.cloud/devapps/api-explorer#delete-api-v2-conversations-messaging-settings--messageSettingId-) |
21 changes: 21 additions & 0 deletions
21
examples/resources/genesyscloud_conversations_messaging_settings/resource.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
resource "genesyscloud_conversations_messaging_settings" "example-messaging-settings" { | ||
name = "Sample Messaging Settings" | ||
content { | ||
story { | ||
mention { | ||
inbound = "Enabled" | ||
} | ||
reply { | ||
inbound = "Enabled" | ||
} | ||
} | ||
} | ||
event { | ||
typing { | ||
on { | ||
inbound = "Enabled" | ||
outbound = "Enabled" | ||
} | ||
} | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
...syscloud/conversations_messaging_settings/data_source_conversations_messaging_settings.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package conversations_messaging_settings | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"terraform-provider-genesyscloud/genesyscloud/provider" | ||
"terraform-provider-genesyscloud/genesyscloud/util" | ||
"time" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag" | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry" | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||
) | ||
|
||
func dataSourceConversationsMessagingSettingsRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { | ||
sdkConfig := m.(*provider.ProviderMeta).ClientConfig | ||
proxy := getConversationsMessagingSettingsProxy(sdkConfig) | ||
name := d.Get("name").(string) | ||
|
||
return util.WithRetries(ctx, 15*time.Second, func() *retry.RetryError { | ||
messageSettingsId, resp, retryable, err := proxy.getConversationsMessagingSettingsIdByName(ctx, name) | ||
if err != nil && !retryable { | ||
return retry.NonRetryableError(util.BuildWithRetriesApiDiagnosticError(resourceName, fmt.Sprintf("error requesting conversations messaging setting by name %s | error: %s", name, err), resp)) | ||
} | ||
|
||
if retryable { | ||
return retry.RetryableError(util.BuildWithRetriesApiDiagnosticError(resourceName, fmt.Sprintf("no conversations messaging setting found with name %s", name), resp)) | ||
} | ||
d.SetId(messageSettingsId) | ||
return nil | ||
}) | ||
} |
55 changes: 55 additions & 0 deletions
55
...oud/conversations_messaging_settings/data_source_conversations_messaging_settings_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package conversations_messaging_settings | ||
|
||
import ( | ||
"fmt" | ||
"terraform-provider-genesyscloud/genesyscloud/provider" | ||
"terraform-provider-genesyscloud/genesyscloud/util" | ||
"testing" | ||
|
||
"github.com/google/uuid" | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" | ||
) | ||
|
||
func TestAccDataSourceConversationsMessagingSettings(t *testing.T) { | ||
var ( | ||
id = "conversations_messaging_settings" | ||
dataId = "conversations_messaging_settings_data" | ||
name = "Messaging Settings " + uuid.NewString() | ||
) | ||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { util.TestAccPreCheck(t) }, | ||
ProviderFactories: provider.GetProviderFactories(providerResources, providerDataSources), | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: generateConversationsMessagingSettingsResource( | ||
id, | ||
name, | ||
generateContentStoryBlock( | ||
generateMentionInboundOnlySetting("Enabled"), | ||
generateReplyInboundOnlySetting("Enabled"), | ||
), | ||
generateTypingOnSetting( | ||
"Enabled", | ||
"Disabled", | ||
), | ||
) + generateConversationsMessagingSettingsDataSource( | ||
dataId, | ||
name, | ||
"genesyscloud_conversations_messaging_settings."+id, | ||
), | ||
Check: resource.ComposeTestCheckFunc( | ||
resource.TestCheckResourceAttrPair("data.genesyscloud_conversations_messaging_settings."+dataId, "id", | ||
"genesyscloud_conversations_messaging_settings."+id, "id"), | ||
), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func generateConversationsMessagingSettingsDataSource(id, name, dependsOn string) string { | ||
return fmt.Sprintf(`data "genesyscloud_conversations_messaging_settings" "%s" { | ||
name = "%s" | ||
depends_on = [%s] | ||
} | ||
`, id, name, dependsOn) | ||
} |
54 changes: 54 additions & 0 deletions
54
...nversations_messaging_settings/genesyscloud_conversations_messaging_settings_init_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package conversations_messaging_settings | ||
|
||
import ( | ||
"sync" | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||
) | ||
|
||
var providerDataSources map[string]*schema.Resource | ||
|
||
// providerResources holds a map of all registered resources | ||
var providerResources map[string]*schema.Resource | ||
|
||
type registerTestInstance struct { | ||
resourceMapMutex sync.RWMutex | ||
datasourceMapMutex sync.RWMutex | ||
} | ||
|
||
// registerTestResources registers all resources used in the tests | ||
func (r *registerTestInstance) registerTestResources() { | ||
r.resourceMapMutex.Lock() | ||
defer r.resourceMapMutex.Unlock() | ||
|
||
providerResources[resourceName] = ResourceConversationsMessagingSettings() | ||
} | ||
|
||
// registerTestDataSources registers all data sources used in the tests. | ||
func (r *registerTestInstance) registerTestDataSources() { | ||
r.datasourceMapMutex.Lock() | ||
defer r.datasourceMapMutex.Unlock() | ||
|
||
providerDataSources[resourceName] = DataSourceConversationsMessagingSettings() | ||
} | ||
|
||
// initTestResources initializes all test resources and data sources. | ||
func initTestResources() { | ||
providerDataSources = make(map[string]*schema.Resource) | ||
providerResources = make(map[string]*schema.Resource) | ||
|
||
regInstance := ®isterTestInstance{} | ||
|
||
regInstance.registerTestResources() | ||
regInstance.registerTestDataSources() | ||
} | ||
|
||
// TestMain is a "setup" function called by the testing framework when run the test | ||
func TestMain(m *testing.M) { | ||
// Run setup function before starting the test suite for the conversations_messaging_settings package | ||
initTestResources() | ||
|
||
// Run the test suite for the conversations_messaging_settings package | ||
m.Run() | ||
} |
Oops, something went wrong.