-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: support set roles for user in workspace level & support group (#…
…82) * chore: support set roles for user in workspace level * fix: lint * fix: test * chore: support group * fix: test * fix: test * chore: update examples
- Loading branch information
Showing
45 changed files
with
1,586 additions
and
328 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
1.0.4 | ||
1.0.5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
package client | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"net/http" | ||
"strings" | ||
|
||
v1pb "github.com/bytebase/bytebase/proto/generated-go/v1" | ||
"google.golang.org/protobuf/encoding/protojson" | ||
) | ||
|
||
// ListGroup list all groups. | ||
func (c *client) ListGroup(ctx context.Context) (*v1pb.ListGroupsResponse, error) { | ||
req, err := http.NewRequestWithContext(ctx, "GET", fmt.Sprintf("%s/%s/groups", c.url, c.version), nil) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
body, err := c.doRequest(req) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
var res v1pb.ListGroupsResponse | ||
if err := ProtojsonUnmarshaler.Unmarshal(body, &res); err != nil { | ||
return nil, err | ||
} | ||
|
||
return &res, nil | ||
} | ||
|
||
// CreateGroup creates the group. | ||
func (c *client) CreateGroup(ctx context.Context, email string, group *v1pb.Group) (*v1pb.Group, error) { | ||
payload, err := protojson.Marshal(group) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
req, err := http.NewRequestWithContext(ctx, "POST", fmt.Sprintf("%s/%s/groups?groupEmail=%s", c.url, c.version, email), strings.NewReader(string(payload))) | ||
|
||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
body, err := c.doRequest(req) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
var res v1pb.Group | ||
if err := ProtojsonUnmarshaler.Unmarshal(body, &res); err != nil { | ||
return nil, err | ||
} | ||
|
||
return &res, nil | ||
} | ||
|
||
// GetGroup gets the group by name. | ||
func (c *client) GetGroup(ctx context.Context, name string) (*v1pb.Group, error) { | ||
body, err := c.getResource(ctx, name) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
var res v1pb.Group | ||
if err := ProtojsonUnmarshaler.Unmarshal(body, &res); err != nil { | ||
return nil, err | ||
} | ||
|
||
return &res, nil | ||
} | ||
|
||
// UpdateGroup updates the group. | ||
func (c *client) UpdateGroup(ctx context.Context, patch *v1pb.Group, updateMasks []string) (*v1pb.Group, error) { | ||
body, err := c.updateResource(ctx, patch.Name, patch, updateMasks, false /* allow missing = false*/) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
var res v1pb.Group | ||
if err := ProtojsonUnmarshaler.Unmarshal(body, &res); err != nil { | ||
return nil, err | ||
} | ||
|
||
return &res, nil | ||
} | ||
|
||
// DeleteGroup deletes the group by name. | ||
func (c *client) DeleteGroup(ctx context.Context, name string) error { | ||
return c.deleteResource(ctx, name) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package client | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"net/http" | ||
"strings" | ||
|
||
v1pb "github.com/bytebase/bytebase/proto/generated-go/v1" | ||
"google.golang.org/protobuf/encoding/protojson" | ||
) | ||
|
||
// GetWorkspaceIAMPolicy gets the workspace IAM policy. | ||
func (c *client) GetWorkspaceIAMPolicy(ctx context.Context) (*v1pb.IamPolicy, error) { | ||
body, err := c.getResource(ctx, "workspaces/-:getIamPolicy") | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
var res v1pb.IamPolicy | ||
if err := ProtojsonUnmarshaler.Unmarshal(body, &res); err != nil { | ||
return nil, err | ||
} | ||
|
||
return &res, nil | ||
} | ||
|
||
// SetWorkspaceIAMPolicy sets the workspace IAM policy. | ||
func (c *client) SetWorkspaceIAMPolicy(ctx context.Context, setIamPolicyRequest *v1pb.SetIamPolicyRequest) (*v1pb.IamPolicy, error) { | ||
payload, err := protojson.Marshal(setIamPolicyRequest) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
req, err := http.NewRequestWithContext(ctx, "POST", fmt.Sprintf("%s/%s/%s:setIamPolicy", c.url, c.version, "workspaces/-"), strings.NewReader(string(payload))) | ||
|
||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
body, err := c.doRequest(req) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
var res v1pb.IamPolicy | ||
if err := ProtojsonUnmarshaler.Unmarshal(body, &res); err != nil { | ||
return nil, err | ||
} | ||
|
||
return &res, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
--- | ||
# generated by https://github.com/hashicorp/terraform-plugin-docs | ||
page_title: "bytebase_group Data Source - terraform-provider-bytebase" | ||
subcategory: "" | ||
description: |- | ||
The group data source. | ||
--- | ||
|
||
# bytebase_group (Data Source) | ||
|
||
The group data source. | ||
|
||
|
||
|
||
<!-- schema generated by tfplugindocs --> | ||
## Schema | ||
|
||
### Required | ||
|
||
- `name` (String) The group name in groups/{email} format. | ||
|
||
### Read-Only | ||
|
||
- `create_time` (String) The group create time in YYYY-MM-DDThh:mm:ss.000Z format | ||
- `creator` (String) The group creator in users/{email} format. | ||
- `description` (String) The group description. | ||
- `id` (String) The ID of this resource. | ||
- `members` (Set of Object) The members in the group. (see [below for nested schema](#nestedatt--members)) | ||
- `source` (String) Source means where the group comes from. For now we support Entra ID SCIM sync, so the source could be Entra ID. | ||
- `title` (String) The group title. | ||
|
||
<a id="nestedatt--members"></a> | ||
### Nested Schema for `members` | ||
|
||
Read-Only: | ||
|
||
- `member` (String) | ||
- `role` (String) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
--- | ||
# generated by https://github.com/hashicorp/terraform-plugin-docs | ||
page_title: "bytebase_group_list Data Source - terraform-provider-bytebase" | ||
subcategory: "" | ||
description: |- | ||
The group data source list. | ||
--- | ||
|
||
# bytebase_group_list (Data Source) | ||
|
||
The group data source list. | ||
|
||
|
||
|
||
<!-- schema generated by tfplugindocs --> | ||
## Schema | ||
|
||
### Read-Only | ||
|
||
- `groups` (List of Object) (see [below for nested schema](#nestedatt--groups)) | ||
- `id` (String) The ID of this resource. | ||
|
||
<a id="nestedatt--groups"></a> | ||
### Nested Schema for `groups` | ||
|
||
Read-Only: | ||
|
||
- `create_time` (String) | ||
- `creator` (String) | ||
- `description` (String) | ||
- `members` (Set of Object) (see [below for nested schema](#nestedobjatt--groups--members)) | ||
- `name` (String) | ||
- `source` (String) | ||
- `title` (String) | ||
|
||
<a id="nestedobjatt--groups--members"></a> | ||
### Nested Schema for `groups.members` | ||
|
||
Read-Only: | ||
|
||
- `member` (String) | ||
- `role` (String) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
--- | ||
# generated by https://github.com/hashicorp/terraform-plugin-docs | ||
page_title: "bytebase_group Resource - terraform-provider-bytebase" | ||
subcategory: "" | ||
description: |- | ||
The group resource. | ||
--- | ||
|
||
# bytebase_group (Resource) | ||
|
||
The group resource. | ||
|
||
|
||
|
||
<!-- schema generated by tfplugindocs --> | ||
## Schema | ||
|
||
### Required | ||
|
||
- `email` (String) The group email. | ||
- `members` (Block Set, Min: 1) The members in the group. (see [below for nested schema](#nestedblock--members)) | ||
- `title` (String) The group title. | ||
|
||
### Optional | ||
|
||
- `description` (String) The group description. | ||
|
||
### Read-Only | ||
|
||
- `create_time` (String) The group create time in YYYY-MM-DDThh:mm:ss.000Z format | ||
- `creator` (String) The group creator in users/{email} format. | ||
- `id` (String) The ID of this resource. | ||
- `name` (String) The group name in groups/{email} format. | ||
- `source` (String) Source means where the group comes from. For now we support Entra ID SCIM sync, so the source could be Entra ID. | ||
|
||
<a id="nestedblock--members"></a> | ||
### Nested Schema for `members` | ||
|
||
Required: | ||
|
||
- `member` (String) The member in users/{email} format. | ||
- `role` (String) The member's role in the group. | ||
|
||
|
Oops, something went wrong.