Skip to content

Commit 07666d9

Browse files
committed
add
1 parent 87b8525 commit 07666d9

File tree

2 files changed

+88
-4
lines changed

2 files changed

+88
-4
lines changed

tencentcloud/services/cls/resource_tc_cls_cos_shipper.go

Lines changed: 84 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,26 @@ func ResourceTencentCloudClsCosShipper() *schema.Resource {
171171
},
172172
},
173173
},
174+
"filename_mode": {
175+
Type: schema.TypeInt,
176+
Optional: true,
177+
Description: "Naming a shipping file. Valid values: 0 (by random number); 1 (by shipping time). Default value: 0.",
178+
},
179+
"start_time": {
180+
Type: schema.TypeInt,
181+
Optional: true,
182+
Description: "Start time for data shipping, which cannot be earlier than the lifecycle start time of the log topic. If you do not specify this parameter, it will be set to the time when you create the data shipping task.",
183+
},
184+
"end_time": {
185+
Type: schema.TypeInt,
186+
Optional: true,
187+
Description: "End time for data shipping, which cannot be set to a future time. If you do not specify this parameter, it indicates continuous data shipping.",
188+
},
189+
"storage_type": {
190+
Type: schema.TypeString,
191+
Optional: true,
192+
Description: "COS bucket storage type. support: STANDARD_IA, ARCHIVE, DEEP_ARCHIVE, STANDARD, MAZ_STANDARD, MAZ_STANDARD_IA, INTELLIGENT_TIERING.",
193+
},
174194
},
175195
}
176196
}
@@ -201,11 +221,11 @@ func resourceTencentCloudClsCosShipperCreate(d *schema.ResourceData, meta interf
201221
request.ShipperName = helper.String(v.(string))
202222
}
203223

204-
if v, ok := d.GetOk("interval"); ok {
224+
if v, ok := d.GetOkExists("interval"); ok {
205225
request.Interval = helper.IntUint64(v.(int))
206226
}
207227

208-
if v, ok := d.GetOk("max_size"); ok {
228+
if v, ok := d.GetOkExists("max_size"); ok {
209229
request.MaxSize = helper.IntUint64(v.(int))
210230
}
211231

@@ -292,6 +312,21 @@ func resourceTencentCloudClsCosShipperCreate(d *schema.ResourceData, meta interf
292312
request.Content = contents[0]
293313
}
294314

315+
if v, ok := d.GetOkExists("filename_mode"); ok {
316+
request.FilenameMode = helper.IntUint64(v.(int))
317+
}
318+
319+
if v, ok := d.GetOkExists("start_time"); ok {
320+
request.StartTime = helper.IntInt64(v.(int))
321+
}
322+
if v, ok := d.GetOkExists("end_time"); ok {
323+
request.EndTime = helper.IntInt64(v.(int))
324+
}
325+
326+
if v, ok := d.GetOk("storage_type"); ok {
327+
request.StorageType = helper.String(v.(string))
328+
}
329+
295330
err := resource.Retry(tccommon.WriteRetryTimeout, func() *resource.RetryError {
296331
result, e := meta.(tccommon.ProviderMeta).GetAPIV3Conn().UseClsClient().CreateShipper(request)
297332
if e != nil {
@@ -300,6 +335,11 @@ func resourceTencentCloudClsCosShipperCreate(d *schema.ResourceData, meta interf
300335
log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n",
301336
logId, request.GetAction(), request.ToJsonString(), result.ToJsonString())
302337
}
338+
339+
if result == nil || result.Response == nil {
340+
return resource.NonRetryableError(fmt.Errorf("Create cls cos shipper failed, Reponse is nil."))
341+
}
342+
303343
response = result
304344
return nil
305345
})
@@ -309,6 +349,10 @@ func resourceTencentCloudClsCosShipperCreate(d *schema.ResourceData, meta interf
309349
return err
310350
}
311351

352+
if response.Response.ShipperId == nil {
353+
return fmt.Errorf("ShipperId is nil.")
354+
}
355+
312356
id := *response.Response.ShipperId
313357
d.SetId(id)
314358
return resourceTencentCloudClsCosShipperRead(d, meta)
@@ -393,6 +437,23 @@ func resourceTencentCloudClsCosShipperRead(d *schema.ResourceData, meta interfac
393437
}
394438
_ = d.Set("content", []interface{}{content})
395439
}
440+
441+
if shipper.FilenameMode != nil {
442+
_ = d.Set("filename_mode", shipper.FilenameMode)
443+
}
444+
445+
if shipper.StartTime != nil {
446+
_ = d.Set("start_time", shipper.StartTime)
447+
}
448+
449+
if shipper.EndTime != nil {
450+
_ = d.Set("end_time", shipper.EndTime)
451+
}
452+
453+
if shipper.StorageType != nil {
454+
_ = d.Set("storage_type", shipper.StorageType)
455+
}
456+
396457
return nil
397458
}
398459

