{
  "swagger": "2.0",
  "info": {
    "title": "Channel metadata 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/channel-metadata/v1/channel-metadata/get": {
      "post": {
        "operationId": "ChannelMetadataService_getChannelMetadata",
        "summary": "Get channel metadata",
        "tags": [
          "Channel Metadata Service"
        ],
        "description": "Get the metadata for a channel.",
        "parameters": [
          {
            "name": "request",
            "in": "body",
            "schema": {
              "$ref": "#/definitions/GetChannelMetadataRequest"
            },
            "required": true,
            "x-example": {
              "channelIdentifier": {
                "channelName": "<channel>",
                "dataSourceRid": "<data source rid>"
              }
            }
          }
        ],
        "responses": {
          "200": {
            "description": "A successful response.",
            "schema": {
              "$ref": "#/definitions/ChannelMetadata"
            },
            "x-example": {
              "channelIdentifier": {
                "channelName": "<channel>",
                "dataSourceRid": "<data source rid>"
              },
              "description": "<description>",
              "unit": "<unit>",
              "dataType": "DOUBLE",
              "channelKind": "STANDARD"
            }
          }
        }
      }
    },
    "/timeseries/channel-metadata/v1/channel-metadata/batch-get": {
      "post": {
        "operationId": "ChannelMetadataService_batchGetChannelMetadata",
        "summary": "Batch get channel metadata",
        "tags": [
          "Channel Metadata Service"
        ],
        "description": "Batch get the metadata for multiple channels. If some channels cannot be found or authorized, they will be omitted from the response.",
        "parameters": [
          {
            "name": "request",
            "in": "body",
            "schema": {
              "$ref": "#/definitions/BatchGetChannelMetadataRequest"
            },
            "required": true,
            "x-example": {
              "requests": [
                {
                  "channelIdentifier": {
                    "channelName": "<channel>",
                    "dataSourceRid": "<data source rid>"
                  }
                }
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "A successful response.",
            "schema": {
              "$ref": "#/definitions/BatchGetChannelMetadataResponse"
            },
            "x-example": {
              "responses": [
                {
                  "channelIdentifier": {
                    "channelName": "<channel>",
                    "dataSourceRid": "<data source rid>"
                  },
                  "description": "<description>",
                  "unit": "<unit>",
                  "dataType": "DOUBLE",
                  "channelKind": "STANDARD"
                }
              ]
            }
          }
        }
      }
    },
    "/timeseries/channel-metadata/v1/channel-metadata/update": {
      "post": {
        "operationId": "ChannelMetadataService_updateChannelMetadata",
        "summary": "Update channel metadata",
        "tags": [
          "Channel Metadata Service"
        ],
        "description": "Update the metadata for a channel.",
        "parameters": [
          {
            "name": "request",
            "in": "body",
            "schema": {
              "$ref": "#/definitions/UpdateChannelMetadataRequest"
            },
            "required": true,
            "x-example": {
              "channelIdentifier": {
                "channelName": "<channel>",
                "dataSourceRid": "<data source rid>"
              }
            }
          }
        ],
        "responses": {
          "200": {
            "description": "A successful response.",
            "schema": {
              "$ref": "#/definitions/ChannelMetadata"
            },
            "x-example": {
              "channelIdentifier": {
                "channelName": "<channel>",
                "dataSourceRid": "<data source rid>"
              },
              "description": "<description>",
              "unit": "<unit>",
              "dataType": "DOUBLE",
              "channelKind": "STANDARD"
            }
          }
        }
      }
    },
    "/timeseries/channel-metadata/v1/channel-metadata/batch-update": {
      "post": {
        "operationId": "ChannelMetadataService_batchUpdateChannelMetadata",
        "summary": "Batch update channel metadata",
        "tags": [
          "Channel Metadata Service"
        ],
        "description": "Batch update the metadata for multiple channels. If some channels cannot be found or authorized, no metadata will be updated for any of the channels in the request.",
        "parameters": [
          {
            "name": "request",
            "in": "body",
            "schema": {
              "$ref": "#/definitions/BatchUpdateChannelMetadataRequest"
            },
            "required": true,
            "x-example": {
              "requests": [
                {
                  "channelIdentifier": {
                    "channelName": "<channel>",
                    "dataSourceRid": "<data source rid>"
                  }
                }
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "A successful response.",
            "schema": {
              "$ref": "#/definitions/BatchUpdateChannelMetadataResponse"
            },
            "x-example": {
              "responses": [
                {
                  "channelIdentifier": {
                    "channelName": "<channel>",
                    "dataSourceRid": "<data source rid>"
                  },
                  "description": "<description>",
                  "unit": "<unit>",
                  "dataType": "DOUBLE",
                  "channelKind": "STANDARD"
                }
              ]
            }
          }
        }
      }
    }
  },
  "definitions": {
    "ChannelKind": {
      "description": "Classifies how a channel is used. COMMAND channels accept commands through the Command Service.",
      "type": "string",
      "enum": [
        "STANDARD",
        "COMMAND"
      ]
    },
    "Empty": {
      "type": "object",
      "properties": {}
    },
    "SeriesDataType": {
      "description": "The data types that are available for querying.",
      "type": "string",
      "enum": [
        "DOUBLE",
        "STRING",
        "LOG",
        "INT",
        "UINT",
        "DOUBLE_ARRAY",
        "STRING_ARRAY",
        "STRUCT",
        "VIDEO",
        "SPATIAL"
      ]
    },
    "BatchGetChannelMetadataRequest": {
      "type": "object",
      "properties": {
        "requests": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/GetChannelMetadataRequest"
          },
          "uniqueItems": true
        }
      },
      "example": {
        "requests": [
          {
            "channelIdentifier": {
              "channelName": "<channel>",
              "dataSourceRid": "<data source rid>"
            }
          }
        ]
      }
    },
    "BatchGetChannelMetadataResponse": {
      "type": "object",
      "properties": {
        "responses": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/ChannelMetadata"
          },
          "uniqueItems": true
        }
      }
    },
    "BatchUpdateChannelMetadataRequest": {
      "type": "object",
      "properties": {
        "requests": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/UpdateChannelMetadataRequest"
          },
          "uniqueItems": true
        }
      },
      "example": {
        "requests": [
          {
            "channelIdentifier": {
              "channelName": "<channel>",
              "dataSourceRid": "<data source rid>"
            }
          }
        ]
      }
    },
    "BatchUpdateChannelMetadataResponse": {
      "type": "object",
      "properties": {
        "responses": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/ChannelMetadata"
          },
          "uniqueItems": true
        }
      }
    },
    "ChannelIdentifier": {
      "type": "object",
      "properties": {
        "channelName": {
          "type": "string",
          "x-alias": "Channel"
        },
        "dataSourceRid": {
          "type": "string",
          "format": "rid",
          "x-alias": "DataSourceRid"
        }
      },
      "required": [
        "channelName",
        "dataSourceRid"
      ]
    },
    "ChannelMetadata": {
      "type": "object",
      "properties": {
        "channelIdentifier": {
          "$ref": "#/definitions/ChannelIdentifier"
        },
        "description": {
          "type": "string"
        },
        "unit": {
          "type": "string",
          "x-alias": "Unit"
        },
        "dataType": {
          "$ref": "#/definitions/SeriesDataType"
        },
        "channelKind": {
          "allOf": [
            {
              "$ref": "#/definitions/ChannelKind"
            }
          ],
          "description": "Classifies how the channel is used. Omitted values should be treated as STANDARD."
        }
      },
      "required": [
        "channelIdentifier"
      ]
    },
    "GetChannelMetadataRequest": {
      "type": "object",
      "properties": {
        "channelIdentifier": {
          "$ref": "#/definitions/ChannelIdentifier"
        }
      },
      "required": [
        "channelIdentifier"
      ],
      "example": {
        "channelIdentifier": {
          "channelName": "<channel>",
          "dataSourceRid": "<data source rid>"
        }
      }
    },
    "UpdateChannelMetadataRequest": {
      "type": "object",
      "properties": {
        "channelIdentifier": {
          "$ref": "#/definitions/ChannelIdentifier"
        },
        "description": {
          "type": "string"
        },
        "unitUpdate": {
          "$ref": "#/definitions/UnitUpdate"
        }
      },
      "required": [
        "channelIdentifier"
      ],
      "example": {
        "channelIdentifier": {
          "channelName": "<channel>",
          "dataSourceRid": "<data source rid>"
        }
      }
    },
    "UnitUpdate": {
      "description": "UnitUpdate is used to either set a unit, or to clear an existing unit.\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": [
            "unit",
            "clearUnit"
          ]
        },
        "unit": {
          "type": "string",
          "x-alias": "Unit"
        },
        "clearUnit": {
          "$ref": "#/definitions/Empty"
        }
      },
      "required": [
        "type"
      ],
      "example": {
        "type": "unit",
        "unit": "string"
      }
    }
  },
  "tags": [
    {
      "name": "Channel Metadata Service",
      "x-displayName": "Channel metadata service",
      "description": "Endpoints for retrieving and updating channel metadata.",
      "x-errors": [
        {
          "status": 404,
          "errorCode": "NOT_FOUND",
          "errorName": "ChannelMetadata:ChannelsNotFound"
        }
      ]
    }
  ]
}
