{
  "openapi": "3.0.1",
  "info": {
    "title": "Vatis HTTP Gateway",
    "description": "Vatis HTTP Gateway API",
    "version": "1.0"
  },
  "servers": [
    {
      "url": "https://http-gateway.vatis.tech",
      "description": "Default server"
    }
  ],
  "paths": {
    "/http-gateway/api/v1/upload": {
      "post": {
        "summary": "Upload",
        "description": "Upload a stream of bytes to a new stream",
        "operationId": "upload",
        "parameters": [
          {
            "name": "id",
            "in": "query",
            "description": "Stream id. The stream created on this upload will bear this id",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "name",
            "in": "query",
            "description": "Stream name",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "groupId",
            "in": "query",
            "description": "Stream group id",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "streamConfigurationTemplateId",
            "in": "query",
            "description": "Stream configuration template id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "patches",
            "in": "query",
            "description": "Stream patches. A map of key-value pairs where all unknown query parameters will be interpreted as patches.\n\nPrefix keys with 'patches.' to explicitly mark the query parameter as patch (e.g. when it coincides with another parameter name).\n\nBy default, a replace patch will be applied.\n\nTo add, prefix the value with '+' (e.g. patches.key=+value).\n\nTo remove, set the value to '-' (e.g. patches.key=-).\n\nTo escape the special characters + and -, use '\\\\' (backslash) escape-character (e.g. 'patches.key=\\\\+value' will replace the key 'key' with value '+value').\n\nTo symbolize a path, use '.' as a separator (e.g. 'patches.key.with.path' will be parsed to '/key/with/path').\n\n",
            "explode": true,
            "schema": {
              "type": "object"
            },
            "example": {
              "patches.key1": "value-replace-explicit-patch",
              "key2": "value-replace-implicit-patch",
              "patches.key3": "+add-value",
              "patches.key-remove": "-",
              "patches.key.with.path": "value"
            }
          },
          {
            "name": "X-Vat-Meta-Template-Patch",
            "in": "header",
            "description": "Stream configuration template JSON patches as described in RFC-6902",
            "schema": {
              "type": "string"
            },
            "example": [
              {
                "op": "replace",
                "path": "/json/path",
                "value": "some_value"
              }
            ]
          },
          {
            "name": "persist",
            "in": "query",
            "description": "Persist the sinks of the stream matched by the tags",
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "persistTags",
            "in": "query",
            "description": "Persist tags to match the sinks of the stream",
            "schema": {
              "minItems": 1,
              "type": "array"
            }
          },
          {
            "name": "matchPersistTags",
            "in": "query",
            "description": "Tags matching strategy. 'ALL'/'ANY' of specified tags must be present on the sink to be marked as persistent",
            "schema": {
              "type": "string",
              "enum": [
                "ALL",
                "ANY"
              ]
            }
          },
          {
            "name": "webhook",
            "in": "query",
            "description": "Define dynamic webhooks for this stream as query parameters.\n\nThe general structure is \"webhook[.RESOURCE[.STATE]]=http://my_domain/path\".\n\nFor example:\n\n- define a webhook for stream completion: \"webhook.stream.completed=http://my_domain/success\"\n\n- define a webhook for all stream events: \"webhook.stream=http://my_domain/stream_event\"\n\n- define the same webhook for stream completion and failure: \"webhook.stream.completed=http://my_domain/path&webhook.stream.failed=http://my_domain/path\"\n\n- define a webhook for all events: \"webhook=http://my_domain/path\"\n",
            "explode": true,
            "schema": {
              "type": "object"
            },
            "example": {
              "webhook.stream.completed": "http://my_domain/success",
              "webhook.stream.failed": "http://my_domain/fail"
            }
          }
        ],
        "requestBody": {
          "description": "The stream of bytes or the multipart form-data to upload",
          "content": {
            "application/octet-stream": {
              "schema": {
                "type": "string",
                "format": "binary"
              }
            },
            "multipart/form-data": {
              "schema": {
                "$ref": "#/components/schemas/MultipartUploadRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StreamDto"
                }
              }
            }
          },
          "default": {
            "description": "Error while uploading the stream",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerToken": []
          }
        ]
      }
    }
  },
  "components": {
    "schemas": {
      "ErrorResponse": {
        "type": "object",
        "properties": {
          "statusCode": {
            "type": "integer",
            "format": "int32"
          },
          "title": {
            "type": "string"
          },
          "message": {
            "type": "string"
          },
          "internalErrorName": {
            "type": "string"
          },
          "nestedErrors": {
            "type": "array",
            "items": {
              "type": "object"
            }
          }
        }
      },
      "HttpStreamConfigurationDto": {
        "type": "object",
        "properties": {
          "patches": {
            "type": "object",
            "additionalProperties": {
              "type": "object"
            }
          },
          "webhook": {
            "type": "object",
            "additionalProperties": {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          }
        },
        "description": "Define dynamic webhooks for this stream as query parameters.\n\nThe general structure is \"webhook[.RESOURCE[.STATE]]=http://my_domain/path\".\n\nFor example:\n\n- define a webhook for stream completion: \"webhook.stream.completed=http://my_domain/success\"\n\n- define a webhook for all stream events: \"webhook.stream=http://my_domain/stream_event\"\n\n- define the same webhook for stream completion and failure: \"webhook.stream.completed=http://my_domain/path&webhook.stream.failed=http://my_domain/path\"\n\n- define a webhook for all events: \"webhook=http://my_domain/path\"\n",
        "example": {
          "patches": {
            "languages": "ro"
          },
          "webhook": {
            "http://my_domain/path": [
              "stream.completed"
            ]
          }
        }
      },
      "MultipartUploadRequest": {
        "required": [
          "configuration",
          "file"
        ],
        "type": "object",
        "properties": {
          "configuration": {
            "$ref": "#/components/schemas/HttpStreamConfigurationDto"
          },
          "file": {
            "type": "string",
            "description": "Stream data",
            "format": "binary"
          }
        },
        "description": "Multipart form-data request"
      },
      "ProcessorConfigurationDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "source": {
            "$ref": "#/components/schemas/SubscriptionDto"
          },
          "destination": {
            "$ref": "#/components/schemas/TopicDto"
          },
          "clusterDomainName": {
            "type": "string"
          },
          "podsDiscoveryClusterDomainName": {
            "type": "string"
          },
          "propertiesSchema": {
            "type": "string"
          },
          "properties": {
            "type": "object"
          },
          "egress": {
            "$ref": "#/components/schemas/ProcessorEgressConfigurationDto"
          }
        }
      },
      "ProcessorEgressConfigurationDto": {
        "type": "object",
        "properties": {
          "persist": {
            "type": "boolean"
          },
          "sink": {
            "type": "boolean"
          },
          "tags": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "StreamConfigurationDto": {
        "type": "object",
        "properties": {
          "streamConfigurationTemplateId": {
            "type": "string"
          },
          "dataSource": {
            "$ref": "#/components/schemas/TopicDto"
          },
          "dataSinks": {
            "type": "object",
            "additionalProperties": {
              "$ref": "#/components/schemas/TopicDto"
            }
          },
          "processors": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ProcessorConfigurationDto"
            }
          },
          "dynamicWebhookEndpoints": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/WebhookEndpointDto"
            }
          }
        }
      },
      "StreamDto": {
        "type": "object",
        "properties": {
          "streamId": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string"
          },
          "groupId": {
            "type": "string",
            "format": "uuid"
          },
          "configuration": {
            "$ref": "#/components/schemas/StreamConfigurationDto"
          },
          "createdTimestamp": {
            "type": "string",
            "format": "date-time"
          },
          "creatorId": {
            "type": "string"
          },
          "groupCreatorId": {
            "type": "string"
          },
          "state": {
            "type": "string",
            "enum": [
              "READY",
              "COMPLETED",
              "FAILED",
              "EXPIRED"
            ]
          },
          "stateDescription": {
            "type": "string"
          },
          "finalizedTimestamp": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "SubscriptionDto": {
        "type": "object",
        "properties": {
          "subscription": {
            "type": "string"
          },
          "topic": {
            "type": "string"
          },
          "messageSchema": {
            "type": "string"
          },
          "connectionOptions": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          },
          "headers": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          }
        }
      },
      "TopicDto": {
        "type": "object",
        "properties": {
          "topic": {
            "type": "string"
          },
          "messageSchema": {
            "type": "string"
          },
          "connectionOptions": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          },
          "headers": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          },
          "messageHeaders": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          },
          "subscriptions": {
            "type": "object",
            "additionalProperties": {
              "$ref": "#/components/schemas/SubscriptionDto"
            }
          }
        }
      },
      "WebhookEndpointDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "url": {
            "type": "string"
          },
          "events": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "enabled": {
            "type": "boolean"
          },
          "description": {
            "type": "string"
          }
        }
      }
    },
    "securitySchemes": {
      "bearerToken": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "JWT"
      }
    }
  }
}
