import os
from gcore import Gcore
client = Gcore(
api_key=os.environ.get("GCORE_API_KEY"), # This is the default and can be omitted
)
security_group = client.cloud.security_groups.get(
group_id="024a29e9-b4b7-4c91-9a46-505be123d9f8",
project_id=1,
region_id=1,
)
print(security_group.id)package main
import (
"context"
"fmt"
"github.com/G-Core/gcore-go"
"github.com/G-Core/gcore-go/cloud"
"github.com/G-Core/gcore-go/option"
)
func main() {
client := gcore.NewClient(
option.WithAPIKey("My API Key"),
)
securityGroup, err := client.Cloud.SecurityGroups.Get(
context.TODO(),
"024a29e9-b4b7-4c91-9a46-505be123d9f8",
cloud.SecurityGroupGetParams{
ProjectID: gcore.Int(1),
RegionID: gcore.Int(1),
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", securityGroup.ID)
}
curl --request GET \
--url https://api.gcore.com/cloud/v1/securitygroups/{project_id}/{region_id}/{group_id} \
--header 'Authorization: <api-key>'const options = {method: 'GET', headers: {Authorization: '<api-key>'}};
fetch('https://api.gcore.com/cloud/v1/securitygroups/{project_id}/{region_id}/{group_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/cloud/v1/securitygroups/{project_id}/{region_id}/{group_id}",
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/cloud/v1/securitygroups/{project_id}/{region_id}/{group_id}")
.header("Authorization", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.gcore.com/cloud/v1/securitygroups/{project_id}/{region_id}/{group_id}")
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{
"created_at": "2019-06-18T11:56:16+0000",
"description": "Some description",
"id": "00000000-0000-4000-8000-000000000000",
"name": "my_security_group",
"project_id": 1337,
"region": "Luxembourg 1",
"region_id": 7,
"revision_number": 1,
"tags_v2": [
{
"key": "my-tag",
"read_only": false,
"value": "my-tag-value"
}
],
"updated_at": "2019-06-18T11:57:00+0000",
"security_group_rules": [
{
"created_at": "2019-06-18T11:56:16+0000",
"description": "Some description",
"direction": "egress",
"ethertype": "IPv4",
"id": "00000000-0000-4000-8000-000000000000",
"port_range_max": 80,
"port_range_min": 80,
"protocol": "tcp",
"remote_group_id": [
"00000000-0000-4000-8000-000000000000"
],
"remote_ip_prefix": "10.0.0.0/8",
"revision_number": 0,
"security_group_id": "00000000-0000-4000-8000-000000000000",
"updated_at": "2019-06-18T11:57:00+0000"
}
]
}Get security group
Get detailed information about a specific security group.
import os
from gcore import Gcore
client = Gcore(
api_key=os.environ.get("GCORE_API_KEY"), # This is the default and can be omitted
)
security_group = client.cloud.security_groups.get(
group_id="024a29e9-b4b7-4c91-9a46-505be123d9f8",
project_id=1,
region_id=1,
)
print(security_group.id)package main
import (
"context"
"fmt"
"github.com/G-Core/gcore-go"
"github.com/G-Core/gcore-go/cloud"
"github.com/G-Core/gcore-go/option"
)
func main() {
client := gcore.NewClient(
option.WithAPIKey("My API Key"),
)
securityGroup, err := client.Cloud.SecurityGroups.Get(
context.TODO(),
"024a29e9-b4b7-4c91-9a46-505be123d9f8",
cloud.SecurityGroupGetParams{
ProjectID: gcore.Int(1),
RegionID: gcore.Int(1),
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", securityGroup.ID)
}
curl --request GET \
--url https://api.gcore.com/cloud/v1/securitygroups/{project_id}/{region_id}/{group_id} \
--header 'Authorization: <api-key>'const options = {method: 'GET', headers: {Authorization: '<api-key>'}};
fetch('https://api.gcore.com/cloud/v1/securitygroups/{project_id}/{region_id}/{group_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/cloud/v1/securitygroups/{project_id}/{region_id}/{group_id}",
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/cloud/v1/securitygroups/{project_id}/{region_id}/{group_id}")
.header("Authorization", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.gcore.com/cloud/v1/securitygroups/{project_id}/{region_id}/{group_id}")
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{
"created_at": "2019-06-18T11:56:16+0000",
"description": "Some description",
"id": "00000000-0000-4000-8000-000000000000",
"name": "my_security_group",
"project_id": 1337,
"region": "Luxembourg 1",
"region_id": 7,
"revision_number": 1,
"tags_v2": [
{
"key": "my-tag",
"read_only": false,
"value": "my-tag-value"
}
],
"updated_at": "2019-06-18T11:57:00+0000",
"security_group_rules": [
{
"created_at": "2019-06-18T11:56:16+0000",
"description": "Some description",
"direction": "egress",
"ethertype": "IPv4",
"id": "00000000-0000-4000-8000-000000000000",
"port_range_max": 80,
"port_range_min": 80,
"protocol": "tcp",
"remote_group_id": [
"00000000-0000-4000-8000-000000000000"
],
"remote_ip_prefix": "10.0.0.0/8",
"revision_number": 0,
"security_group_id": "00000000-0000-4000-8000-000000000000",
"updated_at": "2019-06-18T11:57:00+0000"
}
]
}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
Path Parameters
Project ID
1
Region ID
1
Group ID
"024a29e9-b4b7-4c91-9a46-505be123d9f8"
Response
OK
Datetime when the security group was created
"2019-06-18T11:56:16+0000"
Security group description
"Some description"
Security group ID
"00000000-0000-4000-8000-000000000000"
Security group name
^[a-zA-Z0-9][a-zA-Z 0-9._\-]{1,61}[a-zA-Z0-9._]$"my_security_group"
Project ID
1337
Region name
"Luxembourg 1"
Region ID
7
The number of revisions
1
List of key-value tags associated with the resource. A tag is a key-value pair that can be associated with a resource, enabling efficient filtering and grouping for better organization and management. Some tags are read-only and cannot be modified by the user. Tags are also integrated with cost reports, allowing cost data to be filtered based on tag keys or values.
Show child attributes
Show child attributes
[
{
"key": "my-tag",
"read_only": false,
"value": "my-tag-value"
}
]
Datetime when the security group was last updated
"2019-06-18T11:57:00+0000"
Security group rules
Show child attributes
Show child attributes
Was this page helpful?