scenario:
  id: 376ad526-529d-4026-81d7-ecc60e8c89a1
  context:
    auth:
      type: bearer
    base_path: null
    host: us-west-2.env.shared.aws.tidbcloud.com
  description: next gen console dm operation
  name: ng_console_cluster_dm
steps:
  - operation_id: TidbService_CreateTidb
    request_type: http
    request: |-
      {
        "method": "POST",
        "path": "/api/v2025/cloud/v1beta2/tidbs?orgId={orgId}",
        "headers": {},
        "query_params": {},
        "body": {
          "displayName": "ng-console-cluster-dm",
          "regionId": "{regionId}",
          "maxRcu": "6000",
          "servicePlan": "Premium",
          "cloudProvider": "{cloud_provider}",
          "highAvailabilityType": "REGIONAL"
        },
        "body_params": {
          "regionId": "region_id",
          "cloud_provider": "cloud_provider"
        },
        "path_params": {
          "orgId": "org_id"
        },
        "auth": {
          "auth_type": "bearer_token"
        }
      }
    expect: |-
      {
        "status_code": 200,
        "cel": ""
      }
    save: |-
      {
        "placeholder": [
          {
            "key": "cluster_1",
            "eval": "body.tidbId"
          }
        ]
      }
    description: ''
    max_retries: 0
    delay_after: 0
    name: ''
    continue_on_unexpected: false
    stage: ''
    meta: '{}'
    generation_id: ''
    order: 0
  - operation_id: TidbService_GetTidb
    request_type: http
    request: |-
      {
        "method": "GET",
        "path": "/api/v2025/cloud/v1beta2/tidbs/{tidbId}?orgId={orgId}",
        "headers": {},
        "query_params": {},
        "body": {},
        "auth": {
          "auth_type": "bearer_token"
        },
        "path_params": {
          "tidbId": "cluster_1",
          "orgId": "org_id"
        }
      }
    expect: |-
      {
        "status_code": 200,
        "cel": "body.state == 'ACTIVE'"
      }
    save: null
    description: ""
    max_retries: 120
    delay_after: 30
    name: ""
    continue_on_unexpected: false
    stage: ""
    meta: "{}"
    generation_id: ""
    order: 1
  - case_id: c37f522f5754a26096985d8962f63afe
    operation_id: TidbService_ResetPassword
    case_type: typical_positive
    request_type: http
    request: |-
      {
        "auth": {
          "auth_type": "bearer_token"
        },
        "method": "POST",
        "path": "/api/v2025/cloud/v1beta2/tidbs/{tidbId}:resetRootPassword?orgId={orgId}",
        "path_params": {
          "tidbId": "cluster_1",
          "orgId": "org_id"
        },
        "query_params": {},
        "headers": {},
        "body": {
          "rootPassword": "31415926"
        },
        "body_params": {}
      }
    expect: |-
      {
        "status_code": 200,
        "cel": ""
      }
    description: Reset Cluster Pasword 
    max_retries: 3
    delay_after: 15
    step_type: defined
    name: reset_password
    save: null
    continue_on_unexpected: false
    stage: execute
    meta: "{}"
    generation_id: 09198df8-3eef-4d82-a5a4-31eb9b0db7de
    order: 2
  - operation_id: premiumMigrations_GetDMList
    request_type: http
    request: |-
      {
        "method": "GET",
        "path": "/api/v2025/cloud/v1beta2/tidbs/{tidbId}/premiumMigrations?page_token=1&page_size=10&order_by=create_time+desc",
        "headers": {},
        "query_params": {},
        "body": {},
        "auth": {
          "auth_type": "bearer_token"
        },
        "path_params": {
          "tidbId": "cluster_1",
          "orgId": "org_id"
        }
      }
    expect: |-
      {
        "status_code": 200,
        "cel": "body.total_size == 0"
      }
    save: null
    description: ""
    max_retries: 120
    delay_after: 30
    name: ""
    continue_on_unexpected: false
    stage: ""
    meta: "{}"
    generation_id: ""
    order: 3
  - case_id: c37f522f5754a26096985d8962f63afe
    operation_id: premiumMigrations_validateSourceConnection
    case_type: typical_positive
    request_type: http
    request: |-
      {
        "auth": {
          "auth_type": "bearer_token"
        },
        "method": "POST",
        "path": "/api/v2025/cloud/v1beta2/tidbs/{tidbId}/premiumMigrations:validateSourceConnection",
        "path_params": {
          "tidbId": "cluster_1",
          "orgId": "org_id"
        },
        "query_params": {},
        "headers": {},
        "body": {
          "conn_profile": {
            "conn_type": "PUBLIC",
            "port": 49609,
            "user": "e2e_admin",
            "password": "{mysql_source_password}",
            "host": "34.218.43.86"
          }   
        },
        "body_params": {
          "mysql_source_password": "mysql_source_password"
        }
      }
    expect: |-
      {
        "status_code": 200,
        "cel": ""
      }
    description: DM validateSourceConnection
    max_retries: 0
    delay_after: 0
    step_type: defined
    name: validateSourceConnection
    save: null
    continue_on_unexpected: false
    stage: execute
    meta: "{}"
    generation_id: 09198df8-3eef-4d82-a5a4-31eb9b0db7de
    order: 4
  - case_id: c37f522f5754a26096985d8962f63afe
    operation_id: premiumMigrations_validateTargetConnection
    case_type: typical_positive
    request_type: http
    request: |-
      {
        "auth": {
          "auth_type": "bearer_token"
        },
        "method": "POST",
        "path": "/api/v2025/cloud/v1beta2/tidbs/{tidbId}/premiumMigrations:validateTargetConnection",
        "path_params": {
          "tidbId": "cluster_1",
          "orgId": "org_id"
        },
        "query_params": {},
        "headers": {},
        "body": {
          "user": "root",
          "password": "31415926"
        },
        "body_params": {}
      }
    expect: |-
      {
        "status_code": 200,
        "cel": ""
      }
    description: DM validateTargetConnection
    max_retries: 0
    delay_after: 0
    step_type: defined
    name: validateTargetConnection
    save: null
    continue_on_unexpected: false
    stage: execute
    meta: "{}"
    generation_id: 09198df8-3eef-4d82-a5a4-31eb9b0db7de
    order: 5
  - case_id: c37f522f5754a26096985d8962f63afe
    operation_id: premiumMigrations_Prechecks
    case_type: typical_positive
    request_type: http
    request: |-
      {
        "auth": {
          "auth_type": "bearer_token"
        },
        "method": "POST",
        "path": "/api/v2025/cloud/v1beta2/tidbs/{tidbId}/premiumMigrationPrechecks",
        "path_params": {
          "tidbId": "cluster_1",
          "orgId": "org_id"
        },
        "query_params": {},
        "headers": {},
        "body": {
          "display_name": "dm_job_{tidbId}",
          "sources": [
              {
                  "conn_profile": {
                      "conn_type": "PUBLIC",
                      "port": 49609,
                      "user": "e2e_admin",
                      "password": "{mysql_source_password}",
                      "host": "34.218.43.86"
                  },
                  "source_type": "MYSQL",
                  "premium_migration_rules": []
              }
          ],
          "import_mode": "IMPORTMODE_LOGICAL",
          "target": {
              "user": "root",
              "password": "31415926"
          },
          "mode": "ALL"
        },
        "body_params": {
          "tidbId": "cluster_1",
          "mysql_source_password": "mysql_source_password"
        }
      }
    expect: |-
      {
        "status_code": 200,
        "cel": ""
      }
    description: DM Prechecks
    max_retries: 0
    delay_after: 0
    step_type: defined
    name: dm_prechecks
    save: |-
      {
        "placeholder": [
          {
            "key": "precheck_id_1",
            "eval": "body.precheck_id"
          }
        ]
      }
    continue_on_unexpected: false
    stage: execute
    meta: "{}"
    generation_id: 09198df8-3eef-4d82-a5a4-31eb9b0db7de
    order: 6
  - operation_id: premiumMigrations_GetPrechecks
    request_type: http
    request: |-
      {
        "method": "GET",
        "path": "/api/v2025/cloud/v1beta2/tidbs/{tidbId}/premiumMigrationPrechecks/{precheckId}",
        "query_params": {},
        "body": {},
        "auth": {
          "auth_type": "bearer_token"
        },
        "path_params": {
          "tidbId": "cluster_1",
          "precheckId": "precheck_id_1"
        }
      }
    expect: |-
      {
        "status_code": 200,
        "cel": "body.status == 'FINISHED'"
      }
    save: null
    description: ""
    max_retries: 120
    delay_after: 30
    name: ""
    continue_on_unexpected: false
    stage: ""
    meta: "{}"
    generation_id: ""
    order: 7
  - case_id: c37f522f5754a26096985d8962f63afe
    operation_id: premiumMigrations_CreateDMJob
    case_type: typical_positive
    request_type: http
    request: |-
      {
        "auth": {
          "auth_type": "bearer_token"
        },
        "method": "POST",
        "path": "/api/v2025/cloud/v1beta2/tidbs/{tidbId}/premiumMigrations",
        "path_params": {
          "tidbId": "cluster_1",
          "orgId": "org_id"
        },
        "query_params": {},
        "headers": {},
        "body": {
          "display_name": "dm_job_{tidbId}",
          "sources": [
              {
                  "conn_profile": {
                      "conn_type": "PUBLIC",
                      "port": 49609,
                      "user": "e2e_admin",
                      "password": "{mysql_source_password}",
                      "host": "34.218.43.86"
                  },
                  "source_type": "MYSQL",
                  "premium_migration_rules": []
              }
          ],
          "import_mode": "IMPORTMODE_LOGICAL",
          "target": {
              "user": "root",
              "password": "31415926"
          },
          "mode": "ALL"
        },
        "body_params": {
          "tidbId": "cluster_1",
          "mysql_source_password": "mysql_source_password"
        }
      }
    expect: |-
      {
        "status_code": 200,
        "cel": ""
      }
    description: Create DM Job
    max_retries: 0
    delay_after: 0
    step_type: defined
    name: create_dm_job
    save: |-
      {
        "placeholder": [
          {
            "key": "migration_id_1",
            "eval": "body.migration_id"
          }
        ]
      }
    continue_on_unexpected: false
    stage: execute
    meta: "{}"
    generation_id: 09198df8-3eef-4d82-a5a4-31eb9b0db7de
    order: 8
  - operation_id: premiumMigrations_GetJob
    request_type: http
    request: |-
      {
        "method": "GET",
        "path": "/api/v2025/cloud/v1beta2/tidbs/{tidbId}/premiumMigrations/{migrationId}",
        "query_params": {},
        "body": {},
        "auth": {
          "auth_type": "bearer_token"
        },
        "path_params": {
          "tidbId": "cluster_1",
          "migrationId": "migration_id_1"
        }
      }
    expect: |-
      {
        "status_code": 200,
        "cel": "body.state == 'RUNNING'"
      }
    save: null
    description: ""
    max_retries: 120
    delay_after: 30
    name: ""
    continue_on_unexpected: false
    stage: ""
    meta: "{}"
    generation_id: ""
    order: 9
  - operation_id: premiumMigrations_DeleteJob
    request_type: http
    request: |-
      {
        "method": "DELETE",
        "path": "/api/v2025/cloud/v1beta2/tidbs/{tidbId}/premiumMigrations/{migrationId}",
        "query_params": {},
        "body": {},
        "auth": {
          "auth_type": "bearer_token"
        },
        "path_params": {
          "tidbId": "cluster_1",
          "migrationId": "migration_id_1"
        }
      }
    expect: |-
      {
        "status_code": 200,
        "cel": "body.state == 'DELETING'"
      }
    save: null
    description: ""
    max_retries: 120
    delay_after: 30
    name: ""
    continue_on_unexpected: false
    stage: ""
    meta: "{}"
    generation_id: ""
    order: 10
  - operation_id: premiumMigrations_GetDMList
    request_type: http
    request: |-
      {
        "method": "GET",
        "path": "/api/v2025/cloud/v1beta2/tidbs/{tidbId}/premiumMigrations?page_token=1&page_size=10&order_by=create_time+desc",
        "headers": {},
        "query_params": {},
        "body": {},
        "auth": {
          "auth_type": "bearer_token"
        },
        "path_params": {
          "tidbId": "cluster_1",
          "orgId": "org_id"
        }
      }
    expect: |-
      {
        "status_code": 200,
        "cel": "body.total_size == 0"
      }
    save: null
    description: ""
    max_retries: 120
    delay_after: 30
    name: ""
    continue_on_unexpected: false
    stage: ""
    meta: "{}"
    generation_id: ""
    order: 11
  - operation_id: TidbService_DeleteTidb
    request_type: http
    request: |-
      {
        "method": "DELETE",
        "path": "/api/v2025/cloud/v1beta2/tidbs/{tidbId}?orgId={orgId}",
        "headers": {},
        "query_params": {},
        "body": {},
        "auth": {
          "auth_type": "bearer_token"
        },
        "path_params": {
          "tidbId": "cluster_1",
          "orgId": "org_id"
        }
      }
    expect: |-
      {
        "status_code": 200,
        "cel": ""
      }
    save: null
    description: ''
    max_retries: 0
    delay_after: 0
    name: ''
    continue_on_unexpected: false
    stage: ''
    meta: '{}'
    generation_id: ''
    order: 12
