BatchGetDeployments Go Example
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
rest := chilkat.NewRest()
var success bool
authAws := chilkat.NewAuthAws()
authAws.SetAccessKey("AWS_ACCESS_KEY")
authAws.SetSecretKey("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.SetRegion("us-west-2")
authAws.SetServiceName("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 {
fmt.Println("ConnectFailReason: ", rest.ConnectFailReason())
fmt.Println(rest.LastErrorText())
rest.DisposeRest()
authAws.DisposeAuthAws()
return
}
// 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
json := chilkat.NewJsonObject()
json.UpdateString("deploymentIds[0]","string")
// The JSON request body created by the above code:
// {
// "deploymentIds": [
// "string"
// ]
// }
rest.AddHeader("Content-Type","application/x-amz-json-1.1")
rest.AddHeader("X-Amz-Target","CodeDeploy_20141006.BatchGetDeployments")
sbRequestBody := chilkat.NewStringBuilder()
json.EmitSb(sbRequestBody)
sbResponseBody := chilkat.NewStringBuilder()
success = rest.FullRequestSb("POST","/",sbRequestBody,sbResponseBody)
if success != true {
fmt.Println(rest.LastErrorText())
rest.DisposeRest()
authAws.DisposeAuthAws()
json.DisposeJsonObject()
sbRequestBody.DisposeStringBuilder()
sbResponseBody.DisposeStringBuilder()
return
}
respStatusCode := rest.ResponseStatusCode()
fmt.Println("response status code = ", respStatusCode)
if respStatusCode != 200 {
fmt.Println("Response Header:")
fmt.Println(rest.ResponseHeader())
fmt.Println("Response Body:")
fmt.Println(*sbResponseBody.GetAsString())
rest.DisposeRest()
authAws.DisposeAuthAws()
json.DisposeJsonObject()
sbRequestBody.DisposeStringBuilder()
sbResponseBody.DisposeStringBuilder()
return
}
jResp := chilkat.NewJsonObject()
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
additionalDeploymentStatusInfo_DECLARATION
applicationName_DECLARATION
var Enabled int
ActionOnTimeout_DECLARATION
var WaitTimeInMinutes int
Action_DECLARATION
TerminateBlueInstancesOnDeploymentSuccessAction_DECLARATION
var TerminationWaitTimeInMinutes int
var completeTime int
computePlatform_DECLARATION
var createTime int
creator_DECLARATION
deploymentConfigName_DECLARATION
deploymentGroupName_DECLARATION
deploymentId_DECLARATION
var Failed int
var InProgress int
var Pending int
var Ready int
var Skipped int
var Succeeded int
DeploymentOption_DECLARATION
DeploymentType_DECLARATION
description_DECLARATION
Code_DECLARATION
Message_DECLARATION
externalId_DECLARATION
fileExistsBehavior_DECLARATION
var ignoreApplicationStopFailures int
var instanceTerminationWaitTimeStarted int
Content_DECLARATION
Sha256_DECLARATION
CommitId_DECLARATION
Repository_DECLARATION
RevisionType_DECLARATION
Bucket_DECLARATION
BundleType_DECLARATION
ETag_DECLARATION
Key_DECLARATION
Version_DECLARATION
StringContent_DECLARATION
StringSha256_DECLARATION
AutoUpdateOutdatedInstancesRootDeploymentId_DECLARATION
AppSpecContentContent_DECLARATION
AppSpecContentSha256_DECLARATION
GitHubLocationCommitId_DECLARATION
GitHubLocationRepository_DECLARATION
revisionRevisionType_DECLARATION
S3LocationBucket_DECLARATION
S3LocationBundleType_DECLARATION
S3LocationETag_DECLARATION
S3LocationKey_DECLARATION
S3LocationVersion_DECLARATION
RollbackDeploymentId_DECLARATION
RollbackMessage_DECLARATION
RollbackTriggeringDeploymentId_DECLARATION
var startTime int
status_DECLARATION
var updateOutdatedInstancesOnly int
var j int
var count_j int
strVal_DECLARATION
name_DECLARATION
var k int
var count_k int
v_Type_DECLARATION
Value_DECLARATION
i := 0
count_i := jResp.SizeOfArray("deploymentsInfo")
for i < count_i {
jResp.SetI(i)
additionalDeploymentStatusInfo = *jResp.StringOf("deploymentsInfo[i].additionalDeploymentStatusInfo")
applicationName = *jResp.StringOf("deploymentsInfo[i].applicationName")
Enabled = jResp.IntOf("deploymentsInfo[i].autoRollbackConfiguration.enabled")
ActionOnTimeout = *jResp.StringOf("deploymentsInfo[i].blueGreenDeploymentConfiguration.deploymentReadyOption.actionOnTimeout")
WaitTimeInMinutes = jResp.IntOf("deploymentsInfo[i].blueGreenDeploymentConfiguration.deploymentReadyOption.waitTimeInMinutes")
Action = *jResp.StringOf("deploymentsInfo[i].blueGreenDeploymentConfiguration.greenFleetProvisioningOption.action")
TerminateBlueInstancesOnDeploymentSuccessAction = *jResp.StringOf("deploymentsInfo[i].blueGreenDeploymentConfiguration.terminateBlueInstancesOnDeploymentSuccess.action")
TerminationWaitTimeInMinutes = jResp.IntOf("deploymentsInfo[i].blueGreenDeploymentConfiguration.terminateBlueInstancesOnDeploymentSuccess.terminationWaitTimeInMinutes")
completeTime = jResp.IntOf("deploymentsInfo[i].completeTime")
computePlatform = *jResp.StringOf("deploymentsInfo[i].computePlatform")
createTime = jResp.IntOf("deploymentsInfo[i].createTime")
creator = *jResp.StringOf("deploymentsInfo[i].creator")
deploymentConfigName = *jResp.StringOf("deploymentsInfo[i].deploymentConfigName")
deploymentGroupName = *jResp.StringOf("deploymentsInfo[i].deploymentGroupName")
deploymentId = *jResp.StringOf("deploymentsInfo[i].deploymentId")
Failed = jResp.IntOf("deploymentsInfo[i].deploymentOverview.Failed")
InProgress = jResp.IntOf("deploymentsInfo[i].deploymentOverview.InProgress")
Pending = jResp.IntOf("deploymentsInfo[i].deploymentOverview.Pending")
Ready = jResp.IntOf("deploymentsInfo[i].deploymentOverview.Ready")
Skipped = jResp.IntOf("deploymentsInfo[i].deploymentOverview.Skipped")
Succeeded = jResp.IntOf("deploymentsInfo[i].deploymentOverview.Succeeded")
DeploymentOption = *jResp.StringOf("deploymentsInfo[i].deploymentStyle.deploymentOption")
DeploymentType = *jResp.StringOf("deploymentsInfo[i].deploymentStyle.deploymentType")
description = *jResp.StringOf("deploymentsInfo[i].description")
Code = *jResp.StringOf("deploymentsInfo[i].errorInformation.code")
Message = *jResp.StringOf("deploymentsInfo[i].errorInformation.message")
externalId = *jResp.StringOf("deploymentsInfo[i].externalId")
fileExistsBehavior = *jResp.StringOf("deploymentsInfo[i].fileExistsBehavior")
ignoreApplicationStopFailures = jResp.IntOf("deploymentsInfo[i].ignoreApplicationStopFailures")
instanceTerminationWaitTimeStarted = jResp.IntOf("deploymentsInfo[i].instanceTerminationWaitTimeStarted")
Content = *jResp.StringOf("deploymentsInfo[i].previousRevision.appSpecContent.content")
Sha256 = *jResp.StringOf("deploymentsInfo[i].previousRevision.appSpecContent.sha256")
CommitId = *jResp.StringOf("deploymentsInfo[i].previousRevision.gitHubLocation.commitId")
Repository = *jResp.StringOf("deploymentsInfo[i].previousRevision.gitHubLocation.repository")
RevisionType = *jResp.StringOf("deploymentsInfo[i].previousRevision.revisionType")
Bucket = *jResp.StringOf("deploymentsInfo[i].previousRevision.s3Location.bucket")
BundleType = *jResp.StringOf("deploymentsInfo[i].previousRevision.s3Location.bundleType")
ETag = *jResp.StringOf("deploymentsInfo[i].previousRevision.s3Location.eTag")
Key = *jResp.StringOf("deploymentsInfo[i].previousRevision.s3Location.key")
Version = *jResp.StringOf("deploymentsInfo[i].previousRevision.s3Location.version")
StringContent = *jResp.StringOf("deploymentsInfo[i].previousRevision.string.content")
StringSha256 = *jResp.StringOf("deploymentsInfo[i].previousRevision.string.sha256")
AutoUpdateOutdatedInstancesRootDeploymentId = *jResp.StringOf("deploymentsInfo[i].relatedDeployments.autoUpdateOutdatedInstancesRootDeploymentId")
AppSpecContentContent = *jResp.StringOf("deploymentsInfo[i].revision.appSpecContent.content")
AppSpecContentSha256 = *jResp.StringOf("deploymentsInfo[i].revision.appSpecContent.sha256")
GitHubLocationCommitId = *jResp.StringOf("deploymentsInfo[i].revision.gitHubLocation.commitId")
GitHubLocationRepository = *jResp.StringOf("deploymentsInfo[i].revision.gitHubLocation.repository")
revisionRevisionType = *jResp.StringOf("deploymentsInfo[i].revision.revisionType")
S3LocationBucket = *jResp.StringOf("deploymentsInfo[i].revision.s3Location.bucket")
S3LocationBundleType = *jResp.StringOf("deploymentsInfo[i].revision.s3Location.bundleType")
S3LocationETag = *jResp.StringOf("deploymentsInfo[i].revision.s3Location.eTag")
S3LocationKey = *jResp.StringOf("deploymentsInfo[i].revision.s3Location.key")
S3LocationVersion = *jResp.StringOf("deploymentsInfo[i].revision.s3Location.version")
StringContent = *jResp.StringOf("deploymentsInfo[i].revision.string.content")
StringSha256 = *jResp.StringOf("deploymentsInfo[i].revision.string.sha256")
RollbackDeploymentId = *jResp.StringOf("deploymentsInfo[i].rollbackInfo.rollbackDeploymentId")
RollbackMessage = *jResp.StringOf("deploymentsInfo[i].rollbackInfo.rollbackMessage")
RollbackTriggeringDeploymentId = *jResp.StringOf("deploymentsInfo[i].rollbackInfo.rollbackTriggeringDeploymentId")
startTime = jResp.IntOf("deploymentsInfo[i].startTime")
status = *jResp.StringOf("deploymentsInfo[i].status")
updateOutdatedInstancesOnly = jResp.IntOf("deploymentsInfo[i].updateOutdatedInstancesOnly")
j = 0
count_j = jResp.SizeOfArray("deploymentsInfo[i].autoRollbackConfiguration.events")
for j < count_j {
jResp.SetJ(j)
strVal = *jResp.StringOf("deploymentsInfo[i].autoRollbackConfiguration.events[j]")
j = j + 1
}
j = 0
count_j = jResp.SizeOfArray("deploymentsInfo[i].deploymentStatusMessages")
for j < count_j {
jResp.SetJ(j)
strVal = *jResp.StringOf("deploymentsInfo[i].deploymentStatusMessages[j]")
j = j + 1
}
j = 0
count_j = jResp.SizeOfArray("deploymentsInfo[i].loadBalancerInfo.elbInfoList")
for j < count_j {
jResp.SetJ(j)
name = *jResp.StringOf("deploymentsInfo[i].loadBalancerInfo.elbInfoList[j].name")
j = j + 1
}
j = 0
count_j = jResp.SizeOfArray("deploymentsInfo[i].loadBalancerInfo.targetGroupInfoList")
for j < count_j {
jResp.SetJ(j)
name = *jResp.StringOf("deploymentsInfo[i].loadBalancerInfo.targetGroupInfoList[j].name")
j = j + 1
}
j = 0
count_j = jResp.SizeOfArray("deploymentsInfo[i].loadBalancerInfo.targetGroupPairInfoList")
for j < count_j {
jResp.SetJ(j)
k = 0
count_k = jResp.SizeOfArray("deploymentsInfo[i].loadBalancerInfo.targetGroupPairInfoList[j].prodTrafficRoute.listenerArns")
for k < count_k {
jResp.SetK(k)
strVal = *jResp.StringOf("deploymentsInfo[i].loadBalancerInfo.targetGroupPairInfoList[j].prodTrafficRoute.listenerArns[k]")
k = k + 1
}
k = 0
count_k = jResp.SizeOfArray("deploymentsInfo[i].loadBalancerInfo.targetGroupPairInfoList[j].targetGroups")
for k < count_k {
jResp.SetK(k)
name = *jResp.StringOf("deploymentsInfo[i].loadBalancerInfo.targetGroupPairInfoList[j].targetGroups[k].name")
k = k + 1
}
k = 0
count_k = jResp.SizeOfArray("deploymentsInfo[i].loadBalancerInfo.targetGroupPairInfoList[j].testTrafficRoute.listenerArns")
for k < count_k {
jResp.SetK(k)
strVal = *jResp.StringOf("deploymentsInfo[i].loadBalancerInfo.targetGroupPairInfoList[j].testTrafficRoute.listenerArns[k]")
k = k + 1
}
j = j + 1
}
j = 0
count_j = jResp.SizeOfArray("deploymentsInfo[i].relatedDeployments.autoUpdateOutdatedInstancesDeploymentIds")
for j < count_j {
jResp.SetJ(j)
strVal = *jResp.StringOf("deploymentsInfo[i].relatedDeployments.autoUpdateOutdatedInstancesDeploymentIds[j]")
j = j + 1
}
j = 0
count_j = jResp.SizeOfArray("deploymentsInfo[i].targetInstances.autoScalingGroups")
for j < count_j {
jResp.SetJ(j)
strVal = *jResp.StringOf("deploymentsInfo[i].targetInstances.autoScalingGroups[j]")
j = j + 1
}
j = 0
count_j = jResp.SizeOfArray("deploymentsInfo[i].targetInstances.ec2TagSet.ec2TagSetList")
for j < count_j {
jResp.SetJ(j)
k = 0
count_k = jResp.SizeOfArray("deploymentsInfo[i].targetInstances.ec2TagSet.ec2TagSetList[j]")
for k < count_k {
jResp.SetK(k)
Key = *jResp.StringOf("deploymentsInfo[i].targetInstances.ec2TagSet.ec2TagSetList[j][k].Key")
v_Type = *jResp.StringOf("deploymentsInfo[i].targetInstances.ec2TagSet.ec2TagSetList[j][k].Type")
Value = *jResp.StringOf("deploymentsInfo[i].targetInstances.ec2TagSet.ec2TagSetList[j][k].Value")
k = k + 1
}
j = j + 1
}
j = 0
count_j = jResp.SizeOfArray("deploymentsInfo[i].targetInstances.tagFilters")
for j < count_j {
jResp.SetJ(j)
Key = *jResp.StringOf("deploymentsInfo[i].targetInstances.tagFilters[j].Key")
v_Type = *jResp.StringOf("deploymentsInfo[i].targetInstances.tagFilters[j].Type")
Value = *jResp.StringOf("deploymentsInfo[i].targetInstances.tagFilters[j].Value")
j = j + 1
}
i = i + 1
}
// 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
// }
// ]
// }
rest.DisposeRest()
authAws.DisposeAuthAws()
json.DisposeJsonObject()
sbRequestBody.DisposeStringBuilder()
sbResponseBody.DisposeStringBuilder()
jResp.DisposeJsonObject()