GetLifecyclePolicy 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 = "dlm"
; SetAuthAws causes Chilkat to automatically add the following headers: Authorization, X-Amz-Date
$oRest.SetAuthAws($oAuthAws)
; URL: https://dlm.us-west-2.amazonaws.com/
; Use the same region as specified above.
$bSuccess = $oRest.Connect("dlm.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","GetLifecyclePolicy")
$oSbResponseBody = ObjCreate("Chilkat_9_5_0.StringBuilder")
$bSuccess = $oRest.FullRequestNoBodySb("GET","/policies/{policyId}/",$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 $sCmkArn
Local $iEncrypted
Local $iInterval
Local $sIntervalUnit
Local $sTarget
Local $strVal
Local $iCopyTags
Local $sCronExpression
Local $iCreateRuleInterval
Local $sCreateRuleIntervalUnit
Local $sLocation
Local $iCount
Local $iDeprecateRuleInterval
Local $sDeprecateRuleIntervalUnit
Local $iFastRestoreRuleCount
Local $iFastRestoreRuleInterval
Local $sFastRestoreRuleIntervalUnit
Local $iRetainRuleCount
Local $iRetainRuleInterval
Local $sRetainRuleIntervalUnit
Local $sTargetRegion
Local $iUnshareInterval
Local $sUnshareIntervalUnit
Local $iK
Local $iCount_k
Local $sKey
Local $sValue
Local $iDateCreated = $oJResp.IntOf("Policy.DateCreated")
Local $iDateModified = $oJResp.IntOf("Policy.DateModified")
Local $sDescription = $oJResp.StringOf("Policy.Description")
Local $sExecutionRoleArn = $oJResp.StringOf("Policy.ExecutionRoleArn")
Local $sPolicyArn = $oJResp.StringOf("Policy.PolicyArn")
Local $sDescriptionRegex = $oJResp.StringOf("Policy.PolicyDetails.EventSource.Parameters.DescriptionRegex")
Local $sEventType = $oJResp.StringOf("Policy.PolicyDetails.EventSource.Parameters.EventType")
Local $sV_Type = $oJResp.StringOf("Policy.PolicyDetails.EventSource.Type")
Local $iExcludeBootVolume = $oJResp.IntOf("Policy.PolicyDetails.Parameters.ExcludeBootVolume")
Local $iNoReboot = $oJResp.IntOf("Policy.PolicyDetails.Parameters.NoReboot")
Local $sPolicyType = $oJResp.StringOf("Policy.PolicyDetails.PolicyType")
Local $sPolicyId = $oJResp.StringOf("Policy.PolicyId")
Local $sState = $oJResp.StringOf("Policy.State")
Local $sStatusMessage = $oJResp.StringOf("Policy.StatusMessage")
Local $sV_String = $oJResp.StringOf("Policy.Tags.string")
Local $i = 0
Local $iCount_i = $oJResp.SizeOfArray("Policy.PolicyDetails.Actions")
While $i < $iCount_i
$oJResp.I = $i
$sName = $oJResp.StringOf("Policy.PolicyDetails.Actions[i].Name")
$iJ = 0
$iCount_j = $oJResp.SizeOfArray("Policy.PolicyDetails.Actions[i].CrossRegionCopy")
While $iJ < $iCount_j
$oJResp.J = $iJ
$sCmkArn = $oJResp.StringOf("Policy.PolicyDetails.Actions[i].CrossRegionCopy[j].EncryptionConfiguration.CmkArn")
$iEncrypted = $oJResp.IntOf("Policy.PolicyDetails.Actions[i].CrossRegionCopy[j].EncryptionConfiguration.Encrypted")
$iInterval = $oJResp.IntOf("Policy.PolicyDetails.Actions[i].CrossRegionCopy[j].RetainRule.Interval")
$sIntervalUnit = $oJResp.StringOf("Policy.PolicyDetails.Actions[i].CrossRegionCopy[j].RetainRule.IntervalUnit")
$sTarget = $oJResp.StringOf("Policy.PolicyDetails.Actions[i].CrossRegionCopy[j].Target")
$iJ = $iJ + 1
Wend
$i = $i + 1
Wend
$i = 0
$iCount_i = $oJResp.SizeOfArray("Policy.PolicyDetails.EventSource.Parameters.SnapshotOwner")
While $i < $iCount_i
$oJResp.I = $i
$strVal = $oJResp.StringOf("Policy.PolicyDetails.EventSource.Parameters.SnapshotOwner[i]")
$i = $i + 1
Wend
$i = 0
$iCount_i = $oJResp.SizeOfArray("Policy.PolicyDetails.ResourceLocations")
While $i < $iCount_i
$oJResp.I = $i
$strVal = $oJResp.StringOf("Policy.PolicyDetails.ResourceLocations[i]")
$i = $i + 1
Wend
$i = 0
$iCount_i = $oJResp.SizeOfArray("Policy.PolicyDetails.ResourceTypes")
While $i < $iCount_i
$oJResp.I = $i
$strVal = $oJResp.StringOf("Policy.PolicyDetails.ResourceTypes[i]")
$i = $i + 1
Wend
$i = 0
$iCount_i = $oJResp.SizeOfArray("Policy.PolicyDetails.Schedules")
While $i < $iCount_i
$oJResp.I = $i
$iCopyTags = $oJResp.IntOf("Policy.PolicyDetails.Schedules[i].CopyTags")
$sCronExpression = $oJResp.StringOf("Policy.PolicyDetails.Schedules[i].CreateRule.CronExpression")
$iCreateRuleInterval = $oJResp.IntOf("Policy.PolicyDetails.Schedules[i].CreateRule.Interval")
$sCreateRuleIntervalUnit = $oJResp.StringOf("Policy.PolicyDetails.Schedules[i].CreateRule.IntervalUnit")
$sLocation = $oJResp.StringOf("Policy.PolicyDetails.Schedules[i].CreateRule.Location")
$iCount = $oJResp.IntOf("Policy.PolicyDetails.Schedules[i].DeprecateRule.Count")
$iDeprecateRuleInterval = $oJResp.IntOf("Policy.PolicyDetails.Schedules[i].DeprecateRule.Interval")
$sDeprecateRuleIntervalUnit = $oJResp.StringOf("Policy.PolicyDetails.Schedules[i].DeprecateRule.IntervalUnit")
$iFastRestoreRuleCount = $oJResp.IntOf("Policy.PolicyDetails.Schedules[i].FastRestoreRule.Count")
$iFastRestoreRuleInterval = $oJResp.IntOf("Policy.PolicyDetails.Schedules[i].FastRestoreRule.Interval")
$sFastRestoreRuleIntervalUnit = $oJResp.StringOf("Policy.PolicyDetails.Schedules[i].FastRestoreRule.IntervalUnit")
$sName = $oJResp.StringOf("Policy.PolicyDetails.Schedules[i].Name")
$iRetainRuleCount = $oJResp.IntOf("Policy.PolicyDetails.Schedules[i].RetainRule.Count")
$iRetainRuleInterval = $oJResp.IntOf("Policy.PolicyDetails.Schedules[i].RetainRule.Interval")
$sRetainRuleIntervalUnit = $oJResp.StringOf("Policy.PolicyDetails.Schedules[i].RetainRule.IntervalUnit")
$iJ = 0
$iCount_j = $oJResp.SizeOfArray("Policy.PolicyDetails.Schedules[i].CreateRule.Times")
While $iJ < $iCount_j
$oJResp.J = $iJ
$strVal = $oJResp.StringOf("Policy.PolicyDetails.Schedules[i].CreateRule.Times[j]")
$iJ = $iJ + 1
Wend
$iJ = 0
$iCount_j = $oJResp.SizeOfArray("Policy.PolicyDetails.Schedules[i].CrossRegionCopyRules")
While $iJ < $iCount_j
$oJResp.J = $iJ
$sCmkArn = $oJResp.StringOf("Policy.PolicyDetails.Schedules[i].CrossRegionCopyRules[j].CmkArn")
$iCopyTags = $oJResp.IntOf("Policy.PolicyDetails.Schedules[i].CrossRegionCopyRules[j].CopyTags")
$iDeprecateRuleInterval = $oJResp.IntOf("Policy.PolicyDetails.Schedules[i].CrossRegionCopyRules[j].DeprecateRule.Interval")
$sDeprecateRuleIntervalUnit = $oJResp.StringOf("Policy.PolicyDetails.Schedules[i].CrossRegionCopyRules[j].DeprecateRule.IntervalUnit")
$iEncrypted = $oJResp.IntOf("Policy.PolicyDetails.Schedules[i].CrossRegionCopyRules[j].Encrypted")
$iRetainRuleInterval = $oJResp.IntOf("Policy.PolicyDetails.Schedules[i].CrossRegionCopyRules[j].RetainRule.Interval")
$sRetainRuleIntervalUnit = $oJResp.StringOf("Policy.PolicyDetails.Schedules[i].CrossRegionCopyRules[j].RetainRule.IntervalUnit")
$sTarget = $oJResp.StringOf("Policy.PolicyDetails.Schedules[i].CrossRegionCopyRules[j].Target")
$sTargetRegion = $oJResp.StringOf("Policy.PolicyDetails.Schedules[i].CrossRegionCopyRules[j].TargetRegion")
$iJ = $iJ + 1
Wend
$iJ = 0
$iCount_j = $oJResp.SizeOfArray("Policy.PolicyDetails.Schedules[i].FastRestoreRule.AvailabilityZones")
While $iJ < $iCount_j
$oJResp.J = $iJ
$strVal = $oJResp.StringOf("Policy.PolicyDetails.Schedules[i].FastRestoreRule.AvailabilityZones[j]")
$iJ = $iJ + 1
Wend
$iJ = 0
$iCount_j = $oJResp.SizeOfArray("Policy.PolicyDetails.Schedules[i].ShareRules")
While $iJ < $iCount_j
$oJResp.J = $iJ
$iUnshareInterval = $oJResp.IntOf("Policy.PolicyDetails.Schedules[i].ShareRules[j].UnshareInterval")
$sUnshareIntervalUnit = $oJResp.StringOf("Policy.PolicyDetails.Schedules[i].ShareRules[j].UnshareIntervalUnit")
$iK = 0
$iCount_k = $oJResp.SizeOfArray("Policy.PolicyDetails.Schedules[i].ShareRules[j].TargetAccounts")
While $iK < $iCount_k
$oJResp.K = $iK
$strVal = $oJResp.StringOf("Policy.PolicyDetails.Schedules[i].ShareRules[j].TargetAccounts[k]")
$iK = $iK + 1
Wend
$iJ = $iJ + 1
Wend
$iJ = 0
$iCount_j = $oJResp.SizeOfArray("Policy.PolicyDetails.Schedules[i].TagsToAdd")
While $iJ < $iCount_j
$oJResp.J = $iJ
$sKey = $oJResp.StringOf("Policy.PolicyDetails.Schedules[i].TagsToAdd[j].Key")
$sValue = $oJResp.StringOf("Policy.PolicyDetails.Schedules[i].TagsToAdd[j].Value")
$iJ = $iJ + 1
Wend
$iJ = 0
$iCount_j = $oJResp.SizeOfArray("Policy.PolicyDetails.Schedules[i].VariableTags")
While $iJ < $iCount_j
$oJResp.J = $iJ
$sKey = $oJResp.StringOf("Policy.PolicyDetails.Schedules[i].VariableTags[j].Key")
$sValue = $oJResp.StringOf("Policy.PolicyDetails.Schedules[i].VariableTags[j].Value")
$iJ = $iJ + 1
Wend
$i = $i + 1
Wend
$i = 0
$iCount_i = $oJResp.SizeOfArray("Policy.PolicyDetails.TargetTags")
While $i < $iCount_i
$oJResp.I = $i
$sKey = $oJResp.StringOf("Policy.PolicyDetails.TargetTags[i].Key")
$sValue = $oJResp.StringOf("Policy.PolicyDetails.TargetTags[i].Value")
$i = $i + 1
Wend
; A sample JSON response body parsed by the above code:
; {
; "Policy": {
; "DateCreated": number,
; "DateModified": number,
; "Description": "string",
; "ExecutionRoleArn": "string",
; "PolicyArn": "string",
; "PolicyDetails": {
; "Actions": [
; {
; "CrossRegionCopy": [
; {
; "EncryptionConfiguration": {
; "CmkArn": "string",
; "Encrypted": boolean
; },
; "RetainRule": {
; "Interval": number,
; "IntervalUnit": "string"
; },
; "Target": "string"
; }
; ],
; "Name": "string"
; }
; ],
; "EventSource": {
; "Parameters": {
; "DescriptionRegex": "string",
; "EventType": "string",
; "SnapshotOwner": [
; "string"
; ]
; },
; "Type": "string"
; },
; "Parameters": {
; "ExcludeBootVolume": boolean,
; "NoReboot": boolean
; },
; "PolicyType": "string",
; "ResourceLocations": [
; "string"
; ],
; "ResourceTypes": [
; "string"
; ],
; "Schedules": [
; {
; "CopyTags": boolean,
; "CreateRule": {
; "CronExpression": "string",
; "Interval": number,
; "IntervalUnit": "string",
; "Location": "string",
; "Times": [
; "string"
; ]
; },
; "CrossRegionCopyRules": [
; {
; "CmkArn": "string",
; "CopyTags": boolean,
; "DeprecateRule": {
; "Interval": number,
; "IntervalUnit": "string"
; },
; "Encrypted": boolean,
; "RetainRule": {
; "Interval": number,
; "IntervalUnit": "string"
; },
; "Target": "string",
; "TargetRegion": "string"
; }
; ],
; "DeprecateRule": {
; "Count": number,
; "Interval": number,
; "IntervalUnit": "string"
; },
; "FastRestoreRule": {
; "AvailabilityZones": [
; "string"
; ],
; "Count": number,
; "Interval": number,
; "IntervalUnit": "string"
; },
; "Name": "string",
; "RetainRule": {
; "Count": number,
; "Interval": number,
; "IntervalUnit": "string"
; },
; "ShareRules": [
; {
; "TargetAccounts": [
; "string"
; ],
; "UnshareInterval": number,
; "UnshareIntervalUnit": "string"
; }
; ],
; "TagsToAdd": [
; {
; "Key": "string",
; "Value": "string"
; }
; ],
; "VariableTags": [
; {
; "Key": "string",
; "Value": "string"
; }
; ]
; }
; ],
; "TargetTags": [
; {
; "Key": "string",
; "Value": "string"
; }
; ]
; },
; "PolicyId": "string",
; "State": "string",
; "StatusMessage": "string",
; "Tags": {
; "string": "string"
; }
; }
; }