CreateApp autoit Example
; 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
; 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
$oJson = ObjCreate("Chilkat_9_5_0.JsonObject")
$oJson.UpdateString("accessToken","string")
$oJson.UpdateString("autoBranchCreationConfig.basicAuthCredentials","string")
$oJson.UpdateString("autoBranchCreationConfig.buildSpec","string")
$oJson.UpdateInt("autoBranchCreationConfig.enableAutoBuild",123)
$oJson.UpdateInt("autoBranchCreationConfig.enableBasicAuth",123)
$oJson.UpdateInt("autoBranchCreationConfig.enablePerformanceMode",123)
$oJson.UpdateInt("autoBranchCreationConfig.enablePullRequestPreview",123)
$oJson.UpdateString("autoBranchCreationConfig.environmentVariables.string","string")
$oJson.UpdateString("autoBranchCreationConfig.framework","string")
$oJson.UpdateString("autoBranchCreationConfig.pullRequestEnvironmentName","string")
$oJson.UpdateString("autoBranchCreationConfig.stage","string")
$oJson.UpdateString("autoBranchCreationPatterns[0]","string")
$oJson.UpdateString("basicAuthCredentials","string")
$oJson.UpdateString("buildSpec","string")
$oJson.UpdateString("customHeaders","string")
$oJson.UpdateString("customRules[0].condition","string")
$oJson.UpdateString("customRules[0].source","string")
$oJson.UpdateString("customRules[0].status","string")
$oJson.UpdateString("customRules[0].target","string")
$oJson.UpdateString("description","string")
$oJson.UpdateInt("enableAutoBranchCreation",123)
$oJson.UpdateInt("enableBasicAuth",123)
$oJson.UpdateInt("enableBranchAutoBuild",123)
$oJson.UpdateInt("enableBranchAutoDeletion",123)
$oJson.UpdateString("environmentVariables.string","string")
$oJson.UpdateString("iamServiceRoleArn","string")
$oJson.UpdateString("name","string")
$oJson.UpdateString("oauthToken","string")
$oJson.UpdateString("platform","string")
$oJson.UpdateString("repository","string")
$oJson.UpdateString("tags.string","string")
; The JSON request body created by the above code:
; {
; "accessToken": "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",
; "customHeaders": "string",
; "customRules": [
; {
; "condition": "string",
; "source": "string",
; "status": "string",
; "target": "string"
; }
; ],
; "description": "string",
; "enableAutoBranchCreation": boolean,
; "enableBasicAuth": boolean,
; "enableBranchAutoBuild": boolean,
; "enableBranchAutoDeletion": boolean,
; "environmentVariables": {
; "string": "string"
; },
; "iamServiceRoleArn": "string",
; "name": "string",
; "oauthToken": "string",
; "platform": "string",
; "repository": "string",
; "tags": {
; "string": "string"
; }
; }
$oRest.AddHeader("Content-Type","application/x-amz-json-1.1")
$oRest.AddHeader("X-Amz-Target","CreateApp")
$oSbRequestBody = ObjCreate("Chilkat_9_5_0.StringBuilder")
$oJson.EmitSb($oSbRequestBody)
$oSbResponseBody = ObjCreate("Chilkat_9_5_0.StringBuilder")
$bSuccess = $oRest.FullRequestSb("POST","/apps",$oSbRequestBody,$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 $strVal
Local $sCondition
Local $source
Local $status
Local $sTarget
Local $sAppArn = $oJResp.StringOf("app.appArn")
Local $sAppId = $oJResp.StringOf("app.appId")
Local $sBasicAuthCredentials = $oJResp.StringOf("app.autoBranchCreationConfig.basicAuthCredentials")
Local $sBuildSpec = $oJResp.StringOf("app.autoBranchCreationConfig.buildSpec")
Local $iEnableAutoBuild = $oJResp.IntOf("app.autoBranchCreationConfig.enableAutoBuild")
Local $iEnableBasicAuth = $oJResp.IntOf("app.autoBranchCreationConfig.enableBasicAuth")
Local $iEnablePerformanceMode = $oJResp.IntOf("app.autoBranchCreationConfig.enablePerformanceMode")
Local $iEnablePullRequestPreview = $oJResp.IntOf("app.autoBranchCreationConfig.enablePullRequestPreview")
Local $sV_String = $oJResp.StringOf("app.autoBranchCreationConfig.environmentVariables.string")
Local $sFramework = $oJResp.StringOf("app.autoBranchCreationConfig.framework")
Local $sPullRequestEnvironmentName = $oJResp.StringOf("app.autoBranchCreationConfig.pullRequestEnvironmentName")
Local $sStage = $oJResp.StringOf("app.autoBranchCreationConfig.stage")
Local $sAppBasicAuthCredentials = $oJResp.StringOf("app.basicAuthCredentials")
Local $sAppBuildSpec = $oJResp.StringOf("app.buildSpec")
Local $iCreateTime = $oJResp.IntOf("app.createTime")
Local $sCustomHeaders = $oJResp.StringOf("app.customHeaders")
Local $sDefaultDomain = $oJResp.StringOf("app.defaultDomain")
Local $sDescription = $oJResp.StringOf("app.description")
Local $iEnableAutoBranchCreation = $oJResp.IntOf("app.enableAutoBranchCreation")
Local $iAppEnableBasicAuth = $oJResp.IntOf("app.enableBasicAuth")
Local $iEnableBranchAutoBuild = $oJResp.IntOf("app.enableBranchAutoBuild")
Local $iEnableBranchAutoDeletion = $oJResp.IntOf("app.enableBranchAutoDeletion")
Local $sEnvironmentVariablesString = $oJResp.StringOf("app.environmentVariables.string")
Local $sIamServiceRoleArn = $oJResp.StringOf("app.iamServiceRoleArn")
Local $sName = $oJResp.StringOf("app.name")
Local $sPlatform = $oJResp.StringOf("app.platform")
Local $sBranchName = $oJResp.StringOf("app.productionBranch.branchName")
Local $iLastDeployTime = $oJResp.IntOf("app.productionBranch.lastDeployTime")
Local $sStatus = $oJResp.StringOf("app.productionBranch.status")
Local $sThumbnailUrl = $oJResp.StringOf("app.productionBranch.thumbnailUrl")
Local $sRepository = $oJResp.StringOf("app.repository")
Local $sRepositoryCloneMethod = $oJResp.StringOf("app.repositoryCloneMethod")
Local $sTagsString = $oJResp.StringOf("app.tags.string")
Local $iUpdateTime = $oJResp.IntOf("app.updateTime")
Local $i = 0
Local $iCount_i = $oJResp.SizeOfArray("app.autoBranchCreationPatterns")
While $i < $iCount_i
$oJResp.I = $i
$strVal = $oJResp.StringOf("app.autoBranchCreationPatterns[i]")
$i = $i + 1
Wend
$i = 0
$iCount_i = $oJResp.SizeOfArray("app.customRules")
While $i < $iCount_i
$oJResp.I = $i
$sCondition = $oJResp.StringOf("app.customRules[i].condition")
$source = $oJResp.StringOf("app.customRules[i].source")
$status = $oJResp.StringOf("app.customRules[i].status")
$sTarget = $oJResp.StringOf("app.customRules[i].target")
$i = $i + 1
Wend
; A sample JSON response body parsed by the above code:
; {
; "app": {
; "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
; }
; }