From 5999e583fc144a3bb3438237fc438c1d45e8a3d9 Mon Sep 17 00:00:00 2001 From: gitmkn <41282634+gitmkn@users.noreply.github.com> Date: Fri, 28 Apr 2023 17:39:26 +0800 Subject: [PATCH] feat: support tsf datasource (#1694) * feat: support tsf datasource * fix: modify doc * fix: modify tsf sdk * fix: update api * feat: add changelog --------- Co-authored-by: anonymous --- .changelog/1694.txt | 27 + go.mod | 2 +- go.sum | 2 + .../data_source_tc_tsf_application.go | 373 ++++++++++++ .../data_source_tc_tsf_application_config.go | 283 +++++++++ ...a_source_tc_tsf_application_config_test.go | 58 ++ ...a_source_tc_tsf_application_file_config.go | 316 ++++++++++ ...rce_tc_tsf_application_file_config_test.go | 51 ++ ...source_tc_tsf_application_public_config.go | 269 +++++++++ ...e_tc_tsf_application_public_config_test.go | 44 ++ .../data_source_tc_tsf_application_test.go | 54 ++ tencentcloud/data_source_tc_tsf_cluster.go | 545 ++++++++++++++++++ .../data_source_tc_tsf_cluster_test.go | 49 ++ .../data_source_tc_tsf_microservice.go | 244 ++++++++ .../data_source_tc_tsf_microservice_test.go | 48 ++ tencentcloud/data_source_tc_tsf_unit_rules.go | 365 ++++++++++++ .../data_source_tc_tsf_unit_rules_test.go | 64 ++ tencentcloud/provider.go | 15 + tencentcloud/service_tencentcloud_tsf.go | 455 +++++++++++++++ .../tencentcloud/tsf/v20180326/client.go | 52 ++ .../tencentcloud/tsf/v20180326/models.go | 96 +++ vendor/modules.txt | 2 +- website/docs/d/tsf_application.html.markdown | 63 ++ .../d/tsf_application_config.html.markdown | 57 ++ .../tsf_application_file_config.html.markdown | 61 ++ ...sf_application_public_config.html.markdown | 55 ++ website/docs/d/tsf_cluster.html.markdown | 83 +++ website/docs/d/tsf_microservice.html.markdown | 51 ++ website/docs/d/tsf_unit_rules.html.markdown | 62 ++ website/tencentcloud.erb | 27 +- 30 files changed, 3870 insertions(+), 3 deletions(-) create mode 100644 .changelog/1694.txt create mode 100644 tencentcloud/data_source_tc_tsf_application.go create mode 100644 tencentcloud/data_source_tc_tsf_application_config.go create mode 100644 tencentcloud/data_source_tc_tsf_application_config_test.go create mode 100644 tencentcloud/data_source_tc_tsf_application_file_config.go create mode 100644 tencentcloud/data_source_tc_tsf_application_file_config_test.go create mode 100644 tencentcloud/data_source_tc_tsf_application_public_config.go create mode 100644 tencentcloud/data_source_tc_tsf_application_public_config_test.go create mode 100644 tencentcloud/data_source_tc_tsf_application_test.go create mode 100644 tencentcloud/data_source_tc_tsf_cluster.go create mode 100644 tencentcloud/data_source_tc_tsf_cluster_test.go create mode 100644 tencentcloud/data_source_tc_tsf_microservice.go create mode 100644 tencentcloud/data_source_tc_tsf_microservice_test.go create mode 100644 tencentcloud/data_source_tc_tsf_unit_rules.go create mode 100644 tencentcloud/data_source_tc_tsf_unit_rules_test.go create mode 100644 website/docs/d/tsf_application.html.markdown create mode 100644 website/docs/d/tsf_application_config.html.markdown create mode 100644 website/docs/d/tsf_application_file_config.html.markdown create mode 100644 website/docs/d/tsf_application_public_config.html.markdown create mode 100644 website/docs/d/tsf_cluster.html.markdown create mode 100644 website/docs/d/tsf_microservice.html.markdown create mode 100644 website/docs/d/tsf_unit_rules.html.markdown diff --git a/.changelog/1694.txt b/.changelog/1694.txt new file mode 100644 index 0000000000..c12b2be499 --- /dev/null +++ b/.changelog/1694.txt @@ -0,0 +1,27 @@ +```release-note:new-data-source +tencentcloud_tsf_application +``` + +```release-note:new-data-source +tencentcloud_tsf_application_config +``` + +```release-note:new-data-source +tencentcloud_tsf_application_file_config +``` + +```release-note:new-data-source +tencentcloud_tsf_application_public_config +``` + +```release-note:new-data-source +tencentcloud_tsf_cluster +``` + +```release-note:new-data-source +tencentcloud_tsf_microservice +``` + +```release-note:new-data-source +tencentcloud_tsf_unit_rules +``` diff --git a/go.mod b/go.mod index c7020ab99c..7bc32850a6 100644 --- a/go.mod +++ b/go.mod @@ -82,7 +82,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.644 - github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tsf v1.0.645 + github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tsf v1.0.648 github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/vod v1.0.199 github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/vpc v1.0.648 github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/wss v1.0.199 diff --git a/go.sum b/go.sum index 6b22dbb298..bff2037f6f 100644 --- a/go.sum +++ b/go.sum @@ -623,6 +623,8 @@ github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tsf v1.0.625 h1:7MIw7C2 github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tsf v1.0.625/go.mod h1:xmIp0wQaSn5rSGJFCjakl5FPNVrIPYa3Uknj3oI3tmc= github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tsf v1.0.645 h1:D7cAMz8kGLbihjv0lphEN1+mZdxAd97uju89pkaCZZ4= github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tsf v1.0.645/go.mod h1:QHuHW0b10vcps7ckSVaT12/MGG25UV+3Z+uIUYD65Uo= +github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tsf v1.0.648 h1:2W0dqmFYuJNdNcBgRSoRVeLl6I34kqQQeIuDeJHZAyY= +github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tsf v1.0.648/go.mod h1:Motj98jn34I9Wr5ZINwz6WIe+Wuf75+Otf3NEoO66HE= 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.638 h1:0/btEL8LdbikGa1nVW/3TnHjArPsDGwSKuLi9GZQzPw= diff --git a/tencentcloud/data_source_tc_tsf_application.go b/tencentcloud/data_source_tc_tsf_application.go new file mode 100644 index 0000000000..0295fa5a44 --- /dev/null +++ b/tencentcloud/data_source_tc_tsf_application.go @@ -0,0 +1,373 @@ +/* +Use this data source to query detailed information of tsf application + +Example Usage + +```hcl +data "tencentcloud_tsf_application" "application" { + application_type = "V" + microservice_type = "N" + # application_resource_type_list = [""] + application_id_list = ["application-a24x29xv"] +} +``` +*/ +package tencentcloud + +import ( + "context" + + "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 dataSourceTencentCloudTsfApplication() *schema.Resource { + return &schema.Resource{ + Read: dataSourceTencentCloudTsfApplicationRead, + Schema: map[string]*schema.Schema{ + "application_type": { + Optional: true, + Type: schema.TypeString, + Description: "The application type. V OR C, V means VM, C means container.", + }, + + "microservice_type": { + Optional: true, + Type: schema.TypeString, + Description: "The microservice type of the application.", + }, + + "application_resource_type_list": { + Optional: true, + Type: schema.TypeSet, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + Description: "An array of application resource types.", + }, + + "application_id_list": { + Optional: true, + Type: schema.TypeSet, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + Description: "Id list.", + }, + + "result": { + Computed: true, + Type: schema.TypeList, + Description: "The application paging list information.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "total_count": { + Type: schema.TypeInt, + Computed: true, + Description: "The total number of applications.", + }, + "content": { + Type: schema.TypeList, + Computed: true, + Description: "The list of application information.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "application_id": { + Type: schema.TypeString, + Computed: true, + Description: "The ID of the application.", + }, + "application_name": { + Type: schema.TypeString, + Computed: true, + Description: "The name of the application.", + }, + "application_desc": { + Type: schema.TypeString, + Computed: true, + Description: "The description of the application.", + }, + "application_type": { + Type: schema.TypeString, + Computed: true, + Description: "The type of the application.", + }, + "microservice_type": { + Type: schema.TypeString, + Computed: true, + Description: "The microservice type of the application.", + }, + "prog_lang": { + Type: schema.TypeString, + Computed: true, + Description: "Programming language.", + }, + "create_time": { + Type: schema.TypeString, + Computed: true, + Description: "create time.", + }, + "update_time": { + Type: schema.TypeString, + Computed: true, + Description: "update time.", + }, + "application_resource_type": { + Type: schema.TypeString, + Computed: true, + Description: "application resource type.", + }, + "application_runtime_type": { + Type: schema.TypeString, + Computed: true, + Description: "application runtime type.", + }, + "apigateway_service_id": { + Type: schema.TypeString, + Computed: true, + Description: "gateway service id.", + }, + "application_remark_name": { + Type: schema.TypeString, + Computed: true, + Description: "remark name.", + }, + "service_config_list": { + Type: schema.TypeList, + Computed: true, + Description: "service config list.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Computed: true, + Description: "serviceName.", + }, + "ports": { + Type: schema.TypeList, + Computed: true, + Description: "port list.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "target_port": { + Type: schema.TypeInt, + Computed: true, + Description: "service port.", + }, + "protocol": { + Type: schema.TypeString, + Computed: true, + Description: "protocol.", + }, + }, + }, + }, + "health_check": { + Type: schema.TypeList, + Computed: true, + Description: "health check setting.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "path": { + Type: schema.TypeString, + Computed: true, + Description: "health check path.", + }, + }, + }, + }, + }, + }, + }, + "ignore_create_image_repository": { + Type: schema.TypeBool, + Computed: true, + Description: "whether ignore create image repository.", + }, + }, + }, + }, + }, + }, + }, + + "result_output_file": { + Type: schema.TypeString, + Optional: true, + Description: "Used to save results.", + }, + }, + } +} + +func dataSourceTencentCloudTsfApplicationRead(d *schema.ResourceData, meta interface{}) error { + defer logElapsed("data_source.tencentcloud_tsf_application.read")() + defer inconsistentCheck(d, meta)() + + logId := getLogId(contextNil) + + ctx := context.WithValue(context.TODO(), logIdKey, logId) + + paramMap := make(map[string]interface{}) + if v, ok := d.GetOk("application_type"); ok { + paramMap["ApplicationType"] = helper.String(v.(string)) + } + + if v, ok := d.GetOk("microservice_type"); ok { + paramMap["MicroserviceType"] = helper.String(v.(string)) + } + + if v, ok := d.GetOk("application_resource_type_list"); ok { + applicationResourceTypeListSet := v.(*schema.Set).List() + paramMap["ApplicationResourceTypeList"] = helper.InterfacesStringsPoint(applicationResourceTypeListSet) + } + + if v, ok := d.GetOk("application_id_list"); ok { + applicationIdListSet := v.(*schema.Set).List() + paramMap["ApplicationIdList"] = helper.InterfacesStringsPoint(applicationIdListSet) + } + + service := TsfService{client: meta.(*TencentCloudClient).apiV3Conn} + + var application *tsf.TsfPageApplication + err := resource.Retry(readRetryTimeout, func() *resource.RetryError { + result, e := service.DescribeTsfApplicationByFilter(ctx, paramMap) + if e != nil { + return retryError(e) + } + application = result + return nil + }) + if err != nil { + return err + } + + ids := make([]string, 0, len(application.Content)) + tsfPageApplicationMap := map[string]interface{}{} + if application != nil { + if application.TotalCount != nil { + tsfPageApplicationMap["total_count"] = application.TotalCount + } + + if application.Content != nil { + contentList := []interface{}{} + for _, content := range application.Content { + contentMap := map[string]interface{}{} + + if content.ApplicationId != nil { + contentMap["application_id"] = content.ApplicationId + } + + if content.ApplicationName != nil { + contentMap["application_name"] = content.ApplicationName + } + + if content.ApplicationDesc != nil { + contentMap["application_desc"] = content.ApplicationDesc + } + + if content.ApplicationType != nil { + contentMap["application_type"] = content.ApplicationType + } + + if content.MicroserviceType != nil { + contentMap["microservice_type"] = content.MicroserviceType + } + + if content.ProgLang != nil { + contentMap["prog_lang"] = content.ProgLang + } + + if content.CreateTime != nil { + contentMap["create_time"] = content.CreateTime + } + + if content.UpdateTime != nil { + contentMap["update_time"] = content.UpdateTime + } + + if content.ApplicationResourceType != nil { + contentMap["application_resource_type"] = content.ApplicationResourceType + } + + if content.ApplicationRuntimeType != nil { + contentMap["application_runtime_type"] = content.ApplicationRuntimeType + } + + if content.ApigatewayServiceId != nil { + contentMap["apigateway_service_id"] = content.ApigatewayServiceId + } + + if content.ApplicationRemarkName != nil { + contentMap["application_remark_name"] = content.ApplicationRemarkName + } + + if content.ServiceConfigList != nil { + serviceConfigListList := []interface{}{} + for _, serviceConfigList := range content.ServiceConfigList { + serviceConfigListMap := map[string]interface{}{} + + if serviceConfigList.Name != nil { + serviceConfigListMap["name"] = serviceConfigList.Name + } + + if serviceConfigList.Ports != nil { + portsList := []interface{}{} + for _, ports := range serviceConfigList.Ports { + portsMap := map[string]interface{}{} + + if ports.TargetPort != nil { + portsMap["target_port"] = ports.TargetPort + } + + if ports.Protocol != nil { + portsMap["protocol"] = ports.Protocol + } + + portsList = append(portsList, portsMap) + } + + serviceConfigListMap["ports"] = portsList + } + + if serviceConfigList.HealthCheck != nil { + healthCheckMap := map[string]interface{}{} + + if serviceConfigList.HealthCheck.Path != nil { + healthCheckMap["path"] = serviceConfigList.HealthCheck.Path + } + + serviceConfigListMap["health_check"] = []interface{}{healthCheckMap} + } + + serviceConfigListList = append(serviceConfigListList, serviceConfigListMap) + } + + contentMap["service_config_list"] = serviceConfigListList + } + + if content.IgnoreCreateImageRepository != nil { + contentMap["ignore_create_image_repository"] = content.IgnoreCreateImageRepository + } + + contentList = append(contentList, contentMap) + ids = append(ids, *content.ApplicationId) + } + + tsfPageApplicationMap["content"] = contentList + } + + _ = d.Set("result", []interface{}{tsfPageApplicationMap}) + } + + d.SetId(helper.DataResourceIdsHash(ids)) + output, ok := d.GetOk("result_output_file") + if ok && output.(string) != "" { + if e := writeToFile(output.(string), tsfPageApplicationMap); e != nil { + return e + } + } + return nil +} diff --git a/tencentcloud/data_source_tc_tsf_application_config.go b/tencentcloud/data_source_tc_tsf_application_config.go new file mode 100644 index 0000000000..0352757f98 --- /dev/null +++ b/tencentcloud/data_source_tc_tsf_application_config.go @@ -0,0 +1,283 @@ +/* +Use this data source to query detailed information of tsf application_config + +Example Usage + +```hcl +data "tencentcloud_tsf_application_config" "application_config" { + application_id = "app-123456" + config_id = "config-123456" + config_id_list = + config_name = "test-config" + config_version = "1.0" +} +``` +*/ +package tencentcloud + +import ( + "context" + + "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 dataSourceTencentCloudTsfApplicationConfig() *schema.Resource { + return &schema.Resource{ + Read: dataSourceTencentCloudTsfApplicationConfigRead, + Schema: map[string]*schema.Schema{ + "application_id": { + Optional: true, + Type: schema.TypeString, + Description: "Application ID, query all when not provided.", + }, + + "config_id": { + Optional: true, + Type: schema.TypeString, + Description: "Configuration ID, query all with higher priority when not provided.", + }, + + "config_id_list": { + Optional: true, + Type: schema.TypeSet, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + Description: "Configuration ID list, query all with lower priority when not provided.", + }, + + "config_name": { + Optional: true, + Type: schema.TypeString, + Description: "Configuration name, precise query, query all when not provided.", + }, + + "config_version": { + Optional: true, + Type: schema.TypeString, + Description: "Configuration version, precise query, query all when not provided.", + }, + + "result": { + Computed: true, + Type: schema.TypeList, + Description: "Paginated configuration item list. Note: This field may return null, indicating that no valid values can be obtained.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "total_count": { + Type: schema.TypeInt, + Computed: true, + Description: "TsfPageConfig.", + }, + "content": { + Type: schema.TypeList, + Computed: true, + Description: "Configuration item list.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "config_id": { + Type: schema.TypeString, + Computed: true, + Description: "Configuration ID. Note: This field may return null, indicating that no valid values can be obtained.", + }, + "config_name": { + Type: schema.TypeString, + Computed: true, + Description: "Configuration name Note: This field may return null, indicating that no valid values can be obtained.", + }, + "config_version": { + Type: schema.TypeString, + Computed: true, + Description: "Configuration version. Note: This field may return null, indicating that no valid values can be obtained.", + }, + "config_version_desc": { + Type: schema.TypeString, + Computed: true, + Description: "Configuration version description. Note: This field may return null, indicating that no valid values can be obtained.", + }, + "config_value": { + Type: schema.TypeString, + Computed: true, + Description: "Configuration value. Note: This field may return null, indicating that no valid values can be obtained.", + }, + "config_type": { + Type: schema.TypeString, + Computed: true, + Description: "Configuration type. Note: This field may return null, indicating that no valid values can be obtained.", + }, + "creation_time": { + Type: schema.TypeString, + Computed: true, + Description: "CreationTime. Note: This field may return null, indicating that no valid values can be obtained.", + }, + "application_id": { + Type: schema.TypeString, + Computed: true, + Description: "application Id. Note: This field may return null, indicating that no valid values can be obtained.", + }, + "application_name": { + Type: schema.TypeString, + Computed: true, + Description: "application Id. Note: This field may return null, indicating that no valid values can be obtained.", + }, + "delete_flag": { + Type: schema.TypeBool, + Computed: true, + Description: "delete flag, true: allow delete; false: delete prohibit.", + }, + "last_update_time": { + Type: schema.TypeString, + Computed: true, + Description: "last update time. Note: This field may return null, indicating that no valid values can be obtained.", + }, + "config_version_count": { + Type: schema.TypeInt, + Computed: true, + Description: "config version count. Note: This field may return null, indicating that no valid values can be obtained.", + }, + }, + }, + }, + }, + }, + }, + + "result_output_file": { + Type: schema.TypeString, + Optional: true, + Description: "Used to save results.", + }, + }, + } +} + +func dataSourceTencentCloudTsfApplicationConfigRead(d *schema.ResourceData, meta interface{}) error { + defer logElapsed("data_source.tencentcloud_tsf_application_config.read")() + defer inconsistentCheck(d, meta)() + + logId := getLogId(contextNil) + + ctx := context.WithValue(context.TODO(), logIdKey, logId) + + paramMap := make(map[string]interface{}) + if v, ok := d.GetOk("application_id"); ok { + paramMap["ApplicationId"] = helper.String(v.(string)) + } + + if v, ok := d.GetOk("config_id"); ok { + paramMap["ConfigId"] = helper.String(v.(string)) + } + + if v, ok := d.GetOk("config_id_list"); ok { + configIdListSet := v.(*schema.Set).List() + paramMap["ConfigIdList"] = helper.InterfacesStringsPoint(configIdListSet) + } + + if v, ok := d.GetOk("config_name"); ok { + paramMap["ConfigName"] = helper.String(v.(string)) + } + + if v, ok := d.GetOk("config_version"); ok { + paramMap["ConfigVersion"] = helper.String(v.(string)) + } + + service := TsfService{client: meta.(*TencentCloudClient).apiV3Conn} + + var config *tsf.TsfPageConfig + err := resource.Retry(readRetryTimeout, func() *resource.RetryError { + result, e := service.DescribeTsfApplicationConfigByFilter(ctx, paramMap) + if e != nil { + return retryError(e) + } + config = result + return nil + }) + if err != nil { + return err + } + + ids := make([]string, 0, len(config.Content)) + tsfPageConfigMap := map[string]interface{}{} + if config != nil { + if config.TotalCount != nil { + tsfPageConfigMap["total_count"] = config.TotalCount + } + + if config.Content != nil { + contentList := []interface{}{} + for _, content := range config.Content { + contentMap := map[string]interface{}{} + + if content.ConfigId != nil { + contentMap["config_id"] = content.ConfigId + } + + if content.ConfigName != nil { + contentMap["config_name"] = content.ConfigName + } + + if content.ConfigVersion != nil { + contentMap["config_version"] = content.ConfigVersion + } + + if content.ConfigVersionDesc != nil { + contentMap["config_version_desc"] = content.ConfigVersionDesc + } + + if content.ConfigValue != nil { + contentMap["config_value"] = content.ConfigValue + } + + if content.ConfigType != nil { + contentMap["config_type"] = content.ConfigType + } + + if content.CreationTime != nil { + contentMap["creation_time"] = content.CreationTime + } + + if content.ApplicationId != nil { + contentMap["application_id"] = content.ApplicationId + } + + if content.ApplicationName != nil { + contentMap["application_name"] = content.ApplicationName + } + + if content.DeleteFlag != nil { + contentMap["delete_flag"] = content.DeleteFlag + } + + if content.LastUpdateTime != nil { + contentMap["last_update_time"] = content.LastUpdateTime + } + + if content.ConfigVersionCount != nil { + contentMap["config_version_count"] = content.ConfigVersionCount + } + + contentList = append(contentList, contentMap) + ids = append(ids, *content.ConfigId) + } + + tsfPageConfigMap["content"] = contentList + } + + err = d.Set("result", []interface{}{tsfPageConfigMap}) + if err != nil { + return err + } + } + + d.SetId(helper.DataResourceIdsHash(ids)) + output, ok := d.GetOk("result_output_file") + if ok && output.(string) != "" { + if e := writeToFile(output.(string), tsfPageConfigMap); e != nil { + return e + } + } + return nil +} diff --git a/tencentcloud/data_source_tc_tsf_application_config_test.go b/tencentcloud/data_source_tc_tsf_application_config_test.go new file mode 100644 index 0000000000..0b31ace068 --- /dev/null +++ b/tencentcloud/data_source_tc_tsf_application_config_test.go @@ -0,0 +1,58 @@ +package tencentcloud + +import ( + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/helper/resource" +) + +// go test -i; go test -test.run TestAccTencentCloudTsfApplicationConfigDataSource_basic -v +func TestAccTencentCloudTsfApplicationConfigDataSource_basic(t *testing.T) { + t.Parallel() + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheckCommon(t, ACCOUNT_TYPE_TSF) }, + Providers: testAccProviders, + Steps: []resource.TestStep{ + { + Config: testAccTsfApplicationConfigDataSource, + Check: resource.ComposeTestCheckFunc( + testAccCheckTencentCloudDataSourceID("data.tencentcloud_tsf_application_config.application_config"), + resource.TestCheckResourceAttrSet("data.tencentcloud_tsf_application_config.application_config", "result.#"), + resource.TestCheckResourceAttrSet("data.tencentcloud_tsf_application_config.application_config", "result.0.content.#"), + resource.TestCheckResourceAttrSet("data.tencentcloud_tsf_application_config.application_config", "result.0.content.0.application_id"), + resource.TestCheckResourceAttrSet("data.tencentcloud_tsf_application_config.application_config", "result.0.content.0.application_name"), + resource.TestCheckResourceAttrSet("data.tencentcloud_tsf_application_config.application_config", "result.0.content.0.config_id"), + resource.TestCheckResourceAttrSet("data.tencentcloud_tsf_application_config.application_config", "result.0.content.0.config_name"), + resource.TestCheckResourceAttrSet("data.tencentcloud_tsf_application_config.application_config", "result.0.content.0.config_value"), + resource.TestCheckResourceAttrSet("data.tencentcloud_tsf_application_config.application_config", "result.0.content.0.config_version"), + resource.TestCheckResourceAttrSet("data.tencentcloud_tsf_application_config.application_config", "result.0.content.0.config_version_desc"), + resource.TestCheckResourceAttrSet("data.tencentcloud_tsf_application_config.application_config", "result.0.content.0.creation_time"), + resource.TestCheckResourceAttrSet("data.tencentcloud_tsf_application_config.application_config", "result.0.content.0.delete_flag"), + ), + }, + }, + }) +} + +const testAccTsfApplicationConfigDataSourceVar = ` +variable "application_id" { + default = "` + defaultTsfApplicationId + `" +} + +variable "config_id" { + default = "` + defaultTsfConfigId + `" +} + +` + +const testAccTsfApplicationConfigDataSource = testAccTsfApplicationConfigDataSourceVar + ` + +data "tencentcloud_tsf_application_config" "application_config" { + application_id = var.application_id + config_id = var.config_id + # config_id_list = + config_name = "keep-terraform-testing" + config_version = "v1" +} + +` diff --git a/tencentcloud/data_source_tc_tsf_application_file_config.go b/tencentcloud/data_source_tc_tsf_application_file_config.go new file mode 100644 index 0000000000..38010e3910 --- /dev/null +++ b/tencentcloud/data_source_tc_tsf_application_file_config.go @@ -0,0 +1,316 @@ +/* +Use this data source to query detailed information of tsf application_file_config + +Example Usage + +```hcl +data "tencentcloud_tsf_application_file_config" "application_file_config" { + config_id = "dcfg-f-4y4ekzqv" + # config_id_list = [""] + config_name = "file-log1" + application_id = "application-2vzk6n3v" + config_version = "1.2" +} +``` +*/ +package tencentcloud + +import ( + "context" + + "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 dataSourceTencentCloudTsfApplicationFileConfig() *schema.Resource { + return &schema.Resource{ + Read: dataSourceTencentCloudTsfApplicationFileConfigRead, + Schema: map[string]*schema.Schema{ + "config_id": { + Optional: true, + Type: schema.TypeString, + Description: "Configuration ID.", + }, + + "config_id_list": { + Optional: true, + Type: schema.TypeSet, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + Description: "List of configuration item ID.", + }, + + "config_name": { + Optional: true, + Type: schema.TypeString, + Description: "Configuration item name.", + }, + + "application_id": { + Optional: true, + Type: schema.TypeString, + Description: "Application ID.", + }, + + "config_version": { + Optional: true, + Type: schema.TypeString, + Description: "Configuration item version.", + }, + + "result": { + Computed: true, + Type: schema.TypeList, + Description: "File configuration item list. Note: This field may return null, indicating that no valid values can be obtained.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "total_count": { + Type: schema.TypeInt, + Computed: true, + Description: "total count.", + }, + "content": { + Type: schema.TypeList, + Computed: true, + Description: "File configuration array. Note: This field may return null, indicating that no valid values can be obtained.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "config_id": { + Type: schema.TypeString, + Computed: true, + Description: "Config ID. Note: This field may return null, indicating that no valid values can be obtained.", + }, + "config_name": { + Type: schema.TypeString, + Computed: true, + Description: "Configuration item name. Note: This field may return null, indicating that no valid values can be obtained.", + }, + "config_version": { + Type: schema.TypeString, + Computed: true, + Description: "Configuration version. Note: This field may return null, indicating that no valid values can be obtained.", + }, + "config_version_desc": { + Type: schema.TypeString, + Computed: true, + Description: "Configuration item version description. Note: This field may return null, indicating that no valid values can be obtained.", + }, + "config_file_name": { + Type: schema.TypeString, + Computed: true, + Description: "Configuration item file name. Note: This field may return null, indicating that no valid values can be obtained.", + }, + "config_file_value": { + Type: schema.TypeString, + Computed: true, + Description: "Configuration file content. Note: This field may return null, indicating that no valid values can be obtained.", + }, + "config_file_code": { + Type: schema.TypeString, + Computed: true, + Description: "Configuration file code. Note: This field may return null, indicating that no valid values can be obtained.", + }, + "creation_time": { + Type: schema.TypeString, + Computed: true, + Description: "CreationTime. Note: This field may return null, indicating that no valid values can be obtained.", + }, + "application_id": { + Type: schema.TypeString, + Computed: true, + Description: "application Id. Note: This field may return null, indicating that no valid values can be obtained.", + }, + "application_name": { + Type: schema.TypeString, + Computed: true, + Description: "application name. Note: This field may return null, indicating that no valid values can be obtained.", + }, + "delete_flag": { + Type: schema.TypeBool, + Computed: true, + Description: "delete flag, true: allow delete; false: delete prohibit.", + }, + "config_version_count": { + Type: schema.TypeInt, + Computed: true, + Description: "config version count. Note: This field may return null, indicating that no valid values can be obtained.", + }, + "last_update_time": { + Type: schema.TypeString, + Computed: true, + Description: "last update time. Note: This field may return null, indicating that no valid values can be obtained.", + }, + "config_file_path": { + Type: schema.TypeString, + Computed: true, + Description: "file config path. Note: This field may return null, indicating that no valid values can be obtained.", + }, + "config_post_cmd": { + Type: schema.TypeString, + Computed: true, + Description: "last update time. Note: This field may return null, indicating that no valid values can be obtained.", + }, + "config_file_value_length": { + Type: schema.TypeInt, + Computed: true, + Description: "config item content length. Note: This field may return null, indicating that no valid values can be obtained.", + }, + }, + }, + }, + }, + }, + }, + + "result_output_file": { + Type: schema.TypeString, + Optional: true, + Description: "Used to save results.", + }, + }, + } +} + +func dataSourceTencentCloudTsfApplicationFileConfigRead(d *schema.ResourceData, meta interface{}) error { + defer logElapsed("data_source.tencentcloud_tsf_application_file_config.read")() + defer inconsistentCheck(d, meta)() + + logId := getLogId(contextNil) + + ctx := context.WithValue(context.TODO(), logIdKey, logId) + + paramMap := make(map[string]interface{}) + if v, ok := d.GetOk("config_id"); ok { + paramMap["ConfigId"] = helper.String(v.(string)) + } + + if v, ok := d.GetOk("config_id_list"); ok { + configIdListSet := v.(*schema.Set).List() + paramMap["ConfigIdList"] = helper.InterfacesStringsPoint(configIdListSet) + } + + if v, ok := d.GetOk("config_name"); ok { + paramMap["ConfigName"] = helper.String(v.(string)) + } + + if v, ok := d.GetOk("application_id"); ok { + paramMap["ApplicationId"] = helper.String(v.(string)) + } + + if v, ok := d.GetOk("config_version"); ok { + paramMap["ConfigVersion"] = helper.String(v.(string)) + } + + service := TsfService{client: meta.(*TencentCloudClient).apiV3Conn} + + var config *tsf.TsfPageFileConfig + err := resource.Retry(readRetryTimeout, func() *resource.RetryError { + result, e := service.DescribeTsfApplicationFileConfigByFilter(ctx, paramMap) + if e != nil { + return retryError(e) + } + config = result + return nil + }) + if err != nil { + return err + } + + ids := make([]string, 0, len(config.Content)) + tsfPageFileConfigMap := map[string]interface{}{} + if config != nil { + if config.TotalCount != nil { + tsfPageFileConfigMap["total_count"] = config.TotalCount + } + + if config.Content != nil { + contentList := []interface{}{} + for _, content := range config.Content { + contentMap := map[string]interface{}{} + + if content.ConfigId != nil { + contentMap["config_id"] = content.ConfigId + } + + if content.ConfigName != nil { + contentMap["config_name"] = content.ConfigName + } + + if content.ConfigVersion != nil { + contentMap["config_version"] = content.ConfigVersion + } + + if content.ConfigVersionDesc != nil { + contentMap["config_version_desc"] = content.ConfigVersionDesc + } + + if content.ConfigFileName != nil { + contentMap["config_file_name"] = content.ConfigFileName + } + + if content.ConfigFileValue != nil { + contentMap["config_file_value"] = content.ConfigFileValue + } + + if content.ConfigFileCode != nil { + contentMap["config_file_code"] = content.ConfigFileCode + } + + if content.CreationTime != nil { + contentMap["creation_time"] = content.CreationTime + } + + if content.ApplicationId != nil { + contentMap["application_id"] = content.ApplicationId + } + + if content.ApplicationName != nil { + contentMap["application_name"] = content.ApplicationName + } + + if content.DeleteFlag != nil { + contentMap["delete_flag"] = content.DeleteFlag + } + + if content.ConfigVersionCount != nil { + contentMap["config_version_count"] = content.ConfigVersionCount + } + + if content.LastUpdateTime != nil { + contentMap["last_update_time"] = content.LastUpdateTime + } + + if content.ConfigFilePath != nil { + contentMap["config_file_path"] = content.ConfigFilePath + } + + if content.ConfigPostCmd != nil { + contentMap["config_post_cmd"] = content.ConfigPostCmd + } + + if content.ConfigFileValueLength != nil { + contentMap["config_file_value_length"] = content.ConfigFileValueLength + } + + contentList = append(contentList, contentMap) + ids = append(ids, *content.ConfigId) + } + + tsfPageFileConfigMap["content"] = contentList + } + + _ = d.Set("result", []interface{}{tsfPageFileConfigMap}) + } + + d.SetId(helper.DataResourceIdsHash(ids)) + output, ok := d.GetOk("result_output_file") + if ok && output.(string) != "" { + if e := writeToFile(output.(string), tsfPageFileConfigMap); e != nil { + return e + } + } + return nil +} diff --git a/tencentcloud/data_source_tc_tsf_application_file_config_test.go b/tencentcloud/data_source_tc_tsf_application_file_config_test.go new file mode 100644 index 0000000000..f6d919e672 --- /dev/null +++ b/tencentcloud/data_source_tc_tsf_application_file_config_test.go @@ -0,0 +1,51 @@ +package tencentcloud + +import ( + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/helper/resource" +) + +// go test -i; go test -test.run TestAccTencentCloudTsfApplicationFileConfigDataSource_basic -v +func TestAccTencentCloudTsfApplicationFileConfigDataSource_basic(t *testing.T) { + t.Parallel() + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheckCommon(t, ACCOUNT_TYPE_TSF) }, + Providers: testAccProviders, + Steps: []resource.TestStep{ + { + Config: testAccTsfApplicationFileConfigDataSource, + Check: resource.ComposeTestCheckFunc( + testAccCheckTencentCloudDataSourceID("data.tencentcloud_tsf_application_file_config.application_file_config"), + resource.TestCheckResourceAttrSet("data.tencentcloud_tsf_application_file_config.application_file_config", "result.#"), + resource.TestCheckResourceAttrSet("data.tencentcloud_tsf_application_file_config.application_file_config", "result.0.total_count"), + resource.TestCheckResourceAttrSet("data.tencentcloud_tsf_application_file_config.application_file_config", "result.0.content.#"), + resource.TestCheckResourceAttrSet("data.tencentcloud_tsf_application_file_config.application_file_config", "result.0.content.0.application_id"), + resource.TestCheckResourceAttrSet("data.tencentcloud_tsf_application_file_config.application_file_config", "result.0.content.0.application_name"), + resource.TestCheckResourceAttrSet("data.tencentcloud_tsf_application_file_config.application_file_config", "result.0.content.0.config_file_code"), + resource.TestCheckResourceAttrSet("data.tencentcloud_tsf_application_file_config.application_file_config", "result.0.content.0.config_file_name"), + resource.TestCheckResourceAttrSet("data.tencentcloud_tsf_application_file_config.application_file_config", "result.0.content.0.config_file_path"), + resource.TestCheckResourceAttrSet("data.tencentcloud_tsf_application_file_config.application_file_config", "result.0.content.0.config_file_value"), + resource.TestCheckResourceAttrSet("data.tencentcloud_tsf_application_file_config.application_file_config", "result.0.content.0.config_file_value_length"), + resource.TestCheckResourceAttrSet("data.tencentcloud_tsf_application_file_config.application_file_config", "result.0.content.0.config_id"), + resource.TestCheckResourceAttrSet("data.tencentcloud_tsf_application_file_config.application_file_config", "result.0.content.0.config_name"), + resource.TestCheckResourceAttrSet("data.tencentcloud_tsf_application_file_config.application_file_config", "result.0.content.0.config_version"), + resource.TestCheckResourceAttrSet("data.tencentcloud_tsf_application_file_config.application_file_config", "result.0.content.0.creation_time"), + resource.TestCheckResourceAttrSet("data.tencentcloud_tsf_application_file_config.application_file_config", "result.0.content.0.delete_flag"), + ), + }, + }, + }) +} + +const testAccTsfApplicationFileConfigDataSource = ` + +data "tencentcloud_tsf_application_file_config" "application_file_config" { + # config_id = "dcfg-f-4y4ekzqv" + # config_id_list = [""] + # config_name = "file-log1" + # application_id = "application-2vzk6n3v" + # config_version = "1.2" +} + +` diff --git a/tencentcloud/data_source_tc_tsf_application_public_config.go b/tencentcloud/data_source_tc_tsf_application_public_config.go new file mode 100644 index 0000000000..231206be9a --- /dev/null +++ b/tencentcloud/data_source_tc_tsf_application_public_config.go @@ -0,0 +1,269 @@ +/* +Use this data source to query detailed information of tsf application_public_config + +Example Usage + +```hcl +data "tencentcloud_tsf_application_public_config" "application_public_config" { + config_id = "dcfg-p-evjrbgly" + # config_id_list = [""] + config_name = "dsadsa" + config_version = "123" +} +``` +*/ +package tencentcloud + +import ( + "context" + + "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 dataSourceTencentCloudTsfApplicationPublicConfig() *schema.Resource { + return &schema.Resource{ + Read: dataSourceTencentCloudTsfApplicationPublicConfigRead, + Schema: map[string]*schema.Schema{ + "config_id": { + Optional: true, + Type: schema.TypeString, + Description: "Config ID. Query all items if not passed, high priority.", + }, + + "config_id_list": { + Optional: true, + Type: schema.TypeSet, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + Description: "Config ID list. Query all items if not passed, low priority.", + }, + + "config_name": { + Optional: true, + Type: schema.TypeString, + Description: "Config name. Exact query. Query all items if not passed.", + }, + + "config_version": { + Optional: true, + Type: schema.TypeString, + Description: "Config version. Exact query. Query all items if not passed.", + }, + + "result": { + Computed: true, + Type: schema.TypeList, + Description: "Paginated global configuration list. Note: This field may return null, indicating that no valid value can be obtained.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "total_count": { + Type: schema.TypeInt, + Computed: true, + Description: "TsfPageConfig.", + }, + "content": { + Type: schema.TypeList, + Computed: true, + Description: "Config list.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "config_id": { + Type: schema.TypeString, + Computed: true, + Description: "Config ID. Note: This field may return null, indicating that no valid value can be obtained.", + }, + "config_name": { + Type: schema.TypeString, + Computed: true, + Description: "Config name. Note: This field may return null, indicating that no valid value can be obtained.", + }, + "config_version": { + Type: schema.TypeString, + Computed: true, + Description: "Config version. Note: This field may return null, indicating that no valid value can be obtained.", + }, + "config_version_desc": { + Type: schema.TypeString, + Computed: true, + Description: "Config version description. Note: This field may return null, indicating that no valid value can be obtained.", + }, + "config_value": { + Type: schema.TypeString, + Computed: true, + Description: "Config value. Note: This field may return null, indicating that no valid value can be obtained.", + }, + "config_type": { + Type: schema.TypeString, + Computed: true, + Description: "Config type. Note: This field may return null, indicating that no valid value can be obtained.", + }, + "creation_time": { + Type: schema.TypeString, + Computed: true, + Description: "CreationTime. Note: This field may return null, indicating that no valid values can be obtained.", + }, + "application_id": { + Type: schema.TypeString, + Computed: true, + Description: "application Id. Note: This field may return null, indicating that no valid values can be obtained.", + }, + "application_name": { + Type: schema.TypeString, + Computed: true, + Description: "application Id. Note: This field may return null, indicating that no valid values can be obtained.", + }, + "delete_flag": { + Type: schema.TypeBool, + Computed: true, + Description: "delete flag, true: allow delete; false: delete prohibit.", + }, + "last_update_time": { + Type: schema.TypeString, + Computed: true, + Description: "last update time. Note: This field may return null, indicating that no valid values can be obtained.", + }, + "config_version_count": { + Type: schema.TypeInt, + Computed: true, + Description: "config version count. Note: This field may return null, indicating that no valid values can be obtained.", + }, + }, + }, + }, + }, + }, + }, + + "result_output_file": { + Type: schema.TypeString, + Optional: true, + Description: "Used to save results.", + }, + }, + } +} + +func dataSourceTencentCloudTsfApplicationPublicConfigRead(d *schema.ResourceData, meta interface{}) error { + defer logElapsed("data_source.tencentcloud_tsf_application_public_config.read")() + defer inconsistentCheck(d, meta)() + + logId := getLogId(contextNil) + + ctx := context.WithValue(context.TODO(), logIdKey, logId) + + paramMap := make(map[string]interface{}) + if v, ok := d.GetOk("config_id"); ok { + paramMap["ConfigId"] = helper.String(v.(string)) + } + + if v, ok := d.GetOk("config_id_list"); ok { + configIdListSet := v.(*schema.Set).List() + paramMap["ConfigIdList"] = helper.InterfacesStringsPoint(configIdListSet) + } + + if v, ok := d.GetOk("config_name"); ok { + paramMap["ConfigName"] = helper.String(v.(string)) + } + + if v, ok := d.GetOk("config_version"); ok { + paramMap["ConfigVersion"] = helper.String(v.(string)) + } + + service := TsfService{client: meta.(*TencentCloudClient).apiV3Conn} + + var config *tsf.TsfPageConfig + err := resource.Retry(readRetryTimeout, func() *resource.RetryError { + result, e := service.DescribeTsfApplicationPublicConfigByFilter(ctx, paramMap) + if e != nil { + return retryError(e) + } + config = result + return nil + }) + if err != nil { + return err + } + + ids := make([]string, 0, len(config.Content)) + tsfPageConfigMap := map[string]interface{}{} + if config != nil { + if config.TotalCount != nil { + tsfPageConfigMap["total_count"] = config.TotalCount + } + + if config.Content != nil { + contentList := []interface{}{} + for _, content := range config.Content { + contentMap := map[string]interface{}{} + + if content.ConfigId != nil { + contentMap["config_id"] = content.ConfigId + } + + if content.ConfigName != nil { + contentMap["config_name"] = content.ConfigName + } + + if content.ConfigVersion != nil { + contentMap["config_version"] = content.ConfigVersion + } + + if content.ConfigVersionDesc != nil { + contentMap["config_version_desc"] = content.ConfigVersionDesc + } + + if content.ConfigValue != nil { + contentMap["config_value"] = content.ConfigValue + } + + if content.ConfigType != nil { + contentMap["config_type"] = content.ConfigType + } + + if content.CreationTime != nil { + contentMap["creation_time"] = content.CreationTime + } + + if content.ApplicationId != nil { + contentMap["application_id"] = content.ApplicationId + } + + if content.ApplicationName != nil { + contentMap["application_name"] = content.ApplicationName + } + + if content.DeleteFlag != nil { + contentMap["delete_flag"] = content.DeleteFlag + } + + if content.LastUpdateTime != nil { + contentMap["last_update_time"] = content.LastUpdateTime + } + + if content.ConfigVersionCount != nil { + contentMap["config_version_count"] = content.ConfigVersionCount + } + + contentList = append(contentList, contentMap) + ids = append(ids, *content.ConfigId) + } + + tsfPageConfigMap["content"] = contentList + } + + _ = d.Set("result", []interface{}{tsfPageConfigMap}) + } + + d.SetId(helper.DataResourceIdsHash(ids)) + output, ok := d.GetOk("result_output_file") + if ok && output.(string) != "" { + if e := writeToFile(output.(string), tsfPageConfigMap); e != nil { + return e + } + } + return nil +} diff --git a/tencentcloud/data_source_tc_tsf_application_public_config_test.go b/tencentcloud/data_source_tc_tsf_application_public_config_test.go new file mode 100644 index 0000000000..1a2352365c --- /dev/null +++ b/tencentcloud/data_source_tc_tsf_application_public_config_test.go @@ -0,0 +1,44 @@ +package tencentcloud + +import ( + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/helper/resource" +) + +// go test -i; go test -test.run TestAccTencentCloudTsfApplicationPublicConfigDataSource_basic -v +func TestAccTencentCloudTsfApplicationPublicConfigDataSource_basic(t *testing.T) { + t.Parallel() + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheckCommon(t, ACCOUNT_TYPE_TSF) }, + Providers: testAccProviders, + Steps: []resource.TestStep{ + { + Config: testAccTsfApplicationPublicConfigDataSource, + Check: resource.ComposeTestCheckFunc( + testAccCheckTencentCloudDataSourceID("data.tencentcloud_tsf_application_public_config.application_public_config"), + resource.TestCheckResourceAttrSet("data.tencentcloud_tsf_application_public_config.application_public_config", "result.#"), + resource.TestCheckResourceAttrSet("data.tencentcloud_tsf_application_public_config.application_public_config", "result.0.total_count"), + resource.TestCheckResourceAttrSet("data.tencentcloud_tsf_application_public_config.application_public_config", "result.0.content.#"), + resource.TestCheckResourceAttrSet("data.tencentcloud_tsf_application_public_config.application_public_config", "result.0.content.0.config_id"), + resource.TestCheckResourceAttrSet("data.tencentcloud_tsf_application_public_config.application_public_config", "result.0.content.0.config_name"), + resource.TestCheckResourceAttrSet("data.tencentcloud_tsf_application_public_config.application_public_config", "result.0.content.0.config_value"), + resource.TestCheckResourceAttrSet("data.tencentcloud_tsf_application_public_config.application_public_config", "result.0.content.0.config_version"), + resource.TestCheckResourceAttrSet("data.tencentcloud_tsf_application_public_config.application_public_config", "result.0.content.0.creation_time"), + resource.TestCheckResourceAttrSet("data.tencentcloud_tsf_application_public_config.application_public_config", "result.0.content.0.delete_flag"), + ), + }, + }, + }) +} + +const testAccTsfApplicationPublicConfigDataSource = ` + +data "tencentcloud_tsf_application_public_config" "application_public_config" { + # config_id = "dcfg-p-evjrbgly" + # # config_id_list = [""] + # config_name = "dsadsa" + # config_version = "123" +} + +` diff --git a/tencentcloud/data_source_tc_tsf_application_test.go b/tencentcloud/data_source_tc_tsf_application_test.go new file mode 100644 index 0000000000..4f5a0f89d0 --- /dev/null +++ b/tencentcloud/data_source_tc_tsf_application_test.go @@ -0,0 +1,54 @@ +package tencentcloud + +import ( + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/helper/resource" +) + +// go test -i; go test -test.run TestAccTencentCloudTsfApplicationDataSource_basic -v +func TestAccTencentCloudTsfApplicationDataSource_basic(t *testing.T) { + t.Parallel() + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheckCommon(t, ACCOUNT_TYPE_TSF) }, + Providers: testAccProviders, + Steps: []resource.TestStep{ + { + Config: testAccTsfApplicationDataSource, + Check: resource.ComposeTestCheckFunc( + testAccCheckTencentCloudDataSourceID("data.tencentcloud_tsf_application.application"), + resource.TestCheckResourceAttrSet("data.tencentcloud_tsf_application.application", "result.#"), + resource.TestCheckResourceAttrSet("data.tencentcloud_tsf_application.application", "result.0.total_count"), + resource.TestCheckResourceAttrSet("data.tencentcloud_tsf_application.application", "result.0.content.#"), + resource.TestCheckResourceAttrSet("data.tencentcloud_tsf_application.application", "result.0.content.0.application_desc"), + resource.TestCheckResourceAttrSet("data.tencentcloud_tsf_application.application", "result.0.content.0.application_id"), + resource.TestCheckResourceAttrSet("data.tencentcloud_tsf_application.application", "result.0.content.0.application_name"), + resource.TestCheckResourceAttrSet("data.tencentcloud_tsf_application.application", "result.0.content.0.application_resource_type"), + resource.TestCheckResourceAttrSet("data.tencentcloud_tsf_application.application", "result.0.content.0.application_type"), + resource.TestCheckResourceAttrSet("data.tencentcloud_tsf_application.application", "result.0.content.0.create_time"), + resource.TestCheckResourceAttrSet("data.tencentcloud_tsf_application.application", "result.0.content.0.ignore_create_image_repository"), + resource.TestCheckResourceAttrSet("data.tencentcloud_tsf_application.application", "result.0.content.0.microservice_type"), + resource.TestCheckResourceAttrSet("data.tencentcloud_tsf_application.application", "result.0.content.0.prog_lang"), + resource.TestCheckResourceAttrSet("data.tencentcloud_tsf_application.application", "result.0.content.0.update_time"), + ), + }, + }, + }) +} + +const testAccTsfApplicationDataSourceVar = ` +variable "application_id" { + default = "` + defaultTsfApplicationId + `" +} +` + +const testAccTsfApplicationDataSource = testAccTsfApplicationDataSourceVar + ` + +data "tencentcloud_tsf_application" "application" { + application_type = "V" + microservice_type = "N" + # application_resource_type_list = [""] + application_id_list = [var.application_id] +} + +` diff --git a/tencentcloud/data_source_tc_tsf_cluster.go b/tencentcloud/data_source_tc_tsf_cluster.go new file mode 100644 index 0000000000..2e930fdec7 --- /dev/null +++ b/tencentcloud/data_source_tc_tsf_cluster.go @@ -0,0 +1,545 @@ +/* +Use this data source to query detailed information of tsf cluster + +Example Usage + +```hcl +data "tencentcloud_tsf_cluster" "cluster" { + cluster_id_list = ["cluster-vwgj5e6y"] + cluster_type = "V" + # search_word = "" + disable_program_auth_check = true +} +``` +*/ +package tencentcloud + +import ( + "context" + + "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 dataSourceTencentCloudTsfCluster() *schema.Resource { + return &schema.Resource{ + Read: dataSourceTencentCloudTsfClusterRead, + Schema: map[string]*schema.Schema{ + "cluster_id_list": { + Optional: true, + Type: schema.TypeSet, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + Description: "Cluster ID list to be queried, if not filled in or passed, all content will be queried.", + }, + + "cluster_type": { + Optional: true, + Type: schema.TypeString, + Description: "The type of cluster to be queried, if left blank or not passed, all content will be queried. C: container, V: virtual machine.", + }, + + "search_word": { + Optional: true, + Type: schema.TypeString, + Description: "Filter by keywords for Cluster Id or name.", + }, + + "disable_program_auth_check": { + Optional: true, + Type: schema.TypeBool, + Description: "Whether to disable dataset authentication.", + }, + + "result": { + Computed: true, + Type: schema.TypeList, + Description: "TSF cluster pagination object. Note: This field may return null, indicating no valid value.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "total_count": { + Type: schema.TypeInt, + Computed: true, + Description: "Total number of items. Note: This field may return null, indicating that no valid value was found.", + }, + "content": { + Type: schema.TypeList, + Computed: true, + Description: "Cluster list. Note: This field may return null, indicating no valid values.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "cluster_id": { + Type: schema.TypeString, + Computed: true, + Description: "Cluster ID. Note: This field may return null, indicating no valid value.", + }, + "cluster_name": { + Type: schema.TypeString, + Computed: true, + Description: "Cluster name. Note: This field may return null, indicating no valid value.", + }, + "cluster_desc": { + Type: schema.TypeString, + Computed: true, + Description: "Cluster description. Note: This field may return null, indicating no valid value.", + }, + "cluster_type": { + Type: schema.TypeString, + Computed: true, + Description: "Cluster type. Note: This field may return null, indicating no valid value.", + }, + "vpc_id": { + Type: schema.TypeString, + Computed: true, + Description: "Private network ID of the cluster. Note: This field may return null, indicating no valid value.", + }, + "cluster_status": { + Type: schema.TypeString, + Computed: true, + Description: "cluster status. Note: This field may return null, indicating no valid value.", + }, + "cluster_cidr": { + Type: schema.TypeString, + Computed: true, + Description: "cluster CIDR. Note: This field may return null, indicating no valid value.", + }, + "cluster_total_cpu": { + Type: schema.TypeFloat, + Computed: true, + Description: "Total CPU of the cluster, unit: cores. Note: This field may return null, indicating that no valid value was found.", + }, + "cluster_total_mem": { + Type: schema.TypeFloat, + Computed: true, + Description: "Total memory of the cluster, unit: G. Note: This field may return null, indicating that no valid value is obtained.", + }, + "cluster_used_cpu": { + Type: schema.TypeFloat, + Computed: true, + Description: "Used CPU of the cluster, in cores. This field may return null, indicating no valid value.", + }, + "cluster_used_mem": { + Type: schema.TypeFloat, + Computed: true, + Description: "Cluster used memory in GB. This field may return null, indicating no valid value.", + }, + "instance_count": { + Type: schema.TypeInt, + Computed: true, + Description: "Cluster instance number. This field may return null, indicating no valid value.", + }, + "run_instance_count": { + Type: schema.TypeInt, + Computed: true, + Description: "Cluster running instance number. This field may return null, indicating no valid value.", + }, + "normal_instance_count": { + Type: schema.TypeInt, + Computed: true, + Description: "Cluster normal instance number. This field may return null, indicating no valid value.", + }, + "delete_flag": { + Type: schema.TypeBool, + Computed: true, + Description: "Deletion tag: true means it can be deleted, false means it cannot be deleted. Note: This field may return null, indicating no valid value.", + }, + "create_time": { + Type: schema.TypeString, + Computed: true, + Description: "CreationTime. Note: This field may return null, indicating that no valid values can be obtained.", + }, + "update_time": { + Type: schema.TypeString, + Computed: true, + Description: "last update time. Note: This field may return null, indicating that no valid values can be obtained.", + }, + "tsf_region_id": { + Type: schema.TypeString, + Computed: true, + Description: "region ID of TSF. Note: This field may return null, indicating that no valid values can be obtained.", + }, + "tsf_region_name": { + Type: schema.TypeString, + Computed: true, + Description: "region name of TSF. Note: This field may return null, indicating that no valid values can be obtained.", + }, + "tsf_zone_id": { + Type: schema.TypeString, + Computed: true, + Description: "Zone Id of TSF. Note: This field may return null, indicating that no valid values can be obtained.", + }, + "tsf_zone_name": { + Type: schema.TypeString, + Computed: true, + Description: "Zone name of TSF. Note: This field may return null, indicating that no valid values can be obtained.", + }, + "delete_flag_reason": { + Type: schema.TypeString, + Computed: true, + Description: "Reason why the cluster cannot be deleted. Note: This field may return null, indicating that no valid values can be obtained.", + }, + "cluster_limit_cpu": { + Type: schema.TypeFloat, + Computed: true, + Description: "Maximum CPU limit of the cluster, in cores. This field may return null, indicating that no valid value was found.", + }, + "cluster_limit_mem": { + Type: schema.TypeFloat, + Computed: true, + Description: "Cluster maximum memory limit in GB. This field may return null, indicating that no valid value was found.", + }, + "run_service_instance_count": { + Type: schema.TypeInt, + Computed: true, + Description: "Number of available service instances in the cluster. Note: This field may return null, indicating no valid value.", + }, + "subnet_id": { + Type: schema.TypeString, + Computed: true, + Description: "Cluster subnet ID. Note: This field may return null, indicating no valid values.", + }, + "operation_info": { + Type: schema.TypeList, + Computed: true, + Description: "Control information returned to the frontend. This field may return null, indicating no valid value.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "init": { + Type: schema.TypeList, + Computed: true, + Description: "Control information of the initialization button returned to the front end. Note: This field may return null, indicating no valid value.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "disabled_reason": { + Type: schema.TypeString, + Computed: true, + Description: "Reason for not displaying. Note: This field may return null, indicating no valid value.", + }, + "enabled": { + Type: schema.TypeBool, + Computed: true, + Description: "The availability of the button (whether it is clickable) may return null indicating that the information is not available.", + }, + "supported": { + Type: schema.TypeBool, + Computed: true, + Description: "Whether to display the button. Note: This field may return null, indicating that no valid value was found.", + }, + }, + }, + }, + "add_instance": { + Type: schema.TypeList, + Computed: true, + Description: "Add instance button control information, Note: This field may return null, indicating that no valid value is obtained.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "disabled_reason": { + Type: schema.TypeString, + Computed: true, + Description: "The reason why this button is not displayed, may return null if not applicable.", + }, + "enabled": { + Type: schema.TypeBool, + Computed: true, + Description: "Whether the button is clickable. Note: This field may return null, indicating that no valid value is obtained.", + }, + "supported": { + Type: schema.TypeBool, + Computed: true, + Description: "Whether the button is clickable. Note: This field may return null, indicating that no valid value was found.", + }, + }, + }, + }, + "destroy": { + Type: schema.TypeList, + Computed: true, + Description: "Control information for destroying machine, may return null if no valid value is obtained.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "disabled_reason": { + Type: schema.TypeString, + Computed: true, + Description: "The reason why this button is not displayed, may return null if not applicable.", + }, + "enabled": { + Type: schema.TypeBool, + Computed: true, + Description: "Whether the button is clickable. Note: This field may return null, indicating that no valid value is obtained.", + }, + "supported": { + Type: schema.TypeBool, + Computed: true, + Description: "Whether the button is clickable. Note: This field may return null, indicating that no valid value was found.", + }, + }, + }, + }, + }, + }, + }, + "cluster_version": { + Type: schema.TypeString, + Computed: true, + Description: "The cluster version, may return null if not applicable.", + }, + }, + }, + }, + }, + }, + }, + + "result_output_file": { + Type: schema.TypeString, + Optional: true, + Description: "Used to save results.", + }, + }, + } +} + +func dataSourceTencentCloudTsfClusterRead(d *schema.ResourceData, meta interface{}) error { + defer logElapsed("data_source.tencentcloud_tsf_cluster.read")() + defer inconsistentCheck(d, meta)() + + logId := getLogId(contextNil) + + ctx := context.WithValue(context.TODO(), logIdKey, logId) + + paramMap := make(map[string]interface{}) + if v, ok := d.GetOk("cluster_id_list"); ok { + clusterIdListSet := v.(*schema.Set).List() + paramMap["ClusterIdList"] = helper.InterfacesStringsPoint(clusterIdListSet) + } + + if v, ok := d.GetOk("cluster_type"); ok { + paramMap["ClusterType"] = helper.String(v.(string)) + } + + if v, ok := d.GetOk("search_word"); ok { + paramMap["SearchWord"] = helper.String(v.(string)) + } + + if v, _ := d.GetOk("disable_program_auth_check"); v != nil { + paramMap["DisableProgramAuthCheck"] = helper.Bool(v.(bool)) + } + + service := TsfService{client: meta.(*TencentCloudClient).apiV3Conn} + + var cluster *tsf.TsfPageCluster + err := resource.Retry(readRetryTimeout, func() *resource.RetryError { + result, e := service.DescribeTsfClusterByFilter(ctx, paramMap) + if e != nil { + return retryError(e) + } + cluster = result + return nil + }) + if err != nil { + return err + } + + ids := make([]string, 0, len(cluster.Content)) + tsfPageClusterMap := map[string]interface{}{} + if cluster != nil { + if cluster.TotalCount != nil { + tsfPageClusterMap["total_count"] = cluster.TotalCount + } + + if cluster.Content != nil { + contentList := []interface{}{} + for _, content := range cluster.Content { + contentMap := map[string]interface{}{} + + if content.ClusterId != nil { + contentMap["cluster_id"] = content.ClusterId + } + + if content.ClusterName != nil { + contentMap["cluster_name"] = content.ClusterName + } + + if content.ClusterDesc != nil { + contentMap["cluster_desc"] = content.ClusterDesc + } + + if content.ClusterType != nil { + contentMap["cluster_type"] = content.ClusterType + } + + if content.VpcId != nil { + contentMap["vpc_id"] = content.VpcId + } + + if content.ClusterStatus != nil { + contentMap["cluster_status"] = content.ClusterStatus + } + + if content.ClusterCIDR != nil { + contentMap["cluster_cidr"] = content.ClusterCIDR + } + + if content.ClusterTotalCpu != nil { + contentMap["cluster_total_cpu"] = content.ClusterTotalCpu + } + + if content.ClusterTotalMem != nil { + contentMap["cluster_total_mem"] = content.ClusterTotalMem + } + + if content.ClusterUsedCpu != nil { + contentMap["cluster_used_cpu"] = content.ClusterUsedCpu + } + + if content.ClusterUsedMem != nil { + contentMap["cluster_used_mem"] = content.ClusterUsedMem + } + + if content.InstanceCount != nil { + contentMap["instance_count"] = content.InstanceCount + } + + if content.RunInstanceCount != nil { + contentMap["run_instance_count"] = content.RunInstanceCount + } + + if content.NormalInstanceCount != nil { + contentMap["normal_instance_count"] = content.NormalInstanceCount + } + + if content.DeleteFlag != nil { + contentMap["delete_flag"] = content.DeleteFlag + } + + if content.CreateTime != nil { + contentMap["create_time"] = content.CreateTime + } + + if content.UpdateTime != nil { + contentMap["update_time"] = content.UpdateTime + } + + if content.TsfRegionId != nil { + contentMap["tsf_region_id"] = content.TsfRegionId + } + + if content.TsfRegionName != nil { + contentMap["tsf_region_name"] = content.TsfRegionName + } + + if content.TsfZoneId != nil { + contentMap["tsf_zone_id"] = content.TsfZoneId + } + + if content.TsfZoneName != nil { + contentMap["tsf_zone_name"] = content.TsfZoneName + } + + if content.DeleteFlagReason != nil { + contentMap["delete_flag_reason"] = content.DeleteFlagReason + } + + if content.ClusterLimitCpu != nil { + contentMap["cluster_limit_cpu"] = content.ClusterLimitCpu + } + + if content.ClusterLimitMem != nil { + contentMap["cluster_limit_mem"] = content.ClusterLimitMem + } + + if content.RunServiceInstanceCount != nil { + contentMap["run_service_instance_count"] = content.RunServiceInstanceCount + } + + if content.SubnetId != nil { + contentMap["subnet_id"] = content.SubnetId + } + + if content.OperationInfo != nil { + operationInfoMap := map[string]interface{}{} + + if content.OperationInfo.Init != nil { + initMap := map[string]interface{}{} + + if content.OperationInfo.Init.DisabledReason != nil { + initMap["disabled_reason"] = content.OperationInfo.Init.DisabledReason + } + + if content.OperationInfo.Init.Enabled != nil { + initMap["enabled"] = content.OperationInfo.Init.Enabled + } + + if content.OperationInfo.Init.Supported != nil { + initMap["supported"] = content.OperationInfo.Init.Supported + } + + operationInfoMap["init"] = []interface{}{initMap} + } + + if content.OperationInfo.AddInstance != nil { + addInstanceMap := map[string]interface{}{} + + if content.OperationInfo.AddInstance.DisabledReason != nil { + addInstanceMap["disabled_reason"] = content.OperationInfo.AddInstance.DisabledReason + } + + if content.OperationInfo.AddInstance.Enabled != nil { + addInstanceMap["enabled"] = content.OperationInfo.AddInstance.Enabled + } + + if content.OperationInfo.AddInstance.Supported != nil { + addInstanceMap["supported"] = content.OperationInfo.AddInstance.Supported + } + + operationInfoMap["add_instance"] = []interface{}{addInstanceMap} + } + + if content.OperationInfo.Destroy != nil { + destroyMap := map[string]interface{}{} + + if content.OperationInfo.Destroy.DisabledReason != nil { + destroyMap["disabled_reason"] = content.OperationInfo.Destroy.DisabledReason + } + + if content.OperationInfo.Destroy.Enabled != nil { + destroyMap["enabled"] = content.OperationInfo.Destroy.Enabled + } + + if content.OperationInfo.Destroy.Supported != nil { + destroyMap["supported"] = content.OperationInfo.Destroy.Supported + } + + operationInfoMap["destroy"] = []interface{}{destroyMap} + } + + contentMap["operation_info"] = []interface{}{operationInfoMap} + } + + if content.ClusterVersion != nil { + contentMap["cluster_version"] = content.ClusterVersion + } + + contentList = append(contentList, contentMap) + ids = append(ids, *content.ClusterId) + } + + tsfPageClusterMap["content"] = contentList + } + + _ = d.Set("result", []interface{}{tsfPageClusterMap}) + } + + d.SetId(helper.DataResourceIdsHash(ids)) + output, ok := d.GetOk("result_output_file") + if ok && output.(string) != "" { + if e := writeToFile(output.(string), tsfPageClusterMap); e != nil { + return e + } + } + return nil +} diff --git a/tencentcloud/data_source_tc_tsf_cluster_test.go b/tencentcloud/data_source_tc_tsf_cluster_test.go new file mode 100644 index 0000000000..7b7b8c3868 --- /dev/null +++ b/tencentcloud/data_source_tc_tsf_cluster_test.go @@ -0,0 +1,49 @@ +package tencentcloud + +import ( + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/helper/resource" +) + +// go test -i; go test -test.run TestAccTencentCloudTsfClusterDataSource_basic -v +func TestAccTencentCloudTsfClusterDataSource_basic(t *testing.T) { + t.Parallel() + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheckCommon(t, ACCOUNT_TYPE_TSF) }, + Providers: testAccProviders, + Steps: []resource.TestStep{ + { + Config: testAccTsfClusterDataSource, + Check: resource.ComposeTestCheckFunc( + testAccCheckTencentCloudDataSourceID("data.tencentcloud_tsf_cluster.cluster"), + resource.TestCheckResourceAttrSet("data.tencentcloud_tsf_cluster.cluster", "result.#"), + resource.TestCheckResourceAttrSet("data.tencentcloud_tsf_cluster.cluster", "result.0.total_count"), + resource.TestCheckResourceAttrSet("data.tencentcloud_tsf_cluster.cluster", "result.0.content.#"), + resource.TestCheckResourceAttrSet("data.tencentcloud_tsf_cluster.cluster", "result.0.content.0.cluster_id"), + resource.TestCheckResourceAttrSet("data.tencentcloud_tsf_cluster.cluster", "result.0.content.0.cluster_name"), + resource.TestCheckResourceAttrSet("data.tencentcloud_tsf_cluster.cluster", "result.0.content.0.cluster_type"), + resource.TestCheckResourceAttrSet("data.tencentcloud_tsf_cluster.cluster", "result.0.content.0.delete_flag"), + resource.TestCheckResourceAttrSet("data.tencentcloud_tsf_cluster.cluster", "result.0.content.0.vpc_id"), + ), + }, + }, + }) +} + +const testAccTsfClusterDataSourceVar = ` +variable "cluster_id" { + default = "` + defaultTsfClustId + `" +} +` + +const testAccTsfClusterDataSource = testAccTsfClusterDataSourceVar + ` + +data "tencentcloud_tsf_cluster" "cluster" { + cluster_id_list = [var.cluster_id] + cluster_type = "V" + # search_word = "" + disable_program_auth_check = true +} + +` diff --git a/tencentcloud/data_source_tc_tsf_microservice.go b/tencentcloud/data_source_tc_tsf_microservice.go new file mode 100644 index 0000000000..f90d9030c5 --- /dev/null +++ b/tencentcloud/data_source_tc_tsf_microservice.go @@ -0,0 +1,244 @@ +/* +Use this data source to query detailed information of tsf microservice + +Example Usage + +```hcl +data "tencentcloud_tsf_microservice" "microservice" { + namespace_id = var.namespace_id + # status = + microservice_id_list = ["ms-yq3jo6jd"] + microservice_name_list = ["provider-demo"] +} +``` +*/ +package tencentcloud + +import ( + "context" + + "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 dataSourceTencentCloudTsfMicroservice() *schema.Resource { + return &schema.Resource{ + Read: dataSourceTencentCloudTsfMicroserviceRead, + Schema: map[string]*schema.Schema{ + "namespace_id": { + Required: true, + Type: schema.TypeString, + Description: "namespace id.", + }, + + "status": { + Optional: true, + Type: schema.TypeSet, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + Description: "status filter, online, offline, single_online.", + }, + + "microservice_id_list": { + Optional: true, + Type: schema.TypeSet, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + Description: "microservice id list.", + }, + + "microservice_name_list": { + Optional: true, + Type: schema.TypeSet, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + Description: "List of service names for search.", + }, + + "result": { + Computed: true, + Type: schema.TypeList, + Description: "Microservice paging list information. Note: This field may return null, indicating that no valid value can be obtained.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "total_count": { + Type: schema.TypeInt, + Computed: true, + Description: "Microservice paging list information. Note: This field may return null, indicating that no valid value can be obtained.", + }, + "content": { + Type: schema.TypeList, + Computed: true, + Description: "Microservice list information. Note: This field may return null, indicating that no valid value can be obtained.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "microservice_id": { + Type: schema.TypeString, + Computed: true, + Description: "Microservice Id. Note: This field may return null, indicating that no valid value can be obtained.", + }, + "microservice_name": { + Type: schema.TypeString, + Computed: true, + Description: "Microservice name. Note: This field may return null, indicating that no valid value can be obtained.", + }, + "microservice_desc": { + Type: schema.TypeString, + Computed: true, + Description: "Microservice description. Note: This field may return null, indicating that no valid value can be obtained.", + }, + "create_time": { + Type: schema.TypeInt, + Computed: true, + Description: "CreationTime. Note: This field may return null, indicating that no valid values can be obtained.", + }, + "update_time": { + Type: schema.TypeInt, + Computed: true, + Description: "last update time. Note: This field may return null, indicating that no valid values can be obtained.", + }, + "namespace_id": { + Type: schema.TypeString, + Computed: true, + Description: "Namespace Id. Note: This field may return null, indicating that no valid values can be obtained.", + }, + "run_instance_count": { + Type: schema.TypeInt, + Computed: true, + Description: "run instance count in namespace. Note: This field may return null, indicating that no valid values can be obtained.", + }, + "critical_instance_count": { + Type: schema.TypeInt, + Computed: true, + Description: "offline instance count. Note: This field may return null, indicating that no valid values can be obtained.", + }, + }, + }, + }, + }, + }, + }, + + "result_output_file": { + Type: schema.TypeString, + Optional: true, + Description: "Used to save results.", + }, + }, + } +} + +func dataSourceTencentCloudTsfMicroserviceRead(d *schema.ResourceData, meta interface{}) error { + defer logElapsed("data_source.tencentcloud_tsf_microservice.read")() + defer inconsistentCheck(d, meta)() + + logId := getLogId(contextNil) + + ctx := context.WithValue(context.TODO(), logIdKey, logId) + + paramMap := make(map[string]interface{}) + if v, ok := d.GetOk("namespace_id"); ok { + paramMap["NamespaceId"] = helper.String(v.(string)) + } + + if v, ok := d.GetOk("status"); ok { + statusSet := v.(*schema.Set).List() + paramMap["Status"] = helper.InterfacesStringsPoint(statusSet) + } + + if v, ok := d.GetOk("microservice_id_list"); ok { + microserviceIdListSet := v.(*schema.Set).List() + paramMap["MicroserviceIdList"] = helper.InterfacesStringsPoint(microserviceIdListSet) + } + + if v, ok := d.GetOk("microservice_name_list"); ok { + microserviceNameListSet := v.(*schema.Set).List() + paramMap["MicroserviceNameList"] = helper.InterfacesStringsPoint(microserviceNameListSet) + } + + service := TsfService{client: meta.(*TencentCloudClient).apiV3Conn} + + var microservice *tsf.TsfPageMicroservice + err := resource.Retry(readRetryTimeout, func() *resource.RetryError { + result, e := service.DescribeTsfMicroserviceByFilter(ctx, paramMap) + if e != nil { + return retryError(e) + } + microservice = result + return nil + }) + if err != nil { + return err + } + + ids := make([]string, 0, len(microservice.Content)) + tsfPageMicroserviceMap := map[string]interface{}{} + if microservice != nil { + if microservice.TotalCount != nil { + tsfPageMicroserviceMap["total_count"] = microservice.TotalCount + } + + if microservice.Content != nil { + contentList := []interface{}{} + for _, content := range microservice.Content { + contentMap := map[string]interface{}{} + + if content.MicroserviceId != nil { + contentMap["microservice_id"] = content.MicroserviceId + } + + if content.MicroserviceName != nil { + contentMap["microservice_name"] = content.MicroserviceName + } + + if content.MicroserviceDesc != nil { + contentMap["microservice_desc"] = content.MicroserviceDesc + } + + if content.CreateTime != nil { + contentMap["create_time"] = content.CreateTime + } + + if content.UpdateTime != nil { + contentMap["update_time"] = content.UpdateTime + } + + if content.NamespaceId != nil { + contentMap["namespace_id"] = content.NamespaceId + } + + if content.RunInstanceCount != nil { + contentMap["run_instance_count"] = content.RunInstanceCount + } + + if content.CriticalInstanceCount != nil { + contentMap["critical_instance_count"] = content.CriticalInstanceCount + } + + contentList = append(contentList, contentMap) + ids = append(ids, *content.NamespaceId) + } + + tsfPageMicroserviceMap["content"] = contentList + } + + err = d.Set("result", []interface{}{tsfPageMicroserviceMap}) + if err != nil { + return err + } + } + + d.SetId(helper.DataResourceIdsHash(ids)) + output, ok := d.GetOk("result_output_file") + if ok && output.(string) != "" { + if e := writeToFile(output.(string), tsfPageMicroserviceMap); e != nil { + return e + } + } + return nil +} diff --git a/tencentcloud/data_source_tc_tsf_microservice_test.go b/tencentcloud/data_source_tc_tsf_microservice_test.go new file mode 100644 index 0000000000..1bd8fc50e7 --- /dev/null +++ b/tencentcloud/data_source_tc_tsf_microservice_test.go @@ -0,0 +1,48 @@ +package tencentcloud + +import ( + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/helper/resource" +) + +// go test -i; go test -test.run TestAccTencentCloudTsfMicroserviceDataSource_basic -v +func TestAccTencentCloudTsfMicroserviceDataSource_basic(t *testing.T) { + t.Parallel() + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheckCommon(t, ACCOUNT_TYPE_TSF) }, + Providers: testAccProviders, + Steps: []resource.TestStep{ + { + Config: testAccTsfMicroserviceDataSource, + Check: resource.ComposeTestCheckFunc( + testAccCheckTencentCloudDataSourceID("data.tencentcloud_tsf_microservice.microservice"), + resource.TestCheckResourceAttrSet("data.tencentcloud_tsf_microservice.microservice", "result.#"), + resource.TestCheckResourceAttrSet("data.tencentcloud_tsf_microservice.microservice", "result.0.total_count"), + resource.TestCheckResourceAttrSet("data.tencentcloud_tsf_microservice.microservice", "result.0.content.#"), + resource.TestCheckResourceAttrSet("data.tencentcloud_tsf_microservice.microservice", "result.0.content.0.microservice_id"), + resource.TestCheckResourceAttrSet("data.tencentcloud_tsf_microservice.microservice", "result.0.content.0.microservice_name"), + resource.TestCheckResourceAttrSet("data.tencentcloud_tsf_microservice.microservice", "result.0.content.0.namespace_id"), + resource.TestCheckResourceAttrSet("data.tencentcloud_tsf_microservice.microservice", "result.0.content.0.run_instance_count"), + ), + }, + }, + }) +} + +const testAccTsfMicroserviceDataSourceVar = ` +variable "namespace_id" { + default = "` + defaultNamespaceId + `" +} +` + +const testAccTsfMicroserviceDataSource = testAccTsfMicroserviceDataSourceVar + ` + +data "tencentcloud_tsf_microservice" "microservice" { + namespace_id = var.namespace_id + # status = + microservice_id_list = ["ms-yq3jo6jd"] + microservice_name_list = ["provider-demo"] +} + +` diff --git a/tencentcloud/data_source_tc_tsf_unit_rules.go b/tencentcloud/data_source_tc_tsf_unit_rules.go new file mode 100644 index 0000000000..6e52bdb217 --- /dev/null +++ b/tencentcloud/data_source_tc_tsf_unit_rules.go @@ -0,0 +1,365 @@ +/* +Use this data source to query detailed information of tsf unit_rules + +Example Usage + +```hcl +data "tencentcloud_tsf_unit_rules" "unit_rules" { + gateway_instance_id = "gw-ins-lvdypq5k" + status = "disabled" +} +``` +*/ +package tencentcloud + +import ( + "context" + + "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 dataSourceTencentCloudTsfUnitRules() *schema.Resource { + return &schema.Resource{ + Read: dataSourceTencentCloudTsfUnitRulesRead, + Schema: map[string]*schema.Schema{ + "gateway_instance_id": { + Required: true, + Type: schema.TypeString, + Description: "gateway instance id.", + }, + + "status": { + Optional: true, + Type: schema.TypeString, + Description: "Enabled state, disabled: unpublished, enabled: published.", + }, + + "result": { + Computed: true, + Type: schema.TypeList, + Description: "Pagination list information.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "total_count": { + Type: schema.TypeInt, + Computed: true, + Description: "total number of records.", + }, + "content": { + Type: schema.TypeList, + Computed: true, + Description: "record entity list.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Computed: true, + Description: "rule name.", + }, + "id": { + Type: schema.TypeString, + Computed: true, + Description: "rule ID.", + }, + "gateway_instance_id": { + Type: schema.TypeString, + Computed: true, + Description: "Gateway Entity ID.", + }, + "description": { + Type: schema.TypeString, + Computed: true, + Description: "Rule description.", + }, + "status": { + Type: schema.TypeString, + Computed: true, + Description: "Use status: enabled/disabled.", + }, + "unit_rule_item_list": { + Type: schema.TypeList, + Computed: true, + Description: "list of rule items.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "relationship": { + Type: schema.TypeString, + Computed: true, + Description: "Logical relationship: AND/OR.", + }, + "dest_namespace_id": { + Type: schema.TypeString, + Computed: true, + Description: "Destination Namespace ID.", + }, + "dest_namespace_name": { + Type: schema.TypeString, + Computed: true, + Description: "destination namespace name.", + }, + "name": { + Type: schema.TypeString, + Computed: true, + Description: "rule item name.", + }, + "id": { + Type: schema.TypeString, + Computed: true, + Description: "rule item ID.", + }, + "unit_rule_id": { + Type: schema.TypeString, + Computed: true, + Description: "Unitization rule ID.", + }, + "priority": { + Type: schema.TypeInt, + Computed: true, + Description: "Rule order, the smaller the higher the priority: the default is 0.", + }, + "description": { + Type: schema.TypeString, + Computed: true, + Description: "Rule description.", + }, + "unit_rule_tag_list": { + Type: schema.TypeList, + Computed: true, + Description: "List of rule labels.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "tag_type": { + Type: schema.TypeString, + Computed: true, + Description: "Tag Type: U(User Tag).", + }, + "tag_field": { + Type: schema.TypeString, + Computed: true, + Description: "tag name.", + }, + "tag_operator": { + Type: schema.TypeString, + Computed: true, + Description: "Operator: IN/NOT_IN/EQUAL/NOT_EQUAL/REGEX.", + }, + "tag_value": { + Type: schema.TypeString, + Computed: true, + Description: "tag value.", + }, + "unit_rule_item_id": { + Type: schema.TypeString, + Computed: true, + Description: "Unitization rule item ID.", + }, + "id": { + Type: schema.TypeString, + Computed: true, + Description: "rule ID.", + }, + }, + }, + }, + }, + }, + }, + "created_time": { + Type: schema.TypeString, + Computed: true, + Description: "created time.", + }, + "updated_time": { + Type: schema.TypeString, + Computed: true, + Description: "Updated time.", + }, + }, + }, + }, + }, + }, + }, + + "result_output_file": { + Type: schema.TypeString, + Optional: true, + Description: "Used to save results.", + }, + }, + } +} + +func dataSourceTencentCloudTsfUnitRulesRead(d *schema.ResourceData, meta interface{}) error { + defer logElapsed("data_source.tencentcloud_tsf_unit_rules.read")() + defer inconsistentCheck(d, meta)() + + logId := getLogId(contextNil) + + ctx := context.WithValue(context.TODO(), logIdKey, logId) + + paramMap := make(map[string]interface{}) + if v, ok := d.GetOk("gateway_instance_id"); ok { + paramMap["GatewayInstanceId"] = helper.String(v.(string)) + } + + if v, ok := d.GetOk("status"); ok { + paramMap["Status"] = helper.String(v.(string)) + } + + service := TsfService{client: meta.(*TencentCloudClient).apiV3Conn} + + var unitRule *tsf.TsfPageUnitRuleV2 + err := resource.Retry(readRetryTimeout, func() *resource.RetryError { + result, e := service.DescribeTsfUnitRulesByFilter(ctx, paramMap) + if e != nil { + return retryError(e) + } + unitRule = result + return nil + }) + if err != nil { + return err + } + + ids := make([]string, 0, len(unitRule.Content)) + tmpList := make([]map[string]interface{}, 0, len(unitRule.Content)) + if unitRule != nil { + tsfPageUnitRuleMap := map[string]interface{}{} + if unitRule.TotalCount != nil { + tsfPageUnitRuleMap["total_count"] = unitRule.TotalCount + } + + if unitRule.Content != nil { + contentList := []interface{}{} + for _, content := range unitRule.Content { + contentMap := map[string]interface{}{} + + if content.Name != nil { + contentMap["name"] = content.Name + } + + if content.Id != nil { + contentMap["id"] = content.Id + } + + if content.GatewayInstanceId != nil { + contentMap["gateway_instance_id"] = content.GatewayInstanceId + } + + if content.Description != nil { + contentMap["description"] = content.Description + } + + if content.Status != nil { + contentMap["status"] = content.Status + } + + if content.UnitRuleItemList != nil { + unitRuleItemListList := []interface{}{} + for _, unitRuleItemList := range content.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"] = unitRuleTagListList + } + + unitRuleItemListList = append(unitRuleItemListList, unitRuleItemListMap) + } + + contentMap["unit_rule_item_list"] = unitRuleItemListList + } + + if content.CreatedTime != nil { + contentMap["created_time"] = content.CreatedTime + } + + if content.UpdatedTime != nil { + contentMap["updated_time"] = content.UpdatedTime + } + + contentList = append(contentList, contentMap) + ids = append(ids, *content.GatewayInstanceId) + } + + tsfPageUnitRuleMap["content"] = contentList + } + + _ = d.Set("result", []interface{}{tsfPageUnitRuleMap}) + } + + d.SetId(helper.DataResourceIdsHash(ids)) + output, ok := d.GetOk("result_output_file") + if ok && output.(string) != "" { + if e := writeToFile(output.(string), tmpList); e != nil { + return e + } + } + return nil +} diff --git a/tencentcloud/data_source_tc_tsf_unit_rules_test.go b/tencentcloud/data_source_tc_tsf_unit_rules_test.go new file mode 100644 index 0000000000..333ab8240e --- /dev/null +++ b/tencentcloud/data_source_tc_tsf_unit_rules_test.go @@ -0,0 +1,64 @@ +package tencentcloud + +import ( + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/helper/resource" +) + +// go test -i; go test -test.run TestAccTencentCloudTsfUnitRulesDataSource_basic -v +func TestAccTencentCloudTsfUnitRulesDataSource_basic(t *testing.T) { + t.Parallel() + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheckCommon(t, ACCOUNT_TYPE_TSF) }, + Providers: testAccProviders, + Steps: []resource.TestStep{ + { + Config: testAccTsfUnitRulesDataSource, + Check: resource.ComposeTestCheckFunc( + testAccCheckTencentCloudDataSourceID("data.tencentcloud_tsf_unit_rules.unit_rules"), + resource.TestCheckResourceAttrSet("data.tencentcloud_tsf_unit_rules.unit_rules", "id"), + resource.TestCheckResourceAttrSet("data.tencentcloud_tsf_unit_rules.unit_rules", "status"), + resource.TestCheckResourceAttrSet("data.tencentcloud_tsf_unit_rules.unit_rules", "result.#"), + resource.TestCheckResourceAttrSet("data.tencentcloud_tsf_unit_rules.unit_rules", "result.0.total_count"), + resource.TestCheckResourceAttrSet("data.tencentcloud_tsf_unit_rules.unit_rules", "result.0.content.#"), + resource.TestCheckResourceAttrSet("data.tencentcloud_tsf_unit_rules.unit_rules", "result.0.content.0.created_time"), + resource.TestCheckResourceAttrSet("data.tencentcloud_tsf_unit_rules.unit_rules", "result.0.content.0.description"), + resource.TestCheckResourceAttrSet("data.tencentcloud_tsf_unit_rules.unit_rules", "result.0.content.0.gateway_instance_id"), + resource.TestCheckResourceAttrSet("data.tencentcloud_tsf_unit_rules.unit_rules", "result.0.content.0.name"), + resource.TestCheckResourceAttrSet("data.tencentcloud_tsf_unit_rules.unit_rules", "result.0.content.0.status"), + resource.TestCheckResourceAttrSet("data.tencentcloud_tsf_unit_rules.unit_rules", "result.0.content.0.updated_time"), + resource.TestCheckResourceAttrSet("data.tencentcloud_tsf_unit_rules.unit_rules", "result.0.content.0.unit_rule_item_list.#"), + resource.TestCheckResourceAttrSet("data.tencentcloud_tsf_unit_rules.unit_rules", "result.0.content.0.unit_rule_item_list.0.description"), + resource.TestCheckResourceAttrSet("data.tencentcloud_tsf_unit_rules.unit_rules", "result.0.content.0.unit_rule_item_list.0.dest_namespace_id"), + resource.TestCheckResourceAttrSet("data.tencentcloud_tsf_unit_rules.unit_rules", "result.0.content.0.unit_rule_item_list.0.dest_namespace_name"), + resource.TestCheckResourceAttrSet("data.tencentcloud_tsf_unit_rules.unit_rules", "result.0.content.0.unit_rule_item_list.0.name"), + resource.TestCheckResourceAttrSet("data.tencentcloud_tsf_unit_rules.unit_rules", "result.0.content.0.unit_rule_item_list.0.priority"), + resource.TestCheckResourceAttrSet("data.tencentcloud_tsf_unit_rules.unit_rules", "result.0.content.0.unit_rule_item_list.0.relationship"), + resource.TestCheckResourceAttrSet("data.tencentcloud_tsf_unit_rules.unit_rules", "result.0.content.0.unit_rule_item_list.0.unit_rule_id"), + resource.TestCheckResourceAttrSet("data.tencentcloud_tsf_unit_rules.unit_rules", "result.0.content.0.unit_rule_item_list.0.unit_rule_tag_list.#"), + resource.TestCheckResourceAttrSet("data.tencentcloud_tsf_unit_rules.unit_rules", "result.0.content.0.unit_rule_item_list.0.unit_rule_tag_list.0.tag_field"), + resource.TestCheckResourceAttrSet("data.tencentcloud_tsf_unit_rules.unit_rules", "result.0.content.0.unit_rule_item_list.0.unit_rule_tag_list.0.tag_operator"), + resource.TestCheckResourceAttrSet("data.tencentcloud_tsf_unit_rules.unit_rules", "result.0.content.0.unit_rule_item_list.0.unit_rule_tag_list.0.tag_type"), + resource.TestCheckResourceAttrSet("data.tencentcloud_tsf_unit_rules.unit_rules", "result.0.content.0.unit_rule_item_list.0.unit_rule_tag_list.0.tag_value"), + resource.TestCheckResourceAttrSet("data.tencentcloud_tsf_unit_rules.unit_rules", "result.0.content.0.unit_rule_item_list.0.unit_rule_tag_list.0.unit_rule_item_id"), + ), + }, + }, + }) +} + +const testAccTsfUnitRulesDataSourceVar = ` +variable "gateway_instance_id" { + default = "` + defaultTsfGateway + `" +} +` + +const testAccTsfUnitRulesDataSource = testAccTsfUnitRulesDataSourceVar + ` + +data "tencentcloud_tsf_unit_rules" "unit_rules" { + gateway_instance_id = var.gateway_instance_id + status = "disabled" +} + +` diff --git a/tencentcloud/provider.go b/tencentcloud/provider.go index e43f2df8f7..72b49cf25f 100644 --- a/tencentcloud/provider.go +++ b/tencentcloud/provider.go @@ -1031,6 +1031,14 @@ TDMQ for CMQ tencentcloud_tcmq_subscribe Tencent Service Framework(TSF) + Data Source + tencentcloud_tsf_application + tencentcloud_tsf_application_config + tencentcloud_tsf_application_file_config + tencentcloud_tsf_application_public_config + tencentcloud_tsf_cluster + tencentcloud_tsf_microservice + tencentcloud_tsf_unit_rules Resource tencentcloud_tsf_cluster tencentcloud_tsf_microservice @@ -1472,6 +1480,13 @@ func Provider() terraform.ResourceProvider { "tencentcloud_cvm_disaster_recover_group_quota": dataSourceTencentCloudCvmDisasterRecoverGroupQuota(), "tencentcloud_cvm_chc_hosts": dataSourceTencentCloudCvmChcHosts(), "tencentcloud_cvm_chc_denied_actions": dataSourceTencentCloudCvmChcDeniedActions(), + "tencentcloud_tsf_application": dataSourceTencentCloudTsfApplication(), + "tencentcloud_tsf_application_config": dataSourceTencentCloudTsfApplicationConfig(), + "tencentcloud_tsf_application_file_config": dataSourceTencentCloudTsfApplicationFileConfig(), + "tencentcloud_tsf_application_public_config": dataSourceTencentCloudTsfApplicationPublicConfig(), + "tencentcloud_tsf_cluster": dataSourceTencentCloudTsfCluster(), + "tencentcloud_tsf_microservice": dataSourceTencentCloudTsfMicroservice(), + "tencentcloud_tsf_unit_rules": dataSourceTencentCloudTsfUnitRules(), }, ResourcesMap: map[string]*schema.Resource{ diff --git a/tencentcloud/service_tencentcloud_tsf.go b/tencentcloud/service_tencentcloud_tsf.go index a2ad7a380c..3e54379a5e 100644 --- a/tencentcloud/service_tencentcloud_tsf.go +++ b/tencentcloud/service_tencentcloud_tsf.go @@ -1226,3 +1226,458 @@ func (me *TsfService) DeleteTsfInstancesAttachmentById(ctx context.Context, clus return } + +func (me *TsfService) DescribeTsfApplicationByFilter(ctx context.Context, param map[string]interface{}) (application *tsf.TsfPageApplication, errRet error) { + var ( + logId = getLogId(ctx) + request = tsf.NewDescribeApplicationsRequest() + ) + + 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()) + } + }() + + for k, v := range param { + if k == "ApplicationType" { + request.ApplicationType = v.(*string) + } + if k == "MicroserviceType" { + request.MicroserviceType = v.(*string) + } + if k == "ApplicationResourceTypeList" { + request.ApplicationResourceTypeList = v.([]*string) + } + if k == "ApplicationIdList" { + request.ApplicationIdList = v.([]*string) + } + } + + ratelimit.Check(request.GetAction()) + + var ( + offset int64 = 0 + limit int64 = 20 + total int64 + content = make([]*tsf.ApplicationForPage, 0) + ) + for { + request.Offset = &offset + request.Limit = &limit + response, err := me.client.UseTsfClient().DescribeApplications(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 == nil || len(response.Response.Result.Content) < 1 { + break + } + total = *response.Response.Result.TotalCount + content = append(content, response.Response.Result.Content...) + if len(response.Response.Result.Content) < int(limit) { + break + } + + offset += limit + } + + application = &tsf.TsfPageApplication{ + TotalCount: &total, + Content: content, + } + + return +} + +func (me *TsfService) DescribeTsfApplicationConfigByFilter(ctx context.Context, param map[string]interface{}) (applicationConfig *tsf.TsfPageConfig, errRet error) { + logId := getLogId(ctx) + + request := tsf.NewDescribeConfigsRequest() + + 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()) + } + }() + + for k, v := range param { + if k == "ApplicationId" { + request.ApplicationId = v.(*string) + } + if k == "ConfigId" { + request.ConfigId = v.(*string) + } + if k == "ConfigIdList" { + request.ConfigIdList = v.([]*string) + } + if k == "ConfigName" { + request.ConfigName = v.(*string) + } + if k == "ConfigVersion" { + request.ConfigVersion = v.(*string) + } + } + + ratelimit.Check(request.GetAction()) + + var ( + offset int64 = 0 + limit int64 = 20 + total int64 + config = make([]*tsf.Config, 0) + ) + + for { + request.Offset = &offset + request.Limit = &limit + response, err := me.client.UseTsfClient().DescribeConfigs(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 == nil || len(response.Response.Result.Content) < 1 { + break + } + total = *response.Response.Result.TotalCount + config = append(config, response.Response.Result.Content...) + if len(response.Response.Result.Content) < int(limit) { + break + } + + offset += limit + } + + applicationConfig = &tsf.TsfPageConfig{ + TotalCount: &total, + Content: config, + } + + return +} + +func (me *TsfService) DescribeTsfApplicationFileConfigByFilter(ctx context.Context, param map[string]interface{}) (applicationFileConfig *tsf.TsfPageFileConfig, errRet error) { + var ( + logId = getLogId(ctx) + request = tsf.NewDescribeFileConfigsRequest() + ) + + 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()) + } + }() + + for k, v := range param { + if k == "ConfigId" { + request.ConfigId = v.(*string) + } + if k == "ConfigIdList" { + request.ConfigIdList = v.([]*string) + } + if k == "ConfigName" { + request.ConfigName = v.(*string) + } + if k == "ApplicationId" { + request.ApplicationId = v.(*string) + } + if k == "ConfigVersion" { + request.ConfigVersion = v.(*string) + } + } + + ratelimit.Check(request.GetAction()) + + var ( + offset int64 = 0 + limit int64 = 20 + total int64 + config = make([]*tsf.FileConfig, 0) + ) + for { + request.Offset = &offset + request.Limit = &limit + response, err := me.client.UseTsfClient().DescribeFileConfigs(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 == nil || len(response.Response.Result.Content) < 1 { + break + } + total = *response.Response.Result.TotalCount + config = append(config, response.Response.Result.Content...) + if len(response.Response.Result.Content) < int(limit) { + break + } + + offset += limit + } + + applicationFileConfig = &tsf.TsfPageFileConfig{ + TotalCount: &total, + Content: config, + } + + return +} + +func (me *TsfService) DescribeTsfApplicationPublicConfigByFilter(ctx context.Context, param map[string]interface{}) (applicationPublicConfig *tsf.TsfPageConfig, errRet error) { + var ( + logId = getLogId(ctx) + request = tsf.NewDescribePublicConfigsRequest() + ) + + 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()) + } + }() + + for k, v := range param { + if k == "ConfigId" { + request.ConfigId = v.(*string) + } + if k == "ConfigIdList" { + request.ConfigIdList = v.([]*string) + } + if k == "ConfigName" { + request.ConfigName = v.(*string) + } + if k == "ConfigVersion" { + request.ConfigVersion = v.(*string) + } + } + + ratelimit.Check(request.GetAction()) + + var ( + offset int64 = 0 + limit int64 = 20 + total int64 + config = make([]*tsf.Config, 0) + ) + for { + request.Offset = &offset + request.Limit = &limit + response, err := me.client.UseTsfClient().DescribePublicConfigs(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 == nil || len(response.Response.Result.Content) < 1 { + break + } + total = *response.Response.Result.TotalCount + config = append(config, response.Response.Result.Content...) + if len(response.Response.Result.Content) < int(limit) { + break + } + + offset += limit + } + + applicationPublicConfig = &tsf.TsfPageConfig{ + TotalCount: &total, + Content: config, + } + + return +} + +func (me *TsfService) DescribeTsfClusterByFilter(ctx context.Context, param map[string]interface{}) (cluster *tsf.TsfPageCluster, errRet error) { + var ( + logId = getLogId(ctx) + request = tsf.NewDescribeSimpleClustersRequest() + ) + + 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()) + } + }() + + for k, v := range param { + if k == "ClusterIdList" { + request.ClusterIdList = v.([]*string) + } + if k == "ClusterType" { + request.ClusterType = v.(*string) + } + if k == "SearchWord" { + request.SearchWord = v.(*string) + } + if k == "DisableProgramAuthCheck" { + request.DisableProgramAuthCheck = v.(*bool) + } + } + + ratelimit.Check(request.GetAction()) + + var ( + offset int64 = 0 + limit int64 = 20 + total int64 + clusters = make([]*tsf.Cluster, 0) + ) + for { + request.Offset = &offset + request.Limit = &limit + response, err := me.client.UseTsfClient().DescribeSimpleClusters(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 == nil || len(response.Response.Result.Content) < 1 { + break + } + total = *response.Response.Result.TotalCount + clusters = append(clusters, response.Response.Result.Content...) + if len(response.Response.Result.Content) < int(limit) { + break + } + + offset += limit + } + + cluster = &tsf.TsfPageCluster{ + TotalCount: &total, + Content: clusters, + } + + return +} + +func (me *TsfService) DescribeTsfMicroserviceByFilter(ctx context.Context, param map[string]interface{}) (microservice *tsf.TsfPageMicroservice, errRet error) { + var ( + logId = getLogId(ctx) + request = tsf.NewDescribeMicroservicesRequest() + ) + + 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()) + } + }() + + for k, v := range param { + if k == "NamespaceId" { + request.NamespaceId = v.(*string) + } + if k == "Status" { + request.Status = v.([]*string) + } + if k == "MicroserviceIdList" { + request.MicroserviceIdList = v.([]*string) + } + if k == "MicroserviceNameList" { + request.MicroserviceNameList = v.([]*string) + } + } + + ratelimit.Check(request.GetAction()) + + var ( + offset int64 = 0 + limit int64 = 20 + total int64 + micro = make([]*tsf.Microservice, 0) + ) + for { + request.Offset = &offset + request.Limit = &limit + response, err := me.client.UseTsfClient().DescribeMicroservices(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 == nil || len(response.Response.Result.Content) < 1 { + break + } + total = *response.Response.Result.TotalCount + micro = append(micro, response.Response.Result.Content...) + if len(response.Response.Result.Content) < int(limit) { + break + } + + offset += limit + } + + microservice = &tsf.TsfPageMicroservice{ + TotalCount: &total, + Content: micro, + } + + return +} + +func (me *TsfService) DescribeTsfUnitRulesByFilter(ctx context.Context, param map[string]interface{}) (unitRule *tsf.TsfPageUnitRuleV2, errRet error) { + var ( + logId = getLogId(ctx) + request = tsf.NewDescribeUnitRulesV2Request() + ) + + 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()) + } + }() + + for k, v := range param { + if k == "GatewayInstanceId" { + request.GatewayInstanceId = v.(*string) + } + if k == "Status" { + request.Status = v.(*string) + } + } + + ratelimit.Check(request.GetAction()) + + var ( + offset int64 = 0 + limit int64 = 20 + total int64 + rules = make([]*tsf.UnitRule, 0) + ) + for { + request.Offset = &offset + request.Limit = &limit + response, err := me.client.UseTsfClient().DescribeUnitRulesV2(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 == nil || len(response.Response.Result.Content) < 1 { + break + } + total = *response.Response.Result.TotalCount + rules = append(rules, response.Response.Result.Content...) + if len(response.Response.Result.Content) < int(limit) { + break + } + + offset += limit + } + + unitRule = &tsf.TsfPageUnitRuleV2{ + TotalCount: &total, + Content: rules, + } + + return +} 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 f75055efb9..765ca4fe9e 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 @@ -9623,6 +9623,58 @@ func (c *Client) DescribeUnitRulesWithContext(ctx context.Context, request *Desc return } +func NewDescribeUnitRulesV2Request() (request *DescribeUnitRulesV2Request) { + request = &DescribeUnitRulesV2Request{ + BaseRequest: &tchttp.BaseRequest{}, + } + + request.Init().WithApiInfo("tsf", APIVersion, "DescribeUnitRulesV2") + + + return +} + +func NewDescribeUnitRulesV2Response() (response *DescribeUnitRulesV2Response) { + response = &DescribeUnitRulesV2Response{ + BaseResponse: &tchttp.BaseResponse{}, + } + return +} + +// DescribeUnitRulesV2 +// 查询单元化规则列表V2 +// +// 可能返回的错误码: +// INTERNALERROR_GATEWAYCONSULERROR = "InternalError.GatewayConsulError" +// INVALIDPARAMETERVALUE_GATEWAYPARAMETERINVALID = "InvalidParameterValue.GatewayParameterInvalid" +// MISSINGPARAMETER_GATEWAYPARAMETERREQUIRED = "MissingParameter.GatewayParameterRequired" +func (c *Client) DescribeUnitRulesV2(request *DescribeUnitRulesV2Request) (response *DescribeUnitRulesV2Response, err error) { + return c.DescribeUnitRulesV2WithContext(context.Background(), request) +} + +// DescribeUnitRulesV2 +// 查询单元化规则列表V2 +// +// 可能返回的错误码: +// INTERNALERROR_GATEWAYCONSULERROR = "InternalError.GatewayConsulError" +// INVALIDPARAMETERVALUE_GATEWAYPARAMETERINVALID = "InvalidParameterValue.GatewayParameterInvalid" +// MISSINGPARAMETER_GATEWAYPARAMETERREQUIRED = "MissingParameter.GatewayParameterRequired" +func (c *Client) DescribeUnitRulesV2WithContext(ctx context.Context, request *DescribeUnitRulesV2Request) (response *DescribeUnitRulesV2Response, err error) { + if request == nil { + request = NewDescribeUnitRulesV2Request() + } + + if c.GetCredential() == nil { + return nil, errors.New("DescribeUnitRulesV2 require credential") + } + + request.SetContext(ctx) + + response = NewDescribeUnitRulesV2Response() + err = c.Send(request, response) + return +} + func NewDescribeUploadInfoRequest() (request *DescribeUploadInfoRequest) { request = &DescribeUploadInfoRequest{ BaseRequest: &tchttp.BaseRequest{}, 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 3997650221..4475bc3270 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 @@ -14383,6 +14383,92 @@ func (r *DescribeUnitRulesResponse) FromJsonString(s string) error { return json.Unmarshal([]byte(s), &r) } +// Predefined struct for user +type DescribeUnitRulesV2RequestParams struct { + // 网关实体ID + GatewayInstanceId *string `json:"GatewayInstanceId,omitempty" name:"GatewayInstanceId"` + + // 根据规则名或备注内容模糊查询 + SearchWord *string `json:"SearchWord,omitempty" name:"SearchWord"` + + // 启用状态, disabled: 未发布, enabled: 发布 + Status *string `json:"Status,omitempty" name:"Status"` + + // 翻页查询偏移量 + Offset *int64 `json:"Offset,omitempty" name:"Offset"` + + // 翻页查询每页记录数 + Limit *int64 `json:"Limit,omitempty" name:"Limit"` +} + +type DescribeUnitRulesV2Request struct { + *tchttp.BaseRequest + + // 网关实体ID + GatewayInstanceId *string `json:"GatewayInstanceId,omitempty" name:"GatewayInstanceId"` + + // 根据规则名或备注内容模糊查询 + SearchWord *string `json:"SearchWord,omitempty" name:"SearchWord"` + + // 启用状态, disabled: 未发布, enabled: 发布 + Status *string `json:"Status,omitempty" name:"Status"` + + // 翻页查询偏移量 + Offset *int64 `json:"Offset,omitempty" name:"Offset"` + + // 翻页查询每页记录数 + Limit *int64 `json:"Limit,omitempty" name:"Limit"` +} + +func (r *DescribeUnitRulesV2Request) 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 *DescribeUnitRulesV2Request) FromJsonString(s string) error { + f := make(map[string]interface{}) + if err := json.Unmarshal([]byte(s), &f); err != nil { + return err + } + delete(f, "GatewayInstanceId") + delete(f, "SearchWord") + delete(f, "Status") + delete(f, "Offset") + delete(f, "Limit") + if len(f) > 0 { + return tcerr.NewTencentCloudSDKError("ClientError.BuildRequestError", "DescribeUnitRulesV2Request has unknown keys!", "") + } + return json.Unmarshal([]byte(s), &r) +} + +// Predefined struct for user +type DescribeUnitRulesV2ResponseParams struct { + // 分页列表信息 + // 注意:此字段可能返回 null,表示取不到有效值。 + Result *TsfPageUnitRuleV2 `json:"Result,omitempty" name:"Result"` + + // 唯一请求 ID,每次请求都会返回。定位问题时需要提供该次请求的 RequestId。 + RequestId *string `json:"RequestId,omitempty" name:"RequestId"` +} + +type DescribeUnitRulesV2Response struct { + *tchttp.BaseResponse + Response *DescribeUnitRulesV2ResponseParams `json:"Response"` +} + +func (r *DescribeUnitRulesV2Response) 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 *DescribeUnitRulesV2Response) FromJsonString(s string) error { + return json.Unmarshal([]byte(s), &r) +} + // Predefined struct for user type DescribeUploadInfoRequestParams struct { // 应用ID @@ -21211,6 +21297,16 @@ type TsfPageUnitRule struct { Content []*UnitRule `json:"Content,omitempty" name:"Content"` } +type TsfPageUnitRuleV2 struct { + // 记录总数 + // 注意:此字段可能返回 null,表示取不到有效值。 + TotalCount *int64 `json:"TotalCount,omitempty" name:"TotalCount"` + + // 记录实体列表 + // 注意:此字段可能返回 null,表示取不到有效值。 + Content []*UnitRule `json:"Content,omitempty" name:"Content"` +} + type TsfPageVmGroup struct { // 虚拟机部署组总数目 // 注意:此字段可能返回 null,表示取不到有效值。 diff --git a/vendor/modules.txt b/vendor/modules.txt index f14c1294e1..bfb865f51c 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -662,7 +662,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.644 github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tke/v20180525 -# github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tsf v1.0.645 +# github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tsf v1.0.648 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/d/tsf_application.html.markdown b/website/docs/d/tsf_application.html.markdown new file mode 100644 index 0000000000..5cb7a818ec --- /dev/null +++ b/website/docs/d/tsf_application.html.markdown @@ -0,0 +1,63 @@ +--- +subcategory: "Tencent Service Framework(TSF)" +layout: "tencentcloud" +page_title: "TencentCloud: tencentcloud_tsf_application" +sidebar_current: "docs-tencentcloud-datasource-tsf_application" +description: |- + Use this data source to query detailed information of tsf application +--- + +# tencentcloud_tsf_application + +Use this data source to query detailed information of tsf application + +## Example Usage + +```hcl +data "tencentcloud_tsf_application" "application" { + application_type = "V" + microservice_type = "N" + # application_resource_type_list = [""] + application_id_list = ["application-a24x29xv"] +} +``` + +## Argument Reference + +The following arguments are supported: + +* `application_id_list` - (Optional, Set: [`String`]) Id list. +* `application_resource_type_list` - (Optional, Set: [`String`]) An array of application resource types. +* `application_type` - (Optional, String) The application type. V OR C, V means VM, C means container. +* `microservice_type` - (Optional, String) The microservice type of the application. +* `result_output_file` - (Optional, String) Used to save results. + +## Attributes Reference + +In addition to all arguments above, the following attributes are exported: + +* `result` - The application paging list information. + * `content` - The list of application information. + * `apigateway_service_id` - gateway service id. + * `application_desc` - The description of the application. + * `application_id` - The ID of the application. + * `application_name` - The name of the application. + * `application_remark_name` - remark name. + * `application_resource_type` - application resource type. + * `application_runtime_type` - application runtime type. + * `application_type` - The type of the application. + * `create_time` - create time. + * `ignore_create_image_repository` - whether ignore create image repository. + * `microservice_type` - The microservice type of the application. + * `prog_lang` - Programming language. + * `service_config_list` - service config list. + * `health_check` - health check setting. + * `path` - health check path. + * `name` - serviceName. + * `ports` - port list. + * `protocol` - protocol. + * `target_port` - service port. + * `update_time` - update time. + * `total_count` - The total number of applications. + + diff --git a/website/docs/d/tsf_application_config.html.markdown b/website/docs/d/tsf_application_config.html.markdown new file mode 100644 index 0000000000..94f88b0be7 --- /dev/null +++ b/website/docs/d/tsf_application_config.html.markdown @@ -0,0 +1,57 @@ +--- +subcategory: "Tencent Service Framework(TSF)" +layout: "tencentcloud" +page_title: "TencentCloud: tencentcloud_tsf_application_config" +sidebar_current: "docs-tencentcloud-datasource-tsf_application_config" +description: |- + Use this data source to query detailed information of tsf application_config +--- + +# tencentcloud_tsf_application_config + +Use this data source to query detailed information of tsf application_config + +## Example Usage + +```hcl +data "tencentcloud_tsf_application_config" "application_config" { + application_id = "app-123456" + config_id = "config-123456" + config_id_list = + config_name = "test-config" + config_version = "1.0" +} +``` + +## Argument Reference + +The following arguments are supported: + +* `application_id` - (Optional, String) Application ID, query all when not provided. +* `config_id_list` - (Optional, Set: [`String`]) Configuration ID list, query all with lower priority when not provided. +* `config_id` - (Optional, String) Configuration ID, query all with higher priority when not provided. +* `config_name` - (Optional, String) Configuration name, precise query, query all when not provided. +* `config_version` - (Optional, String) Configuration version, precise query, query all when not provided. +* `result_output_file` - (Optional, String) Used to save results. + +## Attributes Reference + +In addition to all arguments above, the following attributes are exported: + +* `result` - Paginated configuration item list. Note: This field may return null, indicating that no valid values can be obtained. + * `content` - Configuration item list. + * `application_id` - application Id. Note: This field may return null, indicating that no valid values can be obtained. + * `application_name` - application Id. Note: This field may return null, indicating that no valid values can be obtained. + * `config_id` - Configuration ID. Note: This field may return null, indicating that no valid values can be obtained. + * `config_name` - Configuration name Note: This field may return null, indicating that no valid values can be obtained. + * `config_type` - Configuration type. Note: This field may return null, indicating that no valid values can be obtained. + * `config_value` - Configuration value. Note: This field may return null, indicating that no valid values can be obtained. + * `config_version_count` - config version count. Note: This field may return null, indicating that no valid values can be obtained. + * `config_version_desc` - Configuration version description. Note: This field may return null, indicating that no valid values can be obtained. + * `config_version` - Configuration version. Note: This field may return null, indicating that no valid values can be obtained. + * `creation_time` - CreationTime. Note: This field may return null, indicating that no valid values can be obtained. + * `delete_flag` - delete flag, true: allow delete; false: delete prohibit. + * `last_update_time` - last update time. Note: This field may return null, indicating that no valid values can be obtained. + * `total_count` - TsfPageConfig. + + diff --git a/website/docs/d/tsf_application_file_config.html.markdown b/website/docs/d/tsf_application_file_config.html.markdown new file mode 100644 index 0000000000..33d4a324fe --- /dev/null +++ b/website/docs/d/tsf_application_file_config.html.markdown @@ -0,0 +1,61 @@ +--- +subcategory: "Tencent Service Framework(TSF)" +layout: "tencentcloud" +page_title: "TencentCloud: tencentcloud_tsf_application_file_config" +sidebar_current: "docs-tencentcloud-datasource-tsf_application_file_config" +description: |- + Use this data source to query detailed information of tsf application_file_config +--- + +# tencentcloud_tsf_application_file_config + +Use this data source to query detailed information of tsf application_file_config + +## Example Usage + +```hcl +data "tencentcloud_tsf_application_file_config" "application_file_config" { + config_id = "dcfg-f-4y4ekzqv" + # config_id_list = [""] + config_name = "file-log1" + application_id = "application-2vzk6n3v" + config_version = "1.2" +} +``` + +## Argument Reference + +The following arguments are supported: + +* `application_id` - (Optional, String) Application ID. +* `config_id_list` - (Optional, Set: [`String`]) List of configuration item ID. +* `config_id` - (Optional, String) Configuration ID. +* `config_name` - (Optional, String) Configuration item name. +* `config_version` - (Optional, String) Configuration item version. +* `result_output_file` - (Optional, String) Used to save results. + +## Attributes Reference + +In addition to all arguments above, the following attributes are exported: + +* `result` - File configuration item list. Note: This field may return null, indicating that no valid values can be obtained. + * `content` - File configuration array. Note: This field may return null, indicating that no valid values can be obtained. + * `application_id` - application Id. Note: This field may return null, indicating that no valid values can be obtained. + * `application_name` - application name. Note: This field may return null, indicating that no valid values can be obtained. + * `config_file_code` - Configuration file code. Note: This field may return null, indicating that no valid values can be obtained. + * `config_file_name` - Configuration item file name. Note: This field may return null, indicating that no valid values can be obtained. + * `config_file_path` - file config path. Note: This field may return null, indicating that no valid values can be obtained. + * `config_file_value_length` - config item content length. Note: This field may return null, indicating that no valid values can be obtained. + * `config_file_value` - Configuration file content. Note: This field may return null, indicating that no valid values can be obtained. + * `config_id` - Config ID. Note: This field may return null, indicating that no valid values can be obtained. + * `config_name` - Configuration item name. Note: This field may return null, indicating that no valid values can be obtained. + * `config_post_cmd` - last update time. Note: This field may return null, indicating that no valid values can be obtained. + * `config_version_count` - config version count. Note: This field may return null, indicating that no valid values can be obtained. + * `config_version_desc` - Configuration item version description. Note: This field may return null, indicating that no valid values can be obtained. + * `config_version` - Configuration version. Note: This field may return null, indicating that no valid values can be obtained. + * `creation_time` - CreationTime. Note: This field may return null, indicating that no valid values can be obtained. + * `delete_flag` - delete flag, true: allow delete; false: delete prohibit. + * `last_update_time` - last update time. Note: This field may return null, indicating that no valid values can be obtained. + * `total_count` - total count. + + diff --git a/website/docs/d/tsf_application_public_config.html.markdown b/website/docs/d/tsf_application_public_config.html.markdown new file mode 100644 index 0000000000..a1aaf4cd70 --- /dev/null +++ b/website/docs/d/tsf_application_public_config.html.markdown @@ -0,0 +1,55 @@ +--- +subcategory: "Tencent Service Framework(TSF)" +layout: "tencentcloud" +page_title: "TencentCloud: tencentcloud_tsf_application_public_config" +sidebar_current: "docs-tencentcloud-datasource-tsf_application_public_config" +description: |- + Use this data source to query detailed information of tsf application_public_config +--- + +# tencentcloud_tsf_application_public_config + +Use this data source to query detailed information of tsf application_public_config + +## Example Usage + +```hcl +data "tencentcloud_tsf_application_public_config" "application_public_config" { + config_id = "dcfg-p-evjrbgly" + # config_id_list = [""] + config_name = "dsadsa" + config_version = "123" +} +``` + +## Argument Reference + +The following arguments are supported: + +* `config_id_list` - (Optional, Set: [`String`]) Config ID list. Query all items if not passed, low priority. +* `config_id` - (Optional, String) Config ID. Query all items if not passed, high priority. +* `config_name` - (Optional, String) Config name. Exact query. Query all items if not passed. +* `config_version` - (Optional, String) Config version. Exact query. Query all items if not passed. +* `result_output_file` - (Optional, String) Used to save results. + +## Attributes Reference + +In addition to all arguments above, the following attributes are exported: + +* `result` - Paginated global configuration list. Note: This field may return null, indicating that no valid value can be obtained. + * `content` - Config list. + * `application_id` - application Id. Note: This field may return null, indicating that no valid values can be obtained. + * `application_name` - application Id. Note: This field may return null, indicating that no valid values can be obtained. + * `config_id` - Config ID. Note: This field may return null, indicating that no valid value can be obtained. + * `config_name` - Config name. Note: This field may return null, indicating that no valid value can be obtained. + * `config_type` - Config type. Note: This field may return null, indicating that no valid value can be obtained. + * `config_value` - Config value. Note: This field may return null, indicating that no valid value can be obtained. + * `config_version_count` - config version count. Note: This field may return null, indicating that no valid values can be obtained. + * `config_version_desc` - Config version description. Note: This field may return null, indicating that no valid value can be obtained. + * `config_version` - Config version. Note: This field may return null, indicating that no valid value can be obtained. + * `creation_time` - CreationTime. Note: This field may return null, indicating that no valid values can be obtained. + * `delete_flag` - delete flag, true: allow delete; false: delete prohibit. + * `last_update_time` - last update time. Note: This field may return null, indicating that no valid values can be obtained. + * `total_count` - TsfPageConfig. + + diff --git a/website/docs/d/tsf_cluster.html.markdown b/website/docs/d/tsf_cluster.html.markdown new file mode 100644 index 0000000000..627801cf1b --- /dev/null +++ b/website/docs/d/tsf_cluster.html.markdown @@ -0,0 +1,83 @@ +--- +subcategory: "Tencent Service Framework(TSF)" +layout: "tencentcloud" +page_title: "TencentCloud: tencentcloud_tsf_cluster" +sidebar_current: "docs-tencentcloud-datasource-tsf_cluster" +description: |- + Use this data source to query detailed information of tsf cluster +--- + +# tencentcloud_tsf_cluster + +Use this data source to query detailed information of tsf cluster + +## Example Usage + +```hcl +data "tencentcloud_tsf_cluster" "cluster" { + cluster_id_list = ["cluster-vwgj5e6y"] + cluster_type = "V" + # search_word = "" + disable_program_auth_check = true +} +``` + +## Argument Reference + +The following arguments are supported: + +* `cluster_id_list` - (Optional, Set: [`String`]) Cluster ID list to be queried, if not filled in or passed, all content will be queried. +* `cluster_type` - (Optional, String) The type of cluster to be queried, if left blank or not passed, all content will be queried. C: container, V: virtual machine. +* `disable_program_auth_check` - (Optional, Bool) Whether to disable dataset authentication. +* `result_output_file` - (Optional, String) Used to save results. +* `search_word` - (Optional, String) Filter by keywords for Cluster Id or name. + +## Attributes Reference + +In addition to all arguments above, the following attributes are exported: + +* `result` - TSF cluster pagination object. Note: This field may return null, indicating no valid value. + * `content` - Cluster list. Note: This field may return null, indicating no valid values. + * `cluster_cidr` - cluster CIDR. Note: This field may return null, indicating no valid value. + * `cluster_desc` - Cluster description. Note: This field may return null, indicating no valid value. + * `cluster_id` - Cluster ID. Note: This field may return null, indicating no valid value. + * `cluster_limit_cpu` - Maximum CPU limit of the cluster, in cores. This field may return null, indicating that no valid value was found. + * `cluster_limit_mem` - Cluster maximum memory limit in GB. This field may return null, indicating that no valid value was found. + * `cluster_name` - Cluster name. Note: This field may return null, indicating no valid value. + * `cluster_status` - cluster status. Note: This field may return null, indicating no valid value. + * `cluster_total_cpu` - Total CPU of the cluster, unit: cores. Note: This field may return null, indicating that no valid value was found. + * `cluster_total_mem` - Total memory of the cluster, unit: G. Note: This field may return null, indicating that no valid value is obtained. + * `cluster_type` - Cluster type. Note: This field may return null, indicating no valid value. + * `cluster_used_cpu` - Used CPU of the cluster, in cores. This field may return null, indicating no valid value. + * `cluster_used_mem` - Cluster used memory in GB. This field may return null, indicating no valid value. + * `cluster_version` - The cluster version, may return null if not applicable. + * `create_time` - CreationTime. Note: This field may return null, indicating that no valid values can be obtained. + * `delete_flag_reason` - Reason why the cluster cannot be deleted. Note: This field may return null, indicating that no valid values can be obtained. + * `delete_flag` - Deletion tag: true means it can be deleted, false means it cannot be deleted. Note: This field may return null, indicating no valid value. + * `instance_count` - Cluster instance number. This field may return null, indicating no valid value. + * `normal_instance_count` - Cluster normal instance number. This field may return null, indicating no valid value. + * `operation_info` - Control information returned to the frontend. This field may return null, indicating no valid value. + * `add_instance` - Add instance button control information, Note: This field may return null, indicating that no valid value is obtained. + * `disabled_reason` - The reason why this button is not displayed, may return null if not applicable. + * `enabled` - Whether the button is clickable. Note: This field may return null, indicating that no valid value is obtained. + * `supported` - Whether the button is clickable. Note: This field may return null, indicating that no valid value was found. + * `destroy` - Control information for destroying machine, may return null if no valid value is obtained. + * `disabled_reason` - The reason why this button is not displayed, may return null if not applicable. + * `enabled` - Whether the button is clickable. Note: This field may return null, indicating that no valid value is obtained. + * `supported` - Whether the button is clickable. Note: This field may return null, indicating that no valid value was found. + * `init` - Control information of the initialization button returned to the front end. Note: This field may return null, indicating no valid value. + * `disabled_reason` - Reason for not displaying. Note: This field may return null, indicating no valid value. + * `enabled` - The availability of the button (whether it is clickable) may return null indicating that the information is not available. + * `supported` - Whether to display the button. Note: This field may return null, indicating that no valid value was found. + * `run_instance_count` - Cluster running instance number. This field may return null, indicating no valid value. + * `run_service_instance_count` - Number of available service instances in the cluster. Note: This field may return null, indicating no valid value. + * `subnet_id` - Cluster subnet ID. Note: This field may return null, indicating no valid values. + * `tsf_region_id` - region ID of TSF. Note: This field may return null, indicating that no valid values can be obtained. + * `tsf_region_name` - region name of TSF. Note: This field may return null, indicating that no valid values can be obtained. + * `tsf_zone_id` - Zone Id of TSF. Note: This field may return null, indicating that no valid values can be obtained. + * `tsf_zone_name` - Zone name of TSF. Note: This field may return null, indicating that no valid values can be obtained. + * `update_time` - last update time. Note: This field may return null, indicating that no valid values can be obtained. + * `vpc_id` - Private network ID of the cluster. Note: This field may return null, indicating no valid value. + * `total_count` - Total number of items. Note: This field may return null, indicating that no valid value was found. + + diff --git a/website/docs/d/tsf_microservice.html.markdown b/website/docs/d/tsf_microservice.html.markdown new file mode 100644 index 0000000000..c7b4f0c073 --- /dev/null +++ b/website/docs/d/tsf_microservice.html.markdown @@ -0,0 +1,51 @@ +--- +subcategory: "Tencent Service Framework(TSF)" +layout: "tencentcloud" +page_title: "TencentCloud: tencentcloud_tsf_microservice" +sidebar_current: "docs-tencentcloud-datasource-tsf_microservice" +description: |- + Use this data source to query detailed information of tsf microservice +--- + +# tencentcloud_tsf_microservice + +Use this data source to query detailed information of tsf microservice + +## Example Usage + +```hcl +data "tencentcloud_tsf_microservice" "microservice" { + namespace_id = var.namespace_id + # status = + microservice_id_list = ["ms-yq3jo6jd"] + microservice_name_list = ["provider-demo"] +} +``` + +## Argument Reference + +The following arguments are supported: + +* `namespace_id` - (Required, String) namespace id. +* `microservice_id_list` - (Optional, Set: [`String`]) microservice id list. +* `microservice_name_list` - (Optional, Set: [`String`]) List of service names for search. +* `result_output_file` - (Optional, String) Used to save results. +* `status` - (Optional, Set: [`String`]) status filter, online, offline, single_online. + +## Attributes Reference + +In addition to all arguments above, the following attributes are exported: + +* `result` - Microservice paging list information. Note: This field may return null, indicating that no valid value can be obtained. + * `content` - Microservice list information. Note: This field may return null, indicating that no valid value can be obtained. + * `create_time` - CreationTime. Note: This field may return null, indicating that no valid values can be obtained. + * `critical_instance_count` - offline instance count. Note: This field may return null, indicating that no valid values can be obtained. + * `microservice_desc` - Microservice description. Note: This field may return null, indicating that no valid value can be obtained. + * `microservice_id` - Microservice Id. Note: This field may return null, indicating that no valid value can be obtained. + * `microservice_name` - Microservice name. Note: This field may return null, indicating that no valid value can be obtained. + * `namespace_id` - Namespace Id. Note: This field may return null, indicating that no valid values can be obtained. + * `run_instance_count` - run instance count in namespace. Note: This field may return null, indicating that no valid values can be obtained. + * `update_time` - last update time. Note: This field may return null, indicating that no valid values can be obtained. + * `total_count` - Microservice paging list information. Note: This field may return null, indicating that no valid value can be obtained. + + diff --git a/website/docs/d/tsf_unit_rules.html.markdown b/website/docs/d/tsf_unit_rules.html.markdown new file mode 100644 index 0000000000..8c5176449a --- /dev/null +++ b/website/docs/d/tsf_unit_rules.html.markdown @@ -0,0 +1,62 @@ +--- +subcategory: "Tencent Service Framework(TSF)" +layout: "tencentcloud" +page_title: "TencentCloud: tencentcloud_tsf_unit_rules" +sidebar_current: "docs-tencentcloud-datasource-tsf_unit_rules" +description: |- + Use this data source to query detailed information of tsf unit_rules +--- + +# tencentcloud_tsf_unit_rules + +Use this data source to query detailed information of tsf unit_rules + +## Example Usage + +```hcl +data "tencentcloud_tsf_unit_rules" "unit_rules" { + gateway_instance_id = "gw-ins-lvdypq5k" + status = "disabled" +} +``` + +## Argument Reference + +The following arguments are supported: + +* `gateway_instance_id` - (Required, String) gateway instance id. +* `result_output_file` - (Optional, String) Used to save results. +* `status` - (Optional, String) Enabled state, disabled: unpublished, enabled: published. + +## Attributes Reference + +In addition to all arguments above, the following attributes are exported: + +* `result` - Pagination list information. + * `content` - record entity list. + * `created_time` - created time. + * `description` - Rule description. + * `gateway_instance_id` - Gateway Entity ID. + * `id` - rule ID. + * `name` - rule name. + * `status` - Use status: enabled/disabled. + * `unit_rule_item_list` - list of rule items. + * `description` - Rule description. + * `dest_namespace_id` - Destination Namespace ID. + * `dest_namespace_name` - destination namespace name. + * `id` - rule item ID. + * `name` - rule item name. + * `priority` - Rule order, the smaller the higher the priority: the default is 0. + * `relationship` - Logical relationship: AND/OR. + * `unit_rule_id` - Unitization rule ID. + * `unit_rule_tag_list` - List of rule labels. + * `id` - rule ID. + * `tag_field` - tag name. + * `tag_operator` - Operator: IN/NOT_IN/EQUAL/NOT_EQUAL/REGEX. + * `tag_type` - Tag Type: U(User Tag). + * `tag_value` - tag value. + * `unit_rule_item_id` - Unitization rule item ID. + * `updated_time` - Updated time. + * `total_count` - total number of records. + + diff --git a/website/tencentcloud.erb b/website/tencentcloud.erb index 4d739c0dd8..36b5294aae 100644 --- a/website/tencentcloud.erb +++ b/website/tencentcloud.erb @@ -2302,7 +2302,32 @@
  • Tencent Service Framework(TSF)