Chilkat Online Tools

BatchGetDeploymentGroups 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("applicationName","string")
$oJson.UpdateString("deploymentGroupNames[0]","string")

; The JSON request body created by the above code:

; {
;   "applicationName": "string",
;   "deploymentGroupNames": [
;     "string"
;   ]
; }

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

$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 $iEnabled
Local $iIgnorePollAlarmFailure
Local $sApplicationName
Local $iAutoRollbackConfigurationEnabled
Local $sActionOnTimeout
Local $iWaitTimeInMinutes
Local $sAction
Local $sTerminateBlueInstancesOnDeploymentSuccessAction
Local $iTerminationWaitTimeInMinutes
Local $sComputePlatform
Local $sDeploymentConfigName
Local $sDeploymentGroupId
Local $sDeploymentGroupName
Local $sDeploymentOption
Local $sDeploymentType
Local $iCreateTime
Local $sDeploymentId
Local $iEndTime
Local $sStatus
Local $iLastSuccessfulDeploymentCreateTime
Local $sLastSuccessfulDeploymentDeploymentId
Local $iLastSuccessfulDeploymentEndTime
Local $sLastSuccessfulDeploymentStatus
Local $sOutdatedInstancesStrategy
Local $serviceRoleArn
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 $iJ
Local $iCount_j
Local $sName
Local $strVal
Local $sHook
Local $sV_Type
Local $sValue
Local $iK
Local $iCount_k
Local $sClusterName
Local $serviceName
Local $sTriggerName
Local $sTriggerTargetArn

