Selectel Storage API (old)
This is an older version of the Selectel Storage API that was used before object storage updates 29.09.2023. URLs and methods from the old version of the Selectel Storage API continue to be supported for now, but will be disabled in the future. We recommend using new version of Selectel Storage API.
Object Storage provides developers with an opportunity to integrate with their own applications and websites. Interaction with the storage is organized on the basis of REST API. The documentation describes the currently available Storage REST API calls, request and response formats. Currently, the following operations can be performed using REST API requests:
- create links for third-party users to upload files to the repository;
- work with file versions;
- create users and set access settings to the storage for them;
- to download and unzip archives;
- work with special pages, etc.
Methods of authorization and obtaining a token to work with API are described in the section Authorization and token receipt Swift API instructions (old).
Restrictions for additional users
Additional users have limitations when using the API, so the following actions must be performed on behalf of the primary Object Store user:
- container creation;
- deleting multiple files (using
?bulk-delete=true
); - creating or modifying users;
- work with domains and user SSL certificates;
- CDN cache reset;
- log retrieval;
- creation of temporary tokens (
/temptokens
).
Creating an image gallery
Request parameters
Request type | URI | Headings | Description |
---|---|---|---|
PUT | https://api.selcdn.ru/v1/SEL\_\*\*\*\*\*\*\*/container. | X-Auth-Token --- authorization token; X-Container-Meta-Type: gallery --- container type (in our case --- gallery) | Activates the demonstration of images in the gallery view |
Example request
curl -i -XPUT https://api.selcdn.ru/v1/SEL_*****/container -H "X-Auth-Token: $token" -H "X-Container-Metatype: gallery"
If the request is successful, the API returns a response with code 204.
Example answer
HTTP/1.1 202 Accepted
Content-Length: 76
Content-Type: text/html; charset=UTF-8
Access-Control-Allow-Origin: *
Access-Control-Expose-Headers:
Downloading the container as a zip archive
The contents of any container can be downloaded as a zip archive. To do this, the query-parameter download-all-as-zip=[archive name] should be added to the link to the container, for example:
wget https://api.selcdn.ru/v1/SEL_*****/container_name/?download-all-as-zip=container_name.zip
In public containers the zip download functionality is disabled by default, to enable it you need to set the header X-Container-Meta-Allow-ZipDownload: true, example:
curl -i -XPUT https://api.selcdn.ru/v1/SEL_***/container_name -H "X-Auth-Token: $token" -H "X-Container-Meta-Allow-ZipDownload: true"
The value of this X-Container-Meta-Allow-ZipDownload header in private containers is ignored.
The following commands can be used to download the contents of any public container as a zip archive:
curl -i -XGET https://api.selcdn.ru/v1/SEL_*****/container?download-all-as-zip=test.zip -o name.zip
The following commands can be used to download the contents of any private container as a zip archive:
curl -i -XGET https://api.selcdn.ru/v1/SEL_*****/container?download-all-as-zip=test.zip -H "X-Auth-Token: $token" -o name.zip
To view the contents of the downloaded archive, use the command:
unzip -l name.zip
Archive: name.zip
warning [name.zip]: 274 extra bytes at beginning or within zipfile (attempting to process anyway)
Length Date Time Name
--------- ---------- ----- ----
555436 1980-00-00 00:00 IMG_20180802_121146.jpg
39 1980-00-00 00:00 copied_file
245473 1980-00-00 00:00 mergetree.pdf
--------- -------
800948 3 files
The operation described is primarily intended to simplify downloading, not to save traffic, so the files in the archive are not compressed.
The number of objects in one container must not exceed 10,000, otherwise the command will fail and return an error.
You can download objects that start with one specified prefix (for example, IMG) as a zip archive by specifying this IMG prefix in the IMG?download-all-as-zip parameter:
curl -i -XGET https://*****.selcdn.ru/container/?IMG?download-all-as-zip=test.zip -H "X-Auth-Token: $token" -o name.zip
Note: if among the objects there is a folder starting with the same prefix, it will be downloaded together with all its contents.
Downloading the folder as a zip archive
The contents of any folder can be downloaded as a zip archive. To do this, add the query-parameter download-all-as-zip=[archive name] to the link to the folder, for example:
wget https://api.selcdn.ru/v1/SEL_*****/container_name/folder/?download-all-as-zip=container_name.zip
The following commands can be used to download the contents of any folder as a zip archive:
curl -i -XGET https://*****.selcdn.ru/container/folder?download-all-as-zip=test.zip -H "X-Auth-Token: $token" -o name.zip
To view the contents of the downloaded archive, use the command:
unzip -l name.zip
Archive: name.zip
warning [name.zip]: 274 extra bytes at beginning or within zipfile (attempting to process anyway)
Length Date Time Name
--------- ---------- ----- ----
555436 1980-00-00 00:00 IMG_20180802_121146.jpg
39 1980-00-00 00:00 copied_file
245473 1980-00-00 00:00 mergetree.pdf
--------- -------
800948 3 files
The operation described is primarily intended to simplify downloading, not to save traffic, so the files in the archive are not compressed.
The number of objects in one folder must not exceed 10,000, otherwise the command will fail and return an error.
Unpacking archives
Archives in *.tar, *.tar.gz and *.gzip format can be unpacked immediately after being uploaded to the repository. To unpack an archive, the extract-archive query-parameter must be added to the file download request:
curl -i -XPUT https://api.selcdn.ru/v1/SEL_*****/new_container/archive.tar.gz/?extract-archive=tar.gz \
-H "X-Auth-Token: $token" -T "archive.tar.gz"
Creating a symbolic link to a file
When using storage as a backend for public services, it is often necessary to differentiate access to files --- for example, to make files placed in a private container available to a wide range of users.
Especially for such cases, the repository provides the ability to create symbolic links. Such links can be password-protected and their validity period can be set.
Request type | URI | Headings | Description |
---|---|---|---|
PUT | https://api.selcdn.ru/v1/SEL\_\*\*\*\*\*\*\*\*/container/file/ specifies the container in which the symbolic link will be stored and the name under which the link will be stored. | X-Auth-Token --- authorization token; Content-Type --- symbolic link type (x-storage/onetime-symlink --- one-time link, x-storage/symlink+secure --- regular password-protected link, x-storage/onetime-symlink+secure --- one-time password-protected link); X-Object-Meta-Location --- quoted path to the object in storage; X-Object-Meta-Delete-At --- the date (in Unix Timestamp format) until which the link will be valid; X-Object-Meta-Link-Key --- sha1 hash of the object's password and location (for password-protected links; details in Example of generating X-Object-Meta-Link-Key in Python); Content-Disposition --- specifies what to do with the linked file: open in a browser (inline) or download to a local machine (attachment) | Creates a symbolic link with the parameters specified in the request. |
Example request
curl -i -XPUT https://api.selcdn.ru/v1/SEL_*****/new_container/new_link \
-H "X-Auth-Token: $token" -H "Content-Type: x-storage/symlink" \
-H "X-Object-Meta-Location: /new_container/new_object" \
-H "X-Object-Meta-Link-Key: $key" -H "Content-Length: 0"
Example answer
HTTP/1.1 201 Created
> etag: d41d8cd98f00b204e9800998ecf8427e
> Last-Modified: Mon, 27 May 2013 13:34:34 GM
Example of X-Object-Meta-Link-Key generation in Python
import hashlib
# location of file, always with container specified
location = "/container/object"
# password
password = "12345"
# concatenate password + location and encode it
encoded_pass_loc = (password + location).encode('utf-8')
# generate sha1-hash
hash_object = hashlib.sha1(encoded_pass_loc)
# convert sha1-hash to hexadecimal digits
link_key = hash_object.hexdigest()
# show calculated value
print(link_key)
Creating a link to download a file
You can create special links that third-party users can use to download your files (including those from personal containers). You do not need to make an API request to create such a link. Before generating links to account files, you need to set the secret key $key:
curl -i -XPOST http://*****.selcdn.ru/ -H "X-Auth-Token: $token" -H "X-Account-Meta-Temp-URL-Key: $key"
To create a link to a specific container, set the secret key $key, adding the container name:
curl -i -XPOST http://*****.selcdn.ru/сontainer -H "X-Auth-Token: $token" -H "X-Container-Meta-Temp-URL-Key: $key"
Only users who know the secret key will be able to access the files using the generated link.
Python example
import hmac
from hashlib import sha1
from time import time
# access method (always GET)
method = "GET"
# reference valid 60 seconds
expires = int(time()) + 60
# the path to the file in the repository, always with the container specified
path = "/container/dir/file"
# secret key
link_secret_key = str.encode("$key")
# generate access key
hmac_body = str.encode('%s\n%s\n%s' % (method, expires, path))
# access key
sig = hmac.new(link_secret_key, hmac_body, sha1).hexdigest()
#show calculated values
print(sig,expires)
When using a reference of the form https://api.selcdn.ru/v1/SEL_***/container_name/object_name
in the above script, the variable path should look like /v1/SEL_***/container_name/object_name
.
The resulting key will then need to be specified in the link:
http://****.selcdn.ru/container/dir/file?temp_url_sig=3f512dfed32111d6e742afc5522076c0621951cc&temp_url_expires=13909142
Where:
*****.selcdn.ru
--- base domain;temp_url_sig
--- access key;temp_url_expires
--- the time until which the link is valid (unixtime).
If the container has a domain attached to it, you can specify it in the link. The name of the container does not need to be specified:
http://my.domain/dir/file?temp_url_sig=3f512dfed32111d6e742afc5522076c0621951cc&temp_url_expires=1390914227
Content-Disposition header control is supported for the data given by the link. To do this, add the filename parameter with the appropriate value:
http://*****.selcdn.ru/container/dir/file?temp_url_sig=3f512dfed32111d6e742afc5522076c0621951cc&temp_url_expires=1390914227&filename=Other+file+name.doc
The secret key can be changed. After changing the secret key, all previously generated links will stop working.
Node.js example
const crypto = require('crypto');
// access method (always GET)
const method = 'GET';
// reference valid 60 seconds
const expires = Math.floor(Date.now() / 1000) + 60;
// the path to the file in the repository, always with the container specified
const path = '/container/dir/file';
// secret key
const linkSecretKey = '$key';
// generate access key
const hmacBody = `${method}\n${expires}\n${path}`;
// access key
const sig = crypto.createHmac('sha1', linkSecretKey).update(hmacBody).digest('hex');
// show calculated values
console.log(sig);
console.log(expires);
Creating a link for downloading files (sendmefile)
Request type | URI | Headings | Description |
---|---|---|---|
PUT | https://api.selcdn.ru/v1/SEL\_\*\*\*\*\*\*\*\*/container/upload. | X-Auth-Token --- authorization token; Content-Type --- link properties (x-storage/sendmefile+inplace --- download only one file with the specified name; x-storage/sendmefile+timepostfix --- download files with the download time added to the name; x-storage/sendmefile+autopostfix --- uploading files by adding a unique identifier to the name with the extension; x-storage/sendmefile+folderday --- uploading files to a folder with a name like yyyy-dd-mm, x-storage/sendmefile+folderhour --- uploading files to a folder with a name like dd-mm hh:min min, x-storage/sendmefile+folderuniq --- upload each file to a separate folder); X-Object-Meta-Sendmefile-Disable-Web --- enables (no)/disables (yes) the web interface for uploading files; this header defaults to yes (web interface enabled); X-Object-Meta-Sendmefile-Max-Size --- maximum size of the file to be uploaded (in bytes); X-Delete-After --- deletes the link after a specified time (in seconds); X-Object-Meta-Sendmefile-Allow-Overwrite --- allows (yes) or disallows (no) overwriting files when they are re-downloaded (overwriting is disallowed by default); X-Object-Meta-Sendmefile-Ignore-Filename --- allow (yes) automatic renaming of files according to the specified settings; X-Object-Meta-Sendmefile-Secret --- password hash (for password-protected links); -Sendmefile-Session-Id --- upload session identifier | Creates a link that allows third-party users to upload files to the repository. Example link: https://\*\*\*\*\*\*\*\*\*.selcdn.ru/container/upload \*\*\*\*\*\*\*\* --- the base domain of the container as numbers, specified in the control panel, in the Container Settings card ⟶ Link for uploading files; container --- the name of the container; upload --- the name of the link for uploading the file. |
Example request
curl -i -XPUT https://api.selcdn.ru/v1/SEL_*****/container/upload \
-H "X-Auth-Token: $token" -H "Content-Type: x-storage/sendmefile+inplace" \
-H "X-Object-Meta-Sendmefile-Max-Size: 52428800" \
-H "X-Delete-After: 14400" \
-H "X-Object-Meta-Sendmefile-Secret: 5baa61e4c9b93f3f0682250b6cf8331b7ee68" \
-d "Пояснительный текст для страницы загрузки"
Versioning
To store not only the latest version of an object, but also several previous versions, the repository provides version support.
Before you start working with versioning, create a container to store the versions.
When an object is deleted, the last working version is not returned in its place. All versions of the object, including the one before deletion, are stored in the version container.
Request parameters
Request type | URI | Headings | Description |
---|---|---|---|
PUT | https://api.selcdn.ru/v1/SEL\_\*\*\*\*\*\*\*/container. | X-Auth-Token --- authorization token; X-Versions-Location --- name of the container where the versions will be stored. The header will not work unless a container for versions is created | Activates versioning for the specified container. Versions of all objects will be saved in the container whose name is passed in the header |
Example request
curl -i -XPUT https://api.selcdn.ru/v1/SEL_*****/container1/ -H "X-Auth-Token: $token" -H "X-Versions-Location: container2"
If the request is successful, a response with code 202 will be returned.
Example answer
HTTP/1.1 202 Accepted Content-Length: 76
Content-Type: text/html; charset=UTF-8
Access-Control-Allow-Origin: * Access-Control-Expose-Headers: Expires: 0 Pragma: no-cache
Cache-Control: no-cache, no-store, must-revalidate
Specialty pages include:
- The index page given in response to an anonymous GET request for a container or folder placed in that container;
- error page (404) --- file given by an anonymous GET request to a non-existent object.
Index page
Request parameters
Request type | URI | Headings | Description |
---|---|---|---|
POST | https://api.selcdn.ru/v1/SEL\_\*\*\*\*\*\*\*/container. | X-Auth-Token --- authorization token; X-Container-Meta-Web-Index --- path to the file to be used as the index file | Assigns an index file for the specified container |
Both absolute and relative file paths can be specified in the request.
Web-Index | Inquiry | File given |
---|---|---|
/index.html | GET /container/; GET /container/dir1/ | /container/index.html |
index.html | GET /container/ | /container/index.html |
index.html | GET /container/dir1/dir2/ | /container/dir1/dir2/index.html or (if the file does not exist) /container/index.html |
Example request
Create an index file:
echo "<html>custom_index_file</html>" > my_index.html
curl -i -XPUT "https://api.selcdn.ru/v1/SEL_*****/container_name/my_index.html" -H "X-Auth-Token: $token" -T "./my_index.html"
To specify an index page, set the Web-Index value for the container:
curl -i -XPUT "https://api.selcdn.ru/v1/SEL_*****/container_name/my_index.html" \
-H "X-Auth-Token: $token" -H "X-Container-Meta-Web-Index:/my_index.html"
Page 404
Request parameters
Request type | URI | Headings | Description |
---|---|---|---|
POST | https://api.selcdn.ru/v1/SEL\_\*\*\*\*\*\*\*/container. | X-Auth-Token --- authorization token; X-Container-Meta-Web-404-Page --- path to the error file | Configures the error file for the specified container |
Examples
Web-404-Page | Inquiry | Redirection address |
---|---|---|
/404.html | GET /container/nofile; GET /container/dir1/nofile | /container/404.html |
404.html. | /container/nofile | /container/404.html |
404.html. | GET /container/nofile | /container/dir1/dir2/404.html or (if the file does not exist) /container/404.html |
http://test.test | GET /container/nofile; /container/dir1/nofile | http://test.test |
Available template parameters
You can use special template parameters to pass information about the originally requested file:
- {container} --- container name;
- {path} --- the path to the requested file relative to the container.
By default, the forwarding is performed with code 307. Available options: 200, 307, 404. When setting an external link, only code 307 is available.
Example request
Set the Web-404-Page value for the container:
curl -i -XPOST "https://api.selcdn.ru/v1/SEL_*****/container_name" -H "X-Auth-Token: $token" \
-H "X-Container-Meta-Web-404-Page: /404.html?file={path}"
An anonymous request for a non-existent object redirects to the specified file:
curl -i "https://api.selcdn.ru/v1/SEL_*****/container_name/non_existing_object" \
> HTTP/1.1 307 Temporary Redirect
> Location: https://api.selcdn.ru/v1/SEL_*****/404.html?file=non_existing_object
By default, a 404 code is returned when submitting an error page:
curl -i -XPOST "https://api.selcdn.ru/v1/SEL_*****/container_name" -H "X-Auth-Token: $token" \
-H "X-Container-Meta-Web-404-Page: /404.html?file={path}?{code}"
File listing
Request parameters
Request type | URI | Headings | Description |
---|---|---|---|
POST | https://api.selcdn.ru/v1/SEL\_\*\*\*\*\*\*\*/container. | X-Auth-Token --- authorization token; X-Container-Meta-Web-Listings --- on/off --- enable or disable listing mode for container; X-Container-Meta-Web-Listings-CSS --- reference to style file, used for HTML-formatted outputs (optional); X-Container-Meta-Web-Listings-Sort --- listing sort type, possible values: name\_asc, name\_desc, date\_asc, date\_desc, size\_asc, size\_desc; can be sorted by name, modification date, and size. Asc and desc define the sort order | Enables file listing mode for the container specified in the request |
Example request
curl -i -XPOST "https://api.selcdn.ru/v1/SEL_*****/container_name" -H "X-Auth-Token: $token" \
-H "X-Container-Meta-Web-Listings: on"
To retrieve the file listing by anonymous query, type:
curl -i -XGET "https://api.selcdn.ru/v1/SEL_*****/container_name" -H "X-Web-Mode: listing"
To obtain a private container listing, specify the token of the user who has access to the container:
curl -i -XGET "https://api.selcdn.ru/v1/SEL_*****/container_name" -H "X-Auth-Token: $token" -H "X-Web-Mode: listing"
For HTML-formatted output, you can specify the layout using the X-Container-Meta-Web-Listings-Css header, with a reference to a style file in the container as the value; you can also provide a reference to an external style file.
Web-Listings-CSS | Behavior |
---|---|
my.css or /my.css | A styles file located in the same container will be used |
http://my\_site/my.css | Styles file from an external site will be used |
Set the Web-Listings-CSS value for the container:
curl -i -XPOST "https://api.selcdn.ru/v1/SEL_*****/container_name" -H "X-Auth-Token: $token" \
-H "X-Container-Meta-Web-Listings-Css: my_style.css"
Viewing the list of users
Request parameters
Request type | URI | Headings | Description |
---|---|---|---|
GET | https://api.selcdn.ru/v1/users | X-Auth-Token --- authorization token | Outputs a list of users for the current account |
Example request
curl -i https://api.selcdn.ru/v1/users -H "X-Auth-Token: $token"
If the request is successful, the API will return a response with code 200.
Example answer
HTTP/1.1 200 OK
Access-Control-Allow-Origin: *
Content-Type: text/plain; charset=utf-8
Content-Length: 80
main_user (true)
main_user (true)
user1 (true)
user2 (true)
user3 (true)
Adding a new user
Request parameters
Request type | URI | Headings | Description |
---|---|---|---|
PUT | https://api.selcdn.ru/v1/users/username | X-Auth-Token --- authorization token; X-Auth-Key --- password for the new user; X-User-Active --- user status (on--- active, off--- inactive); X-User-ACL-Containers-R --- names of containers that will be read-only for the new user; X-User-ACL-Containers-W --- list of containers that will be writable for the new user; X-User-S3-Password - indicates that the password will be used for s3 access (similar to the Use this data for s3 access option in the control panel). | Creates a user with the specified account settings |
Example request
curl -i -XPUT https://api.selcdn.ru/v1/users/my_test_user
-H "X-Auth-Token: $token"
-H "X-Auth-Key: $key"
-H "X-User-ACL-Containers-W: container1, container2, container3"
-H "X-User-ACL-Containers-R: container4"
-H "X-User-S3-Password: yes"
-H "X-User-Active: on"
If the request is successful, the API returns a response with code 204.
Example answer
HTTP/2 204 Created
access-control-allow-origin: *
Content-Type: text/html; charset=UTF-8
Content-Length: 0
Deleting a user
Request parameters
Request type | URI | Headings | Description |
---|---|---|---|
DELETE | https://api.selcdn.ru/v1/users/username | X-Auth-Token --- authorization token | Deletes the specified user |
Example request
curl -i -X DELETE https://api.selcdn.ru/v1/users/my_test_user -H "X-Auth-Token: $token"
If the user is successfully deleted, the API returns a response with code 204.
Example answer
HTTP/1.1 204 No Content
Access-Control-Allow-Origin: *
Content-Type: text/plain; charset=utf-8
X-Content-Type-Options: nosniff
Date: Mon, 19 Mar 2018 10:04:25 GMT
Changing the password of the primary user
Request parameters
Request type | URI | Headings | Description |
---|---|---|---|
POST | https://api.selcdn.ru/v1/users/ | X-Auth-Token --- authorization token; X-Auth-Key --- new password; X-User-S3-Password - specifies that the password will be used for s3 access (similar to the Use this data for s3 access option in the control panel). | Changes the primary user's password to the password passed in the X-Auth-Key header |
Example request
curl -i -XPOST https://api.selcdn.ru/v1/users -H "X-Auth-Token: $token" -H "X-Auth-Key: $key"
If the request is successful, the API returns a response with code 204.
Example answer
HTTP/1.1 204 No Content
Access-Control-Allow-Origin: *
Content-Type: text/plain; charset=utf-8
X-Content-Type-Options: nosniff
Date: Mon, 19 Mar 2018 10:30:59 GMT
You can attach domains to containers in the storage. All operations with domains are performed via API.
Default Domains
Each object store user automatically gets a set of default domains that can be used to access objects in any containers:
- ********.selcdn.ru --- domain for public access to files in the storage;
- ********.selcdn.com --- the domain for CDN file sharing over http.
Through the ticket system, you can order a domain of the form xxxx.akamaihd.net, which can be used for https access to objects in containers via our partner Akamai's CDN cache.
Getting the list of attached domains
Request parameters
Request type | URI | Headings | Description |
---|---|---|---|
GET | https://api.selcdn.ru/v1/domains | X-Auth-Token --- authorization token | Returns a list of domains |
Example request
curl -i -XGET https://api.selcdn.ru/v1/domains -H "X-Auth-Token: $token"
If the request is successful, the API returns a response with code 200.
Example answer
HTTP/1.1 200 OK
Content-Length: 69
Content-Type: text/html
Date: Mon, 16 May 2016 07:36:35 GMT
Base Domains:
00000.selcdn.ru
00000.selcdn.com
Containers Domains:
container1 domain1.ru
container2 domain1.ru
Domain attachment
Request parameters
Request type | URI | Headings | Description |
---|---|---|---|
POST | https://api.selcdn.ru/v1/SEL\_\*\*\*\*\*\*\*/container. | X-Auth-Token --- authorization token; X-Add-Container-Domains --- list of domains that will be attached to the container, domains are specified comma separated. | Attaches the domains passed in the X-Add-Container-Domains header to the container |
Example request
curl -i -XPOST https://api.selcdn.ru/v1/SEL_*****/container -H "X-Add-Container-Domains: domain1.ru" -H "X-Auth-Token: $token"
If the request is successful, the API will return a response with code 204.
Example answer
HTTP/1.1 204 No Content
Access-Control-Allow-Origin: *
Access-Control-Expose-Headers: X-Backend-Timestamp, Etag, Last-Modified, X-Object-Manifest, X-Timestamp
Content-Type: text/plain; charset=utf-8
X-Content-Type-Options: nosniff
Date: Tue, 20 Mar 2018 12:09:38 GMT
Domain deletion
Request parameters
Request type | URI | Headings | Description |
---|---|---|---|
POST | https://api.selcdn.ru/v1/SEL\_\*\*\*\*\*\*\*/container. | X-Auth-Token --- authorization token; X-Remove-Container-Domains --- list of domains that will be detached from the container, domains are specified separated by commas | Unlinks the domains passed in the X-Remove-Container-Domains header from the container |
Example request
curl -i -XPOST https://api.selcdn.ru/v1/SEL_*****/container -H "X-Remove-Container-Domains: domain1.ru" -H "X-Auth-Token: $token
If the request is successful, the API returns a response with code 204.
Example answer
HTTP/1.1 204 No Content
Access-Control-Allow-Origin: *
Access-Control-Expose-Headers: X-Backend-Timestamp, Etag, Last-Modified, X-Object-Manifest, X-Timestamp
Content-Type: text/plain; charset=utf-8
X-Content-Type-Options: nosniff
Editing the list of domains
Request parameters
Request type | URI | Headings | Description |
---|---|---|---|
POST | https://api.selcdn.ru/v1/SEL\_\*\*\*\*\*\*\*/container. | X-Auth-Token --- authorization token; X-Container-Domains --- list of domains that will be attached to the container, domains are specified comma separated. | Attaches the domains passed in the X-Container-Domains header to the container. Unlike X-Add-Container-Domains, this header completely replaces the list of attached domains rather than supplementing it |
Example request
curl -i -XPOST https://api.selcdn.ru/v1/SEL_*****/container -H "X-Container-Domains: domain1.ru" -H "X-Auth-Token: $token"
If the request is successful, the API returns a response with code 204.
Example answer
HTTP/1.1 204 No Content
Access-Control-Allow-Origin: *
Access-Control-Expose-Headers: X-Backend-Timestamp, Etag, Last-Modified, X-Object-Manifest, X-Timestamp
Content-Type: text/plain; charset=utf-8
X-Content-Type-Options: nosniff
Getting the list of certificates
Request parameters
Request type | URI | Headings | Description |
---|---|---|---|
GET | https://api.selcdn.ru/v1/ssl | X-Auth-Token --- authorization token | Returns a list of certificates |
Example request
curl -i -XGET https://api.selcdn.ru/v1/ssl -H "X-Auth-Token: $token"
Obtaining certificate information
Request parameters
Request type | URI | Headings | Description |
---|---|---|---|
GET | https://api.selcdn.ru/v1/ssl/cert | X-Auth-Token --- authorization token | Returns information about the specified certificate |
Example request
curl -i -XGET https://api.selcdn.ru/v1/ssl/cert -H "X-Auth-Token: $token"
Adding a certificate
Request parameters
Request type | URI | Headings | Description |
---|---|---|---|
PUT | https://api.selcdn.ru/v1/ssl/\*\*\*\*\*\_cert1 | X-Auth-Token --- authorization token | Adds a new certificate |
Example request
curl -i -XPUT https://api.selcdn.ru/v1/ssl/*****_cert1 -H "X-Auth-Token: $token" -T ./cert1.pem
The name of the certificate ({cert_name}) should be sent in the format ********_cert1, where the first part (digits) represents the user account number and the second part is any arbitrary combination of characters.
Certificate names must be unique; it is not possible to upload two certificates with the same name.
The certificate itself and the private key must be passed in the body of the request in one file.
Deleting a certificate
Request parameters
Request type | URI | Headings | Description |
---|---|---|---|
DELETE | https://api.selcdn.ru/v1/ssl/cert | X-Auth-Token --- authorization token | Deletes the specified certificate |
Request Parameters:
- The type of request is --- POST;
- URI ---
https://api.selcdn.ru/v1/storage/purge
; - Headers --- X-Auth-Token authorization token;
- Description --- clears the Object Store cache for pages whose addresses are passed in the request.
Example of a request:
curl -i -XPOST https://api.selcdn.ru/v1/storage/purge -H "x-auth-token: $token" -d '{"objects":["https://example.domain.ru/test_purge/file","https://example2.domain.ru/test_purge/file2"]}'
If the request is successful, the API will return a response with code 200.
Example answer:
HTTP/2 200
content-type: application/json
date: Fri, 27 Aug 2021 13:00:42 GMT
content-length: 66
{"HttpStatus":201,"Detail":"Request accepted.","RejectedUrls":{}}
Request to create an upload
Request parameters
Request type | URI | Headings | Description |
---|---|---|---|
POST | https://api.selcdn.ru/v1/logs | X-Auth-Token --- authorization token; X-Start-Time --- start of period in Y-m-d H:M:S format; X-End-Time --- end of period in Y-m-d H:M:S format; X-Limit --- maximum number of records to be returned in the request | Create a logs container and upload storage logs to it |
Request body:
{
"since": "2019-05-14T06:00:00",
"till": "2019-12-09T13:43:00",
"fields": [
"container_name"
],
"filters": {
"host": [
"example.com",
"foo.bar.baz"
]
},
"container": "logs",
"delete_after": 3600
}
A description of the fields of the request body:
- since --- the beginning of the period for unloading;
- till --- end of period for unloading;
- fields --- list of required fields;
- filters --- filters for unloading;
- container --- container for unloading;
- delete_after --- deleting objects with logs after a specified time.
List of possible fields:
- container_name
- timestamp
- host
- server_to_client_bytes
- client_to_server_bytes
- http_method
- status
- path
- query
- client_ip
A list of possible filters (filters):
- host
- container_name
Example request
curl -i -XPOST -H 'X-Auth-Token: $token' -d '{"since": "2019-05-14T06:00:00","till": "2019-12-09T13:43:00", "fields": ["container_name"], "filters": {"host": ["example.com", "foo.bar.baz"]}, "container": "logs", "delete_after": 3600}' 'https://api.selcdn.ru/v1/logs'
If the request is successful, the API will return a response with code 200.
Example answer
HTTP/1.1 201 Created
Access-Control-Allow-Origin: *
Content-Length: 342
Content-Type: application/json
Date: Tue, 14 Jan 2020 13:01:34 GMT
{
"task": {
"id": "896aae80-bc7e-434d-8528-5ca2bfb41a56",
"created": "2020-01-14T13:01:34",
"updated": "2020-01-14T13:01:34",
"type": "storage_logs",
"data": {
"since": "2019-05-14T06:00:00",
"till": "2019-12-09T13:43:00",
"provider": "storage_access",
"container": "logs",
"fields": ["container_name"],
"filters": {"host": ["example.com", "foo.bar.baz"]},
"delete_after": 3600
},
"status": 0,
"progress": 0
}
}
Getting information about the created task
Request parameters
Request type | URI | Headings | Description |
---|---|---|---|
GET | https://api.selcdn.ru/v1/logs/$task\_id | X-Auth-Token --- authorization token | Create a logs container and upload storage logs to it |
Example request
curl -i -XPOST -H 'X-Auth-Token: $token' -d '{"since": "2019-05-14T06:00:00","till": "2019-12-09T13:43:00", "fields": ["container_name"], "filters": {"host": ["example.com", "foo.bar.baz"]}, "container": "logs", "delete_after": 3600}' 'https://api.selcdn.ru/v1/logs'
Example answer
{
"task": {
"id": "896aae80-bc7e-434d-8528-5ca2bfb41a56",
"created": "2020-01-14T13:01:34",
"updated": "2020-01-14T13:01:45",
"type": "storage_logs",
"data": {
"till": "2019-12-09T13:43:00",
"since": "2019-05-14T06:00:00",
"fields": ["container_name"],
"filters": {"host": ["example.com", "foo.bar.baz"]},
"provider": "storage_access",
"container": "logs",
"delete_after": 3600
},
"status": 2,
"progress": 100
}
}