---
/preservation/waiting-list/items:
  get:
    x-mojo-to: Preservation::WaitingList#list
    operationId: listItemsFromWaitingList
    tags:
      - preservation
    summary: List items from waiting list
    parameters:
      - name: external_id
        in: query
        description: Search on the item's barcode
        required: false
        type: string
      - name: x-koha-embed
        in: header
        required: false
        description: Embed list sent as a request header
        type: array
        items:
          type: string
          enum:
            - biblio
        collectionFormat: csv
      - $ref: "../swagger.yaml#/parameters/match"
      - $ref: "../swagger.yaml#/parameters/order_by"
      - $ref: "../swagger.yaml#/parameters/page"
      - $ref: "../swagger.yaml#/parameters/per_page"
      - $ref: "../swagger.yaml#/parameters/q_param"
      - $ref: "../swagger.yaml#/parameters/q_body"
      - $ref: "../swagger.yaml#/parameters/request_id_header"
    consumes:
      - application/json
    produces:
      - application/json
    responses:
      "200":
        description: A list of item
        schema:
          type: array
          items:
            $ref: "../swagger.yaml#/definitions/item"
      "400":
        description: |
          Bad request. Possible `error_code` attribute values:

            * `invalid_query`
        schema:
          $ref: "../swagger.yaml#/definitions/error"
      "401":
        description: Authentication required
        schema:
          $ref: "../swagger.yaml#/definitions/error"
      "403":
        description: Access forbidden
        schema:
          $ref: "../swagger.yaml#/definitions/error"
      "500":
        description: |
          Internal server error. Possible `error_code` attribute values:

          * `internal_server_error`
        schema:
          $ref: "../swagger.yaml#/definitions/error"
      "503":
        description: Under maintenance
        schema:
          $ref: "../swagger.yaml#/definitions/error"
    x-koha-authorization:
      permissions:
        preservation: 1
  post:
    x-mojo-to: Preservation::WaitingList#add_items
    operationId: addItemsToWaitingList
    tags:
      - preservation
    summary: Add items to waiting list
    consumes:
      - application/json
    produces:
      - application/json
    parameters:
      - description: A list of itemnumbers or barcodes
        in: body
        name: body
        required: true
        schema:
          type: array
          items:
            type: object
    responses:
      201:
        description: A successfully added list of items
        schema:
          type: array
          items:
            type: object
      "400":
        description: Bad request
        schema:
          $ref: "../swagger.yaml#/definitions/error"
      401:
        description: Authentication required
        schema:
          $ref: "../swagger.yaml#/definitions/error"
      403:
        description: Access forbidden
        schema:
          $ref: "../swagger.yaml#/definitions/error"
      404:
        description: Ressource not found
        schema:
          $ref: "../swagger.yaml#/definitions/error"
      409:
        description: Conflict in creating resource
        schema:
          $ref: "../swagger.yaml#/definitions/error"
      413:
        description: Payload too large
        schema:
          $ref: "../swagger.yaml#/definitions/error"
      500:
        description: |
          Internal server error. Possible `error_code` attribute values:

          * `internal_server_error`
        schema:
          $ref: "../swagger.yaml#/definitions/error"
      503:
        description: Under maintenance
        schema:
          $ref: "../swagger.yaml#/definitions/error"
    x-koha-authorization:
      permissions:
        preservation: 1
/preservation/waiting-list/items/{item_id}:
  delete:
    x-mojo-to: Preservation::WaitingList#remove_item
    operationId: removeItemFromWaitingList
    tags:
      - preservation
    summary: Remove item from waiting list
    parameters:
      - $ref: "../swagger.yaml#/parameters/item_id_pp"
    produces:
      - application/json
    responses:
      "204":
        description: Item removed
      "400":
        description: Bad request
        schema:
          $ref: "../swagger.yaml#/definitions/error"
      "401":
        description: Authentication required
        schema:
          $ref: "../swagger.yaml#/definitions/error"
      "403":
        description: Access forbidden
        schema:
          $ref: "../swagger.yaml#/definitions/error"
      "404":
        description: Item not found
        schema:
          $ref: "../swagger.yaml#/definitions/error"
      "500":
        description: |
          Internal server error. Possible `error_code` attribute values:

          * `internal_server_error`
        schema:
          $ref: "../swagger.yaml#/definitions/error"
      "503":
        description: Under maintenance
        schema:
          $ref: "../swagger.yaml#/definitions/error"
    x-koha-authorization:
      permissions:
        preservation: 1
