-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[APIGW] New features resources (#2755)
[APIGW] New features resources Summary of the Pull Request PR Checklist Refers to: #2730 Tests added/passed. Documentation updated. Schema updated. Release notes added. Acceptance Steps Performed === RUN TestAccInstanceRoutes_basic === PAUSE TestAccInstanceRoutes_basic === CONT TestAccInstanceRoutes_basic --- PASS: TestAccInstanceRoutes_basic (51.28s) PASS Process finished with the exit code 0 === RUN TestAccDataSourceInstanceFeatures_basic === PAUSE TestAccDataSourceInstanceFeatures_basic === CONT TestAccDataSourceInstanceFeatures_basic --- PASS: TestAccDataSourceInstanceFeatures_basic (25.46s) PASS Process finished with the exit code 0 === RUN TestAccInstanceFeature_basic === PAUSE TestAccInstanceFeature_basic === CONT TestAccInstanceFeature_basic --- PASS: TestAccInstanceFeature_basic (49.79s) PASS Process finished with the exit code 0 Reviewed-by: Muneeb H. Jan <muneebhafeezjan@gmail.com>
- Loading branch information
1 parent
e8a6652
commit c0ea1f3
Showing
15 changed files
with
1,088 additions
and
1 deletion.
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,57 @@ | ||
--- | ||
subcategory: "APIGW" | ||
layout: "opentelekomcloud" | ||
page_title: "OpenTelekomCloud: opentelekomcloud_apigw_gateway_features_v2" | ||
sidebar_current: "docs-opentelekomcloud-datasource-apigw-gateway-features-v2" | ||
description: |- | ||
Get the all APIGW gateway features from OpenTelekomCloud | ||
--- | ||
|
||
Up-to-date reference of API arguments for API Gateway environment variable service you can get at | ||
[documentation portal](https://docs.otc.t-systems.com/api-gateway/api-ref/dedicated_gateway_apis_v2/gateway_feature_management/querying_gateway_features.html) | ||
|
||
# opentelekomcloud_apigw_gateway_features_v2 | ||
|
||
Use this data source to get the list of the features under the APIGW gateway within OpenTelekomCloud. | ||
|
||
## Example Usage | ||
|
||
```hcl | ||
variable gateway_id {} | ||
data "opentelekomcloud_apigw_gateway_features_v2" "ft" { | ||
gateway_id = var.gateway_id | ||
} | ||
``` | ||
|
||
## Argument Reference | ||
|
||
The following arguments are supported: | ||
|
||
* `gateway_id` - (Required, String) Specified the ID of the dedicated gateway to which the features belong. | ||
|
||
* `name` - (Optional, String) Specified the name of the feature. | ||
|
||
## Attribute Reference | ||
|
||
In addition to all arguments above, the following attributes are exported: | ||
|
||
* `id` - The data source ID. | ||
|
||
* `region` - The region in which to query the data source. | ||
|
||
* `features` - All instance features that match the filter parameters. | ||
The [features](#instance_features) structure is documented below. | ||
|
||
<a name="instance_features"></a> | ||
The `features` block supports: | ||
|
||
* `id` - The ID of the feature. | ||
|
||
* `name` - The name of the feature. | ||
|
||
* `enabled` - Whether the feature is enabled. | ||
|
||
* `config` - The detailed configuration of the instance feature. | ||
|
||
* `updated_at` - The latest update time of the feature, in RFC3339 format. |
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,70 @@ | ||
--- | ||
subcategory: "APIGW" | ||
layout: "opentelekomcloud" | ||
page_title: "OpenTelekomCloud: opentelekomcloud_apigw_gateway_feature_v2" | ||
sidebar_current: "docs-opentelekomcloud-resource-apigw-gateway-feature-v2" | ||
description: |- | ||
Manages a APIGW gateway feature resource within OpenTelekomCloud. | ||
--- | ||
|
||
Up-to-date reference of API arguments for API Gateway environment variable service you can get at | ||
[documentation portal](https://docs.otc.t-systems.com/api-gateway/api-ref/dedicated_gateway_apis_v2/gateway_feature_management/configuring_a_feature_for_a_gateway.html) | ||
|
||
# opentelekomcloud_apigw_gateway_feature_v2 | ||
|
||
Manages an APIGW gateway feature resource within OpenTelekomCloud. | ||
|
||
-> For various types of feature parameter configurations, please refer to the | ||
[documentation](https://docs.otc.t-systems.com/api-gateway/api-ref/appendix/supported_features.html#apig-api-20200402). | ||
|
||
## Example Usage | ||
|
||
```hcl | ||
variable "gateway_id" {} | ||
resource "opentelekomcloud_apigw_gateway_feature_v2" "feat" { | ||
gateway_id = var.gateway_id | ||
name = "ratelimit" | ||
enabled = true | ||
config = jsonencode({ | ||
api_limits = 300 | ||
}) | ||
} | ||
``` | ||
|
||
## Argument Reference | ||
|
||
The following arguments are supported: | ||
|
||
* `gateway_id` - (Required, String, ForceNew) Specified the ID of the dedicated gateway to which the feature belongs. | ||
Changing this creates a new resource. | ||
|
||
* `name` - (Required, String, ForceNew) Specified the name of the feature. | ||
Changing this creates a new resource. | ||
|
||
* `enabled` - (Optional, Bool) Specified whether to enable the feature. Default value is `false`. | ||
|
||
* `config` - (Optional, String) Specified the detailed configuration of the feature. | ||
|
||
## Attribute Reference | ||
|
||
In addition to all arguments above, the following attributes are exported: | ||
|
||
* `id` - The resource ID. The value is the feature name. | ||
|
||
* `region` - The region in which to create the resource. | ||
|
||
## Timeouts | ||
|
||
This resource provides the following timeouts configuration options: | ||
|
||
* `create` - Default is 5 minutes. | ||
|
||
## Import | ||
|
||
The resource can be imported using `gateway_id` and `name`, separated by a slash (/), e.g. | ||
|
||
```bash | ||
$ terraform import opentelekomcloud_apigw_gateway_feature_v2.feat <gateway_id>/<name> | ||
``` |
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,53 @@ | ||
--- | ||
subcategory: "APIGW" | ||
layout: "opentelekomcloud" | ||
page_title: "OpenTelekomCloud: opentelekomcloud_apigw_gateway_routes_v2" | ||
sidebar_current: "docs-opentelekomcloud-resource-apigw-gateway-routes-v2" | ||
description: |- | ||
Manages a APIGW gateway routes resource within OpenTelekomCloud. | ||
--- | ||
|
||
Up-to-date reference of API arguments for API Gateway environment variable service you can get at | ||
[documentation portal](https://docs.otc.t-systems.com/api-gateway/api-ref/dedicated_gateway_apis_v2/gateway_feature_management/configuring_a_feature_for_a_gateway.html) | ||
|
||
# opentelekomcloud_apigw_gateway_routes_v2 | ||
|
||
Manages a APIGW gateway routes resource within OpenTelekomCloud. | ||
|
||
## Example Usage | ||
|
||
```hcl | ||
variable "gateway_id" {} | ||
resource "opentelekomcloud_apigw_gateway_routes_v2" "rt" { | ||
gateway_id = var.gateway_id | ||
nexthops = ["172.16.3.0/24", "172.16.7.0/24"] | ||
} | ||
``` | ||
|
||
## Argument Reference | ||
|
||
The following arguments are supported: | ||
|
||
* `gateway_id` - (Required, String, ForceNew) Specifies the ID of the dedicated gateway to which the routes belong. | ||
Changing this will create a new resource. | ||
|
||
* `nexthops` - (Required, List) Specifies the configuration of the next-hop routes. | ||
|
||
-> The network segment of the next hop cannot overlap with the network segment of the APIGW gateway. | ||
|
||
## Attribute Reference | ||
|
||
In addition to all arguments above, the following attributes are exported: | ||
|
||
* `id` - The resource ID (gateway ID). | ||
|
||
* `region` - The region where the dedicated gateway and routes are located. | ||
|
||
## Import | ||
|
||
Routes can be imported using their related dedicated instance ID (`gateway_id`), e.g. | ||
|
||
```bash | ||
$ terraform import opentelekomcloud_apigw_gateway_routes_v2.rt 628001b3c5eg6d3e91a8da530f46427y | ||
``` |
99 changes: 99 additions & 0 deletions
99
...ekomcloud/acceptance/apigw/data_source_opentelekomcloud_apigw_gateway_features_v2_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,99 @@ | ||
package acceptance | ||
|
||
import ( | ||
"fmt" | ||
"regexp" | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" | ||
"github.com/opentelekomcloud/terraform-provider-opentelekomcloud/opentelekomcloud/acceptance/common" | ||
"github.com/opentelekomcloud/terraform-provider-opentelekomcloud/opentelekomcloud/acceptance/env" | ||
) | ||
|
||
func TestAccDataSourceInstanceFeatures_basic(t *testing.T) { | ||
var ( | ||
rName = "data.opentelekomcloud_apigw_gateway_features_v2.test" | ||
dc = common.InitDataSourceCheck(rName) | ||
|
||
byName = "data.opentelekomcloud_apigw_gateway_features_v2.filter_by_name" | ||
dcByName = common.InitDataSourceCheck(byName) | ||
|
||
byNotFoundName = "data.opentelekomcloud_apigw_gateway_features_v2.filter_by_not_found_name" | ||
dcByNotFoundName = common.InitDataSourceCheck(byNotFoundName) | ||
) | ||
|
||
resource.ParallelTest(t, resource.TestCase{ | ||
PreCheck: func() { | ||
common.TestAccPreCheck(t) | ||
common.TestAccPreCheckApigw(t) | ||
}, | ||
ProviderFactories: common.TestAccProviderFactories, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccDataSourceInstanceFeatures_basic(), | ||
Check: resource.ComposeTestCheckFunc( | ||
dc.CheckResourceExists(), | ||
resource.TestMatchResourceAttr(rName, "features.#", regexp.MustCompile(`^[1-9]([0-9]*)?$`)), | ||
dcByName.CheckResourceExists(), | ||
resource.TestMatchResourceAttr(byName, "features.0.updated_at", | ||
regexp.MustCompile(`^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}?(Z|([+-]\d{2}:\d{2}))$`)), | ||
resource.TestCheckOutput("is_name_filter_useful", "true"), | ||
dcByNotFoundName.CheckResourceExists(), | ||
resource.TestCheckOutput("is_name_not_found_filter_useful", "true"), | ||
), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func testAccDataSourceInstanceFeatures_basic() string { | ||
return fmt.Sprintf(` | ||
locals { | ||
gateway_id = "%[1]s" | ||
} | ||
data "opentelekomcloud_apigw_gateway_features_v2" "test" { | ||
gateway_id = local.gateway_id | ||
} | ||
# Filter by name | ||
locals { | ||
feature_name = data.opentelekomcloud_apigw_gateway_features_v2.test.features[0].name | ||
} | ||
data "opentelekomcloud_apigw_gateway_features_v2" "filter_by_name" { | ||
gateway_id = local.gateway_id | ||
name = local.feature_name | ||
} | ||
locals { | ||
name_filter_result = [ | ||
for v in data.opentelekomcloud_apigw_gateway_features_v2.filter_by_name.features[*].name : v == local.feature_name | ||
] | ||
} | ||
output "is_name_filter_useful" { | ||
value = length(local.name_filter_result) > 0 && alltrue(local.name_filter_result) | ||
} | ||
# Filter by name (not found) | ||
locals { | ||
not_found_name = "not_found" | ||
} | ||
data "opentelekomcloud_apigw_gateway_features_v2" "filter_by_not_found_name" { | ||
gateway_id = local.gateway_id | ||
name = local.not_found_name | ||
} | ||
locals { | ||
not_found_name_filter_result = [ | ||
for v in data.opentelekomcloud_apigw_gateway_features_v2.filter_by_not_found_name.features[*].name : strcontains(v, local.not_found_name) | ||
] | ||
} | ||
output "is_name_not_found_filter_useful" { | ||
value = length(local.not_found_name_filter_result) == 0 | ||
} | ||
`, env.OS_APIGW_GATEWAY_ID) | ||
} |
Oops, something went wrong.