get:
  summary: Return a specific artifact file contents
  description: "Given a project, repository, architecture and package, retrieve the given file's content."
  security:
    - basic_authentication: []
  parameters:
    - $ref: '../components/parameters/project_name.yaml'
    - $ref: '../components/parameters/repository_name.yaml'
    - $ref: '../components/parameters/architecture_name.yaml'
    - $ref: '../components/parameters/package_name.yaml'
    - $ref: '../components/parameters/file_name.yaml'
  responses:
    '200':
      description:
        Returns the artifact's actual file contents
      content:
        application/*:
          schema:
            type: string
            format: binary
    '401':
      $ref: '../components/responses/unauthorized.yaml'
    '404':
      description: |
        Error: Not Found

        XML Schema used for body validation: [status.rng](../schema/status.rng)
      content:
        application/xml; charset=utf-8:
          schema:
            $ref: '../components/schemas/api_response.yaml'
          example:
            code: '404'
            summary: "project 'home:Admin' has no repository '4'"
            details: "404 project 'home:Admin' has no repository '4'"
  tags:
    - Build

put:
  summary: Update a specific artifact file contents
  description: |
    Given a project, repository, architecture and package, update the given file's content.

    This is for Admins only.
  security:
    - basic_authentication: []
  parameters:
    - $ref: '../components/parameters/project_name.yaml'
    - $ref: '../components/parameters/repository_name.yaml'
    - $ref: '../components/parameters/architecture_name.yaml'
    - name: package_name
      in: path
      schema:
        type: array
        items:
          type: string
          enum:
            - "_repository"
      required: true
      description: Package name
    - $ref: '../components/parameters/file_name.yaml'
  requestBody:
    content:
      plain/text:
        schema:
          type: string
          properties:
            file:
              type: string
              format: binary
  responses:
    '200':
      description:
        Updates the artifact's file contents
      content:
        application/xml; charset=utf-8:
          schema:
            $ref: '../components/schemas/api_response.yaml'
          example:
            code: 'ok'
    '401':
      $ref: '../components/responses/unauthorized.yaml'
    '403':
      description: No permission to upload binaries for this project
      content:
        application/xml; charset=utf-8:
          schema:
            $ref: '../components/schemas/api_response.yaml'
          example:
            code: 'upload_binary_no_permission'
            summary: "No permission to upload binaries."
    '404':
      description: |
        Error: Not Found

        XML Schema used for body validation: [status.rng](../schema/status.rng)
      content:
        application/xml; charset=utf-8:
          schema:
            $ref: '../components/schemas/api_response.yaml'
          example:
            code: '404'
            summary: "project 'home:Admin' has no repository '4'"
            details: "404 project 'home:Admin' has no repository '4'"
  tags:
    - Build

delete:
  summary: Delete an existing repository artifact
  description: |
    Given a project, repository and architecture delete the given file in the repository.

    The user needs to have write permissions into the artifact
  security:
    - basic_authentication: []
  parameters:
    - $ref: '../components/parameters/project_name.yaml'
    - $ref: '../components/parameters/repository_name.yaml'
    - $ref: '../components/parameters/architecture_name.yaml'
    - name: package_name
      in: path
      schema:
        type: array
        items:
          type: string
          enum:
            - "_repository"
      required: true
      description: Package name. '_repository' is the only posible value.
    - $ref: '../components/parameters/file_name.yaml'
  responses:
    '200':
      $ref: '../components/responses/succeeded.yaml'
    '400':
      description: Operation is not allowed
      content:
        application/xml; charset=utf-8:
          schema:
            $ref: '../components/schemas/api_response.yaml'
          example:
            code: 'invalid_operation'
            summary: 'Delete operation of build results is not allowed'
    '403':
      description: No permission to delete binaries from this project
      content:
        application/xml; charset=utf-8:
          schema:
            $ref: '../components/schemas/api_response.yaml'
          example:
            code: 'delete_binary_no_permission'
            summary: "No permission to delete binaries from project home:Admin."
    '404':
      description: |
        Error: Not Found

        XML Schema used for body validation: [status.rng](../schema/status.rng)
      content:
        application/xml; charset=utf-8:
          schema:
            $ref: '../components/schemas/api_response.yaml'
          example:
            code: '404'
            summary: "project 'home:Admin' has no repository '4'"
  tags:
    - Build
