Chilkat Online Tools

UpdatePipeline autoit Example

AWS CodePipeline

; 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 = "codepipeline"
; SetAuthAws causes Chilkat to automatically add the following headers: Authorization, X-Amz-Date
$oRest.SetAuthAws($oAuthAws)

; URL: https://codepipeline.us-west-2.amazonaws.com/
; Use the same region as specified above.
$bSuccess = $oRest.Connect("codepipeline.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("pipeline.artifactStore.encryptionKey.id","string")
$oJson.UpdateString("pipeline.artifactStore.encryptionKey.type","string")
$oJson.UpdateString("pipeline.artifactStore.location","string")
$oJson.UpdateString("pipeline.artifactStore.type","string")
$oJson.UpdateString("pipeline.artifactStores.string.encryptionKey.id","string")
$oJson.UpdateString("pipeline.artifactStores.string.encryptionKey.type","string")
$oJson.UpdateString("pipeline.artifactStores.string.location","string")
$oJson.UpdateString("pipeline.artifactStores.string.type","string")
$oJson.UpdateString("pipeline.name","string")
$oJson.UpdateString("pipeline.roleArn","string")
$oJson.UpdateString("pipeline.stages[0].actions[0].actionTypeId.category","string")
$oJson.UpdateString("pipeline.stages[0].actions[0].actionTypeId.owner","string")
$oJson.UpdateString("pipeline.stages[0].actions[0].actionTypeId.provider","string")
$oJson.UpdateString("pipeline.stages[0].actions[0].actionTypeId.version","string")
$oJson.UpdateString("pipeline.stages[0].actions[0].configuration.string","string")
$oJson.UpdateString("pipeline.stages[0].actions[0].inputArtifacts[0].name","string")
$oJson.UpdateString("pipeline.stages[0].actions[0].name","string")
$oJson.UpdateString("pipeline.stages[0].actions[0].namespace","string")
$oJson.UpdateString("pipeline.stages[0].actions[0].outputArtifacts[0].name","string")
$oJson.UpdateString("pipeline.stages[0].actions[0].region","string")
$oJson.UpdateString("pipeline.stages[0].actions[0].roleArn","string")
$oJson.UpdateInt("pipeline.stages[0].actions[0].runOrder",123)
$oJson.UpdateString("pipeline.stages[0].blockers[0].name","string")
$oJson.UpdateString("pipeline.stages[0].blockers[0].type","string")
$oJson.UpdateString("pipeline.stages[0].name","string")
$oJson.UpdateInt("pipeline.version",123)

; The JSON request body created by the above code:

; {
;   "pipeline": {
;     "artifactStore": {
;       "encryptionKey": {
;         "id": "string",
;         "type": "string"
;       },
;       "location": "string",
;       "type": "string"
;     },
;     "artifactStores": {
;       "string": {
;         "encryptionKey": {
;           "id": "string",
;           "type": "string"
;         },
;         "location": "string",
;         "type": "string"
;       }
;     },
;     "name": "string",
;     "roleArn": "string",
;     "stages": [
;       {
;         "actions": [
;           {
;             "actionTypeId": {
;               "category": "string",
;               "owner": "string",
;               "provider": "string",
;               "version": "string"
;             },
;             "configuration": {
;               "string": "string"
;             },
;             "inputArtifacts": [
;               {
;                 "name": "string"
;               }
;             ],
;             "name": "string",
;             "namespace": "string",
;             "outputArtifacts": [
;               {
;                 "name": "string"
;               }
;             ],
;             "region": "string",
;             "roleArn": "string",
;             "runOrder": number
;           }
;         ],
;         "blockers": [
;           {
;             "name": "string",
;             "type": "string"
;           }
;         ],
;         "name": "string"
;       }
;     ],
;     "version": number
;   }
; }

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

$oSbRequestBody = ObjCreate("Chilkat_9_5_0.StringBuilder")
$oJson.EmitSb($oSbRequestBody)
$oSbResponseBody = ObjCreate("Chilkat_9_5_0.StringBuilder")
$bSuccess = $oRest.FullRequestSb("POST","/",$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 $sName
Local $iJ
Local $iCount_j
Local $sCategory
Local $sOwner
Local $sProvider
Local $sActionTypeIdVersion
Local $sV_String
Local $sNamespace
Local $sRegion
Local $sRoleArn
Local $iRunOrder
Local $iK
Local $iCount_k
Local $sV_type

Local $sId = $oJResp.StringOf("pipeline.artifactStore.encryptionKey.id")
Local $sV_Type = $oJResp.StringOf("pipeline.artifactStore.encryptionKey.type")
Local $sLocation = $oJResp.StringOf("pipeline.artifactStore.location")
Local $sArtifactStoreType = $oJResp.StringOf("pipeline.artifactStore.type")
Local $sEncryptionKeyId = $oJResp.StringOf("pipeline.artifactStores.string.encryptionKey.id")
Local $sEncryptionKeyType = $oJResp.StringOf("pipeline.artifactStores.string.encryptionKey.type")
Local $sStringLocation = $oJResp.StringOf("pipeline.artifactStores.string.location")
Local $sStringType = $oJResp.StringOf("pipeline.artifactStores.string.type")
Local $sName = $oJResp.StringOf("pipeline.name")
Local $sRoleArn = $oJResp.StringOf("pipeline.roleArn")
Local $iVersion = $oJResp.IntOf("pipeline.version")
Local $i = 0
Local $iCount_i = $oJResp.SizeOfArray("pipeline.stages")
While $i < $iCount_i
    $oJResp.I = $i
    $sName = $oJResp.StringOf("pipeline.stages[i].name")
    $iJ = 0
    $iCount_j = $oJResp.SizeOfArray("pipeline.stages[i].actions")
    While $iJ < $iCount_j
        $oJResp.J = $iJ
        $sCategory = $oJResp.StringOf("pipeline.stages[i].actions[j].actionTypeId.category")
        $sOwner = $oJResp.StringOf("pipeline.stages[i].actions[j].actionTypeId.owner")
        $sProvider = $oJResp.StringOf("pipeline.stages[i].actions[j].actionTypeId.provider")
        $sActionTypeIdVersion = $oJResp.StringOf("pipeline.stages[i].actions[j].actionTypeId.version")
        $sV_String = $oJResp.StringOf("pipeline.stages[i].actions[j].configuration.string")
        $sName = $oJResp.StringOf("pipeline.stages[i].actions[j].name")
        $sNamespace = $oJResp.StringOf("pipeline.stages[i].actions[j].namespace")
        $sRegion = $oJResp.StringOf("pipeline.stages[i].actions[j].region")
        $sRoleArn = $oJResp.StringOf("pipeline.stages[i].actions[j].roleArn")
        $iRunOrder = $oJResp.IntOf("pipeline.stages[i].actions[j].runOrder")
        $iK = 0
        $iCount_k = $oJResp.SizeOfArray("pipeline.stages[i].actions[j].inputArtifacts")
        While $iK < $iCount_k
            $oJResp.K = $iK
            $sName = $oJResp.StringOf("pipeline.stages[i].actions[j].inputArtifacts[k].name")
            $iK = $iK + 1
        Wend
        $iK = 0
        $iCount_k = $oJResp.SizeOfArray("pipeline.stages[i].actions[j].outputArtifacts")
        While $iK < $iCount_k
            $oJResp.K = $iK
            $sName = $oJResp.StringOf("pipeline.stages[i].actions[j].outputArtifacts[k].name")
            $iK = $iK + 1
        Wend
        $iJ = $iJ + 1
    Wend
    $iJ = 0
    $iCount_j = $oJResp.SizeOfArray("pipeline.stages[i].blockers")
    While $iJ < $iCount_j
        $oJResp.J = $iJ
        $sName = $oJResp.StringOf("pipeline.stages[i].blockers[j].name")
        $sV_type = $oJResp.StringOf("pipeline.stages[i].blockers[j].type")
        $iJ = $iJ + 1
    Wend
    $i = $i + 1
Wend

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

; {
;   "pipeline": {
;     "artifactStore": {
;       "encryptionKey": {
;         "id": "string",
;         "type": "string"
;       },
;       "location": "string",
;       "type": "string"
;     },
;     "artifactStores": {
;       "string": {
;         "encryptionKey": {
;           "id": "string",
;           "type": "string"
;         },
;         "location": "string",
;         "type": "string"
;       }
;     },
;     "name": "string",
;     "roleArn": "string",
;     "stages": [
;       {
;         "actions": [
;           {
;             "actionTypeId": {
;               "category": "string",
;               "owner": "string",
;               "provider": "string",
;               "version": "string"
;             },
;             "configuration": {
;               "string": "string"
;             },
;             "inputArtifacts": [
;               {
;                 "name": "string"
;               }
;             ],
;             "name": "string",
;             "namespace": "string",
;             "outputArtifacts": [
;               {
;                 "name": "string"
;               }
;             ],
;             "region": "string",
;             "roleArn": "string",
;             "runOrder": number
;           }
;         ],
;         "blockers": [
;           {
;             "name": "string",
;             "type": "string"
;           }
;         ],
;         "name": "string"
;       }
;     ],
;     "version": number
;   }
; }