{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/okareo/json-schema/okareo-analytics-query-request-schema.json",
  "title": "AnalyticsQueryRequest",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/okareo-analytics-api-openapi.yml#/components/schemas/AnalyticsQueryRequest",
  "properties": {
    "cube": {
      "type": "string",
      "title": "Cube",
      "default": "check_trend"
    },
    "project_id": {
      "type": "string",
      "format": "uuid",
      "title": "Project Id"
    },
    "measures": {
      "items": {
        "type": "string"
      },
      "type": "array",
      "title": "Measures"
    },
    "dimensions": {
      "items": {
        "type": "string"
      },
      "type": "array",
      "title": "Dimensions"
    },
    "filters": {
      "items": {
        "anyOf": [
          {
            "$ref": "#/$defs/AnalyticsFilter"
          },
          {
            "$ref": "#/$defs/AnalyticsFilterGroup-Input"
          }
        ]
      },
      "type": "array",
      "title": "Filters"
    },
    "segments": {
      "items": {
        "type": "string"
      },
      "type": "array",
      "title": "Segments"
    },
    "time_dimensions": {
      "items": {
        "$ref": "#/$defs/TimeDimension"
      },
      "type": "array",
      "title": "Time Dimensions"
    },
    "time_range": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Time Range"
    },
    "order": {
      "additionalProperties": {
        "type": "string",
        "enum": [
          "asc",
          "desc"
        ]
      },
      "type": "object",
      "title": "Order"
    }
  },
  "type": "object",
  "required": [
    "project_id",
    "measures"
  ],
  "$defs": {
    "AnalyticsFilter": {
      "properties": {
        "member": {
          "type": "string",
          "title": "Member"
        },
        "operator": {
          "$ref": "#/$defs/ComparisonOperator",
          "default": "equal"
        },
        "values": {
          "items": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "string",
                "format": "uuid"
              }
            ]
          },
          "type": "array",
          "title": "Values"
        }
      },
      "type": "object",
      "required": [
        "member"
      ],
      "title": "AnalyticsFilter"
    },
    "AnalyticsFilterGroup-Input": {
      "properties": {
        "op": {
          "type": "string",
          "enum": [
            "and",
            "or"
          ],
          "title": "Op"
        },
        "filters": {
          "items": {
            "anyOf": [
              {
                "$ref": "#/$defs/AnalyticsFilter"
              },
              {
                "$ref": "#/$defs/AnalyticsFilterGroup-Input"
              }
            ]
          },
          "type": "array",
          "minItems": 1,
          "title": "Filters"
        }
      },
      "type": "object",
      "required": [
        "op",
        "filters"
      ],
      "title": "AnalyticsFilterGroup"
    },
    "ComparisonOperator": {
      "type": "string",
      "enum": [
        "equal",
        "not_equal",
        "contains",
        "not_contains",
        "greater_than",
        "greater_than_or_equal",
        "less_than",
        "less_than_or_equal",
        "is_set",
        "not_set"
      ],
      "title": "ComparisonOperator"
    },
    "TimeDimension": {
      "properties": {
        "dimension": {
          "type": "string",
          "title": "Dimension"
        },
        "date_range": {
          "anyOf": [
            {
              "items": {
                "type": "string"
              },
              "type": "array",
              "maxItems": 2,
              "minItems": 2
            },
            {
              "type": "null"
            }
          ],
          "title": "Date Range"
        },
        "granularity": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Granularity"
        }
      },
      "type": "object",
      "required": [
        "dimension"
      ],
      "title": "TimeDimension"
    }
  }
}