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
)
template_short = client.fastedge.templates.replace(
template_id=0,
binary_id=12345,
name="api-gateway-template",
owned=True,
params=[{
"data_type": "string",
"mandatory": True,
"name": "api_key",
}],
)
print(template_short.id)package main
import (
"context"
"fmt"
"github.com/G-Core/gcore-go"
"github.com/G-Core/gcore-go/fastedge"
"github.com/G-Core/gcore-go/option"
)
func main() {
client := gcore.NewClient(
option.WithAPIKey("My API Key"),
)
templateShort, err := client.Fastedge.Templates.Replace(
context.TODO(),
0,
fastedge.TemplateReplaceParams{
Template: fastedge.TemplateParam{
BinaryID: 12345,
Name: "api-gateway-template",
Owned: true,
Params: []fastedge.TemplateParameter{{
DataType: fastedge.TemplateParameterDataTypeString,
Mandatory: true,
Name: "api_key",
}},
},
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", templateShort.ID)
}
curl --request PUT \
--url https://api.gcore.com/fastedge/v1/template/{template_id} \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"binary_id": 12345,
"name": "api-gateway-template",
"owned": true,
"params": [
{
"name": "api_key",
"data_type": "string",
"mandatory": true,
"descr": "API key for external service authentication",
"metadata": "<string>"
}
],
"short_descr": "HTTP API gateway with authentication",
"long_descr": "Complete API gateway solution with JWT authentication, rate limiting, and request transformation capabilities."
}
'const options = {
method: 'PUT',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
binary_id: 12345,
name: 'api-gateway-template',
owned: true,
params: [
{
name: 'api_key',
data_type: 'string',
mandatory: true,
descr: 'API key for external service authentication',
metadata: '<string>'
}
],
short_descr: 'HTTP API gateway with authentication',
long_descr: 'Complete API gateway solution with JWT authentication, rate limiting, and request transformation capabilities.'
})
};
fetch('https://api.gcore.com/fastedge/v1/template/{template_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/fastedge/v1/template/{template_id}",
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([
'binary_id' => 12345,
'name' => 'api-gateway-template',
'owned' => true,
'params' => [
[
'name' => 'api_key',
'data_type' => 'string',
'mandatory' => true,
'descr' => 'API key for external service authentication',
'metadata' => '<string>'
]
],
'short_descr' => 'HTTP API gateway with authentication',
'long_descr' => 'Complete API gateway solution with JWT authentication, rate limiting, and request transformation capabilities.'
]),
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.put("https://api.gcore.com/fastedge/v1/template/{template_id}")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"binary_id\": 12345,\n \"name\": \"api-gateway-template\",\n \"owned\": true,\n \"params\": [\n {\n \"name\": \"api_key\",\n \"data_type\": \"string\",\n \"mandatory\": true,\n \"descr\": \"API key for external service authentication\",\n \"metadata\": \"<string>\"\n }\n ],\n \"short_descr\": \"HTTP API gateway with authentication\",\n \"long_descr\": \"Complete API gateway solution with JWT authentication, rate limiting, and request transformation capabilities.\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.gcore.com/fastedge/v1/template/{template_id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"binary_id\": 12345,\n \"name\": \"api-gateway-template\",\n \"owned\": true,\n \"params\": [\n {\n \"name\": \"api_key\",\n \"data_type\": \"string\",\n \"mandatory\": true,\n \"descr\": \"API key for external service authentication\",\n \"metadata\": \"<string>\"\n }\n ],\n \"short_descr\": \"HTTP API gateway with authentication\",\n \"long_descr\": \"Complete API gateway solution with JWT authentication, rate limiting, and request transformation capabilities.\"\n}"
response = http.request(request)
puts response.read_body{
"id": 123,
"name": "<string>",
"api_type": "<string>",
"owned": true,
"short_descr": "<string>",
"long_descr": "<string>"
}{
"error": "<string>"
}{
"error": "<string>"
}Templates
Update template
Modify an existing template’s configuration. Updates affect future applications created from this template; existing apps are not changed.
PUT
/
fastedge
/
v1
/
template
/
{template_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
)
template_short = client.fastedge.templates.replace(
template_id=0,
binary_id=12345,
name="api-gateway-template",
owned=True,
params=[{
"data_type": "string",
"mandatory": True,
"name": "api_key",
}],
)
print(template_short.id)package main
import (
"context"
"fmt"
"github.com/G-Core/gcore-go"
"github.com/G-Core/gcore-go/fastedge"
"github.com/G-Core/gcore-go/option"
)
func main() {
client := gcore.NewClient(
option.WithAPIKey("My API Key"),
)
templateShort, err := client.Fastedge.Templates.Replace(
context.TODO(),
0,
fastedge.TemplateReplaceParams{
Template: fastedge.TemplateParam{
BinaryID: 12345,
Name: "api-gateway-template",
Owned: true,
Params: []fastedge.TemplateParameter{{
DataType: fastedge.TemplateParameterDataTypeString,
Mandatory: true,
Name: "api_key",
}},
},
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", templateShort.ID)
}
curl --request PUT \
--url https://api.gcore.com/fastedge/v1/template/{template_id} \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"binary_id": 12345,
"name": "api-gateway-template",
"owned": true,
"params": [
{
"name": "api_key",
"data_type": "string",
"mandatory": true,
"descr": "API key for external service authentication",
"metadata": "<string>"
}
],
"short_descr": "HTTP API gateway with authentication",
"long_descr": "Complete API gateway solution with JWT authentication, rate limiting, and request transformation capabilities."
}
'const options = {
method: 'PUT',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
binary_id: 12345,
name: 'api-gateway-template',
owned: true,
params: [
{
name: 'api_key',
data_type: 'string',
mandatory: true,
descr: 'API key for external service authentication',
metadata: '<string>'
}
],
short_descr: 'HTTP API gateway with authentication',
long_descr: 'Complete API gateway solution with JWT authentication, rate limiting, and request transformation capabilities.'
})
};
fetch('https://api.gcore.com/fastedge/v1/template/{template_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/fastedge/v1/template/{template_id}",
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([
'binary_id' => 12345,
'name' => 'api-gateway-template',
'owned' => true,
'params' => [
[
'name' => 'api_key',
'data_type' => 'string',
'mandatory' => true,
'descr' => 'API key for external service authentication',
'metadata' => '<string>'
]
],
'short_descr' => 'HTTP API gateway with authentication',
'long_descr' => 'Complete API gateway solution with JWT authentication, rate limiting, and request transformation capabilities.'
]),
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.put("https://api.gcore.com/fastedge/v1/template/{template_id}")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"binary_id\": 12345,\n \"name\": \"api-gateway-template\",\n \"owned\": true,\n \"params\": [\n {\n \"name\": \"api_key\",\n \"data_type\": \"string\",\n \"mandatory\": true,\n \"descr\": \"API key for external service authentication\",\n \"metadata\": \"<string>\"\n }\n ],\n \"short_descr\": \"HTTP API gateway with authentication\",\n \"long_descr\": \"Complete API gateway solution with JWT authentication, rate limiting, and request transformation capabilities.\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.gcore.com/fastedge/v1/template/{template_id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"binary_id\": 12345,\n \"name\": \"api-gateway-template\",\n \"owned\": true,\n \"params\": [\n {\n \"name\": \"api_key\",\n \"data_type\": \"string\",\n \"mandatory\": true,\n \"descr\": \"API key for external service authentication\",\n \"metadata\": \"<string>\"\n }\n ],\n \"short_descr\": \"HTTP API gateway with authentication\",\n \"long_descr\": \"Complete API gateway solution with JWT authentication, rate limiting, and request transformation capabilities.\"\n}"
response = http.request(request)
puts response.read_body{
"id": 123,
"name": "<string>",
"api_type": "<string>",
"owned": true,
"short_descr": "<string>",
"long_descr": "<string>"
}{
"error": "<string>"
}{
"error": "<string>"
}Authorizations
Body
application/json
Complete template configuration (replaces existing)
Response
Template updated successfully, returns updated metadata
Was this page helpful?