{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "title": "AggregatedSource",
  "type": "object",
  "properties": {
    "branchId": {
      "type": "integer",
      "example": 345,
      "format": "int64"
    },
    "created": {
      "$ref": "#/definitions/CreatedEntity"
    },
    "deleted": {
      "$ref": "#/definitions/DeletedEntity"
    },
    "description": {
      "type": "string",
      "description": "Description of the source.",
      "example": "The source receives events from Github.",
      "maxLength": 4096
    },
    "disabled": {
      "$ref": "#/definitions/DisabledEntity"
    },
    "http": {
      "$ref": "#/definitions/HTTPSource"
    },
    "name": {
      "type": "string",
      "description": "Human readable name of the source.",
      "example": "Github Webhook Source",
      "minLength": 1,
      "maxLength": 40
    },
    "otlp": {
      "$ref": "#/definitions/OTLPSource"
    },
    "projectId": {
      "type": "integer",
      "example": 123,
      "format": "int64"
    },
    "sinks": {
      "type": "array",
      "items": {
        "$ref": "#/definitions/AggregatedSink"
      },
      "example": [
        {
          "projectId": 123,
          "branchId": 345,
          "sourceId": "github-webhook-source",
          "sinkId": "github-pr-table-sink",
          "type": "table",
          "name": "Raw Data Sink",
          "description": "The sink stores records to a table.",
          "allowedSignals": [
            "logs"
          ],
          "table": {
            "type": "keboola",
            "tableId": "in.c-bucket.table",
            "mapping": {
              "columns": [
                {
                  "type": "uuid",
                  "name": "id-col"
                },
                {
                  "type": "datetime",
                  "name": "datetime-col"
                },
                {
                  "type": "ip",
                  "name": "ip-col"
                },
                {
                  "type": "headers",
                  "name": "headers-col"
                },
                {
                  "type": "body",
                  "name": "body-col"
                },
                {
                  "type": "path",
                  "name": "path-col",
                  "path": "foo.bar[0]",
                  "rawString": true,
                  "defaultValue": ""
                },
                {
                  "type": "template",
                  "name": "template-col",
                  "template": {
                    "language": "jsonnet",
                    "content": "body.foo + \"-\" + body.bar"
                  }
                }
              ]
            }
          },
          "version": {
            "number": 3,
            "hash": "f43e93acd97eceb3",
            "description": "The reason for the last change was...",
            "at": "2022-04-28T14:20:04.000Z",
            "by": {
              "type": "user",
              "tokenId": "896455",
              "tokenDesc": "john.green@company.com",
              "userId": "578621",
              "userName": "John Green"
            }
          },
          "created": {
            "at": "2022-04-28T14:20:04.000Z",
            "by": {
              "type": "user",
              "tokenId": "896455",
              "tokenDesc": "john.green@company.com",
              "userId": "578621",
              "userName": "John Green"
            }
          },
          "deleted": {
            "at": "2022-04-28T14:20:04.000Z",
            "by": {
              "type": "user",
              "tokenId": "896455",
              "tokenDesc": "john.green@company.com",
              "userId": "578621",
              "userName": "John Green"
            }
          },
          "disabled": {
            "at": "2022-04-28T14:20:04.000Z",
            "by": {
              "type": "user",
              "tokenId": "896455",
              "tokenDesc": "john.green@company.com",
              "userId": "578621",
              "userName": "John Green"
            },
            "reason": "Disabled for recurring problems."
          },
          "statistics": {
            "total": {
              "firstRecordAt": "2022-04-28T14:20:04.000Z",
              "lastRecordAt": "2022-04-28T14:20:04.000Z",
              "recordsCount": 1,
              "compressedSize": 1,
              "uncompressedSize": 1
            },
            "levels": {
              "local": {
                "firstRecordAt": "2022-04-28T14:20:04.000Z",
                "lastRecordAt": "2022-04-28T14:20:04.000Z",
                "recordsCount": 1,
                "compressedSize": 1,
                "uncompressedSize": 1
              },
              "staging": {
                "firstRecordAt": "2022-04-28T14:20:04.000Z",
                "lastRecordAt": "2022-04-28T14:20:04.000Z",
                "recordsCount": 1,
                "compressedSize": 1,
                "uncompressedSize": 1
              },
              "target": {
                "firstRecordAt": "2022-04-28T14:20:04.000Z",
                "lastRecordAt": "2022-04-28T14:20:04.000Z",
                "recordsCount": 1,
                "compressedSize": 1,
                "uncompressedSize": 1
              }
            },
            "files": [
              {
                "state": "writing",
                "openedAt": "2022-04-28T14:20:04.000Z",
                "closingAt": "2022-04-28T14:20:04.000Z",
                "importingAt": "2022-04-28T14:20:04.000Z",
                "importedAt": "2022-04-28T14:20:04.000Z",
                "retryAttempt": 3,
                "retryReason": "network problem",
                "retryAfter": "2022-04-28T14:20:04.000Z",
                "statistics": {
                  "total": {
                    "firstRecordAt": "2022-04-28T14:20:04.000Z",
                    "lastRecordAt": "2022-04-28T14:20:04.000Z",
                    "recordsCount": 1,
                    "compressedSize": 1,
                    "uncompressedSize": 1
                  },
                  "levels": {
                    "local": {
                      "firstRecordAt": "2022-04-28T14:20:04.000Z",
                      "lastRecordAt": "2022-04-28T14:20:04.000Z",
                      "recordsCount": 1,
                      "compressedSize": 1,
                      "uncompressedSize": 1
                    },
                    "staging": {
                      "firstRecordAt": "2022-04-28T14:20:04.000Z",
                      "lastRecordAt": "2022-04-28T14:20:04.000Z",
                      "recordsCount": 1,
                      "compressedSize": 1,
                      "uncompressedSize": 1
                    },
                    "target": {
                      "firstRecordAt": "2022-04-28T14:20:04.000Z",
                      "lastRecordAt": "2022-04-28T14:20:04.000Z",
                      "recordsCount": 1,
                      "compressedSize": 1,
                      "uncompressedSize": 1
                    }
                  }
                }
              }
            ]
          }
        }
      ]
    },
    "sourceId": {
      "type": "string",
      "example": "github-webhook-source",
      "minLength": 1,
      "maxLength": 48
    },
    "type": {
      "type": "string",
      "example": "http",
      "enum": [
        "http",
        "otlp"
      ]
    },
    "version": {
      "$ref": "#/definitions/Version"
    }
  },
  "description": "Source of data for further processing, start of the stream, max 100 sources per a branch.",
  "example": {
    "branchId": 5678,
    "created": {
      "at": "2024-01-15T10:00:00.000Z",
      "by": {
        "tokenDesc": "john.green@company.com",
        "tokenId": "896455",
        "type": "user",
        "userId": "578621",
        "userName": "John Green"
      }
    },
    "description": "",
    "name": "My OTLP Source",
    "otlp": {
      "baseUrl": "https://stream-in.keboola.com/otlp/1234/my-otlp-source",
      "secret": "EXAMPLE-SECRET-PLACEHOLDER-XXXXXXXXXXXXXXXXXXXXX",
      "url": "https://stream-in.keboola.com/otlp/1234/my-otlp-source/EXAMPLE-SECRET-PLACEHOLDER-XXXXXXXXXXXXXXXXXXXXX"
    },
    "projectId": 1234,
    "sinks": [],
    "sourceId": "my-otlp-source",
    "type": "otlp",
    "version": {
      "at": "2024-01-15T10:00:00.000Z",
      "by": {
        "tokenDesc": "john.green@company.com",
        "tokenId": "896455",
        "type": "user",
        "userId": "578621",
        "userName": "John Green"
      },
      "description": "New source.",
      "hash": "f43e93acd97eceb3",
      "number": 1
    }
  },
  "required": [
    "projectId",
    "branchId",
    "sourceId",
    "type",
    "name",
    "description",
    "version",
    "created",
    "sinks"
  ]
}