curl --request PUT \
--url https://storage.{region}.basaltic.sh/v1/buckets/{bucket}/lifecycle \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'If-Match: <if-match>' \
--data '
{
"lifecycle": {
"rules": [
{
"status": "enabled",
"id": "expire-old-logs",
"filter": {
"prefix": "logs/"
},
"expiration": {
"days": 30,
"date": "2023-11-07T05:31:56Z"
},
"noncurrent_version_expiration": {
"noncurrent_days": 7,
"newer_noncurrent_versions": 3
},
"abort_incomplete_multipart_upload": {
"days_after_initiation": 7
}
}
]
}
}
'import requests
url = "https://storage.{region}.basaltic.sh/v1/buckets/{bucket}/lifecycle"
payload = { "lifecycle": { "rules": [
{
"status": "enabled",
"id": "expire-old-logs",
"filter": { "prefix": "logs/" },
"expiration": {
"days": 30,
"date": "2023-11-07T05:31:56Z"
},
"noncurrent_version_expiration": {
"noncurrent_days": 7,
"newer_noncurrent_versions": 3
},
"abort_incomplete_multipart_upload": { "days_after_initiation": 7 }
}
] } }
headers = {
"If-Match": "<if-match>",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {
'If-Match': '<if-match>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
lifecycle: {
rules: [
{
status: 'enabled',
id: 'expire-old-logs',
filter: {prefix: 'logs/'},
expiration: {days: 30, date: '2023-11-07T05:31:56Z'},
noncurrent_version_expiration: {noncurrent_days: 7, newer_noncurrent_versions: 3},
abort_incomplete_multipart_upload: {days_after_initiation: 7}
}
]
}
})
};
fetch('https://storage.{region}.basaltic.sh/v1/buckets/{bucket}/lifecycle', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://storage.{region}.basaltic.sh/v1/buckets/{bucket}/lifecycle",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'lifecycle' => [
'rules' => [
[
'status' => 'enabled',
'id' => 'expire-old-logs',
'filter' => [
'prefix' => 'logs/'
],
'expiration' => [
'days' => 30,
'date' => '2023-11-07T05:31:56Z'
],
'noncurrent_version_expiration' => [
'noncurrent_days' => 7,
'newer_noncurrent_versions' => 3
],
'abort_incomplete_multipart_upload' => [
'days_after_initiation' => 7
]
]
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json",
"If-Match: <if-match>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://storage.{region}.basaltic.sh/v1/buckets/{bucket}/lifecycle"
payload := strings.NewReader("{\n \"lifecycle\": {\n \"rules\": [\n {\n \"status\": \"enabled\",\n \"id\": \"expire-old-logs\",\n \"filter\": {\n \"prefix\": \"logs/\"\n },\n \"expiration\": {\n \"days\": 30,\n \"date\": \"2023-11-07T05:31:56Z\"\n },\n \"noncurrent_version_expiration\": {\n \"noncurrent_days\": 7,\n \"newer_noncurrent_versions\": 3\n },\n \"abort_incomplete_multipart_upload\": {\n \"days_after_initiation\": 7\n }\n }\n ]\n }\n}")
req, _ := http.NewRequest("PUT", url, payload)
req.Header.Add("If-Match", "<if-match>")
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.put("https://storage.{region}.basaltic.sh/v1/buckets/{bucket}/lifecycle")
.header("If-Match", "<if-match>")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"lifecycle\": {\n \"rules\": [\n {\n \"status\": \"enabled\",\n \"id\": \"expire-old-logs\",\n \"filter\": {\n \"prefix\": \"logs/\"\n },\n \"expiration\": {\n \"days\": 30,\n \"date\": \"2023-11-07T05:31:56Z\"\n },\n \"noncurrent_version_expiration\": {\n \"noncurrent_days\": 7,\n \"newer_noncurrent_versions\": 3\n },\n \"abort_incomplete_multipart_upload\": {\n \"days_after_initiation\": 7\n }\n }\n ]\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://storage.{region}.basaltic.sh/v1/buckets/{bucket}/lifecycle")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["If-Match"] = '<if-match>'
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"lifecycle\": {\n \"rules\": [\n {\n \"status\": \"enabled\",\n \"id\": \"expire-old-logs\",\n \"filter\": {\n \"prefix\": \"logs/\"\n },\n \"expiration\": {\n \"days\": 30,\n \"date\": \"2023-11-07T05:31:56Z\"\n },\n \"noncurrent_version_expiration\": {\n \"noncurrent_days\": 7,\n \"newer_noncurrent_versions\": 3\n },\n \"abort_incomplete_multipart_upload\": {\n \"days_after_initiation\": 7\n }\n }\n ]\n }\n}"
response = http.request(request)
puts response.read_body{
"error": {
"code": "UNAUTHORIZED",
"message": "Authentication required",
"request_id": "550e8400-e29b-41d4-a716-446655440000"
}
}{
"error": {
"code": "ACCESS_DENIED",
"message": "You don't have permission to perform this action",
"request_id": "550e8400-e29b-41d4-a716-446655440000"
}
}Definir configuração de ciclo de vida do bucket
Leia a configuração atual primeiro e, em seguida, forneça sua revisão citada em If-Match. Uma alteração simultânea retorna LIFECYCLE_CONFLICT (412); recarregar e revisar antes de tentar novamente. A API compatível com S3 mantém a substituição incondicional do ciclo de vida.
curl --request PUT \
--url https://storage.{region}.basaltic.sh/v1/buckets/{bucket}/lifecycle \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'If-Match: <if-match>' \
--data '
{
"lifecycle": {
"rules": [
{
"status": "enabled",
"id": "expire-old-logs",
"filter": {
"prefix": "logs/"
},
"expiration": {
"days": 30,
"date": "2023-11-07T05:31:56Z"
},
"noncurrent_version_expiration": {
"noncurrent_days": 7,
"newer_noncurrent_versions": 3
},
"abort_incomplete_multipart_upload": {
"days_after_initiation": 7
}
}
]
}
}
'import requests
url = "https://storage.{region}.basaltic.sh/v1/buckets/{bucket}/lifecycle"
payload = { "lifecycle": { "rules": [
{
"status": "enabled",
"id": "expire-old-logs",
"filter": { "prefix": "logs/" },
"expiration": {
"days": 30,
"date": "2023-11-07T05:31:56Z"
},
"noncurrent_version_expiration": {
"noncurrent_days": 7,
"newer_noncurrent_versions": 3
},
"abort_incomplete_multipart_upload": { "days_after_initiation": 7 }
}
] } }
headers = {
"If-Match": "<if-match>",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {
'If-Match': '<if-match>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
lifecycle: {
rules: [
{
status: 'enabled',
id: 'expire-old-logs',
filter: {prefix: 'logs/'},
expiration: {days: 30, date: '2023-11-07T05:31:56Z'},
noncurrent_version_expiration: {noncurrent_days: 7, newer_noncurrent_versions: 3},
abort_incomplete_multipart_upload: {days_after_initiation: 7}
}
]
}
})
};
fetch('https://storage.{region}.basaltic.sh/v1/buckets/{bucket}/lifecycle', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://storage.{region}.basaltic.sh/v1/buckets/{bucket}/lifecycle",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'lifecycle' => [
'rules' => [
[
'status' => 'enabled',
'id' => 'expire-old-logs',
'filter' => [
'prefix' => 'logs/'
],
'expiration' => [
'days' => 30,
'date' => '2023-11-07T05:31:56Z'
],
'noncurrent_version_expiration' => [
'noncurrent_days' => 7,
'newer_noncurrent_versions' => 3
],
'abort_incomplete_multipart_upload' => [
'days_after_initiation' => 7
]
]
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json",
"If-Match: <if-match>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://storage.{region}.basaltic.sh/v1/buckets/{bucket}/lifecycle"
payload := strings.NewReader("{\n \"lifecycle\": {\n \"rules\": [\n {\n \"status\": \"enabled\",\n \"id\": \"expire-old-logs\",\n \"filter\": {\n \"prefix\": \"logs/\"\n },\n \"expiration\": {\n \"days\": 30,\n \"date\": \"2023-11-07T05:31:56Z\"\n },\n \"noncurrent_version_expiration\": {\n \"noncurrent_days\": 7,\n \"newer_noncurrent_versions\": 3\n },\n \"abort_incomplete_multipart_upload\": {\n \"days_after_initiation\": 7\n }\n }\n ]\n }\n}")
req, _ := http.NewRequest("PUT", url, payload)
req.Header.Add("If-Match", "<if-match>")
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.put("https://storage.{region}.basaltic.sh/v1/buckets/{bucket}/lifecycle")
.header("If-Match", "<if-match>")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"lifecycle\": {\n \"rules\": [\n {\n \"status\": \"enabled\",\n \"id\": \"expire-old-logs\",\n \"filter\": {\n \"prefix\": \"logs/\"\n },\n \"expiration\": {\n \"days\": 30,\n \"date\": \"2023-11-07T05:31:56Z\"\n },\n \"noncurrent_version_expiration\": {\n \"noncurrent_days\": 7,\n \"newer_noncurrent_versions\": 3\n },\n \"abort_incomplete_multipart_upload\": {\n \"days_after_initiation\": 7\n }\n }\n ]\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://storage.{region}.basaltic.sh/v1/buckets/{bucket}/lifecycle")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["If-Match"] = '<if-match>'
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"lifecycle\": {\n \"rules\": [\n {\n \"status\": \"enabled\",\n \"id\": \"expire-old-logs\",\n \"filter\": {\n \"prefix\": \"logs/\"\n },\n \"expiration\": {\n \"days\": 30,\n \"date\": \"2023-11-07T05:31:56Z\"\n },\n \"noncurrent_version_expiration\": {\n \"noncurrent_days\": 7,\n \"newer_noncurrent_versions\": 3\n },\n \"abort_incomplete_multipart_upload\": {\n \"days_after_initiation\": 7\n }\n }\n ]\n }\n}"
response = http.request(request)
puts response.read_body{
"error": {
"code": "UNAUTHORIZED",
"message": "Authentication required",
"request_id": "550e8400-e29b-41d4-a716-446655440000"
}
}{
"error": {
"code": "ACCESS_DENIED",
"message": "You don't have permission to perform this action",
"request_id": "550e8400-e29b-41d4-a716-446655440000"
}
}storage:PutLifecycleConfiguration. Consulte permissões de armazenamento para obter a lista completa, o que cada uma abrange e um exemplo de política.Autorizações
Um token bearer OAuth 2.0, enviado como Authorization: Bearer <token>. Esta é a forma recomendada de autenticação.
Obtenha o token trocando o par de chaves de acesso de uma conta de serviço em POST /v1/oauth/token com grant_type=client_credentials. Esse é o fluxo padrão de credenciais de cliente; bibliotecas compatíveis com OAuth podem obter e renovar o token para você.
curl -s -u "$KEY_ID:$SECRET" -d grant_type=client_credentials \
https://iam.basaltic.sh/v1/oauth/token
Os tokens duram uma hora por padrão. O mesmo par de chaves de acesso também serve como credencial AWS SigV4 para o endpoint de objetos compatível com S3, que aceita somente esse método de autenticação.
Cabeçalhos
Revisão exata citada de GET. Não são aceites curingas e tags de entidade fracas.
"\"none\""
Parâmetros de caminho
"my-app-assets"
Corpo
Show child attributes
Show child attributes
Resposta
Configuração do ciclo de vida armazenada.

