---
setup:
- skip:
    features:
    - "headers"
    - "allowed_warnings_regex"
- do:
    indices.create:
      index: "airline-data"
      body:
        mappings:
          properties:
            time:
              type: "date"
            airline:
              type: "keyword"
            responsetime:
              type: "float"
            event_rate:
              type: "integer"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - ".*rollup functionality will be removed in Elasticsearch.*"
    - "Index \\[\\.profiling-.*\\] name begins with a dot.* and will not be allowed\
      \ in a future Elasticsearch version."
    - "Parameter \\[default_metric\\] is deprecated and will be removed in a future\
      \ version"
- do:
    transform.put_transform:
      transform_id: "updating-airline-transform"
      body: "{\n  \"source\": { \"index\": \"airline-data\" },\n  \"dest\": { \"index\"\
        : \"airline-data-by-airline\" },\n  \"pivot\": {\n    \"group_by\": { \"airline\"\
        : {\"terms\": {\"field\": \"airline\"}}},\n    \"aggs\": {\"avg_response\"\
        : {\"avg\": {\"field\": \"responsetime\"}}}\n  },\n  \"description\": \"yaml\
        \ test transform on airline-data\",\n  \"frequency\": \"60s\",\n  \"sync\"\
        : {\n    \"time\": {\n      \"field\": \"time\",\n      \"delay\": \"90m\"\
        \n    }\n  }\n}\n"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - ".*rollup functionality will be removed in Elasticsearch.*"
    - "Index \\[\\.profiling-.*\\] name begins with a dot.* and will not be allowed\
      \ in a future Elasticsearch version."
    - "Parameter \\[default_metric\\] is deprecated and will be removed in a future\
      \ version"
---
Test update transform with missing transform:
- do:
    catch: "/Transform with id \\[missing-transform\\] could not be found/"
    transform.update_transform:
      transform_id: "missing-transform"
      body: "{\n  \"description\": \"new description\"\n}\n"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - ".*rollup functionality will be removed in Elasticsearch.*"
    - "Index \\[\\.profiling-.*\\] name begins with a dot.* and will not be allowed\
      \ in a future Elasticsearch version."
    - "Parameter \\[default_metric\\] is deprecated and will be removed in a future\
      \ version"
---
Test update transform with missing pipeline:
- do:
    catch: "/Pipeline with id \\[missing-transform-pipeline\\] could not be found/"
    transform.update_transform:
      transform_id: "updating-airline-transform"
      body: "{\n  \"dest\": { \"index\": \"airline-data-by-airline\", \"pipeline\"\
        : \"missing-transform-pipeline\" }\n}\n"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - ".*rollup functionality will be removed in Elasticsearch.*"
    - "Index \\[\\.profiling-.*\\] name begins with a dot.* and will not be allowed\
      \ in a future Elasticsearch version."
    - "Parameter \\[default_metric\\] is deprecated and will be removed in a future\
      \ version"
---
Test update transform with frequency too low:
- do:
    catch: "/minimum permitted \\[frequency\\] is \\[1s\\]/"
    transform.update_transform:
      transform_id: "updating-airline-transform"
      body: "{\n  \"frequency\": \"999ms\"\n}\n"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - ".*rollup functionality will be removed in Elasticsearch.*"
    - "Index \\[\\.profiling-.*\\] name begins with a dot.* and will not be allowed\
      \ in a future Elasticsearch version."
    - "Parameter \\[default_metric\\] is deprecated and will be removed in a future\
      \ version"
---
Test update transform with frequency too high:
- do:
    catch: "/highest permitted \\[frequency\\] is \\[1h\\]/"
    transform.update_transform:
      transform_id: "updating-airline-transform"
      body: "{\n  \"frequency\": \"3600001ms\"\n}\n"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - ".*rollup functionality will be removed in Elasticsearch.*"
    - "Index \\[\\.profiling-.*\\] name begins with a dot.* and will not be allowed\
      \ in a future Elasticsearch version."
    - "Parameter \\[default_metric\\] is deprecated and will be removed in a future\
      \ version"
