Skip to content

Commit bd127d7

Browse files
committed
feat: support teo rule priority
1 parent 3199cf0 commit bd127d7

6 files changed

+287
-1
lines changed

tencentcloud/provider.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import (
1212
"strings"
1313

1414
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
15-
"github.com/mitchellh/go-homedir"
1615
sdkcommon "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common"
1716
commonJson "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/json"
1817
sdksts "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/sts/v20180813"
@@ -1704,6 +1703,7 @@ func Provider() *schema.Provider {
17041703
"tencentcloud_teo_realtime_log_delivery": teo.ResourceTencentCloudTeoRealtimeLogDelivery(),
17051704
"tencentcloud_teo_function": teo.ResourceTencentCloudTeoFunction(),
17061705
"tencentcloud_teo_function_rule": teo.ResourceTencentCloudTeoFunctionRule(),
1706+
"tencentcloud_teo_function_rule_priority": teo.ResourceTencentCloudTeoFunctionRulePriority(),
17071707
"tencentcloud_tcm_mesh": tcm.ResourceTencentCloudTcmMesh(),
17081708
"tencentcloud_tcm_cluster_attachment": tcm.ResourceTencentCloudTcmClusterAttachment(),
17091709
"tencentcloud_tcm_prometheus_attachment": tcm.ResourceTencentCloudTcmPrometheusAttachment(),

tencentcloud/services/teo/resource_tc_teo_function_rule_priority.go

Lines changed: 184 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
Provides a resource to create a teo teo_function_rule_priority
2+
3+
Example Usage
4+
5+
```hcl
6+
resource "tencentcloud_teo_function_rule_priority" "teo_function_rule_priority" {
7+
}
8+
```
9+
10+
Import
11+
12+
teo teo_function_rule_priority can be imported using the id, e.g.
13+
14+
```
15+
terraform import tencentcloud_teo_function_rule_priority.teo_function_rule_priority teo_function_rule_priority_id
16+
```
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package teo
2+
3+
import (
4+
"context"
5+
6+
teov20220901 "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/teo/v20220901"
7+
tccommon "github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/common"
8+
)
9+
10+
func resourceTencentCloudTeoFunctionRulePriorityReadPreHandleResponse0(ctx context.Context, resp *teov20220901.DescribeFunctionRulesResponseParams) error {
11+
d := tccommon.ResourceDataFromContext(ctx)
12+
13+
rulesList := []string{}
14+
if resp.FunctionRules != nil {
15+
for _, functionRules := range respData.FunctionRules {
16+
if functionRules.RuleId != nil {
17+
rulesList = append(rulesList, functionRules.RuleId)
18+
}
19+
}
20+
21+
_ = d.Set("rule_ids", rulesList)
22+
}
23+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package teo
2+
3+
import (
4+
"testing"
5+
6+
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
7+
8+
tcacctest "github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/acctest"
9+
)
10+
11+
func TestAccTencentCloudTeoFunctionRulePriorityResource_basic(t *testing.T) {
12+
t.Parallel()
13+
resource.Test(t, resource.TestCase{
14+
PreCheck: func() {
15+
tcacctest.AccPreCheck(t)
16+
},
17+
Providers: tcacctest.AccProviders,
18+
Steps: []resource.TestStep{{
19+
Config: testAccTeoFunctionRulePriority,
20+
Check: resource.ComposeTestCheckFunc(resource.TestCheckResourceAttrSet("tencentcloud_teo_function_rule_priority.teo_function_rule_priority", "id")),
21+
}, {
22+
ResourceName: "tencentcloud_teo_function_rule_priority.teo_function_rule_priority",
23+
ImportState: true,
24+
ImportStateVerify: true,
25+
}},
26+
})
27+
}
28+
29+
const testAccTeoFunctionRulePriority = `
30+
31+
resource "tencentcloud_teo_function_rule_priority" "teo_function_rule_priority" {
32+
}
33+
`

tencentcloud/services/teo/service_tencentcloud_teo.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1208,3 +1208,33 @@ func (me *TeoService) DescribeTeoFunctionRuleById(ctx context.Context, zoneId st
12081208
ret = response.Response.FunctionRules[0]
12091209
return
12101210
}
1211+
1212+
func (me *TeoService) DescribeTeoFunctionRulePriorityById(ctx context.Context, zoneId string, functionId string) (ret *teo.DescribeFunctionRulesResponseParams, errRet error) {
1213+
logId := tccommon.GetLogId(ctx)
1214+
1215+
request := teo.NewDescribeFunctionRulesRequest()
1216+
request.ZoneId = helper.String(zoneId)
1217+
filter := &teo.Filter{
1218+
Name: helper.String("function-id"),
1219+
Values: []*string{helper.String(functionId)},
1220+
}
1221+
request.Filters = append(request.Filters, filter)
1222+
1223+
defer func() {
1224+
if errRet != nil {
1225+
log.Printf("[CRITAL]%s api[%s] fail, request body [%s], reason[%s]\n", logId, request.GetAction(), request.ToJsonString(), errRet.Error())
1226+
}
1227+
}()
1228+
1229+
ratelimit.Check(request.GetAction())
1230+
1231+
response, err := me.client.UseTeoV20220901Client().DescribeFunctionRules(request)
1232+
if err != nil {
1233+
errRet = err
1234+
return
1235+
}
1236+
log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n", logId, request.GetAction(), request.ToJsonString(), response.ToJsonString())
1237+
1238+
ret = response.Response
1239+
return
1240+
}

0 commit comments

Comments
 (0)