-
Notifications
You must be signed in to change notification settings - Fork 136
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
mikatong
committed
Dec 10, 2024
1 parent
f83afbf
commit a1aaa18
Showing
19 changed files
with
4,055 additions
and
1,248 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
82 changes: 82 additions & 0 deletions
82
tencentcloud/services/dnspod/data_source_tc_subdomain_validate_status.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
package dnspod | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||
|
||
tccommon "github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/common" | ||
"github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/internal/helper" | ||
) | ||
|
||
func DataSourceTencentCloudSubdomainValidateStatus() *schema.Resource { | ||
return &schema.Resource{ | ||
Read: dataSourceTencentCloudSubdomainValidateStatusRead, | ||
Schema: map[string]*schema.Schema{ | ||
"domain_zone": { | ||
Type: schema.TypeString, | ||
Required: true, | ||
Description: "Zone domain for which to view the verification status of TXT records.", | ||
}, | ||
|
||
"status": { | ||
Type: schema.TypeInt, | ||
Computed: true, | ||
Description: "Status. 0: not ready; 1: ready.", | ||
}, | ||
|
||
"result_output_file": { | ||
Type: schema.TypeString, | ||
Optional: true, | ||
Description: "Used to save results.", | ||
}, | ||
}, | ||
} | ||
} | ||
|
||
func dataSourceTencentCloudSubdomainValidateStatusRead(d *schema.ResourceData, meta interface{}) error { | ||
defer tccommon.LogElapsed("data_source.tencentcloud_subdomain_validate_status.read")() | ||
defer tccommon.InconsistentCheck(d, meta)() | ||
|
||
logId := tccommon.GetLogId(tccommon.ContextNil) | ||
ctx := tccommon.NewResourceLifeCycleHandleFuncContext(context.Background(), logId, d, meta) | ||
|
||
service := DnspodService{client: meta.(tccommon.ProviderMeta).GetAPIV3Conn()} | ||
|
||
var ( | ||
domainZone string | ||
) | ||
if v, ok := d.GetOk("domain_zone"); ok { | ||
domainZone = v.(string) | ||
} | ||
paramMap := make(map[string]interface{}) | ||
if v, ok := d.GetOk("domain_zone"); ok { | ||
paramMap["DomainZone"] = helper.String(v.(string)) | ||
} | ||
|
||
var status int | ||
err := resource.Retry(tccommon.ReadRetryTimeout, func() *resource.RetryError { | ||
result, e := service.DescribeSubdomainValidateStatusByFilter(ctx, paramMap) | ||
if e != nil { | ||
return tccommon.RetryError(e) | ||
} | ||
status = result | ||
return nil | ||
}) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
d.SetId(domainZone) | ||
_ = d.Set("status", status) | ||
|
||
output, ok := d.GetOk("result_output_file") | ||
if ok && output.(string) != "" { | ||
if e := tccommon.WriteToFile(output.(string), d); e != nil { | ||
return e | ||
} | ||
} | ||
|
||
return nil | ||
} |
9 changes: 9 additions & 0 deletions
9
tencentcloud/services/dnspod/data_source_tc_subdomain_validate_status.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
Use this data source to query detailed information of dnspod subdomain_validate_status | ||
|
||
Example Usage | ||
|
||
```hcl | ||
data "tencentcloud_subdomain_validate_status" "subdomain_validate_status" { | ||
domain_zone = "www.iac-tf.cloud" | ||
} | ||
``` |
55 changes: 55 additions & 0 deletions
55
tencentcloud/services/dnspod/data_source_tc_subdomain_validate_status_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package dnspod_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" | ||
|
||
tcacctest "github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/acctest" | ||
) | ||
|
||
func TestAccTencentCloudSubdomainValidateStatusDataSource_basic(t *testing.T) { | ||
t.Parallel() | ||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { | ||
tcacctest.AccPreCheck(t) | ||
}, | ||
Providers: tcacctest.AccProviders, | ||
Steps: []resource.TestStep{{ | ||
Config: testAccSubdomainValidateStatusDataSource, | ||
Check: resource.ComposeTestCheckFunc( | ||
tcacctest.AccCheckTencentCloudDataSourceID("data.tencentcloud_subdomain_validate_status.subdomain_validate_status"), | ||
resource.TestCheckResourceAttr("data.tencentcloud_subdomain_validate_status.subdomain_validate_status", "status", "1"), | ||
), | ||
}}, | ||
}) | ||
} | ||
|
||
func TestAccTencentCloudSubdomainValidateStatusDataSource_notReady(t *testing.T) { | ||
t.Parallel() | ||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { | ||
tcacctest.AccPreCheck(t) | ||
}, | ||
Providers: tcacctest.AccProviders, | ||
Steps: []resource.TestStep{{ | ||
Config: testAccSubdomainValidateStatusDataSourceNotReady, | ||
Check: resource.ComposeTestCheckFunc( | ||
tcacctest.AccCheckTencentCloudDataSourceID("data.tencentcloud_subdomain_validate_status.subdomain_validate_status"), | ||
resource.TestCheckResourceAttr("data.tencentcloud_subdomain_validate_status.subdomain_validate_status", "status", "0"), | ||
), | ||
}}, | ||
}) | ||
} | ||
|
||
const testAccSubdomainValidateStatusDataSource = ` | ||
data "tencentcloud_subdomain_validate_status" "subdomain_validate_status" { | ||
domain_zone = "www.iac-tf.cloud" | ||
} | ||
` | ||
|
||
const testAccSubdomainValidateStatusDataSourceNotReady = ` | ||
data "tencentcloud_subdomain_validate_status" "subdomain_validate_status" { | ||
domain_zone = "www.iac-tf.com" | ||
} | ||
` |
122 changes: 122 additions & 0 deletions
122
tencentcloud/services/dnspod/resource_tc_subdomain_validate_txt_value_operation.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
package dnspod | ||
|
||
import ( | ||
"context" | ||
"log" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||
dnspod "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/dnspod/v20210323" | ||
|
||
tccommon "github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/common" | ||
"github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/internal/helper" | ||
) | ||
|
||
func ResourceTencentCloudSubdomainValidateTxtValueOperation() *schema.Resource { | ||
return &schema.Resource{ | ||
Create: resourceTencentCloudSubdomainValidateTxtValueOperationCreate, | ||
Read: resourceTencentCloudSubdomainValidateTxtValueOperationRead, | ||
Delete: resourceTencentCloudSubdomainValidateTxtValueOperationDelete, | ||
Schema: map[string]*schema.Schema{ | ||
"domain_zone": { | ||
Type: schema.TypeString, | ||
Required: true, | ||
ForceNew: true, | ||
Description: "The subdomain to add Zone domain.", | ||
}, | ||
"domain": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
Description: "The domain name for which TXT records need to be added.", | ||
}, | ||
"subdomain": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
Description: "Host records that need to be added to TXT records.", | ||
}, | ||
"record_type": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
Description: "Record types need to be added.", | ||
}, | ||
"value": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
Description: "The record value of the TXT record needs to be added.", | ||
}, | ||
}, | ||
} | ||
} | ||
|
||
func resourceTencentCloudSubdomainValidateTxtValueOperationCreate(d *schema.ResourceData, meta interface{}) error { | ||
defer tccommon.LogElapsed("resource.tencentcloud_subdomain_validate_txt_value_operation.create")() | ||
defer tccommon.InconsistentCheck(d, meta)() | ||
|
||
logId := tccommon.GetLogId(tccommon.ContextNil) | ||
|
||
ctx := tccommon.NewResourceLifeCycleHandleFuncContext(context.Background(), logId, d, meta) | ||
|
||
var ( | ||
domainZone string | ||
) | ||
var ( | ||
request = dnspod.NewCreateSubdomainValidateTXTValueRequest() | ||
response = dnspod.NewCreateSubdomainValidateTXTValueResponse() | ||
) | ||
|
||
if v, ok := d.GetOk("domain_zone"); ok { | ||
domainZone = v.(string) | ||
} | ||
|
||
request.DomainZone = helper.String(domainZone) | ||
|
||
err := resource.Retry(tccommon.WriteRetryTimeout, func() *resource.RetryError { | ||
result, e := meta.(tccommon.ProviderMeta).GetAPIV3Conn().UseDnsPodClient().CreateSubdomainValidateTXTValueWithContext(ctx, request) | ||
if e != nil { | ||
return tccommon.RetryError(e) | ||
} else { | ||
log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n", logId, request.GetAction(), request.ToJsonString(), result.ToJsonString()) | ||
} | ||
response = result | ||
return nil | ||
}) | ||
if err != nil { | ||
log.Printf("[CRITAL]%s create subdomain validate txt value operation failed, reason:%+v", logId, err) | ||
return err | ||
} | ||
|
||
if response.Response != nil { | ||
if response.Response.Domain != nil { | ||
_ = d.Set("domain", response.Response.Domain) | ||
} | ||
if response.Response.Domain != nil { | ||
_ = d.Set("subdomain", response.Response.Subdomain) | ||
} | ||
if response.Response.Domain != nil { | ||
_ = d.Set("record_type", response.Response.RecordType) | ||
} | ||
if response.Response.Domain != nil { | ||
_ = d.Set("value", response.Response.Value) | ||
} | ||
} | ||
|
||
_ = response | ||
|
||
d.SetId(domainZone) | ||
|
||
return resourceTencentCloudSubdomainValidateTxtValueOperationRead(d, meta) | ||
} | ||
|
||
func resourceTencentCloudSubdomainValidateTxtValueOperationRead(d *schema.ResourceData, meta interface{}) error { | ||
defer tccommon.LogElapsed("resource.tencentcloud_subdomain_validate_txt_value_operation.read")() | ||
defer tccommon.InconsistentCheck(d, meta)() | ||
|
||
return nil | ||
} | ||
|
||
func resourceTencentCloudSubdomainValidateTxtValueOperationDelete(d *schema.ResourceData, meta interface{}) error { | ||
defer tccommon.LogElapsed("resource.tencentcloud_subdomain_validate_txt_value_operation.delete")() | ||
defer tccommon.InconsistentCheck(d, meta)() | ||
|
||
return nil | ||
} |
9 changes: 9 additions & 0 deletions
9
tencentcloud/services/dnspod/resource_tc_subdomain_validate_txt_value_operation.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
Provides a resource to create a dnspod subdomain_validate_txt_value_operation | ||
|
||
Example Usage | ||
|
||
```hcl | ||
resource "tencentcloud_subdomain_validate_txt_value_operation" "subdomain_validate_txt_value_operation" { | ||
domain_zone = "www.iac-tf.cloud" | ||
} | ||
``` |
38 changes: 38 additions & 0 deletions
38
tencentcloud/services/dnspod/resource_tc_subdomain_validate_txt_value_operation_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package dnspod_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" | ||
|
||
tcacctest "github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/acctest" | ||
) | ||
|
||
func TestAccTencentCloudSubdomainValidateTxtValueOperationResource_basic(t *testing.T) { | ||
t.Parallel() | ||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { | ||
tcacctest.AccPreCheck(t) | ||
}, | ||
Providers: tcacctest.AccProviders, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccSubdomainValidateTxtValueOperation, | ||
Check: resource.ComposeTestCheckFunc( | ||
resource.TestCheckResourceAttrSet("tencentcloud_subdomain_validate_txt_value_operation.subdomain_validate_txt_value_operation", "id"), | ||
resource.TestCheckResourceAttr("tencentcloud_subdomain_validate_txt_value_operation.subdomain_validate_txt_value_operation", "domain", "iac-tf.cloud"), | ||
resource.TestCheckResourceAttr("tencentcloud_subdomain_validate_txt_value_operation.subdomain_validate_txt_value_operation", "domain_zone", "www.iac-tf.cloud"), | ||
resource.TestCheckResourceAttr("tencentcloud_subdomain_validate_txt_value_operation.subdomain_validate_txt_value_operation", "record_type", "TXT"), | ||
resource.TestCheckResourceAttrSet("tencentcloud_subdomain_validate_txt_value_operation.subdomain_validate_txt_value_operation", "subdomain"), | ||
resource.TestCheckResourceAttrSet("tencentcloud_subdomain_validate_txt_value_operation.subdomain_validate_txt_value_operation", "value"), | ||
), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
const testAccSubdomainValidateTxtValueOperation = ` | ||
resource "tencentcloud_subdomain_validate_txt_value_operation" "subdomain_validate_txt_value_operation" { | ||
domain_zone = "www.iac-tf.cloud" | ||
} | ||
` |
Oops, something went wrong.