{
  "swagger": "2.0",
  "info": {
    "title": "Direct Nominal channel writer",
    "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": {
    "/storage/direct-writer/v1": {
      "post": {
        "operationId": "DirectNominalChannelWriterService_writeBatches",
        "summary": "Write batches",
        "tags": [
          "Direct Nominal Channel Writer"
        ],
        "description": "Synchronously writes batches of records to a Nominal data source. This endpoint bypasses the Channel Writer service entirely, and should only be used if the implications are well understood.\n\nIf you call this endpoint, writes will go directly into Nominal DB and will not be placed in Nominal's durable queue. This results in lower latency, but also consequently lower durability.",
        "parameters": [
          {
            "name": "request",
            "in": "body",
            "schema": {
              "$ref": "#/definitions/WriteBatchesRequest"
            },
            "required": true,
            "x-example": {
              "dataSourceRid": "<nominal data source or dataset rid>"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "No content."
          }
        }
      }
    }
  },
  "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"
      ]
    },
    "ArrayPoints": {
      "description": "Array points for the internal API for directly writing points which supports all points types.\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": [
            "double",
            "string"
          ]
        },
        "double": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/DoubleArrayPoint"
          }
        },
        "string": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/StringArrayPoint"
          }
        }
      },
      "required": [
        "type"
      ],
      "example": {
        "type": "double",
        "double": [
          {
            "timestamp": {
              "seconds": 1,
              "nanos": 1
            },
            "value": [
              1
            ]
          }
        ]
      }
    },
    "DoubleArrayPoint": {
      "type": "object",
      "properties": {
        "timestamp": {
          "$ref": "#/definitions/Timestamp"
        },
        "value": {
          "type": "array",
          "items": {
            "type": "number",
            "format": "double"
          }
        }
      },
      "required": [
        "timestamp"
      ]
    },
    "DoublePoint": {
      "type": "object",
      "properties": {
        "timestamp": {
          "$ref": "#/definitions/Timestamp"
        },
        "value": {
          "type": "number",
          "format": "double"
        }
      },
      "required": [
        "timestamp",
        "value"
      ]
    },
    "IntPoint": {
      "type": "object",
      "properties": {
        "timestamp": {
          "$ref": "#/definitions/Timestamp"
        },
        "value": {
          "type": "integer",
          "format": "int32"
        }
      },
      "required": [
        "timestamp",
        "value"
      ]
    },
    "LogPoint": {
      "type": "object",
      "properties": {
        "timestamp": {
          "$ref": "#/definitions/Timestamp"
        },
        "value": {
          "$ref": "#/definitions/LogValue"
        }
      },
      "required": [
        "timestamp",
        "value"
      ]
    },
    "LogValue": {
      "type": "object",
      "properties": {
        "message": {
          "type": "string"
        },
        "args": {
          "type": "object",
          "additionalProperties": {
            "type": "string"
          }
        }
      },
      "required": [
        "message"
      ]
    },
    "Points": {
      "description": "Points for internal API for directly writing points which supports all points types. Logs specifically are supported externally via a separate endpoint.\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": [
            "string",
            "double",
            "log",
            "int",
            "uint64",
            "array",
            "struct"
          ]
        },
        "string": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/StringPoint"
          }
        },
        "double": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/DoublePoint"
          }
        },
        "log": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/LogPoint"
          }
        },
        "int": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/IntPoint"
          }
        },
        "uint64": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/Uint64Point"
          }
        },
        "array": {
          "$ref": "#/definitions/ArrayPoints"
        },
        "struct": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/StructPoint"
          }
        }
      },
      "required": [
        "type"
      ],
      "example": {
        "type": "string",
        "string": [
          {
            "timestamp": {
              "seconds": 1,
              "nanos": 1
            },
            "value": "string"
          }
        ]
      }
    },
    "RecordsBatch": {
      "type": "object",
      "properties": {
        "channel": {
          "type": "string",
          "x-alias": "Channel"
        },
        "tags": {
          "type": "object",
          "additionalProperties": {
            "type": "string",
            "x-alias": "TagValue"
          },
          "x-map-key": "TagName"
        },
        "points": {
          "$ref": "#/definitions/Points"
        }
      },
      "required": [
        "channel",
        "points"
      ]
    },
    "StringArrayPoint": {
      "type": "object",
      "properties": {
        "timestamp": {
          "$ref": "#/definitions/Timestamp"
        },
        "value": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      },
      "required": [
        "timestamp"
      ]
    },
    "StringPoint": {
      "type": "object",
      "properties": {
        "timestamp": {
          "$ref": "#/definitions/Timestamp"
        },
        "value": {
          "type": "string"
        }
      },
      "required": [
        "timestamp",
        "value"
      ]
    },
    "StructPoint": {
      "type": "object",
      "properties": {
        "timestamp": {
          "$ref": "#/definitions/Timestamp"
        },
        "jsonString": {
          "type": "string"
        }
      },
      "required": [
        "timestamp",
        "jsonString"
      ]
    },
    "Uint64Point": {
      "type": "object",
      "properties": {
        "timestamp": {
          "$ref": "#/definitions/Timestamp"
        },
        "value": {
          "type": "integer",
          "format": "int64"
        }
      },
      "required": [
        "timestamp",
        "value"
      ]
    },
    "WriteBatchesRequest": {
      "type": "object",
      "properties": {
        "batches": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/RecordsBatch"
          }
        },
        "dataSourceRid": {
          "type": "string",
          "format": "rid",
          "x-alias": "NominalDataSourceOrDatasetRid"
        },
        "asynchronousInsert": {
          "type": "boolean",
          "description": "Is always true - setting this to false will do nothing.",
          "x-deprecated": "Should not be used."
        }
      },
      "required": [
        "dataSourceRid"
      ],
      "example": {
        "dataSourceRid": "<nominal data source or dataset rid>"
      }
    }
  },
  "tags": [
    {
      "name": "Direct Nominal Channel Writer",
      "x-displayName": "Direct Nominal channel writer",
      "description": "Writes data points directly to Nominal's managed database offering.",
      "x-errors": [
        {
          "status": 400,
          "errorCode": "INVALID_ARGUMENT",
          "errorName": "NominalChannelWriter:InvalidTimestamp"
        },
        {
          "status": 400,
          "errorCode": "INVALID_ARGUMENT",
          "errorName": "NominalChannelWriter:InvalidTelegrafTimestamp"
        },
        {
          "status": 400,
          "errorCode": "INVALID_ARGUMENT",
          "errorName": "NominalChannelWriter:ConflictingDataTypes",
          "description": "Found two different data types for the same series in the request."
        },
        {
          "status": 400,
          "errorCode": "INVALID_ARGUMENT",
          "errorName": "NominalChannelWriter:ConflictingUnits",
          "description": "Found two different units for the same channel in the request."
        },
        {
          "status": 400,
          "errorCode": "INVALID_ARGUMENT",
          "errorName": "NominalChannelWriter:InvalidDataSource",
          "description": "The nominal data source or dataset provided is invalid."
        },
        {
          "status": 400,
          "errorCode": "INVALID_ARGUMENT",
          "errorName": "NominalChannelWriter:StreamingDisabledOnDataset",
          "description": "Unsupported dataset for streaming."
        },
        {
          "status": 400,
          "errorCode": "INVALID_ARGUMENT",
          "errorName": "NominalChannelWriter:MismatchedTimestampsAndValues",
          "description": "Columnar streaming request contains different numbers of timestamps and values"
        },
        {
          "status": 400,
          "errorCode": "INVALID_ARGUMENT",
          "errorName": "NominalChannelWriter:ArrayTooLarge",
          "description": "Array size exceeds maximum allowed length."
        },
        {
          "status": 413,
          "errorCode": "REQUEST_ENTITY_TOO_LARGE",
          "errorName": "NominalChannelWriter:PointsTooLarge",
          "description": "The size of the points being written exceeds the maximum allowed size."
        },
        {
          "status": 400,
          "errorCode": "INVALID_ARGUMENT",
          "errorName": "NominalChannelWriter:InvalidStruct",
          "description": "Ingested Struct is not a valid JSON struct"
        },
        {
          "status": 400,
          "errorCode": "INVALID_ARGUMENT",
          "errorName": "NominalChannelWriter:StructTooLarge",
          "description": "Struct value exceeds maximum allowed UTF-8 byte size."
        },
        {
          "status": 400,
          "errorCode": "INVALID_ARGUMENT",
          "errorName": "NominalChannelWriter:InvalidChannelName",
          "description": "The channel name is invalid."
        },
        {
          "status": 400,
          "errorCode": "INVALID_ARGUMENT",
          "errorName": "NominalChannelWriter:TooManySessionSources",
          "description": "The dataset has exceeded the maximum number of distinct active session sources allowed per hour. This is a best-effort limit enforced per channel-writer instance."
        },
        {
          "status": 400,
          "errorCode": "INVALID_ARGUMENT",
          "errorName": "NominalChannelWriter:TooManyChannelNameOverrides",
          "description": "The request specifies more channel name overrides than the maximum allowed."
        },
        {
          "status": 400,
          "errorCode": "INVALID_ARGUMENT",
          "errorName": "NominalChannelWriter:ReservedTagName",
          "description": "The request uses a tag name that is reserved for internal use. Remove the tag from the request."
        },
        {
          "status": 400,
          "errorCode": "INVALID_ARGUMENT",
          "errorName": "NominalChannelWriter:StreamingSessionRidNotAllowed",
          "description": "The request sets a streaming session rid, which is assigned by Nominal and cannot be provided by the client."
        },
        {
          "status": 400,
          "errorCode": "INVALID_ARGUMENT",
          "errorName": "NominalChannelWriter:DuplicateResolvedChannelName",
          "description": "Multiple ingested columns resolve to the same channel name after applying channelPrefix and channelNameOverrides. Resolved channel names must be unique within a single ingest."
        }
      ]
    }
  ]
}
