Skip to content

Commit fc9db93

Browse files
committed
feat: support bi
1 parent 7b8f8f5 commit fc9db93

18 files changed

+642
-277
lines changed

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ require (
3131
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/apigateway v1.0.763
3232
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/apm v1.0.624
3333
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/as v1.0.756
34+
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/bi v1.0.770
3435
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cam v1.0.760
3536
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cat v1.0.760
3637
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cbs v1.0.591
@@ -45,7 +46,7 @@ require (
4546
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/clb v1.0.693
4647
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cloudaudit v1.0.544
4748
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cls v1.0.711
48-
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.767
49+
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.770
4950
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cvm v1.0.624
5051
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cwp v1.0.762
5152
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cynosdb v1.0.692
@@ -289,7 +290,6 @@ require (
289290
github.com/subosito/gotenv v1.4.1 // indirect
290291
github.com/t-yuki/gocover-cobertura v0.0.0-20180217150009-aaee18c8195c // indirect
291292
github.com/tdakkota/asciicheck v0.2.0 // indirect
292-
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/bi v1.0.767 // indirect
293293
github.com/tetafro/godot v1.4.11 // indirect
294294
github.com/timakin/bodyclose v0.0.0-20221125081123-e39cf3fc478e // indirect
295295
github.com/timonwong/loggercheck v0.9.4 // indirect

go.sum

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -786,6 +786,8 @@ github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/as v1.0.756 h1:dx4aBdOW
786786
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/as v1.0.756/go.mod h1:lwWeh6aHg6GlttTMp+VIVtpZOtmpP6DQnnYWpyYW37Y=
787787
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/bi v1.0.767 h1:MItav3+Wqh2b/wfUNI2pNCugbSnEY1EA3/j2Olx6dfI=
788788
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/bi v1.0.767/go.mod h1:f6b4HjGgEVZBrnu1GTQVQydsKB7FpQH8oKBGSmoXK4w=
789+
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/bi v1.0.770 h1:5FWt9F+ajshQEEQFfbvTe+n5lJai0eHbEsGDqYmJu5o=
790+
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/bi v1.0.770/go.mod h1:zuWcAJVIXbHbOR7i6SKK0wNlvPLt5Su4ijOZGMJbUi8=
789791
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cam v1.0.760 h1:Ky9dRsTL2HXKWUrTFpQFZWQ1TrM+o+P35kczR7thalo=
790792
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cam v1.0.760/go.mod h1:AAfdrxknvUedvigxbbzKQLxN+1EG5NPbytpiqmfuFvU=
791793
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cat v1.0.760 h1:oGY4IigfIw0iQKh3/cOY29KBeEeFbvJft69e0beyfdI=
@@ -867,6 +869,8 @@ github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.763 h1:N+/G
867869
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.763/go.mod h1:7sCQWVkxcsR38nffDW057DRGk8mUjK1Ing/EFOK8s8Y=
868870
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.767 h1:LO+t7y656Z11tyx97d/8b2CyLV+OG2HJNZbjdY7JDd8=
869871
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.767/go.mod h1:r5r4xbfxSaeR04b166HGsBa/R4U3SueirEUpXGuw+Q0=
872+
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.770 h1:5Nl8q6VJxfgZt/ockI9jwTzJIghxkw+NaG8DANkOMyU=
873+
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.770/go.mod h1:r5r4xbfxSaeR04b166HGsBa/R4U3SueirEUpXGuw+Q0=
870874
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cvm v1.0.624 h1:nEZqsoqt1pEoaP9JjkHQy3/H00suCfzlHW1qOm2nYD8=
871875
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cvm v1.0.624/go.mod h1:+TXSVyeKwt1IhZRqKPbTREteBcP+K07Q846/ilNzLWA=
872876
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cwp v1.0.762 h1:2egy69SP/wPsmnfozcQVZ6tUY6F6N/TpEe/7xtXrc/8=
Lines changed: 244 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,244 @@
1+
/*
2+
Use this data source to query detailed information of bi user_project
3+
4+
Example Usage
5+
6+
```hcl
7+
data "tencentcloud_bi_user_project" "user_project" {
8+
project_id = 123
9+
all_page = true
10+
}
11+
```
12+
*/
13+
package tencentcloud
14+
15+
import (
16+
"context"
17+
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
18+
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
19+
bi "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/bi/v20220105"
20+
"github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/internal/helper"
21+
)
22+
23+
func dataSourceTencentCloudBiUserProject() *schema.Resource {
24+
return &schema.Resource{
25+
Read: dataSourceTencentCloudBiUserProjectRead,
26+
Schema: map[string]*schema.Schema{
27+
"project_id": {
28+
Optional: true,
29+
Type: schema.TypeInt,
30+
Description: "Project id.",
31+
},
32+
33+
"all_page": {
34+
Optional: true,
35+
Type: schema.TypeBool,
36+
Description: "Whether to display all, if true, ignore paging.",
37+
},
38+
39+
"list": {
40+
Type: schema.TypeList,
41+
Computed: true,
42+
Description: "Array(Note: This field may return null, indicating that no valid value can be obtained).",
43+
Elem: &schema.Resource{
44+
Schema: map[string]*schema.Schema{
45+
"user_id": {
46+
Type: schema.TypeString,
47+
Computed: true,
48+
Description: "User id.",
49+
},
50+
"user_name": {
51+
Type: schema.TypeString,
52+
Computed: true,
53+
Description: "Username.",
54+
},
55+
"corp_id": {
56+
Type: schema.TypeString,
57+
Computed: true,
58+
Description: "Enterprise id(Note: This field may return null, indicating that no valid value can be obtained).",
59+
},
60+
"email": {
61+
Type: schema.TypeString,
62+
Computed: true,
63+
Description: "E-mail(Note: This field may return null, indicating that no valid value can be obtained).",
64+
},
65+
"last_login": {
66+
Type: schema.TypeString,
67+
Computed: true,
68+
Description: "Last login time, public cloud unrelated fields(Note: This field may return null, indicating that no valid value can be obtained).",
69+
},
70+
"status": {
71+
Type: schema.TypeInt,
72+
Computed: true,
73+
Description: "Disabled state(Note: This field may return null, indicating that no valid value can be obtained).",
74+
},
75+
"first_modify": {
76+
Type: schema.TypeInt,
77+
Computed: true,
78+
Description: "First login to change password, public cloud unrelated fields(Note: This field may return null, indicating that no valid value can be obtained).",
79+
},
80+
"phone_number": {
81+
Type: schema.TypeString,
82+
Computed: true,
83+
Description: "Phone number(Note: This field may return null, indicating that no valid value can be obtained).",
84+
},
85+
"area_code": {
86+
Type: schema.TypeString,
87+
Computed: true,
88+
Description: "Mobile area code(Note: This field may return null, indicating that no valid value can be obtained).",
89+
},
90+
"created_user": {
91+
Type: schema.TypeString,
92+
Computed: true,
93+
Description: "Created by(Note: This field may return null, indicating that no valid value can be obtained).",
94+
},
95+
"created_at": {
96+
Type: schema.TypeString,
97+
Computed: true,
98+
Description: "Created at(Note: This field may return null, indicating that no valid value can be obtained).",
99+
},
100+
"updated_user": {
101+
Type: schema.TypeString,
102+
Computed: true,
103+
Description: "Updated by(Note: This field may return null, indicating that no valid value can be obtained).",
104+
},
105+
"updated_at": {
106+
Type: schema.TypeString,
107+
Computed: true,
108+
Description: "Updated at(Note: This field may return null, indicating that no valid value can be obtained).",
109+
},
110+
"global_user_name": {
111+
Type: schema.TypeString,
112+
Computed: true,
113+
Description: "Global role name(Note: This field may return null, indicating that no valid value can be obtained).",
114+
},
115+
"mobile": {
116+
Type: schema.TypeString,
117+
Computed: true,
118+
Description: "Mobile number, public cloud unrelated fields(Note: This field may return null, indicating that no valid value can be obtained).",
119+
},
120+
},
121+
},
122+
},
123+
124+
"result_output_file": {
125+
Type: schema.TypeString,
126+
Optional: true,
127+
Description: "Used to save results.",
128+
},
129+
},
130+
}
131+
}
132+
133+
func dataSourceTencentCloudBiUserProjectRead(d *schema.ResourceData, meta interface{}) error {
134+
defer logElapsed("data_source.tencentcloud_bi_user_project.read")()
135+
defer inconsistentCheck(d, meta)()
136+
137+
logId := getLogId(contextNil)
138+
139+
ctx := context.WithValue(context.TODO(), logIdKey, logId)
140+
141+
paramMap := make(map[string]interface{})
142+
if v, _ := d.GetOk("project_id"); v != nil {
143+
paramMap["ProjectId"] = helper.IntInt64(v.(int))
144+
}
145+
146+
if v, _ := d.GetOk("all_page"); v != nil {
147+
paramMap["AllPage"] = helper.Bool(v.(bool))
148+
}
149+
150+
service := BiService{client: meta.(*TencentCloudClient).apiV3Conn}
151+
152+
var data []*bi.UserIdAndUserName
153+
err := resource.Retry(readRetryTimeout, func() *resource.RetryError {
154+
result, e := service.DescribeBiUserProjectByFilter(ctx, paramMap)
155+
if e != nil {
156+
return retryError(e)
157+
}
158+
data = result
159+
return nil
160+
})
161+
if err != nil {
162+
return err
163+
}
164+
165+
ids := make([]string, 0, len(data))
166+
dataList := []interface{}{}
167+
if data != nil {
168+
for _, list := range data {
169+
listMap := map[string]interface{}{}
170+
171+
if list.UserId != nil {
172+
listMap["user_id"] = list.UserId
173+
}
174+
175+
if list.UserName != nil {
176+
listMap["user_name"] = list.UserName
177+
}
178+
179+
if list.CorpId != nil {
180+
listMap["corp_id"] = list.CorpId
181+
}
182+
183+
if list.Email != nil {
184+
listMap["email"] = list.Email
185+
}
186+
187+
if list.LastLogin != nil {
188+
listMap["last_login"] = list.LastLogin
189+
}
190+
191+
if list.Status != nil {
192+
listMap["status"] = list.Status
193+
}
194+
195+
if list.FirstModify != nil {
196+
listMap["first_modify"] = list.FirstModify
197+
}
198+
199+
if list.PhoneNumber != nil {
200+
listMap["phone_number"] = list.PhoneNumber
201+
}
202+
203+
if list.AreaCode != nil {
204+
listMap["area_code"] = list.AreaCode
205+
}
206+
207+
if list.CreatedUser != nil {
208+
listMap["created_user"] = list.CreatedUser
209+
}
210+
211+
if list.CreatedAt != nil {
212+
listMap["created_at"] = list.CreatedAt
213+
}
214+
215+
if list.UpdatedUser != nil {
216+
listMap["updated_user"] = list.UpdatedUser
217+
}
218+
219+
if list.UpdatedAt != nil {
220+
listMap["updated_at"] = list.UpdatedAt
221+
}
222+
223+
if list.GlobalUserName != nil {
224+
listMap["global_user_name"] = list.GlobalUserName
225+
}
226+
227+
if list.Mobile != nil {
228+
listMap["mobile"] = list.Mobile
229+
}
230+
231+
dataList = append(dataList, listMap)
232+
}
233+
_ = d.Set("list", dataList)
234+
}
235+
236+
d.SetId(helper.DataResourceIdsHash(ids))
237+
output, ok := d.GetOk("result_output_file")
238+
if ok && output.(string) != "" {
239+
if e := writeToFile(output.(string), dataList); e != nil {
240+
return e
241+
}
242+
}
243+
return nil
244+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
package tencentcloud
2+
3+
import (
4+
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
5+
"testing"
6+
)
7+
8+
// go test -test.run TestAccTencentCloudBiUserProjectDataSource_basic -v
9+
func TestAccTencentCloudBiUserProjectDataSource_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: testAccBiUserProjectDataSource,
19+
Check: resource.ComposeTestCheckFunc(
20+
testAccCheckTencentCloudDataSourceID("data.tencentcloud_bi_user_project.user_project"),
21+
resource.TestCheckResourceAttrSet("data.tencentcloud_bi_user_project.user_project", "list.#"),
22+
resource.TestCheckResourceAttrSet("data.tencentcloud_bi_user_project.user_project", "list.0.area_code"),
23+
resource.TestCheckResourceAttrSet("data.tencentcloud_bi_user_project.user_project", "list.0.corp_id"),
24+
resource.TestCheckResourceAttrSet("data.tencentcloud_bi_user_project.user_project", "list.0.created_at"),
25+
resource.TestCheckResourceAttrSet("data.tencentcloud_bi_user_project.user_project", "list.0.created_user"),
26+
resource.TestCheckResourceAttrSet("data.tencentcloud_bi_user_project.user_project", "list.0.first_modify"),
27+
resource.TestCheckResourceAttrSet("data.tencentcloud_bi_user_project.user_project", "list.0.global_user_name"),
28+
resource.TestCheckResourceAttrSet("data.tencentcloud_bi_user_project.user_project", "list.0.phone_number"),
29+
resource.TestCheckResourceAttrSet("data.tencentcloud_bi_user_project.user_project", "list.0.status"),
30+
resource.TestCheckResourceAttrSet("data.tencentcloud_bi_user_project.user_project", "list.0.updated_at"),
31+
resource.TestCheckResourceAttrSet("data.tencentcloud_bi_user_project.user_project", "list.0.updated_user"),
32+
resource.TestCheckResourceAttrSet("data.tencentcloud_bi_user_project.user_project", "list.0.user_id"),
33+
resource.TestCheckResourceAttrSet("data.tencentcloud_bi_user_project.user_project", "list.0.user_name"),
34+
),
35+
},
36+
},
37+
})
38+
}
39+
40+
const testAccBiUserProjectDataSource = `
41+
42+
data "tencentcloud_bi_user_project" "user_project" {
43+
project_id = 11015030
44+
all_page = true
45+
}
46+
47+
`

tencentcloud/provider.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1847,12 +1847,13 @@ Cwp
18471847
Business Intelligence(BI)
18481848
Data Source
18491849
tencentcloud_bi_project
1850+
tencentcloud_bi_user_project
18501851
18511852
Resource
18521853
tencentcloud_bi_project
18531854
tencentcloud_bi_user_role
18541855
tencentcloud_bi_project_user_role
1855-
tencentcloud_bi_datasource_cloud
1856+
tencentcloud_bi_datasource
18561857
tencentcloud_bi_embed_token
18571858
tencentcloud_bi_embed_interval
18581859
*/
@@ -2608,6 +2609,7 @@ func Provider() *schema.Provider {
26082609
"tencentcloud_pts_scenario_with_jobs": dataSourceTencentCloudPtsScenarioWithJobs(),
26092610
"tencentcloud_cam_list_attached_user_policy": dataSourceTencentCloudCamListAttachedUserPolicy(),
26102611
"tencentcloud_bi_project": dataSourceTencentCloudBiProject(),
2612+
"tencentcloud_bi_user_project": dataSourceTencentCloudBiUserProject(),
26112613
},
26122614

26132615
ResourcesMap: map[string]*schema.Resource{

0 commit comments

Comments
 (0)