{
  "openapi": "3.0.1",
  "info": {
    "title": "Neverpile eureka API",
    "contact": {
      "name": "levigo solutions gmbh",
      "url": "https://levigo.de",
      "email": "solutions@levigo.de"
    },
    "version": "1.0.0"
  },
  "tags": [
    {
      "name": "Document",
      "description": "Document related APIs"
    },
    {
      "name": "Content",
      "description": "Document content element related APIs"
    },
    {
      "name": "Index",
      "description": "Index Resource"
    }
  ],
  "paths": {
    "/api/v1/documents": {
      "post": {
        "tags": [
          "Content"
        ],
        "summary": "Create a document along with content elements in a single multipart upload",
        "parameters": [
          {
            "name": "facets",
            "in": "query",
            "description": "The list of facets to be included in the response; return all facets if empty",
            "allowEmptyValue": false,
            "style": "form",
            "explode": true,
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Document"
              }
            },
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "__DOC": {
                    "type": "object",
                    "description": "The non-content document information (metadata and other facets). Media type should be `application/json`."
                  },
                  "contentElement": {
                    "description": "Other content elements (can have any name)",
                    "type": "array",
                    "items": {
                      "type": "string",
                      "format": "binary"
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Document found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Document"
                }
              }
            }
          },
          "400": {
            "description": "Invalid documentID supplied"
          },
          "404": {
            "description": "Document not found"
          }
        }
      }
    },
    "/api/v1/documents/{documentID}": {
      "get": {
        "tags": [
          "Document"
        ],
        "summary": "Fetches a document by ID",
        "parameters": [
          {
            "name": "documentID",
            "in": "path",
            "description": "The ID of the document to be fetched",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "facets",
            "in": "query",
            "description": "The list of facets to be included in the response; return all facets if empty",
            "allowEmptyValue": false,
            "style": "form",
            "explode": true,
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Document found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Document"
                }
              }
            }
          },
          "400": {
            "description": "Invalid documentID supplied"
          },
          "404": {
            "description": "Document not found"
          }
        }
      },
      "put": {
        "tags": [
          "Document"
        ],
        "summary": "Update a document",
        "description": "The document must already exist. It is not possible to create a new document with this method.",
        "parameters": [
          {
            "name": "documentID",
            "in": "path",
            "description": "The ID of the document to be fetched",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "facets",
            "in": "query",
            "description": "The list of facets to be included in the response; return all facets if empty",
            "allowEmptyValue": false,
            "style": "form",
            "explode": true,
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          }
        ],
        "requestBody": {
          "description": "requestDto",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Document"
              }
            }
          },
          "required": false
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Document"
                }
              }
            }
          },
          "202": {
            "description": "Document updated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Document"
                }
              }
            }
          },
          "400": {
            "description": "Invalid documentID supplied"
          },
          "404": {
            "description": "Document not found"
          }
        }
      },
      "delete": {
        "tags": [
          "Document"
        ],
        "summary": "Delete a document identified by its ID",
        "parameters": [
          {
            "name": "documentID",
            "in": "path",
            "description": "The ID of the document to be fetched",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Document successfully deleted"
          },
          "400": {
            "description": "Invalid documentID supplied"
          },
          "404": {
            "description": "Document not found"
          },
          "409": {
            "description": "The request could not be completed due to a conflict with the current state of the target resource."
          }
        }
      }
    },
    "/api/v1/documents/{documentID}/content": {
      "get": {
        "tags": [
          "Content"
        ],
        "summary": "Queries content elements",
        "parameters": [
          {
            "name": "documentID",
            "in": "path",
            "description": "ID of the document",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "return",
            "in": "query",
            "description": "Specify what and how to return",
            "allowEmptyValue": false,
            "schema": {
              "type": "string",
              "default": "first",
              "description": "Enum values are * `only` - return the only matching element, assuming there is exactly one match. Return an error `406` otherwise. * `first`- return just the first matching element, assuming there is at least one match. Return `404` otherwise. * `all`- all matching elements as a stream of type `multipart/mixed`.",
              "enum": [
                "only",
                "first",
                "all"
              ]
            }
          },
          {
            "name": "role",
            "in": "query",
            "description": "Role(s) of the content elements to be fetched. Multiple roles can be specified separated by comma",
            "required": false,
            "style": "form",
            "explode": true,
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Content element found",
            "content": {
              "multipart/mixed": {
                "schema": {
                  "description": "Multiple content elements as a RFC 2046 multipart stream. Each part has the following headers (see headers section for details): * `Content-Disposition` * `Last-Modified` * `Content-Type` * `Content-Length` * `ETag` * `Digest` * `X-NPE-Document-Version-Timestamp`",
                  "type": "string",
                  "format": "byte"
                }
              },
              "*/*": {
                "schema": {
                  "type": "string",
                  "format": "byte"
                }
              }
            },
            "headers": {
              "X-NPE-Document-Version-Timestamp": {
                "$ref": "#/components/headers/X-NPE-Document-Version-Timestamp"
              },
              "Last-Modified": {
                "$ref": "#/components/headers/Last-Modified"
              },
              "Content-Length": {
                "$ref": "#/components/headers/Content-Length"
              },
              "ETag": {
                "$ref": "#/components/headers/ETag"
              },
              "Digest": {
                "$ref": "#/components/headers/Digest"
              }
            }
          },
          "404": {
            "description": "Document or content element not found"
          },
          "406": {
            "description": "The query could not be satisfied, e.g. there was more than one match with return mode `only`."
          }
        }
      },
      "post": {
        "tags": [
          "Content"
        ],
        "summary": "Add content elements to a document",
        "parameters": [
          {
            "name": "documentID",
            "in": "path",
            "description": "ID of the document",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "facets",
            "in": "query",
            "description": "The list of facets to be included in the response; return all facets if empty",
            "allowEmptyValue": false,
            "style": "form",
            "explode": true,
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          }
        ],
        "requestBody": {
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "__DOC": {
                    "type": "string",
                    "description": "The document description and facets in the form '#/definitions/Document'",
                    "format": "binary"
                  },
                  "any name": {
                    "type": "string",
                    "description": "Other content elements",
                    "format": "binary"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Content element(s) added",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Document"
                }
              }
            },
            "headers": {
              "X-NPE-Document-Version-Timestamp": {
                "$ref": "#/components/headers/X-NPE-Document-Version-Timestamp"
              }
            }
          },
          "400": {
            "description": "Invalid documentID supplied"
          },
          "404": {
            "description": "Document not found"
          }
        }
      }
    },
    "/api/v1/documents/{documentID}/content/{contentElementId}": {
      "get": {
        "tags": [
          "Content"
        ],
        "summary": "Retrieve a single content element",
        "parameters": [
          {
            "name": "documentID",
            "in": "path",
            "description": "ID of the document",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "contentElementId",
            "in": "path",
            "description": "ID of the content element to be updated",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Content element found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "string",
                  "format": "byte"
                }
              },
              "*/*": {
                "schema": {
                  "type": "string",
                  "format": "byte"
                }
              }
            },
            "headers": {
              "X-NPE-Document-Version-Timestamp": {
                "$ref": "#/components/headers/X-NPE-Document-Version-Timestamp"
              },
              "Last-Modified": {
                "$ref": "#/components/headers/Last-Modified"
              },
              "Content-Length": {
                "$ref": "#/components/headers/Content-Length"
              },
              "ETag": {
                "$ref": "#/components/headers/ETag"
              },
              "Digest": {
                "$ref": "#/components/headers/Digest"
              }
            }
          },
          "404": {
            "description": "Document or content element not found"
          }
        }
      },
      "put": {
        "tags": [
          "Content"
        ],
        "summary": "Update the content data of a specific content element. The new content data must be sent in the body of the request. The referenced document and content element must exist. Updating the content data will preserve some aspects of the content element like `role`, `metadata` and `fileName`. The `mediaType` will be updated from the request body's `Content-Type` header (if present).\nUpdating content data will change its `digest` (unless the content data is the same as before) and may change the content element's `id`, depending on whether the installation uses multi-versioning and other factors. Therefor users of this API mus be prepared to handle an updated id, which will be communicated in the returned `ContentElement` descriptor.",
        "parameters": [
          {
            "name": "documentID",
            "in": "path",
            "description": "ID of the document",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "contentElementId",
            "in": "path",
            "description": "ID of the content element to be updated",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "description": "The new content data",
          "content": {
            "*/*": {
              "schema": {
                "type": "string",
                "format": "byte"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Content data successfully updated.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ContentElement"
                }
              }
            },
            "headers": {
              "X-NPE-Document-Version-Timestamp": {
                "$ref": "#/components/headers/X-NPE-Document-Version-Timestamp"
              }
            }
          },
          "404": {
            "description": "Document or content element not found"
          }
        }
      },
      "delete": {
        "tags": [
          "Content"
        ],
        "summary": "Deletes a content element by ID",
        "parameters": [
          {
            "name": "documentID",
            "in": "path",
            "description": "ID of the document",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "contentElementId",
            "in": "path",
            "description": "ID of the content element to be updated",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "facets",
            "in": "query",
            "description": "The list of facets to be included in the response; return all facets if empty",
            "allowEmptyValue": false,
            "style": "form",
            "explode": true,
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Content element deleted"
          },
          "400": {
            "description": "Invalid documentID supplied"
          },
          "404": {
            "description": "Document/Content not found"
          }
        }
      }
    },
    "/api/v1/index/hard-reset": {
      "post": {
        "tags": [
          "Index"
        ],
        "summary": "Hard resets index",
        "description": "All index data will be lost and index gets reinitialized.",
        "responses": {
          "200": {
            "description": "Index successfully resetted"
          }
        }
      }
    },
    "/api/v1/index/query/{query}": {
      "get": {
        "tags": [
          "Index"
        ],
        "summary": "Fetches documents by query",
        "parameters": [
          {
            "name": "query",
            "in": "path",
            "description": "The query of the documents to be fetched",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "facets",
            "in": "query",
            "description": "The list of facets to be included in the response; return all facets if empty",
            "allowEmptyValue": false,
            "style": "form",
            "explode": true,
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Query successful",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Document"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid query supplied"
          }
        }
      }
    },
    "/api/v1/index/rebuild": {
      "post": {
        "tags": [
          "Index"
        ],
        "summary": "Rebuilds the index with current store information",
        "description": "Current index will remain unchanged for all incoming requests until process is complete.Incoming updates to the index will be included in the new index but wont be accessible until rebuild is complete.",
        "responses": {
          "200": {
            "description": "Index rebuild successfully started."
          }
        }
      }
    },
    "/api/v1/documents/{documentID}/history/{versionTimestamp}": {
      "get": {
        "tags": [
          "Document"
        ],
        "summary": "Fetches a particular version of a document by ID",
        "parameters": [
          {
            "name": "documentID",
            "in": "path",
            "description": "The ID of the document to be fetched",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "versionTimestamp",
            "in": "path",
            "description": "The timestamp of the version to be queried",
            "schema": {
              "type": "string",
              "format": "date-time"
            },
            "required": true
          },
          {
            "name": "facets",
            "in": "query",
            "description": "The list of facets to be included in the response; return all facets if empty",
            "allowEmptyValue": false,
            "style": "form",
            "explode": true,
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Document found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Document"
                }
              }
            },
            "headers": {
              "X-NPE-Document-Version-Timestamp": {
                "$ref": "#/components/headers/X-NPE-Document-Version-Timestamp"
              }
            }
          },
          "400": {
            "description": "Invalid documentID supplied"
          },
          "404": {
            "description": "Document or version not found"
          }
        }
      }
    },
    "/api/v1/documents/{documentID}/history/{versionTimestamp}/content": {
      "get": {
        "tags": [
          "Content"
        ],
        "summary": "Queries a particular document version for content elements",
        "parameters": [
          {
            "name": "documentID",
            "in": "path",
            "description": "ID of the document",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "versionTimestamp",
            "in": "path",
            "description": "The timestamp of the version to be queried",
            "schema": {
              "type": "string",
              "format": "date-time"
            },
            "required": true
          },
          {
            "name": "return",
            "in": "query",
            "description": "Specify what and how to return",
            "allowEmptyValue": false,
            "schema": {
              "type": "string",
              "default": "first",
              "description": "Enum values are * `only` - return the only matching element, assuming there is exactly one match. Return an error `406` otherwise. * `first`- return just the first matching element, assuming there is at least one match. Return `404` otherwise. * `all`- all matching elements as a stream of type `multipart/mixed`.",
              "enum": [
                "only",
                "first",
                "all"
              ]
            }
          },
          {
            "name": "role",
            "in": "query",
            "description": "Role(s) of the content elements to be fetched. Multiple roles can be specified separated by comma",
            "required": false,
            "allowEmptyValue": false,
            "style": "form",
            "explode": true,
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Content element found",
            "content": {
              "multipart/mixed": {
                "schema": {
                  "description": "Multiple content elements as a RFC 2046 multipart stream. Each part has the following headers (see headers section for details): * `Content-Disposition` * `Last-Modified` * `Content-Type` * `Content-Length` * `ETag` * `Digest` * `X-NPE-Document-Version-Timestamp`",
                  "type": "string",
                  "format": "byte"
                }
              },
              "*/*": {
                "schema": {
                  "type": "string",
                  "format": "byte"
                }
              }
            },
            "headers": {
              "X-NPE-Document-Version-Timestamp": {
                "$ref": "#/components/headers/X-NPE-Document-Version-Timestamp"
              },
              "Last-Modified": {
                "$ref": "#/components/headers/Last-Modified"
              },
              "Content-Length": {
                "$ref": "#/components/headers/Content-Length"
              },
              "ETag": {
                "$ref": "#/components/headers/ETag"
              },
              "Digest": {
                "$ref": "#/components/headers/Digest"
              }
            }
          },
          "404": {
            "description": "Document or content element not found"
          },
          "406": {
            "description": "The query could not be satisfied, e.g. there was more than one match with return mode `only`."
          }
        }
      }
    }
  },
  "components": {
    "headers": {
      "X-NPE-Document-Version-Timestamp": {
        "description": "The version timestamp of the document associated with a returned resource.",
        "schema": {
          "type": "string",
          "format": "date-time"
        }
      },
      "Last-Modified": {
        "description": "The modification date",
        "schema": {
          "type": "string",
          "format": "RFC 2616 format"
        }
      },
      "Content-Length": {
        "description": "the lenght in bytes",
        "schema": {
          "type": "integer"
        }
      },
      "ETag": {
        "description": "The ETag. No assumption should be made about the ETag's format.",
        "schema": {
          "type": "string"
        }
      },
      "Digest": {
        "description": "The content digest",
        "schema": {
          "type": "string",
          "format": "<algorighm name>=<digest value>"
        }
      }
    },
    "schemas": {
      "AuditEvent": {
        "title": "AuditEvent",
        "type": "object",
        "properties": {
          "auditId": {
            "type": "string",
            "description": "The ID of this event"
          },
          "description": {
            "type": "string",
            "description": "A textual desription of the event"
          },
          "timestamp": {
            "type": "string",
            "description": "The time at which the event occurred",
            "format": "date-time"
          },
          "type": {
            "type": "string",
            "description": "The type of event",
            "enum": [
              "CREATE",
              "UPDATE",
              "DELETE",
              "CUSTOM"
            ]
          },
          "userID": {
            "type": "string",
            "description": "The ID of the used which triggered the event; may be null if the event wasn't triggered by a user"
          }
        },
        "description": "An audit event associated with a document"
      },
      "EncryptableElement": {
        "description": "An abstract schema class extended by types that support encryption.",
        "type": "object",
        "properties": {
          "encryption": {
            "type": "string",
            "description": "Whether the element is encrypted. Possible values are: * `shared` - The element's contents are shared with (visible to) the server. * `private` - The element's contents are encrypted and therefor opaque to the server.",
            "enum": [
              "shared",
              "private"
            ]
          },
          "keyHint": {
            "type": "string",
            "description": "A key hint that can be used for client-side key management. The content is dependent on the key management scheme used."
          }
        }
      },
      "ContentElement": {
        "title": "ContentElement",
        "allOf": [
          {
            "$ref": "#/components/schemas/EncryptableElement"
          },
          {
            "type": "object",
            "properties": {
              "digest": {
                "$ref": "#/components/schemas/Digest"
              },
              "encryption": {
                "type": "string",
                "description": "The type of encryption the content element is subject to",
                "enum": [
                  "shared",
                  "private"
                ]
              },
              "fileName": {
                "type": "string"
              },
              "id": {
                "type": "string",
                "description": "The id of the content element - uniqueness is guaranteed only within the document"
              },
              "length": {
                "type": "integer",
                "description": "The length of the element in bytes",
                "format": "int64"
              },
              "role": {
                "type": "string",
                "description": "The role of the content element"
              },
              "type": {
                "type": "string",
                "description": "The MIME-Type of the content element as specified in RFC 2045 without parameters"
              }
            },
            "description": "A content element associated with a document"
          }
        ]
      },
      "Digest": {
        "title": "Digest",
        "type": "object",
        "properties": {
          "algorithm": {
            "type": "string",
            "description": "The algorithm used to compute the digest",
            "enum": [
              "SHA-1",
              "SHA-256",
              "SHA-384",
              "SHA-512",
              "MD5"
            ]
          },
          "bytes": {
            "pattern": "^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$",
            "type": "string",
            "description": "The hash value as a byte string",
            "format": "byte"
          }
        },
        "description": "A cryptographic digest used to verify the integrity of an object"
      },
      "Document": {
        "title": "Document",
        "type": "object",
        "properties": {
          "audit": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AuditEvent"
            }
          },
          "contentElements": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ContentElement"
            }
          },
          "dateCreated": {
            "type": "string",
            "format": "date-time"
          },
          "dateModified": {
            "type": "string",
            "format": "date-time"
          },
          "documentId": {
            "type": "string",
            "description": "The document's unique ID"
          },
          "versionTimestamp": {
            "type": "string",
            "format": "date-time"
          }
        },
        "description": "A neverpile document"
      }
    }
  },
  "servers": [
    {
      "url": "/",
      "description": "neverpile fusion"
    },
    {
      "url": "/",
      "description": "neverpile eureka"
    }
  ]
}
