get:
  summary: List request objects that match a XPath condition.
  description: |
    Return a collection of request objects that match a XPath condition.

    This operation is the same as the one defined with [GET /search/request/id](#/Search/get_search_request_id) with the exception of the results returned.
    While the former operation returns a list of request numbers, this one return a list of request objects. See example values of a succeeded request below.
  security:
    - basic_authentication: []
  parameters:
    - in: query
      name: match
      schema:
        type: string
      required: yes
      description: |
        Expression based in XPath.

        Providing a value of `*` will return all requests.

        Available predicates are:
          - Request fields: `@id` and `@creator`.
          - State fields: `state/@name`, `state/@who`, and `state/@when`.
          - Target fields: `target/@project` and `target/@package`.
          - Source fields: `source/@project` and `source/@package`.
          - Actions fields: `action/@type`, `action/grouped/@id`, `action/target/@project`, `action/target/@package`, `action/source/@project`, and `action/source/@package`.
          - Reviews fields:
            - General: `review/@when`, `review/@state`.
            - Review by: `review/@by_user`, `review/@by_group`, `review/@by_project`, and `review/@by_package`.
            - History: `review/history/@when`.
          - History fields: `history/@when` and `history/@who`.
      examples:
        all:
          summary: All
          value: '*'
        id:
          summary: Request number
          value: '@id=123456'
        function_contains:
          summary: Function contains
          value: contains(@creator,'Igg')
        combination:
          summary: State name and date
          value: state/@name='review' and starts_with(state/@when,'2022-08-22')
    - $ref: '../components/parameters/search_limit.yaml'
    - $ref: '../components/parameters/search_offset.yaml'
    - $ref: '../components/parameters/request_withhistory.yaml'
    - $ref: '../components/parameters/request_withfullhistory.yaml'
  responses:
    '200':
      description: OK. The request has succeeded.
      content:
        application/xml; charset=utf-8:
          schema:
            $ref: '../components/schemas/request/collection.yaml'
          examples:
            no_results:
              summary: No matching results
              value:
                matches: 0
            two_results:
              summary: Two matching results
              value:
                matches: 2
                request:
                  - id: 2
                    creator: Iggy
                    description: Praesentium in nobis.
                    action:
                      type: submit
                      source:
                        project: openSUSE:Leap:15.0
                        package: apache2
                      target:
                        project: my_organization:Factory
                        package: inreview
                    state:
                      name: review
                      who: Iggy
                      when: '2022-08-22T08:06:58'
                    review:
                      - state: new
                        when: '2022-08-22T08:06:58'
                        by_package: apache2
                        by_project: openSUSE:Leap:15.0
                      - state: new
                        when: '2022-08-22T08:06:58'
                        by_user: repo-checker
                      - state: accepted
                        when: '2022-08-22T08:06:58'
                        who: Admin
                        by_group: group_1
                  - id: 4
                    creator: Iggy2
                    description: Ut voluptas quibusdam.
                    action:
                      type: submit
                      source:
                        project: requestor_project
                        package: package_1661161028_1
                      target:
                        project: my_organization:Admin
                        package: package_1661161028_1
                    state:
                      name: review
                      who: Requestor
                      when: '2022-08-22T09:37:09'
                      comment: Dolores dolore animi.
                    review:
                      - state: new
                        when: '2022-08-22T09:37:09'
                        who: Requestor
                        by_group: dolorum
                        comment: Aut ipsum accusantium.
                      - state: accepted
                        when: '2022-08-22T09:37:09'
                        who: Requestor
                        by_group: group_1
                        comment:
                        history:
                          who: Admin
                          when: '2022-08-22T09:37:09'
                          description: Review got accepted
            one_result_with_history:
              summary: One result with history
              value:
                matches: 1
                request:
                  - id: 4
                    creator: Iggy2
                    description: Ut voluptas quibusdam.
                    action:
                      type: submit
                      source:
                        project: requestor_project
                        package: package_1661161028_1
                      target:
                        project: my_organization:Admin
                        package: package_1661161028_1
                    state:
                      name: review
                      who: Requestor
                      when: '2022-08-22T09:37:09'
                      comment: Dolores dolore animi.
                    review:
                      - state: new
                        when: '2022-08-22T09:37:09'
                        who: Requestor
                        by_group: dolorum
                        comment: Aut ipsum accusantium.
                      - state: accepted
                        when: '2022-08-22T09:37:09'
                        who: Admin
                        by_group: group_1
                        comment:
                        history:
                          who: Admin
                          when: '2022-08-22T09:37:09'
                          description: Review got accepted
                    history:
                      - who: Iggy
                        when: '2022-08-22T09:37:09'
                        description: Request created
                        comment: Praesentium in nobis. Tempore omnis error.
            one_result_with_full_history:
              summary: One result with full history
              value:
                matches: 1
                request:
                  - id: 4
                    creator: Iggy2
                    description: Ut voluptas quibusdam.
                    action:
                      type: submit
                      source:
                        project: requestor_project
                        package: package_1661161028_1
                      target:
                        project: my_organization:Admin
                        package: package_1661161028_1
                    state:
                      name: review
                      who: Requestor
                      when: '2022-08-22T09:37:09'
                      comment: Dolores dolore animi.
                    review:
                      - state: new
                        when: '2022-08-22T09:37:09'
                        who: Requestor
                        by_group: dolorum
                        comment: Aut ipsum accusantium.
                      - state: accepted
                        when: '2022-08-22T09:37:09'
                        who: Admin
                        by_group: group_1
                        comment:
                        history:
                          who: Admin
                          when: '2022-08-22T09:37:09'
                          description: Review got accepted
                    history:
                      - who: Iggy
                        when: '2022-08-22T09:37:09'
                        description: Request created
                        comment: Praesentium in nobis. Tempore omnis error.
                      - who: Admin
                        when: '2022-08-22T09:37:09'
                        description: Request got accepted
    '400':
      description: Bad Request
      content:
        application/xml; charset=utf-8:
          schema:
            $ref: '../components/schemas/api_response.yaml'
          example:
            code: illegal_xpath_error
            summary: unable to evaluate 'foo' for 'requests'
    '401':
      $ref: '../components/responses/unauthorized.yaml'
    '403':
      description: |
        Forbidden.

        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: search_results_exceed_configured_limit
            summary: |
              The number of results returned by the performed search exceeds the configured limit.

              You can:
              - retrieve only the ids by using an '/search/.../id' API endpoint, or
              - reduce the number of matches of your search:
                - paginating your results, through the 'limit' and 'offset' parameters, or
                - adjusting your `match` expression.
  tags:
    - Search

post:
  deprecated: true
  summary: List requests objects that match a XPath condition.
  description: This endpoint is exactly the same as `GET /search/request`, please use that one.
  tags:
    - Search
