Skip to content

Commit 7e03e1c

Browse files
authored
feat(dnspod): dnspod operation (#2279)
* feat(dnspod): dnspod operation * feat(dnspod): dnspod operation * feat(dnspod): dnspod operation * feat(dnspod): dnspod operation * feat(dnspod): dnspod operation * feat(dnspod): dnspod operation * feat(dnspod): dnspod operation * feat(dnspod): dnspod operation
1 parent 041d67f commit 7e03e1c

17 files changed

+645
-11
lines changed

.changelog/2279.txt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
```release-note:new-resource
2+
tencentcloud_dnspod_modify_domain_owner_operation
3+
```
4+
5+
```release-note:new-resource
6+
tencentcloud_dnspod_modify_record_group_operation
7+
```
8+
9+
```release-note:new-resource
10+
tencentcloud_dnspod_download_snapshot_operation
11+
```
12+
13+
```release-note:enhancement
14+
tencentcloud_dnspod_record: Support set `remark`.
15+
```

tencentcloud/provider.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1236,6 +1236,9 @@ DNSPOD
12361236
tencentcloud_dnspod_domain_alias
12371237
tencentcloud_dnspod_record
12381238
tencentcloud_dnspod_record_group
1239+
tencentcloud_dnspod_modify_record_group_operation
1240+
tencentcloud_dnspod_modify_domain_owner_operation
1241+
tencentcloud_dnspod_download_snapshot_operation
12391242
tencentcloud_dnspod_custom_line
12401243
12411244
Data Source
@@ -3332,6 +3335,9 @@ func Provider() *schema.Provider {
33323335
"tencentcloud_dnspod_domain_alias": resourceTencentCloudDnspodDomainAlias(),
33333336
"tencentcloud_dnspod_record": resourceTencentCloudDnspodRecord(),
33343337
"tencentcloud_dnspod_record_group": resourceTencentCloudDnspodRecordGroup(),
3338+
"tencentcloud_dnspod_modify_domain_owner_operation": resourceTencentCloudDnspodModifyDomainOwnerOperation(),
3339+
"tencentcloud_dnspod_modify_record_group_operation": resourceTencentCloudDnspodModifyRecordGroupOperation(),
3340+
"tencentcloud_dnspod_download_snapshot_operation": resourceTencentCloudDnspodDownloadSnapshotOperation(),
33353341
"tencentcloud_dnspod_custom_line": resourceTencentCloudDnspodCustomLine(),
33363342
"tencentcloud_private_dns_zone": resourceTencentCloudPrivateDnsZone(),
33373343
"tencentcloud_private_dns_record": resourceTencentCloudPrivateDnsRecord(),

tencentcloud/resource_tc_dnspod_domain_alias.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ func resourceTencentCloudDnspodDomainAliasCreate(d *schema.ResourceData, meta in
101101
}
102102

103103
domainAliasId = *response.Response.DomainAliasId
104-
// d.SetId(helper.String(domainAlias))
105104
d.SetId(strings.Join([]string{domain, helper.Int64ToStr(domainAliasId)}, FILED_SP))
106105

107106
return resourceTencentCloudDnspodDomainAliasRead(d, meta)
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
/*
2+
Provides a resource to create a dnspod download_snapshot
3+
Example Usage
4+
```hcl
5+
resource "tencentcloud_dnspod_download_snapshot_operation" "download_snapshot" {
6+
domain = "dnspod.cn"
7+
snapshot_id = "456"
8+
}
9+
```
10+
*/
11+
package tencentcloud
12+
13+
import (
14+
"strings"
15+
16+
"log"
17+
18+
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
19+
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
20+
dnspod "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/dnspod/v20210323"
21+
"github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/internal/helper"
22+
)
23+
24+
func resourceTencentCloudDnspodDownloadSnapshotOperation() *schema.Resource {
25+
return &schema.Resource{
26+
Create: resourceTencentCloudDnspodDownloadSnapshotOperationCreate,
27+
Read: resourceTencentCloudDnspodDownloadSnapshotOperationRead,
28+
Delete: resourceTencentCloudDnspodDownloadSnapshotOperationDelete,
29+
Schema: map[string]*schema.Schema{
30+
"domain": {
31+
Required: true,
32+
ForceNew: true,
33+
Type: schema.TypeString,
34+
Description: "Domain.",
35+
},
36+
37+
"snapshot_id": {
38+
Required: true,
39+
ForceNew: true,
40+
Type: schema.TypeString,
41+
Description: "Snapshot ID.",
42+
},
43+
44+
"cos_url": {
45+
Computed: true,
46+
Type: schema.TypeString,
47+
Description: "Snapshot download url.",
48+
},
49+
},
50+
}
51+
}
52+
53+
func resourceTencentCloudDnspodDownloadSnapshotOperationCreate(d *schema.ResourceData, meta interface{}) error {
54+
defer logElapsed("resource.tencentcloud_dnspod_download_snapshot_operation.create")()
55+
defer inconsistentCheck(d, meta)()
56+
57+
logId := getLogId(contextNil)
58+
59+
var (
60+
request = dnspod.NewDownloadSnapshotRequest()
61+
response = dnspod.NewDownloadSnapshotResponse()
62+
domain string
63+
snapshotId string
64+
cosUrl string
65+
)
66+
if v, ok := d.GetOk("domain"); ok {
67+
domain = v.(string)
68+
request.Domain = helper.String(v.(string))
69+
}
70+
71+
if v, ok := d.GetOk("snapshot_id"); ok {
72+
snapshotId = v.(string)
73+
request.SnapshotId = helper.String(v.(string))
74+
}
75+
76+
err := resource.Retry(writeRetryTimeout, func() *resource.RetryError {
77+
result, e := meta.(*TencentCloudClient).apiV3Conn.UseDnsPodClient().DownloadSnapshot(request)
78+
if e != nil {
79+
return retryError(e)
80+
} else {
81+
log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n", logId, request.GetAction(), request.ToJsonString(), result.ToJsonString())
82+
}
83+
response = result
84+
return nil
85+
})
86+
if err != nil {
87+
log.Printf("[CRITAL]%s operate dnspod download_snapshot failed, reason:%+v", logId, err)
88+
return err
89+
}
90+
91+
if response.Response.CosUrl != nil {
92+
cosUrl = *response.Response.CosUrl
93+
_ = d.Set("cos_url", cosUrl)
94+
}
95+
96+
d.SetId(strings.Join([]string{domain, snapshotId}, FILED_SP))
97+
98+
return resourceTencentCloudDnspodDownloadSnapshotOperationRead(d, meta)
99+
}
100+
101+
func resourceTencentCloudDnspodDownloadSnapshotOperationRead(d *schema.ResourceData, meta interface{}) error {
102+
defer logElapsed("resource.tencentcloud_dnspod_download_snapshot_operation.read")()
103+
defer inconsistentCheck(d, meta)()
104+
105+
return nil
106+
}
107+
108+
func resourceTencentCloudDnspodDownloadSnapshotOperationDelete(d *schema.ResourceData, meta interface{}) error {
109+
defer logElapsed("resource.tencentcloud_dnspod_download_snapshot_operation.delete")()
110+
defer inconsistentCheck(d, meta)()
111+
112+
return nil
113+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package tencentcloud
2+
3+
import (
4+
"testing"
5+
6+
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
7+
)
8+
9+
func TestAccTencentCloudDnspodDownloadSnapshotOperationResource_basic(t *testing.T) {
10+
t.Parallel()
11+
resource.Test(t, resource.TestCase{
12+
PreCheck: func() { testAccPreCheckCommon(t, ACCOUNT_TYPE_PREPAY) },
13+
Providers: testAccProviders,
14+
Steps: []resource.TestStep{
15+
{
16+
Config: testAccDnspodDownloadSnapshotOperation,
17+
Check: resource.ComposeTestCheckFunc(
18+
resource.TestCheckResourceAttr("tencentcloud_dnspod_download_snapshot_operation.download_snapshot", "domain", "iac-tf.cloud"),
19+
resource.TestCheckResourceAttr("tencentcloud_dnspod_download_snapshot_operation.download_snapshot", "snapshot_id", "87910DFF"),
20+
resource.TestCheckResourceAttrSet("tencentcloud_dnspod_download_snapshot_operation.download_snapshot", "cos_url"),
21+
),
22+
},
23+
},
24+
})
25+
}
26+
27+
const testAccDnspodDownloadSnapshotOperation = `
28+
resource "tencentcloud_dnspod_download_snapshot_operation" "download_snapshot" {
29+
domain = "iac-tf.cloud"
30+
snapshot_id = "87910DFF"
31+
}
32+
`
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
/*
2+
Provides a resource to create a dnspod modify_domain_owner
3+
4+
Example Usage
5+
6+
```hcl
7+
resource "tencentcloud_dnspod_modify_domain_owner_operation" "modify_domain_owner" {
8+
domain = "dnspod.cn"
9+
account = "xxxxxxxxx"
10+
domain_id = 123
11+
}
12+
```
13+
*/
14+
package tencentcloud
15+
16+
import (
17+
"log"
18+
19+
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
20+
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
21+
dnspod "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/dnspod/v20210323"
22+
"github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/internal/helper"
23+
)
24+
25+
func resourceTencentCloudDnspodModifyDomainOwnerOperation() *schema.Resource {
26+
return &schema.Resource{
27+
Create: resourceTencentCloudDnspodModifyDomainOwnerOperationCreate,
28+
Read: resourceTencentCloudDnspodModifyDomainOwnerOperationRead,
29+
Delete: resourceTencentCloudDnspodModifyDomainOwnerOperationDelete,
30+
Schema: map[string]*schema.Schema{
31+
"domain": {
32+
Required: true,
33+
ForceNew: true,
34+
Type: schema.TypeString,
35+
Description: "Domain.",
36+
},
37+
38+
"account": {
39+
Required: true,
40+
ForceNew: true,
41+
Type: schema.TypeString,
42+
Description: "The account to which the domain needs to be transferred, supporting Uin or email format.",
43+
},
44+
45+
"domain_id": {
46+
Optional: true,
47+
ForceNew: true,
48+
Type: schema.TypeInt,
49+
Description: "Domain ID. The parameter DomainId has a higher priority than the parameter Domain. If the parameter DomainId is passed, the parameter Domain will be ignored. You can find all Domains and DomainIds through the DescribeDomainList interface.",
50+
},
51+
},
52+
}
53+
}
54+
55+
func resourceTencentCloudDnspodModifyDomainOwnerOperationCreate(d *schema.ResourceData, meta interface{}) error {
56+
defer logElapsed("resource.tencentcloud_dnspod_modify_domain_owner_operation.create")()
57+
defer inconsistentCheck(d, meta)()
58+
59+
logId := getLogId(contextNil)
60+
61+
var (
62+
request = dnspod.NewModifyDomainOwnerRequest()
63+
domain string
64+
)
65+
if v, ok := d.GetOk("domain"); ok {
66+
domain = v.(string)
67+
request.Domain = helper.String(v.(string))
68+
}
69+
70+
if v, ok := d.GetOk("account"); ok {
71+
request.Account = helper.String(v.(string))
72+
}
73+
74+
if v, ok := d.GetOkExists("domain_id"); ok {
75+
request.DomainId = helper.IntUint64(v.(int))
76+
}
77+
78+
err := resource.Retry(writeRetryTimeout, func() *resource.RetryError {
79+
result, e := meta.(*TencentCloudClient).apiV3Conn.UseDnsPodClient().ModifyDomainOwner(request)
80+
if e != nil {
81+
return retryError(e)
82+
} else {
83+
log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n", logId, request.GetAction(), request.ToJsonString(), result.ToJsonString())
84+
}
85+
return nil
86+
})
87+
if err != nil {
88+
log.Printf("[CRITAL]%s operate dnspod modify_domain_owner failed, reason:%+v", logId, err)
89+
return err
90+
}
91+
92+
d.SetId(domain)
93+
94+
return resourceTencentCloudDnspodModifyDomainOwnerOperationRead(d, meta)
95+
}
96+
97+
func resourceTencentCloudDnspodModifyDomainOwnerOperationRead(d *schema.ResourceData, meta interface{}) error {
98+
defer logElapsed("resource.tencentcloud_dnspod_modify_domain_owner_operation.read")()
99+
defer inconsistentCheck(d, meta)()
100+
101+
return nil
102+
}
103+
104+
func resourceTencentCloudDnspodModifyDomainOwnerOperationDelete(d *schema.ResourceData, meta interface{}) error {
105+
defer logElapsed("resource.tencentcloud_dnspod_modify_domain_owner_operation.delete")()
106+
defer inconsistentCheck(d, meta)()
107+
108+
return nil
109+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package tencentcloud
2+
3+
import (
4+
"testing"
5+
6+
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
7+
)
8+
9+
func TestAccTencentCloudDnspodNeedFixModifyDomainOwnerResource_basic(t *testing.T) {
10+
t.Parallel()
11+
resource.Test(t, resource.TestCase{
12+
PreCheck: func() { testAccPreCheckCommon(t, ACCOUNT_TYPE_PREPAY) },
13+
Providers: testAccProviders,
14+
Steps: []resource.TestStep{
15+
{
16+
Config: testAccDnspodModifyDomainOwner,
17+
Check: resource.ComposeTestCheckFunc(
18+
resource.TestCheckResourceAttr("tencentcloud_dnspod_modify_domain_owner_operation.modify_domain_owner", "domain", "terraform.com"),
19+
resource.TestCheckResourceAttr("tencentcloud_dnspod_modify_domain_owner_operation.modify_domain_owner", "account", "xxxxxx"),
20+
// resource.TestCheckResourceAttr("tencentcloud_dnspod_modify_domain_owner_operation.modify_domain_owner", "domain_id", "123"),
21+
),
22+
},
23+
},
24+
})
25+
}
26+
27+
const testAccDnspodModifyDomainOwner = `
28+
29+
resource "tencentcloud_dnspod_modify_domain_owner_operation" "modify_domain_owner" {
30+
domain = "terraform.com"
31+
account = "xxxxxx"
32+
# domain_id = "123"
33+
}
34+
35+
`

0 commit comments

Comments
 (0)