Add Handlers for Add/Set/Remove Group Members (#209)
* Adding members to groups. * Adding Group membership handler and API methods. * Adding custom methods to permision actions list.
This commit is contained in:
1 parent
799242fce4
commit
ed05652729
18 files changed
+2587
-355
No files matched your search
@@ -9,6 +9,20 @@ import "google/protobuf/wrappers.proto";
|
||||
import "controller/api/resources/scopes/v1/scope.proto";
|
||||
import "controller/custom_options/v1/masks.proto";
|
||||
|
||||
message Member {
|
||||
// The ID of the member.
|
||||
// Output only.
|
||||
string id = 1;
|
||||
|
||||
// The type of the member.
|
||||
// Output only.
|
||||
string type = 2;
|
||||
|
||||
// The scope ID of the member.
|
||||
// Output only.
|
||||
string scope_id = 3 [json_name="scope_id"];
|
||||
}
|
||||
|
||||
// Group contains all fields related to a Group resource
|
||||
message Group {
|
||||
// The ID of the Project
|
||||
@@ -18,7 +32,7 @@ message Group {
|
||||
// Scope information for this resource
|
||||
// Output only.
|
||||
resources.scopes.v1.ScopeInfo scope = 2;
|
||||
|
||||
|
||||
// Optional name for identification purposes
|
||||
google.protobuf.StringValue name = 3 [(custom_options.v1.mask_mapping) = {this:"name" that: "name"}];
|
||||
|
||||
@@ -35,4 +49,17 @@ message Group {
|
||||
|
||||
// Whether the resource is disabled
|
||||
google.protobuf.BoolValue disabled = 7;
|
||||
|
||||
// The version can be used in subsiquent write requests to ensure this resource
|
||||
// has not changed and to fail the write if it has.
|
||||
// Output only.
|
||||
uint32 version = 8;
|
||||
|
||||
// Contains the list of member ids in this group.
|
||||
// Output only.
|
||||
repeated string member_ids = 9;
|
||||
|
||||
// The members of this group.
|
||||
// Output only.
|
||||
repeated Member members = 10;
|
||||
}
|
||||
@@ -7,6 +7,7 @@ option go_package = "github.com/hashicorp/watchtower/internal/gen/controller/api
|
||||
import "protoc-gen-swagger/options/annotations.proto";
|
||||
import "google/api/annotations.proto";
|
||||
import "google/protobuf/field_mask.proto";
|
||||
import "google/protobuf/wrappers.proto";
|
||||
import "controller/api/resources/groups/v1/group.proto";
|
||||
import "controller/api/resources/scopes/v1/scope.proto";
|
||||
|
||||
@@ -87,6 +88,52 @@ service GroupService {
|
||||
summary: "Deletes a Group"
|
||||
};
|
||||
}
|
||||
|
||||
// AddGroupMembers adds users as members to a group. The provided
|
||||
// request must include the scope id and the group id which the users
|
||||
// will be set to. If the any of the ids are missing, malformed or references a non
|
||||
// existing resource, an error is returned.
|
||||
rpc AddGroupMembers(AddGroupMembersRequest) returns (AddGroupMembersResponse) {
|
||||
option (google.api.http) = {
|
||||
post: "/v1/scopes/*/groups/{id}:add-members"
|
||||
body: "*"
|
||||
response_body: "item"
|
||||
};
|
||||
option (grpc.gateway.protoc_gen_swagger.options.openapiv2_operation) = {
|
||||
summary: "Adds Users as members to a Group"
|
||||
};
|
||||
}
|
||||
|
||||
// SetGroupMembers sets the group's members. Any existing members on
|
||||
// the group are deleted if they are not included in this request. The provided
|
||||
// request must include the scope id and the group id which the users
|
||||
// will be set to. If the any of the ids are missing, malformed or references a non
|
||||
// existing resource, an error is returned.
|
||||
rpc SetGroupMembers(SetGroupMembersRequest) returns (SetGroupMembersResponse) {
|
||||
option (google.api.http) = {
|
||||
post: "/v1/scopes/*/groups/{id}:set-members"
|
||||
body: "*"
|
||||
response_body: "item"
|
||||
};
|
||||
option (grpc.gateway.protoc_gen_swagger.options.openapiv2_operation) = {
|
||||
summary: "Set a Group's members to exactly the list of provided in the request, removing any members that are not specified."
|
||||
};
|
||||
}
|
||||
|
||||
// RemoveGroupMembers removes members from the specified group.
|
||||
// The provided request must include the scope id and the group id which the users
|
||||
// will be set to. If the any of the ids are missing, malformed or references a non
|
||||
// existing resource, an error is returned.
|
||||
rpc RemoveGroupMembers(RemoveGroupMembersRequest) returns (RemoveGroupMembersResponse) {
|
||||
option (google.api.http) = {
|
||||
post: "/v1/scopes/*/groups/{id}:remove-members"
|
||||
body: "*"
|
||||
response_body: "item"
|
||||
};
|
||||
option (grpc.gateway.protoc_gen_swagger.options.openapiv2_operation) = {
|
||||
summary: "Removes the specified members from a Group."
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
message GetGroupRequest {
|
||||
@@ -132,3 +179,39 @@ message DeleteGroupRequest {
|
||||
message DeleteGroupResponse {
|
||||
bool existed = 1;
|
||||
}
|
||||
|
||||
message AddGroupMembersRequest {
|
||||
string id = 1;
|
||||
// The version ensures the group hasn't changed since it was last retrieved and if
|
||||
// it has the request will fail.
|
||||
google.protobuf.UInt32Value version = 2;
|
||||
repeated string member_ids = 3 [json_name="member_ids"];
|
||||
}
|
||||
|
||||
message AddGroupMembersResponse {
|
||||
resources.groups.v1.Group item = 1;
|
||||
}
|
||||
|
||||
message SetGroupMembersRequest {
|
||||
string id = 1;
|
||||
// The version ensures the group hasn't changed since it was last retrieved and if
|
||||
// it has the request will fail.
|
||||
google.protobuf.UInt32Value version = 2;
|
||||
repeated string member_ids = 3 [json_name="member_ids"];
|
||||
}
|
||||
|
||||
message SetGroupMembersResponse {
|
||||
resources.groups.v1.Group item = 1;
|
||||
}
|
||||
|
||||
message RemoveGroupMembersRequest {
|
||||
string id = 1;
|
||||
// The version ensures the group hasn't changed since it was last retrieved and if
|
||||
// it has the request will fail.
|
||||
google.protobuf.UInt32Value version = 2;
|
||||
repeated string member_ids = 3 [json_name="member_ids"];
|
||||
}
|
||||
|
||||
message RemoveGroupMembersResponse {
|
||||
resources.groups.v1.Group item = 1;
|
||||
}
|
||||
Reference in new issue
Block a user