Chilkat Online Tools

DeleteCluster TCL Example

Amazon Elastic Kubernetes Service

load ./chilkat.dll

# This example requires the Chilkat API to have been previously unlocked.
# See Global Unlock Sample for sample code.

set rest [new_CkRest]

set authAws [new_CkAuthAws]

CkAuthAws_put_AccessKey $authAws "AWS_ACCESS_KEY"
CkAuthAws_put_SecretKey $authAws "AWS_SECRET_KEY"

# Don't forget to change the region to your particular region. (Also make the same change in the call to Connect below.)
CkAuthAws_put_Region $authAws "us-west-2"
CkAuthAws_put_ServiceName $authAws "eks"
# SetAuthAws causes Chilkat to automatically add the following headers: Authorization, X-Amz-Date
CkRest_SetAuthAws $rest $authAws

# URL: https://eks.us-west-2.amazonaws.com/
# Use the same region as specified above.
set success [CkRest_Connect $rest "eks.us-west-2.amazonaws.com" 443 1 1]
if {$success != 1} then {
    puts "ConnectFailReason: [CkRest_get_ConnectFailReason $rest]"
    puts [CkRest_lastErrorText $rest]
    delete_CkRest $rest
    delete_CkAuthAws $authAws
    exit
}

CkRest_AddHeader $rest "Content-Type" "application/x-amz-json-1.1"
CkRest_AddHeader $rest "X-Amz-Target" "DeleteCluster"

set sbResponseBody [new_CkStringBuilder]

set success [CkRest_FullRequestNoBodySb $rest "DELETE" "/clusters/{name}" $sbResponseBody]
if {$success != 1} then {
    puts [CkRest_lastErrorText $rest]
    delete_CkRest $rest
    delete_CkAuthAws $authAws
    delete_CkStringBuilder $sbResponseBody
    exit
}

set respStatusCode [CkRest_get_ResponseStatusCode $rest]
puts "response status code = $respStatusCode"
if {$respStatusCode != 200} then {
    puts "Response Header:"
    puts [CkRest_responseHeader $rest]
    puts "Response Body:"
    puts [CkStringBuilder_getAsString $sbResponseBody]
    delete_CkRest $rest
    delete_CkAuthAws $authAws
    delete_CkStringBuilder $sbResponseBody
    exit
}

set jResp [new_CkJsonObject]

CkJsonObject_LoadSb $jResp $sbResponseBody

# The following code parses the JSON response.
# A sample JSON response is shown below the sample code.

# Use this online tool to generate parsing code from sample JSON:
# Generate Parsing Code from JSON

