{
  "$type": "com.atproto.lexicon.schema",
  "defs": {
    "bucket": {
      "properties": {
        "client": {
          "format": "did",
          "type": "string"
        },
        "connections": {
          "description": "Visitor connections that reached the Client.",
          "minimum": 0,
          "type": "integer"
        },
        "egress": {
          "description": "Bytes from the Client to visitors.",
          "minimum": 0,
          "type": "integer"
        },
        "hostname": {
          "maxLength": 253,
          "type": "string"
        },
        "ingress": {
          "description": "Bytes from visitors to the Client.",
          "minimum": 0,
          "type": "integer"
        },
        "start": {
          "format": "datetime",
          "type": "string"
        }
      },
      "required": [
        "start",
        "client",
        "hostname",
        "ingress",
        "egress",
        "connections"
      ],
      "type": "object"
    },
    "main": {
      "description": "Get the traffic a Provider carried, in buckets of time, for every Client or one.",
      "errors": [
        {
          "description": "The Provider has no operator.",
          "name": "OperatorNotSet"
        },
        {
          "description": "The caller is not the Provider's operator.",
          "name": "NotOperator"
        }
      ],
      "output": {
        "encoding": "application/json",
        "schema": {
          "properties": {
            "bucketSeconds": {
              "description": "The length of each bucket.",
              "minimum": 1,
              "type": "integer"
            },
            "buckets": {
              "description": "One per Client and hostname with traffic in that bucket.",
              "items": {
                "ref": "#bucket",
                "type": "ref"
              },
              "type": "array"
            },
            "from": {
              "format": "datetime",
              "type": "string"
            },
            "to": {
              "format": "datetime",
              "type": "string"
            }
          },
          "required": [
            "bucketSeconds",
            "from",
            "to",
            "buckets"
          ],
          "type": "object"
        }
      },
      "parameters": {
        "properties": {
          "client": {
            "description": "Only this Client's traffic.",
            "format": "did",
            "type": "string"
          },
          "window": {
            "description": "How far back to look.",
            "knownValues": [
              "1h",
              "6h",
              "1d",
              "7d",
              "30d",
              "365d"
            ],
            "maxLength": 16,
            "type": "string"
          }
        },
        "required": [
          "window"
        ],
        "type": "params"
      },
      "type": "query"
    }
  },
  "id": "link.jetbridge.getTraffic",
  "lexicon": 1
}
