{
  "openapi": "3.0.0",
  "info": {
    "description": "Profiling Assistant is responsible for triggering profilings if available.",
    "version": "1.0.0",
    "title": "Profiling Assistant API"
  },
  "servers": [
    {
      "url": "http://localhost:3011"
    }
  ],
  "tags": [
    {
      "name": "profiling",
      "description": "Profiling requests"
    }
  ],
  "paths": {
    "/profiling/exists": {
      "parameters": [
        {
          "$ref": "#/components/parameters/divaHeader"
        }
      ],
      "post": {
        "tags": [
          "profiling"
        ],
        "summary": "Check if profiling workflow exists for given entity.",
        "operationId": "profilingExists",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "entityId": {
                    "$ref": "#/components/schemas/EntityId"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Exist result",
            "content": {
              "text/plain": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "404": {
            "description": "not found error",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/responses/DAGNotFoundError"
                    },
                    {
                      "$ref": "#/components/responses/EntityNotFoundError"
                    }
                  ]
                }
              }
            }
          },
          "4XX": {
            "$ref": "#/components/responses/UnexpectedError"
          },
          "5XX": {
            "$ref": "#/components/responses/UnexpectedError"
          }
        }
      }
    },
    "/profiling/run": {
      "parameters": [
        {
          "$ref": "#/components/parameters/divaHeader"
        }
      ],
      "post": {
        "tags": [
          "profiling"
        ],
        "summary": "Trigger profiling workflow for an entity.",
        "operationId": "profilingRun",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "entityId": {
                    "$ref": "#/components/schemas/EntityId"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Triggered profiling",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "404": {
            "description": "not found error",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/responses/DAGNotFoundError"
                    },
                    {
                      "$ref": "#/components/responses/EntityNotFoundError"
                    }
                  ]
                }
              }
            }
          },
          "4XX": {
            "$ref": "#/components/responses/UnexpectedError"
          },
          "5XX": {
            "$ref": "#/components/responses/UnexpectedError"
          }
        }
      }
    },
    "/profiling/run/{dag}": {
      "parameters": [
        {
          "$ref": "#/components/parameters/divaHeader"
        }
      ],
      "post": {
        "tags": [
          "profiling"
        ],
        "summary": "Trigger specific profiling workflow for an entity.",
        "operationId": "profilingRunDag",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Triggered profiling",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "404": {
            "description": "not found error",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/responses/DAGNotFoundError"
                    },
                    {
                      "$ref": "#/components/responses/EntityNotFoundError"
                    }
                  ]
                }
              }
            }
          },
          "4XX": {
            "$ref": "#/components/responses/UnexpectedError"
          },
          "5XX": {
            "$ref": "#/components/responses/UnexpectedError"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "EntityId": {
        "title": "Entity ID",
        "description": "Unique identifier of an entity",
        "type": "string",
        "example": "resource:uuid:asdsad4d1fcb08-b894-4bdf-b662-0f105d597189",
        "pattern": "^.+:uuid:[0-9a-f]{8}-[0-9a-f]{4}-[0-5][0-9a-f]{3}-[089ab][0-9a-f]{3}-[0-9a-f]{12}$"
      },
      "Error": {
        "type": "object",
        "title": "Operation error",
        "description": "Error that can occure on request processing",
        "required": [
          "type",
          "message",
          "code"
        ],
        "properties": {
          "type": {
            "title": "Error type",
            "description": "Futher error type information",
            "type": "string"
          },
          "message": {
            "title": "Error message",
            "description": "Details about error",
            "type": "string"
          },
          "code": {
            "title": "Error code",
            "description": "HTTP error code",
            "type": "number",
            "format": "int32",
            "example": 409
          },
          "errors": {
            "title": "Errors",
            "description": "More error details that are reference in most case specification or schema validation errors",
            "type": "array",
            "items": {
              "type": "object"
            }
          }
        }
      }
    },
    "responses": {
      "Success": {
        "description": "Successful"
      },
      "DAGNotFoundError": {
        "description": "DAG for Resource does not exist",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "EntityNotFoundError": {
        "description": "Entity does not exist",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "UnexpectedError": {
        "description": "Internal error",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "InvalidDataError": {
        "description": "Invalid data supplied",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      }
    },
    "parameters": {
      "divaHeader": {
        "in": "header",
        "description": "The system specific stringified object whit relevant data like actorId, token etc.",
        "name": "x-diva",
        "required": true,
        "schema": {
          "type": "string"
        }
      }
    }
  }
}