---
Test put transform with invalid source index:
- do:
    catch: "/.*Validation Failed.* no such index \\[missing-index\\]/"
    transform.update_transform:
      transform_id: "updating-airline-transform"
      body: "{\n  \"source\": { \"index\": \"missing-index\" }\n}\n"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - ".*rollup functionality will be removed in Elasticsearch.*"
    - "Index \\[\\.profiling-.*\\] name begins with a dot.* and will not be allowed\
      \ in a future Elasticsearch version."
    - "Parameter \\[default_metric\\] is deprecated and will be removed in a future\
      \ version"
- do:
    transform.update_transform:
      transform_id: "updating-airline-transform"
      defer_validation: true
      body: "{\n  \"source\": { \"index\": \"missing-index\" }\n}\n"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - ".*rollup functionality will be removed in Elasticsearch.*"
    - "Index \\[\\.profiling-.*\\] name begins with a dot.* and will not be allowed\
      \ in a future Elasticsearch version."
    - "Parameter \\[default_metric\\] is deprecated and will be removed in a future\
      \ version"
- match:
    id: "updating-airline-transform"
- match:
    source.index.0: "missing-index"
---
Test update transform when it is batch:
- do:
    transform.put_transform:
      transform_id: "batch-airline-transform"
      body: "{\n  \"source\": { \"index\": \"airline-data\" },\n  \"dest\": { \"index\"\
        : \"airline-data-by-airline\" },\n  \"pivot\": {\n    \"group_by\": { \"airline\"\
        : {\"terms\": {\"field\": \"airline\"}}},\n    \"aggs\": {\"avg_response\"\
        : {\"avg\": {\"field\": \"responsetime\"}}}\n  }\n}\n"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - ".*rollup functionality will be removed in Elasticsearch.*"
    - "Index \\[\\.profiling-.*\\] name begins with a dot.* and will not be allowed\
      \ in a future Elasticsearch version."
    - "Parameter \\[default_metric\\] is deprecated and will be removed in a future\
      \ version"
- do:
    transform.update_transform:
      transform_id: "batch-airline-transform"
      body: "{\n  \"description\": \"time to update\"\n}\n"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - ".*rollup functionality will be removed in Elasticsearch.*"
    - "Index \\[\\.profiling-.*\\] name begins with a dot.* and will not be allowed\
      \ in a future Elasticsearch version."
    - "Parameter \\[default_metric\\] is deprecated and will be removed in a future\
      \ version"
- match:
    description: "time to update"
- do:
    catch: "/Cannot change the current sync configuration of transform \\[batch-airline-transform\\\
      ] from \\[null\\] to \\[time\\]/"
    transform.update_transform:
      transform_id: "batch-airline-transform"
      body: "{\n  \"sync\": {\n    \"time\": {\n      \"field\": \"time\",\n     \
        \ \"delay\": \"90m\"\n    }\n  }\n}\n"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - ".*rollup functionality will be removed in Elasticsearch.*"
    - "Index \\[\\.profiling-.*\\] name begins with a dot.* and will not be allowed\
      \ in a future Elasticsearch version."
    - "Parameter \\[default_metric\\] is deprecated and will be removed in a future\
      \ version"
---
Test basic transform crud:
- do:
    indices.create:
      index: "other-airline-data"
      body:
        mappings:
          properties:
            time:
              type: "date"
            airline:
              type: "keyword"
            responsetime:
              type: "float"
            event_rate:
              type: "integer"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - ".*rollup functionality will be removed in Elasticsearch.*"
    - "Index \\[\\.profiling-.*\\] name begins with a dot.* and will not be allowed\
      \ in a future Elasticsearch version."
    - "Parameter \\[default_metric\\] is deprecated and will be removed in a future\
      \ version"
- do:
    transform.get_transform:
      transform_id: "updating-airline-transform"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - ".*rollup functionality will be removed in Elasticsearch.*"
    - "Index \\[\\.profiling-.*\\] name begins with a dot.* and will not be allowed\
      \ in a future Elasticsearch version."
    - "Parameter \\[default_metric\\] is deprecated and will be removed in a future\
      \ version"
- match:
    count: 1
- match:
    transforms.0.id: "updating-airline-transform"
- match:
    transforms.0.source.index.0: "airline-data"
- match:
    transforms.0.dest.index: "airline-data-by-airline"
