DescribeLayers 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', 'opsworks'
-- SetAuthAws causes Chilkat to automatically add the following headers: Authorization, X-Amz-Date
EXEC sp_OAMethod @rest, 'SetAuthAws', @success OUT, @authAws
-- URL: https://opsworks.us-west-2.amazonaws.com/
-- Use the same region as specified above.
EXEC sp_OAMethod @rest, 'Connect', @success OUT, 'opsworks.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
-- The following code creates the JSON request body.
-- The JSON created by this code is shown below.
-- Use this online tool to generate code from sample JSON:
-- Generate Code to Create JSON
DECLARE @json int
EXEC @hr = sp_OACreate 'Chilkat_9_5_0.JsonObject', @json OUT
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'LayerIds[0]', 'string'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'StackId', 'string'
-- The JSON request body created by the above code:
-- {
-- "LayerIds": [
-- "string"
-- ],
-- "StackId": "string"
-- }
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', 'OpsWorks_20130218.DescribeLayers'
DECLARE @sbRequestBody int
EXEC @hr = sp_OACreate 'Chilkat_9_5_0.StringBuilder', @sbRequestBody OUT
EXEC sp_OAMethod @json, 'EmitSb', @success OUT, @sbRequestBody
DECLARE @sbResponseBody int
EXEC @hr = sp_OACreate 'Chilkat_9_5_0.StringBuilder', @sbResponseBody OUT
EXEC sp_OAMethod @rest, 'FullRequestSb', @success OUT, 'POST', '/', @sbRequestBody, @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 @json
EXEC @hr = sp_OADestroy @sbRequestBody
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 @json
EXEC @hr = sp_OADestroy @sbRequestBody
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 @Arn nvarchar(max)
DECLARE @v_String nvarchar(max)
DECLARE @AutoAssignElasticIps int
DECLARE @AutoAssignPublicIps int
DECLARE @Enabled int
DECLARE @CreatedAt nvarchar(max)
DECLARE @CustomInstanceProfileArn nvarchar(max)
DECLARE @CustomJson nvarchar(max)
DECLARE @EnableAutoHealing int
DECLARE @InstallUpdatesOnBoot int
DECLARE @LayerId nvarchar(max)
DECLARE @DelayUntilElbConnectionsDrained int
DECLARE @ExecutionTimeout int
DECLARE @Name nvarchar(max)
DECLARE @Shortname nvarchar(max)
DECLARE @StackId nvarchar(max)
DECLARE @v_Type nvarchar(max)
DECLARE @UseEbsOptimizedInstances int
DECLARE @j int
DECLARE @count_j int
DECLARE @BatchCount int
DECLARE @BatchSize int
DECLARE @BufferDuration int
DECLARE @DatetimeFormat nvarchar(max)
DECLARE @Encoding nvarchar(max)
DECLARE @File nvarchar(max)
DECLARE @FileFingerprintLines nvarchar(max)
DECLARE @InitialPosition nvarchar(max)
DECLARE @LogGroupName nvarchar(max)
DECLARE @MultiLineStartPattern nvarchar(max)
DECLARE @TimeZone nvarchar(max)
DECLARE @strVal nvarchar(max)
DECLARE @Encrypted int
DECLARE @Iops int
DECLARE @MountPoint nvarchar(max)
DECLARE @NumberOfDisks int
DECLARE @RaidLevel int
DECLARE @Size int
DECLARE @VolumeType nvarchar(max)
DECLARE @i int
SELECT @i = 0
DECLARE @count_i int
EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_i OUT, 'Layers'
WHILE @i < @count_i
BEGIN
EXEC sp_OASetProperty @jResp, 'I', @i
EXEC sp_OAMethod @jResp, 'StringOf', @Arn OUT, 'Layers[i].Arn'
EXEC sp_OAMethod @jResp, 'StringOf', @v_String OUT, 'Layers[i].Attributes.string'
EXEC sp_OAMethod @jResp, 'IntOf', @AutoAssignElasticIps OUT, 'Layers[i].AutoAssignElasticIps'
EXEC sp_OAMethod @jResp, 'IntOf', @AutoAssignPublicIps OUT, 'Layers[i].AutoAssignPublicIps'
EXEC sp_OAMethod @jResp, 'IntOf', @Enabled OUT, 'Layers[i].CloudWatchLogsConfiguration.Enabled'
EXEC sp_OAMethod @jResp, 'StringOf', @CreatedAt OUT, 'Layers[i].CreatedAt'
EXEC sp_OAMethod @jResp, 'StringOf', @CustomInstanceProfileArn OUT, 'Layers[i].CustomInstanceProfileArn'
EXEC sp_OAMethod @jResp, 'StringOf', @CustomJson OUT, 'Layers[i].CustomJson'
EXEC sp_OAMethod @jResp, 'IntOf', @EnableAutoHealing OUT, 'Layers[i].EnableAutoHealing'
EXEC sp_OAMethod @jResp, 'IntOf', @InstallUpdatesOnBoot OUT, 'Layers[i].InstallUpdatesOnBoot'
EXEC sp_OAMethod @jResp, 'StringOf', @LayerId OUT, 'Layers[i].LayerId'
EXEC sp_OAMethod @jResp, 'IntOf', @DelayUntilElbConnectionsDrained OUT, 'Layers[i].LifecycleEventConfiguration.Shutdown.DelayUntilElbConnectionsDrained'
EXEC sp_OAMethod @jResp, 'IntOf', @ExecutionTimeout OUT, 'Layers[i].LifecycleEventConfiguration.Shutdown.ExecutionTimeout'
EXEC sp_OAMethod @jResp, 'StringOf', @Name OUT, 'Layers[i].Name'
EXEC sp_OAMethod @jResp, 'StringOf', @Shortname OUT, 'Layers[i].Shortname'
EXEC sp_OAMethod @jResp, 'StringOf', @StackId OUT, 'Layers[i].StackId'
EXEC sp_OAMethod @jResp, 'StringOf', @v_Type OUT, 'Layers[i].Type'
EXEC sp_OAMethod @jResp, 'IntOf', @UseEbsOptimizedInstances OUT, 'Layers[i].UseEbsOptimizedInstances'
SELECT @j = 0
EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_j OUT, 'Layers[i].CloudWatchLogsConfiguration.LogStreams'
WHILE @j < @count_j
BEGIN
EXEC sp_OASetProperty @jResp, 'J', @j
EXEC sp_OAMethod @jResp, 'IntOf', @BatchCount OUT, 'Layers[i].CloudWatchLogsConfiguration.LogStreams[j].BatchCount'
EXEC sp_OAMethod @jResp, 'IntOf', @BatchSize OUT, 'Layers[i].CloudWatchLogsConfiguration.LogStreams[j].BatchSize'
EXEC sp_OAMethod @jResp, 'IntOf', @BufferDuration OUT, 'Layers[i].CloudWatchLogsConfiguration.LogStreams[j].BufferDuration'
EXEC sp_OAMethod @jResp, 'StringOf', @DatetimeFormat OUT, 'Layers[i].CloudWatchLogsConfiguration.LogStreams[j].DatetimeFormat'
EXEC sp_OAMethod @jResp, 'StringOf', @Encoding OUT, 'Layers[i].CloudWatchLogsConfiguration.LogStreams[j].Encoding'
EXEC sp_OAMethod @jResp, 'StringOf', @File OUT, 'Layers[i].CloudWatchLogsConfiguration.LogStreams[j].File'
EXEC sp_OAMethod @jResp, 'StringOf', @FileFingerprintLines OUT, 'Layers[i].CloudWatchLogsConfiguration.LogStreams[j].FileFingerprintLines'
EXEC sp_OAMethod @jResp, 'StringOf', @InitialPosition OUT, 'Layers[i].CloudWatchLogsConfiguration.LogStreams[j].InitialPosition'
EXEC sp_OAMethod @jResp, 'StringOf', @LogGroupName OUT, 'Layers[i].CloudWatchLogsConfiguration.LogStreams[j].LogGroupName'
EXEC sp_OAMethod @jResp, 'StringOf', @MultiLineStartPattern OUT, 'Layers[i].CloudWatchLogsConfiguration.LogStreams[j].MultiLineStartPattern'
EXEC sp_OAMethod @jResp, 'StringOf', @TimeZone OUT, 'Layers[i].CloudWatchLogsConfiguration.LogStreams[j].TimeZone'
SELECT @j = @j + 1
END
SELECT @j = 0
EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_j OUT, 'Layers[i].CustomRecipes.Configure'
WHILE @j < @count_j
BEGIN
EXEC sp_OASetProperty @jResp, 'J', @j
EXEC sp_OAMethod @jResp, 'StringOf', @strVal OUT, 'Layers[i].CustomRecipes.Configure[j]'
SELECT @j = @j + 1
END
SELECT @j = 0
EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_j OUT, 'Layers[i].CustomRecipes.Deploy'
WHILE @j < @count_j
BEGIN
EXEC sp_OASetProperty @jResp, 'J', @j
EXEC sp_OAMethod @jResp, 'StringOf', @strVal OUT, 'Layers[i].CustomRecipes.Deploy[j]'
SELECT @j = @j + 1
END
SELECT @j = 0
EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_j OUT, 'Layers[i].CustomRecipes.Setup'
WHILE @j < @count_j
BEGIN
EXEC sp_OASetProperty @jResp, 'J', @j
EXEC sp_OAMethod @jResp, 'StringOf', @strVal OUT, 'Layers[i].CustomRecipes.Setup[j]'
SELECT @j = @j + 1
END
SELECT @j = 0
EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_j OUT, 'Layers[i].CustomRecipes.Shutdown'
WHILE @j < @count_j
BEGIN
EXEC sp_OASetProperty @jResp, 'J', @j
EXEC sp_OAMethod @jResp, 'StringOf', @strVal OUT, 'Layers[i].CustomRecipes.Shutdown[j]'
SELECT @j = @j + 1
END
SELECT @j = 0
EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_j OUT, 'Layers[i].CustomRecipes.Undeploy'
WHILE @j < @count_j
BEGIN
EXEC sp_OASetProperty @jResp, 'J', @j
EXEC sp_OAMethod @jResp, 'StringOf', @strVal OUT, 'Layers[i].CustomRecipes.Undeploy[j]'
SELECT @j = @j + 1
END
SELECT @j = 0
EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_j OUT, 'Layers[i].CustomSecurityGroupIds'
WHILE @j < @count_j
BEGIN
EXEC sp_OASetProperty @jResp, 'J', @j
EXEC sp_OAMethod @jResp, 'StringOf', @strVal OUT, 'Layers[i].CustomSecurityGroupIds[j]'
SELECT @j = @j + 1
END
SELECT @j = 0
EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_j OUT, 'Layers[i].DefaultRecipes.Configure'
WHILE @j < @count_j
BEGIN
EXEC sp_OASetProperty @jResp, 'J', @j
EXEC sp_OAMethod @jResp, 'StringOf', @strVal OUT, 'Layers[i].DefaultRecipes.Configure[j]'
SELECT @j = @j + 1
END
SELECT @j = 0
EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_j OUT, 'Layers[i].DefaultRecipes.Deploy'
WHILE @j < @count_j
BEGIN
EXEC sp_OASetProperty @jResp, 'J', @j
EXEC sp_OAMethod @jResp, 'StringOf', @strVal OUT, 'Layers[i].DefaultRecipes.Deploy[j]'
SELECT @j = @j + 1
END
SELECT @j = 0
EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_j OUT, 'Layers[i].DefaultRecipes.Setup'
WHILE @j < @count_j
BEGIN
EXEC sp_OASetProperty @jResp, 'J', @j
EXEC sp_OAMethod @jResp, 'StringOf', @strVal OUT, 'Layers[i].DefaultRecipes.Setup[j]'
SELECT @j = @j + 1
END
SELECT @j = 0
EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_j OUT, 'Layers[i].DefaultRecipes.Shutdown'
WHILE @j < @count_j
BEGIN
EXEC sp_OASetProperty @jResp, 'J', @j
EXEC sp_OAMethod @jResp, 'StringOf', @strVal OUT, 'Layers[i].DefaultRecipes.Shutdown[j]'
SELECT @j = @j + 1
END
SELECT @j = 0
EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_j OUT, 'Layers[i].DefaultRecipes.Undeploy'
WHILE @j < @count_j
BEGIN
EXEC sp_OASetProperty @jResp, 'J', @j
EXEC sp_OAMethod @jResp, 'StringOf', @strVal OUT, 'Layers[i].DefaultRecipes.Undeploy[j]'
SELECT @j = @j + 1
END
SELECT @j = 0
EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_j OUT, 'Layers[i].DefaultSecurityGroupNames'
WHILE @j < @count_j
BEGIN
EXEC sp_OASetProperty @jResp, 'J', @j
EXEC sp_OAMethod @jResp, 'StringOf', @strVal OUT, 'Layers[i].DefaultSecurityGroupNames[j]'
SELECT @j = @j + 1
END
SELECT @j = 0
EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_j OUT, 'Layers[i].Packages'
WHILE @j < @count_j
BEGIN
EXEC sp_OASetProperty @jResp, 'J', @j
EXEC sp_OAMethod @jResp, 'StringOf', @strVal OUT, 'Layers[i].Packages[j]'
SELECT @j = @j + 1
END
SELECT @j = 0
EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_j OUT, 'Layers[i].VolumeConfigurations'
WHILE @j < @count_j
BEGIN
EXEC sp_OASetProperty @jResp, 'J', @j
EXEC sp_OAMethod @jResp, 'IntOf', @Encrypted OUT, 'Layers[i].VolumeConfigurations[j].Encrypted'
EXEC sp_OAMethod @jResp, 'IntOf', @Iops OUT, 'Layers[i].VolumeConfigurations[j].Iops'
EXEC sp_OAMethod @jResp, 'StringOf', @MountPoint OUT, 'Layers[i].VolumeConfigurations[j].MountPoint'
EXEC sp_OAMethod @jResp, 'IntOf', @NumberOfDisks OUT, 'Layers[i].VolumeConfigurations[j].NumberOfDisks'
EXEC sp_OAMethod @jResp, 'IntOf', @RaidLevel OUT, 'Layers[i].VolumeConfigurations[j].RaidLevel'
EXEC sp_OAMethod @jResp, 'IntOf', @Size OUT, 'Layers[i].VolumeConfigurations[j].Size'
EXEC sp_OAMethod @jResp, 'StringOf', @VolumeType OUT, 'Layers[i].VolumeConfigurations[j].VolumeType'
SELECT @j = @j + 1
END
SELECT @i = @i + 1
END
-- A sample JSON response body parsed by the above code:
-- {
-- "Layers": [
-- {
-- "Arn": "string",
-- "Attributes": {
-- "string": "string"
-- },
-- "AutoAssignElasticIps": boolean,
-- "AutoAssignPublicIps": boolean,
-- "CloudWatchLogsConfiguration": {
-- "Enabled": boolean,
-- "LogStreams": [
-- {
-- "BatchCount": number,
-- "BatchSize": number,
-- "BufferDuration": number,
-- "DatetimeFormat": "string",
-- "Encoding": "string",
-- "File": "string",
-- "FileFingerprintLines": "string",
-- "InitialPosition": "string",
-- "LogGroupName": "string",
-- "MultiLineStartPattern": "string",
-- "TimeZone": "string"
-- }
-- ]
-- },
-- "CreatedAt": "string",
-- "CustomInstanceProfileArn": "string",
-- "CustomJson": "string",
-- "CustomRecipes": {
-- "Configure": [
-- "string"
-- ],
-- "Deploy": [
-- "string"
-- ],
-- "Setup": [
-- "string"
-- ],
-- "Shutdown": [
-- "string"
-- ],
-- "Undeploy": [
-- "string"
-- ]
-- },
-- "CustomSecurityGroupIds": [
-- "string"
-- ],
-- "DefaultRecipes": {
-- "Configure": [
-- "string"
-- ],
-- "Deploy": [
-- "string"
-- ],
-- "Setup": [
-- "string"
-- ],
-- "Shutdown": [
-- "string"
-- ],
-- "Undeploy": [
-- "string"
-- ]
-- },
-- "DefaultSecurityGroupNames": [
-- "string"
-- ],
-- "EnableAutoHealing": boolean,
-- "InstallUpdatesOnBoot": boolean,
-- "LayerId": "string",
-- "LifecycleEventConfiguration": {
-- "Shutdown": {
-- "DelayUntilElbConnectionsDrained": boolean,
-- "ExecutionTimeout": number
-- }
-- },
-- "Name": "string",
-- "Packages": [
-- "string"
-- ],
-- "Shortname": "string",
-- "StackId": "string",
-- "Type": "string",
-- "UseEbsOptimizedInstances": boolean,
-- "VolumeConfigurations": [
-- {
-- "Encrypted": boolean,
-- "Iops": number,
-- "MountPoint": "string",
-- "NumberOfDisks": number,
-- "RaidLevel": number,
-- "Size": number,
-- "VolumeType": "string"
-- }
-- ]
-- }
-- ]
-- }
EXEC @hr = sp_OADestroy @rest
EXEC @hr = sp_OADestroy @authAws
EXEC @hr = sp_OADestroy @json
EXEC @hr = sp_OADestroy @sbRequestBody
EXEC @hr = sp_OADestroy @sbResponseBody
EXEC @hr = sp_OADestroy @jResp
END
GO