{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/permitio/json-schema/permitio-resource-role-read-schema.json",
  "title": "ResourceRoleRead",
  "x-generated": "2026-11-30",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/permitio-openapi.json#/components/schemas/ResourceRoleRead",
  "properties": {
    "name": {
      "type": "string",
      "title": "Name",
      "description": "The name of the role"
    },
    "description": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Description",
      "description": "optional description string explaining what this role represents, or what permissions are granted to it."
    },
    "permissions": {
      "anyOf": [
        {
          "items": {
            "type": "string"
          },
          "type": "array"
        },
        {
          "type": "null"
        }
      ],
      "title": "Permissions",
      "description": "list of action keys and action group keys that define what actions this resource role is permitted to do"
    },
    "attributes": {
      "anyOf": [
        {
          "additionalProperties": true,
          "type": "object"
        },
        {
          "type": "null"
        }
      ],
      "title": "Attributes",
      "description": "optional dictionary of key-value pairs that can be used to store arbitrary metadata about this role. This metadata can be used to filter role using query parameters with attr_ prefix, currently supports only 'equals' operator"
    },
    "extends": {
      "anyOf": [
        {
          "items": {
            "type": "string"
          },
          "type": "array"
        },
        {
          "type": "null"
        }
      ],
      "title": "Extends",
      "description": "list of role keys that define what roles this role extends. In other words: this role will automatically inherit all the permissions of the given roles in this list.",
      "default": []
    },
    "granted_to": {
      "anyOf": [
        {
          "$ref": "#/$defs/DerivedRoleBlockRead"
        },
        {
          "type": "null"
        }
      ],
      "description": "Derived role that inherit will be applied on this role"
    },
    "key": {
      "type": "string",
      "title": "Key",
      "description": "A URL-friendly name of the role (i.e: slug). You will be able to query later using this key instead of the id (UUID) of the role."
    },
    "id": {
      "type": "string",
      "format": "uuid",
      "title": "Id",
      "description": "Unique id of the role"
    },
    "organization_id": {
      "type": "string",
      "format": "uuid",
      "title": "Organization Id",
      "description": "Unique id of the organization that the role belongs to."
    },
    "project_id": {
      "type": "string",
      "format": "uuid",
      "title": "Project Id",
      "description": "Unique id of the project that the role belongs to."
    },
    "environment_id": {
      "type": "string",
      "format": "uuid",
      "title": "Environment Id",
      "description": "Unique id of the environment that the role belongs to."
    },
    "resource_id": {
      "type": "string",
      "format": "uuid",
      "title": "Resource Id",
      "description": "Unique id of the resource that the role belongs to."
    },
    "resource": {
      "type": "string",
      "title": "Resource",
      "description": "The unique resource key that the role belongs to."
    },
    "created_at": {
      "type": "string",
      "format": "date-time",
      "title": "Created At",
      "description": "Date and time when the role was created (ISO_8601 format)."
    },
    "updated_at": {
      "type": "string",
      "format": "date-time",
      "title": "Updated At",
      "description": "Date and time when the role was last updated/modified (ISO_8601 format)."
    }
  },
  "additionalProperties": false,
  "type": "object",
  "required": [
    "name",
    "key",
    "id",
    "organization_id",
    "project_id",
    "environment_id",
    "resource_id",
    "resource",
    "created_at",
    "updated_at"
  ],
  "$defs": {
    "DerivedRoleBlockRead": {
      "properties": {
        "when": {
          "$ref": "#/$defs/permit_backend__schemas__schema_derived_role_rule__DerivationSettings",
          "description": "the settings of the derived role",
          "default": {
            "no_direct_roles_on_object": false
          }
        },
        "id": {
          "type": "string",
          "format": "uuid",
          "title": "Id",
          "description": "The unique id of the derived_role"
        },
        "users_with_role": {
          "items": {
            "$ref": "#/$defs/DerivedRoleRuleRead"
          },
          "type": "array",
          "title": "Users With Role",
          "description": "the rules of the derived role",
          "default": []
        }
      },
      "additionalProperties": false,
      "type": "object",
      "required": [
        "id"
      ],
      "title": "DerivedRoleBlockRead"
    },
    "DerivedRoleRuleRead": {
      "properties": {
        "role_id": {
          "type": "string",
          "format": "uuid",
          "title": "Role Id",
          "description": "the role id that needs to exist on the related resource (from the relation)"
        },
        "resource_id": {
          "type": "string",
          "format": "uuid",
          "title": "Resource Id",
          "description": "the resource id that needs to exist on the related role (from the relation)"
        },
        "relation_id": {
          "type": "string",
          "format": "uuid",
          "title": "Relation Id",
          "description": "the relation id that needs to exist between the resource and the related resource"
        },
        "role": {
          "type": "string",
          "title": "Role",
          "description": "the role key that needs to exist on the related resource (from the relation)"
        },
        "on_resource": {
          "type": "string",
          "title": "On Resource",
          "description": "the resource key that needs to exist on the related role (from the relation)"
        },
        "linked_by_relation": {
          "type": "string",
          "title": "Linked By Relation",
          "description": "the relation key that needs to exist between the resource and the related resource"
        },
        "when": {
          "$ref": "#/$defs/permit_backend__schemas__schema_derived_role_rule__DerivationSettings",
          "description": "the settings of the derived role rule",
          "default": {
            "no_direct_roles_on_object": false
          }
        }
      },
      "additionalProperties": false,
      "type": "object",
      "required": [
        "role_id",
        "resource_id",
        "relation_id",
        "role",
        "on_resource",
        "linked_by_relation"
      ],
      "title": "DerivedRoleRuleRead"
    },
    "permit_backend__schemas__schema_derived_role_rule__DerivationSettings": {
      "properties": {
        "no_direct_roles_on_object": {
          "type": "boolean",
          "title": "No Direct Roles On Object",
          "description": "If true, the derived role or the specific rule will not apply if the resource has any direct role",
          "default": false
        }
      },
      "additionalProperties": false,
      "type": "object",
      "title": "DerivationSettings",
      "description": "Settings for a derived role or a derived role rule"
    }
  }
}