Skip to content

Commit 92e9bf1

Browse files
gitmknanonymous
andauthored
Feat/ci support (#1483)
* feat: support pic style * feat: support hot link * feat: support snapshot template * feat: support snapshot template * feat: support snapshot template * feat: transcode template * feat: transcode template * feat: support animation template * feat: support concat template * feat: support video process template * feat: support video montage template * feat: support voice separate template * feat: support super resolution template * feat: support pic process template * feat: support watermark template * feat: support tts template * feat: support transcode pro template * feat: support smart cover template * feat: support speech recognition * feat: support tts template * fix: merge master * feat: add changelog Co-authored-by: anonymous <anonymous@mail.org>
1 parent a5582e5 commit 92e9bf1

File tree

54 files changed

+10417
-3
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+10417
-3
lines changed

.changelog/1483.txt

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
```release-note:new-resource
2+
tencentcloud_ci_bucket_attachment
3+
```
4+
5+
```release-note:new-resource
6+
tencentcloud_ci_bucket_pic_style
7+
```
8+
9+
```release-note:new-resource
10+
tencentcloud_ci_hot_link
11+
```
12+
13+
```release-note:new-resource
14+
tencentcloud_ci_media_snapshot_template
15+
```
16+
17+
```release-note:new-resource
18+
tencentcloud_ci_media_transcode_template
19+
```
20+
21+
```release-note:new-resource
22+
tencentcloud_ci_media_animation_template
23+
```
24+
25+
```release-note:new-resource
26+
tencentcloud_ci_media_concat_template
27+
```
28+
29+
```release-note:new-resource
30+
tencentcloud_ci_media_video_process_template
31+
```
32+
33+
```release-note:new-resource
34+
tencentcloud_ci_media_video_montage_template
35+
```
36+
37+
```release-note:new-resource
38+
tencentcloud_ci_media_voice_separate_template
39+
```
40+
41+
```release-note:new-resource
42+
tencentcloud_ci_media_super_resolution_template
43+
```
44+
45+
```release-note:new-resource
46+
tencentcloud_ci_media_pic_process_template
47+
```
48+
49+
```release-note:new-resource
50+
tencentcloud_ci_media_watermark_template
51+
```
52+
53+
```release-note:new-resource
54+
tencentcloud_ci_media_tts_template
55+
```
56+
57+
```release-note:new-resource
58+
tencentcloud_ci_media_transcode_pro_template
59+
```
60+
61+
```release-note:new-resource
62+
tencentcloud_ci_media_smart_cover_template
63+
```
64+
65+
```release-note:new-resource
66+
tencentcloud_ci_media_speech_recognition_template
67+
```

tencentcloud/basic_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -873,3 +873,10 @@ const (
873873
)
874874

875875
// End of TEM
876+
877+
// CI
878+
const (
879+
defaultCiBucket = "terraform-ci-1308919341"
880+
)
881+
882+
// End of CI

tencentcloud/connectivity/client.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -978,6 +978,30 @@ func (me *TencentCloudClient) UseDtsClient() *dts.Client {
978978

979979
// UseCiClient returns ci client for service
980980
func (me *TencentCloudClient) UseCiClient(bucket string) *cos.Client {
981+
u, _ := url.Parse(fmt.Sprintf("https://%s.ci.%s.myqcloud.com", bucket, me.Region))
982+
983+
if me.ciConn != nil && me.ciConn.BaseURL.BucketURL == u {
984+
return me.ciConn
985+
}
986+
987+
baseUrl := &cos.BaseURL{
988+
CIURL: u,
989+
}
990+
991+
me.ciConn = cos.NewClient(baseUrl, &http.Client{
992+
Timeout: 100 * time.Second,
993+
Transport: &cos.AuthorizationTransport{
994+
SecretID: me.Credential.SecretId,
995+
SecretKey: me.Credential.SecretKey,
996+
SessionToken: me.Credential.Token,
997+
},
998+
})
999+
1000+
return me.ciConn
1001+
}
1002+
1003+
// UsePicClient returns pic client for service
1004+
func (me *TencentCloudClient) UsePicClient(bucket string) *cos.Client {
9811005
u, _ := url.Parse(fmt.Sprintf("https://%s.pic.%s.myqcloud.com", bucket, me.Region))
9821006

9831007
if me.ciConn != nil && me.ciConn.BaseURL.CIURL == u {

tencentcloud/provider.go

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -867,6 +867,22 @@ TDMQ for RocketMQ(trocket)
867867
Cloud Infinite(CI)
868868
Resource
869869
tencentcloud_ci_bucket_attachment
870+
tencentcloud_ci_bucket_pic_style
871+
tencentcloud_ci_hot_link
872+
tencentcloud_ci_media_snapshot_template
873+
tencentcloud_ci_media_transcode_template
874+
tencentcloud_ci_media_animation_template
875+
tencentcloud_ci_media_concat_template
876+
tencentcloud_ci_media_video_process_template
877+
tencentcloud_ci_media_video_montage_template
878+
tencentcloud_ci_media_voice_separate_template
879+
tencentcloud_ci_media_super_resolution_template
880+
tencentcloud_ci_media_pic_process_template
881+
tencentcloud_ci_media_watermark_template
882+
tencentcloud_ci_media_tts_template
883+
tencentcloud_ci_media_transcode_pro_template
884+
tencentcloud_ci_media_smart_cover_template
885+
tencentcloud_ci_media_speech_recognition_template
870886
871887
TDMQ for CMQ
872888
Data Source
@@ -1548,6 +1564,22 @@ func Provider() terraform.ResourceProvider {
15481564
"tencentcloud_tcmq_queue": resourceTencentCloudTcmqQueue(),
15491565
"tencentcloud_tcmq_topic": resourceTencentCloudTcmqTopic(),
15501566
"tencentcloud_tcmq_subscribe": resourceTencentCloudTcmqSubscribe(),
1567+
"tencentcloud_ci_bucket_pic_style": resourceTencentCloudCiBucketPicStyle(),
1568+
"tencentcloud_ci_hot_link": resourceTencentCloudCiHotLink(),
1569+
"tencentcloud_ci_media_snapshot_template": resourceTencentCloudCiMediaSnapshotTemplate(),
1570+
"tencentcloud_ci_media_transcode_template": resourceTencentCloudCiMediaTranscodeTemplate(),
1571+
"tencentcloud_ci_media_animation_template": resourceTencentCloudCiMediaAnimationTemplate(),
1572+
"tencentcloud_ci_media_concat_template": resourceTencentCloudCiMediaConcatTemplate(),
1573+
"tencentcloud_ci_media_video_process_template": resourceTencentCloudCiMediaVideoProcessTemplate(),
1574+
"tencentcloud_ci_media_video_montage_template": resourceTencentCloudCiMediaVideoMontageTemplate(),
1575+
"tencentcloud_ci_media_voice_separate_template": resourceTencentCloudCiMediaVoiceSeparateTemplate(),
1576+
"tencentcloud_ci_media_super_resolution_template": resourceTencentCloudCiMediaSuperResolutionTemplate(),
1577+
"tencentcloud_ci_media_pic_process_template": resourceTencentCloudCiMediaPicProcessTemplate(),
1578+
"tencentcloud_ci_media_watermark_template": resourceTencentCloudCiMediaWatermarkTemplate(),
1579+
"tencentcloud_ci_media_tts_template": resourceTencentCloudCiMediaTtsTemplate(),
1580+
"tencentcloud_ci_media_transcode_pro_template": resourceTencentCloudCiMediaTranscodeProTemplate(),
1581+
"tencentcloud_ci_media_smart_cover_template": resourceTencentCloudCiMediaSmartCoverTemplate(),
1582+
"tencentcloud_ci_media_speech_recognition_template": resourceTencentCloudCiMediaSpeechRecognitionTemplate(),
15511583
},
15521584

15531585
ConfigureFunc: providerConfigure,

tencentcloud/resource_tc_ci_bucket_attachment.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ func resourceTencentCloudCiBucketAttachmentCreate(d *schema.ResourceData, meta i
6868
return errors.New("get bucket failed!")
6969
}
7070

71-
ciClient := meta.(*TencentCloudClient).apiV3Conn.UseCiClient(bucket)
71+
ciClient := meta.(*TencentCloudClient).apiV3Conn.UsePicClient(bucket)
7272
err := resource.Retry(writeRetryTimeout, func() *resource.RetryError {
7373
result, e := ciClient.CI.OpenCIService(ctx)
7474
if e != nil {
Lines changed: 173 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,173 @@
1+
/*
2+
Provides a resource to create a ci bucket_pic_style
3+
4+
Example Usage
5+
6+
```hcl
7+
resource "tencentcloud_ci_bucket_pic_style" "bucket_pic_style" {
8+
bucket = "terraform-ci-xxxxxx"
9+
style_name = "rayscale_2"
10+
style_body = "imageMogr2/thumbnail/20x/crop/20x20/gravity/center/interlace/0/quality/100"
11+
}
12+
```
13+
14+
Import
15+
16+
ci bucket_pic_style can be imported using the bucket#styleName, e.g.
17+
18+
```
19+
terraform import tencentcloud_ci_bucket_pic_style.bucket_pic_style terraform-ci-xxxxxx#rayscale_2
20+
```
21+
*/
22+
package tencentcloud
23+
24+
import (
25+
"context"
26+
"fmt"
27+
"log"
28+
"strings"
29+
30+
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
31+
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
32+
"github.com/pkg/errors"
33+
ci "github.com/tencentyun/cos-go-sdk-v5"
34+
)
35+
36+
func resourceTencentCloudCiBucketPicStyle() *schema.Resource {
37+
return &schema.Resource{
38+
Create: resourceTencentCloudCiBucketPicStyleCreate,
39+
Read: resourceTencentCloudCiBucketPicStyleRead,
40+
Delete: resourceTencentCloudCiBucketPicStyleDelete,
41+
Importer: &schema.ResourceImporter{
42+
State: schema.ImportStatePassthrough,
43+
},
44+
Schema: map[string]*schema.Schema{
45+
"bucket": {
46+
Required: true,
47+
ForceNew: true,
48+
Type: schema.TypeString,
49+
ValidateFunc: validateCosBucketName,
50+
Description: "bucket name.",
51+
},
52+
"style_name": {
53+
Required: true,
54+
ForceNew: true,
55+
Type: schema.TypeString,
56+
Description: "style name, style names are case-sensitive, and a combination of uppercase and lowercase letters, numbers, and `$ + _ ( )` is supported.",
57+
},
58+
59+
"style_body": {
60+
Required: true,
61+
ForceNew: true,
62+
Type: schema.TypeString,
63+
Description: "style details, example: mageMogr2/grayscale/1.",
64+
},
65+
},
66+
}
67+
}
68+
69+
func resourceTencentCloudCiBucketPicStyleCreate(d *schema.ResourceData, meta interface{}) error {
70+
defer logElapsed("resource.tencentcloud_ci_bucket_pic_style.create")()
71+
defer inconsistentCheck(d, meta)()
72+
73+
logId := getLogId(contextNil)
74+
ctx := context.WithValue(context.TODO(), logIdKey, logId)
75+
76+
var (
77+
styleName string
78+
styleBody string
79+
bucket string
80+
)
81+
if v, ok := d.GetOk("bucket"); ok {
82+
bucket = v.(string)
83+
} else {
84+
return errors.New("get bucket failed!")
85+
}
86+
87+
if v, _ := d.GetOk("style_name"); v != nil {
88+
styleName = v.(string)
89+
}
90+
91+
if v, ok := d.GetOk("style_body"); ok {
92+
styleBody = v.(string)
93+
}
94+
95+
ciClient := meta.(*TencentCloudClient).apiV3Conn.UsePicClient(bucket)
96+
err := resource.Retry(writeRetryTimeout, func() *resource.RetryError {
97+
result, e := ciClient.CI.AddStyle(ctx, &ci.AddStyleOptions{
98+
StyleName: styleName,
99+
StyleBody: styleBody,
100+
})
101+
if e != nil {
102+
return retryError(e)
103+
} else {
104+
log.Printf("[DEBUG]%s api[%s] success, response status [%s]\n", logId, "AddStyle", result.Status)
105+
106+
}
107+
return nil
108+
})
109+
if err != nil {
110+
log.Printf("[CRITAL]%s create ci bucketPicStyle failed, reason:%+v", logId, err)
111+
return err
112+
}
113+
114+
d.SetId(bucket + FILED_SP + styleName)
115+
116+
return resourceTencentCloudCiBucketPicStyleRead(d, meta)
117+
}
118+
119+
func resourceTencentCloudCiBucketPicStyleRead(d *schema.ResourceData, meta interface{}) error {
120+
defer logElapsed("resource.tencentcloud_ci_bucket_pic_style.read")()
121+
defer inconsistentCheck(d, meta)()
122+
123+
logId := getLogId(contextNil)
124+
125+
ctx := context.WithValue(context.TODO(), logIdKey, logId)
126+
127+
service := CiService{client: meta.(*TencentCloudClient).apiV3Conn}
128+
129+
idSplit := strings.Split(d.Id(), FILED_SP)
130+
if len(idSplit) != 2 {
131+
return fmt.Errorf("id is broken,%s", d.Id())
132+
}
133+
bucket := idSplit[0]
134+
styleName := idSplit[1]
135+
136+
bucketPicStyle, err := service.DescribeCiBucketPicStyleById(ctx, bucket, styleName)
137+
if err != nil {
138+
return err
139+
}
140+
141+
if bucketPicStyle == nil {
142+
d.SetId("")
143+
return fmt.Errorf("resource `track` %s does not exist", d.Id())
144+
}
145+
146+
_ = d.Set("bucket", bucket)
147+
_ = d.Set("style_name", bucketPicStyle.StyleName)
148+
_ = d.Set("style_body", bucketPicStyle.StyleBody)
149+
150+
return nil
151+
}
152+
153+
func resourceTencentCloudCiBucketPicStyleDelete(d *schema.ResourceData, meta interface{}) error {
154+
defer logElapsed("resource.tencentcloud_ci_bucket_pic_style.delete")()
155+
defer inconsistentCheck(d, meta)()
156+
157+
logId := getLogId(contextNil)
158+
ctx := context.WithValue(context.TODO(), logIdKey, logId)
159+
160+
idSplit := strings.Split(d.Id(), FILED_SP)
161+
if len(idSplit) != 2 {
162+
return fmt.Errorf("id is broken,%s", d.Id())
163+
}
164+
bucket := idSplit[0]
165+
styleName := idSplit[1]
166+
167+
service := CiService{client: meta.(*TencentCloudClient).apiV3Conn}
168+
if err := service.DeleteCiBucketPicStyleById(ctx, bucket, styleName); err != nil {
169+
return err
170+
}
171+
172+
return nil
173+
}

0 commit comments

Comments
 (0)