- is_true: "transforms.0.source.query.match_all"
- is_true: "transforms.0.create_time"
- is_true: "transforms.0.version"
- match:
    transforms.0.pivot.group_by.airline.terms.field: "airline"
- match:
    transforms.0.pivot.aggregations.avg_response.avg.field: "responsetime"
- match:
    transforms.0.description: "yaml test transform on airline-data"
- match:
    transforms.0.sync.time.field: "time"
- match:
    transforms.0.sync.time.delay: "90m"
- match:
    transforms.0.frequency: "60s"
- do:
    transform.update_transform:
      transform_id: "updating-airline-transform"
      body: "{\n  \"source\": { \"index\": \"other-airline-data\" },\n  \"dest\":\
        \ { \"index\": \"new-destination\" },\n  \"description\": \"updated description\"\
        ,\n  \"sync\": {\n    \"time\": { \"field\": \"time\", \"delay\": \"120m\"\
        }\n  },\n  \"frequency\": \"5s\"\n}\n"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - ".*rollup functionality will be removed in Elasticsearch.*"
    - "Index \\[\\.profiling-.*\\] name begins with a dot.* and will not be allowed\
      \ in a future Elasticsearch version."
    - "Parameter \\[default_metric\\] is deprecated and will be removed in a future\
      \ version"
- match:
    id: "updating-airline-transform"
- match:
    source.index.0: "other-airline-data"
- match:
    dest.index: "new-destination"
- is_true: "source.query.match_all"
- is_true: "create_time"
- is_true: "version"
- match:
    pivot.group_by.airline.terms.field: "airline"
- match:
    pivot.aggregations.avg_response.avg.field: "responsetime"
- match:
    description: "updated description"
- match:
    sync.time.field: "time"
- match:
    sync.time.delay: "120m"
- match:
    frequency: "5s"
- is_true: "authorization.roles"
- do:
    transform.get_transform:
      transform_id: "updating-airline-transform"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - ".*rollup functionality will be removed in Elasticsearch.*"
    - "Index \\[\\.profiling-.*\\] name begins with a dot.* and will not be allowed\
      \ in a future Elasticsearch version."
    - "Parameter \\[default_metric\\] is deprecated and will be removed in a future\
      \ version"
- match:
    count: 1
- match:
    transforms.0.id: "updating-airline-transform"
- match:
    transforms.0.source.index.0: "other-airline-data"
- match:
    transforms.0.dest.index: "new-destination"
- is_true: "transforms.0.source.query.match_all"
- is_true: "transforms.0.create_time"
- is_true: "transforms.0.version"
- match:
    transforms.0.pivot.group_by.airline.terms.field: "airline"
- match:
    transforms.0.pivot.aggregations.avg_response.avg.field: "responsetime"
- match:
    transforms.0.description: "updated description"
- match:
    transforms.0.sync.time.field: "time"
- match:
    transforms.0.sync.time.delay: "120m"
- match:
    transforms.0.frequency: "5s"
- is_true: "transforms.0.authorization.roles"
---
Test update retention policy:
- do:
    transform.get_transform:
      transform_id: "updating-airline-transform"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - ".*rollup functionality will be removed in Elasticsearch.*"
    - "Index \\[\\.profiling-.*\\] name begins with a dot.* and will not be allowed\
      \ in a future Elasticsearch version."
    - "Parameter \\[default_metric\\] is deprecated and will be removed in a future\
      \ version"
- match:
    count: 1
- match:
    transforms.0.id: "updating-airline-transform"
- match:
    transforms.0.retention_policy: null
- do:
    transform.update_transform:
      transform_id: "updating-airline-transform"
      body: "{\n  \"retention_policy\": {\n    \"time\": {\n      \"field\": \"time\"\
        ,\n      \"max_age\": \"24h\"\n    }\n  }\n}\n"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - ".*rollup functionality will be removed in Elasticsearch.*"
    - "Index \\[\\.profiling-.*\\] name begins with a dot.* and will not be allowed\
      \ in a future Elasticsearch version."
    - "Parameter \\[default_metric\\] is deprecated and will be removed in a future\
      \ version"
- do:
    transform.get_transform:
      transform_id: "updating-airline-transform"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - ".*rollup functionality will be removed in Elasticsearch.*"
    - "Index \\[\\.profiling-.*\\] name begins with a dot.* and will not be allowed\
      \ in a future Elasticsearch version."
    - "Parameter \\[default_metric\\] is deprecated and will be removed in a future\
      \ version"
