Python
import os
from gcore import Gcore
client = Gcore(
api_key=os.environ.get("GCORE_API_KEY"), # This is the default and can be omitted
)
lifecycle_policy = client.cloud.lifecycle_policies.update(
policy_id=1,
project_id=1,
region_id=1,
)
print(lifecycle_policy.id)package main
import (
"context"
"fmt"
"github.com/G-Core/gcore-go"
"github.com/G-Core/gcore-go/cloud"
"github.com/G-Core/gcore-go/option"
)
func main() {
client := gcore.NewClient(
option.WithAPIKey("My API Key"),
)
lifecyclePolicy, err := client.Cloud.LifecyclePolicies.Update(
context.TODO(),
1,
cloud.LifecyclePolicyUpdateParams{
ProjectID: gcore.Int(1),
RegionID: gcore.Int(1),
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", lifecyclePolicy.ID)
}
curl --request PATCH \
--url https://api.gcore.com/cloud/v1/lifecycle_policy/{project_id}/{region_id}/{policy_id} \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "schedule_1",
"status": "paused"
}
'const options = {
method: 'PATCH',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({name: 'schedule_1', status: 'paused'})
};
fetch('https://api.gcore.com/cloud/v1/lifecycle_policy/{project_id}/{region_id}/{policy_id}', 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://api.gcore.com/cloud/v1/lifecycle_policy/{project_id}/{region_id}/{policy_id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'name' => 'schedule_1',
'status' => 'paused'
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}HttpResponse<String> response = Unirest.patch("https://api.gcore.com/cloud/v1/lifecycle_policy/{project_id}/{region_id}/{policy_id}")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"schedule_1\",\n \"status\": \"paused\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.gcore.com/cloud/v1/lifecycle_policy/{project_id}/{region_id}/{policy_id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"schedule_1\",\n \"status\": \"paused\"\n}"
response = http.request(request)
puts response.read_body{
"action": "volume_snapshot",
"id": 1,
"name": "schedule_1",
"project_id": 1,
"region_id": 1,
"schedules": [
{
"day_of_week": "*",
"hour": "0, 10, 20",
"id": "1488e2ce-f906-47fb-ba32-c25a3f63df4f",
"max_quantity": 2,
"minute": "30",
"owner": "lifecycle_policy",
"owner_id": 1,
"resource_name_template": "reserve snap of the volume {volume_id}",
"type": "cron",
"user_id": 12
}
],
"status": "active",
"user_id": 11,
"volumes": [
{
"volume_id": "3ed9e2ce-f906-47fb-ba32-c25a3f63df4f",
"volume_name": "test schedule"
}
]
}Snapshot Schedules
Update snapshot policy
Update the configuration of an existing snapshot policy.
PATCH
/
cloud
/
v1
/
lifecycle_policy
/
{project_id}
/
{region_id}
/
{policy_id}
Python
import os
from gcore import Gcore
client = Gcore(
api_key=os.environ.get("GCORE_API_KEY"), # This is the default and can be omitted
)
lifecycle_policy = client.cloud.lifecycle_policies.update(
policy_id=1,
project_id=1,
region_id=1,
)
print(lifecycle_policy.id)package main
import (
"context"
"fmt"
"github.com/G-Core/gcore-go"
"github.com/G-Core/gcore-go/cloud"
"github.com/G-Core/gcore-go/option"
)
func main() {
client := gcore.NewClient(
option.WithAPIKey("My API Key"),
)
lifecyclePolicy, err := client.Cloud.LifecyclePolicies.Update(
context.TODO(),
1,
cloud.LifecyclePolicyUpdateParams{
ProjectID: gcore.Int(1),
RegionID: gcore.Int(1),
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", lifecyclePolicy.ID)
}
curl --request PATCH \
--url https://api.gcore.com/cloud/v1/lifecycle_policy/{project_id}/{region_id}/{policy_id} \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "schedule_1",
"status": "paused"
}
'const options = {
method: 'PATCH',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({name: 'schedule_1', status: 'paused'})
};
fetch('https://api.gcore.com/cloud/v1/lifecycle_policy/{project_id}/{region_id}/{policy_id}', 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://api.gcore.com/cloud/v1/lifecycle_policy/{project_id}/{region_id}/{policy_id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'name' => 'schedule_1',
'status' => 'paused'
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}HttpResponse<String> response = Unirest.patch("https://api.gcore.com/cloud/v1/lifecycle_policy/{project_id}/{region_id}/{policy_id}")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"schedule_1\",\n \"status\": \"paused\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.gcore.com/cloud/v1/lifecycle_policy/{project_id}/{region_id}/{policy_id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"schedule_1\",\n \"status\": \"paused\"\n}"
response = http.request(request)
puts response.read_body{
"action": "volume_snapshot",
"id": 1,
"name": "schedule_1",
"project_id": 1,
"region_id": 1,
"schedules": [
{
"day_of_week": "*",
"hour": "0, 10, 20",
"id": "1488e2ce-f906-47fb-ba32-c25a3f63df4f",
"max_quantity": 2,
"minute": "30",
"owner": "lifecycle_policy",
"owner_id": 1,
"resource_name_template": "reserve snap of the volume {volume_id}",
"type": "cron",
"user_id": 12
}
],
"status": "active",
"user_id": 11,
"volumes": [
{
"volume_id": "3ed9e2ce-f906-47fb-ba32-c25a3f63df4f",
"volume_name": "test schedule"
}
]
}Authorizations
API key for authentication. Make sure to include the word apikey, followed by a single space and then your token.
Example: apikey 1234_abcdef
Path Parameters
Project ID
Example:
1
Region ID
Example:
1
Lifecycle policy ID.
Example:
1
Body
application/json
Response
200 - application/json
OK
Action associated with the lifecycle policy.
Example:
"volume_snapshot"
Unique identifier for the policy.
Example:
1
Name of the policy.
Example:
"schedule_1"
Project ID associated with the policy.
Example:
1
Region ID where the policy is applied.
Example:
1
List of schedules within the policy.
- GetCronScheduleSerializer
- GetIntervalScheduleSerializer
Show child attributes
Show child attributes
Example:
[ { "day_of_week": "*", "hour": "0, 10, 20", "id": "1488e2ce-f906-47fb-ba32-c25a3f63df4f", "max_quantity": 2, "minute": "30", "owner": "lifecycle_policy", "owner_id": 1, "resource_name_template": "reserve snap of the volume {volume_id}", "type": "cron", "user_id": 12 } ]
Status of the lifecycle policy.
Available options:
active, paused Example:
"active"
User ID of the creator of the policy.
Example:
11
Data of volumes that should be reserved. Displayed only when the query parameter is specified.
Show child attributes
Show child attributes
Example:
[ { "volume_id": "3ed9e2ce-f906-47fb-ba32-c25a3f63df4f", "volume_name": "test schedule" } ]
Was this page helpful?