set Arn [CkJsonObject_stringOf $jResp "cluster.arn"]
set Data [CkJsonObject_stringOf $jResp "cluster.certificateAuthority.data"]
set ClientRequestToken [CkJsonObject_stringOf $jResp "cluster.clientRequestToken"]
set ActivationCode [CkJsonObject_stringOf $jResp "cluster.connectorConfig.activationCode"]
set ActivationExpiry [CkJsonObject_IntOf $jResp "cluster.connectorConfig.activationExpiry"]
set ActivationId [CkJsonObject_stringOf $jResp "cluster.connectorConfig.activationId"]
set Provider [CkJsonObject_stringOf $jResp "cluster.connectorConfig.provider"]
set RoleArn [CkJsonObject_stringOf $jResp "cluster.connectorConfig.roleArn"]
set CreatedAt [CkJsonObject_IntOf $jResp "cluster.createdAt"]
set Endpoint [CkJsonObject_stringOf $jResp "cluster.endpoint"]
set Issuer [CkJsonObject_stringOf $jResp "cluster.identity.oidc.issuer"]
set IpFamily [CkJsonObject_stringOf $jResp "cluster.kubernetesNetworkConfig.ipFamily"]
set ServiceIpv4Cidr [CkJsonObject_stringOf $jResp "cluster.kubernetesNetworkConfig.serviceIpv4Cidr"]
set ServiceIpv6Cidr [CkJsonObject_stringOf $jResp "cluster.kubernetesNetworkConfig.serviceIpv6Cidr"]
set Name [CkJsonObject_stringOf $jResp "cluster.name"]
set PlatformVersion [CkJsonObject_stringOf $jResp "cluster.platformVersion"]
set ClusterSecurityGroupId [CkJsonObject_stringOf $jResp "cluster.resourcesVpcConfig.clusterSecurityGroupId"]
set EndpointPrivateAccess [CkJsonObject_IntOf $jResp "cluster.resourcesVpcConfig.endpointPrivateAccess"]
set EndpointPublicAccess [CkJsonObject_IntOf $jResp "cluster.resourcesVpcConfig.endpointPublicAccess"]
set VpcId [CkJsonObject_stringOf $jResp "cluster.resourcesVpcConfig.vpcId"]
set clusterRoleArn [CkJsonObject_stringOf $jResp "cluster.roleArn"]
set Status [CkJsonObject_stringOf $jResp "cluster.status"]
set v_String [CkJsonObject_stringOf $jResp "cluster.tags.string"]
set Version [CkJsonObject_stringOf $jResp "cluster.version"]
set i 0
set count_i [CkJsonObject_SizeOfArray $jResp "cluster.encryptionConfig"]
while {$i < $count_i} {
    CkJsonObject_put_I $jResp $i
    set KeyArn [CkJsonObject_stringOf $jResp "cluster.encryptionConfig[i].provider.keyArn"]
    set j 0
    set count_j [CkJsonObject_SizeOfArray $jResp "cluster.encryptionConfig[i].resources"]
    while {$j < $count_j} {
        CkJsonObject_put_J $jResp $j
        set strVal [CkJsonObject_stringOf $jResp "cluster.encryptionConfig[i].resources[j]"]
        set j [expr $j + 1]
    }
    set i [expr $i + 1]
}
set i 0
set count_i [CkJsonObject_SizeOfArray $jResp "cluster.logging.clusterLogging"]
while {$i < $count_i} {
    CkJsonObject_put_I $jResp $i
    set enabled [CkJsonObject_IntOf $jResp "cluster.logging.clusterLogging[i].enabled"]
    set j 0
    set count_j [CkJsonObject_SizeOfArray $jResp "cluster.logging.clusterLogging[i].types"]
    while {$j < $count_j} {
        CkJsonObject_put_J $jResp $j
        set strVal [CkJsonObject_stringOf $jResp "cluster.logging.clusterLogging[i].types[j]"]
        set j [expr $j + 1]
    }
    set i [expr $i + 1]
}
set i 0
set count_i [CkJsonObject_SizeOfArray $jResp "cluster.resourcesVpcConfig.publicAccessCidrs"]
while {$i < $count_i} {
    CkJsonObject_put_I $jResp $i
    set strVal [CkJsonObject_stringOf $jResp "cluster.resourcesVpcConfig.publicAccessCidrs[i]"]
    set i [expr $i + 1]
}
set i 0
set count_i [CkJsonObject_SizeOfArray $jResp "cluster.resourcesVpcConfig.securityGroupIds"]
while {$i < $count_i} {
    CkJsonObject_put_I $jResp $i
    set strVal [CkJsonObject_stringOf $jResp "cluster.resourcesVpcConfig.securityGroupIds[i]"]
    set i [expr $i + 1]
}
set i 0
set count_i [CkJsonObject_SizeOfArray $jResp "cluster.resourcesVpcConfig.subnetIds"]
while {$i < $count_i} {
    CkJsonObject_put_I $jResp $i
    set strVal [CkJsonObject_stringOf $jResp "cluster.resourcesVpcConfig.subnetIds[i]"]
    set i [expr $i + 1]
}

# A sample JSON response body parsed by the above code:

# {
#   "cluster": {
#     "arn": "string",
#     "certificateAuthority": {
#       "data": "string"
#     },
#     "clientRequestToken": "string",
#     "connectorConfig": {
#       "activationCode": "string",
#       "activationExpiry": number,
#       "activationId": "string",
#       "provider": "string",
#       "roleArn": "string"
#     },
#     "createdAt": number,
#     "encryptionConfig": [
#       {
#         "provider": {
#           "keyArn": "string"
#         },
#         "resources": [
#           "string"
#         ]
#       }
#     ],
#     "endpoint": "string",
#     "identity": {
#       "oidc": {
#         "issuer": "string"
#       }
#     },
#     "kubernetesNetworkConfig": {
#       "ipFamily": "string",
#       "serviceIpv4Cidr": "string",
#       "serviceIpv6Cidr": "string"
#     },
#     "logging": {
#       "clusterLogging": [
#         {
#           "enabled": boolean,
#           "types": [
#             "string"
#           ]
#         }
#       ]
#     },
#     "name": "string",
#     "platformVersion": "string",
#     "resourcesVpcConfig": {
#       "clusterSecurityGroupId": "string",
#       "endpointPrivateAccess": boolean,
#       "endpointPublicAccess": boolean,
#       "publicAccessCidrs": [
#         "string"
#       ],
#       "securityGroupIds": [
#         "string"
#       ],
#       "subnetIds": [
#         "string"
#       ],
#       "vpcId": "string"
#     },
#     "roleArn": "string",
#     "status": "string",
#     "tags": {
#       "string": "string"
#     },
#     "version": "string"
#   }
# }

delete_CkRest $rest
delete_CkAuthAws $authAws
delete_CkStringBuilder $sbResponseBody
delete_CkJsonObject $jResp