Skip to content

Commit 95b5c07

Browse files
WeiMengXSWeiMengXS
andauthored
feat: dlc store location (#2262)
* feat: doc * feat: doc * feat: changelog --------- Co-authored-by: WeiMengXS <nickcchen@tencent.com>
1 parent 171a956 commit 95b5c07

File tree

11 files changed

+521
-22
lines changed

11 files changed

+521
-22
lines changed

.changelog/2262.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:enhancement
2+
tencentcloud_dlc_store_location_config: Support api `ModifyAdvancedStoreLocation` and `DescribeAdvancedStoreLocation`, replace `CreateStoreLocation` and `DescribeStoreLocation`
3+
```

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ require (
5454
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/dbbrain v1.0.652
5555
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/dc v1.0.633
5656
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/dcdb v1.0.673
57-
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/dlc v1.0.768
57+
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/dlc v1.0.777
5858
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/dnspod v1.0.765
5959
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/domain v1.0.414
6060
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/dts v1.0.628

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -890,6 +890,8 @@ github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/dcdb v1.0.673 h1:YyjGLj
890890
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/dcdb v1.0.673/go.mod h1:hXPMop1kJFqAvHj+7TyxxxXS/HGUP4SuKx5gGoAl0Zc=
891891
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/dlc v1.0.768 h1:iLKkurl27Znu0MjMpWK6miP+4L6E/tPflRzGv2dVDCU=
892892
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/dlc v1.0.768/go.mod h1:RAxl/gvd0vEXPlwESmyv7XgfKFKPKQkGksumwX4aLvU=
893+
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/dlc v1.0.777 h1:3fuNSFtYzAa7pR9/xhGiirOfZIwVTPRw0DKWi/Ar5bw=
894+
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/dlc v1.0.777/go.mod h1:Zr9BUBp00uOgu0zS43wT8wKZul08iQmZ3WjJ1St1ENc=
893895
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/dnspod v1.0.765 h1:46VxMLFcM3mWr+GdOHmMCXsQM8Mle7pOip1z2RWmubU=
894896
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/dnspod v1.0.765/go.mod h1:EYfCXcZvLWidtpSNYsR2pvrBCUmOza39kox80Ud6PZg=
895897
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/domain v1.0.414 h1:egwjvOEUKBaxsoRVn/YSEhp2E8qdh77Ous9A/wftDo0=

tencentcloud/resource_tc_dlc_store_location_config.go

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ Example Usage
55
66
```hcl
77
resource "tencentcloud_dlc_store_location_config" "store_location_config" {
8-
store_location = "cosn://cos-xxxxx-xxx/test/"
8+
store_location = "cosn://bucketname/"
9+
enable = 1
910
}
1011
```
1112
@@ -42,7 +43,13 @@ func resourceTencentCloudDlcStoreLocationConfig() *schema.Resource {
4243
"store_location": {
4344
Required: true,
4445
Type: schema.TypeString,
45-
Description: "Calculate the results of the COS path, such as: cosn: // bucketName/.",
46+
Description: "The calculation results are stored in the cos path, such as: cosn://bucketname/.",
47+
},
48+
49+
"enable": {
50+
Required: true,
51+
Type: schema.TypeInt,
52+
Description: "Whether to enable advanced settings: 0-no, 1-yes.",
4653
},
4754
},
4855
}
@@ -65,9 +72,7 @@ func resourceTencentCloudDlcStoreLocationConfigRead(d *schema.ResourceData, meta
6572

6673
service := DlcService{client: meta.(*TencentCloudClient).apiV3Conn}
6774

68-
storeLocationConfigId := d.Id()
69-
70-
storeLocationConfig, err := service.DescribeDlcStoreLocationConfigById(ctx, storeLocationConfigId)
75+
storeLocationConfig, err := service.DescribeDlcStoreLocationConfigById(ctx)
7176
if err != nil {
7277
return err
7378
}
@@ -82,6 +87,9 @@ func resourceTencentCloudDlcStoreLocationConfigRead(d *schema.ResourceData, meta
8287
_ = d.Set("store_location", storeLocationConfig.StoreLocation)
8388
}
8489

90+
if storeLocationConfig.Enable != nil {
91+
_ = d.Set("enable", storeLocationConfig.Enable)
92+
}
8593
return nil
8694
}
8795

@@ -91,18 +99,20 @@ func resourceTencentCloudDlcStoreLocationConfigUpdate(d *schema.ResourceData, me
9199

92100
logId := getLogId(contextNil)
93101

94-
request := dlc.NewCreateStoreLocationRequest()
102+
request := dlc.NewModifyAdvancedStoreLocationRequest()
95103

96-
var (
97-
storeLocationId string
98-
)
104+
var storeLocation string
99105
if v, ok := d.GetOk("store_location"); ok {
100-
storeLocationId = v.(string)
106+
storeLocation = v.(string)
101107
request.StoreLocation = helper.String(v.(string))
102108
}
103109

110+
if v, ok := d.GetOkExists("enable"); ok {
111+
request.Enable = helper.IntUint64(v.(int))
112+
}
113+
104114
err := resource.Retry(writeRetryTimeout, func() *resource.RetryError {
105-
result, e := meta.(*TencentCloudClient).apiV3Conn.UseDlcClient().CreateStoreLocation(request)
115+
result, e := meta.(*TencentCloudClient).apiV3Conn.UseDlcClient().ModifyAdvancedStoreLocation(request)
106116
if e != nil {
107117
return retryError(e)
108118
} else {
@@ -115,8 +125,7 @@ func resourceTencentCloudDlcStoreLocationConfigUpdate(d *schema.ResourceData, me
115125
return err
116126
}
117127

118-
d.SetId(storeLocationId)
119-
128+
d.SetId(storeLocation)
120129
return resourceTencentCloudDlcStoreLocationConfigRead(d, meta)
121130
}
122131

tencentcloud/resource_tc_dlc_store_location_config_test.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,15 @@ func TestAccTencentCloudDlcStoreLocationConfigResource_basic(t *testing.T) {
1717
{
1818
Config: testAccDlcStoreLocationConfig,
1919
Check: resource.ComposeTestCheckFunc(resource.TestCheckResourceAttrSet("tencentcloud_dlc_store_location_config.store_location_config", "id"),
20-
resource.TestCheckResourceAttr("tencentcloud_dlc_store_location_config.store_location_config", "store_location", "cosn://cos-lock-1308919341/test/")),
20+
resource.TestCheckResourceAttr("tencentcloud_dlc_store_location_config.store_location_config", "store_location", "cosn://cos-lock-1308919341/test/"),
21+
resource.TestCheckResourceAttr("tencentcloud_dlc_store_location_config.store_location_config", "enable", "1"),
22+
),
2123
},
2224
{
2325
Config: testAccDlcStoreLocationConfigUpdate,
2426
Check: resource.ComposeTestCheckFunc(resource.TestCheckResourceAttrSet("tencentcloud_dlc_store_location_config.store_location_config", "id"),
25-
resource.TestCheckResourceAttr("tencentcloud_dlc_store_location_config.store_location_config", "store_location", "cosn://cos-lock-1308919341/")),
27+
resource.TestCheckResourceAttr("tencentcloud_dlc_store_location_config.store_location_config", "store_location", "cosn://cos-lock-1308919341/"),
28+
resource.TestCheckResourceAttr("tencentcloud_dlc_store_location_config.store_location_config", "enable", "1")),
2629
},
2730
{
2831
ResourceName: "tencentcloud_dlc_store_location_config.store_location_config",
@@ -37,13 +40,15 @@ const testAccDlcStoreLocationConfig = `
3740
3841
resource "tencentcloud_dlc_store_location_config" "store_location_config" {
3942
store_location = "cosn://cos-lock-1308919341/test/"
43+
enable = 1
4044
}
4145
4246
`
4347
const testAccDlcStoreLocationConfigUpdate = `
4448
4549
resource "tencentcloud_dlc_store_location_config" "store_location_config" {
4650
store_location = "cosn://cos-lock-1308919341/"
51+
enable = 1
4752
}
4853
4954
`

tencentcloud/service_tencentcloud_dlc.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,10 +183,10 @@ func (me *DlcService) DescribeDlcCheckDataEngineImageCanBeRollbackByFilter(ctx c
183183
return
184184
}
185185

186-
func (me *DlcService) DescribeDlcStoreLocationConfigById(ctx context.Context, storeLocationId string) (storeLocationConfig *dlc.DescribeStoreLocationResponseParams, errRet error) {
186+
func (me *DlcService) DescribeDlcStoreLocationConfigById(ctx context.Context) (storeLocationConfig *dlc.DescribeAdvancedStoreLocationResponseParams, errRet error) {
187187
logId := getLogId(ctx)
188188

189-
request := dlc.NewDescribeStoreLocationRequest()
189+
request := dlc.NewDescribeAdvancedStoreLocationRequest()
190190

191191
defer func() {
192192
if errRet != nil {
@@ -196,13 +196,16 @@ func (me *DlcService) DescribeDlcStoreLocationConfigById(ctx context.Context, st
196196

197197
ratelimit.Check(request.GetAction())
198198

199-
response, err := me.client.UseDlcClient().DescribeStoreLocation(request)
199+
response, err := me.client.UseDlcClient().DescribeAdvancedStoreLocation(request)
200200
if err != nil {
201201
errRet = err
202202
return
203203
}
204204
log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n", logId, request.GetAction(), request.ToJsonString(), response.ToJsonString())
205205

206+
if response == nil || response.Response == nil {
207+
return
208+
}
206209
storeLocationConfig = response.Response
207210
return
208211
}

0 commit comments

Comments
 (0)