Chilkat Online Tools

GetContainerRecipe autoit Example

EC2 Image Builder

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

; URL: https://imagebuilder.us-west-2.amazonaws.com/
; Use the same region as specified above.
$bSuccess = $oRest.Connect("imagebuilder.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","GetContainerRecipe")

$oSbResponseBody = ObjCreate("Chilkat_9_5_0.StringBuilder")
$bSuccess = $oRest.FullRequestNoBodySb("GET","/GetContainerRecipe",$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 $sComponentArn
Local $iJ
Local $iCount_j
Local $sName
Local $iK
Local $iCount_k
Local $strVal
Local $sDeviceName
Local $iDeleteOnTermination
Local $iEbsEncrypted
Local $iIops
Local $sEbsKmsKeyId
Local $sSnapshotId
Local $iThroughput
Local $iVolumeSize
Local $sVolumeType
Local $sNoDevice
Local $sVirtualName

Local $sArn = $oJResp.StringOf("containerRecipe.arn")
Local $sContainerType = $oJResp.StringOf("containerRecipe.containerType")
Local $sDateCreated = $oJResp.StringOf("containerRecipe.dateCreated")
Local $sDescription = $oJResp.StringOf("containerRecipe.description")
Local $sDockerfileTemplateData = $oJResp.StringOf("containerRecipe.dockerfileTemplateData")
Local $iEncrypted = $oJResp.IntOf("containerRecipe.encrypted")
Local $sImage = $oJResp.StringOf("containerRecipe.instanceConfiguration.image")
Local $sKmsKeyId = $oJResp.StringOf("containerRecipe.kmsKeyId")
Local $sName = $oJResp.StringOf("containerRecipe.name")
Local $sOwner = $oJResp.StringOf("containerRecipe.owner")
Local $sParentImage = $oJResp.StringOf("containerRecipe.parentImage")
Local $sPlatform = $oJResp.StringOf("containerRecipe.platform")
Local $sV_String = $oJResp.StringOf("containerRecipe.tags.string")
Local $sRepositoryName = $oJResp.StringOf("containerRecipe.targetRepository.repositoryName")
Local $sService = $oJResp.StringOf("containerRecipe.targetRepository.service")
Local $sVersion = $oJResp.StringOf("containerRecipe.version")
Local $sWorkingDirectory = $oJResp.StringOf("containerRecipe.workingDirectory")
Local $sRequestId = $oJResp.StringOf("requestId")
Local $i = 0
Local $iCount_i = $oJResp.SizeOfArray("containerRecipe.components")
While $i < $iCount_i
    $oJResp.I = $i
    $sComponentArn = $oJResp.StringOf("containerRecipe.components[i].componentArn")
    $iJ = 0
    $iCount_j = $oJResp.SizeOfArray("containerRecipe.components[i].parameters")
    While $iJ < $iCount_j
        $oJResp.J = $iJ
        $sName = $oJResp.StringOf("containerRecipe.components[i].parameters[j].name")
        $iK = 0
        $iCount_k = $oJResp.SizeOfArray("containerRecipe.components[i].parameters[j].value")
        While $iK < $iCount_k
            $oJResp.K = $iK
            $strVal = $oJResp.StringOf("containerRecipe.components[i].parameters[j].value[k]")
            $iK = $iK + 1
        Wend
        $iJ = $iJ + 1
    Wend
    $i = $i + 1
Wend
$i = 0
$iCount_i = $oJResp.SizeOfArray("containerRecipe.instanceConfiguration.blockDeviceMappings")
While $i < $iCount_i
    $oJResp.I = $i
    $sDeviceName = $oJResp.StringOf("containerRecipe.instanceConfiguration.blockDeviceMappings[i].deviceName")
    $iDeleteOnTermination = $oJResp.IntOf("containerRecipe.instanceConfiguration.blockDeviceMappings[i].ebs.deleteOnTermination")
    $iEbsEncrypted = $oJResp.IntOf("containerRecipe.instanceConfiguration.blockDeviceMappings[i].ebs.encrypted")
    $iIops = $oJResp.IntOf("containerRecipe.instanceConfiguration.blockDeviceMappings[i].ebs.iops")
    $sEbsKmsKeyId = $oJResp.StringOf("containerRecipe.instanceConfiguration.blockDeviceMappings[i].ebs.kmsKeyId")
    $sSnapshotId = $oJResp.StringOf("containerRecipe.instanceConfiguration.blockDeviceMappings[i].ebs.snapshotId")
    $iThroughput = $oJResp.IntOf("containerRecipe.instanceConfiguration.blockDeviceMappings[i].ebs.throughput")
    $iVolumeSize = $oJResp.IntOf("containerRecipe.instanceConfiguration.blockDeviceMappings[i].ebs.volumeSize")
    $sVolumeType = $oJResp.StringOf("containerRecipe.instanceConfiguration.blockDeviceMappings[i].ebs.volumeType")
    $sNoDevice = $oJResp.StringOf("containerRecipe.instanceConfiguration.blockDeviceMappings[i].noDevice")
    $sVirtualName = $oJResp.StringOf("containerRecipe.instanceConfiguration.blockDeviceMappings[i].virtualName")
    $i = $i + 1
Wend

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

; {
;   "containerRecipe": {
;     "arn": "string",
;     "components": [
;       {
;         "componentArn": "string",
;         "parameters": [
;           {
;             "name": "string",
;             "value": [
;               "string"
;             ]
;           }
;         ]
;       }
;     ],
;     "containerType": "string",
;     "dateCreated": "string",
;     "description": "string",
;     "dockerfileTemplateData": "string",
;     "encrypted": boolean,
;     "instanceConfiguration": {
;       "blockDeviceMappings": [
;         {
;           "deviceName": "string",
;           "ebs": {
;             "deleteOnTermination": boolean,
;             "encrypted": boolean,
;             "iops": number,
;             "kmsKeyId": "string",
;             "snapshotId": "string",
;             "throughput": number,
;             "volumeSize": number,
;             "volumeType": "string"
;           },
;           "noDevice": "string",
;           "virtualName": "string"
;         }
;       ],
;       "image": "string"
;     },
;     "kmsKeyId": "string",
;     "name": "string",
;     "owner": "string",
;     "parentImage": "string",
;     "platform": "string",
;     "tags": {
;       "string": "string"
;     },
;     "targetRepository": {
;       "repositoryName": "string",
;       "service": "string"
;     },
;     "version": "string",
;     "workingDirectory": "string"
;   },
;   "requestId": "string"
; }