{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/antfly/json-schema/antfly-permission-schema.json",
  "title": "Permission",
  "description": "Specify exactly one of a legacy literal resource or a structured table_target; table_target requires resource_type table.",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/antfly-permission-api-openapi.yml#/components/schemas/Permission",
  "type": "object",
  "properties": {
    "resource": {
      "type": "string",
      "description": "Resource name (e.g., table name, target username, or '*' for all inference operations or a global grant)."
    },
    "table_target": {
      "$ref": "#/$defs/CatalogTableScope"
    },
    "resource_type": {
      "$ref": "#/$defs/ResourceType"
    },
    "type": {
      "$ref": "#/$defs/PermissionType"
    }
  },
  "required": [
    "resource_type",
    "type"
  ],
  "$defs": {
    "CatalogTableScope": {
      "type": "object",
      "description": "A table or all tables in an explicit namespace. A missing table selects the namespace; a table named '*' remains literal.",
      "properties": {
        "database": {
          "type": "string",
          "default": "default"
        },
        "namespace": {
          "type": "string",
          "default": "public"
        },
        "table": {
          "type": "string"
        }
      },
      "additionalProperties": false
    },
    "PermissionType": {
      "type": "string",
      "enum": [
        "read",
        "write",
        "curator",
        "admin"
      ],
      "description": "Type of permission."
    },
    "ResourceType": {
      "type": "string",
      "enum": [
        "table",
        "database",
        "namespace",
        "tablespace",
        "user",
        "inference",
        "*"
      ],
      "description": "Type of resource: table, user, inference, or global ('*'). Use inference with resource '*' to grant access to unified inference routes."
    }
  }
}