-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes DEVTOOLING-851 and DEVTOOLING-848 for genesyscloud_telephony_pr…
…oviders_edges_site_outbound_route (#1261) * Adds a data resource for genesyscloud_telephony_providers_edges_site_outbound_route and unit tests * Add required permissions to PR Labeler (see https://github.com/TimonVS/pr-labeler-action?tab=readme-ov-file#usage ) * Refactor the telephony_providers_edges_site_outbound_route resource to require individual instances of the resource per route. Adds a data resource too. Updates the docs * Add handling for including site_id attribute on data resource * Feature toggle check recommendation as per PR comment * Fix caching issue * Fix issue from PR comment: remove item from cache after deleting
- Loading branch information
Showing
14 changed files
with
771 additions
and
441 deletions.
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
docs/data-sources/telephony_providers_edges_site_outbound_route.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,29 @@ | ||
--- | ||
# generated by https://github.com/hashicorp/terraform-plugin-docs | ||
page_title: "genesyscloud_telephony_providers_edges_site_outbound_route Data Source - terraform-provider-genesyscloud" | ||
subcategory: "" | ||
description: |- | ||
Data source for Genesys Cloud Site Outbound Routes. Select a Site Outbound Route by name. | ||
--- | ||
|
||
# genesyscloud_telephony_providers_edges_site_outbound_route (Data Source) | ||
|
||
Data source for Genesys Cloud Site Outbound Routes. Select a Site Outbound Route by name. | ||
|
||
|
||
|
||
<!-- schema generated by tfplugindocs --> | ||
## Schema | ||
|
||
### Required | ||
|
||
- `name` (String) Outbound Route name. | ||
|
||
### Optional | ||
|
||
- `site_id` (String) Site Id | ||
|
||
### Read-Only | ||
|
||
- `id` (String) The ID of this resource. | ||
- `route_id` (String) Route Id |
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
18 changes: 13 additions & 5 deletions
18
...es/resources/genesyscloud_telephony_providers_edges_site_outbound_route/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 |
---|---|---|
@@ -1,5 +1,13 @@ | ||
* [GET /api/v2/telephony/providers/edges/sites](https://developer.genesys.cloud/api/rest/v2/telephonyprovidersedge/#get-api-v2-telephony-providers-edges-sites) | ||
* [GET /api/v2/telephony/providers/edges/sites/{siteId}/outboundroutes](https://developer.genesys.cloud/api/rest/v2/telephonyprovidersedge/#get-api-v2-telephony-providers-edges-sites--siteId--outboundroutes) | ||
* [POST /api/v2/telephony/providers/edges/sites/{siteId}/outboundroutes](https://developer.genesys.cloud/api/rest/v2/telephonyprovidersedge/#post-api-v2-telephony-providers-edges-sites--siteId--outboundroutes) | ||
* [DELETE /api/v2/telephony/providers/edges/sites/{siteId}/outboundroutes/{outboundRouteId}](https://developer.genesys.cloud/api/rest/v2/telephonyprovidersedge/#delete-api-v2-telephony-providers-edges-sites--siteId--outboundroutes--outboundRouteId-) | ||
* [PUT /api/v2/telephony/providers/edges/sites/{siteId}/outboundroutes/{outboundRouteId}](https://developer.genesys.cloud/api/rest/v2/telephonyprovidersedge/#put-api-v2-telephony-providers-edges-sites--siteId--outboundroutes--outboundRouteId-) | ||
- [GET /api/v2/telephony/providers/edges/sites](https://developer.genesys.cloud/api/rest/v2/telephonyprovidersedge/#get-api-v2-telephony-providers-edges-sites) | ||
- [GET /api/v2/telephony/providers/edges/sites/{siteId}/outboundroutes](https://developer.genesys.cloud/api/rest/v2/telephonyprovidersedge/#get-api-v2-telephony-providers-edges-sites--siteId--outboundroutes) | ||
- [POST /api/v2/telephony/providers/edges/sites/{siteId}/outboundroutes](https://developer.genesys.cloud/api/rest/v2/telephonyprovidersedge/#post-api-v2-telephony-providers-edges-sites--siteId--outboundroutes) | ||
- [DELETE /api/v2/telephony/providers/edges/sites/{siteId}/outboundroutes/{outboundRouteId}](https://developer.genesys.cloud/api/rest/v2/telephonyprovidersedge/#delete-api-v2-telephony-providers-edges-sites--siteId--outboundroutes--outboundRouteId-) | ||
- [PUT /api/v2/telephony/providers/edges/sites/{siteId}/outboundroutes/{outboundRouteId}](https://developer.genesys.cloud/api/rest/v2/telephonyprovidersedge/#put-api-v2-telephony-providers-edges-sites--siteId--outboundroutes--outboundRouteId-) | ||
|
||
#### Compatibility Note | ||
|
||
In versions 1.39.0 to 1.48.0 of the provider, this resource was constructed with a different structure. The current version introduces structural changes that are not backwards compatible with those earlier versions. | ||
|
||
These changes are currently controlled by a feature flag and are not yet the default behavior. This allows for a phased implementation and thorough testing of this resource before full release. | ||
|
||
If you're upgrading from an earlier version, please be aware of these structural changes and consult these examples on how to migrate your configuration. |
38 changes: 19 additions & 19 deletions
38
examples/resources/genesyscloud_telephony_providers_edges_site_outbound_route/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 |
---|---|---|
@@ -1,20 +1,20 @@ | ||
// To enable this resource, set ENABLE_STANDALONE_OUTBOUND_ROUTES as an environment variable | ||
resource "genesyscloud_telephony_providers_edges_site_outbound_routes" "site1-routes" { | ||
site_id = genesyscloud_telephony_providers_edges_site.site1.id | ||
outbound_routes { | ||
name = "outboundRoute 1" | ||
description = "outboundRoute description" | ||
classification_types = ["International", "National"] | ||
external_trunk_base_ids = [genesyscloud_telephony_providers_edges_trunkbasesettings.trunk-base-settings1.id] | ||
distribution = "RANDOM" | ||
enabled = false | ||
} | ||
outbound_routes { | ||
name = "outboundRoute 2" | ||
description = "outboundRoute description" | ||
classification_types = ["Network"] | ||
external_trunk_base_ids = [genesyscloud_telephony_providers_edges_trunkbasesettings.trunk-base-settings2.id] | ||
distribution = "SEQUENTIAL" | ||
enabled = true | ||
} | ||
} | ||
resource "genesyscloud_telephony_providers_edges_site_outbound_routes" "site1-route1" { | ||
site_id = genesyscloud_telephony_providers_edges_site.site1.id | ||
name = "outboundRoute 1" | ||
description = "outboundRoute description" | ||
classification_types = ["International", "National"] | ||
external_trunk_base_ids = [genesyscloud_telephony_providers_edges_trunkbasesettings.trunk-base-settings1.id] | ||
distribution = "RANDOM" | ||
enabled = false | ||
} | ||
|
||
resource "genesyscloud_telephony_providers_edges_site_outbound_routes" "site1-route2" { | ||
site_id = genesyscloud_telephony_providers_edges_site.site1.id | ||
name = "outboundRoute 2" | ||
description = "outboundRoute description" | ||
classification_types = ["Network"] | ||
external_trunk_base_ids = [genesyscloud_telephony_providers_edges_trunkbasesettings.trunk-base-settings2.id] | ||
distribution = "SEQUENTIAL" | ||
enabled = true | ||
} |
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
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
44 changes: 44 additions & 0 deletions
44
..._outbound_route/data_source_genesyscloud_telephony_providers_edges_site_outbound_route.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,44 @@ | ||
package telephony_providers_edges_site_outbound_route | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"terraform-provider-genesyscloud/genesyscloud/provider" | ||
"terraform-provider-genesyscloud/genesyscloud/util" | ||
featureToggles "terraform-provider-genesyscloud/genesyscloud/util/feature_toggles" | ||
"time" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag" | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||
) | ||
|
||
func dataSourceSiteOutboundRouteRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { | ||
if exists := featureToggles.OutboundRoutesToggleExists(); !exists { | ||
return util.BuildDiagnosticError(resourceName, fmt.Sprintf("Environment variable %s not set", featureToggles.OutboundRoutesToggleName()), fmt.Errorf("environment variable %s not set", featureToggles.OutboundRoutesToggleName())) | ||
} | ||
sdkConfig := m.(*provider.ProviderMeta).ClientConfig | ||
proxy := getSiteOutboundRouteProxy(sdkConfig) | ||
|
||
name := d.Get("name").(string) | ||
siteId := d.Get("site_id").(string) | ||
|
||
return util.WithRetries(ctx, 15*time.Second, func() *retry.RetryError { | ||
siteId, routeId, retryable, resp, err := proxy.getSiteOutboundRouteByName(ctx, name, siteId) | ||
if err != nil { | ||
if retryable { | ||
return retry.RetryableError(util.BuildWithRetriesApiDiagnosticError(resourceName, fmt.Sprintf("failed to get outbound route %s", name), resp)) | ||
} | ||
|
||
return retry.NonRetryableError(util.BuildWithRetriesApiDiagnosticError(resourceName, fmt.Sprintf("error requesting outbound route %s | error: %s", name, err), resp)) | ||
} | ||
|
||
outboundRouteId := buildSiteAndOutboundRouteId(siteId, routeId) | ||
|
||
d.SetId(outboundRouteId) | ||
d.Set("site_id", siteId) | ||
d.Set("route_id", routeId) | ||
return nil | ||
}) | ||
} |
Oops, something went wrong.