Chilkat Online Tools

BatchGetDeployments autoit Example

AWS CodeDeploy

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

$oRest = ObjCreate("Chilkat_9_5_0.Rest")
Local $bSuccess

$oAuthAws = ObjCreate("Chilkat_9_5_0.AuthAws")
$oAuthAws.AccessKey = "AWS_ACCESS_KEY"
$oAuthAws.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.)
$oAuthAws.Region = "us-west-2"
$oAuthAws.ServiceName = "codedeploy"
; SetAuthAws causes Chilkat to automatically add the following headers: Authorization, X-Amz-Date
$oRest.SetAuthAws($oAuthAws)

; URL: https://codedeploy.us-west-2.amazonaws.com/
; Use the same region as specified above.
$bSuccess = $oRest.Connect("codedeploy.us-west-2.amazonaws.com",443,True,True)
If ($bSuccess <> True) Then
    ConsoleWrite("ConnectFailReason: " & $oRest.ConnectFailReason & @CRLF)
    ConsoleWrite($oRest.LastErrorText & @CRLF)
    Exit
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

$oJson = ObjCreate("Chilkat_9_5_0.JsonObject")
$oJson.UpdateString("deploymentIds[0]","string")

; The JSON request body created by the above code:

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

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

$oSbRequestBody = ObjCreate("Chilkat_9_5_0.StringBuilder")
$oJson.EmitSb($oSbRequestBody)
$oSbResponseBody = ObjCreate("Chilkat_9_5_0.StringBuilder")
$bSuccess = $oRest.FullRequestSb("POST","/",$oSbRequestBody,$oSbResponseBody)
If ($bSuccess <> True) Then
    ConsoleWrite($oRest.LastErrorText & @CRLF)
    Exit
EndIf

Local $iRespStatusCode = $oRest.ResponseStatusCode
ConsoleWrite("response status code = " & $iRespStatusCode & @CRLF)
If ($iRespStatusCode <> 200) Then
    ConsoleWrite("Response Header:" & @CRLF)
    ConsoleWrite($oRest.ResponseHeader & @CRLF)
    ConsoleWrite("Response Body:" & @CRLF)
    ConsoleWrite($oSbResponseBody.GetAsString() & @CRLF)
    Exit
EndIf

$oJResp = ObjCreate("Chilkat_9_5_0.JsonObject")
$oJResp.LoadSb($oSbResponseBody)

; 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

Local $sAdditionalDeploymentStatusInfo
Local $sApplicationName
Local $iEnabled
Local $sActionOnTimeout
Local $iWaitTimeInMinutes
Local $sAction
Local $sTerminateBlueInstancesOnDeploymentSuccessAction
Local $iTerminationWaitTimeInMinutes
Local $iCompleteTime
Local $sComputePlatform
Local $iCreateTime
Local $sCreator
Local $sDeploymentConfigName
Local $sDeploymentGroupName
Local $sDeploymentId
Local $iFailed
Local $iInProgress
Local $iPending
Local $iReady
Local $iSkipped
Local $iSucceeded
Local $sDeploymentOption
Local $sDeploymentType
Local $sDescription
Local $sCode
Local $sMessage
Local $sExternalId
Local $sFileExistsBehavior
Local $ignoreApplicationStopFailures
Local $instanceTerminationWaitTimeStarted
Local $sContent
Local $sSha256
Local $sCommitId
Local $sRepository
Local $sRevisionType
Local $sBucket
Local $sBundleType
Local $sETag
Local $sKey
Local $sVersion
Local $sStringContent
Local $sStringSha256
Local $sAutoUpdateOutdatedInstancesRootDeploymentId
Local $sAppSpecContentContent
Local $sAppSpecContentSha256
Local $sGitHubLocationCommitId
Local $sGitHubLocationRepository
Local $sRevisionRevisionType
Local $sS3LocationBucket
Local $sS3LocationBundleType
Local $sS3LocationETag
Local $sS3LocationKey
Local $sS3LocationVersion
Local $sRollbackDeploymentId
Local $sRollbackMessage
Local $sRollbackTriggeringDeploymentId
Local $iStartTime
Local $status
Local $iUpdateOutdatedInstancesOnly
Local $iJ
Local $iCount_j
Local $strVal
Local $sName
Local $iK
Local $iCount_k
Local $sV_Type
Local $sValue

