---
setup:
- skip:
    features:
    - "headers"
    - "allowed_warnings_regex"
---
Prevalidation basic test:
- requires:
    test_runner_features:
    - "contains"
    cluster_features:
    - "gte_v8.7.0"
    reason: "The reason field was introduced in 8.7.0"
- do:
    nodes.info: {}
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - "Use of the \\[max_size\\] rollover condition has been deprecated in favour\
      \ of the \\[max_primary_shard_size\\] condition and will be removed in a later\
      \ version"
    - "Parameter \\[confidence_interval\\] in \\[index_options\\] for dense_vector\
      \ field \\[[^\\]]+\\] is deprecated and will be removed in a future version"
- set:
    nodes._arbitrary_key_: "node_id"
- do:
    _internal.prevalidate_node_removal:
      ids: "$node_id"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - "Use of the \\[max_size\\] rollover condition has been deprecated in favour\
      \ of the \\[max_primary_shard_size\\] condition and will be removed in a later\
      \ version"
    - "Parameter \\[confidence_interval\\] in \\[index_options\\] for dense_vector\
      \ field \\[[^\\]]+\\] is deprecated and will be removed in a future version"
- match:
    is_safe: true
- contains:
    nodes:
      id: "$node_id"
      result:
        is_safe: true
        reason: "no_problems"
        message: ""
---
Prevalidation with no node specified:
- requires:
    cluster_features:
    - "gte_v8.6.0"
    reason: "API added in 8.6.0"
- do:
    catch: "bad_request"
    _internal.prevalidate_node_removal: {}
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - "Use of the \\[max_size\\] rollover condition has been deprecated in favour\
      \ of the \\[max_primary_shard_size\\] condition and will be removed in a later\
      \ version"
    - "Parameter \\[confidence_interval\\] in \\[index_options\\] for dense_vector\
      \ field \\[[^\\]]+\\] is deprecated and will be removed in a future version"
- match:
    status: 400
- match:
    error.type: "action_request_validation_exception"
- match:
    error.reason: "Validation Failed: 1: request must contain one of the parameters\
      \ 'names', 'ids', or 'external_ids';"
---
Prevalidation with more than one query parameter:
- requires:
    cluster_features:
    - "gte_v8.6.0"
    reason: "API added in 8.6.0"
- do:
    catch: "bad_request"
    _internal.prevalidate_node_removal:
      names: "node1"
      ids: "id1"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - "Use of the \\[max_size\\] rollover condition has been deprecated in favour\
      \ of the \\[max_primary_shard_size\\] condition and will be removed in a later\
      \ version"
    - "Parameter \\[confidence_interval\\] in \\[index_options\\] for dense_vector\
      \ field \\[[^\\]]+\\] is deprecated and will be removed in a future version"
- match:
    status: 400
- match:
    error.type: "action_request_validation_exception"
- match:
    error.reason: "Validation Failed: 1: request must contain only one of the parameters\
      \ 'names', 'ids', or 'external_ids';"
---
Prevalidation with non-existing node:
- requires:
    cluster_features:
    - "gte_v8.6.0"
    reason: "API added in 8.6.0"
- do:
    catch: "missing"
    _internal.prevalidate_node_removal:
      external_ids: "non-existing-id"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - "Use of the \\[max_size\\] rollover condition has been deprecated in favour\
      \ of the \\[max_primary_shard_size\\] condition and will be removed in a later\
      \ version"
    - "Parameter \\[confidence_interval\\] in \\[index_options\\] for dense_vector\
      \ field \\[[^\\]]+\\] is deprecated and will be removed in a future version"
- match:
    status: 404
- match:
    error.type: "resource_not_found_exception"
- match:
    error.reason: "could not resolve node external IDs [non-existing-id]"
