Lifecycle Policy Usage and Examples
A user can enable lifecycle policies at either of the following three levels:
Cluster Setting Level
A user can enable lifecycle policies at the cluster setting level using the command below:
curl -X PUT --header 'Content-Type: application/json' --header 'Accept: text/plain' -d '{}' \
'http://STORAGE-NODE:91/api/storage/clusters/_self/settings/policy.lifecycle?value=enabled' \
-u admin:ourpwdofchoicehere
Domain Level
Info
A missing Policy-Lifecycle
header on the domain is considered a tacit enablement so this step is not strictly necessary.
To enable lifecycle policies at the domain level, use a PUT /_admin/manage/tenants/acme/domains/mydomain?lifecycle=yes
with a copy of all existing headers. For example:
curl -i -XPUT -u admin@:password \
-H 'Policy-Versioning: enabled' ...
'http://GATEWAY/_admin/manage/tenants/mytenant/domains/mydomain?lifecycle=yes'
Important
Re-transmit all
Policy-
headers to appear on the new domain or, e.g., versioning will be disabled. It is advised to use the Content UI for enabling or editing policy rules.
Bucket Level
To enable lifecycle policies at the bucket level, use a COPY mybucket?domain=mydomain&lifecycle=yes
to a Content Gateway with Policy-Lifecycle header defining the rule(s).
curl -i -XCOPY -u admin@:password 'http://GATEWAY/mybucket?domain=mydomain&lifecycle=yes'
It is not necessary to use ?preserve
or provide existing headers for the bucket when the endpoint is a Content Gateway. If the endpoint is a storage node, it is necessary to use ?preserve,
and ?lifecycle=yes
is not used.
A bucket contains one or multiple lifecycle policies, such as:
Expire all versioned content after one year.
Expire all current content after 5 years, etc.
Such policies are applied on a bucket object using one or multiple Policy-Lifecycle
headers:
# RECOMMENDED: use Content Gateway as the endpoint. Note this requires ?lifecycle=yes.
curl -i -X COPY -u admin@:password \
-H 'Policy-Lifecycle: RuleId:"rule5" ExpirationDays:1826 ObsoleteExpirationDays:365' \
'http://GATEWAY/mybucket?domain=mydomain&lifecycle=yes'
# If using a storage node as the endpoint then ?preserve must be used.
curl -X COPY --post301 --location-trusted \
-H 'Policy-Lifecycle: RuleId:"rule5" ExpirationDays:1825 ObsoleteExpirationDays:365' \
'http://STORAGE-NODE/mybucket?domain=mydomain&preserve'
In the previous example, apply implicitly to all content in the bucket by:
Naming the single policy
Not declaring it enabled (default enabled)
Relying on a missing prefix
When using Content Gateway the ?lifecycle=yes
query arg must be used to see the Policy-Lifecycle
header on a bucket and the user must have GetLifecycleConfiguration
permission.
curl --head -u admin@:password \
'http://GATEWAY/mybucket?domain=mydomain&lifecycle=yes'
See Examples of S3 Lifecycle configurations - Amazon Simple Storage Service. Swarm currently supports expiration policies.
Related content
© DataCore Software Corporation. · https://www.datacore.com · All rights reserved.