Local $sErrorMessage = $oJResp.StringOf("errorMessage")
Local $i = 0
Local $iCount_i = $oJResp.SizeOfArray("deploymentGroupsInfo")
While $i < $iCount_i
    $oJResp.I = $i
    $iEnabled = $oJResp.IntOf("deploymentGroupsInfo[i].alarmConfiguration.enabled")
    $iIgnorePollAlarmFailure = $oJResp.IntOf("deploymentGroupsInfo[i].alarmConfiguration.ignorePollAlarmFailure")
    $sApplicationName = $oJResp.StringOf("deploymentGroupsInfo[i].applicationName")
    $iAutoRollbackConfigurationEnabled = $oJResp.IntOf("deploymentGroupsInfo[i].autoRollbackConfiguration.enabled")
    $sActionOnTimeout = $oJResp.StringOf("deploymentGroupsInfo[i].blueGreenDeploymentConfiguration.deploymentReadyOption.actionOnTimeout")
    $iWaitTimeInMinutes = $oJResp.IntOf("deploymentGroupsInfo[i].blueGreenDeploymentConfiguration.deploymentReadyOption.waitTimeInMinutes")
    $sAction = $oJResp.StringOf("deploymentGroupsInfo[i].blueGreenDeploymentConfiguration.greenFleetProvisioningOption.action")
    $sTerminateBlueInstancesOnDeploymentSuccessAction = $oJResp.StringOf("deploymentGroupsInfo[i].blueGreenDeploymentConfiguration.terminateBlueInstancesOnDeploymentSuccess.action")
    $iTerminationWaitTimeInMinutes = $oJResp.IntOf("deploymentGroupsInfo[i].blueGreenDeploymentConfiguration.terminateBlueInstancesOnDeploymentSuccess.terminationWaitTimeInMinutes")
    $sComputePlatform = $oJResp.StringOf("deploymentGroupsInfo[i].computePlatform")
    $sDeploymentConfigName = $oJResp.StringOf("deploymentGroupsInfo[i].deploymentConfigName")
    $sDeploymentGroupId = $oJResp.StringOf("deploymentGroupsInfo[i].deploymentGroupId")
    $sDeploymentGroupName = $oJResp.StringOf("deploymentGroupsInfo[i].deploymentGroupName")
    $sDeploymentOption = $oJResp.StringOf("deploymentGroupsInfo[i].deploymentStyle.deploymentOption")
    $sDeploymentType = $oJResp.StringOf("deploymentGroupsInfo[i].deploymentStyle.deploymentType")
    $iCreateTime = $oJResp.IntOf("deploymentGroupsInfo[i].lastAttemptedDeployment.createTime")
    $sDeploymentId = $oJResp.StringOf("deploymentGroupsInfo[i].lastAttemptedDeployment.deploymentId")
    $iEndTime = $oJResp.IntOf("deploymentGroupsInfo[i].lastAttemptedDeployment.endTime")
    $sStatus = $oJResp.StringOf("deploymentGroupsInfo[i].lastAttemptedDeployment.status")
    $iLastSuccessfulDeploymentCreateTime = $oJResp.IntOf("deploymentGroupsInfo[i].lastSuccessfulDeployment.createTime")
    $sLastSuccessfulDeploymentDeploymentId = $oJResp.StringOf("deploymentGroupsInfo[i].lastSuccessfulDeployment.deploymentId")
    $iLastSuccessfulDeploymentEndTime = $oJResp.IntOf("deploymentGroupsInfo[i].lastSuccessfulDeployment.endTime")
    $sLastSuccessfulDeploymentStatus = $oJResp.StringOf("deploymentGroupsInfo[i].lastSuccessfulDeployment.status")
    $sOutdatedInstancesStrategy = $oJResp.StringOf("deploymentGroupsInfo[i].outdatedInstancesStrategy")
    $serviceRoleArn = $oJResp.StringOf("deploymentGroupsInfo[i].serviceRoleArn")
    $sContent = $oJResp.StringOf("deploymentGroupsInfo[i].targetRevision.appSpecContent.content")
    $sSha256 = $oJResp.StringOf("deploymentGroupsInfo[i].targetRevision.appSpecContent.sha256")
    $sCommitId = $oJResp.StringOf("deploymentGroupsInfo[i].targetRevision.gitHubLocation.commitId")
    $sRepository = $oJResp.StringOf("deploymentGroupsInfo[i].targetRevision.gitHubLocation.repository")
    $sRevisionType = $oJResp.StringOf("deploymentGroupsInfo[i].targetRevision.revisionType")
    $sBucket = $oJResp.StringOf("deploymentGroupsInfo[i].targetRevision.s3Location.bucket")
    $sBundleType = $oJResp.StringOf("deploymentGroupsInfo[i].targetRevision.s3Location.bundleType")
    $sETag = $oJResp.StringOf("deploymentGroupsInfo[i].targetRevision.s3Location.eTag")
    $sKey = $oJResp.StringOf("deploymentGroupsInfo[i].targetRevision.s3Location.key")
    $sVersion = $oJResp.StringOf("deploymentGroupsInfo[i].targetRevision.s3Location.version")
    $sStringContent = $oJResp.StringOf("deploymentGroupsInfo[i].targetRevision.string.content")
    $sStringSha256 = $oJResp.StringOf("deploymentGroupsInfo[i].targetRevision.string.sha256")
    $iJ = 0
    $iCount_j = $oJResp.SizeOfArray("deploymentGroupsInfo[i].alarmConfiguration.alarms")
    While $iJ < $iCount_j
        $oJResp.J = $iJ
        $sName = $oJResp.StringOf("deploymentGroupsInfo[i].alarmConfiguration.alarms[j].name")
        $iJ = $iJ + 1
    Wend
    $iJ = 0
    $iCount_j = $oJResp.SizeOfArray("deploymentGroupsInfo[i].autoRollbackConfiguration.events")
    While $iJ < $iCount_j
        $oJResp.J = $iJ
        $strVal = $oJResp.StringOf("deploymentGroupsInfo[i].autoRollbackConfiguration.events[j]")
        $iJ = $iJ + 1
    Wend
    $iJ = 0
    $iCount_j = $oJResp.SizeOfArray("deploymentGroupsInfo[i].autoScalingGroups")
    While $iJ < $iCount_j
        $oJResp.J = $iJ
        $sHook = $oJResp.StringOf("deploymentGroupsInfo[i].autoScalingGroups[j].hook")
        $sName = $oJResp.StringOf("deploymentGroupsInfo[i].autoScalingGroups[j].name")
        $iJ = $iJ + 1
    Wend
    $iJ = 0
    $iCount_j = $oJResp.SizeOfArray("deploymentGroupsInfo[i].ec2TagFilters")
    While $iJ < $iCount_j
        $oJResp.J = $iJ
        $sKey = $oJResp.StringOf("deploymentGroupsInfo[i].ec2TagFilters[j].Key")
        $sV_Type = $oJResp.StringOf("deploymentGroupsInfo[i].ec2TagFilters[j].Type")
        $sValue = $oJResp.StringOf("deploymentGroupsInfo[i].ec2TagFilters[j].Value")
        $iJ = $iJ + 1
    Wend
    $iJ = 0
    $iCount_j = $oJResp.SizeOfArray("deploymentGroupsInfo[i].ec2TagSet.ec2TagSetList")
    While $iJ < $iCount_j
        $oJResp.J = $iJ
        $iK = 0
        $iCount_k = $oJResp.SizeOfArray("deploymentGroupsInfo[i].ec2TagSet.ec2TagSetList[j]")
        While $iK < $iCount_k
            $oJResp.K = $iK
            $sKey = $oJResp.StringOf("deploymentGroupsInfo[i].ec2TagSet.ec2TagSetList[j][k].Key")
            $sV_Type = $oJResp.StringOf("deploymentGroupsInfo[i].ec2TagSet.ec2TagSetList[j][k].Type")
            $sValue = $oJResp.StringOf("deploymentGroupsInfo[i].ec2TagSet.ec2TagSetList[j][k].Value")
            $iK = $iK + 1
        Wend
        $iJ = $iJ + 1
    Wend
    $iJ = 0
    $iCount_j = $oJResp.SizeOfArray("deploymentGroupsInfo[i].ecsServices")
    While $iJ < $iCount_j
        $oJResp.J = $iJ
        $sClusterName = $oJResp.StringOf("deploymentGroupsInfo[i].ecsServices[j].clusterName")
        $serviceName = $oJResp.StringOf("deploymentGroupsInfo[i].ecsServices[j].serviceName")
        $iJ = $iJ + 1
    Wend
    $iJ = 0
    $iCount_j = $oJResp.SizeOfArray("deploymentGroupsInfo[i].loadBalancerInfo.elbInfoList")
    While $iJ < $iCount_j
        $oJResp.J = $iJ
        $sName = $oJResp.StringOf("deploymentGroupsInfo[i].loadBalancerInfo.elbInfoList[j].name")
        $iJ = $iJ + 1
    Wend
    $iJ = 0
    $iCount_j = $oJResp.SizeOfArray("deploymentGroupsInfo[i].loadBalancerInfo.targetGroupInfoList")
    While $iJ < $iCount_j
        $oJResp.J = $iJ
        $sName = $oJResp.StringOf("deploymentGroupsInfo[i].loadBalancerInfo.targetGroupInfoList[j].name")
        $iJ = $iJ + 1
    Wend
    $iJ = 0
    $iCount_j = $oJResp.SizeOfArray("deploymentGroupsInfo[i].loadBalancerInfo.targetGroupPairInfoList")
    While $iJ < $iCount_j
        $oJResp.J = $iJ
        $iK = 0
        $iCount_k = $oJResp.SizeOfArray("deploymentGroupsInfo[i].loadBalancerInfo.targetGroupPairInfoList[j].prodTrafficRoute.listenerArns")
        While $iK < $iCount_k
            $oJResp.K = $iK
            $strVal = $oJResp.StringOf("deploymentGroupsInfo[i].loadBalancerInfo.targetGroupPairInfoList[j].prodTrafficRoute.listenerArns[k]")
            $iK = $iK + 1
        Wend
        $iK = 0
        $iCount_k = $oJResp.SizeOfArray("deploymentGroupsInfo[i].loadBalancerInfo.targetGroupPairInfoList[j].targetGroups")
        While $iK < $iCount_k
            $oJResp.K = $iK
            $sName = $oJResp.StringOf("deploymentGroupsInfo[i].loadBalancerInfo.targetGroupPairInfoList[j].targetGroups[k].name")
            $iK = $iK + 1
        Wend
        $iK = 0
        $iCount_k = $oJResp.SizeOfArray("deploymentGroupsInfo[i].loadBalancerInfo.targetGroupPairInfoList[j].testTrafficRoute.listenerArns")
        While $iK < $iCount_k
            $oJResp.K = $iK
            $strVal = $oJResp.StringOf("deploymentGroupsInfo[i].loadBalancerInfo.targetGroupPairInfoList[j].testTrafficRoute.listenerArns[k]")
            $iK = $iK + 1
        Wend
        $iJ = $iJ + 1
    Wend
    $iJ = 0
    $iCount_j = $oJResp.SizeOfArray("deploymentGroupsInfo[i].onPremisesInstanceTagFilters")
    While $iJ < $iCount_j
        $oJResp.J = $iJ
        $sKey = $oJResp.StringOf("deploymentGroupsInfo[i].onPremisesInstanceTagFilters[j].Key")
        $sV_Type = $oJResp.StringOf("deploymentGroupsInfo[i].onPremisesInstanceTagFilters[j].Type")
        $sValue = $oJResp.StringOf("deploymentGroupsInfo[i].onPremisesInstanceTagFilters[j].Value")
        $iJ = $iJ + 1
    Wend
    $iJ = 0
    $iCount_j = $oJResp.SizeOfArray("deploymentGroupsInfo[i].onPremisesTagSet.onPremisesTagSetList")
    While $iJ < $iCount_j
        $oJResp.J = $iJ
        $iK = 0
        $iCount_k = $oJResp.SizeOfArray("deploymentGroupsInfo[i].onPremisesTagSet.onPremisesTagSetList[j]")
        While $iK < $iCount_k
            $oJResp.K = $iK
            $sKey = $oJResp.StringOf("deploymentGroupsInfo[i].onPremisesTagSet.onPremisesTagSetList[j][k].Key")
            $sV_Type = $oJResp.StringOf("deploymentGroupsInfo[i].onPremisesTagSet.onPremisesTagSetList[j][k].Type")
            $sValue = $oJResp.StringOf("deploymentGroupsInfo[i].onPremisesTagSet.onPremisesTagSetList[j][k].Value")
            $iK = $iK + 1
        Wend
        $iJ = $iJ + 1
    Wend
    $iJ = 0
    $iCount_j = $oJResp.SizeOfArray("deploymentGroupsInfo[i].triggerConfigurations")
    While $iJ < $iCount_j
        $oJResp.J = $iJ
        $sTriggerName = $oJResp.StringOf("deploymentGroupsInfo[i].triggerConfigurations[j].triggerName")
        $sTriggerTargetArn = $oJResp.StringOf("deploymentGroupsInfo[i].triggerConfigurations[j].triggerTargetArn")
        $iK = 0
        $iCount_k = $oJResp.SizeOfArray("deploymentGroupsInfo[i].triggerConfigurations[j].triggerEvents")
        While $iK < $iCount_k
            $oJResp.K = $iK
            $strVal = $oJResp.StringOf("deploymentGroupsInfo[i].triggerConfigurations[j].triggerEvents[k]")
            $iK = $iK + 1
        Wend
        $iJ = $iJ + 1
    Wend
    $i = $i + 1
