DescribeDataset C Example
#include <C_CkRest.h>
#include <C_CkAuthAws.h>
#include <C_CkStringBuilder.h>
#include <C_CkJsonObject.h>
void ChilkatSample(void)
{
HCkRest rest;
BOOL success;
HCkAuthAws authAws;
HCkStringBuilder sbResponseBody;
int respStatusCode;
HCkJsonObject jResp;
const char *actionName;
const char *ExecutionRoleArn;
const char *Image;
const char *ComputeType;
int VolumeSizeInGB;
const char *SqlQuery;
int j;
int count_j;
const char *DatasetName;
int doubleValue;
const char *name;
const char *FileName;
const char *stringValue;
int OffsetSeconds;
const char *TimeExpression;
const char *InputName;
const char *RoleArn;
const char *Bucket;
const char *DatabaseName;
const char *TableName;
const char *Key;
const char *S3DestinationConfigurationRoleArn;
const char *entryName;
int TimeoutInMinutes;
const char *ruleName;
const char *datasetName;
const char *Expression;
const char *Arn;
int CreationTime;
int LastUpdateTime;
const char *Name;
int NumberOfDays;
int Unlimited;
const char *Status;
int MaxVersions;
int VersioningConfigurationUnlimited;
int i;
int count_i;
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
rest = CkRest_Create();
authAws = CkAuthAws_Create();
CkAuthAws_putAccessKey(authAws,"AWS_ACCESS_KEY");
CkAuthAws_putSecretKey(authAws,"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.)
CkAuthAws_putRegion(authAws,"us-west-2");
CkAuthAws_putServiceName(authAws,"iotanalytics");
// SetAuthAws causes Chilkat to automatically add the following headers: Authorization, X-Amz-Date
CkRest_SetAuthAws(rest,authAws);
// URL: https://iotanalytics.us-west-2.amazonaws.com/
// Use the same region as specified above.
success = CkRest_Connect(rest,"iotanalytics.us-west-2.amazonaws.com",443,TRUE,TRUE);
if (success != TRUE) {
printf("ConnectFailReason: %d\n",CkRest_getConnectFailReason(rest));
printf("%s\n",CkRest_lastErrorText(rest));
CkRest_Dispose(rest);
CkAuthAws_Dispose(authAws);
return;
}
CkRest_AddHeader(rest,"Content-Type","application/x-amz-json-1.1");
CkRest_AddHeader(rest,"X-Amz-Target","DescribeDataset");
sbResponseBody = CkStringBuilder_Create();
success = CkRest_FullRequestNoBodySb(rest,"GET","/datasets/{datasetName}",sbResponseBody);
if (success != TRUE) {
printf("%s\n",CkRest_lastErrorText(rest));
CkRest_Dispose(rest);
CkAuthAws_Dispose(authAws);
CkStringBuilder_Dispose(sbResponseBody);
return;
}
respStatusCode = CkRest_getResponseStatusCode(rest);
printf("response status code = %d\n",respStatusCode);
if (respStatusCode != 200) {
printf("Response Header:\n");
printf("%s\n",CkRest_responseHeader(rest));
printf("Response Body:\n");
printf("%s\n",CkStringBuilder_getAsString(sbResponseBody));
CkRest_Dispose(rest);
CkAuthAws_Dispose(authAws);
CkStringBuilder_Dispose(sbResponseBody);
return;
}
jResp = CkJsonObject_Create();
CkJsonObject_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.
Arn = CkJsonObject_stringOf(jResp,"dataset.arn");
CreationTime = CkJsonObject_IntOf(jResp,"dataset.creationTime");
LastUpdateTime = CkJsonObject_IntOf(jResp,"dataset.lastUpdateTime");
Name = CkJsonObject_stringOf(jResp,"dataset.name");
NumberOfDays = CkJsonObject_IntOf(jResp,"dataset.retentionPeriod.numberOfDays");
Unlimited = CkJsonObject_IntOf(jResp,"dataset.retentionPeriod.unlimited");
Status = CkJsonObject_stringOf(jResp,"dataset.status");
MaxVersions = CkJsonObject_IntOf(jResp,"dataset.versioningConfiguration.maxVersions");
VersioningConfigurationUnlimited = CkJsonObject_IntOf(jResp,"dataset.versioningConfiguration.unlimited");
i = 0;
count_i = CkJsonObject_SizeOfArray(jResp,"dataset.actions");
while (i < count_i) {
CkJsonObject_putI(jResp,i);
actionName = CkJsonObject_stringOf(jResp,"dataset.actions[i].actionName");
ExecutionRoleArn = CkJsonObject_stringOf(jResp,"dataset.actions[i].containerAction.executionRoleArn");
Image = CkJsonObject_stringOf(jResp,"dataset.actions[i].containerAction.image");
ComputeType = CkJsonObject_stringOf(jResp,"dataset.actions[i].containerAction.resourceConfiguration.computeType");
VolumeSizeInGB = CkJsonObject_IntOf(jResp,"dataset.actions[i].containerAction.resourceConfiguration.volumeSizeInGB");
SqlQuery = CkJsonObject_stringOf(jResp,"dataset.actions[i].queryAction.sqlQuery");
j = 0;
count_j = CkJsonObject_SizeOfArray(jResp,"dataset.actions[i].containerAction.variables");
while (j < count_j) {
CkJsonObject_putJ(jResp,j);
DatasetName = CkJsonObject_stringOf(jResp,"dataset.actions[i].containerAction.variables[j].datasetContentVersionValue.datasetName");
doubleValue = CkJsonObject_IntOf(jResp,"dataset.actions[i].containerAction.variables[j].doubleValue");
name = CkJsonObject_stringOf(jResp,"dataset.actions[i].containerAction.variables[j].name");
FileName = CkJsonObject_stringOf(jResp,"dataset.actions[i].containerAction.variables[j].outputFileUriValue.fileName");
stringValue = CkJsonObject_stringOf(jResp,"dataset.actions[i].containerAction.variables[j].stringValue");
j = j + 1;
}
j = 0;
count_j = CkJsonObject_SizeOfArray(jResp,"dataset.actions[i].queryAction.filters");
while (j < count_j) {
CkJsonObject_putJ(jResp,j);
OffsetSeconds = CkJsonObject_IntOf(jResp,"dataset.actions[i].queryAction.filters[j].deltaTime.offsetSeconds");
TimeExpression = CkJsonObject_stringOf(jResp,"dataset.actions[i].queryAction.filters[j].deltaTime.timeExpression");
j = j + 1;
}
i = i + 1;
}
i = 0;
count_i = CkJsonObject_SizeOfArray(jResp,"dataset.contentDeliveryRules");
while (i < count_i) {
CkJsonObject_putI(jResp,i);
InputName = CkJsonObject_stringOf(jResp,"dataset.contentDeliveryRules[i].destination.iotEventsDestinationConfiguration.inputName");
RoleArn = CkJsonObject_stringOf(jResp,"dataset.contentDeliveryRules[i].destination.iotEventsDestinationConfiguration.roleArn");
Bucket = CkJsonObject_stringOf(jResp,"dataset.contentDeliveryRules[i].destination.s3DestinationConfiguration.bucket");
DatabaseName = CkJsonObject_stringOf(jResp,"dataset.contentDeliveryRules[i].destination.s3DestinationConfiguration.glueConfiguration.databaseName");
TableName = CkJsonObject_stringOf(jResp,"dataset.contentDeliveryRules[i].destination.s3DestinationConfiguration.glueConfiguration.tableName");
Key = CkJsonObject_stringOf(jResp,"dataset.contentDeliveryRules[i].destination.s3DestinationConfiguration.key");
S3DestinationConfigurationRoleArn = CkJsonObject_stringOf(jResp,"dataset.contentDeliveryRules[i].destination.s3DestinationConfiguration.roleArn");
entryName = CkJsonObject_stringOf(jResp,"dataset.contentDeliveryRules[i].entryName");
i = i + 1;
}
i = 0;
count_i = CkJsonObject_SizeOfArray(jResp,"dataset.lateDataRules");
while (i < count_i) {
CkJsonObject_putI(jResp,i);
TimeoutInMinutes = CkJsonObject_IntOf(jResp,"dataset.lateDataRules[i].ruleConfiguration.deltaTimeSessionWindowConfiguration.timeoutInMinutes");
ruleName = CkJsonObject_stringOf(jResp,"dataset.lateDataRules[i].ruleName");
i = i + 1;
}
i = 0;
count_i = CkJsonObject_SizeOfArray(jResp,"dataset.triggers");
while (i < count_i) {
CkJsonObject_putI(jResp,i);
datasetName = CkJsonObject_stringOf(jResp,"dataset.triggers[i].dataset.name");
Expression = CkJsonObject_stringOf(jResp,"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
// }
// }
// }
CkRest_Dispose(rest);
CkAuthAws_Dispose(authAws);
CkStringBuilder_Dispose(sbResponseBody);
CkJsonObject_Dispose(jResp);
}