Chilkat Online Tools

BatchGetProjects TCL Example

AWS CodeBuild

load ./chilkat.dll

# This example requires the Chilkat API to have been previously unlocked.
# See Global Unlock Sample for sample code.

set rest [new_CkRest]

set authAws [new_CkAuthAws]

CkAuthAws_put_AccessKey $authAws "AWS_ACCESS_KEY"
CkAuthAws_put_SecretKey $authAws "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.)
CkAuthAws_put_Region $authAws "us-west-2"
CkAuthAws_put_ServiceName $authAws "codebuild"
# SetAuthAws causes Chilkat to automatically add the following headers: Authorization, X-Amz-Date
CkRest_SetAuthAws $rest $authAws

# URL: https://codebuild.us-west-2.amazonaws.com/
# Use the same region as specified above.
set success [CkRest_Connect $rest "codebuild.us-west-2.amazonaws.com" 443 1 1]
if {$success != 1} then {
    puts "ConnectFailReason: [CkRest_get_ConnectFailReason $rest]"
    puts [CkRest_lastErrorText $rest]
    delete_CkRest $rest
    delete_CkAuthAws $authAws
    exit
}

# 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

set json [new_CkJsonObject]

CkJsonObject_UpdateString $json "names[0]" "string"

# The JSON request body created by the above code:

# {
#   "names": [
#     "string"
#   ]
# }

CkRest_AddHeader $rest "Content-Type" "application/x-amz-json-1.1"
CkRest_AddHeader $rest "X-Amz-Target" "CodeBuild_20161006.BatchGetProjects"

set sbRequestBody [new_CkStringBuilder]

CkJsonObject_EmitSb $json $sbRequestBody
set sbResponseBody [new_CkStringBuilder]

set success [CkRest_FullRequestSb $rest "POST" "/" $sbRequestBody $sbResponseBody]
if {$success != 1} then {
    puts [CkRest_lastErrorText $rest]
    delete_CkRest $rest
    delete_CkAuthAws $authAws
    delete_CkJsonObject $json
    delete_CkStringBuilder $sbRequestBody
    delete_CkStringBuilder $sbResponseBody
    exit
}

set respStatusCode [CkRest_get_ResponseStatusCode $rest]
puts "response status code = $respStatusCode"
if {$respStatusCode != 200} then {
    puts "Response Header:"
    puts [CkRest_responseHeader $rest]
    puts "Response Body:"
    puts [CkStringBuilder_getAsString $sbResponseBody]
    delete_CkRest $rest
    delete_CkAuthAws $authAws
    delete_CkJsonObject $json
    delete_CkStringBuilder $sbRequestBody
    delete_CkStringBuilder $sbResponseBody
    exit
}

set jResp [new_CkJsonObject]

CkJsonObject_LoadSb $jResp $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

