{
  "swagger": "2.0",
  "info": {
    "title": "Role service",
    "version": "0.1507.0",
    "description": "Send your API key as a bearer token: `Authorization: Bearer <api key>`."
  },
  "tags": [
    {
      "name": "RoleService",
      "x-displayName": "Role service",
      "description": "RoleService provides methods for managing roles within Nominal."
    }
  ],
  "consumes": [
    "application/json"
  ],
  "produces": [
    "application/json"
  ],
  "paths": {
    "/authorization/roles/v1/batch-get-resource-roles": {
      "post": {
        "operationId": "RoleService_BatchGetResourceRoles",
        "responses": {
          "200": {
            "description": "A successful response.",
            "schema": {
              "$ref": "#/definitions/BatchGetResourceRolesResponse"
            },
            "x-example": {
              "roleAssignmentsByResource": {
                "<key>": {
                  "roleAssignments": [
                    {
                      "role": "ROLE_OWNER",
                      "userRid": "<user rid>"
                    }
                  ]
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "body",
            "in": "body",
            "required": true,
            "schema": {
              "$ref": "#/definitions/BatchGetResourceRolesRequest"
            },
            "x-example": {
              "resources": [
                "<resources>"
              ]
            }
          }
        ],
        "tags": [
          "RoleService"
        ],
        "summary": "Batch get resource roles",
        "description": "Gets the role assignments for multiple resources."
      }
    },
    "/authorization/roles/v1/resource/{resource}/roles": {
      "get": {
        "operationId": "RoleService_GetResourceRoles",
        "responses": {
          "200": {
            "description": "A successful response.",
            "schema": {
              "$ref": "#/definitions/GetResourceRolesResponse"
            },
            "x-example": {
              "roleAssignments": [
                {
                  "role": "ROLE_OWNER",
                  "userRid": "<user rid>"
                }
              ]
            }
          }
        },
        "parameters": [
          {
            "name": "resource",
            "in": "path",
            "required": true,
            "type": "string"
          }
        ],
        "tags": [
          "RoleService"
        ],
        "summary": "Get resource roles",
        "description": "Gets the role assignments for a resource."
      },
      "post": {
        "operationId": "RoleService_UpdateResourceRoles",
        "responses": {
          "200": {
            "description": "A successful response.",
            "schema": {
              "$ref": "#/definitions/UpdateResourceRolesResponse"
            },
            "x-example": {}
          }
        },
        "parameters": [
          {
            "name": "resource",
            "in": "path",
            "required": true,
            "type": "string"
          },
          {
            "name": "body",
            "in": "body",
            "required": true,
            "schema": {
              "$ref": "#/definitions/UpdateResourceRolesBody"
            },
            "x-example": {
              "assignmentsToAdd": [
                {
                  "role": "ROLE_OWNER",
                  "userRid": "<user rid>"
                }
              ],
              "assignmentsToRemove": [
                {
                  "role": "ROLE_OWNER",
                  "userRid": "<user rid>"
                }
              ]
            }
          }
        ],
        "tags": [
          "RoleService"
        ],
        "summary": "Update resource roles",
        "description": "Atomically adds and removes role assignments for a resource. Throws if the same role assignment is both added and removed in the same request."
      }
    }
  },
  "definitions": {
    "BatchGetResourceRolesRequest": {
      "type": "object",
      "properties": {
        "resources": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      },
      "example": {
        "resources": [
          "<resources>"
        ]
      }
    },
    "BatchGetResourceRolesResponse": {
      "type": "object",
      "properties": {
        "roleAssignmentsByResource": {
          "type": "object",
          "additionalProperties": {
            "$ref": "#/definitions/RoleAssignmentWrapper"
          }
        }
      }
    },
    "RoleAssignmentWrapper": {
      "type": "object",
      "properties": {
        "roleAssignments": {
          "type": "array",
          "items": {
            "type": "object",
            "$ref": "#/definitions/RoleAssignmentResponse"
          }
        }
      }
    },
    "GetResourceRolesResponse": {
      "type": "object",
      "properties": {
        "roleAssignments": {
          "type": "array",
          "items": {
            "type": "object",
            "$ref": "#/definitions/RoleAssignmentResponse"
          }
        }
      }
    },
    "Role": {
      "type": "string",
      "enum": [
        "ROLE_UNSPECIFIED",
        "ROLE_OWNER"
      ],
      "default": "ROLE_UNSPECIFIED",
      "description": "- ROLE_UNSPECIFIED: Default value, should not be used.",
      "example": "ROLE_OWNER"
    },
    "RoleAssignmentRequest": {
      "type": "object",
      "properties": {
        "role": {
          "$ref": "#/definitions/Role"
        },
        "userRid": {
          "type": "string"
        }
      },
      "x-oneofs": [
        {
          "fields": [
            "userRid"
          ],
          "required": true
        }
      ],
      "example": {
        "role": "ROLE_OWNER",
        "userRid": "string"
      }
    },
    "RoleAssignmentResponse": {
      "type": "object",
      "properties": {
        "role": {
          "$ref": "#/definitions/Role"
        },
        "userRid": {
          "type": "string"
        }
      },
      "x-oneofs": [
        {
          "fields": [
            "userRid"
          ],
          "required": true
        }
      ],
      "example": {
        "role": "ROLE_OWNER",
        "userRid": "string"
      }
    },
    "UpdateResourceRolesBody": {
      "type": "object",
      "properties": {
        "assignmentsToAdd": {
          "type": "array",
          "items": {
            "type": "object",
            "$ref": "#/definitions/RoleAssignmentRequest"
          }
        },
        "assignmentsToRemove": {
          "type": "array",
          "items": {
            "type": "object",
            "$ref": "#/definitions/RoleAssignmentRequest"
          }
        }
      },
      "example": {
        "assignmentsToAdd": [
          {
            "role": "ROLE_OWNER",
            "userRid": "<user rid>"
          }
        ],
        "assignmentsToRemove": [
          {
            "role": "ROLE_OWNER",
            "userRid": "<user rid>"
          }
        ]
      }
    },
    "UpdateResourceRolesResponse": {
      "type": "object",
      "description": "Intentionally empty."
    }
  },
  "securityDefinitions": {
    "ApiKey": {
      "type": "apiKey",
      "in": "header",
      "name": "Authorization",
      "description": "Your API key as a bearer token: `Authorization: Bearer <api key>`."
    }
  },
  "security": [
    {
      "ApiKey": []
    }
  ]
}