Local $i = 0
Local $iCount_i = $oJResp.SizeOfArray("deploymentsInfo")
While $i < $iCount_i
    $oJResp.I = $i
    $sAdditionalDeploymentStatusInfo = $oJResp.StringOf("deploymentsInfo[i].additionalDeploymentStatusInfo")
    $sApplicationName = $oJResp.StringOf("deploymentsInfo[i].applicationName")
    $iEnabled = $oJResp.IntOf("deploymentsInfo[i].autoRollbackConfiguration.enabled")
    $sActionOnTimeout = $oJResp.StringOf("deploymentsInfo[i].blueGreenDeploymentConfiguration.deploymentReadyOption.actionOnTimeout")
    $iWaitTimeInMinutes = $oJResp.IntOf("deploymentsInfo[i].blueGreenDeploymentConfiguration.deploymentReadyOption.waitTimeInMinutes")
    $sAction = $oJResp.StringOf("deploymentsInfo[i].blueGreenDeploymentConfiguration.greenFleetProvisioningOption.action")
    $sTerminateBlueInstancesOnDeploymentSuccessAction = $oJResp.StringOf("deploymentsInfo[i].blueGreenDeploymentConfiguration.terminateBlueInstancesOnDeploymentSuccess.action")
    $iTerminationWaitTimeInMinutes = $oJResp.IntOf("deploymentsInfo[i].blueGreenDeploymentConfiguration.terminateBlueInstancesOnDeploymentSuccess.terminationWaitTimeInMinutes")
    $iCompleteTime = $oJResp.IntOf("deploymentsInfo[i].completeTime")
    $sComputePlatform = $oJResp.StringOf("deploymentsInfo[i].computePlatform")
    $iCreateTime = $oJResp.IntOf("deploymentsInfo[i].createTime")
    $sCreator = $oJResp.StringOf("deploymentsInfo[i].creator")
    $sDeploymentConfigName = $oJResp.StringOf("deploymentsInfo[i].deploymentConfigName")
    $sDeploymentGroupName = $oJResp.StringOf("deploymentsInfo[i].deploymentGroupName")
    $sDeploymentId = $oJResp.StringOf("deploymentsInfo[i].deploymentId")
    $iFailed = $oJResp.IntOf("deploymentsInfo[i].deploymentOverview.Failed")
    $iInProgress = $oJResp.IntOf("deploymentsInfo[i].deploymentOverview.InProgress")
    $iPending = $oJResp.IntOf("deploymentsInfo[i].deploymentOverview.Pending")
    $iReady = $oJResp.IntOf("deploymentsInfo[i].deploymentOverview.Ready")
    $iSkipped = $oJResp.IntOf("deploymentsInfo[i].deploymentOverview.Skipped")
    $iSucceeded = $oJResp.IntOf("deploymentsInfo[i].deploymentOverview.Succeeded")
    $sDeploymentOption = $oJResp.StringOf("deploymentsInfo[i].deploymentStyle.deploymentOption")
    $sDeploymentType = $oJResp.StringOf("deploymentsInfo[i].deploymentStyle.deploymentType")
    $sDescription = $oJResp.StringOf("deploymentsInfo[i].description")
    $sCode = $oJResp.StringOf("deploymentsInfo[i].errorInformation.code")
    $sMessage = $oJResp.StringOf("deploymentsInfo[i].errorInformation.message")
    $sExternalId = $oJResp.StringOf("deploymentsInfo[i].externalId")
    $sFileExistsBehavior = $oJResp.StringOf("deploymentsInfo[i].fileExistsBehavior")
    $ignoreApplicationStopFailures = $oJResp.IntOf("deploymentsInfo[i].ignoreApplicationStopFailures")
    $instanceTerminationWaitTimeStarted = $oJResp.IntOf("deploymentsInfo[i].instanceTerminationWaitTimeStarted")
    $sContent = $oJResp.StringOf("deploymentsInfo[i].previousRevision.appSpecContent.content")
    $sSha256 = $oJResp.StringOf("deploymentsInfo[i].previousRevision.appSpecContent.sha256")
    $sCommitId = $oJResp.StringOf("deploymentsInfo[i].previousRevision.gitHubLocation.commitId")
    $sRepository = $oJResp.StringOf("deploymentsInfo[i].previousRevision.gitHubLocation.repository")
    $sRevisionType = $oJResp.StringOf("deploymentsInfo[i].previousRevision.revisionType")
    $sBucket = $oJResp.StringOf("deploymentsInfo[i].previousRevision.s3Location.bucket")
    $sBundleType = $oJResp.StringOf("deploymentsInfo[i].previousRevision.s3Location.bundleType")
    $sETag = $oJResp.StringOf("deploymentsInfo[i].previousRevision.s3Location.eTag")
    $sKey = $oJResp.StringOf("deploymentsInfo[i].previousRevision.s3Location.key")
    $sVersion = $oJResp.StringOf("deploymentsInfo[i].previousRevision.s3Location.version")
    $sStringContent = $oJResp.StringOf("deploymentsInfo[i].previousRevision.string.content")
    $sStringSha256 = $oJResp.StringOf("deploymentsInfo[i].previousRevision.string.sha256")
    $sAutoUpdateOutdatedInstancesRootDeploymentId = $oJResp.StringOf("deploymentsInfo[i].relatedDeployments.autoUpdateOutdatedInstancesRootDeploymentId")
    $sAppSpecContentContent = $oJResp.StringOf("deploymentsInfo[i].revision.appSpecContent.content")
    $sAppSpecContentSha256 = $oJResp.StringOf("deploymentsInfo[i].revision.appSpecContent.sha256")
    $sGitHubLocationCommitId = $oJResp.StringOf("deploymentsInfo[i].revision.gitHubLocation.commitId")
    $sGitHubLocationRepository = $oJResp.StringOf("deploymentsInfo[i].revision.gitHubLocation.repository")
    $sRevisionRevisionType = $oJResp.StringOf("deploymentsInfo[i].revision.revisionType")
    $sS3LocationBucket = $oJResp.StringOf("deploymentsInfo[i].revision.s3Location.bucket")
    $sS3LocationBundleType = $oJResp.StringOf("deploymentsInfo[i].revision.s3Location.bundleType")
    $sS3LocationETag = $oJResp.StringOf("deploymentsInfo[i].revision.s3Location.eTag")
    $sS3LocationKey = $oJResp.StringOf("deploymentsInfo[i].revision.s3Location.key")
    $sS3LocationVersion = $oJResp.StringOf("deploymentsInfo[i].revision.s3Location.version")
    $sStringContent = $oJResp.StringOf("deploymentsInfo[i].revision.string.content")
    $sStringSha256 = $oJResp.StringOf("deploymentsInfo[i].revision.string.sha256")
    $sRollbackDeploymentId = $oJResp.StringOf("deploymentsInfo[i].rollbackInfo.rollbackDeploymentId")
    $sRollbackMessage = $oJResp.StringOf("deploymentsInfo[i].rollbackInfo.rollbackMessage")
    $sRollbackTriggeringDeploymentId = $oJResp.StringOf("deploymentsInfo[i].rollbackInfo.rollbackTriggeringDeploymentId")
    $iStartTime = $oJResp.IntOf("deploymentsInfo[i].startTime")
    $status = $oJResp.StringOf("deploymentsInfo[i].status")
    $iUpdateOutdatedInstancesOnly = $oJResp.IntOf("deploymentsInfo[i].updateOutdatedInstancesOnly")
    $iJ = 0
    $iCount_j = $oJResp.SizeOfArray("deploymentsInfo[i].autoRollbackConfiguration.events")
    While $iJ < $iCount_j
        $oJResp.J = $iJ
        $strVal = $oJResp.StringOf("deploymentsInfo[i].autoRollbackConfiguration.events[j]")
        $iJ = $iJ + 1
    Wend
    $iJ = 0
    $iCount_j = $oJResp.SizeOfArray("deploymentsInfo[i].deploymentStatusMessages")
    While $iJ < $iCount_j
        $oJResp.J = $iJ
        $strVal = $oJResp.StringOf("deploymentsInfo[i].deploymentStatusMessages[j]")
        $iJ = $iJ + 1
    Wend
    $iJ = 0
    $iCount_j = $oJResp.SizeOfArray("deploymentsInfo[i].loadBalancerInfo.elbInfoList")
    While $iJ < $iCount_j
        $oJResp.J = $iJ
        $sName = $oJResp.StringOf("deploymentsInfo[i].loadBalancerInfo.elbInfoList[j].name")
        $iJ = $iJ + 1
    Wend
    $iJ = 0
    $iCount_j = $oJResp.SizeOfArray("deploymentsInfo[i].loadBalancerInfo.targetGroupInfoList")
    While $iJ < $iCount_j
        $oJResp.J = $iJ
        $sName = $oJResp.StringOf("deploymentsInfo[i].loadBalancerInfo.targetGroupInfoList[j].name")
        $iJ = $iJ + 1
    Wend
    $iJ = 0
    $iCount_j = $oJResp.SizeOfArray("deploymentsInfo[i].loadBalancerInfo.targetGroupPairInfoList")
    While $iJ < $iCount_j
        $oJResp.J = $iJ
        $iK = 0
        $iCount_k = $oJResp.SizeOfArray("deploymentsInfo[i].loadBalancerInfo.targetGroupPairInfoList[j].prodTrafficRoute.listenerArns")
        While $iK < $iCount_k
            $oJResp.K = $iK
            $strVal = $oJResp.StringOf("deploymentsInfo[i].loadBalancerInfo.targetGroupPairInfoList[j].prodTrafficRoute.listenerArns[k]")
            $iK = $iK + 1
        Wend
        $iK = 0
        $iCount_k = $oJResp.SizeOfArray("deploymentsInfo[i].loadBalancerInfo.targetGroupPairInfoList[j].targetGroups")
        While $iK < $iCount_k
            $oJResp.K = $iK
            $sName = $oJResp.StringOf("deploymentsInfo[i].loadBalancerInfo.targetGroupPairInfoList[j].targetGroups[k].name")
            $iK = $iK + 1
        Wend
        $iK = 0
        $iCount_k = $oJResp.SizeOfArray("deploymentsInfo[i].loadBalancerInfo.targetGroupPairInfoList[j].testTrafficRoute.listenerArns")
        While $iK < $iCount_k
            $oJResp.K = $iK
            $strVal = $oJResp.StringOf("deploymentsInfo[i].loadBalancerInfo.targetGroupPairInfoList[j].testTrafficRoute.listenerArns[k]")
            $iK = $iK + 1
        Wend
        $iJ = $iJ + 1
    Wend
    $iJ = 0
    $iCount_j = $oJResp.SizeOfArray("deploymentsInfo[i].relatedDeployments.autoUpdateOutdatedInstancesDeploymentIds")
    While $iJ < $iCount_j
        $oJResp.J = $iJ
        $strVal = $oJResp.StringOf("deploymentsInfo[i].relatedDeployments.autoUpdateOutdatedInstancesDeploymentIds[j]")
        $iJ = $iJ + 1
    Wend
    $iJ = 0
    $iCount_j = $oJResp.SizeOfArray("deploymentsInfo[i].targetInstances.autoScalingGroups")
    While $iJ < $iCount_j
        $oJResp.J = $iJ
        $strVal = $oJResp.StringOf("deploymentsInfo[i].targetInstances.autoScalingGroups[j]")
        $iJ = $iJ + 1
    Wend
    $iJ = 0
    $iCount_j = $oJResp.SizeOfArray("deploymentsInfo[i].targetInstances.ec2TagSet.ec2TagSetList")
    While $iJ < $iCount_j
        $oJResp.J = $iJ
        $iK = 0
        $iCount_k = $oJResp.SizeOfArray("deploymentsInfo[i].targetInstances.ec2TagSet.ec2TagSetList[j]")
        While $iK < $iCount_k
            $oJResp.K = $iK
            $sKey = $oJResp.StringOf("deploymentsInfo[i].targetInstances.ec2TagSet.ec2TagSetList[j][k].Key")
            $sV_Type = $oJResp.StringOf("deploymentsInfo[i].targetInstances.ec2TagSet.ec2TagSetList[j][k].Type")
            $sValue = $oJResp.StringOf("deploymentsInfo[i].targetInstances.ec2TagSet.ec2TagSetList[j][k].Value")
            $iK = $iK + 1
        Wend
        $iJ = $iJ + 1
    Wend
    $iJ = 0
    $iCount_j = $oJResp.SizeOfArray("deploymentsInfo[i].targetInstances.tagFilters")
    While $iJ < $iCount_j
        $oJResp.J = $iJ
        $sKey = $oJResp.StringOf("deploymentsInfo[i].targetInstances.tagFilters[j].Key")
        $sV_Type = $oJResp.StringOf("deploymentsInfo[i].targetInstances.tagFilters[j].Type")
        $sValue = $oJResp.StringOf("deploymentsInfo[i].targetInstances.tagFilters[j].Value")
        $iJ = $iJ + 1
    Wend
    $i = $i + 1
Wend

; 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
;     }
;   ]
; }