{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://limecloud.github.io/agentpolicy/schemas/agentpolicy-permission-grant.schema.json",
  "title": "Agent Policy Permission Grant",
  "type": "object",
  "required": [
    "schema_version",
    "grant_id",
    "granted_to",
    "capability",
    "constraints",
    "issued_by",
    "issued_at",
    "status"
  ],
  "properties": {
    "schema_version": {
      "type": "string"
    },
    "grant_id": {
      "type": "string"
    },
    "decision_id": {
      "type": "string"
    },
    "approval_id": {
      "type": "string"
    },
    "granted_to": {
      "type": "object",
      "required": [
        "type"
      ],
      "properties": {
        "type": {
          "type": "string",
          "minLength": 1
        },
        "id": {
          "type": "string"
        },
        "name": {
          "type": "string"
        },
        "refs": {
          "type": "array",
          "items": {
            "type": "object"
          }
        }
      },
      "additionalProperties": true
    },
    "capability": {
      "type": "object",
      "required": [
        "type"
      ],
      "properties": {
        "type": {
          "type": "string",
          "minLength": 1
        },
        "id": {
          "type": "string"
        },
        "name": {
          "type": "string"
        },
        "refs": {
          "type": "array",
          "items": {
            "type": "object"
          }
        }
      },
      "additionalProperties": true
    },
    "constraints": {
      "type": "object",
      "additionalProperties": true
    },
    "issued_by": {
      "type": "object",
      "required": [
        "type"
      ],
      "properties": {
        "type": {
          "type": "string",
          "minLength": 1
        },
        "id": {
          "type": "string"
        },
        "name": {
          "type": "string"
        },
        "refs": {
          "type": "array",
          "items": {
            "type": "object"
          }
        }
      },
      "additionalProperties": true
    },
    "issued_at": {
      "type": "string",
      "format": "date-time"
    },
    "expires_at": {
      "type": "string",
      "format": "date-time"
    },
    "revoked_at": {
      "type": "string",
      "format": "date-time"
    },
    "revoked_by": {
      "type": "object",
      "required": [
        "type"
      ],
      "properties": {
        "type": {
          "type": "string",
          "minLength": 1
        },
        "id": {
          "type": "string"
        },
        "name": {
          "type": "string"
        },
        "refs": {
          "type": "array",
          "items": {
            "type": "object"
          }
        }
      },
      "additionalProperties": true
    },
    "revocation_reason": {
      "type": "string"
    },
    "status": {
      "type": "string",
      "enum": [
        "active",
        "expired",
        "revoked",
        "superseded",
        "pending"
      ]
    },
    "delegation": {
      "type": "object",
      "additionalProperties": true
    },
    "refs": {
      "type": "array",
      "items": {
        "type": "object"
      }
    }
  },
  "additionalProperties": true
}
