Skip to content

Commit 4a33fb2

Browse files
authored
fix: api update (#67)
* fix: api update * chore: reset change * fix: lint
1 parent ed15ccf commit 4a33fb2

File tree

13 files changed

+93
-61
lines changed

13 files changed

+93
-61
lines changed

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.0.8
1+
0.0.9

api/client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ type Client interface {
3636
// UndeleteInstance undeletes the instance.
3737
UndeleteInstance(ctx context.Context, instanceID string) (*InstanceMessage, error)
3838
// SyncInstanceSchema will trigger the schema sync for an instance.
39-
SyncInstanceSchema(ctx context.Context, instanceUID string) error
39+
SyncInstanceSchema(ctx context.Context, instanceID string) error
4040

4141
// Role
4242
// CreateRole creates the role in the instance.

api/database_role.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,18 @@ type RoleAttribute struct {
1313

1414
// Role is the API message for role.
1515
type Role struct {
16-
Name string `json:"name"`
17-
RoleName string `json:"roleName"`
18-
ConnectionLimit int `json:"connectionLimit"`
19-
ValidUntil *string `json:"validUntil"`
20-
Attribute *RoleAttribute `json:"attribute"`
16+
Name string `json:"name"`
17+
RoleName string `json:"roleName"`
18+
ConnectionLimit int `json:"connectionLimit"`
19+
ValidUntil *string `json:"validUntil"`
20+
Attribute *string `json:"attribute"`
2121
}
2222

2323
// RoleUpsert is the API message for upserting a new role.
2424
type RoleUpsert struct {
25-
RoleName string `json:"roleName"`
26-
Password *string `json:"password"`
27-
ConnectionLimit *int `json:"connectionLimit"`
28-
ValidUntil *string `json:"validUntil"`
29-
Attribute *RoleAttribute `json:"attribute"`
25+
RoleName string `json:"roleName"`
26+
Password *string `json:"password"`
27+
ConnectionLimit *int `json:"connectionLimit"`
28+
ValidUntil *string `json:"validUntil"`
29+
Attribute *string `json:"attribute"`
3030
}

client/instance.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,8 @@ func (c *client) UndeleteInstance(ctx context.Context, instanceID string) (*api.
152152
}
153153

154154
// SyncInstanceSchema will trigger the schema sync for an instance.
155-
func (c *client) SyncInstanceSchema(ctx context.Context, instanceUID string) error {
156-
payload := fmt.Sprintf(`{"data":{"type":"sqlSyncSchema","attributes":{"instanceId":%s}}}`, instanceUID)
157-
req, err := http.NewRequestWithContext(ctx, "POST", fmt.Sprintf("%s/api/sql/sync-schema", c.url), strings.NewReader(string(payload)))
155+
func (c *client) SyncInstanceSchema(ctx context.Context, instanceID string) error {
156+
req, err := http.NewRequestWithContext(ctx, "POST", fmt.Sprintf("%s/%s/instances/%s:sync", c.url, c.version, instanceID), nil)
158157

159158
if err != nil {
160159
return err

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 = "0.0.8"
5+
version = "0.0.9"
66
# For local development, please use "terraform.local/bytebase/bytebase" instead
77
source = "registry.terraform.io/bytebase/bytebase"
88
}

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 = "0.0.8"
5+
version = "0.0.9"
66
# For local development, please use "terraform.local/bytebase/bytebase" instead
77
source = "registry.terraform.io/bytebase/bytebase"
88
}

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 = "0.0.8"
5+
version = "0.0.9"
66
# For local development, please use "terraform.local/bytebase/bytebase" instead
77
source = "registry.terraform.io/bytebase/bytebase"
88
}

examples/roles/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 = "0.0.8"
4+
version = "0.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 = "0.0.8"
4+
version = "0.0.9"
55
# For local development, please use "terraform.local/bytebase/bytebase" instead
66
source = "registry.terraform.io/bytebase/bytebase"
77
}

provider/data_source_database_role_list.go

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -126,17 +126,7 @@ func dataSourceRoleListRead(ctx context.Context, d *schema.ResourceData, m inter
126126
role["name"] = roleName
127127
role["connection_limit"] = raw.ConnectionLimit
128128
role["valid_until"] = raw.ValidUntil
129-
130-
attribute := map[string]interface{}{
131-
"super_user": raw.Attribute.SuperUser,
132-
"no_inherit": raw.Attribute.NoInherit,
133-
"create_role": raw.Attribute.CreateRole,
134-
"create_db": raw.Attribute.CreateDB,
135-
"can_login": raw.Attribute.CanLogin,
136-
"replication": raw.Attribute.Replication,
137-
"bypass_rls": raw.Attribute.ByPassRLS,
138-
}
139-
role["attribute"] = []interface{}{attribute}
129+
role["attribute"] = []interface{}{convertStringToRoleAttribute(raw.Attribute)}
140130

141131
roles = append(roles, role)
142132
}

0 commit comments

Comments
 (0)