{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://raw.githubusercontent.com/api-evangelist/harness/main/json-schema/harness-aggregation-rule-details-request-schema.json",
  "title": "AggregationRuleDetailsRequest",
  "x-generated": "2026-10-04",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/harness-aggregationrules-api-openapi.yml#/components/schemas/AggregationRuleDetailsRequest",
  "type": "object",
  "properties": {
    "aggregation_rule": {
      "$ref": "#/$defs/AggregationRuleDetails"
    }
  },
  "$defs": {
    "AggFormula": {
      "title": "AggFormula",
      "type": "string",
      "enum": [
        "SUM",
        "AVG",
        "COUNT",
        "MAX",
        "MIN",
        "MEDIAN"
      ]
    },
    "AggregationComputeStatus": {
      "title": "AggregationComputeStatus",
      "type": "string",
      "enum": [
        "CALCULATING",
        "ERROR",
        "SUCCESS"
      ]
    },
    "AggregationEntitySelectionCriteria": {
      "title": "AggregationEntitySelectionCriteria",
      "type": "object",
      "properties": {
        "scopes": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "Scope identifiers of selected entities (e.g., org/project)"
        },
        "kind": {
          "type": "string"
        },
        "type": {
          "type": "string"
        },
        "owners": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "tags": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "lifecycles": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      }
    },
    "AggregationRuleDetails": {
      "title": "AggregationRuleDetails",
      "type": "object",
      "required": [
        "identifier",
        "name",
        "field_for_agg",
        "agg_formula",
        "scopes_to_aggregate_at"
      ],
      "properties": {
        "identifier": {
          "type": "string"
        },
        "name": {
          "type": "string"
        },
        "description": {
          "type": "string"
        },
        "field_for_agg": {
          "type": "string",
          "description": "Field to aggregate"
        },
        "agg_formula": {
          "$ref": "#/$defs/AggFormula"
        },
        "scopes_to_aggregate_at": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/AggregationScopeLevel"
          }
        },
        "entity_selection_criteria": {
          "$ref": "#/$defs/AggregationEntitySelectionCriteria"
        },
        "last_computed_status": {
          "$ref": "#/$defs/AggregationComputeStatus"
        },
        "last_computed_at": {
          "type": "integer",
          "format": "int64"
        },
        "last_error_message": {
          "type": "string"
        }
      }
    },
    "AggregationScopeLevel": {
      "title": "AggregationScopeLevel",
      "type": "string",
      "enum": [
        "ACCOUNT",
        "ORGANIZATION",
        "PROJECT",
        "SYSTEM",
        "TEAM"
      ]
    }
  }
}