DescribeDataset SQL Server Example
CREATE PROCEDURE ChilkatSample
AS
BEGIN
DECLARE @hr int
DECLARE @iTmp0 int
DECLARE @sTmp0 nvarchar(max)
-- This example requires the Chilkat API to have been previously unlocked.
-- See Global Unlock Sample for sample code.
DECLARE @rest int
EXEC @hr = sp_OACreate 'Chilkat_9_5_0.Rest', @rest OUT
IF @hr <> 0
BEGIN
PRINT 'Failed to create ActiveX component'
RETURN
END
DECLARE @success int
DECLARE @authAws int
EXEC @hr = sp_OACreate 'Chilkat_9_5_0.AuthAws', @authAws OUT
EXEC sp_OASetProperty @authAws, 'AccessKey', 'AWS_ACCESS_KEY'
EXEC sp_OASetProperty @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.)
EXEC sp_OASetProperty @authAws, 'Region', 'us-west-2'
EXEC sp_OASetProperty @authAws, 'ServiceName', 'iotanalytics'
-- SetAuthAws causes Chilkat to automatically add the following headers: Authorization, X-Amz-Date
EXEC sp_OAMethod @rest, 'SetAuthAws', @success OUT, @authAws
-- URL: https://iotanalytics.us-west-2.amazonaws.com/
-- Use the same region as specified above.
EXEC sp_OAMethod @rest, 'Connect', @success OUT, 'iotanalytics.us-west-2.amazonaws.com', 443, 1, 1
IF @success <> 1
BEGIN
EXEC sp_OAGetProperty @rest, 'ConnectFailReason', @iTmp0 OUT
PRINT 'ConnectFailReason: ' + @iTmp0
EXEC sp_OAGetProperty @rest, 'LastErrorText', @sTmp0 OUT
PRINT @sTmp0
EXEC @hr = sp_OADestroy @rest
EXEC @hr = sp_OADestroy @authAws
RETURN
END
EXEC sp_OAMethod @rest, 'AddHeader', @success OUT, 'Content-Type', 'application/x-amz-json-1.1'
EXEC sp_OAMethod @rest, 'AddHeader', @success OUT, 'X-Amz-Target', 'DescribeDataset'
DECLARE @sbResponseBody int
EXEC @hr = sp_OACreate 'Chilkat_9_5_0.StringBuilder', @sbResponseBody OUT
EXEC sp_OAMethod @rest, 'FullRequestNoBodySb', @success OUT, 'GET', '/datasets/{datasetName}', @sbResponseBody
IF @success <> 1
BEGIN
EXEC sp_OAGetProperty @rest, 'LastErrorText', @sTmp0 OUT
PRINT @sTmp0
EXEC @hr = sp_OADestroy @rest
EXEC @hr = sp_OADestroy @authAws
EXEC @hr = sp_OADestroy @sbResponseBody
RETURN
END
DECLARE @respStatusCode int
EXEC sp_OAGetProperty @rest, 'ResponseStatusCode', @respStatusCode OUT
PRINT 'response status code = ' + @respStatusCode
IF @respStatusCode <> 200
BEGIN
PRINT 'Response Header:'
EXEC sp_OAGetProperty @rest, 'ResponseHeader', @sTmp0 OUT
PRINT @sTmp0
PRINT 'Response Body:'
EXEC sp_OAMethod @sbResponseBody, 'GetAsString', @sTmp0 OUT
PRINT @sTmp0
EXEC @hr = sp_OADestroy @rest
EXEC @hr = sp_OADestroy @authAws
EXEC @hr = sp_OADestroy @sbResponseBody
RETURN
END
DECLARE @jResp int
EXEC @hr = sp_OACreate 'Chilkat_9_5_0.JsonObject', @jResp OUT
EXEC sp_OAMethod @jResp, 'LoadSb', @success OUT, @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
DECLARE @actionName nvarchar(max)
DECLARE @ExecutionRoleArn nvarchar(max)
DECLARE @Image nvarchar(max)
DECLARE @ComputeType nvarchar(max)
DECLARE @VolumeSizeInGB int
DECLARE @SqlQuery nvarchar(max)
DECLARE @j int
DECLARE @count_j int
DECLARE @DatasetName nvarchar(max)
DECLARE @doubleValue int
DECLARE @name nvarchar(max)
DECLARE @FileName nvarchar(max)
DECLARE @stringValue nvarchar(max)
DECLARE @OffsetSeconds int
DECLARE @TimeExpression nvarchar(max)
DECLARE @InputName nvarchar(max)
DECLARE @RoleArn nvarchar(max)
DECLARE @Bucket nvarchar(max)
DECLARE @DatabaseName nvarchar(max)
DECLARE @TableName nvarchar(max)
DECLARE @Key nvarchar(max)
DECLARE @S3DestinationConfigurationRoleArn nvarchar(max)
DECLARE @entryName nvarchar(max)
DECLARE @TimeoutInMinutes int
DECLARE @ruleName nvarchar(max)
DECLARE @datasetName nvarchar(max)
DECLARE @Expression nvarchar(max)
DECLARE @Arn nvarchar(max)
EXEC sp_OAMethod @jResp, 'StringOf', @Arn OUT, 'dataset.arn'
DECLARE @CreationTime int
EXEC sp_OAMethod @jResp, 'IntOf', @CreationTime OUT, 'dataset.creationTime'
DECLARE @LastUpdateTime int
EXEC sp_OAMethod @jResp, 'IntOf', @LastUpdateTime OUT, 'dataset.lastUpdateTime'
DECLARE @Name nvarchar(max)
EXEC sp_OAMethod @jResp, 'StringOf', @Name OUT, 'dataset.name'
DECLARE @NumberOfDays int
EXEC sp_OAMethod @jResp, 'IntOf', @NumberOfDays OUT, 'dataset.retentionPeriod.numberOfDays'
DECLARE @Unlimited int
EXEC sp_OAMethod @jResp, 'IntOf', @Unlimited OUT, 'dataset.retentionPeriod.unlimited'
DECLARE @Status nvarchar(max)
EXEC sp_OAMethod @jResp, 'StringOf', @Status OUT, 'dataset.status'
DECLARE @MaxVersions int
EXEC sp_OAMethod @jResp, 'IntOf', @MaxVersions OUT, 'dataset.versioningConfiguration.maxVersions'
DECLARE @VersioningConfigurationUnlimited int
EXEC sp_OAMethod @jResp, 'IntOf', @VersioningConfigurationUnlimited OUT, 'dataset.versioningConfiguration.unlimited'
DECLARE @i int
SELECT @i = 0
DECLARE @count_i int
EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_i OUT, 'dataset.actions'
WHILE @i < @count_i
BEGIN
EXEC sp_OASetProperty @jResp, 'I', @i
EXEC sp_OAMethod @jResp, 'StringOf', @actionName OUT, 'dataset.actions[i].actionName'
EXEC sp_OAMethod @jResp, 'StringOf', @ExecutionRoleArn OUT, 'dataset.actions[i].containerAction.executionRoleArn'
EXEC sp_OAMethod @jResp, 'StringOf', @Image OUT, 'dataset.actions[i].containerAction.image'
EXEC sp_OAMethod @jResp, 'StringOf', @ComputeType OUT, 'dataset.actions[i].containerAction.resourceConfiguration.computeType'
EXEC sp_OAMethod @jResp, 'IntOf', @VolumeSizeInGB OUT, 'dataset.actions[i].containerAction.resourceConfiguration.volumeSizeInGB'
EXEC sp_OAMethod @jResp, 'StringOf', @SqlQuery OUT, 'dataset.actions[i].queryAction.sqlQuery'
SELECT @j = 0
EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_j OUT, 'dataset.actions[i].containerAction.variables'
WHILE @j < @count_j
BEGIN
EXEC sp_OASetProperty @jResp, 'J', @j
EXEC sp_OAMethod @jResp, 'StringOf', @DatasetName OUT, 'dataset.actions[i].containerAction.variables[j].datasetContentVersionValue.datasetName'
EXEC sp_OAMethod @jResp, 'IntOf', @doubleValue OUT, 'dataset.actions[i].containerAction.variables[j].doubleValue'
EXEC sp_OAMethod @jResp, 'StringOf', @name OUT, 'dataset.actions[i].containerAction.variables[j].name'
EXEC sp_OAMethod @jResp, 'StringOf', @FileName OUT, 'dataset.actions[i].containerAction.variables[j].outputFileUriValue.fileName'
EXEC sp_OAMethod @jResp, 'StringOf', @stringValue OUT, 'dataset.actions[i].containerAction.variables[j].stringValue'
SELECT @j = @j + 1
END
SELECT @j = 0
EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_j OUT, 'dataset.actions[i].queryAction.filters'
WHILE @j < @count_j
BEGIN
EXEC sp_OASetProperty @jResp, 'J', @j
EXEC sp_OAMethod @jResp, 'IntOf', @OffsetSeconds OUT, 'dataset.actions[i].queryAction.filters[j].deltaTime.offsetSeconds'
EXEC sp_OAMethod @jResp, 'StringOf', @TimeExpression OUT, 'dataset.actions[i].queryAction.filters[j].deltaTime.timeExpression'
SELECT @j = @j + 1
END
SELECT @i = @i + 1
END
SELECT @i = 0
EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_i OUT, 'dataset.contentDeliveryRules'
WHILE @i < @count_i
BEGIN
EXEC sp_OASetProperty @jResp, 'I', @i
EXEC sp_OAMethod @jResp, 'StringOf', @InputName OUT, 'dataset.contentDeliveryRules[i].destination.iotEventsDestinationConfiguration.inputName'
EXEC sp_OAMethod @jResp, 'StringOf', @RoleArn OUT, 'dataset.contentDeliveryRules[i].destination.iotEventsDestinationConfiguration.roleArn'
EXEC sp_OAMethod @jResp, 'StringOf', @Bucket OUT, 'dataset.contentDeliveryRules[i].destination.s3DestinationConfiguration.bucket'
EXEC sp_OAMethod @jResp, 'StringOf', @DatabaseName OUT, 'dataset.contentDeliveryRules[i].destination.s3DestinationConfiguration.glueConfiguration.databaseName'
EXEC sp_OAMethod @jResp, 'StringOf', @TableName OUT, 'dataset.contentDeliveryRules[i].destination.s3DestinationConfiguration.glueConfiguration.tableName'
EXEC sp_OAMethod @jResp, 'StringOf', @Key OUT, 'dataset.contentDeliveryRules[i].destination.s3DestinationConfiguration.key'
EXEC sp_OAMethod @jResp, 'StringOf', @S3DestinationConfigurationRoleArn OUT, 'dataset.contentDeliveryRules[i].destination.s3DestinationConfiguration.roleArn'
EXEC sp_OAMethod @jResp, 'StringOf', @entryName OUT, 'dataset.contentDeliveryRules[i].entryName'
SELECT @i = @i + 1
END
SELECT @i = 0
EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_i OUT, 'dataset.lateDataRules'
WHILE @i < @count_i
BEGIN
EXEC sp_OASetProperty @jResp, 'I', @i
EXEC sp_OAMethod @jResp, 'IntOf', @TimeoutInMinutes OUT, 'dataset.lateDataRules[i].ruleConfiguration.deltaTimeSessionWindowConfiguration.timeoutInMinutes'
EXEC sp_OAMethod @jResp, 'StringOf', @ruleName OUT, 'dataset.lateDataRules[i].ruleName'
SELECT @i = @i + 1
END
SELECT @i = 0
EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_i OUT, 'dataset.triggers'
WHILE @i < @count_i
BEGIN
EXEC sp_OASetProperty @jResp, 'I', @i
EXEC sp_OAMethod @jResp, 'StringOf', @datasetName OUT, 'dataset.triggers[i].dataset.name'
EXEC sp_OAMethod @jResp, 'StringOf', @Expression OUT, 'dataset.triggers[i].schedule.expression'
SELECT @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
-- }
-- }
-- }
EXEC @hr = sp_OADestroy @rest
EXEC @hr = sp_OADestroy @authAws
EXEC @hr = sp_OADestroy @sbResponseBody
EXEC @hr = sp_OADestroy @jResp
END
GO