Skip to content

Commit 6ee12bb

Browse files
committed
chore: use set for unordered collection
1 parent 7ff66ef commit 6ee12bb

23 files changed

+342
-104
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))

examples/environments/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
terraform {
33
required_providers {
44
bytebase = {
5-
version = "1.0.8"
5+
version = "1.0.9"
66
# For local development, please use "terraform.local/bytebase/bytebase" instead
77
source = "registry.terraform.io/bytebase/bytebase"
88
}

examples/groups/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
terraform {
22
required_providers {
33
bytebase = {
4-
version = "1.0.8"
4+
version = "1.0.9"
55
# For local development, please use "terraform.local/bytebase/bytebase" instead
66
source = "registry.terraform.io/bytebase/bytebase"
77
}

examples/instances/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
terraform {
33
required_providers {
44
bytebase = {
5-
version = "1.0.8"
5+
version = "1.0.9"
66
# For local development, please use "terraform.local/bytebase/bytebase" instead
77
source = "registry.terraform.io/bytebase/bytebase"
88
}

examples/policies/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
terraform {
22
required_providers {
33
bytebase = {
4-
version = "1.0.8"
4+
version = "1.0.9"
55
# For local development, please use "terraform.local/bytebase/bytebase" instead
66
source = "registry.terraform.io/bytebase/bytebase"
77
}

examples/projects/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
terraform {
33
required_providers {
44
bytebase = {
5-
version = "1.0.8"
5+
version = "1.0.9"
66
# For local development, please use "terraform.local/bytebase/bytebase" instead
77
source = "registry.terraform.io/bytebase/bytebase"
88
}

examples/settings/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
terraform {
22
required_providers {
33
bytebase = {
4-
version = "1.0.8"
4+
version = "1.0.9"
55
# For local development, please use "terraform.local/bytebase/bytebase" instead
66
source = "registry.terraform.io/bytebase/bytebase"
77
}

examples/setup/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
terraform {
22
required_providers {
33
bytebase = {
4-
version = "1.0.8"
4+
version = "1.0.9"
55
# For local development, please use "terraform.local/bytebase/bytebase" instead
66
source = "registry.terraform.io/bytebase/bytebase"
77
}

0 commit comments

Comments
 (0)