Chilkat Online Tools

GetDeployment VB.NET Example

AWS CodeDeploy

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

Dim rest As New Chilkat.Rest
Dim success As Boolean

Dim authAws As New Chilkat.AuthAws
authAws.AccessKey = "AWS_ACCESS_KEY"
authAws.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.)
authAws.Region = "us-west-2"
authAws.ServiceName = "codedeploy"
' SetAuthAws causes Chilkat to automatically add the following headers: Authorization, X-Amz-Date
rest.SetAuthAws(authAws)

' URL: https://codedeploy.us-west-2.amazonaws.com/
' Use the same region as specified above.
success = rest.Connect("codedeploy.us-west-2.amazonaws.com",443,True,True)
If (success <> True) Then
    Debug.WriteLine("ConnectFailReason: " & rest.ConnectFailReason)
    Debug.WriteLine(rest.LastErrorText)
    Exit Sub
End If


' 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

Dim json As New Chilkat.JsonObject
json.UpdateString("deploymentId","string")

' The JSON request body created by the above code:

' {
'   "deploymentId": "string"
' }

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

Dim sbRequestBody As New Chilkat.StringBuilder
json.EmitSb(sbRequestBody)
Dim sbResponseBody As New Chilkat.StringBuilder
success = rest.FullRequestSb("POST","/",sbRequestBody,sbResponseBody)
If (success <> True) Then
    Debug.WriteLine(rest.LastErrorText)
    Exit Sub
End If

Dim respStatusCode As Integer = rest.ResponseStatusCode
Debug.WriteLine("response status code = " & respStatusCode)
If (respStatusCode <> 200) Then
    Debug.WriteLine("Response Header:")
    Debug.WriteLine(rest.ResponseHeader)
    Debug.WriteLine("Response Body:")
    Debug.WriteLine(sbResponseBody.GetAsString())
    Exit Sub
End If


Dim jResp As New Chilkat.JsonObject
jResp.LoadSb(sbResponseBody)

' 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



Dim strVal As String
Dim name As String
Dim j As Integer
Dim count_j As Integer
Dim v_Type As String
Dim Value As String