- match:
    count: 1
- match:
    transforms.0.id: "updating-airline-transform"
- match:
    transforms.0.retention_policy.time.field: "time"
- match:
    transforms.0.retention_policy.time.max_age: "24h"
- is_true: "transforms.0.authorization.roles"
- do:
    transform.update_transform:
      transform_id: "updating-airline-transform"
      body: "{\n  \"retention_policy\": null\n}\n"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - ".*rollup functionality will be removed in Elasticsearch.*"
    - "Index \\[\\.profiling-.*\\] name begins with a dot.* and will not be allowed\
      \ in a future Elasticsearch version."
    - "Parameter \\[default_metric\\] is deprecated and will be removed in a future\
      \ version"
- do:
    transform.get_transform:
      transform_id: "updating-airline-transform"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - ".*rollup functionality will be removed in Elasticsearch.*"
    - "Index \\[\\.profiling-.*\\] name begins with a dot.* and will not be allowed\
      \ in a future Elasticsearch version."
    - "Parameter \\[default_metric\\] is deprecated and will be removed in a future\
      \ version"
- match:
    count: 1
- match:
    transforms.0.id: "updating-airline-transform"
- match:
    transforms.0.retention_policy: null
---
Test transform where dest is included in source:
- do:
    catch: "/Destination index \\[airline-data-by-airline\\] is included in source\
      \ expression \\[airline-data/"
    transform.update_transform:
      transform_id: "updating-airline-transform"
      body: "{\n  \"source\": {\n    \"index\": [\"airline-data*\"]\n  },\n  \"dest\"\
        : { \"index\": \"airline-data-by-airline\" }\n}\n"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - ".*rollup functionality will be removed in Elasticsearch.*"
    - "Index \\[\\.profiling-.*\\] name begins with a dot.* and will not be allowed\
      \ in a future Elasticsearch version."
    - "Parameter \\[default_metric\\] is deprecated and will be removed in a future\
      \ version"
- do:
    transform.update_transform:
      transform_id: "updating-airline-transform"
      defer_validation: true
      body: "{\n  \"source\": {\n    \"index\": [\"airline-data*\"]\n  },\n  \"dest\"\
        : { \"index\": \"airline-data-by-airline\" }\n}\n"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - ".*rollup functionality will be removed in Elasticsearch.*"
    - "Index \\[\\.profiling-.*\\] name begins with a dot.* and will not be allowed\
      \ in a future Elasticsearch version."
    - "Parameter \\[default_metric\\] is deprecated and will be removed in a future\
      \ version"
---
Test alias scenarios:
- do:
    indices.create:
      index: "created-destination-index"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - ".*rollup functionality will be removed in Elasticsearch.*"
    - "Index \\[\\.profiling-.*\\] name begins with a dot.* and will not be allowed\
      \ in a future Elasticsearch version."
    - "Parameter \\[default_metric\\] is deprecated and will be removed in a future\
      \ version"
- do:
    indices.create:
      index: "second-created-destination-index"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - ".*rollup functionality will be removed in Elasticsearch.*"
    - "Index \\[\\.profiling-.*\\] name begins with a dot.* and will not be allowed\
      \ in a future Elasticsearch version."
    - "Parameter \\[default_metric\\] is deprecated and will be removed in a future\
      \ version"
- do:
    indices.put_alias:
      index: "airline-data"
      name: "source-index"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - ".*rollup functionality will be removed in Elasticsearch.*"
    - "Index \\[\\.profiling-.*\\] name begins with a dot.* and will not be allowed\
      \ in a future Elasticsearch version."
    - "Parameter \\[default_metric\\] is deprecated and will be removed in a future\
      \ version"
- do:
    indices.put_alias:
      index: "created-destination-index"
      name: "dest-index"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - ".*rollup functionality will be removed in Elasticsearch.*"
    - "Index \\[\\.profiling-.*\\] name begins with a dot.* and will not be allowed\
      \ in a future Elasticsearch version."
    - "Parameter \\[default_metric\\] is deprecated and will be removed in a future\
      \ version"
