get:
  summary: Get package's attribute
  description: Get the specified attribute of the package
  security:
    - basic_authentication: []
  parameters:
    - $ref: '../components/parameters/project_name.yaml'
    - $ref: '../components/parameters/package_name.yaml'
    - $ref: '../components/parameters/attribute_name.yaml'
    # Query Strings:
    # `meta`: either you pass `meta` or not, it's always replaced by meta: 1.
    - name: rev
      in: query
      schema:
        type: string
      description: |
        Passing the number of the revision, this endpoint displays the attributes' XML as it was at that point.
      example: 3
    - name: view
      in: query
      schema:
        type: string
        enum:
          - blame
      description: With `view=blame`, information about who changed each XML tag and when is displayed.
      example: blame
    - name: with_default
      in: query
      schema:
        type: string
      description: |
        If the attribute doesn't contain any value and `with_default` is present,
        the default values will be displayed, if any.
      example: 1
    - name: with_project
      in: query
      schema:
        type: string
      description: |
        Passing `with_project`, the response displays the specified attribute of the package's project, if any, in addition to the package one.
      example: 1
  responses:
    '200':
      description: OK. The request has succeeded.
      content:
        application/xml; charset=utf-8:
          schema:
            $ref: '../components/schemas/source/attributes.yaml'
          examples:
            oneAttribute:
              value:
                - name: MaintenanceProject
                  namespace: OBS
            viewBlame:
              description: Passing `view=blame`.
              value: |
                10 (Admin        2023-03-09 11:46:01     1) <attributes>
                12 (Iggy         2023-03-13 14:46:01     5)   <attribute namespace="OBS" name="MakeOriginOlder"/>
                14 (Admin        2023-03-13 15:14:21     6)   <attribute namespace="OBS" name="QualityCategory">
                14 (Admin        2023-03-13 15:14:21     7)     <value>Development</value>
                14 (Admin        2023-03-13 15:14:21     8)   </attribute>
                10 (Admin        2023-03-09 11:46:01     9) </attributes>
    '400':
      description: |
        Bad Request.

        XML Schema used for body validation: [status.rng](../schema/status.rng).
      content:
        application/xml; charset=utf-8:
          schema:
            $ref: '../components/schemas/api_response.yaml'
          examples:
            invalid_attribute:
              description: Wrong attribute name.
              value:
                code: invalid_attribute
                summary: "Attribute 'OwnerRootProjectTest' must be in the $NAMESPACE:$NAME style"
    '401':
      $ref: '../components/responses/unauthorized.yaml'
    '404':
      $ref: '../components/responses/unknown_project.yaml'
  tags:
    - Sources - Packages

post:
  summary: Create or update an attribute of a package
  description: Create or update the specified attribute of the package
  security:
    - basic_authentication: []
  parameters:
    - $ref: '../components/parameters/project_name.yaml'
    - $ref: '../components/parameters/package_name.yaml'
    - $ref: '../components/parameters/attribute_name.yaml'
  requestBody:
    description: Attribute you want to create or update
    content:
      application/xml; charset=utf-8:
        schema:
          $ref: '../components/schemas/source/attributes.yaml'
        example:
          - name: MaintenanceProject
            namespace: OBS
  responses:
    '200':
      $ref: '../components/responses/succeeded.yaml'
    '400':
      description: |
        Bad Request.

        XML Schema used for body validation: [status.rng](../schema/status.rng).
      content:
        application/xml; charset=utf-8:
          schema:
            $ref: '../components/schemas/api_response.yaml'
          examples:
            invalid_attribute:
              description: Wrong attribute name.
              value:
                code: invalid_attribute
                summary: "Attribute 'OwnerRootProjectTest' must be in the $NAMESPACE:$NAME style"
            invalid_xml:
              description: When not passing an XML body to the requset.
              value:
                code: invalid_xml
                summary: Invalid XML
    '401':
      $ref: '../components/responses/unauthorized.yaml'
    '404':
      $ref: '../components/responses/unknown_project_or_package.yaml'
  tags:
    - Sources - Packages

delete:
  summary: Delete the specified attribute of a package
  security:
    - basic_authentication: []
  parameters:
    - $ref: '../components/parameters/project_name.yaml'
    - $ref: '../components/parameters/package_name.yaml'
    - $ref: '../components/parameters/attribute_name.yaml'
  responses:
    '200':
      $ref: '../components/responses/succeeded.yaml'
    '400':
      description: |
        Bad Request.

        XML Schema used for body validation: [status.rng](../schema/status.rng).
      content:
        application/xml; charset=utf-8:
          schema:
            $ref: '../components/schemas/api_response.yaml'
          examples:
            invalid_attribute:
              description: Wrong attribute name.
              value:
                code: invalid_attribute
                summary: "Attribute 'OwnerRootProjectTest' must be in the $NAMESPACE:$NAME style"
    '401':
      $ref: '../components/responses/unauthorized.yaml'
    '403':
      description: The user don't have permission to delete the specified attribute
      content:
        application/xml; charset=utf-8:
          schema:
            $ref: '../components/schemas/api_response.yaml'
          examples:
            change_attribute_no_permission:
              value:
                code: change_attribute_no_permission
                summary: User Iggy has no permission to change attribute
    '404':
      description: Unknown attribute
      content:
        application/xml; charset=utf-8:
          schema:
            $ref: '../components/schemas/api_response.yaml'
          examples:
            unknown_attribute_type:
              value:
                code: unknown_attribute_type
                summary: Attribute Type OBS:Fake does not exist
  tags:
    - Sources - Packages
