import os
from gcore import Gcore
client = Gcore(
api_key=os.environ.get("GCORE_API_KEY"), # This is the default and can be omitted
)
page = client.cdn.cdn_resources.list()
page = page.results[0]
print(page.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"),
)
page, err := client.CDN.CDNResources.List(context.TODO(), cdn.CDNResourceListParams{})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", page)
}
curl --request GET \
--url https://api.gcore.com/cdn/resources \
--header 'Authorization: <api-key>'const options = {method: 'GET', headers: {Authorization: '<api-key>'}};
fetch('https://api.gcore.com/cdn/resources', 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/resources",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}HttpResponse<String> response = Unirest.get("https://api.gcore.com/cdn/resources")
.header("Authorization", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.gcore.com/cdn/resources")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = '<api-key>'
response = http.request(request)
puts response.read_body[
{
"id": 220,
"cname": "cdn.example.com",
"active": true,
"enabled": true,
"status": "active",
"deleted": false,
"client": 170,
"name": "My resource",
"description": "Resource for images",
"created": "2017-06-10T10:30:04.954354Z",
"updated": "2017-06-10T10:35:04.954354Z",
"originGroup": 80,
"originGroup_name": "Resource origin group",
"originProtocol": "HTTP",
"secondaryHostnames": [
"images.example.com",
"video.example.com"
],
"shielded": false,
"shield_dc": null,
"shield_enabled": false,
"shield_routing_map": null,
"sslEnabled": true,
"sslData": 100,
"proxy_ssl_enabled": false,
"proxy_ssl_ca": null,
"proxy_ssl_data": null,
"preset_applied": false,
"vp_enabled": false,
"full_custom_enabled": false,
"can_purge_by_urls": true,
"suspend_date": null,
"suspended": false,
"primary_resource": null,
"is_primary": null,
"waap_domain_id": null,
"rules": [],
"options": {}
},
{
"id": 222,
"deleted": true,
"client": 170,
"status": "deleted",
"updated": "2021-06-07T12:23:44.978506Z",
"cname": "www.example.com"
}
]Get CDN resources list
Get information about all CDN resources in your account.
import os
from gcore import Gcore
client = Gcore(
api_key=os.environ.get("GCORE_API_KEY"), # This is the default and can be omitted
)
page = client.cdn.cdn_resources.list()
page = page.results[0]
print(page.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"),
)
page, err := client.CDN.CDNResources.List(context.TODO(), cdn.CDNResourceListParams{})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", page)
}
curl --request GET \
--url https://api.gcore.com/cdn/resources \
--header 'Authorization: <api-key>'const options = {method: 'GET', headers: {Authorization: '<api-key>'}};
fetch('https://api.gcore.com/cdn/resources', 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/resources",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}HttpResponse<String> response = Unirest.get("https://api.gcore.com/cdn/resources")
.header("Authorization", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.gcore.com/cdn/resources")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = '<api-key>'
response = http.request(request)
puts response.read_body[
{
"id": 220,
"cname": "cdn.example.com",
"active": true,
"enabled": true,
"status": "active",
"deleted": false,
"client": 170,
"name": "My resource",
"description": "Resource for images",
"created": "2017-06-10T10:30:04.954354Z",
"updated": "2017-06-10T10:35:04.954354Z",
"originGroup": 80,
"originGroup_name": "Resource origin group",
"originProtocol": "HTTP",
"secondaryHostnames": [
"images.example.com",
"video.example.com"
],
"shielded": false,
"shield_dc": null,
"shield_enabled": false,
"shield_routing_map": null,
"sslEnabled": true,
"sslData": 100,
"proxy_ssl_enabled": false,
"proxy_ssl_ca": null,
"proxy_ssl_data": null,
"preset_applied": false,
"vp_enabled": false,
"full_custom_enabled": false,
"can_purge_by_urls": true,
"suspend_date": null,
"suspended": false,
"primary_resource": null,
"is_primary": null,
"waap_domain_id": null,
"rules": [],
"options": {}
},
{
"id": 222,
"deleted": true,
"client": 170,
"status": "deleted",
"updated": "2021-06-07T12:23:44.978506Z",
"cname": "www.example.com"
}
]Authorizations
Query Parameters
Defines whether a CDN resource is currently suspended. This reflects the
resource's suspended state, unlike the suspend parameter, which selects
resources that have a scheduled automatic suspension date.
Possible values:
- true - CDN resource is currently suspended.
- false - CDN resource is not suspended.
Filters CDN resources by their primary/alternate relationship. Standalone
resources — those not linked to another resource, which is the default —
match neither value and are returned by neither true nor false.
Possible values:
- true - CDN resource is a primary resource for one or more alternate resources.
- false - CDN resource is an alternate resource linked to a primary resource.
Response
Successful.
- Plain list · object[]
- Paginated list · object
Delivery domains that will be used for content delivery through a CDN.
Delivery domains should be added to your DNS settings.
A delivery domain can also be a hostname on a domain the service provides for your account,
such as my-site.example.net. You do not add such a hostname to your DNS settings. It is a single label
in front of the provided domain, and the label:
- is 5 to 63 characters long;
- uses only letters, digits and hyphens, without a leading or trailing hyphen;
- does not start with
xn--.
Some labels are reserved or not allowed and cannot be used.
"cdn.example.com"
CDN resource status.
Possible values:
- active - CDN resource is active. Content is available to users.
- suspended - CDN resource is suspended. Content is not available to users.
- processed - CDN resource has recently been created and is currently being processed. It will take about fifteen minutes to propagate it to all locations.
- deleted - CDN resource is deleted.
active, suspended, processed, deleted "active"
Protocol used by CDN servers to request content from an origin source.
Possible values:
- HTTPS - CDN servers will connect to the origin via HTTPS.
- HTTP - CDN servers will connect to the origin via HTTP.
- MATCH - connection protocol will be chosen automatically (content on the origin source should be available for the CDN both through HTTP and HTTPS).
If protocol is not specified, HTTP is used to connect to an origin server.
If an enabled origin in the resource's origin group is bound to a Gcore Object Storage (s3_type is gcore), the CDN connects to every origin in that group over HTTPS regardless of this setting.
HTTP, HTTPS, MATCH "HTTPS"
Additional delivery domains (CNAMEs) that will be used to deliver content via the CDN.
Up to ten additional CNAMEs are possible.
A resource on a domain the service provides cannot have additional delivery domains. Use aliases instead.
["images.example.com", "video.example.com"]
ID of the SSL certificate linked to the CDN resource.
Can be used only with "sslEnabled": true.
In responses, the value is null when HTTPS uses the certificate of a domain the service provides. That
certificate cannot be replaced or removed: for such a resource, omit the field or send null.
192
Defines whether the CDN resource is integrated with the Streaming Platform.
Possible values:
- true - CDN resource is configured for Streaming Platform. Changing resource settings can affect its operation.
- false - CDN resource is not configured for Streaming Platform.
false
Defines whether the CDN resource has a custom configuration.
Possible values:
- true - CDN resource has a custom configuration. You cannot change resource settings, except for the SSL certificate. To change other settings, contact technical support.
- false - CDN resource has a regular configuration. You can change CDN resource settings.
false
Defines whether the CDN resource has been automatically suspended because there was no traffic on it for 90 days.
Possible values:
- true - CDN resource is currently automatically suspended.
- false - CDN resource is not automatically suspended.
You can enable CDN resource using the active field. If there is no traffic on the CDN resource within seven days following activation, it will be suspended again.
To avoid CDN resource suspension due to no traffic, contact technical support.
false
ID of the main CDN resource which has a shared caching zone with a reserve CDN resource.
If the parameter is not empty, then the current CDN resource is the reserve. You cannot change some options, create rules, set up origin shielding, or use the reserve CDN resource for Streaming.
null
Defines whether a CDN resource has a cache zone shared with other CDN resources.
Possible values:
- true - CDN resource is main and has a shared caching zone with other CDN resources, which are called reserve.
- false - CDN resource is reserve and it has a shared caching zone with the main CDN resource. You cannot change some options, create rules, set up origin shielding and use the reserve resource for Streaming.
- null - CDN resource does not have a shared cache zone.
The main CDN resource is specified in the primary_resource field. It cannot be suspended unless all related reserve CDN resources are suspended.
null
Was this page helpful?