Chilkat Online Tools

DescribeLayers autoit Example

AWS OpsWorks

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

; URL: https://opsworks.us-west-2.amazonaws.com/
; Use the same region as specified above.
$bSuccess = $oRest.Connect("opsworks.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("LayerIds[0]","string")
$oJson.UpdateString("StackId","string")

; The JSON request body created by the above code:

; {
;   "LayerIds": [
;     "string"
;   ],
;   "StackId": "string"
; }

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

$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 $sArn
Local $sV_String
Local $iAutoAssignElasticIps
Local $iAutoAssignPublicIps
Local $iEnabled
Local $sCreatedAt
Local $sCustomInstanceProfileArn
Local $sCustomJson
Local $iEnableAutoHealing
Local $iInstallUpdatesOnBoot
Local $sLayerId
Local $iDelayUntilElbConnectionsDrained
Local $iExecutionTimeout
Local $sName
Local $sShortname
Local $sStackId
Local $sV_Type
Local $iUseEbsOptimizedInstances
Local $iJ
Local $iCount_j
Local $iBatchCount
Local $iBatchSize
Local $iBufferDuration
Local $sDatetimeFormat
Local $sEncoding
Local $sFile
Local $sFileFingerprintLines
Local $sInitialPosition
Local $sLogGroupName
Local $sMultiLineStartPattern
Local $sTimeZone
Local $strVal
Local $iEncrypted
Local $iIops
Local $sMountPoint
Local $iNumberOfDisks
Local $iRaidLevel
Local $iSize
Local $sVolumeType

Local $i = 0
Local $iCount_i = $oJResp.SizeOfArray("Layers")
While $i < $iCount_i
    $oJResp.I = $i
    $sArn = $oJResp.StringOf("Layers[i].Arn")
    $sV_String = $oJResp.StringOf("Layers[i].Attributes.string")
    $iAutoAssignElasticIps = $oJResp.IntOf("Layers[i].AutoAssignElasticIps")
    $iAutoAssignPublicIps = $oJResp.IntOf("Layers[i].AutoAssignPublicIps")
    $iEnabled = $oJResp.IntOf("Layers[i].CloudWatchLogsConfiguration.Enabled")
    $sCreatedAt = $oJResp.StringOf("Layers[i].CreatedAt")
    $sCustomInstanceProfileArn = $oJResp.StringOf("Layers[i].CustomInstanceProfileArn")
    $sCustomJson = $oJResp.StringOf("Layers[i].CustomJson")
    $iEnableAutoHealing = $oJResp.IntOf("Layers[i].EnableAutoHealing")
    $iInstallUpdatesOnBoot = $oJResp.IntOf("Layers[i].InstallUpdatesOnBoot")
    $sLayerId = $oJResp.StringOf("Layers[i].LayerId")
    $iDelayUntilElbConnectionsDrained = $oJResp.IntOf("Layers[i].LifecycleEventConfiguration.Shutdown.DelayUntilElbConnectionsDrained")
    $iExecutionTimeout = $oJResp.IntOf("Layers[i].LifecycleEventConfiguration.Shutdown.ExecutionTimeout")
    $sName = $oJResp.StringOf("Layers[i].Name")
    $sShortname = $oJResp.StringOf("Layers[i].Shortname")
    $sStackId = $oJResp.StringOf("Layers[i].StackId")
    $sV_Type = $oJResp.StringOf("Layers[i].Type")
    $iUseEbsOptimizedInstances = $oJResp.IntOf("Layers[i].UseEbsOptimizedInstances")
    $iJ = 0
    $iCount_j = $oJResp.SizeOfArray("Layers[i].CloudWatchLogsConfiguration.LogStreams")
    While $iJ < $iCount_j
        $oJResp.J = $iJ
        $iBatchCount = $oJResp.IntOf("Layers[i].CloudWatchLogsConfiguration.LogStreams[j].BatchCount")
        $iBatchSize = $oJResp.IntOf("Layers[i].CloudWatchLogsConfiguration.LogStreams[j].BatchSize")
        $iBufferDuration = $oJResp.IntOf("Layers[i].CloudWatchLogsConfiguration.LogStreams[j].BufferDuration")
        $sDatetimeFormat = $oJResp.StringOf("Layers[i].CloudWatchLogsConfiguration.LogStreams[j].DatetimeFormat")
        $sEncoding = $oJResp.StringOf("Layers[i].CloudWatchLogsConfiguration.LogStreams[j].Encoding")
        $sFile = $oJResp.StringOf("Layers[i].CloudWatchLogsConfiguration.LogStreams[j].File")
        $sFileFingerprintLines = $oJResp.StringOf("Layers[i].CloudWatchLogsConfiguration.LogStreams[j].FileFingerprintLines")
        $sInitialPosition = $oJResp.StringOf("Layers[i].CloudWatchLogsConfiguration.LogStreams[j].InitialPosition")
        $sLogGroupName = $oJResp.StringOf("Layers[i].CloudWatchLogsConfiguration.LogStreams[j].LogGroupName")
        $sMultiLineStartPattern = $oJResp.StringOf("Layers[i].CloudWatchLogsConfiguration.LogStreams[j].MultiLineStartPattern")
        $sTimeZone = $oJResp.StringOf("Layers[i].CloudWatchLogsConfiguration.LogStreams[j].TimeZone")
        $iJ = $iJ + 1
    Wend
    $iJ = 0
    $iCount_j = $oJResp.SizeOfArray("Layers[i].CustomRecipes.Configure")
    While $iJ < $iCount_j
        $oJResp.J = $iJ
        $strVal = $oJResp.StringOf("Layers[i].CustomRecipes.Configure[j]")
        $iJ = $iJ + 1
    Wend
    $iJ = 0
    $iCount_j = $oJResp.SizeOfArray("Layers[i].CustomRecipes.Deploy")
    While $iJ < $iCount_j
        $oJResp.J = $iJ
        $strVal = $oJResp.StringOf("Layers[i].CustomRecipes.Deploy[j]")
        $iJ = $iJ + 1
    Wend
    $iJ = 0
    $iCount_j = $oJResp.SizeOfArray("Layers[i].CustomRecipes.Setup")
    While $iJ < $iCount_j
        $oJResp.J = $iJ
        $strVal = $oJResp.StringOf("Layers[i].CustomRecipes.Setup[j]")
        $iJ = $iJ + 1
    Wend
    $iJ = 0
    $iCount_j = $oJResp.SizeOfArray("Layers[i].CustomRecipes.Shutdown")
    While $iJ < $iCount_j
        $oJResp.J = $iJ
        $strVal = $oJResp.StringOf("Layers[i].CustomRecipes.Shutdown[j]")
        $iJ = $iJ + 1
    Wend
    $iJ = 0
    $iCount_j = $oJResp.SizeOfArray("Layers[i].CustomRecipes.Undeploy")
    While $iJ < $iCount_j
        $oJResp.J = $iJ
        $strVal = $oJResp.StringOf("Layers[i].CustomRecipes.Undeploy[j]")
        $iJ = $iJ + 1
    Wend
    $iJ = 0
    $iCount_j = $oJResp.SizeOfArray("Layers[i].CustomSecurityGroupIds")
    While $iJ < $iCount_j
        $oJResp.J = $iJ
        $strVal = $oJResp.StringOf("Layers[i].CustomSecurityGroupIds[j]")
        $iJ = $iJ + 1
    Wend
    $iJ = 0
    $iCount_j = $oJResp.SizeOfArray("Layers[i].DefaultRecipes.Configure")
    While $iJ < $iCount_j
        $oJResp.J = $iJ
        $strVal = $oJResp.StringOf("Layers[i].DefaultRecipes.Configure[j]")
        $iJ = $iJ + 1
    Wend
    $iJ = 0
    $iCount_j = $oJResp.SizeOfArray("Layers[i].DefaultRecipes.Deploy")
    While $iJ < $iCount_j
        $oJResp.J = $iJ
        $strVal = $oJResp.StringOf("Layers[i].DefaultRecipes.Deploy[j]")
        $iJ = $iJ + 1
    Wend
    $iJ = 0
    $iCount_j = $oJResp.SizeOfArray("Layers[i].DefaultRecipes.Setup")
    While $iJ < $iCount_j
        $oJResp.J = $iJ
        $strVal = $oJResp.StringOf("Layers[i].DefaultRecipes.Setup[j]")
        $iJ = $iJ + 1
    Wend
    $iJ = 0
    $iCount_j = $oJResp.SizeOfArray("Layers[i].DefaultRecipes.Shutdown")
    While $iJ < $iCount_j
        $oJResp.J = $iJ
        $strVal = $oJResp.StringOf("Layers[i].DefaultRecipes.Shutdown[j]")
        $iJ = $iJ + 1
    Wend
    $iJ = 0
    $iCount_j = $oJResp.SizeOfArray("Layers[i].DefaultRecipes.Undeploy")
    While $iJ < $iCount_j
        $oJResp.J = $iJ
        $strVal = $oJResp.StringOf("Layers[i].DefaultRecipes.Undeploy[j]")
        $iJ = $iJ + 1
    Wend
    $iJ = 0
    $iCount_j = $oJResp.SizeOfArray("Layers[i].DefaultSecurityGroupNames")
    While $iJ < $iCount_j
        $oJResp.J = $iJ
        $strVal = $oJResp.StringOf("Layers[i].DefaultSecurityGroupNames[j]")
        $iJ = $iJ + 1
    Wend
    $iJ = 0
    $iCount_j = $oJResp.SizeOfArray("Layers[i].Packages")
    While $iJ < $iCount_j
        $oJResp.J = $iJ
        $strVal = $oJResp.StringOf("Layers[i].Packages[j]")
        $iJ = $iJ + 1
    Wend
    $iJ = 0
    $iCount_j = $oJResp.SizeOfArray("Layers[i].VolumeConfigurations")
    While $iJ < $iCount_j
        $oJResp.J = $iJ
        $iEncrypted = $oJResp.IntOf("Layers[i].VolumeConfigurations[j].Encrypted")
        $iIops = $oJResp.IntOf("Layers[i].VolumeConfigurations[j].Iops")
        $sMountPoint = $oJResp.StringOf("Layers[i].VolumeConfigurations[j].MountPoint")
        $iNumberOfDisks = $oJResp.IntOf("Layers[i].VolumeConfigurations[j].NumberOfDisks")
        $iRaidLevel = $oJResp.IntOf("Layers[i].VolumeConfigurations[j].RaidLevel")
        $iSize = $oJResp.IntOf("Layers[i].VolumeConfigurations[j].Size")
        $sVolumeType = $oJResp.StringOf("Layers[i].VolumeConfigurations[j].VolumeType")
        $iJ = $iJ + 1
    Wend
    $i = $i + 1
Wend

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

; {
;   "Layers": [
;     {
;       "Arn": "string",
;       "Attributes": {
;         "string": "string"
;       },
;       "AutoAssignElasticIps": boolean,
;       "AutoAssignPublicIps": boolean,
;       "CloudWatchLogsConfiguration": {
;         "Enabled": boolean,
;         "LogStreams": [
;           {
;             "BatchCount": number,
;             "BatchSize": number,
;             "BufferDuration": number,
;             "DatetimeFormat": "string",
;             "Encoding": "string",
;             "File": "string",
;             "FileFingerprintLines": "string",
;             "InitialPosition": "string",
;             "LogGroupName": "string",
;             "MultiLineStartPattern": "string",
;             "TimeZone": "string"
;           }
;         ]
;       },
;       "CreatedAt": "string",
;       "CustomInstanceProfileArn": "string",
;       "CustomJson": "string",
;       "CustomRecipes": {
;         "Configure": [
;           "string"
;         ],
;         "Deploy": [
;           "string"
;         ],
;         "Setup": [
;           "string"
;         ],
;         "Shutdown": [
;           "string"
;         ],
;         "Undeploy": [
;           "string"
;         ]
;       },
;       "CustomSecurityGroupIds": [
;         "string"
;       ],
;       "DefaultRecipes": {
;         "Configure": [
;           "string"
;         ],
;         "Deploy": [
;           "string"
;         ],
;         "Setup": [
;           "string"
;         ],
;         "Shutdown": [
;           "string"
;         ],
;         "Undeploy": [
;           "string"
;         ]
;       },
;       "DefaultSecurityGroupNames": [
;         "string"
;       ],
;       "EnableAutoHealing": boolean,
;       "InstallUpdatesOnBoot": boolean,
;       "LayerId": "string",
;       "LifecycleEventConfiguration": {
;         "Shutdown": {
;           "DelayUntilElbConnectionsDrained": boolean,
;           "ExecutionTimeout": number
;         }
;       },
;       "Name": "string",
;       "Packages": [
;         "string"
;       ],
;       "Shortname": "string",
;       "StackId": "string",
;       "Type": "string",
;       "UseEbsOptimizedInstances": boolean,
;       "VolumeConfigurations": [
;         {
;           "Encrypted": boolean,
;           "Iops": number,
;           "MountPoint": "string",
;           "NumberOfDisks": number,
;           "RaidLevel": number,
;           "Size": number,
;           "VolumeType": "string"
;         }
;       ]
;     }
;   ]
; }