Create Role CUDLR API and SDK (#135)
* Implement the Role CRUD API. * Implement the Role List API. * Adding Roles SDK.
This commit is contained in:
1 parent
1023c90729
commit
5b1e4a680d
20 files changed
+3928
No files matched your search
@@ -0,0 +1,32 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package controller.api.resources.roles.v1;
|
||||
|
||||
option go_package = "github.com/hashicorp/watchtower/internal/gen/controller/api/resources/roles;roles";
|
||||
|
||||
import "google/protobuf/timestamp.proto";
|
||||
import "google/protobuf/wrappers.proto";
|
||||
|
||||
// Role contains all fields related to a Role resource
|
||||
message Role {
|
||||
// The ID of the Role
|
||||
// Output only.
|
||||
string id = 1;
|
||||
|
||||
// Optional name for identification purposes
|
||||
google.protobuf.StringValue name = 2;
|
||||
|
||||
// Optional user-set description 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/roles/v1/role.proto";
|
||||
|
||||
service RoleService {
|
||||
|
||||
// GetRole returns a stored Role if present. The provided request
|
||||
// must include the org and role id for the role being retrieved. If
|
||||
// any of those ids are missing, malformed or reference a non existing
|
||||
// resource an error is returned.
|
||||
rpc GetRole(GetRoleRequest) returns (GetRoleResponse) {
|
||||
option (google.api.http) = {
|
||||
get: "/v1/orgs/{org_id}/roles/{id}"
|
||||
response_body: "item"
|
||||
};
|
||||
option (grpc.gateway.protoc_gen_swagger.options.openapiv2_operation) = {
|
||||
summary: "Gets a single Role"
|
||||
};
|
||||
}
|
||||
|
||||
// ListRoles returns a list of stored roles which exist inside the org
|
||||
// referenced inside the request. The request must include the org id for
|
||||
// the roles being retrieved. If the org id is missing, malformed, or
|
||||
// reference a non existing organization, an error is returned.
|
||||
rpc ListRoles(ListRolesRequest) returns (ListRolesResponse) {
|
||||
option (google.api.http) = {
|
||||
get: "/v1/orgs/{org_id}/roles"
|
||||
};
|
||||
option (grpc.gateway.protoc_gen_swagger.options.openapiv2_operation) = {
|
||||
summary: "Lists all Roles"
|
||||
};
|
||||
}
|
||||
|
||||
// CreateRole creates and stores a role in watchtower. The provided
|
||||
// request must include the org id in which the role 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 role in the same organization, an error is returned.
|
||||
rpc CreateRole(CreateRoleRequest) returns (CreateRoleResponse) {
|
||||
option (google.api.http) = {
|
||||
post: "/v1/orgs/{org_id}/roles"
|
||||
body: "item"
|
||||
response_body: "item"
|
||||
};
|
||||
option (grpc.gateway.protoc_gen_swagger.options.openapiv2_operation) = {
|
||||
summary: "Creates a single Role"
|
||||
};
|
||||
}
|
||||
|
||||
// UpdateRole updates an existing role in watchtower. The provided
|
||||
// role 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 role. An error is returned if either the organization
|
||||
// or role 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 UpdateRole(UpdateRoleRequest) returns (UpdateRoleResponse) {
|
||||
option (google.api.http) = {
|
||||
patch: "/v1/orgs/{org_id}/roles/{id}"
|
||||
body: "item"
|
||||
response_body: "item"
|
||||
};
|
||||
option (grpc.gateway.protoc_gen_swagger.options.openapiv2_operation) = {
|
||||
summary: "Updates a Role"
|
||||
};
|
||||
}
|
||||
|
||||
// DeleteRole removes a role from Watchtower. If the provided org or role 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 DeleteRole request was
|
||||
// received.
|
||||
rpc DeleteRole(DeleteRoleRequest) returns (DeleteRoleResponse) {
|
||||
option (google.api.http) = {
|
||||
delete: "/v1/orgs/{org_id}/roles/{id}"
|
||||
};
|
||||
option (grpc.gateway.protoc_gen_swagger.options.openapiv2_operation) = {
|
||||
summary: "Deletes a Role"
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
message GetRoleRequest {
|
||||
string org_id = 1;
|
||||
string id = 2;
|
||||
string view = 3;
|
||||
}
|
||||
|
||||
message GetRoleResponse {
|
||||
resources.roles.v1.Role item = 1;
|
||||
}
|
||||
|
||||
message ListRolesRequest {
|
||||
string org_id = 1;
|
||||
string view = 2;
|
||||
}
|
||||
|
||||
message ListRolesResponse {
|
||||
repeated resources.roles.v1.Role items = 1;
|
||||
}
|
||||
|
||||
message CreateRoleRequest {
|
||||
string org_id = 1;
|
||||
resources.roles.v1.Role item = 2;
|
||||
}
|
||||
|
||||
message CreateRoleResponse {
|
||||
string uri = 1;
|
||||
resources.roles.v1.Role item = 2;
|
||||
}
|
||||
|
||||
message UpdateRoleRequest {
|
||||
string org_id = 1;
|
||||
string id = 2;
|
||||
resources.roles.v1.Role item = 3;
|
||||
google.protobuf.FieldMask update_mask = 4;
|
||||
}
|
||||
|
||||
message UpdateRoleResponse {
|
||||
resources.roles.v1.Role item = 1;
|
||||
}
|
||||
|
||||
message DeleteRoleRequest {
|
||||
string org_id = 1;
|
||||
string id = 2;
|
||||
}
|
||||
|
||||
message DeleteRoleResponse {
|
||||
bool existed = 1;
|
||||
}
|
||||
Reference in new issue
Block a user