{
  "swagger": "2.0",
  "info": {
    "title": "Series cache 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": {
    "/timeseries/series-cache/v1/logical-series/{logicalSeriesRid}/get-chunks": {
      "post": {
        "operationId": "SeriesCacheService_getChunks",
        "summary": "Get chunks",
        "tags": [
          "Series Cache Service"
        ],
        "description": "Fetches \"chunks\" of series that are stored as Arrow files in S3. This endpoint is being deprecated for new series in favor of batchGetCachedSeries",
        "parameters": [
          {
            "name": "logicalSeriesRid",
            "in": "path",
            "type": "string",
            "format": "rid",
            "x-alias": "LogicalSeriesRid",
            "required": true
          },
          {
            "name": "getChunksParameters",
            "in": "body",
            "schema": {
              "$ref": "#/definitions/GetChunksParameters"
            },
            "required": true,
            "x-example": {
              "startTimestamp": {
                "seconds": 1,
                "nanos": 1
              },
              "endTimestamp": {
                "seconds": 1,
                "nanos": 1
              },
              "resolutionNanos": 1
            }
          }
        ],
        "responses": {
          "200": {
            "description": "A successful response.",
            "schema": {
              "$ref": "#/definitions/GetChunksResponse"
            },
            "x-example": {
              "chunks": [
                {
                  "rid": "<chunk rid>",
                  "type": "ARROW_WITH_RELATIVE_TIMESTAMPS",
                  "logicalSeriesRid": "<logical series rid>",
                  "startTimestamp": {
                    "seconds": 1,
                    "nanos": 1
                  },
                  "endTimestamp": {
                    "seconds": 1,
                    "nanos": 1
                  },
                  "count": 1,
                  "sizeInBytes": 1,
                  "resolution": 1,
                  "handle": {
                    "type": "s3",
                    "s3": {
                      "s3Path": "<s3 path>"
                    }
                  }
                }
              ]
            }
          }
        }
      }
    },
    "/timeseries/series-cache/v1/logical-series/{logicalSeriesRid}/create-chunks": {
      "post": {
        "operationId": "SeriesCacheService_createChunks",
        "summary": "Create chunks",
        "tags": [
          "Series Cache Service"
        ],
        "deprecated": true,
        "x-deprecated": "Deprecated in favor of batchCreateChunks",
        "parameters": [
          {
            "name": "logicalSeriesRid",
            "in": "path",
            "type": "string",
            "format": "rid",
            "x-alias": "LogicalSeriesRid",
            "required": true
          },
          {
            "name": "createChunksParameters",
            "in": "body",
            "schema": {
              "$ref": "#/definitions/CreateChunksParameters"
            },
            "required": true,
            "x-example": {
              "createChunks": [
                {
                  "type": "ARROW_WITH_RELATIVE_TIMESTAMPS",
                  "logicalSeriesRid": "<logical series rid>",
                  "startTimestamp": {
                    "seconds": 1,
                    "nanos": 1
                  },
                  "endTimestamp": {
                    "seconds": 1,
                    "nanos": 1
                  },
                  "count": 1,
                  "sizeInBytes": 1,
                  "resolution": 1,
                  "handle": {
                    "type": "s3",
                    "s3": {
                      "s3Path": "<s3 path>"
                    }
                  }
                }
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "A successful response.",
            "schema": {
              "$ref": "#/definitions/CreateChunksResponse"
            },
            "x-example": {
              "chunkRids": [
                "<chunk rid>"
              ]
            }
          }
        }
      }
    },
    "/timeseries/series-cache/v1/batch-create-chunks": {
      "post": {
        "operationId": "SeriesCacheService_batchCreateChunks",
        "summary": "Batch create chunks",
        "tags": [
          "Series Cache Service"
        ],
        "parameters": [
          {
            "name": "request",
            "in": "body",
            "schema": {
              "$ref": "#/definitions/CreateChunksParameters"
            },
            "required": true,
            "x-example": {
              "createChunks": [
                {
                  "type": "ARROW_WITH_RELATIVE_TIMESTAMPS",
                  "logicalSeriesRid": "<logical series rid>",
                  "startTimestamp": {
                    "seconds": 1,
                    "nanos": 1
                  },
                  "endTimestamp": {
                    "seconds": 1,
                    "nanos": 1
                  },
                  "count": 1,
                  "sizeInBytes": 1,
                  "resolution": 1,
                  "handle": {
                    "type": "s3",
                    "s3": {
                      "s3Path": "<s3 path>"
                    }
                  }
                }
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "A successful response.",
            "schema": {
              "$ref": "#/definitions/CreateChunksResponse"
            },
            "x-example": {
              "chunkRids": [
                "<chunk rid>"
              ]
            }
          }
        }
      }
    },
    "/timeseries/series-cache/v1/logical-series/{logicalSeriesRid}/delete-chunks": {
      "post": {
        "operationId": "SeriesCacheService_deleteChunks",
        "summary": "Delete chunks",
        "tags": [
          "Series Cache Service"
        ],
        "description": "Deletes the chunks that intersect the given time range. Does not delete the corresponding files from S3.",
        "parameters": [
          {
            "name": "logicalSeriesRid",
            "in": "path",
            "type": "string",
            "format": "rid",
            "x-alias": "LogicalSeriesRid",
            "required": true
          },
          {
            "name": "request",
            "in": "body",
            "schema": {
              "$ref": "#/definitions/DeleteChunksParameters"
            },
            "required": true,
            "x-example": {
              "startTimestamp": {
                "seconds": 1,
                "nanos": 1
              },
              "endTimestamp": {
                "seconds": 1,
                "nanos": 1
              }
            }
          }
        ],
        "responses": {
          "200": {
            "description": "A successful response.",
            "schema": {
              "$ref": "#/definitions/DeleteChunksResponse"
            },
            "x-example": {
              "deletedChunkRids": [
                "<chunk rid>"
              ]
            }
          }
        }
      }
    }
  },
  "definitions": {
    "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"
      ]
    },
    "Chunk": {
      "type": "object",
      "properties": {
        "rid": {
          "type": "string",
          "format": "rid",
          "x-alias": "ChunkRid"
        },
        "type": {
          "$ref": "#/definitions/ChunkType"
        },
        "logicalSeriesRid": {
          "type": "string",
          "format": "rid",
          "x-alias": "LogicalSeriesRid"
        },
        "startTimestamp": {
          "$ref": "#/definitions/Timestamp"
        },
        "endTimestamp": {
          "$ref": "#/definitions/Timestamp"
        },
        "count": {
          "type": "integer",
          "format": "int64",
          "description": "The number of distinct timestamps contained within the chunk."
        },
        "sizeInBytes": {
          "type": "integer",
          "format": "int64"
        },
        "resolution": {
          "type": "integer",
          "format": "int64",
          "x-alias": "Resolution"
        },
        "handle": {
          "$ref": "#/definitions/Handle"
        }
      },
      "required": [
        "rid",
        "type",
        "logicalSeriesRid",
        "startTimestamp",
        "endTimestamp",
        "count",
        "sizeInBytes",
        "resolution",
        "handle"
      ]
    },
    "ChunkType": {
      "type": "string",
      "enum": [
        "ARROW_WITH_RELATIVE_TIMESTAMPS",
        "ARROW_WITH_ABSOLUTE_TIMESTAMPS"
      ]
    },
    "CreateChunk": {
      "type": "object",
      "properties": {
        "type": {
          "$ref": "#/definitions/ChunkType"
        },
        "logicalSeriesRid": {
          "type": "string",
          "format": "rid",
          "x-alias": "LogicalSeriesRid"
        },
        "startTimestamp": {
          "$ref": "#/definitions/Timestamp"
        },
        "endTimestamp": {
          "$ref": "#/definitions/Timestamp"
        },
        "count": {
          "type": "integer",
          "format": "int64"
        },
        "sizeInBytes": {
          "type": "integer",
          "format": "int64"
        },
        "resolution": {
          "type": "integer",
          "format": "int64",
          "x-alias": "Resolution"
        },
        "handle": {
          "$ref": "#/definitions/Handle"
        }
      },
      "required": [
        "type",
        "logicalSeriesRid",
        "startTimestamp",
        "endTimestamp",
        "count",
        "sizeInBytes",
        "resolution",
        "handle"
      ]
    },
    "CreateChunksParameters": {
      "type": "object",
      "properties": {
        "createChunks": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/CreateChunk"
          }
        }
      },
      "example": {
        "createChunks": [
          {
            "type": "ARROW_WITH_RELATIVE_TIMESTAMPS",
            "logicalSeriesRid": "<logical series rid>",
            "startTimestamp": {
              "seconds": 1,
              "nanos": 1
            },
            "endTimestamp": {
              "seconds": 1,
              "nanos": 1
            },
            "count": 1,
            "sizeInBytes": 1,
            "resolution": 1,
            "handle": {
              "type": "s3",
              "s3": {
                "s3Path": "<s3 path>"
              }
            }
          }
        ]
      }
    },
    "CreateChunksResponse": {
      "description": "Responses are returned in the same order as the requests.",
      "type": "object",
      "properties": {
        "chunkRids": {
          "type": "array",
          "items": {
            "type": "string",
            "format": "rid",
            "x-alias": "ChunkRid"
          }
        }
      }
    },
    "DeleteChunksParameters": {
      "type": "object",
      "properties": {
        "startTimestamp": {
          "$ref": "#/definitions/Timestamp"
        },
        "endTimestamp": {
          "$ref": "#/definitions/Timestamp"
        }
      },
      "required": [
        "startTimestamp",
        "endTimestamp"
      ],
      "example": {
        "startTimestamp": {
          "seconds": 1,
          "nanos": 1
        },
        "endTimestamp": {
          "seconds": 1,
          "nanos": 1
        }
      }
    },
    "DeleteChunksResponse": {
      "type": "object",
      "properties": {
        "deletedChunkRids": {
          "type": "array",
          "items": {
            "type": "string",
            "format": "rid",
            "x-alias": "ChunkRid"
          },
          "uniqueItems": true
        }
      }
    },
    "GetChunksParameters": {
      "type": "object",
      "properties": {
        "startTimestamp": {
          "$ref": "#/definitions/Timestamp"
        },
        "endTimestamp": {
          "$ref": "#/definitions/Timestamp"
        },
        "resolutionNanos": {
          "type": "integer",
          "format": "int64"
        }
      },
      "required": [
        "startTimestamp",
        "endTimestamp",
        "resolutionNanos"
      ],
      "example": {
        "startTimestamp": {
          "seconds": 1,
          "nanos": 1
        },
        "endTimestamp": {
          "seconds": 1,
          "nanos": 1
        },
        "resolutionNanos": 1
      }
    },
    "GetChunksResponse": {
      "type": "object",
      "properties": {
        "chunks": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/Chunk"
          }
        }
      }
    },
    "Handle": {
      "type": "object",
      "x-union": true,
      "properties": {
        "type": {
          "type": "string",
          "enum": [
            "s3"
          ]
        },
        "s3": {
          "$ref": "#/definitions/S3Handle"
        }
      },
      "required": [
        "type"
      ],
      "description": "Set `type` to the name of one of the other fields, and set only that field.",
      "example": {
        "type": "s3",
        "s3": {
          "s3Path": "string"
        }
      }
    },
    "S3Handle": {
      "type": "object",
      "properties": {
        "s3Path": {
          "type": "string",
          "x-alias": "S3Path"
        }
      },
      "required": [
        "s3Path"
      ]
    }
  },
  "tags": [
    {
      "name": "Series Cache Service",
      "x-displayName": "Series cache service",
      "description": "The Series Cache service manages internal chunks of data cached by Nominal's backend.",
      "x-errors": [
        {
          "status": 409,
          "errorCode": "CONFLICT",
          "errorName": "SeriesCache:ChunkAlreadyExists"
        }
      ]
    }
  ]
}
