Chilkat Online Tools

ListSites autoit Example

AWS Outposts

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

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

$oSbResponseBody = ObjCreate("Chilkat_9_5_0.StringBuilder")
$bSuccess = $oRest.FullRequestNoBodySb("GET","/sites",$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 $sAccountId
Local $sDescription
Local $sName
Local $sNotes
Local $sOperatingAddressCity
Local $sOperatingAddressCountryCode
Local $sOperatingAddressStateOrRegion
Local $sFiberOpticCableType
Local $sMaximumSupportedWeightLbs
Local $sOpticalStandard
Local $sPowerConnector
Local $sPowerDrawKva
Local $sPowerFeedDrop
Local $sPowerPhase
Local $sUplinkCount
Local $sUplinkGbps
Local $sSiteArn
Local $sSiteId
Local $sV_String

Local $sNextToken = $oJResp.StringOf("NextToken")
Local $i = 0
Local $iCount_i = $oJResp.SizeOfArray("Sites")
While $i < $iCount_i
    $oJResp.I = $i
    $sAccountId = $oJResp.StringOf("Sites[i].AccountId")
    $sDescription = $oJResp.StringOf("Sites[i].Description")
    $sName = $oJResp.StringOf("Sites[i].Name")
    $sNotes = $oJResp.StringOf("Sites[i].Notes")
    $sOperatingAddressCity = $oJResp.StringOf("Sites[i].OperatingAddressCity")
    $sOperatingAddressCountryCode = $oJResp.StringOf("Sites[i].OperatingAddressCountryCode")
    $sOperatingAddressStateOrRegion = $oJResp.StringOf("Sites[i].OperatingAddressStateOrRegion")
    $sFiberOpticCableType = $oJResp.StringOf("Sites[i].RackPhysicalProperties.FiberOpticCableType")
    $sMaximumSupportedWeightLbs = $oJResp.StringOf("Sites[i].RackPhysicalProperties.MaximumSupportedWeightLbs")
    $sOpticalStandard = $oJResp.StringOf("Sites[i].RackPhysicalProperties.OpticalStandard")
    $sPowerConnector = $oJResp.StringOf("Sites[i].RackPhysicalProperties.PowerConnector")
    $sPowerDrawKva = $oJResp.StringOf("Sites[i].RackPhysicalProperties.PowerDrawKva")
    $sPowerFeedDrop = $oJResp.StringOf("Sites[i].RackPhysicalProperties.PowerFeedDrop")
    $sPowerPhase = $oJResp.StringOf("Sites[i].RackPhysicalProperties.PowerPhase")
    $sUplinkCount = $oJResp.StringOf("Sites[i].RackPhysicalProperties.UplinkCount")
    $sUplinkGbps = $oJResp.StringOf("Sites[i].RackPhysicalProperties.UplinkGbps")
    $sSiteArn = $oJResp.StringOf("Sites[i].SiteArn")
    $sSiteId = $oJResp.StringOf("Sites[i].SiteId")
    $sV_String = $oJResp.StringOf("Sites[i].Tags.string")
    $i = $i + 1
Wend

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

; {
;   "NextToken": "string",
;   "Sites": [
;     {
;       "AccountId": "string",
;       "Description": "string",
;       "Name": "string",
;       "Notes": "string",
;       "OperatingAddressCity": "string",
;       "OperatingAddressCountryCode": "string",
;       "OperatingAddressStateOrRegion": "string",
;       "RackPhysicalProperties": {
;         "FiberOpticCableType": "string",
;         "MaximumSupportedWeightLbs": "string",
;         "OpticalStandard": "string",
;         "PowerConnector": "string",
;         "PowerDrawKva": "string",
;         "PowerFeedDrop": "string",
;         "PowerPhase": "string",
;         "UplinkCount": "string",
;         "UplinkGbps": "string"
;       },
;       "SiteArn": "string",
;       "SiteId": "string",
;       "Tags": {
;         "string": "string"
;       }
;     }
;   ]
; }