syntax = "proto3";

option go_package = "v1";

option java_package = "io.stackrox.proto.api.v1";

import "google/api/annotations.proto";
import "api/v1/common.proto";
import "api/v1/empty.proto";
import "storage/role.proto";

package v1;

// storage.Access values should be in escalating order. IE READ_WRITE means you have READ as well.

message Permission {
    string resource = 1;
    storage.Access access = 2;
}

message GetRolesResponse {
    repeated storage.Role roles = 1;
}

service RoleService {

    rpc GetRoles (Empty) returns (GetRolesResponse) {
        option (google.api.http) = {
            get: "/v1/roles"
        };
    }

    rpc GetRole (ResourceByID) returns (storage.Role) {
        option (google.api.http) = {
            get: "/v1/roles/{id}"
        };
    }

    rpc CreateRole (storage.Role) returns (Empty) {
        option (google.api.http) = {
            post: "/v1/roles/{name}"
            body: "*"
        };
    }

    rpc UpdateRole (storage.Role) returns (Empty) {
        option (google.api.http) = {
            put: "/v1/roles/{name}"
            body: "*"
        };
    }

    rpc DeleteRole (ResourceByID) returns (Empty) {
        option (google.api.http) = {
            delete: "/v1/roles/{id}"
        };
    }

}