Chilkat Online Tools

DescribeCluster Foxpro Example

Amazon Elastic Kubernetes Service

LOCAL loRest
LOCAL lnSuccess
LOCAL loAuthAws
LOCAL loSbResponseBody
LOCAL lnRespStatusCode
LOCAL loJResp
LOCAL lcKeyArn
LOCAL j
LOCAL lnCount_j
LOCAL lcStrVal
LOCAL lnEnabled
LOCAL lcArn
LOCAL lcData
LOCAL lcClientRequestToken
LOCAL lcActivationCode
LOCAL lnActivationExpiry
LOCAL lcActivationId
LOCAL lcProvider
LOCAL lcRoleArn
LOCAL lnCreatedAt
LOCAL lcEndpoint
LOCAL lcIssuer
LOCAL lcIpFamily
LOCAL lcServiceIpv4Cidr
LOCAL lcServiceIpv6Cidr
LOCAL lcName
LOCAL lcPlatformVersion
LOCAL lcClusterSecurityGroupId
LOCAL lnEndpointPrivateAccess
LOCAL lnEndpointPublicAccess
LOCAL lcVpcId
LOCAL lcClusterRoleArn
LOCAL lcStatus
LOCAL lcV_String
LOCAL lcVersion
LOCAL i
LOCAL lnCount_i

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

loRest = CreateObject('Chilkat_9_5_0.Rest')

loAuthAws = CreateObject('Chilkat_9_5_0.AuthAws')
loAuthAws.AccessKey = "AWS_ACCESS_KEY"
loAuthAws.SecretKey = "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.)
loAuthAws.Region = "us-west-2"
loAuthAws.ServiceName = "eks"
* SetAuthAws causes Chilkat to automatically add the following headers: Authorization, X-Amz-Date
loRest.SetAuthAws(loAuthAws)

* URL: https://eks.us-west-2.amazonaws.com/
* Use the same region as specified above.
lnSuccess = loRest.Connect("eks.us-west-2.amazonaws.com",443,1,1)
IF (lnSuccess <> 1) THEN
    ? "ConnectFailReason: " + STR(loRest.ConnectFailReason)
    ? loRest.LastErrorText
    RELEASE loRest
    RELEASE loAuthAws
    CANCEL
ENDIF

loRest.AddHeader("Content-Type","application/x-amz-json-1.1")
loRest.AddHeader("X-Amz-Target","DescribeCluster")

loSbResponseBody = CreateObject('Chilkat_9_5_0.StringBuilder')
lnSuccess = loRest.FullRequestNoBodySb("GET","/clusters/{name}",loSbResponseBody)
IF (lnSuccess <> 1) THEN
    ? loRest.LastErrorText
    RELEASE loRest
    RELEASE loAuthAws
    RELEASE loSbResponseBody
    CANCEL
ENDIF

lnRespStatusCode = loRest.ResponseStatusCode
? "response status code = " + STR(lnRespStatusCode)
IF (lnRespStatusCode <> 200) THEN
    ? "Response Header:"
    ? loRest.ResponseHeader
    ? "Response Body:"
    ? loSbResponseBody.GetAsString()
    RELEASE loRest
    RELEASE loAuthAws
    RELEASE loSbResponseBody
    CANCEL
ENDIF

loJResp = CreateObject('Chilkat_9_5_0.JsonObject')
loJResp.LoadSb(loSbResponseBody)

* 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

