GetLifecyclePolicy DataFlex Example
Use ChilkatAx-9.5.0-win32.pkg
Procedure Test
Handle hoRest
Boolean iSuccess
Variant vAuthAws
Handle hoAuthAws
Variant vSbResponseBody
Handle hoSbResponseBody
Integer iRespStatusCode
Handle hoJResp
String sName
Integer j
Integer iCount_j
String sCmkArn
Integer iEncrypted
Integer iInterval
String sIntervalUnit
String sTarget
String sStrVal
Integer iCopyTags
String sCronExpression
Integer iCreateRuleInterval
String sCreateRuleIntervalUnit
String sLocation
Integer iCount
Integer iDeprecateRuleInterval
String sDeprecateRuleIntervalUnit
Integer iFastRestoreRuleCount
Integer iFastRestoreRuleInterval
String sFastRestoreRuleIntervalUnit
Integer iRetainRuleCount
Integer iRetainRuleInterval
String sRetainRuleIntervalUnit
String sTargetRegion
Integer iUnshareInterval
String sUnshareIntervalUnit
Integer k
Integer iCount_k
String sKey
String sValue
Integer iDateCreated
Integer iDateModified
String sDescription
String sExecutionRoleArn
String sPolicyArn
String sDescriptionRegex
String sEventType
String sV_Type
Integer iExcludeBootVolume
Integer iNoReboot
String sPolicyType
String sPolicyId
String sState
String sStatusMessage
String sV_String
Integer i
Integer iCount_i
String sTemp1
Integer iTemp1
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
Get Create (RefClass(cComChilkatRest)) To hoRest
If (Not(IsComObjectCreated(hoRest))) Begin
Send CreateComObject of hoRest
End
Get Create (RefClass(cComChilkatAuthAws)) To hoAuthAws
If (Not(IsComObjectCreated(hoAuthAws))) Begin
Send CreateComObject of hoAuthAws
End
Set ComAccessKey Of hoAuthAws To "AWS_ACCESS_KEY"
Set ComSecretKey Of hoAuthAws To "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.)
Set ComRegion Of hoAuthAws To "us-west-2"
Set ComServiceName Of hoAuthAws To "dlm"
// SetAuthAws causes Chilkat to automatically add the following headers: Authorization, X-Amz-Date
Get pvComObject of hoAuthAws to vAuthAws
Get ComSetAuthAws Of hoRest vAuthAws To iSuccess
// URL: https://dlm.us-west-2.amazonaws.com/
// Use the same region as specified above.
Get ComConnect Of hoRest "dlm.us-west-2.amazonaws.com" 443 True True To iSuccess
If (iSuccess <> True) Begin
Get ComConnectFailReason Of hoRest To iTemp1
Showln "ConnectFailReason: " iTemp1
Get ComLastErrorText Of hoRest To sTemp1
Showln sTemp1
Procedure_Return
End
Get ComAddHeader Of hoRest "Content-Type" "application/x-amz-json-1.1" To iSuccess
Get ComAddHeader Of hoRest "X-Amz-Target" "GetLifecyclePolicy" To iSuccess
Get Create (RefClass(cComChilkatStringBuilder)) To hoSbResponseBody
If (Not(IsComObjectCreated(hoSbResponseBody))) Begin
Send CreateComObject of hoSbResponseBody
End
Get pvComObject of hoSbResponseBody to vSbResponseBody
Get ComFullRequestNoBodySb Of hoRest "GET" "/policies/{policyId}/" vSbResponseBody To iSuccess
If (iSuccess <> True) Begin
Get ComLastErrorText Of hoRest To sTemp1
Showln sTemp1
Procedure_Return
End
Get ComResponseStatusCode Of hoRest To iRespStatusCode
Showln "response status code = " iRespStatusCode
If (iRespStatusCode <> 200) Begin
Showln "Response Header:"
Get ComResponseHeader Of hoRest To sTemp1
Showln sTemp1
Showln "Response Body:"
Get ComGetAsString Of hoSbResponseBody To sTemp1
Showln sTemp1
Procedure_Return
End
Get Create (RefClass(cComChilkatJsonObject)) To hoJResp
If (Not(IsComObjectCreated(hoJResp))) Begin
Send CreateComObject of hoJResp
End
Get pvComObject of hoSbResponseBody to vSbResponseBody
Get ComLoadSb Of hoJResp vSbResponseBody To iSuccess
// 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
Get ComIntOf Of hoJResp "Policy.DateCreated" To iDateCreated
Get ComIntOf Of hoJResp "Policy.DateModified" To iDateModified
Get ComStringOf Of hoJResp "Policy.Description" To sDescription
Get ComStringOf Of hoJResp "Policy.ExecutionRoleArn" To sExecutionRoleArn
Get ComStringOf Of hoJResp "Policy.PolicyArn" To sPolicyArn
Get ComStringOf Of hoJResp "Policy.PolicyDetails.EventSource.Parameters.DescriptionRegex" To sDescriptionRegex
Get ComStringOf Of hoJResp "Policy.PolicyDetails.EventSource.Parameters.EventType" To sEventType
Get ComStringOf Of hoJResp "Policy.PolicyDetails.EventSource.Type" To sV_Type
Get ComIntOf Of hoJResp "Policy.PolicyDetails.Parameters.ExcludeBootVolume" To iExcludeBootVolume
Get ComIntOf Of hoJResp "Policy.PolicyDetails.Parameters.NoReboot" To iNoReboot
Get ComStringOf Of hoJResp "Policy.PolicyDetails.PolicyType" To sPolicyType
Get ComStringOf Of hoJResp "Policy.PolicyId" To sPolicyId
Get ComStringOf Of hoJResp "Policy.State" To sState
Get ComStringOf Of hoJResp "Policy.StatusMessage" To sStatusMessage
Get ComStringOf Of hoJResp "Policy.Tags.string" To sV_String
Move 0 To i
Get ComSizeOfArray Of hoJResp "Policy.PolicyDetails.Actions" To iCount_i
While (i < iCount_i)
Set ComI Of hoJResp To i
Get ComStringOf Of hoJResp "Policy.PolicyDetails.Actions[i].Name" To sName
Move 0 To j
Get ComSizeOfArray Of hoJResp "Policy.PolicyDetails.Actions[i].CrossRegionCopy" To iCount_j
While (j < iCount_j)
Set ComJ Of hoJResp To j
Get ComStringOf Of hoJResp "Policy.PolicyDetails.Actions[i].CrossRegionCopy[j].EncryptionConfiguration.CmkArn" To sCmkArn
Get ComIntOf Of hoJResp "Policy.PolicyDetails.Actions[i].CrossRegionCopy[j].EncryptionConfiguration.Encrypted" To iEncrypted
Get ComIntOf Of hoJResp "Policy.PolicyDetails.Actions[i].CrossRegionCopy[j].RetainRule.Interval" To iInterval
Get ComStringOf Of hoJResp "Policy.PolicyDetails.Actions[i].CrossRegionCopy[j].RetainRule.IntervalUnit" To sIntervalUnit
Get ComStringOf Of hoJResp "Policy.PolicyDetails.Actions[i].CrossRegionCopy[j].Target" To sTarget
Move (j + 1) To j
Loop
Move (i + 1) To i
Loop
Move 0 To i
Get ComSizeOfArray Of hoJResp "Policy.PolicyDetails.EventSource.Parameters.SnapshotOwner" To iCount_i
While (i < iCount_i)
Set ComI Of hoJResp To i
Get ComStringOf Of hoJResp "Policy.PolicyDetails.EventSource.Parameters.SnapshotOwner[i]" To sStrVal
Move (i + 1) To i
Loop
Move 0 To i
Get ComSizeOfArray Of hoJResp "Policy.PolicyDetails.ResourceLocations" To iCount_i
While (i < iCount_i)
Set ComI Of hoJResp To i
Get ComStringOf Of hoJResp "Policy.PolicyDetails.ResourceLocations[i]" To sStrVal
Move (i + 1) To i
Loop
Move 0 To i
Get ComSizeOfArray Of hoJResp "Policy.PolicyDetails.ResourceTypes" To iCount_i
While (i < iCount_i)
Set ComI Of hoJResp To i
Get ComStringOf Of hoJResp "Policy.PolicyDetails.ResourceTypes[i]" To sStrVal
Move (i + 1) To i
Loop
Move 0 To i
Get ComSizeOfArray Of hoJResp "Policy.PolicyDetails.Schedules" To iCount_i
While (i < iCount_i)
Set ComI Of hoJResp To i
Get ComIntOf Of hoJResp "Policy.PolicyDetails.Schedules[i].CopyTags" To iCopyTags
Get ComStringOf Of hoJResp "Policy.PolicyDetails.Schedules[i].CreateRule.CronExpression" To sCronExpression
Get ComIntOf Of hoJResp "Policy.PolicyDetails.Schedules[i].CreateRule.Interval" To iCreateRuleInterval
Get ComStringOf Of hoJResp "Policy.PolicyDetails.Schedules[i].CreateRule.IntervalUnit" To sCreateRuleIntervalUnit
Get ComStringOf Of hoJResp "Policy.PolicyDetails.Schedules[i].CreateRule.Location" To sLocation
Get ComIntOf Of hoJResp "Policy.PolicyDetails.Schedules[i].DeprecateRule.Count" To iCount
Get ComIntOf Of hoJResp "Policy.PolicyDetails.Schedules[i].DeprecateRule.Interval" To iDeprecateRuleInterval
Get ComStringOf Of hoJResp "Policy.PolicyDetails.Schedules[i].DeprecateRule.IntervalUnit" To sDeprecateRuleIntervalUnit
Get ComIntOf Of hoJResp "Policy.PolicyDetails.Schedules[i].FastRestoreRule.Count" To iFastRestoreRuleCount
Get ComIntOf Of hoJResp "Policy.PolicyDetails.Schedules[i].FastRestoreRule.Interval" To iFastRestoreRuleInterval
Get ComStringOf Of hoJResp "Policy.PolicyDetails.Schedules[i].FastRestoreRule.IntervalUnit" To sFastRestoreRuleIntervalUnit
Get ComStringOf Of hoJResp "Policy.PolicyDetails.Schedules[i].Name" To sName
Get ComIntOf Of hoJResp "Policy.PolicyDetails.Schedules[i].RetainRule.Count" To iRetainRuleCount
Get ComIntOf Of hoJResp "Policy.PolicyDetails.Schedules[i].RetainRule.Interval" To iRetainRuleInterval
Get ComStringOf Of hoJResp "Policy.PolicyDetails.Schedules[i].RetainRule.IntervalUnit" To sRetainRuleIntervalUnit
Move 0 To j
Get ComSizeOfArray Of hoJResp "Policy.PolicyDetails.Schedules[i].CreateRule.Times" To iCount_j
While (j < iCount_j)
Set ComJ Of hoJResp To j
Get ComStringOf Of hoJResp "Policy.PolicyDetails.Schedules[i].CreateRule.Times[j]" To sStrVal
Move (j + 1) To j
Loop
Move 0 To j
Get ComSizeOfArray Of hoJResp "Policy.PolicyDetails.Schedules[i].CrossRegionCopyRules" To iCount_j
While (j < iCount_j)
Set ComJ Of hoJResp To j
Get ComStringOf Of hoJResp "Policy.PolicyDetails.Schedules[i].CrossRegionCopyRules[j].CmkArn" To sCmkArn
Get ComIntOf Of hoJResp "Policy.PolicyDetails.Schedules[i].CrossRegionCopyRules[j].CopyTags" To iCopyTags
Get ComIntOf Of hoJResp "Policy.PolicyDetails.Schedules[i].CrossRegionCopyRules[j].DeprecateRule.Interval" To iDeprecateRuleInterval
Get ComStringOf Of hoJResp "Policy.PolicyDetails.Schedules[i].CrossRegionCopyRules[j].DeprecateRule.IntervalUnit" To sDeprecateRuleIntervalUnit
Get ComIntOf Of hoJResp "Policy.PolicyDetails.Schedules[i].CrossRegionCopyRules[j].Encrypted" To iEncrypted
Get ComIntOf Of hoJResp "Policy.PolicyDetails.Schedules[i].CrossRegionCopyRules[j].RetainRule.Interval" To iRetainRuleInterval
Get ComStringOf Of hoJResp "Policy.PolicyDetails.Schedules[i].CrossRegionCopyRules[j].RetainRule.IntervalUnit" To sRetainRuleIntervalUnit
Get ComStringOf Of hoJResp "Policy.PolicyDetails.Schedules[i].CrossRegionCopyRules[j].Target" To sTarget
Get ComStringOf Of hoJResp "Policy.PolicyDetails.Schedules[i].CrossRegionCopyRules[j].TargetRegion" To sTargetRegion
Move (j + 1) To j
Loop
Move 0 To j
Get ComSizeOfArray Of hoJResp "Policy.PolicyDetails.Schedules[i].FastRestoreRule.AvailabilityZones" To iCount_j
While (j < iCount_j)
Set ComJ Of hoJResp To j
Get ComStringOf Of hoJResp "Policy.PolicyDetails.Schedules[i].FastRestoreRule.AvailabilityZones[j]" To sStrVal
Move (j + 1) To j
Loop
Move 0 To j
Get ComSizeOfArray Of hoJResp "Policy.PolicyDetails.Schedules[i].ShareRules" To iCount_j
While (j < iCount_j)
Set ComJ Of hoJResp To j
Get ComIntOf Of hoJResp "Policy.PolicyDetails.Schedules[i].ShareRules[j].UnshareInterval" To iUnshareInterval
Get ComStringOf Of hoJResp "Policy.PolicyDetails.Schedules[i].ShareRules[j].UnshareIntervalUnit" To sUnshareIntervalUnit
Move 0 To k
Get ComSizeOfArray Of hoJResp "Policy.PolicyDetails.Schedules[i].ShareRules[j].TargetAccounts" To iCount_k
While (k < iCount_k)
Set ComK Of hoJResp To k
Get ComStringOf Of hoJResp "Policy.PolicyDetails.Schedules[i].ShareRules[j].TargetAccounts[k]" To sStrVal
Move (k + 1) To k
Loop
Move (j + 1) To j
Loop
Move 0 To j
Get ComSizeOfArray Of hoJResp "Policy.PolicyDetails.Schedules[i].TagsToAdd" To iCount_j
While (j < iCount_j)
Set ComJ Of hoJResp To j
Get ComStringOf Of hoJResp "Policy.PolicyDetails.Schedules[i].TagsToAdd[j].Key" To sKey
Get ComStringOf Of hoJResp "Policy.PolicyDetails.Schedules[i].TagsToAdd[j].Value" To sValue
Move (j + 1) To j
Loop
Move 0 To j
Get ComSizeOfArray Of hoJResp "Policy.PolicyDetails.Schedules[i].VariableTags" To iCount_j
While (j < iCount_j)
Set ComJ Of hoJResp To j
Get ComStringOf Of hoJResp "Policy.PolicyDetails.Schedules[i].VariableTags[j].Key" To sKey
Get ComStringOf Of hoJResp "Policy.PolicyDetails.Schedules[i].VariableTags[j].Value" To sValue
Move (j + 1) To j
Loop
Move (i + 1) To i
Loop
Move 0 To i
Get ComSizeOfArray Of hoJResp "Policy.PolicyDetails.TargetTags" To iCount_i
While (i < iCount_i)
Set ComI Of hoJResp To i
Get ComStringOf Of hoJResp "Policy.PolicyDetails.TargetTags[i].Key" To sKey
Get ComStringOf Of hoJResp "Policy.PolicyDetails.TargetTags[i].Value" To sValue
Move (i + 1) To i
Loop
// 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"
// }
// }
// }
End_Procedure