@@ -401,6 +462,13 @@ func resourceTencentCloudClsCosShipperUpdate(d *schema.ResourceData, meta interf
401462
logId := tccommon.GetLogId(tccommon.ContextNil)
402463
request := cls.NewModifyShipperRequest()
403464

465+
immutableArgs := []string{"start_time", "end_time"}
466+
for _, v := range immutableArgs {
467+
if d.HasChange(v) {
468+
return fmt.Errorf("argument `%s` cannot be changed", v)
469+
}
470+
}
471+
404472
request.ShipperId = helper.String(d.Id())
405473

406474
if d.HasChange("bucket") {
@@ -422,13 +490,13 @@ func resourceTencentCloudClsCosShipperUpdate(d *schema.ResourceData, meta interf
422490
}
423491

424492
if d.HasChange("interval") {
425-
if v, ok := d.GetOk("interval"); ok {
493+
if v, ok := d.GetOkExists("interval"); ok {
426494
request.Interval = helper.IntUint64(v.(int))
427495
}
428496
}
429497

430498
if d.HasChange("max_size") {
431-
if v, ok := d.GetOk("max_size"); ok {
499+
if v, ok := d.GetOkExists("max_size"); ok {
432500
request.MaxSize = helper.IntUint64(v.(int))
433501
}
434502
}
@@ -524,6 +592,18 @@ func resourceTencentCloudClsCosShipperUpdate(d *schema.ResourceData, meta interf
524592
}
525593
}
526594

595+
if d.HasChange("filename_mode") {
596+
if v, ok := d.GetOkExists("filename_mode"); ok {
597+
request.FilenameMode = helper.IntUint64(v.(int))
598+
}
599+
}
600+
601+
if d.HasChange("storage_type") {
602+
if v, ok := d.GetOk("storage_type"); ok {
603+
request.StorageType = helper.String(v.(string))
604+
}
605+
}
606+
527607
err := resource.Retry(tccommon.WriteRetryTimeout, func() *resource.RetryError {
528608
result, e := meta.(tccommon.ProviderMeta).GetAPIV3Conn().UseClsClient().ModifyShipper(request)
529609
if e != nil {

website/docs/r/cls_cos_shipper.html.markdown

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,14 @@ The following arguments are supported:
5252
* `topic_id` - (Required, String) ID of the log topic to which the shipping rule to be created belongs.
5353
* `compress` - (Optional, List) Compression configuration of shipped log.
5454
* `content` - (Optional, List) Format configuration of shipped log content.
55+
* `end_time` - (Optional, Int) End time for data shipping, which cannot be set to a future time. If you do not specify this parameter, it indicates continuous data shipping.
56+
* `filename_mode` - (Optional, Int) Naming a shipping file. Valid values: 0 (by random number); 1 (by shipping time). Default value: 0.
5557
* `filter_rules` - (Optional, List) Filter rules for shipped logs. Only logs matching the rules can be shipped. All rules are in the AND relationship, and up to five rules can be added. If the array is empty, no filtering will be performed, and all logs will be shipped.
5658
* `interval` - (Optional, Int) Shipping time interval in seconds. Default value: 300. Value range: 300~900.
5759
* `max_size` - (Optional, Int) Maximum size of a file to be shipped, in MB. Default value: 256. Value range: 100~256.
5860
* `partition` - (Optional, String) Partition rule of shipped log, which can be represented in strftime time format.
61+
* `start_time` - (Optional, Int) Start time for data shipping, which cannot be earlier than the lifecycle start time of the log topic. If you do not specify this parameter, it will be set to the time when you create the data shipping task.
62+
* `storage_type` - (Optional, String) COS bucket storage type. support: STANDARD_IA, ARCHIVE, DEEP_ARCHIVE, STANDARD, MAZ_STANDARD, MAZ_STANDARD_IA, INTELLIGENT_TIERING.
5963

6064
The `compress` object supports the following:
6165

0 commit comments

Comments
 (0)