Skip to content

Commit 3116cf9

Browse files
author
ttomzhou
committed
fix review
1 parent 070466f commit 3116cf9

24 files changed

+82
-257
lines changed

tencentcloud/data_source_tc_api_gateway_customer_domains.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ func dataSourceTencentCloudAPIGatewayCustomerDomains() *schema.Resource {
5757
Computed: true,
5858
Description: "Domain name.",
5959
},
60-
"status": {
60+
"is_status_on": {
6161
Type: schema.TypeBool,
6262
Computed: true,
6363
Description: "Domain name resolution status. Valid values: `true`, `false`. `true` means normal parsing, `false` means parsing failed.",
@@ -154,7 +154,7 @@ func dataSourceTencentCloudAPIGatewayCustomerDomainRead(d *schema.ResourceData,
154154
}
155155
list = append(list, map[string]interface{}{
156156
"domain_name": info.DomainName,
157-
"status": status,
157+
"is_status_on": status,
158158
"certificate_id": info.CertificateId,
159159
"is_default_mapping": info.IsDefaultMapping,
160160
"protocol": info.Protocol,

tencentcloud/data_source_tc_api_gateway_customer_domains_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ func TestAccTencentAPIGatewayCustomerDomain(t *testing.T) {
2020
testAccCheckCustomDomainExists("tencentcloud_api_gateway_custom_domain.foo"),
2121
resource.TestCheckResourceAttrSet(testAPIGatewayDomainSourceName+".id", "list.#"),
2222
resource.TestCheckResourceAttrSet(testAPIGatewayDomainSourceName+".id", "list.0.domain_name"),
23-
resource.TestCheckResourceAttrSet(testAPIGatewayDomainSourceName+".id", "list.0.status"),
23+
resource.TestCheckResourceAttrSet(testAPIGatewayDomainSourceName+".id", "list.0.is_status_on"),
2424
resource.TestCheckResourceAttrSet(testAPIGatewayDomainSourceName+".id", "list.0.is_default_mapping"),
2525
resource.TestCheckResourceAttrSet(testAPIGatewayDomainSourceName+".id", "list.0.net_type"),
2626
resource.TestCheckResourceAttrSet(testAPIGatewayDomainSourceName+".id", "list.0.path_mappings.#"),

tencentcloud/data_source_tc_api_gateway_services.go

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -157,40 +157,6 @@ func dataSourceTencentCloudAPIGatewayServices() *schema.Resource {
157157
},
158158
},
159159
},
160-
"api_list": {
161-
Type: schema.TypeList,
162-
Computed: true,
163-
Description: "A list of APIs.",
164-
Elem: &schema.Resource{
165-
Schema: map[string]*schema.Schema{
166-
"api_id": {
167-
Type: schema.TypeString,
168-
Computed: true,
169-
Description: "ID of the API.",
170-
},
171-
"api_name": {
172-
Type: schema.TypeString,
173-
Computed: true,
174-
Description: "Name of the API.",
175-
},
176-
"api_desc": {
177-
Type: schema.TypeString,
178-
Computed: true,
179-
Description: "Description of the API.",
180-
},
181-
"path": {
182-
Type: schema.TypeString,
183-
Computed: true,
184-
Description: "Path of the API.",
185-
},
186-
"method": {
187-
Type: schema.TypeString,
188-
Computed: true,
189-
Description: "Method of the API.",
190-
},
191-
},
192-
},
193-
},
194160
},
195161
},
196162
},
@@ -231,9 +197,7 @@ func dataSourceTencentCloudAPIGatewayServicesRead(d *schema.ResourceData, meta i
231197
list := make([]map[string]interface{}, 0, len(services))
232198

233199
for _, service := range services {
234-
235200
var info apigateway.DescribeServiceResponse
236-
237201
if err = resource.Retry(readRetryTimeout, func() *resource.RetryError {
238202
info, has, err = apiGatewayService.DescribeService(ctx, *service.ServiceId)
239203
if err != nil {
@@ -247,19 +211,6 @@ func dataSourceTencentCloudAPIGatewayServicesRead(d *schema.ResourceData, meta i
247211
continue
248212
}
249213

250-
var apiList = make([]map[string]interface{}, 0, len(info.Response.ApiIdStatusSet))
251-
252-
for _, item := range info.Response.ApiIdStatusSet {
253-
apiList = append(
254-
apiList, map[string]interface{}{
255-
"api_id": item.ApiId,
256-
"api_name": item.ApiName,
257-
"api_desc": item.ApiDesc,
258-
"path": item.Path,
259-
"method": item.Method,
260-
})
261-
}
262-
263214
var plans []*apigateway.ApiUsagePlan
264215

265216
var planList = make([]map[string]interface{}, 0, len(info.Response.ApiIdStatusSet))
@@ -324,7 +275,6 @@ func dataSourceTencentCloudAPIGatewayServicesRead(d *schema.ResourceData, meta i
324275
"inner_https_port": info.Response.InnerHttpsPort,
325276
"modify_time": info.Response.ModifiedTime,
326277
"create_time": info.Response.CreatedTime,
327-
"api_list": apiList,
328278
"usage_plan_list": planList,
329279
})
330280
}

tencentcloud/data_source_tc_api_gateway_throttling_apis.go

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,7 @@ func dataSourceTencentCloudAPIGatewayThrottlingApisRead(d *schema.ResourceData,
197197
return err
198198
}
199199

200-
for i := range infos {
201-
result := infos[i]
200+
for _, result := range infos {
202201
if result.ServiceId == nil {
203202
continue
204203
}
@@ -208,32 +207,31 @@ func dataSourceTencentCloudAPIGatewayThrottlingApisRead(d *schema.ResourceData,
208207
serviceIds = append(serviceIds, serviceID)
209208
}
210209

211-
for i := range serviceIds {
212-
serviceIdTmp := serviceIds[i]
210+
for _, serviceIdTmp := range serviceIds {
213211
environmentList, err := apiGatewayService.DescribeApiEnvironmentStrategyList(ctx, serviceIdTmp, environmentNames)
214212
if err != nil {
215213
return err
216214
}
217215

218216
environmentResults := make([]map[string]interface{}, 0, len(environmentList))
219-
for i := range environmentList {
220-
environmentSet := environmentList[i].EnvironmentStrategySet
217+
for _, envList := range environmentList {
218+
environmentSet := envList.EnvironmentStrategySet
221219
strategyList := make([]map[string]interface{}, 0, len(environmentSet))
222-
for j := range environmentSet {
223-
if environmentSet[j] == nil {
220+
for _, envSet := range environmentSet {
221+
if envSet == nil {
224222
continue
225223
}
226224
strategyList = append(strategyList, map[string]interface{}{
227-
"environment_name": environmentSet[j].EnvironmentName,
228-
"quota": environmentSet[j].Quota,
225+
"environment_name": envSet.EnvironmentName,
226+
"quota": envSet.Quota,
229227
})
230228
}
231229

232230
item := map[string]interface{}{
233-
"api_id": environmentList[i].ApiId,
234-
"api_name": environmentList[i].ApiName,
235-
"path": environmentList[i].Path,
236-
"method": environmentList[i].Method,
231+
"api_id": envList.ApiId,
232+
"api_name": envList.ApiName,
233+
"path": envList.Path,
234+
"method": envList.Method,
237235
"strategy_list": strategyList,
238236
}
239237
environmentResults = append(environmentResults, item)

tencentcloud/data_source_tc_api_gateway_throttling_services.go

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ import (
3030
"log"
3131

3232
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
33-
3433
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
3534
apigateway "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/apigateway/v20180808"
3635
"github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/internal/helper"
@@ -134,8 +133,7 @@ func dataSourceTencentCloudAPIGatewayThrottlingServicesRead(d *schema.ResourceDa
134133
return err
135134
}
136135

137-
for i := range infos {
138-
result := infos[i]
136+
for _, result := range infos {
139137
if result.ServiceId == nil {
140138
continue
141139
}
@@ -145,16 +143,14 @@ func dataSourceTencentCloudAPIGatewayThrottlingServicesRead(d *schema.ResourceDa
145143
serviceIds = append(serviceIds, serviceID)
146144
}
147145

148-
for i := range serviceIds {
149-
serviceIdTmp := serviceIds[i]
146+
for _, serviceIdTmp := range serviceIds {
150147
environmentList, err := apiGatewayService.DescribeServiceEnvironmentStrategyList(ctx, serviceIdTmp)
151148
if err != nil {
152149
return err
153150
}
154151

155152
environmentResults := make([]map[string]interface{}, 0, len(environmentList))
156-
for i := range environmentList {
157-
value := environmentList[i]
153+
for _, value := range environmentList {
158154
if value == nil {
159155
continue
160156
}

tencentcloud/data_source_tc_api_gateway_usage_plans.go

Lines changed: 1 addition & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -94,60 +94,6 @@ func dataSourceTencentCloudAPIGatewayUsagePlans() *schema.Resource {
9494
Computed: true,
9595
Description: "Creation time in the format of YYYY-MM-DDThh:mm:ssZ according to ISO 8601 standard. UTC time is used.",
9696
},
97-
"attach_list": {
98-
Type: schema.TypeList,
99-
Computed: true,
100-
Description: "Attach service and API list.",
101-
Elem: &schema.Resource{
102-
Schema: map[string]*schema.Schema{
103-
"service_id": {
104-
Type: schema.TypeString,
105-
Computed: true,
106-
Description: "The service ID.",
107-
},
108-
"service_name": {
109-
Type: schema.TypeString,
110-
Computed: true,
111-
Description: "The service name.",
112-
},
113-
"api_id": {
114-
Type: schema.TypeString,
115-
Computed: true,
116-
Description: "The API ID, this value is empty if attach service.",
117-
},
118-
"api_name": {
119-
Type: schema.TypeString,
120-
Computed: true,
121-
Description: "The API name, this value is empty if attach service.",
122-
},
123-
"path": {
124-
Type: schema.TypeString,
125-
Computed: true,
126-
Description: "The API path, this value is empty if attach service.",
127-
},
128-
"method": {
129-
Type: schema.TypeString,
130-
Computed: true,
131-
Description: "The API method, this value is empty if attach service.",
132-
},
133-
"environment": {
134-
Type: schema.TypeString,
135-
Computed: true,
136-
Description: "The environment name.",
137-
},
138-
"modify_time": {
139-
Type: schema.TypeString,
140-
Computed: true,
141-
Description: "Last modified time in the format of YYYY-MM-DDThh:mm:ssZ according to ISO 8601 standard. UTC time is used.",
142-
},
143-
"create_time": {
144-
Type: schema.TypeString,
145-
Computed: true,
146-
Description: "Creation time in the format of YYYY-MM-DDThh:mm:ssZ according to ISO 8601 standard. UTC time is used.",
147-
},
148-
},
149-
},
150-
},
15197
},
15298
},
15399
},
@@ -186,45 +132,14 @@ func dataSourceTencentCloudAPIGatewayUsagePlansRead(d *schema.ResourceData, meta
186132
}
187133

188134
for _, info := range infos {
189-
var (
190-
infoMap = make(map[string]interface{}, 10)
191-
attachList []*apigateway.UsagePlanEnvironment
192-
)
193-
for _, bindType := range API_GATEWAY_TYPES {
194-
var tyepeList []*apigateway.UsagePlanEnvironment
195-
if err = resource.Retry(readRetryTimeout, func() *resource.RetryError {
196-
tyepeList, err = apiGatewayService.DescribeUsagePlanEnvironments(ctx, *info.UsagePlanId, bindType)
197-
if err != nil {
198-
return retryError(err, InternalError)
199-
}
200-
attachList = append(attachList, tyepeList...)
201-
return nil
202-
}); err != nil {
203-
return err
204-
}
205-
}
206-
infoAttachList := make([]map[string]interface{}, 0, len(attachList))
207-
for _, v := range attachList {
208-
infoAttachList = append(infoAttachList, map[string]interface{}{
209-
"service_id": v.ServiceId,
210-
"service_name": v.ServiceName,
211-
"api_id": v.ApiId,
212-
"api_name": v.ApiName,
213-
"path": v.Path,
214-
"method": v.Method,
215-
"environment": v.Environment,
216-
"modify_time": v.ModifiedTime,
217-
"create_time": v.CreatedTime,
218-
})
219-
}
135+
var infoMap = make(map[string]interface{}, 7)
220136
infoMap["usage_plan_id"] = info.UsagePlanId
221137
infoMap["usage_plan_name"] = info.UsagePlanName
222138
infoMap["usage_plan_desc"] = info.UsagePlanDesc
223139
infoMap["max_request_num"] = info.MaxRequestNum
224140
infoMap["max_request_num_pre_sec"] = info.MaxRequestNumPreSec
225141
infoMap["modify_time"] = info.ModifiedTime
226142
infoMap["create_time"] = info.CreatedTime
227-
infoMap["attach_list"] = infoAttachList
228143

229144
list = append(list, infoMap)
230145
}

tencentcloud/extension_api_gateway.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package tencentcloud
33
const (
44
SERVICE_ERR_CODE = "ResourceNotFound.InvalidService"
55
API_ERR_CODE = "ResourceNotFound.InvalidApi"
6+
OSS_EXCEPTION = "InternalError.OssException"
67
)
78

89
const (

tencentcloud/resource_tc_api_gateway_api.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ func resourceTencentCloudAPIGatewayAPI() *schema.Resource {
269269
},
270270
},
271271
// Computed values.
272-
"modify_time": {
272+
"update_time": {
273273
Type: schema.TypeString,
274274
Computed: true,
275275
Description: "Last modified time in the format of YYYY-MM-DDThh:mm:ssZ according to ISO 8601 standard. UTC time is used.",
@@ -436,7 +436,7 @@ func resourceTencentCloudAPIGatewayAPICreate(d *schema.ResourceData, meta interf
436436
ratelimit.Check(request.GetAction())
437437
response, err = apiGatewayService.client.UseAPIGatewayClient().CreateApi(request)
438438
if err != nil {
439-
return retryError(err, InternalError)
439+
return retryError(err)
440440
}
441441
return nil
442442
})
@@ -498,7 +498,7 @@ func resourceTencentCloudAPIGatewayAPIRead(d *schema.ResourceData, meta interfac
498498
_ = d.Set("service_config_scf_function_namespace", info.ServiceScfFunctionNamespace)
499499
_ = d.Set("service_config_scf_function_qualifier", info.ServiceScfFunctionQualifier)
500500
_ = d.Set("service_config_mock_return_message", info.ServiceMockReturnMessage)
501-
_ = d.Set("modify_time", info.ModifiedTime)
501+
_ = d.Set("update_time", info.ModifiedTime)
502502
_ = d.Set("create_time", info.CreatedTime)
503503

504504
if info.RequestConfig != nil {
@@ -689,7 +689,7 @@ func resourceTencentCloudAPIGatewayAPIUpdate(d *schema.ResourceData, meta interf
689689
ratelimit.Check(request.GetAction())
690690
response, err = apiGatewayService.client.UseAPIGatewayClient().ModifyApi(request)
691691
if err != nil {
692-
return retryError(err, InternalError)
692+
return retryError(err)
693693
}
694694
return nil
695695
})
@@ -717,7 +717,7 @@ func resourceTencentCloudAPIGatewayAPIDelete(d *schema.ResourceData, meta interf
717717
return resource.Retry(writeRetryTimeout, func() *resource.RetryError {
718718
err := apiGatewayService.DeleteApi(ctx, serviceId, apiId)
719719
if err != nil {
720-
return retryError(err, InternalError)
720+
return retryError(err)
721721
}
722722
return nil
723723
})

0 commit comments

Comments
 (0)