{
  "openapi": "3.0.1",
  "info": {
    "title": "Neverpile fusion API",
    "contact": {
      "name": "levigo solutions gmbh",
      "url": "https://levigo.de",
      "email": "solutions@levigo.de"
    },
    "version": "1.0.0"
  },
  "tags": [
    {
      "name": "Collection",
      "description": "Collection related APIs"
    }
  ],
  "paths": {
    "/api/v1/collections": {
      "post": {
        "tags": [
          "Collection"
        ],
        "summary": "Create a new collection, letting the service assign an id for it",
        "description": "Create a new collection from the specification in the request body. The collection's id is generated by the service and returned as part of the returned collection specification as well through the location header.",
        "requestBody": {
          "description": "the new collection version",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Collection"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "New collection saved",
            "headers": {
              "Location": {
                "description": "The URL of the collection just created",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Collection"
                }
              }
            }
          },
          "405": {
            "description": "A collection with the given id already exists. Use PUT to update it."
          }
        }
      }
    },
    "/api/v1/collections/{collectionID}": {
      "get": {
        "tags": [
          "Collection"
        ],
        "summary": "Get the current version of a collection",
        "parameters": [
          {
            "name": "collectionID",
            "in": "path",
            "description": "The ID of the collection to be fetched",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Collection found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Collection"
                }
              }
            }
          },
          "400": {
            "description": "Invalid collectionID supplied"
          },
          "404": {
            "description": "Collection not found"
          }
        }
      },
      "put": {
        "tags": [
          "Collection"
        ],
        "summary": "Save a new version of a collection or create a new one",
        "description": "Replace the current version of the collection with a new one provided in the request body or create an entirely new collection. If the collection with the given id does not exist, the collection is created only if the server's configuration allows client-provided ids for new collections.\nThis operation uses optimistic concurrency control to prevent lost updates when updating a collection. To that end, the collection to be saved must carry a version timestamp matching the timestamp of the previous version.",
        "parameters": [
          {
            "name": "collectionID",
            "in": "path",
            "description": "The ID of the collection to be saved",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "requestBody": {
          "description": "the new collection version",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Collection"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "New version saved",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Collection"
                }
              }
            }
          },
          "409": {
            "description": "Version conflict detected"
          },
          "404": {
            "description": "Collection not found"
          }
        }
      }
    },
    "/api/v1/collections/{collectionID}/elements": {
      "post": {
        "tags": [
          "Collection",
          "Element"
        ],
        "summary": "Add a collection element",
        "parameters": [
          {
            "name": "collectionID",
            "in": "path",
            "description": "The ID of the collection to which to add",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "requestBody": {
          "description": "The new collection element. The element can either have its `id` property set in which case the given id is validated against the configured id strategy. Otherwise a new id is generated by the id strategy.",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Element"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Element created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Element"
                }
              }
            }
          },
          "400": {
            "description": "Invalid collectionID supplied"
          },
          "404": {
            "description": "Collection not found"
          },
          "409": {
            "description": "Element already exists (if element is supplied with a given ID and that id already exists in the collection)"
          }
        }
      }
    },
    "/api/v1/collections/{collectionID}/elements/{elementID}": {
      "get": {
        "tags": [
          "Collection",
          "Element"
        ],
        "summary": "Get a collection element",
        "parameters": [
          {
            "name": "collectionID",
            "in": "path",
            "description": "The ID of the collection to which to add",
            "schema": {
              "type": "string"
            },
            "required": true
          },
          {
            "name": "elementID",
            "in": "path",
            "description": "The ID of the element to be retrieved",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Element found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Element"
                }
              }
            }
          },
          "400": {
            "description": "Invalid collectionID supplied"
          },
          "404": {
            "description": "Collection or element not found"
          }
        }
      },
      "put": {
        "tags": [
          "Collection",
          "Element"
        ],
        "summary": "Update a collection element",
        "parameters": [
          {
            "name": "collectionID",
            "in": "path",
            "description": "The ID of the collection to be updated",
            "schema": {
              "type": "string"
            },
            "required": true
          },
          {
            "name": "elementID",
            "in": "path",
            "description": "The ID of the element to be updated",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "requestBody": {
          "description": "The new collection element value. If the element's `id` property is set then it must match the value of the `elementID` parameter.",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Element"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Element updated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Element"
                }
              }
            }
          },
          "400": {
            "description": "Invalid collectionID supplied"
          },
          "404": {
            "description": "Collection or element not found"
          },
          "406": {
            "description": "The given element's id does not match the elementID parameter."
          }
        }
      },
      "delete": {
        "tags": [
          "Collection",
          "Element"
        ],
        "summary": "Delete a collection element by its id",
        "parameters": [
          {
            "name": "collectionID",
            "in": "path",
            "description": "The ID of the collection to be updated",
            "schema": {
              "type": "string"
            },
            "required": true
          },
          {
            "name": "elementID",
            "in": "path",
            "description": "The ID of the element to be deleted",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "responses": {
          "204": {
            "description": "Element deleted"
          },
          "400": {
            "description": "Invalid collectionID supplied"
          },
          "404": {
            "description": "Collection or element not found"
          }
        }
      }
    },
    "/api/v1/collections/{collectionID}/history": {
      "get": {
        "tags": [
          "Collection",
          "History"
        ],
        "summary": "Get the list of versions of a collection by ID. The result is a list of version timestamps.",
        "parameters": [
          {
            "name": "collectionID",
            "in": "path",
            "description": "The ID of the collection for which to return the history",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Collection history found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "string",
                    "format": "date-time"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid collectionID supplied"
          },
          "404": {
            "description": "Collection not found"
          }
        }
      }
    },
    "/api/v1/collections/{collectionID}/historyWithMetadata": {
      "get": {
        "tags": [
          "Collection",
          "History"
        ],
        "summary": "Get the list of versions of a collection by ID. The result is a list of version timestamps along with creator and type information",
        "parameters": [
          {
            "name": "collectionID",
            "in": "path",
            "description": "The ID of the collection for which to return the history",
            "schema": {
              "type": "string"
            },
            "required": true
          },
          {
            "name": "groupRelatedVersions",
            "in": "query",
            "description": "whether to group related successive versions. The grouping algorithm is up to the server implementation but will, in general group only versions by the same creator with the same type.",
            "schema": {
              "type": "boolean"
            },
            "allowEmptyValue": true
          }
        ],
        "responses": {
          "200": {
            "description": "Collection history found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/VersionMetadata"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid collectionID supplied"
          },
          "404": {
            "description": "Collection not found"
          }
        }
      }
    },
    "/api/v1/collections/{collectionID}/history/{versionTimestamp}": {
      "get": {
        "tags": [
          "Collection",
          "History"
        ],
        "summary": "Get a particular version of a collection",
        "parameters": [
          {
            "name": "collectionID",
            "in": "path",
            "description": "The ID of the collection to be fetched",
            "schema": {
              "type": "string"
            },
            "required": true
          },
          {
            "name": "versionTimestamp",
            "in": "path",
            "description": "The timestamp of the version to be fetched",
            "schema": {
              "type": "string",
              "format": "date-time"
            },
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Collection found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Collection"
                }
              }
            }
          },
          "400": {
            "description": "Invalid collectionID and/or version timestamp supplied"
          },
          "404": {
            "description": "Collection not found"
          }
        }
      }
    },
    "/api/v1/collection-types": {
      "get": {
        "tags": [
          "CollectionType"
        ],
        "summary": "Get the list of all collection types",
        "responses": {
          "200": {
            "description": "List of collection types found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CollectionTypeList"
                }
              }
            }
          },
          "403": {
            "description": "Access denied"
          }
        }
      },
      "post": {
        "tags": [
          "CollectionType"
        ],
        "summary": "Create or update a collection type",
        "description": "Save the collection type given in the request body. If the type has no `id`, a random UUID is assigned. If a type with the given `id` already exists, it is replaced.",
        "requestBody": {
          "description": "The collection type specification",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CollectionType"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Collection type created/updated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CollectionType"
                }
              }
            }
          },
          "403": {
            "description": "Access denied"
          }
        }
      }
    },
    "/api/v1/collection-types/{id}": {
      "get": {
        "tags": [
          "CollectionType"
        ],
        "summary": "Get a collection type by ID",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "The ID of the collection-type to be fetched",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Collection type found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CollectionType"
                }
              }
            }
          },
          "404": {
            "description": "Collection type not found"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Collection": {
        "description": "A collection represents a set of elements which are relevant in a certain business or domain 'context. There are several possible types of elements:' * general artifacts like a document, an image or a media stream, * reference to another collection within the same system, * paged media (e.g. PDFs, scanned images, etc.) which can be arbitrarily composed from any * number of sources to form a virtual document.\nCollections are generally versioned, so that updates do not replace the old state but simply add a new version with old versions still being accessible for reference purposes.",
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "The collection's unique id. In general, an id is just a string. Implementations may however, subject ids to a certain format like UUIDs, numeric values etc."
          },
          "versionTimestamp": {
            "type": "string",
            "format": "date-time",
            "description": "The time when this version of the collection was created. The version timestamp must be unique among all versions of a collection with a certain id."
          },
          "typeId": {
            "type": "string",
            "description": "The collections type's id. The type id references a `CollectionType` via its unique id."
          },
          "dateCreated": {
            "type": "string",
            "format": "date-time",
            "description": "The time when the collection was created."
          },
          "dateModified": {
            "type": "string",
            "format": "date-time",
            "description": "The time when the collection was last modified. In contrast to the property `versionTimestamp` this property holds the business-relevant time which may be different from the technical version timestamp."
          },
          "state": {
            "type": "string",
            "enum": [
              "Active",
              "Closed",
              "MarkedForDeletion"
            ],
            "description": "The state of the collection (with the last/current version of the collection representing the current state). * `Active` - the collection is currently in active use. New versions can be create at any time. * `Closed` - the collection is closed. It can be viewed, but creating new versions and thus changing its state is restricted to users holding special permissions. * `MarkedForDeletion`- the collection is marked for deletion. Viewing the collection is restricted to users holding special permissions."
          },
          "createdBy": {
            "type": "string",
            "description": "The user who created this particular version of the collection."
          },
          "metadata": {
            "$ref": "#/components/schemas/Metadata"
          },
          "elements": {
            "type": "array",
            "description": "A collection of collection elements.",
            "items": {
              "$ref": "#/components/schemas/Element"
            }
          }
        }
      },
      "Element": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "The element's unique id. In general, an id is just a string. Implementations may however, subject ids to a certain format like UUIDs, numeric values etc. The id must be unique among all elements of the collection."
          },
          "metadata": {
            "$ref": "#/components/schemas/Metadata"
          },
          "dateCreated": {
            "type": "string",
            "format": "date-time",
            "description": "The time when the element was created."
          },
          "dateModified": {
            "type": "string",
            "format": "date-time",
            "description": "The time when the element was last modified."
          },
          "tags": {
            "type": "array",
            "description": "The element's tags. Tags describe an element and are usually used to build a view layout for a collection.",
            "items": {
              "type": "string",
              "pattern": "[\\w .-_/]+"
            }
          },
          "specification": {
            "discriminator": {
              "propertyName": "type"
            },
            "oneOf": [
              {
                "type": "object",
                "title": "Artifact",
                "description": "A general artifact which could be, for example, a document, an image or a media stream.",
                "required": [
                  "type",
                  "contentURI",
                  "mediaType"
                ],
                "properties": {
                  "type": {
                    "type": "string",
                    "description": "Must be `artifact`."
                  },
                  "contentURI": {
                    "type": "string",
                    "description": "The URI by which the artifact can be addressed. This may or may not be also a URL. If it is not a URL, further, integration-specific resolution must be performed to turn a URI into a URL suitable for loading the actual artifact data."
                  },
                  "mediaType": {
                    "$ref": "#/components/schemas/MediaType"
                  }
                }
              },
              {
                "type": "object",
                "title": "EmbeddedArtifact",
                "description": "A general artifact like `Artifact` which has its content embedded in the collection instead of it being referenced from an external source. This should generally only be used for small payload sizes up to a few kilobytes.",
                "required": [
                  "type",
                  "content",
                  "mediaType"
                ],
                "properties": {
                  "type": {
                    "type": "string",
                    "description": "Must be `embeddedArtifact`."
                  },
                  "content": {
                    "type": "string",
                    "description": "The actual artifact content. The content may be, for example, encoded as Base64. This must be reflected in the media type by adding an appropriate parameter, e.g. `type/subtype;base64`."
                  },
                  "mediaType": {
                    "$ref": "#/components/schemas/MediaType"
                  }
                }
              },
              {
                "type": "object",
                "title": "CollectionReference",
                "description": "A reference to another collection within the same system.",
                "required": [
                  "type",
                  "collectionId"
                ],
                "properties": {
                  "type": {
                    "type": "string",
                    "description": "Must be `collectionReference`."
                  },
                  "collectionId": {
                    "type": "string",
                    "description": "The id of the referenced collection."
                  }
                }
              },
              {
                "type": "object",
                "title": "CompositePaged",
                "description": "A collection element consisting of paged media (e.g. PDFs, scanned images, etc.) which can be arbitrarily composed from any number of sources to form a virtual document.",
                "required": [
                  "type"
                ],
                "properties": {
                  "type": {
                    "type": "string",
                    "description": "Must be `compositePaged`."
                  },
                  "pageSequences": {
                    "type": "array",
                    "items": {
                      "title": "PageSequence",
                      "type": "object",
                      "required": [
                        "type",
                        "contentURI"
                      ],
                      "properties": {
                        "mediaType": {
                          "$ref": "#/components/schemas/MediaType"
                        },
                        "contentURI": {
                          "type": "string",
                          "description": "The URI by which the part document can be addressed. This may or may not be also a URL. If it is not a URL, further, integration-specific resolution must be performed to turn a URI into a URL suitable for loading the actual document data."
                        },
                        "pageIndices": {
                          "type": "array",
                          "nullable": true,
                          "description": "The pages selected from the source document for inclusion into the composite paged. Indices are zero-based, i.e. the first page is index 0. As a special case, if this property is null (but _not_ the empty array!) in implies _all_ pages of the source to be included.",
                          "items": {
                            "type": "number",
                            "minimum": 0
                          }
                        },
                        "annotationData": {
                          "$ref": "#/components/schemas/AnnotationData"
                        },
                        "renderSettingsData": {
                          "type": "object",
                          "nullable": true,
                          "description": "Render settings data for the page Sequence.",
                          "properties": {
                            "pageRenderSettingsData": {
                              "type": "array",
                              "description": "Render settings data per page.",
                              "items": {
                                "type": "object",
                                "description": "Render settings data for a single page.",
                                "properties": {
                                  "pageIndex": {
                                    "description": "Index of the annotated Page in the Sequence.",
                                    "type": "number"
                                  },
                                  "serializedPageRenderSettings": {
                                    "description": "Serialized Render Inormation.",
                                    "type": "string"
                                  }
                                }
                              }
                            }
                          }
                        }
                      }
                    }
                  }
                }
              },
              {
                "type": "object",
                "title": "Query",
                "description": "A query specification. Currently carries no further properties.",
                "required": [
                  "type"
                ],
                "properties": {
                  "type": {
                    "type": "string",
                    "description": "Must be `query`."
                  }
                }
              }
            ]
          }
        }
      },
      "VersionMetadata": {
        "description": "Metadata for one or more collection versions.",
        "properties": {
          "versionTimestamps": {
            "description": "A list of version timestamps for which the metadata is applicable. Ungrouped results will have just one entry, grouped ones may have more than one.",
            "type": "array",
            "items": {
              "type": "string",
              "format": "date-time"
            },
            "minItems": 1
          },
          "typeId": {
            "type": "string",
            "description": "The collections type's id. The type id references a `CollectionType` via its unique id."
          },
          "createdBy": {
            "type": "string",
            "description": "The user who created this particular version of the collection."
          }
        }
      },
      "AnnotationData": {
        "description": "Annotations are markings, textual notes or other forms of supplementary information added to a paged document that can be applied by a user without changing the underlying document information. Anotations can be transported in various forms, e.g. as binary streams, XML, JSON etc.\nFor `CompositePaged`s, annotation data can be managed as one stream/object set for the whole element or per individual page sequence. Only one should be used for a particular element.",
        "anyOf": [
          {
            "type": "string",
            "format": "binary",
            "description": "Annotation data in binary form."
          },
          {
            "type": "object",
            "description": "Annotation data as JSON objects. The schema of those objects is subject to the requirements of the particular format implementation."
          }
        ]
      },
      "CollectionType": {
        "type": "object",
        "description": "A type definition for a collection. Each collection belongs to one of the defined collection types. The type describes the tags permitted for elements of a collection and contains rules that are used to generate views.",
        "properties": {
          "id": {
            "type": "string",
            "description": "The type's unique id. In general, an id is just a string. Implementations may however, subject ids to a certain format like UUIDs, numeric values etc."
          },
          "description": {
            "type": "string",
            "description": "The description of the collection type."
          },
          "name": {
            "type": "string",
            "description": "The name of the collection type."
          },
          "permittedTags": {
            "type": "array",
            "description": "The list of permitted tags for elements of this collection type.",
            "items": {
              "type": "string",
              "pattern": "[\\w .-_/]+"
            }
          },
          "metadata": {
            "type": "array",
            "description": "Defined metadata can then be displayed or edited in the collection.",
            "items": {
              "type": "object",
              "description": "Metadata element containing the property key and a corresponding label.",
              "required": [
                "key",
                "label"
              ],
              "properties": {
                "key": {
                  "type": "string",
                  "pattern": "^(?![0-9])[a-zA-Z0-9.]+$"
                },
                "label": {
                  "type": "string"
                },
                "type": {
                  "type": "string",
                  "enum": [
                    "string",
                    "boolean"
                  ]
                },
                "options": {
                  "type": "array",
                  "description": "For String type metadata you can define a list of valid options to choose from.",
                  "items": {
                    "type": "string"
                  }
                },
                "permission": {
                  "type": "string",
                  "enum": [
                    "EDIT",
                    "READ"
                  ]
                },
                "visibility": {
                  "type": "string",
                  "enum": [
                    "ALL",
                    "CREATE",
                    "EDIT"
                  ]
                }
              }
            }
          },
          "allowAllTags": {
            "type": "boolean",
            "description": "Whether to allow arbitrary tags in addition to the ones defined in `permittedTags`."
          },
          "views": {
            "type": "array",
            "description": "The list of views defined for this collection type.",
            "items": {
              "type": "object",
              "title": "View",
              "description": "A definition of a collection view.",
              "properties": {
                "name": {
                  "type": "string",
                  "description": "The name of the view. Usually displayed to the user when presenting a choice of views."
                },
                "elementRules": {
                  "type": "array",
                  "description": "A list of rules used generate the view based on the collection's elements. The rules are executed/called once per element.",
                  "items": {
                    "anyOf": [
                      {
                        "$ref": "#/components/schemas/JavaScriptRule"
                      }
                    ]
                  }
                },
                "treeRules": {
                  "type": "array",
                  "description": "A list of rules used finalize the view. They can be used for applications like sorting, pruning the tree etc.",
                  "items": {
                    "anyOf": [
                      {
                        "$ref": "#/components/schemas/JavaScriptRule"
                      }
                    ]
                  }
                }
              }
            }
          }
        }
      },
      "JavaScriptRule": {
        "type": "object",
        "description": "A JavaScript-based definition of a rule",
        "properties": {
          "name": {
            "type": "string",
            "description": "The name of the rule"
          },
          "scriptCode": {
            "type": "string",
            "description": "The JavaScript code making up the rule."
          }
        }
      },
      "MediaType": {
        "description": "An RFC 6863 media type",
        "type": "string",
        "pattern": "[A-Za-z][A-Za-z0-9-]*/[A-Za-z][A-Za-z0-9-]*(;([A-Za-z0-9-]+\\s*=\\s*.*)*)"
      },
      "Metadata": {
        "type": "object",
        "description": "An object's metadata. The schema of metadata is not restricted and thus can be any JSON object."
      },
      "CollectionTypeList": {
        "description": "A list of collection types. The elements include just the id and the description of the type.",
        "type": "array",
        "items": {
          "type": "object",
          "properties": {
            "id": {
              "type": "string",
              "description": "The id of the collection type"
            },
            "name": {
              "type": "string",
              "description": "The name of the collection type"
            },
            "description": {
              "type": "string",
              "description": "The description of the collection type"
            }
          }
        }
      },
      "Permissions": {
        "description": "A list of `Permission`s to be evaluated in order to make client-side authorization decisions. Permissions are to be evaluated sequentially by matching a desired action against the permission's `actionKeys`. Once a matching permission is found, the permission's `effect` shall be chosen as the evaluation's outcome.",
        "type": "array",
        "items": {
          "type": "object",
          "properties": {
            "effect": {
              "type": "string",
              "enum": [
                "ALLOW",
                "DENY"
              ],
              "description": "The effect to be caused by a match of this permission. * `ALLOW` - allow the action * `deny` - deny the action"
            },
            "actionKeys": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "description": "The action keys this permission affects. In order to ensure uniqueness, actions can choose to apply name-spacing of the form `namespace:action-name`. E.g. all core actions are prefixed with the namespace `core:`. They may also use the trailing wildcard `*`."
            }
          }
        }
      }
    }
  },
  "servers": [
    {
      "url": "/",
      "description": "neverpile fusion"
    },
    {
      "url": "/",
      "description": "neverpile eureka"
    }
  ]
}
