Chilkat Online Tools

RetryBuild SQL Server Example

AWS CodeBuild

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', 'codebuild'
    -- SetAuthAws causes Chilkat to automatically add the following headers: Authorization, X-Amz-Date
    EXEC sp_OAMethod @rest, 'SetAuthAws', @success OUT, @authAws

    -- URL: https://codebuild.us-west-2.amazonaws.com/
    -- Use the same region as specified above.
    EXEC sp_OAMethod @rest, 'Connect', @success OUT, 'codebuild.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, 'id', 'string'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'idempotencyToken', 'string'

    -- The JSON request body created by the above code:

    -- {
    --   "id": "string",
    --   "idempotencyToken": "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', 'CodeBuild_20161006.RetryBuild'

    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 @strVal nvarchar(max)

    DECLARE @name nvarchar(max)

    DECLARE @v_type nvarchar(max)

    DECLARE @value nvarchar(max)

    DECLARE @identifier nvarchar(max)

    DECLARE @location nvarchar(max)

    DECLARE @mountOptions nvarchar(max)

    DECLARE @mountPoint nvarchar(max)

    DECLARE @durationInSeconds int

    DECLARE @endTime int

    DECLARE @phaseStatus nvarchar(max)

    DECLARE @phaseType nvarchar(max)

    DECLARE @startTime int

    DECLARE @j int

    DECLARE @count_j int

    DECLARE @message nvarchar(max)

    DECLARE @statusCode nvarchar(max)

    DECLARE @artifactIdentifier nvarchar(max)

    DECLARE @bucketOwnerAccess nvarchar(max)

    DECLARE @encryptionDisabled int

    DECLARE @md5sum nvarchar(max)

    DECLARE @overrideArtifactName int

    DECLARE @sha256sum nvarchar(max)

    DECLARE @authResource nvarchar(max)

    DECLARE @authType nvarchar(max)

    DECLARE @buildspec nvarchar(max)

    DECLARE @buildStatusConfigContext nvarchar(max)

    DECLARE @buildStatusConfigTargetUrl nvarchar(max)

    DECLARE @gitCloneDepth int

    DECLARE @gitSubmodulesConfigFetchSubmodules int

    DECLARE @insecureSsl int

    DECLARE @reportBuildStatus int

    DECLARE @sourceIdentifier nvarchar(max)

    DECLARE @sourceVersion nvarchar(max)

    DECLARE @Arn nvarchar(max)
    EXEC sp_OAMethod @jResp, 'StringOf', @Arn OUT, 'build.arn'
    DECLARE @ArtifactIdentifier nvarchar(max)
    EXEC sp_OAMethod @jResp, 'StringOf', @ArtifactIdentifier OUT, 'build.artifacts.artifactIdentifier'
    DECLARE @BucketOwnerAccess nvarchar(max)
    EXEC sp_OAMethod @jResp, 'StringOf', @BucketOwnerAccess OUT, 'build.artifacts.bucketOwnerAccess'
    DECLARE @EncryptionDisabled int
    EXEC sp_OAMethod @jResp, 'IntOf', @EncryptionDisabled OUT, 'build.artifacts.encryptionDisabled'
    DECLARE @Location nvarchar(max)
    EXEC sp_OAMethod @jResp, 'StringOf', @Location OUT, 'build.artifacts.location'
    DECLARE @Md5sum nvarchar(max)
    EXEC sp_OAMethod @jResp, 'StringOf', @Md5sum OUT, 'build.artifacts.md5sum'
    DECLARE @OverrideArtifactName int
    EXEC sp_OAMethod @jResp, 'IntOf', @OverrideArtifactName OUT, 'build.artifacts.overrideArtifactName'
    DECLARE @Sha256sum nvarchar(max)
    EXEC sp_OAMethod @jResp, 'StringOf', @Sha256sum OUT, 'build.artifacts.sha256sum'
    DECLARE @BuildBatchArn nvarchar(max)
    EXEC sp_OAMethod @jResp, 'StringOf', @BuildBatchArn OUT, 'build.buildBatchArn'
    DECLARE @BuildComplete int
    EXEC sp_OAMethod @jResp, 'IntOf', @BuildComplete OUT, 'build.buildComplete'
    DECLARE @BuildNumber int
    EXEC sp_OAMethod @jResp, 'IntOf', @BuildNumber OUT, 'build.buildNumber'
    DECLARE @BuildStatus nvarchar(max)
    EXEC sp_OAMethod @jResp, 'StringOf', @BuildStatus OUT, 'build.buildStatus'
    DECLARE @CacheLocation nvarchar(max)
    EXEC sp_OAMethod @jResp, 'StringOf', @CacheLocation OUT, 'build.cache.location'
    DECLARE @v_Type nvarchar(max)
    EXEC sp_OAMethod @jResp, 'StringOf', @v_Type OUT, 'build.cache.type'
    DECLARE @CurrentPhase nvarchar(max)
    EXEC sp_OAMethod @jResp, 'StringOf', @CurrentPhase OUT, 'build.currentPhase'
    DECLARE @SessionEnabled int
    EXEC sp_OAMethod @jResp, 'IntOf', @SessionEnabled OUT, 'build.debugSession.sessionEnabled'
    DECLARE @SessionTarget nvarchar(max)
    EXEC sp_OAMethod @jResp, 'StringOf', @SessionTarget OUT, 'build.debugSession.sessionTarget'
    DECLARE @EncryptionKey nvarchar(max)
    EXEC sp_OAMethod @jResp, 'StringOf', @EncryptionKey OUT, 'build.encryptionKey'
    DECLARE @EndTime int
    EXEC sp_OAMethod @jResp, 'IntOf', @EndTime OUT, 'build.endTime'
    DECLARE @Certificate nvarchar(max)
    EXEC sp_OAMethod @jResp, 'StringOf', @Certificate OUT, 'build.environment.certificate'
    DECLARE @ComputeType nvarchar(max)
    EXEC sp_OAMethod @jResp, 'StringOf', @ComputeType OUT, 'build.environment.computeType'
    DECLARE @Image nvarchar(max)
    EXEC sp_OAMethod @jResp, 'StringOf', @Image OUT, 'build.environment.image'
    DECLARE @ImagePullCredentialsType nvarchar(max)
    EXEC sp_OAMethod @jResp, 'StringOf', @ImagePullCredentialsType OUT, 'build.environment.imagePullCredentialsType'
    DECLARE @PrivilegedMode int
    EXEC sp_OAMethod @jResp, 'IntOf', @PrivilegedMode OUT, 'build.environment.privilegedMode'
    DECLARE @Credential nvarchar(max)
    EXEC sp_OAMethod @jResp, 'StringOf', @Credential OUT, 'build.environment.registryCredential.credential'
    DECLARE @CredentialProvider nvarchar(max)
    EXEC sp_OAMethod @jResp, 'StringOf', @CredentialProvider OUT, 'build.environment.registryCredential.credentialProvider'
    DECLARE @EnvironmentType nvarchar(max)
    EXEC sp_OAMethod @jResp, 'StringOf', @EnvironmentType OUT, 'build.environment.type'
    DECLARE @Id nvarchar(max)
    EXEC sp_OAMethod @jResp, 'StringOf', @Id OUT, 'build.id'
    DECLARE @Initiator nvarchar(max)
    EXEC sp_OAMethod @jResp, 'StringOf', @Initiator OUT, 'build.initiator'
    DECLARE @GroupName nvarchar(max)
    EXEC sp_OAMethod @jResp, 'StringOf', @GroupName OUT, 'build.logs.cloudWatchLogs.groupName'
    DECLARE @Status nvarchar(max)
    EXEC sp_OAMethod @jResp, 'StringOf', @Status OUT, 'build.logs.cloudWatchLogs.status'
    DECLARE @StreamName nvarchar(max)
    EXEC sp_OAMethod @jResp, 'StringOf', @StreamName OUT, 'build.logs.cloudWatchLogs.streamName'
    DECLARE @CloudWatchLogsArn nvarchar(max)
    EXEC sp_OAMethod @jResp, 'StringOf', @CloudWatchLogsArn OUT, 'build.logs.cloudWatchLogsArn'
    DECLARE @DeepLink nvarchar(max)
    EXEC sp_OAMethod @jResp, 'StringOf', @DeepLink OUT, 'build.logs.deepLink'
    DECLARE @LogsGroupName nvarchar(max)
    EXEC sp_OAMethod @jResp, 'StringOf', @LogsGroupName OUT, 'build.logs.groupName'
    DECLARE @S3DeepLink nvarchar(max)
    EXEC sp_OAMethod @jResp, 'StringOf', @S3DeepLink OUT, 'build.logs.s3DeepLink'
    DECLARE @S3LogsBucketOwnerAccess nvarchar(max)
    EXEC sp_OAMethod @jResp, 'StringOf', @S3LogsBucketOwnerAccess OUT, 'build.logs.s3Logs.bucketOwnerAccess'
    DECLARE @S3LogsEncryptionDisabled int
    EXEC sp_OAMethod @jResp, 'IntOf', @S3LogsEncryptionDisabled OUT, 'build.logs.s3Logs.encryptionDisabled'
    DECLARE @S3LogsLocation nvarchar(max)
    EXEC sp_OAMethod @jResp, 'StringOf', @S3LogsLocation OUT, 'build.logs.s3Logs.location'
    DECLARE @S3LogsStatus nvarchar(max)
    EXEC sp_OAMethod @jResp, 'StringOf', @S3LogsStatus OUT, 'build.logs.s3Logs.status'
    DECLARE @S3LogsArn nvarchar(max)
    EXEC sp_OAMethod @jResp, 'StringOf', @S3LogsArn OUT, 'build.logs.s3LogsArn'
    DECLARE @LogsStreamName nvarchar(max)
    EXEC sp_OAMethod @jResp, 'StringOf', @LogsStreamName OUT, 'build.logs.streamName'
    DECLARE @NetworkInterfaceId nvarchar(max)
    EXEC sp_OAMethod @jResp, 'StringOf', @NetworkInterfaceId OUT, 'build.networkInterface.networkInterfaceId'
    DECLARE @SubnetId nvarchar(max)
    EXEC sp_OAMethod @jResp, 'StringOf', @SubnetId OUT, 'build.networkInterface.subnetId'
    DECLARE @ProjectName nvarchar(max)
    EXEC sp_OAMethod @jResp, 'StringOf', @ProjectName OUT, 'build.projectName'
    DECLARE @QueuedTimeoutInMinutes int
    EXEC sp_OAMethod @jResp, 'IntOf', @QueuedTimeoutInMinutes OUT, 'build.queuedTimeoutInMinutes'
    DECLARE @ResolvedSourceVersion nvarchar(max)
    EXEC sp_OAMethod @jResp, 'StringOf', @ResolvedSourceVersion OUT, 'build.resolvedSourceVersion'
    DECLARE @ServiceRole nvarchar(max)
    EXEC sp_OAMethod @jResp, 'StringOf', @ServiceRole OUT, 'build.serviceRole'
    DECLARE @Resource nvarchar(max)
    EXEC sp_OAMethod @jResp, 'StringOf', @Resource OUT, 'build.source.auth.resource'
    DECLARE @AuthType nvarchar(max)
    EXEC sp_OAMethod @jResp, 'StringOf', @AuthType OUT, 'build.source.auth.type'
    DECLARE @Buildspec nvarchar(max)
    EXEC sp_OAMethod @jResp, 'StringOf', @Buildspec OUT, 'build.source.buildspec'
    DECLARE @Context nvarchar(max)
    EXEC sp_OAMethod @jResp, 'StringOf', @Context OUT, 'build.source.buildStatusConfig.context'
    DECLARE @TargetUrl nvarchar(max)
    EXEC sp_OAMethod @jResp, 'StringOf', @TargetUrl OUT, 'build.source.buildStatusConfig.targetUrl'
    DECLARE @GitCloneDepth int
    EXEC sp_OAMethod @jResp, 'IntOf', @GitCloneDepth OUT, 'build.source.gitCloneDepth'
    DECLARE @FetchSubmodules int
    EXEC sp_OAMethod @jResp, 'IntOf', @FetchSubmodules OUT, 'build.source.gitSubmodulesConfig.fetchSubmodules'
    DECLARE @InsecureSsl int
    EXEC sp_OAMethod @jResp, 'IntOf', @InsecureSsl OUT, 'build.source.insecureSsl'
    DECLARE @SourceLocation nvarchar(max)
    EXEC sp_OAMethod @jResp, 'StringOf', @SourceLocation OUT, 'build.source.location'
    DECLARE @ReportBuildStatus int
    EXEC sp_OAMethod @jResp, 'IntOf', @ReportBuildStatus OUT, 'build.source.reportBuildStatus'
    DECLARE @SourceIdentifier nvarchar(max)
    EXEC sp_OAMethod @jResp, 'StringOf', @SourceIdentifier OUT, 'build.source.sourceIdentifier'
    DECLARE @SourceType nvarchar(max)
    EXEC sp_OAMethod @jResp, 'StringOf', @SourceType OUT, 'build.source.type'
    DECLARE @SourceVersion nvarchar(max)
    EXEC sp_OAMethod @jResp, 'StringOf', @SourceVersion OUT, 'build.sourceVersion'
    DECLARE @StartTime int
    EXEC sp_OAMethod @jResp, 'IntOf', @StartTime OUT, 'build.startTime'
    DECLARE @TimeoutInMinutes int
    EXEC sp_OAMethod @jResp, 'IntOf', @TimeoutInMinutes OUT, 'build.timeoutInMinutes'
    DECLARE @VpcId nvarchar(max)
    EXEC sp_OAMethod @jResp, 'StringOf', @VpcId OUT, 'build.vpcConfig.vpcId'
    DECLARE @i int
    SELECT @i = 0
    DECLARE @count_i int
    EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_i OUT, 'build.cache.modes'
    WHILE @i < @count_i
      BEGIN
        EXEC sp_OASetProperty @jResp, 'I', @i
        EXEC sp_OAMethod @jResp, 'StringOf', @strVal OUT, 'build.cache.modes[i]'
        SELECT @i = @i + 1
      END
    SELECT @i = 0
    EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_i OUT, 'build.environment.environmentVariables'
    WHILE @i < @count_i
      BEGIN
        EXEC sp_OASetProperty @jResp, 'I', @i
        EXEC sp_OAMethod @jResp, 'StringOf', @name OUT, 'build.environment.environmentVariables[i].name'
        EXEC sp_OAMethod @jResp, 'StringOf', @v_type OUT, 'build.environment.environmentVariables[i].type'
        EXEC sp_OAMethod @jResp, 'StringOf', @value OUT, 'build.environment.environmentVariables[i].value'
        SELECT @i = @i + 1
      END
    SELECT @i = 0
    EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_i OUT, 'build.exportedEnvironmentVariables'
    WHILE @i < @count_i
      BEGIN
        EXEC sp_OASetProperty @jResp, 'I', @i
        EXEC sp_OAMethod @jResp, 'StringOf', @name OUT, 'build.exportedEnvironmentVariables[i].name'
        EXEC sp_OAMethod @jResp, 'StringOf', @value OUT, 'build.exportedEnvironmentVariables[i].value'
        SELECT @i = @i + 1
      END
    SELECT @i = 0
    EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_i OUT, 'build.fileSystemLocations'
    WHILE @i < @count_i
      BEGIN
        EXEC sp_OASetProperty @jResp, 'I', @i
        EXEC sp_OAMethod @jResp, 'StringOf', @identifier OUT, 'build.fileSystemLocations[i].identifier'
        EXEC sp_OAMethod @jResp, 'StringOf', @location OUT, 'build.fileSystemLocations[i].location'
        EXEC sp_OAMethod @jResp, 'StringOf', @mountOptions OUT, 'build.fileSystemLocations[i].mountOptions'
        EXEC sp_OAMethod @jResp, 'StringOf', @mountPoint OUT, 'build.fileSystemLocations[i].mountPoint'
        EXEC sp_OAMethod @jResp, 'StringOf', @v_type OUT, 'build.fileSystemLocations[i].type'
        SELECT @i = @i + 1
      END
    SELECT @i = 0
    EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_i OUT, 'build.phases'
    WHILE @i < @count_i
      BEGIN
        EXEC sp_OASetProperty @jResp, 'I', @i
        EXEC sp_OAMethod @jResp, 'IntOf', @durationInSeconds OUT, 'build.phases[i].durationInSeconds'
        EXEC sp_OAMethod @jResp, 'IntOf', @endTime OUT, 'build.phases[i].endTime'
        EXEC sp_OAMethod @jResp, 'StringOf', @phaseStatus OUT, 'build.phases[i].phaseStatus'
        EXEC sp_OAMethod @jResp, 'StringOf', @phaseType OUT, 'build.phases[i].phaseType'
        EXEC sp_OAMethod @jResp, 'IntOf', @startTime OUT, 'build.phases[i].startTime'
        SELECT @j = 0
        EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_j OUT, 'build.phases[i].contexts'
        WHILE @j < @count_j
          BEGIN
            EXEC sp_OASetProperty @jResp, 'J', @j
            EXEC sp_OAMethod @jResp, 'StringOf', @message OUT, 'build.phases[i].contexts[j].message'
            EXEC sp_OAMethod @jResp, 'StringOf', @statusCode OUT, 'build.phases[i].contexts[j].statusCode'
            SELECT @j = @j + 1
          END
        SELECT @i = @i + 1
      END
    SELECT @i = 0
    EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_i OUT, 'build.reportArns'
    WHILE @i < @count_i
      BEGIN
        EXEC sp_OASetProperty @jResp, 'I', @i
        EXEC sp_OAMethod @jResp, 'StringOf', @strVal OUT, 'build.reportArns[i]'
        SELECT @i = @i + 1
      END
    SELECT @i = 0
    EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_i OUT, 'build.secondaryArtifacts'
    WHILE @i < @count_i
      BEGIN
        EXEC sp_OASetProperty @jResp, 'I', @i
        EXEC sp_OAMethod @jResp, 'StringOf', @artifactIdentifier OUT, 'build.secondaryArtifacts[i].artifactIdentifier'
        EXEC sp_OAMethod @jResp, 'StringOf', @bucketOwnerAccess OUT, 'build.secondaryArtifacts[i].bucketOwnerAccess'
        EXEC sp_OAMethod @jResp, 'IntOf', @encryptionDisabled OUT, 'build.secondaryArtifacts[i].encryptionDisabled'
        EXEC sp_OAMethod @jResp, 'StringOf', @location OUT, 'build.secondaryArtifacts[i].location'
        EXEC sp_OAMethod @jResp, 'StringOf', @md5sum OUT, 'build.secondaryArtifacts[i].md5sum'
        EXEC sp_OAMethod @jResp, 'IntOf', @overrideArtifactName OUT, 'build.secondaryArtifacts[i].overrideArtifactName'
        EXEC sp_OAMethod @jResp, 'StringOf', @sha256sum OUT, 'build.secondaryArtifacts[i].sha256sum'
        SELECT @i = @i + 1
      END
    SELECT @i = 0
    EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_i OUT, 'build.secondarySources'
    WHILE @i < @count_i
      BEGIN
        EXEC sp_OASetProperty @jResp, 'I', @i
        EXEC sp_OAMethod @jResp, 'StringOf', @authResource OUT, 'build.secondarySources[i].auth.resource'
        EXEC sp_OAMethod @jResp, 'StringOf', @authType OUT, 'build.secondarySources[i].auth.type'
        EXEC sp_OAMethod @jResp, 'StringOf', @buildspec OUT, 'build.secondarySources[i].buildspec'
        EXEC sp_OAMethod @jResp, 'StringOf', @buildStatusConfigContext OUT, 'build.secondarySources[i].buildStatusConfig.context'
        EXEC sp_OAMethod @jResp, 'StringOf', @buildStatusConfigTargetUrl OUT, 'build.secondarySources[i].buildStatusConfig.targetUrl'
        EXEC sp_OAMethod @jResp, 'IntOf', @gitCloneDepth OUT, 'build.secondarySources[i].gitCloneDepth'
        EXEC sp_OAMethod @jResp, 'IntOf', @gitSubmodulesConfigFetchSubmodules OUT, 'build.secondarySources[i].gitSubmodulesConfig.fetchSubmodules'
        EXEC sp_OAMethod @jResp, 'IntOf', @insecureSsl OUT, 'build.secondarySources[i].insecureSsl'
        EXEC sp_OAMethod @jResp, 'StringOf', @location OUT, 'build.secondarySources[i].location'
        EXEC sp_OAMethod @jResp, 'IntOf', @reportBuildStatus OUT, 'build.secondarySources[i].reportBuildStatus'
        EXEC sp_OAMethod @jResp, 'StringOf', @sourceIdentifier OUT, 'build.secondarySources[i].sourceIdentifier'
        EXEC sp_OAMethod @jResp, 'StringOf', @v_type OUT, 'build.secondarySources[i].type'
        SELECT @i = @i + 1
      END
    SELECT @i = 0
    EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_i OUT, 'build.secondarySourceVersions'
    WHILE @i < @count_i
      BEGIN
        EXEC sp_OASetProperty @jResp, 'I', @i
        EXEC sp_OAMethod @jResp, 'StringOf', @sourceIdentifier OUT, 'build.secondarySourceVersions[i].sourceIdentifier'
        EXEC sp_OAMethod @jResp, 'StringOf', @sourceVersion OUT, 'build.secondarySourceVersions[i].sourceVersion'
        SELECT @i = @i + 1
      END
    SELECT @i = 0
    EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_i OUT, 'build.vpcConfig.securityGroupIds'
    WHILE @i < @count_i
      BEGIN
        EXEC sp_OASetProperty @jResp, 'I', @i
        EXEC sp_OAMethod @jResp, 'StringOf', @strVal OUT, 'build.vpcConfig.securityGroupIds[i]'
        SELECT @i = @i + 1
      END
    SELECT @i = 0
    EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_i OUT, 'build.vpcConfig.subnets'
    WHILE @i < @count_i
      BEGIN
        EXEC sp_OASetProperty @jResp, 'I', @i
        EXEC sp_OAMethod @jResp, 'StringOf', @strVal OUT, 'build.vpcConfig.subnets[i]'
        SELECT @i = @i + 1
      END

    -- A sample JSON response body parsed by the above code:

    -- {
    --   "build": {
    --     "arn": "string",
    --     "artifacts": {
    --       "artifactIdentifier": "string",
    --       "bucketOwnerAccess": "string",
    --       "encryptionDisabled": boolean,
    --       "location": "string",
    --       "md5sum": "string",
    --       "overrideArtifactName": boolean,
    --       "sha256sum": "string"
    --     },
    --     "buildBatchArn": "string",
    --     "buildComplete": boolean,
    --     "buildNumber": number,
    --     "buildStatus": "string",
    --     "cache": {
    --       "location": "string",
    --       "modes": [
    --         "string"
    --       ],
    --       "type": "string"
    --     },
    --     "currentPhase": "string",
    --     "debugSession": {
    --       "sessionEnabled": boolean,
    --       "sessionTarget": "string"
    --     },
    --     "encryptionKey": "string",
    --     "endTime": number,
    --     "environment": {
    --       "certificate": "string",
    --       "computeType": "string",
    --       "environmentVariables": [
    --         {
    --           "name": "string",
    --           "type": "string",
    --           "value": "string"
    --         }
    --       ],
    --       "image": "string",
    --       "imagePullCredentialsType": "string",
    --       "privilegedMode": boolean,
    --       "registryCredential": {
    --         "credential": "string",
    --         "credentialProvider": "string"
    --       },
    --       "type": "string"
    --     },
    --     "exportedEnvironmentVariables": [
    --       {
    --         "name": "string",
    --         "value": "string"
    --       }
    --     ],
    --     "fileSystemLocations": [
    --       {
    --         "identifier": "string",
    --         "location": "string",
    --         "mountOptions": "string",
    --         "mountPoint": "string",
    --         "type": "string"
    --       }
    --     ],
    --     "id": "string",
    --     "initiator": "string",
    --     "logs": {
    --       "cloudWatchLogs": {
    --         "groupName": "string",
    --         "status": "string",
    --         "streamName": "string"
    --       },
    --       "cloudWatchLogsArn": "string",
    --       "deepLink": "string",
    --       "groupName": "string",
    --       "s3DeepLink": "string",
    --       "s3Logs": {
    --         "bucketOwnerAccess": "string",
    --         "encryptionDisabled": boolean,
    --         "location": "string",
    --         "status": "string"
    --       },
    --       "s3LogsArn": "string",
    --       "streamName": "string"
    --     },
    --     "networkInterface": {
    --       "networkInterfaceId": "string",
    --       "subnetId": "string"
    --     },
    --     "phases": [
    --       {
    --         "contexts": [
    --           {
    --             "message": "string",
    --             "statusCode": "string"
    --           }
    --         ],
    --         "durationInSeconds": number,
    --         "endTime": number,
    --         "phaseStatus": "string",
    --         "phaseType": "string",
    --         "startTime": number
    --       }
    --     ],
    --     "projectName": "string",
    --     "queuedTimeoutInMinutes": number,
    --     "reportArns": [
    --       "string"
    --     ],
    --     "resolvedSourceVersion": "string",
    --     "secondaryArtifacts": [
    --       {
    --         "artifactIdentifier": "string",
    --         "bucketOwnerAccess": "string",
    --         "encryptionDisabled": boolean,
    --         "location": "string",
    --         "md5sum": "string",
    --         "overrideArtifactName": boolean,
    --         "sha256sum": "string"
    --       }
    --     ],
    --     "secondarySources": [
    --       {
    --         "auth": {
    --           "resource": "string",
    --           "type": "string"
    --         },
    --         "buildspec": "string",
    --         "buildStatusConfig": {
    --           "context": "string",
    --           "targetUrl": "string"
    --         },
    --         "gitCloneDepth": number,
    --         "gitSubmodulesConfig": {
    --           "fetchSubmodules": boolean
    --         },
    --         "insecureSsl": boolean,
    --         "location": "string",
    --         "reportBuildStatus": boolean,
    --         "sourceIdentifier": "string",
    --         "type": "string"
    --       }
    --     ],
    --     "secondarySourceVersions": [
    --       {
    --         "sourceIdentifier": "string",
    --         "sourceVersion": "string"
    --       }
    --     ],
    --     "serviceRole": "string",
    --     "source": {
    --       "auth": {
    --         "resource": "string",
    --         "type": "string"
    --       },
    --       "buildspec": "string",
    --       "buildStatusConfig": {
    --         "context": "string",
    --         "targetUrl": "string"
    --       },
    --       "gitCloneDepth": number,
    --       "gitSubmodulesConfig": {
    --         "fetchSubmodules": boolean
    --       },
    --       "insecureSsl": boolean,
    --       "location": "string",
    --       "reportBuildStatus": boolean,
    --       "sourceIdentifier": "string",
    --       "type": "string"
    --     },
    --     "sourceVersion": "string",
    --     "startTime": number,
    --     "timeoutInMinutes": number,
    --     "vpcConfig": {
    --       "securityGroupIds": [
    --         "string"
    --       ],
    --       "subnets": [
    --         "string"
    --       ],
    --       "vpcId": "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