Chilkat Online Tools

RetryBuildBatch 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'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'retryType', 'string'

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

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

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

    DECLARE @BuildStatus nvarchar(max)

    DECLARE @Identifier nvarchar(max)

    DECLARE @PrimaryArtifactLocation nvarchar(max)

    DECLARE @PrimaryArtifactType nvarchar(max)

    DECLARE @RequestedOn int

    DECLARE @identifier nvarchar(max)

    DECLARE @ignoreFailure int

    DECLARE @j int

    DECLARE @count_j int

    DECLARE @location nvarchar(max)

    DECLARE @v_type nvarchar(max)

    DECLARE @arn nvarchar(max)

    DECLARE @buildStatus nvarchar(max)

    DECLARE @primaryArtifactIdentifier nvarchar(max)

    DECLARE @primaryArtifactLocation nvarchar(max)

    DECLARE @primaryArtifactType nvarchar(max)

    DECLARE @requestedOn int

    DECLARE @k int

    DECLARE @count_k int

    DECLARE @name nvarchar(max)

    DECLARE @value 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 @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, 'buildBatch.arn'
    DECLARE @ArtifactIdentifier nvarchar(max)
    EXEC sp_OAMethod @jResp, 'StringOf', @ArtifactIdentifier OUT, 'buildBatch.artifacts.artifactIdentifier'
    DECLARE @BucketOwnerAccess nvarchar(max)
    EXEC sp_OAMethod @jResp, 'StringOf', @BucketOwnerAccess OUT, 'buildBatch.artifacts.bucketOwnerAccess'
    DECLARE @EncryptionDisabled int
    EXEC sp_OAMethod @jResp, 'IntOf', @EncryptionDisabled OUT, 'buildBatch.artifacts.encryptionDisabled'
    DECLARE @Location nvarchar(max)
    EXEC sp_OAMethod @jResp, 'StringOf', @Location OUT, 'buildBatch.artifacts.location'
    DECLARE @Md5sum nvarchar(max)
    EXEC sp_OAMethod @jResp, 'StringOf', @Md5sum OUT, 'buildBatch.artifacts.md5sum'
    DECLARE @OverrideArtifactName int
    EXEC sp_OAMethod @jResp, 'IntOf', @OverrideArtifactName OUT, 'buildBatch.artifacts.overrideArtifactName'
    DECLARE @Sha256sum nvarchar(max)
    EXEC sp_OAMethod @jResp, 'StringOf', @Sha256sum OUT, 'buildBatch.artifacts.sha256sum'
    DECLARE @BatchReportMode nvarchar(max)
    EXEC sp_OAMethod @jResp, 'StringOf', @BatchReportMode OUT, 'buildBatch.buildBatchConfig.batchReportMode'
    DECLARE @CombineArtifacts int
    EXEC sp_OAMethod @jResp, 'IntOf', @CombineArtifacts OUT, 'buildBatch.buildBatchConfig.combineArtifacts'
    DECLARE @MaximumBuildsAllowed int
    EXEC sp_OAMethod @jResp, 'IntOf', @MaximumBuildsAllowed OUT, 'buildBatch.buildBatchConfig.restrictions.maximumBuildsAllowed'
    DECLARE @ServiceRole nvarchar(max)
    EXEC sp_OAMethod @jResp, 'StringOf', @ServiceRole OUT, 'buildBatch.buildBatchConfig.serviceRole'
    DECLARE @TimeoutInMins int
    EXEC sp_OAMethod @jResp, 'IntOf', @TimeoutInMins OUT, 'buildBatch.buildBatchConfig.timeoutInMins'
    DECLARE @BuildBatchNumber int
    EXEC sp_OAMethod @jResp, 'IntOf', @BuildBatchNumber OUT, 'buildBatch.buildBatchNumber'
    DECLARE @BuildBatchStatus nvarchar(max)
    EXEC sp_OAMethod @jResp, 'StringOf', @BuildBatchStatus OUT, 'buildBatch.buildBatchStatus'
    DECLARE @BuildTimeoutInMinutes int
    EXEC sp_OAMethod @jResp, 'IntOf', @BuildTimeoutInMinutes OUT, 'buildBatch.buildTimeoutInMinutes'
    DECLARE @CacheLocation nvarchar(max)
    EXEC sp_OAMethod @jResp, 'StringOf', @CacheLocation OUT, 'buildBatch.cache.location'
    DECLARE @v_Type nvarchar(max)
    EXEC sp_OAMethod @jResp, 'StringOf', @v_Type OUT, 'buildBatch.cache.type'
    DECLARE @Complete int
    EXEC sp_OAMethod @jResp, 'IntOf', @Complete OUT, 'buildBatch.complete'
    DECLARE @CurrentPhase nvarchar(max)
    EXEC sp_OAMethod @jResp, 'StringOf', @CurrentPhase OUT, 'buildBatch.currentPhase'
    DECLARE @DebugSessionEnabled int
    EXEC sp_OAMethod @jResp, 'IntOf', @DebugSessionEnabled OUT, 'buildBatch.debugSessionEnabled'
    DECLARE @EncryptionKey nvarchar(max)
    EXEC sp_OAMethod @jResp, 'StringOf', @EncryptionKey OUT, 'buildBatch.encryptionKey'
    DECLARE @EndTime int
    EXEC sp_OAMethod @jResp, 'IntOf', @EndTime OUT, 'buildBatch.endTime'
    DECLARE @Certificate nvarchar(max)
    EXEC sp_OAMethod @jResp, 'StringOf', @Certificate OUT, 'buildBatch.environment.certificate'
    DECLARE @ComputeType nvarchar(max)
    EXEC sp_OAMethod @jResp, 'StringOf', @ComputeType OUT, 'buildBatch.environment.computeType'
    DECLARE @Image nvarchar(max)
    EXEC sp_OAMethod @jResp, 'StringOf', @Image OUT, 'buildBatch.environment.image'
    DECLARE @ImagePullCredentialsType nvarchar(max)
    EXEC sp_OAMethod @jResp, 'StringOf', @ImagePullCredentialsType OUT, 'buildBatch.environment.imagePullCredentialsType'
    DECLARE @PrivilegedMode int
    EXEC sp_OAMethod @jResp, 'IntOf', @PrivilegedMode OUT, 'buildBatch.environment.privilegedMode'
    DECLARE @Credential nvarchar(max)
    EXEC sp_OAMethod @jResp, 'StringOf', @Credential OUT, 'buildBatch.environment.registryCredential.credential'
    DECLARE @CredentialProvider nvarchar(max)
    EXEC sp_OAMethod @jResp, 'StringOf', @CredentialProvider OUT, 'buildBatch.environment.registryCredential.credentialProvider'
    DECLARE @EnvironmentType nvarchar(max)
    EXEC sp_OAMethod @jResp, 'StringOf', @EnvironmentType OUT, 'buildBatch.environment.type'
    DECLARE @Id nvarchar(max)
    EXEC sp_OAMethod @jResp, 'StringOf', @Id OUT, 'buildBatch.id'
    DECLARE @Initiator nvarchar(max)
    EXEC sp_OAMethod @jResp, 'StringOf', @Initiator OUT, 'buildBatch.initiator'
    DECLARE @GroupName nvarchar(max)
    EXEC sp_OAMethod @jResp, 'StringOf', @GroupName OUT, 'buildBatch.logConfig.cloudWatchLogs.groupName'
    DECLARE @Status nvarchar(max)
    EXEC sp_OAMethod @jResp, 'StringOf', @Status OUT, 'buildBatch.logConfig.cloudWatchLogs.status'
    DECLARE @StreamName nvarchar(max)
    EXEC sp_OAMethod @jResp, 'StringOf', @StreamName OUT, 'buildBatch.logConfig.cloudWatchLogs.streamName'
    DECLARE @S3LogsBucketOwnerAccess nvarchar(max)
    EXEC sp_OAMethod @jResp, 'StringOf', @S3LogsBucketOwnerAccess OUT, 'buildBatch.logConfig.s3Logs.bucketOwnerAccess'
    DECLARE @S3LogsEncryptionDisabled int
    EXEC sp_OAMethod @jResp, 'IntOf', @S3LogsEncryptionDisabled OUT, 'buildBatch.logConfig.s3Logs.encryptionDisabled'
    DECLARE @S3LogsLocation nvarchar(max)
    EXEC sp_OAMethod @jResp, 'StringOf', @S3LogsLocation OUT, 'buildBatch.logConfig.s3Logs.location'
    DECLARE @S3LogsStatus nvarchar(max)
    EXEC sp_OAMethod @jResp, 'StringOf', @S3LogsStatus OUT, 'buildBatch.logConfig.s3Logs.status'
    DECLARE @ProjectName nvarchar(max)
    EXEC sp_OAMethod @jResp, 'StringOf', @ProjectName OUT, 'buildBatch.projectName'
    DECLARE @QueuedTimeoutInMinutes int
    EXEC sp_OAMethod @jResp, 'IntOf', @QueuedTimeoutInMinutes OUT, 'buildBatch.queuedTimeoutInMinutes'
    DECLARE @ResolvedSourceVersion nvarchar(max)
    EXEC sp_OAMethod @jResp, 'StringOf', @ResolvedSourceVersion OUT, 'buildBatch.resolvedSourceVersion'
    DECLARE @buildBatchServiceRole nvarchar(max)
    EXEC sp_OAMethod @jResp, 'StringOf', @buildBatchServiceRole OUT, 'buildBatch.serviceRole'
    DECLARE @Resource nvarchar(max)
    EXEC sp_OAMethod @jResp, 'StringOf', @Resource OUT, 'buildBatch.source.auth.resource'
    DECLARE @AuthType nvarchar(max)
    EXEC sp_OAMethod @jResp, 'StringOf', @AuthType OUT, 'buildBatch.source.auth.type'
    DECLARE @Buildspec nvarchar(max)
    EXEC sp_OAMethod @jResp, 'StringOf', @Buildspec OUT, 'buildBatch.source.buildspec'
    DECLARE @Context nvarchar(max)
    EXEC sp_OAMethod @jResp, 'StringOf', @Context OUT, 'buildBatch.source.buildStatusConfig.context'
    DECLARE @TargetUrl nvarchar(max)
    EXEC sp_OAMethod @jResp, 'StringOf', @TargetUrl OUT, 'buildBatch.source.buildStatusConfig.targetUrl'
    DECLARE @GitCloneDepth int
    EXEC sp_OAMethod @jResp, 'IntOf', @GitCloneDepth OUT, 'buildBatch.source.gitCloneDepth'
    DECLARE @FetchSubmodules int
    EXEC sp_OAMethod @jResp, 'IntOf', @FetchSubmodules OUT, 'buildBatch.source.gitSubmodulesConfig.fetchSubmodules'
    DECLARE @InsecureSsl int
    EXEC sp_OAMethod @jResp, 'IntOf', @InsecureSsl OUT, 'buildBatch.source.insecureSsl'
    DECLARE @SourceLocation nvarchar(max)
    EXEC sp_OAMethod @jResp, 'StringOf', @SourceLocation OUT, 'buildBatch.source.location'
    DECLARE @ReportBuildStatus int
    EXEC sp_OAMethod @jResp, 'IntOf', @ReportBuildStatus OUT, 'buildBatch.source.reportBuildStatus'
    DECLARE @SourceIdentifier nvarchar(max)
    EXEC sp_OAMethod @jResp, 'StringOf', @SourceIdentifier OUT, 'buildBatch.source.sourceIdentifier'
    DECLARE @SourceType nvarchar(max)
    EXEC sp_OAMethod @jResp, 'StringOf', @SourceType OUT, 'buildBatch.source.type'
    DECLARE @SourceVersion nvarchar(max)
    EXEC sp_OAMethod @jResp, 'StringOf', @SourceVersion OUT, 'buildBatch.sourceVersion'
    DECLARE @StartTime int
    EXEC sp_OAMethod @jResp, 'IntOf', @StartTime OUT, 'buildBatch.startTime'
    DECLARE @VpcId nvarchar(max)
    EXEC sp_OAMethod @jResp, 'StringOf', @VpcId OUT, 'buildBatch.vpcConfig.vpcId'
    DECLARE @i int
    SELECT @i = 0
    DECLARE @count_i int
    EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_i OUT, 'buildBatch.buildBatchConfig.restrictions.computeTypesAllowed'
    WHILE @i < @count_i
      BEGIN
        EXEC sp_OASetProperty @jResp, 'I', @i
        EXEC sp_OAMethod @jResp, 'StringOf', @strVal OUT, 'buildBatch.buildBatchConfig.restrictions.computeTypesAllowed[i]'
        SELECT @i = @i + 1
      END
    SELECT @i = 0
    EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_i OUT, 'buildBatch.buildGroups'
    WHILE @i < @count_i
      BEGIN
        EXEC sp_OASetProperty @jResp, 'I', @i
        EXEC sp_OAMethod @jResp, 'StringOf', @currentBuildSummaryArn OUT, 'buildBatch.buildGroups[i].currentBuildSummary.arn'
        EXEC sp_OAMethod @jResp, 'StringOf', @BuildStatus OUT, 'buildBatch.buildGroups[i].currentBuildSummary.buildStatus'
        EXEC sp_OAMethod @jResp, 'StringOf', @Identifier OUT, 'buildBatch.buildGroups[i].currentBuildSummary.primaryArtifact.identifier'
        EXEC sp_OAMethod @jResp, 'StringOf', @PrimaryArtifactLocation OUT, 'buildBatch.buildGroups[i].currentBuildSummary.primaryArtifact.location'
        EXEC sp_OAMethod @jResp, 'StringOf', @PrimaryArtifactType OUT, 'buildBatch.buildGroups[i].currentBuildSummary.primaryArtifact.type'
        EXEC sp_OAMethod @jResp, 'IntOf', @RequestedOn OUT, 'buildBatch.buildGroups[i].currentBuildSummary.requestedOn'
        EXEC sp_OAMethod @jResp, 'StringOf', @identifier OUT, 'buildBatch.buildGroups[i].identifier'
        EXEC sp_OAMethod @jResp, 'IntOf', @ignoreFailure OUT, 'buildBatch.buildGroups[i].ignoreFailure'
        SELECT @j = 0
        EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_j OUT, 'buildBatch.buildGroups[i].currentBuildSummary.secondaryArtifacts'
        WHILE @j < @count_j
          BEGIN
            EXEC sp_OASetProperty @jResp, 'J', @j
            EXEC sp_OAMethod @jResp, 'StringOf', @identifier OUT, 'buildBatch.buildGroups[i].currentBuildSummary.secondaryArtifacts[j].identifier'
            EXEC sp_OAMethod @jResp, 'StringOf', @location OUT, 'buildBatch.buildGroups[i].currentBuildSummary.secondaryArtifacts[j].location'
            EXEC sp_OAMethod @jResp, 'StringOf', @v_type OUT, 'buildBatch.buildGroups[i].currentBuildSummary.secondaryArtifacts[j].type'
            SELECT @j = @j + 1
          END
        SELECT @j = 0
        EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_j OUT, 'buildBatch.buildGroups[i].dependsOn'
        WHILE @j < @count_j
          BEGIN
            EXEC sp_OASetProperty @jResp, 'J', @j
            EXEC sp_OAMethod @jResp, 'StringOf', @strVal OUT, 'buildBatch.buildGroups[i].dependsOn[j]'
            SELECT @j = @j + 1
          END
        SELECT @j = 0
        EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_j OUT, 'buildBatch.buildGroups[i].priorBuildSummaryList'
        WHILE @j < @count_j
          BEGIN
            EXEC sp_OASetProperty @jResp, 'J', @j
            EXEC sp_OAMethod @jResp, 'StringOf', @arn OUT, 'buildBatch.buildGroups[i].priorBuildSummaryList[j].arn'
            EXEC sp_OAMethod @jResp, 'StringOf', @buildStatus OUT, 'buildBatch.buildGroups[i].priorBuildSummaryList[j].buildStatus'
            EXEC sp_OAMethod @jResp, 'StringOf', @primaryArtifactIdentifier OUT, 'buildBatch.buildGroups[i].priorBuildSummaryList[j].primaryArtifact.identifier'
            EXEC sp_OAMethod @jResp, 'StringOf', @primaryArtifactLocation OUT, 'buildBatch.buildGroups[i].priorBuildSummaryList[j].primaryArtifact.location'
            EXEC sp_OAMethod @jResp, 'StringOf', @primaryArtifactType OUT, 'buildBatch.buildGroups[i].priorBuildSummaryList[j].primaryArtifact.type'
            EXEC sp_OAMethod @jResp, 'IntOf', @requestedOn OUT, 'buildBatch.buildGroups[i].priorBuildSummaryList[j].requestedOn'
            SELECT @k = 0
            EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_k OUT, 'buildBatch.buildGroups[i].priorBuildSummaryList[j].secondaryArtifacts'
            WHILE @k < @count_k
              BEGIN
                EXEC sp_OASetProperty @jResp, 'K', @k
                EXEC sp_OAMethod @jResp, 'StringOf', @identifier OUT, 'buildBatch.buildGroups[i].priorBuildSummaryList[j].secondaryArtifacts[k].identifier'
                EXEC sp_OAMethod @jResp, 'StringOf', @location OUT, 'buildBatch.buildGroups[i].priorBuildSummaryList[j].secondaryArtifacts[k].location'
                EXEC sp_OAMethod @jResp, 'StringOf', @v_type OUT, 'buildBatch.buildGroups[i].priorBuildSummaryList[j].secondaryArtifacts[k].type'
                SELECT @k = @k + 1
              END
            SELECT @j = @j + 1
          END
        SELECT @i = @i + 1
      END
    SELECT @i = 0
    EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_i OUT, 'buildBatch.cache.modes'
    WHILE @i < @count_i
      BEGIN
        EXEC sp_OASetProperty @jResp, 'I', @i
        EXEC sp_OAMethod @jResp, 'StringOf', @strVal OUT, 'buildBatch.cache.modes[i]'
        SELECT @i = @i + 1
      END
    SELECT @i = 0
    EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_i OUT, 'buildBatch.environment.environmentVariables'
    WHILE @i < @count_i
      BEGIN
        EXEC sp_OASetProperty @jResp, 'I', @i
        EXEC sp_OAMethod @jResp, 'StringOf', @name OUT, 'buildBatch.environment.environmentVariables[i].name'
        EXEC sp_OAMethod @jResp, 'StringOf', @v_type OUT, 'buildBatch.environment.environmentVariables[i].type'
        EXEC sp_OAMethod @jResp, 'StringOf', @value OUT, 'buildBatch.environment.environmentVariables[i].value'
        SELECT @i = @i + 1
      END
    SELECT @i = 0
    EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_i OUT, 'buildBatch.fileSystemLocations'
    WHILE @i < @count_i
      BEGIN
        EXEC sp_OASetProperty @jResp, 'I', @i
        EXEC sp_OAMethod @jResp, 'StringOf', @identifier OUT, 'buildBatch.fileSystemLocations[i].identifier'
        EXEC sp_OAMethod @jResp, 'StringOf', @location OUT, 'buildBatch.fileSystemLocations[i].location'
        EXEC sp_OAMethod @jResp, 'StringOf', @mountOptions OUT, 'buildBatch.fileSystemLocations[i].mountOptions'
        EXEC sp_OAMethod @jResp, 'StringOf', @mountPoint OUT, 'buildBatch.fileSystemLocations[i].mountPoint'
        EXEC sp_OAMethod @jResp, 'StringOf', @v_type OUT, 'buildBatch.fileSystemLocations[i].type'
        SELECT @i = @i + 1
      END
    SELECT @i = 0
    EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_i OUT, 'buildBatch.phases'
    WHILE @i < @count_i
      BEGIN
        EXEC sp_OASetProperty @jResp, 'I', @i
        EXEC sp_OAMethod @jResp, 'IntOf', @durationInSeconds OUT, 'buildBatch.phases[i].durationInSeconds'
        EXEC sp_OAMethod @jResp, 'IntOf', @endTime OUT, 'buildBatch.phases[i].endTime'
        EXEC sp_OAMethod @jResp, 'StringOf', @phaseStatus OUT, 'buildBatch.phases[i].phaseStatus'
        EXEC sp_OAMethod @jResp, 'StringOf', @phaseType OUT, 'buildBatch.phases[i].phaseType'
        EXEC sp_OAMethod @jResp, 'IntOf', @startTime OUT, 'buildBatch.phases[i].startTime'
        SELECT @j = 0
        EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_j OUT, 'buildBatch.phases[i].contexts'
        WHILE @j < @count_j
          BEGIN
            EXEC sp_OASetProperty @jResp, 'J', @j
            EXEC sp_OAMethod @jResp, 'StringOf', @message OUT, 'buildBatch.phases[i].contexts[j].message'
            EXEC sp_OAMethod @jResp, 'StringOf', @statusCode OUT, 'buildBatch.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, 'buildBatch.secondaryArtifacts'
    WHILE @i < @count_i
      BEGIN
        EXEC sp_OASetProperty @jResp, 'I', @i
        EXEC sp_OAMethod @jResp, 'StringOf', @artifactIdentifier OUT, 'buildBatch.secondaryArtifacts[i].artifactIdentifier'
        EXEC sp_OAMethod @jResp, 'StringOf', @bucketOwnerAccess OUT, 'buildBatch.secondaryArtifacts[i].bucketOwnerAccess'
        EXEC sp_OAMethod @jResp, 'IntOf', @encryptionDisabled OUT, 'buildBatch.secondaryArtifacts[i].encryptionDisabled'
        EXEC sp_OAMethod @jResp, 'StringOf', @location OUT, 'buildBatch.secondaryArtifacts[i].location'
        EXEC sp_OAMethod @jResp, 'StringOf', @md5sum OUT, 'buildBatch.secondaryArtifacts[i].md5sum'
        EXEC sp_OAMethod @jResp, 'IntOf', @overrideArtifactName OUT, 'buildBatch.secondaryArtifacts[i].overrideArtifactName'
        EXEC sp_OAMethod @jResp, 'StringOf', @sha256sum OUT, 'buildBatch.secondaryArtifacts[i].sha256sum'
        SELECT @i = @i + 1
      END
    SELECT @i = 0
    EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_i OUT, 'buildBatch.secondarySources'
    WHILE @i < @count_i
      BEGIN
        EXEC sp_OASetProperty @jResp, 'I', @i
        EXEC sp_OAMethod @jResp, 'StringOf', @authResource OUT, 'buildBatch.secondarySources[i].auth.resource'
        EXEC sp_OAMethod @jResp, 'StringOf', @authType OUT, 'buildBatch.secondarySources[i].auth.type'
        EXEC sp_OAMethod @jResp, 'StringOf', @buildspec OUT, 'buildBatch.secondarySources[i].buildspec'
        EXEC sp_OAMethod @jResp, 'StringOf', @buildStatusConfigContext OUT, 'buildBatch.secondarySources[i].buildStatusConfig.context'
        EXEC sp_OAMethod @jResp, 'StringOf', @buildStatusConfigTargetUrl OUT, 'buildBatch.secondarySources[i].buildStatusConfig.targetUrl'
        EXEC sp_OAMethod @jResp, 'IntOf', @gitCloneDepth OUT, 'buildBatch.secondarySources[i].gitCloneDepth'
        EXEC sp_OAMethod @jResp, 'IntOf', @gitSubmodulesConfigFetchSubmodules OUT, 'buildBatch.secondarySources[i].gitSubmodulesConfig.fetchSubmodules'
        EXEC sp_OAMethod @jResp, 'IntOf', @insecureSsl OUT, 'buildBatch.secondarySources[i].insecureSsl'
        EXEC sp_OAMethod @jResp, 'StringOf', @location OUT, 'buildBatch.secondarySources[i].location'
        EXEC sp_OAMethod @jResp, 'IntOf', @reportBuildStatus OUT, 'buildBatch.secondarySources[i].reportBuildStatus'
        EXEC sp_OAMethod @jResp, 'StringOf', @sourceIdentifier OUT, 'buildBatch.secondarySources[i].sourceIdentifier'
        EXEC sp_OAMethod @jResp, 'StringOf', @v_type OUT, 'buildBatch.secondarySources[i].type'
        SELECT @i = @i + 1
      END
    SELECT @i = 0
    EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_i OUT, 'buildBatch.secondarySourceVersions'
    WHILE @i < @count_i
      BEGIN
        EXEC sp_OASetProperty @jResp, 'I', @i
        EXEC sp_OAMethod @jResp, 'StringOf', @sourceIdentifier OUT, 'buildBatch.secondarySourceVersions[i].sourceIdentifier'
        EXEC sp_OAMethod @jResp, 'StringOf', @sourceVersion OUT, 'buildBatch.secondarySourceVersions[i].sourceVersion'
        SELECT @i = @i + 1
      END
    SELECT @i = 0
    EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_i OUT, 'buildBatch.vpcConfig.securityGroupIds'
    WHILE @i < @count_i
      BEGIN
        EXEC sp_OASetProperty @jResp, 'I', @i
        EXEC sp_OAMethod @jResp, 'StringOf', @strVal OUT, 'buildBatch.vpcConfig.securityGroupIds[i]'
        SELECT @i = @i + 1
      END
    SELECT @i = 0
    EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_i OUT, 'buildBatch.vpcConfig.subnets'
    WHILE @i < @count_i
      BEGIN
        EXEC sp_OASetProperty @jResp, 'I', @i
        EXEC sp_OAMethod @jResp, 'StringOf', @strVal OUT, 'buildBatch.vpcConfig.subnets[i]'
        SELECT @i = @i + 1
      END

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

    -- {
    --   "buildBatch": {
    --     "arn": "string",
    --     "artifacts": {
    --       "artifactIdentifier": "string",
    --       "bucketOwnerAccess": "string",
    --       "encryptionDisabled": boolean,
    --       "location": "string",
    --       "md5sum": "string",
    --       "overrideArtifactName": boolean,
    --       "sha256sum": "string"
    --     },
    --     "buildBatchConfig": {
    --       "batchReportMode": "string",
    --       "combineArtifacts": boolean,
    --       "restrictions": {
    --         "computeTypesAllowed": [
    --           "string"
    --         ],
    --         "maximumBuildsAllowed": number
    --       },
    --       "serviceRole": "string",
    --       "timeoutInMins": number
    --     },
    --     "buildBatchNumber": number,
    --     "buildBatchStatus": "string",
    --     "buildGroups": [
    --       {
    --         "currentBuildSummary": {
    --           "arn": "string",
    --           "buildStatus": "string",
    --           "primaryArtifact": {
    --             "identifier": "string",
    --             "location": "string",
    --             "type": "string"
    --           },
    --           "requestedOn": number,
    --           "secondaryArtifacts": [
    --             {
    --               "identifier": "string",
    --               "location": "string",
    --               "type": "string"
    --             }
    --           ]
    --         },
    --         "dependsOn": [
    --           "string"
    --         ],
    --         "identifier": "string",
    --         "ignoreFailure": boolean,
    --         "priorBuildSummaryList": [
    --           {
    --             "arn": "string",
    --             "buildStatus": "string",
    --             "primaryArtifact": {
    --               "identifier": "string",
    --               "location": "string",
    --               "type": "string"
    --             },
    --             "requestedOn": number,
    --             "secondaryArtifacts": [
    --               {
    --                 "identifier": "string",
    --                 "location": "string",
    --                 "type": "string"
    --               }
    --             ]
    --           }
    --         ]
    --       }
    --     ],
    --     "buildTimeoutInMinutes": number,
    --     "cache": {
    --       "location": "string",
    --       "modes": [
    --         "string"
    --       ],
    --       "type": "string"
    --     },
    --     "complete": boolean,
    --     "currentPhase": "string",
    --     "debugSessionEnabled": boolean,
    --     "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"
    --     },
    --     "fileSystemLocations": [
    --       {
    --         "identifier": "string",
    --         "location": "string",
    --         "mountOptions": "string",
    --         "mountPoint": "string",
    --         "type": "string"
    --       }
    --     ],
    --     "id": "string",
    --     "initiator": "string",
    --     "logConfig": {
    --       "cloudWatchLogs": {
    --         "groupName": "string",
    --         "status": "string",
    --         "streamName": "string"
    --       },
    --       "s3Logs": {
    --         "bucketOwnerAccess": "string",
    --         "encryptionDisabled": boolean,
    --         "location": "string",
    --         "status": "string"
    --       }
    --     },
    --     "phases": [
    --       {
    --         "contexts": [
    --           {
    --             "message": "string",
    --             "statusCode": "string"
    --           }
    --         ],
    --         "durationInSeconds": number,
    --         "endTime": number,
    --         "phaseStatus": "string",
    --         "phaseType": "string",
    --         "startTime": number
    --       }
    --     ],
    --     "projectName": "string",
    --     "queuedTimeoutInMinutes": number,
    --     "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,
    --     "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