lcArn = loJResp.StringOf("cluster.arn")
lcData = loJResp.StringOf("cluster.certificateAuthority.data")
lcClientRequestToken = loJResp.StringOf("cluster.clientRequestToken")
lcActivationCode = loJResp.StringOf("cluster.connectorConfig.activationCode")
lnActivationExpiry = loJResp.IntOf("cluster.connectorConfig.activationExpiry")
lcActivationId = loJResp.StringOf("cluster.connectorConfig.activationId")
lcProvider = loJResp.StringOf("cluster.connectorConfig.provider")
lcRoleArn = loJResp.StringOf("cluster.connectorConfig.roleArn")
lnCreatedAt = loJResp.IntOf("cluster.createdAt")
lcEndpoint = loJResp.StringOf("cluster.endpoint")
lcIssuer = loJResp.StringOf("cluster.identity.oidc.issuer")
lcIpFamily = loJResp.StringOf("cluster.kubernetesNetworkConfig.ipFamily")
lcServiceIpv4Cidr = loJResp.StringOf("cluster.kubernetesNetworkConfig.serviceIpv4Cidr")
lcServiceIpv6Cidr = loJResp.StringOf("cluster.kubernetesNetworkConfig.serviceIpv6Cidr")
lcName = loJResp.StringOf("cluster.name")
lcPlatformVersion = loJResp.StringOf("cluster.platformVersion")
lcClusterSecurityGroupId = loJResp.StringOf("cluster.resourcesVpcConfig.clusterSecurityGroupId")
lnEndpointPrivateAccess = loJResp.IntOf("cluster.resourcesVpcConfig.endpointPrivateAccess")
lnEndpointPublicAccess = loJResp.IntOf("cluster.resourcesVpcConfig.endpointPublicAccess")
lcVpcId = loJResp.StringOf("cluster.resourcesVpcConfig.vpcId")
lcClusterRoleArn = loJResp.StringOf("cluster.roleArn")
lcStatus = loJResp.StringOf("cluster.status")
lcV_String = loJResp.StringOf("cluster.tags.string")
lcVersion = loJResp.StringOf("cluster.version")
i = 0
lnCount_i = loJResp.SizeOfArray("cluster.encryptionConfig")
DO WHILE i < lnCount_i
    loJResp.I = i
    lcKeyArn = loJResp.StringOf("cluster.encryptionConfig[i].provider.keyArn")
    j = 0
    lnCount_j = loJResp.SizeOfArray("cluster.encryptionConfig[i].resources")
    DO WHILE j < lnCount_j
        loJResp.J = j
        lcStrVal = loJResp.StringOf("cluster.encryptionConfig[i].resources[j]")
        j = j + 1
    ENDDO
    i = i + 1
ENDDO
i = 0
lnCount_i = loJResp.SizeOfArray("cluster.logging.clusterLogging")
DO WHILE i < lnCount_i
    loJResp.I = i
    lnEnabled = loJResp.IntOf("cluster.logging.clusterLogging[i].enabled")
    j = 0
    lnCount_j = loJResp.SizeOfArray("cluster.logging.clusterLogging[i].types")
    DO WHILE j < lnCount_j
        loJResp.J = j
        lcStrVal = loJResp.StringOf("cluster.logging.clusterLogging[i].types[j]")
        j = j + 1
    ENDDO
    i = i + 1
ENDDO
i = 0
lnCount_i = loJResp.SizeOfArray("cluster.resourcesVpcConfig.publicAccessCidrs")
DO WHILE i < lnCount_i
    loJResp.I = i
    lcStrVal = loJResp.StringOf("cluster.resourcesVpcConfig.publicAccessCidrs[i]")
    i = i + 1
ENDDO
i = 0
lnCount_i = loJResp.SizeOfArray("cluster.resourcesVpcConfig.securityGroupIds")
DO WHILE i < lnCount_i
    loJResp.I = i
    lcStrVal = loJResp.StringOf("cluster.resourcesVpcConfig.securityGroupIds[i]")
    i = i + 1
ENDDO
i = 0
lnCount_i = loJResp.SizeOfArray("cluster.resourcesVpcConfig.subnetIds")
DO WHILE i < lnCount_i
    loJResp.I = i
    lcStrVal = loJResp.StringOf("cluster.resourcesVpcConfig.subnetIds[i]")
    i = i + 1
ENDDO

* 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"
*   }
* }

RELEASE loRest
RELEASE loAuthAws
RELEASE loSbResponseBody
RELEASE loJResp