Skip to content

Commit 4e6e80b

Browse files
authored
chore: support database catalog (#83)
* chore: support set roles for user in workspace level * fix: lint * fix: test * chore: support group * fix: test * fix: test * chore: update examples * chore: support database catalog * fix: lint
1 parent 0e0054c commit 4e6e80b

40 files changed

+783
-403
lines changed

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.0.5
1+
1.0.6

api/client.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ type Client interface {
5959
ListDatabase(ctx context.Context, instanceID, filter string) (*v1pb.ListDatabasesResponse, error)
6060
// UpdateDatabase patches the database.
6161
UpdateDatabase(ctx context.Context, patch *v1pb.Database, updateMasks []string) (*v1pb.Database, error)
62+
// GetDatabaseCatalog gets the database catalog by the database full name.
63+
GetDatabaseCatalog(ctx context.Context, databaseName string) (*v1pb.DatabaseCatalog, error)
64+
// UpdateDatabaseCatalog patches the database catalog.
65+
UpdateDatabaseCatalog(ctx context.Context, patch *v1pb.DatabaseCatalog, updateMasks []string) (*v1pb.DatabaseCatalog, error)
6266

6367
// Project
6468
// GetProject gets the project by project full name.

client/database.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,33 @@ func (c *client) UpdateDatabase(ctx context.Context, patch *v1pb.Database, updat
6363

6464
return &res, nil
6565
}
66+
67+
// GetDatabaseCatalog gets the database catalog by the database full name.
68+
func (c *client) GetDatabaseCatalog(ctx context.Context, databaseName string) (*v1pb.DatabaseCatalog, error) {
69+
body, err := c.getResource(ctx, fmt.Sprintf("%s/catalog", databaseName))
70+
if err != nil {
71+
return nil, err
72+
}
73+
74+
var res v1pb.DatabaseCatalog
75+
if err := ProtojsonUnmarshaler.Unmarshal(body, &res); err != nil {
76+
return nil, err
77+
}
78+
79+
return &res, nil
80+
}
81+
82+
// UpdateDatabaseCatalog patches the database catalog.
83+
func (c *client) UpdateDatabaseCatalog(ctx context.Context, patch *v1pb.DatabaseCatalog, updateMasks []string) (*v1pb.DatabaseCatalog, error) {
84+
body, err := c.updateResource(ctx, patch.Name, patch, updateMasks, false /* allow missing = false*/)
85+
if err != nil {
86+
return nil, err
87+
}
88+
89+
var res v1pb.DatabaseCatalog
90+
if err := ProtojsonUnmarshaler.Unmarshal(body, &res); err != nil {
91+
return nil, err
92+
}
93+
94+
return &res, nil
95+
}

docs/data-sources/database_catalog.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
---
2+
# generated by https://github.com/hashicorp/terraform-plugin-docs
3+
page_title: "bytebase_database_catalog Data Source - terraform-provider-bytebase"
4+
subcategory: ""
5+
description: |-
6+
The database catalog data source.
7+
---
8+
9+
# bytebase_database_catalog (Data Source)
10+
11+
The database catalog data source.
12+
13+
14+
15+
<!-- schema generated by tfplugindocs -->
16+
## Schema
17+
18+
### Required
19+
20+
- `database` (String) The database full name in instances/{instance}/databases/{database} format
21+
22+
### Read-Only
23+
24+
- `id` (String) The ID of this resource.
25+
- `schemas` (List of Object) (see [below for nested schema](#nestedatt--schemas))
26+
27+
<a id="nestedatt--schemas"></a>
28+
### Nested Schema for `schemas`
29+
30+
Read-Only:
31+
32+
- `name` (String)
33+
- `tables` (List of Object) (see [below for nested schema](#nestedobjatt--schemas--tables))
34+
35+
<a id="nestedobjatt--schemas--tables"></a>
36+
### Nested Schema for `schemas.tables`
37+
38+
Read-Only:
39+
40+
- `classification` (String)
41+
- `columns` (List of Object) (see [below for nested schema](#nestedobjatt--schemas--tables--columns))
42+
- `name` (String)
43+
44+
<a id="nestedobjatt--schemas--tables--columns"></a>
45+
### Nested Schema for `schemas.tables.columns`
46+
47+
Read-Only:
48+
49+
- `classification` (String)
50+
- `labels` (Map of String)
51+
- `name` (String)
52+
- `semantic_type` (String)
53+
54+

docs/data-sources/policy.md

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ The policy data source.
2222
### Optional
2323

2424
- `masking_exception_policy` (Block List, Max: 1) (see [below for nested schema](#nestedblock--masking_exception_policy))
25-
- `masking_policy` (Block List, Max: 1) (see [below for nested schema](#nestedblock--masking_policy))
2625
- `parent` (String) The policy parent name for the policy, support projects/{resource id}, environments/{resource id}, instances/{resource id}, or instances/{resource id}/databases/{database name}
2726

2827
### Read-Only
@@ -48,30 +47,8 @@ Optional:
4847
- `column` (String)
4948
- `database` (String) The database full name in instances/{instance resource id}/databases/{database name} format
5049
- `expire_timestamp` (String) The expiration timestamp in YYYY-MM-DDThh:mm:ss.000Z format
51-
- `masking_level` (String)
5250
- `member` (String) The member in user:{email} or group:{email} format.
5351
- `schema` (String)
5452
- `table` (String)
5553

5654

57-
58-
<a id="nestedblock--masking_policy"></a>
59-
### Nested Schema for `masking_policy`
60-
61-
Optional:
62-
63-
- `mask_data` (Block List) (see [below for nested schema](#nestedblock--masking_policy--mask_data))
64-
65-
<a id="nestedblock--masking_policy--mask_data"></a>
66-
### Nested Schema for `masking_policy.mask_data`
67-
68-
Optional:
69-
70-
- `column` (String)
71-
- `full_masking_algorithm_id` (String)
72-
- `masking_level` (String)
73-
- `partial_masking_algorithm_id` (String)
74-
- `schema` (String)
75-
- `table` (String)
76-
77-

docs/data-sources/policy_list.md

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ Read-Only:
3232
- `enforce` (Boolean)
3333
- `inherit_from_parent` (Boolean)
3434
- `masking_exception_policy` (List of Object) (see [below for nested schema](#nestedobjatt--policies--masking_exception_policy))
35-
- `masking_policy` (List of Object) (see [below for nested schema](#nestedobjatt--policies--masking_policy))
3635
- `name` (String)
3736
- `type` (String)
3837

@@ -52,30 +51,8 @@ Read-Only:
5251
- `column` (String)
5352
- `database` (String)
5453
- `expire_timestamp` (String)
55-
- `masking_level` (String)
5654
- `member` (String)
5755
- `schema` (String)
5856
- `table` (String)
5957

6058

61-
62-
<a id="nestedobjatt--policies--masking_policy"></a>
63-
### Nested Schema for `policies.masking_policy`
64-
65-
Read-Only:
66-
67-
- `mask_data` (List of Object) (see [below for nested schema](#nestedobjatt--policies--masking_policy--mask_data))
68-
69-
<a id="nestedobjatt--policies--masking_policy--mask_data"></a>
70-
### Nested Schema for `policies.masking_policy.mask_data`
71-
72-
Read-Only:
73-
74-
- `column` (String)
75-
- `full_masking_algorithm_id` (String)
76-
- `masking_level` (String)
77-
- `partial_masking_algorithm_id` (String)
78-
- `schema` (String)
79-
- `table` (String)
80-
81-

docs/data-sources/setting.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ The setting data source.
2121

2222
### Read-Only
2323

24-
- `approval_flow` (Block List) (see [below for nested schema](#nestedblock--approval_flow))
25-
- `external_approval_nodes` (Block List) (see [below for nested schema](#nestedblock--external_approval_nodes))
24+
- `approval_flow` (Block List) Configure risk level and approval flow for different tasks. Require ENTERPRISE subscription. (see [below for nested schema](#nestedblock--approval_flow))
25+
- `external_approval_nodes` (Block List) Configure external nodes in the approval flow. Require ENTERPRISE subscription. (see [below for nested schema](#nestedblock--external_approval_nodes))
2626
- `id` (String) The ID of this resource.
2727

2828
<a id="nestedblock--approval_flow"></a>

docs/resources/database_catalog.md

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
---
2+
# generated by https://github.com/hashicorp/terraform-plugin-docs
3+
page_title: "bytebase_database_catalog Resource - terraform-provider-bytebase"
4+
subcategory: ""
5+
description: |-
6+
The database catalog resource.
7+
---
8+
9+
# bytebase_database_catalog (Resource)
10+
11+
The database catalog resource.
12+
13+
14+
15+
<!-- schema generated by tfplugindocs -->
16+
## Schema
17+
18+
### Required
19+
20+
- `database` (String) The database full name in instances/{instance}/databases/{database} format
21+
- `schemas` (Block List, Min: 1) (see [below for nested schema](#nestedblock--schemas))
22+
23+
### Read-Only
24+
25+
- `id` (String) The ID of this resource.
26+
27+
<a id="nestedblock--schemas"></a>
28+
### Nested Schema for `schemas`
29+
30+
Required:
31+
32+
- `tables` (Block List, Min: 1) (see [below for nested schema](#nestedblock--schemas--tables))
33+
34+
Optional:
35+
36+
- `name` (String)
37+
38+
<a id="nestedblock--schemas--tables"></a>
39+
### Nested Schema for `schemas.tables`
40+
41+
Required:
42+
43+
- `columns` (Block List, Min: 1) (see [below for nested schema](#nestedblock--schemas--tables--columns))
44+
- `name` (String)
45+
46+
Optional:
47+
48+
- `classification` (String) The classification id
49+
50+
<a id="nestedblock--schemas--tables--columns"></a>
51+
### Nested Schema for `schemas.tables.columns`
52+
53+
Required:
54+
55+
- `name` (String)
56+
57+
Optional:
58+
59+
- `classification` (String) The classification id
60+
- `labels` (Map of String)
61+
- `semantic_type` (String) The semantic type id
62+
63+

docs/resources/environment.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ The environment resource.
1717

1818
### Required
1919

20-
- `environment_tier_policy` (String) If marked as PROTECTED, developers cannot execute any query on this environment's databases using SQL Editor by default.
20+
- `environment_tier_policy` (String) If marked as PROTECTED, developers cannot execute any query on this environment's databases using SQL Editor by default. Require ENTERPRISE subscription.
2121
- `order` (Number) The environment sorting order.
2222
- `resource_id` (String) The environment unique resource id.
2323
- `title` (String) The environment title.

docs/resources/group.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
page_title: "bytebase_group Resource - terraform-provider-bytebase"
44
subcategory: ""
55
description: |-
6-
The group resource.
6+
The group resource. Workspace domain is required for creating groups.
77
---
88

99
# bytebase_group (Resource)
1010

11-
The group resource.
11+
The group resource. Workspace domain is required for creating groups.
1212

1313

1414

0 commit comments

Comments
 (0)