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
)
applied_preset_created = client.cdn.presets.applied.apply(
preset_id=0,
object_id=7531,
)
print(applied_preset_created.object_id)package main
import (
"context"
"fmt"
"github.com/G-Core/gcore-go"
"github.com/G-Core/gcore-go/cdn"
"github.com/G-Core/gcore-go/option"
)
func main() {
client := gcore.NewClient(
option.WithAPIKey("My API Key"),
)
appliedPresetCreated, err := client.CDN.Presets.Applied.Apply(
context.TODO(),
0,
cdn.PresetAppliedApplyParams{
ObjectID: 7531,
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", appliedPresetCreated.ObjectID)
}
curl --request POST \
--url https://api.gcore.com/cdn/presets/{preset_id}/applied \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"object_id": 7531
}
'const options = {
method: 'POST',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({object_id: 7531})
};
fetch('https://api.gcore.com/cdn/presets/{preset_id}/applied', 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/cdn/presets/{preset_id}/applied",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'object_id' => 7531
]),
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.post("https://api.gcore.com/cdn/presets/{preset_id}/applied")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"object_id\": 7531\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.gcore.com/cdn/presets/{preset_id}/applied")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"object_id\": 7531\n}"
response = http.request(request)
puts response.read_body{
"preset_id": 42,
"object_id": 7531,
"message": "Preset successfully applied"
}Presets
Apply preset
Apply the preset to an object (CDN resource or rule, according to the preset object_type).
The preset settings are applied to the object, and the options included in the preset can no longer be edited on the object until the preset is unapplied.
POST
/
cdn
/
presets
/
{preset_id}
/
applied
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
)
applied_preset_created = client.cdn.presets.applied.apply(
preset_id=0,
object_id=7531,
)
print(applied_preset_created.object_id)package main
import (
"context"
"fmt"
"github.com/G-Core/gcore-go"
"github.com/G-Core/gcore-go/cdn"
"github.com/G-Core/gcore-go/option"
)
func main() {
client := gcore.NewClient(
option.WithAPIKey("My API Key"),
)
appliedPresetCreated, err := client.CDN.Presets.Applied.Apply(
context.TODO(),
0,
cdn.PresetAppliedApplyParams{
ObjectID: 7531,
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", appliedPresetCreated.ObjectID)
}
curl --request POST \
--url https://api.gcore.com/cdn/presets/{preset_id}/applied \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"object_id": 7531
}
'const options = {
method: 'POST',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({object_id: 7531})
};
fetch('https://api.gcore.com/cdn/presets/{preset_id}/applied', 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/cdn/presets/{preset_id}/applied",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'object_id' => 7531
]),
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.post("https://api.gcore.com/cdn/presets/{preset_id}/applied")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"object_id\": 7531\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.gcore.com/cdn/presets/{preset_id}/applied")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"object_id\": 7531\n}"
response = http.request(request)
puts response.read_body{
"preset_id": 42,
"object_id": 7531,
"message": "Preset successfully applied"
}Authorizations
Body
application/json
Response
Successful.
Was this page helpful?