Chilkat Online Tools

BatchGetDeployments Foxpro Example

AWS CodeDeploy

LOCAL loRest
LOCAL lnSuccess
LOCAL loAuthAws
LOCAL loJson
LOCAL loSbRequestBody
LOCAL loSbResponseBody
LOCAL lnRespStatusCode
LOCAL loJResp
LOCAL lcAdditionalDeploymentStatusInfo
LOCAL lcApplicationName
LOCAL lnEnabled
LOCAL lcActionOnTimeout
LOCAL lnWaitTimeInMinutes
LOCAL lcAction
LOCAL lcTerminateBlueInstancesOnDeploymentSuccessAction
LOCAL lnTerminationWaitTimeInMinutes
LOCAL lnCompleteTime
LOCAL lcComputePlatform
LOCAL lnCreateTime
LOCAL lcCreator
LOCAL lcDeploymentConfigName
LOCAL lcDeploymentGroupName
LOCAL lcDeploymentId
LOCAL lnFailed
LOCAL lnInProgress
LOCAL lnPending
LOCAL lnReady
LOCAL lnSkipped
LOCAL lnSucceeded
LOCAL lcDeploymentOption
LOCAL lcDeploymentType
LOCAL lcDescription
LOCAL lcCode
LOCAL lcMessage
LOCAL lcExternalId
LOCAL lcFileExistsBehavior
LOCAL lnIgnoreApplicationStopFailures
LOCAL lnInstanceTerminationWaitTimeStarted
LOCAL lcContent
LOCAL lcSha256
LOCAL lcCommitId
LOCAL lcRepository
LOCAL lcRevisionType
LOCAL lcBucket
LOCAL lcBundleType
LOCAL lcETag
LOCAL lcKey
LOCAL lcVersion
LOCAL lcStringContent
LOCAL lcStringSha256
LOCAL lcAutoUpdateOutdatedInstancesRootDeploymentId
LOCAL lcAppSpecContentContent
LOCAL lcAppSpecContentSha256
LOCAL lcGitHubLocationCommitId
LOCAL lcGitHubLocationRepository
LOCAL lcRevisionRevisionType
LOCAL lcS3LocationBucket
LOCAL lcS3LocationBundleType
LOCAL lcS3LocationETag
LOCAL lcS3LocationKey
LOCAL lcS3LocationVersion
LOCAL lcRollbackDeploymentId
LOCAL lcRollbackMessage
LOCAL lcRollbackTriggeringDeploymentId
LOCAL lnStartTime
LOCAL lcStatus
LOCAL lnUpdateOutdatedInstancesOnly
LOCAL j
LOCAL lnCount_j
LOCAL lcStrVal
LOCAL lcName
LOCAL k
LOCAL lnCount_k
LOCAL lcV_Type
LOCAL lcValue
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 = "codedeploy"
* SetAuthAws causes Chilkat to automatically add the following headers: Authorization, X-Amz-Date
loRest.SetAuthAws(loAuthAws)

