Skip to content

Commit 859a90a

Browse files
authored
chore: use set for unordered collection (#86)
* chore: use set for unordered collection * chore: update doc
1 parent 7ff66ef commit 859a90a

35 files changed

+358
-124
lines changed

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.0.8
1+
1.0.9

api/client.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ 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+
// BatchUpdateDatabases batch updates databases.
63+
BatchUpdateDatabases(ctx context.Context, request *v1pb.BatchUpdateDatabasesRequest) (*v1pb.BatchUpdateDatabasesResponse, error)
6264
// GetDatabaseCatalog gets the database catalog by the database full name.
6365
GetDatabaseCatalog(ctx context.Context, databaseName string) (*v1pb.DatabaseCatalog, error)
6466
// UpdateDatabaseCatalog patches the database catalog.

client/database.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@ import (
55
"fmt"
66
"net/http"
77
"net/url"
8+
"strings"
89

910
v1pb "github.com/bytebase/bytebase/proto/generated-go/v1"
11+
"google.golang.org/protobuf/encoding/protojson"
1012
)
1113

1214
// GetDatabase gets the database by the database full name.
@@ -64,6 +66,32 @@ func (c *client) UpdateDatabase(ctx context.Context, patch *v1pb.Database, updat
6466
return &res, nil
6567
}
6668

69+
// BatchUpdateDatabases batch updates databases.
70+
func (c *client) BatchUpdateDatabases(ctx context.Context, request *v1pb.BatchUpdateDatabasesRequest) (*v1pb.BatchUpdateDatabasesResponse, error) {
71+
requestURL := fmt.Sprintf("%s/%s/instances/-/databases:batchUpdate", c.url, c.version)
72+
payload, err := protojson.Marshal(request)
73+
if err != nil {
74+
return nil, err
75+
}
76+
77+
req, err := http.NewRequestWithContext(ctx, "POST", requestURL, strings.NewReader(string(payload)))
78+
if err != nil {
79+
return nil, err
80+
}
81+
82+
body, err := c.doRequest(req)
83+
if err != nil {
84+
return nil, err
85+
}
86+
87+
var res v1pb.BatchUpdateDatabasesResponse
88+
if err := ProtojsonUnmarshaler.Unmarshal(body, &res); err != nil {
89+
return nil, err
90+
}
91+
92+
return &res, nil
93+
}
94+
6795
// GetDatabaseCatalog gets the database catalog by the database full name.
6896
func (c *client) GetDatabaseCatalog(ctx context.Context, databaseName string) (*v1pb.DatabaseCatalog, error) {
6997
body, err := c.getResource(ctx, fmt.Sprintf("%s/catalog", databaseName))

docs/data-sources/database_catalog.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,23 +22,23 @@ The database catalog data source.
2222
### Read-Only
2323

2424
- `id` (String) The ID of this resource.
25-
- `schemas` (List of Object) (see [below for nested schema](#nestedatt--schemas))
25+
- `schemas` (Set of Object) (see [below for nested schema](#nestedatt--schemas))
2626

2727
<a id="nestedatt--schemas"></a>
2828
### Nested Schema for `schemas`
2929

3030
Read-Only:
3131

3232
- `name` (String)
33-
- `tables` (List of Object) (see [below for nested schema](#nestedobjatt--schemas--tables))
33+
- `tables` (Set of Object) (see [below for nested schema](#nestedobjatt--schemas--tables))
3434

3535
<a id="nestedobjatt--schemas--tables"></a>
3636
### Nested Schema for `schemas.tables`
3737

3838
Read-Only:
3939

4040
- `classification` (String)
41-
- `columns` (List of Object) (see [below for nested schema](#nestedobjatt--schemas--tables--columns))
41+
- `columns` (Set of Object) (see [below for nested schema](#nestedobjatt--schemas--tables--columns))
4242
- `name` (String)
4343

4444
<a id="nestedobjatt--schemas--tables--columns"></a>

docs/data-sources/instance.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ The instance data source.
2121

2222
### Read-Only
2323

24-
- `data_sources` (List of Object) (see [below for nested schema](#nestedatt--data_sources))
24+
- `data_sources` (Set of Object) (see [below for nested schema](#nestedatt--data_sources))
2525
- `engine` (String) The instance engine. Support MYSQL, POSTGRES, TIDB, SNOWFLAKE, CLICKHOUSE, MONGODB, SQLITE, REDIS, ORACLE, SPANNER, MSSQL, REDSHIFT, MARIADB, OCEANBASE.
2626
- `engine_version` (String) The engine version.
2727
- `environment` (String) The environment name for your instance in "environments/{resource id}" format.

docs/data-sources/policy.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ The policy data source.
3636

3737
Optional:
3838

39-
- `exceptions` (Block List) (see [below for nested schema](#nestedblock--masking_exception_policy--exceptions))
39+
- `exceptions` (Block Set) (see [below for nested schema](#nestedblock--masking_exception_policy--exceptions))
4040

4141
<a id="nestedblock--masking_exception_policy--exceptions"></a>
4242
### Nested Schema for `masking_exception_policy.exceptions`

docs/data-sources/policy_list.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ Read-Only:
4040

4141
Read-Only:
4242

43-
- `exceptions` (List of Object) (see [below for nested schema](#nestedobjatt--policies--masking_exception_policy--exceptions))
43+
- `exceptions` (Set of Object) (see [below for nested schema](#nestedobjatt--policies--masking_exception_policy--exceptions))
4444

4545
<a id="nestedobjatt--policies--masking_exception_policy--exceptions"></a>
4646
### Nested Schema for `policies.masking_exception_policy.exceptions`

docs/data-sources/project.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ The project data source.
2424
- `allow_modify_statement` (Boolean) Allow modifying statement after issue is created.
2525
- `auto_enable_backup` (Boolean) Whether to automatically enable backup.
2626
- `auto_resolve_issue` (Boolean) Enable auto resolve issue.
27-
- `databases` (List of Object) The databases in the project. (see [below for nested schema](#nestedatt--databases))
27+
- `databases` (Set of Object) The databases in the project. (see [below for nested schema](#nestedatt--databases))
2828
- `enforce_issue_title` (Boolean) Enforce issue title created by user instead of generated by Bytebase.
2929
- `id` (String) The ID of this resource.
3030
- `key` (String) The project key.

docs/data-sources/project_list.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Read-Only:
3232
- `allow_modify_statement` (Boolean)
3333
- `auto_enable_backup` (Boolean)
3434
- `auto_resolve_issue` (Boolean)
35-
- `databases` (List of Object) (see [below for nested schema](#nestedobjatt--projects--databases))
35+
- `databases` (Set of Object) (see [below for nested schema](#nestedobjatt--projects--databases))
3636
- `enforce_issue_title` (Boolean)
3737
- `key` (String)
3838
- `members` (Set of Object) (see [below for nested schema](#nestedobjatt--projects--members))

docs/data-sources/setting.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ The setting data source.
3636
Optional:
3737

3838
- `classification_from_config` (Boolean) If true, we will only store the classification in the config. Otherwise we will get the classification from table/column comment, and write back to the schema metadata.
39-
- `classifications` (Block List) (see [below for nested schema](#nestedblock--classification--classifications))
39+
- `classifications` (Block Set) (see [below for nested schema](#nestedblock--classification--classifications))
4040
- `id` (String) The classification unique uuid.
41-
- `levels` (Block List) (see [below for nested schema](#nestedblock--classification--levels))
41+
- `levels` (Block Set) (see [below for nested schema](#nestedblock--classification--levels))
4242
- `title` (String) The classification title. Optional.
4343

4444
<a id="nestedblock--classification--classifications"></a>
@@ -126,7 +126,7 @@ Read-Only:
126126

127127
Read-Only:
128128

129-
- `nodes` (List of Object) (see [below for nested schema](#nestedatt--external_approval_nodes--nodes))
129+
- `nodes` (Set of Object) (see [below for nested schema](#nestedatt--external_approval_nodes--nodes))
130130

131131
<a id="nestedatt--external_approval_nodes--nodes"></a>
132132
### Nested Schema for `external_approval_nodes.nodes`

0 commit comments

Comments
 (0)