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"
}
}Establecer la configuración del ciclo de vida del bucket
Lea primero la configuración actual y luego proporcione su revisión citada en If-Match. Un cambio simultáneo devuelve LIFECYCLE_CONFLICT (412); recargue y revise antes de volver a intentarlo. La API compatible con S3 mantiene el reemplazo incondicional del 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 permisos de almacenamiento para obtener la lista completa, lo que cubre cada una y un ejemplo de política.Autorizaciones
Un token bearer de OAuth 2.0, enviado como Authorization: Bearer <token>. Esta es la forma recomendada de autenticación.
Obtén el token intercambiando el par de claves de acceso de una cuenta de servicio en POST /v1/oauth/token con grant_type=client_credentials. Es el flujo estándar de credenciales de cliente; las bibliotecas compatibles con OAuth pueden obtener y renovar el token por ti.
curl -s -u "$KEY_ID:$SECRET" -d grant_type=client_credentials \
https://iam.basaltic.sh/v1/oauth/token
Los tokens duran una hora por defecto. El mismo par de claves de acceso también sirve como credencial AWS SigV4 para el endpoint de objetos compatible con S3, que solo acepta ese método de autenticación.
Encabezados
Revisión exacta citada de GET. No se aceptan comodines ni etiquetas de entidad débiles.
"\"none\""
Parámetros de ruta
"my-app-assets"
Cuerpo
Show child attributes
Show child attributes
Respuesta
Configuración del ciclo de vida almacenada.

