Skip to content

Commit 6bb14d1

Browse files
committed
feat: support teo runtime_environment
1 parent bd127d7 commit 6bb14d1

5 files changed

+371
-0
lines changed

tencentcloud/services/teo/resource_tc_teo_function_runtime_environment.go

Lines changed: 273 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
Provides a resource to create a teo teo_function_runtime_environment
2+
3+
Example Usage
4+
5+
```hcl
6+
resource "tencentcloud_teo_function_runtime_environment" "teo_function_runtime_environment" {
7+
environment_variables = {
8+
}
9+
}
10+
```
11+
12+
Import
13+
14+
teo teo_function_runtime_environment can be imported using the id, e.g.
15+
16+
```
17+
terraform import tencentcloud_teo_function_runtime_environment.teo_function_runtime_environment teo_function_runtime_environment_id
18+
```
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package teo
2+
3+
import (
4+
"context"
5+
6+
teov20220901 "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/teo/v20220901"
7+
8+
"github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/internal/helper"
9+
)
10+
11+
func resourceTencentCloudTeoFunctionRuntimeEnvironmentUpdatePostFillRequest0(ctx context.Context, req *teov20220901.HandleFunctionRuntimeEnvironmentRequest) error {
12+
req.Operation = helper.String("setEnvironmentVariable")
13+
return nil
14+
}
15+
16+
func resourceTencentCloudTeoFunctionRuntimeEnvironmentDeletePostFillRequest0(ctx context.Context, req *teov20220901.HandleFunctionRuntimeEnvironmentRequest) error {
17+
req.Operation = helper.String("deleteEnvironmentVariable")
18+
return nil
19+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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 TestAccTencentCloudTeoFunctionRuntimeEnvironmentResource_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: testAccTeoFunctionRuntimeEnvironment,
20+
Check: resource.ComposeTestCheckFunc(resource.TestCheckResourceAttrSet("tencentcloud_teo_function_runtime_environment.teo_function_runtime_environment", "id")),
21+
}, {
22+
ResourceName: "tencentcloud_teo_function_runtime_environment.teo_function_runtime_environment",
23+
ImportState: true,
24+
ImportStateVerify: true,
25+
}},
26+
})
27+
}
28+
29+
const testAccTeoFunctionRuntimeEnvironment = `
30+
31+
resource "tencentcloud_teo_function_runtime_environment" "teo_function_runtime_environment" {
32+
environment_variables = {
33+
}
34+
}
35+
`

tencentcloud/services/teo/service_tencentcloud_teo.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1238,3 +1238,29 @@ func (me *TeoService) DescribeTeoFunctionRulePriorityById(ctx context.Context, z
12381238
ret = response.Response
12391239
return
12401240
}
1241+
1242+
func (me *TeoService) DescribeTeoFunctionRuntimeEnvironmentById(ctx context.Context, zoneId string, functionId string) (ret *teo.DescribeFunctionRuntimeEnvironmentResponseParams, errRet error) {
1243+
logId := tccommon.GetLogId(ctx)
1244+
1245+
request := teo.NewDescribeFunctionRuntimeEnvironmentRequest()
1246+
request.ZoneId = helper.String(zoneId)
1247+
request.FunctionId = helper.String(functionId)
1248+
1249+
defer func() {
1250+
if errRet != nil {
1251+
log.Printf("[CRITAL]%s api[%s] fail, request body [%s], reason[%s]\n", logId, request.GetAction(), request.ToJsonString(), errRet.Error())
1252+
}
1253+
}()
1254+
1255+
ratelimit.Check(request.GetAction())
1256+
1257+
response, err := me.client.UseTeoV20220901Client().DescribeFunctionRuntimeEnvironment(request)
1258+
if err != nil {
1259+
errRet = err
1260+
return
1261+
}
1262+
log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n", logId, request.GetAction(), request.ToJsonString(), response.ToJsonString())
1263+
1264+
ret = response.Response
1265+
return
1266+
}

0 commit comments

Comments
 (0)