---
openapi: "3.0.0"
info:
    version: "1.0.0"
    title: "Chill api"
    description: "Api documentation for chill. Currently, work in progress"
servers:
    -   url: "/api"
        description: "Your current dev server"

components:
    schemas:
        StoredObject:
            type: object
            properties:
                id:
                    type: integer
                filename:
                    type: string
                type:
                    type: string
        GenericDoc:
            type: object
            properties:
                type:
                    type: string
                    enum:
                        - doc_store_generic_doc
                key:
                    type: string
                context:
                    type: string
                    enum:
                        - person
                        - accompanying-period
                doc_date:
                    $ref: '#/components/schemas/Date'

paths:
    /1.0/doc-store/stored-object/create:
        post:
            tags:
                - storedobject
            summary: Create a stored object
            responses:
                200:
                    description: "OK"
                    content:
                        application/json:
                            schema:
                                $ref: "#/components/schemas/StoredObject"
                403:
                    description: "Unauthorized"
                422:
                    description: "Invalid data"

    /1.0/doc-store/async-upload/temp_url/{uuid}/generate/post:
        get:
            tags:
                - storedobject
            summary: Get a signed route to post stored object
            parameters:
                -   in: path
                    name: uuid
                    required: true
                    allowEmptyValue: false
                    description: The UUID of the storedObject
                    schema:
                        type: string
                        format: uuid
            responses:
                200:
                    description: "OK"
                    content:
                        application/json:
                            schema:
                                type: object
                403:
                    description: "Unauthorized"
                404:
                    description: "Not found"
    /1.0/doc-store/async-upload/temp_url/{uuid}/generate/{method}:
        get:
            tags:
                - storedobject
            summary: Get a signed route to get a stored object
            parameters:
                -   in: path
                    name: uuid
                    required: true
                    allowEmptyValue: false
                    description: The UUID of the storedObjeect
                    schema:
                        type: string
                        format: uuid
                -   in: path
                    name: method
                    required: true
                    allowEmptyValue: false
                    description: the method of the signed url (get or head)
                    schema:
                        type: string
                        enum: [ get, head ]
                -   in: query
                    name: version
                    required: false
                    allowEmptyValue: false
                    description: the version's filename of the stored object
                    schema:
                        type: string
                        minLength: 2
            responses:
                200:
                    description: "OK"
                    content:
                        application/json:
                            schema:
                                type: object
                403:
                    description: "Unauthorized"
                404:
                    description: "Not found"

    /1.0/doc-store/stored-object/{uuid}/versions:
        get:
            tags:
                - storedobject
            summary: Get a signed route to post stored object
            parameters:
                -   in: path
                    name: uuid
                    required: true
                    allowEmptyValue: false
                    description: The UUID of the storedObjeect
                    schema:
                        type: string
                        format: uuid
            responses:
                200:
                    description: "OK"
                    content:
                        application/json:
                            schema:
                                type: object
                403:
                    description: "Unauthorized"
                404:
                    description: "Not found"

    /1.0/doc-store/stored-object/restore-from-version/{id}:
        post:
            tags:
                - storedobject
            summary: Restore an old version of a stored object
            parameters:
                -   in: path
                    name: id
                    required: true
                    allowEmptyValue: false
                    description: The id of the stored object version
                    schema:
                        type: integer
            responses:
                200:
                    description: "OK"
                    content:
                        application/json:
                            schema:
                                type: object
    /1.0/doc-store/generic-doc/by-period/{id}/index:
        get:
            tags:
                - storedobject
            summary: A list of generic doc associated with the accompanying period
            parameters:
                -   in: path
                    name: id
                    required: true
                    allowEmptyValue: false
                    description: The id of the accompanying period
                    schema:
                        type: integer
            responses:
                200:
                    description: "OK"
                    content:
                        application/json:
                            schema:
                                allOf:
                                    - $ref: '#/components/schemas/PaginatedResult'
                                    - type: object
                                      properties:
                                          results:
                                              type: array
                                              items:
                                                  $ref: '#/components/schemas/GenericDoc'

                                type: object
