DescribeDataset unicodeCpp Example
#include <CkRestW.h>
#include <CkAuthAwsW.h>
#include <CkStringBuilderW.h>
#include <CkJsonObjectW.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"iotanalytics");
// SetAuthAws causes Chilkat to automatically add the following headers: Authorization, X-Amz-Date
rest.SetAuthAws(authAws);
// URL: https://iotanalytics.us-west-2.amazonaws.com/
// Use the same region as specified above.
success = rest.Connect(L"iotanalytics.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;
}
rest.AddHeader(L"Content-Type",L"application/x-amz-json-1.1");
rest.AddHeader(L"X-Amz-Target",L"DescribeDataset");
CkStringBuilderW sbResponseBody;
success = rest.FullRequestNoBodySb(L"GET",L"/datasets/{datasetName}",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 *actionName = 0;
const wchar_t *ExecutionRoleArn = 0;
const wchar_t *Image = 0;
const wchar_t *ComputeType = 0;
int VolumeSizeInGB;
const wchar_t *SqlQuery = 0;
int j;
int count_j;
const wchar_t *DatasetName = 0;
int doubleValue;
const wchar_t *name = 0;
const wchar_t *FileName = 0;
const wchar_t *stringValue = 0;
int OffsetSeconds;
const wchar_t *TimeExpression = 0;
const wchar_t *InputName = 0;
const wchar_t *RoleArn = 0;
const wchar_t *Bucket = 0;
const wchar_t *DatabaseName = 0;
const wchar_t *TableName = 0;
const wchar_t *Key = 0;
const wchar_t *S3DestinationConfigurationRoleArn = 0;
const wchar_t *entryName = 0;
int TimeoutInMinutes;
const wchar_t *ruleName = 0;
const wchar_t *datasetName = 0;
const wchar_t *Expression = 0;
const wchar_t *Arn = jResp.stringOf(L"dataset.arn");
int CreationTime = jResp.IntOf(L"dataset.creationTime");
int LastUpdateTime = jResp.IntOf(L"dataset.lastUpdateTime");
const wchar_t *Name = jResp.stringOf(L"dataset.name");
int NumberOfDays = jResp.IntOf(L"dataset.retentionPeriod.numberOfDays");
int Unlimited = jResp.IntOf(L"dataset.retentionPeriod.unlimited");
const wchar_t *Status = jResp.stringOf(L"dataset.status");
int MaxVersions = jResp.IntOf(L"dataset.versioningConfiguration.maxVersions");
int VersioningConfigurationUnlimited = jResp.IntOf(L"dataset.versioningConfiguration.unlimited");
int i = 0;
int count_i = jResp.SizeOfArray(L"dataset.actions");
while (i < count_i) {
jResp.put_I(i);
actionName = jResp.stringOf(L"dataset.actions[i].actionName");
ExecutionRoleArn = jResp.stringOf(L"dataset.actions[i].containerAction.executionRoleArn");
Image = jResp.stringOf(L"dataset.actions[i].containerAction.image");
ComputeType = jResp.stringOf(L"dataset.actions[i].containerAction.resourceConfiguration.computeType");
VolumeSizeInGB = jResp.IntOf(L"dataset.actions[i].containerAction.resourceConfiguration.volumeSizeInGB");
SqlQuery = jResp.stringOf(L"dataset.actions[i].queryAction.sqlQuery");
j = 0;
count_j = jResp.SizeOfArray(L"dataset.actions[i].containerAction.variables");
while (j < count_j) {
jResp.put_J(j);
DatasetName = jResp.stringOf(L"dataset.actions[i].containerAction.variables[j].datasetContentVersionValue.datasetName");
doubleValue = jResp.IntOf(L"dataset.actions[i].containerAction.variables[j].doubleValue");
name = jResp.stringOf(L"dataset.actions[i].containerAction.variables[j].name");
FileName = jResp.stringOf(L"dataset.actions[i].containerAction.variables[j].outputFileUriValue.fileName");
stringValue = jResp.stringOf(L"dataset.actions[i].containerAction.variables[j].stringValue");
j = j + 1;
}
j = 0;
count_j = jResp.SizeOfArray(L"dataset.actions[i].queryAction.filters");
while (j < count_j) {
jResp.put_J(j);
OffsetSeconds = jResp.IntOf(L"dataset.actions[i].queryAction.filters[j].deltaTime.offsetSeconds");
TimeExpression = jResp.stringOf(L"dataset.actions[i].queryAction.filters[j].deltaTime.timeExpression");
j = j + 1;
}
i = i + 1;
}
i = 0;
count_i = jResp.SizeOfArray(L"dataset.contentDeliveryRules");
while (i < count_i) {
jResp.put_I(i);
InputName = jResp.stringOf(L"dataset.contentDeliveryRules[i].destination.iotEventsDestinationConfiguration.inputName");
RoleArn = jResp.stringOf(L"dataset.contentDeliveryRules[i].destination.iotEventsDestinationConfiguration.roleArn");
Bucket = jResp.stringOf(L"dataset.contentDeliveryRules[i].destination.s3DestinationConfiguration.bucket");
DatabaseName = jResp.stringOf(L"dataset.contentDeliveryRules[i].destination.s3DestinationConfiguration.glueConfiguration.databaseName");
TableName = jResp.stringOf(L"dataset.contentDeliveryRules[i].destination.s3DestinationConfiguration.glueConfiguration.tableName");
Key = jResp.stringOf(L"dataset.contentDeliveryRules[i].destination.s3DestinationConfiguration.key");
S3DestinationConfigurationRoleArn = jResp.stringOf(L"dataset.contentDeliveryRules[i].destination.s3DestinationConfiguration.roleArn");
entryName = jResp.stringOf(L"dataset.contentDeliveryRules[i].entryName");
i = i + 1;
}
i = 0;
count_i = jResp.SizeOfArray(L"dataset.lateDataRules");
while (i < count_i) {
jResp.put_I(i);
TimeoutInMinutes = jResp.IntOf(L"dataset.lateDataRules[i].ruleConfiguration.deltaTimeSessionWindowConfiguration.timeoutInMinutes");
ruleName = jResp.stringOf(L"dataset.lateDataRules[i].ruleName");
i = i + 1;
}
i = 0;
count_i = jResp.SizeOfArray(L"dataset.triggers");
while (i < count_i) {
jResp.put_I(i);
datasetName = jResp.stringOf(L"dataset.triggers[i].dataset.name");
Expression = jResp.stringOf(L"dataset.triggers[i].schedule.expression");
i = i + 1;
}
// A sample JSON response body parsed by the above code:
// {
// "dataset": {
// "actions": [
// {
// "actionName": "string",
// "containerAction": {
// "executionRoleArn": "string",
// "image": "string",
// "resourceConfiguration": {
// "computeType": "string",
// "volumeSizeInGB": number
// },
// "variables": [
// {
// "datasetContentVersionValue": {
// "datasetName": "string"
// },
// "doubleValue": number,
// "name": "string",
// "outputFileUriValue": {
// "fileName": "string"
// },
// "stringValue": "string"
// }
// ]
// },
// "queryAction": {
// "filters": [
// {
// "deltaTime": {
// "offsetSeconds": number,
// "timeExpression": "string"
// }
// }
// ],
// "sqlQuery": "string"
// }
// }
// ],
// "arn": "string",
// "contentDeliveryRules": [
// {
// "destination": {
// "iotEventsDestinationConfiguration": {
// "inputName": "string",
// "roleArn": "string"
// },
// "s3DestinationConfiguration": {
// "bucket": "string",
// "glueConfiguration": {
// "databaseName": "string",
// "tableName": "string"
// },
// "key": "string",
// "roleArn": "string"
// }
// },
// "entryName": "string"
// }
// ],
// "creationTime": number,
// "lastUpdateTime": number,
// "lateDataRules": [
// {
// "ruleConfiguration": {
// "deltaTimeSessionWindowConfiguration": {
// "timeoutInMinutes": number
// }
// },
// "ruleName": "string"
// }
// ],
// "name": "string",
// "retentionPeriod": {
// "numberOfDays": number,
// "unlimited": boolean
// },
// "status": "string",
// "triggers": [
// {
// "dataset": {
// "name": "string"
// },
// "schedule": {
// "expression": "string"
// }
// }
// ],
// "versioningConfiguration": {
// "maxVersions": number,
// "unlimited": boolean
// }
// }
// }
}