set i 0
set count_i [CkJsonObject_SizeOfArray $jResp "projects"]
while {$i < $count_i} {
    CkJsonObject_put_I $jResp $i
    set arn [CkJsonObject_stringOf $jResp "projects[i].arn"]
    set ArtifactIdentifier [CkJsonObject_stringOf $jResp "projects[i].artifacts.artifactIdentifier"]
    set BucketOwnerAccess [CkJsonObject_stringOf $jResp "projects[i].artifacts.bucketOwnerAccess"]
    set EncryptionDisabled [CkJsonObject_IntOf $jResp "projects[i].artifacts.encryptionDisabled"]
    set Location [CkJsonObject_stringOf $jResp "projects[i].artifacts.location"]
    set Name [CkJsonObject_stringOf $jResp "projects[i].artifacts.name"]
    set NamespaceType [CkJsonObject_stringOf $jResp "projects[i].artifacts.namespaceType"]
    set OverrideArtifactName [CkJsonObject_IntOf $jResp "projects[i].artifacts.overrideArtifactName"]
    set Packaging [CkJsonObject_stringOf $jResp "projects[i].artifacts.packaging"]
    set Path [CkJsonObject_stringOf $jResp "projects[i].artifacts.path"]
    set v_Type [CkJsonObject_stringOf $jResp "projects[i].artifacts.type"]
    set BadgeEnabled [CkJsonObject_IntOf $jResp "projects[i].badge.badgeEnabled"]
    set BadgeRequestUrl [CkJsonObject_stringOf $jResp "projects[i].badge.badgeRequestUrl"]
    set BatchReportMode [CkJsonObject_stringOf $jResp "projects[i].buildBatchConfig.batchReportMode"]
    set CombineArtifacts [CkJsonObject_IntOf $jResp "projects[i].buildBatchConfig.combineArtifacts"]
    set MaximumBuildsAllowed [CkJsonObject_IntOf $jResp "projects[i].buildBatchConfig.restrictions.maximumBuildsAllowed"]
    set ServiceRole [CkJsonObject_stringOf $jResp "projects[i].buildBatchConfig.serviceRole"]
    set TimeoutInMins [CkJsonObject_IntOf $jResp "projects[i].buildBatchConfig.timeoutInMins"]
    set cacheLocation [CkJsonObject_stringOf $jResp "projects[i].cache.location"]
    set cacheType [CkJsonObject_stringOf $jResp "projects[i].cache.type"]
    set concurrentBuildLimit [CkJsonObject_IntOf $jResp "projects[i].concurrentBuildLimit"]
    set created [CkJsonObject_IntOf $jResp "projects[i].created"]
    set description [CkJsonObject_stringOf $jResp "projects[i].description"]
    set encryptionKey [CkJsonObject_stringOf $jResp "projects[i].encryptionKey"]
    set Certificate [CkJsonObject_stringOf $jResp "projects[i].environment.certificate"]
    set ComputeType [CkJsonObject_stringOf $jResp "projects[i].environment.computeType"]
    set Image [CkJsonObject_stringOf $jResp "projects[i].environment.image"]
    set ImagePullCredentialsType [CkJsonObject_stringOf $jResp "projects[i].environment.imagePullCredentialsType"]
    set PrivilegedMode [CkJsonObject_IntOf $jResp "projects[i].environment.privilegedMode"]
    set Credential [CkJsonObject_stringOf $jResp "projects[i].environment.registryCredential.credential"]
    set CredentialProvider [CkJsonObject_stringOf $jResp "projects[i].environment.registryCredential.credentialProvider"]
    set environmentType [CkJsonObject_stringOf $jResp "projects[i].environment.type"]
    set lastModified [CkJsonObject_IntOf $jResp "projects[i].lastModified"]
    set GroupName [CkJsonObject_stringOf $jResp "projects[i].logsConfig.cloudWatchLogs.groupName"]
    set Status [CkJsonObject_stringOf $jResp "projects[i].logsConfig.cloudWatchLogs.status"]
    set StreamName [CkJsonObject_stringOf $jResp "projects[i].logsConfig.cloudWatchLogs.streamName"]
    set S3LogsBucketOwnerAccess [CkJsonObject_stringOf $jResp "projects[i].logsConfig.s3Logs.bucketOwnerAccess"]
    set S3LogsEncryptionDisabled [CkJsonObject_IntOf $jResp "projects[i].logsConfig.s3Logs.encryptionDisabled"]
    set S3LogsLocation [CkJsonObject_stringOf $jResp "projects[i].logsConfig.s3Logs.location"]
    set S3LogsStatus [CkJsonObject_stringOf $jResp "projects[i].logsConfig.s3Logs.status"]
    set name [CkJsonObject_stringOf $jResp "projects[i].name"]
    set projectVisibility [CkJsonObject_stringOf $jResp "projects[i].projectVisibility"]
    set publicProjectAlias [CkJsonObject_stringOf $jResp "projects[i].publicProjectAlias"]
    set queuedTimeoutInMinutes [CkJsonObject_IntOf $jResp "projects[i].queuedTimeoutInMinutes"]
    set resourceAccessRole [CkJsonObject_stringOf $jResp "projects[i].resourceAccessRole"]
    set serviceRole [CkJsonObject_stringOf $jResp "projects[i].serviceRole"]
    set Resource [CkJsonObject_stringOf $jResp "projects[i].source.auth.resource"]
    set AuthType [CkJsonObject_stringOf $jResp "projects[i].source.auth.type"]
    set Buildspec [CkJsonObject_stringOf $jResp "projects[i].source.buildspec"]
    set Context [CkJsonObject_stringOf $jResp "projects[i].source.buildStatusConfig.context"]
    set TargetUrl [CkJsonObject_stringOf $jResp "projects[i].source.buildStatusConfig.targetUrl"]
    set GitCloneDepth [CkJsonObject_IntOf $jResp "projects[i].source.gitCloneDepth"]
    set FetchSubmodules [CkJsonObject_IntOf $jResp "projects[i].source.gitSubmodulesConfig.fetchSubmodules"]
    set InsecureSsl [CkJsonObject_IntOf $jResp "projects[i].source.insecureSsl"]
    set sourceLocation [CkJsonObject_stringOf $jResp "projects[i].source.location"]
    set ReportBuildStatus [CkJsonObject_IntOf $jResp "projects[i].source.reportBuildStatus"]
    set SourceIdentifier [CkJsonObject_stringOf $jResp "projects[i].source.sourceIdentifier"]
    set sourceType [CkJsonObject_stringOf $jResp "projects[i].source.type"]
    set sourceVersion [CkJsonObject_stringOf $jResp "projects[i].sourceVersion"]
    set timeoutInMinutes [CkJsonObject_IntOf $jResp "projects[i].timeoutInMinutes"]
    set VpcId [CkJsonObject_stringOf $jResp "projects[i].vpcConfig.vpcId"]
    set BranchFilter [CkJsonObject_stringOf $jResp "projects[i].webhook.branchFilter"]
    set BuildType [CkJsonObject_stringOf $jResp "projects[i].webhook.buildType"]
    set LastModifiedSecret [CkJsonObject_IntOf $jResp "projects[i].webhook.lastModifiedSecret"]
    set PayloadUrl [CkJsonObject_stringOf $jResp "projects[i].webhook.payloadUrl"]
    set Secret [CkJsonObject_stringOf $jResp "projects[i].webhook.secret"]
    set v_Url [CkJsonObject_stringOf $jResp "projects[i].webhook.url"]
    set j 0
    set count_j [CkJsonObject_SizeOfArray $jResp "projects[i].buildBatchConfig.restrictions.computeTypesAllowed"]
    while {$j < $count_j} {
        CkJsonObject_put_J $jResp $j
        set strVal [CkJsonObject_stringOf $jResp "projects[i].buildBatchConfig.restrictions.computeTypesAllowed[j]"]
        set j [expr $j + 1]
    }
    set j 0
    set count_j [CkJsonObject_SizeOfArray $jResp "projects[i].cache.modes"]
    while {$j < $count_j} {
        CkJsonObject_put_J $jResp $j
        set strVal [CkJsonObject_stringOf $jResp "projects[i].cache.modes[j]"]
        set j [expr $j + 1]
    }
    set j 0
    set count_j [CkJsonObject_SizeOfArray $jResp "projects[i].environment.environmentVariables"]
    while {$j < $count_j} {
        CkJsonObject_put_J $jResp $j
        set name [CkJsonObject_stringOf $jResp "projects[i].environment.environmentVariables[j].name"]
        set v_type [CkJsonObject_stringOf $jResp "projects[i].environment.environmentVariables[j].type"]
        set value [CkJsonObject_stringOf $jResp "projects[i].environment.environmentVariables[j].value"]
        set j [expr $j + 1]
    }
    set j 0
    set count_j [CkJsonObject_SizeOfArray $jResp "projects[i].fileSystemLocations"]
    while {$j < $count_j} {
        CkJsonObject_put_J $jResp $j
        set identifier [CkJsonObject_stringOf $jResp "projects[i].fileSystemLocations[j].identifier"]
        set location [CkJsonObject_stringOf $jResp "projects[i].fileSystemLocations[j].location"]
        set mountOptions [CkJsonObject_stringOf $jResp "projects[i].fileSystemLocations[j].mountOptions"]
        set mountPoint [CkJsonObject_stringOf $jResp "projects[i].fileSystemLocations[j].mountPoint"]
        set v_type [CkJsonObject_stringOf $jResp "projects[i].fileSystemLocations[j].type"]
        set j [expr $j + 1]
    }
    set j 0
    set count_j [CkJsonObject_SizeOfArray $jResp "projects[i].secondaryArtifacts"]
    while {$j < $count_j} {
        CkJsonObject_put_J $jResp $j
        set artifactIdentifier [CkJsonObject_stringOf $jResp "projects[i].secondaryArtifacts[j].artifactIdentifier"]
        set bucketOwnerAccess [CkJsonObject_stringOf $jResp "projects[i].secondaryArtifacts[j].bucketOwnerAccess"]
        set encryptionDisabled [CkJsonObject_IntOf $jResp "projects[i].secondaryArtifacts[j].encryptionDisabled"]
        set location [CkJsonObject_stringOf $jResp "projects[i].secondaryArtifacts[j].location"]
        set name [CkJsonObject_stringOf $jResp "projects[i].secondaryArtifacts[j].name"]
        set namespaceType [CkJsonObject_stringOf $jResp "projects[i].secondaryArtifacts[j].namespaceType"]
        set overrideArtifactName [CkJsonObject_IntOf $jResp "projects[i].secondaryArtifacts[j].overrideArtifactName"]
        set packaging [CkJsonObject_stringOf $jResp "projects[i].secondaryArtifacts[j].packaging"]
        set path [CkJsonObject_stringOf $jResp "projects[i].secondaryArtifacts[j].path"]
        set v_type [CkJsonObject_stringOf $jResp "projects[i].secondaryArtifacts[j].type"]
        set j [expr $j + 1]
    }
    set j 0
    set count_j [CkJsonObject_SizeOfArray $jResp "projects[i].secondarySources"]
    while {$j < $count_j} {
        CkJsonObject_put_J $jResp $j
        set authResource [CkJsonObject_stringOf $jResp "projects[i].secondarySources[j].auth.resource"]
        set authType [CkJsonObject_stringOf $jResp "projects[i].secondarySources[j].auth.type"]
        set buildspec [CkJsonObject_stringOf $jResp "projects[i].secondarySources[j].buildspec"]
        set buildStatusConfigContext [CkJsonObject_stringOf $jResp "projects[i].secondarySources[j].buildStatusConfig.context"]
        set buildStatusConfigTargetUrl [CkJsonObject_stringOf $jResp "projects[i].secondarySources[j].buildStatusConfig.targetUrl"]
        set gitCloneDepth [CkJsonObject_IntOf $jResp "projects[i].secondarySources[j].gitCloneDepth"]
        set gitSubmodulesConfigFetchSubmodules [CkJsonObject_IntOf $jResp "projects[i].secondarySources[j].gitSubmodulesConfig.fetchSubmodules"]
        set insecureSsl [CkJsonObject_IntOf $jResp "projects[i].secondarySources[j].insecureSsl"]
        set location [CkJsonObject_stringOf $jResp "projects[i].secondarySources[j].location"]
        set reportBuildStatus [CkJsonObject_IntOf $jResp "projects[i].secondarySources[j].reportBuildStatus"]
        set sourceIdentifier [CkJsonObject_stringOf $jResp "projects[i].secondarySources[j].sourceIdentifier"]
        set v_type [CkJsonObject_stringOf $jResp "projects[i].secondarySources[j].type"]
        set j [expr $j + 1]
    }
    set j 0
    set count_j [CkJsonObject_SizeOfArray $jResp "projects[i].secondarySourceVersions"]
    while {$j < $count_j} {
        CkJsonObject_put_J $jResp $j
        set sourceIdentifier [CkJsonObject_stringOf $jResp "projects[i].secondarySourceVersions[j].sourceIdentifier"]
        set sourceVersion [CkJsonObject_stringOf $jResp "projects[i].secondarySourceVersions[j].sourceVersion"]
        set j [expr $j + 1]
    }
    set j 0
    set count_j [CkJsonObject_SizeOfArray $jResp "projects[i].tags"]
    while {$j < $count_j} {
        CkJsonObject_put_J $jResp $j
        set key [CkJsonObject_stringOf $jResp "projects[i].tags[j].key"]
        set value [CkJsonObject_stringOf $jResp "projects[i].tags[j].value"]
        set j [expr $j + 1]
    }
    set j 0
    set count_j [CkJsonObject_SizeOfArray $jResp "projects[i].vpcConfig.securityGroupIds"]
    while {$j < $count_j} {
        CkJsonObject_put_J $jResp $j
        set strVal [CkJsonObject_stringOf $jResp "projects[i].vpcConfig.securityGroupIds[j]"]
        set j [expr $j + 1]
    }
    set j 0
    set count_j [CkJsonObject_SizeOfArray $jResp "projects[i].vpcConfig.subnets"]
    while {$j < $count_j} {
        CkJsonObject_put_J $jResp $j
        set strVal [CkJsonObject_stringOf $jResp "projects[i].vpcConfig.subnets[j]"]
        set j [expr $j + 1]
    }
    set j 0
    set count_j [CkJsonObject_SizeOfArray $jResp "projects[i].webhook.filterGroups"]
    while {$j < $count_j} {
        CkJsonObject_put_J $jResp $j
        set k 0
        set count_k [CkJsonObject_SizeOfArray $jResp "projects[i].webhook.filterGroups[j]"]
        while {$k < $count_k} {
            CkJsonObject_put_K $jResp $k
            set excludeMatchedPattern [CkJsonObject_IntOf $jResp "projects[i].webhook.filterGroups[j][k].excludeMatchedPattern"]
            set pattern [CkJsonObject_stringOf $jResp "projects[i].webhook.filterGroups[j][k].pattern"]
            set v_type [CkJsonObject_stringOf $jResp "projects[i].webhook.filterGroups[j][k].type"]
            set k [expr $k + 1]
        }
        set j [expr $j + 1]
    }
    set i [expr $i + 1]
}
set i 0
set count_i [CkJsonObject_SizeOfArray $jResp "projectsNotFound"]
while {$i < $count_i} {
    CkJsonObject_put_I $jResp $i
    set strVal [CkJsonObject_stringOf $jResp "projectsNotFound[i]"]
    set i [expr $i + 1]
}

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

