CreateCluster Foxpro Example
LOCAL loRest
LOCAL lnSuccess
LOCAL loAuthAws
LOCAL loJson
LOCAL loSbRequestBody
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
* The following code creates the JSON request body.
* The JSON created by this code is shown below.
* Use this online tool to generate code from sample JSON:
* Generate Code to Create JSON
loJson = CreateObject('Chilkat_9_5_0.JsonObject')
loJson.UpdateString("clientRequestToken","string")
loJson.UpdateString("encryptionConfig[0].provider.keyArn","string")
loJson.UpdateString("encryptionConfig[0].resources[0]","string")
loJson.UpdateString("kubernetesNetworkConfig.ipFamily","string")
loJson.UpdateString("kubernetesNetworkConfig.serviceIpv4Cidr","string")
loJson.UpdateInt("logging.clusterLogging[0].enabled",123)
loJson.UpdateString("logging.clusterLogging[0].types[0]","string")
loJson.UpdateString("name","string")
loJson.UpdateInt("resourcesVpcConfig.endpointPrivateAccess",123)
loJson.UpdateInt("resourcesVpcConfig.endpointPublicAccess",123)
loJson.UpdateString("resourcesVpcConfig.publicAccessCidrs[0]","string")
loJson.UpdateString("resourcesVpcConfig.securityGroupIds[0]","string")
loJson.UpdateString("resourcesVpcConfig.subnetIds[0]","string")
loJson.UpdateString("roleArn","string")
loJson.UpdateString("tags.string","string")
loJson.UpdateString("version","string")
* The JSON request body created by the above code:
* {
* "clientRequestToken": "string",
* "encryptionConfig": [
* {
* "provider": {
* "keyArn": "string"
* },
* "resources": [
* "string"
* ]
* }
* ],
* "kubernetesNetworkConfig": {
* "ipFamily": "string",
* "serviceIpv4Cidr": "string"
* },
* "logging": {
* "clusterLogging": [
* {
* "enabled": boolean,
* "types": [
* "string"
* ]
* }
* ]
* },
* "name": "string",
* "resourcesVpcConfig": {
* "endpointPrivateAccess": boolean,
* "endpointPublicAccess": boolean,
* "publicAccessCidrs": [
* "string"
* ],
* "securityGroupIds": [
* "string"
* ],
* "subnetIds": [
* "string"
* ]
* },
* "roleArn": "string",
* "tags": {
* "string": "string"
* },
* "version": "string"
* }
loRest.AddHeader("Content-Type","application/x-amz-json-1.1")
loRest.AddHeader("X-Amz-Target","CreateCluster")
loSbRequestBody = CreateObject('Chilkat_9_5_0.StringBuilder')
loJson.EmitSb(loSbRequestBody)
loSbResponseBody = CreateObject('Chilkat_9_5_0.StringBuilder')
lnSuccess = loRest.FullRequestSb("POST","/clusters",loSbRequestBody,loSbResponseBody)
IF (lnSuccess <> 1) THEN
? loRest.LastErrorText
RELEASE loRest
RELEASE loAuthAws
RELEASE loJson
RELEASE loSbRequestBody
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 loJson
RELEASE loSbRequestBody
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 loJson
RELEASE loSbRequestBody
RELEASE loSbResponseBody
RELEASE loJResp