Chilkat Online Tools

GetDeploymentGroup DataFlex Example

AWS CodeDeploy

Use ChilkatAx-9.5.0-win32.pkg

Procedure Test
    Handle hoRest
    Boolean iSuccess
    Variant vAuthAws
    Handle hoAuthAws
    Handle hoJson
    Variant vSbRequestBody
    Handle hoSbRequestBody
    Variant vSbResponseBody
    Handle hoSbResponseBody
    Integer iRespStatusCode
    Handle hoJResp
    String sName
    String sStrVal
    String sHook
    String sV_Type
    String sValue
    Integer j
    Integer iCount_j
    String sClusterName
    String sServiceName
    String sTriggerName
    String sTriggerTargetArn
    Integer iEnabled
    Integer iIgnorePollAlarmFailure
    String sApplicationName
    Integer iAutoRollbackConfigurationEnabled
    String sActionOnTimeout
    Integer iWaitTimeInMinutes
    String sAction
    String sTerminateBlueInstancesOnDeploymentSuccessAction
    Integer iTerminationWaitTimeInMinutes
    String sComputePlatform
    String sDeploymentConfigName
    String sDeploymentGroupId
    String sDeploymentGroupName
    String sDeploymentOption
    String sDeploymentType
    Integer iCreateTime
    String sDeploymentId
    Integer iEndTime
    String sStatus
    Integer iLastSuccessfulDeploymentCreateTime
    String sLastSuccessfulDeploymentDeploymentId
    Integer iLastSuccessfulDeploymentEndTime
    String sLastSuccessfulDeploymentStatus
    String sOutdatedInstancesStrategy
    String sServiceRoleArn
    String sContent
    String sSha256
    String sCommitId
    String sRepository
    String sRevisionType
    String sBucket
    String sBundleType
    String sETag
    String sKey
    String sVersion
    String sStringContent
    String sStringSha256
    Integer i
    Integer iCount_i
    String sTemp1
    Integer iTemp1

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

    Get Create (RefClass(cComChilkatRest)) To hoRest
    If (Not(IsComObjectCreated(hoRest))) Begin
        Send CreateComObject of hoRest
    End

    Get Create (RefClass(cComChilkatAuthAws)) To hoAuthAws
    If (Not(IsComObjectCreated(hoAuthAws))) Begin
        Send CreateComObject of hoAuthAws
    End
    Set ComAccessKey Of hoAuthAws To "AWS_ACCESS_KEY"
    Set ComSecretKey Of hoAuthAws To "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.)
    Set ComRegion Of hoAuthAws To "us-west-2"
    Set ComServiceName Of hoAuthAws To "codedeploy"
    // SetAuthAws causes Chilkat to automatically add the following headers: Authorization, X-Amz-Date
    Get pvComObject of hoAuthAws to vAuthAws
    Get ComSetAuthAws Of hoRest vAuthAws To iSuccess

    // URL: https://codedeploy.us-west-2.amazonaws.com/
    // Use the same region as specified above.
    Get ComConnect Of hoRest "codedeploy.us-west-2.amazonaws.com" 443 True True To iSuccess
    If (iSuccess <> True) Begin
        Get ComConnectFailReason Of hoRest To iTemp1
        Showln "ConnectFailReason: " iTemp1
        Get ComLastErrorText Of hoRest To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    // 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

    Get Create (RefClass(cComChilkatJsonObject)) To hoJson
    If (Not(IsComObjectCreated(hoJson))) Begin
        Send CreateComObject of hoJson
    End
    Get ComUpdateString Of hoJson "applicationName" "string" To iSuccess
    Get ComUpdateString Of hoJson "deploymentGroupName" "string" To iSuccess

    // The JSON request body created by the above code:

    // {
    //   "applicationName": "string",
    //   "deploymentGroupName": "string"
    // }

    Get ComAddHeader Of hoRest "Content-Type" "application/x-amz-json-1.1" To iSuccess
    Get ComAddHeader Of hoRest "X-Amz-Target" "CodeDeploy_20141006.GetDeploymentGroup" To iSuccess

    Get Create (RefClass(cComChilkatStringBuilder)) To hoSbRequestBody
    If (Not(IsComObjectCreated(hoSbRequestBody))) Begin
        Send CreateComObject of hoSbRequestBody
    End
    Get pvComObject of hoSbRequestBody to vSbRequestBody
    Get ComEmitSb Of hoJson vSbRequestBody To iSuccess
    Get Create (RefClass(cComChilkatStringBuilder)) To hoSbResponseBody
    If (Not(IsComObjectCreated(hoSbResponseBody))) Begin
        Send CreateComObject of hoSbResponseBody
    End
    Get pvComObject of hoSbRequestBody to vSbRequestBody
    Get pvComObject of hoSbResponseBody to vSbResponseBody
    Get ComFullRequestSb Of hoRest "POST" "/" vSbRequestBody vSbResponseBody To iSuccess
    If (iSuccess <> True) Begin
        Get ComLastErrorText Of hoRest To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Get ComResponseStatusCode Of hoRest To iRespStatusCode
    Showln "response status code = " iRespStatusCode
    If (iRespStatusCode <> 200) Begin
        Showln "Response Header:"
        Get ComResponseHeader Of hoRest To sTemp1
        Showln sTemp1
        Showln "Response Body:"
        Get ComGetAsString Of hoSbResponseBody To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Get Create (RefClass(cComChilkatJsonObject)) To hoJResp
    If (Not(IsComObjectCreated(hoJResp))) Begin
        Send CreateComObject of hoJResp
    End
    Get pvComObject of hoSbResponseBody to vSbResponseBody
    Get ComLoadSb Of hoJResp vSbResponseBody To iSuccess

    // 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

    Get ComIntOf Of hoJResp "deploymentGroupInfo.alarmConfiguration.enabled" To iEnabled
    Get ComIntOf Of hoJResp "deploymentGroupInfo.alarmConfiguration.ignorePollAlarmFailure" To iIgnorePollAlarmFailure
    Get ComStringOf Of hoJResp "deploymentGroupInfo.applicationName" To sApplicationName
    Get ComIntOf Of hoJResp "deploymentGroupInfo.autoRollbackConfiguration.enabled" To iAutoRollbackConfigurationEnabled
    Get ComStringOf Of hoJResp "deploymentGroupInfo.blueGreenDeploymentConfiguration.deploymentReadyOption.actionOnTimeout" To sActionOnTimeout
    Get ComIntOf Of hoJResp "deploymentGroupInfo.blueGreenDeploymentConfiguration.deploymentReadyOption.waitTimeInMinutes" To iWaitTimeInMinutes
    Get ComStringOf Of hoJResp "deploymentGroupInfo.blueGreenDeploymentConfiguration.greenFleetProvisioningOption.action" To sAction
    Get ComStringOf Of hoJResp "deploymentGroupInfo.blueGreenDeploymentConfiguration.terminateBlueInstancesOnDeploymentSuccess.action" To sTerminateBlueInstancesOnDeploymentSuccessAction
    Get ComIntOf Of hoJResp "deploymentGroupInfo.blueGreenDeploymentConfiguration.terminateBlueInstancesOnDeploymentSuccess.terminationWaitTimeInMinutes" To iTerminationWaitTimeInMinutes
    Get ComStringOf Of hoJResp "deploymentGroupInfo.computePlatform" To sComputePlatform
    Get ComStringOf Of hoJResp "deploymentGroupInfo.deploymentConfigName" To sDeploymentConfigName
    Get ComStringOf Of hoJResp "deploymentGroupInfo.deploymentGroupId" To sDeploymentGroupId
    Get ComStringOf Of hoJResp "deploymentGroupInfo.deploymentGroupName" To sDeploymentGroupName
    Get ComStringOf Of hoJResp "deploymentGroupInfo.deploymentStyle.deploymentOption" To sDeploymentOption
    Get ComStringOf Of hoJResp "deploymentGroupInfo.deploymentStyle.deploymentType" To sDeploymentType
    Get ComIntOf Of hoJResp "deploymentGroupInfo.lastAttemptedDeployment.createTime" To iCreateTime
    Get ComStringOf Of hoJResp "deploymentGroupInfo.lastAttemptedDeployment.deploymentId" To sDeploymentId
    Get ComIntOf Of hoJResp "deploymentGroupInfo.lastAttemptedDeployment.endTime" To iEndTime
    Get ComStringOf Of hoJResp "deploymentGroupInfo.lastAttemptedDeployment.status" To sStatus
    Get ComIntOf Of hoJResp "deploymentGroupInfo.lastSuccessfulDeployment.createTime" To iLastSuccessfulDeploymentCreateTime
    Get ComStringOf Of hoJResp "deploymentGroupInfo.lastSuccessfulDeployment.deploymentId" To sLastSuccessfulDeploymentDeploymentId
    Get ComIntOf Of hoJResp "deploymentGroupInfo.lastSuccessfulDeployment.endTime" To iLastSuccessfulDeploymentEndTime
    Get ComStringOf Of hoJResp "deploymentGroupInfo.lastSuccessfulDeployment.status" To sLastSuccessfulDeploymentStatus
    Get ComStringOf Of hoJResp "deploymentGroupInfo.outdatedInstancesStrategy" To sOutdatedInstancesStrategy
    Get ComStringOf Of hoJResp "deploymentGroupInfo.serviceRoleArn" To sServiceRoleArn
    Get ComStringOf Of hoJResp "deploymentGroupInfo.targetRevision.appSpecContent.content" To sContent
    Get ComStringOf Of hoJResp "deploymentGroupInfo.targetRevision.appSpecContent.sha256" To sSha256
    Get ComStringOf Of hoJResp "deploymentGroupInfo.targetRevision.gitHubLocation.commitId" To sCommitId
    Get ComStringOf Of hoJResp "deploymentGroupInfo.targetRevision.gitHubLocation.repository" To sRepository
    Get ComStringOf Of hoJResp "deploymentGroupInfo.targetRevision.revisionType" To sRevisionType
    Get ComStringOf Of hoJResp "deploymentGroupInfo.targetRevision.s3Location.bucket" To sBucket
    Get ComStringOf Of hoJResp "deploymentGroupInfo.targetRevision.s3Location.bundleType" To sBundleType
    Get ComStringOf Of hoJResp "deploymentGroupInfo.targetRevision.s3Location.eTag" To sETag
    Get ComStringOf Of hoJResp "deploymentGroupInfo.targetRevision.s3Location.key" To sKey
    Get ComStringOf Of hoJResp "deploymentGroupInfo.targetRevision.s3Location.version" To sVersion
    Get ComStringOf Of hoJResp "deploymentGroupInfo.targetRevision.string.content" To sStringContent
    Get ComStringOf Of hoJResp "deploymentGroupInfo.targetRevision.string.sha256" To sStringSha256
    Move 0 To i
    Get ComSizeOfArray Of hoJResp "deploymentGroupInfo.alarmConfiguration.alarms" To iCount_i
    While (i < iCount_i)
        Set ComI Of hoJResp To i
        Get ComStringOf Of hoJResp "deploymentGroupInfo.alarmConfiguration.alarms[i].name" To sName
        Move (i + 1) To i
    Loop

    Move 0 To i
    Get ComSizeOfArray Of hoJResp "deploymentGroupInfo.autoRollbackConfiguration.events" To iCount_i
    While (i < iCount_i)
        Set ComI Of hoJResp To i
        Get ComStringOf Of hoJResp "deploymentGroupInfo.autoRollbackConfiguration.events[i]" To sStrVal
        Move (i + 1) To i
    Loop

    Move 0 To i
    Get ComSizeOfArray Of hoJResp "deploymentGroupInfo.autoScalingGroups" To iCount_i
    While (i < iCount_i)
        Set ComI Of hoJResp To i
        Get ComStringOf Of hoJResp "deploymentGroupInfo.autoScalingGroups[i].hook" To sHook
        Get ComStringOf Of hoJResp "deploymentGroupInfo.autoScalingGroups[i].name" To sName
        Move (i + 1) To i
    Loop

    Move 0 To i
    Get ComSizeOfArray Of hoJResp "deploymentGroupInfo.ec2TagFilters" To iCount_i
    While (i < iCount_i)
        Set ComI Of hoJResp To i
        Get ComStringOf Of hoJResp "deploymentGroupInfo.ec2TagFilters[i].Key" To sKey
        Get ComStringOf Of hoJResp "deploymentGroupInfo.ec2TagFilters[i].Type" To sV_Type
        Get ComStringOf Of hoJResp "deploymentGroupInfo.ec2TagFilters[i].Value" To sValue
        Move (i + 1) To i
    Loop

    Move 0 To i
    Get ComSizeOfArray Of hoJResp "deploymentGroupInfo.ec2TagSet.ec2TagSetList" To iCount_i
    While (i < iCount_i)
        Set ComI Of hoJResp To i
        Move 0 To j
        Get ComSizeOfArray Of hoJResp "deploymentGroupInfo.ec2TagSet.ec2TagSetList[i]" To iCount_j
        While (j < iCount_j)
            Set ComJ Of hoJResp To j
            Get ComStringOf Of hoJResp "deploymentGroupInfo.ec2TagSet.ec2TagSetList[i][j].Key" To sKey
            Get ComStringOf Of hoJResp "deploymentGroupInfo.ec2TagSet.ec2TagSetList[i][j].Type" To sV_Type
            Get ComStringOf Of hoJResp "deploymentGroupInfo.ec2TagSet.ec2TagSetList[i][j].Value" To sValue
            Move (j + 1) To j
        Loop

        Move (i + 1) To i
    Loop

    Move 0 To i
    Get ComSizeOfArray Of hoJResp "deploymentGroupInfo.ecsServices" To iCount_i
    While (i < iCount_i)
        Set ComI Of hoJResp To i
        Get ComStringOf Of hoJResp "deploymentGroupInfo.ecsServices[i].clusterName" To sClusterName
        Get ComStringOf Of hoJResp "deploymentGroupInfo.ecsServices[i].serviceName" To sServiceName
        Move (i + 1) To i
    Loop

    Move 0 To i
    Get ComSizeOfArray Of hoJResp "deploymentGroupInfo.loadBalancerInfo.elbInfoList" To iCount_i
    While (i < iCount_i)
        Set ComI Of hoJResp To i
        Get ComStringOf Of hoJResp "deploymentGroupInfo.loadBalancerInfo.elbInfoList[i].name" To sName
        Move (i + 1) To i
    Loop

    Move 0 To i
    Get ComSizeOfArray Of hoJResp "deploymentGroupInfo.loadBalancerInfo.targetGroupInfoList" To iCount_i
    While (i < iCount_i)
        Set ComI Of hoJResp To i
        Get ComStringOf Of hoJResp "deploymentGroupInfo.loadBalancerInfo.targetGroupInfoList[i].name" To sName
        Move (i + 1) To i
    Loop

    Move 0 To i
    Get ComSizeOfArray Of hoJResp "deploymentGroupInfo.loadBalancerInfo.targetGroupPairInfoList" To iCount_i
    While (i < iCount_i)
        Set ComI Of hoJResp To i
        Move 0 To j
        Get ComSizeOfArray Of hoJResp "deploymentGroupInfo.loadBalancerInfo.targetGroupPairInfoList[i].prodTrafficRoute.listenerArns" To iCount_j
        While (j < iCount_j)
            Set ComJ Of hoJResp To j
            Get ComStringOf Of hoJResp "deploymentGroupInfo.loadBalancerInfo.targetGroupPairInfoList[i].prodTrafficRoute.listenerArns[j]" To sStrVal
            Move (j + 1) To j
        Loop

        Move 0 To j
        Get ComSizeOfArray Of hoJResp "deploymentGroupInfo.loadBalancerInfo.targetGroupPairInfoList[i].targetGroups" To iCount_j
        While (j < iCount_j)
            Set ComJ Of hoJResp To j
            Get ComStringOf Of hoJResp "deploymentGroupInfo.loadBalancerInfo.targetGroupPairInfoList[i].targetGroups[j].name" To sName
            Move (j + 1) To j
        Loop

        Move 0 To j
        Get ComSizeOfArray Of hoJResp "deploymentGroupInfo.loadBalancerInfo.targetGroupPairInfoList[i].testTrafficRoute.listenerArns" To iCount_j
        While (j < iCount_j)
            Set ComJ Of hoJResp To j
            Get ComStringOf Of hoJResp "deploymentGroupInfo.loadBalancerInfo.targetGroupPairInfoList[i].testTrafficRoute.listenerArns[j]" To sStrVal
            Move (j + 1) To j
        Loop

        Move (i + 1) To i
    Loop

    Move 0 To i
    Get ComSizeOfArray Of hoJResp "deploymentGroupInfo.onPremisesInstanceTagFilters" To iCount_i
    While (i < iCount_i)
        Set ComI Of hoJResp To i
        Get ComStringOf Of hoJResp "deploymentGroupInfo.onPremisesInstanceTagFilters[i].Key" To sKey
        Get ComStringOf Of hoJResp "deploymentGroupInfo.onPremisesInstanceTagFilters[i].Type" To sV_Type
        Get ComStringOf Of hoJResp "deploymentGroupInfo.onPremisesInstanceTagFilters[i].Value" To sValue
        Move (i + 1) To i
    Loop

    Move 0 To i
    Get ComSizeOfArray Of hoJResp "deploymentGroupInfo.onPremisesTagSet.onPremisesTagSetList" To iCount_i
    While (i < iCount_i)
        Set ComI Of hoJResp To i
        Move 0 To j
        Get ComSizeOfArray Of hoJResp "deploymentGroupInfo.onPremisesTagSet.onPremisesTagSetList[i]" To iCount_j
        While (j < iCount_j)
            Set ComJ Of hoJResp To j
            Get ComStringOf Of hoJResp "deploymentGroupInfo.onPremisesTagSet.onPremisesTagSetList[i][j].Key" To sKey
            Get ComStringOf Of hoJResp "deploymentGroupInfo.onPremisesTagSet.onPremisesTagSetList[i][j].Type" To sV_Type
            Get ComStringOf Of hoJResp "deploymentGroupInfo.onPremisesTagSet.onPremisesTagSetList[i][j].Value" To sValue
            Move (j + 1) To j
        Loop

        Move (i + 1) To i
    Loop

    Move 0 To i
    Get ComSizeOfArray Of hoJResp "deploymentGroupInfo.triggerConfigurations" To iCount_i
    While (i < iCount_i)
        Set ComI Of hoJResp To i
        Get ComStringOf Of hoJResp "deploymentGroupInfo.triggerConfigurations[i].triggerName" To sTriggerName
        Get ComStringOf Of hoJResp "deploymentGroupInfo.triggerConfigurations[i].triggerTargetArn" To sTriggerTargetArn
        Move 0 To j
        Get ComSizeOfArray Of hoJResp "deploymentGroupInfo.triggerConfigurations[i].triggerEvents" To iCount_j
        While (j < iCount_j)
            Set ComJ Of hoJResp To j
            Get ComStringOf Of hoJResp "deploymentGroupInfo.triggerConfigurations[i].triggerEvents[j]" To sStrVal
            Move (j + 1) To j
        Loop

        Move (i + 1) To i
    Loop

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

    // {
    //   "deploymentGroupInfo": {
    //     "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"
    //       }
    //     ]
    //   }
    // }


End_Procedure