Adding Groups API endpoint and SDK (#122)
* feat: Add group grpc handler. * feat: Add group sdk hooks. * fix: Adding forgotten generated group sdk file. * fix: Fix a copy/paste error in test msg. * fix: Correct assert error msg. * fix: Remove unused proto imports.
This commit is contained in:
1 parent
ffddf24f86
commit
6ea448a7f3
23 files changed
+3834
-2
No files matched your search
@@ -0,0 +1,32 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package controller.api.resources.groups.v1;
|
||||
|
||||
option go_package = "github.com/hashicorp/watchtower/internal/gen/controller/api/resources/groups;groups";
|
||||
|
||||
import "google/protobuf/timestamp.proto";
|
||||
import "google/protobuf/wrappers.proto";
|
||||
|
||||
// Group contains all fields related to a Group resource
|
||||
message Group {
|
||||
// The ID of the Project
|
||||
// Output only.
|
||||
string id = 1;
|
||||
|
||||
// Optional name for identification purposes
|
||||
google.protobuf.StringValue name = 2;
|
||||
|
||||
// Optional user-set descripton for identification purposes
|
||||
google.protobuf.StringValue description = 3;
|
||||
|
||||
// The time this resource was created
|
||||
// Output only.
|
||||
google.protobuf.Timestamp created_time = 4 [json_name="created_time"];
|
||||
|
||||
// The time this resource was last updated.
|
||||
// Output only.
|
||||
google.protobuf.Timestamp updated_time = 5 [json_name="updated_time"];
|
||||
|
||||
// Whether the resource is disabled
|
||||
google.protobuf.BoolValue disabled = 6;
|
||||
}
|
||||
@@ -0,0 +1,138 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package controller.api.services.v1;
|
||||
|
||||
option go_package = "github.com/hashicorp/watchtower/internal/gen/controller/api/services;services";
|
||||
|
||||
import "protoc-gen-swagger/options/annotations.proto";
|
||||
import "google/api/annotations.proto";
|
||||
import "google/protobuf/field_mask.proto";
|
||||
import "controller/api/resources/groups/v1/group.proto";
|
||||
|
||||
service GroupService {
|
||||
|
||||
// GetGroup returns a stored Group if present. The provided request
|
||||
// must include the org and group id for the group being retrieved. If
|
||||
// any of those ids are missing, malformed or reference a non existing
|
||||
// resource an error is returned.
|
||||
rpc GetGroup(GetGroupRequest) returns (GetGroupResponse) {
|
||||
option (google.api.http) = {
|
||||
get: "/v1/orgs/{org_id}/groups/{id}"
|
||||
response_body: "item"
|
||||
};
|
||||
option (grpc.gateway.protoc_gen_swagger.options.openapiv2_operation) = {
|
||||
summary: "Gets a single Group"
|
||||
};
|
||||
}
|
||||
|
||||
// ListGroups returns a list of stored groups which exist inside the org
|
||||
// referenced inside the request. The request must include the org id for
|
||||
// the groups being retrieved. If the org id is missing, malformed, or
|
||||
// reference a non existing organization, an error is returned.
|
||||
rpc ListGroups(ListGroupsRequest) returns (ListGroupsResponse) {
|
||||
option (google.api.http) = {
|
||||
get: "/v1/orgs/{org_id}/groups"
|
||||
};
|
||||
option (grpc.gateway.protoc_gen_swagger.options.openapiv2_operation) = {
|
||||
summary: "Lists all Groups"
|
||||
};
|
||||
}
|
||||
|
||||
// CreateGroup creates and stores a group in watchtower. The provided
|
||||
// request must include the org id in which the group will be created.
|
||||
// If the org id is missing, malformed or references a non existing
|
||||
// organization, an error is returned. If a name is provided that is in
|
||||
// use in another group in the same organization, an error is returned.
|
||||
rpc CreateGroup(CreateGroupRequest) returns (CreateGroupResponse) {
|
||||
option (google.api.http) = {
|
||||
post: "/v1/orgs/{org_id}/groups"
|
||||
body: "item"
|
||||
response_body: "item"
|
||||
};
|
||||
option (grpc.gateway.protoc_gen_swagger.options.openapiv2_operation) = {
|
||||
summary: "Creates a single Group"
|
||||
};
|
||||
}
|
||||
|
||||
// UpdateGroup updates an existing group in watchtower. The provided
|
||||
// group must not have any read only fields set. The update mask must be
|
||||
// included in the request and contain at least 1 mutable field. To unset
|
||||
// a field's value, include the field in the update mask and don't set it
|
||||
// in the provided group. An error is returned if either the organization
|
||||
// or group ids are missing or reference a non existing resource. An error
|
||||
// is also returned if the request attempts to update the name to one that is
|
||||
// already in use in this organization.
|
||||
rpc UpdateGroup(UpdateGroupRequest) returns (UpdateGroupResponse) {
|
||||
option (google.api.http) = {
|
||||
patch: "/v1/orgs/{org_id}/groups/{id}"
|
||||
body: "item"
|
||||
response_body: "item"
|
||||
};
|
||||
option (grpc.gateway.protoc_gen_swagger.options.openapiv2_operation) = {
|
||||
summary: "Updates a Group"
|
||||
};
|
||||
}
|
||||
|
||||
// DeleteGroup removes a group from Watchtower. If the provided org or group ids
|
||||
// are malformed or not provided an error is returned. No error is returned
|
||||
// if either ids reference resources that do not exist as the response itself
|
||||
// specifies if the resource existed before the DeleteGroup request was
|
||||
// received.
|
||||
rpc DeleteGroup(DeleteGroupRequest) returns (DeleteGroupResponse) {
|
||||
option (google.api.http) = {
|
||||
delete: "/v1/orgs/{org_id}/groups/{id}"
|
||||
};
|
||||
option (grpc.gateway.protoc_gen_swagger.options.openapiv2_operation) = {
|
||||
summary: "Deletes a Group"
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
message GetGroupRequest {
|
||||
string org_id = 1;
|
||||
string id = 2;
|
||||
string view = 3;
|
||||
}
|
||||
|
||||
message GetGroupResponse {
|
||||
resources.groups.v1.Group item = 1;
|
||||
}
|
||||
|
||||
message ListGroupsRequest {
|
||||
string org_id = 1;
|
||||
string view = 2;
|
||||
}
|
||||
|
||||
message ListGroupsResponse {
|
||||
repeated resources.groups.v1.Group items = 1;
|
||||
}
|
||||
|
||||
message CreateGroupRequest {
|
||||
string org_id = 1;
|
||||
resources.groups.v1.Group item = 2;
|
||||
}
|
||||
|
||||
message CreateGroupResponse {
|
||||
string uri = 1;
|
||||
resources.groups.v1.Group item = 2;
|
||||
}
|
||||
|
||||
message UpdateGroupRequest {
|
||||
string org_id = 1;
|
||||
string id = 2;
|
||||
resources.groups.v1.Group item = 3;
|
||||
google.protobuf.FieldMask update_mask = 4;
|
||||
}
|
||||
|
||||
message UpdateGroupResponse {
|
||||
resources.groups.v1.Group item = 1;
|
||||
}
|
||||
|
||||
message DeleteGroupRequest {
|
||||
string org_id = 1;
|
||||
string id = 2;
|
||||
}
|
||||
|
||||
message DeleteGroupResponse {
|
||||
bool existed = 1;
|
||||
}
|
||||
Reference in new issue
Block a user