Skip to content

Commit ac3d0f3

Browse files
committed
add animated graphics template
1 parent c1b1acc commit ac3d0f3

File tree

5 files changed

+112
-48
lines changed

5 files changed

+112
-48
lines changed

tencentcloud/provider.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -951,6 +951,7 @@ Media Processing Service(MPS)
951951
tencentcloud_mps_image_sprite_template
952952
tencentcloud_mps_snapshot_by_timeoffset_template
953953
tencentcloud_mps_sample_snapshot_template
954+
tencentcloud_mps_animated_graphics_template
954955
955956
Cloud HDFS(CHDFS)
956957
Data Source
@@ -1711,6 +1712,7 @@ func Provider() terraform.ResourceProvider {
17111712
"tencentcloud_mps_image_sprite_template": resourceTencentCloudMpsImageSpriteTemplate(),
17121713
"tencentcloud_mps_snapshot_by_timeoffset_template": resourceTencentCloudMpsSnapshotByTimeoffsetTemplate(),
17131714
"tencentcloud_mps_sample_snapshot_template": resourceTencentCloudMpsSampleSnapshotTemplate(),
1715+
"tencentcloud_mps_animated_graphics_template": resourceTencentCloudMpsAnimatedGraphicsTemplate(),
17141716
"tencentcloud_cbs_disk_backup": resourceTencentCloudCbsDiskBackup(),
17151717
"tencentcloud_cbs_snapshot_share_permission": resourceTencentCloudCbsSnapshotSharePermission(),
17161718
"tencentcloud_cbs_disk_backup_rollback_operation": resourceTencentCloudCbsDiskBackupRollbackOperation(),

tencentcloud/resource_tc_mps_animated_graphics_template.go

Lines changed: 26 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,13 @@ Example Usage
55
66
```hcl
77
resource "tencentcloud_mps_animated_graphics_template" "animated_graphics_template" {
8-
fps = <nil>
9-
width = 0
10-
height = 0
8+
format = "gif"
9+
fps = 20
10+
height = 130
11+
name = "terraform-test"
12+
quality = 75
1113
resolution_adaptive = "open"
12-
format = "gif"
13-
quality =
14-
name = <nil>
15-
comment = <nil>
14+
width = 140
1615
}
1716
```
1817
@@ -28,7 +27,6 @@ package tencentcloud
2827

2928
import (
3029
"context"
31-
"fmt"
3230
"log"
3331

3432
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
@@ -232,74 +230,64 @@ func resourceTencentCloudMpsAnimatedGraphicsTemplateUpdate(d *schema.ResourceDat
232230

233231
request.Definition = helper.StrToUint64Point(definition)
234232

235-
immutableArgs := []string{"fps", "width", "height", "resolution_adaptive", "format", "quality", "name", "comment"}
233+
mutableArgs := []string{"fps", "width", "height", "resolution_adaptive", "format", "quality", "name", "comment"}
236234

237-
for _, v := range immutableArgs {
235+
needChange := false
236+
237+
for _, v := range mutableArgs {
238238
if d.HasChange(v) {
239-
return fmt.Errorf("argument `%s` cannot be changed", v)
239+
needChange = true
240+
break
240241
}
241242
}
242243

243-
if d.HasChange("fps") {
244+
if needChange {
245+
244246
if v, ok := d.GetOkExists("fps"); ok {
245247
request.Fps = helper.IntUint64(v.(int))
246248
}
247-
}
248249

249-
if d.HasChange("width") {
250250
if v, ok := d.GetOkExists("width"); ok {
251251
request.Width = helper.IntUint64(v.(int))
252252
}
253-
}
254253

255-
if d.HasChange("height") {
256254
if v, ok := d.GetOkExists("height"); ok {
257255
request.Height = helper.IntUint64(v.(int))
258256
}
259-
}
260257

261-
if d.HasChange("resolution_adaptive") {
262258
if v, ok := d.GetOk("resolution_adaptive"); ok {
263259
request.ResolutionAdaptive = helper.String(v.(string))
264260
}
265-
}
266261

267-
if d.HasChange("format") {
268262
if v, ok := d.GetOk("format"); ok {
269263
request.Format = helper.String(v.(string))
270264
}
271-
}
272265

273-
if d.HasChange("quality") {
274266
if v, ok := d.GetOkExists("quality"); ok {
275267
request.Quality = helper.Float64(v.(float64))
276268
}
277-
}
278269

279-
if d.HasChange("name") {
280270
if v, ok := d.GetOk("name"); ok {
281271
request.Name = helper.String(v.(string))
282272
}
283-
}
284273

285-
if d.HasChange("comment") {
286274
if v, ok := d.GetOk("comment"); ok {
287275
request.Comment = helper.String(v.(string))
288276
}
289-
}
290277

291-
err := resource.Retry(writeRetryTimeout, func() *resource.RetryError {
292-
result, e := meta.(*TencentCloudClient).apiV3Conn.UseMpsClient().ModifyAnimatedGraphicsTemplate(request)
293-
if e != nil {
294-
return retryError(e)
295-
} else {
296-
log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n", logId, request.GetAction(), request.ToJsonString(), result.ToJsonString())
278+
err := resource.Retry(writeRetryTimeout, func() *resource.RetryError {
279+
result, e := meta.(*TencentCloudClient).apiV3Conn.UseMpsClient().ModifyAnimatedGraphicsTemplate(request)
280+
if e != nil {
281+
return retryError(e)
282+
} else {
283+
log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n", logId, request.GetAction(), request.ToJsonString(), result.ToJsonString())
284+
}
285+
return nil
286+
})
287+
if err != nil {
288+
log.Printf("[CRITAL]%s update mps animatedGraphicsTemplate failed, reason:%+v", logId, err)
289+
return err
297290
}
298-
return nil
299-
})
300-
if err != nil {
301-
log.Printf("[CRITAL]%s update mps animatedGraphicsTemplate failed, reason:%+v", logId, err)
302-
return err
303291
}
304292

305293
return resourceTencentCloudMpsAnimatedGraphicsTemplateRead(d, meta)

tencentcloud/resource_tc_mps_animated_graphics_template_test.go

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,11 @@ func TestAccTencentCloudMpsAnimatedGraphicsTemplateResource_basic(t *testing.T)
1919
Check: resource.ComposeTestCheckFunc(resource.TestCheckResourceAttrSet("tencentcloud_mps_animated_graphics_template.animated_graphics_template", "id")),
2020
},
2121
{
22-
ResourceName: "tencentcloud_mps_animated_graphics_template.animated_graphics_template",
23-
ImportState: true,
24-
ImportStateVerify: true,
22+
Config: testAccMpsAnimatedGraphicsTemplateUpdate,
23+
Check: resource.ComposeTestCheckFunc(
24+
resource.TestCheckResourceAttrSet("tencentcloud_mps_animated_graphics_template.animated_graphics_template", "id"),
25+
resource.TestCheckResourceAttr("tencentcloud_mps_animated_graphics_template.animated_graphics_template", "name", "terraform-for-test"),
26+
),
2527
},
2628
},
2729
})
@@ -30,14 +32,27 @@ func TestAccTencentCloudMpsAnimatedGraphicsTemplateResource_basic(t *testing.T)
3032
const testAccMpsAnimatedGraphicsTemplate = `
3133
3234
resource "tencentcloud_mps_animated_graphics_template" "animated_graphics_template" {
33-
fps = <nil>
34-
width = 0
35-
height = 0
35+
format = "gif"
36+
fps = 20
37+
height = 130
38+
name = "terraform-test"
39+
quality = 75
3640
resolution_adaptive = "open"
37-
format = "gif"
38-
quality =
39-
name = <nil>
40-
comment = <nil>
41+
width = 140
42+
}
43+
44+
`
45+
46+
const testAccMpsAnimatedGraphicsTemplateUpdate = `
47+
48+
resource "tencentcloud_mps_animated_graphics_template" "animated_graphics_template" {
49+
format = "gif"
50+
fps = 20
51+
height = 130
52+
name = "terraform-for-test"
53+
quality = 75
54+
resolution_adaptive = "open"
55+
width = 140
4156
}
4257
4358
`
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
---
2+
subcategory: "Media Processing Service(MPS)"
3+
layout: "tencentcloud"
4+
page_title: "TencentCloud: tencentcloud_mps_animated_graphics_template"
5+
sidebar_current: "docs-tencentcloud-resource-mps_animated_graphics_template"
6+
description: |-
7+
Provides a resource to create a mps animated_graphics_template
8+
---
9+
10+
# tencentcloud_mps_animated_graphics_template
11+
12+
Provides a resource to create a mps animated_graphics_template
13+
14+
## Example Usage
15+
16+
```hcl
17+
resource "tencentcloud_mps_animated_graphics_template" "animated_graphics_template" {
18+
format = "gif"
19+
fps = 20
20+
height = 130
21+
name = "terraform-test"
22+
quality = 75
23+
resolution_adaptive = "open"
24+
width = 140
25+
}
26+
```
27+
28+
## Argument Reference
29+
30+
The following arguments are supported:
31+
32+
* `fps` - (Required, Int) Frame rate, value range: [1, 30], unit: Hz.
33+
* `comment` - (Optional, String) Template description information, length limit: 256 characters.
34+
* `format` - (Optional, String) Animation format, the values are gif and webp. Default is gif.
35+
* `height` - (Optional, Int) The maximum value of the animation height (or short side), value range: 0 and [128, 4096], unit: px.When Width and Height are both 0, the resolution is the same.When Width is 0 and Height is not 0, Width is scaled proportionally.When Width is not 0 and Height is 0, Height is scaled proportionally.When both Width and Height are not 0, the resolution is specified by the user.Default value: 0.
36+
* `name` - (Optional, String) Rotation diagram template name, length limit: 64 characters.
37+
* `quality` - (Optional, Float64) Image quality, value range: [1, 100], default value is 75.
38+
* `resolution_adaptive` - (Optional, String) Adaptive resolution, optional value:open: At this time, Width represents the long side of the video, Height represents the short side of the video.close: At this point, Width represents the width of the video, and Height represents the height of the video.Default value: open.
39+
* `width` - (Optional, Int) The maximum value of the animation width (or long side), value range: 0 and [128, 4096], unit: px.When Width and Height are both 0, the resolution is the same.When Width is 0 and Height is not 0, Width is scaled proportionally.When Width is not 0 and Height is 0, Height is scaled proportionally.When both Width and Height are not 0, the resolution is specified by the user.Default value: 0.
40+
41+
## Attributes Reference
42+
43+
In addition to all arguments above, the following attributes are exported:
44+
45+
* `id` - ID of the resource.
46+
47+
48+
49+
## Import
50+
51+
mps animated_graphics_template can be imported using the id, e.g.
52+
53+
```
54+
terraform import tencentcloud_mps_animated_graphics_template.animated_graphics_template animated_graphics_template_id
55+
```
56+

website/tencentcloud.erb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1428,6 +1428,9 @@
14281428
<li>
14291429
<a href="#">Resources</a>
14301430
<ul class="nav nav-auto-expand">
1431+
<li>
1432+
<a href="/docs/providers/tencentcloud/r/mps_animated_graphics_template.html">tencentcloud_mps_animated_graphics_template</a>
1433+
</li>
14311434
<li>
14321435
<a href="/docs/providers/tencentcloud/r/mps_image_sprite_template.html">tencentcloud_mps_image_sprite_template</a>
14331436
</li>

0 commit comments

Comments
 (0)