DescribeDataset delphiDll Example
var
rest: HCkRest;
success: Boolean;
authAws: HCkAuthAws;
sbResponseBody: HCkStringBuilder;
respStatusCode: Integer;
jResp: HCkJsonObject;
actionName: PWideChar;
ExecutionRoleArn: PWideChar;
Image: PWideChar;
ComputeType: PWideChar;
VolumeSizeInGB: Integer;
SqlQuery: PWideChar;
j: Integer;
count_j: Integer;
DatasetName: PWideChar;
doubleValue: Integer;
name: PWideChar;
FileName: PWideChar;
stringValue: PWideChar;
OffsetSeconds: Integer;
TimeExpression: PWideChar;
InputName: PWideChar;
RoleArn: PWideChar;
Bucket: PWideChar;
DatabaseName: PWideChar;
TableName: PWideChar;
Key: PWideChar;
S3DestinationConfigurationRoleArn: PWideChar;
entryName: PWideChar;
TimeoutInMinutes: Integer;
ruleName: PWideChar;
datasetName: PWideChar;
Expression: PWideChar;
Arn: PWideChar;
CreationTime: Integer;
LastUpdateTime: Integer;
Name: PWideChar;
NumberOfDays: Integer;
Unlimited: Integer;
Status: PWideChar;
MaxVersions: Integer;
VersioningConfigurationUnlimited: Integer;
i: Integer;
count_i: Integer;
begin
// 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) then
begin
Memo1.Lines.Add('ConnectFailReason: ' + IntToStr(CkRest_getConnectFailReason(rest)));
Memo1.Lines.Add(CkRest__lastErrorText(rest));
Exit;
end;
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) then
begin
Memo1.Lines.Add(CkRest__lastErrorText(rest));
Exit;
end;
respStatusCode := CkRest_getResponseStatusCode(rest);
Memo1.Lines.Add('response status code = ' + IntToStr(respStatusCode));
if (respStatusCode <> 200) then
begin
Memo1.Lines.Add('Response Header:');
Memo1.Lines.Add(CkRest__responseHeader(rest));
Memo1.Lines.Add('Response Body:');
Memo1.Lines.Add(CkStringBuilder__getAsString(sbResponseBody));
Exit;
end;
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
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 do
begin
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 do
begin
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;
end;
j := 0;
count_j := CkJsonObject_SizeOfArray(jResp,'dataset.actions[i].queryAction.filters');
while j < count_j do
begin
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;
end;
i := i + 1;
end;
i := 0;
count_i := CkJsonObject_SizeOfArray(jResp,'dataset.contentDeliveryRules');
while i < count_i do
begin
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;
end;
i := 0;
count_i := CkJsonObject_SizeOfArray(jResp,'dataset.lateDataRules');
while i < count_i do
begin
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;
end;
i := 0;
count_i := CkJsonObject_SizeOfArray(jResp,'dataset.triggers');
while i < count_i do
begin
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;
end;
// 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);