Dim AdditionalDeploymentStatusInfo As String = jResp.StringOf("deploymentInfo.additionalDeploymentStatusInfo")
Dim ApplicationName As String = jResp.StringOf("deploymentInfo.applicationName")
Dim Enabled As Integer = jResp.IntOf("deploymentInfo.autoRollbackConfiguration.enabled")
Dim ActionOnTimeout As String = jResp.StringOf("deploymentInfo.blueGreenDeploymentConfiguration.deploymentReadyOption.actionOnTimeout")
Dim WaitTimeInMinutes As Integer = jResp.IntOf("deploymentInfo.blueGreenDeploymentConfiguration.deploymentReadyOption.waitTimeInMinutes")
Dim Action As String = jResp.StringOf("deploymentInfo.blueGreenDeploymentConfiguration.greenFleetProvisioningOption.action")
Dim TerminateBlueInstancesOnDeploymentSuccessAction As String = jResp.StringOf("deploymentInfo.blueGreenDeploymentConfiguration.terminateBlueInstancesOnDeploymentSuccess.action")
Dim TerminationWaitTimeInMinutes As Integer = jResp.IntOf("deploymentInfo.blueGreenDeploymentConfiguration.terminateBlueInstancesOnDeploymentSuccess.terminationWaitTimeInMinutes")
Dim CompleteTime As Integer = jResp.IntOf("deploymentInfo.completeTime")
Dim ComputePlatform As String = jResp.StringOf("deploymentInfo.computePlatform")
Dim CreateTime As Integer = jResp.IntOf("deploymentInfo.createTime")
Dim Creator As String = jResp.StringOf("deploymentInfo.creator")
Dim DeploymentConfigName As String = jResp.StringOf("deploymentInfo.deploymentConfigName")
Dim DeploymentGroupName As String = jResp.StringOf("deploymentInfo.deploymentGroupName")
Dim DeploymentId As String = jResp.StringOf("deploymentInfo.deploymentId")
Dim Failed As Integer = jResp.IntOf("deploymentInfo.deploymentOverview.Failed")
Dim InProgress As Integer = jResp.IntOf("deploymentInfo.deploymentOverview.InProgress")
Dim Pending As Integer = jResp.IntOf("deploymentInfo.deploymentOverview.Pending")
Dim Ready As Integer = jResp.IntOf("deploymentInfo.deploymentOverview.Ready")
Dim Skipped As Integer = jResp.IntOf("deploymentInfo.deploymentOverview.Skipped")
Dim Succeeded As Integer = jResp.IntOf("deploymentInfo.deploymentOverview.Succeeded")
Dim DeploymentOption As String = jResp.StringOf("deploymentInfo.deploymentStyle.deploymentOption")
Dim DeploymentType As String = jResp.StringOf("deploymentInfo.deploymentStyle.deploymentType")
Dim Description As String = jResp.StringOf("deploymentInfo.description")
Dim Code As String = jResp.StringOf("deploymentInfo.errorInformation.code")
Dim Message As String = jResp.StringOf("deploymentInfo.errorInformation.message")
Dim ExternalId As String = jResp.StringOf("deploymentInfo.externalId")
Dim FileExistsBehavior As String = jResp.StringOf("deploymentInfo.fileExistsBehavior")
Dim IgnoreApplicationStopFailures As Integer = jResp.IntOf("deploymentInfo.ignoreApplicationStopFailures")
Dim InstanceTerminationWaitTimeStarted As Integer = jResp.IntOf("deploymentInfo.instanceTerminationWaitTimeStarted")
Dim Content As String = jResp.StringOf("deploymentInfo.previousRevision.appSpecContent.content")
Dim Sha256 As String = jResp.StringOf("deploymentInfo.previousRevision.appSpecContent.sha256")
Dim CommitId As String = jResp.StringOf("deploymentInfo.previousRevision.gitHubLocation.commitId")
Dim Repository As String = jResp.StringOf("deploymentInfo.previousRevision.gitHubLocation.repository")
Dim RevisionType As String = jResp.StringOf("deploymentInfo.previousRevision.revisionType")
Dim Bucket As String = jResp.StringOf("deploymentInfo.previousRevision.s3Location.bucket")
Dim BundleType As String = jResp.StringOf("deploymentInfo.previousRevision.s3Location.bundleType")
Dim ETag As String = jResp.StringOf("deploymentInfo.previousRevision.s3Location.eTag")
Dim Key As String = jResp.StringOf("deploymentInfo.previousRevision.s3Location.key")
Dim Version As String = jResp.StringOf("deploymentInfo.previousRevision.s3Location.version")
Dim StringContent As String = jResp.StringOf("deploymentInfo.previousRevision.string.content")
Dim StringSha256 As String = jResp.StringOf("deploymentInfo.previousRevision.string.sha256")
Dim AutoUpdateOutdatedInstancesRootDeploymentId As String = jResp.StringOf("deploymentInfo.relatedDeployments.autoUpdateOutdatedInstancesRootDeploymentId")
Dim AppSpecContentContent As String = jResp.StringOf("deploymentInfo.revision.appSpecContent.content")
Dim AppSpecContentSha256 As String = jResp.StringOf("deploymentInfo.revision.appSpecContent.sha256")
Dim GitHubLocationCommitId As String = jResp.StringOf("deploymentInfo.revision.gitHubLocation.commitId")
Dim GitHubLocationRepository As String = jResp.StringOf("deploymentInfo.revision.gitHubLocation.repository")
Dim RevisionRevisionType As String = jResp.StringOf("deploymentInfo.revision.revisionType")
Dim S3LocationBucket As String = jResp.StringOf("deploymentInfo.revision.s3Location.bucket")
Dim S3LocationBundleType As String = jResp.StringOf("deploymentInfo.revision.s3Location.bundleType")
Dim S3LocationETag As String = jResp.StringOf("deploymentInfo.revision.s3Location.eTag")
Dim S3LocationKey As String = jResp.StringOf("deploymentInfo.revision.s3Location.key")
Dim S3LocationVersion As String = jResp.StringOf("deploymentInfo.revision.s3Location.version")
StringContent = jResp.StringOf("deploymentInfo.revision.string.content")
StringSha256 = jResp.StringOf("deploymentInfo.revision.string.sha256")
Dim RollbackDeploymentId As String = jResp.StringOf("deploymentInfo.rollbackInfo.rollbackDeploymentId")
Dim RollbackMessage As String = jResp.StringOf("deploymentInfo.rollbackInfo.rollbackMessage")
Dim RollbackTriggeringDeploymentId As String = jResp.StringOf("deploymentInfo.rollbackInfo.rollbackTriggeringDeploymentId")
Dim StartTime As Integer = jResp.IntOf("deploymentInfo.startTime")
Dim Status As String = jResp.StringOf("deploymentInfo.status")
Dim UpdateOutdatedInstancesOnly As Integer = jResp.IntOf("deploymentInfo.updateOutdatedInstancesOnly")
Dim i As Integer = 0
Dim count_i As Integer = jResp.SizeOfArray("deploymentInfo.autoRollbackConfiguration.events")
While i < count_i
    jResp.I = i
    strVal = jResp.StringOf("deploymentInfo.autoRollbackConfiguration.events[i]")
    i = i + 1