- do:
    transform.update_transform:
      transform_id: "updating-airline-transform"
      body: "{\n  \"source\": {\n    \"index\": \"source-index\"\n  },\n  \"dest\"\
        : { \"index\": \"dest-index\" }\n}\n"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - ".*rollup functionality will be removed in Elasticsearch.*"
    - "Index \\[\\.profiling-.*\\] name begins with a dot.* and will not be allowed\
      \ in a future Elasticsearch version."
    - "Parameter \\[default_metric\\] is deprecated and will be removed in a future\
      \ version"
- match:
    id: "updating-airline-transform"
- do:
    indices.put_alias:
      index: "created-destination-index"
      name: "source2-index"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - ".*rollup functionality will be removed in Elasticsearch.*"
    - "Index \\[\\.profiling-.*\\] name begins with a dot.* and will not be allowed\
      \ in a future Elasticsearch version."
    - "Parameter \\[default_metric\\] is deprecated and will be removed in a future\
      \ version"
- do:
    catch: "/.*Validation Failed.* Destination index \\[created-destination-index\\\
      ] is included in source expression \\[created-destination-index\\]/"
    transform.update_transform:
      transform_id: "updating-airline-transform"
      body: "{\n  \"source\": {\n    \"index\": \"source2-index\"\n  },\n  \"dest\"\
        : { \"index\": \"dest-index\" }\n}\n"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - ".*rollup functionality will be removed in Elasticsearch.*"
    - "Index \\[\\.profiling-.*\\] name begins with a dot.* and will not be allowed\
      \ in a future Elasticsearch version."
    - "Parameter \\[default_metric\\] is deprecated and will be removed in a future\
      \ version"
- do:
    indices.delete_alias:
      index: "created-destination-index"
      name: "source2-index"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - ".*rollup functionality will be removed in Elasticsearch.*"
    - "Index \\[\\.profiling-.*\\] name begins with a dot.* and will not be allowed\
      \ in a future Elasticsearch version."
    - "Parameter \\[default_metric\\] is deprecated and will be removed in a future\
      \ version"
- do:
    indices.put_alias:
      index: "second-created-destination-index"
      name: "dest2-index"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - ".*rollup functionality will be removed in Elasticsearch.*"
    - "Index \\[\\.profiling-.*\\] name begins with a dot.* and will not be allowed\
      \ in a future Elasticsearch version."
    - "Parameter \\[default_metric\\] is deprecated and will be removed in a future\
      \ version"
- do:
    indices.put_alias:
      index: "created-destination-index"
      name: "dest2-index"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - ".*rollup functionality will be removed in Elasticsearch.*"
    - "Index \\[\\.profiling-.*\\] name begins with a dot.* and will not be allowed\
      \ in a future Elasticsearch version."
    - "Parameter \\[default_metric\\] is deprecated and will be removed in a future\
      \ version"
- do:
    catch: "/.*Validation Failed.* no write index is defined for alias [dest2-index].*/"
    transform.update_transform:
      transform_id: "updating-airline-transform"
      body: "{\n  \"dest\": { \"index\": \"dest2-index\" }\n}\n"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - ".*rollup functionality will be removed in Elasticsearch.*"
    - "Index \\[\\.profiling-.*\\] name begins with a dot.* and will not be allowed\
      \ in a future Elasticsearch version."
    - "Parameter \\[default_metric\\] is deprecated and will be removed in a future\
      \ version"
---
Test invalid destination index name:
- do:
    catch: "/.*Validation Failed.* Destination index \\[DeStInAtIoN\\] must be lowercase/"
    transform.update_transform:
      transform_id: "updating-airline-transform"
      body: "{\n  \"dest\": { \"index\": \"DeStInAtIoN\" }\n}\n"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - ".*rollup functionality will be removed in Elasticsearch.*"
    - "Index \\[\\.profiling-.*\\] name begins with a dot.* and will not be allowed\
      \ in a future Elasticsearch version."
    - "Parameter \\[default_metric\\] is deprecated and will be removed in a future\
      \ version"
