|
- package main
-
- import (
- "fmt"
-
- "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common"
- "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/errors"
- "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/profile"
- tke "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tke/v20180525"
- )
-
- func main() {
-
- credential := common.NewCredential(
- "SecretId",
- "SecretKey",
- )
- cpf := profile.NewClientProfile()
- cpf.HttpProfile.Endpoint = "tke.tencentcloudapi.com"
- client, _ := tke.NewClient(credential, "ap-beijing", cpf)
- //创建容器实例
- request := tke.NewCreateEKSContainerInstancesRequest()
-
- response, err := client.CreateEKSContainerInstances(request)
- if _, ok := err.(*errors.TencentCloudSDKError); ok {
- fmt.Printf("An API error has returned: %s", err)
- return
- }
- if err != nil {
- panic(err)
- }
- fmt.Printf("%s", response.ToJsonString())
-
- //查询容器实例
- desRequest := tke.NewDescribeEKSContainerInstancesRequest()
- desResponse, err := client.DescribeEKSContainerInstances(desRequest)
- if _, ok := err.(*errors.TencentCloudSDKError); ok {
- fmt.Printf("An API error has returned: %s", err)
- return
- }
- if err != nil {
- panic(err)
- }
- fmt.Printf("%s", desResponse.ToJsonString())
-
- //删除容器实例
- delRequest := tke.NewDeleteEKSContainerInstancesRequest()
- delResponse, err := client.DeleteEKSContainerInstances(delRequest)
- if _, ok := err.(*errors.TencentCloudSDKError); ok {
- fmt.Printf("An API error has returned: %s", err)
- return
- }
- if err != nil {
- panic(err)
- }
- fmt.Printf("%s", delResponse.ToJsonString())
-
- //更改容器实例
- updateRequest := tke.NewUpdateEKSContainerInstanceRequest()
- updateResponse, err := client.UpdateEKSContainerInstance(updateRequest)
- if _, ok := err.(*errors.TencentCloudSDKError); ok {
- fmt.Printf("An API error has returned: %s", err)
- return
- }
- if err != nil {
- panic(err)
- }
- fmt.Printf("%s", updateResponse.ToJsonString())
-
- }
|