StopBuildBatch 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("codebuild")
// SetAuthAws causes Chilkat to automatically add the following headers: Authorization, X-Amz-Date
rest.SetAuthAws(authAws)
// URL: https://codebuild.us-west-2.amazonaws.com/
// Use the same region as specified above.
success = rest.Connect("codebuild.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("id","string")
// The JSON request body created by the above code:
// {
// "id": "string"
// }
rest.AddHeader("Content-Type","application/x-amz-json-1.1")
rest.AddHeader("X-Amz-Target","CodeBuild_20161006.StopBuildBatch")
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
strVal_DECLARATION
currentBuildSummaryArn_DECLARATION
BuildStatus_DECLARATION
Identifier_DECLARATION
PrimaryArtifactLocation_DECLARATION
PrimaryArtifactType_DECLARATION
var RequestedOn int
identifier_DECLARATION
var ignoreFailure int
var j int
var count_j int
location_DECLARATION
v_type_DECLARATION
arn_DECLARATION
buildStatus_DECLARATION
primaryArtifactIdentifier_DECLARATION
primaryArtifactLocation_DECLARATION
primaryArtifactType_DECLARATION
var requestedOn int
var k int
var count_k int
name_DECLARATION
value_DECLARATION
mountOptions_DECLARATION
mountPoint_DECLARATION
var durationInSeconds int
var endTime int
phaseStatus_DECLARATION
phaseType_DECLARATION
var startTime int
message_DECLARATION
statusCode_DECLARATION
artifactIdentifier_DECLARATION
bucketOwnerAccess_DECLARATION
var encryptionDisabled int
md5sum_DECLARATION
var overrideArtifactName int
sha256sum_DECLARATION
authResource_DECLARATION
authType_DECLARATION
buildspec_DECLARATION
buildStatusConfigContext_DECLARATION
buildStatusConfigTargetUrl_DECLARATION
var gitCloneDepth int
var gitSubmodulesConfigFetchSubmodules int
var insecureSsl int
var reportBuildStatus int
sourceIdentifier_DECLARATION
sourceVersion_DECLARATION
Arn := jResp.StringOf("buildBatch.arn")
ArtifactIdentifier := jResp.StringOf("buildBatch.artifacts.artifactIdentifier")
BucketOwnerAccess := jResp.StringOf("buildBatch.artifacts.bucketOwnerAccess")
EncryptionDisabled := jResp.IntOf("buildBatch.artifacts.encryptionDisabled")
Location := jResp.StringOf("buildBatch.artifacts.location")
Md5sum := jResp.StringOf("buildBatch.artifacts.md5sum")
OverrideArtifactName := jResp.IntOf("buildBatch.artifacts.overrideArtifactName")
Sha256sum := jResp.StringOf("buildBatch.artifacts.sha256sum")
BatchReportMode := jResp.StringOf("buildBatch.buildBatchConfig.batchReportMode")
CombineArtifacts := jResp.IntOf("buildBatch.buildBatchConfig.combineArtifacts")
MaximumBuildsAllowed := jResp.IntOf("buildBatch.buildBatchConfig.restrictions.maximumBuildsAllowed")
ServiceRole := jResp.StringOf("buildBatch.buildBatchConfig.serviceRole")
TimeoutInMins := jResp.IntOf("buildBatch.buildBatchConfig.timeoutInMins")
BuildBatchNumber := jResp.IntOf("buildBatch.buildBatchNumber")
BuildBatchStatus := jResp.StringOf("buildBatch.buildBatchStatus")
BuildTimeoutInMinutes := jResp.IntOf("buildBatch.buildTimeoutInMinutes")
CacheLocation := jResp.StringOf("buildBatch.cache.location")
v_Type := jResp.StringOf("buildBatch.cache.type")
Complete := jResp.IntOf("buildBatch.complete")
CurrentPhase := jResp.StringOf("buildBatch.currentPhase")
DebugSessionEnabled := jResp.IntOf("buildBatch.debugSessionEnabled")
EncryptionKey := jResp.StringOf("buildBatch.encryptionKey")
EndTime := jResp.IntOf("buildBatch.endTime")
Certificate := jResp.StringOf("buildBatch.environment.certificate")
ComputeType := jResp.StringOf("buildBatch.environment.computeType")
Image := jResp.StringOf("buildBatch.environment.image")
ImagePullCredentialsType := jResp.StringOf("buildBatch.environment.imagePullCredentialsType")
PrivilegedMode := jResp.IntOf("buildBatch.environment.privilegedMode")
Credential := jResp.StringOf("buildBatch.environment.registryCredential.credential")
CredentialProvider := jResp.StringOf("buildBatch.environment.registryCredential.credentialProvider")
EnvironmentType := jResp.StringOf("buildBatch.environment.type")
Id := jResp.StringOf("buildBatch.id")
Initiator := jResp.StringOf("buildBatch.initiator")
GroupName := jResp.StringOf("buildBatch.logConfig.cloudWatchLogs.groupName")
Status := jResp.StringOf("buildBatch.logConfig.cloudWatchLogs.status")
StreamName := jResp.StringOf("buildBatch.logConfig.cloudWatchLogs.streamName")
S3LogsBucketOwnerAccess := jResp.StringOf("buildBatch.logConfig.s3Logs.bucketOwnerAccess")
S3LogsEncryptionDisabled := jResp.IntOf("buildBatch.logConfig.s3Logs.encryptionDisabled")
S3LogsLocation := jResp.StringOf("buildBatch.logConfig.s3Logs.location")
S3LogsStatus := jResp.StringOf("buildBatch.logConfig.s3Logs.status")
ProjectName := jResp.StringOf("buildBatch.projectName")
QueuedTimeoutInMinutes := jResp.IntOf("buildBatch.queuedTimeoutInMinutes")
ResolvedSourceVersion := jResp.StringOf("buildBatch.resolvedSourceVersion")
buildBatchServiceRole := jResp.StringOf("buildBatch.serviceRole")
Resource := jResp.StringOf("buildBatch.source.auth.resource")
AuthType := jResp.StringOf("buildBatch.source.auth.type")
Buildspec := jResp.StringOf("buildBatch.source.buildspec")
Context := jResp.StringOf("buildBatch.source.buildStatusConfig.context")
TargetUrl := jResp.StringOf("buildBatch.source.buildStatusConfig.targetUrl")
GitCloneDepth := jResp.IntOf("buildBatch.source.gitCloneDepth")
FetchSubmodules := jResp.IntOf("buildBatch.source.gitSubmodulesConfig.fetchSubmodules")
InsecureSsl := jResp.IntOf("buildBatch.source.insecureSsl")
SourceLocation := jResp.StringOf("buildBatch.source.location")
ReportBuildStatus := jResp.IntOf("buildBatch.source.reportBuildStatus")
SourceIdentifier := jResp.StringOf("buildBatch.source.sourceIdentifier")
SourceType := jResp.StringOf("buildBatch.source.type")
SourceVersion := jResp.StringOf("buildBatch.sourceVersion")
StartTime := jResp.IntOf("buildBatch.startTime")
VpcId := jResp.StringOf("buildBatch.vpcConfig.vpcId")
i := 0
count_i := jResp.SizeOfArray("buildBatch.buildBatchConfig.restrictions.computeTypesAllowed")
for i < count_i {
jResp.SetI(i)
strVal = *jResp.StringOf("buildBatch.buildBatchConfig.restrictions.computeTypesAllowed[i]")
i = i + 1
}
i = 0
count_i = jResp.SizeOfArray("buildBatch.buildGroups")
for i < count_i {
jResp.SetI(i)
currentBuildSummaryArn = *jResp.StringOf("buildBatch.buildGroups[i].currentBuildSummary.arn")
BuildStatus = *jResp.StringOf("buildBatch.buildGroups[i].currentBuildSummary.buildStatus")
Identifier = *jResp.StringOf("buildBatch.buildGroups[i].currentBuildSummary.primaryArtifact.identifier")
PrimaryArtifactLocation = *jResp.StringOf("buildBatch.buildGroups[i].currentBuildSummary.primaryArtifact.location")
PrimaryArtifactType = *jResp.StringOf("buildBatch.buildGroups[i].currentBuildSummary.primaryArtifact.type")
RequestedOn = jResp.IntOf("buildBatch.buildGroups[i].currentBuildSummary.requestedOn")
identifier = *jResp.StringOf("buildBatch.buildGroups[i].identifier")
ignoreFailure = jResp.IntOf("buildBatch.buildGroups[i].ignoreFailure")
j = 0
count_j = jResp.SizeOfArray("buildBatch.buildGroups[i].currentBuildSummary.secondaryArtifacts")
for j < count_j {
jResp.SetJ(j)
identifier = *jResp.StringOf("buildBatch.buildGroups[i].currentBuildSummary.secondaryArtifacts[j].identifier")
location = *jResp.StringOf("buildBatch.buildGroups[i].currentBuildSummary.secondaryArtifacts[j].location")
v_type = *jResp.StringOf("buildBatch.buildGroups[i].currentBuildSummary.secondaryArtifacts[j].type")
j = j + 1
}
j = 0
count_j = jResp.SizeOfArray("buildBatch.buildGroups[i].dependsOn")
for j < count_j {
jResp.SetJ(j)
strVal = *jResp.StringOf("buildBatch.buildGroups[i].dependsOn[j]")
j = j + 1
}
j = 0
count_j = jResp.SizeOfArray("buildBatch.buildGroups[i].priorBuildSummaryList")
for j < count_j {
jResp.SetJ(j)
arn = *jResp.StringOf("buildBatch.buildGroups[i].priorBuildSummaryList[j].arn")
buildStatus = *jResp.StringOf("buildBatch.buildGroups[i].priorBuildSummaryList[j].buildStatus")
primaryArtifactIdentifier = *jResp.StringOf("buildBatch.buildGroups[i].priorBuildSummaryList[j].primaryArtifact.identifier")
primaryArtifactLocation = *jResp.StringOf("buildBatch.buildGroups[i].priorBuildSummaryList[j].primaryArtifact.location")
primaryArtifactType = *jResp.StringOf("buildBatch.buildGroups[i].priorBuildSummaryList[j].primaryArtifact.type")
requestedOn = jResp.IntOf("buildBatch.buildGroups[i].priorBuildSummaryList[j].requestedOn")
k = 0
count_k = jResp.SizeOfArray("buildBatch.buildGroups[i].priorBuildSummaryList[j].secondaryArtifacts")
for k < count_k {
jResp.SetK(k)
identifier = *jResp.StringOf("buildBatch.buildGroups[i].priorBuildSummaryList[j].secondaryArtifacts[k].identifier")
location = *jResp.StringOf("buildBatch.buildGroups[i].priorBuildSummaryList[j].secondaryArtifacts[k].location")
v_type = *jResp.StringOf("buildBatch.buildGroups[i].priorBuildSummaryList[j].secondaryArtifacts[k].type")
k = k + 1
}
j = j + 1
}
i = i + 1
}
i = 0
count_i = jResp.SizeOfArray("buildBatch.cache.modes")
for i < count_i {
jResp.SetI(i)
strVal = *jResp.StringOf("buildBatch.cache.modes[i]")
i = i + 1
}
i = 0
count_i = jResp.SizeOfArray("buildBatch.environment.environmentVariables")
for i < count_i {
jResp.SetI(i)
name = *jResp.StringOf("buildBatch.environment.environmentVariables[i].name")
v_type = *jResp.StringOf("buildBatch.environment.environmentVariables[i].type")
value = *jResp.StringOf("buildBatch.environment.environmentVariables[i].value")
i = i + 1
}
i = 0
count_i = jResp.SizeOfArray("buildBatch.fileSystemLocations")
for i < count_i {
jResp.SetI(i)
identifier = *jResp.StringOf("buildBatch.fileSystemLocations[i].identifier")
location = *jResp.StringOf("buildBatch.fileSystemLocations[i].location")
mountOptions = *jResp.StringOf("buildBatch.fileSystemLocations[i].mountOptions")
mountPoint = *jResp.StringOf("buildBatch.fileSystemLocations[i].mountPoint")
v_type = *jResp.StringOf("buildBatch.fileSystemLocations[i].type")
i = i + 1
}
i = 0
count_i = jResp.SizeOfArray("buildBatch.phases")
for i < count_i {
jResp.SetI(i)
durationInSeconds = jResp.IntOf("buildBatch.phases[i].durationInSeconds")
endTime = jResp.IntOf("buildBatch.phases[i].endTime")
phaseStatus = *jResp.StringOf("buildBatch.phases[i].phaseStatus")
phaseType = *jResp.StringOf("buildBatch.phases[i].phaseType")
startTime = jResp.IntOf("buildBatch.phases[i].startTime")
j = 0
count_j = jResp.SizeOfArray("buildBatch.phases[i].contexts")
for j < count_j {
jResp.SetJ(j)
message = *jResp.StringOf("buildBatch.phases[i].contexts[j].message")
statusCode = *jResp.StringOf("buildBatch.phases[i].contexts[j].statusCode")
j = j + 1
}
i = i + 1
}
i = 0
count_i = jResp.SizeOfArray("buildBatch.secondaryArtifacts")
for i < count_i {
jResp.SetI(i)
artifactIdentifier = *jResp.StringOf("buildBatch.secondaryArtifacts[i].artifactIdentifier")
bucketOwnerAccess = *jResp.StringOf("buildBatch.secondaryArtifacts[i].bucketOwnerAccess")
encryptionDisabled = jResp.IntOf("buildBatch.secondaryArtifacts[i].encryptionDisabled")
location = *jResp.StringOf("buildBatch.secondaryArtifacts[i].location")
md5sum = *jResp.StringOf("buildBatch.secondaryArtifacts[i].md5sum")
overrideArtifactName = jResp.IntOf("buildBatch.secondaryArtifacts[i].overrideArtifactName")
sha256sum = *jResp.StringOf("buildBatch.secondaryArtifacts[i].sha256sum")
i = i + 1
}
i = 0
count_i = jResp.SizeOfArray("buildBatch.secondarySources")
for i < count_i {
jResp.SetI(i)
authResource = *jResp.StringOf("buildBatch.secondarySources[i].auth.resource")
authType = *jResp.StringOf("buildBatch.secondarySources[i].auth.type")
buildspec = *jResp.StringOf("buildBatch.secondarySources[i].buildspec")
buildStatusConfigContext = *jResp.StringOf("buildBatch.secondarySources[i].buildStatusConfig.context")
buildStatusConfigTargetUrl = *jResp.StringOf("buildBatch.secondarySources[i].buildStatusConfig.targetUrl")
gitCloneDepth = jResp.IntOf("buildBatch.secondarySources[i].gitCloneDepth")
gitSubmodulesConfigFetchSubmodules = jResp.IntOf("buildBatch.secondarySources[i].gitSubmodulesConfig.fetchSubmodules")
insecureSsl = jResp.IntOf("buildBatch.secondarySources[i].insecureSsl")
location = *jResp.StringOf("buildBatch.secondarySources[i].location")
reportBuildStatus = jResp.IntOf("buildBatch.secondarySources[i].reportBuildStatus")
sourceIdentifier = *jResp.StringOf("buildBatch.secondarySources[i].sourceIdentifier")
v_type = *jResp.StringOf("buildBatch.secondarySources[i].type")
i = i + 1
}
i = 0
count_i = jResp.SizeOfArray("buildBatch.secondarySourceVersions")
for i < count_i {
jResp.SetI(i)
sourceIdentifier = *jResp.StringOf("buildBatch.secondarySourceVersions[i].sourceIdentifier")
sourceVersion = *jResp.StringOf("buildBatch.secondarySourceVersions[i].sourceVersion")
i = i + 1
}
i = 0
count_i = jResp.SizeOfArray("buildBatch.vpcConfig.securityGroupIds")
for i < count_i {
jResp.SetI(i)
strVal = *jResp.StringOf("buildBatch.vpcConfig.securityGroupIds[i]")
i = i + 1
}
i = 0
count_i = jResp.SizeOfArray("buildBatch.vpcConfig.subnets")
for i < count_i {
jResp.SetI(i)
strVal = *jResp.StringOf("buildBatch.vpcConfig.subnets[i]")
i = i + 1
}
// A sample JSON response body parsed by the above code:
// {
// "buildBatch": {
// "arn": "string",
// "artifacts": {
// "artifactIdentifier": "string",
// "bucketOwnerAccess": "string",
// "encryptionDisabled": boolean,
// "location": "string",
// "md5sum": "string",
// "overrideArtifactName": boolean,
// "sha256sum": "string"
// },
// "buildBatchConfig": {
// "batchReportMode": "string",
// "combineArtifacts": boolean,
// "restrictions": {
// "computeTypesAllowed": [
// "string"
// ],
// "maximumBuildsAllowed": number
// },
// "serviceRole": "string",
// "timeoutInMins": number
// },
// "buildBatchNumber": number,
// "buildBatchStatus": "string",
// "buildGroups": [
// {
// "currentBuildSummary": {
// "arn": "string",
// "buildStatus": "string",
// "primaryArtifact": {
// "identifier": "string",
// "location": "string",
// "type": "string"
// },
// "requestedOn": number,
// "secondaryArtifacts": [
// {
// "identifier": "string",
// "location": "string",
// "type": "string"
// }
// ]
// },
// "dependsOn": [
// "string"
// ],
// "identifier": "string",
// "ignoreFailure": boolean,
// "priorBuildSummaryList": [
// {
// "arn": "string",
// "buildStatus": "string",
// "primaryArtifact": {
// "identifier": "string",
// "location": "string",
// "type": "string"
// },
// "requestedOn": number,
// "secondaryArtifacts": [
// {
// "identifier": "string",
// "location": "string",
// "type": "string"
// }
// ]
// }
// ]
// }
// ],
// "buildTimeoutInMinutes": number,
// "cache": {
// "location": "string",
// "modes": [
// "string"
// ],
// "type": "string"
// },
// "complete": boolean,
// "currentPhase": "string",
// "debugSessionEnabled": boolean,
// "encryptionKey": "string",
// "endTime": number,
// "environment": {
// "certificate": "string",
// "computeType": "string",
// "environmentVariables": [
// {
// "name": "string",
// "type": "string",
// "value": "string"
// }
// ],
// "image": "string",
// "imagePullCredentialsType": "string",
// "privilegedMode": boolean,
// "registryCredential": {
// "credential": "string",
// "credentialProvider": "string"
// },
// "type": "string"
// },
// "fileSystemLocations": [
// {
// "identifier": "string",
// "location": "string",
// "mountOptions": "string",
// "mountPoint": "string",
// "type": "string"
// }
// ],
// "id": "string",
// "initiator": "string",
// "logConfig": {
// "cloudWatchLogs": {
// "groupName": "string",
// "status": "string",
// "streamName": "string"
// },
// "s3Logs": {
// "bucketOwnerAccess": "string",
// "encryptionDisabled": boolean,
// "location": "string",
// "status": "string"
// }
// },
// "phases": [
// {
// "contexts": [
// {
// "message": "string",
// "statusCode": "string"
// }
// ],
// "durationInSeconds": number,
// "endTime": number,
// "phaseStatus": "string",
// "phaseType": "string",
// "startTime": number
// }
// ],
// "projectName": "string",
// "queuedTimeoutInMinutes": number,
// "resolvedSourceVersion": "string",
// "secondaryArtifacts": [
// {
// "artifactIdentifier": "string",
// "bucketOwnerAccess": "string",
// "encryptionDisabled": boolean,
// "location": "string",
// "md5sum": "string",
// "overrideArtifactName": boolean,
// "sha256sum": "string"
// }
// ],
// "secondarySources": [
// {
// "auth": {
// "resource": "string",
// "type": "string"
// },
// "buildspec": "string",
// "buildStatusConfig": {
// "context": "string",
// "targetUrl": "string"
// },
// "gitCloneDepth": number,
// "gitSubmodulesConfig": {
// "fetchSubmodules": boolean
// },
// "insecureSsl": boolean,
// "location": "string",
// "reportBuildStatus": boolean,
// "sourceIdentifier": "string",
// "type": "string"
// }
// ],
// "secondarySourceVersions": [
// {
// "sourceIdentifier": "string",
// "sourceVersion": "string"
// }
// ],
// "serviceRole": "string",
// "source": {
// "auth": {
// "resource": "string",
// "type": "string"
// },
// "buildspec": "string",
// "buildStatusConfig": {
// "context": "string",
// "targetUrl": "string"
// },
// "gitCloneDepth": number,
// "gitSubmodulesConfig": {
// "fetchSubmodules": boolean
// },
// "insecureSsl": boolean,
// "location": "string",
// "reportBuildStatus": boolean,
// "sourceIdentifier": "string",
// "type": "string"
// },
// "sourceVersion": "string",
// "startTime": number,
// "vpcConfig": {
// "securityGroupIds": [
// "string"
// ],
// "subnets": [
// "string"
// ],
// "vpcId": "string"
// }
// }
// }
rest.DisposeRest()
authAws.DisposeAuthAws()
json.DisposeJsonObject()
sbRequestBody.DisposeStringBuilder()
sbResponseBody.DisposeStringBuilder()
jResp.DisposeJsonObject()