-
Notifications
You must be signed in to change notification settings - Fork 136
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat/apigw #2518
Merged
Merged
feat/apigw #2518
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,3 @@ | ||
```release-note:new-resource | ||
tencentcloud_api_gateway_update_service | ||
``` |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -147,7 +147,8 @@ API GateWay(apigateway) | |
tencentcloud_api_gateway_upstream | ||
tencentcloud_api_gateway_api_app_attachment | ||
tencentcloud_api_gateway_update_api_app_key | ||
tencentcloud_api_gateway_import_open_api | ||
tencentcloud_api_gateway_import_open_api | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 这里是新增了 2 个 operation 资源吗 |
||
tencentcloud_api_gateway_update_service | ||
|
||
Cloud Audit(Audit) | ||
Data Source | ||
|
99 changes: 99 additions & 0 deletions
99
tencentcloud/services/apigateway/resource_tc_api_gateway_update_service.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 apigateway | ||
|
||
import ( | ||
"log" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||
apigateway "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/apigateway/v20180808" | ||
|
||
tccommon "github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/common" | ||
"github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/internal/helper" | ||
) | ||
|
||
func ResourceTencentCloudAPIGatewayUpdateService() *schema.Resource { | ||
return &schema.Resource{ | ||
Create: resourceTencentCloudAPIGatewayUpdateServiceCreate, | ||
Read: resourceTencentCloudAPIGatewayUpdateServiceRead, | ||
Delete: resourceTencentCloudAPIGatewayUpdateServiceDelete, | ||
|
||
Schema: map[string]*schema.Schema{ | ||
"service_id": { | ||
Required: true, | ||
ForceNew: true, | ||
Type: schema.TypeString, | ||
Description: "Service ID.", | ||
}, | ||
"environment_name": { | ||
Required: true, | ||
ForceNew: true, | ||
Type: schema.TypeString, | ||
ValidateFunc: tccommon.ValidateAllowedStringValue([]string{"test", "prepub", "release"}), | ||
Description: "The name of the environment to be switched, currently supporting three environments: test (test environment), prepub (pre release environment), and release (release environment).", | ||
}, | ||
"version_name": { | ||
Required: true, | ||
ForceNew: true, | ||
Type: schema.TypeString, | ||
Description: "The version number of the switch.", | ||
}, | ||
}, | ||
} | ||
} | ||
|
||
func resourceTencentCloudAPIGatewayUpdateServiceCreate(d *schema.ResourceData, meta interface{}) error { | ||
defer tccommon.LogElapsed("resource.tencentcloud_api_gateway_update_service.create")() | ||
defer tccommon.InconsistentCheck(d, meta)() | ||
|
||
var ( | ||
logId = tccommon.GetLogId(tccommon.ContextNil) | ||
request = apigateway.NewUpdateServiceRequest() | ||
serviceId string | ||
) | ||
|
||
if v, ok := d.GetOk("service_id"); ok { | ||
request.ServiceId = helper.String(v.(string)) | ||
serviceId = v.(string) | ||
} | ||
|
||
if v, ok := d.GetOk("environment_name"); ok { | ||
request.EnvironmentName = helper.String(v.(string)) | ||
} | ||
|
||
if v, ok := d.GetOk("version_name"); ok { | ||
request.VersionName = helper.String(v.(string)) | ||
} | ||
|
||
err := resource.Retry(tccommon.WriteRetryTimeout, func() *resource.RetryError { | ||
result, e := meta.(tccommon.ProviderMeta).GetAPIV3Conn().UseAPIGatewayClient().UpdateService(request) | ||
if e != nil { | ||
return tccommon.RetryError(e) | ||
} else { | ||
log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n", logId, request.GetAction(), request.ToJsonString(), result.ToJsonString()) | ||
} | ||
|
||
return nil | ||
}) | ||
|
||
if err != nil { | ||
log.Printf("[CRITAL]%s operate apigateway updateService failed, reason:%+v", logId, err) | ||
return err | ||
} | ||
|
||
d.SetId(serviceId) | ||
return resourceTencentCloudAPIGatewayUpdateServiceRead(d, meta) | ||
} | ||
|
||
func resourceTencentCloudAPIGatewayUpdateServiceRead(d *schema.ResourceData, meta interface{}) error { | ||
defer tccommon.LogElapsed("resource.tencentcloud_api_gateway_update_service.read")() | ||
defer tccommon.InconsistentCheck(d, meta)() | ||
|
||
return nil | ||
} | ||
|
||
func resourceTencentCloudAPIGatewayUpdateServiceDelete(d *schema.ResourceData, meta interface{}) error { | ||
defer tccommon.LogElapsed("resource.tencentcloud_api_gateway_update_service.delete")() | ||
defer tccommon.InconsistentCheck(d, meta)() | ||
|
||
return nil | ||
} |
11 changes: 11 additions & 0 deletions
11
tencentcloud/services/apigateway/resource_tc_api_gateway_update_service.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,11 @@ | ||
Provides a resource to create a apigateway update_service | ||
|
||
Example Usage | ||
|
||
```hcl | ||
resource "tencentcloud_api_gateway_update_service" "example" { | ||
service_id = "service-oczq2nyk" | ||
environment_name = "test" | ||
version_name = "20240204142759-b5a4f741-adc0-4964-b01b-2a4a04ff6964" | ||
} | ||
``` |
56 changes: 56 additions & 0 deletions
56
tencentcloud/services/apigateway/resource_tc_api_gateway_update_service_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,56 @@ | ||
package apigateway_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" | ||
|
||
tcacctest "github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/acctest" | ||
) | ||
|
||
// go test -i; go test -test.run TestAccTencentCloudAPIGatewayUpdateServiceResource_basic -v | ||
func TestAccTencentCloudAPIGatewayUpdateServiceResource_basic(t *testing.T) { | ||
t.Parallel() | ||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { | ||
tcacctest.AccPreCheck(t) | ||
}, | ||
Providers: tcacctest.AccProviders, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccAPIGatewayUpdateService1, | ||
Check: resource.ComposeTestCheckFunc( | ||
resource.TestCheckResourceAttrSet("tencentcloud_api_gateway_update_service.example", "id"), | ||
resource.TestCheckResourceAttr("tencentcloud_api_gateway_update_service.example", "service_id", "service-oczq2nyk"), | ||
resource.TestCheckResourceAttr("tencentcloud_api_gateway_update_service.example", "environment_name", "test"), | ||
resource.TestCheckResourceAttr("tencentcloud_api_gateway_update_service.example", "version_name", "20240204142759-b5a4f741-adc0-4964-b01b-2a4a04ff6964"), | ||
), | ||
}, | ||
{ | ||
Config: testAccAPIGatewayUpdateService2, | ||
Check: resource.ComposeTestCheckFunc( | ||
resource.TestCheckResourceAttrSet("tencentcloud_api_gateway_update_service.example", "id"), | ||
resource.TestCheckResourceAttr("tencentcloud_api_gateway_update_service.example", "service_id", "service-oczq2nyk"), | ||
resource.TestCheckResourceAttr("tencentcloud_api_gateway_update_service.example", "environment_name", "test"), | ||
resource.TestCheckResourceAttr("tencentcloud_api_gateway_update_service.example", "version_name", "20240126164018-c6ec85b5-8aae-4896-bc26-8afbf88dcbcc"), | ||
), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
const testAccAPIGatewayUpdateService1 = ` | ||
resource "tencentcloud_api_gateway_update_service" "example" { | ||
service_id = "service-oczq2nyk" | ||
environment_name = "test" | ||
version_name = "20240204142759-b5a4f741-adc0-4964-b01b-2a4a04ff6964" | ||
} | ||
` | ||
|
||
const testAccAPIGatewayUpdateService2 = ` | ||
resource "tencentcloud_api_gateway_update_service" "example" { | ||
service_id = "service-oczq2nyk" | ||
environment_name = "test" | ||
version_name = "20240126164018-c6ec85b5-8aae-4896-bc26-8afbf88dcbcc" | ||
} | ||
` |
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,39 @@ | ||
--- | ||
subcategory: "API GateWay(apigateway)" | ||
layout: "tencentcloud" | ||
page_title: "TencentCloud: tencentcloud_api_gateway_update_service" | ||
sidebar_current: "docs-tencentcloud-resource-api_gateway_update_service" | ||
description: |- | ||
Provides a resource to create a apigateway update_service | ||
--- | ||
|
||
# tencentcloud_api_gateway_update_service | ||
|
||
Provides a resource to create a apigateway update_service | ||
|
||
## Example Usage | ||
|
||
```hcl | ||
resource "tencentcloud_api_gateway_update_service" "example" { | ||
service_id = "service-oczq2nyk" | ||
environment_name = "test" | ||
version_name = "20240204142759-b5a4f741-adc0-4964-b01b-2a4a04ff6964" | ||
} | ||
``` | ||
|
||
## Argument Reference | ||
|
||
The following arguments are supported: | ||
|
||
* `environment_name` - (Required, String, ForceNew) The name of the environment to be switched, currently supporting three environments: test (test environment), prepub (pre release environment), and release (release environment). | ||
* `service_id` - (Required, String, ForceNew) Service ID. | ||
* `version_name` - (Required, String, ForceNew) The version number of the switch. | ||
|
||
## Attributes Reference | ||
|
||
In addition to all arguments above, the following attributes are exported: | ||
|
||
* `id` - ID of the 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里的 changelog 补全?