End While
i = 0
count_i = jResp.SizeOfArray("deploymentInfo.deploymentStatusMessages")
While i < count_i
    jResp.I = i
    strVal = jResp.StringOf("deploymentInfo.deploymentStatusMessages[i]")
    i = i + 1
End While
i = 0
count_i = jResp.SizeOfArray("deploymentInfo.loadBalancerInfo.elbInfoList")
While i < count_i
    jResp.I = i
    name = jResp.StringOf("deploymentInfo.loadBalancerInfo.elbInfoList[i].name")
    i = i + 1
End While
i = 0
count_i = jResp.SizeOfArray("deploymentInfo.loadBalancerInfo.targetGroupInfoList")
While i < count_i
    jResp.I = i
    name = jResp.StringOf("deploymentInfo.loadBalancerInfo.targetGroupInfoList[i].name")
    i = i + 1
End While
i = 0
count_i = jResp.SizeOfArray("deploymentInfo.loadBalancerInfo.targetGroupPairInfoList")
While i < count_i
    jResp.I = i
    j = 0
    count_j = jResp.SizeOfArray("deploymentInfo.loadBalancerInfo.targetGroupPairInfoList[i].prodTrafficRoute.listenerArns")
    While j < count_j
        jResp.J = j
        strVal = jResp.StringOf("deploymentInfo.loadBalancerInfo.targetGroupPairInfoList[i].prodTrafficRoute.listenerArns[j]")
        j = j + 1
    End While
    j = 0
    count_j = jResp.SizeOfArray("deploymentInfo.loadBalancerInfo.targetGroupPairInfoList[i].targetGroups")
    While j < count_j
        jResp.J = j
        name = jResp.StringOf("deploymentInfo.loadBalancerInfo.targetGroupPairInfoList[i].targetGroups[j].name")
        j = j + 1
    End While
    j = 0
    count_j = jResp.SizeOfArray("deploymentInfo.loadBalancerInfo.targetGroupPairInfoList[i].testTrafficRoute.listenerArns")
    While j < count_j
        jResp.J = j
        strVal = jResp.StringOf("deploymentInfo.loadBalancerInfo.targetGroupPairInfoList[i].testTrafficRoute.listenerArns[j]")
        j = j + 1
    End While
    i = i + 1
End While
i = 0
count_i = jResp.SizeOfArray("deploymentInfo.relatedDeployments.autoUpdateOutdatedInstancesDeploymentIds")
While i < count_i
    jResp.I = i
    strVal = jResp.StringOf("deploymentInfo.relatedDeployments.autoUpdateOutdatedInstancesDeploymentIds[i]")
    i = i + 1
End While
i = 0
count_i = jResp.SizeOfArray("deploymentInfo.targetInstances.autoScalingGroups")
While i < count_i
    jResp.I = i
    strVal = jResp.StringOf("deploymentInfo.targetInstances.autoScalingGroups[i]")
    i = i + 1
End While
i = 0
count_i = jResp.SizeOfArray("deploymentInfo.targetInstances.ec2TagSet.ec2TagSetList")
While i < count_i
    jResp.I = i
    j = 0
    count_j = jResp.SizeOfArray("deploymentInfo.targetInstances.ec2TagSet.ec2TagSetList[i]")
    While j < count_j
        jResp.J = j
        Key = jResp.StringOf("deploymentInfo.targetInstances.ec2TagSet.ec2TagSetList[i][j].Key")
        v_Type = jResp.StringOf("deploymentInfo.targetInstances.ec2TagSet.ec2TagSetList[i][j].Type")
        Value = jResp.StringOf("deploymentInfo.targetInstances.ec2TagSet.ec2TagSetList[i][j].Value")
        j = j + 1
    End While
    i = i + 1
End While
i = 0
count_i = jResp.SizeOfArray("deploymentInfo.targetInstances.tagFilters")
While i < count_i
    jResp.I = i
    Key = jResp.StringOf("deploymentInfo.targetInstances.tagFilters[i].Key")
    v_Type = jResp.StringOf("deploymentInfo.targetInstances.tagFilters[i].Type")
    Value = jResp.StringOf("deploymentInfo.targetInstances.tagFilters[i].Value")
    i = i + 1
End While


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

' {
'   "deploymentInfo": {
'     "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
'   }
' }