Skip to content

Commit 0bb271d

Browse files
committed
add
1 parent 5fab45e commit 0bb271d

File tree

50 files changed

+21834
-1
lines changed

Some content is hidden

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

50 files changed

+21834
-1
lines changed

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ require (
107107

108108
require (
109109
github.com/hashicorp/go-uuid v1.0.3
110+
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/bh v1.3.7
110111
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/billing v1.1.31
111112
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cdc v1.0.1149
112113
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cdwdoris v1.0.993

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -829,6 +829,8 @@ github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/apm v1.2.2 h1:/BlN5LD/r
829829
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/apm v1.2.2/go.mod h1:XIggn8QQknIzb+1lnsOiKbTQ0fjRe1uV6P+1N0L2ccI=
830830
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/as v1.3.4 h1:hTOxj4qB+UX6MflqmIYT4cPbfEqtiJEfi9tR58DxkIw=
831831
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/as v1.3.4/go.mod h1:q7fZk23gy6BkZGcNw9NXFSj26R44tiJZKGxLFfOrMo0=
832+
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/bh v1.3.7 h1:EmqV7a3kxOzI+oPR9o8npRupCGfzgRRgIfF7KHAa1cs=
833+
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/bh v1.3.7/go.mod h1:jOm6mEGQbEzxX8hkRSoBfZRvCRqHtUG2jQ0gmyT8w68=
832834
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/bi v1.0.824 h1:DVKvZ6h+qd7tadUrCjVAkCCmE3TsbK2ZmwGd3AJcpWc=
833835
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/bi v1.0.824/go.mod h1:DvBpDX/qdJG4KKLeULmRvhAjPYiw8za0HeTSu2y/lFw=
834836
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/billing v1.1.31 h1:teA14cAcXuGxas6+5YANQ5KCoPaQBKIb2Q8+sk08Mu0=

tencentcloud/connectivity/client.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323
apigateway "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/apigateway/v20180808"
2424
apm "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/apm/v20210622"
2525
as "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/as/v20180419"
26+
bhv20230418 "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/bh/v20230418"
2627
bi "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/bi/v20220105"
2728
billing "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/billing/v20180709"
2829
cam "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cam/v20190116"
@@ -243,6 +244,7 @@ type TencentCloudClient struct {
243244
gwlbv20240906Conn *gwlb.Client
244245
billingv20180709Conn *billing.Client
245246
igtmv20231024Conn *igtmv20231024.Client
247+
bhv20230418Conn *bhv20230418.Client
246248
}
247249

248250
// NewClientProfile returns a new ClientProfile
@@ -1709,6 +1711,19 @@ func (me *TencentCloudClient) UseDasbClient() *dasb.Client {
17091711
return me.dasbConn
17101712
}
17111713

1714+
// UseBhV20230418Client return BH client for service
1715+
func (me *TencentCloudClient) UseBhV20230418Client() *bhv20230418.Client {
1716+
if me.bhv20230418Conn != nil {
1717+
return me.bhv20230418Conn
1718+
}
1719+
1720+
cpf := me.NewClientProfile(300)
1721+
me.bhv20230418Conn, _ = bhv20230418.NewClient(me.Credential, me.Region, cpf)
1722+
me.bhv20230418Conn.WithHttpTransport(&LogRoundTripper{})
1723+
1724+
return me.bhv20230418Conn
1725+
}
1726+
17121727
// UseTrocketClient returns trocket client for service
17131728
func (me *TencentCloudClient) UseTrocketClient() *trocket.Client {
17141729
if me.trocketConn != nil {

tencentcloud/provider.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1226,6 +1226,8 @@ func Provider() *schema.Provider {
12261226
"tencentcloud_cfw_nat_fw_switches": cfw.DataSourceTencentCloudCfwNatFwSwitches(),
12271227
"tencentcloud_cfw_vpc_fw_switches": cfw.DataSourceTencentCloudCfwVpcFwSwitches(),
12281228
"tencentcloud_cfw_edge_fw_switches": cfw.DataSourceTencentCloudCfwEdgeFwSwitches(),
1229+
"tencentcloud_bh_account_groups": bh.DataSourceTencentCloudBhAccountGroups(),
1230+
"tencentcloud_bh_source_types": bh.DataSourceTencentCloudBhSourceTypes(),
12291231
"tencentcloud_cwp_machines_simple": cwp.DataSourceTencentCloudCwpMachinesSimple(),
12301232
"tencentcloud_ses_receivers": ses.DataSourceTencentCloudSesReceivers(),
12311233
"tencentcloud_ses_send_tasks": ses.DataSourceTencentCloudSesSendTasks(),
@@ -2401,6 +2403,17 @@ func Provider() *schema.Provider {
24012403
"tencentcloud_cfw_vpc_firewall_switch": cfw.ResourceTencentCloudCfwVpcFirewallSwitch(),
24022404
"tencentcloud_cfw_edge_firewall_switch": cfw.ResourceTencentCloudCfwEdgeFirewallSwitch(),
24032405
"tencentcloud_sg_rule": cfw.ResourceTencentCloudSgRule(),
2406+
"tencentcloud_bh_access_white_list_rule": bh.ResourceTencentCloudBhAccessWhiteListRule(),
2407+
"tencentcloud_bh_access_white_list_config": bh.ResourceTencentCloudBhAccessWhiteListConfig(),
2408+
"tencentcloud_bh_device": bh.ResourceTencentCloudBhDevice(),
2409+
"tencentcloud_bh_asset_sync_job_operation": bh.ResourceTencentCloudBhAssetSyncJobOperation(),
2410+
"tencentcloud_bh_asset_sync_flag_config": bh.ResourceTencentCloudBhAssetSyncFlagConfig(),
2411+
"tencentcloud_bh_resource": bh.ResourceTencentCloudBhResource(),
2412+
"tencentcloud_bh_reconnection_setting_config": bh.ResourceTencentCloudBhReconnectionSettingConfig(),
2413+
"tencentcloud_bh_user": bh.ResourceTencentCloudBhUser(),
2414+
"tencentcloud_bh_user_group": bh.ResourceTencentCloudBhUserGroup(),
2415+
"tencentcloud_bh_user_directory": bh.ResourceTencentCloudBhUserDirectory(),
2416+
"tencentcloud_bh_user_sync_task_operation": bh.ResourceTencentCloudBhUserSyncTaskOperation(),
24042417
"tencentcloud_dasb_acl": bh.ResourceTencentCloudDasbAcl(),
24052418
"tencentcloud_dasb_cmd_template": bh.ResourceTencentCloudDasbCmdTemplate(),
24062419
"tencentcloud_dasb_device_group": bh.ResourceTencentCloudDasbDeviceGroup(),

tencentcloud/provider.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2341,7 +2341,21 @@ tencentcloud_cfw_edge_firewall_switch
23412341
tencentcloud_sg_rule
23422342

23432343
Bastion Host(BH)
2344-
Resource
2344+
Data Source
2345+
tencentcloud_bh_account_groups
2346+
tencentcloud_bh_source_types
2347+
Resource
2348+
tencentcloud_bh_access_white_list_rule
2349+
tencentcloud_bh_access_white_list_config
2350+
tencentcloud_bh_device
2351+
tencentcloud_bh_asset_sync_job_operation
2352+
tencentcloud_bh_asset_sync_flag_config
2353+
tencentcloud_bh_resource
2354+
tencentcloud_bh_reconnection_setting_config
2355+
tencentcloud_bh_user
2356+
tencentcloud_bh_user_group
2357+
tencentcloud_bh_user_directory
2358+
tencentcloud_bh_user_sync_task_operation
23452359
tencentcloud_dasb_resource
23462360
tencentcloud_dasb_acl
23472361
tencentcloud_dasb_cmd_template
Lines changed: 239 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,239 @@
1+
package bh
2+
3+
import (
4+
"context"
5+
6+
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
7+
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
8+
bhv20230418 "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/bh/v20230418"
9+
10+
tccommon "github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/common"
11+
"github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/internal/helper"
12+
)
13+
14+
func DataSourceTencentCloudBhAccountGroups() *schema.Resource {
15+
return &schema.Resource{
16+
Read: dataSourceTencentCloudBhAccountGroupsRead,
17+
Schema: map[string]*schema.Schema{
18+
"deep_in": {
19+
Type: schema.TypeInt,
20+
Optional: true,
21+
Description: "Whether to recursively query, 0 for non-recursive, 1 for recursive.",
22+
},
23+
24+
"parent_id": {
25+
Type: schema.TypeInt,
26+
Optional: true,
27+
Description: "Parent account group ID, default 0, query all groups under the root account group.",
28+
},
29+
30+
"group_name": {
31+
Type: schema.TypeString,
32+
Optional: true,
33+
Description: "Account group name, fuzzy query.",
34+
},
35+
36+
"page_num": {
37+
Type: schema.TypeInt,
38+
Optional: true,
39+
Description: "Get data from which page.",
40+
},
41+
42+
"account_group_set": {
43+
Type: schema.TypeList,
44+
Computed: true,
45+
Description: "Account group information.",
46+
Elem: &schema.Resource{
47+
Schema: map[string]*schema.Schema{
48+
"id": {
49+
Type: schema.TypeInt,
50+
Computed: true,
51+
Description: "Account group ID.",
52+
},
53+
"name": {
54+
Type: schema.TypeString,
55+
Computed: true,
56+
Description: "Account group name.",
57+
},
58+
"id_path": {
59+
Type: schema.TypeString,
60+
Computed: true,
61+
Description: "Account group ID path.",
62+
},
63+
"name_path": {
64+
Type: schema.TypeString,
65+
Computed: true,
66+
Description: "Account group name path.",
67+
},
68+
"parent_id": {
69+
Type: schema.TypeInt,
70+
Computed: true,
71+
Description: "Parent account group ID.",
72+
},
73+
"source": {
74+
Type: schema.TypeInt,
75+
Computed: true,
76+
Description: "Account group source.",
77+
},
78+
"user_total": {
79+
Type: schema.TypeInt,
80+
Computed: true,
81+
Description: "Total number of users under the account group.",
82+
},
83+
"is_leaf": {
84+
Type: schema.TypeBool,
85+
Computed: true,
86+
Description: "Whether it is a leaf node.",
87+
},
88+
"import_type": {
89+
Type: schema.TypeString,
90+
Computed: true,
91+
Description: "Account group import type.",
92+
},
93+
"description": {
94+
Type: schema.TypeString,
95+
Computed: true,
96+
Description: "Account group description.",
97+
},
98+
"parent_org_id": {
99+
Type: schema.TypeString,
100+
Computed: true,
101+
Description: "Parent source account organization ID. When using third-party import user sources, record the group ID of this group in the source organization structure.",
102+
},
103+
"org_id": {
104+
Type: schema.TypeString,
105+
Computed: true,
106+
Description: "Source account organization ID. When using third-party import user sources, record the group ID of this group in the source organization structure.",
107+
},
108+
"status": {
109+
Type: schema.TypeInt,
110+
Computed: true,
111+
Description: "Whether the account group has been connected, 0 means not connected, 1 means connected.",
112+
},
113+
},
114+
},
115+
},
116+
117+
"result_output_file": {
118+
Type: schema.TypeString,
119+
Optional: true,
120+
Description: "Used to save results.",
121+
},
122+
},
123+
}
124+
}
125+
126+
func dataSourceTencentCloudBhAccountGroupsRead(d *schema.ResourceData, meta interface{}) error {
127+
defer tccommon.LogElapsed("data_source.tencentcloud_bh_account_groups.read")()
128+
defer tccommon.InconsistentCheck(d, meta)()
129+
130+
var (
131+
logId = tccommon.GetLogId(nil)
132+
ctx = tccommon.NewResourceLifeCycleHandleFuncContext(context.Background(), logId, d, meta)
133+
service = BhService{client: meta.(tccommon.ProviderMeta).GetAPIV3Conn()}
134+
)
135+
136+
paramMap := make(map[string]interface{})
137+
if v, ok := d.GetOkExists("deep_in"); ok {
138+
paramMap["DeepIn"] = helper.IntInt64(v.(int))
139+
}
140+
141+
if v, ok := d.GetOkExists("parent_id"); ok {
142+
paramMap["ParentId"] = helper.IntInt64(v.(int))
143+
}
144+
145+
if v, ok := d.GetOk("group_name"); ok {
146+
paramMap["GroupName"] = helper.String(v.(string))
147+
}
148+
149+
if v, ok := d.GetOkExists("page_num"); ok {
150+
paramMap["PageNum"] = helper.IntInt64(v.(int))
151+
}
152+
153+
var respData []*bhv20230418.AccountGroup
154+
reqErr := resource.Retry(tccommon.ReadRetryTimeout, func() *resource.RetryError {
155+
result, e := service.DescribeBhAccountGroupsByFilter(ctx, paramMap)
156+
if e != nil {
157+
return tccommon.RetryError(e)
158+
}
159+
160+
respData = result
161+
return nil
162+
})
163+
164+
if reqErr != nil {
165+
return reqErr
166+
}
167+
168+
accountGroupSetList := make([]map[string]interface{}, 0, len(respData))
169+
if respData != nil {
170+
for _, accountGroupSet := range respData {
171+
accountGroupSetMap := map[string]interface{}{}
172+
if accountGroupSet.Id != nil {
173+
accountGroupSetMap["id"] = accountGroupSet.Id
174+
}
175+
176+
if accountGroupSet.Name != nil {
177+
accountGroupSetMap["name"] = accountGroupSet.Name
178+
}
179+
180+
if accountGroupSet.IdPath != nil {
181+
accountGroupSetMap["id_path"] = accountGroupSet.IdPath
182+
}
183+
184+
if accountGroupSet.NamePath != nil {
185+
accountGroupSetMap["name_path"] = accountGroupSet.NamePath
186+
}
187+
188+
if accountGroupSet.ParentId != nil {
189+
accountGroupSetMap["parent_id"] = accountGroupSet.ParentId
190+
}
191+
192+
if accountGroupSet.Source != nil {
193+
accountGroupSetMap["source"] = accountGroupSet.Source
194+
}
195+
196+
if accountGroupSet.UserTotal != nil {
197+
accountGroupSetMap["user_total"] = accountGroupSet.UserTotal
198+
}
199+
200+
if accountGroupSet.IsLeaf != nil {
201+
accountGroupSetMap["is_leaf"] = accountGroupSet.IsLeaf
202+
}
203+
204+
if accountGroupSet.ImportType != nil {
205+
accountGroupSetMap["import_type"] = accountGroupSet.ImportType
206+
}
207+
208+
if accountGroupSet.Description != nil {
209+
accountGroupSetMap["description"] = accountGroupSet.Description
210+
}
211+
212+
if accountGroupSet.ParentOrgId != nil {
213+
accountGroupSetMap["parent_org_id"] = accountGroupSet.ParentOrgId
214+
}
215+
216+
if accountGroupSet.OrgId != nil {
217+
accountGroupSetMap["org_id"] = accountGroupSet.OrgId
218+
}
219+
220+
if accountGroupSet.Status != nil {
221+
accountGroupSetMap["status"] = accountGroupSet.Status
222+
}
223+
224+
accountGroupSetList = append(accountGroupSetList, accountGroupSetMap)
225+
}
226+
227+
_ = d.Set("account_group_set", accountGroupSetList)
228+
}
229+
230+
d.SetId(helper.BuildToken())
231+
output, ok := d.GetOk("result_output_file")
232+
if ok && output.(string) != "" {
233+
if e := tccommon.WriteToFile(output.(string), accountGroupSetList); e != nil {
234+
return e
235+
}
236+
}
237+
238+
return nil
239+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Use this data source to query detailed information of BH account groups
2+
3+
Example Usage
4+
5+
```hcl
6+
data "tencentcloud_bh_account_groups" "example" {}
7+
```
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package bh_test
2+
3+
import (
4+
"testing"
5+
6+
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
7+
8+
tcacctest "github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/acctest"
9+
)
10+
11+
func TestAccTencentCloudBhAccountGroupsDataSource_basic(t *testing.T) {
12+
t.Parallel()
13+
resource.Test(t, resource.TestCase{
14+
PreCheck: func() {
15+
tcacctest.AccPreCheck(t)
16+
},
17+
Providers: tcacctest.AccProviders,
18+
Steps: []resource.TestStep{{
19+
Config: testAccBhAccountGroupsDataSource,
20+
Check: resource.ComposeTestCheckFunc(
21+
tcacctest.AccCheckTencentCloudDataSourceID("data.tencentcloud_bh_account_groups.example"),
22+
),
23+
}},
24+
})
25+
}
26+
27+
const testAccBhAccountGroupsDataSource = `
28+
data "tencentcloud_bh_account_groups" "example" {}
29+
`

0 commit comments

Comments
 (0)