GetDeploymentTarget 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', 'codedeploy'
-- SetAuthAws causes Chilkat to automatically add the following headers: Authorization, X-Amz-Date
EXEC sp_OAMethod @rest, 'SetAuthAws', @success OUT, @authAws
-- URL: https://codedeploy.us-west-2.amazonaws.com/
-- Use the same region as specified above.
EXEC sp_OAMethod @rest, 'Connect', @success OUT, 'codedeploy.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, 'deploymentId', 'string'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'targetId', 'string'
-- The JSON request body created by the above code:
-- {
-- "deploymentId": "string",
-- "targetId": "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', 'CodeDeploy_20141006.GetDeploymentTarget'
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 @ErrorCode nvarchar(max)
DECLARE @LogTail nvarchar(max)
DECLARE @Message nvarchar(max)
DECLARE @ScriptName nvarchar(max)
DECLARE @endTime int
DECLARE @lifecycleEventName nvarchar(max)
DECLARE @startTime int
DECLARE @status nvarchar(max)
DECLARE @diagnosticsErrorCode nvarchar(max)
DECLARE @diagnosticsLogTail nvarchar(max)
DECLARE @diagnosticsMessage nvarchar(max)
DECLARE @diagnosticsScriptName nvarchar(max)
DECLARE @desiredCount int
DECLARE @identifer nvarchar(max)
DECLARE @pendingCount int
DECLARE @runningCount int
DECLARE @Name nvarchar(max)
DECLARE @taskSetLabel nvarchar(max)
DECLARE @trafficWeight int
DECLARE @DeploymentId nvarchar(max)
EXEC sp_OAMethod @jResp, 'StringOf', @DeploymentId OUT, 'deploymentTarget.cloudFormationTarget.deploymentId'
DECLARE @LastUpdatedAt int
EXEC sp_OAMethod @jResp, 'IntOf', @LastUpdatedAt OUT, 'deploymentTarget.cloudFormationTarget.lastUpdatedAt'
DECLARE @ResourceType nvarchar(max)
EXEC sp_OAMethod @jResp, 'StringOf', @ResourceType OUT, 'deploymentTarget.cloudFormationTarget.resourceType'
DECLARE @Status nvarchar(max)
EXEC sp_OAMethod @jResp, 'StringOf', @Status OUT, 'deploymentTarget.cloudFormationTarget.status'
DECLARE @TargetId nvarchar(max)
EXEC sp_OAMethod @jResp, 'StringOf', @TargetId OUT, 'deploymentTarget.cloudFormationTarget.targetId'
DECLARE @TargetVersionWeight int
EXEC sp_OAMethod @jResp, 'IntOf', @TargetVersionWeight OUT, 'deploymentTarget.cloudFormationTarget.targetVersionWeight'
DECLARE @DeploymentTargetType nvarchar(max)
EXEC sp_OAMethod @jResp, 'StringOf', @DeploymentTargetType OUT, 'deploymentTarget.deploymentTargetType'
DECLARE @EcsTargetDeploymentId nvarchar(max)
EXEC sp_OAMethod @jResp, 'StringOf', @EcsTargetDeploymentId OUT, 'deploymentTarget.ecsTarget.deploymentId'
DECLARE @EcsTargetLastUpdatedAt int
EXEC sp_OAMethod @jResp, 'IntOf', @EcsTargetLastUpdatedAt OUT, 'deploymentTarget.ecsTarget.lastUpdatedAt'
DECLARE @EcsTargetStatus nvarchar(max)
EXEC sp_OAMethod @jResp, 'StringOf', @EcsTargetStatus OUT, 'deploymentTarget.ecsTarget.status'
DECLARE @TargetArn nvarchar(max)
EXEC sp_OAMethod @jResp, 'StringOf', @TargetArn OUT, 'deploymentTarget.ecsTarget.targetArn'
DECLARE @EcsTargetTargetId nvarchar(max)
EXEC sp_OAMethod @jResp, 'StringOf', @EcsTargetTargetId OUT, 'deploymentTarget.ecsTarget.targetId'
DECLARE @InstanceTargetDeploymentId nvarchar(max)
EXEC sp_OAMethod @jResp, 'StringOf', @InstanceTargetDeploymentId OUT, 'deploymentTarget.instanceTarget.deploymentId'
DECLARE @InstanceLabel nvarchar(max)
EXEC sp_OAMethod @jResp, 'StringOf', @InstanceLabel OUT, 'deploymentTarget.instanceTarget.instanceLabel'
DECLARE @InstanceTargetLastUpdatedAt int
EXEC sp_OAMethod @jResp, 'IntOf', @InstanceTargetLastUpdatedAt OUT, 'deploymentTarget.instanceTarget.lastUpdatedAt'
DECLARE @InstanceTargetStatus nvarchar(max)
EXEC sp_OAMethod @jResp, 'StringOf', @InstanceTargetStatus OUT, 'deploymentTarget.instanceTarget.status'
DECLARE @InstanceTargetTargetArn nvarchar(max)
EXEC sp_OAMethod @jResp, 'StringOf', @InstanceTargetTargetArn OUT, 'deploymentTarget.instanceTarget.targetArn'
DECLARE @InstanceTargetTargetId nvarchar(max)
EXEC sp_OAMethod @jResp, 'StringOf', @InstanceTargetTargetId OUT, 'deploymentTarget.instanceTarget.targetId'
DECLARE @LambdaTargetDeploymentId nvarchar(max)
EXEC sp_OAMethod @jResp, 'StringOf', @LambdaTargetDeploymentId OUT, 'deploymentTarget.lambdaTarget.deploymentId'
DECLARE @CurrentVersion nvarchar(max)
EXEC sp_OAMethod @jResp, 'StringOf', @CurrentVersion OUT, 'deploymentTarget.lambdaTarget.lambdaFunctionInfo.currentVersion'
DECLARE @FunctionAlias nvarchar(max)
EXEC sp_OAMethod @jResp, 'StringOf', @FunctionAlias OUT, 'deploymentTarget.lambdaTarget.lambdaFunctionInfo.functionAlias'
DECLARE @FunctionName nvarchar(max)
EXEC sp_OAMethod @jResp, 'StringOf', @FunctionName OUT, 'deploymentTarget.lambdaTarget.lambdaFunctionInfo.functionName'
DECLARE @TargetVersion nvarchar(max)
EXEC sp_OAMethod @jResp, 'StringOf', @TargetVersion OUT, 'deploymentTarget.lambdaTarget.lambdaFunctionInfo.targetVersion'
DECLARE @LambdaFunctionInfoTargetVersionWeight int
EXEC sp_OAMethod @jResp, 'IntOf', @LambdaFunctionInfoTargetVersionWeight OUT, 'deploymentTarget.lambdaTarget.lambdaFunctionInfo.targetVersionWeight'
DECLARE @LambdaTargetLastUpdatedAt int
EXEC sp_OAMethod @jResp, 'IntOf', @LambdaTargetLastUpdatedAt OUT, 'deploymentTarget.lambdaTarget.lastUpdatedAt'
DECLARE @LambdaTargetStatus nvarchar(max)
EXEC sp_OAMethod @jResp, 'StringOf', @LambdaTargetStatus OUT, 'deploymentTarget.lambdaTarget.status'
DECLARE @LambdaTargetTargetArn nvarchar(max)
EXEC sp_OAMethod @jResp, 'StringOf', @LambdaTargetTargetArn OUT, 'deploymentTarget.lambdaTarget.targetArn'
DECLARE @LambdaTargetTargetId nvarchar(max)
EXEC sp_OAMethod @jResp, 'StringOf', @LambdaTargetTargetId OUT, 'deploymentTarget.lambdaTarget.targetId'
DECLARE @i int
SELECT @i = 0
DECLARE @count_i int
EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_i OUT, 'deploymentTarget.cloudFormationTarget.lifecycleEvents'
WHILE @i < @count_i
BEGIN
EXEC sp_OASetProperty @jResp, 'I', @i
EXEC sp_OAMethod @jResp, 'StringOf', @ErrorCode OUT, 'deploymentTarget.cloudFormationTarget.lifecycleEvents[i].diagnostics.errorCode'
EXEC sp_OAMethod @jResp, 'StringOf', @LogTail OUT, 'deploymentTarget.cloudFormationTarget.lifecycleEvents[i].diagnostics.logTail'
EXEC sp_OAMethod @jResp, 'StringOf', @Message OUT, 'deploymentTarget.cloudFormationTarget.lifecycleEvents[i].diagnostics.message'
EXEC sp_OAMethod @jResp, 'StringOf', @ScriptName OUT, 'deploymentTarget.cloudFormationTarget.lifecycleEvents[i].diagnostics.scriptName'
EXEC sp_OAMethod @jResp, 'IntOf', @endTime OUT, 'deploymentTarget.cloudFormationTarget.lifecycleEvents[i].endTime'
EXEC sp_OAMethod @jResp, 'StringOf', @lifecycleEventName OUT, 'deploymentTarget.cloudFormationTarget.lifecycleEvents[i].lifecycleEventName'
EXEC sp_OAMethod @jResp, 'IntOf', @startTime OUT, 'deploymentTarget.cloudFormationTarget.lifecycleEvents[i].startTime'
EXEC sp_OAMethod @jResp, 'StringOf', @status OUT, 'deploymentTarget.cloudFormationTarget.lifecycleEvents[i].status'
SELECT @i = @i + 1
END
SELECT @i = 0
EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_i OUT, 'deploymentTarget.ecsTarget.lifecycleEvents'
WHILE @i < @count_i
BEGIN
EXEC sp_OASetProperty @jResp, 'I', @i
EXEC sp_OAMethod @jResp, 'StringOf', @diagnosticsErrorCode OUT, 'deploymentTarget.ecsTarget.lifecycleEvents[i].diagnostics.errorCode'
EXEC sp_OAMethod @jResp, 'StringOf', @diagnosticsLogTail OUT, 'deploymentTarget.ecsTarget.lifecycleEvents[i].diagnostics.logTail'
EXEC sp_OAMethod @jResp, 'StringOf', @diagnosticsMessage OUT, 'deploymentTarget.ecsTarget.lifecycleEvents[i].diagnostics.message'
EXEC sp_OAMethod @jResp, 'StringOf', @diagnosticsScriptName OUT, 'deploymentTarget.ecsTarget.lifecycleEvents[i].diagnostics.scriptName'
EXEC sp_OAMethod @jResp, 'IntOf', @endTime OUT, 'deploymentTarget.ecsTarget.lifecycleEvents[i].endTime'
EXEC sp_OAMethod @jResp, 'StringOf', @lifecycleEventName OUT, 'deploymentTarget.ecsTarget.lifecycleEvents[i].lifecycleEventName'
EXEC sp_OAMethod @jResp, 'IntOf', @startTime OUT, 'deploymentTarget.ecsTarget.lifecycleEvents[i].startTime'
EXEC sp_OAMethod @jResp, 'StringOf', @status OUT, 'deploymentTarget.ecsTarget.lifecycleEvents[i].status'
SELECT @i = @i + 1
END
SELECT @i = 0
EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_i OUT, 'deploymentTarget.ecsTarget.taskSetsInfo'
WHILE @i < @count_i
BEGIN
EXEC sp_OASetProperty @jResp, 'I', @i
EXEC sp_OAMethod @jResp, 'IntOf', @desiredCount OUT, 'deploymentTarget.ecsTarget.taskSetsInfo[i].desiredCount'
EXEC sp_OAMethod @jResp, 'StringOf', @identifer OUT, 'deploymentTarget.ecsTarget.taskSetsInfo[i].identifer'
EXEC sp_OAMethod @jResp, 'IntOf', @pendingCount OUT, 'deploymentTarget.ecsTarget.taskSetsInfo[i].pendingCount'
EXEC sp_OAMethod @jResp, 'IntOf', @runningCount OUT, 'deploymentTarget.ecsTarget.taskSetsInfo[i].runningCount'
EXEC sp_OAMethod @jResp, 'StringOf', @status OUT, 'deploymentTarget.ecsTarget.taskSetsInfo[i].status'
EXEC sp_OAMethod @jResp, 'StringOf', @Name OUT, 'deploymentTarget.ecsTarget.taskSetsInfo[i].targetGroup.name'
EXEC sp_OAMethod @jResp, 'StringOf', @taskSetLabel OUT, 'deploymentTarget.ecsTarget.taskSetsInfo[i].taskSetLabel'
EXEC sp_OAMethod @jResp, 'IntOf', @trafficWeight OUT, 'deploymentTarget.ecsTarget.taskSetsInfo[i].trafficWeight'
SELECT @i = @i + 1
END
SELECT @i = 0
EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_i OUT, 'deploymentTarget.instanceTarget.lifecycleEvents'
WHILE @i < @count_i
BEGIN
EXEC sp_OASetProperty @jResp, 'I', @i
EXEC sp_OAMethod @jResp, 'StringOf', @diagnosticsErrorCode OUT, 'deploymentTarget.instanceTarget.lifecycleEvents[i].diagnostics.errorCode'
EXEC sp_OAMethod @jResp, 'StringOf', @diagnosticsLogTail OUT, 'deploymentTarget.instanceTarget.lifecycleEvents[i].diagnostics.logTail'
EXEC sp_OAMethod @jResp, 'StringOf', @diagnosticsMessage OUT, 'deploymentTarget.instanceTarget.lifecycleEvents[i].diagnostics.message'
EXEC sp_OAMethod @jResp, 'StringOf', @diagnosticsScriptName OUT, 'deploymentTarget.instanceTarget.lifecycleEvents[i].diagnostics.scriptName'
EXEC sp_OAMethod @jResp, 'IntOf', @endTime OUT, 'deploymentTarget.instanceTarget.lifecycleEvents[i].endTime'
EXEC sp_OAMethod @jResp, 'StringOf', @lifecycleEventName OUT, 'deploymentTarget.instanceTarget.lifecycleEvents[i].lifecycleEventName'
EXEC sp_OAMethod @jResp, 'IntOf', @startTime OUT, 'deploymentTarget.instanceTarget.lifecycleEvents[i].startTime'
EXEC sp_OAMethod @jResp, 'StringOf', @status OUT, 'deploymentTarget.instanceTarget.lifecycleEvents[i].status'
SELECT @i = @i + 1
END
SELECT @i = 0
EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_i OUT, 'deploymentTarget.lambdaTarget.lifecycleEvents'
WHILE @i < @count_i
BEGIN
EXEC sp_OASetProperty @jResp, 'I', @i
EXEC sp_OAMethod @jResp, 'StringOf', @diagnosticsErrorCode OUT, 'deploymentTarget.lambdaTarget.lifecycleEvents[i].diagnostics.errorCode'
EXEC sp_OAMethod @jResp, 'StringOf', @diagnosticsLogTail OUT, 'deploymentTarget.lambdaTarget.lifecycleEvents[i].diagnostics.logTail'
EXEC sp_OAMethod @jResp, 'StringOf', @diagnosticsMessage OUT, 'deploymentTarget.lambdaTarget.lifecycleEvents[i].diagnostics.message'
EXEC sp_OAMethod @jResp, 'StringOf', @diagnosticsScriptName OUT, 'deploymentTarget.lambdaTarget.lifecycleEvents[i].diagnostics.scriptName'
EXEC sp_OAMethod @jResp, 'IntOf', @endTime OUT, 'deploymentTarget.lambdaTarget.lifecycleEvents[i].endTime'
EXEC sp_OAMethod @jResp, 'StringOf', @lifecycleEventName OUT, 'deploymentTarget.lambdaTarget.lifecycleEvents[i].lifecycleEventName'
EXEC sp_OAMethod @jResp, 'IntOf', @startTime OUT, 'deploymentTarget.lambdaTarget.lifecycleEvents[i].startTime'
EXEC sp_OAMethod @jResp, 'StringOf', @status OUT, 'deploymentTarget.lambdaTarget.lifecycleEvents[i].status'
SELECT @i = @i + 1
END
-- A sample JSON response body parsed by the above code:
-- {
-- "deploymentTarget": {
-- "cloudFormationTarget": {
-- "deploymentId": "string",
-- "lastUpdatedAt": number,
-- "lifecycleEvents": [
-- {
-- "diagnostics": {
-- "errorCode": "string",
-- "logTail": "string",
-- "message": "string",
-- "scriptName": "string"
-- },
-- "endTime": number,
-- "lifecycleEventName": "string",
-- "startTime": number,
-- "status": "string"
-- }
-- ],
-- "resourceType": "string",
-- "status": "string",
-- "targetId": "string",
-- "targetVersionWeight": number
-- },
-- "deploymentTargetType": "string",
-- "ecsTarget": {
-- "deploymentId": "string",
-- "lastUpdatedAt": number,
-- "lifecycleEvents": [
-- {
-- "diagnostics": {
-- "errorCode": "string",
-- "logTail": "string",
-- "message": "string",
-- "scriptName": "string"
-- },
-- "endTime": number,
-- "lifecycleEventName": "string",
-- "startTime": number,
-- "status": "string"
-- }
-- ],
-- "status": "string",
-- "targetArn": "string",
-- "targetId": "string",
-- "taskSetsInfo": [
-- {
-- "desiredCount": number,
-- "identifer": "string",
-- "pendingCount": number,
-- "runningCount": number,
-- "status": "string",
-- "targetGroup": {
-- "name": "string"
-- },
-- "taskSetLabel": "string",
-- "trafficWeight": number
-- }
-- ]
-- },
-- "instanceTarget": {
-- "deploymentId": "string",
-- "instanceLabel": "string",
-- "lastUpdatedAt": number,
-- "lifecycleEvents": [
-- {
-- "diagnostics": {
-- "errorCode": "string",
-- "logTail": "string",
-- "message": "string",
-- "scriptName": "string"
-- },
-- "endTime": number,
-- "lifecycleEventName": "string",
-- "startTime": number,
-- "status": "string"
-- }
-- ],
-- "status": "string",
-- "targetArn": "string",
-- "targetId": "string"
-- },
-- "lambdaTarget": {
-- "deploymentId": "string",
-- "lambdaFunctionInfo": {
-- "currentVersion": "string",
-- "functionAlias": "string",
-- "functionName": "string",
-- "targetVersion": "string",
-- "targetVersionWeight": number
-- },
-- "lastUpdatedAt": number,
-- "lifecycleEvents": [
-- {
-- "diagnostics": {
-- "errorCode": "string",
-- "logTail": "string",
-- "message": "string",
-- "scriptName": "string"
-- },
-- "endTime": number,
-- "lifecycleEventName": "string",
-- "startTime": number,
-- "status": "string"
-- }
-- ],
-- "status": "string",
-- "targetArn": "string",
-- "targetId": "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