Skip to content

Commit

Permalink
feat: changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
WeiMengXS committed Oct 8, 2023
1 parent e4ff5da commit 1dee318
Show file tree
Hide file tree
Showing 61 changed files with 8,998 additions and 553 deletions.
916 changes: 916 additions & 0 deletions tencentcloud/data_source_tc_ssl_describe_certificate.go

Large diffs are not rendered by default.

31 changes: 31 additions & 0 deletions tencentcloud/data_source_tc_ssl_describe_certificate_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package tencentcloud

import (
"testing"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
)

func TestAccTencentCloudSslDescribeCertificateDataSource_basic(t *testing.T) {
t.Parallel()
resource.Test(t, resource.TestCase{
PreCheck: func() {
testAccPreCheckCommon(t, ACCOUNT_TYPE_SSL)
},
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Config: testAccSslDescribeCertificateDataSource,
Check: resource.ComposeTestCheckFunc(testAccCheckTencentCloudDataSourceID("data.tencentcloud_ssl_describe_certificate.describe_certificate"),
resource.TestCheckResourceAttr("data.tencentcloud_ssl_describe_certificate.describe_certificate", "certificate_id", "9Bpk7XOu")),
},
},
})
}

const testAccSslDescribeCertificateDataSource = `
data "tencentcloud_ssl_describe_certificate" "describe_certificate" {
certificate_id = "9Bpk7XOu"
}
`
184 changes: 184 additions & 0 deletions tencentcloud/data_source_tc_ssl_describe_companies.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
/*
Use this data source to query detailed information of ssl describe_companies
Example Usage
```hcl
data "tencentcloud_ssl_describe_companies" "describe_companies" {
company_id = 122
}
```
*/
package tencentcloud

import (
"context"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
ssl "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/ssl/v20191205"
"github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/internal/helper"
)

func dataSourceTencentCloudSslDescribeCompanies() *schema.Resource {
return &schema.Resource{
Read: dataSourceTencentCloudSslDescribeCompaniesRead,
Schema: map[string]*schema.Schema{
"company_id": {
Optional: true,
Type: schema.TypeInt,
Description: "Company ID.",
},

"companies": {
Computed: true,
Type: schema.TypeList,
Description: "Company list.",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"company_name": {
Type: schema.TypeString,
Computed: true,
Description: "Company Name.",
},
"company_id": {
Type: schema.TypeInt,
Computed: true,
Description: "Company ID.",
},
"company_country": {
Type: schema.TypeString,
Computed: true,
Description: "Company country.",
},
"company_province": {
Type: schema.TypeString,
Computed: true,
Description: "Province where the company is located.",
},
"company_city": {
Type: schema.TypeString,
Computed: true,
Description: "The city where the company is.",
},
"company_address": {
Type: schema.TypeString,
Computed: true,
Description: "Detailed address where the company is located.",
},
"company_phone": {
Type: schema.TypeString,
Computed: true,
Description: "company phone.",
},
"id_type": {
Type: schema.TypeString,
Computed: true,
Description: "typeNote: This field may return NULL, indicating that the valid value cannot be obtained.",
},
"id_number": {
Type: schema.TypeString,
Computed: true,
Description: "ID numberNote: This field may return NULL, indicating that the valid value cannot be obtained.",
},
},
},
},

"result_output_file": {
Type: schema.TypeString,
Optional: true,
Description: "Used to save results.",
},
},
}
}

func dataSourceTencentCloudSslDescribeCompaniesRead(d *schema.ResourceData, meta interface{}) error {
defer logElapsed("data_source.tencentcloud_ssl_describe_companies.read")()
defer inconsistentCheck(d, meta)()

logId := getLogId(contextNil)

ctx := context.WithValue(context.TODO(), logIdKey, logId)

paramMap := make(map[string]interface{})
if v, _ := d.GetOk("company_id"); v != nil {
paramMap["CompanyId"] = helper.IntInt64(v.(int))
}

service := SslService{client: meta.(*TencentCloudClient).apiV3Conn}

var companies []*ssl.CompanyInfo

err := resource.Retry(readRetryTimeout, func() *resource.RetryError {
result, e := service.DescribeSslDescribeCompaniesByFilter(ctx, paramMap)
if e != nil {
return retryError(e)
}
companies = result
return nil
})
if err != nil {
return err
}

ids := make([]string, 0, len(companies))
tmpList := make([]map[string]interface{}, 0, len(companies))

if companies != nil {
for _, companyInfo := range companies {
companyInfoMap := map[string]interface{}{}

if companyInfo.CompanyName != nil {
companyInfoMap["company_name"] = companyInfo.CompanyName
}

if companyInfo.CompanyId != nil {
companyInfoMap["company_id"] = companyInfo.CompanyId
}

if companyInfo.CompanyCountry != nil {
companyInfoMap["company_country"] = companyInfo.CompanyCountry
}

if companyInfo.CompanyProvince != nil {
companyInfoMap["company_province"] = companyInfo.CompanyProvince
}

if companyInfo.CompanyCity != nil {
companyInfoMap["company_city"] = companyInfo.CompanyCity
}

if companyInfo.CompanyAddress != nil {
companyInfoMap["company_address"] = companyInfo.CompanyAddress
}

if companyInfo.CompanyPhone != nil {
companyInfoMap["company_phone"] = companyInfo.CompanyPhone
}

if companyInfo.IdType != nil {
companyInfoMap["id_type"] = companyInfo.IdType
}

if companyInfo.IdNumber != nil {
companyInfoMap["id_number"] = companyInfo.IdNumber
}

ids = append(ids, helper.Int64ToStr(*companyInfo.CompanyId))
tmpList = append(tmpList, companyInfoMap)
}

_ = d.Set("companies", tmpList)
}

d.SetId(helper.DataResourceIdsHash(ids))
output3, ok := d.GetOk("result_output_file")
if ok && output3.(string) != "" {
if e := writeToFile(output3.(string), tmpList); e != nil {
return e
}
}
return nil
}
34 changes: 34 additions & 0 deletions tencentcloud/data_source_tc_ssl_describe_companies_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package tencentcloud

import (
"testing"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
)

func TestAccTencentCloudSslDescribeCompaniesDataSource_basic(t *testing.T) {
t.Parallel()
resource.Test(t, resource.TestCase{
PreCheck: func() {
testAccPreCheckCommon(t, ACCOUNT_TYPE_SSL)
},
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Config: testAccSslDescribeCompaniesDataSource,
Check: resource.ComposeTestCheckFunc(
testAccCheckTencentCloudDataSourceID("data.tencentcloud_ssl_describe_companies.describe_companies"),
resource.TestCheckResourceAttr("data.tencentcloud_ssl_describe_companies.describe_companies", "company_id", "122"),
),
},
},
})
}

const testAccSslDescribeCompaniesDataSource = `
data "tencentcloud_ssl_describe_companies" "describe_companies" {
company_id = 122
}
`
Loading

0 comments on commit 1dee318

Please sign in to comment.