GetLifecyclePolicy Foxpro Example
LOCAL loRest
LOCAL lnSuccess
LOCAL loAuthAws
LOCAL loSbResponseBody
LOCAL lnRespStatusCode
LOCAL loJResp
LOCAL lcName
LOCAL j
LOCAL lnCount_j
LOCAL lcCmkArn
LOCAL lnEncrypted
LOCAL lnInterval
LOCAL lcIntervalUnit
LOCAL lcTarget
LOCAL lcStrVal
LOCAL lnCopyTags
LOCAL lcCronExpression
LOCAL lnCreateRuleInterval
LOCAL lcCreateRuleIntervalUnit
LOCAL lcLocation
LOCAL lnCount
LOCAL lnDeprecateRuleInterval
LOCAL lcDeprecateRuleIntervalUnit
LOCAL lnFastRestoreRuleCount
LOCAL lnFastRestoreRuleInterval
LOCAL lcFastRestoreRuleIntervalUnit
LOCAL lnRetainRuleCount
LOCAL lnRetainRuleInterval
LOCAL lcRetainRuleIntervalUnit
LOCAL lcTargetRegion
LOCAL lnUnshareInterval
LOCAL lcUnshareIntervalUnit
LOCAL k
LOCAL lnCount_k
LOCAL lcKey
LOCAL lcValue
LOCAL lnDateCreated
LOCAL lnDateModified
LOCAL lcDescription
LOCAL lcExecutionRoleArn
LOCAL lcPolicyArn
LOCAL lcDescriptionRegex
LOCAL lcEventType
LOCAL lcV_Type
LOCAL lnExcludeBootVolume
LOCAL lnNoReboot
LOCAL lcPolicyType
LOCAL lcPolicyId
LOCAL lcState
LOCAL lcStatusMessage
LOCAL lcV_String
LOCAL i
LOCAL lnCount_i
* This example requires the Chilkat API to have been previously unlocked.
* See Global Unlock Sample for sample code.
loRest = CreateObject('Chilkat_9_5_0.Rest')
loAuthAws = CreateObject('Chilkat_9_5_0.AuthAws')
loAuthAws.AccessKey = "AWS_ACCESS_KEY"
loAuthAws.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.)
loAuthAws.Region = "us-west-2"
loAuthAws.ServiceName = "dlm"
* SetAuthAws causes Chilkat to automatically add the following headers: Authorization, X-Amz-Date
loRest.SetAuthAws(loAuthAws)
* URL: https://dlm.us-west-2.amazonaws.com/
* Use the same region as specified above.
lnSuccess = loRest.Connect("dlm.us-west-2.amazonaws.com",443,1,1)
IF (lnSuccess <> 1) THEN
? "ConnectFailReason: " + STR(loRest.ConnectFailReason)
? loRest.LastErrorText
RELEASE loRest
RELEASE loAuthAws
CANCEL
ENDIF
loRest.AddHeader("Content-Type","application/x-amz-json-1.1")
loRest.AddHeader("X-Amz-Target","GetLifecyclePolicy")
loSbResponseBody = CreateObject('Chilkat_9_5_0.StringBuilder')
lnSuccess = loRest.FullRequestNoBodySb("GET","/policies/{policyId}/",loSbResponseBody)
IF (lnSuccess <> 1) THEN
? loRest.LastErrorText
RELEASE loRest
RELEASE loAuthAws
RELEASE loSbResponseBody
CANCEL
ENDIF
lnRespStatusCode = loRest.ResponseStatusCode
? "response status code = " + STR(lnRespStatusCode)
IF (lnRespStatusCode <> 200) THEN
? "Response Header:"
? loRest.ResponseHeader
? "Response Body:"
? loSbResponseBody.GetAsString()
RELEASE loRest
RELEASE loAuthAws
RELEASE loSbResponseBody
CANCEL
ENDIF
loJResp = CreateObject('Chilkat_9_5_0.JsonObject')
loJResp.LoadSb(loSbResponseBody)
* 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
lnDateCreated = loJResp.IntOf("Policy.DateCreated")
lnDateModified = loJResp.IntOf("Policy.DateModified")
lcDescription = loJResp.StringOf("Policy.Description")
lcExecutionRoleArn = loJResp.StringOf("Policy.ExecutionRoleArn")
lcPolicyArn = loJResp.StringOf("Policy.PolicyArn")
lcDescriptionRegex = loJResp.StringOf("Policy.PolicyDetails.EventSource.Parameters.DescriptionRegex")
lcEventType = loJResp.StringOf("Policy.PolicyDetails.EventSource.Parameters.EventType")
lcV_Type = loJResp.StringOf("Policy.PolicyDetails.EventSource.Type")
lnExcludeBootVolume = loJResp.IntOf("Policy.PolicyDetails.Parameters.ExcludeBootVolume")
lnNoReboot = loJResp.IntOf("Policy.PolicyDetails.Parameters.NoReboot")
lcPolicyType = loJResp.StringOf("Policy.PolicyDetails.PolicyType")
lcPolicyId = loJResp.StringOf("Policy.PolicyId")
lcState = loJResp.StringOf("Policy.State")
lcStatusMessage = loJResp.StringOf("Policy.StatusMessage")
lcV_String = loJResp.StringOf("Policy.Tags.string")
i = 0
lnCount_i = loJResp.SizeOfArray("Policy.PolicyDetails.Actions")
DO WHILE i < lnCount_i
loJResp.I = i
lcName = loJResp.StringOf("Policy.PolicyDetails.Actions[i].Name")
j = 0
lnCount_j = loJResp.SizeOfArray("Policy.PolicyDetails.Actions[i].CrossRegionCopy")
DO WHILE j < lnCount_j
loJResp.J = j
lcCmkArn = loJResp.StringOf("Policy.PolicyDetails.Actions[i].CrossRegionCopy[j].EncryptionConfiguration.CmkArn")
lnEncrypted = loJResp.IntOf("Policy.PolicyDetails.Actions[i].CrossRegionCopy[j].EncryptionConfiguration.Encrypted")
lnInterval = loJResp.IntOf("Policy.PolicyDetails.Actions[i].CrossRegionCopy[j].RetainRule.Interval")
lcIntervalUnit = loJResp.StringOf("Policy.PolicyDetails.Actions[i].CrossRegionCopy[j].RetainRule.IntervalUnit")
lcTarget = loJResp.StringOf("Policy.PolicyDetails.Actions[i].CrossRegionCopy[j].Target")
j = j + 1
ENDDO
i = i + 1
ENDDO
i = 0
lnCount_i = loJResp.SizeOfArray("Policy.PolicyDetails.EventSource.Parameters.SnapshotOwner")
DO WHILE i < lnCount_i
loJResp.I = i
lcStrVal = loJResp.StringOf("Policy.PolicyDetails.EventSource.Parameters.SnapshotOwner[i]")
i = i + 1
ENDDO
i = 0
lnCount_i = loJResp.SizeOfArray("Policy.PolicyDetails.ResourceLocations")
DO WHILE i < lnCount_i
loJResp.I = i
lcStrVal = loJResp.StringOf("Policy.PolicyDetails.ResourceLocations[i]")
i = i + 1
ENDDO
i = 0
lnCount_i = loJResp.SizeOfArray("Policy.PolicyDetails.ResourceTypes")
DO WHILE i < lnCount_i
loJResp.I = i
lcStrVal = loJResp.StringOf("Policy.PolicyDetails.ResourceTypes[i]")
i = i + 1
ENDDO
i = 0
lnCount_i = loJResp.SizeOfArray("Policy.PolicyDetails.Schedules")
DO WHILE i < lnCount_i
loJResp.I = i
lnCopyTags = loJResp.IntOf("Policy.PolicyDetails.Schedules[i].CopyTags")
lcCronExpression = loJResp.StringOf("Policy.PolicyDetails.Schedules[i].CreateRule.CronExpression")
lnCreateRuleInterval = loJResp.IntOf("Policy.PolicyDetails.Schedules[i].CreateRule.Interval")
lcCreateRuleIntervalUnit = loJResp.StringOf("Policy.PolicyDetails.Schedules[i].CreateRule.IntervalUnit")
lcLocation = loJResp.StringOf("Policy.PolicyDetails.Schedules[i].CreateRule.Location")
lnCount = loJResp.IntOf("Policy.PolicyDetails.Schedules[i].DeprecateRule.Count")
lnDeprecateRuleInterval = loJResp.IntOf("Policy.PolicyDetails.Schedules[i].DeprecateRule.Interval")
lcDeprecateRuleIntervalUnit = loJResp.StringOf("Policy.PolicyDetails.Schedules[i].DeprecateRule.IntervalUnit")
lnFastRestoreRuleCount = loJResp.IntOf("Policy.PolicyDetails.Schedules[i].FastRestoreRule.Count")
lnFastRestoreRuleInterval = loJResp.IntOf("Policy.PolicyDetails.Schedules[i].FastRestoreRule.Interval")
lcFastRestoreRuleIntervalUnit = loJResp.StringOf("Policy.PolicyDetails.Schedules[i].FastRestoreRule.IntervalUnit")
lcName = loJResp.StringOf("Policy.PolicyDetails.Schedules[i].Name")
lnRetainRuleCount = loJResp.IntOf("Policy.PolicyDetails.Schedules[i].RetainRule.Count")
lnRetainRuleInterval = loJResp.IntOf("Policy.PolicyDetails.Schedules[i].RetainRule.Interval")
lcRetainRuleIntervalUnit = loJResp.StringOf("Policy.PolicyDetails.Schedules[i].RetainRule.IntervalUnit")
j = 0
lnCount_j = loJResp.SizeOfArray("Policy.PolicyDetails.Schedules[i].CreateRule.Times")
DO WHILE j < lnCount_j
loJResp.J = j
lcStrVal = loJResp.StringOf("Policy.PolicyDetails.Schedules[i].CreateRule.Times[j]")
j = j + 1
ENDDO
j = 0
lnCount_j = loJResp.SizeOfArray("Policy.PolicyDetails.Schedules[i].CrossRegionCopyRules")
DO WHILE j < lnCount_j
loJResp.J = j
lcCmkArn = loJResp.StringOf("Policy.PolicyDetails.Schedules[i].CrossRegionCopyRules[j].CmkArn")
lnCopyTags = loJResp.IntOf("Policy.PolicyDetails.Schedules[i].CrossRegionCopyRules[j].CopyTags")
lnDeprecateRuleInterval = loJResp.IntOf("Policy.PolicyDetails.Schedules[i].CrossRegionCopyRules[j].DeprecateRule.Interval")
lcDeprecateRuleIntervalUnit = loJResp.StringOf("Policy.PolicyDetails.Schedules[i].CrossRegionCopyRules[j].DeprecateRule.IntervalUnit")
lnEncrypted = loJResp.IntOf("Policy.PolicyDetails.Schedules[i].CrossRegionCopyRules[j].Encrypted")
lnRetainRuleInterval = loJResp.IntOf("Policy.PolicyDetails.Schedules[i].CrossRegionCopyRules[j].RetainRule.Interval")
lcRetainRuleIntervalUnit = loJResp.StringOf("Policy.PolicyDetails.Schedules[i].CrossRegionCopyRules[j].RetainRule.IntervalUnit")
lcTarget = loJResp.StringOf("Policy.PolicyDetails.Schedules[i].CrossRegionCopyRules[j].Target")
lcTargetRegion = loJResp.StringOf("Policy.PolicyDetails.Schedules[i].CrossRegionCopyRules[j].TargetRegion")
j = j + 1
ENDDO
j = 0
lnCount_j = loJResp.SizeOfArray("Policy.PolicyDetails.Schedules[i].FastRestoreRule.AvailabilityZones")
DO WHILE j < lnCount_j
loJResp.J = j
lcStrVal = loJResp.StringOf("Policy.PolicyDetails.Schedules[i].FastRestoreRule.AvailabilityZones[j]")
j = j + 1
ENDDO
j = 0
lnCount_j = loJResp.SizeOfArray("Policy.PolicyDetails.Schedules[i].ShareRules")
DO WHILE j < lnCount_j
loJResp.J = j
lnUnshareInterval = loJResp.IntOf("Policy.PolicyDetails.Schedules[i].ShareRules[j].UnshareInterval")
lcUnshareIntervalUnit = loJResp.StringOf("Policy.PolicyDetails.Schedules[i].ShareRules[j].UnshareIntervalUnit")
k = 0
lnCount_k = loJResp.SizeOfArray("Policy.PolicyDetails.Schedules[i].ShareRules[j].TargetAccounts")
DO WHILE k < lnCount_k
loJResp.K = k
lcStrVal = loJResp.StringOf("Policy.PolicyDetails.Schedules[i].ShareRules[j].TargetAccounts[k]")
k = k + 1
ENDDO
j = j + 1
ENDDO
j = 0
lnCount_j = loJResp.SizeOfArray("Policy.PolicyDetails.Schedules[i].TagsToAdd")
DO WHILE j < lnCount_j
loJResp.J = j
lcKey = loJResp.StringOf("Policy.PolicyDetails.Schedules[i].TagsToAdd[j].Key")
lcValue = loJResp.StringOf("Policy.PolicyDetails.Schedules[i].TagsToAdd[j].Value")
j = j + 1
ENDDO
j = 0
lnCount_j = loJResp.SizeOfArray("Policy.PolicyDetails.Schedules[i].VariableTags")
DO WHILE j < lnCount_j
loJResp.J = j
lcKey = loJResp.StringOf("Policy.PolicyDetails.Schedules[i].VariableTags[j].Key")
lcValue = loJResp.StringOf("Policy.PolicyDetails.Schedules[i].VariableTags[j].Value")
j = j + 1
ENDDO
i = i + 1
ENDDO
i = 0
lnCount_i = loJResp.SizeOfArray("Policy.PolicyDetails.TargetTags")
DO WHILE i < lnCount_i
loJResp.I = i
lcKey = loJResp.StringOf("Policy.PolicyDetails.TargetTags[i].Key")
lcValue = loJResp.StringOf("Policy.PolicyDetails.TargetTags[i].Value")
i = i + 1
ENDDO
* 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"
* }
* }
* }
RELEASE loRest
RELEASE loAuthAws
RELEASE loSbResponseBody
RELEASE loJResp