From 8b412b2e9a087116270cc223f107a1dc83702db4 Mon Sep 17 00:00:00 2001 From: anonymous Date: Thu, 19 Jan 2023 01:47:48 +0800 Subject: [PATCH 01/11] feat: support tsf --- tencentcloud/resource_tc_tsf_api_group.go | 507 +++++++ .../resource_tc_tsf_api_group_test.go | 44 + .../resource_tc_tsf_api_rate_limit_rule.go | 301 +++++ ...esource_tc_tsf_api_rate_limit_rule_test.go | 37 + ...ource_tc_tsf_application_release_config.go | 290 ++++ ..._tc_tsf_application_release_config_test.go | 37 + .../resource_tc_tsf_config_template.go | 291 ++++ .../resource_tc_tsf_config_template_test.go | 39 + tencentcloud/resource_tc_tsf_contain_group.go | 1183 +++++++++++++++++ .../resource_tc_tsf_contain_group_test.go | 64 + tencentcloud/resource_tc_tsf_lane.go | 455 +++++++ tencentcloud/resource_tc_tsf_lane_rule.go | 465 +++++++ .../resource_tc_tsf_lane_rule_test.go | 49 + tencentcloud/resource_tc_tsf_lane_test.go | 52 + tencentcloud/resource_tc_tsf_namespace.go | 803 +++++++++++ .../resource_tc_tsf_namespace_test.go | 43 + tencentcloud/resource_tc_tsf_path_rewrite.go | 266 ++++ .../resource_tc_tsf_path_rewrite_test.go | 39 + tencentcloud/resource_tc_tsf_repository.go | 283 ++++ .../resource_tc_tsf_repository_test.go | 40 + tencentcloud/resource_tc_tsf_task.go | 704 ++++++++++ tencentcloud/resource_tc_tsf_task_test.go | 62 + tencentcloud/resource_tc_tsf_unit_rule.go | 536 ++++++++ .../resource_tc_tsf_unit_rule_test.go | 56 + tencentcloud/service_tencentcloud_tsf.go | 641 +++++++++ 25 files changed, 7287 insertions(+) create mode 100644 tencentcloud/resource_tc_tsf_api_group.go create mode 100644 tencentcloud/resource_tc_tsf_api_group_test.go create mode 100644 tencentcloud/resource_tc_tsf_api_rate_limit_rule.go create mode 100644 tencentcloud/resource_tc_tsf_api_rate_limit_rule_test.go create mode 100644 tencentcloud/resource_tc_tsf_application_release_config.go create mode 100644 tencentcloud/resource_tc_tsf_application_release_config_test.go create mode 100644 tencentcloud/resource_tc_tsf_config_template.go create mode 100644 tencentcloud/resource_tc_tsf_config_template_test.go create mode 100644 tencentcloud/resource_tc_tsf_contain_group.go create mode 100644 tencentcloud/resource_tc_tsf_contain_group_test.go create mode 100644 tencentcloud/resource_tc_tsf_lane.go create mode 100644 tencentcloud/resource_tc_tsf_lane_rule.go create mode 100644 tencentcloud/resource_tc_tsf_lane_rule_test.go create mode 100644 tencentcloud/resource_tc_tsf_lane_test.go create mode 100644 tencentcloud/resource_tc_tsf_namespace.go create mode 100644 tencentcloud/resource_tc_tsf_namespace_test.go create mode 100644 tencentcloud/resource_tc_tsf_path_rewrite.go create mode 100644 tencentcloud/resource_tc_tsf_path_rewrite_test.go create mode 100644 tencentcloud/resource_tc_tsf_repository.go create mode 100644 tencentcloud/resource_tc_tsf_repository_test.go create mode 100644 tencentcloud/resource_tc_tsf_task.go create mode 100644 tencentcloud/resource_tc_tsf_task_test.go create mode 100644 tencentcloud/resource_tc_tsf_unit_rule.go create mode 100644 tencentcloud/resource_tc_tsf_unit_rule_test.go diff --git a/tencentcloud/resource_tc_tsf_api_group.go b/tencentcloud/resource_tc_tsf_api_group.go new file mode 100644 index 0000000000..339138f906 --- /dev/null +++ b/tencentcloud/resource_tc_tsf_api_group.go @@ -0,0 +1,507 @@ +/* +Provides a resource to create a tsf api_group + +Example Usage + +```hcl +resource "tencentcloud_tsf_api_group" "api_group" { + group_name = "" + group_context = "" + auth_type = "" + description = "" + group_type = "" + gateway_instance_id = "" + namespace_name_key = "" + service_name_key = "" + namespace_name_key_position = "" + service_name_key_position = "" +} +``` + +Import + +tsf api_group can be imported using the id, e.g. + +``` +terraform import tencentcloud_tsf_api_group.api_group api_group_id +``` +*/ +package tencentcloud + +import ( + "context" + "fmt" + "log" + + "github.com/hashicorp/terraform-plugin-sdk/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + tsf "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tsf/v20180326" + "github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/internal/helper" +) + +func resourceTencentCloudTsfApiGroup() *schema.Resource { + return &schema.Resource{ + Create: resourceTencentCloudTsfApiGroupCreate, + Read: resourceTencentCloudTsfApiGroupRead, + Update: resourceTencentCloudTsfApiGroupUpdate, + Delete: resourceTencentCloudTsfApiGroupDelete, + Importer: &schema.ResourceImporter{ + State: schema.ImportStatePassthrough, + }, + Schema: map[string]*schema.Schema{ + "group_id": { + Type: schema.TypeString, + Computed: true, + Description: "Api Group Id.", + }, + "group_name": { + Required: true, + Type: schema.TypeString, + Description: "group name, cannot contain Chinese.", + }, + + "group_context": { + Required: true, + Type: schema.TypeString, + Description: "grouping context.", + }, + + "auth_type": { + Optional: true, + Computed: true, + Type: schema.TypeString, + Description: "authentication type. secret: key authentication; none: no authentication.", + }, + + "description": { + Optional: true, + Computed: true, + Type: schema.TypeString, + Description: "remarks.", + }, + + "group_type": { + Optional: true, + Computed: true, + Type: schema.TypeString, + Description: "grouping type, default ms. ms: microservice grouping; external: external Api grouping.", + }, + + "gateway_instance_id": { + Optional: true, + Computed: true, + Type: schema.TypeString, + Description: "gateway entity ID.", + }, + + "namespace_name_key": { + Optional: true, + Computed: true, + Type: schema.TypeString, + Description: "namespace parameter key value.", + }, + + "service_name_key": { + Optional: true, + Computed: true, + Type: schema.TypeString, + Description: "microservice name parameter key value.", + }, + + "namespace_name_key_position": { + Optional: true, + Computed: true, + Type: schema.TypeString, + Description: "namespace parameter position, path, header or query, the default is path.", + }, + + "service_name_key_position": { + Optional: true, + Computed: true, + Type: schema.TypeString, + Description: "microservice name parameter position, path, header or query, the default is path.", + }, + + "status": { + Type: schema.TypeString, + Computed: true, + Description: "Release status, drafted: Not published. released: released.", + }, + + "created_time": { + Type: schema.TypeString, + Computed: true, + Description: "Group creation time such as: 2019-06-20 15:51:28.", + }, + "updated_time": { + Type: schema.TypeString, + Computed: true, + Description: "Group update time such as: 2019-06-20 15:51:28.", + }, + "binded_gateway_deploy_groups": { + Type: schema.TypeList, + Computed: true, + Description: "api group bound gateway deployment group.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "deploy_group_id": { + Type: schema.TypeString, + Computed: true, + Description: "Gateway deployment group ID.", + }, + "deploy_group_name": { + Type: schema.TypeString, + Computed: true, + Description: "Gateway deployment group name.", + }, + "application_id": { + Type: schema.TypeString, + Computed: true, + Description: "application ID.", + }, + "application_name": { + Type: schema.TypeString, + Computed: true, + Description: "Application Name.", + }, + "application_type": { + Type: schema.TypeString, + Computed: true, + Description: "Application classification: V: virtual machine application, C: container application.", + }, + "group_status": { + Type: schema.TypeString, + Computed: true, + Description: "Deployment group application status, values: Running, Waiting, Paused, Updating, RollingBack, Abnormal, Unknown.", + }, + "cluster_type": { + Type: schema.TypeString, + Computed: true, + Description: "Cluster type, C: container, V: virtual machine.", + }, + }, + }, + }, + "api_count": { + Type: schema.TypeInt, + Computed: true, + Description: "number of APIs.", + }, + "acl_mode": { + Type: schema.TypeString, + Computed: true, + Description: "Access group ACL type.", + }, + "gateway_instance_type": { + Type: schema.TypeString, + Computed: true, + Description: "Type of gateway instance.", + }, + }, + } +} + +func resourceTencentCloudTsfApiGroupCreate(d *schema.ResourceData, meta interface{}) error { + defer logElapsed("resource.tencentcloud_tsf_api_group.create")() + defer inconsistentCheck(d, meta)() + + logId := getLogId(contextNil) + + var ( + request = tsf.NewCreateApiGroupRequest() + response = tsf.NewCreateApiGroupResponse() + groupId string + ) + if v, ok := d.GetOk("group_name"); ok { + request.GroupName = helper.String(v.(string)) + } + + if v, ok := d.GetOk("group_context"); ok { + request.GroupContext = helper.String(v.(string)) + } + + if v, ok := d.GetOk("auth_type"); ok { + request.AuthType = helper.String(v.(string)) + } + + if v, ok := d.GetOk("description"); ok { + request.Description = helper.String(v.(string)) + } + + if v, ok := d.GetOk("group_type"); ok { + request.GroupType = helper.String(v.(string)) + } + + if v, ok := d.GetOk("gateway_instance_id"); ok { + request.GatewayInstanceId = helper.String(v.(string)) + } + + if v, ok := d.GetOk("namespace_name_key"); ok { + request.NamespaceNameKey = helper.String(v.(string)) + } + + if v, ok := d.GetOk("service_name_key"); ok { + request.ServiceNameKey = helper.String(v.(string)) + } + + if v, ok := d.GetOk("namespace_name_key_position"); ok { + request.NamespaceNameKeyPosition = helper.String(v.(string)) + } + + if v, ok := d.GetOk("service_name_key_position"); ok { + request.ServiceNameKeyPosition = helper.String(v.(string)) + } + + err := resource.Retry(writeRetryTimeout, func() *resource.RetryError { + result, e := meta.(*TencentCloudClient).apiV3Conn.UseTsfClient().CreateApiGroup(request) + if e != nil { + return retryError(e) + } else { + log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n", logId, request.GetAction(), request.ToJsonString(), result.ToJsonString()) + } + response = result + return nil + }) + if err != nil { + log.Printf("[CRITAL]%s create tsf apiGroup failed, reason:%+v", logId, err) + return err + } + + groupId = *response.Response.Result + d.SetId(groupId) + + return resourceTencentCloudTsfApiGroupRead(d, meta) +} + +func resourceTencentCloudTsfApiGroupRead(d *schema.ResourceData, meta interface{}) error { + defer logElapsed("resource.tencentcloud_tsf_api_group.read")() + defer inconsistentCheck(d, meta)() + + logId := getLogId(contextNil) + + ctx := context.WithValue(context.TODO(), logIdKey, logId) + + service := TsfService{client: meta.(*TencentCloudClient).apiV3Conn} + + groupId := d.Id() + + apiGroup, err := service.DescribeTsfApiGroupById(ctx, groupId) + if err != nil { + return err + } + + if apiGroup == nil { + d.SetId("") + log.Printf("[WARN]%s resource `TsfApiGroup` [%s] not found, please check if it has been deleted.\n", logId, d.Id()) + return nil + } + + _ = d.Set("group_id", groupId) + + if apiGroup.GroupName != nil { + _ = d.Set("group_name", apiGroup.GroupName) + } + + if apiGroup.GroupContext != nil { + _ = d.Set("group_context", apiGroup.GroupContext) + } + + if apiGroup.AuthType != nil { + _ = d.Set("auth_type", apiGroup.AuthType) + } + + if apiGroup.Description != nil { + _ = d.Set("description", apiGroup.Description) + } + + if apiGroup.GroupType != nil { + _ = d.Set("group_type", apiGroup.GroupType) + } + + if apiGroup.GatewayInstanceId != nil { + _ = d.Set("gateway_instance_id", apiGroup.GatewayInstanceId) + } + + if apiGroup.NamespaceNameKey != nil { + _ = d.Set("namespace_name_key", apiGroup.NamespaceNameKey) + } + + if apiGroup.ServiceNameKey != nil { + _ = d.Set("service_name_key", apiGroup.ServiceNameKey) + } + + if apiGroup.NamespaceNameKeyPosition != nil { + _ = d.Set("namespace_name_key_position", apiGroup.NamespaceNameKeyPosition) + } + + if apiGroup.ServiceNameKeyPosition != nil { + _ = d.Set("service_name_key_position", apiGroup.ServiceNameKeyPosition) + } + + if apiGroup.Status != nil { + _ = d.Set("status", apiGroup.Status) + } + + if apiGroup.CreatedTime != nil { + _ = d.Set("created_time", apiGroup.CreatedTime) + } + + if apiGroup.UpdatedTime != nil { + _ = d.Set("updated_time", apiGroup.UpdatedTime) + } + + if apiGroup.BindedGatewayDeployGroups != nil { + bindedGatewayDeployGroupsList := []interface{}{} + for _, bindedGatewayDeployGroups := range apiGroup.BindedGatewayDeployGroups { + bindedGatewayDeployGroupsMap := map[string]interface{}{} + + if bindedGatewayDeployGroups.DeployGroupId != nil { + bindedGatewayDeployGroupsMap["deploy_group_id"] = bindedGatewayDeployGroups.DeployGroupId + } + + if bindedGatewayDeployGroups.DeployGroupName != nil { + bindedGatewayDeployGroupsMap["deploy_group_name"] = bindedGatewayDeployGroups.DeployGroupName + } + + if bindedGatewayDeployGroups.ApplicationId != nil { + bindedGatewayDeployGroupsMap["application_id"] = bindedGatewayDeployGroups.ApplicationId + } + + if bindedGatewayDeployGroups.ApplicationName != nil { + bindedGatewayDeployGroupsMap["application_name"] = bindedGatewayDeployGroups.ApplicationName + } + + if bindedGatewayDeployGroups.ApplicationType != nil { + bindedGatewayDeployGroupsMap["application_type"] = bindedGatewayDeployGroups.ApplicationType + } + + if bindedGatewayDeployGroups.GroupStatus != nil { + bindedGatewayDeployGroupsMap["group_status"] = bindedGatewayDeployGroups.GroupStatus + } + + if bindedGatewayDeployGroups.ClusterType != nil { + bindedGatewayDeployGroupsMap["cluster_type"] = bindedGatewayDeployGroups.ClusterType + } + + bindedGatewayDeployGroupsList = append(bindedGatewayDeployGroupsList, bindedGatewayDeployGroupsMap) + } + + _ = d.Set("binded_gateway_deploy_groups", []interface{}{bindedGatewayDeployGroupsList}) + } + + if apiGroup.ApiCount != nil { + _ = d.Set("api_count", apiGroup.ApiCount) + } + + if apiGroup.AclMode != nil { + _ = d.Set("acl_mode", apiGroup.AclMode) + } + + if apiGroup.GatewayInstanceType != nil { + _ = d.Set("gateway_instance_type", apiGroup.GatewayInstanceType) + } + + return nil +} + +func resourceTencentCloudTsfApiGroupUpdate(d *schema.ResourceData, meta interface{}) error { + defer logElapsed("resource.tencentcloud_tsf_api_group.update")() + defer inconsistentCheck(d, meta)() + + logId := getLogId(contextNil) + + request := tsf.NewUpdateApiGroupRequest() + + groupId := d.Id() + + request.GroupId = &groupId + + immutableArgs := []string{"group_name", "group_context", "auth_type", "description", "group_type", "gateway_instance_id", "namespace_name_key", "service_name_key", "namespace_name_key_position", "service_name_key_position", "result"} + + for _, v := range immutableArgs { + if d.HasChange(v) { + return fmt.Errorf("argument `%s` cannot be changed", v) + } + } + + if d.HasChange("group_name") { + if v, ok := d.GetOk("group_name"); ok { + request.GroupName = helper.String(v.(string)) + } + } + + if d.HasChange("group_context") { + if v, ok := d.GetOk("group_context"); ok { + request.GroupContext = helper.String(v.(string)) + } + } + + if d.HasChange("auth_type") { + if v, ok := d.GetOk("auth_type"); ok { + request.AuthType = helper.String(v.(string)) + } + } + + if d.HasChange("description") { + if v, ok := d.GetOk("description"); ok { + request.Description = helper.String(v.(string)) + } + } + + if d.HasChange("namespace_name_key") { + if v, ok := d.GetOk("namespace_name_key"); ok { + request.NamespaceNameKey = helper.String(v.(string)) + } + } + + if d.HasChange("service_name_key") { + if v, ok := d.GetOk("service_name_key"); ok { + request.ServiceNameKey = helper.String(v.(string)) + } + } + + if d.HasChange("namespace_name_key_position") { + if v, ok := d.GetOk("namespace_name_key_position"); ok { + request.NamespaceNameKeyPosition = helper.String(v.(string)) + } + } + + if d.HasChange("service_name_key_position") { + if v, ok := d.GetOk("service_name_key_position"); ok { + request.ServiceNameKeyPosition = helper.String(v.(string)) + } + } + + err := resource.Retry(writeRetryTimeout, func() *resource.RetryError { + result, e := meta.(*TencentCloudClient).apiV3Conn.UseTsfClient().UpdateApiGroup(request) + if e != nil { + return 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 update tsf apiGroup failed, reason:%+v", logId, err) + return err + } + + return resourceTencentCloudTsfApiGroupRead(d, meta) +} + +func resourceTencentCloudTsfApiGroupDelete(d *schema.ResourceData, meta interface{}) error { + defer logElapsed("resource.tencentcloud_tsf_api_group.delete")() + defer inconsistentCheck(d, meta)() + + logId := getLogId(contextNil) + ctx := context.WithValue(context.TODO(), logIdKey, logId) + + service := TsfService{client: meta.(*TencentCloudClient).apiV3Conn} + groupId := d.Id() + + if err := service.DeleteTsfApiGroupById(ctx, groupId); err != nil { + return err + } + + return nil +} diff --git a/tencentcloud/resource_tc_tsf_api_group_test.go b/tencentcloud/resource_tc_tsf_api_group_test.go new file mode 100644 index 0000000000..2394c4a372 --- /dev/null +++ b/tencentcloud/resource_tc_tsf_api_group_test.go @@ -0,0 +1,44 @@ +package tencentcloud + +import ( + "github.com/hashicorp/terraform-plugin-sdk/helper/resource" + "testing" +) + +func TestAccTencentCloudTsfApiGroupResource_basic(t *testing.T) { + t.Parallel() + resource.Test(t, resource.TestCase{ + PreCheck: func() { + testAccPreCheck(t) + }, + Providers: testAccProviders, + Steps: []resource.TestStep{ + { + Config: testAccTsfApiGroup, + Check: resource.ComposeTestCheckFunc(resource.TestCheckResourceAttrSet("tencentcloud_tsf_api_group.api_group", "id")), + }, + { + ResourceName: "tencentcloud_tsf_api_group.api_group", + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + +const testAccTsfApiGroup = ` + +resource "tencentcloud_tsf_api_group" "api_group" { + group_name = "" + group_context = "" + auth_type = "" + description = "" + group_type = "" + gateway_instance_id = "" + namespace_name_key = "" + service_name_key = "" + namespace_name_key_position = "" + service_name_key_position = "" + } + +` diff --git a/tencentcloud/resource_tc_tsf_api_rate_limit_rule.go b/tencentcloud/resource_tc_tsf_api_rate_limit_rule.go new file mode 100644 index 0000000000..8ab95bb31b --- /dev/null +++ b/tencentcloud/resource_tc_tsf_api_rate_limit_rule.go @@ -0,0 +1,301 @@ +/* +Provides a resource to create a tsf api_rate_limit_rule + +Example Usage + +```hcl +resource "tencentcloud_tsf_api_rate_limit_rule" "api_rate_limit_rule" { + api_id = "" + max_qps = + usable_status = "" +} +``` + +Import + +tsf api_rate_limit_rule can be imported using the id, e.g. + +``` +terraform import tencentcloud_tsf_api_rate_limit_rule.api_rate_limit_rule api_rate_limit_rule_id +``` +*/ +package tencentcloud + +import ( + "context" + "fmt" + "log" + "strings" + + "github.com/hashicorp/terraform-plugin-sdk/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + tsf "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tsf/v20180326" + "github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/internal/helper" +) + +func resourceTencentCloudTsfApiRateLimitRule() *schema.Resource { + return &schema.Resource{ + Create: resourceTencentCloudTsfApiRateLimitRuleCreate, + Read: resourceTencentCloudTsfApiRateLimitRuleRead, + Update: resourceTencentCloudTsfApiRateLimitRuleUpdate, + Delete: resourceTencentCloudTsfApiRateLimitRuleDelete, + Importer: &schema.ResourceImporter{ + State: schema.ImportStatePassthrough, + }, + Schema: map[string]*schema.Schema{ + "api_id": { + Required: true, + Type: schema.TypeString, + Description: "Api Id.", + }, + + "max_qps": { + Required: true, + Type: schema.TypeInt, + Description: "qps value.", + }, + + "usable_status": { + Optional: true, + Computed: true, + Type: schema.TypeString, + Description: "Enable/disable, enabled/disabled, if not passed, it is enabled by default.", + }, + + "rule_id": { + Type: schema.TypeString, + Computed: true, + Description: "rule Id.", + }, + + "rule_name": { + Type: schema.TypeString, + Computed: true, + Description: "Current limit name.", + }, + + "rule_content": { + Type: schema.TypeString, + Computed: true, + Description: "Rule content.", + }, + + "tsf_rule_id": { + Type: schema.TypeString, + Computed: true, + Description: "Tsf Rule ID.", + }, + + "description": { + Type: schema.TypeString, + Computed: true, + Description: "describe.", + }, + + "created_time": { + Type: schema.TypeString, + Computed: true, + Description: "creation time.", + }, + + "updated_time": { + Type: schema.TypeString, + Computed: true, + Description: "update time.", + }, + }, + } +} + +func resourceTencentCloudTsfApiRateLimitRuleCreate(d *schema.ResourceData, meta interface{}) error { + defer logElapsed("resource.tencentcloud_tsf_api_rate_limit_rule.create")() + defer inconsistentCheck(d, meta)() + + logId := getLogId(contextNil) + + var ( + request = tsf.NewCreateApiRateLimitRuleRequest() + // response = tsf.NewCreateApiRateLimitRuleResponse() + apiId string + ruleId string + ) + if v, ok := d.GetOk("api_id"); ok { + apiId = v.(string) + request.ApiId = helper.String(v.(string)) + } + + if v, _ := d.GetOk("max_qps"); v != nil { + request.MaxQps = helper.IntUint64(v.(int)) + } + + if v, ok := d.GetOk("usable_status"); ok { + request.UsableStatus = helper.String(v.(string)) + } + + err := resource.Retry(writeRetryTimeout, func() *resource.RetryError { + result, e := meta.(*TencentCloudClient).apiV3Conn.UseTsfClient().CreateApiRateLimitRule(request) + if e != nil { + return retryError(e) + } else { + log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n", logId, request.GetAction(), request.ToJsonString(), result.ToJsonString()) + } + // response = result + return nil + }) + if err != nil { + log.Printf("[CRITAL]%s create tsf apiRateLimitRule failed, reason:%+v", logId, err) + return err + } + + // ruleId = *response.Response.RuleId + d.SetId(apiId + FILED_SP + ruleId) + + return resourceTencentCloudTsfApiRateLimitRuleRead(d, meta) +} + +func resourceTencentCloudTsfApiRateLimitRuleRead(d *schema.ResourceData, meta interface{}) error { + defer logElapsed("resource.tencentcloud_tsf_api_rate_limit_rule.read")() + defer inconsistentCheck(d, meta)() + + logId := getLogId(contextNil) + + ctx := context.WithValue(context.TODO(), logIdKey, logId) + + service := TsfService{client: meta.(*TencentCloudClient).apiV3Conn} + + idSplit := strings.Split(d.Id(), FILED_SP) + if len(idSplit) != 2 { + return fmt.Errorf("id is broken,%s", d.Id()) + } + apiId := idSplit[0] + ruleId := idSplit[1] + + apiRateLimitRule, err := service.DescribeTsfApiRateLimitRuleById(ctx, apiId, ruleId) + if err != nil { + return err + } + + if apiRateLimitRule == nil { + d.SetId("") + log.Printf("[WARN]%s resource `TsfApiRateLimitRule` [%s] not found, please check if it has been deleted.\n", logId, d.Id()) + return nil + } + + if apiRateLimitRule.ApiId != nil { + _ = d.Set("api_id", apiRateLimitRule.ApiId) + } + + if apiRateLimitRule.MaxQps != nil { + _ = d.Set("max_qps", apiRateLimitRule.MaxQps) + } + + if apiRateLimitRule.UsableStatus != nil { + _ = d.Set("usable_status", apiRateLimitRule.UsableStatus) + } + + if apiRateLimitRule.RuleId != nil { + _ = d.Set("rule_id", apiRateLimitRule.RuleId) + } + + if apiRateLimitRule.RuleName != nil { + _ = d.Set("rule_name", apiRateLimitRule.RuleName) + } + + if apiRateLimitRule.RuleContent != nil { + _ = d.Set("rule_content", apiRateLimitRule.RuleContent) + } + + if apiRateLimitRule.TsfRuleId != nil { + _ = d.Set("tsf_rule_id", apiRateLimitRule.TsfRuleId) + } + + if apiRateLimitRule.Description != nil { + _ = d.Set("description", apiRateLimitRule.Description) + } + + if apiRateLimitRule.CreatedTime != nil { + _ = d.Set("created_time", apiRateLimitRule.CreatedTime) + } + + if apiRateLimitRule.UpdatedTime != nil { + _ = d.Set("updated_time", apiRateLimitRule.UpdatedTime) + } + + return nil +} + +func resourceTencentCloudTsfApiRateLimitRuleUpdate(d *schema.ResourceData, meta interface{}) error { + defer logElapsed("resource.tencentcloud_tsf_api_rate_limit_rule.update")() + defer inconsistentCheck(d, meta)() + + logId := getLogId(contextNil) + + request := tsf.NewUpdateApiRateLimitRuleRequest() + + idSplit := strings.Split(d.Id(), FILED_SP) + if len(idSplit) != 2 { + return fmt.Errorf("id is broken,%s", d.Id()) + } + // apiId := idSplit[0] + ruleId := idSplit[1] + + request.RuleId = &ruleId + + immutableArgs := []string{"api_id", "max_qps", "usable_status", "result"} + + for _, v := range immutableArgs { + if d.HasChange(v) { + return fmt.Errorf("argument `%s` cannot be changed", v) + } + } + + if d.HasChange("max_qps") { + if v, _ := d.GetOk("max_qps"); v != nil { + request.MaxQps = helper.IntInt64(v.(int)) + } + } + + if d.HasChange("usable_status") { + if v, ok := d.GetOk("usable_status"); ok { + request.UsableStatus = helper.String(v.(string)) + } + } + + err := resource.Retry(writeRetryTimeout, func() *resource.RetryError { + result, e := meta.(*TencentCloudClient).apiV3Conn.UseTsfClient().UpdateApiRateLimitRule(request) + if e != nil { + return 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 update tsf apiRateLimitRule failed, reason:%+v", logId, err) + return err + } + + return resourceTencentCloudTsfApiRateLimitRuleRead(d, meta) +} + +func resourceTencentCloudTsfApiRateLimitRuleDelete(d *schema.ResourceData, meta interface{}) error { + defer logElapsed("resource.tencentcloud_tsf_api_rate_limit_rule.delete")() + defer inconsistentCheck(d, meta)() + + // logId := getLogId(contextNil) + // ctx := context.WithValue(context.TODO(), logIdKey, logId) + + // service := TsfService{client: meta.(*TencentCloudClient).apiV3Conn} + // idSplit := strings.Split(d.Id(), FILED_SP) + // if len(idSplit) != 2 { + // return fmt.Errorf("id is broken,%s", d.Id()) + // } + // apiId := idSplit[0] + // ruleId := idSplit[1] + + // if err := service.DeleteTsfApiRateLimitRuleById(ctx, apiId, ruleId); err != nil { + // return err + // } + + return nil +} diff --git a/tencentcloud/resource_tc_tsf_api_rate_limit_rule_test.go b/tencentcloud/resource_tc_tsf_api_rate_limit_rule_test.go new file mode 100644 index 0000000000..54c1a52e70 --- /dev/null +++ b/tencentcloud/resource_tc_tsf_api_rate_limit_rule_test.go @@ -0,0 +1,37 @@ +package tencentcloud + +import ( + "github.com/hashicorp/terraform-plugin-sdk/helper/resource" + "testing" +) + +func TestAccTencentCloudTsfApiRateLimitRuleResource_basic(t *testing.T) { + t.Parallel() + resource.Test(t, resource.TestCase{ + PreCheck: func() { + testAccPreCheck(t) + }, + Providers: testAccProviders, + Steps: []resource.TestStep{ + { + Config: testAccTsfApiRateLimitRule, + Check: resource.ComposeTestCheckFunc(resource.TestCheckResourceAttrSet("tencentcloud_tsf_api_rate_limit_rule.api_rate_limit_rule", "id")), + }, + { + ResourceName: "tencentcloud_tsf_api_rate_limit_rule.api_rate_limit_rule", + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + +const testAccTsfApiRateLimitRule = ` + +resource "tencentcloud_tsf_api_rate_limit_rule" "api_rate_limit_rule" { + api_id = "" + max_qps = + usable_status = "" + } + +` diff --git a/tencentcloud/resource_tc_tsf_application_release_config.go b/tencentcloud/resource_tc_tsf_application_release_config.go new file mode 100644 index 0000000000..f96f432386 --- /dev/null +++ b/tencentcloud/resource_tc_tsf_application_release_config.go @@ -0,0 +1,290 @@ +/* +Provides a resource to create a tsf application_release_config + +Example Usage + +```hcl +resource "tencentcloud_tsf_application_release_config" "application_release_config" { + config_id = "" + group_id = "" + release_desc = "" +} +``` + +Import + +tsf application_release_config can be imported using the id, e.g. + +``` +terraform import tencentcloud_tsf_application_release_config.application_release_config application_release_config_id +``` +*/ +package tencentcloud + +import ( + "context" + "fmt" + "log" + "strings" + + "github.com/hashicorp/terraform-plugin-sdk/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + tsf "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tsf/v20180326" + "github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/internal/helper" +) + +func resourceTencentCloudTsfApplicationReleaseConfig() *schema.Resource { + return &schema.Resource{ + Create: resourceTencentCloudTsfApplicationReleaseConfigCreate, + Read: resourceTencentCloudTsfApplicationReleaseConfigRead, + Delete: resourceTencentCloudTsfApplicationReleaseConfigDelete, + Importer: &schema.ResourceImporter{ + State: schema.ImportStatePassthrough, + }, + Schema: map[string]*schema.Schema{ + "config_id": { + Required: true, + ForceNew: true, + Type: schema.TypeString, + Description: "Configuration ID.", + }, + + "group_id": { + Required: true, + ForceNew: true, + Type: schema.TypeString, + Description: "deployment group ID.", + }, + + "release_desc": { + Optional: true, + Computed: true, + ForceNew: true, + Type: schema.TypeString, + Description: "release description.", + }, + + "config_release_id": { + Computed: true, + ForceNew: true, + Type: schema.TypeString, + Description: "configuration item release ID.", + }, + + "config_name": { + Computed: true, + ForceNew: true, + Type: schema.TypeString, + Description: "configuration item name.", + }, + + "config_version": { + Computed: true, + ForceNew: true, + Type: schema.TypeString, + Description: "configuration item version.", + }, + + "release_time": { + Computed: true, + ForceNew: true, + Type: schema.TypeString, + Description: "release time.", + }, + + "group_name": { + Computed: true, + ForceNew: true, + Type: schema.TypeString, + Description: "deployment group name.", + }, + + "namespace_id": { + Computed: true, + ForceNew: true, + Type: schema.TypeString, + Description: "Namespace ID.", + }, + + "namespace_name": { + Computed: true, + ForceNew: true, + Type: schema.TypeString, + Description: "namespace name.", + }, + + "cluster_id": { + Computed: true, + ForceNew: true, + Type: schema.TypeString, + Description: "cluster ID.", + }, + + "cluster_name": { + Computed: true, + ForceNew: true, + Type: schema.TypeString, + Description: "cluster name.", + }, + + "application_id": { + Computed: true, + ForceNew: true, + Type: schema.TypeString, + Description: "Application ID.", + }, + }, + } +} + +func resourceTencentCloudTsfApplicationReleaseConfigCreate(d *schema.ResourceData, meta interface{}) error { + defer logElapsed("resource.tencentcloud_tsf_application_release_config.create")() + defer inconsistentCheck(d, meta)() + + logId := getLogId(contextNil) + + var ( + request = tsf.NewReleaseConfigRequest() + configId string + groupId string + ) + if v, ok := d.GetOk("config_id"); ok { + configId = v.(string) + request.ConfigId = helper.String(v.(string)) + } + + if v, ok := d.GetOk("group_id"); ok { + groupId = v.(string) + request.GroupId = helper.String(v.(string)) + } + + if v, ok := d.GetOk("release_desc"); ok { + request.ReleaseDesc = helper.String(v.(string)) + } + + err := resource.Retry(writeRetryTimeout, func() *resource.RetryError { + result, e := meta.(*TencentCloudClient).apiV3Conn.UseTsfClient().ReleaseConfig(request) + if e != nil { + return retryError(e) + } else { + log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n", logId, request.GetAction(), request.ToJsonString(), result.ToJsonString()) + } + if !*result.Response.Result { + log.Printf("[CRITAL]%s create tsf applicationReleaseConfig failed, result: %v", logId, *result.Response.Result) + } + return nil + }) + if err != nil { + log.Printf("[CRITAL]%s create tsf applicationReleaseConfig failed, reason:%+v", logId, err) + return err + } + + d.SetId(configId + FILED_SP + groupId) + + return resourceTencentCloudTsfApplicationReleaseConfigRead(d, meta) +} + +func resourceTencentCloudTsfApplicationReleaseConfigRead(d *schema.ResourceData, meta interface{}) error { + defer logElapsed("resource.tencentcloud_tsf_application_release_config.read")() + defer inconsistentCheck(d, meta)() + + logId := getLogId(contextNil) + + ctx := context.WithValue(context.TODO(), logIdKey, logId) + + service := TsfService{client: meta.(*TencentCloudClient).apiV3Conn} + + idSplit := strings.Split(d.Id(), FILED_SP) + if len(idSplit) != 2 { + return fmt.Errorf("id is broken,%s", d.Id()) + } + configId := idSplit[0] + groupId := idSplit[1] + + applicationReleaseConfig, err := service.DescribeTsfApplicationReleaseConfigById(ctx, configId, groupId) + if err != nil { + return err + } + + if applicationReleaseConfig == nil { + d.SetId("") + log.Printf("[WARN]%s resource `TsfApplicationReleaseConfig` [%s] not found, please check if it has been deleted.\n", logId, d.Id()) + return nil + } + + if applicationReleaseConfig.ConfigId != nil { + _ = d.Set("config_id", applicationReleaseConfig.ConfigId) + } + + if applicationReleaseConfig.GroupId != nil { + _ = d.Set("group_id", applicationReleaseConfig.GroupId) + } + + if applicationReleaseConfig.ReleaseDesc != nil { + _ = d.Set("release_desc", applicationReleaseConfig.ReleaseDesc) + } + + if applicationReleaseConfig.ConfigReleaseId != nil { + _ = d.Set("config_release_id", applicationReleaseConfig.ConfigReleaseId) + } + + if applicationReleaseConfig.ConfigName != nil { + _ = d.Set("config_name", applicationReleaseConfig.ConfigName) + } + + if applicationReleaseConfig.ConfigVersion != nil { + _ = d.Set("config_version", applicationReleaseConfig.ConfigVersion) + } + + if applicationReleaseConfig.ReleaseTime != nil { + _ = d.Set("release_time", applicationReleaseConfig.ReleaseTime) + } + + if applicationReleaseConfig.GroupName != nil { + _ = d.Set("group_name", applicationReleaseConfig.GroupName) + } + + if applicationReleaseConfig.NamespaceId != nil { + _ = d.Set("namespace_id", applicationReleaseConfig.NamespaceId) + } + + if applicationReleaseConfig.NamespaceName != nil { + _ = d.Set("namespace_name", applicationReleaseConfig.NamespaceName) + } + + if applicationReleaseConfig.ClusterId != nil { + _ = d.Set("cluster_id", applicationReleaseConfig.ClusterId) + } + + if applicationReleaseConfig.ClusterName != nil { + _ = d.Set("cluster_name", applicationReleaseConfig.ClusterName) + } + + if applicationReleaseConfig.ApplicationId != nil { + _ = d.Set("application_id", applicationReleaseConfig.ApplicationId) + } + + return nil +} + +func resourceTencentCloudTsfApplicationReleaseConfigDelete(d *schema.ResourceData, meta interface{}) error { + defer logElapsed("resource.tencentcloud_tsf_application_release_config.delete")() + defer inconsistentCheck(d, meta)() + + logId := getLogId(contextNil) + ctx := context.WithValue(context.TODO(), logIdKey, logId) + + service := TsfService{client: meta.(*TencentCloudClient).apiV3Conn} + idSplit := strings.Split(d.Id(), FILED_SP) + if len(idSplit) != 2 { + return fmt.Errorf("id is broken,%s", d.Id()) + } + configId := idSplit[0] + // groupId := idSplit[1] + + if err := service.DeleteTsfApplicationReleaseConfigById(ctx, configId); err != nil { + return err + } + + return nil +} diff --git a/tencentcloud/resource_tc_tsf_application_release_config_test.go b/tencentcloud/resource_tc_tsf_application_release_config_test.go new file mode 100644 index 0000000000..8e53f6e2fb --- /dev/null +++ b/tencentcloud/resource_tc_tsf_application_release_config_test.go @@ -0,0 +1,37 @@ +package tencentcloud + +import ( + "github.com/hashicorp/terraform-plugin-sdk/helper/resource" + "testing" +) + +func TestAccTencentCloudTsfApplicationReleaseConfigResource_basic(t *testing.T) { + t.Parallel() + resource.Test(t, resource.TestCase{ + PreCheck: func() { + testAccPreCheck(t) + }, + Providers: testAccProviders, + Steps: []resource.TestStep{ + { + Config: testAccTsfApplicationReleaseConfig, + Check: resource.ComposeTestCheckFunc(resource.TestCheckResourceAttrSet("tencentcloud_tsf_application_release_config.application_release_config", "id")), + }, + { + ResourceName: "tencentcloud_tsf_application_release_config.application_release_config", + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + +const testAccTsfApplicationReleaseConfig = ` + +resource "tencentcloud_tsf_application_release_config" "application_release_config" { + config_id = "" + group_id = "" + release_desc = "" + } + +` diff --git a/tencentcloud/resource_tc_tsf_config_template.go b/tencentcloud/resource_tc_tsf_config_template.go new file mode 100644 index 0000000000..ab3aae500f --- /dev/null +++ b/tencentcloud/resource_tc_tsf_config_template.go @@ -0,0 +1,291 @@ +/* +Provides a resource to create a tsf config_template + +Example Usage + +```hcl +resource "tencentcloud_tsf_config_template" "config_template" { + config_template_name = "" + config_template_type = "" + config_template_value = "" + config_template_desc = "" + program_id_list = +} +``` + +Import + +tsf config_template can be imported using the id, e.g. + +``` +terraform import tencentcloud_tsf_config_template.config_template config_template_id +``` +*/ +package tencentcloud + +import ( + "context" + "fmt" + "log" + + "github.com/hashicorp/terraform-plugin-sdk/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + tsf "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tsf/v20180326" + "github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/internal/helper" +) + +func resourceTencentCloudTsfConfigTemplate() *schema.Resource { + return &schema.Resource{ + Create: resourceTencentCloudTsfConfigTemplateCreate, + Read: resourceTencentCloudTsfConfigTemplateRead, + Update: resourceTencentCloudTsfConfigTemplateUpdate, + Delete: resourceTencentCloudTsfConfigTemplateDelete, + Importer: &schema.ResourceImporter{ + State: schema.ImportStatePassthrough, + }, + Schema: map[string]*schema.Schema{ + "config_template_name": { + Required: true, + Type: schema.TypeString, + Description: "Configuration template name.", + }, + + "config_template_type": { + Required: true, + Type: schema.TypeString, + Description: "Configure the microservice framework corresponding to the template.", + }, + + "config_template_value": { + Required: true, + Type: schema.TypeString, + Description: "Configure template data.", + }, + + "config_template_desc": { + Optional: true, + Type: schema.TypeString, + Description: "Configuration template description.", + }, + + "program_id_list": { + Optional: true, + Type: schema.TypeSet, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + Description: "Program id list.", + }, + + "create_time": { + Computed: true, + Type: schema.TypeString, + Description: "creation time.", + }, + + "update_time": { + Computed: true, + Type: schema.TypeString, + Description: "update time.", + }, + + "config_template_id": { + Computed: true, + Type: schema.TypeString, + Description: "Template Id.", + }, + }, + } +} + +func resourceTencentCloudTsfConfigTemplateCreate(d *schema.ResourceData, meta interface{}) error { + defer logElapsed("resource.tencentcloud_tsf_config_template.create")() + defer inconsistentCheck(d, meta)() + + logId := getLogId(contextNil) + + var ( + request = tsf.NewCreateConfigTemplateRequest() + // response = tsf.NewCreateConfigTemplateResponse() + templateId string + ) + if v, ok := d.GetOk("config_template_name"); ok { + request.ConfigTemplateName = helper.String(v.(string)) + } + + if v, ok := d.GetOk("config_template_type"); ok { + request.ConfigTemplateType = helper.String(v.(string)) + } + + if v, ok := d.GetOk("config_template_value"); ok { + request.ConfigTemplateValue = helper.String(v.(string)) + } + + if v, ok := d.GetOk("config_template_desc"); ok { + request.ConfigTemplateDesc = helper.String(v.(string)) + } + + if v, ok := d.GetOk("program_id_list"); ok { + programIdListSet := v.(*schema.Set).List() + for i := range programIdListSet { + programIdList := programIdListSet[i].(string) + request.ProgramIdList = append(request.ProgramIdList, &programIdList) + } + } + + err := resource.Retry(writeRetryTimeout, func() *resource.RetryError { + result, e := meta.(*TencentCloudClient).apiV3Conn.UseTsfClient().CreateConfigTemplate(request) + if e != nil { + return retryError(e) + } else { + log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n", logId, request.GetAction(), request.ToJsonString(), result.ToJsonString()) + } + // response = result + return nil + }) + if err != nil { + log.Printf("[CRITAL]%s create tsf configTemplate failed, reason:%+v", logId, err) + return err + } + + // templateId = *response.Response.templateId + d.SetId(templateId) + + return resourceTencentCloudTsfConfigTemplateRead(d, meta) +} + +func resourceTencentCloudTsfConfigTemplateRead(d *schema.ResourceData, meta interface{}) error { + defer logElapsed("resource.tencentcloud_tsf_config_template.read")() + defer inconsistentCheck(d, meta)() + + logId := getLogId(contextNil) + + ctx := context.WithValue(context.TODO(), logIdKey, logId) + + service := TsfService{client: meta.(*TencentCloudClient).apiV3Conn} + + templateId := d.Id() + + configTemplate, err := service.DescribeTsfConfigTemplateById(ctx, templateId) + if err != nil { + return err + } + + if configTemplate == nil { + d.SetId("") + log.Printf("[WARN]%s resource `TsfConfigTemplate` [%s] not found, please check if it has been deleted.\n", logId, d.Id()) + return nil + } + + if configTemplate.ConfigTemplateName != nil { + _ = d.Set("config_template_name", configTemplate.ConfigTemplateName) + } + + if configTemplate.ConfigTemplateType != nil { + _ = d.Set("config_template_type", configTemplate.ConfigTemplateType) + } + + if configTemplate.ConfigTemplateValue != nil { + _ = d.Set("config_template_value", configTemplate.ConfigTemplateValue) + } + + if configTemplate.ConfigTemplateDesc != nil { + _ = d.Set("config_template_desc", configTemplate.ConfigTemplateDesc) + } + + // if configTemplate.ProgramIdList != nil { + // _ = d.Set("program_id_list", configTemplate.ProgramIdList) + // } + + if configTemplate.CreateTime != nil { + _ = d.Set("create_time", configTemplate.CreateTime) + } + + if configTemplate.UpdateTime != nil { + _ = d.Set("update_time", configTemplate.UpdateTime) + } + + if configTemplate.ConfigTemplateId != nil { + _ = d.Set("config_template_id", configTemplate.ConfigTemplateId) + } + + return nil +} + +func resourceTencentCloudTsfConfigTemplateUpdate(d *schema.ResourceData, meta interface{}) error { + defer logElapsed("resource.tencentcloud_tsf_config_template.update")() + defer inconsistentCheck(d, meta)() + + logId := getLogId(contextNil) + + request := tsf.NewUpdateConfigTemplateRequest() + + templateId := d.Id() + + request.ConfigTemplateId = &templateId + + immutableArgs := []string{"config_template_name", "config_template_type", "config_template_value", "config_template_desc", "program_id_list", "create_time", "update_time", "config_template_id"} + + for _, v := range immutableArgs { + if d.HasChange(v) { + return fmt.Errorf("argument `%s` cannot be changed", v) + } + } + + if d.HasChange("config_template_name") { + if v, ok := d.GetOk("config_template_name"); ok { + request.ConfigTemplateName = helper.String(v.(string)) + } + } + + if d.HasChange("config_template_type") { + if v, ok := d.GetOk("config_template_type"); ok { + request.ConfigTemplateType = helper.String(v.(string)) + } + } + + if d.HasChange("config_template_value") { + if v, ok := d.GetOk("config_template_value"); ok { + request.ConfigTemplateValue = helper.String(v.(string)) + } + } + + if d.HasChange("config_template_desc") { + if v, ok := d.GetOk("config_template_desc"); ok { + request.ConfigTemplateDesc = helper.String(v.(string)) + } + } + + err := resource.Retry(writeRetryTimeout, func() *resource.RetryError { + result, e := meta.(*TencentCloudClient).apiV3Conn.UseTsfClient().UpdateConfigTemplate(request) + if e != nil { + return 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 update tsf configTemplate failed, reason:%+v", logId, err) + return err + } + + return resourceTencentCloudTsfConfigTemplateRead(d, meta) +} + +func resourceTencentCloudTsfConfigTemplateDelete(d *schema.ResourceData, meta interface{}) error { + defer logElapsed("resource.tencentcloud_tsf_config_template.delete")() + defer inconsistentCheck(d, meta)() + + logId := getLogId(contextNil) + ctx := context.WithValue(context.TODO(), logIdKey, logId) + + service := TsfService{client: meta.(*TencentCloudClient).apiV3Conn} + templateId := d.Id() + + if err := service.DeleteTsfConfigTemplateById(ctx, templateId); err != nil { + return err + } + + return nil +} diff --git a/tencentcloud/resource_tc_tsf_config_template_test.go b/tencentcloud/resource_tc_tsf_config_template_test.go new file mode 100644 index 0000000000..4b1b63a66e --- /dev/null +++ b/tencentcloud/resource_tc_tsf_config_template_test.go @@ -0,0 +1,39 @@ +package tencentcloud + +import ( + "github.com/hashicorp/terraform-plugin-sdk/helper/resource" + "testing" +) + +func TestAccTencentCloudTsfConfigTemplateResource_basic(t *testing.T) { + t.Parallel() + resource.Test(t, resource.TestCase{ + PreCheck: func() { + testAccPreCheck(t) + }, + Providers: testAccProviders, + Steps: []resource.TestStep{ + { + Config: testAccTsfConfigTemplate, + Check: resource.ComposeTestCheckFunc(resource.TestCheckResourceAttrSet("tencentcloud_tsf_config_template.config_template", "id")), + }, + { + ResourceName: "tencentcloud_tsf_config_template.config_template", + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + +const testAccTsfConfigTemplate = ` + +resource "tencentcloud_tsf_config_template" "config_template" { + config_template_name = "" + config_template_type = "" + config_template_value = "" + config_template_desc = "" + program_id_list = + } + +` diff --git a/tencentcloud/resource_tc_tsf_contain_group.go b/tencentcloud/resource_tc_tsf_contain_group.go new file mode 100644 index 0000000000..fb6065ce73 --- /dev/null +++ b/tencentcloud/resource_tc_tsf_contain_group.go @@ -0,0 +1,1183 @@ +/* +Provides a resource to create a tsf contain_group + +Example Usage + +```hcl +resource "tencentcloud_tsf_contain_group" "contain_group" { + application_id = "" + namespace_id = "" + group_name = "" + instance_num = + access_type = + protocol_ports { + protocol = "" + port = + target_port = + node_port = + + } + cluster_id = "" + cpu_limit = "" + mem_limit = "" + group_comment = "" + update_type = + update_ivl = + cpu_request = "" + mem_request = "" + group_resource_type = "" + subnet_id = "" + agent_cpu_request = "" + agent_cpu_limit = "" + agent_mem_request = "" + agent_mem_limit = "" + istio_cpu_request = "" + istio_cpu_limit = "" + istio_mem_request = "" + istio_mem_limit = "" +} +``` + +Import + +tsf contain_group can be imported using the id, e.g. + +``` +terraform import tencentcloud_tsf_contain_group.contain_group contain_group_id +``` +*/ +package tencentcloud + +import ( + "context" + "fmt" + "log" + + "github.com/hashicorp/terraform-plugin-sdk/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + tsf "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tsf/v20180326" + "github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/internal/helper" +) + +func resourceTencentCloudTsfContainGroup() *schema.Resource { + return &schema.Resource{ + Create: resourceTencentCloudTsfContainGroupCreate, + Read: resourceTencentCloudTsfContainGroupRead, + Update: resourceTencentCloudTsfContainGroupUpdate, + Delete: resourceTencentCloudTsfContainGroupDelete, + Importer: &schema.ResourceImporter{ + State: schema.ImportStatePassthrough, + }, + Schema: map[string]*schema.Schema{ + "application_id": { + Required: true, + Type: schema.TypeString, + Description: "The application ID to which the group belongs.", + }, + + "namespace_id": { + Required: true, + Type: schema.TypeString, + Description: "ID of the namespace to which the group belongs.", + }, + + "group_name": { + Required: true, + Type: schema.TypeString, + Description: "Group name field, length 1~60, beginning with a letter or underscore, can contain alphanumeric underscore.", + }, + + "instance_num": { + Required: true, + Type: schema.TypeInt, + Description: "number of instances.", + }, + + "access_type": { + Required: true, + Type: schema.TypeInt, + Description: "0: public network 1: access within the cluster 2: NodePort.", + }, + + "protocol_ports": { + Required: true, + Type: schema.TypeList, + Description: "Protocol Ports array.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "protocol": { + Type: schema.TypeString, + Required: true, + Description: "TCP UDP.", + }, + "port": { + Type: schema.TypeInt, + Required: true, + Description: "service port.", + }, + "target_port": { + Type: schema.TypeInt, + Required: true, + Description: "container port.", + }, + "node_port": { + Type: schema.TypeInt, + Optional: true, + Computed: true, + Description: "host port.", + }, + }, + }, + }, + + "cluster_id": { + Required: true, + Type: schema.TypeString, + Description: "Cluster ID.", + }, + + "cpu_limit": { + Optional: true, + Type: schema.TypeString, + Description: "The maximum number of allocated CPU cores, corresponding to the K8S limit.", + }, + + "mem_limit": { + Optional: true, + Type: schema.TypeString, + Description: "Maximum allocated memory MiB, corresponding to K8S limit.", + }, + + "group_comment": { + Optional: true, + Type: schema.TypeString, + Description: "Group remarks field, the length should not exceed 200 characters.", + }, + + "update_type": { + Optional: true, + Computed: true, + Type: schema.TypeInt, + Description: "Update method: 0: fast update 1: rolling update.", + }, + + "update_ivl": { + Optional: true, + Computed: true, + Type: schema.TypeInt, + Description: "Rolling update is required, update interval.", + }, + + "cpu_request": { + Optional: true, + Type: schema.TypeString, + Description: "Initially allocated CPU cores, corresponding to K8S request.", + }, + + "mem_request": { + Optional: true, + Type: schema.TypeString, + Description: "Initially allocated memory MiB, corresponding to K8S request.", + }, + + "group_resource_type": { + Optional: true, + Computed: true, + Type: schema.TypeString, + Description: "Deployment Group Resource Type.", + }, + + "subnet_id": { + Optional: true, + Computed: true, + Type: schema.TypeString, + Description: "subnet ID.", + }, + + "agent_cpu_request": { + Optional: true, + Type: schema.TypeString, + Description: "The number of CPU cores allocated by the agent container, corresponding to the K8S request.", + }, + + "agent_cpu_limit": { + Optional: true, + Type: schema.TypeString, + Description: "The maximum number of CPU cores for the agent container, corresponding to the limit of K8S.", + }, + + "agent_mem_request": { + Optional: true, + Type: schema.TypeString, + Description: "The number of memory MiB allocated by the agent container, corresponding to the K8S request.", + }, + + "agent_mem_limit": { + Optional: true, + Type: schema.TypeString, + Description: "The maximum memory MiB of the agent container, corresponding to the limit of K8S.", + }, + + "istio_cpu_request": { + Optional: true, + Computed: true, + Type: schema.TypeString, + Description: "The number of CPU cores allocated by the istioproxy container, corresponding to the K8S request.", + }, + + "istio_cpu_limit": { + Optional: true, + Computed: true, + Type: schema.TypeString, + Description: "The maximum number of CPU cores for the istioproxy container corresponds to the limit of K8S.", + }, + + "istio_mem_request": { + Optional: true, + Computed: true, + Type: schema.TypeString, + Description: "The number of memory MiB allocated by the istioproxy container, corresponding to the K8S request.", + }, + + "istio_mem_limit": { + Optional: true, + Computed: true, + Type: schema.TypeString, + Description: "The maximum memory MiB of the istioproxy container corresponds to the limit of K8S.", + }, + + "group_id": { + Computed: true, + Type: schema.TypeString, + Description: "Deployment group ID.", + }, + + "current_num": { + Computed: true, + Type: schema.TypeInt, + Description: "Total number of instances launched.", + }, + + "create_time": { + Computed: true, + Type: schema.TypeString, + Description: "creation time.", + }, + + "server": { + Computed: true, + Type: schema.TypeString, + Description: "mirror server.", + }, + + "reponame": { + Computed: true, + Type: schema.TypeString, + Description: "Mirror name, such as /tsf/nginx.", + }, + + "tag_name": { + Computed: true, + Type: schema.TypeString, + Description: "Image version name.", + }, + + "cluster_name": { + Computed: true, + Type: schema.TypeString, + Description: "cluster name.", + }, + + "namespace_name": { + Computed: true, + Type: schema.TypeString, + Description: "namespace name.", + }, + + "lb_ip": { + Computed: true, + Type: schema.TypeString, + Description: "load balancing ip.", + }, + + "application_type": { + Computed: true, + Type: schema.TypeString, + Description: "App types.", + }, + + "cluster_ip": { + Computed: true, + Type: schema.TypeString, + Description: "Service ip.", + }, + + "envs": { + Computed: true, + Type: schema.TypeList, + Description: "environment variable array object.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Computed: true, + Description: "environment variable name.", + }, + "value": { + Type: schema.TypeString, + Computed: true, + Description: "environment variable value.", + }, + "value_from": { + Type: schema.TypeList, + Computed: true, + Description: "k8s ValueFrom.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "field_ref": { + Type: schema.TypeList, + Computed: true, + Description: "FieldRef for k8s env.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "field_path": { + Type: schema.TypeString, + Computed: true, + Description: "FieldPath of k8s.", + }, + }, + }, + }, + "resource_field_ref": { + Type: schema.TypeList, + Computed: true, + Description: "ResourceFieldRef of k8s env.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "resource": { + Type: schema.TypeString, + Computed: true, + Description: "Resource of k8s.", + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + + "application_name": { + Computed: true, + Type: schema.TypeString, + Description: "Application Name.", + }, + + "message": { + Computed: true, + Type: schema.TypeString, + Description: "pod error message description.", + }, + + "status": { + Computed: true, + Type: schema.TypeString, + Description: "Deployment group status.", + }, + + "microservice_type": { + Computed: true, + Type: schema.TypeString, + Description: "Service type.", + }, + + "instance_count": { + Computed: true, + Type: schema.TypeInt, + Description: "Number of deployment group instances.", + }, + + "updated_time": { + Computed: true, + Type: schema.TypeInt, + Description: "Deployment group update timestamp.", + }, + + "max_surge": { + Computed: true, + Type: schema.TypeString, + Description: "The MaxSurge parameter of the kubernetes rolling update policy.", + }, + + "max_unavailable": { + Computed: true, + Type: schema.TypeString, + Description: "The MaxUnavailable parameter of the kubernetes rolling update policy.", + }, + + "health_check_settings": { + Computed: true, + Type: schema.TypeList, + Description: "Deployment group health check settings.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "liveness_probe": { + Type: schema.TypeList, + Computed: true, + Description: "live health check.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "action_type": { + Type: schema.TypeString, + Computed: true, + Description: "health check method. HTTP: check by HTTP interface; CMD: check by executing command; TCP: check by establishing TCP connection.", + }, + "initial_delay_seconds": { + Type: schema.TypeInt, + Computed: true, + Description: "The time for the container to delay starting the health check.", + }, + "timeout_seconds": { + Type: schema.TypeInt, + Computed: true, + Description: "Maximum timeout for each health check response.", + }, + "period_seconds": { + Type: schema.TypeInt, + Computed: true, + Description: "Interval between health checks.", + }, + "success_threshold": { + Type: schema.TypeInt, + Computed: true, + Description: "Indicates the number of consecutive health check successes for the backend container from failure to success.", + }, + "failure_threshold": { + Type: schema.TypeInt, + Computed: true, + Description: "Indicates the number of consecutive health check successes of the backend container from success to failure.", + }, + "scheme": { + Type: schema.TypeString, + Computed: true, + Description: "The inspection protocol used by the HTTP health check method. HTTP and HTTPS are supported.", + }, + "port": { + Type: schema.TypeInt, + Computed: true, + Description: "Health check port, range 1~65535.", + }, + "path": { + Type: schema.TypeString, + Computed: true, + Description: "The request path of the HTTP health check interface.", + }, + "command": { + Type: schema.TypeSet, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + Computed: true, + Description: "Execute command check mode, the command to execute.", + }, + "type": { + Type: schema.TypeString, + Computed: true, + Description: "TSF_DEFAULT: tsf default readiness probe. K8S_NATIVE: k8s native probe. If not filled, it defaults to k8s native probe.", + }, + }, + }, + }, + "readiness_probe": { + Type: schema.TypeList, + Computed: true, + Description: "readiness health check.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "action_type": { + Type: schema.TypeString, + Computed: true, + Description: "health check method. HTTP: check by HTTP interface; CMD: check by executing command; TCP: check by establishing TCP connection.", + }, + "initial_delay_seconds": { + Type: schema.TypeInt, + Computed: true, + Description: "The time for the container to delay starting the health check.", + }, + "timeout_seconds": { + Type: schema.TypeInt, + Computed: true, + Description: "The maximum timeout for each health check response.", + }, + "period_seconds": { + Type: schema.TypeInt, + Computed: true, + Description: "The interval at which health checks are performed.", + }, + "success_threshold": { + Type: schema.TypeInt, + Computed: true, + Description: "Indicates the number of consecutive health check successes for the backend container from failure to success.", + }, + "failure_threshold": { + Type: schema.TypeInt, + Computed: true, + Description: "Indicates the number of consecutive health check successes for the backend container from success to failure.", + }, + "scheme": { + Type: schema.TypeString, + Computed: true, + Description: "The inspection protocol used by the HTTP health check method. HTTP and HTTPS are supported.", + }, + "port": { + Type: schema.TypeInt, + Computed: true, + Description: "Health check port, range 1~65535.", + }, + "path": { + Type: schema.TypeString, + Computed: true, + Description: "The request path of the HTTP health check interface.", + }, + "command": { + Type: schema.TypeSet, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + Computed: true, + Description: "Execute command check mode, the command to execute.", + }, + "type": { + Type: schema.TypeString, + Computed: true, + Description: "TSF_DEFAULT: tsf default readiness probe. K8S_NATIVE: k8s native probe. If not filled, it defaults to k8s native probe.", + }, + }, + }, + }, + }, + }, + }, + }, + } +} + +func resourceTencentCloudTsfContainGroupCreate(d *schema.ResourceData, meta interface{}) error { + defer logElapsed("resource.tencentcloud_tsf_contain_group.create")() + defer inconsistentCheck(d, meta)() + + logId := getLogId(contextNil) + + var ( + request = tsf.NewCreateContainGroupRequest() + response = tsf.NewCreateContainGroupResponse() + groupId string + ) + if v, ok := d.GetOk("application_id"); ok { + request.ApplicationId = helper.String(v.(string)) + } + + if v, ok := d.GetOk("namespace_id"); ok { + request.NamespaceId = helper.String(v.(string)) + } + + if v, ok := d.GetOk("group_name"); ok { + request.GroupName = helper.String(v.(string)) + } + + if v, _ := d.GetOk("instance_num"); v != nil { + request.InstanceNum = helper.IntInt64(v.(int)) + } + + if v, _ := d.GetOk("access_type"); v != nil { + request.AccessType = helper.IntInt64(v.(int)) + } + + if v, ok := d.GetOk("protocol_ports"); ok { + for _, item := range v.([]interface{}) { + dMap := item.(map[string]interface{}) + protocolPort := tsf.ProtocolPort{} + if v, ok := dMap["protocol"]; ok { + protocolPort.Protocol = helper.String(v.(string)) + } + if v, ok := dMap["port"]; ok { + protocolPort.Port = helper.IntInt64(v.(int)) + } + if v, ok := dMap["target_port"]; ok { + protocolPort.TargetPort = helper.IntInt64(v.(int)) + } + if v, ok := dMap["node_port"]; ok { + protocolPort.NodePort = helper.IntInt64(v.(int)) + } + request.ProtocolPorts = append(request.ProtocolPorts, &protocolPort) + } + } + + if v, ok := d.GetOk("cluster_id"); ok { + request.ClusterId = helper.String(v.(string)) + } + + if v, ok := d.GetOk("cpu_limit"); ok { + request.CpuLimit = helper.String(v.(string)) + } + + if v, ok := d.GetOk("mem_limit"); ok { + request.MemLimit = helper.String(v.(string)) + } + + if v, ok := d.GetOk("group_comment"); ok { + request.GroupComment = helper.String(v.(string)) + } + + if v, _ := d.GetOk("update_type"); v != nil { + request.UpdateType = helper.IntInt64(v.(int)) + } + + if v, _ := d.GetOk("update_ivl"); v != nil { + request.UpdateIvl = helper.IntInt64(v.(int)) + } + + if v, ok := d.GetOk("cpu_request"); ok { + request.CpuRequest = helper.String(v.(string)) + } + + if v, ok := d.GetOk("mem_request"); ok { + request.MemRequest = helper.String(v.(string)) + } + + if v, ok := d.GetOk("group_resource_type"); ok { + request.GroupResourceType = helper.String(v.(string)) + } + + if v, ok := d.GetOk("subnet_id"); ok { + request.SubnetId = helper.String(v.(string)) + } + + if v, ok := d.GetOk("agent_cpu_request"); ok { + request.AgentCpuRequest = helper.String(v.(string)) + } + + if v, ok := d.GetOk("agent_cpu_limit"); ok { + request.AgentCpuLimit = helper.String(v.(string)) + } + + if v, ok := d.GetOk("agent_mem_request"); ok { + request.AgentMemRequest = helper.String(v.(string)) + } + + if v, ok := d.GetOk("agent_mem_limit"); ok { + request.AgentMemLimit = helper.String(v.(string)) + } + + if v, ok := d.GetOk("istio_cpu_request"); ok { + request.IstioCpuRequest = helper.String(v.(string)) + } + + if v, ok := d.GetOk("istio_cpu_limit"); ok { + request.IstioCpuLimit = helper.String(v.(string)) + } + + if v, ok := d.GetOk("istio_mem_request"); ok { + request.IstioMemRequest = helper.String(v.(string)) + } + + if v, ok := d.GetOk("istio_mem_limit"); ok { + request.IstioMemLimit = helper.String(v.(string)) + } + + err := resource.Retry(writeRetryTimeout, func() *resource.RetryError { + result, e := meta.(*TencentCloudClient).apiV3Conn.UseTsfClient().CreateContainGroup(request) + if e != nil { + return retryError(e) + } else { + log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n", logId, request.GetAction(), request.ToJsonString(), result.ToJsonString()) + } + response = result + return nil + }) + if err != nil { + log.Printf("[CRITAL]%s create tsf containGroup failed, reason:%+v", logId, err) + return err + } + + groupId = *response.Response.Result + d.SetId(groupId) + + return resourceTencentCloudTsfContainGroupRead(d, meta) +} + +func resourceTencentCloudTsfContainGroupRead(d *schema.ResourceData, meta interface{}) error { + defer logElapsed("resource.tencentcloud_tsf_contain_group.read")() + defer inconsistentCheck(d, meta)() + + logId := getLogId(contextNil) + + ctx := context.WithValue(context.TODO(), logIdKey, logId) + + service := TsfService{client: meta.(*TencentCloudClient).apiV3Conn} + + groupId := d.Id() + + containGroup, err := service.DescribeTsfContainGroupById(ctx, groupId) + if err != nil { + return err + } + + if containGroup == nil { + d.SetId("") + log.Printf("[WARN]%s resource `TsfContainGroup` [%s] not found, please check if it has been deleted.\n", logId, d.Id()) + return nil + } + + if containGroup.ApplicationId != nil { + _ = d.Set("application_id", containGroup.ApplicationId) + } + + if containGroup.NamespaceId != nil { + _ = d.Set("namespace_id", containGroup.NamespaceId) + } + + if containGroup.GroupName != nil { + _ = d.Set("group_name", containGroup.GroupName) + } + + if containGroup.InstanceNum != nil { + _ = d.Set("instance_num", containGroup.InstanceNum) + } + + if containGroup.AccessType != nil { + _ = d.Set("access_type", containGroup.AccessType) + } + + if containGroup.ProtocolPorts != nil { + protocolPortsList := []interface{}{} + for _, protocolPorts := range containGroup.ProtocolPorts { + protocolPortsMap := map[string]interface{}{} + + if protocolPorts.Protocol != nil { + protocolPortsMap["protocol"] = protocolPorts.Protocol + } + + if protocolPorts.Port != nil { + protocolPortsMap["port"] = protocolPorts.Port + } + + if protocolPorts.TargetPort != nil { + protocolPortsMap["target_port"] = protocolPorts.TargetPort + } + + if protocolPorts.NodePort != nil { + protocolPortsMap["node_port"] = protocolPorts.NodePort + } + + protocolPortsList = append(protocolPortsList, protocolPortsMap) + } + + _ = d.Set("protocol_ports", protocolPortsList) + + } + + if containGroup.ClusterId != nil { + _ = d.Set("cluster_id", containGroup.ClusterId) + } + + if containGroup.CpuLimit != nil { + _ = d.Set("cpu_limit", containGroup.CpuLimit) + } + + if containGroup.MemLimit != nil { + _ = d.Set("mem_limit", containGroup.MemLimit) + } + + // if containGroup.GroupComment != nil { + // _ = d.Set("group_comment", containGroup.GroupComment) + // } + + if containGroup.UpdateType != nil { + _ = d.Set("update_type", containGroup.UpdateType) + } + + if containGroup.UpdateIvl != nil { + _ = d.Set("update_ivl", containGroup.UpdateIvl) + } + + if containGroup.CpuRequest != nil { + _ = d.Set("cpu_request", containGroup.CpuRequest) + } + + if containGroup.MemRequest != nil { + _ = d.Set("mem_request", containGroup.MemRequest) + } + + if containGroup.GroupResourceType != nil { + _ = d.Set("group_resource_type", containGroup.GroupResourceType) + } + + if containGroup.SubnetId != nil { + _ = d.Set("subnet_id", containGroup.SubnetId) + } + + // if containGroup.AgentCpuRequest != nil { + // _ = d.Set("agent_cpu_request", containGroup.AgentCpuRequest) + // } + + // if containGroup.AgentCpuLimit != nil { + // _ = d.Set("agent_cpu_limit", containGroup.AgentCpuLimit) + // } + + // if containGroup.AgentMemRequest != nil { + // _ = d.Set("agent_mem_request", containGroup.AgentMemRequest) + // } + + // if containGroup.AgentMemLimit != nil { + // _ = d.Set("agent_mem_limit", containGroup.AgentMemLimit) + // } + + // if containGroup.IstioCpuRequest != nil { + // _ = d.Set("istio_cpu_request", containGroup.IstioCpuRequest) + // } + + // if containGroup.IstioCpuLimit != nil { + // _ = d.Set("istio_cpu_limit", containGroup.IstioCpuLimit) + // } + + // if containGroup.IstioMemRequest != nil { + // _ = d.Set("istio_mem_request", containGroup.IstioMemRequest) + // } + + // if containGroup.IstioMemLimit != nil { + // _ = d.Set("istio_mem_limit", containGroup.IstioMemLimit) + // } + + if containGroup.GroupId != nil { + _ = d.Set("group_id", containGroup.GroupId) + } + + if containGroup.CurrentNum != nil { + _ = d.Set("current_num", containGroup.CurrentNum) + } + + if containGroup.CreateTime != nil { + _ = d.Set("create_time", containGroup.CreateTime) + } + + if containGroup.Server != nil { + _ = d.Set("server", containGroup.Server) + } + + if containGroup.Reponame != nil { + _ = d.Set("reponame", containGroup.Reponame) + } + + if containGroup.TagName != nil { + _ = d.Set("tag_name", containGroup.TagName) + } + + if containGroup.ClusterName != nil { + _ = d.Set("cluster_name", containGroup.ClusterName) + } + + if containGroup.NamespaceName != nil { + _ = d.Set("namespace_name", containGroup.NamespaceName) + } + + if containGroup.LbIp != nil { + _ = d.Set("lb_ip", containGroup.LbIp) + } + + if containGroup.ApplicationType != nil { + _ = d.Set("application_type", containGroup.ApplicationType) + } + + if containGroup.ClusterIp != nil { + _ = d.Set("cluster_ip", containGroup.ClusterIp) + } + + if containGroup.Envs != nil { + envsList := []interface{}{} + for _, envs := range containGroup.Envs { + envsMap := map[string]interface{}{} + + if envs.Name != nil { + envsMap["name"] = envs.Name + } + + if envs.Value != nil { + envsMap["value"] = envs.Value + } + + if envs.ValueFrom != nil { + valueFromMap := map[string]interface{}{} + + if envs.ValueFrom.FieldRef != nil { + fieldRefMap := map[string]interface{}{} + + if envs.ValueFrom.FieldRef.FieldPath != nil { + fieldRefMap["field_path"] = envs.ValueFrom.FieldRef.FieldPath + } + + valueFromMap["field_ref"] = []interface{}{fieldRefMap} + } + + if envs.ValueFrom.ResourceFieldRef != nil { + resourceFieldRefMap := map[string]interface{}{} + + if envs.ValueFrom.ResourceFieldRef.Resource != nil { + resourceFieldRefMap["resource"] = envs.ValueFrom.ResourceFieldRef.Resource + } + + valueFromMap["resource_field_ref"] = []interface{}{resourceFieldRefMap} + } + + envsMap["value_from"] = []interface{}{valueFromMap} + } + + envsList = append(envsList, envsMap) + } + + _ = d.Set("envs", envsList) + + } + + if containGroup.ApplicationName != nil { + _ = d.Set("application_name", containGroup.ApplicationName) + } + + if containGroup.Message != nil { + _ = d.Set("message", containGroup.Message) + } + + if containGroup.Status != nil { + _ = d.Set("status", containGroup.Status) + } + + if containGroup.MicroserviceType != nil { + _ = d.Set("microservice_type", containGroup.MicroserviceType) + } + + if containGroup.InstanceCount != nil { + _ = d.Set("instance_count", containGroup.InstanceCount) + } + + if containGroup.UpdatedTime != nil { + _ = d.Set("updated_time", containGroup.UpdatedTime) + } + + if containGroup.MaxSurge != nil { + _ = d.Set("max_surge", containGroup.MaxSurge) + } + + if containGroup.MaxUnavailable != nil { + _ = d.Set("max_unavailable", containGroup.MaxUnavailable) + } + + if containGroup.HealthCheckSettings != nil { + healthCheckSettingsMap := map[string]interface{}{} + + if containGroup.HealthCheckSettings.LivenessProbe != nil { + livenessProbeMap := map[string]interface{}{} + + if containGroup.HealthCheckSettings.LivenessProbe.ActionType != nil { + livenessProbeMap["action_type"] = containGroup.HealthCheckSettings.LivenessProbe.ActionType + } + + if containGroup.HealthCheckSettings.LivenessProbe.InitialDelaySeconds != nil { + livenessProbeMap["initial_delay_seconds"] = containGroup.HealthCheckSettings.LivenessProbe.InitialDelaySeconds + } + + if containGroup.HealthCheckSettings.LivenessProbe.TimeoutSeconds != nil { + livenessProbeMap["timeout_seconds"] = containGroup.HealthCheckSettings.LivenessProbe.TimeoutSeconds + } + + if containGroup.HealthCheckSettings.LivenessProbe.PeriodSeconds != nil { + livenessProbeMap["period_seconds"] = containGroup.HealthCheckSettings.LivenessProbe.PeriodSeconds + } + + if containGroup.HealthCheckSettings.LivenessProbe.SuccessThreshold != nil { + livenessProbeMap["success_threshold"] = containGroup.HealthCheckSettings.LivenessProbe.SuccessThreshold + } + + if containGroup.HealthCheckSettings.LivenessProbe.FailureThreshold != nil { + livenessProbeMap["failure_threshold"] = containGroup.HealthCheckSettings.LivenessProbe.FailureThreshold + } + + if containGroup.HealthCheckSettings.LivenessProbe.Scheme != nil { + livenessProbeMap["scheme"] = containGroup.HealthCheckSettings.LivenessProbe.Scheme + } + + if containGroup.HealthCheckSettings.LivenessProbe.Port != nil { + livenessProbeMap["port"] = containGroup.HealthCheckSettings.LivenessProbe.Port + } + + if containGroup.HealthCheckSettings.LivenessProbe.Path != nil { + livenessProbeMap["path"] = containGroup.HealthCheckSettings.LivenessProbe.Path + } + + if containGroup.HealthCheckSettings.LivenessProbe.Command != nil { + livenessProbeMap["command"] = containGroup.HealthCheckSettings.LivenessProbe.Command + } + + if containGroup.HealthCheckSettings.LivenessProbe.Type != nil { + livenessProbeMap["type"] = containGroup.HealthCheckSettings.LivenessProbe.Type + } + + healthCheckSettingsMap["liveness_probe"] = []interface{}{livenessProbeMap} + } + + if containGroup.HealthCheckSettings.ReadinessProbe != nil { + readinessProbeMap := map[string]interface{}{} + + if containGroup.HealthCheckSettings.ReadinessProbe.ActionType != nil { + readinessProbeMap["action_type"] = containGroup.HealthCheckSettings.ReadinessProbe.ActionType + } + + if containGroup.HealthCheckSettings.ReadinessProbe.InitialDelaySeconds != nil { + readinessProbeMap["initial_delay_seconds"] = containGroup.HealthCheckSettings.ReadinessProbe.InitialDelaySeconds + } + + if containGroup.HealthCheckSettings.ReadinessProbe.TimeoutSeconds != nil { + readinessProbeMap["timeout_seconds"] = containGroup.HealthCheckSettings.ReadinessProbe.TimeoutSeconds + } + + if containGroup.HealthCheckSettings.ReadinessProbe.PeriodSeconds != nil { + readinessProbeMap["period_seconds"] = containGroup.HealthCheckSettings.ReadinessProbe.PeriodSeconds + } + + if containGroup.HealthCheckSettings.ReadinessProbe.SuccessThreshold != nil { + readinessProbeMap["success_threshold"] = containGroup.HealthCheckSettings.ReadinessProbe.SuccessThreshold + } + + if containGroup.HealthCheckSettings.ReadinessProbe.FailureThreshold != nil { + readinessProbeMap["failure_threshold"] = containGroup.HealthCheckSettings.ReadinessProbe.FailureThreshold + } + + if containGroup.HealthCheckSettings.ReadinessProbe.Scheme != nil { + readinessProbeMap["scheme"] = containGroup.HealthCheckSettings.ReadinessProbe.Scheme + } + + if containGroup.HealthCheckSettings.ReadinessProbe.Port != nil { + readinessProbeMap["port"] = containGroup.HealthCheckSettings.ReadinessProbe.Port + } + + if containGroup.HealthCheckSettings.ReadinessProbe.Path != nil { + readinessProbeMap["path"] = containGroup.HealthCheckSettings.ReadinessProbe.Path + } + + if containGroup.HealthCheckSettings.ReadinessProbe.Command != nil { + readinessProbeMap["command"] = containGroup.HealthCheckSettings.ReadinessProbe.Command + } + + if containGroup.HealthCheckSettings.ReadinessProbe.Type != nil { + readinessProbeMap["type"] = containGroup.HealthCheckSettings.ReadinessProbe.Type + } + + healthCheckSettingsMap["readiness_probe"] = []interface{}{readinessProbeMap} + } + + _ = d.Set("health_check_settings", []interface{}{healthCheckSettingsMap}) + } + + return nil +} + +func resourceTencentCloudTsfContainGroupUpdate(d *schema.ResourceData, meta interface{}) error { + defer logElapsed("resource.tencentcloud_tsf_contain_group.update")() + defer inconsistentCheck(d, meta)() + + logId := getLogId(contextNil) + + request := tsf.NewModifyContainerGroupRequest() + + groupId := d.Id() + + request.GroupId = &groupId + + immutableArgs := []string{"application_id", "namespace_id", "group_name", "instance_num", "access_type", "protocol_ports", "cluster_id", "cpu_limit", "mem_limit", "group_comment", "update_type", "update_ivl", "cpu_request", "mem_request", "group_resource_type", "subnet_id", "agent_cpu_request", "agent_cpu_limit", "agent_mem_request", "agent_mem_limit", "istio_cpu_request", "istio_cpu_limit", "istio_mem_request", "istio_mem_limit", "group_id", "current_num", "create_time", "server", "reponame", "tag_name", "cluster_name", "namespace_name", "lb_ip", "application_type", "cluster_ip", "envs", "application_name", "message", "status", "microservice_type", "instance_count", "updated_time", "max_surge", "max_unavailable", "health_check_settings"} + + for _, v := range immutableArgs { + if d.HasChange(v) { + return fmt.Errorf("argument `%s` cannot be changed", v) + } + } + + if d.HasChange("access_type") { + if v, _ := d.GetOk("access_type"); v != nil { + request.AccessType = helper.IntInt64(v.(int)) + } + } + + if d.HasChange("protocol_ports") { + if v, ok := d.GetOk("protocol_ports"); ok { + for _, item := range v.([]interface{}) { + dMap := item.(map[string]interface{}) + protocolPort := tsf.ProtocolPort{} + if v, ok := dMap["protocol"]; ok { + protocolPort.Protocol = helper.String(v.(string)) + } + if v, ok := dMap["port"]; ok { + protocolPort.Port = helper.IntInt64(v.(int)) + } + if v, ok := dMap["target_port"]; ok { + protocolPort.TargetPort = helper.IntInt64(v.(int)) + } + if v, ok := dMap["node_port"]; ok { + protocolPort.NodePort = helper.IntInt64(v.(int)) + } + request.ProtocolPorts = append(request.ProtocolPorts, &protocolPort) + } + } + } + + if d.HasChange("update_type") { + if v, _ := d.GetOk("update_type"); v != nil { + request.UpdateType = helper.IntInt64(v.(int)) + } + } + + if d.HasChange("update_ivl") { + if v, _ := d.GetOk("update_ivl"); v != nil { + request.UpdateIvl = helper.IntInt64(v.(int)) + } + } + + if d.HasChange("subnet_id") { + if v, ok := d.GetOk("subnet_id"); ok { + request.SubnetId = helper.String(v.(string)) + } + } + + err := resource.Retry(writeRetryTimeout, func() *resource.RetryError { + result, e := meta.(*TencentCloudClient).apiV3Conn.UseTsfClient().ModifyContainerGroup(request) + if e != nil { + return 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 update tsf containGroup failed, reason:%+v", logId, err) + return err + } + + return resourceTencentCloudTsfContainGroupRead(d, meta) +} + +func resourceTencentCloudTsfContainGroupDelete(d *schema.ResourceData, meta interface{}) error { + defer logElapsed("resource.tencentcloud_tsf_contain_group.delete")() + defer inconsistentCheck(d, meta)() + + logId := getLogId(contextNil) + ctx := context.WithValue(context.TODO(), logIdKey, logId) + + service := TsfService{client: meta.(*TencentCloudClient).apiV3Conn} + groupId := d.Id() + + if err := service.DeleteTsfContainGroupById(ctx, groupId); err != nil { + return err + } + + return nil +} diff --git a/tencentcloud/resource_tc_tsf_contain_group_test.go b/tencentcloud/resource_tc_tsf_contain_group_test.go new file mode 100644 index 0000000000..ab7df17e73 --- /dev/null +++ b/tencentcloud/resource_tc_tsf_contain_group_test.go @@ -0,0 +1,64 @@ +package tencentcloud + +import ( + "github.com/hashicorp/terraform-plugin-sdk/helper/resource" + "testing" +) + +func TestAccTencentCloudTsfContainGroupResource_basic(t *testing.T) { + t.Parallel() + resource.Test(t, resource.TestCase{ + PreCheck: func() { + testAccPreCheck(t) + }, + Providers: testAccProviders, + Steps: []resource.TestStep{ + { + Config: testAccTsfContainGroup, + Check: resource.ComposeTestCheckFunc(resource.TestCheckResourceAttrSet("tencentcloud_tsf_contain_group.contain_group", "id")), + }, + { + ResourceName: "tencentcloud_tsf_contain_group.contain_group", + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + +const testAccTsfContainGroup = ` + +resource "tencentcloud_tsf_contain_group" "contain_group" { + application_id = "" + namespace_id = "" + group_name = "" + instance_num = + access_type = + protocol_ports { + protocol = "" + port = + target_port = + node_port = + + } + cluster_id = "" + cpu_limit = "" + mem_limit = "" + group_comment = "" + update_type = + update_ivl = + cpu_request = "" + mem_request = "" + group_resource_type = "" + subnet_id = "" + agent_cpu_request = "" + agent_cpu_limit = "" + agent_mem_request = "" + agent_mem_limit = "" + istio_cpu_request = "" + istio_cpu_limit = "" + istio_mem_request = "" + istio_mem_limit = "" + } + +` diff --git a/tencentcloud/resource_tc_tsf_lane.go b/tencentcloud/resource_tc_tsf_lane.go new file mode 100644 index 0000000000..f2923bc04e --- /dev/null +++ b/tencentcloud/resource_tc_tsf_lane.go @@ -0,0 +1,455 @@ +/* +Provides a resource to create a tsf lane + +Example Usage + +```hcl +resource "tencentcloud_tsf_lane" "lane" { + lane_name = "" + remark = "" + lane_group_list { + group_id = "" + entrance = + lane_group_id = "" + lane_id = "" + group_name = "" + application_id = "" + application_name = "" + namespace_id = "" + namespace_name = "" + create_time = + update_time = + cluster_type = "" + } + program_id_list = +} +``` + +Import + +tsf lane can be imported using the id, e.g. + +``` +terraform import tencentcloud_tsf_lane.lane lane_id +``` +*/ +package tencentcloud + +import ( + "context" + "fmt" + "log" + + "github.com/hashicorp/terraform-plugin-sdk/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + tsf "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tsf/v20180326" + "github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/internal/helper" +) + +func resourceTencentCloudTsfLane() *schema.Resource { + return &schema.Resource{ + Create: resourceTencentCloudTsfLaneCreate, + Read: resourceTencentCloudTsfLaneRead, + Update: resourceTencentCloudTsfLaneUpdate, + Delete: resourceTencentCloudTsfLaneDelete, + Importer: &schema.ResourceImporter{ + State: schema.ImportStatePassthrough, + }, + Schema: map[string]*schema.Schema{ + "lane_id": { + Type: schema.TypeString, + Computed: true, + Description: "Lane id.", + }, + + "lane_name": { + Required: true, + Type: schema.TypeString, + Description: "Lane name.", + }, + + "remark": { + Required: true, + Type: schema.TypeString, + Description: "Lane Remarks.", + }, + + "create_time": { + Type: schema.TypeInt, + Computed: true, + Description: "creation time.", + }, + "update_time": { + Type: schema.TypeInt, + Computed: true, + Description: "update time.", + }, + + "lane_group_list": { + Required: true, + Type: schema.TypeList, + Description: "Swimlane Deployment Group Information.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "group_id": { + Type: schema.TypeString, + Required: true, + Description: "Deployment group ID.", + }, + "entrance": { + Type: schema.TypeBool, + Required: true, + Description: "Whether to enter the application.", + }, + "lane_group_id": { + Type: schema.TypeString, + Optional: true, + Description: "Swimlane deployment group ID.", + }, + "lane_id": { + Type: schema.TypeString, + Optional: true, + Description: "Lane ID.", + }, + "group_name": { + Type: schema.TypeString, + Optional: true, + Description: "deployment group name.", + }, + "application_id": { + Type: schema.TypeString, + Optional: true, + Description: "application ID.", + }, + "application_name": { + Type: schema.TypeString, + Optional: true, + Description: "application name.", + }, + "namespace_id": { + Type: schema.TypeString, + Optional: true, + Description: "Namespace ID.", + }, + "namespace_name": { + Type: schema.TypeString, + Optional: true, + Description: "namespace name.", + }, + "create_time": { + Type: schema.TypeInt, + Optional: true, + Description: "creation time.", + }, + "update_time": { + Type: schema.TypeInt, + Optional: true, + Description: "update time.", + }, + "cluster_type": { + Type: schema.TypeString, + Optional: true, + Description: "cluster type.", + }, + }, + }, + }, + + "program_id_list": { + Optional: true, + Type: schema.TypeSet, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + Description: "Program id list.", + }, + + "entrance": { + Type: schema.TypeBool, + Computed: true, + Description: "Whether to enter the application.", + }, + "namespace_id_list": { + Type: schema.TypeSet, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + Computed: true, + Description: "A list of namespaces to which the swimlane has associated deployment groups.", + }, + }, + } +} + +func resourceTencentCloudTsfLaneCreate(d *schema.ResourceData, meta interface{}) error { + defer logElapsed("resource.tencentcloud_tsf_lane.create")() + defer inconsistentCheck(d, meta)() + + logId := getLogId(contextNil) + + var ( + request = tsf.NewCreateLaneRequest() + response = tsf.NewCreateLaneResponse() + laneId string + ) + if v, ok := d.GetOk("lane_name"); ok { + request.LaneName = helper.String(v.(string)) + } + + if v, ok := d.GetOk("remark"); ok { + request.Remark = helper.String(v.(string)) + } + + if v, ok := d.GetOk("lane_group_list"); ok { + for _, item := range v.([]interface{}) { + dMap := item.(map[string]interface{}) + laneGroup := tsf.LaneGroup{} + if v, ok := dMap["group_id"]; ok { + laneGroup.GroupId = helper.String(v.(string)) + } + if v, ok := dMap["entrance"]; ok { + laneGroup.Entrance = helper.Bool(v.(bool)) + } + if v, ok := dMap["lane_group_id"]; ok { + laneGroup.LaneGroupId = helper.String(v.(string)) + } + if v, ok := dMap["lane_id"]; ok { + laneGroup.LaneId = helper.String(v.(string)) + } + if v, ok := dMap["group_name"]; ok { + laneGroup.GroupName = helper.String(v.(string)) + } + if v, ok := dMap["application_id"]; ok { + laneGroup.ApplicationId = helper.String(v.(string)) + } + if v, ok := dMap["application_name"]; ok { + laneGroup.ApplicationName = helper.String(v.(string)) + } + if v, ok := dMap["namespace_id"]; ok { + laneGroup.NamespaceId = helper.String(v.(string)) + } + if v, ok := dMap["namespace_name"]; ok { + laneGroup.NamespaceName = helper.String(v.(string)) + } + if v, ok := dMap["create_time"]; ok { + laneGroup.CreateTime = helper.IntInt64(v.(int)) + } + if v, ok := dMap["update_time"]; ok { + laneGroup.UpdateTime = helper.IntInt64(v.(int)) + } + if v, ok := dMap["cluster_type"]; ok { + laneGroup.ClusterType = helper.String(v.(string)) + } + request.LaneGroupList = append(request.LaneGroupList, &laneGroup) + } + } + + if v, ok := d.GetOk("program_id_list"); ok { + programIdListSet := v.(*schema.Set).List() + for i := range programIdListSet { + programIdList := programIdListSet[i].(string) + request.ProgramIdList = append(request.ProgramIdList, &programIdList) + } + } + + err := resource.Retry(writeRetryTimeout, func() *resource.RetryError { + result, e := meta.(*TencentCloudClient).apiV3Conn.UseTsfClient().CreateLane(request) + if e != nil { + return retryError(e) + } else { + log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n", logId, request.GetAction(), request.ToJsonString(), result.ToJsonString()) + } + response = result + return nil + }) + if err != nil { + log.Printf("[CRITAL]%s create tsf lane failed, reason:%+v", logId, err) + return err + } + + laneId = *response.Response.Result + d.SetId(laneId) + + return resourceTencentCloudTsfLaneRead(d, meta) +} + +func resourceTencentCloudTsfLaneRead(d *schema.ResourceData, meta interface{}) error { + defer logElapsed("resource.tencentcloud_tsf_lane.read")() + defer inconsistentCheck(d, meta)() + + logId := getLogId(contextNil) + + ctx := context.WithValue(context.TODO(), logIdKey, logId) + + service := TsfService{client: meta.(*TencentCloudClient).apiV3Conn} + + laneId := d.Id() + + lane, err := service.DescribeTsfLaneById(ctx, laneId) + if err != nil { + return err + } + + if lane == nil { + d.SetId("") + log.Printf("[WARN]%s resource `TsfLane` [%s] not found, please check if it has been deleted.\n", logId, d.Id()) + return nil + } + + _ = d.Set("lane_id", laneId) + + if lane.LaneName != nil { + _ = d.Set("lane_name", lane.LaneName) + } + + if lane.Remark != nil { + _ = d.Set("remark", lane.Remark) + } + + if lane.LaneGroupList != nil { + laneGroupListList := []interface{}{} + for _, laneGroupList := range lane.LaneGroupList { + laneGroupListMap := map[string]interface{}{} + + if laneGroupList.GroupId != nil { + laneGroupListMap["group_id"] = laneGroupList.GroupId + } + + if laneGroupList.Entrance != nil { + laneGroupListMap["entrance"] = laneGroupList.Entrance + } + + if laneGroupList.LaneGroupId != nil { + laneGroupListMap["lane_group_id"] = laneGroupList.LaneGroupId + } + + if laneGroupList.LaneId != nil { + laneGroupListMap["lane_id"] = laneGroupList.LaneId + } + + if laneGroupList.GroupName != nil { + laneGroupListMap["group_name"] = laneGroupList.GroupName + } + + if laneGroupList.ApplicationId != nil { + laneGroupListMap["application_id"] = laneGroupList.ApplicationId + } + + if laneGroupList.ApplicationName != nil { + laneGroupListMap["application_name"] = laneGroupList.ApplicationName + } + + if laneGroupList.NamespaceId != nil { + laneGroupListMap["namespace_id"] = laneGroupList.NamespaceId + } + + if laneGroupList.NamespaceName != nil { + laneGroupListMap["namespace_name"] = laneGroupList.NamespaceName + } + + if laneGroupList.CreateTime != nil { + laneGroupListMap["create_time"] = laneGroupList.CreateTime + } + + if laneGroupList.UpdateTime != nil { + laneGroupListMap["update_time"] = laneGroupList.UpdateTime + } + + if laneGroupList.ClusterType != nil { + laneGroupListMap["cluster_type"] = laneGroupList.ClusterType + } + + laneGroupListList = append(laneGroupListList, laneGroupListMap) + } + + _ = d.Set("lane_group_list", laneGroupListList) + + } + + // if lane.ProgramIdList != nil { + // _ = d.Set("program_id_list", lane.ProgramIdList) + // } + + if lane.CreateTime != nil { + _ = d.Set("create_time", lane.CreateTime) + } + + if lane.UpdateTime != nil { + _ = d.Set("update_time", lane.UpdateTime) + } + if lane.Entrance != nil { + _ = d.Set("entrance", lane.Entrance) + } + + if lane.NamespaceIdList != nil { + _ = d.Set("namespace_id_list", lane.NamespaceIdList) + } + + return nil +} + +func resourceTencentCloudTsfLaneUpdate(d *schema.ResourceData, meta interface{}) error { + defer logElapsed("resource.tencentcloud_tsf_lane.update")() + defer inconsistentCheck(d, meta)() + + logId := getLogId(contextNil) + + request := tsf.NewModifyLaneRequest() + + laneId := d.Id() + + request.LaneId = &laneId + + immutableArgs := []string{"lane_name", "remark", "lane_group_list", "program_id_list", "result"} + + for _, v := range immutableArgs { + if d.HasChange(v) { + return fmt.Errorf("argument `%s` cannot be changed", v) + } + } + + if d.HasChange("lane_name") { + if v, ok := d.GetOk("lane_name"); ok { + request.LaneName = helper.String(v.(string)) + } + } + + if d.HasChange("remark") { + if v, ok := d.GetOk("remark"); ok { + request.Remark = helper.String(v.(string)) + } + } + + err := resource.Retry(writeRetryTimeout, func() *resource.RetryError { + result, e := meta.(*TencentCloudClient).apiV3Conn.UseTsfClient().ModifyLane(request) + if e != nil { + return 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 update tsf lane failed, reason:%+v", logId, err) + return err + } + + return resourceTencentCloudTsfLaneRead(d, meta) +} + +func resourceTencentCloudTsfLaneDelete(d *schema.ResourceData, meta interface{}) error { + defer logElapsed("resource.tencentcloud_tsf_lane.delete")() + defer inconsistentCheck(d, meta)() + + logId := getLogId(contextNil) + ctx := context.WithValue(context.TODO(), logIdKey, logId) + + service := TsfService{client: meta.(*TencentCloudClient).apiV3Conn} + laneId := d.Id() + + if err := service.DeleteTsfLaneById(ctx, laneId); err != nil { + return err + } + + return nil +} diff --git a/tencentcloud/resource_tc_tsf_lane_rule.go b/tencentcloud/resource_tc_tsf_lane_rule.go new file mode 100644 index 0000000000..53157f884a --- /dev/null +++ b/tencentcloud/resource_tc_tsf_lane_rule.go @@ -0,0 +1,465 @@ +/* +Provides a resource to create a tsf lane_rule + +Example Usage + +```hcl +resource "tencentcloud_tsf_lane_rule" "lane_rule" { + rule_name = "" + remark = "" + rule_tag_list { + tag_id = "" + tag_name = "" + tag_operator = "" + tag_value = "" + lane_rule_id = "" + create_time = + update_time = + } + rule_tag_relationship = "" + lane_id = "" + program_id_list = +} +``` + +Import + +tsf lane_rule can be imported using the id, e.g. + +``` +terraform import tencentcloud_tsf_lane_rule.lane_rule lane_rule_id +``` +*/ +package tencentcloud + +import ( + "context" + "fmt" + "log" + + "github.com/hashicorp/terraform-plugin-sdk/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + tsf "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tsf/v20180326" + "github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/internal/helper" +) + +func resourceTencentCloudTsfLaneRule() *schema.Resource { + return &schema.Resource{ + Create: resourceTencentCloudTsfLaneRuleCreate, + Read: resourceTencentCloudTsfLaneRuleRead, + Update: resourceTencentCloudTsfLaneRuleUpdate, + Delete: resourceTencentCloudTsfLaneRuleDelete, + Importer: &schema.ResourceImporter{ + State: schema.ImportStatePassthrough, + }, + Schema: map[string]*schema.Schema{ + "rule_id": { + Computed: true, + Type: schema.TypeString, + Description: "Rule id.", + }, + + "rule_name": { + Required: true, + Type: schema.TypeString, + Description: "lane rule name.", + }, + + "remark": { + Required: true, + Type: schema.TypeString, + Description: "Lane rule notes.", + }, + + "rule_tag_list": { + Required: true, + Type: schema.TypeList, + Description: "list of swimlane rule labels.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "tag_id": { + Type: schema.TypeString, + Required: true, + Description: "label ID.", + }, + "tag_name": { + Type: schema.TypeString, + Required: true, + Description: "label name.", + }, + "tag_operator": { + Type: schema.TypeString, + Required: true, + Description: "label operator.", + }, + "tag_value": { + Type: schema.TypeString, + Required: true, + Description: "tag value.", + }, + "lane_rule_id": { + Type: schema.TypeString, + Required: true, + Description: "lane rule ID.", + }, + "create_time": { + Type: schema.TypeInt, + Required: true, + Description: "creation time.", + }, + "update_time": { + Type: schema.TypeInt, + Required: true, + Description: "update time.", + }, + }, + }, + }, + + "rule_tag_relationship": { + Required: true, + Type: schema.TypeString, + Description: "lane rule label relationship.", + }, + + "lane_id": { + Required: true, + Type: schema.TypeString, + Description: "lane ID.", + }, + + "priority": { + Computed: true, + Type: schema.TypeInt, + Description: "Priority.", + }, + + "enable": { + Computed: true, + Type: schema.TypeBool, + Description: "open state.", + }, + + "create_time": { + Computed: true, + Type: schema.TypeInt, + Description: "creation time.", + }, + + "update_time": { + Computed: true, + Type: schema.TypeInt, + Description: "update time.", + }, + + "program_id_list": { + Optional: true, + Type: schema.TypeSet, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + Description: "Program id list.", + }, + }, + } +} + +func resourceTencentCloudTsfLaneRuleCreate(d *schema.ResourceData, meta interface{}) error { + defer logElapsed("resource.tencentcloud_tsf_lane_rule.create")() + defer inconsistentCheck(d, meta)() + + logId := getLogId(contextNil) + + var ( + request = tsf.NewCreateLaneRuleRequest() + response = tsf.NewCreateLaneRuleResponse() + ruleId string + ) + if v, ok := d.GetOk("rule_name"); ok { + request.RuleName = helper.String(v.(string)) + } + + if v, ok := d.GetOk("remark"); ok { + request.Remark = helper.String(v.(string)) + } + + if v, ok := d.GetOk("rule_tag_list"); ok { + for _, item := range v.([]interface{}) { + dMap := item.(map[string]interface{}) + laneRuleTag := tsf.LaneRuleTag{} + if v, ok := dMap["tag_id"]; ok { + laneRuleTag.TagId = helper.String(v.(string)) + } + if v, ok := dMap["tag_name"]; ok { + laneRuleTag.TagName = helper.String(v.(string)) + } + if v, ok := dMap["tag_operator"]; ok { + laneRuleTag.TagOperator = helper.String(v.(string)) + } + if v, ok := dMap["tag_value"]; ok { + laneRuleTag.TagValue = helper.String(v.(string)) + } + if v, ok := dMap["lane_rule_id"]; ok { + laneRuleTag.LaneRuleId = helper.String(v.(string)) + } + if v, ok := dMap["create_time"]; ok { + laneRuleTag.CreateTime = helper.IntInt64(v.(int)) + } + if v, ok := dMap["update_time"]; ok { + laneRuleTag.UpdateTime = helper.IntInt64(v.(int)) + } + request.RuleTagList = append(request.RuleTagList, &laneRuleTag) + } + } + + if v, ok := d.GetOk("rule_tag_relationship"); ok { + request.RuleTagRelationship = helper.String(v.(string)) + } + + if v, ok := d.GetOk("lane_id"); ok { + request.LaneId = helper.String(v.(string)) + } + + if v, ok := d.GetOk("program_id_list"); ok { + programIdListSet := v.(*schema.Set).List() + for i := range programIdListSet { + programIdList := programIdListSet[i].(string) + request.ProgramIdList = append(request.ProgramIdList, &programIdList) + } + } + + err := resource.Retry(writeRetryTimeout, func() *resource.RetryError { + result, e := meta.(*TencentCloudClient).apiV3Conn.UseTsfClient().CreateLaneRule(request) + if e != nil { + return retryError(e) + } else { + log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n", logId, request.GetAction(), request.ToJsonString(), result.ToJsonString()) + } + response = result + return nil + }) + if err != nil { + log.Printf("[CRITAL]%s create tsf laneRule failed, reason:%+v", logId, err) + return err + } + + ruleId = *response.Response.Result + d.SetId(ruleId) + + return resourceTencentCloudTsfLaneRuleRead(d, meta) +} + +func resourceTencentCloudTsfLaneRuleRead(d *schema.ResourceData, meta interface{}) error { + defer logElapsed("resource.tencentcloud_tsf_lane_rule.read")() + defer inconsistentCheck(d, meta)() + + logId := getLogId(contextNil) + + ctx := context.WithValue(context.TODO(), logIdKey, logId) + + service := TsfService{client: meta.(*TencentCloudClient).apiV3Conn} + + ruleId := d.Id() + + laneRule, err := service.DescribeTsfLaneRuleById(ctx, ruleId) + if err != nil { + return err + } + + if laneRule == nil { + d.SetId("") + log.Printf("[WARN]%s resource `TsfLaneRule` [%s] not found, please check if it has been deleted.\n", logId, d.Id()) + return nil + } + + if laneRule.RuleId != nil { + _ = d.Set("rule_id", laneRule.RuleId) + } + + if laneRule.RuleName != nil { + _ = d.Set("rule_name", laneRule.RuleName) + } + + if laneRule.Remark != nil { + _ = d.Set("remark", laneRule.Remark) + } + + if laneRule.RuleTagList != nil { + ruleTagListList := []interface{}{} + for _, ruleTagList := range laneRule.RuleTagList { + ruleTagListMap := map[string]interface{}{} + + if ruleTagList.TagId != nil { + ruleTagListMap["tag_id"] = ruleTagList.TagId + } + + if ruleTagList.TagName != nil { + ruleTagListMap["tag_name"] = ruleTagList.TagName + } + + if ruleTagList.TagOperator != nil { + ruleTagListMap["tag_operator"] = ruleTagList.TagOperator + } + + if ruleTagList.TagValue != nil { + ruleTagListMap["tag_value"] = ruleTagList.TagValue + } + + if ruleTagList.LaneRuleId != nil { + ruleTagListMap["lane_rule_id"] = ruleTagList.LaneRuleId + } + + if ruleTagList.CreateTime != nil { + ruleTagListMap["create_time"] = ruleTagList.CreateTime + } + + if ruleTagList.UpdateTime != nil { + ruleTagListMap["update_time"] = ruleTagList.UpdateTime + } + + ruleTagListList = append(ruleTagListList, ruleTagListMap) + } + + _ = d.Set("rule_tag_list", ruleTagListList) + + } + + if laneRule.RuleTagRelationship != nil { + _ = d.Set("rule_tag_relationship", laneRule.RuleTagRelationship) + } + + if laneRule.LaneId != nil { + _ = d.Set("lane_id", laneRule.LaneId) + } + + if laneRule.Priority != nil { + _ = d.Set("priority", laneRule.Priority) + } + + if laneRule.Enable != nil { + _ = d.Set("enable", laneRule.Enable) + } + + if laneRule.CreateTime != nil { + _ = d.Set("create_time", laneRule.CreateTime) + } + + if laneRule.UpdateTime != nil { + _ = d.Set("update_time", laneRule.UpdateTime) + } + + // if laneRule.ProgramIdList != nil { + // _ = d.Set("program_id_list", laneRule.ProgramIdList) + // } + + return nil +} + +func resourceTencentCloudTsfLaneRuleUpdate(d *schema.ResourceData, meta interface{}) error { + defer logElapsed("resource.tencentcloud_tsf_lane_rule.update")() + defer inconsistentCheck(d, meta)() + + logId := getLogId(contextNil) + + request := tsf.NewModifyLaneRuleRequest() + + ruleId := d.Id() + + request.RuleId = &ruleId + + immutableArgs := []string{"rule_id", "rule_name", "remark", "rule_tag_list", "rule_tag_relationship", "lane_id", "priority", "enable", "create_time", "update_time", "program_id_list"} + + for _, v := range immutableArgs { + if d.HasChange(v) { + return fmt.Errorf("argument `%s` cannot be changed", v) + } + } + + if d.HasChange("rule_name") { + if v, ok := d.GetOk("rule_name"); ok { + request.RuleName = helper.String(v.(string)) + } + } + + if d.HasChange("remark") { + if v, ok := d.GetOk("remark"); ok { + request.Remark = helper.String(v.(string)) + } + } + + if d.HasChange("rule_tag_list") { + if v, ok := d.GetOk("rule_tag_list"); ok { + for _, item := range v.([]interface{}) { + dMap := item.(map[string]interface{}) + laneRuleTag := tsf.LaneRuleTag{} + if v, ok := dMap["tag_id"]; ok { + laneRuleTag.TagId = helper.String(v.(string)) + } + if v, ok := dMap["tag_name"]; ok { + laneRuleTag.TagName = helper.String(v.(string)) + } + if v, ok := dMap["tag_operator"]; ok { + laneRuleTag.TagOperator = helper.String(v.(string)) + } + if v, ok := dMap["tag_value"]; ok { + laneRuleTag.TagValue = helper.String(v.(string)) + } + if v, ok := dMap["lane_rule_id"]; ok { + laneRuleTag.LaneRuleId = helper.String(v.(string)) + } + if v, ok := dMap["create_time"]; ok { + laneRuleTag.CreateTime = helper.IntInt64(v.(int)) + } + if v, ok := dMap["update_time"]; ok { + laneRuleTag.UpdateTime = helper.IntInt64(v.(int)) + } + request.RuleTagList = append(request.RuleTagList, &laneRuleTag) + } + } + } + + if d.HasChange("rule_tag_relationship") { + if v, ok := d.GetOk("rule_tag_relationship"); ok { + request.RuleTagRelationship = helper.String(v.(string)) + } + } + + if d.HasChange("lane_id") { + if v, ok := d.GetOk("lane_id"); ok { + request.LaneId = helper.String(v.(string)) + } + } + + err := resource.Retry(writeRetryTimeout, func() *resource.RetryError { + result, e := meta.(*TencentCloudClient).apiV3Conn.UseTsfClient().ModifyLaneRule(request) + if e != nil { + return 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 update tsf laneRule failed, reason:%+v", logId, err) + return err + } + + return resourceTencentCloudTsfLaneRuleRead(d, meta) +} + +func resourceTencentCloudTsfLaneRuleDelete(d *schema.ResourceData, meta interface{}) error { + defer logElapsed("resource.tencentcloud_tsf_lane_rule.delete")() + defer inconsistentCheck(d, meta)() + + logId := getLogId(contextNil) + ctx := context.WithValue(context.TODO(), logIdKey, logId) + + service := TsfService{client: meta.(*TencentCloudClient).apiV3Conn} + ruleId := d.Id() + + if err := service.DeleteTsfLaneRuleById(ctx, ruleId); err != nil { + return err + } + + return nil +} diff --git a/tencentcloud/resource_tc_tsf_lane_rule_test.go b/tencentcloud/resource_tc_tsf_lane_rule_test.go new file mode 100644 index 0000000000..0f2bef709c --- /dev/null +++ b/tencentcloud/resource_tc_tsf_lane_rule_test.go @@ -0,0 +1,49 @@ +package tencentcloud + +import ( + "github.com/hashicorp/terraform-plugin-sdk/helper/resource" + "testing" +) + +func TestAccTencentCloudTsfLaneRuleResource_basic(t *testing.T) { + t.Parallel() + resource.Test(t, resource.TestCase{ + PreCheck: func() { + testAccPreCheck(t) + }, + Providers: testAccProviders, + Steps: []resource.TestStep{ + { + Config: testAccTsfLaneRule, + Check: resource.ComposeTestCheckFunc(resource.TestCheckResourceAttrSet("tencentcloud_tsf_lane_rule.lane_rule", "id")), + }, + { + ResourceName: "tencentcloud_tsf_lane_rule.lane_rule", + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + +const testAccTsfLaneRule = ` + +resource "tencentcloud_tsf_lane_rule" "lane_rule" { + rule_name = "" + remark = "" + rule_tag_list { + tag_id = "" + tag_name = "" + tag_operator = "" + tag_value = "" + lane_rule_id = "" + create_time = + update_time = + + } + rule_tag_relationship = "" + lane_id = "" + program_id_list = +} + +` diff --git a/tencentcloud/resource_tc_tsf_lane_test.go b/tencentcloud/resource_tc_tsf_lane_test.go new file mode 100644 index 0000000000..d1e7a7e82c --- /dev/null +++ b/tencentcloud/resource_tc_tsf_lane_test.go @@ -0,0 +1,52 @@ +package tencentcloud + +import ( + "github.com/hashicorp/terraform-plugin-sdk/helper/resource" + "testing" +) + +func TestAccTencentCloudTsfLaneResource_basic(t *testing.T) { + t.Parallel() + resource.Test(t, resource.TestCase{ + PreCheck: func() { + testAccPreCheck(t) + }, + Providers: testAccProviders, + Steps: []resource.TestStep{ + { + Config: testAccTsfLane, + Check: resource.ComposeTestCheckFunc(resource.TestCheckResourceAttrSet("tencentcloud_tsf_lane.lane", "id")), + }, + { + ResourceName: "tencentcloud_tsf_lane.lane", + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + +const testAccTsfLane = ` + +resource "tencentcloud_tsf_lane" "lane" { + lane_name = "" + remark = "" + lane_group_list { + group_id = "" + entrance = + lane_group_id = "" + lane_id = "" + group_name = "" + application_id = "" + application_name = "" + namespace_id = "" + namespace_name = "" + create_time = + update_time = + cluster_type = "" + + } + program_id_list = + } + +` diff --git a/tencentcloud/resource_tc_tsf_namespace.go b/tencentcloud/resource_tc_tsf_namespace.go new file mode 100644 index 0000000000..688c274482 --- /dev/null +++ b/tencentcloud/resource_tc_tsf_namespace.go @@ -0,0 +1,803 @@ +/* +Provides a resource to create a tsf namespace + +Example Usage + +```hcl +resource "tencentcloud_tsf_namespace" "namespace" { + namespace_name = "" + cluster_id = "" + namespace_desc = "" + namespace_resource_type = "" + namespace_type = "" + namespace_id = "" + is_ha_enable = "" + program_id = "" + program_id_list = +} +``` + +Import + +tsf namespace can be imported using the id, e.g. + +``` +terraform import tencentcloud_tsf_namespace.namespace namespace_id +``` +*/ +package tencentcloud + +import ( + "context" + "fmt" + "log" + + "github.com/hashicorp/terraform-plugin-sdk/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + tsf "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tsf/v20180326" + "github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/internal/helper" +) + +func resourceTencentCloudTsfNamespace() *schema.Resource { + return &schema.Resource{ + Create: resourceTencentCloudTsfNamespaceCreate, + Read: resourceTencentCloudTsfNamespaceRead, + Update: resourceTencentCloudTsfNamespaceUpdate, + Delete: resourceTencentCloudTsfNamespaceDelete, + Importer: &schema.ResourceImporter{ + State: schema.ImportStatePassthrough, + }, + Schema: map[string]*schema.Schema{ + "namespace_name": { + Required: true, + Type: schema.TypeString, + Description: "namespace name.", + }, + + "cluster_id": { + Optional: true, + Computed: true, + Type: schema.TypeString, + Description: "cluster ID.", + }, + + "namespace_desc": { + Optional: true, + Computed: true, + Type: schema.TypeString, + Description: "namespace description.", + }, + + "namespace_resource_type": { + Optional: true, + Computed: true, + Type: schema.TypeString, + Description: "namespace resource type (default is DEF).", + }, + + "namespace_type": { + Optional: true, + Computed: true, + Type: schema.TypeString, + Description: "Whether it is a global namespace (the default is DEF, which means a common namespace; GLOBAL means a global namespace).", + }, + + "namespace_id": { + Optional: true, + Computed: true, + Type: schema.TypeString, + Description: "Namespace ID.", + }, + + "is_ha_enable": { + Optional: true, + Computed: true, + Type: schema.TypeString, + Description: "whether to enable high availability.", + }, + + "program_id": { + Optional: true, + Type: schema.TypeString, + Description: "ID of the dataset to be bound.", + }, + + "kube_inject_enable": { + Computed: true, + Type: schema.TypeBool, + Description: "KubeInjectEnable value.", + }, + + "program_id_list": { + Optional: true, + Type: schema.TypeSet, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + Description: "Program id list.", + }, + + "namespace_code": { + Computed: true, + Type: schema.TypeString, + Description: "Namespace encoding.", + }, + + "is_default": { + Computed: true, + Type: schema.TypeString, + Description: "default namespace.", + }, + + "namespace_status": { + Computed: true, + Type: schema.TypeString, + Description: "namespace status.", + }, + + "delete_flag": { + Computed: true, + Type: schema.TypeBool, + Description: "Delete ID.", + }, + + "create_time": { + Computed: true, + Type: schema.TypeString, + Description: "creation time.", + }, + + "update_time": { + Computed: true, + Type: schema.TypeString, + Description: "update time.", + }, + + "cluster_list": { + Computed: true, + Type: schema.TypeList, + Description: "Cluster array, only carrying basic information such as cluster ID, cluster name, and cluster type.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "cluster_id": { + Type: schema.TypeString, + Computed: true, + Description: "cluster ID.", + }, + "cluster_name": { + Type: schema.TypeString, + Computed: true, + Description: "cluster name.", + }, + "cluster_desc": { + Type: schema.TypeString, + Computed: true, + Description: "cluster description.", + }, + "cluster_type": { + Type: schema.TypeString, + Computed: true, + Description: "cluster type.", + }, + "vpc_id": { + Type: schema.TypeString, + Computed: true, + Description: "ID of the private network to which the cluster belongs.", + }, + "cluster_status": { + Type: schema.TypeString, + Computed: true, + Description: "cluster status.", + }, + "cluster_c_i_d_r": { + Type: schema.TypeString, + Computed: true, + Description: "Cluster CIDR.", + }, + "cluster_total_cpu": { + Type: schema.TypeFloat, + Computed: true, + Description: "Total CPU of the cluster, unit: core.", + }, + "cluster_total_mem": { + Type: schema.TypeFloat, + Computed: true, + Description: "Total memory of the cluster, unit: G.", + }, + "cluster_used_cpu": { + Type: schema.TypeFloat, + Computed: true, + Description: "The CPU used by the cluster, unit: core.", + }, + "cluster_used_mem": { + Type: schema.TypeFloat, + Computed: true, + Description: "The cluster has used memory, unit: G.", + }, + "instance_count": { + Type: schema.TypeInt, + Computed: true, + Description: "number of cluster machine instances.", + }, + "run_instance_count": { + Type: schema.TypeInt, + Computed: true, + Description: "the number of machine instances available in the cluster.", + }, + "normal_instance_count": { + Type: schema.TypeInt, + Computed: true, + Description: "the number of machine instances in the normal state of the cluster.", + }, + "delete_flag": { + Type: schema.TypeBool, + Computed: true, + Description: "delete flag: true: can be deleted; false: can not be deleted.", + }, + "create_time": { + Type: schema.TypeString, + Computed: true, + Description: "creation time.", + }, + "update_time": { + Type: schema.TypeString, + Computed: true, + Description: "update time.", + }, + "tsf_region_id": { + Type: schema.TypeString, + Computed: true, + Description: "ID of the TSF region to which the cluster belongs.", + }, + "tsf_region_name": { + Type: schema.TypeString, + Computed: true, + Description: "the name of the TSF region to which the cluster belongs.", + }, + "tsf_zone_id": { + Type: schema.TypeString, + Computed: true, + Description: "ID of the TSF availability zone to which the cluster belongs.", + }, + "tsf_zone_name": { + Type: schema.TypeString, + Computed: true, + Description: "The name of the TSF availability zone to which the cluster belongs.", + }, + "delete_flag_reason": { + Type: schema.TypeString, + Computed: true, + Description: "the reason why the cluster cannot be deleted.", + }, + "cluster_limit_cpu": { + Type: schema.TypeFloat, + Computed: true, + Description: "the maximum CPU limit of the cluster, unit: core.", + }, + "cluster_limit_mem": { + Type: schema.TypeFloat, + Computed: true, + Description: "the maximum memory limit of the cluster, unit: G.", + }, + "run_service_instance_count": { + Type: schema.TypeInt, + Computed: true, + Description: "the number of service instances available in the cluster.", + }, + "subnet_id": { + Type: schema.TypeString, + Computed: true, + Description: "ID of the subnet to which the cluster belongs.", + }, + "operation_info": { + Type: schema.TypeList, + Computed: true, + Description: "control information returned to the front end.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "init": { + Type: schema.TypeList, + Computed: true, + Description: "Initialize the control information of the button.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "disabled_reason": { + Type: schema.TypeString, + Computed: true, + Description: "the reason for not displaying.", + }, + "enabled": { + Type: schema.TypeBool, + Computed: true, + Description: "whether the button is clickable.", + }, + "supported": { + Type: schema.TypeBool, + Computed: true, + Description: "whether to display the button.", + }, + }, + }, + }, + "add_instance": { + Type: schema.TypeList, + Computed: true, + Description: "Add the control information of the instance button.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "disabled_reason": { + Type: schema.TypeString, + Computed: true, + Description: "the reason for not displaying.", + }, + "enabled": { + Type: schema.TypeBool, + Computed: true, + Description: "whether the button is clickable.", + }, + "supported": { + Type: schema.TypeBool, + Computed: true, + Description: "whether to display the button.", + }, + }, + }, + }, + "destroy": { + Type: schema.TypeList, + Computed: true, + Description: "Destroy the control information of the machine.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "disabled_reason": { + Type: schema.TypeString, + Computed: true, + Description: "the reason for not displaying.", + }, + "enabled": { + Type: schema.TypeBool, + Computed: true, + Description: "whether the button is clickable.", + }, + "supported": { + Type: schema.TypeBool, + Computed: true, + Description: "whether to display the button.", + }, + }, + }, + }, + }, + }, + }, + "cluster_version": { + Type: schema.TypeString, + Computed: true, + Description: "cluster version.", + }, + }, + }, + }, + }, + } +} + +func resourceTencentCloudTsfNamespaceCreate(d *schema.ResourceData, meta interface{}) error { + defer logElapsed("resource.tencentcloud_tsf_namespace.create")() + defer inconsistentCheck(d, meta)() + + logId := getLogId(contextNil) + + var ( + request = tsf.NewCreateNamespaceRequest() + response = tsf.NewCreateNamespaceResponse() + namespaceId string + ) + if v, ok := d.GetOk("namespace_name"); ok { + request.NamespaceName = helper.String(v.(string)) + } + + if v, ok := d.GetOk("cluster_id"); ok { + request.ClusterId = helper.String(v.(string)) + } + + if v, ok := d.GetOk("namespace_desc"); ok { + request.NamespaceDesc = helper.String(v.(string)) + } + + if v, ok := d.GetOk("namespace_resource_type"); ok { + request.NamespaceResourceType = helper.String(v.(string)) + } + + if v, ok := d.GetOk("namespace_type"); ok { + request.NamespaceType = helper.String(v.(string)) + } + + if v, ok := d.GetOk("namespace_id"); ok { + request.NamespaceId = helper.String(v.(string)) + } + + if v, ok := d.GetOk("is_ha_enable"); ok { + request.IsHaEnable = helper.String(v.(string)) + } + + if v, ok := d.GetOk("program_id"); ok { + request.ProgramId = helper.String(v.(string)) + } + + if v, ok := d.GetOk("program_id_list"); ok { + programIdListSet := v.(*schema.Set).List() + for i := range programIdListSet { + programIdList := programIdListSet[i].(string) + request.ProgramIdList = append(request.ProgramIdList, &programIdList) + } + } + + err := resource.Retry(writeRetryTimeout, func() *resource.RetryError { + result, e := meta.(*TencentCloudClient).apiV3Conn.UseTsfClient().CreateNamespace(request) + if e != nil { + return retryError(e) + } else { + log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n", logId, request.GetAction(), request.ToJsonString(), result.ToJsonString()) + } + response = result + return nil + }) + if err != nil { + log.Printf("[CRITAL]%s create tsf namespace failed, reason:%+v", logId, err) + return err + } + + namespaceId = *response.Response.Result + d.SetId(namespaceId) + + return resourceTencentCloudTsfNamespaceRead(d, meta) +} + +func resourceTencentCloudTsfNamespaceRead(d *schema.ResourceData, meta interface{}) error { + defer logElapsed("resource.tencentcloud_tsf_namespace.read")() + defer inconsistentCheck(d, meta)() + + logId := getLogId(contextNil) + + ctx := context.WithValue(context.TODO(), logIdKey, logId) + + service := TsfService{client: meta.(*TencentCloudClient).apiV3Conn} + + namespaceId := d.Id() + + namespace, err := service.DescribeTsfNamespaceById(ctx, namespaceId) + if err != nil { + return err + } + + if namespace == nil { + d.SetId("") + log.Printf("[WARN]%s resource `TsfNamespace` [%s] not found, please check if it has been deleted.\n", logId, d.Id()) + return nil + } + + if namespace.NamespaceName != nil { + _ = d.Set("namespace_name", namespace.NamespaceName) + } + + if namespace.ClusterId != nil { + _ = d.Set("cluster_id", namespace.ClusterId) + } + + if namespace.NamespaceDesc != nil { + _ = d.Set("namespace_desc", namespace.NamespaceDesc) + } + + if namespace.NamespaceResourceType != nil { + _ = d.Set("namespace_resource_type", namespace.NamespaceResourceType) + } + + if namespace.NamespaceType != nil { + _ = d.Set("namespace_type", namespace.NamespaceType) + } + + if namespace.NamespaceId != nil { + _ = d.Set("namespace_id", namespace.NamespaceId) + } + + if namespace.IsHaEnable != nil { + _ = d.Set("is_ha_enable", namespace.IsHaEnable) + } + + // if namespace.ProgramId != nil { + // _ = d.Set("program_id", namespace.ProgramId) + // } + + if namespace.KubeInjectEnable != nil { + _ = d.Set("kube_inject_enable", namespace.KubeInjectEnable) + } + + // if namespace.ProgramIdList != nil { + // _ = d.Set("program_id_list", namespace.ProgramIdList) + // } + + if namespace.NamespaceCode != nil { + _ = d.Set("namespace_code", namespace.NamespaceCode) + } + + if namespace.IsDefault != nil { + _ = d.Set("is_default", namespace.IsDefault) + } + + if namespace.NamespaceStatus != nil { + _ = d.Set("namespace_status", namespace.NamespaceStatus) + } + + if namespace.DeleteFlag != nil { + _ = d.Set("delete_flag", namespace.DeleteFlag) + } + + if namespace.CreateTime != nil { + _ = d.Set("create_time", namespace.CreateTime) + } + + if namespace.UpdateTime != nil { + _ = d.Set("update_time", namespace.UpdateTime) + } + + if namespace.ClusterList != nil { + clusterListList := []interface{}{} + for _, clusterList := range namespace.ClusterList { + clusterListMap := map[string]interface{}{} + + if clusterList.ClusterId != nil { + clusterListMap["cluster_id"] = clusterList.ClusterId + } + + if clusterList.ClusterName != nil { + clusterListMap["cluster_name"] = clusterList.ClusterName + } + + if clusterList.ClusterDesc != nil { + clusterListMap["cluster_desc"] = clusterList.ClusterDesc + } + + if clusterList.ClusterType != nil { + clusterListMap["cluster_type"] = clusterList.ClusterType + } + + if clusterList.VpcId != nil { + clusterListMap["vpc_id"] = clusterList.VpcId + } + + if clusterList.ClusterStatus != nil { + clusterListMap["cluster_status"] = clusterList.ClusterStatus + } + + if clusterList.ClusterCIDR != nil { + clusterListMap["cluster_c_i_d_r"] = clusterList.ClusterCIDR + } + + if clusterList.ClusterTotalCpu != nil { + clusterListMap["cluster_total_cpu"] = clusterList.ClusterTotalCpu + } + + if clusterList.ClusterTotalMem != nil { + clusterListMap["cluster_total_mem"] = clusterList.ClusterTotalMem + } + + if clusterList.ClusterUsedCpu != nil { + clusterListMap["cluster_used_cpu"] = clusterList.ClusterUsedCpu + } + + if clusterList.ClusterUsedMem != nil { + clusterListMap["cluster_used_mem"] = clusterList.ClusterUsedMem + } + + if clusterList.InstanceCount != nil { + clusterListMap["instance_count"] = clusterList.InstanceCount + } + + if clusterList.RunInstanceCount != nil { + clusterListMap["run_instance_count"] = clusterList.RunInstanceCount + } + + if clusterList.NormalInstanceCount != nil { + clusterListMap["normal_instance_count"] = clusterList.NormalInstanceCount + } + + if clusterList.DeleteFlag != nil { + clusterListMap["delete_flag"] = clusterList.DeleteFlag + } + + if clusterList.CreateTime != nil { + clusterListMap["create_time"] = clusterList.CreateTime + } + + if clusterList.UpdateTime != nil { + clusterListMap["update_time"] = clusterList.UpdateTime + } + + if clusterList.TsfRegionId != nil { + clusterListMap["tsf_region_id"] = clusterList.TsfRegionId + } + + if clusterList.TsfRegionName != nil { + clusterListMap["tsf_region_name"] = clusterList.TsfRegionName + } + + if clusterList.TsfZoneId != nil { + clusterListMap["tsf_zone_id"] = clusterList.TsfZoneId + } + + if clusterList.TsfZoneName != nil { + clusterListMap["tsf_zone_name"] = clusterList.TsfZoneName + } + + if clusterList.DeleteFlagReason != nil { + clusterListMap["delete_flag_reason"] = clusterList.DeleteFlagReason + } + + if clusterList.ClusterLimitCpu != nil { + clusterListMap["cluster_limit_cpu"] = clusterList.ClusterLimitCpu + } + + if clusterList.ClusterLimitMem != nil { + clusterListMap["cluster_limit_mem"] = clusterList.ClusterLimitMem + } + + if clusterList.RunServiceInstanceCount != nil { + clusterListMap["run_service_instance_count"] = clusterList.RunServiceInstanceCount + } + + if clusterList.SubnetId != nil { + clusterListMap["subnet_id"] = clusterList.SubnetId + } + + if clusterList.OperationInfo != nil { + operationInfoMap := map[string]interface{}{} + + if clusterList.OperationInfo.Init != nil { + initMap := map[string]interface{}{} + + if clusterList.OperationInfo.Init.DisabledReason != nil { + initMap["disabled_reason"] = clusterList.OperationInfo.Init.DisabledReason + } + + if clusterList.OperationInfo.Init.Enabled != nil { + initMap["enabled"] = clusterList.OperationInfo.Init.Enabled + } + + if clusterList.OperationInfo.Init.Supported != nil { + initMap["supported"] = clusterList.OperationInfo.Init.Supported + } + + operationInfoMap["init"] = []interface{}{initMap} + } + + if clusterList.OperationInfo.AddInstance != nil { + addInstanceMap := map[string]interface{}{} + + if clusterList.OperationInfo.AddInstance.DisabledReason != nil { + addInstanceMap["disabled_reason"] = clusterList.OperationInfo.AddInstance.DisabledReason + } + + if clusterList.OperationInfo.AddInstance.Enabled != nil { + addInstanceMap["enabled"] = clusterList.OperationInfo.AddInstance.Enabled + } + + if clusterList.OperationInfo.AddInstance.Supported != nil { + addInstanceMap["supported"] = clusterList.OperationInfo.AddInstance.Supported + } + + operationInfoMap["add_instance"] = []interface{}{addInstanceMap} + } + + if clusterList.OperationInfo.Destroy != nil { + destroyMap := map[string]interface{}{} + + if clusterList.OperationInfo.Destroy.DisabledReason != nil { + destroyMap["disabled_reason"] = clusterList.OperationInfo.Destroy.DisabledReason + } + + if clusterList.OperationInfo.Destroy.Enabled != nil { + destroyMap["enabled"] = clusterList.OperationInfo.Destroy.Enabled + } + + if clusterList.OperationInfo.Destroy.Supported != nil { + destroyMap["supported"] = clusterList.OperationInfo.Destroy.Supported + } + + operationInfoMap["destroy"] = []interface{}{destroyMap} + } + + clusterListMap["operation_info"] = []interface{}{operationInfoMap} + } + + if clusterList.ClusterVersion != nil { + clusterListMap["cluster_version"] = clusterList.ClusterVersion + } + + clusterListList = append(clusterListList, clusterListMap) + } + + _ = d.Set("cluster_list", clusterListList) + + } + + return nil +} + +func resourceTencentCloudTsfNamespaceUpdate(d *schema.ResourceData, meta interface{}) error { + defer logElapsed("resource.tencentcloud_tsf_namespace.update")() + defer inconsistentCheck(d, meta)() + + logId := getLogId(contextNil) + + request := tsf.NewModifyNamespaceRequest() + + namespaceId := d.Id() + + request.NamespaceId = &namespaceId + + immutableArgs := []string{"namespace_name", "cluster_id", "namespace_desc", "namespace_resource_type", "namespace_type", "namespace_id", "is_ha_enable", "program_id", "kube_inject_enable", "program_id_list", "namespace_code", "is_default", "namespace_status", "delete_flag", "create_time", "update_time", "cluster_list"} + + for _, v := range immutableArgs { + if d.HasChange(v) { + return fmt.Errorf("argument `%s` cannot be changed", v) + } + } + + if d.HasChange("namespace_name") { + if v, ok := d.GetOk("namespace_name"); ok { + request.NamespaceName = helper.String(v.(string)) + } + } + + if d.HasChange("namespace_desc") { + if v, ok := d.GetOk("namespace_desc"); ok { + request.NamespaceDesc = helper.String(v.(string)) + } + } + + if d.HasChange("namespace_id") { + if v, ok := d.GetOk("namespace_id"); ok { + request.NamespaceId = helper.String(v.(string)) + } + } + + if d.HasChange("is_ha_enable") { + if v, ok := d.GetOk("is_ha_enable"); ok { + request.IsHaEnable = helper.String(v.(string)) + } + } + + err := resource.Retry(writeRetryTimeout, func() *resource.RetryError { + result, e := meta.(*TencentCloudClient).apiV3Conn.UseTsfClient().ModifyNamespace(request) + if e != nil { + return 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 update tsf namespace failed, reason:%+v", logId, err) + return err + } + + return resourceTencentCloudTsfNamespaceRead(d, meta) +} + +func resourceTencentCloudTsfNamespaceDelete(d *schema.ResourceData, meta interface{}) error { + defer logElapsed("resource.tencentcloud_tsf_namespace.delete")() + defer inconsistentCheck(d, meta)() + + logId := getLogId(contextNil) + ctx := context.WithValue(context.TODO(), logIdKey, logId) + + service := TsfService{client: meta.(*TencentCloudClient).apiV3Conn} + namespaceId := d.Id() + + if err := service.DeleteTsfNamespaceById(ctx, namespaceId); err != nil { + return err + } + + return nil +} diff --git a/tencentcloud/resource_tc_tsf_namespace_test.go b/tencentcloud/resource_tc_tsf_namespace_test.go new file mode 100644 index 0000000000..7d94e24d8c --- /dev/null +++ b/tencentcloud/resource_tc_tsf_namespace_test.go @@ -0,0 +1,43 @@ +package tencentcloud + +import ( + "github.com/hashicorp/terraform-plugin-sdk/helper/resource" + "testing" +) + +func TestAccTencentCloudTsfNamespaceResource_basic(t *testing.T) { + t.Parallel() + resource.Test(t, resource.TestCase{ + PreCheck: func() { + testAccPreCheck(t) + }, + Providers: testAccProviders, + Steps: []resource.TestStep{ + { + Config: testAccTsfNamespace, + Check: resource.ComposeTestCheckFunc(resource.TestCheckResourceAttrSet("tencentcloud_tsf_namespace.namespace", "id")), + }, + { + ResourceName: "tencentcloud_tsf_namespace.namespace", + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + +const testAccTsfNamespace = ` + +resource "tencentcloud_tsf_namespace" "namespace" { + namespace_name = "" + cluster_id = "" + namespace_desc = "" + namespace_resource_type = "" + namespace_type = "" + namespace_id = "" + is_ha_enable = "" + program_id = "" + program_id_list = + } + +` diff --git a/tencentcloud/resource_tc_tsf_path_rewrite.go b/tencentcloud/resource_tc_tsf_path_rewrite.go new file mode 100644 index 0000000000..2fd2218a70 --- /dev/null +++ b/tencentcloud/resource_tc_tsf_path_rewrite.go @@ -0,0 +1,266 @@ +/* +Provides a resource to create a tsf path_rewrite + +Example Usage + +```hcl +resource "tencentcloud_tsf_path_rewrite" "path_rewrite" { + gateway_group_id = "" + regex = "" + replacement = "" + blocked = "" + order = +} +``` + +Import + +tsf path_rewrite can be imported using the id, e.g. + +``` +terraform import tencentcloud_tsf_path_rewrite.path_rewrite path_rewrite_id +``` +*/ +package tencentcloud + +import ( + "context" + "fmt" + "log" + + "github.com/hashicorp/terraform-plugin-sdk/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + tsf "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tsf/v20180326" + "github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/internal/helper" +) + +func resourceTencentCloudTsfPathRewrite() *schema.Resource { + return &schema.Resource{ + Create: resourceTencentCloudTsfPathRewriteCreate, + Read: resourceTencentCloudTsfPathRewriteRead, + Update: resourceTencentCloudTsfPathRewriteUpdate, + Delete: resourceTencentCloudTsfPathRewriteDelete, + Importer: &schema.ResourceImporter{ + State: schema.ImportStatePassthrough, + }, + Schema: map[string]*schema.Schema{ + "path_rewrite_id": { + Computed: true, + Type: schema.TypeString, + Description: "path rewrite rule ID.", + }, + + "gateway_group_id": { + Required: true, + Type: schema.TypeString, + Description: "gateway deployment group ID.", + }, + + "regex": { + Required: true, + Type: schema.TypeString, + Description: "regular expression.", + }, + + "replacement": { + Required: true, + Type: schema.TypeString, + Description: "content to replace.", + }, + + "blocked": { + Required: true, + Type: schema.TypeString, + Description: "Whether to shield the mapped path, Y: Yes N: No.", + }, + + "order": { + Required: true, + Type: schema.TypeInt, + Description: "rule order, the smaller the higher the priority.", + }, + }, + } +} + +func resourceTencentCloudTsfPathRewriteCreate(d *schema.ResourceData, meta interface{}) error { + defer logElapsed("resource.tencentcloud_tsf_path_rewrite.create")() + defer inconsistentCheck(d, meta)() + + logId := getLogId(contextNil) + + var ( + request = tsf.NewCreatePathRewritesRequest() + pathRewrite = tsf.PathRewriteCreateObject{} + // response = tsf.NewCreatePathRewritesResponse() + pathRewriteId string + ) + if v, ok := d.GetOk("gateway_group_id"); ok { + pathRewrite.GatewayGroupId = helper.String(v.(string)) + } + + if v, ok := d.GetOk("regex"); ok { + pathRewrite.Regex = helper.String(v.(string)) + } + + if v, ok := d.GetOk("replacement"); ok { + pathRewrite.Replacement = helper.String(v.(string)) + } + + if v, ok := d.GetOk("blocked"); ok { + pathRewrite.Blocked = helper.String(v.(string)) + } + + if v, _ := d.GetOk("order"); v != nil { + pathRewrite.Order = helper.IntInt64(v.(int)) + } + + request.PathRewrites = &pathRewrite + err := resource.Retry(writeRetryTimeout, func() *resource.RetryError { + result, e := meta.(*TencentCloudClient).apiV3Conn.UseTsfClient().CreatePathRewrites(request) + if e != nil { + return retryError(e) + } else { + log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n", logId, request.GetAction(), request.ToJsonString(), result.ToJsonString()) + } + // response = result + return nil + }) + if err != nil { + log.Printf("[CRITAL]%s create tsf pathRewrite failed, reason:%+v", logId, err) + return err + } + + // pathRewriteId = *response.Response.pathRewriteId + d.SetId(pathRewriteId) + + return resourceTencentCloudTsfPathRewriteRead(d, meta) +} + +func resourceTencentCloudTsfPathRewriteRead(d *schema.ResourceData, meta interface{}) error { + defer logElapsed("resource.tencentcloud_tsf_path_rewrite.read")() + defer inconsistentCheck(d, meta)() + + logId := getLogId(contextNil) + + ctx := context.WithValue(context.TODO(), logIdKey, logId) + + service := TsfService{client: meta.(*TencentCloudClient).apiV3Conn} + + pathRewriteId := d.Id() + + pathRewrite, err := service.DescribeTsfPathRewriteById(ctx, pathRewriteId) + if err != nil { + return err + } + + if pathRewrite == nil { + d.SetId("") + log.Printf("[WARN]%s resource `TsfPathRewrite` [%s] not found, please check if it has been deleted.\n", logId, d.Id()) + return nil + } + + if pathRewrite.PathRewriteId != nil { + _ = d.Set("path_rewrite_id", pathRewrite.PathRewriteId) + } + + if pathRewrite.GatewayGroupId != nil { + _ = d.Set("gateway_group_id", pathRewrite.GatewayGroupId) + } + + if pathRewrite.Regex != nil { + _ = d.Set("regex", pathRewrite.Regex) + } + + if pathRewrite.Replacement != nil { + _ = d.Set("replacement", pathRewrite.Replacement) + } + + if pathRewrite.Blocked != nil { + _ = d.Set("blocked", pathRewrite.Blocked) + } + + if pathRewrite.Order != nil { + _ = d.Set("order", pathRewrite.Order) + } + + return nil +} + +func resourceTencentCloudTsfPathRewriteUpdate(d *schema.ResourceData, meta interface{}) error { + defer logElapsed("resource.tencentcloud_tsf_path_rewrite.update")() + defer inconsistentCheck(d, meta)() + + logId := getLogId(contextNil) + + request := tsf.NewModifyPathRewriteRequest() + + pathRewriteId := d.Id() + + request.PathRewriteId = &pathRewriteId + + immutableArgs := []string{"path_rewrite_id", "gateway_group_id"} + + for _, v := range immutableArgs { + if d.HasChange(v) { + return fmt.Errorf("argument `%s` cannot be changed", v) + } + } + + if d.HasChange("regex") { + if v, ok := d.GetOk("regex"); ok { + request.Regex = helper.String(v.(string)) + } + } + + if d.HasChange("replacement") { + if v, ok := d.GetOk("replacement"); ok { + request.Replacement = helper.String(v.(string)) + } + } + + if d.HasChange("blocked") { + if v, ok := d.GetOk("blocked"); ok { + request.Blocked = helper.String(v.(string)) + } + } + + if d.HasChange("order") { + if v, ok := d.GetOk("order"); ok { + request.Order = helper.IntInt64(v.(int)) + } + } + + err := resource.Retry(writeRetryTimeout, func() *resource.RetryError { + result, e := meta.(*TencentCloudClient).apiV3Conn.UseTsfClient().ModifyPathRewrite(request) + if e != nil { + return 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 update tsf pathRewrite failed, reason:%+v", logId, err) + return err + } + + return resourceTencentCloudTsfPathRewriteRead(d, meta) +} + +func resourceTencentCloudTsfPathRewriteDelete(d *schema.ResourceData, meta interface{}) error { + defer logElapsed("resource.tencentcloud_tsf_path_rewrite.delete")() + defer inconsistentCheck(d, meta)() + + logId := getLogId(contextNil) + ctx := context.WithValue(context.TODO(), logIdKey, logId) + + service := TsfService{client: meta.(*TencentCloudClient).apiV3Conn} + pathRewriteId := d.Id() + + if err := service.DeleteTsfPathRewriteById(ctx, pathRewriteId); err != nil { + return err + } + + return nil +} diff --git a/tencentcloud/resource_tc_tsf_path_rewrite_test.go b/tencentcloud/resource_tc_tsf_path_rewrite_test.go new file mode 100644 index 0000000000..072c4e07f5 --- /dev/null +++ b/tencentcloud/resource_tc_tsf_path_rewrite_test.go @@ -0,0 +1,39 @@ +package tencentcloud + +import ( + "github.com/hashicorp/terraform-plugin-sdk/helper/resource" + "testing" +) + +func TestAccTencentCloudTsfPathRewriteResource_basic(t *testing.T) { + t.Parallel() + resource.Test(t, resource.TestCase{ + PreCheck: func() { + testAccPreCheck(t) + }, + Providers: testAccProviders, + Steps: []resource.TestStep{ + { + Config: testAccTsfPathRewrite, + Check: resource.ComposeTestCheckFunc(resource.TestCheckResourceAttrSet("tencentcloud_tsf_path_rewrite.path_rewrite", "id")), + }, + { + ResourceName: "tencentcloud_tsf_path_rewrite.path_rewrite", + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + +const testAccTsfPathRewrite = ` + +resource "tencentcloud_tsf_path_rewrite" "path_rewrite" { + gateway_group_id = "" + regex = "" + replacement = "" + blocked = "" + order = +} + +` diff --git a/tencentcloud/resource_tc_tsf_repository.go b/tencentcloud/resource_tc_tsf_repository.go new file mode 100644 index 0000000000..8bee293d8e --- /dev/null +++ b/tencentcloud/resource_tc_tsf_repository.go @@ -0,0 +1,283 @@ +/* +Provides a resource to create a tsf repository + +Example Usage + +```hcl +resource "tencentcloud_tsf_repository" "repository" { + repository_name = "" + repository_type = "" + bucket_name = "" + bucket_region = "" + directory = "" + repository_desc = "" +} +``` + +Import + +tsf repository can be imported using the id, e.g. + +``` +terraform import tencentcloud_tsf_repository.repository repository_id +``` +*/ +package tencentcloud + +import ( + "context" + "fmt" + "log" + + "github.com/hashicorp/terraform-plugin-sdk/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + tsf "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tsf/v20180326" + "github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/internal/helper" +) + +func resourceTencentCloudTsfRepository() *schema.Resource { + return &schema.Resource{ + Create: resourceTencentCloudTsfRepositoryCreate, + Read: resourceTencentCloudTsfRepositoryRead, + Update: resourceTencentCloudTsfRepositoryUpdate, + Delete: resourceTencentCloudTsfRepositoryDelete, + Importer: &schema.ResourceImporter{ + State: schema.ImportStatePassthrough, + }, + Schema: map[string]*schema.Schema{ + "repository_id": { + Computed: true, + Type: schema.TypeString, + Description: "Warehouse ID.", + }, + + "repository_name": { + Required: true, + Type: schema.TypeString, + Description: "warehouse name.", + }, + + "repository_type": { + Required: true, + Type: schema.TypeString, + Description: "warehouse type (default warehouse: default, private warehouse: private).", + }, + + "bucket_name": { + Required: true, + Type: schema.TypeString, + Description: "the name of the bucket where the warehouse is located.", + }, + + "bucket_region": { + Required: true, + Type: schema.TypeString, + Description: "Bucket region where the warehouse is located.", + }, + + "directory": { + Optional: true, + Computed: true, + Type: schema.TypeString, + Description: "directory.", + }, + + "repository_desc": { + Optional: true, + Computed: true, + Type: schema.TypeString, + Description: "warehouse description.", + }, + + "is_used": { + Computed: true, + Type: schema.TypeBool, + Description: "whether the repository is in use.", + }, + + "create_time": { + Computed: true, + Type: schema.TypeString, + Description: "warehouse creation time.", + }, + }, + } +} + +func resourceTencentCloudTsfRepositoryCreate(d *schema.ResourceData, meta interface{}) error { + defer logElapsed("resource.tencentcloud_tsf_repository.create")() + defer inconsistentCheck(d, meta)() + + logId := getLogId(contextNil) + + var ( + request = tsf.NewCreateRepositoryRequest() + // response = tsf.NewCreateRepositoryResponse() + repositoryId string + ) + if v, ok := d.GetOk("repository_name"); ok { + request.RepositoryName = helper.String(v.(string)) + } + + if v, ok := d.GetOk("repository_type"); ok { + request.RepositoryType = helper.String(v.(string)) + } + + if v, ok := d.GetOk("bucket_name"); ok { + request.BucketName = helper.String(v.(string)) + } + + if v, ok := d.GetOk("bucket_region"); ok { + request.BucketRegion = helper.String(v.(string)) + } + + if v, ok := d.GetOk("directory"); ok { + request.Directory = helper.String(v.(string)) + } + + if v, ok := d.GetOk("repository_desc"); ok { + request.RepositoryDesc = helper.String(v.(string)) + } + + err := resource.Retry(writeRetryTimeout, func() *resource.RetryError { + result, e := meta.(*TencentCloudClient).apiV3Conn.UseTsfClient().CreateRepository(request) + if e != nil { + return retryError(e) + } else { + log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n", logId, request.GetAction(), request.ToJsonString(), result.ToJsonString()) + } + // response = result + return nil + }) + if err != nil { + log.Printf("[CRITAL]%s create tsf repository failed, reason:%+v", logId, err) + return err + } + + // repositoryId = *response.Response.RepositoryId + d.SetId(repositoryId) + + return resourceTencentCloudTsfRepositoryRead(d, meta) +} + +func resourceTencentCloudTsfRepositoryRead(d *schema.ResourceData, meta interface{}) error { + defer logElapsed("resource.tencentcloud_tsf_repository.read")() + defer inconsistentCheck(d, meta)() + + logId := getLogId(contextNil) + + ctx := context.WithValue(context.TODO(), logIdKey, logId) + + service := TsfService{client: meta.(*TencentCloudClient).apiV3Conn} + + repositoryId := d.Id() + + repository, err := service.DescribeTsfRepositoryById(ctx, repositoryId) + if err != nil { + return err + } + + if repository == nil { + d.SetId("") + log.Printf("[WARN]%s resource `TsfRepository` [%s] not found, please check if it has been deleted.\n", logId, d.Id()) + return nil + } + + if repository.RepositoryId != nil { + _ = d.Set("repository_id", repository.RepositoryId) + } + + if repository.RepositoryName != nil { + _ = d.Set("repository_name", repository.RepositoryName) + } + + if repository.RepositoryType != nil { + _ = d.Set("repository_type", repository.RepositoryType) + } + + if repository.BucketName != nil { + _ = d.Set("bucket_name", repository.BucketName) + } + + if repository.BucketRegion != nil { + _ = d.Set("bucket_region", repository.BucketRegion) + } + + if repository.Directory != nil { + _ = d.Set("directory", repository.Directory) + } + + if repository.RepositoryDesc != nil { + _ = d.Set("repository_desc", repository.RepositoryDesc) + } + + if repository.IsUsed != nil { + _ = d.Set("is_used", repository.IsUsed) + } + + if repository.CreateTime != nil { + _ = d.Set("create_time", repository.CreateTime) + } + + return nil +} + +func resourceTencentCloudTsfRepositoryUpdate(d *schema.ResourceData, meta interface{}) error { + defer logElapsed("resource.tencentcloud_tsf_repository.update")() + defer inconsistentCheck(d, meta)() + + logId := getLogId(contextNil) + + request := tsf.NewUpdateRepositoryRequest() + + repositoryId := d.Id() + + request.RepositoryId = &repositoryId + + immutableArgs := []string{"repository_id", "repository_name", "repository_type", "bucket_name", "bucket_region", "directory", "repository_desc", "is_used", "create_time"} + + for _, v := range immutableArgs { + if d.HasChange(v) { + return fmt.Errorf("argument `%s` cannot be changed", v) + } + } + + if d.HasChange("repository_desc") { + if v, ok := d.GetOk("repository_desc"); ok { + request.RepositoryDesc = helper.String(v.(string)) + } + } + + err := resource.Retry(writeRetryTimeout, func() *resource.RetryError { + result, e := meta.(*TencentCloudClient).apiV3Conn.UseTsfClient().UpdateRepository(request) + if e != nil { + return 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 update tsf repository failed, reason:%+v", logId, err) + return err + } + + return resourceTencentCloudTsfRepositoryRead(d, meta) +} + +func resourceTencentCloudTsfRepositoryDelete(d *schema.ResourceData, meta interface{}) error { + defer logElapsed("resource.tencentcloud_tsf_repository.delete")() + defer inconsistentCheck(d, meta)() + + logId := getLogId(contextNil) + ctx := context.WithValue(context.TODO(), logIdKey, logId) + + service := TsfService{client: meta.(*TencentCloudClient).apiV3Conn} + repositoryId := d.Id() + + if err := service.DeleteTsfRepositoryById(ctx, repositoryId); err != nil { + return err + } + + return nil +} diff --git a/tencentcloud/resource_tc_tsf_repository_test.go b/tencentcloud/resource_tc_tsf_repository_test.go new file mode 100644 index 0000000000..5d719b734a --- /dev/null +++ b/tencentcloud/resource_tc_tsf_repository_test.go @@ -0,0 +1,40 @@ +package tencentcloud + +import ( + "github.com/hashicorp/terraform-plugin-sdk/helper/resource" + "testing" +) + +func TestAccTencentCloudTsfRepositoryResource_basic(t *testing.T) { + t.Parallel() + resource.Test(t, resource.TestCase{ + PreCheck: func() { + testAccPreCheck(t) + }, + Providers: testAccProviders, + Steps: []resource.TestStep{ + { + Config: testAccTsfRepository, + Check: resource.ComposeTestCheckFunc(resource.TestCheckResourceAttrSet("tencentcloud_tsf_repository.repository", "id")), + }, + { + ResourceName: "tencentcloud_tsf_repository.repository", + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + +const testAccTsfRepository = ` + +resource "tencentcloud_tsf_repository" "repository" { + repository_name = "" + repository_type = "" + bucket_name = "" + bucket_region = "" + directory = "" + repository_desc = "" + } + +` diff --git a/tencentcloud/resource_tc_tsf_task.go b/tencentcloud/resource_tc_tsf_task.go new file mode 100644 index 0000000000..73eb4a3313 --- /dev/null +++ b/tencentcloud/resource_tc_tsf_task.go @@ -0,0 +1,704 @@ +/* +Provides a resource to create a tsf task + +Example Usage + +```hcl +resource "tencentcloud_tsf_task" "task" { + task_name = "" + task_content = "" + execute_type = "" + task_type = "" + time_out = + group_id = "" + task_rule { + rule_type = "" + expression = "" + repeat_interval = + + } + retry_count = + retry_interval = + shard_count = + shard_arguments { + shard_key = + shard_value = "" + + } + success_operator = "" + success_ratio = "" + advance_settings { + sub_task_concurrency = + + } + task_argument = "" + program_id_list = +} +``` + +Import + +tsf task can be imported using the id, e.g. + +``` +terraform import tencentcloud_tsf_task.task task_id +``` +*/ +package tencentcloud + +import ( + "context" + "fmt" + "log" + + "github.com/hashicorp/terraform-plugin-sdk/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + tsf "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tsf/v20180326" + "github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/internal/helper" +) + +func resourceTencentCloudTsfTask() *schema.Resource { + return &schema.Resource{ + Create: resourceTencentCloudTsfTaskCreate, + Read: resourceTencentCloudTsfTaskRead, + Update: resourceTencentCloudTsfTaskUpdate, + Delete: resourceTencentCloudTsfTaskDelete, + Importer: &schema.ResourceImporter{ + State: schema.ImportStatePassthrough, + }, + Schema: map[string]*schema.Schema{ + "task_id": { + Computed: true, + Type: schema.TypeString, + Description: "task ID.", + }, + + "task_name": { + Required: true, + Type: schema.TypeString, + Description: "task name, task length 64 characters.", + }, + + "task_content": { + Required: true, + Type: schema.TypeString, + Description: "task content, length limit 65536 bytes.", + }, + + "execute_type": { + Required: true, + Type: schema.TypeString, + Description: "execution type, unicast/broadcast.", + }, + + "task_type": { + Required: true, + Type: schema.TypeString, + Description: "task type, java.", + }, + + "time_out": { + Required: true, + Type: schema.TypeInt, + Description: "task timeout, time unit ms.", + }, + + "group_id": { + Required: true, + Type: schema.TypeString, + Description: "deployment group ID.", + }, + + "task_rule": { + Optional: true, + Computed: true, + Type: schema.TypeList, + MaxItems: 1, + Description: "trigger rule.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "rule_type": { + Type: schema.TypeString, + Required: true, + Description: "trigger rule type, Cron/Repeat.", + }, + "expression": { + Type: schema.TypeString, + Optional: true, + Description: "Cron type rule, cron expression.", + }, + "repeat_interval": { + Type: schema.TypeInt, + Optional: true, + Description: "time interval, in milliseconds.", + }, + }, + }, + }, + + "retry_count": { + Optional: true, + Computed: true, + Type: schema.TypeInt, + Description: "number of retries, 0 &lt;= RetryCount&lt;= 10.", + }, + + "retry_interval": { + Optional: true, + Computed: true, + Type: schema.TypeInt, + Description: "retry interval, 0 &lt;= RetryInterval &lt;= 600000, time unit ms.", + }, + + "shard_count": { + Optional: true, + Computed: true, + Type: schema.TypeInt, + Description: "number of shards.", + }, + + "shard_arguments": { + Optional: true, + Computed: true, + Type: schema.TypeList, + Description: "Fragmentation parameters.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "shard_key": { + Type: schema.TypeInt, + Required: true, + Description: "Sharding parameter KEY, integer, range [1,1000].", + }, + "shard_value": { + Type: schema.TypeString, + Required: true, + Description: "Shard parameter VALUE.", + }, + }, + }, + }, + + "success_operator": { + Optional: true, + Computed: true, + Type: schema.TypeString, + Description: "the operator to judge the success of the task.", + }, + + "success_ratio": { + Optional: true, + Computed: true, + Type: schema.TypeString, + Description: "The threshold for judging the success rate of the task, such as 100.", + }, + + "advance_settings": { + Optional: true, + Computed: true, + Type: schema.TypeList, + MaxItems: 1, + Description: "advanced settings.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "sub_task_concurrency": { + Type: schema.TypeInt, + Optional: true, + Description: "Subtask single-machine concurrency limit, the default value is 2.", + }, + }, + }, + }, + + "task_argument": { + Optional: true, + Computed: true, + Type: schema.TypeString, + Description: "task parameters, the length limit is 10000 characters.", + }, + + "task_state": { + Computed: true, + Type: schema.TypeString, + Description: "Whether to enable the task, ENABLED/DISABLED.", + }, + + "belong_flow_ids": { + Computed: true, + Type: schema.TypeSet, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + Description: "ID of the workflow to which it belongs.", + }, + + "task_log_id": { + Computed: true, + Type: schema.TypeString, + Description: "task history ID.", + }, + + "trigger_type": { + Computed: true, + Type: schema.TypeString, + Description: "trigger type.", + }, + + "program_id_list": { + Optional: true, + Type: schema.TypeSet, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + Description: "Program id list.", + }, + }, + } +} + +func resourceTencentCloudTsfTaskCreate(d *schema.ResourceData, meta interface{}) error { + defer logElapsed("resource.tencentcloud_tsf_task.create")() + defer inconsistentCheck(d, meta)() + + logId := getLogId(contextNil) + + var ( + request = tsf.NewCreateTaskRequest() + response = tsf.NewCreateTaskResponse() + taskId string + ) + if v, ok := d.GetOk("task_name"); ok { + request.TaskName = helper.String(v.(string)) + } + + if v, ok := d.GetOk("task_content"); ok { + request.TaskContent = helper.String(v.(string)) + } + + if v, ok := d.GetOk("execute_type"); ok { + request.ExecuteType = helper.String(v.(string)) + } + + if v, ok := d.GetOk("task_type"); ok { + request.TaskType = helper.String(v.(string)) + } + + if v, _ := d.GetOk("time_out"); v != nil { + request.TimeOut = helper.IntUint64(v.(int)) + } + + if v, ok := d.GetOk("group_id"); ok { + request.GroupId = helper.String(v.(string)) + } + + if dMap, ok := helper.InterfacesHeadMap(d, "task_rule"); ok { + taskRule := tsf.TaskRule{} + if v, ok := dMap["rule_type"]; ok { + taskRule.RuleType = helper.String(v.(string)) + } + if v, ok := dMap["expression"]; ok { + taskRule.Expression = helper.String(v.(string)) + } + if v, ok := dMap["repeat_interval"]; ok { + taskRule.RepeatInterval = helper.IntUint64(v.(int)) + } + request.TaskRule = &taskRule + } + + if v, _ := d.GetOk("retry_count"); v != nil { + request.RetryCount = helper.IntUint64(v.(int)) + } + + if v, _ := d.GetOk("retry_interval"); v != nil { + request.RetryInterval = helper.IntUint64(v.(int)) + } + + if v, _ := d.GetOk("shard_count"); v != nil { + request.ShardCount = helper.IntInt64(v.(int)) + } + + if v, ok := d.GetOk("shard_arguments"); ok { + for _, item := range v.([]interface{}) { + dMap := item.(map[string]interface{}) + shardArgument := tsf.ShardArgument{} + if v, ok := dMap["shard_key"]; ok { + shardArgument.ShardKey = helper.IntUint64(v.(int)) + } + if v, ok := dMap["shard_value"]; ok { + shardArgument.ShardValue = helper.String(v.(string)) + } + request.ShardArguments = append(request.ShardArguments, &shardArgument) + } + } + + if v, ok := d.GetOk("success_operator"); ok { + request.SuccessOperator = helper.String(v.(string)) + } + + if v, ok := d.GetOk("success_ratio"); ok { + request.SuccessRatio = helper.String(v.(string)) + } + + if dMap, ok := helper.InterfacesHeadMap(d, "advance_settings"); ok { + advanceSettings := tsf.AdvanceSettings{} + if v, ok := dMap["sub_task_concurrency"]; ok { + advanceSettings.SubTaskConcurrency = helper.IntInt64(v.(int)) + } + request.AdvanceSettings = &advanceSettings + } + + if v, ok := d.GetOk("task_argument"); ok { + request.TaskArgument = helper.String(v.(string)) + } + + if v, ok := d.GetOk("program_id_list"); ok { + programIdListSet := v.(*schema.Set).List() + for i := range programIdListSet { + programIdList := programIdListSet[i].(string) + request.ProgramIdList = append(request.ProgramIdList, &programIdList) + } + } + + err := resource.Retry(writeRetryTimeout, func() *resource.RetryError { + result, e := meta.(*TencentCloudClient).apiV3Conn.UseTsfClient().CreateTask(request) + if e != nil { + return retryError(e) + } else { + log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n", logId, request.GetAction(), request.ToJsonString(), result.ToJsonString()) + } + response = result + return nil + }) + if err != nil { + log.Printf("[CRITAL]%s create tsf task failed, reason:%+v", logId, err) + return err + } + + taskId = *response.Response.Result + d.SetId(taskId) + + return resourceTencentCloudTsfTaskRead(d, meta) +} + +func resourceTencentCloudTsfTaskRead(d *schema.ResourceData, meta interface{}) error { + defer logElapsed("resource.tencentcloud_tsf_task.read")() + defer inconsistentCheck(d, meta)() + + logId := getLogId(contextNil) + + ctx := context.WithValue(context.TODO(), logIdKey, logId) + + service := TsfService{client: meta.(*TencentCloudClient).apiV3Conn} + + taskId := d.Id() + + task, err := service.DescribeTsfTaskById(ctx, taskId) + if err != nil { + return err + } + + if task == nil { + d.SetId("") + log.Printf("[WARN]%s resource `TsfTask` [%s] not found, please check if it has been deleted.\n", logId, d.Id()) + return nil + } + + if task.TaskId != nil { + _ = d.Set("task_id", task.TaskId) + } + + if task.TaskName != nil { + _ = d.Set("task_name", task.TaskName) + } + + if task.TaskContent != nil { + _ = d.Set("task_content", task.TaskContent) + } + + if task.ExecuteType != nil { + _ = d.Set("execute_type", task.ExecuteType) + } + + if task.TaskType != nil { + _ = d.Set("task_type", task.TaskType) + } + + if task.TimeOut != nil { + _ = d.Set("time_out", task.TimeOut) + } + + if task.GroupId != nil { + _ = d.Set("group_id", task.GroupId) + } + + if task.TaskRule != nil { + taskRuleMap := map[string]interface{}{} + + if task.TaskRule.RuleType != nil { + taskRuleMap["rule_type"] = task.TaskRule.RuleType + } + + if task.TaskRule.Expression != nil { + taskRuleMap["expression"] = task.TaskRule.Expression + } + + if task.TaskRule.RepeatInterval != nil { + taskRuleMap["repeat_interval"] = task.TaskRule.RepeatInterval + } + + _ = d.Set("task_rule", []interface{}{taskRuleMap}) + } + + if task.RetryCount != nil { + _ = d.Set("retry_count", task.RetryCount) + } + + if task.RetryInterval != nil { + _ = d.Set("retry_interval", task.RetryInterval) + } + + if task.ShardCount != nil { + _ = d.Set("shard_count", task.ShardCount) + } + + if task.ShardArguments != nil { + shardArgumentsList := []interface{}{} + for _, shardArguments := range task.ShardArguments { + shardArgumentsMap := map[string]interface{}{} + + if shardArguments.ShardKey != nil { + shardArgumentsMap["shard_key"] = shardArguments.ShardKey + } + + if shardArguments.ShardValue != nil { + shardArgumentsMap["shard_value"] = shardArguments.ShardValue + } + + shardArgumentsList = append(shardArgumentsList, shardArgumentsMap) + } + + _ = d.Set("shard_arguments", shardArgumentsList) + + } + + if task.SuccessOperator != nil { + _ = d.Set("success_operator", task.SuccessOperator) + } + + if task.SuccessRatio != nil { + _ = d.Set("success_ratio", task.SuccessRatio) + } + + if task.AdvanceSettings != nil { + advanceSettingsMap := map[string]interface{}{} + + if task.AdvanceSettings.SubTaskConcurrency != nil { + advanceSettingsMap["sub_task_concurrency"] = task.AdvanceSettings.SubTaskConcurrency + } + + _ = d.Set("advance_settings", []interface{}{advanceSettingsMap}) + } + + if task.TaskArgument != nil { + _ = d.Set("task_argument", task.TaskArgument) + } + + if task.TaskState != nil { + _ = d.Set("task_state", task.TaskState) + } + + if task.BelongFlowIds != nil { + _ = d.Set("belong_flow_ids", task.BelongFlowIds) + } + + if task.TaskLogId != nil { + _ = d.Set("task_log_id", task.TaskLogId) + } + + if task.TriggerType != nil { + _ = d.Set("trigger_type", task.TriggerType) + } + + // if task.ProgramIdList != nil { + // _ = d.Set("program_id_list", task.ProgramIdList) + // } + + return nil +} + +func resourceTencentCloudTsfTaskUpdate(d *schema.ResourceData, meta interface{}) error { + defer logElapsed("resource.tencentcloud_tsf_task.update")() + defer inconsistentCheck(d, meta)() + + logId := getLogId(contextNil) + + request := tsf.NewModifyTaskRequest() + + taskId := d.Id() + + request.TaskId = &taskId + + immutableArgs := []string{"task_id", "task_name", "task_content", "execute_type", "task_type", "time_out", "group_id", "task_rule", "retry_count", "retry_interval", "shard_count", "shard_arguments", "success_operator", "success_ratio", "advance_settings", "task_argument", "task_state", "belong_flow_ids", "task_log_id", "trigger_type", "program_id_list"} + + for _, v := range immutableArgs { + if d.HasChange(v) { + return fmt.Errorf("argument `%s` cannot be changed", v) + } + } + + if d.HasChange("task_name") { + if v, ok := d.GetOk("task_name"); ok { + request.TaskName = helper.String(v.(string)) + } + } + + if d.HasChange("task_content") { + if v, ok := d.GetOk("task_content"); ok { + request.TaskContent = helper.String(v.(string)) + } + } + + if d.HasChange("execute_type") { + if v, ok := d.GetOk("execute_type"); ok { + request.ExecuteType = helper.String(v.(string)) + } + } + + if d.HasChange("task_type") { + if v, ok := d.GetOk("task_type"); ok { + request.TaskType = helper.String(v.(string)) + } + } + + if d.HasChange("time_out") { + if v, _ := d.GetOk("time_out"); v != nil { + request.TimeOut = helper.IntUint64(v.(int)) + } + } + + if d.HasChange("group_id") { + if v, ok := d.GetOk("group_id"); ok { + request.GroupId = helper.String(v.(string)) + } + } + + if d.HasChange("task_rule") { + if dMap, ok := helper.InterfacesHeadMap(d, "task_rule"); ok { + taskRule := tsf.TaskRule{} + if v, ok := dMap["rule_type"]; ok { + taskRule.RuleType = helper.String(v.(string)) + } + if v, ok := dMap["expression"]; ok { + taskRule.Expression = helper.String(v.(string)) + } + if v, ok := dMap["repeat_interval"]; ok { + taskRule.RepeatInterval = helper.IntUint64(v.(int)) + } + request.TaskRule = &taskRule + } + } + + if d.HasChange("retry_count") { + if v, _ := d.GetOk("retry_count"); v != nil { + request.RetryCount = helper.IntUint64(v.(int)) + } + } + + if d.HasChange("retry_interval") { + if v, _ := d.GetOk("retry_interval"); v != nil { + request.RetryInterval = helper.IntUint64(v.(int)) + } + } + + if d.HasChange("shard_count") { + if v, _ := d.GetOk("shard_count"); v != nil { + request.ShardCount = helper.IntInt64(v.(int)) + } + } + + if d.HasChange("shard_arguments") { + if v, ok := d.GetOk("shard_arguments"); ok { + for _, item := range v.([]interface{}) { + dMap := item.(map[string]interface{}) + shardArgument := tsf.ShardArgument{} + if v, ok := dMap["shard_key"]; ok { + shardArgument.ShardKey = helper.IntUint64(v.(int)) + } + if v, ok := dMap["shard_value"]; ok { + shardArgument.ShardValue = helper.String(v.(string)) + } + request.ShardArguments = append(request.ShardArguments, &shardArgument) + } + } + } + + if d.HasChange("success_operator") { + if v, ok := d.GetOk("success_operator"); ok { + request.SuccessOperator = helper.String(v.(string)) + } + } + + if d.HasChange("success_ratio") { + if v, ok := d.GetOk("success_ratio"); ok { + request.SuccessRatio = helper.StrToInt64Point(v.(string)) + } + } + + if d.HasChange("advance_settings") { + if dMap, ok := helper.InterfacesHeadMap(d, "advance_settings"); ok { + advanceSettings := tsf.AdvanceSettings{} + if v, ok := dMap["sub_task_concurrency"]; ok { + advanceSettings.SubTaskConcurrency = helper.IntInt64(v.(int)) + } + request.AdvanceSettings = &advanceSettings + } + } + + if d.HasChange("task_argument") { + if v, ok := d.GetOk("task_argument"); ok { + request.TaskArgument = helper.String(v.(string)) + } + } + + if d.HasChange("program_id_list") { + if v, ok := d.GetOk("program_id_list"); ok { + programIdListSet := v.(*schema.Set).List() + for i := range programIdListSet { + programIdList := programIdListSet[i].(string) + request.ProgramIdList = append(request.ProgramIdList, &programIdList) + } + } + } + + err := resource.Retry(writeRetryTimeout, func() *resource.RetryError { + result, e := meta.(*TencentCloudClient).apiV3Conn.UseTsfClient().ModifyTask(request) + if e != nil { + return 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 update tsf task failed, reason:%+v", logId, err) + return err + } + + return resourceTencentCloudTsfTaskRead(d, meta) +} + +func resourceTencentCloudTsfTaskDelete(d *schema.ResourceData, meta interface{}) error { + defer logElapsed("resource.tencentcloud_tsf_task.delete")() + defer inconsistentCheck(d, meta)() + + logId := getLogId(contextNil) + ctx := context.WithValue(context.TODO(), logIdKey, logId) + + service := TsfService{client: meta.(*TencentCloudClient).apiV3Conn} + taskId := d.Id() + + if err := service.DeleteTsfTaskById(ctx, taskId); err != nil { + return err + } + + return nil +} diff --git a/tencentcloud/resource_tc_tsf_task_test.go b/tencentcloud/resource_tc_tsf_task_test.go new file mode 100644 index 0000000000..a1d1aef3ec --- /dev/null +++ b/tencentcloud/resource_tc_tsf_task_test.go @@ -0,0 +1,62 @@ +package tencentcloud + +import ( + "github.com/hashicorp/terraform-plugin-sdk/helper/resource" + "testing" +) + +func TestAccTencentCloudTsfTaskResource_basic(t *testing.T) { + t.Parallel() + resource.Test(t, resource.TestCase{ + PreCheck: func() { + testAccPreCheck(t) + }, + Providers: testAccProviders, + Steps: []resource.TestStep{ + { + Config: testAccTsfTask, + Check: resource.ComposeTestCheckFunc(resource.TestCheckResourceAttrSet("tencentcloud_tsf_task.task", "id")), + }, + { + ResourceName: "tencentcloud_tsf_task.task", + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + +const testAccTsfTask = ` + +resource "tencentcloud_tsf_task" "task" { + task_name = "" + task_content = "" + execute_type = "" + task_type = "" + time_out = + group_id = "" + task_rule { + rule_type = "" + expression = "" + repeat_interval = + + } + retry_count = + retry_interval = + shard_count = + shard_arguments { + shard_key = + shard_value = "" + + } + success_operator = "" + success_ratio = "" + advance_settings { + sub_task_concurrency = + + } + task_argument = "" + program_id_list = +} + +` diff --git a/tencentcloud/resource_tc_tsf_unit_rule.go b/tencentcloud/resource_tc_tsf_unit_rule.go new file mode 100644 index 0000000000..26cb16543d --- /dev/null +++ b/tencentcloud/resource_tc_tsf_unit_rule.go @@ -0,0 +1,536 @@ +/* +Provides a resource to create a tsf unit_rule + +Example Usage + +```hcl +resource "tencentcloud_tsf_unit_rule" "unit_rule" { + gateway_instance_id = "" + name = "" + description = "" + unit_rule_item_list { + relationship = "" + dest_namespace_id = "" + dest_namespace_name = "" + name = "" + id = "" + unit_rule_id = "" + priority = + description = "" + unit_rule_tag_list { + tag_type = "" + tag_field = "" + tag_operator = "" + tag_value = "" + unit_rule_item_id = "" + id = "" + } + + } +} +``` + +Import + +tsf unit_rule can be imported using the id, e.g. + +``` +terraform import tencentcloud_tsf_unit_rule.unit_rule unit_rule_id +``` +*/ +package tencentcloud + +import ( + "context" + "fmt" + "log" + + "github.com/hashicorp/terraform-plugin-sdk/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + tsf "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tsf/v20180326" + "github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/internal/helper" +) + +func resourceTencentCloudTsfUnitRule() *schema.Resource { + return &schema.Resource{ + Create: resourceTencentCloudTsfUnitRuleCreate, + Read: resourceTencentCloudTsfUnitRuleRead, + Update: resourceTencentCloudTsfUnitRuleUpdate, + Delete: resourceTencentCloudTsfUnitRuleDelete, + Importer: &schema.ResourceImporter{ + State: schema.ImportStatePassthrough, + }, + Schema: map[string]*schema.Schema{ + "gateway_instance_id": { + Required: true, + Type: schema.TypeString, + Description: "gateway entity ID.", + }, + + "name": { + Required: true, + Type: schema.TypeString, + Description: "rule name.", + }, + + "id": { + Computed: true, + Type: schema.TypeString, + Description: "rule ID.", + }, + + "status": { + Computed: true, + Type: schema.TypeString, + Description: "usage status: enabled/disabled.", + }, + + "description": { + Optional: true, + Computed: true, + Type: schema.TypeString, + Description: "rule description.", + }, + + "unit_rule_item_list": { + Optional: true, + Type: schema.TypeList, + Description: "list of rule items.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "relationship": { + Type: schema.TypeString, + Required: true, + Description: "logical relationship: AND/OR.", + }, + "dest_namespace_id": { + Type: schema.TypeString, + Required: true, + Description: "destination namespace ID.", + }, + "dest_namespace_name": { + Type: schema.TypeString, + Required: true, + Description: "destination namespace name.", + }, + "name": { + Type: schema.TypeString, + Required: true, + Description: "rule item name.", + }, + "id": { + Type: schema.TypeString, + Optional: true, + Description: "rule item ID.", + }, + "unit_rule_id": { + Type: schema.TypeString, + Optional: true, + Description: "Unitization rule ID.", + }, + "priority": { + Type: schema.TypeInt, + Optional: true, + Description: "rule order, the smaller the higher the priority: the default is 0.", + }, + "description": { + Type: schema.TypeString, + Optional: true, + Description: "rule description.", + }, + "unit_rule_tag_list": { + Type: schema.TypeList, + Optional: true, + Description: "list of rule labels.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "tag_type": { + Type: schema.TypeString, + Required: true, + Description: "Tag Type: U(User Tag).", + }, + "tag_field": { + Type: schema.TypeString, + Required: true, + Description: "label name.", + }, + "tag_operator": { + Type: schema.TypeString, + Required: true, + Description: "Operator: IN/NOT_IN/EQUAL/NOT_EQUAL/REGEX.", + }, + "tag_value": { + Type: schema.TypeString, + Required: true, + Description: "tag value.", + }, + "unit_rule_item_id": { + Type: schema.TypeString, + Optional: true, + Description: "Unitization rule item ID.", + }, + "id": { + Type: schema.TypeString, + Optional: true, + Description: "rule ID.", + }, + }, + }, + }, + }, + }, + }, + }, + } +} + +func resourceTencentCloudTsfUnitRuleCreate(d *schema.ResourceData, meta interface{}) error { + defer logElapsed("resource.tencentcloud_tsf_unit_rule.create")() + defer inconsistentCheck(d, meta)() + + logId := getLogId(contextNil) + + var ( + request = tsf.NewCreateUnitRuleRequest() + // response = tsf.NewCreateUnitRuleResponse() + id string + ) + if v, ok := d.GetOk("gateway_instance_id"); ok { + request.GatewayInstanceId = helper.String(v.(string)) + } + + if v, ok := d.GetOk("name"); ok { + request.Name = helper.String(v.(string)) + } + + if v, ok := d.GetOk("description"); ok { + request.Description = helper.String(v.(string)) + } + + if v, ok := d.GetOk("unit_rule_item_list"); ok { + for _, item := range v.([]interface{}) { + dMap := item.(map[string]interface{}) + unitRuleItem := tsf.UnitRuleItem{} + if v, ok := dMap["relationship"]; ok { + unitRuleItem.Relationship = helper.String(v.(string)) + } + if v, ok := dMap["dest_namespace_id"]; ok { + unitRuleItem.DestNamespaceId = helper.String(v.(string)) + } + if v, ok := dMap["dest_namespace_name"]; ok { + unitRuleItem.DestNamespaceName = helper.String(v.(string)) + } + if v, ok := dMap["name"]; ok { + unitRuleItem.Name = helper.String(v.(string)) + } + if v, ok := dMap["id"]; ok { + unitRuleItem.Id = helper.String(v.(string)) + } + if v, ok := dMap["unit_rule_id"]; ok { + unitRuleItem.UnitRuleId = helper.String(v.(string)) + } + if v, ok := dMap["priority"]; ok { + unitRuleItem.Priority = helper.IntInt64(v.(int)) + } + if v, ok := dMap["description"]; ok { + unitRuleItem.Description = helper.String(v.(string)) + } + if v, ok := dMap["unit_rule_tag_list"]; ok { + for _, item := range v.([]interface{}) { + unitRuleTagListMap := item.(map[string]interface{}) + unitRuleTag := tsf.UnitRuleTag{} + if v, ok := unitRuleTagListMap["tag_type"]; ok { + unitRuleTag.TagType = helper.String(v.(string)) + } + if v, ok := unitRuleTagListMap["tag_field"]; ok { + unitRuleTag.TagField = helper.String(v.(string)) + } + if v, ok := unitRuleTagListMap["tag_operator"]; ok { + unitRuleTag.TagOperator = helper.String(v.(string)) + } + if v, ok := unitRuleTagListMap["tag_value"]; ok { + unitRuleTag.TagValue = helper.String(v.(string)) + } + if v, ok := unitRuleTagListMap["unit_rule_item_id"]; ok { + unitRuleTag.UnitRuleItemId = helper.String(v.(string)) + } + if v, ok := unitRuleTagListMap["id"]; ok { + unitRuleTag.Id = helper.String(v.(string)) + } + unitRuleItem.UnitRuleTagList = append(unitRuleItem.UnitRuleTagList, &unitRuleTag) + } + } + request.UnitRuleItemList = append(request.UnitRuleItemList, &unitRuleItem) + } + } + + err := resource.Retry(writeRetryTimeout, func() *resource.RetryError { + result, e := meta.(*TencentCloudClient).apiV3Conn.UseTsfClient().CreateUnitRule(request) + if e != nil { + return retryError(e) + } else { + log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n", logId, request.GetAction(), request.ToJsonString(), result.ToJsonString()) + } + // response = result + return nil + }) + if err != nil { + log.Printf("[CRITAL]%s create tsf unitRule failed, reason:%+v", logId, err) + return err + } + + // id = *response.Response.Id + d.SetId(id) + + return resourceTencentCloudTsfUnitRuleRead(d, meta) +} + +func resourceTencentCloudTsfUnitRuleRead(d *schema.ResourceData, meta interface{}) error { + defer logElapsed("resource.tencentcloud_tsf_unit_rule.read")() + defer inconsistentCheck(d, meta)() + + logId := getLogId(contextNil) + + ctx := context.WithValue(context.TODO(), logIdKey, logId) + + service := TsfService{client: meta.(*TencentCloudClient).apiV3Conn} + + id := d.Id() + + unitRule, err := service.DescribeTsfUnitRuleById(ctx, id) + if err != nil { + return err + } + + if unitRule == nil { + d.SetId("") + log.Printf("[WARN]%s resource `TsfUnitRule` [%s] not found, please check if it has been deleted.\n", logId, d.Id()) + return nil + } + + if unitRule.GatewayInstanceId != nil { + _ = d.Set("gateway_instance_id", unitRule.GatewayInstanceId) + } + + if unitRule.Name != nil { + _ = d.Set("name", unitRule.Name) + } + + if unitRule.Id != nil { + _ = d.Set("id", unitRule.Id) + } + + if unitRule.Status != nil { + _ = d.Set("status", unitRule.Status) + } + + if unitRule.Description != nil { + _ = d.Set("description", unitRule.Description) + } + + if unitRule.UnitRuleItemList != nil { + unitRuleItemListList := []interface{}{} + for _, unitRuleItemList := range unitRule.UnitRuleItemList { + unitRuleItemListMap := map[string]interface{}{} + + if unitRuleItemList.Relationship != nil { + unitRuleItemListMap["relationship"] = unitRuleItemList.Relationship + } + + if unitRuleItemList.DestNamespaceId != nil { + unitRuleItemListMap["dest_namespace_id"] = unitRuleItemList.DestNamespaceId + } + + if unitRuleItemList.DestNamespaceName != nil { + unitRuleItemListMap["dest_namespace_name"] = unitRuleItemList.DestNamespaceName + } + + if unitRuleItemList.Name != nil { + unitRuleItemListMap["name"] = unitRuleItemList.Name + } + + if unitRuleItemList.Id != nil { + unitRuleItemListMap["id"] = unitRuleItemList.Id + } + + if unitRuleItemList.UnitRuleId != nil { + unitRuleItemListMap["unit_rule_id"] = unitRuleItemList.UnitRuleId + } + + if unitRuleItemList.Priority != nil { + unitRuleItemListMap["priority"] = unitRuleItemList.Priority + } + + if unitRuleItemList.Description != nil { + unitRuleItemListMap["description"] = unitRuleItemList.Description + } + + if unitRuleItemList.UnitRuleTagList != nil { + unitRuleTagListList := []interface{}{} + for _, unitRuleTagList := range unitRuleItemList.UnitRuleTagList { + unitRuleTagListMap := map[string]interface{}{} + + if unitRuleTagList.TagType != nil { + unitRuleTagListMap["tag_type"] = unitRuleTagList.TagType + } + + if unitRuleTagList.TagField != nil { + unitRuleTagListMap["tag_field"] = unitRuleTagList.TagField + } + + if unitRuleTagList.TagOperator != nil { + unitRuleTagListMap["tag_operator"] = unitRuleTagList.TagOperator + } + + if unitRuleTagList.TagValue != nil { + unitRuleTagListMap["tag_value"] = unitRuleTagList.TagValue + } + + if unitRuleTagList.UnitRuleItemId != nil { + unitRuleTagListMap["unit_rule_item_id"] = unitRuleTagList.UnitRuleItemId + } + + if unitRuleTagList.Id != nil { + unitRuleTagListMap["id"] = unitRuleTagList.Id + } + + unitRuleTagListList = append(unitRuleTagListList, unitRuleTagListMap) + } + + unitRuleItemListMap["unit_rule_tag_list"] = []interface{}{unitRuleTagListList} + } + + unitRuleItemListList = append(unitRuleItemListList, unitRuleItemListMap) + } + + _ = d.Set("unit_rule_item_list", unitRuleItemListList) + + } + + return nil +} + +func resourceTencentCloudTsfUnitRuleUpdate(d *schema.ResourceData, meta interface{}) error { + defer logElapsed("resource.tencentcloud_tsf_unit_rule.update")() + defer inconsistentCheck(d, meta)() + + logId := getLogId(contextNil) + + request := tsf.NewUpdateUnitRuleRequest() + + id := d.Id() + + request.Id = &id + + immutableArgs := []string{"gateway_instance_id", "name", "id", "status", "description", "unit_rule_item_list"} + + for _, v := range immutableArgs { + if d.HasChange(v) { + return fmt.Errorf("argument `%s` cannot be changed", v) + } + } + + if d.HasChange("name") { + if v, ok := d.GetOk("name"); ok { + request.Name = helper.String(v.(string)) + } + } + + if d.HasChange("description") { + if v, ok := d.GetOk("description"); ok { + request.Description = helper.String(v.(string)) + } + } + + if d.HasChange("unit_rule_item_list") { + if v, ok := d.GetOk("unit_rule_item_list"); ok { + for _, item := range v.([]interface{}) { + dMap := item.(map[string]interface{}) + unitRuleItem := tsf.UnitRuleItem{} + if v, ok := dMap["relationship"]; ok { + unitRuleItem.Relationship = helper.String(v.(string)) + } + if v, ok := dMap["dest_namespace_id"]; ok { + unitRuleItem.DestNamespaceId = helper.String(v.(string)) + } + if v, ok := dMap["dest_namespace_name"]; ok { + unitRuleItem.DestNamespaceName = helper.String(v.(string)) + } + if v, ok := dMap["name"]; ok { + unitRuleItem.Name = helper.String(v.(string)) + } + if v, ok := dMap["id"]; ok { + unitRuleItem.Id = helper.String(v.(string)) + } + if v, ok := dMap["unit_rule_id"]; ok { + unitRuleItem.UnitRuleId = helper.String(v.(string)) + } + if v, ok := dMap["priority"]; ok { + unitRuleItem.Priority = helper.IntInt64(v.(int)) + } + if v, ok := dMap["description"]; ok { + unitRuleItem.Description = helper.String(v.(string)) + } + if v, ok := dMap["unit_rule_tag_list"]; ok { + for _, item := range v.([]interface{}) { + unitRuleTagListMap := item.(map[string]interface{}) + unitRuleTag := tsf.UnitRuleTag{} + if v, ok := unitRuleTagListMap["tag_type"]; ok { + unitRuleTag.TagType = helper.String(v.(string)) + } + if v, ok := unitRuleTagListMap["tag_field"]; ok { + unitRuleTag.TagField = helper.String(v.(string)) + } + if v, ok := unitRuleTagListMap["tag_operator"]; ok { + unitRuleTag.TagOperator = helper.String(v.(string)) + } + if v, ok := unitRuleTagListMap["tag_value"]; ok { + unitRuleTag.TagValue = helper.String(v.(string)) + } + if v, ok := unitRuleTagListMap["unit_rule_item_id"]; ok { + unitRuleTag.UnitRuleItemId = helper.String(v.(string)) + } + if v, ok := unitRuleTagListMap["id"]; ok { + unitRuleTag.Id = helper.String(v.(string)) + } + unitRuleItem.UnitRuleTagList = append(unitRuleItem.UnitRuleTagList, &unitRuleTag) + } + } + request.UnitRuleItemList = append(request.UnitRuleItemList, &unitRuleItem) + } + } + } + + err := resource.Retry(writeRetryTimeout, func() *resource.RetryError { + result, e := meta.(*TencentCloudClient).apiV3Conn.UseTsfClient().UpdateUnitRule(request) + if e != nil { + return 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 update tsf unitRule failed, reason:%+v", logId, err) + return err + } + + return resourceTencentCloudTsfUnitRuleRead(d, meta) +} + +func resourceTencentCloudTsfUnitRuleDelete(d *schema.ResourceData, meta interface{}) error { + defer logElapsed("resource.tencentcloud_tsf_unit_rule.delete")() + defer inconsistentCheck(d, meta)() + + logId := getLogId(contextNil) + ctx := context.WithValue(context.TODO(), logIdKey, logId) + + service := TsfService{client: meta.(*TencentCloudClient).apiV3Conn} + id := d.Id() + + if err := service.DeleteTsfUnitRuleById(ctx, id); err != nil { + return err + } + + return nil +} diff --git a/tencentcloud/resource_tc_tsf_unit_rule_test.go b/tencentcloud/resource_tc_tsf_unit_rule_test.go new file mode 100644 index 0000000000..ba4c13e9c1 --- /dev/null +++ b/tencentcloud/resource_tc_tsf_unit_rule_test.go @@ -0,0 +1,56 @@ +package tencentcloud + +import ( + "github.com/hashicorp/terraform-plugin-sdk/helper/resource" + "testing" +) + +func TestAccTencentCloudTsfUnitRuleResource_basic(t *testing.T) { + t.Parallel() + resource.Test(t, resource.TestCase{ + PreCheck: func() { + testAccPreCheck(t) + }, + Providers: testAccProviders, + Steps: []resource.TestStep{ + { + Config: testAccTsfUnitRule, + Check: resource.ComposeTestCheckFunc(resource.TestCheckResourceAttrSet("tencentcloud_tsf_unit_rule.unit_rule", "id")), + }, + { + ResourceName: "tencentcloud_tsf_unit_rule.unit_rule", + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + +const testAccTsfUnitRule = ` + +resource "tencentcloud_tsf_unit_rule" "unit_rule" { + gateway_instance_id = "" + name = "" + description = "" + unit_rule_item_list { + relationship = "" + dest_namespace_id = "" + dest_namespace_name = "" + name = "" + id = "" + unit_rule_id = "" + priority = + description = "" + unit_rule_tag_list { + tag_type = "" + tag_field = "" + tag_operator = "" + tag_value = "" + unit_rule_item_id = "" + id = "" + } + + } +} + +` diff --git a/tencentcloud/service_tencentcloud_tsf.go b/tencentcloud/service_tencentcloud_tsf.go index 9cf71e4943..644d02f8d0 100644 --- a/tencentcloud/service_tencentcloud_tsf.go +++ b/tencentcloud/service_tencentcloud_tsf.go @@ -143,3 +143,644 @@ func (me *TsfService) DeleteTsfMicroserviceById(ctx context.Context, microservic return } + +func (me *TsfService) DescribeTsfApiGroupById(ctx context.Context, groupId string) (apiGroup *tsf.ApiGroupInfo, errRet error) { + logId := getLogId(ctx) + + request := tsf.NewDescribeApiGroupRequest() + request.GroupId = &groupId + + defer func() { + if errRet != nil { + log.Printf("[CRITAL]%s api[%s] fail, request body [%s], reason[%s]\n", logId, request.GetAction(), request.ToJsonString(), errRet.Error()) + } + }() + + ratelimit.Check(request.GetAction()) + + response, err := me.client.UseTsfClient().DescribeApiGroup(request) + if err != nil { + errRet = err + return + } + log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n", logId, request.GetAction(), request.ToJsonString(), response.ToJsonString()) + + if response.Response.Result == nil { + return + } + + apiGroup = response.Response.Result + return +} + +func (me *TsfService) DeleteTsfApiGroupById(ctx context.Context, groupId string) (errRet error) { + logId := getLogId(ctx) + + request := tsf.NewDeleteApiGroupRequest() + request.GroupId = &groupId + + defer func() { + if errRet != nil { + log.Printf("[CRITAL]%s api[%s] fail, request body [%s], reason[%s]\n", logId, request.GetAction(), request.ToJsonString(), errRet.Error()) + } + }() + + ratelimit.Check(request.GetAction()) + + response, err := me.client.UseTsfClient().DeleteApiGroup(request) + if err != nil { + errRet = err + return + } + log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n", logId, request.GetAction(), request.ToJsonString(), response.ToJsonString()) + + return +} + +func (me *TsfService) DescribeTsfApiRateLimitRuleById(ctx context.Context, apiId, ruleId string) (apiRateLimitRule *tsf.ApiRateLimitRule, errRet error) { + logId := getLogId(ctx) + + request := tsf.NewDescribeApiRateLimitRulesRequest() + request.ApiId = &apiId + + defer func() { + if errRet != nil { + log.Printf("[CRITAL]%s api[%s] fail, request body [%s], reason[%s]\n", logId, request.GetAction(), request.ToJsonString(), errRet.Error()) + } + }() + + ratelimit.Check(request.GetAction()) + + response, err := me.client.UseTsfClient().DescribeApiRateLimitRules(request) + if err != nil { + errRet = err + return + } + log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n", logId, request.GetAction(), request.ToJsonString(), response.ToJsonString()) + + if len(response.Response.Result) < 1 { + return + } + + for _, v := range response.Response.Result { + if *v.RuleId == ruleId { + apiRateLimitRule = v + return + } + } + + return +} + +// func (me *TsfService) DeleteTsfApiRateLimitRuleById(ctx context.Context, apiId, ruleId string) (errRet error) { +// logId := getLogId(ctx) + +// request := tsf.NewDeleteApiRateLimitRuleRequest() +// request.ApiId = &apiId + +// defer func() { +// if errRet != nil { +// log.Printf("[CRITAL]%s api[%s] fail, request body [%s], reason[%s]\n", logId, request.GetAction(), request.ToJsonString(), errRet.Error()) +// } +// }() + +// ratelimit.Check(request.GetAction()) + +// response, err := me.client.UseTsfClient().DeleteApiRateLimitRule(request) +// if err != nil { +// errRet = err +// return +// } +// log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n", logId, request.GetAction(), request.ToJsonString(), response.ToJsonString()) + +// return +// } + +func (me *TsfService) DescribeTsfConfigTemplateById(ctx context.Context, templateId string) (configTemplate *tsf.ConfigTemplate, errRet error) { + logId := getLogId(ctx) + + request := tsf.NewDescribeConfigTemplateRequest() + request.ConfigTemplateId = &templateId + + defer func() { + if errRet != nil { + log.Printf("[CRITAL]%s api[%s] fail, request body [%s], reason[%s]\n", logId, request.GetAction(), request.ToJsonString(), errRet.Error()) + } + }() + + ratelimit.Check(request.GetAction()) + + response, err := me.client.UseTsfClient().DescribeConfigTemplate(request) + if err != nil { + errRet = err + return + } + log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n", logId, request.GetAction(), request.ToJsonString(), response.ToJsonString()) + + if response.Response.Result == nil { + return + } + + configTemplate = response.Response.Result + return +} + +func (me *TsfService) DeleteTsfConfigTemplateById(ctx context.Context, templateId string) (errRet error) { + logId := getLogId(ctx) + + request := tsf.NewDeleteConfigTemplateRequest() + request.ConfigTemplateId = &templateId + + defer func() { + if errRet != nil { + log.Printf("[CRITAL]%s api[%s] fail, request body [%s], reason[%s]\n", logId, request.GetAction(), request.ToJsonString(), errRet.Error()) + } + }() + + ratelimit.Check(request.GetAction()) + + response, err := me.client.UseTsfClient().DeleteConfigTemplate(request) + if err != nil { + errRet = err + return + } + log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n", logId, request.GetAction(), request.ToJsonString(), response.ToJsonString()) + + return +} + +func (me *TsfService) DescribeTsfLaneById(ctx context.Context, laneId string) (lane *tsf.LaneInfo, errRet error) { + logId := getLogId(ctx) + + request := tsf.NewDescribeLanesRequest() + request.LaneIdList = []*string{&laneId} + + defer func() { + if errRet != nil { + log.Printf("[CRITAL]%s api[%s] fail, request body [%s], reason[%s]\n", logId, request.GetAction(), request.ToJsonString(), errRet.Error()) + } + }() + + ratelimit.Check(request.GetAction()) + + response, err := me.client.UseTsfClient().DescribeLanes(request) + if err != nil { + errRet = err + return + } + log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n", logId, request.GetAction(), request.ToJsonString(), response.ToJsonString()) + + if response.Response.Result == nil || len(response.Response.Result.Content) < 1 { + return + } + + lane = response.Response.Result.Content[0] + return +} + +func (me *TsfService) DeleteTsfLaneById(ctx context.Context, laneId string) (errRet error) { + logId := getLogId(ctx) + + request := tsf.NewDeleteLaneRequest() + request.LaneId = &laneId + + defer func() { + if errRet != nil { + log.Printf("[CRITAL]%s api[%s] fail, request body [%s], reason[%s]\n", logId, request.GetAction(), request.ToJsonString(), errRet.Error()) + } + }() + + ratelimit.Check(request.GetAction()) + + response, err := me.client.UseTsfClient().DeleteLane(request) + if err != nil { + errRet = err + return + } + log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n", logId, request.GetAction(), request.ToJsonString(), response.ToJsonString()) + + return +} + +func (me *TsfService) DescribeTsfLaneRuleById(ctx context.Context, ruleId string) (laneRule *tsf.LaneRule, errRet error) { + logId := getLogId(ctx) + + request := tsf.NewDescribeLaneRulesRequest() + request.RuleId = &ruleId + + defer func() { + if errRet != nil { + log.Printf("[CRITAL]%s api[%s] fail, request body [%s], reason[%s]\n", logId, request.GetAction(), request.ToJsonString(), errRet.Error()) + } + }() + + ratelimit.Check(request.GetAction()) + + response, err := me.client.UseTsfClient().DescribeLaneRules(request) + if err != nil { + errRet = err + return + } + log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n", logId, request.GetAction(), request.ToJsonString(), response.ToJsonString()) + + if response.Response.Result == nil || len(response.Response.Result.Content) < 1 { + return + } + + laneRule = response.Response.Result.Content[0] + return +} + +func (me *TsfService) DeleteTsfLaneRuleById(ctx context.Context, ruleId string) (errRet error) { + logId := getLogId(ctx) + + request := tsf.NewDeleteLaneRuleRequest() + request.RuleId = &ruleId + + defer func() { + if errRet != nil { + log.Printf("[CRITAL]%s api[%s] fail, request body [%s], reason[%s]\n", logId, request.GetAction(), request.ToJsonString(), errRet.Error()) + } + }() + + ratelimit.Check(request.GetAction()) + + response, err := me.client.UseTsfClient().DeleteLaneRule(request) + if err != nil { + errRet = err + return + } + log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n", logId, request.GetAction(), request.ToJsonString(), response.ToJsonString()) + + return +} + +func (me *TsfService) DescribeTsfNamespaceById(ctx context.Context, namespaceId string) (namespace *tsf.Namespace, errRet error) { + logId := getLogId(ctx) + + request := tsf.NewDescribeSimpleNamespacesRequest() + request.NamespaceId = &namespaceId + + defer func() { + if errRet != nil { + log.Printf("[CRITAL]%s api[%s] fail, request body [%s], reason[%s]\n", logId, request.GetAction(), request.ToJsonString(), errRet.Error()) + } + }() + + ratelimit.Check(request.GetAction()) + + response, err := me.client.UseTsfClient().DescribeSimpleNamespaces(request) + if err != nil { + errRet = err + return + } + log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n", logId, request.GetAction(), request.ToJsonString(), response.ToJsonString()) + + if response.Response.Result == nil || len(response.Response.Result.Content) < 1 { + return + } + + namespace = response.Response.Result.Content[0] + return +} + +func (me *TsfService) DeleteTsfNamespaceById(ctx context.Context, namespaceId string) (errRet error) { + logId := getLogId(ctx) + + request := tsf.NewDeleteNamespaceRequest() + request.NamespaceId = &namespaceId + + defer func() { + if errRet != nil { + log.Printf("[CRITAL]%s api[%s] fail, request body [%s], reason[%s]\n", logId, request.GetAction(), request.ToJsonString(), errRet.Error()) + } + }() + + ratelimit.Check(request.GetAction()) + + response, err := me.client.UseTsfClient().DeleteNamespace(request) + if err != nil { + errRet = err + return + } + log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n", logId, request.GetAction(), request.ToJsonString(), response.ToJsonString()) + + return +} +func (me *TsfService) DescribeTsfPathRewriteById(ctx context.Context, pathRewriteId string) (pathRewrite *tsf.PathRewrite, errRet error) { + logId := getLogId(ctx) + + request := tsf.NewDescribePathRewriteRequest() + request.PathRewriteId = &pathRewriteId + + defer func() { + if errRet != nil { + log.Printf("[CRITAL]%s api[%s] fail, request body [%s], reason[%s]\n", logId, request.GetAction(), request.ToJsonString(), errRet.Error()) + } + }() + + ratelimit.Check(request.GetAction()) + + response, err := me.client.UseTsfClient().DescribePathRewrite(request) + if err != nil { + errRet = err + return + } + log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n", logId, request.GetAction(), request.ToJsonString(), response.ToJsonString()) + + if response.Response.Result == nil { + return + } + + pathRewrite = response.Response.Result + return +} + +func (me *TsfService) DeleteTsfPathRewriteById(ctx context.Context, pathRewriteId string) (errRet error) { + logId := getLogId(ctx) + + request := tsf.NewDeletePathRewritesRequest() + request.PathRewriteIds = []*string{&pathRewriteId} + + defer func() { + if errRet != nil { + log.Printf("[CRITAL]%s api[%s] fail, request body [%s], reason[%s]\n", logId, request.GetAction(), request.ToJsonString(), errRet.Error()) + } + }() + + ratelimit.Check(request.GetAction()) + + response, err := me.client.UseTsfClient().DeletePathRewrites(request) + if err != nil { + errRet = err + return + } + log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n", logId, request.GetAction(), request.ToJsonString(), response.ToJsonString()) + + return +} + +func (me *TsfService) DescribeTsfRepositoryById(ctx context.Context, repositoryId string) (repository *tsf.RepositoryInfo, errRet error) { + logId := getLogId(ctx) + + request := tsf.NewDescribeRepositoryRequest() + request.RepositoryId = &repositoryId + + defer func() { + if errRet != nil { + log.Printf("[CRITAL]%s api[%s] fail, request body [%s], reason[%s]\n", logId, request.GetAction(), request.ToJsonString(), errRet.Error()) + } + }() + + ratelimit.Check(request.GetAction()) + + response, err := me.client.UseTsfClient().DescribeRepository(request) + if err != nil { + errRet = err + return + } + log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n", logId, request.GetAction(), request.ToJsonString(), response.ToJsonString()) + + if response.Response.Result == nil { + return + } + + repository = response.Response.Result + return +} + +func (me *TsfService) DeleteTsfRepositoryById(ctx context.Context, repositoryId string) (errRet error) { + logId := getLogId(ctx) + + request := tsf.NewDeleteRepositoryRequest() + request.RepositoryId = &repositoryId + + defer func() { + if errRet != nil { + log.Printf("[CRITAL]%s api[%s] fail, request body [%s], reason[%s]\n", logId, request.GetAction(), request.ToJsonString(), errRet.Error()) + } + }() + + ratelimit.Check(request.GetAction()) + + response, err := me.client.UseTsfClient().DeleteRepository(request) + if err != nil { + errRet = err + return + } + log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n", logId, request.GetAction(), request.ToJsonString(), response.ToJsonString()) + + return +} + +func (me *TsfService) DescribeTsfTaskById(ctx context.Context, taskId string) (task *tsf.TaskRecord, errRet error) { + logId := getLogId(ctx) + + request := tsf.NewDescribeTaskDetailRequest() + request.TaskId = &taskId + + defer func() { + if errRet != nil { + log.Printf("[CRITAL]%s api[%s] fail, request body [%s], reason[%s]\n", logId, request.GetAction(), request.ToJsonString(), errRet.Error()) + } + }() + + ratelimit.Check(request.GetAction()) + + response, err := me.client.UseTsfClient().DescribeTaskDetail(request) + if err != nil { + errRet = err + return + } + log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n", logId, request.GetAction(), request.ToJsonString(), response.ToJsonString()) + + if response.Response.Result == nil { + return + } + + task = response.Response.Result + return +} + +func (me *TsfService) DeleteTsfTaskById(ctx context.Context, taskId string) (errRet error) { + logId := getLogId(ctx) + + request := tsf.NewDeleteTaskRequest() + request.TaskId = &taskId + + defer func() { + if errRet != nil { + log.Printf("[CRITAL]%s api[%s] fail, request body [%s], reason[%s]\n", logId, request.GetAction(), request.ToJsonString(), errRet.Error()) + } + }() + + ratelimit.Check(request.GetAction()) + + response, err := me.client.UseTsfClient().DeleteTask(request) + if err != nil { + errRet = err + return + } + log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n", logId, request.GetAction(), request.ToJsonString(), response.ToJsonString()) + + return +} + +func (me *TsfService) DescribeTsfUnitRuleById(ctx context.Context, id string) (unitRule *tsf.UnitRule, errRet error) { + logId := getLogId(ctx) + + request := tsf.NewDescribeUnitRuleRequest() + request.Id = &id + + defer func() { + if errRet != nil { + log.Printf("[CRITAL]%s api[%s] fail, request body [%s], reason[%s]\n", logId, request.GetAction(), request.ToJsonString(), errRet.Error()) + } + }() + + ratelimit.Check(request.GetAction()) + + response, err := me.client.UseTsfClient().DescribeUnitRule(request) + if err != nil { + errRet = err + return + } + log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n", logId, request.GetAction(), request.ToJsonString(), response.ToJsonString()) + + if response.Response.Result == nil { + return + } + + unitRule = response.Response.Result + return +} + +func (me *TsfService) DeleteTsfUnitRuleById(ctx context.Context, id string) (errRet error) { + logId := getLogId(ctx) + + request := tsf.NewDeleteUnitRuleRequest() + request.Id = &id + + defer func() { + if errRet != nil { + log.Printf("[CRITAL]%s api[%s] fail, request body [%s], reason[%s]\n", logId, request.GetAction(), request.ToJsonString(), errRet.Error()) + } + }() + + ratelimit.Check(request.GetAction()) + + response, err := me.client.UseTsfClient().DeleteUnitRule(request) + if err != nil { + errRet = err + return + } + log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n", logId, request.GetAction(), request.ToJsonString(), response.ToJsonString()) + + return +} +func (me *TsfService) DescribeTsfContainGroupById(ctx context.Context, groupId string) (containGroup *tsf.ContainerGroupDetail, errRet error) { + logId := getLogId(ctx) + + request := tsf.NewDescribeContainerGroupDetailRequest() + request.GroupId = &groupId + + defer func() { + if errRet != nil { + log.Printf("[CRITAL]%s api[%s] fail, request body [%s], reason[%s]\n", logId, request.GetAction(), request.ToJsonString(), errRet.Error()) + } + }() + + ratelimit.Check(request.GetAction()) + + response, err := me.client.UseTsfClient().DescribeContainerGroupDetail(request) + if err != nil { + errRet = err + return + } + log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n", logId, request.GetAction(), request.ToJsonString(), response.ToJsonString()) + + if response.Response.Result == nil { + return + } + + containGroup = response.Response.Result + return +} + +func (me *TsfService) DeleteTsfContainGroupById(ctx context.Context, groupId string) (errRet error) { + logId := getLogId(ctx) + + request := tsf.NewDeleteContainerGroupRequest() + request.GroupId = &groupId + + defer func() { + if errRet != nil { + log.Printf("[CRITAL]%s api[%s] fail, request body [%s], reason[%s]\n", logId, request.GetAction(), request.ToJsonString(), errRet.Error()) + } + }() + + ratelimit.Check(request.GetAction()) + + response, err := me.client.UseTsfClient().DeleteContainerGroup(request) + if err != nil { + errRet = err + return + } + log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n", logId, request.GetAction(), request.ToJsonString(), response.ToJsonString()) + + return +} + +func (me *TsfService) DescribeTsfApplicationReleaseConfigById(ctx context.Context, configId string, groupId string) (applicationReleaseConfig *tsf.ConfigRelease, errRet error) { + logId := getLogId(ctx) + + request := tsf.NewDescribeConfigReleasesRequest() + request.ConfigId = &configId + request.GroupId = &groupId + + defer func() { + if errRet != nil { + log.Printf("[CRITAL]%s api[%s] fail, request body [%s], reason[%s]\n", logId, request.GetAction(), request.ToJsonString(), errRet.Error()) + } + }() + + ratelimit.Check(request.GetAction()) + + response, err := me.client.UseTsfClient().DescribeConfigReleases(request) + if err != nil { + errRet = err + return + } + log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n", logId, request.GetAction(), request.ToJsonString(), response.ToJsonString()) + + if response.Response.Result == nil || len(response.Response.Result.Content) < 1 { + return + } + + applicationReleaseConfig = response.Response.Result.Content[0] + return +} + +func (me *TsfService) DeleteTsfApplicationReleaseConfigById(ctx context.Context, configId string) (errRet error) { + logId := getLogId(ctx) + + request := tsf.NewRevocationConfigRequest() + request.ConfigReleaseId = &configId + + defer func() { + if errRet != nil { + log.Printf("[CRITAL]%s api[%s] fail, request body [%s], reason[%s]\n", logId, request.GetAction(), request.ToJsonString(), errRet.Error()) + } + }() + + ratelimit.Check(request.GetAction()) + + response, err := me.client.UseTsfClient().RevocationConfig(request) + if err != nil { + errRet = err + return + } + log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n", logId, request.GetAction(), request.ToJsonString(), response.ToJsonString()) + + return +} From 252d02d5ee1b16764fb576184839b141e7724f0f Mon Sep 17 00:00:00 2001 From: anonymous Date: Wed, 1 Feb 2023 01:16:10 +0800 Subject: [PATCH 02/11] feat: support tsf --- go.mod | 4 +- go.sum | 4 + tencentcloud/provider.go | 14 + tencentcloud/resource_tc_tsf_api_group.go | 30 +- .../resource_tc_tsf_api_group_test.go | 90 +- tencentcloud/resource_tc_tsf_lane.go | 31 +- tencentcloud/resource_tc_tsf_lane_rule.go | 3 +- tencentcloud/resource_tc_tsf_lane_test.go | 105 +- tencentcloud/resource_tc_tsf_namespace.go | 432 +----- .../resource_tc_tsf_namespace_test.go | 85 +- .../tencentcloud/common/http/request.go | 2 +- .../tencentcloud/tsf/v20180326/client.go | 786 +++++++++++ .../tencentcloud/tsf/v20180326/errors.go | 63 + .../tencentcloud/tsf/v20180326/models.go | 1253 ++++++++++++++++- vendor/modules.txt | 4 +- website/docs/r/tsf_api_group.html.markdown | 75 + website/docs/r/tsf_namespace.html.markdown | 65 + website/tencentcloud.erb | 6 + 18 files changed, 2515 insertions(+), 537 deletions(-) create mode 100644 website/docs/r/tsf_api_group.html.markdown create mode 100644 website/docs/r/tsf_namespace.html.markdown diff --git a/go.mod b/go.mod index f8c309a265..dcf3eb9819 100644 --- a/go.mod +++ b/go.mod @@ -35,7 +35,7 @@ require ( github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/clb v1.0.445 github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cloudaudit v1.0.544 github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cls v1.0.412 - github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.578 + github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.584 github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cvm v1.0.553 github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cynosdb v1.0.572 github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/dayu v1.0.335 @@ -77,7 +77,7 @@ require ( github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tem v1.0.578 github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/teo v1.0.529 github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tke v1.0.549 - github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tsf v1.0.577 + github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tsf v1.0.584 github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/vod v1.0.199 github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/vpc v1.0.569 github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/wss v1.0.199 diff --git a/go.sum b/go.sum index cf99ffdeac..f055aedbe4 100644 --- a/go.sum +++ b/go.sum @@ -559,6 +559,8 @@ github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.576/go.mod github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.577/go.mod h1:7sCQWVkxcsR38nffDW057DRGk8mUjK1Ing/EFOK8s8Y= github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.578 h1:dfSNB1i1dOgGQ/WBAlWax7iLFAIiodDSr9xDIwPNLDM= github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.578/go.mod h1:7sCQWVkxcsR38nffDW057DRGk8mUjK1Ing/EFOK8s8Y= +github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.584 h1:FbppCUoExsYKd8orUHqcTJacEIGgFcTyvzdFNMb/7zI= +github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.584/go.mod h1:7sCQWVkxcsR38nffDW057DRGk8mUjK1Ing/EFOK8s8Y= github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cvm v1.0.445 h1:Bh7XD0ypNMHYyBOM8hhKsSu+y0VVKUnJVS+YKKhfpGg= github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cvm v1.0.445/go.mod h1:jMDD351efCFpT1+KVFbcpu6SbmP4TYmp4qkoCfr63nQ= github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cvm v1.0.553 h1:Pl1kYgFhJp0QSoVFSzRsiGk+HfEAkBTQg7+O60tytNA= @@ -670,6 +672,8 @@ github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tke v1.0.549 h1:WWKxOUM github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tke v1.0.549/go.mod h1:UPffPhIo23aJ3N40bwWhxhr0fIR9jn0Lfboxh17km8E= github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tsf v1.0.577 h1:IR6FJYLGSQ6isnbGQon6E9Ucc4PEUE+d3l9+/4pnH70= github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tsf v1.0.577/go.mod h1:6cRxUX1QsRcd9EHDg1BVBlC524oupmN0DuAFGAdJLC0= +github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tsf v1.0.584 h1:gejIVfoHRqvbR0Znt6DJlpsA3Z9cutUmbdhdWb4gZK4= +github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tsf v1.0.584/go.mod h1:Qs+sspd2V1hRAn7WmK6K3iu3M+F+azX1ryFgsZbGGg4= github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/vod v1.0.199 h1:6Yt74l4pA5QtzhwMNIEUt0spXdSBKH744DDqTHJOCP0= github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/vod v1.0.199/go.mod h1:Yw6OQ33z3s4k0HVYTNSffB12qOzEJ2Zf1Vj4+5S3sRs= github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/vpc v1.0.515 h1:OWA3zSqC+tY42DwnlzAZVNYkB5dWgcwk435n+84jXNM= diff --git a/tencentcloud/provider.go b/tencentcloud/provider.go index 5756e64f50..6fb1246857 100644 --- a/tencentcloud/provider.go +++ b/tencentcloud/provider.go @@ -923,6 +923,8 @@ Tencent Service Framework(TSF) Resource tencentcloud_tsf_microservice tencentcloud_tsf_application_config + tencentcloud_tsf_api_group + tencentcloud_tsf_namespace */ package tencentcloud @@ -1636,6 +1638,18 @@ func Provider() terraform.ResourceProvider { "tencentcloud_dayu_ddos_ip_attachment_v2": resourceTencentCloudDayuDDosIpAttachmentV2(), "tencentcloud_tsf_microservice": resourceTencentCloudTsfMicroservice(), "tencentcloud_tsf_application_config": resourceTencentCloudTsfApplicationConfig(), + "tencentcloud_tsf_api_group": resourceTencentCloudTsfApiGroup(), + "tencentcloud_tsf_namespace": resourceTencentCloudTsfNamespace(), + // "tencentcloud_tsf_path_rewrite": resourceTencentCloudTsfPathRewrite(), + // "tencentcloud_tsf_unit_rule": resourceTencentCloudTsfUnitRule(), + // "tencentcloud_tsf_task": resourceTencentCloudTsfTask(), + // "tencentcloud_tsf_repository": resourceTencentCloudTsfRepository(), + // "tencentcloud_tsf_config_template": resourceTencentCloudTsfConfigTemplate(), + // "tencentcloud_tsf_api_rate_limit_rule": resourceTencentCloudTsfApiRateLimitRule(), + // "tencentcloud_tsf_application_release_config": resourceTencentCloudTsfApplicationReleaseConfig(), + // "tencentcloud_tsf_contain_group": resourceTencentCloudTsfContainGroup(), + // "tencentcloud_tsf_lane": resourceTencentCloudTsfLane(), + // "tencentcloud_tsf_lane_rule": resourceTencentCloudTsfLaneRule(), }, ConfigureFunc: providerConfigure, diff --git a/tencentcloud/resource_tc_tsf_api_group.go b/tencentcloud/resource_tc_tsf_api_group.go index 339138f906..628da4327f 100644 --- a/tencentcloud/resource_tc_tsf_api_group.go +++ b/tencentcloud/resource_tc_tsf_api_group.go @@ -5,16 +5,16 @@ Example Usage ```hcl resource "tencentcloud_tsf_api_group" "api_group" { - group_name = "" - group_context = "" - auth_type = "" - description = "" - group_type = "" - gateway_instance_id = "" - namespace_name_key = "" - service_name_key = "" - namespace_name_key_position = "" - service_name_key_position = "" + group_name = "terraform_test_group" + group_context = "/terraform-test" + auth_type = "none" + description = "terraform-test" + group_type = "ms" + gateway_instance_id = "gw-ins-i6mjpgm8" + # namespace_name_key = "path" + # service_name_key = "path" + namespace_name_key_position = "path" + service_name_key_position = "path" } ``` @@ -386,7 +386,7 @@ func resourceTencentCloudTsfApiGroupRead(d *schema.ResourceData, meta interface{ bindedGatewayDeployGroupsList = append(bindedGatewayDeployGroupsList, bindedGatewayDeployGroupsMap) } - _ = d.Set("binded_gateway_deploy_groups", []interface{}{bindedGatewayDeployGroupsList}) + _ = d.Set("binded_gateway_deploy_groups", bindedGatewayDeployGroupsList) } if apiGroup.ApiCount != nil { @@ -416,7 +416,7 @@ func resourceTencentCloudTsfApiGroupUpdate(d *schema.ResourceData, meta interfac request.GroupId = &groupId - immutableArgs := []string{"group_name", "group_context", "auth_type", "description", "group_type", "gateway_instance_id", "namespace_name_key", "service_name_key", "namespace_name_key_position", "service_name_key_position", "result"} + immutableArgs := []string{"group_name", "group_type", "gateway_instance_id"} for _, v := range immutableArgs { if d.HasChange(v) { @@ -424,12 +424,6 @@ func resourceTencentCloudTsfApiGroupUpdate(d *schema.ResourceData, meta interfac } } - if d.HasChange("group_name") { - if v, ok := d.GetOk("group_name"); ok { - request.GroupName = helper.String(v.(string)) - } - } - if d.HasChange("group_context") { if v, ok := d.GetOk("group_context"); ok { request.GroupContext = helper.String(v.(string)) diff --git a/tencentcloud/resource_tc_tsf_api_group_test.go b/tencentcloud/resource_tc_tsf_api_group_test.go index 2394c4a372..d788a48043 100644 --- a/tencentcloud/resource_tc_tsf_api_group_test.go +++ b/tencentcloud/resource_tc_tsf_api_group_test.go @@ -1,21 +1,38 @@ package tencentcloud import ( - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" + "context" + "fmt" "testing" + + "github.com/hashicorp/terraform-plugin-sdk/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/terraform" ) -func TestAccTencentCloudTsfApiGroupResource_basic(t *testing.T) { +// go test -i; go test -test.run TestAccTencentCloudTsfApiGroupResource_basic -v +func TestAccTencentCloudNeedFixTsfApiGroupResource_basic(t *testing.T) { t.Parallel() + resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, + Providers: testAccProviders, + CheckDestroy: testAccCheckTsfApiGroupDestroy, Steps: []resource.TestStep{ { Config: testAccTsfApiGroup, - Check: resource.ComposeTestCheckFunc(resource.TestCheckResourceAttrSet("tencentcloud_tsf_api_group.api_group", "id")), + Check: resource.ComposeTestCheckFunc( + testAccCheckTsfApiGroupExists("tencentcloud_tsf_api_group.api_group"), + resource.TestCheckResourceAttrSet("tencentcloud_tsf_api_group.api_group", "id"), + resource.TestCheckResourceAttr("tencentcloud_tsf_api_group.api_group", "group_name", "terraform_test_group"), + resource.TestCheckResourceAttr("tencentcloud_tsf_api_group.api_group", "group_context", "/terraform-test"), + resource.TestCheckResourceAttr("tencentcloud_tsf_api_group.api_group", "auth_type", "none"), + resource.TestCheckResourceAttr("tencentcloud_tsf_api_group.api_group", "description", "terraform-test"), + resource.TestCheckResourceAttr("tencentcloud_tsf_api_group.api_group", "group_type", "ms"), + resource.TestCheckResourceAttr("tencentcloud_tsf_api_group.api_group", "namespace_name_key_position", "path"), + resource.TestCheckResourceAttr("tencentcloud_tsf_api_group.api_group", "service_name_key_position", "path"), + ), }, { ResourceName: "tencentcloud_tsf_api_group.api_group", @@ -26,19 +43,64 @@ func TestAccTencentCloudTsfApiGroupResource_basic(t *testing.T) { }) } +func testAccCheckTsfApiGroupDestroy(s *terraform.State) error { + logId := getLogId(contextNil) + ctx := context.WithValue(context.TODO(), logIdKey, logId) + service := TsfService{client: testAccProvider.Meta().(*TencentCloudClient).apiV3Conn} + for _, rs := range s.RootModule().Resources { + if rs.Type != "tencentcloud_tsf_api_group" { + continue + } + + res, err := service.DescribeTsfApiGroupById(ctx, rs.Primary.ID) + if err != nil { + return err + } + + if res != nil { + return fmt.Errorf("tsf api group %s still exists", rs.Primary.ID) + } + } + return nil +} + +func testAccCheckTsfApiGroupExists(r string) resource.TestCheckFunc { + return func(s *terraform.State) error { + logId := getLogId(contextNil) + ctx := context.WithValue(context.TODO(), logIdKey, logId) + + rs, ok := s.RootModule().Resources[r] + if !ok { + return fmt.Errorf("resource %s is not found", r) + } + + service := TsfService{client: testAccProvider.Meta().(*TencentCloudClient).apiV3Conn} + res, err := service.DescribeTsfApiGroupById(ctx, rs.Primary.ID) + if err != nil { + return err + } + + if res == nil { + return fmt.Errorf("tsf api group %s is not found", rs.Primary.ID) + } + + return nil + } +} + const testAccTsfApiGroup = ` resource "tencentcloud_tsf_api_group" "api_group" { - group_name = "" - group_context = "" - auth_type = "" - description = "" - group_type = "" - gateway_instance_id = "" - namespace_name_key = "" - service_name_key = "" - namespace_name_key_position = "" - service_name_key_position = "" + group_name = "terraform_test_group" + group_context = "/terraform-test" + auth_type = "none" + description = "terraform-test" + group_type = "ms" + gateway_instance_id = "gw-ins-i6mjpgm8" + # namespace_name_key = "path" + # service_name_key = "path" + namespace_name_key_position = "path" + service_name_key_position = "path" } ` diff --git a/tencentcloud/resource_tc_tsf_lane.go b/tencentcloud/resource_tc_tsf_lane.go index f2923bc04e..6b90f1208d 100644 --- a/tencentcloud/resource_tc_tsf_lane.go +++ b/tencentcloud/resource_tc_tsf_lane.go @@ -5,23 +5,22 @@ Example Usage ```hcl resource "tencentcloud_tsf_lane" "lane" { - lane_name = "" - remark = "" + lane_name = "lane-name-1" + remark = "lane desc1" lane_group_list { - group_id = "" - entrance = - lane_group_id = "" - lane_id = "" - group_name = "" - application_id = "" - application_name = "" - namespace_id = "" - namespace_name = "" - create_time = - update_time = - cluster_type = "" + group_id = "group-yn7j5l8a" + entrance = true + # lane_group_id = "" + # lane_id = "" + # group_name = "" + # application_id = "" + # application_name = "" + # namespace_id = "" + # namespace_name = "" + # create_time = + # update_time = + # cluster_type = "" } - program_id_list = } ``` @@ -400,7 +399,7 @@ func resourceTencentCloudTsfLaneUpdate(d *schema.ResourceData, meta interface{}) request.LaneId = &laneId - immutableArgs := []string{"lane_name", "remark", "lane_group_list", "program_id_list", "result"} + immutableArgs := []string{"lane_group_list", "program_id_list", "result"} for _, v := range immutableArgs { if d.HasChange(v) { diff --git a/tencentcloud/resource_tc_tsf_lane_rule.go b/tencentcloud/resource_tc_tsf_lane_rule.go index 53157f884a..5131a98888 100644 --- a/tencentcloud/resource_tc_tsf_lane_rule.go +++ b/tencentcloud/resource_tc_tsf_lane_rule.go @@ -109,7 +109,8 @@ func resourceTencentCloudTsfLaneRule() *schema.Resource { }, "update_time": { Type: schema.TypeInt, - Required: true, + Optional: true, + Computed: true, Description: "update time.", }, }, diff --git a/tencentcloud/resource_tc_tsf_lane_test.go b/tencentcloud/resource_tc_tsf_lane_test.go index d1e7a7e82c..e9d9c1d66c 100644 --- a/tencentcloud/resource_tc_tsf_lane_test.go +++ b/tencentcloud/resource_tc_tsf_lane_test.go @@ -1,21 +1,35 @@ package tencentcloud import ( - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" + "context" + "fmt" "testing" + + "github.com/hashicorp/terraform-plugin-sdk/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/terraform" ) -func TestAccTencentCloudTsfLaneResource_basic(t *testing.T) { +func TestAccTencentCloudNeedFixTsfLaneResource_basic(t *testing.T) { t.Parallel() + resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, + Providers: testAccProviders, + CheckDestroy: testAccCheckTsfLaneDestroy, Steps: []resource.TestStep{ { - Config: testAccTsfLane, - Check: resource.ComposeTestCheckFunc(resource.TestCheckResourceAttrSet("tencentcloud_tsf_lane.lane", "id")), + Config: testAccTsfNamespace, + Check: resource.ComposeTestCheckFunc( + testAccCheckTsfLaneExists("tencentcloud_tsf_lane.lane"), + resource.TestCheckResourceAttrSet("tencentcloud_tsf_lane.lane", "id"), + resource.TestCheckResourceAttr("tencentcloud_tsf_lane.lane", "lane_name", "lane-name"), + resource.TestCheckResourceAttr("tencentcloud_tsf_lane.lane", "remark", "lane desc"), + resource.TestCheckResourceAttr("tencentcloud_tsf_lane.lane", "lane_group_list.#", "1"), + resource.TestCheckResourceAttr("tencentcloud_tsf_lane.lane", "lane_group_list.0.group_id", "group-yn7j5l8a"), + resource.TestCheckResourceAttr("tencentcloud_tsf_lane.lane", "lane_group_list.0.entrance", "true"), + ), }, { ResourceName: "tencentcloud_tsf_lane.lane", @@ -26,27 +40,70 @@ func TestAccTencentCloudTsfLaneResource_basic(t *testing.T) { }) } +func testAccCheckTsfLaneDestroy(s *terraform.State) error { + logId := getLogId(contextNil) + ctx := context.WithValue(context.TODO(), logIdKey, logId) + service := TsfService{client: testAccProvider.Meta().(*TencentCloudClient).apiV3Conn} + for _, rs := range s.RootModule().Resources { + if rs.Type != "tencentcloud_tsf_lane" { + continue + } + + res, err := service.DescribeTsfLaneById(ctx, rs.Primary.ID) + if err != nil { + return err + } + + if res != nil { + return fmt.Errorf("tsf lane %s still exists", rs.Primary.ID) + } + } + return nil +} + +func testAccCheckTsfLaneExists(r string) resource.TestCheckFunc { + return func(s *terraform.State) error { + logId := getLogId(contextNil) + ctx := context.WithValue(context.TODO(), logIdKey, logId) + + rs, ok := s.RootModule().Resources[r] + if !ok { + return fmt.Errorf("resource %s is not found", r) + } + + service := TsfService{client: testAccProvider.Meta().(*TencentCloudClient).apiV3Conn} + res, err := service.DescribeTsfLaneById(ctx, rs.Primary.ID) + if err != nil { + return err + } + + if res == nil { + return fmt.Errorf("tsf lane %s is not found", rs.Primary.ID) + } + + return nil + } +} + const testAccTsfLane = ` resource "tencentcloud_tsf_lane" "lane" { - lane_name = "" - remark = "" - lane_group_list { - group_id = "" - entrance = - lane_group_id = "" - lane_id = "" - group_name = "" - application_id = "" - application_name = "" - namespace_id = "" - namespace_name = "" - create_time = - update_time = - cluster_type = "" - - } - program_id_list = - } + lane_name = "lane-name" + remark = "lane desc" + lane_group_list { + group_id = "group-yn7j5l8a" + entrance = true + # lane_group_id = "" + # lane_id = "" + # group_name = "" + # application_id = "" + # application_name = "" + # namespace_id = "" + # namespace_name = "" + # create_time = + # update_time = + # cluster_type = "" + } +} ` diff --git a/tencentcloud/resource_tc_tsf_namespace.go b/tencentcloud/resource_tc_tsf_namespace.go index 688c274482..37a6467fbc 100644 --- a/tencentcloud/resource_tc_tsf_namespace.go +++ b/tencentcloud/resource_tc_tsf_namespace.go @@ -5,15 +5,15 @@ Example Usage ```hcl resource "tencentcloud_tsf_namespace" "namespace" { - namespace_name = "" - cluster_id = "" - namespace_desc = "" - namespace_resource_type = "" - namespace_type = "" - namespace_id = "" - is_ha_enable = "" - program_id = "" - program_id_list = + namespace_name = "xxx" + # cluster_id = "" + namespace_desc = "xxx" + # namespace_resource_type = "" + namespace_type = "DEF" + # namespace_id = "" + is_ha_enable = "0" + # program_id = "" + # program_id_list = } ``` @@ -152,232 +152,6 @@ func resourceTencentCloudTsfNamespace() *schema.Resource { Type: schema.TypeString, Description: "update time.", }, - - "cluster_list": { - Computed: true, - Type: schema.TypeList, - Description: "Cluster array, only carrying basic information such as cluster ID, cluster name, and cluster type.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "cluster_id": { - Type: schema.TypeString, - Computed: true, - Description: "cluster ID.", - }, - "cluster_name": { - Type: schema.TypeString, - Computed: true, - Description: "cluster name.", - }, - "cluster_desc": { - Type: schema.TypeString, - Computed: true, - Description: "cluster description.", - }, - "cluster_type": { - Type: schema.TypeString, - Computed: true, - Description: "cluster type.", - }, - "vpc_id": { - Type: schema.TypeString, - Computed: true, - Description: "ID of the private network to which the cluster belongs.", - }, - "cluster_status": { - Type: schema.TypeString, - Computed: true, - Description: "cluster status.", - }, - "cluster_c_i_d_r": { - Type: schema.TypeString, - Computed: true, - Description: "Cluster CIDR.", - }, - "cluster_total_cpu": { - Type: schema.TypeFloat, - Computed: true, - Description: "Total CPU of the cluster, unit: core.", - }, - "cluster_total_mem": { - Type: schema.TypeFloat, - Computed: true, - Description: "Total memory of the cluster, unit: G.", - }, - "cluster_used_cpu": { - Type: schema.TypeFloat, - Computed: true, - Description: "The CPU used by the cluster, unit: core.", - }, - "cluster_used_mem": { - Type: schema.TypeFloat, - Computed: true, - Description: "The cluster has used memory, unit: G.", - }, - "instance_count": { - Type: schema.TypeInt, - Computed: true, - Description: "number of cluster machine instances.", - }, - "run_instance_count": { - Type: schema.TypeInt, - Computed: true, - Description: "the number of machine instances available in the cluster.", - }, - "normal_instance_count": { - Type: schema.TypeInt, - Computed: true, - Description: "the number of machine instances in the normal state of the cluster.", - }, - "delete_flag": { - Type: schema.TypeBool, - Computed: true, - Description: "delete flag: true: can be deleted; false: can not be deleted.", - }, - "create_time": { - Type: schema.TypeString, - Computed: true, - Description: "creation time.", - }, - "update_time": { - Type: schema.TypeString, - Computed: true, - Description: "update time.", - }, - "tsf_region_id": { - Type: schema.TypeString, - Computed: true, - Description: "ID of the TSF region to which the cluster belongs.", - }, - "tsf_region_name": { - Type: schema.TypeString, - Computed: true, - Description: "the name of the TSF region to which the cluster belongs.", - }, - "tsf_zone_id": { - Type: schema.TypeString, - Computed: true, - Description: "ID of the TSF availability zone to which the cluster belongs.", - }, - "tsf_zone_name": { - Type: schema.TypeString, - Computed: true, - Description: "The name of the TSF availability zone to which the cluster belongs.", - }, - "delete_flag_reason": { - Type: schema.TypeString, - Computed: true, - Description: "the reason why the cluster cannot be deleted.", - }, - "cluster_limit_cpu": { - Type: schema.TypeFloat, - Computed: true, - Description: "the maximum CPU limit of the cluster, unit: core.", - }, - "cluster_limit_mem": { - Type: schema.TypeFloat, - Computed: true, - Description: "the maximum memory limit of the cluster, unit: G.", - }, - "run_service_instance_count": { - Type: schema.TypeInt, - Computed: true, - Description: "the number of service instances available in the cluster.", - }, - "subnet_id": { - Type: schema.TypeString, - Computed: true, - Description: "ID of the subnet to which the cluster belongs.", - }, - "operation_info": { - Type: schema.TypeList, - Computed: true, - Description: "control information returned to the front end.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "init": { - Type: schema.TypeList, - Computed: true, - Description: "Initialize the control information of the button.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "disabled_reason": { - Type: schema.TypeString, - Computed: true, - Description: "the reason for not displaying.", - }, - "enabled": { - Type: schema.TypeBool, - Computed: true, - Description: "whether the button is clickable.", - }, - "supported": { - Type: schema.TypeBool, - Computed: true, - Description: "whether to display the button.", - }, - }, - }, - }, - "add_instance": { - Type: schema.TypeList, - Computed: true, - Description: "Add the control information of the instance button.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "disabled_reason": { - Type: schema.TypeString, - Computed: true, - Description: "the reason for not displaying.", - }, - "enabled": { - Type: schema.TypeBool, - Computed: true, - Description: "whether the button is clickable.", - }, - "supported": { - Type: schema.TypeBool, - Computed: true, - Description: "whether to display the button.", - }, - }, - }, - }, - "destroy": { - Type: schema.TypeList, - Computed: true, - Description: "Destroy the control information of the machine.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "disabled_reason": { - Type: schema.TypeString, - Computed: true, - Description: "the reason for not displaying.", - }, - "enabled": { - Type: schema.TypeBool, - Computed: true, - Description: "whether the button is clickable.", - }, - "supported": { - Type: schema.TypeBool, - Computed: true, - Description: "whether to display the button.", - }, - }, - }, - }, - }, - }, - }, - "cluster_version": { - Type: schema.TypeString, - Computed: true, - Description: "cluster version.", - }, - }, - }, - }, }, } } @@ -541,186 +315,6 @@ func resourceTencentCloudTsfNamespaceRead(d *schema.ResourceData, meta interface _ = d.Set("update_time", namespace.UpdateTime) } - if namespace.ClusterList != nil { - clusterListList := []interface{}{} - for _, clusterList := range namespace.ClusterList { - clusterListMap := map[string]interface{}{} - - if clusterList.ClusterId != nil { - clusterListMap["cluster_id"] = clusterList.ClusterId - } - - if clusterList.ClusterName != nil { - clusterListMap["cluster_name"] = clusterList.ClusterName - } - - if clusterList.ClusterDesc != nil { - clusterListMap["cluster_desc"] = clusterList.ClusterDesc - } - - if clusterList.ClusterType != nil { - clusterListMap["cluster_type"] = clusterList.ClusterType - } - - if clusterList.VpcId != nil { - clusterListMap["vpc_id"] = clusterList.VpcId - } - - if clusterList.ClusterStatus != nil { - clusterListMap["cluster_status"] = clusterList.ClusterStatus - } - - if clusterList.ClusterCIDR != nil { - clusterListMap["cluster_c_i_d_r"] = clusterList.ClusterCIDR - } - - if clusterList.ClusterTotalCpu != nil { - clusterListMap["cluster_total_cpu"] = clusterList.ClusterTotalCpu - } - - if clusterList.ClusterTotalMem != nil { - clusterListMap["cluster_total_mem"] = clusterList.ClusterTotalMem - } - - if clusterList.ClusterUsedCpu != nil { - clusterListMap["cluster_used_cpu"] = clusterList.ClusterUsedCpu - } - - if clusterList.ClusterUsedMem != nil { - clusterListMap["cluster_used_mem"] = clusterList.ClusterUsedMem - } - - if clusterList.InstanceCount != nil { - clusterListMap["instance_count"] = clusterList.InstanceCount - } - - if clusterList.RunInstanceCount != nil { - clusterListMap["run_instance_count"] = clusterList.RunInstanceCount - } - - if clusterList.NormalInstanceCount != nil { - clusterListMap["normal_instance_count"] = clusterList.NormalInstanceCount - } - - if clusterList.DeleteFlag != nil { - clusterListMap["delete_flag"] = clusterList.DeleteFlag - } - - if clusterList.CreateTime != nil { - clusterListMap["create_time"] = clusterList.CreateTime - } - - if clusterList.UpdateTime != nil { - clusterListMap["update_time"] = clusterList.UpdateTime - } - - if clusterList.TsfRegionId != nil { - clusterListMap["tsf_region_id"] = clusterList.TsfRegionId - } - - if clusterList.TsfRegionName != nil { - clusterListMap["tsf_region_name"] = clusterList.TsfRegionName - } - - if clusterList.TsfZoneId != nil { - clusterListMap["tsf_zone_id"] = clusterList.TsfZoneId - } - - if clusterList.TsfZoneName != nil { - clusterListMap["tsf_zone_name"] = clusterList.TsfZoneName - } - - if clusterList.DeleteFlagReason != nil { - clusterListMap["delete_flag_reason"] = clusterList.DeleteFlagReason - } - - if clusterList.ClusterLimitCpu != nil { - clusterListMap["cluster_limit_cpu"] = clusterList.ClusterLimitCpu - } - - if clusterList.ClusterLimitMem != nil { - clusterListMap["cluster_limit_mem"] = clusterList.ClusterLimitMem - } - - if clusterList.RunServiceInstanceCount != nil { - clusterListMap["run_service_instance_count"] = clusterList.RunServiceInstanceCount - } - - if clusterList.SubnetId != nil { - clusterListMap["subnet_id"] = clusterList.SubnetId - } - - if clusterList.OperationInfo != nil { - operationInfoMap := map[string]interface{}{} - - if clusterList.OperationInfo.Init != nil { - initMap := map[string]interface{}{} - - if clusterList.OperationInfo.Init.DisabledReason != nil { - initMap["disabled_reason"] = clusterList.OperationInfo.Init.DisabledReason - } - - if clusterList.OperationInfo.Init.Enabled != nil { - initMap["enabled"] = clusterList.OperationInfo.Init.Enabled - } - - if clusterList.OperationInfo.Init.Supported != nil { - initMap["supported"] = clusterList.OperationInfo.Init.Supported - } - - operationInfoMap["init"] = []interface{}{initMap} - } - - if clusterList.OperationInfo.AddInstance != nil { - addInstanceMap := map[string]interface{}{} - - if clusterList.OperationInfo.AddInstance.DisabledReason != nil { - addInstanceMap["disabled_reason"] = clusterList.OperationInfo.AddInstance.DisabledReason - } - - if clusterList.OperationInfo.AddInstance.Enabled != nil { - addInstanceMap["enabled"] = clusterList.OperationInfo.AddInstance.Enabled - } - - if clusterList.OperationInfo.AddInstance.Supported != nil { - addInstanceMap["supported"] = clusterList.OperationInfo.AddInstance.Supported - } - - operationInfoMap["add_instance"] = []interface{}{addInstanceMap} - } - - if clusterList.OperationInfo.Destroy != nil { - destroyMap := map[string]interface{}{} - - if clusterList.OperationInfo.Destroy.DisabledReason != nil { - destroyMap["disabled_reason"] = clusterList.OperationInfo.Destroy.DisabledReason - } - - if clusterList.OperationInfo.Destroy.Enabled != nil { - destroyMap["enabled"] = clusterList.OperationInfo.Destroy.Enabled - } - - if clusterList.OperationInfo.Destroy.Supported != nil { - destroyMap["supported"] = clusterList.OperationInfo.Destroy.Supported - } - - operationInfoMap["destroy"] = []interface{}{destroyMap} - } - - clusterListMap["operation_info"] = []interface{}{operationInfoMap} - } - - if clusterList.ClusterVersion != nil { - clusterListMap["cluster_version"] = clusterList.ClusterVersion - } - - clusterListList = append(clusterListList, clusterListMap) - } - - _ = d.Set("cluster_list", clusterListList) - - } - return nil } @@ -736,7 +330,7 @@ func resourceTencentCloudTsfNamespaceUpdate(d *schema.ResourceData, meta interfa request.NamespaceId = &namespaceId - immutableArgs := []string{"namespace_name", "cluster_id", "namespace_desc", "namespace_resource_type", "namespace_type", "namespace_id", "is_ha_enable", "program_id", "kube_inject_enable", "program_id_list", "namespace_code", "is_default", "namespace_status", "delete_flag", "create_time", "update_time", "cluster_list"} + immutableArgs := []string{"namespace_name", "cluster_id", "namespace_resource_type", "namespace_type", "program_id", "kube_inject_enable", "program_id_list", "namespace_code", "is_default", "namespace_status", "delete_flag", "create_time", "update_time", "cluster_list"} for _, v := range immutableArgs { if d.HasChange(v) { @@ -744,12 +338,6 @@ func resourceTencentCloudTsfNamespaceUpdate(d *schema.ResourceData, meta interfa } } - if d.HasChange("namespace_name") { - if v, ok := d.GetOk("namespace_name"); ok { - request.NamespaceName = helper.String(v.(string)) - } - } - if d.HasChange("namespace_desc") { if v, ok := d.GetOk("namespace_desc"); ok { request.NamespaceDesc = helper.String(v.(string)) diff --git a/tencentcloud/resource_tc_tsf_namespace_test.go b/tencentcloud/resource_tc_tsf_namespace_test.go index 7d94e24d8c..df131a9b94 100644 --- a/tencentcloud/resource_tc_tsf_namespace_test.go +++ b/tencentcloud/resource_tc_tsf_namespace_test.go @@ -1,21 +1,35 @@ package tencentcloud import ( - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" + "context" + "fmt" "testing" + + "github.com/hashicorp/terraform-plugin-sdk/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/terraform" ) +// go test -i; go test -test.run TestAccTencentCloudTsfNamespaceResource_basic -v func TestAccTencentCloudTsfNamespaceResource_basic(t *testing.T) { t.Parallel() + resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, + Providers: testAccProviders, + CheckDestroy: testAccCheckTsfNamespaceDestroy, Steps: []resource.TestStep{ { Config: testAccTsfNamespace, - Check: resource.ComposeTestCheckFunc(resource.TestCheckResourceAttrSet("tencentcloud_tsf_namespace.namespace", "id")), + Check: resource.ComposeTestCheckFunc( + testAccCheckTsfNamespaceExists("tencentcloud_tsf_namespace.namespace"), + resource.TestCheckResourceAttrSet("tencentcloud_tsf_namespace.namespace", "id"), + resource.TestCheckResourceAttr("tencentcloud_tsf_namespace.namespace", "namespace_name", "terraform-namespace-name"), + resource.TestCheckResourceAttr("tencentcloud_tsf_namespace.namespace", "namespace_desc", "terraform-test"), + resource.TestCheckResourceAttr("tencentcloud_tsf_namespace.namespace", "namespace_type", "DEF"), + resource.TestCheckResourceAttr("tencentcloud_tsf_namespace.namespace", "is_ha_enable", "0"), + ), }, { ResourceName: "tencentcloud_tsf_namespace.namespace", @@ -26,18 +40,63 @@ func TestAccTencentCloudTsfNamespaceResource_basic(t *testing.T) { }) } +func testAccCheckTsfNamespaceDestroy(s *terraform.State) error { + logId := getLogId(contextNil) + ctx := context.WithValue(context.TODO(), logIdKey, logId) + service := TsfService{client: testAccProvider.Meta().(*TencentCloudClient).apiV3Conn} + for _, rs := range s.RootModule().Resources { + if rs.Type != "tencentcloud_tsf_namespace" { + continue + } + + res, err := service.DescribeTsfNamespaceById(ctx, rs.Primary.ID) + if err != nil { + return err + } + + if res != nil { + return fmt.Errorf("tsf namespace %s still exists", rs.Primary.ID) + } + } + return nil +} + +func testAccCheckTsfNamespaceExists(r string) resource.TestCheckFunc { + return func(s *terraform.State) error { + logId := getLogId(contextNil) + ctx := context.WithValue(context.TODO(), logIdKey, logId) + + rs, ok := s.RootModule().Resources[r] + if !ok { + return fmt.Errorf("resource %s is not found", r) + } + + service := TsfService{client: testAccProvider.Meta().(*TencentCloudClient).apiV3Conn} + res, err := service.DescribeTsfNamespaceById(ctx, rs.Primary.ID) + if err != nil { + return err + } + + if res == nil { + return fmt.Errorf("tsf namespace %s is not found", rs.Primary.ID) + } + + return nil + } +} + const testAccTsfNamespace = ` resource "tencentcloud_tsf_namespace" "namespace" { - namespace_name = "" - cluster_id = "" - namespace_desc = "" - namespace_resource_type = "" - namespace_type = "" - namespace_id = "" - is_ha_enable = "" - program_id = "" - program_id_list = - } + namespace_name = "terraform-namespace-name" + # cluster_id = "" + namespace_desc = "terraform-test" + # namespace_resource_type = "" + namespace_type = "DEF" + # namespace_id = "" + is_ha_enable = "0" + # program_id = "" + # program_id_list = +} ` diff --git a/vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/http/request.go b/vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/http/request.go index adc7c66c90..421df19194 100644 --- a/vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/http/request.go +++ b/vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/http/request.go @@ -265,7 +265,7 @@ func CompleteCommonParams(request Request, region string, requestClient string) params["Action"] = request.GetAction() params["Timestamp"] = strconv.FormatInt(time.Now().Unix(), 10) params["Nonce"] = strconv.Itoa(rand.Int()) - params["RequestClient"] = "SDK_GO_1.0.578" + params["RequestClient"] = "SDK_GO_1.0.584" if requestClient != "" { params["RequestClient"] += ": " + requestClient } diff --git a/vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tsf/v20180326/client.go b/vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tsf/v20180326/client.go index ba87783246..c20f31af06 100644 --- a/vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tsf/v20180326/client.go +++ b/vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tsf/v20180326/client.go @@ -699,6 +699,7 @@ func NewCreateApplicationResponse() (response *CreateApplicationResponse) { // 可能返回的错误码: // FAILEDOPERATION_APPLICATIONCREATEESATUHERROR = "FailedOperation.ApplicationCreateEsAtuhError" // FAILEDOPERATION_APPLICATIONQUERYFAILED = "FailedOperation.ApplicationQueryFailed" +// FAILEDOPERATION_CLOUDAPIPROXYERROR = "FailedOperation.CloudApiProxyError" // INTERNALERROR_APPLICATIONMASTERFEIGNERROR = "InternalError.ApplicationMasterFeignError" // INTERNALERROR_APPLICATIONMASTERNUKNOWNERROR = "InternalError.ApplicationMasterNuknownError" // INTERNALERROR_APPLICATIONSCALABLEINITERROR = "InternalError.ApplicationScalableInitError" @@ -726,6 +727,7 @@ func (c *Client) CreateApplication(request *CreateApplicationRequest) (response // 可能返回的错误码: // FAILEDOPERATION_APPLICATIONCREATEESATUHERROR = "FailedOperation.ApplicationCreateEsAtuhError" // FAILEDOPERATION_APPLICATIONQUERYFAILED = "FailedOperation.ApplicationQueryFailed" +// FAILEDOPERATION_CLOUDAPIPROXYERROR = "FailedOperation.CloudApiProxyError" // INTERNALERROR_APPLICATIONMASTERFEIGNERROR = "InternalError.ApplicationMasterFeignError" // INTERNALERROR_APPLICATIONMASTERNUKNOWNERROR = "InternalError.ApplicationMasterNuknownError" // INTERNALERROR_APPLICATIONSCALABLEINITERROR = "InternalError.ApplicationScalableInitError" @@ -923,6 +925,80 @@ func (c *Client) CreateConfigWithContext(ctx context.Context, request *CreateCon return } +func NewCreateConfigTemplateRequest() (request *CreateConfigTemplateRequest) { + request = &CreateConfigTemplateRequest{ + BaseRequest: &tchttp.BaseRequest{}, + } + + request.Init().WithApiInfo("tsf", APIVersion, "CreateConfigTemplate") + + + return +} + +func NewCreateConfigTemplateResponse() (response *CreateConfigTemplateResponse) { + response = &CreateConfigTemplateResponse{ + BaseResponse: &tchttp.BaseResponse{}, + } + return +} + +// CreateConfigTemplate +// 创建参数模板 +// +// 可能返回的错误码: +// FAILEDOPERATION_CONFIGTEMPLATECREATEFAILED = "FailedOperation.ConfigTemplateCreateFailed" +// FAILEDOPERATION_CONFIGTEMPLATEDELETEFAILED = "FailedOperation.ConfigTemplateDeleteFailed" +// FAILEDOPERATION_CONFIGTEMPLATEIMPORTFAILED = "FailedOperation.ConfigTemplateImportFailed" +// FAILEDOPERATION_CONFIGTEMPLATESEARCHLISTFAILED = "FailedOperation.ConfigTemplateSearchListFailed" +// FAILEDOPERATION_CONFIGTEMPLATEUPDATEFAILED = "FailedOperation.ConfigTemplateUpdateFailed" +// INVALIDPARAMETER_CONFIGTEMPLATENAMEINVALID = "InvalidParameter.ConfigTemplateNameInvalid" +// INVALIDPARAMETERVALUE_CONFIGTEMPLATEDESCTOOLONG = "InvalidParameterValue.ConfigTemplateDescTooLong" +// INVALIDPARAMETERVALUE_CONFIGTEMPLATENAMEINVALID = "InvalidParameterValue.ConfigTemplateNameInvalid" +// INVALIDPARAMETERVALUE_CONFIGTEMPLATENAMETOOLONG = "InvalidParameterValue.ConfigTemplateNameTooLong" +// INVALIDPARAMETERVALUE_CONFIGTEMPLATETYPEINVALID = "InvalidParameterValue.ConfigTemplateTypeInvalid" +// INVALIDPARAMETERVALUE_CONFIGVALUEFORMATINVALID = "InvalidParameterValue.ConfigValueFormatInvalid" +// MISSINGPARAMETER_CONFIGTEMPLATEIDREQUIRED = "MissingParameter.ConfigTemplateIdRequired" +// MISSINGPARAMETER_CONFIGTEMPLATENAMEREQUIRED = "MissingParameter.ConfigTemplateNameRequired" +// MISSINGPARAMETER_CONFIGTEMPLATETYPEREQUIRED = "MissingParameter.ConfigTemplateTypeRequired" +func (c *Client) CreateConfigTemplate(request *CreateConfigTemplateRequest) (response *CreateConfigTemplateResponse, err error) { + return c.CreateConfigTemplateWithContext(context.Background(), request) +} + +// CreateConfigTemplate +// 创建参数模板 +// +// 可能返回的错误码: +// FAILEDOPERATION_CONFIGTEMPLATECREATEFAILED = "FailedOperation.ConfigTemplateCreateFailed" +// FAILEDOPERATION_CONFIGTEMPLATEDELETEFAILED = "FailedOperation.ConfigTemplateDeleteFailed" +// FAILEDOPERATION_CONFIGTEMPLATEIMPORTFAILED = "FailedOperation.ConfigTemplateImportFailed" +// FAILEDOPERATION_CONFIGTEMPLATESEARCHLISTFAILED = "FailedOperation.ConfigTemplateSearchListFailed" +// FAILEDOPERATION_CONFIGTEMPLATEUPDATEFAILED = "FailedOperation.ConfigTemplateUpdateFailed" +// INVALIDPARAMETER_CONFIGTEMPLATENAMEINVALID = "InvalidParameter.ConfigTemplateNameInvalid" +// INVALIDPARAMETERVALUE_CONFIGTEMPLATEDESCTOOLONG = "InvalidParameterValue.ConfigTemplateDescTooLong" +// INVALIDPARAMETERVALUE_CONFIGTEMPLATENAMEINVALID = "InvalidParameterValue.ConfigTemplateNameInvalid" +// INVALIDPARAMETERVALUE_CONFIGTEMPLATENAMETOOLONG = "InvalidParameterValue.ConfigTemplateNameTooLong" +// INVALIDPARAMETERVALUE_CONFIGTEMPLATETYPEINVALID = "InvalidParameterValue.ConfigTemplateTypeInvalid" +// INVALIDPARAMETERVALUE_CONFIGVALUEFORMATINVALID = "InvalidParameterValue.ConfigValueFormatInvalid" +// MISSINGPARAMETER_CONFIGTEMPLATEIDREQUIRED = "MissingParameter.ConfigTemplateIdRequired" +// MISSINGPARAMETER_CONFIGTEMPLATENAMEREQUIRED = "MissingParameter.ConfigTemplateNameRequired" +// MISSINGPARAMETER_CONFIGTEMPLATETYPEREQUIRED = "MissingParameter.ConfigTemplateTypeRequired" +func (c *Client) CreateConfigTemplateWithContext(ctx context.Context, request *CreateConfigTemplateRequest) (response *CreateConfigTemplateResponse, err error) { + if request == nil { + request = NewCreateConfigTemplateRequest() + } + + if c.GetCredential() == nil { + return nil, errors.New("CreateConfigTemplate require credential") + } + + request.SetContext(ctx) + + response = NewCreateConfigTemplateResponse() + err = c.Send(request, response) + return +} + func NewCreateContainGroupRequest() (request *CreateContainGroupRequest) { request = &CreateContainGroupRequest{ BaseRequest: &tchttp.BaseRequest{}, @@ -1041,6 +1117,7 @@ func NewCreateFileConfigResponse() (response *CreateFileConfigResponse) { // INVALIDPARAMETERVALUE_FILECONFIGEXISTS = "InvalidParameterValue.FileConfigExists" // INVALIDPARAMETERVALUE_FILECONFIGEXISTSPATH = "InvalidParameterValue.FileConfigExistsPath" // INVALIDPARAMETERVALUE_FILECONFIGEXISTSPATHOTHER = "InvalidParameterValue.FileConfigExistsPathOther" +// INVALIDPARAMETERVALUE_FILECONFIGFILENAMEINVALID = "InvalidParameterValue.FileConfigFileNameInvalid" // INVALIDPARAMETERVALUE_FILECONFIGFILEPATHINVALID = "InvalidParameterValue.FileConfigFilePathInvalid" // INVALIDPARAMETERVALUE_FILECONFIGNAMEINVALID = "InvalidParameterValue.FileConfigNameInvalid" // INVALIDPARAMETERVALUE_FILECONFIGVERSIONDESCINVALID = "InvalidParameterValue.FileConfigVersionDescInvalid" @@ -1060,6 +1137,7 @@ func (c *Client) CreateFileConfig(request *CreateFileConfigRequest) (response *C // INVALIDPARAMETERVALUE_FILECONFIGEXISTS = "InvalidParameterValue.FileConfigExists" // INVALIDPARAMETERVALUE_FILECONFIGEXISTSPATH = "InvalidParameterValue.FileConfigExistsPath" // INVALIDPARAMETERVALUE_FILECONFIGEXISTSPATHOTHER = "InvalidParameterValue.FileConfigExistsPathOther" +// INVALIDPARAMETERVALUE_FILECONFIGFILENAMEINVALID = "InvalidParameterValue.FileConfigFileNameInvalid" // INVALIDPARAMETERVALUE_FILECONFIGFILEPATHINVALID = "InvalidParameterValue.FileConfigFilePathInvalid" // INVALIDPARAMETERVALUE_FILECONFIGNAMEINVALID = "InvalidParameterValue.FileConfigNameInvalid" // INVALIDPARAMETERVALUE_FILECONFIGVERSIONDESCINVALID = "InvalidParameterValue.FileConfigVersionDescInvalid" @@ -1547,6 +1625,56 @@ func (c *Client) CreateMicroserviceWithContext(ctx context.Context, request *Cre return } +func NewCreateMicroserviceWithDetailRespRequest() (request *CreateMicroserviceWithDetailRespRequest) { + request = &CreateMicroserviceWithDetailRespRequest{ + BaseRequest: &tchttp.BaseRequest{}, + } + + request.Init().WithApiInfo("tsf", APIVersion, "CreateMicroserviceWithDetailResp") + + + return +} + +func NewCreateMicroserviceWithDetailRespResponse() (response *CreateMicroserviceWithDetailRespResponse) { + response = &CreateMicroserviceWithDetailRespResponse{ + BaseResponse: &tchttp.BaseResponse{}, + } + return +} + +// CreateMicroserviceWithDetailResp +// 新增微服务返回id +// +// 可能返回的错误码: +// INVALIDPARAMETERVALUE_SERVICENAMEREPEATED = "InvalidParameterValue.ServiceNameRepeated" +// RESOURCENOTFOUND_NAMESPACENOTEXIST = "ResourceNotFound.NamespaceNotExist" +func (c *Client) CreateMicroserviceWithDetailResp(request *CreateMicroserviceWithDetailRespRequest) (response *CreateMicroserviceWithDetailRespResponse, err error) { + return c.CreateMicroserviceWithDetailRespWithContext(context.Background(), request) +} + +// CreateMicroserviceWithDetailResp +// 新增微服务返回id +// +// 可能返回的错误码: +// INVALIDPARAMETERVALUE_SERVICENAMEREPEATED = "InvalidParameterValue.ServiceNameRepeated" +// RESOURCENOTFOUND_NAMESPACENOTEXIST = "ResourceNotFound.NamespaceNotExist" +func (c *Client) CreateMicroserviceWithDetailRespWithContext(ctx context.Context, request *CreateMicroserviceWithDetailRespRequest) (response *CreateMicroserviceWithDetailRespResponse, err error) { + if request == nil { + request = NewCreateMicroserviceWithDetailRespRequest() + } + + if c.GetCredential() == nil { + return nil, errors.New("CreateMicroserviceWithDetailResp require credential") + } + + request.SetContext(ctx) + + response = NewCreateMicroserviceWithDetailRespResponse() + err = c.Send(request, response) + return +} + func NewCreateNamespaceRequest() (request *CreateNamespaceRequest) { request = &CreateNamespaceRequest{ BaseRequest: &tchttp.BaseRequest{}, @@ -2081,6 +2209,80 @@ func (c *Client) DeleteApplicationWithContext(ctx context.Context, request *Dele return } +func NewDeleteClusterRequest() (request *DeleteClusterRequest) { + request = &DeleteClusterRequest{ + BaseRequest: &tchttp.BaseRequest{}, + } + + request.Init().WithApiInfo("tsf", APIVersion, "DeleteCluster") + + + return +} + +func NewDeleteClusterResponse() (response *DeleteClusterResponse) { + response = &DeleteClusterResponse{ + BaseResponse: &tchttp.BaseResponse{}, + } + return +} + +// DeleteCluster +// 删除集群 +// +// 可能返回的错误码: +// FAILEDOPERATION_TKECLUSTERDELETEFAILED = "FailedOperation.TkeClusterDeleteFailed" +// INTERNALERROR_CLOUDAPIPROXYERROR = "InternalError.CloudApiProxyError" +// INTERNALERROR_CPCLUSTERUNAVAILABLE = "InternalError.CpClusterUnavailable" +// INTERNALERROR_UNHANDLEDEXCEPTION = "InternalError.UnhandledException" +// INVALIDPARAMETER_PARAMERROR = "InvalidParameter.ParamError" +// RESOURCEINUSE_CVMCAEMASTERCANNOTDELETE = "ResourceInUse.CvmcaeMasterCannotDelete" +// RESOURCEINUSE_GROUPEXISTS = "ResourceInUse.GroupExists" +// RESOURCEINUSE_INSTANCEEXISTS = "ResourceInUse.InstanceExists" +// RESOURCEINUSE_NONDEFAULTNAMESPACEEXISTS = "ResourceInUse.NonDefaultNamespaceExists" +// RESOURCENOTFOUND_CLUSTERNOTEXIST = "ResourceNotFound.ClusterNotExist" +// RESOURCENOTFOUND_CONTAINERGROUPGROUPNAMESPACECLUSTERNOTFOUND = "ResourceNotFound.ContainergroupGroupNamespaceClusterNotFound" +// RESOURCENOTFOUND_MICROSERVICEOFFLINE = "ResourceNotFound.MicroserviceOffline" +// RESOURCENOTFOUND_TKECLUSTERNOTEXISTS = "ResourceNotFound.TkeClusterNotExists" +// UNAUTHORIZEDOPERATION_NOPRIVILEGE = "UnauthorizedOperation.NoPrivilege" +func (c *Client) DeleteCluster(request *DeleteClusterRequest) (response *DeleteClusterResponse, err error) { + return c.DeleteClusterWithContext(context.Background(), request) +} + +// DeleteCluster +// 删除集群 +// +// 可能返回的错误码: +// FAILEDOPERATION_TKECLUSTERDELETEFAILED = "FailedOperation.TkeClusterDeleteFailed" +// INTERNALERROR_CLOUDAPIPROXYERROR = "InternalError.CloudApiProxyError" +// INTERNALERROR_CPCLUSTERUNAVAILABLE = "InternalError.CpClusterUnavailable" +// INTERNALERROR_UNHANDLEDEXCEPTION = "InternalError.UnhandledException" +// INVALIDPARAMETER_PARAMERROR = "InvalidParameter.ParamError" +// RESOURCEINUSE_CVMCAEMASTERCANNOTDELETE = "ResourceInUse.CvmcaeMasterCannotDelete" +// RESOURCEINUSE_GROUPEXISTS = "ResourceInUse.GroupExists" +// RESOURCEINUSE_INSTANCEEXISTS = "ResourceInUse.InstanceExists" +// RESOURCEINUSE_NONDEFAULTNAMESPACEEXISTS = "ResourceInUse.NonDefaultNamespaceExists" +// RESOURCENOTFOUND_CLUSTERNOTEXIST = "ResourceNotFound.ClusterNotExist" +// RESOURCENOTFOUND_CONTAINERGROUPGROUPNAMESPACECLUSTERNOTFOUND = "ResourceNotFound.ContainergroupGroupNamespaceClusterNotFound" +// RESOURCENOTFOUND_MICROSERVICEOFFLINE = "ResourceNotFound.MicroserviceOffline" +// RESOURCENOTFOUND_TKECLUSTERNOTEXISTS = "ResourceNotFound.TkeClusterNotExists" +// UNAUTHORIZEDOPERATION_NOPRIVILEGE = "UnauthorizedOperation.NoPrivilege" +func (c *Client) DeleteClusterWithContext(ctx context.Context, request *DeleteClusterRequest) (response *DeleteClusterResponse, err error) { + if request == nil { + request = NewDeleteClusterRequest() + } + + if c.GetCredential() == nil { + return nil, errors.New("DeleteCluster require credential") + } + + request.SetContext(ctx) + + response = NewDeleteClusterResponse() + err = c.Send(request, response) + return +} + func NewDeleteConfigRequest() (request *DeleteConfigRequest) { request = &DeleteConfigRequest{ BaseRequest: &tchttp.BaseRequest{}, @@ -2133,6 +2335,76 @@ func (c *Client) DeleteConfigWithContext(ctx context.Context, request *DeleteCon return } +func NewDeleteConfigTemplateRequest() (request *DeleteConfigTemplateRequest) { + request = &DeleteConfigTemplateRequest{ + BaseRequest: &tchttp.BaseRequest{}, + } + + request.Init().WithApiInfo("tsf", APIVersion, "DeleteConfigTemplate") + + + return +} + +func NewDeleteConfigTemplateResponse() (response *DeleteConfigTemplateResponse) { + response = &DeleteConfigTemplateResponse{ + BaseResponse: &tchttp.BaseResponse{}, + } + return +} + +// DeleteConfigTemplate +// 删除模板 +// +// 可能返回的错误码: +// FAILEDOPERATION_CONFIGTEMPLATECREATEFAILED = "FailedOperation.ConfigTemplateCreateFailed" +// FAILEDOPERATION_CONFIGTEMPLATEDELETEFAILED = "FailedOperation.ConfigTemplateDeleteFailed" +// FAILEDOPERATION_CONFIGTEMPLATEIMPORTFAILED = "FailedOperation.ConfigTemplateImportFailed" +// FAILEDOPERATION_CONFIGTEMPLATESEARCHLISTFAILED = "FailedOperation.ConfigTemplateSearchListFailed" +// FAILEDOPERATION_CONFIGTEMPLATEUPDATEFAILED = "FailedOperation.ConfigTemplateUpdateFailed" +// INVALIDPARAMETER_CONFIGTEMPLATENAMEINVALID = "InvalidParameter.ConfigTemplateNameInvalid" +// INVALIDPARAMETERVALUE_CONFIGTEMPLATEDESCTOOLONG = "InvalidParameterValue.ConfigTemplateDescTooLong" +// INVALIDPARAMETERVALUE_CONFIGTEMPLATENAMETOOLONG = "InvalidParameterValue.ConfigTemplateNameTooLong" +// INVALIDPARAMETERVALUE_CONFIGTEMPLATETYPEINVALID = "InvalidParameterValue.ConfigTemplateTypeInvalid" +// MISSINGPARAMETER_CONFIGTEMPLATEIDREQUIRED = "MissingParameter.ConfigTemplateIdRequired" +// MISSINGPARAMETER_CONFIGTEMPLATENAMEREQUIRED = "MissingParameter.ConfigTemplateNameRequired" +// MISSINGPARAMETER_CONFIGTEMPLATETYPEREQUIRED = "MissingParameter.ConfigTemplateTypeRequired" +func (c *Client) DeleteConfigTemplate(request *DeleteConfigTemplateRequest) (response *DeleteConfigTemplateResponse, err error) { + return c.DeleteConfigTemplateWithContext(context.Background(), request) +} + +// DeleteConfigTemplate +// 删除模板 +// +// 可能返回的错误码: +// FAILEDOPERATION_CONFIGTEMPLATECREATEFAILED = "FailedOperation.ConfigTemplateCreateFailed" +// FAILEDOPERATION_CONFIGTEMPLATEDELETEFAILED = "FailedOperation.ConfigTemplateDeleteFailed" +// FAILEDOPERATION_CONFIGTEMPLATEIMPORTFAILED = "FailedOperation.ConfigTemplateImportFailed" +// FAILEDOPERATION_CONFIGTEMPLATESEARCHLISTFAILED = "FailedOperation.ConfigTemplateSearchListFailed" +// FAILEDOPERATION_CONFIGTEMPLATEUPDATEFAILED = "FailedOperation.ConfigTemplateUpdateFailed" +// INVALIDPARAMETER_CONFIGTEMPLATENAMEINVALID = "InvalidParameter.ConfigTemplateNameInvalid" +// INVALIDPARAMETERVALUE_CONFIGTEMPLATEDESCTOOLONG = "InvalidParameterValue.ConfigTemplateDescTooLong" +// INVALIDPARAMETERVALUE_CONFIGTEMPLATENAMETOOLONG = "InvalidParameterValue.ConfigTemplateNameTooLong" +// INVALIDPARAMETERVALUE_CONFIGTEMPLATETYPEINVALID = "InvalidParameterValue.ConfigTemplateTypeInvalid" +// MISSINGPARAMETER_CONFIGTEMPLATEIDREQUIRED = "MissingParameter.ConfigTemplateIdRequired" +// MISSINGPARAMETER_CONFIGTEMPLATENAMEREQUIRED = "MissingParameter.ConfigTemplateNameRequired" +// MISSINGPARAMETER_CONFIGTEMPLATETYPEREQUIRED = "MissingParameter.ConfigTemplateTypeRequired" +func (c *Client) DeleteConfigTemplateWithContext(ctx context.Context, request *DeleteConfigTemplateRequest) (response *DeleteConfigTemplateResponse, err error) { + if request == nil { + request = NewDeleteConfigTemplateRequest() + } + + if c.GetCredential() == nil { + return nil, errors.New("DeleteConfigTemplate require credential") + } + + request.SetContext(ctx) + + response = NewDeleteConfigTemplateResponse() + err = c.Send(request, response) + return +} + func NewDeleteContainerGroupRequest() (request *DeleteContainerGroupRequest) { request = &DeleteContainerGroupRequest{ BaseRequest: &tchttp.BaseRequest{}, @@ -2155,6 +2427,7 @@ func NewDeleteContainerGroupResponse() (response *DeleteContainerGroupResponse) // 删除容器部署组 // // 可能返回的错误码: +// FAILEDOPERATION_CONTAINERGROUPKUBERNETEAPIINVOKEERROR = "FailedOperation.ContainergroupKuberneteApiInvokeError" // INTERNALERROR_CLOUDAPIPROXYERROR = "InternalError.CloudApiProxyError" // INTERNALERROR_CONTAINERGROUPKUBERNETEAPIINVOKEERROR = "InternalError.ContainergroupKuberneteApiInvokeError" // INTERNALERROR_CONTAINERGROUPKUBERNETECONNECTERROR = "InternalError.ContainergroupKuberneteConnectError" @@ -2171,6 +2444,7 @@ func (c *Client) DeleteContainerGroup(request *DeleteContainerGroupRequest) (res // 删除容器部署组 // // 可能返回的错误码: +// FAILEDOPERATION_CONTAINERGROUPKUBERNETEAPIINVOKEERROR = "FailedOperation.ContainergroupKuberneteApiInvokeError" // INTERNALERROR_CLOUDAPIPROXYERROR = "InternalError.CloudApiProxyError" // INTERNALERROR_CONTAINERGROUPKUBERNETEAPIINVOKEERROR = "InternalError.ContainergroupKuberneteApiInvokeError" // INTERNALERROR_CONTAINERGROUPKUBERNETECONNECTERROR = "InternalError.ContainergroupKuberneteConnectError" @@ -4095,6 +4369,7 @@ func NewDescribeClusterInstancesResponse() (response *DescribeClusterInstancesRe // 查询集群实例 // // 可能返回的错误码: +// FAILEDOPERATION_CLOUDAPIPROXYERROR = "FailedOperation.CloudApiProxyError" // FAILEDOPERATION_CONTAINERGROUPKUBERNETECONNECTERROR = "FailedOperation.ContainergroupKuberneteConnectError" // FAILEDOPERATION_GROUPQUERYFAILD = "FailedOperation.GroupQueryFaild" // FAILEDOPERATION_INSTANCEQUERYFAILED = "FailedOperation.InstanceQueryFailed" @@ -4120,6 +4395,7 @@ func (c *Client) DescribeClusterInstances(request *DescribeClusterInstancesReque // 查询集群实例 // // 可能返回的错误码: +// FAILEDOPERATION_CLOUDAPIPROXYERROR = "FailedOperation.CloudApiProxyError" // FAILEDOPERATION_CONTAINERGROUPKUBERNETECONNECTERROR = "FailedOperation.ContainergroupKuberneteConnectError" // FAILEDOPERATION_GROUPQUERYFAILD = "FailedOperation.GroupQueryFaild" // FAILEDOPERATION_INSTANCEQUERYFAILED = "FailedOperation.InstanceQueryFailed" @@ -4153,6 +4429,70 @@ func (c *Client) DescribeClusterInstancesWithContext(ctx context.Context, reques return } +func NewDescribeClustersRequest() (request *DescribeClustersRequest) { + request = &DescribeClustersRequest{ + BaseRequest: &tchttp.BaseRequest{}, + } + + request.Init().WithApiInfo("tsf", APIVersion, "DescribeClusters") + + + return +} + +func NewDescribeClustersResponse() (response *DescribeClustersResponse) { + response = &DescribeClustersResponse{ + BaseResponse: &tchttp.BaseResponse{}, + } + return +} + +// DescribeClusters +// 获取集群列表 +// +// 可能返回的错误码: +// FAILEDOPERATION_CLUSTERQUERYFAILED = "FailedOperation.ClusterQueryFailed" +// FAILEDOPERATION_TSFPRIVILEGEERROR = "FailedOperation.TsfPrivilegeError" +// INTERNALERROR_UNHANDLEDEXCEPTION = "InternalError.UnhandledException" +// INVALIDPARAMETER_PARAMERROR = "InvalidParameter.ParamError" +// RESOURCENOTFOUND_CLUSTERNOTEXIST = "ResourceNotFound.ClusterNotExist" +// RESOURCENOTFOUND_LICENSESERVERNOTFOUND = "ResourceNotFound.LicenseServerNotFound" +// RESOURCENOTFOUND_MICROSERVICEOFFLINE = "ResourceNotFound.MicroserviceOffline" +// UNAUTHORIZEDOPERATION_NOLICENSE = "UnauthorizedOperation.NoLicense" +// UNAUTHORIZEDOPERATION_NOPRIVILEGE = "UnauthorizedOperation.NoPrivilege" +func (c *Client) DescribeClusters(request *DescribeClustersRequest) (response *DescribeClustersResponse, err error) { + return c.DescribeClustersWithContext(context.Background(), request) +} + +// DescribeClusters +// 获取集群列表 +// +// 可能返回的错误码: +// FAILEDOPERATION_CLUSTERQUERYFAILED = "FailedOperation.ClusterQueryFailed" +// FAILEDOPERATION_TSFPRIVILEGEERROR = "FailedOperation.TsfPrivilegeError" +// INTERNALERROR_UNHANDLEDEXCEPTION = "InternalError.UnhandledException" +// INVALIDPARAMETER_PARAMERROR = "InvalidParameter.ParamError" +// RESOURCENOTFOUND_CLUSTERNOTEXIST = "ResourceNotFound.ClusterNotExist" +// RESOURCENOTFOUND_LICENSESERVERNOTFOUND = "ResourceNotFound.LicenseServerNotFound" +// RESOURCENOTFOUND_MICROSERVICEOFFLINE = "ResourceNotFound.MicroserviceOffline" +// UNAUTHORIZEDOPERATION_NOLICENSE = "UnauthorizedOperation.NoLicense" +// UNAUTHORIZEDOPERATION_NOPRIVILEGE = "UnauthorizedOperation.NoPrivilege" +func (c *Client) DescribeClustersWithContext(ctx context.Context, request *DescribeClustersRequest) (response *DescribeClustersResponse, err error) { + if request == nil { + request = NewDescribeClustersRequest() + } + + if c.GetCredential() == nil { + return nil, errors.New("DescribeClusters require credential") + } + + request.SetContext(ctx) + + response = NewDescribeClustersResponse() + err = c.Send(request, response) + return +} + func NewDescribeConfigRequest() (request *DescribeConfigRequest) { request = &DescribeConfigRequest{ BaseRequest: &tchttp.BaseRequest{}, @@ -4176,6 +4516,7 @@ func NewDescribeConfigResponse() (response *DescribeConfigResponse) { // // 可能返回的错误码: // FAILEDOPERATION_CONFIGAPPLICATIONQUERYFAILED = "FailedOperation.ConfigApplicationQueryFailed" +// MISSINGPARAMETER_CONFIGIDREQUIRED = "MissingParameter.ConfigIdRequired" // RESOURCENOTFOUND_MICROSERVICEOFFLINE = "ResourceNotFound.MicroserviceOffline" func (c *Client) DescribeConfig(request *DescribeConfigRequest) (response *DescribeConfigResponse, err error) { return c.DescribeConfigWithContext(context.Background(), request) @@ -4186,6 +4527,7 @@ func (c *Client) DescribeConfig(request *DescribeConfigRequest) (response *Descr // // 可能返回的错误码: // FAILEDOPERATION_CONFIGAPPLICATIONQUERYFAILED = "FailedOperation.ConfigApplicationQueryFailed" +// MISSINGPARAMETER_CONFIGIDREQUIRED = "MissingParameter.ConfigIdRequired" // RESOURCENOTFOUND_MICROSERVICEOFFLINE = "ResourceNotFound.MicroserviceOffline" func (c *Client) DescribeConfigWithContext(ctx context.Context, request *DescribeConfigRequest) (response *DescribeConfigResponse, err error) { if request == nil { @@ -4367,6 +4709,78 @@ func (c *Client) DescribeConfigSummaryWithContext(ctx context.Context, request * return } +func NewDescribeConfigTemplateRequest() (request *DescribeConfigTemplateRequest) { + request = &DescribeConfigTemplateRequest{ + BaseRequest: &tchttp.BaseRequest{}, + } + + request.Init().WithApiInfo("tsf", APIVersion, "DescribeConfigTemplate") + + + return +} + +func NewDescribeConfigTemplateResponse() (response *DescribeConfigTemplateResponse) { + response = &DescribeConfigTemplateResponse{ + BaseResponse: &tchttp.BaseResponse{}, + } + return +} + +// DescribeConfigTemplate +// 导入配置 +// +// 可能返回的错误码: +// FAILEDOPERATION_CONFIGTEMPLATECREATEFAILED = "FailedOperation.ConfigTemplateCreateFailed" +// FAILEDOPERATION_CONFIGTEMPLATEDELETEFAILED = "FailedOperation.ConfigTemplateDeleteFailed" +// FAILEDOPERATION_CONFIGTEMPLATEIMPORTFAILED = "FailedOperation.ConfigTemplateImportFailed" +// FAILEDOPERATION_CONFIGTEMPLATESEARCHLISTFAILED = "FailedOperation.ConfigTemplateSearchListFailed" +// FAILEDOPERATION_CONFIGTEMPLATEUPDATEFAILED = "FailedOperation.ConfigTemplateUpdateFailed" +// INVALIDPARAMETER_CONFIGTEMPLATENAMEINVALID = "InvalidParameter.ConfigTemplateNameInvalid" +// INVALIDPARAMETERVALUE_CONFIGTEMPLATEDESCTOOLONG = "InvalidParameterValue.ConfigTemplateDescTooLong" +// INVALIDPARAMETERVALUE_CONFIGTEMPLATENAMETOOLONG = "InvalidParameterValue.ConfigTemplateNameTooLong" +// INVALIDPARAMETERVALUE_CONFIGTEMPLATETYPEINVALID = "InvalidParameterValue.ConfigTemplateTypeInvalid" +// MISSINGPARAMETER_CONFIGTEMPLATEIDREQUIRED = "MissingParameter.ConfigTemplateIdRequired" +// MISSINGPARAMETER_CONFIGTEMPLATENAMEREQUIRED = "MissingParameter.ConfigTemplateNameRequired" +// MISSINGPARAMETER_CONFIGTEMPLATETYPEREQUIRED = "MissingParameter.ConfigTemplateTypeRequired" +// UNAUTHORIZEDOPERATION_NOPRIVILEGE = "UnauthorizedOperation.NoPrivilege" +func (c *Client) DescribeConfigTemplate(request *DescribeConfigTemplateRequest) (response *DescribeConfigTemplateResponse, err error) { + return c.DescribeConfigTemplateWithContext(context.Background(), request) +} + +// DescribeConfigTemplate +// 导入配置 +// +// 可能返回的错误码: +// FAILEDOPERATION_CONFIGTEMPLATECREATEFAILED = "FailedOperation.ConfigTemplateCreateFailed" +// FAILEDOPERATION_CONFIGTEMPLATEDELETEFAILED = "FailedOperation.ConfigTemplateDeleteFailed" +// FAILEDOPERATION_CONFIGTEMPLATEIMPORTFAILED = "FailedOperation.ConfigTemplateImportFailed" +// FAILEDOPERATION_CONFIGTEMPLATESEARCHLISTFAILED = "FailedOperation.ConfigTemplateSearchListFailed" +// FAILEDOPERATION_CONFIGTEMPLATEUPDATEFAILED = "FailedOperation.ConfigTemplateUpdateFailed" +// INVALIDPARAMETER_CONFIGTEMPLATENAMEINVALID = "InvalidParameter.ConfigTemplateNameInvalid" +// INVALIDPARAMETERVALUE_CONFIGTEMPLATEDESCTOOLONG = "InvalidParameterValue.ConfigTemplateDescTooLong" +// INVALIDPARAMETERVALUE_CONFIGTEMPLATENAMETOOLONG = "InvalidParameterValue.ConfigTemplateNameTooLong" +// INVALIDPARAMETERVALUE_CONFIGTEMPLATETYPEINVALID = "InvalidParameterValue.ConfigTemplateTypeInvalid" +// MISSINGPARAMETER_CONFIGTEMPLATEIDREQUIRED = "MissingParameter.ConfigTemplateIdRequired" +// MISSINGPARAMETER_CONFIGTEMPLATENAMEREQUIRED = "MissingParameter.ConfigTemplateNameRequired" +// MISSINGPARAMETER_CONFIGTEMPLATETYPEREQUIRED = "MissingParameter.ConfigTemplateTypeRequired" +// UNAUTHORIZEDOPERATION_NOPRIVILEGE = "UnauthorizedOperation.NoPrivilege" +func (c *Client) DescribeConfigTemplateWithContext(ctx context.Context, request *DescribeConfigTemplateRequest) (response *DescribeConfigTemplateResponse, err error) { + if request == nil { + request = NewDescribeConfigTemplateRequest() + } + + if c.GetCredential() == nil { + return nil, errors.New("DescribeConfigTemplate require credential") + } + + request.SetContext(ctx) + + response = NewDescribeConfigTemplateResponse() + err = c.Send(request, response) + return +} + func NewDescribeConfigsRequest() (request *DescribeConfigsRequest) { request = &DescribeConfigsRequest{ BaseRequest: &tchttp.BaseRequest{}, @@ -5003,6 +5417,56 @@ func (c *Client) DescribeEnabledUnitRuleWithContext(ctx context.Context, request return } +func NewDescribeFileConfigReleasesRequest() (request *DescribeFileConfigReleasesRequest) { + request = &DescribeFileConfigReleasesRequest{ + BaseRequest: &tchttp.BaseRequest{}, + } + + request.Init().WithApiInfo("tsf", APIVersion, "DescribeFileConfigReleases") + + + return +} + +func NewDescribeFileConfigReleasesResponse() (response *DescribeFileConfigReleasesResponse) { + response = &DescribeFileConfigReleasesResponse{ + BaseResponse: &tchttp.BaseResponse{}, + } + return +} + +// DescribeFileConfigReleases +// 查询文件配置项发布信息 +// +// 可能返回的错误码: +// FAILEDOPERATION_TSFPRIVILEGEERROR = "FailedOperation.TsfPrivilegeError" +// RESOURCENOTFOUND_MICROSERVICEOFFLINE = "ResourceNotFound.MicroserviceOffline" +func (c *Client) DescribeFileConfigReleases(request *DescribeFileConfigReleasesRequest) (response *DescribeFileConfigReleasesResponse, err error) { + return c.DescribeFileConfigReleasesWithContext(context.Background(), request) +} + +// DescribeFileConfigReleases +// 查询文件配置项发布信息 +// +// 可能返回的错误码: +// FAILEDOPERATION_TSFPRIVILEGEERROR = "FailedOperation.TsfPrivilegeError" +// RESOURCENOTFOUND_MICROSERVICEOFFLINE = "ResourceNotFound.MicroserviceOffline" +func (c *Client) DescribeFileConfigReleasesWithContext(ctx context.Context, request *DescribeFileConfigReleasesRequest) (response *DescribeFileConfigReleasesResponse, err error) { + if request == nil { + request = NewDescribeFileConfigReleasesRequest() + } + + if c.GetCredential() == nil { + return nil, errors.New("DescribeFileConfigReleases require credential") + } + + request.SetContext(ctx) + + response = NewDescribeFileConfigReleasesResponse() + err = c.Send(request, response) + return +} + func NewDescribeFileConfigsRequest() (request *DescribeFileConfigsRequest) { request = &DescribeFileConfigsRequest{ BaseRequest: &tchttp.BaseRequest{}, @@ -9315,6 +9779,112 @@ func (c *Client) ExpandGroupWithContext(ctx context.Context, request *ExpandGrou return } +func NewModifyApplicationRequest() (request *ModifyApplicationRequest) { + request = &ModifyApplicationRequest{ + BaseRequest: &tchttp.BaseRequest{}, + } + + request.Init().WithApiInfo("tsf", APIVersion, "ModifyApplication") + + + return +} + +func NewModifyApplicationResponse() (response *ModifyApplicationResponse) { + response = &ModifyApplicationResponse{ + BaseResponse: &tchttp.BaseResponse{}, + } + return +} + +// ModifyApplication +// 修改应用 +// +// 可能返回的错误码: +// INVALIDPARAMETER_APPLICATIONDELETEFAILED = "InvalidParameter.ApplicationDeleteFailed" +// INVALIDPARAMETERVALUE_APPLICATIONDESCLENGTH = "InvalidParameterValue.ApplicationDescLength" +// RESOURCENOTFOUND_APPLICATIONNOTEXIST = "ResourceNotFound.ApplicationNotExist" +// UNAUTHORIZEDOPERATION_NOPRIVILEGE = "UnauthorizedOperation.NoPrivilege" +func (c *Client) ModifyApplication(request *ModifyApplicationRequest) (response *ModifyApplicationResponse, err error) { + return c.ModifyApplicationWithContext(context.Background(), request) +} + +// ModifyApplication +// 修改应用 +// +// 可能返回的错误码: +// INVALIDPARAMETER_APPLICATIONDELETEFAILED = "InvalidParameter.ApplicationDeleteFailed" +// INVALIDPARAMETERVALUE_APPLICATIONDESCLENGTH = "InvalidParameterValue.ApplicationDescLength" +// RESOURCENOTFOUND_APPLICATIONNOTEXIST = "ResourceNotFound.ApplicationNotExist" +// UNAUTHORIZEDOPERATION_NOPRIVILEGE = "UnauthorizedOperation.NoPrivilege" +func (c *Client) ModifyApplicationWithContext(ctx context.Context, request *ModifyApplicationRequest) (response *ModifyApplicationResponse, err error) { + if request == nil { + request = NewModifyApplicationRequest() + } + + if c.GetCredential() == nil { + return nil, errors.New("ModifyApplication require credential") + } + + request.SetContext(ctx) + + response = NewModifyApplicationResponse() + err = c.Send(request, response) + return +} + +func NewModifyClusterRequest() (request *ModifyClusterRequest) { + request = &ModifyClusterRequest{ + BaseRequest: &tchttp.BaseRequest{}, + } + + request.Init().WithApiInfo("tsf", APIVersion, "ModifyCluster") + + + return +} + +func NewModifyClusterResponse() (response *ModifyClusterResponse) { + response = &ModifyClusterResponse{ + BaseResponse: &tchttp.BaseResponse{}, + } + return +} + +// ModifyCluster +// 修改集群信息 +// +// 可能返回的错误码: +// INTERNALERROR_CPCLUSTERUNAVAILABLE = "InternalError.CpClusterUnavailable" +// INTERNALERROR_TKEAPIFAILEDOPERATION = "InternalError.TkeApiFailedOperation" +// RESOURCENOTFOUND_CLUSTERNOTEXIST = "ResourceNotFound.ClusterNotExist" +func (c *Client) ModifyCluster(request *ModifyClusterRequest) (response *ModifyClusterResponse, err error) { + return c.ModifyClusterWithContext(context.Background(), request) +} + +// ModifyCluster +// 修改集群信息 +// +// 可能返回的错误码: +// INTERNALERROR_CPCLUSTERUNAVAILABLE = "InternalError.CpClusterUnavailable" +// INTERNALERROR_TKEAPIFAILEDOPERATION = "InternalError.TkeApiFailedOperation" +// RESOURCENOTFOUND_CLUSTERNOTEXIST = "ResourceNotFound.ClusterNotExist" +func (c *Client) ModifyClusterWithContext(ctx context.Context, request *ModifyClusterRequest) (response *ModifyClusterResponse, err error) { + if request == nil { + request = NewModifyClusterRequest() + } + + if c.GetCredential() == nil { + return nil, errors.New("ModifyCluster require credential") + } + + request.SetContext(ctx) + + response = NewModifyClusterResponse() + err = c.Send(request, response) + return +} + func NewModifyContainerGroupRequest() (request *ModifyContainerGroupRequest) { request = &ModifyContainerGroupRequest{ BaseRequest: &tchttp.BaseRequest{}, @@ -9429,6 +9999,54 @@ func (c *Client) ModifyContainerReplicasWithContext(ctx context.Context, request return } +func NewModifyGroupRequest() (request *ModifyGroupRequest) { + request = &ModifyGroupRequest{ + BaseRequest: &tchttp.BaseRequest{}, + } + + request.Init().WithApiInfo("tsf", APIVersion, "ModifyGroup") + + + return +} + +func NewModifyGroupResponse() (response *ModifyGroupResponse) { + response = &ModifyGroupResponse{ + BaseResponse: &tchttp.BaseResponse{}, + } + return +} + +// ModifyGroup +// 更新部署组信息 +// +// 可能返回的错误码: +// RESOURCENOTFOUND_GROUPNOTEXIST = "ResourceNotFound.GroupNotExist" +func (c *Client) ModifyGroup(request *ModifyGroupRequest) (response *ModifyGroupResponse, err error) { + return c.ModifyGroupWithContext(context.Background(), request) +} + +// ModifyGroup +// 更新部署组信息 +// +// 可能返回的错误码: +// RESOURCENOTFOUND_GROUPNOTEXIST = "ResourceNotFound.GroupNotExist" +func (c *Client) ModifyGroupWithContext(ctx context.Context, request *ModifyGroupRequest) (response *ModifyGroupResponse, err error) { + if request == nil { + request = NewModifyGroupRequest() + } + + if c.GetCredential() == nil { + return nil, errors.New("ModifyGroup require credential") + } + + request.SetContext(ctx) + + response = NewModifyGroupResponse() + err = c.Send(request, response) + return +} + func NewModifyLaneRequest() (request *ModifyLaneRequest) { request = &ModifyLaneRequest{ BaseRequest: &tchttp.BaseRequest{}, @@ -9751,6 +10369,54 @@ func (c *Client) ModifyMicroserviceWithContext(ctx context.Context, request *Mod return } +func NewModifyNamespaceRequest() (request *ModifyNamespaceRequest) { + request = &ModifyNamespaceRequest{ + BaseRequest: &tchttp.BaseRequest{}, + } + + request.Init().WithApiInfo("tsf", APIVersion, "ModifyNamespace") + + + return +} + +func NewModifyNamespaceResponse() (response *ModifyNamespaceResponse) { + response = &ModifyNamespaceResponse{ + BaseResponse: &tchttp.BaseResponse{}, + } + return +} + +// ModifyNamespace +// 修改命名空间 +// +// 可能返回的错误码: +// UNSUPPORTEDOPERATION_UNSUPPORTACTION = "UnsupportedOperation.UnsupportAction" +func (c *Client) ModifyNamespace(request *ModifyNamespaceRequest) (response *ModifyNamespaceResponse, err error) { + return c.ModifyNamespaceWithContext(context.Background(), request) +} + +// ModifyNamespace +// 修改命名空间 +// +// 可能返回的错误码: +// UNSUPPORTEDOPERATION_UNSUPPORTACTION = "UnsupportedOperation.UnsupportAction" +func (c *Client) ModifyNamespaceWithContext(ctx context.Context, request *ModifyNamespaceRequest) (response *ModifyNamespaceResponse, err error) { + if request == nil { + request = NewModifyNamespaceRequest() + } + + if c.GetCredential() == nil { + return nil, errors.New("ModifyNamespace require credential") + } + + request.SetContext(ctx) + + response = NewModifyNamespaceResponse() + err = c.Send(request, response) + return +} + func NewModifyPathRewriteRequest() (request *ModifyPathRewriteRequest) { request = &ModifyPathRewriteRequest{ BaseRequest: &tchttp.BaseRequest{}, @@ -10729,6 +11395,56 @@ func (c *Client) RevocationPublicConfigWithContext(ctx context.Context, request return } +func NewRevokeFileConfigRequest() (request *RevokeFileConfigRequest) { + request = &RevokeFileConfigRequest{ + BaseRequest: &tchttp.BaseRequest{}, + } + + request.Init().WithApiInfo("tsf", APIVersion, "RevokeFileConfig") + + + return +} + +func NewRevokeFileConfigResponse() (response *RevokeFileConfigResponse) { + response = &RevokeFileConfigResponse{ + BaseResponse: &tchttp.BaseResponse{}, + } + return +} + +// RevokeFileConfig +// 撤回已发布的文件配置 +// +// 可能返回的错误码: +// INTERNALERROR_CONSULSERVERERROR = "InternalError.ConsulServerError" +// INVALIDPARAMETERVALUE_FILECONFIGRELEASENOTEXISTS = "InvalidParameterValue.FileConfigReleaseNotExists" +func (c *Client) RevokeFileConfig(request *RevokeFileConfigRequest) (response *RevokeFileConfigResponse, err error) { + return c.RevokeFileConfigWithContext(context.Background(), request) +} + +// RevokeFileConfig +// 撤回已发布的文件配置 +// +// 可能返回的错误码: +// INTERNALERROR_CONSULSERVERERROR = "InternalError.ConsulServerError" +// INVALIDPARAMETERVALUE_FILECONFIGRELEASENOTEXISTS = "InvalidParameterValue.FileConfigReleaseNotExists" +func (c *Client) RevokeFileConfigWithContext(ctx context.Context, request *RevokeFileConfigRequest) (response *RevokeFileConfigResponse, err error) { + if request == nil { + request = NewRevokeFileConfigRequest() + } + + if c.GetCredential() == nil { + return nil, errors.New("RevokeFileConfig require credential") + } + + request.SetContext(ctx) + + response = NewRevokeFileConfigResponse() + err = c.Send(request, response) + return +} + func NewRollbackConfigRequest() (request *RollbackConfigRequest) { request = &RollbackConfigRequest{ BaseRequest: &tchttp.BaseRequest{}, @@ -11146,6 +11862,7 @@ func NewStopContainerGroupResponse() (response *StopContainerGroupResponse) { // // 可能返回的错误码: // FAILEDOPERATION_CONTAINERGROUPGROUPHASSTOP = "FailedOperation.ContainergroupGroupHasstop" +// FAILEDOPERATION_CONTAINERGROUPKUBERNETEAPIINVOKEERROR = "FailedOperation.ContainergroupKuberneteApiInvokeError" // INTERNALERROR_CONTAINERGROUPKUBERNETEAPIINVOKEERROR = "InternalError.ContainergroupKuberneteApiInvokeError" // INTERNALERROR_CONTAINERGROUPKUBERNETECONNECTERROR = "InternalError.ContainergroupKuberneteConnectError" // RESOURCENOTFOUND_CONTAINERGROUPGROUPNOTFOUND = "ResourceNotFound.ContainergroupGroupNotFound" @@ -11159,6 +11876,7 @@ func (c *Client) StopContainerGroup(request *StopContainerGroupRequest) (respons // // 可能返回的错误码: // FAILEDOPERATION_CONTAINERGROUPGROUPHASSTOP = "FailedOperation.ContainergroupGroupHasstop" +// FAILEDOPERATION_CONTAINERGROUPKUBERNETEAPIINVOKEERROR = "FailedOperation.ContainergroupKuberneteApiInvokeError" // INTERNALERROR_CONTAINERGROUPKUBERNETEAPIINVOKEERROR = "InternalError.ContainergroupKuberneteApiInvokeError" // INTERNALERROR_CONTAINERGROUPKUBERNETECONNECTERROR = "InternalError.ContainergroupKuberneteConnectError" // RESOURCENOTFOUND_CONTAINERGROUPGROUPNOTFOUND = "ResourceNotFound.ContainergroupGroupNotFound" @@ -11705,6 +12423,74 @@ func (c *Client) UpdateApiTimeoutsWithContext(ctx context.Context, request *Upda return } +func NewUpdateConfigTemplateRequest() (request *UpdateConfigTemplateRequest) { + request = &UpdateConfigTemplateRequest{ + BaseRequest: &tchttp.BaseRequest{}, + } + + request.Init().WithApiInfo("tsf", APIVersion, "UpdateConfigTemplate") + + + return +} + +func NewUpdateConfigTemplateResponse() (response *UpdateConfigTemplateResponse) { + response = &UpdateConfigTemplateResponse{ + BaseResponse: &tchttp.BaseResponse{}, + } + return +} + +// UpdateConfigTemplate +// 更新参数模板 +// +// 可能返回的错误码: +// FAILEDOPERATION_CONFIGTEMPLATECREATEFAILED = "FailedOperation.ConfigTemplateCreateFailed" +// FAILEDOPERATION_CONFIGTEMPLATEDELETEFAILED = "FailedOperation.ConfigTemplateDeleteFailed" +// FAILEDOPERATION_CONFIGTEMPLATEIMPORTFAILED = "FailedOperation.ConfigTemplateImportFailed" +// FAILEDOPERATION_CONFIGTEMPLATESEARCHLISTFAILED = "FailedOperation.ConfigTemplateSearchListFailed" +// FAILEDOPERATION_CONFIGTEMPLATEUPDATEFAILED = "FailedOperation.ConfigTemplateUpdateFailed" +// INVALIDPARAMETERVALUE_CONFIGTEMPLATEDESCTOOLONG = "InvalidParameterValue.ConfigTemplateDescTooLong" +// INVALIDPARAMETERVALUE_CONFIGTEMPLATENAMETOOLONG = "InvalidParameterValue.ConfigTemplateNameTooLong" +// INVALIDPARAMETERVALUE_CONFIGTEMPLATETYPEINVALID = "InvalidParameterValue.ConfigTemplateTypeInvalid" +// MISSINGPARAMETER_CONFIGTEMPLATEIDREQUIRED = "MissingParameter.ConfigTemplateIdRequired" +// MISSINGPARAMETER_CONFIGTEMPLATENAMEREQUIRED = "MissingParameter.ConfigTemplateNameRequired" +// MISSINGPARAMETER_CONFIGTEMPLATETYPEREQUIRED = "MissingParameter.ConfigTemplateTypeRequired" +func (c *Client) UpdateConfigTemplate(request *UpdateConfigTemplateRequest) (response *UpdateConfigTemplateResponse, err error) { + return c.UpdateConfigTemplateWithContext(context.Background(), request) +} + +// UpdateConfigTemplate +// 更新参数模板 +// +// 可能返回的错误码: +// FAILEDOPERATION_CONFIGTEMPLATECREATEFAILED = "FailedOperation.ConfigTemplateCreateFailed" +// FAILEDOPERATION_CONFIGTEMPLATEDELETEFAILED = "FailedOperation.ConfigTemplateDeleteFailed" +// FAILEDOPERATION_CONFIGTEMPLATEIMPORTFAILED = "FailedOperation.ConfigTemplateImportFailed" +// FAILEDOPERATION_CONFIGTEMPLATESEARCHLISTFAILED = "FailedOperation.ConfigTemplateSearchListFailed" +// FAILEDOPERATION_CONFIGTEMPLATEUPDATEFAILED = "FailedOperation.ConfigTemplateUpdateFailed" +// INVALIDPARAMETERVALUE_CONFIGTEMPLATEDESCTOOLONG = "InvalidParameterValue.ConfigTemplateDescTooLong" +// INVALIDPARAMETERVALUE_CONFIGTEMPLATENAMETOOLONG = "InvalidParameterValue.ConfigTemplateNameTooLong" +// INVALIDPARAMETERVALUE_CONFIGTEMPLATETYPEINVALID = "InvalidParameterValue.ConfigTemplateTypeInvalid" +// MISSINGPARAMETER_CONFIGTEMPLATEIDREQUIRED = "MissingParameter.ConfigTemplateIdRequired" +// MISSINGPARAMETER_CONFIGTEMPLATENAMEREQUIRED = "MissingParameter.ConfigTemplateNameRequired" +// MISSINGPARAMETER_CONFIGTEMPLATETYPEREQUIRED = "MissingParameter.ConfigTemplateTypeRequired" +func (c *Client) UpdateConfigTemplateWithContext(ctx context.Context, request *UpdateConfigTemplateRequest) (response *UpdateConfigTemplateResponse, err error) { + if request == nil { + request = NewUpdateConfigTemplateRequest() + } + + if c.GetCredential() == nil { + return nil, errors.New("UpdateConfigTemplate require credential") + } + + request.SetContext(ctx) + + response = NewUpdateConfigTemplateResponse() + err = c.Send(request, response) + return +} + func NewUpdateGatewayApiRequest() (request *UpdateGatewayApiRequest) { request = &UpdateGatewayApiRequest{ BaseRequest: &tchttp.BaseRequest{}, diff --git a/vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tsf/v20180326/errors.go b/vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tsf/v20180326/errors.go index 34560eae15..e829bde44f 100644 --- a/vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tsf/v20180326/errors.go +++ b/vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tsf/v20180326/errors.go @@ -53,6 +53,21 @@ const ( // 配置项发布信息查询失败。 FAILEDOPERATION_CONFIGRELEASEQUERYFAILED = "FailedOperation.ConfigReleaseQueryFailed" + // 配置模板创建失败。 + FAILEDOPERATION_CONFIGTEMPLATECREATEFAILED = "FailedOperation.ConfigTemplateCreateFailed" + + // 配置模板删除失败。 + FAILEDOPERATION_CONFIGTEMPLATEDELETEFAILED = "FailedOperation.ConfigTemplateDeleteFailed" + + // 配置模板导入失败。 + FAILEDOPERATION_CONFIGTEMPLATEIMPORTFAILED = "FailedOperation.ConfigTemplateImportFailed" + + // 配置模板分页查询失败。 + FAILEDOPERATION_CONFIGTEMPLATESEARCHLISTFAILED = "FailedOperation.ConfigTemplateSearchListFailed" + + // 配置模板更新失败。 + FAILEDOPERATION_CONFIGTEMPLATEUPDATEFAILED = "FailedOperation.ConfigTemplateUpdateFailed" + // 部署组处于运行状态,无法启动。 FAILEDOPERATION_CONTAINERGROUPGROUPHASRUN = "FailedOperation.ContainergroupGroupHasrun" @@ -155,6 +170,9 @@ const ( // TKE 集群创建失败,%s。 FAILEDOPERATION_TKECLUSTERCREATEFAILED = "FailedOperation.TkeClusterCreateFailed" + // TKE 集群删除失败。 + FAILEDOPERATION_TKECLUSTERDELETEFAILED = "FailedOperation.TkeClusterDeleteFailed" + // TKE 集群查询失败。 FAILEDOPERATION_TKECLUSTERQUERYFAILED = "FailedOperation.TkeClusterQueryFailed" @@ -317,9 +335,15 @@ const ( // 参数错误。 INVALIDPARAMETER = "InvalidParameter" + // 删除应用失败。 + INVALIDPARAMETER_APPLICATIONDELETEFAILED = "InvalidParameter.ApplicationDeleteFailed" + // [%s]模块接口[%s]请求不正确(400 BAD REQUEST)。。 INVALIDPARAMETER_BADREQUEST = "InvalidParameter.BadRequest" + // 配置模板名称不符合规范。 + INVALIDPARAMETER_CONFIGTEMPLATENAMEINVALID = "InvalidParameter.ConfigTemplateNameInvalid" + // TSF MASTER 实例状态异常。 INVALIDPARAMETER_CVMCAEMASTERUNKNOWNINSTANCESTATUS = "InvalidParameter.CvmCaeMasterUnknownInstanceStatus" @@ -437,6 +461,9 @@ const ( // 参数取值错误。 INVALIDPARAMETERVALUE = "InvalidParameterValue" + // 应用描述不能大于200组字符。 + INVALIDPARAMETERVALUE_APPLICATIONDESCLENGTH = "InvalidParameterValue.ApplicationDescLength" + // 无效的微服务类型。 INVALIDPARAMETERVALUE_APPLICATIONMICROTYPEINVALID = "InvalidParameterValue.ApplicationMicroTypeInvalid" @@ -497,6 +524,18 @@ const ( // 无法获取配置项发布信息。 INVALIDPARAMETERVALUE_CONFIGRELEASENOTEXISTS = "InvalidParameterValue.ConfigReleaseNotExists" + // 配置模板描述过长。 + INVALIDPARAMETERVALUE_CONFIGTEMPLATEDESCTOOLONG = "InvalidParameterValue.ConfigTemplateDescTooLong" + + // 配置模板名称不合规。 + INVALIDPARAMETERVALUE_CONFIGTEMPLATENAMEINVALID = "InvalidParameterValue.ConfigTemplateNameInvalid" + + // 配置模板内容过长。 + INVALIDPARAMETERVALUE_CONFIGTEMPLATENAMETOOLONG = "InvalidParameterValue.ConfigTemplateNameTooLong" + + // 配置模板类型不合规。 + INVALIDPARAMETERVALUE_CONFIGTEMPLATETYPEINVALID = "InvalidParameterValue.ConfigTemplateTypeInvalid" + // 配置格式不符合YAML要求。 INVALIDPARAMETERVALUE_CONFIGVALUEFORMATINVALID = "InvalidParameterValue.ConfigValueFormatInvalid" @@ -614,6 +653,9 @@ const ( // 其他用户已发布此配置文件路径。 INVALIDPARAMETERVALUE_FILECONFIGEXISTSPATHOTHER = "InvalidParameterValue.FileConfigExistsPathOther" + // 文件配置项文件名称不合规。 + INVALIDPARAMETERVALUE_FILECONFIGFILENAMEINVALID = "InvalidParameterValue.FileConfigFileNameInvalid" + // 文件配置项文件路径不合规。 INVALIDPARAMETERVALUE_FILECONFIGFILEPATHINVALID = "InvalidParameterValue.FileConfigFilePathInvalid" @@ -626,6 +668,9 @@ const ( // 同一部署组禁止配置文件重复(文件路径+文件名)。 INVALIDPARAMETERVALUE_FILECONFIGPATHEXISTS = "InvalidParameterValue.FileConfigPathExists" + // 无法获取文件配置项发布信息。 + INVALIDPARAMETERVALUE_FILECONFIGRELEASENOTEXISTS = "InvalidParameterValue.FileConfigReleaseNotExists" + // 文件配置项版本描述不合规。 INVALIDPARAMETERVALUE_FILECONFIGVERSIONDESCINVALID = "InvalidParameterValue.FileConfigVersionDescInvalid" @@ -824,6 +869,15 @@ const ( // 配置项发布信息ID未填写。 MISSINGPARAMETER_CONFIGRELEASEIDREQUIRED = "MissingParameter.ConfigReleaseIdRequired" + // 缺少配置模板id。 + MISSINGPARAMETER_CONFIGTEMPLATEIDREQUIRED = "MissingParameter.ConfigTemplateIdRequired" + + // 配置模板名称未填写。 + MISSINGPARAMETER_CONFIGTEMPLATENAMEREQUIRED = "MissingParameter.ConfigTemplateNameRequired" + + // 配置模板类型未填写。 + MISSINGPARAMETER_CONFIGTEMPLATETYPEREQUIRED = "MissingParameter.ConfigTemplateTypeRequired" + // 配置项类型未填写。 MISSINGPARAMETER_CONFIGTYPEREQUIRED = "MissingParameter.ConfigTypeRequired" @@ -881,15 +935,24 @@ const ( // 此分组下存在资源,无法执行删除操作。 RESOURCEINUSE_GROUPCANNOTDELETE = "ResourceInUse.GroupCannotDelete" + // 集群下存在分组。 + RESOURCEINUSE_GROUPEXISTS = "ResourceInUse.GroupExists" + // 部署组在更新中 请稍后再执行该操作。 RESOURCEINUSE_GROUPINOPERATION = "ResourceInUse.GroupInOperation" + // 实例已经存在。 + RESOURCEINUSE_INSTANCEEXISTS = "ResourceInUse.InstanceExists" + // 机器实例已经被使用。 RESOURCEINUSE_INSTANCEHASBEENUSED = "ResourceInUse.InstanceHasBeenUsed" // 此命名空间下存在资源,无法执行删除操作。 RESOURCEINUSE_NAMESPACECANNOTDELETE = "ResourceInUse.NamespaceCannotDelete" + // 集群下存在非默认命名空间。 + RESOURCEINUSE_NONDEFAULTNAMESPACEEXISTS = "ResourceInUse.NonDefaultNamespaceExists" + // 资源对象已存在。 RESOURCEINUSE_OBJECTEXIST = "ResourceInUse.ObjectExist" diff --git a/vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tsf/v20180326/models.go b/vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tsf/v20180326/models.go index 17a6a93889..9cc132e1d3 100644 --- a/vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tsf/v20180326/models.go +++ b/vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tsf/v20180326/models.go @@ -1270,6 +1270,152 @@ type Cluster struct { ClusterVersion *string `json:"ClusterVersion,omitempty" name:"ClusterVersion"` } +type ClusterV2 struct { + // 集群ID + // 注意:此字段可能返回 null,表示取不到有效值。 + ClusterId *string `json:"ClusterId,omitempty" name:"ClusterId"` + + // 集群名称 + // 注意:此字段可能返回 null,表示取不到有效值。 + ClusterName *string `json:"ClusterName,omitempty" name:"ClusterName"` + + // 集群描述 + // 注意:此字段可能返回 null,表示取不到有效值。 + ClusterDesc *string `json:"ClusterDesc,omitempty" name:"ClusterDesc"` + + // 集群类型 + // 注意:此字段可能返回 null,表示取不到有效值。 + ClusterType *string `json:"ClusterType,omitempty" name:"ClusterType"` + + // 集群所属私有网络ID + // 注意:此字段可能返回 null,表示取不到有效值。 + VpcId *string `json:"VpcId,omitempty" name:"VpcId"` + + // 集群状态 + // 注意:此字段可能返回 null,表示取不到有效值。 + ClusterStatus *string `json:"ClusterStatus,omitempty" name:"ClusterStatus"` + + // 集群CIDR + // 注意:此字段可能返回 null,表示取不到有效值。 + ClusterCIDR *string `json:"ClusterCIDR,omitempty" name:"ClusterCIDR"` + + // 集群总CPU,单位: 核 + // 注意:此字段可能返回 null,表示取不到有效值。 + ClusterTotalCpu *float64 `json:"ClusterTotalCpu,omitempty" name:"ClusterTotalCpu"` + + // 集群总内存,单位: G + // 注意:此字段可能返回 null,表示取不到有效值。 + ClusterTotalMem *float64 `json:"ClusterTotalMem,omitempty" name:"ClusterTotalMem"` + + // 集群已使用CPU,单位: 核 + // 注意:此字段可能返回 null,表示取不到有效值。 + ClusterUsedCpu *float64 `json:"ClusterUsedCpu,omitempty" name:"ClusterUsedCpu"` + + // 集群已使用内存,单位: G + // 注意:此字段可能返回 null,表示取不到有效值。 + ClusterUsedMem *float64 `json:"ClusterUsedMem,omitempty" name:"ClusterUsedMem"` + + // 集群机器实例数量 + // 注意:此字段可能返回 null,表示取不到有效值。 + InstanceCount *int64 `json:"InstanceCount,omitempty" name:"InstanceCount"` + + // 集群运行中的机器实例数量 + // 注意:此字段可能返回 null,表示取不到有效值。 + RunInstanceCount *int64 `json:"RunInstanceCount,omitempty" name:"RunInstanceCount"` + + // 集群正常状态的机器实例数量 + // 注意:此字段可能返回 null,表示取不到有效值。 + NormalInstanceCount *int64 `json:"NormalInstanceCount,omitempty" name:"NormalInstanceCount"` + + // 删除标记:true:可以删除;false:不可删除 + // 注意:此字段可能返回 null,表示取不到有效值。 + DeleteFlag *bool `json:"DeleteFlag,omitempty" name:"DeleteFlag"` + + // 创建时间 + // 注意:此字段可能返回 null,表示取不到有效值。 + CreateTime *string `json:"CreateTime,omitempty" name:"CreateTime"` + + // 更新时间 + // 注意:此字段可能返回 null,表示取不到有效值。 + UpdateTime *string `json:"UpdateTime,omitempty" name:"UpdateTime"` + + // 集群所属TSF地域ID + // 注意:此字段可能返回 null,表示取不到有效值。 + TsfRegionId *string `json:"TsfRegionId,omitempty" name:"TsfRegionId"` + + // 集群所属TSF地域名称 + // 注意:此字段可能返回 null,表示取不到有效值。 + TsfRegionName *string `json:"TsfRegionName,omitempty" name:"TsfRegionName"` + + // 集群所属TSF可用区ID + // 注意:此字段可能返回 null,表示取不到有效值。 + TsfZoneId *string `json:"TsfZoneId,omitempty" name:"TsfZoneId"` + + // 集群所属TSF可用区名称 + // 注意:此字段可能返回 null,表示取不到有效值。 + TsfZoneName *string `json:"TsfZoneName,omitempty" name:"TsfZoneName"` + + // 集群不可删除的原因 + // 注意:此字段可能返回 null,表示取不到有效值。 + DeleteFlagReason *string `json:"DeleteFlagReason,omitempty" name:"DeleteFlagReason"` + + // 集群所属私有网络子网ID + // 注意:此字段可能返回 null,表示取不到有效值。 + SubnetId *string `json:"SubnetId,omitempty" name:"SubnetId"` + + // 集群剩余 cpu limit + // 注意:此字段可能返回 null,表示取不到有效值。 + ClusterLimitCpu *string `json:"ClusterLimitCpu,omitempty" name:"ClusterLimitCpu"` + + // 集群剩余 memory limit + // 注意:此字段可能返回 null,表示取不到有效值。 + ClusterLimitMem *string `json:"ClusterLimitMem,omitempty" name:"ClusterLimitMem"` + + // 运行服务实例数 + // 注意:此字段可能返回 null,表示取不到有效值。 + RunServiceInstanceCount *int64 `json:"RunServiceInstanceCount,omitempty" name:"RunServiceInstanceCount"` + + // 给前端的按钮控制信息 + // 注意:此字段可能返回 null,表示取不到有效值。 + OperationInfo *OperationInfo `json:"OperationInfo,omitempty" name:"OperationInfo"` + + // 容器集群版本 + // 注意:此字段可能返回 null,表示取不到有效值。 + ClusterVersion *string `json:"ClusterVersion,omitempty" name:"ClusterVersion"` + + // 部署组总数 + // 注意:此字段可能返回 null,表示取不到有效值。 + GroupCount *uint64 `json:"GroupCount,omitempty" name:"GroupCount"` + + // 运行中部署组数 + // 注意:此字段可能返回 null,表示取不到有效值。 + RunGroupCount *uint64 `json:"RunGroupCount,omitempty" name:"RunGroupCount"` + + // 停止中部署组数 + // 注意:此字段可能返回 null,表示取不到有效值。 + StopGroupCount *uint64 `json:"StopGroupCount,omitempty" name:"StopGroupCount"` + + // 异常部署组数 + // 注意:此字段可能返回 null,表示取不到有效值。 + AbnormalGroupCount *uint64 `json:"AbnormalGroupCount,omitempty" name:"AbnormalGroupCount"` + + // 集群备注名 + // 注意:此字段可能返回 null,表示取不到有效值。 + ClusterRemarkName *string `json:"ClusterRemarkName,omitempty" name:"ClusterRemarkName"` + + // api地址 + // 注意:此字段可能返回 null,表示取不到有效值。 + KuberneteApiServer *string `json:"KuberneteApiServer,omitempty" name:"KuberneteApiServer"` + + // K : kubeconfig, S : service account + // 注意:此字段可能返回 null,表示取不到有效值。 + KuberneteNativeType *string `json:"KuberneteNativeType,omitempty" name:"KuberneteNativeType"` + + // native secret + // 注意:此字段可能返回 null,表示取不到有效值。 + KuberneteNativeSecret *string `json:"KuberneteNativeSecret,omitempty" name:"KuberneteNativeSecret"` +} + type Config struct { // 配置项ID // 注意:此字段可能返回 null,表示取不到有效值。 @@ -1444,6 +1590,36 @@ type ConfigReleaseLog struct { RollbackFlag *bool `json:"RollbackFlag,omitempty" name:"RollbackFlag"` } +type ConfigTemplate struct { + // 配置模板Id + // 注意:此字段可能返回 null,表示取不到有效值。 + ConfigTemplateId *string `json:"ConfigTemplateId,omitempty" name:"ConfigTemplateId"` + + // 配置模板名称 + // 注意:此字段可能返回 null,表示取不到有效值。 + ConfigTemplateName *string `json:"ConfigTemplateName,omitempty" name:"ConfigTemplateName"` + + // 配置模板描述 + // 注意:此字段可能返回 null,表示取不到有效值。 + ConfigTemplateDesc *string `json:"ConfigTemplateDesc,omitempty" name:"ConfigTemplateDesc"` + + // 配置模板对应的微服务框架 + // 注意:此字段可能返回 null,表示取不到有效值。 + ConfigTemplateType *string `json:"ConfigTemplateType,omitempty" name:"ConfigTemplateType"` + + // 配置模板数据 + // 注意:此字段可能返回 null,表示取不到有效值。 + ConfigTemplateValue *string `json:"ConfigTemplateValue,omitempty" name:"ConfigTemplateValue"` + + // 创建时间 + // 注意:此字段可能返回 null,表示取不到有效值。 + CreateTime *string `json:"CreateTime,omitempty" name:"CreateTime"` + + // 更新时间 + // 注意:此字段可能返回 null,表示取不到有效值。 + UpdateTime *string `json:"UpdateTime,omitempty" name:"UpdateTime"` +} + type ContainGroup struct { // 部署组ID // 注意:此字段可能返回 null,表示取不到有效值。 @@ -2633,6 +2809,91 @@ func (r *CreateConfigResponse) FromJsonString(s string) error { return json.Unmarshal([]byte(s), &r) } +// Predefined struct for user +type CreateConfigTemplateRequestParams struct { + // 配置模板名称 + ConfigTemplateName *string `json:"ConfigTemplateName,omitempty" name:"ConfigTemplateName"` + + // 配置模板对应的微服务框架 + ConfigTemplateType *string `json:"ConfigTemplateType,omitempty" name:"ConfigTemplateType"` + + // 配置模板数据 + ConfigTemplateValue *string `json:"ConfigTemplateValue,omitempty" name:"ConfigTemplateValue"` + + // 配置模板描述 + ConfigTemplateDesc *string `json:"ConfigTemplateDesc,omitempty" name:"ConfigTemplateDesc"` + + // 无 + ProgramIdList []*string `json:"ProgramIdList,omitempty" name:"ProgramIdList"` +} + +type CreateConfigTemplateRequest struct { + *tchttp.BaseRequest + + // 配置模板名称 + ConfigTemplateName *string `json:"ConfigTemplateName,omitempty" name:"ConfigTemplateName"` + + // 配置模板对应的微服务框架 + ConfigTemplateType *string `json:"ConfigTemplateType,omitempty" name:"ConfigTemplateType"` + + // 配置模板数据 + ConfigTemplateValue *string `json:"ConfigTemplateValue,omitempty" name:"ConfigTemplateValue"` + + // 配置模板描述 + ConfigTemplateDesc *string `json:"ConfigTemplateDesc,omitempty" name:"ConfigTemplateDesc"` + + // 无 + ProgramIdList []*string `json:"ProgramIdList,omitempty" name:"ProgramIdList"` +} + +func (r *CreateConfigTemplateRequest) ToJsonString() string { + b, _ := json.Marshal(r) + return string(b) +} + +// FromJsonString It is highly **NOT** recommended to use this function +// because it has no param check, nor strict type check +func (r *CreateConfigTemplateRequest) FromJsonString(s string) error { + f := make(map[string]interface{}) + if err := json.Unmarshal([]byte(s), &f); err != nil { + return err + } + delete(f, "ConfigTemplateName") + delete(f, "ConfigTemplateType") + delete(f, "ConfigTemplateValue") + delete(f, "ConfigTemplateDesc") + delete(f, "ProgramIdList") + if len(f) > 0 { + return tcerr.NewTencentCloudSDKError("ClientError.BuildRequestError", "CreateConfigTemplateRequest has unknown keys!", "") + } + return json.Unmarshal([]byte(s), &r) +} + +// Predefined struct for user +type CreateConfigTemplateResponseParams struct { + // true:创建成功;false:创建失败 + Result *bool `json:"Result,omitempty" name:"Result"` + + // 唯一请求 ID,每次请求都会返回。定位问题时需要提供该次请求的 RequestId。 + RequestId *string `json:"RequestId,omitempty" name:"RequestId"` +} + +type CreateConfigTemplateResponse struct { + *tchttp.BaseResponse + Response *CreateConfigTemplateResponseParams `json:"Response"` +} + +func (r *CreateConfigTemplateResponse) ToJsonString() string { + b, _ := json.Marshal(r) + return string(b) +} + +// FromJsonString It is highly **NOT** recommended to use this function +// because it has no param check, nor strict type check +func (r *CreateConfigTemplateResponse) FromJsonString(s string) error { + return json.Unmarshal([]byte(s), &r) +} + // Predefined struct for user type CreateContainGroupRequestParams struct { // 分组所属应用ID @@ -3395,6 +3656,77 @@ func (r *CreateMicroserviceResponse) FromJsonString(s string) error { return json.Unmarshal([]byte(s), &r) } +// Predefined struct for user +type CreateMicroserviceWithDetailRespRequestParams struct { + // 命名空间ID + NamespaceId *string `json:"NamespaceId,omitempty" name:"NamespaceId"` + + // 微服务名称 + MicroserviceName *string `json:"MicroserviceName,omitempty" name:"MicroserviceName"` + + // 微服务描述信息 + MicroserviceDesc *string `json:"MicroserviceDesc,omitempty" name:"MicroserviceDesc"` +} + +type CreateMicroserviceWithDetailRespRequest struct { + *tchttp.BaseRequest + + // 命名空间ID + NamespaceId *string `json:"NamespaceId,omitempty" name:"NamespaceId"` + + // 微服务名称 + MicroserviceName *string `json:"MicroserviceName,omitempty" name:"MicroserviceName"` + + // 微服务描述信息 + MicroserviceDesc *string `json:"MicroserviceDesc,omitempty" name:"MicroserviceDesc"` +} + +func (r *CreateMicroserviceWithDetailRespRequest) ToJsonString() string { + b, _ := json.Marshal(r) + return string(b) +} + +// FromJsonString It is highly **NOT** recommended to use this function +// because it has no param check, nor strict type check +func (r *CreateMicroserviceWithDetailRespRequest) FromJsonString(s string) error { + f := make(map[string]interface{}) + if err := json.Unmarshal([]byte(s), &f); err != nil { + return err + } + delete(f, "NamespaceId") + delete(f, "MicroserviceName") + delete(f, "MicroserviceDesc") + if len(f) > 0 { + return tcerr.NewTencentCloudSDKError("ClientError.BuildRequestError", "CreateMicroserviceWithDetailRespRequest has unknown keys!", "") + } + return json.Unmarshal([]byte(s), &r) +} + +// Predefined struct for user +type CreateMicroserviceWithDetailRespResponseParams struct { + // id + Result *string `json:"Result,omitempty" name:"Result"` + + // 唯一请求 ID,每次请求都会返回。定位问题时需要提供该次请求的 RequestId。 + RequestId *string `json:"RequestId,omitempty" name:"RequestId"` +} + +type CreateMicroserviceWithDetailRespResponse struct { + *tchttp.BaseResponse + Response *CreateMicroserviceWithDetailRespResponseParams `json:"Response"` +} + +func (r *CreateMicroserviceWithDetailRespResponse) ToJsonString() string { + b, _ := json.Marshal(r) + return string(b) +} + +// FromJsonString It is highly **NOT** recommended to use this function +// because it has no param check, nor strict type check +func (r *CreateMicroserviceWithDetailRespResponse) FromJsonString(s string) error { + return json.Unmarshal([]byte(s), &r) +} + // Predefined struct for user type CreateNamespaceRequestParams struct { // 命名空间名称 @@ -4215,6 +4547,72 @@ func (r *DeleteApplicationResponse) FromJsonString(s string) error { return json.Unmarshal([]byte(s), &r) } +// Predefined struct for user +type DeleteClusterRequestParams struct { + // 集群ID + ClusterId *string `json:"ClusterId,omitempty" name:"ClusterId"` + + // 是否只解绑,不删除容器集群,默认不传则删除容器集群。 + Unbind *bool `json:"Unbind,omitempty" name:"Unbind"` +} + +type DeleteClusterRequest struct { + *tchttp.BaseRequest + + // 集群ID + ClusterId *string `json:"ClusterId,omitempty" name:"ClusterId"` + + // 是否只解绑,不删除容器集群,默认不传则删除容器集群。 + Unbind *bool `json:"Unbind,omitempty" name:"Unbind"` +} + +func (r *DeleteClusterRequest) ToJsonString() string { + b, _ := json.Marshal(r) + return string(b) +} + +// FromJsonString It is highly **NOT** recommended to use this function +// because it has no param check, nor strict type check +func (r *DeleteClusterRequest) FromJsonString(s string) error { + f := make(map[string]interface{}) + if err := json.Unmarshal([]byte(s), &f); err != nil { + return err + } + delete(f, "ClusterId") + delete(f, "Unbind") + if len(f) > 0 { + return tcerr.NewTencentCloudSDKError("ClientError.BuildRequestError", "DeleteClusterRequest has unknown keys!", "") + } + return json.Unmarshal([]byte(s), &r) +} + +// Predefined struct for user +type DeleteClusterResponseParams struct { + // 删除集群操作是否成功。 + // true:操作成功。 + // false:操作失败。 + Result *bool `json:"Result,omitempty" name:"Result"` + + // 唯一请求 ID,每次请求都会返回。定位问题时需要提供该次请求的 RequestId。 + RequestId *string `json:"RequestId,omitempty" name:"RequestId"` +} + +type DeleteClusterResponse struct { + *tchttp.BaseResponse + Response *DeleteClusterResponseParams `json:"Response"` +} + +func (r *DeleteClusterResponse) ToJsonString() string { + b, _ := json.Marshal(r) + return string(b) +} + +// FromJsonString It is highly **NOT** recommended to use this function +// because it has no param check, nor strict type check +func (r *DeleteClusterResponse) FromJsonString(s string) error { + return json.Unmarshal([]byte(s), &r) +} + // Predefined struct for user type DeleteConfigRequestParams struct { // 配置项ID @@ -4272,6 +4670,63 @@ func (r *DeleteConfigResponse) FromJsonString(s string) error { return json.Unmarshal([]byte(s), &r) } +// Predefined struct for user +type DeleteConfigTemplateRequestParams struct { + // 无 + ConfigTemplateId *string `json:"ConfigTemplateId,omitempty" name:"ConfigTemplateId"` +} + +type DeleteConfigTemplateRequest struct { + *tchttp.BaseRequest + + // 无 + ConfigTemplateId *string `json:"ConfigTemplateId,omitempty" name:"ConfigTemplateId"` +} + +func (r *DeleteConfigTemplateRequest) ToJsonString() string { + b, _ := json.Marshal(r) + return string(b) +} + +// FromJsonString It is highly **NOT** recommended to use this function +// because it has no param check, nor strict type check +func (r *DeleteConfigTemplateRequest) FromJsonString(s string) error { + f := make(map[string]interface{}) + if err := json.Unmarshal([]byte(s), &f); err != nil { + return err + } + delete(f, "ConfigTemplateId") + if len(f) > 0 { + return tcerr.NewTencentCloudSDKError("ClientError.BuildRequestError", "DeleteConfigTemplateRequest has unknown keys!", "") + } + return json.Unmarshal([]byte(s), &r) +} + +// Predefined struct for user +type DeleteConfigTemplateResponseParams struct { + // true:删除成功;false:删除失败 + Result *bool `json:"Result,omitempty" name:"Result"` + + // 唯一请求 ID,每次请求都会返回。定位问题时需要提供该次请求的 RequestId。 + RequestId *string `json:"RequestId,omitempty" name:"RequestId"` +} + +type DeleteConfigTemplateResponse struct { + *tchttp.BaseResponse + Response *DeleteConfigTemplateResponseParams `json:"Response"` +} + +func (r *DeleteConfigTemplateResponse) ToJsonString() string { + b, _ := json.Marshal(r) + return string(b) +} + +// FromJsonString It is highly **NOT** recommended to use this function +// because it has no param check, nor strict type check +func (r *DeleteConfigTemplateResponse) FromJsonString(s string) error { + return json.Unmarshal([]byte(s), &r) +} + // Predefined struct for user type DeleteContainerGroupRequestParams struct { // 部署组ID,分组唯一标识 @@ -6784,6 +7239,106 @@ func (r *DescribeClusterInstancesResponse) FromJsonString(s string) error { return json.Unmarshal([]byte(s), &r) } +// Predefined struct for user +type DescribeClustersRequestParams struct { + // 搜索词 + SearchWord *string `json:"SearchWord,omitempty" name:"SearchWord"` + + // 排序字段 + OrderBy *string `json:"OrderBy,omitempty" name:"OrderBy"` + + // 排序方式 + OrderType *int64 `json:"OrderType,omitempty" name:"OrderType"` + + // 偏移量 + Offset *int64 `json:"Offset,omitempty" name:"Offset"` + + // 分页个数 + Limit *int64 `json:"Limit,omitempty" name:"Limit"` + + // 集群类型 + ClusterType *string `json:"ClusterType,omitempty" name:"ClusterType"` + + // idList + ClusterIdList []*string `json:"ClusterIdList,omitempty" name:"ClusterIdList"` +} + +type DescribeClustersRequest struct { + *tchttp.BaseRequest + + // 搜索词 + SearchWord *string `json:"SearchWord,omitempty" name:"SearchWord"` + + // 排序字段 + OrderBy *string `json:"OrderBy,omitempty" name:"OrderBy"` + + // 排序方式 + OrderType *int64 `json:"OrderType,omitempty" name:"OrderType"` + + // 偏移量 + Offset *int64 `json:"Offset,omitempty" name:"Offset"` + + // 分页个数 + Limit *int64 `json:"Limit,omitempty" name:"Limit"` + + // 集群类型 + ClusterType *string `json:"ClusterType,omitempty" name:"ClusterType"` + + // idList + ClusterIdList []*string `json:"ClusterIdList,omitempty" name:"ClusterIdList"` +} + +func (r *DescribeClustersRequest) ToJsonString() string { + b, _ := json.Marshal(r) + return string(b) +} + +// FromJsonString It is highly **NOT** recommended to use this function +// because it has no param check, nor strict type check +func (r *DescribeClustersRequest) FromJsonString(s string) error { + f := make(map[string]interface{}) + if err := json.Unmarshal([]byte(s), &f); err != nil { + return err + } + delete(f, "SearchWord") + delete(f, "OrderBy") + delete(f, "OrderType") + delete(f, "Offset") + delete(f, "Limit") + delete(f, "ClusterType") + delete(f, "ClusterIdList") + if len(f) > 0 { + return tcerr.NewTencentCloudSDKError("ClientError.BuildRequestError", "DescribeClustersRequest has unknown keys!", "") + } + return json.Unmarshal([]byte(s), &r) +} + +// Predefined struct for user +type DescribeClustersResponseParams struct { + // Cluster分页信息 + // 注意:此字段可能返回 null,表示取不到有效值。 + Result *TsfPageClusterV2 `json:"Result,omitempty" name:"Result"` + + // 唯一请求 ID,每次请求都会返回。定位问题时需要提供该次请求的 RequestId。 + RequestId *string `json:"RequestId,omitempty" name:"RequestId"` +} + +type DescribeClustersResponse struct { + *tchttp.BaseResponse + Response *DescribeClustersResponseParams `json:"Response"` +} + +func (r *DescribeClustersResponse) ToJsonString() string { + b, _ := json.Marshal(r) + return string(b) +} + +// FromJsonString It is highly **NOT** recommended to use this function +// because it has no param check, nor strict type check +func (r *DescribeClustersResponse) FromJsonString(s string) error { + return json.Unmarshal([]byte(s), &r) +} + // Predefined struct for user type DescribeConfigReleaseLogsRequestParams struct { // 部署组ID,不传入时查询全量 @@ -7097,61 +7652,119 @@ type DescribeConfigSummaryRequest struct { ConfigTagList []*string `json:"ConfigTagList,omitempty" name:"ConfigTagList"` // 无 - DisableProgramAuthCheck *bool `json:"DisableProgramAuthCheck,omitempty" name:"DisableProgramAuthCheck"` + DisableProgramAuthCheck *bool `json:"DisableProgramAuthCheck,omitempty" name:"DisableProgramAuthCheck"` + + // 无 + ConfigIdList []*string `json:"ConfigIdList,omitempty" name:"ConfigIdList"` +} + +func (r *DescribeConfigSummaryRequest) ToJsonString() string { + b, _ := json.Marshal(r) + return string(b) +} + +// FromJsonString It is highly **NOT** recommended to use this function +// because it has no param check, nor strict type check +func (r *DescribeConfigSummaryRequest) FromJsonString(s string) error { + f := make(map[string]interface{}) + if err := json.Unmarshal([]byte(s), &f); err != nil { + return err + } + delete(f, "ApplicationId") + delete(f, "SearchWord") + delete(f, "Offset") + delete(f, "Limit") + delete(f, "OrderBy") + delete(f, "OrderType") + delete(f, "ConfigTagList") + delete(f, "DisableProgramAuthCheck") + delete(f, "ConfigIdList") + if len(f) > 0 { + return tcerr.NewTencentCloudSDKError("ClientError.BuildRequestError", "DescribeConfigSummaryRequest has unknown keys!", "") + } + return json.Unmarshal([]byte(s), &r) +} + +// Predefined struct for user +type DescribeConfigSummaryResponseParams struct { + // 配置项分页对象 + Result *TsfPageConfig `json:"Result,omitempty" name:"Result"` + + // 唯一请求 ID,每次请求都会返回。定位问题时需要提供该次请求的 RequestId。 + RequestId *string `json:"RequestId,omitempty" name:"RequestId"` +} + +type DescribeConfigSummaryResponse struct { + *tchttp.BaseResponse + Response *DescribeConfigSummaryResponseParams `json:"Response"` +} + +func (r *DescribeConfigSummaryResponse) ToJsonString() string { + b, _ := json.Marshal(r) + return string(b) +} + +// FromJsonString It is highly **NOT** recommended to use this function +// because it has no param check, nor strict type check +func (r *DescribeConfigSummaryResponse) FromJsonString(s string) error { + return json.Unmarshal([]byte(s), &r) +} + +// Predefined struct for user +type DescribeConfigTemplateRequestParams struct { + // 无 + ConfigTemplateId *string `json:"ConfigTemplateId,omitempty" name:"ConfigTemplateId"` +} +type DescribeConfigTemplateRequest struct { + *tchttp.BaseRequest + // 无 - ConfigIdList []*string `json:"ConfigIdList,omitempty" name:"ConfigIdList"` + ConfigTemplateId *string `json:"ConfigTemplateId,omitempty" name:"ConfigTemplateId"` } -func (r *DescribeConfigSummaryRequest) ToJsonString() string { +func (r *DescribeConfigTemplateRequest) ToJsonString() string { b, _ := json.Marshal(r) return string(b) } // FromJsonString It is highly **NOT** recommended to use this function // because it has no param check, nor strict type check -func (r *DescribeConfigSummaryRequest) FromJsonString(s string) error { +func (r *DescribeConfigTemplateRequest) FromJsonString(s string) error { f := make(map[string]interface{}) if err := json.Unmarshal([]byte(s), &f); err != nil { return err } - delete(f, "ApplicationId") - delete(f, "SearchWord") - delete(f, "Offset") - delete(f, "Limit") - delete(f, "OrderBy") - delete(f, "OrderType") - delete(f, "ConfigTagList") - delete(f, "DisableProgramAuthCheck") - delete(f, "ConfigIdList") + delete(f, "ConfigTemplateId") if len(f) > 0 { - return tcerr.NewTencentCloudSDKError("ClientError.BuildRequestError", "DescribeConfigSummaryRequest has unknown keys!", "") + return tcerr.NewTencentCloudSDKError("ClientError.BuildRequestError", "DescribeConfigTemplateRequest has unknown keys!", "") } return json.Unmarshal([]byte(s), &r) } // Predefined struct for user -type DescribeConfigSummaryResponseParams struct { - // 配置项分页对象 - Result *TsfPageConfig `json:"Result,omitempty" name:"Result"` +type DescribeConfigTemplateResponseParams struct { + // Result + // 注意:此字段可能返回 null,表示取不到有效值。 + Result *ConfigTemplate `json:"Result,omitempty" name:"Result"` // 唯一请求 ID,每次请求都会返回。定位问题时需要提供该次请求的 RequestId。 RequestId *string `json:"RequestId,omitempty" name:"RequestId"` } -type DescribeConfigSummaryResponse struct { +type DescribeConfigTemplateResponse struct { *tchttp.BaseResponse - Response *DescribeConfigSummaryResponseParams `json:"Response"` + Response *DescribeConfigTemplateResponseParams `json:"Response"` } -func (r *DescribeConfigSummaryResponse) ToJsonString() string { +func (r *DescribeConfigTemplateResponse) ToJsonString() string { b, _ := json.Marshal(r) return string(b) } // FromJsonString It is highly **NOT** recommended to use this function // because it has no param check, nor strict type check -func (r *DescribeConfigSummaryResponse) FromJsonString(s string) error { +func (r *DescribeConfigTemplateResponse) FromJsonString(s string) error { return json.Unmarshal([]byte(s), &r) } @@ -7948,6 +8561,113 @@ func (r *DescribeEnabledUnitRuleResponse) FromJsonString(s string) error { return json.Unmarshal([]byte(s), &r) } +// Predefined struct for user +type DescribeFileConfigReleasesRequestParams struct { + // 配置项ID + ConfigId *string `json:"ConfigId,omitempty" name:"ConfigId"` + + // 配置项名称 + ConfigName *string `json:"ConfigName,omitempty" name:"ConfigName"` + + // 部署组ID + GroupId *string `json:"GroupId,omitempty" name:"GroupId"` + + // 命名空间ID + NamespaceId *string `json:"NamespaceId,omitempty" name:"NamespaceId"` + + // 集群ID + ClusterId *string `json:"ClusterId,omitempty" name:"ClusterId"` + + // 应用ID + ApplicationId *string `json:"ApplicationId,omitempty" name:"ApplicationId"` + + // 偏移量 + Offset *int64 `json:"Offset,omitempty" name:"Offset"` + + // 每页条数 + Limit *int64 `json:"Limit,omitempty" name:"Limit"` +} + +type DescribeFileConfigReleasesRequest struct { + *tchttp.BaseRequest + + // 配置项ID + ConfigId *string `json:"ConfigId,omitempty" name:"ConfigId"` + + // 配置项名称 + ConfigName *string `json:"ConfigName,omitempty" name:"ConfigName"` + + // 部署组ID + GroupId *string `json:"GroupId,omitempty" name:"GroupId"` + + // 命名空间ID + NamespaceId *string `json:"NamespaceId,omitempty" name:"NamespaceId"` + + // 集群ID + ClusterId *string `json:"ClusterId,omitempty" name:"ClusterId"` + + // 应用ID + ApplicationId *string `json:"ApplicationId,omitempty" name:"ApplicationId"` + + // 偏移量 + Offset *int64 `json:"Offset,omitempty" name:"Offset"` + + // 每页条数 + Limit *int64 `json:"Limit,omitempty" name:"Limit"` +} + +func (r *DescribeFileConfigReleasesRequest) ToJsonString() string { + b, _ := json.Marshal(r) + return string(b) +} + +// FromJsonString It is highly **NOT** recommended to use this function +// because it has no param check, nor strict type check +func (r *DescribeFileConfigReleasesRequest) FromJsonString(s string) error { + f := make(map[string]interface{}) + if err := json.Unmarshal([]byte(s), &f); err != nil { + return err + } + delete(f, "ConfigId") + delete(f, "ConfigName") + delete(f, "GroupId") + delete(f, "NamespaceId") + delete(f, "ClusterId") + delete(f, "ApplicationId") + delete(f, "Offset") + delete(f, "Limit") + if len(f) > 0 { + return tcerr.NewTencentCloudSDKError("ClientError.BuildRequestError", "DescribeFileConfigReleasesRequest has unknown keys!", "") + } + return json.Unmarshal([]byte(s), &r) +} + +// Predefined struct for user +type DescribeFileConfigReleasesResponseParams struct { + // 配置项发布信息列表 + // 注意:此字段可能返回 null,表示取不到有效值。 + Result *TsfPageFileConfigRelease `json:"Result,omitempty" name:"Result"` + + // 唯一请求 ID,每次请求都会返回。定位问题时需要提供该次请求的 RequestId。 + RequestId *string `json:"RequestId,omitempty" name:"RequestId"` +} + +type DescribeFileConfigReleasesResponse struct { + *tchttp.BaseResponse + Response *DescribeFileConfigReleasesResponseParams `json:"Response"` +} + +func (r *DescribeFileConfigReleasesResponse) ToJsonString() string { + b, _ := json.Marshal(r) + return string(b) +} + +// FromJsonString It is highly **NOT** recommended to use this function +// because it has no param check, nor strict type check +func (r *DescribeFileConfigReleasesResponse) FromJsonString(s string) error { + return json.Unmarshal([]byte(s), &r) +} + // Predefined struct for user type DescribeFileConfigsRequestParams struct { // 配置项ID @@ -15177,9 +15897,175 @@ type Microservice struct { // 注意:此字段可能返回 null,表示取不到有效值。 RunInstanceCount *int64 `json:"RunInstanceCount,omitempty" name:"RunInstanceCount"` - // 微服务的离线实例数目 - // 注意:此字段可能返回 null,表示取不到有效值。 - CriticalInstanceCount *int64 `json:"CriticalInstanceCount,omitempty" name:"CriticalInstanceCount"` + // 微服务的离线实例数目 + // 注意:此字段可能返回 null,表示取不到有效值。 + CriticalInstanceCount *int64 `json:"CriticalInstanceCount,omitempty" name:"CriticalInstanceCount"` +} + +// Predefined struct for user +type ModifyApplicationRequestParams struct { + // 应用ID + ApplicationId *string `json:"ApplicationId,omitempty" name:"ApplicationId"` + + // 应用名称 + ApplicationName *string `json:"ApplicationName,omitempty" name:"ApplicationName"` + + // 应用备注 + ApplicationDesc *string `json:"ApplicationDesc,omitempty" name:"ApplicationDesc"` + + // 应用备注名 + ApplicationRemarkName *string `json:"ApplicationRemarkName,omitempty" name:"ApplicationRemarkName"` + + // 服务配置信息列表 + ServiceConfigList []*ServiceConfig `json:"ServiceConfigList,omitempty" name:"ServiceConfigList"` +} + +type ModifyApplicationRequest struct { + *tchttp.BaseRequest + + // 应用ID + ApplicationId *string `json:"ApplicationId,omitempty" name:"ApplicationId"` + + // 应用名称 + ApplicationName *string `json:"ApplicationName,omitempty" name:"ApplicationName"` + + // 应用备注 + ApplicationDesc *string `json:"ApplicationDesc,omitempty" name:"ApplicationDesc"` + + // 应用备注名 + ApplicationRemarkName *string `json:"ApplicationRemarkName,omitempty" name:"ApplicationRemarkName"` + + // 服务配置信息列表 + ServiceConfigList []*ServiceConfig `json:"ServiceConfigList,omitempty" name:"ServiceConfigList"` +} + +func (r *ModifyApplicationRequest) ToJsonString() string { + b, _ := json.Marshal(r) + return string(b) +} + +// FromJsonString It is highly **NOT** recommended to use this function +// because it has no param check, nor strict type check +func (r *ModifyApplicationRequest) FromJsonString(s string) error { + f := make(map[string]interface{}) + if err := json.Unmarshal([]byte(s), &f); err != nil { + return err + } + delete(f, "ApplicationId") + delete(f, "ApplicationName") + delete(f, "ApplicationDesc") + delete(f, "ApplicationRemarkName") + delete(f, "ServiceConfigList") + if len(f) > 0 { + return tcerr.NewTencentCloudSDKError("ClientError.BuildRequestError", "ModifyApplicationRequest has unknown keys!", "") + } + return json.Unmarshal([]byte(s), &r) +} + +// Predefined struct for user +type ModifyApplicationResponseParams struct { + // true/false + // 注意:此字段可能返回 null,表示取不到有效值。 + Result *bool `json:"Result,omitempty" name:"Result"` + + // 唯一请求 ID,每次请求都会返回。定位问题时需要提供该次请求的 RequestId。 + RequestId *string `json:"RequestId,omitempty" name:"RequestId"` +} + +type ModifyApplicationResponse struct { + *tchttp.BaseResponse + Response *ModifyApplicationResponseParams `json:"Response"` +} + +func (r *ModifyApplicationResponse) ToJsonString() string { + b, _ := json.Marshal(r) + return string(b) +} + +// FromJsonString It is highly **NOT** recommended to use this function +// because it has no param check, nor strict type check +func (r *ModifyApplicationResponse) FromJsonString(s string) error { + return json.Unmarshal([]byte(s), &r) +} + +// Predefined struct for user +type ModifyClusterRequestParams struct { + // 集群ID + ClusterId *string `json:"ClusterId,omitempty" name:"ClusterId"` + + // 集群名称 + ClusterName *string `json:"ClusterName,omitempty" name:"ClusterName"` + + // 集群描述信息 + ClusterDesc *string `json:"ClusterDesc,omitempty" name:"ClusterDesc"` + + // 备注名 + ClusterRemarkName *string `json:"ClusterRemarkName,omitempty" name:"ClusterRemarkName"` +} + +type ModifyClusterRequest struct { + *tchttp.BaseRequest + + // 集群ID + ClusterId *string `json:"ClusterId,omitempty" name:"ClusterId"` + + // 集群名称 + ClusterName *string `json:"ClusterName,omitempty" name:"ClusterName"` + + // 集群描述信息 + ClusterDesc *string `json:"ClusterDesc,omitempty" name:"ClusterDesc"` + + // 备注名 + ClusterRemarkName *string `json:"ClusterRemarkName,omitempty" name:"ClusterRemarkName"` +} + +func (r *ModifyClusterRequest) ToJsonString() string { + b, _ := json.Marshal(r) + return string(b) +} + +// FromJsonString It is highly **NOT** recommended to use this function +// because it has no param check, nor strict type check +func (r *ModifyClusterRequest) FromJsonString(s string) error { + f := make(map[string]interface{}) + if err := json.Unmarshal([]byte(s), &f); err != nil { + return err + } + delete(f, "ClusterId") + delete(f, "ClusterName") + delete(f, "ClusterDesc") + delete(f, "ClusterRemarkName") + if len(f) > 0 { + return tcerr.NewTencentCloudSDKError("ClientError.BuildRequestError", "ModifyClusterRequest has unknown keys!", "") + } + return json.Unmarshal([]byte(s), &r) +} + +// Predefined struct for user +type ModifyClusterResponseParams struct { + // 更新集群详情操作是否成功。 + // true: 操作成功。 + // false:操作失败。 + Result *bool `json:"Result,omitempty" name:"Result"` + + // 唯一请求 ID,每次请求都会返回。定位问题时需要提供该次请求的 RequestId。 + RequestId *string `json:"RequestId,omitempty" name:"RequestId"` +} + +type ModifyClusterResponse struct { + *tchttp.BaseResponse + Response *ModifyClusterResponseParams `json:"Response"` +} + +func (r *ModifyClusterResponse) ToJsonString() string { + b, _ := json.Marshal(r) + return string(b) +} + +// FromJsonString It is highly **NOT** recommended to use this function +// because it has no param check, nor strict type check +func (r *ModifyClusterResponse) FromJsonString(s string) error { + return json.Unmarshal([]byte(s), &r) } // Predefined struct for user @@ -15348,6 +16234,87 @@ func (r *ModifyContainerReplicasResponse) FromJsonString(s string) error { return json.Unmarshal([]byte(s), &r) } +// Predefined struct for user +type ModifyGroupRequestParams struct { + // 部署组ID + GroupId *string `json:"GroupId,omitempty" name:"GroupId"` + + // 部署组名称 + GroupName *string `json:"GroupName,omitempty" name:"GroupName"` + + // 部署组描述 + GroupDesc *string `json:"GroupDesc,omitempty" name:"GroupDesc"` + + // 部署组备注 + Alias *string `json:"Alias,omitempty" name:"Alias"` +} + +type ModifyGroupRequest struct { + *tchttp.BaseRequest + + // 部署组ID + GroupId *string `json:"GroupId,omitempty" name:"GroupId"` + + // 部署组名称 + GroupName *string `json:"GroupName,omitempty" name:"GroupName"` + + // 部署组描述 + GroupDesc *string `json:"GroupDesc,omitempty" name:"GroupDesc"` + + // 部署组备注 + Alias *string `json:"Alias,omitempty" name:"Alias"` +} + +func (r *ModifyGroupRequest) ToJsonString() string { + b, _ := json.Marshal(r) + return string(b) +} + +// FromJsonString It is highly **NOT** recommended to use this function +// because it has no param check, nor strict type check +func (r *ModifyGroupRequest) FromJsonString(s string) error { + f := make(map[string]interface{}) + if err := json.Unmarshal([]byte(s), &f); err != nil { + return err + } + delete(f, "GroupId") + delete(f, "GroupName") + delete(f, "GroupDesc") + delete(f, "Alias") + if len(f) > 0 { + return tcerr.NewTencentCloudSDKError("ClientError.BuildRequestError", "ModifyGroupRequest has unknown keys!", "") + } + return json.Unmarshal([]byte(s), &r) +} + +// Predefined struct for user +type ModifyGroupResponseParams struct { + // 更新部署组详情是否成功。 + // true:操作成功。 + // false:操作失败。 + // 注意:此字段可能返回 null,表示取不到有效值。 + Result *bool `json:"Result,omitempty" name:"Result"` + + // 唯一请求 ID,每次请求都会返回。定位问题时需要提供该次请求的 RequestId。 + RequestId *string `json:"RequestId,omitempty" name:"RequestId"` +} + +type ModifyGroupResponse struct { + *tchttp.BaseResponse + Response *ModifyGroupResponseParams `json:"Response"` +} + +func (r *ModifyGroupResponse) ToJsonString() string { + b, _ := json.Marshal(r) + return string(b) +} + +// FromJsonString It is highly **NOT** recommended to use this function +// because it has no param check, nor strict type check +func (r *ModifyGroupResponse) FromJsonString(s string) error { + return json.Unmarshal([]byte(s), &r) +} + // Predefined struct for user type ModifyLaneRequestParams struct { // 泳道ID @@ -15585,6 +16552,81 @@ func (r *ModifyMicroserviceResponse) FromJsonString(s string) error { return json.Unmarshal([]byte(s), &r) } +// Predefined struct for user +type ModifyNamespaceRequestParams struct { + // 命名空间ID + NamespaceId *string `json:"NamespaceId,omitempty" name:"NamespaceId"` + + // 命名空间名称 + NamespaceName *string `json:"NamespaceName,omitempty" name:"NamespaceName"` + + // 命名空间备注 + NamespaceDesc *string `json:"NamespaceDesc,omitempty" name:"NamespaceDesc"` + + // 是否开启高可用 + IsHaEnable *string `json:"IsHaEnable,omitempty" name:"IsHaEnable"` +} + +type ModifyNamespaceRequest struct { + *tchttp.BaseRequest + + // 命名空间ID + NamespaceId *string `json:"NamespaceId,omitempty" name:"NamespaceId"` + + // 命名空间名称 + NamespaceName *string `json:"NamespaceName,omitempty" name:"NamespaceName"` + + // 命名空间备注 + NamespaceDesc *string `json:"NamespaceDesc,omitempty" name:"NamespaceDesc"` + + // 是否开启高可用 + IsHaEnable *string `json:"IsHaEnable,omitempty" name:"IsHaEnable"` +} + +func (r *ModifyNamespaceRequest) ToJsonString() string { + b, _ := json.Marshal(r) + return string(b) +} + +// FromJsonString It is highly **NOT** recommended to use this function +// because it has no param check, nor strict type check +func (r *ModifyNamespaceRequest) FromJsonString(s string) error { + f := make(map[string]interface{}) + if err := json.Unmarshal([]byte(s), &f); err != nil { + return err + } + delete(f, "NamespaceId") + delete(f, "NamespaceName") + delete(f, "NamespaceDesc") + delete(f, "IsHaEnable") + if len(f) > 0 { + return tcerr.NewTencentCloudSDKError("ClientError.BuildRequestError", "ModifyNamespaceRequest has unknown keys!", "") + } + return json.Unmarshal([]byte(s), &r) +} + +// Predefined struct for user +type ModifyNamespaceResponseParams struct { + // 唯一请求 ID,每次请求都会返回。定位问题时需要提供该次请求的 RequestId。 + RequestId *string `json:"RequestId,omitempty" name:"RequestId"` +} + +type ModifyNamespaceResponse struct { + *tchttp.BaseResponse + Response *ModifyNamespaceResponseParams `json:"Response"` +} + +func (r *ModifyNamespaceResponse) ToJsonString() string { + b, _ := json.Marshal(r) + return string(b) +} + +// FromJsonString It is highly **NOT** recommended to use this function +// because it has no param check, nor strict type check +func (r *ModifyNamespaceResponse) FromJsonString(s string) error { + return json.Unmarshal([]byte(s), &r) +} + // Predefined struct for user type ModifyPathRewriteRequestParams struct { // 路径重写规则ID @@ -17409,6 +18451,64 @@ func (r *RevocationPublicConfigResponse) FromJsonString(s string) error { return json.Unmarshal([]byte(s), &r) } +// Predefined struct for user +type RevokeFileConfigRequestParams struct { + // 配置项发布ID + ConfigReleaseId *string `json:"ConfigReleaseId,omitempty" name:"ConfigReleaseId"` +} + +type RevokeFileConfigRequest struct { + *tchttp.BaseRequest + + // 配置项发布ID + ConfigReleaseId *string `json:"ConfigReleaseId,omitempty" name:"ConfigReleaseId"` +} + +func (r *RevokeFileConfigRequest) ToJsonString() string { + b, _ := json.Marshal(r) + return string(b) +} + +// FromJsonString It is highly **NOT** recommended to use this function +// because it has no param check, nor strict type check +func (r *RevokeFileConfigRequest) FromJsonString(s string) error { + f := make(map[string]interface{}) + if err := json.Unmarshal([]byte(s), &f); err != nil { + return err + } + delete(f, "ConfigReleaseId") + if len(f) > 0 { + return tcerr.NewTencentCloudSDKError("ClientError.BuildRequestError", "RevokeFileConfigRequest has unknown keys!", "") + } + return json.Unmarshal([]byte(s), &r) +} + +// Predefined struct for user +type RevokeFileConfigResponseParams struct { + // 撤回结果 + // 注意:此字段可能返回 null,表示取不到有效值。 + Result *bool `json:"Result,omitempty" name:"Result"` + + // 唯一请求 ID,每次请求都会返回。定位问题时需要提供该次请求的 RequestId。 + RequestId *string `json:"RequestId,omitempty" name:"RequestId"` +} + +type RevokeFileConfigResponse struct { + *tchttp.BaseResponse + Response *RevokeFileConfigResponseParams `json:"Response"` +} + +func (r *RevokeFileConfigResponse) ToJsonString() string { + b, _ := json.Marshal(r) + return string(b) +} + +// FromJsonString It is highly **NOT** recommended to use this function +// because it has no param check, nor strict type check +func (r *RevokeFileConfigResponse) FromJsonString(s string) error { + return json.Unmarshal([]byte(s), &r) +} + // Predefined struct for user type RollbackConfigRequestParams struct { // 配置项发布历史ID @@ -18934,6 +20034,16 @@ type TsfPageCluster struct { Content []*Cluster `json:"Content,omitempty" name:"Content"` } +type TsfPageClusterV2 struct { + // 集群总数目 + // 注意:此字段可能返回 null,表示取不到有效值。 + TotalCount *int64 `json:"TotalCount,omitempty" name:"TotalCount"` + + // 集群列表 + // 注意:此字段可能返回 null,表示取不到有效值。 + Content []*ClusterV2 `json:"Content,omitempty" name:"Content"` +} + type TsfPageConfig struct { // TsfPageConfig TotalCount *int64 `json:"TotalCount,omitempty" name:"TotalCount"` @@ -18988,6 +20098,16 @@ type TsfPageFileConfig struct { Content []*FileConfig `json:"Content,omitempty" name:"Content"` } +type TsfPageFileConfigRelease struct { + // 数量 + // 注意:此字段可能返回 null,表示取不到有效值。 + TotalCount *int64 `json:"TotalCount,omitempty" name:"TotalCount"` + + // 列表 + // 注意:此字段可能返回 null,表示取不到有效值。 + Content []*FileConfigRelease `json:"Content,omitempty" name:"Content"` +} + type TsfPageGatewayDeployGroup struct { // 记录总数 TotalCount *int64 `json:"TotalCount,omitempty" name:"TotalCount"` @@ -19587,6 +20707,91 @@ func (r *UpdateApiTimeoutsResponse) FromJsonString(s string) error { return json.Unmarshal([]byte(s), &r) } +// Predefined struct for user +type UpdateConfigTemplateRequestParams struct { + // 配置模板id + ConfigTemplateId *string `json:"ConfigTemplateId,omitempty" name:"ConfigTemplateId"` + + // 配置模板名称 + ConfigTemplateName *string `json:"ConfigTemplateName,omitempty" name:"ConfigTemplateName"` + + // 配置模板对应的微服务框架 + ConfigTemplateType *string `json:"ConfigTemplateType,omitempty" name:"ConfigTemplateType"` + + // 配置模板数据 + ConfigTemplateValue *string `json:"ConfigTemplateValue,omitempty" name:"ConfigTemplateValue"` + + // 配置模板描述 + ConfigTemplateDesc *string `json:"ConfigTemplateDesc,omitempty" name:"ConfigTemplateDesc"` +} + +type UpdateConfigTemplateRequest struct { + *tchttp.BaseRequest + + // 配置模板id + ConfigTemplateId *string `json:"ConfigTemplateId,omitempty" name:"ConfigTemplateId"` + + // 配置模板名称 + ConfigTemplateName *string `json:"ConfigTemplateName,omitempty" name:"ConfigTemplateName"` + + // 配置模板对应的微服务框架 + ConfigTemplateType *string `json:"ConfigTemplateType,omitempty" name:"ConfigTemplateType"` + + // 配置模板数据 + ConfigTemplateValue *string `json:"ConfigTemplateValue,omitempty" name:"ConfigTemplateValue"` + + // 配置模板描述 + ConfigTemplateDesc *string `json:"ConfigTemplateDesc,omitempty" name:"ConfigTemplateDesc"` +} + +func (r *UpdateConfigTemplateRequest) ToJsonString() string { + b, _ := json.Marshal(r) + return string(b) +} + +// FromJsonString It is highly **NOT** recommended to use this function +// because it has no param check, nor strict type check +func (r *UpdateConfigTemplateRequest) FromJsonString(s string) error { + f := make(map[string]interface{}) + if err := json.Unmarshal([]byte(s), &f); err != nil { + return err + } + delete(f, "ConfigTemplateId") + delete(f, "ConfigTemplateName") + delete(f, "ConfigTemplateType") + delete(f, "ConfigTemplateValue") + delete(f, "ConfigTemplateDesc") + if len(f) > 0 { + return tcerr.NewTencentCloudSDKError("ClientError.BuildRequestError", "UpdateConfigTemplateRequest has unknown keys!", "") + } + return json.Unmarshal([]byte(s), &r) +} + +// Predefined struct for user +type UpdateConfigTemplateResponseParams struct { + // 结果true:成功;false:失败; + Result *bool `json:"Result,omitempty" name:"Result"` + + // 唯一请求 ID,每次请求都会返回。定位问题时需要提供该次请求的 RequestId。 + RequestId *string `json:"RequestId,omitempty" name:"RequestId"` +} + +type UpdateConfigTemplateResponse struct { + *tchttp.BaseResponse + Response *UpdateConfigTemplateResponseParams `json:"Response"` +} + +func (r *UpdateConfigTemplateResponse) ToJsonString() string { + b, _ := json.Marshal(r) + return string(b) +} + +// FromJsonString It is highly **NOT** recommended to use this function +// because it has no param check, nor strict type check +func (r *UpdateConfigTemplateResponse) FromJsonString(s string) error { + return json.Unmarshal([]byte(s), &r) +} + // Predefined struct for user type UpdateGatewayApiRequestParams struct { // API ID diff --git a/vendor/modules.txt b/vendor/modules.txt index 794a3a0070..c961485bdb 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -559,7 +559,7 @@ github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/clb/v20180317 github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cloudaudit/v20190319 # github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cls v1.0.412 github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cls/v20201016 -# github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.578 +# github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.584 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/http @@ -647,7 +647,7 @@ github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tem/v20210701 github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/teo/v20220901 # github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tke v1.0.549 github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tke/v20180525 -# github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tsf v1.0.577 +# github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tsf v1.0.584 github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tsf/v20180326 # github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/vod v1.0.199 github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/vod/v20180717 diff --git a/website/docs/r/tsf_api_group.html.markdown b/website/docs/r/tsf_api_group.html.markdown new file mode 100644 index 0000000000..eb754bc8f8 --- /dev/null +++ b/website/docs/r/tsf_api_group.html.markdown @@ -0,0 +1,75 @@ +--- +subcategory: "Tencent Service Framework(TSF)" +layout: "tencentcloud" +page_title: "TencentCloud: tencentcloud_tsf_api_group" +sidebar_current: "docs-tencentcloud-resource-tsf_api_group" +description: |- + Provides a resource to create a tsf api_group +--- + +# tencentcloud_tsf_api_group + +Provides a resource to create a tsf api_group + +## Example Usage + +```hcl +resource "tencentcloud_tsf_api_group" "api_group" { + group_name = "terraform_test_group" + group_context = "/terraform-test" + auth_type = "none" + description = "terraform-test" + group_type = "ms" + gateway_instance_id = "gw-ins-i6mjpgm8" + # namespace_name_key = "path" + # service_name_key = "path" + namespace_name_key_position = "path" + service_name_key_position = "path" +} +``` + +## Argument Reference + +The following arguments are supported: + +* `group_context` - (Required, String) grouping context. +* `group_name` - (Required, String) group name, cannot contain Chinese. +* `auth_type` - (Optional, String) authentication type. secret: key authentication; none: no authentication. +* `description` - (Optional, String) remarks. +* `gateway_instance_id` - (Optional, String) gateway entity ID. +* `group_type` - (Optional, String) grouping type, default ms. ms: microservice grouping; external: external Api grouping. +* `namespace_name_key_position` - (Optional, String) namespace parameter position, path, header or query, the default is path. +* `namespace_name_key` - (Optional, String) namespace parameter key value. +* `service_name_key_position` - (Optional, String) microservice name parameter position, path, header or query, the default is path. +* `service_name_key` - (Optional, String) microservice name parameter key value. + +## Attributes Reference + +In addition to all arguments above, the following attributes are exported: + +* `id` - ID of the resource. +* `acl_mode` - Access group ACL type. +* `api_count` - number of APIs. +* `binded_gateway_deploy_groups` - api group bound gateway deployment group. + * `application_id` - application ID. + * `application_name` - Application Name. + * `application_type` - Application classification: V: virtual machine application, C: container application. + * `cluster_type` - Cluster type, C: container, V: virtual machine. + * `deploy_group_id` - Gateway deployment group ID. + * `deploy_group_name` - Gateway deployment group name. + * `group_status` - Deployment group application status, values: Running, Waiting, Paused, Updating, RollingBack, Abnormal, Unknown. +* `created_time` - Group creation time such as: 2019-06-20 15:51:28. +* `gateway_instance_type` - Type of gateway instance. +* `group_id` - Api Group Id. +* `status` - Release status, drafted: Not published. released: released. +* `updated_time` - Group update time such as: 2019-06-20 15:51:28. + + +## Import + +tsf api_group can be imported using the id, e.g. + +``` +terraform import tencentcloud_tsf_api_group.api_group api_group_id +``` + diff --git a/website/docs/r/tsf_namespace.html.markdown b/website/docs/r/tsf_namespace.html.markdown new file mode 100644 index 0000000000..edc0c54551 --- /dev/null +++ b/website/docs/r/tsf_namespace.html.markdown @@ -0,0 +1,65 @@ +--- +subcategory: "Tencent Service Framework(TSF)" +layout: "tencentcloud" +page_title: "TencentCloud: tencentcloud_tsf_namespace" +sidebar_current: "docs-tencentcloud-resource-tsf_namespace" +description: |- + Provides a resource to create a tsf namespace +--- + +# tencentcloud_tsf_namespace + +Provides a resource to create a tsf namespace + +## Example Usage + +```hcl +resource "tencentcloud_tsf_namespace" "namespace" { + namespace_name = "xxx" + # cluster_id = "" + namespace_desc = "xxx" + # namespace_resource_type = "" + namespace_type = "DEF" + # namespace_id = "" + is_ha_enable = "0" + # program_id = "" + # program_id_list = +} +``` + +## Argument Reference + +The following arguments are supported: + +* `namespace_name` - (Required, String) namespace name. +* `cluster_id` - (Optional, String) cluster ID. +* `is_ha_enable` - (Optional, String) whether to enable high availability. +* `namespace_desc` - (Optional, String) namespace description. +* `namespace_id` - (Optional, String) Namespace ID. +* `namespace_resource_type` - (Optional, String) namespace resource type (default is DEF). +* `namespace_type` - (Optional, String) Whether it is a global namespace (the default is DEF, which means a common namespace; GLOBAL means a global namespace). +* `program_id_list` - (Optional, Set: [`String`]) Program id list. +* `program_id` - (Optional, String) ID of the dataset to be bound. + +## Attributes Reference + +In addition to all arguments above, the following attributes are exported: + +* `id` - ID of the resource. +* `create_time` - creation time. +* `delete_flag` - Delete ID. +* `is_default` - default namespace. +* `kube_inject_enable` - KubeInjectEnable value. +* `namespace_code` - Namespace encoding. +* `namespace_status` - namespace status. +* `update_time` - update time. + + +## Import + +tsf namespace can be imported using the id, e.g. + +``` +terraform import tencentcloud_tsf_namespace.namespace namespace_id +``` + diff --git a/website/tencentcloud.erb b/website/tencentcloud.erb index c1ff57e34c..486aee407e 100644 --- a/website/tencentcloud.erb +++ b/website/tencentcloud.erb @@ -2047,6 +2047,12 @@
  • tencentcloud_tsf_application_config
  • +
  • + tencentcloud_tsf_api_group +
  • +
  • + tencentcloud_tsf_namespace +
  • From e67360cb5c825de8601cddd6e58723013793bf31 Mon Sep 17 00:00:00 2001 From: anonymous Date: Wed, 1 Feb 2023 10:17:24 +0800 Subject: [PATCH 03/11] fix: tfprovider lint --- .../resource_tc_tsf_application_release_config.go | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/tencentcloud/resource_tc_tsf_application_release_config.go b/tencentcloud/resource_tc_tsf_application_release_config.go index f96f432386..93e166b2b8 100644 --- a/tencentcloud/resource_tc_tsf_application_release_config.go +++ b/tencentcloud/resource_tc_tsf_application_release_config.go @@ -66,70 +66,60 @@ func resourceTencentCloudTsfApplicationReleaseConfig() *schema.Resource { "config_release_id": { Computed: true, - ForceNew: true, Type: schema.TypeString, Description: "configuration item release ID.", }, "config_name": { Computed: true, - ForceNew: true, Type: schema.TypeString, Description: "configuration item name.", }, "config_version": { Computed: true, - ForceNew: true, Type: schema.TypeString, Description: "configuration item version.", }, "release_time": { Computed: true, - ForceNew: true, Type: schema.TypeString, Description: "release time.", }, "group_name": { Computed: true, - ForceNew: true, Type: schema.TypeString, Description: "deployment group name.", }, "namespace_id": { Computed: true, - ForceNew: true, Type: schema.TypeString, Description: "Namespace ID.", }, "namespace_name": { Computed: true, - ForceNew: true, Type: schema.TypeString, Description: "namespace name.", }, "cluster_id": { Computed: true, - ForceNew: true, Type: schema.TypeString, Description: "cluster ID.", }, "cluster_name": { Computed: true, - ForceNew: true, Type: schema.TypeString, Description: "cluster name.", }, "application_id": { Computed: true, - ForceNew: true, Type: schema.TypeString, Description: "Application ID.", }, From a3838af198a28f83a94cf619e183c4c00d21fed2 Mon Sep 17 00:00:00 2001 From: anonymous Date: Wed, 1 Feb 2023 10:31:41 +0800 Subject: [PATCH 04/11] fix: support tsf --- tencentcloud/provider.go | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/tencentcloud/provider.go b/tencentcloud/provider.go index 1f0d9f8a84..013bc11318 100644 --- a/tencentcloud/provider.go +++ b/tencentcloud/provider.go @@ -1657,16 +1657,16 @@ func Provider() terraform.ResourceProvider { "tencentcloud_cvm_launch_template": resourceTencentCloudCvmLaunchTemplate(), "tencentcloud_tsf_api_group": resourceTencentCloudTsfApiGroup(), "tencentcloud_tsf_namespace": resourceTencentCloudTsfNamespace(), - // "tencentcloud_tsf_path_rewrite": resourceTencentCloudTsfPathRewrite(), - // "tencentcloud_tsf_unit_rule": resourceTencentCloudTsfUnitRule(), - // "tencentcloud_tsf_task": resourceTencentCloudTsfTask(), - // "tencentcloud_tsf_repository": resourceTencentCloudTsfRepository(), - // "tencentcloud_tsf_config_template": resourceTencentCloudTsfConfigTemplate(), - // "tencentcloud_tsf_api_rate_limit_rule": resourceTencentCloudTsfApiRateLimitRule(), - // "tencentcloud_tsf_application_release_config": resourceTencentCloudTsfApplicationReleaseConfig(), - // "tencentcloud_tsf_contain_group": resourceTencentCloudTsfContainGroup(), - // "tencentcloud_tsf_lane": resourceTencentCloudTsfLane(), - // "tencentcloud_tsf_lane_rule": resourceTencentCloudTsfLaneRule(), + "tencentcloud_tsf_path_rewrite": resourceTencentCloudTsfPathRewrite(), + "tencentcloud_tsf_unit_rule": resourceTencentCloudTsfUnitRule(), + "tencentcloud_tsf_task": resourceTencentCloudTsfTask(), + "tencentcloud_tsf_repository": resourceTencentCloudTsfRepository(), + "tencentcloud_tsf_config_template": resourceTencentCloudTsfConfigTemplate(), + "tencentcloud_tsf_api_rate_limit_rule": resourceTencentCloudTsfApiRateLimitRule(), + "tencentcloud_tsf_application_release_config": resourceTencentCloudTsfApplicationReleaseConfig(), + "tencentcloud_tsf_contain_group": resourceTencentCloudTsfContainGroup(), + "tencentcloud_tsf_lane": resourceTencentCloudTsfLane(), + "tencentcloud_tsf_lane_rule": resourceTencentCloudTsfLaneRule(), }, ConfigureFunc: providerConfigure, From d57ccd2663952000a59bfbb328e5de9931904830 Mon Sep 17 00:00:00 2001 From: anonymous Date: Wed, 1 Feb 2023 14:36:53 +0800 Subject: [PATCH 05/11] fix:unit tests --- tencentcloud/resource_tc_tsf_unit_rule.go | 32 +++++++++++------------ 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/tencentcloud/resource_tc_tsf_unit_rule.go b/tencentcloud/resource_tc_tsf_unit_rule.go index 26cb16543d..dc8e56035c 100644 --- a/tencentcloud/resource_tc_tsf_unit_rule.go +++ b/tencentcloud/resource_tc_tsf_unit_rule.go @@ -13,7 +13,7 @@ resource "tencentcloud_tsf_unit_rule" "unit_rule" { dest_namespace_id = "" dest_namespace_name = "" name = "" - id = "" + rule_id = "" unit_rule_id = "" priority = description = "" @@ -23,7 +23,7 @@ resource "tencentcloud_tsf_unit_rule" "unit_rule" { tag_operator = "" tag_value = "" unit_rule_item_id = "" - id = "" + rule_id = "" } } @@ -73,7 +73,7 @@ func resourceTencentCloudTsfUnitRule() *schema.Resource { Description: "rule name.", }, - "id": { + "rule_id": { Computed: true, Type: schema.TypeString, Description: "rule ID.", @@ -118,7 +118,7 @@ func resourceTencentCloudTsfUnitRule() *schema.Resource { Required: true, Description: "rule item name.", }, - "id": { + "rule_id": { Type: schema.TypeString, Optional: true, Description: "rule item ID.", @@ -169,7 +169,7 @@ func resourceTencentCloudTsfUnitRule() *schema.Resource { Optional: true, Description: "Unitization rule item ID.", }, - "id": { + "rule_id": { Type: schema.TypeString, Optional: true, Description: "rule ID.", @@ -193,7 +193,7 @@ func resourceTencentCloudTsfUnitRuleCreate(d *schema.ResourceData, meta interfac var ( request = tsf.NewCreateUnitRuleRequest() // response = tsf.NewCreateUnitRuleResponse() - id string + ruleId string ) if v, ok := d.GetOk("gateway_instance_id"); ok { request.GatewayInstanceId = helper.String(v.(string)) @@ -223,7 +223,7 @@ func resourceTencentCloudTsfUnitRuleCreate(d *schema.ResourceData, meta interfac if v, ok := dMap["name"]; ok { unitRuleItem.Name = helper.String(v.(string)) } - if v, ok := dMap["id"]; ok { + if v, ok := dMap["rule_id"]; ok { unitRuleItem.Id = helper.String(v.(string)) } if v, ok := dMap["unit_rule_id"]; ok { @@ -254,7 +254,7 @@ func resourceTencentCloudTsfUnitRuleCreate(d *schema.ResourceData, meta interfac if v, ok := unitRuleTagListMap["unit_rule_item_id"]; ok { unitRuleTag.UnitRuleItemId = helper.String(v.(string)) } - if v, ok := unitRuleTagListMap["id"]; ok { + if v, ok := unitRuleTagListMap["rule_id"]; ok { unitRuleTag.Id = helper.String(v.(string)) } unitRuleItem.UnitRuleTagList = append(unitRuleItem.UnitRuleTagList, &unitRuleTag) @@ -279,8 +279,8 @@ func resourceTencentCloudTsfUnitRuleCreate(d *schema.ResourceData, meta interfac return err } - // id = *response.Response.Id - d.SetId(id) + // ruleId = *response.Response.RuleId + d.SetId(ruleId) return resourceTencentCloudTsfUnitRuleRead(d, meta) } @@ -317,7 +317,7 @@ func resourceTencentCloudTsfUnitRuleRead(d *schema.ResourceData, meta interface{ } if unitRule.Id != nil { - _ = d.Set("id", unitRule.Id) + _ = d.Set("rule_id", unitRule.Id) } if unitRule.Status != nil { @@ -350,7 +350,7 @@ func resourceTencentCloudTsfUnitRuleRead(d *schema.ResourceData, meta interface{ } if unitRuleItemList.Id != nil { - unitRuleItemListMap["id"] = unitRuleItemList.Id + unitRuleItemListMap["rule_id"] = unitRuleItemList.Id } if unitRuleItemList.UnitRuleId != nil { @@ -391,7 +391,7 @@ func resourceTencentCloudTsfUnitRuleRead(d *schema.ResourceData, meta interface{ } if unitRuleTagList.Id != nil { - unitRuleTagListMap["id"] = unitRuleTagList.Id + unitRuleTagListMap["rule_id"] = unitRuleTagList.Id } unitRuleTagListList = append(unitRuleTagListList, unitRuleTagListMap) @@ -422,7 +422,7 @@ func resourceTencentCloudTsfUnitRuleUpdate(d *schema.ResourceData, meta interfac request.Id = &id - immutableArgs := []string{"gateway_instance_id", "name", "id", "status", "description", "unit_rule_item_list"} + immutableArgs := []string{"gateway_instance_id", "name", "rule_id", "status", "description", "unit_rule_item_list"} for _, v := range immutableArgs { if d.HasChange(v) { @@ -459,7 +459,7 @@ func resourceTencentCloudTsfUnitRuleUpdate(d *schema.ResourceData, meta interfac if v, ok := dMap["name"]; ok { unitRuleItem.Name = helper.String(v.(string)) } - if v, ok := dMap["id"]; ok { + if v, ok := dMap["rule_id"]; ok { unitRuleItem.Id = helper.String(v.(string)) } if v, ok := dMap["unit_rule_id"]; ok { @@ -490,7 +490,7 @@ func resourceTencentCloudTsfUnitRuleUpdate(d *schema.ResourceData, meta interfac if v, ok := unitRuleTagListMap["unit_rule_item_id"]; ok { unitRuleTag.UnitRuleItemId = helper.String(v.(string)) } - if v, ok := unitRuleTagListMap["id"]; ok { + if v, ok := unitRuleTagListMap["rule_id"]; ok { unitRuleTag.Id = helper.String(v.(string)) } unitRuleItem.UnitRuleTagList = append(unitRuleItem.UnitRuleTagList, &unitRuleTag) From d9997fbd4cdb3162d608b6f7f8ad761aa341162c Mon Sep 17 00:00:00 2001 From: anonymous Date: Wed, 1 Feb 2023 14:38:55 +0800 Subject: [PATCH 06/11] fix: golangci lint --- tencentcloud/resource_tc_tsf_lane_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tencentcloud/resource_tc_tsf_lane_test.go b/tencentcloud/resource_tc_tsf_lane_test.go index e9d9c1d66c..21bf2fce40 100644 --- a/tencentcloud/resource_tc_tsf_lane_test.go +++ b/tencentcloud/resource_tc_tsf_lane_test.go @@ -20,7 +20,7 @@ func TestAccTencentCloudNeedFixTsfLaneResource_basic(t *testing.T) { CheckDestroy: testAccCheckTsfLaneDestroy, Steps: []resource.TestStep{ { - Config: testAccTsfNamespace, + Config: testAccTsfLane, Check: resource.ComposeTestCheckFunc( testAccCheckTsfLaneExists("tencentcloud_tsf_lane.lane"), resource.TestCheckResourceAttrSet("tencentcloud_tsf_lane.lane", "id"), From 706840d141ce195985fd76ba2988b1e0ba882cf5 Mon Sep 17 00:00:00 2001 From: anonymous Date: Wed, 1 Feb 2023 15:06:51 +0800 Subject: [PATCH 07/11] fix: fix unit --- tencentcloud/resource_tc_tsf_config_template_test.go | 5 +++-- tencentcloud/resource_tc_tsf_contain_group_test.go | 5 +++-- tencentcloud/resource_tc_tsf_lane_rule_test.go | 5 +++-- tencentcloud/resource_tc_tsf_path_rewrite_test.go | 5 +++-- tencentcloud/resource_tc_tsf_repository_test.go | 5 +++-- tencentcloud/resource_tc_tsf_task_test.go | 5 +++-- tencentcloud/resource_tc_tsf_unit_rule_test.go | 5 +++-- 7 files changed, 21 insertions(+), 14 deletions(-) diff --git a/tencentcloud/resource_tc_tsf_config_template_test.go b/tencentcloud/resource_tc_tsf_config_template_test.go index 4b1b63a66e..bf04357343 100644 --- a/tencentcloud/resource_tc_tsf_config_template_test.go +++ b/tencentcloud/resource_tc_tsf_config_template_test.go @@ -1,11 +1,12 @@ package tencentcloud import ( - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" "testing" + + "github.com/hashicorp/terraform-plugin-sdk/helper/resource" ) -func TestAccTencentCloudTsfConfigTemplateResource_basic(t *testing.T) { +func TestAccTencentCloudNeedFixTsfConfigTemplateResource_basic(t *testing.T) { t.Parallel() resource.Test(t, resource.TestCase{ PreCheck: func() { diff --git a/tencentcloud/resource_tc_tsf_contain_group_test.go b/tencentcloud/resource_tc_tsf_contain_group_test.go index ab7df17e73..5b2fc394fb 100644 --- a/tencentcloud/resource_tc_tsf_contain_group_test.go +++ b/tencentcloud/resource_tc_tsf_contain_group_test.go @@ -1,11 +1,12 @@ package tencentcloud import ( - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" "testing" + + "github.com/hashicorp/terraform-plugin-sdk/helper/resource" ) -func TestAccTencentCloudTsfContainGroupResource_basic(t *testing.T) { +func TestAccTencentCloudNeedFixTsfContainGroupResource_basic(t *testing.T) { t.Parallel() resource.Test(t, resource.TestCase{ PreCheck: func() { diff --git a/tencentcloud/resource_tc_tsf_lane_rule_test.go b/tencentcloud/resource_tc_tsf_lane_rule_test.go index 0f2bef709c..89a0a6eef5 100644 --- a/tencentcloud/resource_tc_tsf_lane_rule_test.go +++ b/tencentcloud/resource_tc_tsf_lane_rule_test.go @@ -1,11 +1,12 @@ package tencentcloud import ( - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" "testing" + + "github.com/hashicorp/terraform-plugin-sdk/helper/resource" ) -func TestAccTencentCloudTsfLaneRuleResource_basic(t *testing.T) { +func TestAccTencentCloudNeedFixTsfLaneRuleResource_basic(t *testing.T) { t.Parallel() resource.Test(t, resource.TestCase{ PreCheck: func() { diff --git a/tencentcloud/resource_tc_tsf_path_rewrite_test.go b/tencentcloud/resource_tc_tsf_path_rewrite_test.go index 072c4e07f5..2617d566c8 100644 --- a/tencentcloud/resource_tc_tsf_path_rewrite_test.go +++ b/tencentcloud/resource_tc_tsf_path_rewrite_test.go @@ -1,11 +1,12 @@ package tencentcloud import ( - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" "testing" + + "github.com/hashicorp/terraform-plugin-sdk/helper/resource" ) -func TestAccTencentCloudTsfPathRewriteResource_basic(t *testing.T) { +func TestAccTencentCloudNeedFixTsfPathRewriteResource_basic(t *testing.T) { t.Parallel() resource.Test(t, resource.TestCase{ PreCheck: func() { diff --git a/tencentcloud/resource_tc_tsf_repository_test.go b/tencentcloud/resource_tc_tsf_repository_test.go index 5d719b734a..ef9c30ea97 100644 --- a/tencentcloud/resource_tc_tsf_repository_test.go +++ b/tencentcloud/resource_tc_tsf_repository_test.go @@ -1,11 +1,12 @@ package tencentcloud import ( - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" "testing" + + "github.com/hashicorp/terraform-plugin-sdk/helper/resource" ) -func TestAccTencentCloudTsfRepositoryResource_basic(t *testing.T) { +func TestAccTencentCloudNeedFixTsfRepositoryResource_basic(t *testing.T) { t.Parallel() resource.Test(t, resource.TestCase{ PreCheck: func() { diff --git a/tencentcloud/resource_tc_tsf_task_test.go b/tencentcloud/resource_tc_tsf_task_test.go index a1d1aef3ec..06fcbad761 100644 --- a/tencentcloud/resource_tc_tsf_task_test.go +++ b/tencentcloud/resource_tc_tsf_task_test.go @@ -1,11 +1,12 @@ package tencentcloud import ( - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" "testing" + + "github.com/hashicorp/terraform-plugin-sdk/helper/resource" ) -func TestAccTencentCloudTsfTaskResource_basic(t *testing.T) { +func TestAccTencentCloudNeedFixTsfTaskResource_basic(t *testing.T) { t.Parallel() resource.Test(t, resource.TestCase{ PreCheck: func() { diff --git a/tencentcloud/resource_tc_tsf_unit_rule_test.go b/tencentcloud/resource_tc_tsf_unit_rule_test.go index ba4c13e9c1..a60b187805 100644 --- a/tencentcloud/resource_tc_tsf_unit_rule_test.go +++ b/tencentcloud/resource_tc_tsf_unit_rule_test.go @@ -1,11 +1,12 @@ package tencentcloud import ( - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" "testing" + + "github.com/hashicorp/terraform-plugin-sdk/helper/resource" ) -func TestAccTencentCloudTsfUnitRuleResource_basic(t *testing.T) { +func TestAccTencentCloudNeedFixTsfUnitRuleResource_basic(t *testing.T) { t.Parallel() resource.Test(t, resource.TestCase{ PreCheck: func() { From 0d6ba805997597fac88034dbae2444cb109bb503 Mon Sep 17 00:00:00 2001 From: anonymous Date: Wed, 1 Feb 2023 15:41:45 +0800 Subject: [PATCH 08/11] fix: fix unit --- tencentcloud/resource_tc_tsf_api_rate_limit_rule_test.go | 5 +++-- .../resource_tc_tsf_application_release_config_test.go | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/tencentcloud/resource_tc_tsf_api_rate_limit_rule_test.go b/tencentcloud/resource_tc_tsf_api_rate_limit_rule_test.go index 54c1a52e70..0c6d5063f6 100644 --- a/tencentcloud/resource_tc_tsf_api_rate_limit_rule_test.go +++ b/tencentcloud/resource_tc_tsf_api_rate_limit_rule_test.go @@ -1,11 +1,12 @@ package tencentcloud import ( - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" "testing" + + "github.com/hashicorp/terraform-plugin-sdk/helper/resource" ) -func TestAccTencentCloudTsfApiRateLimitRuleResource_basic(t *testing.T) { +func TestAccTencentCloudNeedFixTsfApiRateLimitRuleResource_basic(t *testing.T) { t.Parallel() resource.Test(t, resource.TestCase{ PreCheck: func() { diff --git a/tencentcloud/resource_tc_tsf_application_release_config_test.go b/tencentcloud/resource_tc_tsf_application_release_config_test.go index 8e53f6e2fb..88e6837038 100644 --- a/tencentcloud/resource_tc_tsf_application_release_config_test.go +++ b/tencentcloud/resource_tc_tsf_application_release_config_test.go @@ -1,11 +1,12 @@ package tencentcloud import ( - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" "testing" + + "github.com/hashicorp/terraform-plugin-sdk/helper/resource" ) -func TestAccTencentCloudTsfApplicationReleaseConfigResource_basic(t *testing.T) { +func TestAccTencentCloudNeedFixTsfApplicationReleaseConfigResource_basic(t *testing.T) { t.Parallel() resource.Test(t, resource.TestCase{ PreCheck: func() { From 9b6de6ae6b27045688f96e7886074b2406a9a4fd Mon Sep 17 00:00:00 2001 From: anonymous Date: Wed, 1 Feb 2023 15:54:14 +0800 Subject: [PATCH 09/11] feat: add changelog --- .changelog/1524.txt | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 .changelog/1524.txt diff --git a/.changelog/1524.txt b/.changelog/1524.txt new file mode 100644 index 0000000000..fd79e4ef80 --- /dev/null +++ b/.changelog/1524.txt @@ -0,0 +1,7 @@ +```release-note:new-resource +tencentcloud_tsf_api_group +``` + +```release-note:new-resource +tencentcloud_tsf_namespace +``` \ No newline at end of file From e5d5680812bcb1131687f4ac60f0c26ab6c27fc9 Mon Sep 17 00:00:00 2001 From: anonymous Date: Wed, 1 Feb 2023 22:07:23 +0800 Subject: [PATCH 10/11] fix: modify example --- tencentcloud/resource_tc_tsf_namespace.go | 5 ++--- website/docs/r/tsf_namespace.html.markdown | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/tencentcloud/resource_tc_tsf_namespace.go b/tencentcloud/resource_tc_tsf_namespace.go index 37a6467fbc..aa712f845c 100644 --- a/tencentcloud/resource_tc_tsf_namespace.go +++ b/tencentcloud/resource_tc_tsf_namespace.go @@ -5,15 +5,14 @@ Example Usage ```hcl resource "tencentcloud_tsf_namespace" "namespace" { - namespace_name = "xxx" + namespace_name = "namespace-name" # cluster_id = "" - namespace_desc = "xxx" + namespace_desc = "namespace desc" # namespace_resource_type = "" namespace_type = "DEF" # namespace_id = "" is_ha_enable = "0" # program_id = "" - # program_id_list = } ``` diff --git a/website/docs/r/tsf_namespace.html.markdown b/website/docs/r/tsf_namespace.html.markdown index edc0c54551..f033e8f492 100644 --- a/website/docs/r/tsf_namespace.html.markdown +++ b/website/docs/r/tsf_namespace.html.markdown @@ -15,15 +15,14 @@ Provides a resource to create a tsf namespace ```hcl resource "tencentcloud_tsf_namespace" "namespace" { - namespace_name = "xxx" + namespace_name = "namespace-name" # cluster_id = "" - namespace_desc = "xxx" + namespace_desc = "namespace desc" # namespace_resource_type = "" namespace_type = "DEF" # namespace_id = "" is_ha_enable = "0" # program_id = "" - # program_id_list = } ``` From 36d97a85f3715e4dc5f0ede213b9c0fac1214de9 Mon Sep 17 00:00:00 2001 From: anonymous Date: Wed, 1 Feb 2023 22:11:42 +0800 Subject: [PATCH 11/11] fix: modify example --- tencentcloud/resource_tc_tsf_namespace.go | 2 +- website/docs/r/tsf_namespace.html.markdown | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tencentcloud/resource_tc_tsf_namespace.go b/tencentcloud/resource_tc_tsf_namespace.go index aa712f845c..e41eb327e4 100644 --- a/tencentcloud/resource_tc_tsf_namespace.go +++ b/tencentcloud/resource_tc_tsf_namespace.go @@ -6,7 +6,7 @@ Example Usage ```hcl resource "tencentcloud_tsf_namespace" "namespace" { namespace_name = "namespace-name" - # cluster_id = "" + # cluster_id = "cls-xxxx" namespace_desc = "namespace desc" # namespace_resource_type = "" namespace_type = "DEF" diff --git a/website/docs/r/tsf_namespace.html.markdown b/website/docs/r/tsf_namespace.html.markdown index f033e8f492..33f292195d 100644 --- a/website/docs/r/tsf_namespace.html.markdown +++ b/website/docs/r/tsf_namespace.html.markdown @@ -16,7 +16,7 @@ Provides a resource to create a tsf namespace ```hcl resource "tencentcloud_tsf_namespace" "namespace" { namespace_name = "namespace-name" - # cluster_id = "" + # cluster_id = "cls-xxxx" namespace_desc = "namespace desc" # namespace_resource_type = "" namespace_type = "DEF"