Skip to content

Commit cde741d

Browse files
authored
Feat/css support (#2265)
* feat: support backup stream * feat: support css * fix: modify go mod * fix: modify example * feat: add changelog * feat: add doc * fix: modify test
1 parent 8fac34c commit cde741d

File tree

82 files changed

+11501
-177
lines changed

Some content is hidden

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

82 files changed

+11501
-177
lines changed

.changelog/2265.txt

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
```release-note:new-data-source
2+
tencentcloud_css_backup_stream
3+
```
4+
5+
```release-note:new-data-source
6+
tencentcloud_css_monitor_report
7+
```
8+
9+
```release-note:new-data-source
10+
tencentcloud_css_pad_templates
11+
```
12+
13+
```release-note:new-data-source
14+
tencentcloud_css_pull_stream_task_status
15+
```
16+
17+
```release-note:new-data-source
18+
tencentcloud_css_stream_monitor_list
19+
```
20+
21+
```release-note:new-data-source
22+
tencentcloud_css_time_shift_record_detail
23+
```
24+
25+
```release-note:new-data-source
26+
tencentcloud_css_time_shift_stream_list
27+
```
28+
29+
```release-note:new-data-source
30+
tencentcloud_css_watermarks
31+
```
32+
33+
```release-note:new-data-source
34+
tencentcloud_css_xp2p_detail_info_list
35+
```
36+
37+
```release-note:new-resource
38+
tencentcloud_css_backup_stream
39+
```
40+
41+
```release-note:new-resource
42+
tencentcloud_css_callback_rule_attachment
43+
```
44+
45+
```release-note:new-resource
46+
tencentcloud_css_callback_template
47+
```
48+
49+
```release-note:new-resource
50+
tencentcloud_css_domain_referer
51+
```
52+
53+
```release-note:new-resource
54+
tencentcloud_css_enable_optimal_switching
55+
```
56+
57+
```release-note:new-resource
58+
tencentcloud_css_record_rule_attachment
59+
```
60+
61+
```release-note:new-resource
62+
tencentcloud_css_snapshot_rule_attachment
63+
```
64+
65+
```release-note:new-resource
66+
tencentcloud_css_snapshot_template
67+
```
68+
69+
```release-note:new-resource
70+
tencentcloud_css_pad_template
71+
```
72+
73+
```release-note:new-resource
74+
tencentcloud_css_pad_rule_attachment
75+
```
76+
77+
```release-note:new-resource
78+
tencentcloud_css_timeshift_template
79+
```
80+
81+
```release-note:new-resource
82+
tencentcloud_css_timeshift_rule_attachment
83+
```
84+
85+
```release-note:new-resource
86+
tencentcloud_css_stream_monitor
87+
```

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ require (
6464
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/gaap v1.0.771
6565
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/kms v1.0.563
6666
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/lighthouse v1.0.729
67-
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/live v1.0.756
67+
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/live v1.0.777
6868
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/mariadb v1.0.672
6969
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/mongodb v1.0.651
7070
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/monitor v1.0.764

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -910,6 +910,8 @@ github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/lighthouse v1.0.729 h1:
910910
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/lighthouse v1.0.729/go.mod h1:lLoyD7Z6OQQDFxDGGTe8wmirhUFZ36l5OaxzP75853Y=
911911
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/live v1.0.756 h1:uwlWCqnsEXlafj/SixOJyyJojgEsjxkGtVOFGRhKk5I=
912912
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/live v1.0.756/go.mod h1:MWQuFxqztpy6xLJ/XXuAxjBXcjpCLbyN42P3eub1yEs=
913+
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/live v1.0.777 h1:8nSy6GAXc4lHj7jpSimcM2eM1wE1r7PQJM9WVzY82+U=
914+
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/live v1.0.777/go.mod h1:Nsd3yEpXQqXrWbN3mJbrk+A2KcdxHVW5xIRFAyIvlAE=
913915
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/mariadb v1.0.672 h1:sR3MyM9RBw1PNRdWoBrtK+2M9Qbb0i6DfQSrvZ4/4os=
914916
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/mariadb v1.0.672/go.mod h1:o3rBKhtfIJfw4BG22M0CQVLQAc0WqIsbyRI/EW52Ka0=
915917
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/mongodb v1.0.651 h1:Ohb58H6gIlTcd73CF+goUlEdNJ2CYkYUHTYxV/M4UL4=
Lines changed: 203 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,203 @@
1+
/*
2+
Use this data source to query detailed information of css backup_stream
3+
4+
Example Usage
5+
6+
```hcl
7+
data "tencentcloud_css_backup_stream" "backup_stream" {
8+
stream_name = "live"
9+
}
10+
```
11+
*/
12+
package tencentcloud
13+
14+
import (
15+
"context"
16+
17+
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
18+
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
19+
css "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/live/v20180801"
20+
"github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/internal/helper"
21+
)
22+
23+
func dataSourceTencentCloudCssBackupStream() *schema.Resource {
24+
return &schema.Resource{
25+
Read: dataSourceTencentCloudCssBackupStreamRead,
26+
Schema: map[string]*schema.Schema{
27+
"stream_name": {
28+
Optional: true,
29+
Type: schema.TypeString,
30+
Description: "Stream id.",
31+
},
32+
33+
"stream_info_list": {
34+
Computed: true,
35+
Type: schema.TypeList,
36+
Description: "Backup stream group info.",
37+
Elem: &schema.Resource{
38+
Schema: map[string]*schema.Schema{
39+
"stream_name": {
40+
Type: schema.TypeString,
41+
Computed: true,
42+
Description: "Stream name.",
43+
},
44+
"backup_list": {
45+
Type: schema.TypeList,
46+
Computed: true,
47+
Description: "Backup stream info.",
48+
Elem: &schema.Resource{
49+
Schema: map[string]*schema.Schema{
50+
"domain_name": {
51+
Type: schema.TypeString,
52+
Computed: true,
53+
Description: "Push domain.",
54+
},
55+
"app_name": {
56+
Type: schema.TypeString,
57+
Computed: true,
58+
Description: "Push path.",
59+
},
60+
"publish_time": {
61+
Type: schema.TypeString,
62+
Computed: true,
63+
Description: "UTC time, eg, 2018-06-29T19:00:00Z.",
64+
},
65+
"upstream_sequence": {
66+
Type: schema.TypeString,
67+
Computed: true,
68+
Description: "Push stream sequence.",
69+
},
70+
"source_from": {
71+
Type: schema.TypeString,
72+
Computed: true,
73+
Description: "Source from.",
74+
},
75+
"master_flag": {
76+
Type: schema.TypeInt,
77+
Computed: true,
78+
Description: "Master stream flag.",
79+
},
80+
},
81+
},
82+
},
83+
"optimal_enable": {
84+
Type: schema.TypeInt,
85+
Computed: true,
86+
Description: "Optimal switch, 1-enable, 0-disable.",
87+
},
88+
"host_group_name": {
89+
Type: schema.TypeString,
90+
Computed: true,
91+
Description: "Group name.",
92+
},
93+
},
94+
},
95+
},
96+
97+
"result_output_file": {
98+
Type: schema.TypeString,
99+
Optional: true,
100+
Description: "Used to save results.",
101+
},
102+
},
103+
}
104+
}
105+
106+
func dataSourceTencentCloudCssBackupStreamRead(d *schema.ResourceData, meta interface{}) error {
107+
defer logElapsed("data_source.tencentcloud_css_backup_stream.read")()
108+
defer inconsistentCheck(d, meta)()
109+
110+
logId := getLogId(contextNil)
111+
112+
ctx := context.WithValue(context.TODO(), logIdKey, logId)
113+
114+
paramMap := make(map[string]interface{})
115+
if v, ok := d.GetOk("stream_name"); ok {
116+
paramMap["StreamName"] = helper.String(v.(string))
117+
}
118+
119+
service := CssService{client: meta.(*TencentCloudClient).apiV3Conn}
120+
121+
var streamInfoList []*css.BackupStreamGroupInfo
122+
err := resource.Retry(readRetryTimeout, func() *resource.RetryError {
123+
result, e := service.DescribeCssBackupStreamByFilter(ctx, paramMap)
124+
if e != nil {
125+
return retryError(e)
126+
}
127+
streamInfoList = result
128+
return nil
129+
})
130+
if err != nil {
131+
return err
132+
}
133+
134+
ids := make([]string, 0, len(streamInfoList))
135+
tmpList := make([]map[string]interface{}, 0, len(streamInfoList))
136+
137+
if streamInfoList != nil {
138+
for _, backupStreamGroupInfo := range streamInfoList {
139+
backupStreamGroupInfoMap := map[string]interface{}{}
140+
141+
if backupStreamGroupInfo.StreamName != nil {
142+
backupStreamGroupInfoMap["stream_name"] = backupStreamGroupInfo.StreamName
143+
}
144+
145+
if backupStreamGroupInfo.BackupList != nil {
146+
backupListList := []interface{}{}
147+
for _, backupList := range backupStreamGroupInfo.BackupList {
148+
backupListMap := map[string]interface{}{}
149+
150+
if backupList.DomainName != nil {
151+
backupListMap["domain_name"] = backupList.DomainName
152+
}
153+
154+
if backupList.AppName != nil {
155+
backupListMap["app_name"] = backupList.AppName
156+
}
157+
158+
if backupList.PublishTime != nil {
159+
backupListMap["publish_time"] = backupList.PublishTime
160+
}
161+
162+
if backupList.UpstreamSequence != nil {
163+
backupListMap["upstream_sequence"] = backupList.UpstreamSequence
164+
}
165+
166+
if backupList.SourceFrom != nil {
167+
backupListMap["source_from"] = backupList.SourceFrom
168+
}
169+
170+
if backupList.MasterFlag != nil {
171+
backupListMap["master_flag"] = backupList.MasterFlag
172+
}
173+
174+
backupListList = append(backupListList, backupListMap)
175+
}
176+
177+
backupStreamGroupInfoMap["backup_list"] = backupListList
178+
}
179+
180+
if backupStreamGroupInfo.OptimalEnable != nil {
181+
backupStreamGroupInfoMap["optimal_enable"] = backupStreamGroupInfo.OptimalEnable
182+
}
183+
184+
if backupStreamGroupInfo.HostGroupName != nil {
185+
backupStreamGroupInfoMap["host_group_name"] = backupStreamGroupInfo.HostGroupName
186+
}
187+
188+
ids = append(ids, *backupStreamGroupInfo.StreamName)
189+
tmpList = append(tmpList, backupStreamGroupInfoMap)
190+
}
191+
192+
_ = d.Set("stream_info_list", tmpList)
193+
}
194+
195+
d.SetId(helper.DataResourceIdsHash(ids))
196+
output, ok := d.GetOk("result_output_file")
197+
if ok && output.(string) != "" {
198+
if e := writeToFile(output.(string), tmpList); e != nil {
199+
return e
200+
}
201+
}
202+
return nil
203+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package tencentcloud
2+
3+
import (
4+
"testing"
5+
6+
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
7+
)
8+
9+
func TestAccTencentCloudCssBackupStreamDataSource_basic(t *testing.T) {
10+
t.Parallel()
11+
resource.Test(t, resource.TestCase{
12+
PreCheck: func() {
13+
testAccPreCheck(t)
14+
},
15+
Providers: testAccProviders,
16+
Steps: []resource.TestStep{
17+
{
18+
Config: testAccCssBackupStreamDataSource,
19+
Check: resource.ComposeTestCheckFunc(testAccCheckTencentCloudDataSourceID("data.tencentcloud_css_backup_stream.backup_stream")),
20+
},
21+
},
22+
})
23+
}
24+
25+
const testAccCssBackupStreamDataSource = `
26+
27+
data "tencentcloud_css_backup_stream" "backup_stream" {
28+
stream_name = "live"
29+
}
30+
31+
`

0 commit comments

Comments
 (0)