Chilkat Online Tools

ListApps autoit Example

Amplify

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

$oRest = ObjCreate("Chilkat_9_5_0.Rest")
Local $bSuccess

$oAuthAws = ObjCreate("Chilkat_9_5_0.AuthAws")
$oAuthAws.AccessKey = "AWS_ACCESS_KEY"
$oAuthAws.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.)
$oAuthAws.Region = "us-west-2"
$oAuthAws.ServiceName = "amplify"
; SetAuthAws causes Chilkat to automatically add the following headers: Authorization, X-Amz-Date
$oRest.SetAuthAws($oAuthAws)

; URL: https://amplify.us-west-2.amazonaws.com/
; Use the same region as specified above.
$bSuccess = $oRest.Connect("amplify.us-west-2.amazonaws.com",443,True,True)
If ($bSuccess <> True) Then
    ConsoleWrite("ConnectFailReason: " & $oRest.ConnectFailReason & @CRLF)
    ConsoleWrite($oRest.LastErrorText & @CRLF)
    Exit
EndIf

$oRest.AddHeader("Content-Type","application/x-amz-json-1.1")
$oRest.AddHeader("X-Amz-Target","ListApps")

$oSbResponseBody = ObjCreate("Chilkat_9_5_0.StringBuilder")
$bSuccess = $oRest.FullRequestNoBodySb("GET","/apps",$oSbResponseBody)
If ($bSuccess <> True) Then
    ConsoleWrite($oRest.LastErrorText & @CRLF)
    Exit
EndIf

Local $iRespStatusCode = $oRest.ResponseStatusCode
ConsoleWrite("response status code = " & $iRespStatusCode & @CRLF)
If ($iRespStatusCode <> 200) Then
    ConsoleWrite("Response Header:" & @CRLF)
    ConsoleWrite($oRest.ResponseHeader & @CRLF)
    ConsoleWrite("Response Body:" & @CRLF)
    ConsoleWrite($oSbResponseBody.GetAsString() & @CRLF)
    Exit
EndIf

$oJResp = ObjCreate("Chilkat_9_5_0.JsonObject")
$oJResp.LoadSb($oSbResponseBody)

; 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

Local $sAppArn
Local $sAppId
Local $sBasicAuthCredentials
Local $sBuildSpec
Local $iEnableAutoBuild
Local $iEnableBasicAuth
Local $iEnablePerformanceMode
Local $iEnablePullRequestPreview
Local $sV_String
Local $sFramework
Local $sPullRequestEnvironmentName
Local $sStage
Local $sBasicAuthCredentials
Local $sBuildSpec
Local $iCreateTime
Local $sCustomHeaders
Local $sDefaultDomain
Local $sDescription
Local $iEnableAutoBranchCreation
Local $iEnableBasicAuth
Local $iEnableBranchAutoBuild
Local $iEnableBranchAutoDeletion
Local $sEnvironmentVariablesString
Local $sIamServiceRoleArn
Local $sName
Local $sPlatform
Local $sBranchName
Local $iLastDeployTime
Local $sStatus
Local $sThumbnailUrl
Local $sRepository
Local $sRepositoryCloneMethod
Local $sTagsString
Local $iUpdateTime
Local $iJ
Local $iCount_j
Local $strVal
Local $sCondition
Local $source
Local $status
Local $sTarget

