BatchGetBuilds unicodeCpp Example
#include <CkRestW.h>
#include <CkAuthAwsW.h>
#include <CkJsonObjectW.h>
#include <CkStringBuilderW.h>
void ChilkatSample(void)
{
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
CkRestW rest;
bool success;
CkAuthAwsW authAws;
authAws.put_AccessKey(L"AWS_ACCESS_KEY");
authAws.put_SecretKey(L"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.put_Region(L"us-west-2");
authAws.put_ServiceName(L"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(L"codebuild.us-west-2.amazonaws.com",443,true,true);
if (success != true) {
wprintf(L"ConnectFailReason: %d\n",rest.get_ConnectFailReason());
wprintf(L"%s\n",rest.lastErrorText());
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
CkJsonObjectW json;
json.UpdateString(L"ids[0]",L"string");
// The JSON request body created by the above code:
// {
// "ids": [
// "string"
// ]
// }
rest.AddHeader(L"Content-Type",L"application/x-amz-json-1.1");
rest.AddHeader(L"X-Amz-Target",L"CodeBuild_20161006.BatchGetBuilds");
CkStringBuilderW sbRequestBody;
json.EmitSb(sbRequestBody);
CkStringBuilderW sbResponseBody;
success = rest.FullRequestSb(L"POST",L"/",sbRequestBody,sbResponseBody);
if (success != true) {
wprintf(L"%s\n",rest.lastErrorText());
return;
}
int respStatusCode = rest.get_ResponseStatusCode();
wprintf(L"response status code = %d\n",respStatusCode);
if (respStatusCode != 200) {
wprintf(L"Response Header:\n");
wprintf(L"%s\n",rest.responseHeader());
wprintf(L"Response Body:\n");
wprintf(L"%s\n",sbResponseBody.getAsString());
return;
}
CkJsonObjectW jResp;
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
// Chilkat functions returning "const char *" return a pointer to temporary internal memory owned and managed by Chilkat.
// See this example explaining how this memory should be used: const char * functions.
const wchar_t *arn = 0;
const wchar_t *ArtifactIdentifier = 0;
const wchar_t *BucketOwnerAccess = 0;
int EncryptionDisabled;
const wchar_t *Location = 0;
const wchar_t *Md5sum = 0;
int OverrideArtifactName;
const wchar_t *Sha256sum = 0;
const wchar_t *buildBatchArn = 0;
int buildComplete;
int buildNumber;
const wchar_t *buildStatus = 0;
const wchar_t *cacheLocation = 0;
const wchar_t *v_Type = 0;
const wchar_t *currentPhase = 0;
int SessionEnabled;
const wchar_t *SessionTarget = 0;
const wchar_t *encryptionKey = 0;
int endTime;
const wchar_t *Certificate = 0;
const wchar_t *ComputeType = 0;
const wchar_t *Image = 0;
const wchar_t *ImagePullCredentialsType = 0;
int PrivilegedMode;
const wchar_t *Credential = 0;
const wchar_t *CredentialProvider = 0;
const wchar_t *environmentType = 0;
const wchar_t *id = 0;
const wchar_t *initiator = 0;
const wchar_t *GroupName = 0;
const wchar_t *Status = 0;
const wchar_t *StreamName = 0;
const wchar_t *CloudWatchLogsArn = 0;
const wchar_t *DeepLink = 0;
const wchar_t *logsGroupName = 0;
const wchar_t *S3DeepLink = 0;
const wchar_t *S3LogsBucketOwnerAccess = 0;
int S3LogsEncryptionDisabled;
const wchar_t *S3LogsLocation = 0;
const wchar_t *S3LogsStatus = 0;
const wchar_t *S3LogsArn = 0;
const wchar_t *logsStreamName = 0;
const wchar_t *NetworkInterfaceId = 0;
const wchar_t *SubnetId = 0;
const wchar_t *projectName = 0;
int queuedTimeoutInMinutes;
const wchar_t *resolvedSourceVersion = 0;
const wchar_t *serviceRole = 0;
const wchar_t *Resource = 0;
const wchar_t *AuthType = 0;
const wchar_t *Buildspec = 0;
const wchar_t *Context = 0;
const wchar_t *TargetUrl = 0;
int GitCloneDepth;
int FetchSubmodules;
int InsecureSsl;
const wchar_t *sourceLocation = 0;
int ReportBuildStatus;
const wchar_t *SourceIdentifier = 0;
const wchar_t *sourceType = 0;
const wchar_t *sourceVersion = 0;
int startTime;
int timeoutInMinutes;
const wchar_t *VpcId = 0;
int j;
int count_j;
const wchar_t *strVal = 0;
const wchar_t *name = 0;
const wchar_t *v_type = 0;
const wchar_t *value = 0;
const wchar_t *identifier = 0;
const wchar_t *location = 0;
const wchar_t *mountOptions = 0;
const wchar_t *mountPoint = 0;
int durationInSeconds;
const wchar_t *phaseStatus = 0;
const wchar_t *phaseType = 0;
int k;
int count_k;
const wchar_t *message = 0;
const wchar_t *statusCode = 0;
const wchar_t *artifactIdentifier = 0;
const wchar_t *bucketOwnerAccess = 0;
int encryptionDisabled;
const wchar_t *md5sum = 0;
int overrideArtifactName;
const wchar_t *sha256sum = 0;
const wchar_t *authResource = 0;
const wchar_t *authType = 0;
const wchar_t *buildspec = 0;
const wchar_t *buildStatusConfigContext = 0;
const wchar_t *buildStatusConfigTargetUrl = 0;
int gitCloneDepth;
int gitSubmodulesConfigFetchSubmodules;
int insecureSsl;
int reportBuildStatus;
const wchar_t *sourceIdentifier = 0;
int i = 0;
int count_i = jResp.SizeOfArray(L"builds");
while (i < count_i) {
jResp.put_I(i);
arn = jResp.stringOf(L"builds[i].arn");
ArtifactIdentifier = jResp.stringOf(L"builds[i].artifacts.artifactIdentifier");
BucketOwnerAccess = jResp.stringOf(L"builds[i].artifacts.bucketOwnerAccess");
EncryptionDisabled = jResp.IntOf(L"builds[i].artifacts.encryptionDisabled");
Location = jResp.stringOf(L"builds[i].artifacts.location");
Md5sum = jResp.stringOf(L"builds[i].artifacts.md5sum");
OverrideArtifactName = jResp.IntOf(L"builds[i].artifacts.overrideArtifactName");
Sha256sum = jResp.stringOf(L"builds[i].artifacts.sha256sum");
buildBatchArn = jResp.stringOf(L"builds[i].buildBatchArn");
buildComplete = jResp.IntOf(L"builds[i].buildComplete");
buildNumber = jResp.IntOf(L"builds[i].buildNumber");
buildStatus = jResp.stringOf(L"builds[i].buildStatus");
cacheLocation = jResp.stringOf(L"builds[i].cache.location");
v_Type = jResp.stringOf(L"builds[i].cache.type");
currentPhase = jResp.stringOf(L"builds[i].currentPhase");
SessionEnabled = jResp.IntOf(L"builds[i].debugSession.sessionEnabled");
SessionTarget = jResp.stringOf(L"builds[i].debugSession.sessionTarget");
encryptionKey = jResp.stringOf(L"builds[i].encryptionKey");
endTime = jResp.IntOf(L"builds[i].endTime");
Certificate = jResp.stringOf(L"builds[i].environment.certificate");
ComputeType = jResp.stringOf(L"builds[i].environment.computeType");
Image = jResp.stringOf(L"builds[i].environment.image");
ImagePullCredentialsType = jResp.stringOf(L"builds[i].environment.imagePullCredentialsType");
PrivilegedMode = jResp.IntOf(L"builds[i].environment.privilegedMode");
Credential = jResp.stringOf(L"builds[i].environment.registryCredential.credential");
CredentialProvider = jResp.stringOf(L"builds[i].environment.registryCredential.credentialProvider");
environmentType = jResp.stringOf(L"builds[i].environment.type");
id = jResp.stringOf(L"builds[i].id");
initiator = jResp.stringOf(L"builds[i].initiator");
GroupName = jResp.stringOf(L"builds[i].logs.cloudWatchLogs.groupName");
Status = jResp.stringOf(L"builds[i].logs.cloudWatchLogs.status");
StreamName = jResp.stringOf(L"builds[i].logs.cloudWatchLogs.streamName");
CloudWatchLogsArn = jResp.stringOf(L"builds[i].logs.cloudWatchLogsArn");
DeepLink = jResp.stringOf(L"builds[i].logs.deepLink");
logsGroupName = jResp.stringOf(L"builds[i].logs.groupName");
S3DeepLink = jResp.stringOf(L"builds[i].logs.s3DeepLink");
S3LogsBucketOwnerAccess = jResp.stringOf(L"builds[i].logs.s3Logs.bucketOwnerAccess");
S3LogsEncryptionDisabled = jResp.IntOf(L"builds[i].logs.s3Logs.encryptionDisabled");
S3LogsLocation = jResp.stringOf(L"builds[i].logs.s3Logs.location");
S3LogsStatus = jResp.stringOf(L"builds[i].logs.s3Logs.status");
S3LogsArn = jResp.stringOf(L"builds[i].logs.s3LogsArn");
logsStreamName = jResp.stringOf(L"builds[i].logs.streamName");
NetworkInterfaceId = jResp.stringOf(L"builds[i].networkInterface.networkInterfaceId");
SubnetId = jResp.stringOf(L"builds[i].networkInterface.subnetId");
projectName = jResp.stringOf(L"builds[i].projectName");
queuedTimeoutInMinutes = jResp.IntOf(L"builds[i].queuedTimeoutInMinutes");
resolvedSourceVersion = jResp.stringOf(L"builds[i].resolvedSourceVersion");
serviceRole = jResp.stringOf(L"builds[i].serviceRole");
Resource = jResp.stringOf(L"builds[i].source.auth.resource");
AuthType = jResp.stringOf(L"builds[i].source.auth.type");
Buildspec = jResp.stringOf(L"builds[i].source.buildspec");
Context = jResp.stringOf(L"builds[i].source.buildStatusConfig.context");
TargetUrl = jResp.stringOf(L"builds[i].source.buildStatusConfig.targetUrl");
GitCloneDepth = jResp.IntOf(L"builds[i].source.gitCloneDepth");
FetchSubmodules = jResp.IntOf(L"builds[i].source.gitSubmodulesConfig.fetchSubmodules");
InsecureSsl = jResp.IntOf(L"builds[i].source.insecureSsl");
sourceLocation = jResp.stringOf(L"builds[i].source.location");
ReportBuildStatus = jResp.IntOf(L"builds[i].source.reportBuildStatus");
SourceIdentifier = jResp.stringOf(L"builds[i].source.sourceIdentifier");
sourceType = jResp.stringOf(L"builds[i].source.type");
sourceVersion = jResp.stringOf(L"builds[i].sourceVersion");
startTime = jResp.IntOf(L"builds[i].startTime");
timeoutInMinutes = jResp.IntOf(L"builds[i].timeoutInMinutes");
VpcId = jResp.stringOf(L"builds[i].vpcConfig.vpcId");
j = 0;
count_j = jResp.SizeOfArray(L"builds[i].cache.modes");
while (j < count_j) {
jResp.put_J(j);
strVal = jResp.stringOf(L"builds[i].cache.modes[j]");
j = j + 1;
}
j = 0;
count_j = jResp.SizeOfArray(L"builds[i].environment.environmentVariables");
while (j < count_j) {
jResp.put_J(j);
name = jResp.stringOf(L"builds[i].environment.environmentVariables[j].name");
v_type = jResp.stringOf(L"builds[i].environment.environmentVariables[j].type");
value = jResp.stringOf(L"builds[i].environment.environmentVariables[j].value");
j = j + 1;
}
j = 0;
count_j = jResp.SizeOfArray(L"builds[i].exportedEnvironmentVariables");
while (j < count_j) {
jResp.put_J(j);
name = jResp.stringOf(L"builds[i].exportedEnvironmentVariables[j].name");
value = jResp.stringOf(L"builds[i].exportedEnvironmentVariables[j].value");
j = j + 1;
}
j = 0;
count_j = jResp.SizeOfArray(L"builds[i].fileSystemLocations");
while (j < count_j) {
jResp.put_J(j);
identifier = jResp.stringOf(L"builds[i].fileSystemLocations[j].identifier");
location = jResp.stringOf(L"builds[i].fileSystemLocations[j].location");
mountOptions = jResp.stringOf(L"builds[i].fileSystemLocations[j].mountOptions");
mountPoint = jResp.stringOf(L"builds[i].fileSystemLocations[j].mountPoint");
v_type = jResp.stringOf(L"builds[i].fileSystemLocations[j].type");
j = j + 1;
}
j = 0;
count_j = jResp.SizeOfArray(L"builds[i].phases");
while (j < count_j) {
jResp.put_J(j);
durationInSeconds = jResp.IntOf(L"builds[i].phases[j].durationInSeconds");
endTime = jResp.IntOf(L"builds[i].phases[j].endTime");
phaseStatus = jResp.stringOf(L"builds[i].phases[j].phaseStatus");
phaseType = jResp.stringOf(L"builds[i].phases[j].phaseType");
startTime = jResp.IntOf(L"builds[i].phases[j].startTime");
k = 0;
count_k = jResp.SizeOfArray(L"builds[i].phases[j].contexts");
while (k < count_k) {
jResp.put_K(k);
message = jResp.stringOf(L"builds[i].phases[j].contexts[k].message");
statusCode = jResp.stringOf(L"builds[i].phases[j].contexts[k].statusCode");
k = k + 1;
}
j = j + 1;
}
j = 0;
count_j = jResp.SizeOfArray(L"builds[i].reportArns");
while (j < count_j) {
jResp.put_J(j);
strVal = jResp.stringOf(L"builds[i].reportArns[j]");
j = j + 1;
}
j = 0;
count_j = jResp.SizeOfArray(L"builds[i].secondaryArtifacts");
while (j < count_j) {
jResp.put_J(j);
artifactIdentifier = jResp.stringOf(L"builds[i].secondaryArtifacts[j].artifactIdentifier");
bucketOwnerAccess = jResp.stringOf(L"builds[i].secondaryArtifacts[j].bucketOwnerAccess");
encryptionDisabled = jResp.IntOf(L"builds[i].secondaryArtifacts[j].encryptionDisabled");
location = jResp.stringOf(L"builds[i].secondaryArtifacts[j].location");
md5sum = jResp.stringOf(L"builds[i].secondaryArtifacts[j].md5sum");
overrideArtifactName = jResp.IntOf(L"builds[i].secondaryArtifacts[j].overrideArtifactName");
sha256sum = jResp.stringOf(L"builds[i].secondaryArtifacts[j].sha256sum");
j = j + 1;
}
j = 0;
count_j = jResp.SizeOfArray(L"builds[i].secondarySources");
while (j < count_j) {
jResp.put_J(j);
authResource = jResp.stringOf(L"builds[i].secondarySources[j].auth.resource");
authType = jResp.stringOf(L"builds[i].secondarySources[j].auth.type");
buildspec = jResp.stringOf(L"builds[i].secondarySources[j].buildspec");
buildStatusConfigContext = jResp.stringOf(L"builds[i].secondarySources[j].buildStatusConfig.context");
buildStatusConfigTargetUrl = jResp.stringOf(L"builds[i].secondarySources[j].buildStatusConfig.targetUrl");
gitCloneDepth = jResp.IntOf(L"builds[i].secondarySources[j].gitCloneDepth");
gitSubmodulesConfigFetchSubmodules = jResp.IntOf(L"builds[i].secondarySources[j].gitSubmodulesConfig.fetchSubmodules");
insecureSsl = jResp.IntOf(L"builds[i].secondarySources[j].insecureSsl");
location = jResp.stringOf(L"builds[i].secondarySources[j].location");
reportBuildStatus = jResp.IntOf(L"builds[i].secondarySources[j].reportBuildStatus");
sourceIdentifier = jResp.stringOf(L"builds[i].secondarySources[j].sourceIdentifier");
v_type = jResp.stringOf(L"builds[i].secondarySources[j].type");
j = j + 1;
}
j = 0;
count_j = jResp.SizeOfArray(L"builds[i].secondarySourceVersions");
while (j < count_j) {
jResp.put_J(j);
sourceIdentifier = jResp.stringOf(L"builds[i].secondarySourceVersions[j].sourceIdentifier");
sourceVersion = jResp.stringOf(L"builds[i].secondarySourceVersions[j].sourceVersion");
j = j + 1;
}
j = 0;
count_j = jResp.SizeOfArray(L"builds[i].vpcConfig.securityGroupIds");
while (j < count_j) {
jResp.put_J(j);
strVal = jResp.stringOf(L"builds[i].vpcConfig.securityGroupIds[j]");
j = j + 1;
}
j = 0;
count_j = jResp.SizeOfArray(L"builds[i].vpcConfig.subnets");
while (j < count_j) {
jResp.put_J(j);
strVal = jResp.stringOf(L"builds[i].vpcConfig.subnets[j]");
j = j + 1;
}
i = i + 1;
}
i = 0;
count_i = jResp.SizeOfArray(L"buildsNotFound");
while (i < count_i) {
jResp.put_I(i);
strVal = jResp.stringOf(L"buildsNotFound[i]");
i = i + 1;
}
// A sample JSON response body parsed by the above code:
// {
// "builds": [
// {
// "arn": "string",
// "artifacts": {
// "artifactIdentifier": "string",
// "bucketOwnerAccess": "string",
// "encryptionDisabled": boolean,
// "location": "string",
// "md5sum": "string",
// "overrideArtifactName": boolean,
// "sha256sum": "string"
// },
// "buildBatchArn": "string",
// "buildComplete": boolean,
// "buildNumber": number,
// "buildStatus": "string",
// "cache": {
// "location": "string",
// "modes": [
// "string"
// ],
// "type": "string"
// },
// "currentPhase": "string",
// "debugSession": {
// "sessionEnabled": boolean,
// "sessionTarget": "string"
// },
// "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"
// },
// "exportedEnvironmentVariables": [
// {
// "name": "string",
// "value": "string"
// }
// ],
// "fileSystemLocations": [
// {
// "identifier": "string",
// "location": "string",
// "mountOptions": "string",
// "mountPoint": "string",
// "type": "string"
// }
// ],
// "id": "string",
// "initiator": "string",
// "logs": {
// "cloudWatchLogs": {
// "groupName": "string",
// "status": "string",
// "streamName": "string"
// },
// "cloudWatchLogsArn": "string",
// "deepLink": "string",
// "groupName": "string",
// "s3DeepLink": "string",
// "s3Logs": {
// "bucketOwnerAccess": "string",
// "encryptionDisabled": boolean,
// "location": "string",
// "status": "string"
// },
// "s3LogsArn": "string",
// "streamName": "string"
// },
// "networkInterface": {
// "networkInterfaceId": "string",
// "subnetId": "string"
// },
// "phases": [
// {
// "contexts": [
// {
// "message": "string",
// "statusCode": "string"
// }
// ],
// "durationInSeconds": number,
// "endTime": number,
// "phaseStatus": "string",
// "phaseType": "string",
// "startTime": number
// }
// ],
// "projectName": "string",
// "queuedTimeoutInMinutes": number,
// "reportArns": [
// "string"
// ],
// "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,
// "timeoutInMinutes": number,
// "vpcConfig": {
// "securityGroupIds": [
// "string"
// ],
// "subnets": [
// "string"
// ],
// "vpcId": "string"
// }
// }
// ],
// "buildsNotFound": [
// "string"
// ]
// }
}