At the cluster setting level, a user must enable lifecycle policies. As it is enabled in the cluster, so use the management APIA 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:
Code Block | ||
---|---|---|
| ||
curl -X PUT --header 'Content-Type: application/json' --header 'Accept: text/plain' -d '{}' \ 'http://lucky1.tx.caringo.comSTORAGE-NODE:91/api/storage/clusters/_self/settings/policy.lifecycle?value=enabled' \ -u admin:ourpwdofchoicehere |
Domain Level
Info |
---|
InfoA missing |
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:
Code Block |
---|
curl -i -XPUT -u admin@:password \
-H 'Policy-Versioning: enabled' ...
'http://GATEWAY/_admin/manage/tenants/mytenant/domains/mydomain?lifecycle=yes' |
Info |
---|
Important
|
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).
Code Block |
---|
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 may have 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:
Code Block | ||
---|---|---|
| ||
curl –X COPY –-post301 –-location-trusted –H# 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://lucky1.tx.caringo.comSTORAGE-NODE/mybucket?domain=mydomain&preserve' |
In the previous example, apply implicitly applying to all content in the bucket by;:
Naming the single policy
Not declaring it enabled (as it is by default enabled)
Relying on a missing prefix
The preserve query argument on the COPY operations indicates leaving other persisted headers as it is.
SeeS3 lifecycle policy examples. Note that Swarm currently only 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.
Code Block |
---|
curl --head -u admin@:password \
'http://GATEWAY/mybucket?domain=mydomain&lifecycle=yes' |
Seehttps://docs.aws.amazon.com/AmazonS3/latest/userguide/lifecycle-configuration-examples.html. Swarm currently supports expiration policies.
...