# {
#   "projects": [
#     {
#       "arn": "string",
#       "artifacts": {
#         "artifactIdentifier": "string",
#         "bucketOwnerAccess": "string",
#         "encryptionDisabled": boolean,
#         "location": "string",
#         "name": "string",
#         "namespaceType": "string",
#         "overrideArtifactName": boolean,
#         "packaging": "string",
#         "path": "string",
#         "type": "string"
#       },
#       "badge": {
#         "badgeEnabled": boolean,
#         "badgeRequestUrl": "string"
#       },
#       "buildBatchConfig": {
#         "batchReportMode": "string",
#         "combineArtifacts": boolean,
#         "restrictions": {
#           "computeTypesAllowed": [
#             "string"
#           ],
#           "maximumBuildsAllowed": number
#         },
#         "serviceRole": "string",
#         "timeoutInMins": number
#       },
#       "cache": {
#         "location": "string",
#         "modes": [
#           "string"
#         ],
#         "type": "string"
#       },
#       "concurrentBuildLimit": number,
#       "created": number,
#       "description": "string",
#       "encryptionKey": "string",
#       "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"
#         }
#       ],
#       "lastModified": number,
#       "logsConfig": {
#         "cloudWatchLogs": {
#           "groupName": "string",
#           "status": "string",
#           "streamName": "string"
#         },
#         "s3Logs": {
#           "bucketOwnerAccess": "string",
#           "encryptionDisabled": boolean,
#           "location": "string",
#           "status": "string"
#         }
#       },
#       "name": "string",
#       "projectVisibility": "string",
#       "publicProjectAlias": "string",
#       "queuedTimeoutInMinutes": number,
#       "resourceAccessRole": "string",
#       "secondaryArtifacts": [
#         {
#           "artifactIdentifier": "string",
#           "bucketOwnerAccess": "string",
#           "encryptionDisabled": boolean,
#           "location": "string",
#           "name": "string",
#           "namespaceType": "string",
#           "overrideArtifactName": boolean,
#           "packaging": "string",
#           "path": "string",
#           "type": "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",
#       "tags": [
#         {
#           "key": "string",
#           "value": "string"
#         }
#       ],
#       "timeoutInMinutes": number,
#       "vpcConfig": {
#         "securityGroupIds": [
#           "string"
#         ],
#         "subnets": [
#           "string"
#         ],
#         "vpcId": "string"
#       },
#       "webhook": {
#         "branchFilter": "string",
#         "buildType": "string",
#         "filterGroups": [
#           [
#             {
#               "excludeMatchedPattern": boolean,
#               "pattern": "string",
#               "type": "string"
#             }
#           ]
#         ],
#         "lastModifiedSecret": number,
#         "payloadUrl": "string",
#         "secret": "string",
#         "url": "string"
#       }
#     }
#   ],
#   "projectsNotFound": [
#     "string"
#   ]
# }

delete_CkRest $rest
delete_CkAuthAws $authAws
delete_CkJsonObject $json
delete_CkStringBuilder $sbRequestBody
delete_CkStringBuilder $sbResponseBody
delete_CkJsonObject $jResp