* URL: https://codedeploy.us-west-2.amazonaws.com/
* Use the same region as specified above.
lnSuccess = loRest.Connect("codedeploy.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("deploymentIds[0]","string")

* The JSON request body created by the above code:

* {
*   "deploymentIds": [
*     "string"
*   ]
* }

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

loSbRequestBody = CreateObject('Chilkat_9_5_0.StringBuilder')
loJson.EmitSb(loSbRequestBody)
loSbResponseBody = CreateObject('Chilkat_9_5_0.StringBuilder')
lnSuccess = loRest.FullRequestSb("POST","/",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

i = 0
lnCount_i = loJResp.SizeOfArray("deploymentsInfo")
DO WHILE i < lnCount_i
    loJResp.I = i
    lcAdditionalDeploymentStatusInfo = loJResp.StringOf("deploymentsInfo[i].additionalDeploymentStatusInfo")
    lcApplicationName = loJResp.StringOf("deploymentsInfo[i].applicationName")
    lnEnabled = loJResp.IntOf("deploymentsInfo[i].autoRollbackConfiguration.enabled")
    lcActionOnTimeout = loJResp.StringOf("deploymentsInfo[i].blueGreenDeploymentConfiguration.deploymentReadyOption.actionOnTimeout")
    lnWaitTimeInMinutes = loJResp.IntOf("deploymentsInfo[i].blueGreenDeploymentConfiguration.deploymentReadyOption.waitTimeInMinutes")
    lcAction = loJResp.StringOf("deploymentsInfo[i].blueGreenDeploymentConfiguration.greenFleetProvisioningOption.action")
    lcTerminateBlueInstancesOnDeploymentSuccessAction = loJResp.StringOf("deploymentsInfo[i].blueGreenDeploymentConfiguration.terminateBlueInstancesOnDeploymentSuccess.action")
    lnTerminationWaitTimeInMinutes = loJResp.IntOf("deploymentsInfo[i].blueGreenDeploymentConfiguration.terminateBlueInstancesOnDeploymentSuccess.terminationWaitTimeInMinutes")
    lnCompleteTime = loJResp.IntOf("deploymentsInfo[i].completeTime")
    lcComputePlatform = loJResp.StringOf("deploymentsInfo[i].computePlatform")
    lnCreateTime = loJResp.IntOf("deploymentsInfo[i].createTime")
    lcCreator = loJResp.StringOf("deploymentsInfo[i].creator")
    lcDeploymentConfigName = loJResp.StringOf("deploymentsInfo[i].deploymentConfigName")
    lcDeploymentGroupName = loJResp.StringOf("deploymentsInfo[i].deploymentGroupName")
    lcDeploymentId = loJResp.StringOf("deploymentsInfo[i].deploymentId")
    lnFailed = loJResp.IntOf("deploymentsInfo[i].deploymentOverview.Failed")
    lnInProgress = loJResp.IntOf("deploymentsInfo[i].deploymentOverview.InProgress")
    lnPending = loJResp.IntOf("deploymentsInfo[i].deploymentOverview.Pending")
    lnReady = loJResp.IntOf("deploymentsInfo[i].deploymentOverview.Ready")
    lnSkipped = loJResp.IntOf("deploymentsInfo[i].deploymentOverview.Skipped")
    lnSucceeded = loJResp.IntOf("deploymentsInfo[i].deploymentOverview.Succeeded")
    lcDeploymentOption = loJResp.StringOf("deploymentsInfo[i].deploymentStyle.deploymentOption")
    lcDeploymentType = loJResp.StringOf("deploymentsInfo[i].deploymentStyle.deploymentType")
    lcDescription = loJResp.StringOf("deploymentsInfo[i].description")
    lcCode = loJResp.StringOf("deploymentsInfo[i].errorInformation.code")
    lcMessage = loJResp.StringOf("deploymentsInfo[i].errorInformation.message")
    lcExternalId = loJResp.StringOf("deploymentsInfo[i].externalId")
    lcFileExistsBehavior = loJResp.StringOf("deploymentsInfo[i].fileExistsBehavior")
    lnIgnoreApplicationStopFailures = loJResp.IntOf("deploymentsInfo[i].ignoreApplicationStopFailures")
    lnInstanceTerminationWaitTimeStarted = loJResp.IntOf("deploymentsInfo[i].instanceTerminationWaitTimeStarted")
    lcContent = loJResp.StringOf("deploymentsInfo[i].previousRevision.appSpecContent.content")
    lcSha256 = loJResp.StringOf("deploymentsInfo[i].previousRevision.appSpecContent.sha256")
    lcCommitId = loJResp.StringOf("deploymentsInfo[i].previousRevision.gitHubLocation.commitId")
    lcRepository = loJResp.StringOf("deploymentsInfo[i].previousRevision.gitHubLocation.repository")
    lcRevisionType = loJResp.StringOf("deploymentsInfo[i].previousRevision.revisionType")
    lcBucket = loJResp.StringOf("deploymentsInfo[i].previousRevision.s3Location.bucket")
    lcBundleType = loJResp.StringOf("deploymentsInfo[i].previousRevision.s3Location.bundleType")
    lcETag = loJResp.StringOf("deploymentsInfo[i].previousRevision.s3Location.eTag")
    lcKey = loJResp.StringOf("deploymentsInfo[i].previousRevision.s3Location.key")
    lcVersion = loJResp.StringOf("deploymentsInfo[i].previousRevision.s3Location.version")
    lcStringContent = loJResp.StringOf("deploymentsInfo[i].previousRevision.string.content")
    lcStringSha256 = loJResp.StringOf("deploymentsInfo[i].previousRevision.string.sha256")
    lcAutoUpdateOutdatedInstancesRootDeploymentId = loJResp.StringOf("deploymentsInfo[i].relatedDeployments.autoUpdateOutdatedInstancesRootDeploymentId")
    lcAppSpecContentContent = loJResp.StringOf("deploymentsInfo[i].revision.appSpecContent.content")
    lcAppSpecContentSha256 = loJResp.StringOf("deploymentsInfo[i].revision.appSpecContent.sha256")
    lcGitHubLocationCommitId = loJResp.StringOf("deploymentsInfo[i].revision.gitHubLocation.commitId")
    lcGitHubLocationRepository = loJResp.StringOf("deploymentsInfo[i].revision.gitHubLocation.repository")
    lcRevisionRevisionType = loJResp.StringOf("deploymentsInfo[i].revision.revisionType")
    lcS3LocationBucket = loJResp.StringOf("deploymentsInfo[i].revision.s3Location.bucket")
    lcS3LocationBundleType = loJResp.StringOf("deploymentsInfo[i].revision.s3Location.bundleType")
    lcS3LocationETag = loJResp.StringOf("deploymentsInfo[i].revision.s3Location.eTag")
    lcS3LocationKey = loJResp.StringOf("deploymentsInfo[i].revision.s3Location.key")
    lcS3LocationVersion = loJResp.StringOf("deploymentsInfo[i].revision.s3Location.version")
    lcStringContent = loJResp.StringOf("deploymentsInfo[i].revision.string.content")
    lcStringSha256 = loJResp.StringOf("deploymentsInfo[i].revision.string.sha256")
    lcRollbackDeploymentId = loJResp.StringOf("deploymentsInfo[i].rollbackInfo.rollbackDeploymentId")
    lcRollbackMessage = loJResp.StringOf("deploymentsInfo[i].rollbackInfo.rollbackMessage")
    lcRollbackTriggeringDeploymentId = loJResp.StringOf("deploymentsInfo[i].rollbackInfo.rollbackTriggeringDeploymentId")
    lnStartTime = loJResp.IntOf("deploymentsInfo[i].startTime")
    lcStatus = loJResp.StringOf("deploymentsInfo[i].status")
    lnUpdateOutdatedInstancesOnly = loJResp.IntOf("deploymentsInfo[i].updateOutdatedInstancesOnly")
    j = 0
    lnCount_j = loJResp.SizeOfArray("deploymentsInfo[i].autoRollbackConfiguration.events")
    DO WHILE j < lnCount_j
        loJResp.J = j
        lcStrVal = loJResp.StringOf("deploymentsInfo[i].autoRollbackConfiguration.events[j]")
        j = j + 1
    ENDDO
    j = 0
    lnCount_j = loJResp.SizeOfArray("deploymentsInfo[i].deploymentStatusMessages")
    DO WHILE j < lnCount_j
        loJResp.J = j
        lcStrVal = loJResp.StringOf("deploymentsInfo[i].deploymentStatusMessages[j]")
        j = j + 1
    ENDDO
    j = 0
    lnCount_j = loJResp.SizeOfArray("deploymentsInfo[i].loadBalancerInfo.elbInfoList")
    DO WHILE j < lnCount_j
        loJResp.J = j
        lcName = loJResp.StringOf("deploymentsInfo[i].loadBalancerInfo.elbInfoList[j].name")
        j = j + 1
    ENDDO
    j = 0
    lnCount_j = loJResp.SizeOfArray("deploymentsInfo[i].loadBalancerInfo.targetGroupInfoList")
    DO WHILE j < lnCount_j
        loJResp.J = j
        lcName = loJResp.StringOf("deploymentsInfo[i].loadBalancerInfo.targetGroupInfoList[j].name")
        j = j + 1
    ENDDO
    j = 0
    lnCount_j = loJResp.SizeOfArray("deploymentsInfo[i].loadBalancerInfo.targetGroupPairInfoList")
    DO WHILE j < lnCount_j
        loJResp.J = j
        k = 0
        lnCount_k = loJResp.SizeOfArray("deploymentsInfo[i].loadBalancerInfo.targetGroupPairInfoList[j].prodTrafficRoute.listenerArns")
        DO WHILE k < lnCount_k
            loJResp.K = k
            lcStrVal = loJResp.StringOf("deploymentsInfo[i].loadBalancerInfo.targetGroupPairInfoList[j].prodTrafficRoute.listenerArns[k]")
            k = k + 1
        ENDDO
        k = 0
        lnCount_k = loJResp.SizeOfArray("deploymentsInfo[i].loadBalancerInfo.targetGroupPairInfoList[j].targetGroups")
        DO WHILE k < lnCount_k
            loJResp.K = k
            lcName = loJResp.StringOf("deploymentsInfo[i].loadBalancerInfo.targetGroupPairInfoList[j].targetGroups[k].name")
            k = k + 1
        ENDDO
        k = 0
        lnCount_k = loJResp.SizeOfArray("deploymentsInfo[i].loadBalancerInfo.targetGroupPairInfoList[j].testTrafficRoute.listenerArns")
        DO WHILE k < lnCount_k
            loJResp.K = k
            lcStrVal = loJResp.StringOf("deploymentsInfo[i].loadBalancerInfo.targetGroupPairInfoList[j].testTrafficRoute.listenerArns[k]")
            k = k + 1
        ENDDO
        j = j + 1
    ENDDO
    j = 0
    lnCount_j = loJResp.SizeOfArray("deploymentsInfo[i].relatedDeployments.autoUpdateOutdatedInstancesDeploymentIds")
    DO WHILE j < lnCount_j
        loJResp.J = j
        lcStrVal = loJResp.StringOf("deploymentsInfo[i].relatedDeployments.autoUpdateOutdatedInstancesDeploymentIds[j]")
        j = j + 1
    ENDDO
    j = 0
    lnCount_j = loJResp.SizeOfArray("deploymentsInfo[i].targetInstances.autoScalingGroups")
    DO WHILE j < lnCount_j
        loJResp.J = j
        lcStrVal = loJResp.StringOf("deploymentsInfo[i].targetInstances.autoScalingGroups[j]")
        j = j + 1
    ENDDO
    j = 0
    lnCount_j = loJResp.SizeOfArray("deploymentsInfo[i].targetInstances.ec2TagSet.ec2TagSetList")
    DO WHILE j < lnCount_j
        loJResp.J = j
        k = 0
        lnCount_k = loJResp.SizeOfArray("deploymentsInfo[i].targetInstances.ec2TagSet.ec2TagSetList[j]")
        DO WHILE k < lnCount_k
            loJResp.K = k
            lcKey = loJResp.StringOf("deploymentsInfo[i].targetInstances.ec2TagSet.ec2TagSetList[j][k].Key")
            lcV_Type = loJResp.StringOf("deploymentsInfo[i].targetInstances.ec2TagSet.ec2TagSetList[j][k].Type")
            lcValue = loJResp.StringOf("deploymentsInfo[i].targetInstances.ec2TagSet.ec2TagSetList[j][k].Value")
            k = k + 1
        ENDDO
        j = j + 1
    ENDDO
    j = 0
    lnCount_j = loJResp.SizeOfArray("deploymentsInfo[i].targetInstances.tagFilters")
    DO WHILE j < lnCount_j
        loJResp.J = j
        lcKey = loJResp.StringOf("deploymentsInfo[i].targetInstances.tagFilters[j].Key")
        lcV_Type = loJResp.StringOf("deploymentsInfo[i].targetInstances.tagFilters[j].Type")
        lcValue = loJResp.StringOf("deploymentsInfo[i].targetInstances.tagFilters[j].Value")
        j = j + 1
    ENDDO
    i = i + 1
ENDDO

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

* {
*   "deploymentsInfo": [
*     {
*       "additionalDeploymentStatusInfo": "string",
*       "applicationName": "string",
*       "autoRollbackConfiguration": {
*         "enabled": boolean,
*         "events": [
*           "string"
*         ]
*       },
*       "blueGreenDeploymentConfiguration": {
*         "deploymentReadyOption": {
*           "actionOnTimeout": "string",
*           "waitTimeInMinutes": number
*         },
*         "greenFleetProvisioningOption": {
*           "action": "string"
*         },
*         "terminateBlueInstancesOnDeploymentSuccess": {
*           "action": "string",
*           "terminationWaitTimeInMinutes": number
*         }
*       },
*       "completeTime": number,
*       "computePlatform": "string",
*       "createTime": number,
*       "creator": "string",
*       "deploymentConfigName": "string",
*       "deploymentGroupName": "string",
*       "deploymentId": "string",
*       "deploymentOverview": {
*         "Failed": number,
*         "InProgress": number,
*         "Pending": number,
*         "Ready": number,
*         "Skipped": number,
*         "Succeeded": number
*       },
*       "deploymentStatusMessages": [
*         "string"
*       ],
*       "deploymentStyle": {
*         "deploymentOption": "string",
*         "deploymentType": "string"
*       },
*       "description": "string",
*       "errorInformation": {
*         "code": "string",
*         "message": "string"
*       },
*       "externalId": "string",
*       "fileExistsBehavior": "string",
*       "ignoreApplicationStopFailures": boolean,
*       "instanceTerminationWaitTimeStarted": boolean,
*       "loadBalancerInfo": {
*         "elbInfoList": [
*           {
*             "name": "string"
*           }
*         ],
*         "targetGroupInfoList": [
*           {
*             "name": "string"
*           }
*         ],
*         "targetGroupPairInfoList": [
*           {
*             "prodTrafficRoute": {
*               "listenerArns": [
*                 "string"
*               ]
*             },
*             "targetGroups": [
*               {
*                 "name": "string"
*               }
*             ],
*             "testTrafficRoute": {
*               "listenerArns": [
*                 "string"
*               ]
*             }
*           }
*         ]
*       },
*       "previousRevision": {
*         "appSpecContent": {
*           "content": "string",
*           "sha256": "string"
*         },
*         "gitHubLocation": {
*           "commitId": "string",
*           "repository": "string"
*         },
*         "revisionType": "string",
*         "s3Location": {
*           "bucket": "string",
*           "bundleType": "string",
*           "eTag": "string",
*           "key": "string",
*           "version": "string"
*         },
*         "string": {
*           "content": "string",
*           "sha256": "string"
*         }
*       },
*       "relatedDeployments": {
*         "autoUpdateOutdatedInstancesDeploymentIds": [
*           "string"
*         ],
*         "autoUpdateOutdatedInstancesRootDeploymentId": "string"
*       },
*       "revision": {
*         "appSpecContent": {
*           "content": "string",
*           "sha256": "string"
*         },
*         "gitHubLocation": {
*           "commitId": "string",
*           "repository": "string"
*         },
*         "revisionType": "string",
*         "s3Location": {
*           "bucket": "string",
*           "bundleType": "string",
*           "eTag": "string",
*           "key": "string",
*           "version": "string"
*         },
*         "string": {
*           "content": "string",
*           "sha256": "string"
*         }
*       },
*       "rollbackInfo": {
*         "rollbackDeploymentId": "string",
*         "rollbackMessage": "string",
*         "rollbackTriggeringDeploymentId": "string"
*       },
*       "startTime": number,
*       "status": "string",
*       "targetInstances": {
*         "autoScalingGroups": [
*           "string"
*         ],
*         "ec2TagSet": {
*           "ec2TagSetList": [
*             [
*               {
*                 "Key": "string",
*                 "Type": "string",
*                 "Value": "string"
*               }
*             ]
*           ]
*         },
*         "tagFilters": [
*           {
*             "Key": "string",
*             "Type": "string",
*             "Value": "string"
*           }
*         ]
*       },
*       "updateOutdatedInstancesOnly": boolean
*     }
*   ]
* }

RELEASE loRest
RELEASE loAuthAws
RELEASE loJson
RELEASE loSbRequestBody
RELEASE loSbResponseBody
RELEASE loJResp