Policies
There are two types of Cloudlets policies. The policy type determines which version of the Cloudlets API you use.
- Non-shared policies use Cloudlets API v2.
- Shared policies use Cloudlets API v3.
Get policies and rules
To get a list of your Cloudlet policies, policy versions, or a policy version's rules use the designated command and parameter for your policy type.
List policies
For both policy types, the API returns paginated results that you can manage with a parameter.
Non-shared
Command
List-CloudletPolicies
Parameters
-PageSize
- Returns a specific number of pages. Value is an integer between 1 and 999.
-All
- Switch that returns all policies. Pagination is automatic. May make several calls to get a complete list.
-IncludeRules
- Switch that will also return rules with each version.
Command | Parameters |
---|---|
Non-Shared | |
List-CloudletPolicies |
|
Shared | |
List-SharedCloudletPolicies |
|
Examples
# Get policies
$Policies = List-CloudletPolicies -PageSize 999
$Policies = List-CloudletPolicies -All
# Get policies
$Policies = List-SharedCloudletPolicies -Size 10000
$Policies = List-SharedCloudletPolicies -All
List versions
Once you have a list of policies, use a policy ID to get a list of its versions.
Examples
# Get version
$Versions = List-CloudletPolicyVersions -PolicyID 123456
$Versions = List-SharedCloudletPolicyVersions -PolicyID 123456
Get rules
Use a policy's ID and a specific version to get its rule set.
Write to JSON file
Alternatively, you can pipe the result so it's converted to JSON and written to a .json
file. It's recommended to set the depth of your request from 7 to 99.
Examples
# Get rules
$Rules = Get-CloudletPolicyVersion -PolicyID 123456 -Version 10
$Rules = Get-CloudletPolicyVersion -PolicyID 123456 -Version latest
# Pipe results to convert your rules to JSON at a particular depth (7-99)
Get-CloudletPolicyVersion -PolicyID 123456 -Version latest | ConvertTo-Json -Depth 10 | Out-File example.json
# Get rules
$Rules = Get-SharedCloudletPolicyVersion -PolicyID 123456 -Version 10
$Rules = Get-SharedCloudletPolicyVersion -PolicyID 123456 -Version latest
# Pipe results to convert your rules to JSON at a particular depth (7-99)
Get-SharedCloudletPolicyVersion -PolicyID 123456 -Version latest | ConvertTo-Json -Depth 10 | Out-File example.json
Filter results
Use standard script block or comparison statement format to narrow your results based on search terms.
API version response parameters can vary your search request syntax. Where parameters are the same across both versions, use the same query syntax.
- v2 uses the
policyId
andcloudletCode
properties for ID and type.- v3 uses
id
andcloudletCode
properties for ID and type.
Examples
# Filters results based on the name property
$Policies | Where-Object {$_.name -eq "MyPolicy"}
$Policies | Where name -eq MyPolicy
Update policy
To update your policies, get your rules and make your changes, and then create and activate your new policy.
1. Update rules
After getting your rules, update them directly in the shell or in a JSON file that you later import.
The
akaRuleId
fields and rule type are uneditable.
Examples
# Set the percentage for a Phased Release or Application Load Balancer rule
$Policy.matchRules[0].forwardSettings.percent = 100
# Set the percentage for a Visitor Prioritization rule
$Policy.matchRules[1].passThroughPercent = 80
# Set a Request Control rule to deny
$Policy.matchRules[4].allowDeny = 'deny'
# Set the redirect rule for an Edge Redirector policy
$Policy.matchRules[3].redirectURL = '/specialoffer'
$Policy = Get-Content example.json | ConvertFrom-Json
2. Create New Version
To apply your changes to your policy, create a new version. You can include the rules either as a piped object or inline.
Non-shared
Commands
New-CloudletPolicyVersion
Parameters
PolicyID {value}
- The unique ID for a policy.
-Version {value}
- Identifies a specific version. Value is an integer or
latest
. -Description {value}
- Adds a description to your new version. Value is a string.
-MatchRules $Policy
- Identifies your match rules through the
$Policy
variable.
Non-shared
Commands
New-SharedCloudletPolicyVersion
Parameters
PolicyID {value}
- The unique ID for a policy.
-Version {value}
- Identifies a specific version. Value is an integer or
latest
. -Description {value}
- Adds a description to your new version. Value is a string.
-MatchRules $Policy
- Identifies your match rules through the
$Policy
variable.
Examples
# Create new version
$Policy | New-CloudletPolicyVersion -PolicyID 123456
New-CloudletPolicyVersion -PolicyID 123456 -Policy $Policy
# Create new version with description and matchRules separately
New-CloudletPolicyVersion -PolicyID 123456 -Description "My new changes" -MatchRules $Policy.matchRules
# Create new version
$Policy | New-SharedCloudletPolicyVersion -PolicyID 123456
New-SharedCloudletPolicyVersion -PolicyID 123456 -Policy $Policy
# Create new version with description and matchRules separately
New-SharedCloudletPolicyVersion -PolicyID 123456 -Description "My new changes" -MatchRules $Policy.matchRules
3. Activate a Version
To update environment with an updated version, use the designated command and parameter for your policy type.
Non-shared
Commands
Activate-CloudletPolicyVersion
Parameters
PolicyID {value}
- The unique ID for a policy. For
-Version {value}
- Identifies a specific version. Value is an integer or
latest
. -Network {value}
- Identifies the network on which your policy is activated. Value is
production
orstaging
. -AdditionalPropertynames {value}
- Identifies additional property names to which your policy should be associated.
Examples
# Activate a policy
Activate-CloudletPolicyVersion -PolicyID 123456 -Version latest -Network staging
# Associating a new property
Activate-CloudletPolicyVersion -PolicyID 123456 -Version latest -Network production -AdditionalPropertynames myproperty
Activate-SharedCloudletPolicy -PolicyID 12345 -Version latest -Network STAGING
Updated 9 months ago