-
Notifications
You must be signed in to change notification settings - Fork 133
/
resource_tc_api_gateway_update_api_app_key.go
99 lines (80 loc) · 3.03 KB
/
resource_tc_api_gateway_update_api_app_key.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
package apigateway
import (
"log"
tccommon "github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/common"
"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"
"github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/internal/helper"
)
func ResourceTencentCloudApiGatewayUpdateApiAppKey() *schema.Resource {
return &schema.Resource{
Create: resourceTencentCloudApiGatewayUpdateApiAppKeyCreate,
Read: resourceTencentCloudApiGatewayUpdateApiAppKeyRead,
Delete: resourceTencentCloudApiGatewayUpdateApiAppKeyDelete,
Schema: map[string]*schema.Schema{
"api_app_id": {
Required: true,
ForceNew: true,
Type: schema.TypeString,
Description: "Application unique ID.",
},
"api_app_key": {
Required: true,
ForceNew: true,
Type: schema.TypeString,
Description: "Key of the application.",
},
//"api_app_secret": {
// Optional: true,
// ForceNew: true,
// Type: schema.TypeString,
// Description: "Application Secret.",
//},
},
}
}
func resourceTencentCloudApiGatewayUpdateApiAppKeyCreate(d *schema.ResourceData, meta interface{}) error {
defer tccommon.LogElapsed("resource.tencentcloud_api_gateway_update_api_app_key.create")()
defer tccommon.InconsistentCheck(d, meta)()
var (
logId = tccommon.GetLogId(tccommon.ContextNil)
request = apiGateway.NewUpdateApiAppKeyRequest()
apiAppId string
)
if v, ok := d.GetOk("api_app_id"); ok {
request.ApiAppId = helper.String(v.(string))
apiAppId = v.(string)
}
if v, ok := d.GetOk("api_app_key"); ok {
request.ApiAppKey = helper.String(v.(string))
}
//if v, ok := d.GetOk("api_app_secret"); ok {
// request.ApiAppSecret = helper.String(v.(string))
//}
err := resource.Retry(tccommon.WriteRetryTimeout, func() *resource.RetryError {
result, e := meta.(tccommon.ProviderMeta).GetAPIV3Conn().UseAPIGatewayClient().UpdateApiAppKey(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 updateApiAppKey failed, reason:%+v", logId, err)
return err
}
d.SetId(apiAppId)
return resourceTencentCloudApiGatewayUpdateApiAppKeyRead(d, meta)
}
func resourceTencentCloudApiGatewayUpdateApiAppKeyRead(d *schema.ResourceData, meta interface{}) error {
defer tccommon.LogElapsed("resource.tencentcloud_api_gateway_update_api_app_key.read")()
defer tccommon.InconsistentCheck(d, meta)()
return nil
}
func resourceTencentCloudApiGatewayUpdateApiAppKeyDelete(d *schema.ResourceData, meta interface{}) error {
defer tccommon.LogElapsed("resource.tencentcloud_api_gateway_update_api_app_key.delete")()
defer tccommon.InconsistentCheck(d, meta)()
return nil
}