- do:
    catch: "/.*Validation Failed.* Invalid index name \\[destination#dest\\], must\
      \ not contain \\'#\\'/"
    transform.update_transform:
      transform_id: "updating-airline-transform"
      body: "{\n  \"dest\": { \"index\": \"destination#dest\" }\n}\n"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - ".*rollup functionality will be removed in Elasticsearch.*"
    - "Index \\[\\.profiling-.*\\] name begins with a dot.* and will not be allowed\
      \ in a future Elasticsearch version."
    - "Parameter \\[default_metric\\] is deprecated and will be removed in a future\
      \ version"
---
Test update transform metadata:
- do:
    transform.get_transform:
      transform_id: "updating-airline-transform"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - ".*rollup functionality will be removed in Elasticsearch.*"
    - "Index \\[\\.profiling-.*\\] name begins with a dot.* and will not be allowed\
      \ in a future Elasticsearch version."
    - "Parameter \\[default_metric\\] is deprecated and will be removed in a future\
      \ version"
- match:
    count: 1
- match:
    transforms.0.id: "updating-airline-transform"
- is_false: "transforms.0._meta"
- do:
    transform.update_transform:
      transform_id: "updating-airline-transform"
      body: "{\n  \"_meta\": {\n    \"foo\": 123,\n    \"bar\": 456,\n    \"baz\"\
        : {\n      \"a1\": 11,\n      \"a2\": 22\n    }\n  }\n}\n"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - ".*rollup functionality will be removed in Elasticsearch.*"
    - "Index \\[\\.profiling-.*\\] name begins with a dot.* and will not be allowed\
      \ in a future Elasticsearch version."
    - "Parameter \\[default_metric\\] is deprecated and will be removed in a future\
      \ version"
- match:
    id: "updating-airline-transform"
- match:
    _meta.foo: 123
- match:
    _meta.bar: 456
- match:
    _meta.baz.a1: 11
- match:
    _meta.baz.a2: 22
- is_false: "_meta.baz.a3"
- is_true: "authorization.roles"
- do:
    transform.get_transform:
      transform_id: "updating-airline-transform"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - ".*rollup functionality will be removed in Elasticsearch.*"
    - "Index \\[\\.profiling-.*\\] name begins with a dot.* and will not be allowed\
      \ in a future Elasticsearch version."
    - "Parameter \\[default_metric\\] is deprecated and will be removed in a future\
      \ version"
- match:
    count: 1
- match:
    transforms.0.id: "updating-airline-transform"
- match:
    transforms.0._meta.foo: 123
- match:
    transforms.0._meta.bar: 456
- match:
    transforms.0._meta.baz.a1: 11
- match:
    transforms.0._meta.baz.a2: 22
- is_false: "transforms.0._meta.baz.a3"
- is_true: "transforms.0.authorization.roles"
- do:
    transform.update_transform:
      transform_id: "updating-airline-transform"
      body: "{\n  \"_meta\": {\n    \"bar\": \"some bar note\",\n    \"baz\": {\n\
        \      \"a2\": 222,\n      \"a3\": 333\n    }\n  }\n}\n"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - ".*rollup functionality will be removed in Elasticsearch.*"
    - "Index \\[\\.profiling-.*\\] name begins with a dot.* and will not be allowed\
      \ in a future Elasticsearch version."
    - "Parameter \\[default_metric\\] is deprecated and will be removed in a future\
      \ version"
- match:
    id: "updating-airline-transform"
- is_false: "_meta.foo"
- match:
    _meta.bar: "some bar note"
- is_false: "_meta.baz.a1"
- match:
    _meta.baz.a2: 222
- match:
    _meta.baz.a3: 333
- is_true: "authorization.roles"
- do:
    transform.get_transform:
      transform_id: "updating-airline-transform"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - ".*rollup functionality will be removed in Elasticsearch.*"
    - "Index \\[\\.profiling-.*\\] name begins with a dot.* and will not be allowed\
      \ in a future Elasticsearch version."
    - "Parameter \\[default_metric\\] is deprecated and will be removed in a future\
      \ version"
- match:
    count: 1
- match:
    transforms.0.id: "updating-airline-transform"
- is_false: "transforms.0._meta.foo"
- match:
    transforms.0._meta.bar: "some bar note"
- is_false: "transforms.0._meta.baz.a1"
- match:
    transforms.0._meta.baz.a2: 222
- match:
    transforms.0._meta.baz.a3: 333
- is_true: "transforms.0.authorization.roles"
