DescribeDataset Objective-C Example
#import <CkoRest.h>
#import <CkoAuthAws.h>
#import <CkoStringBuilder.h>
#import <CkoJsonObject.h>
#import <NSString.h>
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
CkoRest *rest = [[CkoRest alloc] init];
BOOL success;
CkoAuthAws *authAws = [[CkoAuthAws alloc] init];
authAws.AccessKey = @"AWS_ACCESS_KEY";
authAws.SecretKey = @"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.Region = @"us-west-2";
authAws.ServiceName = @"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: @"iotanalytics.us-west-2.amazonaws.com" port: [NSNumber numberWithInt: 443] tls: YES autoReconnect: YES];
if (success != YES) {
NSLog(@"%@%d",@"ConnectFailReason: ",[rest.ConnectFailReason intValue]);
NSLog(@"%@",rest.LastErrorText);
return;
}
[rest AddHeader: @"Content-Type" value: @"application/x-amz-json-1.1"];
[rest AddHeader: @"X-Amz-Target" value: @"DescribeDataset"];
CkoStringBuilder *sbResponseBody = [[CkoStringBuilder alloc] init];
success = [rest FullRequestNoBodySb: @"GET" uriPath: @"/datasets/{datasetName}" sb: sbResponseBody];
if (success != YES) {
NSLog(@"%@",rest.LastErrorText);
return;
}
int respStatusCode = [rest.ResponseStatusCode intValue];
NSLog(@"%@%d",@"response status code = ",respStatusCode);
if (respStatusCode != 200) {
NSLog(@"%@",@"Response Header:");
NSLog(@"%@",rest.ResponseHeader);
NSLog(@"%@",@"Response Body:");
NSLog(@"%@",[sbResponseBody GetAsString]);
return;
}
CkoJsonObject *jResp = [[CkoJsonObject alloc] init];
[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
NSString *actionName = 0;
NSString *ExecutionRoleArn = 0;
NSString *Image = 0;
NSString *ComputeType = 0;
int VolumeSizeInGB;
NSString *SqlQuery = 0;
int j;
int count_j;
NSString *DatasetName = 0;
int doubleValue;
NSString *name = 0;
NSString *FileName = 0;
NSString *stringValue = 0;
int OffsetSeconds;
NSString *TimeExpression = 0;
NSString *InputName = 0;
NSString *RoleArn = 0;
NSString *Bucket = 0;
NSString *DatabaseName = 0;
NSString *TableName = 0;
NSString *Key = 0;
NSString *S3DestinationConfigurationRoleArn = 0;
NSString *entryName = 0;
int TimeoutInMinutes;
NSString *ruleName = 0;
NSString *datasetName = 0;
NSString *Expression = 0;
NSString *Arn = [jResp StringOf: @"dataset.arn"];
int CreationTime = [[jResp IntOf: @"dataset.creationTime"] intValue];
int LastUpdateTime = [[jResp IntOf: @"dataset.lastUpdateTime"] intValue];
NSString *Name = [jResp StringOf: @"dataset.name"];
int NumberOfDays = [[jResp IntOf: @"dataset.retentionPeriod.numberOfDays"] intValue];
int Unlimited = [[jResp IntOf: @"dataset.retentionPeriod.unlimited"] intValue];
NSString *Status = [jResp StringOf: @"dataset.status"];
int MaxVersions = [[jResp IntOf: @"dataset.versioningConfiguration.maxVersions"] intValue];
int VersioningConfigurationUnlimited = [[jResp IntOf: @"dataset.versioningConfiguration.unlimited"] intValue];
int i = 0;
int count_i = [[jResp SizeOfArray: @"dataset.actions"] intValue];
while (i < count_i) {
jResp.I = [NSNumber numberWithInt: i];
actionName = [jResp StringOf: @"dataset.actions[i].actionName"];
ExecutionRoleArn = [jResp StringOf: @"dataset.actions[i].containerAction.executionRoleArn"];
Image = [jResp StringOf: @"dataset.actions[i].containerAction.image"];
ComputeType = [jResp StringOf: @"dataset.actions[i].containerAction.resourceConfiguration.computeType"];
VolumeSizeInGB = [[jResp IntOf: @"dataset.actions[i].containerAction.resourceConfiguration.volumeSizeInGB"] intValue];
SqlQuery = [jResp StringOf: @"dataset.actions[i].queryAction.sqlQuery"];
j = 0;
count_j = [[jResp SizeOfArray: @"dataset.actions[i].containerAction.variables"] intValue];
while (j < count_j) {
jResp.J = [NSNumber numberWithInt: j];
DatasetName = [jResp StringOf: @"dataset.actions[i].containerAction.variables[j].datasetContentVersionValue.datasetName"];
doubleValue = [[jResp IntOf: @"dataset.actions[i].containerAction.variables[j].doubleValue"] intValue];
name = [jResp StringOf: @"dataset.actions[i].containerAction.variables[j].name"];
FileName = [jResp StringOf: @"dataset.actions[i].containerAction.variables[j].outputFileUriValue.fileName"];
stringValue = [jResp StringOf: @"dataset.actions[i].containerAction.variables[j].stringValue"];
j = j + 1;
}
j = 0;
count_j = [[jResp SizeOfArray: @"dataset.actions[i].queryAction.filters"] intValue];
while (j < count_j) {
jResp.J = [NSNumber numberWithInt: j];
OffsetSeconds = [[jResp IntOf: @"dataset.actions[i].queryAction.filters[j].deltaTime.offsetSeconds"] intValue];
TimeExpression = [jResp StringOf: @"dataset.actions[i].queryAction.filters[j].deltaTime.timeExpression"];
j = j + 1;
}
i = i + 1;
}
i = 0;
count_i = [[jResp SizeOfArray: @"dataset.contentDeliveryRules"] intValue];
while (i < count_i) {
jResp.I = [NSNumber numberWithInt: i];
InputName = [jResp StringOf: @"dataset.contentDeliveryRules[i].destination.iotEventsDestinationConfiguration.inputName"];
RoleArn = [jResp StringOf: @"dataset.contentDeliveryRules[i].destination.iotEventsDestinationConfiguration.roleArn"];
Bucket = [jResp StringOf: @"dataset.contentDeliveryRules[i].destination.s3DestinationConfiguration.bucket"];
DatabaseName = [jResp StringOf: @"dataset.contentDeliveryRules[i].destination.s3DestinationConfiguration.glueConfiguration.databaseName"];
TableName = [jResp StringOf: @"dataset.contentDeliveryRules[i].destination.s3DestinationConfiguration.glueConfiguration.tableName"];
Key = [jResp StringOf: @"dataset.contentDeliveryRules[i].destination.s3DestinationConfiguration.key"];
S3DestinationConfigurationRoleArn = [jResp StringOf: @"dataset.contentDeliveryRules[i].destination.s3DestinationConfiguration.roleArn"];
entryName = [jResp StringOf: @"dataset.contentDeliveryRules[i].entryName"];
i = i + 1;
}
i = 0;
count_i = [[jResp SizeOfArray: @"dataset.lateDataRules"] intValue];
while (i < count_i) {
jResp.I = [NSNumber numberWithInt: i];
TimeoutInMinutes = [[jResp IntOf: @"dataset.lateDataRules[i].ruleConfiguration.deltaTimeSessionWindowConfiguration.timeoutInMinutes"] intValue];
ruleName = [jResp StringOf: @"dataset.lateDataRules[i].ruleName"];
i = i + 1;
}
i = 0;
count_i = [[jResp SizeOfArray: @"dataset.triggers"] intValue];
while (i < count_i) {
jResp.I = [NSNumber numberWithInt: i];
datasetName = [jResp StringOf: @"dataset.triggers[i].dataset.name"];
Expression = [jResp StringOf: @"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
// }
// }
// }