RegisterJobDefinition Unicode C++ 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"batch");
// SetAuthAws causes Chilkat to automatically add the following headers: Authorization, X-Amz-Date
rest.SetAuthAws(authAws);
// URL: https://batch.us-west-2.amazonaws.com/
// Use the same region as specified above.
success = rest.Connect(L"batch.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"containerProperties.command[0]",L"string");
json.UpdateString(L"containerProperties.environment[0].name",L"string");
json.UpdateString(L"containerProperties.environment[0].value",L"string");
json.UpdateString(L"containerProperties.executionRoleArn",L"string");
json.UpdateString(L"containerProperties.fargatePlatformConfiguration.platformVersion",L"string");
json.UpdateString(L"containerProperties.image",L"string");
json.UpdateString(L"containerProperties.instanceType",L"string");
json.UpdateString(L"containerProperties.jobRoleArn",L"string");
json.UpdateString(L"containerProperties.linuxParameters.devices[0].containerPath",L"string");
json.UpdateString(L"containerProperties.linuxParameters.devices[0].hostPath",L"string");
json.UpdateString(L"containerProperties.linuxParameters.devices[0].permissions[0]",L"string");
json.UpdateInt(L"containerProperties.linuxParameters.initProcessEnabled",123);
json.UpdateInt(L"containerProperties.linuxParameters.maxSwap",123);
json.UpdateInt(L"containerProperties.linuxParameters.sharedMemorySize",123);
json.UpdateInt(L"containerProperties.linuxParameters.swappiness",123);
json.UpdateString(L"containerProperties.linuxParameters.tmpfs[0].containerPath",L"string");
json.UpdateString(L"containerProperties.linuxParameters.tmpfs[0].mountOptions[0]",L"string");
json.UpdateInt(L"containerProperties.linuxParameters.tmpfs[0].size",123);
json.UpdateString(L"containerProperties.logConfiguration.logDriver",L"string");
json.UpdateString(L"containerProperties.logConfiguration.options.string",L"string");
json.UpdateString(L"containerProperties.logConfiguration.secretOptions[0].name",L"string");
json.UpdateString(L"containerProperties.logConfiguration.secretOptions[0].valueFrom",L"string");
json.UpdateInt(L"containerProperties.memory",123);
json.UpdateString(L"containerProperties.mountPoints[0].containerPath",L"string");
json.UpdateInt(L"containerProperties.mountPoints[0].readOnly",123);
json.UpdateString(L"containerProperties.mountPoints[0].sourceVolume",L"string");
json.UpdateString(L"containerProperties.networkConfiguration.assignPublicIp",L"string");
json.UpdateInt(L"containerProperties.privileged",123);
json.UpdateInt(L"containerProperties.readonlyRootFilesystem",123);
json.UpdateString(L"containerProperties.resourceRequirements[0].type",L"string");
json.UpdateString(L"containerProperties.resourceRequirements[0].value",L"string");
json.UpdateString(L"containerProperties.secrets[0].name",L"string");
json.UpdateString(L"containerProperties.secrets[0].valueFrom",L"string");
json.UpdateInt(L"containerProperties.ulimits[0].hardLimit",123);
json.UpdateString(L"containerProperties.ulimits[0].name",L"string");
json.UpdateInt(L"containerProperties.ulimits[0].softLimit",123);
json.UpdateString(L"containerProperties.user",L"string");
json.UpdateInt(L"containerProperties.vcpus",123);
json.UpdateString(L"containerProperties.volumes[0].efsVolumeConfiguration.authorizationConfig.accessPointId",L"string");
json.UpdateString(L"containerProperties.volumes[0].efsVolumeConfiguration.authorizationConfig.iam",L"string");
json.UpdateString(L"containerProperties.volumes[0].efsVolumeConfiguration.fileSystemId",L"string");
json.UpdateString(L"containerProperties.volumes[0].efsVolumeConfiguration.rootDirectory",L"string");
json.UpdateString(L"containerProperties.volumes[0].efsVolumeConfiguration.transitEncryption",L"string");
json.UpdateInt(L"containerProperties.volumes[0].efsVolumeConfiguration.transitEncryptionPort",123);
json.UpdateString(L"containerProperties.volumes[0].host.sourcePath",L"string");
json.UpdateString(L"containerProperties.volumes[0].name",L"string");
json.UpdateString(L"jobDefinitionName",L"string");
json.UpdateInt(L"nodeProperties.mainNode",123);
json.UpdateString(L"nodeProperties.nodeRangeProperties[0].container.command[0]",L"string");
json.UpdateString(L"nodeProperties.nodeRangeProperties[0].container.environment[0].name",L"string");
json.UpdateString(L"nodeProperties.nodeRangeProperties[0].container.environment[0].value",L"string");
json.UpdateString(L"nodeProperties.nodeRangeProperties[0].container.executionRoleArn",L"string");
json.UpdateString(L"nodeProperties.nodeRangeProperties[0].container.fargatePlatformConfiguration.platformVersion",L"string");
json.UpdateString(L"nodeProperties.nodeRangeProperties[0].container.image",L"string");
json.UpdateString(L"nodeProperties.nodeRangeProperties[0].container.instanceType",L"string");
json.UpdateString(L"nodeProperties.nodeRangeProperties[0].container.jobRoleArn",L"string");
json.UpdateString(L"nodeProperties.nodeRangeProperties[0].container.linuxParameters.devices[0].containerPath",L"string");
json.UpdateString(L"nodeProperties.nodeRangeProperties[0].container.linuxParameters.devices[0].hostPath",L"string");
json.UpdateString(L"nodeProperties.nodeRangeProperties[0].container.linuxParameters.devices[0].permissions[0]",L"string");
json.UpdateInt(L"nodeProperties.nodeRangeProperties[0].container.linuxParameters.initProcessEnabled",123);
json.UpdateInt(L"nodeProperties.nodeRangeProperties[0].container.linuxParameters.maxSwap",123);
json.UpdateInt(L"nodeProperties.nodeRangeProperties[0].container.linuxParameters.sharedMemorySize",123);
json.UpdateInt(L"nodeProperties.nodeRangeProperties[0].container.linuxParameters.swappiness",123);
json.UpdateString(L"nodeProperties.nodeRangeProperties[0].container.linuxParameters.tmpfs[0].containerPath",L"string");
json.UpdateString(L"nodeProperties.nodeRangeProperties[0].container.linuxParameters.tmpfs[0].mountOptions[0]",L"string");
json.UpdateInt(L"nodeProperties.nodeRangeProperties[0].container.linuxParameters.tmpfs[0].size",123);
json.UpdateString(L"nodeProperties.nodeRangeProperties[0].container.logConfiguration.logDriver",L"string");
json.UpdateString(L"nodeProperties.nodeRangeProperties[0].container.logConfiguration.options.string",L"string");
json.UpdateString(L"nodeProperties.nodeRangeProperties[0].container.logConfiguration.secretOptions[0].name",L"string");
json.UpdateString(L"nodeProperties.nodeRangeProperties[0].container.logConfiguration.secretOptions[0].valueFrom",L"string");
json.UpdateInt(L"nodeProperties.nodeRangeProperties[0].container.memory",123);
json.UpdateString(L"nodeProperties.nodeRangeProperties[0].container.mountPoints[0].containerPath",L"string");
json.UpdateInt(L"nodeProperties.nodeRangeProperties[0].container.mountPoints[0].readOnly",123);
json.UpdateString(L"nodeProperties.nodeRangeProperties[0].container.mountPoints[0].sourceVolume",L"string");
json.UpdateString(L"nodeProperties.nodeRangeProperties[0].container.networkConfiguration.assignPublicIp",L"string");
json.UpdateInt(L"nodeProperties.nodeRangeProperties[0].container.privileged",123);
json.UpdateInt(L"nodeProperties.nodeRangeProperties[0].container.readonlyRootFilesystem",123);
json.UpdateString(L"nodeProperties.nodeRangeProperties[0].container.resourceRequirements[0].type",L"string");
json.UpdateString(L"nodeProperties.nodeRangeProperties[0].container.resourceRequirements[0].value",L"string");
json.UpdateString(L"nodeProperties.nodeRangeProperties[0].container.secrets[0].name",L"string");
json.UpdateString(L"nodeProperties.nodeRangeProperties[0].container.secrets[0].valueFrom",L"string");
json.UpdateInt(L"nodeProperties.nodeRangeProperties[0].container.ulimits[0].hardLimit",123);
json.UpdateString(L"nodeProperties.nodeRangeProperties[0].container.ulimits[0].name",L"string");
json.UpdateInt(L"nodeProperties.nodeRangeProperties[0].container.ulimits[0].softLimit",123);
json.UpdateString(L"nodeProperties.nodeRangeProperties[0].container.user",L"string");
json.UpdateInt(L"nodeProperties.nodeRangeProperties[0].container.vcpus",123);
json.UpdateString(L"nodeProperties.nodeRangeProperties[0].container.volumes[0].efsVolumeConfiguration.authorizationConfig.accessPointId",L"string");
json.UpdateString(L"nodeProperties.nodeRangeProperties[0].container.volumes[0].efsVolumeConfiguration.authorizationConfig.iam",L"string");
json.UpdateString(L"nodeProperties.nodeRangeProperties[0].container.volumes[0].efsVolumeConfiguration.fileSystemId",L"string");
json.UpdateString(L"nodeProperties.nodeRangeProperties[0].container.volumes[0].efsVolumeConfiguration.rootDirectory",L"string");
json.UpdateString(L"nodeProperties.nodeRangeProperties[0].container.volumes[0].efsVolumeConfiguration.transitEncryption",L"string");
json.UpdateInt(L"nodeProperties.nodeRangeProperties[0].container.volumes[0].efsVolumeConfiguration.transitEncryptionPort",123);
json.UpdateString(L"nodeProperties.nodeRangeProperties[0].container.volumes[0].host.sourcePath",L"string");
json.UpdateString(L"nodeProperties.nodeRangeProperties[0].container.volumes[0].name",L"string");
json.UpdateString(L"nodeProperties.nodeRangeProperties[0].targetNodes",L"string");
json.UpdateInt(L"nodeProperties.numNodes",123);
json.UpdateString(L"parameters.string",L"string");
json.UpdateString(L"platformCapabilities[0]",L"string");
json.UpdateInt(L"propagateTags",123);
json.UpdateInt(L"retryStrategy.attempts",123);
json.UpdateString(L"retryStrategy.evaluateOnExit[0].action",L"string");
json.UpdateString(L"retryStrategy.evaluateOnExit[0].onExitCode",L"string");
json.UpdateString(L"retryStrategy.evaluateOnExit[0].onReason",L"string");
json.UpdateString(L"retryStrategy.evaluateOnExit[0].onStatusReason",L"string");
json.UpdateInt(L"schedulingPriority",123);
json.UpdateString(L"tags.string",L"string");
json.UpdateInt(L"timeout.attemptDurationSeconds",123);
json.UpdateString(L"type",L"string");
// The JSON request body created by the above code:
// {
// "containerProperties": {
// "command": [
// "string"
// ],
// "environment": [
// {
// "name": "string",
// "value": "string"
// }
// ],
// "executionRoleArn": "string",
// "fargatePlatformConfiguration": {
// "platformVersion": "string"
// },
// "image": "string",
// "instanceType": "string",
// "jobRoleArn": "string",
// "linuxParameters": {
// "devices": [
// {
// "containerPath": "string",
// "hostPath": "string",
// "permissions": [
// "string"
// ]
// }
// ],
// "initProcessEnabled": boolean,
// "maxSwap": number,
// "sharedMemorySize": number,
// "swappiness": number,
// "tmpfs": [
// {
// "containerPath": "string",
// "mountOptions": [
// "string"
// ],
// "size": number
// }
// ]
// },
// "logConfiguration": {
// "logDriver": "string",
// "options": {
// "string": "string"
// },
// "secretOptions": [
// {
// "name": "string",
// "valueFrom": "string"
// }
// ]
// },
// "memory": number,
// "mountPoints": [
// {
// "containerPath": "string",
// "readOnly": boolean,
// "sourceVolume": "string"
// }
// ],
// "networkConfiguration": {
// "assignPublicIp": "string"
// },
// "privileged": boolean,
// "readonlyRootFilesystem": boolean,
// "resourceRequirements": [
// {
// "type": "string",
// "value": "string"
// }
// ],
// "secrets": [
// {
// "name": "string",
// "valueFrom": "string"
// }
// ],
// "ulimits": [
// {
// "hardLimit": number,
// "name": "string",
// "softLimit": number
// }
// ],
// "user": "string",
// "vcpus": number,
// "volumes": [
// {
// "efsVolumeConfiguration": {
// "authorizationConfig": {
// "accessPointId": "string",
// "iam": "string"
// },
// "fileSystemId": "string",
// "rootDirectory": "string",
// "transitEncryption": "string",
// "transitEncryptionPort": number
// },
// "host": {
// "sourcePath": "string"
// },
// "name": "string"
// }
// ]
// },
// "jobDefinitionName": "string",
// "nodeProperties": {
// "mainNode": number,
// "nodeRangeProperties": [
// {
// "container": {
// "command": [
// "string"
// ],
// "environment": [
// {
// "name": "string",
// "value": "string"
// }
// ],
// "executionRoleArn": "string",
// "fargatePlatformConfiguration": {
// "platformVersion": "string"
// },
// "image": "string",
// "instanceType": "string",
// "jobRoleArn": "string",
// "linuxParameters": {
// "devices": [
// {
// "containerPath": "string",
// "hostPath": "string",
// "permissions": [
// "string"
// ]
// }
// ],
// "initProcessEnabled": boolean,
// "maxSwap": number,
// "sharedMemorySize": number,
// "swappiness": number,
// "tmpfs": [
// {
// "containerPath": "string",
// "mountOptions": [
// "string"
// ],
// "size": number
// }
// ]
// },
// "logConfiguration": {
// "logDriver": "string",
// "options": {
// "string": "string"
// },
// "secretOptions": [
// {
// "name": "string",
// "valueFrom": "string"
// }
// ]
// },
// "memory": number,
// "mountPoints": [
// {
// "containerPath": "string",
// "readOnly": boolean,
// "sourceVolume": "string"
// }
// ],
// "networkConfiguration": {
// "assignPublicIp": "string"
// },
// "privileged": boolean,
// "readonlyRootFilesystem": boolean,
// "resourceRequirements": [
// {
// "type": "string",
// "value": "string"
// }
// ],
// "secrets": [
// {
// "name": "string",
// "valueFrom": "string"
// }
// ],
// "ulimits": [
// {
// "hardLimit": number,
// "name": "string",
// "softLimit": number
// }
// ],
// "user": "string",
// "vcpus": number,
// "volumes": [
// {
// "efsVolumeConfiguration": {
// "authorizationConfig": {
// "accessPointId": "string",
// "iam": "string"
// },
// "fileSystemId": "string",
// "rootDirectory": "string",
// "transitEncryption": "string",
// "transitEncryptionPort": number
// },
// "host": {
// "sourcePath": "string"
// },
// "name": "string"
// }
// ]
// },
// "targetNodes": "string"
// }
// ],
// "numNodes": number
// },
// "parameters": {
// "string": "string"
// },
// "platformCapabilities": [
// "string"
// ],
// "propagateTags": boolean,
// "retryStrategy": {
// "attempts": number,
// "evaluateOnExit": [
// {
// "action": "string",
// "onExitCode": "string",
// "onReason": "string",
// "onStatusReason": "string"
// }
// ]
// },
// "schedulingPriority": number,
// "tags": {
// "string": "string"
// },
// "timeout": {
// "attemptDurationSeconds": number
// },
// "type": "string"
// }
rest.AddHeader(L"Content-Type",L"application/x-amz-json-1.1");
rest.AddHeader(L"X-Amz-Target",L"RegisterJobDefinition");
CkStringBuilderW sbRequestBody;
json.EmitSb(sbRequestBody);
CkStringBuilderW sbResponseBody;
success = rest.FullRequestSb(L"POST",L"/v1/registerjobdefinition",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 *jobDefinitionArn = jResp.stringOf(L"jobDefinitionArn");
const wchar_t *jobDefinitionName = jResp.stringOf(L"jobDefinitionName");
int revision = jResp.IntOf(L"revision");
// A sample JSON response body parsed by the above code:
// {
// "jobDefinitionArn": "string",
// "jobDefinitionName": "string",
// "revision": number
// }
}