Local $sNextToken = $oJResp.StringOf("nextToken")
Local $i = 0
Local $iCount_i = $oJResp.SizeOfArray("apps")
While $i < $iCount_i
    $oJResp.I = $i
    $sAppArn = $oJResp.StringOf("apps[i].appArn")
    $sAppId = $oJResp.StringOf("apps[i].appId")
    $sBasicAuthCredentials = $oJResp.StringOf("apps[i].autoBranchCreationConfig.basicAuthCredentials")
    $sBuildSpec = $oJResp.StringOf("apps[i].autoBranchCreationConfig.buildSpec")
    $iEnableAutoBuild = $oJResp.IntOf("apps[i].autoBranchCreationConfig.enableAutoBuild")
    $iEnableBasicAuth = $oJResp.IntOf("apps[i].autoBranchCreationConfig.enableBasicAuth")
    $iEnablePerformanceMode = $oJResp.IntOf("apps[i].autoBranchCreationConfig.enablePerformanceMode")
    $iEnablePullRequestPreview = $oJResp.IntOf("apps[i].autoBranchCreationConfig.enablePullRequestPreview")
    $sV_String = $oJResp.StringOf("apps[i].autoBranchCreationConfig.environmentVariables.string")
    $sFramework = $oJResp.StringOf("apps[i].autoBranchCreationConfig.framework")
    $sPullRequestEnvironmentName = $oJResp.StringOf("apps[i].autoBranchCreationConfig.pullRequestEnvironmentName")
    $sStage = $oJResp.StringOf("apps[i].autoBranchCreationConfig.stage")
    $sBasicAuthCredentials = $oJResp.StringOf("apps[i].basicAuthCredentials")
    $sBuildSpec = $oJResp.StringOf("apps[i].buildSpec")
    $iCreateTime = $oJResp.IntOf("apps[i].createTime")
    $sCustomHeaders = $oJResp.StringOf("apps[i].customHeaders")
    $sDefaultDomain = $oJResp.StringOf("apps[i].defaultDomain")
    $sDescription = $oJResp.StringOf("apps[i].description")
    $iEnableAutoBranchCreation = $oJResp.IntOf("apps[i].enableAutoBranchCreation")
    $iEnableBasicAuth = $oJResp.IntOf("apps[i].enableBasicAuth")
    $iEnableBranchAutoBuild = $oJResp.IntOf("apps[i].enableBranchAutoBuild")
    $iEnableBranchAutoDeletion = $oJResp.IntOf("apps[i].enableBranchAutoDeletion")
    $sEnvironmentVariablesString = $oJResp.StringOf("apps[i].environmentVariables.string")
    $sIamServiceRoleArn = $oJResp.StringOf("apps[i].iamServiceRoleArn")
    $sName = $oJResp.StringOf("apps[i].name")
    $sPlatform = $oJResp.StringOf("apps[i].platform")
    $sBranchName = $oJResp.StringOf("apps[i].productionBranch.branchName")
    $iLastDeployTime = $oJResp.IntOf("apps[i].productionBranch.lastDeployTime")
    $sStatus = $oJResp.StringOf("apps[i].productionBranch.status")
    $sThumbnailUrl = $oJResp.StringOf("apps[i].productionBranch.thumbnailUrl")
    $sRepository = $oJResp.StringOf("apps[i].repository")
    $sRepositoryCloneMethod = $oJResp.StringOf("apps[i].repositoryCloneMethod")
    $sTagsString = $oJResp.StringOf("apps[i].tags.string")
    $iUpdateTime = $oJResp.IntOf("apps[i].updateTime")
    $iJ = 0
    $iCount_j = $oJResp.SizeOfArray("apps[i].autoBranchCreationPatterns")
    While $iJ < $iCount_j
        $oJResp.J = $iJ
        $strVal = $oJResp.StringOf("apps[i].autoBranchCreationPatterns[j]")
        $iJ = $iJ + 1
    Wend
    $iJ = 0
    $iCount_j = $oJResp.SizeOfArray("apps[i].customRules")
    While $iJ < $iCount_j
        $oJResp.J = $iJ
        $sCondition = $oJResp.StringOf("apps[i].customRules[j].condition")
        $source = $oJResp.StringOf("apps[i].customRules[j].source")
        $status = $oJResp.StringOf("apps[i].customRules[j].status")
        $sTarget = $oJResp.StringOf("apps[i].customRules[j].target")
        $iJ = $iJ + 1
    Wend
    $i = $i + 1
Wend

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

; {
;   "apps": [
;     {
;       "appArn": "string",
;       "appId": "string",
;       "autoBranchCreationConfig": {
;         "basicAuthCredentials": "string",
;         "buildSpec": "string",
;         "enableAutoBuild": boolean,
;         "enableBasicAuth": boolean,
;         "enablePerformanceMode": boolean,
;         "enablePullRequestPreview": boolean,
;         "environmentVariables": {
;           "string": "string"
;         },
;         "framework": "string",
;         "pullRequestEnvironmentName": "string",
;         "stage": "string"
;       },
;       "autoBranchCreationPatterns": [
;         "string"
;       ],
;       "basicAuthCredentials": "string",
;       "buildSpec": "string",
;       "createTime": number,
;       "customHeaders": "string",
;       "customRules": [
;         {
;           "condition": "string",
;           "source": "string",
;           "status": "string",
;           "target": "string"
;         }
;       ],
;       "defaultDomain": "string",
;       "description": "string",
;       "enableAutoBranchCreation": boolean,
;       "enableBasicAuth": boolean,
;       "enableBranchAutoBuild": boolean,
;       "enableBranchAutoDeletion": boolean,
;       "environmentVariables": {
;         "string": "string"
;       },
;       "iamServiceRoleArn": "string",
;       "name": "string",
;       "platform": "string",
;       "productionBranch": {
;         "branchName": "string",
;         "lastDeployTime": number,
;         "status": "string",
;         "thumbnailUrl": "string"
;       },
;       "repository": "string",
;       "repositoryCloneMethod": "string",
;       "tags": {
;         "string": "string"
;       },
;       "updateTime": number
;     }
;   ],
;   "nextToken": "string"
; }