scenario:
  id: bee93175-b9d9-4eb6-b3a2-f5f7f145b8cf
  context:
    auth:
      type: digest
    base_path: /v1beta2
    host: null
  description: ng_byoc_public_connection_azure
  name: ng_byoc_public_connection_azure
steps:
  - operation_id: TidbService_CreateTidb
    request_type: http
    request: |-
      {
        "method": "POST",
        "path": "/tidbs",
        "headers": {},
        "query_params": {},
        "body": {
          "displayName": "sce-ng-byoc-public-connection-azure",
          "regionId": "{regionId}",
          "minRcu": "5000",
          "maxRcu": "6000",
          "servicePlan": "BYOC",
          "cloudProvider": "{cloud_provider}",
          "resourcePoolId": "{resource_pool_id}"
        },
        "body_params": {
          "regionId": "region_id",
          "cloud_provider": "cloud_provider",
          "resource_pool_id": "resource_pool_id"
        },
        "auth": {
          "auth_type": "digest",
          "content": {
            "private_key": "placeholder",
            "public_key": "placeholder"
          }
        }
      }
    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": "/tidbs/{tidbId}",
        "headers": {},
        "query_params": {},
        "body": {},
        "auth": {
          "auth_type": "digest",
          "content": {
            "private_key": "placeholder",
            "public_key": "placeholder"
          }
        },
        "path_params": {
          "tidbId": "cluster_1"
        }
      }
    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
  - operation_id: TidbService_ResetRootPassword
    request_type: http
    request: |-
      {
        "method": "POST",
        "path": "/tidbs/{tidbId}:resetRootPassword",
        "headers": {},
        "query_params": {},
        "body": {
          "rootPassword": "pi31415926"
        },
        "auth": {
          "auth_type": "digest",
          "content": {
            "private_key": "placeholder",
            "public_key": "placeholder"
          }
        },
        "path_params": {
          "tidbId": "cluster_1"
        }
      }
    expect: |-
      {
        "status_code": 200,
        "cel": ""
      }
    save: null
    description: ''
    max_retries: 5
    delay_after: 60
    name: ''
    continue_on_unexpected: false
    stage: ''
    meta: '{}'
    generation_id: ''
    order: 1.5
  - operation_id: PublicConnectionSettingService_GetPublicConnectionSetting
    request_type: http
    request: |-
      {
        "method": "GET",
        "path": "/tidbs/{tidbId}/publicConnectionSetting",
        "headers": {},
        "query_params": {},
        "body": {},
        "auth": {
          "auth_type": "digest",
          "content": {
            "private_key": "placeholder",
            "public_key": "placeholder"
          }
        },
        "path_params": {
          "tidbId": "cluster_1"
        }
      }
    expect: |-
      {
        "status_code": 200,
        "cel": "body.enabled == false"
      }
    save: null
    description: ""
    max_retries: 0
    delay_after: 0
    name: ""
    continue_on_unexpected: false
    stage: ""
    meta: "{}"
    generation_id: ""
    order: 1.6
  - operation_id: PublicConnectionSettingService_UpdatePublicConnectionSetting
    request_type: http
    request: |-
      {
        "method": "PATCH",
        "path": "/tidbs/{tidbId}/publicConnectionSetting",
        "headers": {},
        "query_params": {},
        "body": {
          "enabled": true,
          "ipAccessList": [
            {
              "cidrNotation": "0.0.0.0/0",
              "description": "Allow all IPs"
            }
          ]
        },
        "auth": {
          "auth_type": "digest",
          "content": {
            "private_key": "placeholder",
            "public_key": "placeholder"
          }
        },
        "path_params": {
          "tidbId": "cluster_1"
        }
      }
    expect: |-
      {
        "status_code": 200,
        "cel": ""
      }
    save: null
    description: ""
    max_retries: 0
    delay_after: 0
    name: ""
    continue_on_unexpected: false
    stage: ""
    meta: "{}"
    generation_id: ""
    order: 2
  - operation_id: PublicConnectionSettingService_GetPublicConnectionSetting
    request_type: http
    request: |-
      {
        "method": "GET",
        "path": "/tidbs/{tidbId}/publicConnectionSetting",
        "headers": {},
        "query_params": {},
        "body": {},
        "auth": {
          "auth_type": "digest",
          "content": {
            "private_key": "placeholder",
            "public_key": "placeholder"
          }
        },
        "path_params": {
          "tidbId": "cluster_1"
        }
      }
    expect: |-
      {
        "status_code": 200,
        "cel": "body.enabled == true && body.ipAccessList[0].description == 'Allow all IPs'"
      }
    save: null
    description: ""
    max_retries: 0
    delay_after: 0
    name: ""
    continue_on_unexpected: false
    stage: ""
    meta: "{}"
    generation_id: ""
    order: 2.5
  - operation_id: ClusterService_GetCluster
    generation_id: 09198df8-3eef-4d82-a5a4-31eb9b0db7de
    order: 3
    case_type: supplimental_positive
    request_type: http
    request: |-
      {
        "auth": {
          "auth_type": "digest",
          "content": {"private_key": "placeholder","public_key": "placeholder"}
        },
        "method": "GET",
        "path": "/tidbs/{tidbId}",
        "path_params": {
          "tidbId": "cluster_1"
        },
        "query_params": {},
        "headers": {},
        "body": {}
      }
    expect: |-
      {
        "status_code": 200,
        "cel": "body.state == \"ABC\""
      }
    description: Poll the cluster state until it becomes ACTIVE.
    max_retries: 40
    delay_after: 10
    step_type: defined
    name: force_wait_dns
    save: null
    continue_on_unexpected: true
    stage: prepare
    meta: "{}"
  - operation_id: TidbService_GetTidb
    request_type: http
    request: |-
      {
        "method": "GET",
        "path": "/tidbs/{tidbId}",
        "headers": {},
        "query_params": {},
        "body": {},
        "auth": {
          "auth_type": "digest",
          "content": {
            "private_key": "placeholder",
            "public_key": "placeholder"
          }
        },
        "path_params": {
          "tidbId": "cluster_1"
        }
      }
    expect: |-
      {
        "status_code": 200,
        "cel": "body.state == \"ACTIVE\" && size(body.endpoints.filter(e, e.connectionType == 'PUBLIC')) > 0 && body.endpoints.filter(e, e.connectionType == 'PUBLIC')[0].host != \"\""
      }
    save: |-
      {
        "placeholder": [
          {"key": "public_endpoint", "eval": "body.endpoints.filter(e, e.connectionType == 'PUBLIC')[0].host"},
          {"key": "port", "eval": "body.endpoints.filter(e, e.connectionType == 'PUBLIC')[0].port"}
        ]
      }
    description: ""
    max_retries: 120
    delay_after: 30
    name: ""
    continue_on_unexpected: false
    stage: ""
    meta: "{}"
    generation_id: ""
    order: 4
  - operation_id: Mysqlsh_connection
    generation_id: 09198df8-3eef-4d82-a5a4-31eb9b0db7de
    order: 5
    case_type: typical_positive
    request_type: cmd_mysqlsh
    request: |-
      {
        "name": "mysqlsh",
        "args": [
          "--sql",
          "mysql://root:pi31415926@{public_endpoint}:{port}/mysql",
          "--result-format=json",
          "-e",
          "select count(*) as count from mysql.user",
          "--quiet-start=2"
        ],
        "args_params": {
          "public_endpoint": "public_endpoint",
          "port": "port"
        }
      }
    expect: |-
      {
        "exit_code": 0,
        "cel": "output.count >= 1"
      }
    description: Check the connection status of the cluster.
    max_retries: 0
    delay_after: 0
    step_type: defined
    name: check_password
    continue_on_unexpected: false
    save: null
    stage: execute
    meta: "{}"
  - operation_id: PublicConnectionSettingService_UpdatePublicConnectionSetting
    request_type: http
    request: |-
      {
        "method": "PATCH",
        "path": "/tidbs/{tidbId}/publicConnectionSetting",
        "headers": {},
        "query_params": {},
        "body": {
          "enabled": true,
          "ipAccessList": [
            {
              "cidrNotation": "152.104.28.129/32",
              "description": "Existing IP address"
            },
            {
              "cidrNotation": "0.0.0.0/0",
              "description": "Allow all IPs"
            }
          ]
        },
        "auth": {
          "auth_type": "digest",
          "content": {
            "private_key": "placeholder",
            "public_key": "placeholder"
          }
        },
        "path_params": {
          "tidbId": "cluster_1"
        }
      }
    expect: |-
      {
        "status_code": 200,
        "cel": ""
      }
    save: null
    description: ""
    max_retries: 0
    delay_after: 0
    name: ""
    continue_on_unexpected: false
    stage: ""
    meta: "{}"
    generation_id: ""
    order: 6
  - operation_id: Mysqlsh_connection
    generation_id: 09198df8-3eef-4d82-a5a4-31eb9b0db7de
    order: 7
    case_type: typical_positive
    request_type: cmd_mysqlsh
    request: |-
      {
        "name": "mysqlsh",
        "args": [
          "--sql",
          "mysql://root:pi31415926@{public_endpoint}:{port}/mysql",
          "--result-format=json",
          "-e",
          "select count(*) as count from mysql.user",
          "--quiet-start=2"
        ],
        "args_params": {
          "public_endpoint": "public_endpoint",
          "port": "port"
        }
      }
    expect: |-
      {
        "exit_code": 0,
        "cel": "output.count >= 1"
      }
    description: Check the connection status of the cluster.
    max_retries: 0
    delay_after: 0
    step_type: defined
    name: check_password
    continue_on_unexpected: false
    save: null
    stage: execute
    meta: "{}"
  - operation_id: PublicConnectionSettingService_UpdatePublicConnectionSetting
    request_type: http
    request: |-
      {
        "method": "PATCH",
        "path": "/tidbs/{tidbId}/publicConnectionSetting",
        "headers": {},
        "query_params": {},
        "body": {
          "enabled": false,
          "ipAccessList": [
            {
              "cidrNotation": "152.104.28.129/32",
              "description": "Existing IP address"
            },
            {
              "cidrNotation": "0.0.0.0/0",
              "description": "Allow all IPs"
            }
          ]
        },
        "auth": {
          "auth_type": "digest",
          "content": {
            "private_key": "placeholder",
            "public_key": "placeholder"
          }
        },
        "path_params": {
          "tidbId": "cluster_1"
        }
      }
    expect: |-
      {
        "status_code": 200,
        "cel": ""
      }
    save: null
    description: ""
    max_retries: 0
    delay_after: 0
    name: ""
    continue_on_unexpected: false
    stage: ""
    meta: "{}"
    generation_id: ""
    order: 8
  - operation_id: ClusterService_GetCluster
    generation_id: 09198df8-3eef-4d82-a5a4-31eb9b0db7de
    order: 8.5
    case_type: supplimental_positive
    request_type: http
    request: |-
      {
        "auth": {
          "auth_type": "digest",
          "content": {"private_key": "placeholder","public_key": "placeholder"}
        },
        "method": "GET",
        "path": "/tidbs/{tidbId}",
        "path_params": {
          "tidbId": "cluster_1"
        },
        "query_params": {},
        "headers": {},
        "body": {}
      }
    expect: |-
      {
        "status_code": 200,
        "cel": "body.state == \"ABC\""
      }
    description: Poll the cluster state until it becomes ACTIVE.
    max_retries: 30
    delay_after: 10
    step_type: defined
    name: force_wait_dns
    save: null
    continue_on_unexpected: true
    stage: prepare
    meta: "{}"
  - operation_id: Mysqlsh_connection
    generation_id: 09198df8-3eef-4d82-a5a4-31eb9b0db7de
    order: 9
    case_type: typical_positive
    request_type: cmd_mysqlsh
    request: |-
      {
        "name": "mysqlsh",
        "args": [
          "--sql",
          "mysql://root:pi31415926@{public_endpoint}:{port}/mysql",
          "--result-format=json",
          "-e",
          "select count(*) as count from mysql.user",
          "--quiet-start=2"
        ],
        "args_params": {
          "public_endpoint": "public_endpoint",
          "port": "port"
        }
      }
    expect: |-
      {
        "exit_code": 1,
        "cel": ""
      }
    description: Check the connection status of the cluster.
    max_retries: 0
    delay_after: 0
    step_type: defined
    name: check_password
    continue_on_unexpected: true
    save: null
    stage: execute
    meta: "{}"
  - operation_id: TidbService_DeleteTidb
    request_type: http
    request: |-
      {
        "method": "DELETE",
        "path": "/tidbs/{tidbId}",
        "headers": {},
        "query_params": {},
        "body": {},
        "auth": {
          "auth_type": "digest",
          "content": {
            "private_key": "placeholder",
            "public_key": "placeholder"
          }
        },
        "path_params": {
          "tidbId": "cluster_1"
        }
      }
    expect: |-
      {
        "status_code": 200,
        "cel": ""
      }
    save: null
    description: ''
    max_retries: 0
    delay_after: 0
    name: ''
    continue_on_unexpected: false
    stage: ''
    meta: '{}'
    generation_id: ''
    order: 10
