ScheduleRun unicodeC Example
#include <C_CkRestW.h>
#include <C_CkAuthAwsW.h>
#include <C_CkJsonObjectW.h>
#include <C_CkStringBuilderW.h>
void ChilkatSample(void)
{
HCkRestW rest;
BOOL success;
HCkAuthAwsW authAws;
HCkJsonObjectW json;
HCkStringBuilderW sbRequestBody;
HCkStringBuilderW sbResponseBody;
int respStatusCode;
HCkJsonObjectW jResp;
const wchar_t *strVal;
const wchar_t *attribute;
const wchar_t *operator;
int j;
int count_j;
const wchar_t *AppUpload;
const wchar_t *Arn;
const wchar_t *BillingMethod;
int CompletedJobs;
int Errored;
int Failed;
int Passed;
int Skipped;
int Stopped;
int Total;
int Warned;
int Created;
int Metered;
int DeviceMinutesTotal;
int Unmetered;
const wchar_t *DevicePoolArn;
int MatchedDevicesCount;
int MaxDevices;
int EventCount;
int JobTimeoutMinutes;
const wchar_t *Locale;
int Latitude;
int Longitude;
const wchar_t *Message;
const wchar_t *Name;
const wchar_t *NetworkProfileArn;
const wchar_t *Description;
int DownlinkBandwidthBits;
int DownlinkDelayMs;
int DownlinkJitterMs;
int DownlinkLossPercent;
const wchar_t *NetworkProfileName;
const wchar_t *v_Type;
int UplinkBandwidthBits;
int UplinkDelayMs;
int UplinkJitterMs;
int UplinkLossPercent;
const wchar_t *ParsingResultUrl;
const wchar_t *Platform;
int Bluetooth;
int Gps;
int Nfc;
int Wifi;
const wchar_t *Result;
const wchar_t *ResultCode;
int Seed;
int SkipAppResign;
int Started;
const wchar_t *Status;
int runStopped;
const wchar_t *TestSpecArn;
int TotalJobs;
const wchar_t *runType;
const wchar_t *WebUrl;
int i;
int count_i;
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
rest = CkRestW_Create();
authAws = CkAuthAwsW_Create();
CkAuthAwsW_putAccessKey(authAws,L"AWS_ACCESS_KEY");
CkAuthAwsW_putSecretKey(authAws,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.)
CkAuthAwsW_putRegion(authAws,L"us-west-2");
CkAuthAwsW_putServiceName(authAws,L"devicefarm");
// SetAuthAws causes Chilkat to automatically add the following headers: Authorization, X-Amz-Date
CkRestW_SetAuthAws(rest,authAws);
// URL: https://devicefarm.us-west-2.amazonaws.com/
// Use the same region as specified above.
success = CkRestW_Connect(rest,L"devicefarm.us-west-2.amazonaws.com",443,TRUE,TRUE);
if (success != TRUE) {
wprintf(L"ConnectFailReason: %d\n",CkRestW_getConnectFailReason(rest));
wprintf(L"%s\n",CkRestW_lastErrorText(rest));
CkRestW_Dispose(rest);
CkAuthAwsW_Dispose(authAws);
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 = CkJsonObjectW_Create();
CkJsonObjectW_UpdateString(json,L"appArn",L"string");
CkJsonObjectW_UpdateString(json,L"configuration.auxiliaryApps[0]",L"string");
CkJsonObjectW_UpdateString(json,L"configuration.billingMethod",L"string");
CkJsonObjectW_UpdateString(json,L"configuration.customerArtifactPaths.androidPaths[0]",L"string");
CkJsonObjectW_UpdateString(json,L"configuration.customerArtifactPaths.deviceHostPaths[0]",L"string");
CkJsonObjectW_UpdateString(json,L"configuration.customerArtifactPaths.iosPaths[0]",L"string");
CkJsonObjectW_UpdateString(json,L"configuration.extraDataPackageArn",L"string");
CkJsonObjectW_UpdateString(json,L"configuration.locale",L"string");
CkJsonObjectW_UpdateInt(json,L"configuration.location.latitude",123);
CkJsonObjectW_UpdateInt(json,L"configuration.location.longitude",123);
CkJsonObjectW_UpdateString(json,L"configuration.networkProfileArn",L"string");
CkJsonObjectW_UpdateInt(json,L"configuration.radios.bluetooth",123);
CkJsonObjectW_UpdateInt(json,L"configuration.radios.gps",123);
CkJsonObjectW_UpdateInt(json,L"configuration.radios.nfc",123);
CkJsonObjectW_UpdateInt(json,L"configuration.radios.wifi",123);
CkJsonObjectW_UpdateString(json,L"configuration.vpceConfigurationArns[0]",L"string");
CkJsonObjectW_UpdateString(json,L"devicePoolArn",L"string");
CkJsonObjectW_UpdateString(json,L"deviceSelectionConfiguration.filters[0].attribute",L"string");
CkJsonObjectW_UpdateString(json,L"deviceSelectionConfiguration.filters[0].operator",L"string");
CkJsonObjectW_UpdateString(json,L"deviceSelectionConfiguration.filters[0].values[0]",L"string");
CkJsonObjectW_UpdateInt(json,L"deviceSelectionConfiguration.maxDevices",123);
CkJsonObjectW_UpdateInt(json,L"executionConfiguration.accountsCleanup",123);
CkJsonObjectW_UpdateInt(json,L"executionConfiguration.appPackagesCleanup",123);
CkJsonObjectW_UpdateInt(json,L"executionConfiguration.jobTimeoutMinutes",123);
CkJsonObjectW_UpdateInt(json,L"executionConfiguration.skipAppResign",123);
CkJsonObjectW_UpdateInt(json,L"executionConfiguration.videoCapture",123);
CkJsonObjectW_UpdateString(json,L"name",L"string");
CkJsonObjectW_UpdateString(json,L"projectArn",L"string");
CkJsonObjectW_UpdateString(json,L"test.filter",L"string");
CkJsonObjectW_UpdateString(json,L"test.parameters.string",L"string");
CkJsonObjectW_UpdateString(json,L"test.testPackageArn",L"string");
CkJsonObjectW_UpdateString(json,L"test.testSpecArn",L"string");
CkJsonObjectW_UpdateString(json,L"test.type",L"string");
// The JSON request body created by the above code:
// {
// "appArn": "string",
// "configuration": {
// "auxiliaryApps": [
// "string"
// ],
// "billingMethod": "string",
// "customerArtifactPaths": {
// "androidPaths": [
// "string"
// ],
// "deviceHostPaths": [
// "string"
// ],
// "iosPaths": [
// "string"
// ]
// },
// "extraDataPackageArn": "string",
// "locale": "string",
// "location": {
// "latitude": number,
// "longitude": number
// },
// "networkProfileArn": "string",
// "radios": {
// "bluetooth": boolean,
// "gps": boolean,
// "nfc": boolean,
// "wifi": boolean
// },
// "vpceConfigurationArns": [
// "string"
// ]
// },
// "devicePoolArn": "string",
// "deviceSelectionConfiguration": {
// "filters": [
// {
// "attribute": "string",
// "operator": "string",
// "values": [
// "string"
// ]
// }
// ],
// "maxDevices": number
// },
// "executionConfiguration": {
// "accountsCleanup": boolean,
// "appPackagesCleanup": boolean,
// "jobTimeoutMinutes": number,
// "skipAppResign": boolean,
// "videoCapture": boolean
// },
// "name": "string",
// "projectArn": "string",
// "test": {
// "filter": "string",
// "parameters": {
// "string": "string"
// },
// "testPackageArn": "string",
// "testSpecArn": "string",
// "type": "string"
// }
// }
CkRestW_AddHeader(rest,L"Content-Type",L"application/x-amz-json-1.1");
CkRestW_AddHeader(rest,L"X-Amz-Target",L"DeviceFarm_20150623.ScheduleRun");
sbRequestBody = CkStringBuilderW_Create();
CkJsonObjectW_EmitSb(json,sbRequestBody);
sbResponseBody = CkStringBuilderW_Create();
success = CkRestW_FullRequestSb(rest,L"POST",L"/",sbRequestBody,sbResponseBody);
if (success != TRUE) {
wprintf(L"%s\n",CkRestW_lastErrorText(rest));
CkRestW_Dispose(rest);
CkAuthAwsW_Dispose(authAws);
CkJsonObjectW_Dispose(json);
CkStringBuilderW_Dispose(sbRequestBody);
CkStringBuilderW_Dispose(sbResponseBody);
return;
}
respStatusCode = CkRestW_getResponseStatusCode(rest);
wprintf(L"response status code = %d\n",respStatusCode);
if (respStatusCode != 200) {
wprintf(L"Response Header:\n");
wprintf(L"%s\n",CkRestW_responseHeader(rest));
wprintf(L"Response Body:\n");
wprintf(L"%s\n",CkStringBuilderW_getAsString(sbResponseBody));
CkRestW_Dispose(rest);
CkAuthAwsW_Dispose(authAws);
CkJsonObjectW_Dispose(json);
CkStringBuilderW_Dispose(sbRequestBody);
CkStringBuilderW_Dispose(sbResponseBody);
return;
}
jResp = CkJsonObjectW_Create();
CkJsonObjectW_LoadSb(jResp,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.
AppUpload = CkJsonObjectW_stringOf(jResp,L"run.appUpload");
Arn = CkJsonObjectW_stringOf(jResp,L"run.arn");
BillingMethod = CkJsonObjectW_stringOf(jResp,L"run.billingMethod");
CompletedJobs = CkJsonObjectW_IntOf(jResp,L"run.completedJobs");
Errored = CkJsonObjectW_IntOf(jResp,L"run.counters.errored");
Failed = CkJsonObjectW_IntOf(jResp,L"run.counters.failed");
Passed = CkJsonObjectW_IntOf(jResp,L"run.counters.passed");
Skipped = CkJsonObjectW_IntOf(jResp,L"run.counters.skipped");
Stopped = CkJsonObjectW_IntOf(jResp,L"run.counters.stopped");
Total = CkJsonObjectW_IntOf(jResp,L"run.counters.total");
Warned = CkJsonObjectW_IntOf(jResp,L"run.counters.warned");
Created = CkJsonObjectW_IntOf(jResp,L"run.created");
Metered = CkJsonObjectW_IntOf(jResp,L"run.deviceMinutes.metered");
DeviceMinutesTotal = CkJsonObjectW_IntOf(jResp,L"run.deviceMinutes.total");
Unmetered = CkJsonObjectW_IntOf(jResp,L"run.deviceMinutes.unmetered");
DevicePoolArn = CkJsonObjectW_stringOf(jResp,L"run.devicePoolArn");
MatchedDevicesCount = CkJsonObjectW_IntOf(jResp,L"run.deviceSelectionResult.matchedDevicesCount");
MaxDevices = CkJsonObjectW_IntOf(jResp,L"run.deviceSelectionResult.maxDevices");
EventCount = CkJsonObjectW_IntOf(jResp,L"run.eventCount");
JobTimeoutMinutes = CkJsonObjectW_IntOf(jResp,L"run.jobTimeoutMinutes");
Locale = CkJsonObjectW_stringOf(jResp,L"run.locale");
Latitude = CkJsonObjectW_IntOf(jResp,L"run.location.latitude");
Longitude = CkJsonObjectW_IntOf(jResp,L"run.location.longitude");
Message = CkJsonObjectW_stringOf(jResp,L"run.message");
Name = CkJsonObjectW_stringOf(jResp,L"run.name");
NetworkProfileArn = CkJsonObjectW_stringOf(jResp,L"run.networkProfile.arn");
Description = CkJsonObjectW_stringOf(jResp,L"run.networkProfile.description");
DownlinkBandwidthBits = CkJsonObjectW_IntOf(jResp,L"run.networkProfile.downlinkBandwidthBits");
DownlinkDelayMs = CkJsonObjectW_IntOf(jResp,L"run.networkProfile.downlinkDelayMs");
DownlinkJitterMs = CkJsonObjectW_IntOf(jResp,L"run.networkProfile.downlinkJitterMs");
DownlinkLossPercent = CkJsonObjectW_IntOf(jResp,L"run.networkProfile.downlinkLossPercent");
NetworkProfileName = CkJsonObjectW_stringOf(jResp,L"run.networkProfile.name");
v_Type = CkJsonObjectW_stringOf(jResp,L"run.networkProfile.type");
UplinkBandwidthBits = CkJsonObjectW_IntOf(jResp,L"run.networkProfile.uplinkBandwidthBits");
UplinkDelayMs = CkJsonObjectW_IntOf(jResp,L"run.networkProfile.uplinkDelayMs");
UplinkJitterMs = CkJsonObjectW_IntOf(jResp,L"run.networkProfile.uplinkJitterMs");
UplinkLossPercent = CkJsonObjectW_IntOf(jResp,L"run.networkProfile.uplinkLossPercent");
ParsingResultUrl = CkJsonObjectW_stringOf(jResp,L"run.parsingResultUrl");
Platform = CkJsonObjectW_stringOf(jResp,L"run.platform");
Bluetooth = CkJsonObjectW_IntOf(jResp,L"run.radios.bluetooth");
Gps = CkJsonObjectW_IntOf(jResp,L"run.radios.gps");
Nfc = CkJsonObjectW_IntOf(jResp,L"run.radios.nfc");
Wifi = CkJsonObjectW_IntOf(jResp,L"run.radios.wifi");
Result = CkJsonObjectW_stringOf(jResp,L"run.result");
ResultCode = CkJsonObjectW_stringOf(jResp,L"run.resultCode");
Seed = CkJsonObjectW_IntOf(jResp,L"run.seed");
SkipAppResign = CkJsonObjectW_IntOf(jResp,L"run.skipAppResign");
Started = CkJsonObjectW_IntOf(jResp,L"run.started");
Status = CkJsonObjectW_stringOf(jResp,L"run.status");
runStopped = CkJsonObjectW_IntOf(jResp,L"run.stopped");
TestSpecArn = CkJsonObjectW_stringOf(jResp,L"run.testSpecArn");
TotalJobs = CkJsonObjectW_IntOf(jResp,L"run.totalJobs");
runType = CkJsonObjectW_stringOf(jResp,L"run.type");
WebUrl = CkJsonObjectW_stringOf(jResp,L"run.webUrl");
i = 0;
count_i = CkJsonObjectW_SizeOfArray(jResp,L"run.customerArtifactPaths.androidPaths");
while (i < count_i) {
CkJsonObjectW_putI(jResp,i);
strVal = CkJsonObjectW_stringOf(jResp,L"run.customerArtifactPaths.androidPaths[i]");
i = i + 1;
}
i = 0;
count_i = CkJsonObjectW_SizeOfArray(jResp,L"run.customerArtifactPaths.deviceHostPaths");
while (i < count_i) {
CkJsonObjectW_putI(jResp,i);
strVal = CkJsonObjectW_stringOf(jResp,L"run.customerArtifactPaths.deviceHostPaths[i]");
i = i + 1;
}
i = 0;
count_i = CkJsonObjectW_SizeOfArray(jResp,L"run.customerArtifactPaths.iosPaths");
while (i < count_i) {
CkJsonObjectW_putI(jResp,i);
strVal = CkJsonObjectW_stringOf(jResp,L"run.customerArtifactPaths.iosPaths[i]");
i = i + 1;
}
i = 0;
count_i = CkJsonObjectW_SizeOfArray(jResp,L"run.deviceSelectionResult.filters");
while (i < count_i) {
CkJsonObjectW_putI(jResp,i);
attribute = CkJsonObjectW_stringOf(jResp,L"run.deviceSelectionResult.filters[i].attribute");
operator = CkJsonObjectW_stringOf(jResp,L"run.deviceSelectionResult.filters[i].operator");
j = 0;
count_j = CkJsonObjectW_SizeOfArray(jResp,L"run.deviceSelectionResult.filters[i].values");
while (j < count_j) {
CkJsonObjectW_putJ(jResp,j);
strVal = CkJsonObjectW_stringOf(jResp,L"run.deviceSelectionResult.filters[i].values[j]");
j = j + 1;
}
i = i + 1;
}
// A sample JSON response body parsed by the above code:
// {
// "run": {
// "appUpload": "string",
// "arn": "string",
// "billingMethod": "string",
// "completedJobs": number,
// "counters": {
// "errored": number,
// "failed": number,
// "passed": number,
// "skipped": number,
// "stopped": number,
// "total": number,
// "warned": number
// },
// "created": number,
// "customerArtifactPaths": {
// "androidPaths": [
// "string"
// ],
// "deviceHostPaths": [
// "string"
// ],
// "iosPaths": [
// "string"
// ]
// },
// "deviceMinutes": {
// "metered": number,
// "total": number,
// "unmetered": number
// },
// "devicePoolArn": "string",
// "deviceSelectionResult": {
// "filters": [
// {
// "attribute": "string",
// "operator": "string",
// "values": [
// "string"
// ]
// }
// ],
// "matchedDevicesCount": number,
// "maxDevices": number
// },
// "eventCount": number,
// "jobTimeoutMinutes": number,
// "locale": "string",
// "location": {
// "latitude": number,
// "longitude": number
// },
// "message": "string",
// "name": "string",
// "networkProfile": {
// "arn": "string",
// "description": "string",
// "downlinkBandwidthBits": number,
// "downlinkDelayMs": number,
// "downlinkJitterMs": number,
// "downlinkLossPercent": number,
// "name": "string",
// "type": "string",
// "uplinkBandwidthBits": number,
// "uplinkDelayMs": number,
// "uplinkJitterMs": number,
// "uplinkLossPercent": number
// },
// "parsingResultUrl": "string",
// "platform": "string",
// "radios": {
// "bluetooth": boolean,
// "gps": boolean,
// "nfc": boolean,
// "wifi": boolean
// },
// "result": "string",
// "resultCode": "string",
// "seed": number,
// "skipAppResign": boolean,
// "started": number,
// "status": "string",
// "stopped": number,
// "testSpecArn": "string",
// "totalJobs": number,
// "type": "string",
// "webUrl": "string"
// }
// }
CkRestW_Dispose(rest);
CkAuthAwsW_Dispose(authAws);
CkJsonObjectW_Dispose(json);
CkStringBuilderW_Dispose(sbRequestBody);
CkStringBuilderW_Dispose(sbResponseBody);
CkJsonObjectW_Dispose(jResp);
}