Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.0.8
1.0.9
2 changes: 2 additions & 0 deletions api/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ type Client interface {
ListDatabase(ctx context.Context, instanceID, filter string) (*v1pb.ListDatabasesResponse, error)
// UpdateDatabase patches the database.
UpdateDatabase(ctx context.Context, patch *v1pb.Database, updateMasks []string) (*v1pb.Database, error)
// BatchUpdateDatabases batch updates databases.
BatchUpdateDatabases(ctx context.Context, request *v1pb.BatchUpdateDatabasesRequest) (*v1pb.BatchUpdateDatabasesResponse, error)
// GetDatabaseCatalog gets the database catalog by the database full name.
GetDatabaseCatalog(ctx context.Context, databaseName string) (*v1pb.DatabaseCatalog, error)
// UpdateDatabaseCatalog patches the database catalog.
Expand Down
28 changes: 28 additions & 0 deletions client/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ import (
"fmt"
"net/http"
"net/url"
"strings"

v1pb "github.com/bytebase/bytebase/proto/generated-go/v1"
"google.golang.org/protobuf/encoding/protojson"
)

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

// BatchUpdateDatabases batch updates databases.
func (c *client) BatchUpdateDatabases(ctx context.Context, request *v1pb.BatchUpdateDatabasesRequest) (*v1pb.BatchUpdateDatabasesResponse, error) {
requestURL := fmt.Sprintf("%s/%s/instances/-/databases:batchUpdate", c.url, c.version)
payload, err := protojson.Marshal(request)
if err != nil {
return nil, err
}

req, err := http.NewRequestWithContext(ctx, "POST", requestURL, strings.NewReader(string(payload)))
if err != nil {
return nil, err
}

body, err := c.doRequest(req)
if err != nil {
return nil, err
}

var res v1pb.BatchUpdateDatabasesResponse
if err := ProtojsonUnmarshaler.Unmarshal(body, &res); err != nil {
return nil, err
}

return &res, nil
}

// GetDatabaseCatalog gets the database catalog by the database full name.
func (c *client) GetDatabaseCatalog(ctx context.Context, databaseName string) (*v1pb.DatabaseCatalog, error) {
body, err := c.getResource(ctx, fmt.Sprintf("%s/catalog", databaseName))
Expand Down
6 changes: 3 additions & 3 deletions docs/data-sources/database_catalog.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,23 @@ The database catalog data source.
### Read-Only

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

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

Read-Only:

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

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

Read-Only:

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

<a id="nestedobjatt--schemas--tables--columns"></a>
Expand Down
2 changes: 1 addition & 1 deletion docs/data-sources/instance.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ The instance data source.

### Read-Only

- `data_sources` (List of Object) (see [below for nested schema](#nestedatt--data_sources))
- `data_sources` (Set of Object) (see [below for nested schema](#nestedatt--data_sources))
- `engine` (String) The instance engine. Support MYSQL, POSTGRES, TIDB, SNOWFLAKE, CLICKHOUSE, MONGODB, SQLITE, REDIS, ORACLE, SPANNER, MSSQL, REDSHIFT, MARIADB, OCEANBASE.
- `engine_version` (String) The engine version.
- `environment` (String) The environment name for your instance in "environments/{resource id}" format.
Expand Down
2 changes: 1 addition & 1 deletion docs/data-sources/policy.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ The policy data source.

Optional:

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

<a id="nestedblock--masking_exception_policy--exceptions"></a>
### Nested Schema for `masking_exception_policy.exceptions`
Expand Down
2 changes: 1 addition & 1 deletion docs/data-sources/policy_list.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Read-Only:

Read-Only:

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

<a id="nestedobjatt--policies--masking_exception_policy--exceptions"></a>
### Nested Schema for `policies.masking_exception_policy.exceptions`
Expand Down
2 changes: 1 addition & 1 deletion docs/data-sources/project.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ The project data source.
- `allow_modify_statement` (Boolean) Allow modifying statement after issue is created.
- `auto_enable_backup` (Boolean) Whether to automatically enable backup.
- `auto_resolve_issue` (Boolean) Enable auto resolve issue.
- `databases` (List of Object) The databases in the project. (see [below for nested schema](#nestedatt--databases))
- `databases` (Set of Object) The databases in the project. (see [below for nested schema](#nestedatt--databases))
- `enforce_issue_title` (Boolean) Enforce issue title created by user instead of generated by Bytebase.
- `id` (String) The ID of this resource.
- `key` (String) The project key.
Expand Down
2 changes: 1 addition & 1 deletion docs/data-sources/project_list.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Read-Only:
- `allow_modify_statement` (Boolean)
- `auto_enable_backup` (Boolean)
- `auto_resolve_issue` (Boolean)
- `databases` (List of Object) (see [below for nested schema](#nestedobjatt--projects--databases))
- `databases` (Set of Object) (see [below for nested schema](#nestedobjatt--projects--databases))
- `enforce_issue_title` (Boolean)
- `key` (String)
- `members` (Set of Object) (see [below for nested schema](#nestedobjatt--projects--members))
Expand Down
6 changes: 3 additions & 3 deletions docs/data-sources/setting.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ The setting data source.
Optional:

- `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.
- `classifications` (Block List) (see [below for nested schema](#nestedblock--classification--classifications))
- `classifications` (Block Set) (see [below for nested schema](#nestedblock--classification--classifications))
- `id` (String) The classification unique uuid.
- `levels` (Block List) (see [below for nested schema](#nestedblock--classification--levels))
- `levels` (Block Set) (see [below for nested schema](#nestedblock--classification--levels))
- `title` (String) The classification title. Optional.

<a id="nestedblock--classification--classifications"></a>
Expand Down Expand Up @@ -126,7 +126,7 @@ Read-Only:

Read-Only:

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

<a id="nestedatt--external_approval_nodes--nodes"></a>
### Nested Schema for `external_approval_nodes.nodes`
Expand Down
6 changes: 3 additions & 3 deletions docs/resources/database_catalog.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ The database catalog resource.
### Required

- `database` (String) The database full name in instances/{instance}/databases/{database} format
- `schemas` (Block List, Min: 1) (see [below for nested schema](#nestedblock--schemas))
- `schemas` (Block Set, Min: 1) (see [below for nested schema](#nestedblock--schemas))

### Read-Only

Expand All @@ -29,7 +29,7 @@ The database catalog resource.

Required:

- `tables` (Block List, Min: 1) (see [below for nested schema](#nestedblock--schemas--tables))
- `tables` (Block Set, Min: 1) (see [below for nested schema](#nestedblock--schemas--tables))

Optional:

Expand All @@ -40,7 +40,7 @@ Optional:

Required:

- `columns` (Block List, Min: 1) (see [below for nested schema](#nestedblock--schemas--tables--columns))
- `columns` (Block Set, Min: 1) (see [below for nested schema](#nestedblock--schemas--tables--columns))
- `name` (String)

Optional:
Expand Down
2 changes: 1 addition & 1 deletion docs/resources/instance.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ The instance resource.

### Required

- `data_sources` (Block List, Min: 1) The connection for the instance. You can configure read-only or admin connection account here. (see [below for nested schema](#nestedblock--data_sources))
- `data_sources` (Block Set, Min: 1) The connection for the instance. You can configure read-only or admin connection account here. (see [below for nested schema](#nestedblock--data_sources))
- `engine` (String) The instance engine. Support MYSQL, POSTGRES, TIDB, SNOWFLAKE, CLICKHOUSE, MONGODB, SQLITE, REDIS, ORACLE, SPANNER, MSSQL, REDSHIFT, MARIADB, OCEANBASE.
- `environment` (String) The environment full name for the instance in environments/{environment id} format.
- `resource_id` (String) The instance unique resource id.
Expand Down
2 changes: 1 addition & 1 deletion docs/resources/policy.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ The policy resource.

Optional:

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

<a id="nestedblock--masking_exception_policy--exceptions"></a>
### Nested Schema for `masking_exception_policy.exceptions`
Expand Down
2 changes: 1 addition & 1 deletion docs/resources/project.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ The project resource.
- `allow_modify_statement` (Boolean) Allow modifying statement after issue is created.
- `auto_enable_backup` (Boolean) Whether to automatically enable backup.
- `auto_resolve_issue` (Boolean) Enable auto resolve issue.
- `databases` (Block List) The databases in the project. (see [below for nested schema](#nestedblock--databases))
- `databases` (Block Set) The databases in the project. (see [below for nested schema](#nestedblock--databases))
- `enforce_issue_title` (Boolean) Enforce issue title created by user instead of generated by Bytebase.
- `members` (Block Set) The members in the project. (see [below for nested schema](#nestedblock--members))
- `postgres_database_tenant_mode` (Boolean) Whether to enable the database tenant mode for PostgreSQL. If enabled, the issue will be created with the pre-appended "set role <db_owner>" statement.
Expand Down
6 changes: 3 additions & 3 deletions docs/resources/setting.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ Optional:
Optional:

- `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.
- `classifications` (Block List) (see [below for nested schema](#nestedblock--classification--classifications))
- `classifications` (Block Set) (see [below for nested schema](#nestedblock--classification--classifications))
- `id` (String) The classification unique uuid.
- `levels` (Block List) (see [below for nested schema](#nestedblock--classification--levels))
- `levels` (Block Set) (see [below for nested schema](#nestedblock--classification--levels))
- `title` (String) The classification title. Optional.

<a id="nestedblock--classification--classifications"></a>
Expand Down Expand Up @@ -123,7 +123,7 @@ Optional:

Required:

- `nodes` (Block List, Min: 1) (see [below for nested schema](#nestedblock--external_approval_nodes--nodes))
- `nodes` (Block Set, Min: 1) (see [below for nested schema](#nestedblock--external_approval_nodes--nodes))

<a id="nestedblock--external_approval_nodes--nodes"></a>
### Nested Schema for `external_approval_nodes.nodes`
Expand Down
2 changes: 1 addition & 1 deletion examples/environments/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
terraform {
required_providers {
bytebase = {
version = "1.0.8"
version = "1.0.9"
# For local development, please use "terraform.local/bytebase/bytebase" instead
source = "registry.terraform.io/bytebase/bytebase"
}
Expand Down
2 changes: 1 addition & 1 deletion examples/groups/main.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
terraform {
required_providers {
bytebase = {
version = "1.0.8"
version = "1.0.9"
# For local development, please use "terraform.local/bytebase/bytebase" instead
source = "registry.terraform.io/bytebase/bytebase"
}
Expand Down
2 changes: 1 addition & 1 deletion examples/instances/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
terraform {
required_providers {
bytebase = {
version = "1.0.8"
version = "1.0.9"
# For local development, please use "terraform.local/bytebase/bytebase" instead
source = "registry.terraform.io/bytebase/bytebase"
}
Expand Down
2 changes: 1 addition & 1 deletion examples/policies/main.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
terraform {
required_providers {
bytebase = {
version = "1.0.8"
version = "1.0.9"
# For local development, please use "terraform.local/bytebase/bytebase" instead
source = "registry.terraform.io/bytebase/bytebase"
}
Expand Down
2 changes: 1 addition & 1 deletion examples/projects/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
terraform {
required_providers {
bytebase = {
version = "1.0.8"
version = "1.0.9"
# For local development, please use "terraform.local/bytebase/bytebase" instead
source = "registry.terraform.io/bytebase/bytebase"
}
Expand Down
2 changes: 1 addition & 1 deletion examples/settings/main.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
terraform {
required_providers {
bytebase = {
version = "1.0.8"
version = "1.0.9"
# For local development, please use "terraform.local/bytebase/bytebase" instead
source = "registry.terraform.io/bytebase/bytebase"
}
Expand Down
2 changes: 1 addition & 1 deletion examples/setup/main.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
terraform {
required_providers {
bytebase = {
version = "1.0.8"
version = "1.0.9"
# For local development, please use "terraform.local/bytebase/bytebase" instead
source = "registry.terraform.io/bytebase/bytebase"
}
Expand Down
2 changes: 1 addition & 1 deletion examples/users/main.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
terraform {
required_providers {
bytebase = {
version = "1.0.8"
version = "1.0.9"
# For local development, please use "terraform.local/bytebase/bytebase" instead
source = "registry.terraform.io/bytebase/bytebase"
}
Expand Down
2 changes: 1 addition & 1 deletion examples/vcs/main.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
terraform {
required_providers {
bytebase = {
version = "1.0.8"
version = "1.0.9"
# For local development, please use "terraform.local/bytebase/bytebase" instead
source = "registry.terraform.io/bytebase/bytebase"
}
Expand Down
Loading