{
  "components": {
    "schemas": {
      "AggregateNetworkObjects": {
        "properties": {
          "aggregate_by": {
            "enum": [
              "century",
              "day",
              "hour",
              "minute",
              "month",
              "second",
              "year"
            ],
            "type": "string"
          },
          "query_kind": {
            "enum": [
              "aggregate_network_objects"
            ],
            "type": "string"
          },
          "statistic": {
            "enum": [
              "avg",
              "max",
              "median",
              "min",
              "mode",
              "stddev",
              "variance"
            ],
            "type": "string"
          },
          "total_network_objects": {
            "$ref": "#/components/schemas/InputToAggregateNetworkObjects"
          }
        },
        "required": [
          "query_kind",
          "statistic",
          "total_network_objects"
        ],
        "type": "object"
      },
      "BernoulliRandomSample": {
        "properties": {
          "estimate_count": {
            "default": true,
            "type": "boolean"
          },
          "fraction": {
            "format": "float",
            "maximum": 1.0,
            "minimum": 0.0,
            "nullable": true,
            "type": "number"
          },
          "sampling_method": {
            "enum": [
              "bernoulli"
            ],
            "type": "string"
          },
          "seed": {
            "format": "float",
            "type": "number"
          },
          "size": {
            "format": "int32",
            "minimum": 1,
            "nullable": true,
            "type": "integer"
          }
        },
        "required": [
          "query_kind",
          "seed"
        ],
        "type": "object"
      },
      "DFSTotalMetricAmount": {
        "properties": {
          "aggregation_unit": {
            "enum": [
              "admin0",
              "admin1",
              "admin2",
              "admin3",
              "lon-lat"
            ],
            "type": "string"
          },
          "end_date": {
            "format": "date",
            "type": "string"
          },
          "metric": {
            "enum": [
              "amount",
              "commission",
              "discount",
              "fee"
            ],
            "type": "string"
          },
          "query_kind": {
            "enum": [
              "dfs_metric_total_amount"
            ],
            "type": "string"
          },
          "start_date": {
            "format": "date",
            "type": "string"
          }
        },
        "required": [
          "aggregation_unit",
          "end_date",
          "metric",
          "query_kind",
          "start_date"
        ],
        "type": "object"
      },
      "DailyLocation": {
        "properties": {
          "aggregation_unit": {
            "enum": [
              "admin0",
              "admin1",
              "admin2",
              "admin3",
              "lon-lat"
            ],
            "type": "string"
          },
          "date": {
            "format": "date",
            "type": "string"
          },
          "method": {
            "enum": [
              "last",
              "most-common"
            ],
            "type": "string"
          },
          "query_kind": {
            "enum": [
              "daily_location"
            ],
            "type": "string"
          },
          "sampling": {
            "allOf": [
              {
                "$ref": "#/components/schemas/RandomSample"
              }
            ],
            "nullable": true
          },
          "subscriber_subset": {
            "enum": [
              null
            ],
            "nullable": true,
            "type": "string"
          }
        },
        "required": [
          "aggregation_unit",
          "date",
          "method",
          "query_kind"
        ],
        "type": "object"
      },
      "Displacement": {
        "properties": {
          "query_kind": {
            "enum": [
              "displacement"
            ],
            "type": "string"
          },
          "reference_location": {
            "$ref": "#/components/schemas/InputToDisplacement"
          },
          "sampling": {
            "allOf": [
              {
                "$ref": "#/components/schemas/RandomSample"
              }
            ],
            "nullable": true
          },
          "start": {
            "format": "date",
            "type": "string"
          },
          "statistic": {
            "enum": [
              "avg",
              "max",
              "median",
              "min",
              "mode",
              "stddev",
              "variance"
            ],
            "type": "string"
          },
          "stop": {
            "format": "date",
            "type": "string"
          },
          "subscriber_subset": {
            "enum": [
              null
            ],
            "nullable": true,
            "type": "string"
          }
        },
        "required": [
          "query_kind",
          "start",
          "statistic",
          "stop"
        ],
        "type": "object"
      },
      "DummyQuery": {
        "properties": {
          "aggregation_unit": {
            "enum": [
              "admin0",
              "admin1",
              "admin2",
              "admin3",
              "lon-lat"
            ],
            "type": "string"
          },
          "dummy_delay": {
            "default": 0,
            "format": "int32",
            "type": "integer"
          },
          "dummy_param": {
            "type": "string"
          },
          "query_kind": {
            "enum": [
              "dummy_query"
            ],
            "type": "string"
          }
        },
        "required": [
          "aggregation_unit",
          "dummy_param",
          "query_kind"
        ],
        "type": "object"
      },
      "EventCount": {
        "properties": {
          "direction": {
            "enum": [
              "both",
              "in",
              "out"
            ],
            "type": "string"
          },
          "event_types": {
            "items": {
              "enum": [
                "calls",
                "mds",
                "sms",
                "topups"
              ],
              "type": "string"
            },
            "minItems": 1,
            "nullable": true,
            "type": "array"
          },
          "query_kind": {
            "enum": [
              "event_count"
            ],
            "type": "string"
          },
          "sampling": {
            "allOf": [
              {
                "$ref": "#/components/schemas/RandomSample"
              }
            ],
            "nullable": true
          },
          "start": {
            "format": "date",
            "type": "string"
          },
          "stop": {
            "format": "date",
            "type": "string"
          },
          "subscriber_subset": {
            "enum": [
              null
            ],
            "nullable": true,
            "type": "string"
          }
        },
        "required": [
          "query_kind",
          "start",
          "stop"
        ],
        "type": "object"
      },
      "FlowmachineQuerySchema": {
        "discriminator": {
          "mapping": {
            "aggregate_network_objects": "#/components/schemas/AggregateNetworkObjects",
            "dfs_metric_total_amount": "#/components/schemas/DFSTotalMetricAmount",
            "dummy_query": "#/components/schemas/DummyQuery",
            "flows": "#/components/schemas/Flows",
            "geography": "#/components/schemas/Geography",
            "joined_spatial_aggregate": "#/components/schemas/JoinedSpatialAggregate",
            "location_event_counts": "#/components/schemas/LocationEventCounts",
            "location_introversion": "#/components/schemas/LocationIntroversion",
            "meaningful_locations_aggregate": "#/components/schemas/MeaningfulLocationsAggregate",
            "meaningful_locations_between_dates_od_matrix": "#/components/schemas/MeaningfulLocationsBetweenDatesODMatrix",
            "meaningful_locations_between_label_od_matrix": "#/components/schemas/MeaningfulLocationsBetweenLabelODMatrix",
            "spatial_aggregate": "#/components/schemas/SpatialAggregate",
            "total_network_objects": "#/components/schemas/TotalNetworkObjects",
            "unique_subscriber_counts": "#/components/schemas/UniqueSubscriberCounts"
          },
          "propertyName": "query_kind"
        },
        "oneOf": [
          {
            "$ref": "#/components/schemas/AggregateNetworkObjects"
          },
          {
            "$ref": "#/components/schemas/DFSTotalMetricAmount"
          },
          {
            "$ref": "#/components/schemas/DummyQuery"
          },
          {
            "$ref": "#/components/schemas/Flows"
          },
          {
            "$ref": "#/components/schemas/Geography"
          },
          {
            "$ref": "#/components/schemas/JoinedSpatialAggregate"
          },
          {
            "$ref": "#/components/schemas/LocationEventCounts"
          },
          {
            "$ref": "#/components/schemas/LocationIntroversion"
          },
          {
            "$ref": "#/components/schemas/MeaningfulLocationsAggregate"
          },
          {
            "$ref": "#/components/schemas/MeaningfulLocationsBetweenDatesODMatrix"
          },
          {
            "$ref": "#/components/schemas/MeaningfulLocationsBetweenLabelODMatrix"
          },
          {
            "$ref": "#/components/schemas/SpatialAggregate"
          },
          {
            "$ref": "#/components/schemas/TotalNetworkObjects"
          },
          {
            "$ref": "#/components/schemas/UniqueSubscriberCounts"
          }
        ]
      },
      "Flows": {
        "properties": {
          "aggregation_unit": {
            "enum": [
              "admin0",
              "admin1",
              "admin2",
              "admin3",
              "lon-lat"
            ],
            "type": "string"
          },
          "from_location": {
            "$ref": "#/components/schemas/InputToFlows"
          },
          "query_kind": {
            "enum": [
              "flows"
            ],
            "type": "string"
          },
          "to_location": {
            "$ref": "#/components/schemas/InputToFlows"
          }
        },
        "required": [
          "aggregation_unit",
          "from_location",
          "query_kind",
          "to_location"
        ],
        "type": "object"
      },
      "Geography": {
        "properties": {
          "aggregation_unit": {
            "enum": [
              "admin0",
              "admin1",
              "admin2",
              "admin3",
              "lon-lat"
            ],
            "type": "string"
          },
          "query_kind": {
            "enum": [
              "geography"
            ],
            "type": "string"
          }
        },
        "required": [
          "aggregation_unit",
          "query_kind"
        ],
        "type": "object"
      },
      "Handset": {
        "properties": {
          "characteristic": {
            "enum": [
              "brand",
              "hnd_type",
              "model",
              "software_os_name",
              "software_os_vendor"
            ],
            "type": "string"
          },
          "end_date": {
            "format": "date",
            "type": "string"
          },
          "method": {
            "enum": [
              "last",
              "most-common"
            ],
            "type": "string"
          },
          "query_kind": {
            "enum": [
              "handset"
            ],
            "type": "string"
          },
          "sampling": {
            "allOf": [
              {
                "$ref": "#/components/schemas/RandomSample"
              }
            ],
            "nullable": true
          },
          "start_date": {
            "format": "date",
            "type": "string"
          },
          "subscriber_subset": {
            "enum": [
              null
            ],
            "nullable": true,
            "type": "string"
          }
        },
        "required": [
          "end_date",
          "query_kind",
          "start_date"
        ],
        "type": "object"
      },
      "InputToAggregateNetworkObjects": {
        "discriminator": {
          "mapping": {
            "total_network_objects": "#/components/schemas/TotalNetworkObjects"
          },
          "propertyName": "query_kind"
        },
        "oneOf": [
          {
            "$ref": "#/components/schemas/TotalNetworkObjects"
          }
        ]
      },
      "InputToDisplacement": {
        "discriminator": {
          "mapping": {
            "daily_location": "#/components/schemas/DailyLocation",
            "modal_location": "#/components/schemas/ModalLocation"
          },
          "propertyName": "query_kind"
        },
        "oneOf": [
          {
            "$ref": "#/components/schemas/DailyLocation"
          },
          {
            "$ref": "#/components/schemas/ModalLocation"
          }
        ]
      },
      "InputToFlows": {
        "discriminator": {
          "mapping": {
            "daily_location": "#/components/schemas/DailyLocation",
            "modal_location": "#/components/schemas/ModalLocation"
          },
          "propertyName": "query_kind"
        },
        "oneOf": [
          {
            "$ref": "#/components/schemas/DailyLocation"
          },
          {
            "$ref": "#/components/schemas/ModalLocation"
          }
        ]
      },
      "InputToModalLocation": {
        "discriminator": {
          "mapping": {
            "daily_location": "#/components/schemas/DailyLocation"
          },
          "propertyName": "query_kind"
        },
        "oneOf": [
          {
            "$ref": "#/components/schemas/DailyLocation"
          }
        ]
      },
      "InputToSpatialAggregate": {
        "discriminator": {
          "mapping": {
            "daily_location": "#/components/schemas/DailyLocation",
            "modal_location": "#/components/schemas/ModalLocation"
          },
          "propertyName": "query_kind"
        },
        "oneOf": [
          {
            "$ref": "#/components/schemas/DailyLocation"
          },
          {
            "$ref": "#/components/schemas/ModalLocation"
          }
        ]
      },
      "JoinableMetrics": {
        "discriminator": {
          "mapping": {
            "displacement": "#/components/schemas/Displacement",
            "event_count": "#/components/schemas/EventCount",
            "handset": "#/components/schemas/Handset",
            "nocturnal_events": "#/components/schemas/NocturnalEvents",
            "pareto_interactions": "#/components/schemas/ParetoInteractions",
            "radius_of_gyration": "#/components/schemas/RadiusOfGyration",
            "subscriber_degree": "#/components/schemas/SubscriberDegree",
            "topup_amount": "#/components/schemas/TopUpAmount",
            "topup_balance": "#/components/schemas/TopUpBalance",
            "unique_location_counts": "#/components/schemas/UniqueLocationCounts"
          },
          "propertyName": "query_kind"
        },
        "oneOf": [
          {
            "$ref": "#/components/schemas/Displacement"
          },
          {
            "$ref": "#/components/schemas/EventCount"
          },
          {
            "$ref": "#/components/schemas/Handset"
          },
          {
            "$ref": "#/components/schemas/NocturnalEvents"
          },
          {
            "$ref": "#/components/schemas/ParetoInteractions"
          },
          {
            "$ref": "#/components/schemas/RadiusOfGyration"
          },
          {
            "$ref": "#/components/schemas/SubscriberDegree"
          },
          {
            "$ref": "#/components/schemas/TopUpAmount"
          },
          {
            "$ref": "#/components/schemas/TopUpBalance"
          },
          {
            "$ref": "#/components/schemas/UniqueLocationCounts"
          }
        ]
      },
      "JoinedSpatialAggregate": {
        "properties": {
          "locations": {
            "$ref": "#/components/schemas/InputToSpatialAggregate"
          },
          "method": {
            "enum": [
              "avg",
              "distr",
              "max",
              "median",
              "min",
              "mode",
              "stddev",
              "variance"
            ],
            "type": "string"
          },
          "metric": {
            "$ref": "#/components/schemas/JoinableMetrics"
          },
          "query_kind": {
            "enum": [
              "joined_spatial_aggregate"
            ],
            "type": "string"
          }
        },
        "required": [
          "locations",
          "metric",
          "query_kind"
        ],
        "type": "object"
      },
      "LocationEventCounts": {
        "properties": {
          "aggregation_unit": {
            "enum": [
              "admin0",
              "admin1",
              "admin2",
              "admin3",
              "lon-lat"
            ],
            "type": "string"
          },
          "direction": {
            "enum": [
              "both",
              "in",
              "out"
            ],
            "type": "string"
          },
          "end_date": {
            "format": "date",
            "type": "string"
          },
          "event_types": {
            "items": {
              "enum": [
                "calls",
                "mds",
                "sms",
                "topups"
              ],
              "type": "string"
            },
            "minItems": 1,
            "nullable": true,
            "type": "array"
          },
          "interval": {
            "enum": [
              "day",
              "hour",
              "min"
            ],
            "type": "string"
          },
          "query_kind": {
            "enum": [
              "location_event_counts"
            ],
            "type": "string"
          },
          "start_date": {
            "format": "date",
            "type": "string"
          },
          "subscriber_subset": {
            "enum": [
              null
            ],
            "nullable": true,
            "type": "string"
          }
        },
        "required": [
          "aggregation_unit",
          "direction",
          "end_date",
          "interval",
          "query_kind",
          "start_date"
        ],
        "type": "object"
      },
      "LocationIntroversion": {
        "properties": {
          "aggregation_unit": {
            "enum": [
              "admin0",
              "admin1",
              "admin2",
              "admin3",
              "lon-lat"
            ],
            "type": "string"
          },
          "direction": {
            "enum": [
              "both",
              "in",
              "out"
            ],
            "type": "string"
          },
          "end_date": {
            "format": "date",
            "type": "string"
          },
          "query_kind": {
            "enum": [
              "location_introversion"
            ],
            "type": "string"
          },
          "start_date": {
            "format": "date",
            "type": "string"
          }
        },
        "required": [
          "aggregation_unit",
          "end_date",
          "query_kind",
          "start_date"
        ],
        "type": "object"
      },
      "MeaningfulLocationsAggregate": {
        "properties": {
          "aggregation_unit": {
            "enum": [
              "admin0",
              "admin1",
              "admin2",
              "admin3",
              "lon-lat"
            ],
            "type": "string"
          },
          "end_date": {
            "format": "date",
            "type": "string"
          },
          "label": {
            "type": "string"
          },
          "labels": {
            "additionalProperties": {
              "type": "object"
            },
            "type": "object"
          },
          "query_kind": {
            "enum": [
              "meaningful_locations_aggregate"
            ],
            "type": "string"
          },
          "start_date": {
            "format": "date",
            "type": "string"
          },
          "subscriber_subset": {
            "enum": [
              null
            ],
            "nullable": true,
            "type": "string"
          },
          "tower_cluster_call_threshold": {
            "format": "int32",
            "type": "integer"
          },
          "tower_cluster_radius": {
            "format": "float",
            "type": "number"
          },
          "tower_day_of_week_scores": {
            "additionalProperties": {
              "format": "float",
              "maximum": 1.0,
              "minimum": -1.0,
              "type": "number"
            },
            "type": "object"
          },
          "tower_hour_of_day_scores": {
            "items": {
              "format": "float",
              "maximum": 1.0,
              "minimum": -1.0,
              "type": "number"
            },
            "maxItems": 24,
            "minItems": 24,
            "type": "array"
          }
        },
        "required": [
          "aggregation_unit",
          "end_date",
          "label",
          "labels",
          "query_kind",
          "start_date",
          "tower_day_of_week_scores",
          "tower_hour_of_day_scores"
        ],
        "type": "object"
      },
      "MeaningfulLocationsBetweenDatesODMatrix": {
        "properties": {
          "aggregation_unit": {
            "enum": [
              "admin0",
              "admin1",
              "admin2",
              "admin3",
              "lon-lat"
            ],
            "type": "string"
          },
          "end_date_a": {
            "format": "date",
            "type": "string"
          },
          "end_date_b": {
            "format": "date",
            "type": "string"
          },
          "label": {
            "type": "string"
          },
          "labels": {
            "additionalProperties": {
              "type": "object"
            },
            "type": "object"
          },
          "query_kind": {
            "enum": [
              "meaningful_locations_between_dates_od_matrix"
            ],
            "type": "string"
          },
          "start_date_a": {
            "format": "date",
            "type": "string"
          },
          "start_date_b": {
            "format": "date",
            "type": "string"
          },
          "subscriber_subset": {
            "enum": [
              null
            ],
            "nullable": true,
            "type": "string"
          },
          "tower_cluster_call_threshold": {
            "format": "int32",
            "type": "integer"
          },
          "tower_cluster_radius": {
            "format": "float",
            "type": "number"
          },
          "tower_day_of_week_scores": {
            "additionalProperties": {
              "format": "float",
              "maximum": 1.0,
              "minimum": -1.0,
              "type": "number"
            },
            "type": "object"
          },
          "tower_hour_of_day_scores": {
            "items": {
              "format": "float",
              "maximum": 1.0,
              "minimum": -1.0,
              "type": "number"
            },
            "maxItems": 24,
            "minItems": 24,
            "type": "array"
          }
        },
        "required": [
          "aggregation_unit",
          "end_date_a",
          "end_date_b",
          "label",
          "query_kind",
          "start_date_a",
          "start_date_b",
          "tower_day_of_week_scores",
          "tower_hour_of_day_scores"
        ],
        "type": "object"
      },
      "MeaningfulLocationsBetweenLabelODMatrix": {
        "properties": {
          "aggregation_unit": {
            "enum": [
              "admin0",
              "admin1",
              "admin2",
              "admin3",
              "lon-lat"
            ],
            "type": "string"
          },
          "end_date": {
            "format": "date",
            "type": "string"
          },
          "label_a": {
            "type": "string"
          },
          "label_b": {
            "type": "string"
          },
          "labels": {
            "additionalProperties": {
              "type": "object"
            },
            "type": "object"
          },
          "query_kind": {
            "enum": [
              "meaningful_locations_between_label_od_matrix"
            ],
            "type": "string"
          },
          "start_date": {
            "format": "date",
            "type": "string"
          },
          "subscriber_subset": {
            "enum": [
              null
            ],
            "nullable": true,
            "type": "string"
          },
          "tower_cluster_call_threshold": {
            "format": "int32",
            "type": "integer"
          },
          "tower_cluster_radius": {
            "format": "float",
            "type": "number"
          },
          "tower_day_of_week_scores": {
            "additionalProperties": {
              "format": "float",
              "maximum": 1.0,
              "minimum": -1.0,
              "type": "number"
            },
            "type": "object"
          },
          "tower_hour_of_day_scores": {
            "items": {
              "format": "float",
              "maximum": 1.0,
              "minimum": -1.0,
              "type": "number"
            },
            "maxItems": 24,
            "minItems": 24,
            "type": "array"
          }
        },
        "required": [
          "aggregation_unit",
          "end_date",
          "label_a",
          "label_b",
          "query_kind",
          "start_date",
          "tower_day_of_week_scores",
          "tower_hour_of_day_scores"
        ],
        "type": "object"
      },
      "ModalLocation": {
        "properties": {
          "aggregation_unit": {
            "enum": [
              "admin0",
              "admin1",
              "admin2",
              "admin3",
              "lon-lat"
            ],
            "type": "string"
          },
          "locations": {
            "items": {
              "$ref": "#/components/schemas/InputToModalLocation"
            },
            "minItems": 1,
            "type": "array"
          },
          "query_kind": {
            "enum": [
              "modal_location"
            ],
            "type": "string"
          },
          "sampling": {
            "allOf": [
              {
                "$ref": "#/components/schemas/RandomSample"
              }
            ],
            "nullable": true
          },
          "subscriber_subset": {
            "enum": [
              null
            ],
            "nullable": true,
            "type": "string"
          }
        },
        "required": [
          "aggregation_unit",
          "query_kind"
        ],
        "type": "object"
      },
      "NocturnalEvents": {
        "properties": {
          "night_end_hour": {
            "format": "int32",
            "maximum": 23,
            "minimum": 0,
            "type": "integer"
          },
          "night_start_hour": {
            "format": "int32",
            "maximum": 23,
            "minimum": 0,
            "type": "integer"
          },
          "query_kind": {
            "enum": [
              "nocturnal_events"
            ],
            "type": "string"
          },
          "sampling": {
            "allOf": [
              {
                "$ref": "#/components/schemas/RandomSample"
              }
            ],
            "nullable": true
          },
          "start": {
            "format": "date",
            "type": "string"
          },
          "stop": {
            "format": "date",
            "type": "string"
          },
          "subscriber_subset": {
            "enum": [
              null
            ],
            "nullable": true,
            "type": "string"
          }
        },
        "required": [
          "query_kind",
          "start",
          "stop"
        ],
        "type": "object"
      },
      "ParetoInteractions": {
        "properties": {
          "proportion": {
            "format": "float",
            "maximum": 1.0,
            "minimum": 0.0,
            "type": "number"
          },
          "query_kind": {
            "enum": [
              "pareto_interactions"
            ],
            "type": "string"
          },
          "sampling": {
            "allOf": [
              {
                "$ref": "#/components/schemas/RandomSample"
              }
            ],
            "nullable": true
          },
          "start": {
            "format": "date",
            "type": "string"
          },
          "stop": {
            "format": "date",
            "type": "string"
          },
          "subscriber_subset": {
            "enum": [
              null
            ],
            "nullable": true,
            "type": "string"
          }
        },
        "required": [
          "proportion",
          "query_kind",
          "start",
          "stop"
        ],
        "type": "object"
      },
      "RadiusOfGyration": {
        "properties": {
          "end_date": {
            "format": "date",
            "type": "string"
          },
          "query_kind": {
            "enum": [
              "radius_of_gyration"
            ],
            "type": "string"
          },
          "sampling": {
            "allOf": [
              {
                "$ref": "#/components/schemas/RandomSample"
              }
            ],
            "nullable": true
          },
          "start_date": {
            "format": "date",
            "type": "string"
          },
          "subscriber_subset": {
            "enum": [
              null
            ],
            "nullable": true,
            "type": "string"
          }
        },
        "required": [
          "end_date",
          "query_kind",
          "start_date"
        ],
        "type": "object"
      },
      "RandomIDsRandomSample": {
        "properties": {
          "estimate_count": {
            "default": true,
            "type": "boolean"
          },
          "fraction": {
            "format": "float",
            "maximum": 1.0,
            "minimum": 0.0,
            "nullable": true,
            "type": "number"
          },
          "sampling_method": {
            "enum": [
              "random_ids"
            ],
            "type": "string"
          },
          "seed": {
            "format": "float",
            "maximum": 1.0,
            "minimum": -1.0,
            "type": "number"
          },
          "size": {
            "format": "int32",
            "minimum": 1,
            "nullable": true,
            "type": "integer"
          }
        },
        "required": [
          "query_kind",
          "seed"
        ],
        "type": "object"
      },
      "RandomSample": {
        "discriminator": {
          "mapping": {
            "bernoulli": "#/components/schemas/BernoulliRandomSample",
            "random_ids": "#/components/schemas/RandomIDsRandomSample",
            "system": "#/components/schemas/SystemRandomSample"
          },
          "propertyName": "sampling_method"
        },
        "oneOf": [
          {
            "$ref": "#/components/schemas/BernoulliRandomSample"
          },
          {
            "$ref": "#/components/schemas/RandomIDsRandomSample"
          },
          {
            "$ref": "#/components/schemas/SystemRandomSample"
          }
        ]
      },
      "SpatialAggregate": {
        "properties": {
          "locations": {
            "$ref": "#/components/schemas/InputToSpatialAggregate"
          },
          "query_kind": {
            "enum": [
              "spatial_aggregate"
            ],
            "type": "string"
          }
        },
        "required": [
          "locations",
          "query_kind"
        ],
        "type": "object"
      },
      "SubscriberDegree": {
        "properties": {
          "direction": {
            "enum": [
              "both",
              "in",
              "out"
            ],
            "type": "string"
          },
          "query_kind": {
            "enum": [
              "subscriber_degree"
            ],
            "type": "string"
          },
          "sampling": {
            "allOf": [
              {
                "$ref": "#/components/schemas/RandomSample"
              }
            ],
            "nullable": true
          },
          "start": {
            "format": "date",
            "type": "string"
          },
          "stop": {
            "format": "date",
            "type": "string"
          },
          "subscriber_subset": {
            "enum": [
              null
            ],
            "nullable": true,
            "type": "string"
          }
        },
        "required": [
          "query_kind",
          "start",
          "stop"
        ],
        "type": "object"
      },
      "SystemRandomSample": {
        "properties": {
          "estimate_count": {
            "default": true,
            "type": "boolean"
          },
          "fraction": {
            "format": "float",
            "maximum": 1.0,
            "minimum": 0.0,
            "nullable": true,
            "type": "number"
          },
          "sampling_method": {
            "enum": [
              "system"
            ],
            "type": "string"
          },
          "seed": {
            "format": "float",
            "type": "number"
          },
          "size": {
            "format": "int32",
            "minimum": 1,
            "nullable": true,
            "type": "integer"
          }
        },
        "required": [
          "query_kind",
          "seed"
        ],
        "type": "object"
      },
      "TopUpAmount": {
        "properties": {
          "query_kind": {
            "enum": [
              "topup_amount"
            ],
            "type": "string"
          },
          "sampling": {
            "allOf": [
              {
                "$ref": "#/components/schemas/RandomSample"
              }
            ],
            "nullable": true
          },
          "start": {
            "format": "date",
            "type": "string"
          },
          "statistic": {
            "enum": [
              "avg",
              "max",
              "median",
              "min",
              "mode",
              "stddev",
              "variance"
            ],
            "type": "string"
          },
          "stop": {
            "format": "date",
            "type": "string"
          },
          "subscriber_subset": {
            "enum": [
              null
            ],
            "nullable": true,
            "type": "string"
          }
        },
        "required": [
          "query_kind",
          "start",
          "statistic",
          "stop"
        ],
        "type": "object"
      },
      "TopUpBalance": {
        "properties": {
          "end_date": {
            "format": "date",
            "type": "string"
          },
          "query_kind": {
            "enum": [
              "topup_balance"
            ],
            "type": "string"
          },
          "sampling": {
            "allOf": [
              {
                "$ref": "#/components/schemas/RandomSample"
              }
            ],
            "nullable": true
          },
          "start_date": {
            "format": "date",
            "type": "string"
          },
          "statistic": {
            "enum": [
              "avg",
              "max",
              "median",
              "min",
              "mode",
              "stddev",
              "variance"
            ],
            "type": "string"
          },
          "subscriber_subset": {
            "enum": [
              null
            ],
            "nullable": true,
            "type": "string"
          }
        },
        "required": [
          "end_date",
          "query_kind",
          "start_date",
          "statistic"
        ],
        "type": "object"
      },
      "TotalNetworkObjects": {
        "properties": {
          "aggregation_unit": {
            "enum": [
              "admin0",
              "admin1",
              "admin2",
              "admin3",
              "lon-lat"
            ],
            "type": "string"
          },
          "end_date": {
            "format": "date",
            "type": "string"
          },
          "query_kind": {
            "enum": [
              "total_network_objects"
            ],
            "type": "string"
          },
          "start_date": {
            "format": "date",
            "type": "string"
          },
          "total_by": {
            "default": "day",
            "enum": [
              "day",
              "hour",
              "minute",
              "month",
              "second",
              "year"
            ],
            "type": "string"
          }
        },
        "required": [
          "aggregation_unit",
          "end_date",
          "query_kind",
          "start_date"
        ],
        "type": "object"
      },
      "UniqueLocationCounts": {
        "properties": {
          "aggregation_unit": {
            "enum": [
              "admin0",
              "admin1",
              "admin2",
              "admin3",
              "lon-lat"
            ],
            "type": "string"
          },
          "end_date": {
            "format": "date",
            "type": "string"
          },
          "query_kind": {
            "enum": [
              "unique_location_counts"
            ],
            "type": "string"
          },
          "sampling": {
            "allOf": [
              {
                "$ref": "#/components/schemas/RandomSample"
              }
            ],
            "nullable": true
          },
          "start_date": {
            "format": "date",
            "type": "string"
          },
          "subscriber_subset": {
            "enum": [
              null
            ],
            "nullable": true,
            "type": "string"
          }
        },
        "required": [
          "aggregation_unit",
          "end_date",
          "query_kind",
          "start_date"
        ],
        "type": "object"
      },
      "UniqueSubscriberCounts": {
        "properties": {
          "aggregation_unit": {
            "enum": [
              "admin0",
              "admin1",
              "admin2",
              "admin3",
              "lon-lat"
            ],
            "type": "string"
          },
          "end_date": {
            "format": "date",
            "type": "string"
          },
          "query_kind": {
            "enum": [
              "unique_subscriber_counts"
            ],
            "type": "string"
          },
          "start_date": {
            "format": "date",
            "type": "string"
          }
        },
        "required": [
          "aggregation_unit",
          "end_date",
          "query_kind",
          "start_date"
        ],
        "type": "object"
      }
    },
    "securitySchemes": {
      "token": {
        "bearerFormat": "JWT",
        "scheme": "bearer",
        "type": "http"
      }
    }
  },
  "info": {
    "contact": {
      "email": "flowkit@flowminder.org"
    },
    "description": "FlowKit Analytical API",
    "license": {
      "name": "MPLv2",
      "url": "https://www.mozilla.org/en-US/MPL/2.0/"
    },
    "title": "FlowAPI"
  },
  "openapi": "3.0.1",
  "paths": {
    "/api/0/available_dates": {
      "get": {
        "operationId": "query.get_available_dates.get",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "calls": {
                      "items": {
                        "format": "date",
                        "type": "string"
                      },
                      "type": "array"
                    },
                    "mds": {
                      "items": {
                        "format": "date",
                        "type": "string"
                      },
                      "type": "array"
                    },
                    "sms": {
                      "items": {
                        "format": "date",
                        "type": "string"
                      },
                      "type": "array"
                    },
                    "topups": {
                      "items": {
                        "format": "date",
                        "type": "string"
                      },
                      "type": "array"
                    }
                  },
                  "type": "object"
                }
              }
            },
            "description": "Dates available for each event type."
          },
          "401": {
            "description": "Unauthorized."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            },
            "description": "No access with this token."
          },
          "500": {
            "description": "Server error."
          }
        },
        "summary": "Get the dates available to query over."
      }
    },
    "/api/0/geography/<aggregation_unit>": {
      "get": {
        "operationId": "geography.get_geography.get",
        "parameters": [
          {
            "in": "path",
            "name": "aggregation_unit",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/geo+json": {
                "schema": {
                  "type": "object"
                }
              }
            },
            "description": "Downloading."
          },
          "401": {
            "description": "Unauthorized."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            },
            "description": "Token does not grant run access to this spatial aggregation unit."
          },
          "500": {
            "description": "Server error."
          }
        },
        "summary": "Get geojson for an aggregation unit"
      }
    },
    "/api/0/get/<query_id>": {
      "get": {
        "operationId": "query.get_query_result.get",
        "parameters": [
          {
            "in": "path",
            "name": "query_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            },
            "description": "Results returning."
          },
          "202": {
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            },
            "description": "Request accepted."
          },
          "401": {
            "description": "Unauthorized."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            },
            "description": "Token does not grant results access to this query or spatial aggregation unit."
          },
          "404": {
            "description": "Unknown ID"
          },
          "500": {
            "description": "Server error."
          }
        },
        "summary": "Get the output of query"
      }
    },
    "/api/0/poll/<query_id>": {
      "get": {
        "operationId": "query.poll_query.get",
        "parameters": [
          {
            "in": "path",
            "name": "query_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "202": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "msg": {
                      "type": "string"
                    },
                    "status": {
                      "enum": [
                        "executing",
                        "queued"
                      ],
                      "type": "string"
                    }
                  },
                  "type": "object"
                }
              }
            },
            "description": "Request accepted."
          },
          "303": {
            "description": "Data ready.",
            "headers": {
              "Location": {
                "description": "URL to download data",
                "schema": {
                  "format": "url",
                  "type": "string"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            },
            "description": "Token does not grant poll access to this query or spatial aggregation unit."
          },
          "404": {
            "description": "Unknown ID"
          },
          "500": {
            "description": "Server error."
          }
        },
        "summary": "Get the status of a query"
      }
    },
    "/api/0/run": {
      "post": {
        "operationId": "query.run_query.post",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/FlowmachineQuerySchema"
              }
            }
          },
          "required": true
        },
        "responses": {
          "202": {
            "description": "Request accepted.",
            "headers": {
              "Location": {
                "description": "URL to poll for status",
                "schema": {
                  "format": "url",
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            },
            "description": "Query spec could not be run.."
          },
          "401": {
            "description": "Unauthorized."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            },
            "description": "Token does not grant run access to this query or spatial aggregation unit."
          },
          "500": {
            "description": "Server error."
          }
        },
        "summary": "Run a query"
      }
    }
  }
}