Wend

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

; {
;   "deploymentGroupsInfo": [
;     {
;       "alarmConfiguration": {
;         "alarms": [
;           {
;             "name": "string"
;           }
;         ],
;         "enabled": boolean,
;         "ignorePollAlarmFailure": boolean
;       },
;       "applicationName": "string",
;       "autoRollbackConfiguration": {
;         "enabled": boolean,
;         "events": [
;           "string"
;         ]
;       },
;       "autoScalingGroups": [
;         {
;           "hook": "string",
;           "name": "string"
;         }
;       ],
;       "blueGreenDeploymentConfiguration": {
;         "deploymentReadyOption": {
;           "actionOnTimeout": "string",
;           "waitTimeInMinutes": number
;         },
;         "greenFleetProvisioningOption": {
;           "action": "string"
;         },
;         "terminateBlueInstancesOnDeploymentSuccess": {
;           "action": "string",
;           "terminationWaitTimeInMinutes": number
;         }
;       },
;       "computePlatform": "string",
;       "deploymentConfigName": "string",
;       "deploymentGroupId": "string",
;       "deploymentGroupName": "string",
;       "deploymentStyle": {
;         "deploymentOption": "string",
;         "deploymentType": "string"
;       },
;       "ec2TagFilters": [
;         {
;           "Key": "string",
;           "Type": "string",
;           "Value": "string"
;         }
;       ],
;       "ec2TagSet": {
;         "ec2TagSetList": [
;           [
;             {
;               "Key": "string",
;               "Type": "string",
;               "Value": "string"
;             }
;           ]
;         ]
;       },
;       "ecsServices": [
;         {
;           "clusterName": "string",
;           "serviceName": "string"
;         }
;       ],
;       "lastAttemptedDeployment": {
;         "createTime": number,
;         "deploymentId": "string",
;         "endTime": number,
;         "status": "string"
;       },
;       "lastSuccessfulDeployment": {
;         "createTime": number,
;         "deploymentId": "string",
;         "endTime": number,
;         "status": "string"
;       },
;       "loadBalancerInfo": {
;         "elbInfoList": [
;           {
;             "name": "string"
;           }
;         ],
;         "targetGroupInfoList": [
;           {
;             "name": "string"
;           }
;         ],
;         "targetGroupPairInfoList": [
;           {
;             "prodTrafficRoute": {
;               "listenerArns": [
;                 "string"
;               ]
;             },
;             "targetGroups": [
;               {
;                 "name": "string"
;               }
;             ],
;             "testTrafficRoute": {
;               "listenerArns": [
;                 "string"
;               ]
;             }
;           }
;         ]
;       },
;       "onPremisesInstanceTagFilters": [
;         {
;           "Key": "string",
;           "Type": "string",
;           "Value": "string"
;         }
;       ],
;       "onPremisesTagSet": {
;         "onPremisesTagSetList": [
;           [
;             {
;               "Key": "string",
;               "Type": "string",
;               "Value": "string"
;             }
;           ]
;         ]
;       },
;       "outdatedInstancesStrategy": "string",
;       "serviceRoleArn": "string",
;       "targetRevision": {
;         "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"
;         }
;       },
;       "triggerConfigurations": [
;         {
;           "triggerEvents": [
;             "string"
;           ],
;           "triggerName": "string",
;           "triggerTargetArn": "string"
;         }
;       ]
;     }
;   ],
;   "errorMessage": "string"
; }