Create logging topic
curl --request PUT \
--url https://api.gcore.com/cloud/v1/laas/{project_id}/{region_id}/topics \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "my-topic",
"index_pattern": {
"id": "exampletopicindexpatternid"
},
"retention_policy": {
"period": 45
},
"size_in_bytes": 0
}
'import requests
url = "https://api.gcore.com/cloud/v1/laas/{project_id}/{region_id}/topics"
payload = {
"name": "my-topic",
"index_pattern": { "id": "exampletopicindexpatternid" },
"retention_policy": { "period": 45 },
"size_in_bytes": 0
}
headers = {
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: 'my-topic',
index_pattern: {id: 'exampletopicindexpatternid'},
retention_policy: {period: 45},
size_in_bytes: 0
})
};
fetch('https://api.gcore.com/cloud/v1/laas/{project_id}/{region_id}/topics', 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/laas/{project_id}/{region_id}/topics",
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([
'name' => 'my-topic',
'index_pattern' => [
'id' => 'exampletopicindexpatternid'
],
'retention_policy' => [
'period' => 45
],
'size_in_bytes' => 0
]),
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;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.gcore.com/cloud/v1/laas/{project_id}/{region_id}/topics"
payload := strings.NewReader("{\n \"name\": \"my-topic\",\n \"index_pattern\": {\n \"id\": \"exampletopicindexpatternid\"\n },\n \"retention_policy\": {\n \"period\": 45\n },\n \"size_in_bytes\": 0\n}")
req, _ := http.NewRequest("PUT", url, payload)
req.Header.Add("Authorization", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.put("https://api.gcore.com/cloud/v1/laas/{project_id}/{region_id}/topics")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"my-topic\",\n \"index_pattern\": {\n \"id\": \"exampletopicindexpatternid\"\n },\n \"retention_policy\": {\n \"period\": 45\n },\n \"size_in_bytes\": 0\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.gcore.com/cloud/v1/laas/{project_id}/{region_id}/topics")
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 \"name\": \"my-topic\",\n \"index_pattern\": {\n \"id\": \"exampletopicindexpatternid\"\n },\n \"retention_policy\": {\n \"period\": 45\n },\n \"size_in_bytes\": 0\n}"
response = http.request(request)
puts response.read_body{
"index_pattern": {
"id": "exampletopicindexpatternid"
},
"name": "my-topic",
"retention_policy": {
"period": 45
},
"size_in_bytes": 1
}{
"code": 123,
"message": "<string>"
}{
"code": 123,
"message": "<string>"
}Logging
Create logging topic
Create a new Kafka topic within the client’s LaaS namespace for the specified project and region. If a topic with the same name exists, it will be updated.
PUT
/
cloud
/
v1
/
laas
/
{project_id}
/
{region_id}
/
topics
Create logging topic
curl --request PUT \
--url https://api.gcore.com/cloud/v1/laas/{project_id}/{region_id}/topics \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "my-topic",
"index_pattern": {
"id": "exampletopicindexpatternid"
},
"retention_policy": {
"period": 45
},
"size_in_bytes": 0
}
'import requests
url = "https://api.gcore.com/cloud/v1/laas/{project_id}/{region_id}/topics"
payload = {
"name": "my-topic",
"index_pattern": { "id": "exampletopicindexpatternid" },
"retention_policy": { "period": 45 },
"size_in_bytes": 0
}
headers = {
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: 'my-topic',
index_pattern: {id: 'exampletopicindexpatternid'},
retention_policy: {period: 45},
size_in_bytes: 0
})
};
fetch('https://api.gcore.com/cloud/v1/laas/{project_id}/{region_id}/topics', 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/laas/{project_id}/{region_id}/topics",
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([
'name' => 'my-topic',
'index_pattern' => [
'id' => 'exampletopicindexpatternid'
],
'retention_policy' => [
'period' => 45
],
'size_in_bytes' => 0
]),
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;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.gcore.com/cloud/v1/laas/{project_id}/{region_id}/topics"
payload := strings.NewReader("{\n \"name\": \"my-topic\",\n \"index_pattern\": {\n \"id\": \"exampletopicindexpatternid\"\n },\n \"retention_policy\": {\n \"period\": 45\n },\n \"size_in_bytes\": 0\n}")
req, _ := http.NewRequest("PUT", url, payload)
req.Header.Add("Authorization", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.put("https://api.gcore.com/cloud/v1/laas/{project_id}/{region_id}/topics")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"my-topic\",\n \"index_pattern\": {\n \"id\": \"exampletopicindexpatternid\"\n },\n \"retention_policy\": {\n \"period\": 45\n },\n \"size_in_bytes\": 0\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.gcore.com/cloud/v1/laas/{project_id}/{region_id}/topics")
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 \"name\": \"my-topic\",\n \"index_pattern\": {\n \"id\": \"exampletopicindexpatternid\"\n },\n \"retention_policy\": {\n \"period\": 45\n },\n \"size_in_bytes\": 0\n}"
response = http.request(request)
puts response.read_body{
"index_pattern": {
"id": "exampletopicindexpatternid"
},
"name": "my-topic",
"retention_policy": {
"period": 45
},
"size_in_bytes": 1
}{
"code": 123,
"message": "<string>"
}{
"code": 123,
"message": "<string>"
}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
Body
application/json
Kafka topic name to be used in log shipper config to write logs to LaaS
Required string length:
1 - 223Pattern:
^[a-z0-9](?:[-a-z0-9]*[a-z0-9])?(?:\.[a-z0-9](?:[-a-z0-9]*[a-z0-9])*)*$Example:
"my-topic"
Index Pattern data
Show child attributes
Show child attributes
Example:
{ "id": "exampletopicindexpatternid" }
Show child attributes
Show child attributes
Example:
{ "period": 45 }
Size of the topic in bytes
Required range:
x >= 0Response
LaaS Kafka topic
Index Pattern data
Show child attributes
Show child attributes
Example:
{ "id": "exampletopicindexpatternid" }
Kafka topic name to be used in log shipper config to write logs to LaaS
Example:
"my-topic"
Show child attributes
Show child attributes
Example:
{ "period": 45 }
Size of the topic in bytes
Required range:
x >= 0Was this page helpful?