{
  "swagger": "2.0",
  "info": {
    "title": "Streaming session service",
    "version": "0.1507.0",
    "description": "Send your API key as a bearer token: `Authorization: Bearer <api key>`."
  },
  "consumes": [
    "application/json"
  ],
  "produces": [
    "application/json"
  ],
  "securityDefinitions": {
    "ApiKey": {
      "type": "apiKey",
      "in": "header",
      "name": "Authorization",
      "description": "Your API key as a bearer token: `Authorization: Bearer <api key>`."
    }
  },
  "security": [
    {
      "ApiKey": []
    }
  ],
  "paths": {
    "/ingest/v1/internal/streaming-session/dataset/{datasetRid}/resolve": {
      "post": {
        "operationId": "StreamingSessionService_resolve",
        "summary": "Resolve",
        "tags": [
          "Streaming Session Service"
        ],
        "parameters": [
          {
            "name": "datasetRid",
            "in": "path",
            "type": "string",
            "format": "rid",
            "x-alias": "DatasetRid",
            "required": true
          },
          {
            "name": "request",
            "in": "body",
            "schema": {
              "$ref": "#/definitions/ResolveStreamingSessionRequest"
            },
            "required": true,
            "x-example": {
              "source": {
                "type": "mesh",
                "mesh": {
                  "sourceDatasetRid": "<dataset rid>",
                  "sourceOrgRid": "<org rid>",
                  "originStreamingSessionSource": "<origin streaming session source>"
                }
              }
            }
          }
        ],
        "responses": {
          "200": {
            "description": "A successful response.",
            "schema": {
              "$ref": "#/definitions/ResolveStreamingSessionResponse"
            },
            "x-example": {
              "sessionRid": "<streaming session rid>",
              "datasetRid": "<dataset rid>",
              "status": "IN_PROGRESS",
              "source": {
                "type": "mesh",
                "mesh": {
                  "sourceDatasetRid": "<dataset rid>",
                  "sourceOrgRid": "<org rid>",
                  "originStreamingSessionSource": "<origin streaming session source>"
                }
              },
              "bounds": {
                "start": {
                  "seconds": 1,
                  "nanos": 1
                },
                "end": {
                  "seconds": 1,
                  "nanos": 1
                }
              },
              "pointsCount": 1,
              "createdAt": {
                "seconds": 1,
                "nanos": 1
              }
            }
          }
        }
      }
    },
    "/ingest/v1/internal/streaming-session/{sessionRid}/heartbeat": {
      "put": {
        "operationId": "StreamingSessionService_heartbeat",
        "summary": "Heartbeat",
        "tags": [
          "Streaming Session Service"
        ],
        "parameters": [
          {
            "name": "sessionRid",
            "in": "path",
            "type": "string",
            "format": "rid",
            "x-alias": "StreamingSessionRid",
            "required": true
          },
          {
            "name": "request",
            "in": "body",
            "schema": {
              "$ref": "#/definitions/HeartbeatStreamingSessionRequest"
            },
            "required": true,
            "x-example": {
              "bounds": {
                "start": {
                  "seconds": 1,
                  "nanos": 1
                },
                "end": {
                  "seconds": 1,
                  "nanos": 1
                }
              },
              "pointsCount": 1
            }
          }
        ],
        "responses": {
          "204": {
            "description": "No content."
          }
        }
      }
    },
    "/ingest/v1/streaming-sessions/search": {
      "post": {
        "operationId": "StreamingSessionService_searchStreamingSessions",
        "summary": "Search streaming sessions",
        "tags": [
          "Streaming Session Service"
        ],
        "description": "Returns a paginated list of streaming sessions, optionally filtered by dataset.",
        "parameters": [
          {
            "name": "request",
            "in": "body",
            "schema": {
              "$ref": "#/definitions/SearchStreamingSessionsRequest"
            },
            "required": true,
            "x-example": {
              "pageSize": 1,
              "nextPageToken": "<token>",
              "filter": {
                "type": "datasetRids",
                "datasetRids": [
                  "<dataset rid>"
                ]
              },
              "sort": {
                "isDescending": true,
                "sortKey": "CREATED_AT"
              }
            }
          }
        ],
        "responses": {
          "200": {
            "description": "A successful response.",
            "schema": {
              "$ref": "#/definitions/SearchStreamingSessionsResponse"
            },
            "x-example": {
              "streamingSessions": [
                {
                  "sessionRid": "<streaming session rid>",
                  "datasetRid": "<dataset rid>",
                  "status": "IN_PROGRESS",
                  "source": {
                    "type": "mesh",
                    "mesh": {
                      "sourceDatasetRid": "<dataset rid>",
                      "sourceOrgRid": "<org rid>",
                      "originStreamingSessionSource": "<origin streaming session source>"
                    }
                  },
                  "bounds": {
                    "start": {
                      "seconds": 1,
                      "nanos": 1
                    },
                    "end": {
                      "seconds": 1,
                      "nanos": 1
                    }
                  },
                  "pointsCount": 1,
                  "createdAt": {
                    "seconds": 1,
                    "nanos": 1
                  },
                  "lastSeenAt": {
                    "seconds": 1,
                    "nanos": 1
                  },
                  "closedAt": {
                    "seconds": 1,
                    "nanos": 1
                  }
                }
              ],
              "nextPageToken": "<token>"
            }
          }
        }
      }
    },
    "/ingest/v1/streaming-sources/search": {
      "post": {
        "operationId": "StreamingSessionService_searchStreamingSources",
        "summary": "Search streaming sources",
        "tags": [
          "Streaming Session Service"
        ],
        "description": "Returns a paginated list of streaming sessions aggregated by (source, dataset) group, ordered by latest activity descending.",
        "parameters": [
          {
            "name": "request",
            "in": "body",
            "schema": {
              "$ref": "#/definitions/SearchStreamingSourcesRequest"
            },
            "required": true,
            "x-example": {
              "pageSize": 1,
              "nextPageToken": "<token>",
              "filter": {
                "type": "datasetRids",
                "datasetRids": [
                  "<dataset rid>"
                ]
              },
              "activityAfter": {
                "seconds": 1,
                "nanos": 1
              }
            }
          }
        ],
        "responses": {
          "200": {
            "description": "A successful response.",
            "schema": {
              "$ref": "#/definitions/SearchStreamingSourcesResponse"
            },
            "x-example": {
              "streamingSources": [
                {
                  "source": {
                    "type": "mesh",
                    "mesh": {
                      "sourceDatasetRid": "<dataset rid>",
                      "sourceOrgRid": "<org rid>",
                      "originStreamingSessionSource": "<origin streaming session source>"
                    }
                  },
                  "datasetRid": "<dataset rid>",
                  "sessionCount": 1,
                  "totalPointsCount": 1,
                  "earliestCreatedAt": {
                    "seconds": 1,
                    "nanos": 1
                  },
                  "latestLastSeenAt": {
                    "seconds": 1,
                    "nanos": 1
                  },
                  "mergedBounds": {
                    "start": {
                      "seconds": 1,
                      "nanos": 1
                    },
                    "end": {
                      "seconds": 1,
                      "nanos": 1
                    }
                  },
                  "anyInProgress": true
                }
              ],
              "nextPageToken": "<token>"
            }
          }
        }
      }
    }
  },
  "definitions": {
    "Range": {
      "description": "Deprecated for new APIs. Define an API-owned range with the endpoint semantics it needs instead.",
      "type": "object",
      "properties": {
        "start": {
          "$ref": "#/definitions/Timestamp"
        },
        "end": {
          "$ref": "#/definitions/Timestamp"
        }
      },
      "required": [
        "start",
        "end"
      ]
    },
    "Timestamp": {
      "description": "Deprecated for new APIs. Use google.protobuf.Timestamp for absolute instants in proto APIs.\n\nThis legacy nanosecond precision timestamp type is represented by an epoch time in seconds and a nanosecond offset. The nanosecond offset is from the start of the epoch second, so must be less than 1 billion.",
      "type": "object",
      "properties": {
        "seconds": {
          "type": "integer",
          "format": "int64"
        },
        "nanos": {
          "type": "integer",
          "format": "int64"
        }
      },
      "required": [
        "seconds",
        "nanos"
      ]
    },
    "CustomStreamingSessionSource": {
      "type": "object",
      "properties": {
        "sourceName": {
          "type": "string"
        }
      },
      "required": [
        "sourceName"
      ]
    },
    "DataConnectorStreamingSessionSource": {
      "type": "object",
      "properties": {
        "dataConnectorRid": {
          "type": "string",
          "format": "rid",
          "x-alias": "DataConnectorRid"
        }
      },
      "required": [
        "dataConnectorRid"
      ]
    },
    "HeartbeatStreamingSessionRequest": {
      "type": "object",
      "properties": {
        "bounds": {
          "allOf": [
            {
              "$ref": "#/definitions/Range"
            }
          ],
          "description": "The time range of data points ingested since the last heartbeat. The server atomically merges this with the session's existing bounds using LEAST/GREATEST to track the full time range."
        },
        "pointsCount": {
          "type": "integer",
          "format": "int32",
          "description": "Number of data points ingested since the last heartbeat. The server atomically adds this to the session's running total."
        }
      },
      "required": [
        "bounds",
        "pointsCount"
      ],
      "example": {
        "bounds": {
          "start": {
            "seconds": 1,
            "nanos": 1
          },
          "end": {
            "seconds": 1,
            "nanos": 1
          }
        },
        "pointsCount": 1
      }
    },
    "MeshStreamingSessionSource": {
      "type": "object",
      "properties": {
        "sourceDatasetRid": {
          "type": "string",
          "format": "rid",
          "x-alias": "DatasetRid"
        },
        "sourceOrgRid": {
          "type": "string",
          "format": "rid",
          "x-alias": "OrgRid"
        },
        "originStreamingSessionSource": {
          "type": "string"
        }
      },
      "required": [
        "sourceDatasetRid",
        "sourceOrgRid",
        "originStreamingSessionSource"
      ]
    },
    "ResolveStreamingSessionRequest": {
      "type": "object",
      "properties": {
        "source": {
          "allOf": [
            {
              "$ref": "#/definitions/StreamingSessionSource"
            }
          ],
          "description": "The source attribution for this streaming session. Each unique source gets its own in-progress session per dataset. If absent, the session is unattributed."
        }
      },
      "example": {
        "source": {
          "type": "mesh",
          "mesh": {
            "sourceDatasetRid": "<dataset rid>",
            "sourceOrgRid": "<org rid>",
            "originStreamingSessionSource": "<origin streaming session source>"
          }
        }
      }
    },
    "ResolveStreamingSessionResponse": {
      "type": "object",
      "properties": {
        "sessionRid": {
          "type": "string",
          "format": "rid",
          "x-alias": "StreamingSessionRid"
        },
        "datasetRid": {
          "type": "string",
          "format": "rid",
          "x-alias": "DatasetRid"
        },
        "status": {
          "$ref": "#/definitions/StreamingSessionStatus"
        },
        "source": {
          "$ref": "#/definitions/StreamingSessionSource"
        },
        "bounds": {
          "$ref": "#/definitions/Range"
        },
        "pointsCount": {
          "type": "integer",
          "format": "int64"
        },
        "createdAt": {
          "$ref": "#/definitions/Timestamp"
        }
      },
      "required": [
        "sessionRid",
        "datasetRid",
        "status",
        "pointsCount",
        "createdAt"
      ]
    },
    "SearchStreamingSessionsRequest": {
      "type": "object",
      "properties": {
        "pageSize": {
          "type": "integer",
          "format": "int32",
          "description": "Defaults to 100. Clamped to 1_000 if larger, and to 1 if non-positive."
        },
        "nextPageToken": {
          "type": "string",
          "x-alias": "Token"
        },
        "filter": {
          "$ref": "#/definitions/StreamingSessionSearchFilter"
        },
        "sort": {
          "allOf": [
            {
              "$ref": "#/definitions/StreamingSessionSortOptions"
            }
          ],
          "description": "Defaults to created_at DESC when omitted."
        }
      },
      "example": {
        "pageSize": 1,
        "nextPageToken": "<token>",
        "filter": {
          "type": "datasetRids",
          "datasetRids": [
            "<dataset rid>"
          ]
        },
        "sort": {
          "isDescending": true,
          "sortKey": "CREATED_AT"
        }
      }
    },
    "SearchStreamingSessionsResponse": {
      "type": "object",
      "properties": {
        "streamingSessions": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/StreamingSession"
          }
        },
        "nextPageToken": {
          "type": "string",
          "x-alias": "Token"
        }
      }
    },
    "SearchStreamingSourcesRequest": {
      "type": "object",
      "properties": {
        "pageSize": {
          "type": "integer",
          "format": "int32",
          "description": "Defaults to 100. Clamped to 1_000 if larger, and to 1 if non-positive."
        },
        "nextPageToken": {
          "type": "string",
          "x-alias": "Token"
        },
        "filter": {
          "$ref": "#/definitions/StreamingSourceSearchFilter"
        },
        "activityAfter": {
          "allOf": [
            {
              "$ref": "#/definitions/Timestamp"
            }
          ],
          "description": "If present, only sessions last seen strictly after this instant are aggregated; groups whose sessions were all last seen at or before it are omitted."
        }
      },
      "example": {
        "pageSize": 1,
        "nextPageToken": "<token>",
        "filter": {
          "type": "datasetRids",
          "datasetRids": [
            "<dataset rid>"
          ]
        },
        "activityAfter": {
          "seconds": 1,
          "nanos": 1
        }
      }
    },
    "SearchStreamingSourcesResponse": {
      "type": "object",
      "properties": {
        "streamingSources": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/StreamingSource"
          }
        },
        "nextPageToken": {
          "type": "string",
          "x-alias": "Token"
        }
      }
    },
    "StreamingSession": {
      "description": "Public view of a streaming ingest session.",
      "type": "object",
      "properties": {
        "sessionRid": {
          "type": "string",
          "format": "rid",
          "x-alias": "StreamingSessionRid"
        },
        "datasetRid": {
          "type": "string",
          "format": "rid",
          "x-alias": "DatasetRid"
        },
        "status": {
          "$ref": "#/definitions/StreamingSessionStatus"
        },
        "source": {
          "$ref": "#/definitions/StreamingSessionSource"
        },
        "bounds": {
          "$ref": "#/definitions/Range"
        },
        "pointsCount": {
          "type": "integer",
          "format": "int64"
        },
        "createdAt": {
          "$ref": "#/definitions/Timestamp"
        },
        "lastSeenAt": {
          "allOf": [
            {
              "$ref": "#/definitions/Timestamp"
            }
          ],
          "description": "Time of the most recent heartbeat for this session."
        },
        "closedAt": {
          "allOf": [
            {
              "$ref": "#/definitions/Timestamp"
            }
          ],
          "description": "Time the session was completed. Absent while the session is in progress."
        }
      },
      "required": [
        "sessionRid",
        "datasetRid",
        "status",
        "pointsCount",
        "createdAt",
        "lastSeenAt"
      ]
    },
    "StreamingSessionSearchFilter": {
      "description": "Filter for streaming-session search. An empty `datasetRids` list matches all sessions. Filters compose with `and`/`or`/`not`.\n\nSet `type` to the name of one of the other fields, and set only that field.",
      "type": "object",
      "x-union": true,
      "properties": {
        "type": {
          "type": "string",
          "enum": [
            "datasetRids",
            "source",
            "timeRange",
            "workspace",
            "and",
            "or",
            "not"
          ]
        },
        "datasetRids": {
          "type": "array",
          "items": {
            "type": "string",
            "format": "rid",
            "x-alias": "DatasetRid"
          }
        },
        "source": {
          "$ref": "#/definitions/StreamingSourceFilter"
        },
        "timeRange": {
          "$ref": "#/definitions/StreamingSessionTimeRangeFilter"
        },
        "workspace": {
          "type": "string",
          "format": "rid",
          "x-alias": "WorkspaceRid",
          "description": "Matches sessions whose dataset belongs to the workspace."
        },
        "and": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/StreamingSessionSearchFilter"
          }
        },
        "or": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/StreamingSessionSearchFilter"
          }
        },
        "not": {
          "$ref": "#/definitions/StreamingSessionSearchFilter"
        }
      },
      "required": [
        "type"
      ],
      "example": {
        "type": "datasetRids",
        "datasetRids": [
          "string"
        ]
      }
    },
    "StreamingSessionSortKey": {
      "type": "string",
      "enum": [
        "CREATED_AT",
        "DATA_BOUNDS_START"
      ],
      "x-enum-descriptions": {
        "CREATED_AT": "Orders by the time the session was created.",
        "DATA_BOUNDS_START": "Orders by the start of the session's data bounds. Sessions with no data bounds are excluded from the results."
      }
    },
    "StreamingSessionSortOptions": {
      "type": "object",
      "properties": {
        "isDescending": {
          "type": "boolean"
        },
        "sortKey": {
          "$ref": "#/definitions/StreamingSessionSortKey"
        }
      },
      "required": [
        "isDescending",
        "sortKey"
      ]
    },
    "StreamingSessionSource": {
      "type": "object",
      "x-union": true,
      "properties": {
        "type": {
          "type": "string",
          "enum": [
            "mesh",
            "dataConnector",
            "custom"
          ]
        },
        "mesh": {
          "$ref": "#/definitions/MeshStreamingSessionSource"
        },
        "dataConnector": {
          "$ref": "#/definitions/DataConnectorStreamingSessionSource"
        },
        "custom": {
          "$ref": "#/definitions/CustomStreamingSessionSource"
        }
      },
      "required": [
        "type"
      ],
      "description": "Set `type` to the name of one of the other fields, and set only that field.",
      "example": {
        "type": "mesh",
        "mesh": {
          "sourceDatasetRid": "string",
          "sourceOrgRid": "string",
          "originStreamingSessionSource": "string"
        }
      }
    },
    "StreamingSessionStatus": {
      "type": "string",
      "enum": [
        "IN_PROGRESS",
        "COMPLETED"
      ]
    },
    "StreamingSessionTimeRangeFilter": {
      "description": "Matches sessions whose data bounds overlap this window. Sessions with no data bounds do not match. If both bounds are present, `start` must not be after `end`.",
      "type": "object",
      "properties": {
        "start": {
          "$ref": "#/definitions/Timestamp"
        },
        "end": {
          "$ref": "#/definitions/Timestamp"
        }
      }
    },
    "StreamingSource": {
      "description": "Aggregate view of the streaming sessions sharing a single (source, dataset) pair.",
      "type": "object",
      "properties": {
        "source": {
          "allOf": [
            {
              "$ref": "#/definitions/StreamingSessionSource"
            }
          ],
          "description": "The source attribution shared by the aggregated sessions. Absent for unattributed sessions."
        },
        "datasetRid": {
          "type": "string",
          "format": "rid",
          "x-alias": "DatasetRid"
        },
        "sessionCount": {
          "type": "integer",
          "format": "int64",
          "description": "Number of sessions aggregated into this group."
        },
        "totalPointsCount": {
          "type": "integer",
          "format": "int64",
          "description": "Sum of the points counts across the aggregated sessions."
        },
        "earliestCreatedAt": {
          "allOf": [
            {
              "$ref": "#/definitions/Timestamp"
            }
          ],
          "description": "Creation time of the oldest aggregated session."
        },
        "latestLastSeenAt": {
          "allOf": [
            {
              "$ref": "#/definitions/Timestamp"
            }
          ],
          "description": "Most recent heartbeat time across the aggregated sessions."
        },
        "mergedBounds": {
          "allOf": [
            {
              "$ref": "#/definitions/Range"
            }
          ],
          "description": "Union of the data bounds across the aggregated sessions, if any session has bounds."
        },
        "anyInProgress": {
          "type": "boolean",
          "description": "True if at least one aggregated session is in progress."
        }
      },
      "required": [
        "datasetRid",
        "sessionCount",
        "totalPointsCount",
        "earliestCreatedAt",
        "latestLastSeenAt",
        "anyInProgress"
      ]
    },
    "StreamingSourceFilter": {
      "description": "Matches the sessions of a single streaming source: the sessions on `datasetRid` with exactly the given `source` attribution. An absent `source` matches unattributed sessions.",
      "type": "object",
      "properties": {
        "datasetRid": {
          "type": "string",
          "format": "rid",
          "x-alias": "DatasetRid"
        },
        "source": {
          "$ref": "#/definitions/StreamingSessionSource"
        }
      },
      "required": [
        "datasetRid"
      ]
    },
    "StreamingSourceSearchFilter": {
      "description": "Filter for streaming-source search. An empty `datasetRids` list matches all sources. Filters compose with `and`/`or`/`not`.\n\nSet `type` to the name of one of the other fields, and set only that field.",
      "type": "object",
      "x-union": true,
      "properties": {
        "type": {
          "type": "string",
          "enum": [
            "datasetRids",
            "source",
            "workspace",
            "and",
            "or",
            "not"
          ]
        },
        "datasetRids": {
          "type": "array",
          "items": {
            "type": "string",
            "format": "rid",
            "x-alias": "DatasetRid"
          }
        },
        "source": {
          "$ref": "#/definitions/StreamingSourceFilter"
        },
        "workspace": {
          "type": "string",
          "format": "rid",
          "x-alias": "WorkspaceRid",
          "description": "Matches sources whose dataset belongs to the workspace."
        },
        "and": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/StreamingSourceSearchFilter"
          }
        },
        "or": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/StreamingSourceSearchFilter"
          }
        },
        "not": {
          "$ref": "#/definitions/StreamingSourceSearchFilter"
        }
      },
      "required": [
        "type"
      ],
      "example": {
        "type": "datasetRids",
        "datasetRids": [
          "string"
        ]
      }
    }
  },
  "tags": [
    {
      "name": "Streaming Session Service",
      "x-displayName": "Streaming session service"
    }
  ]
}
