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.cloud.security_groups.list(
project_id=1,
region_id=1,
)
page = page.results[0]
print(page.id){
"count": 1,
"results": [
{
"created_at": "2023-11-07T05:31:56Z",
"id": "<string>",
"name": "<string>",
"project_id": 123,
"region": "<string>",
"region_id": 123,
"revision_number": 123,
"tags_v2": [
{
"key": "<string>",
"read_only": true,
"value": "<string>"
}
],
"updated_at": "2023-11-07T05:31:56Z",
"description": "Some description",
"security_group_rules": [
{
"created_at": "2023-11-07T05:31:56Z",
"direction": "egress",
"id": "<string>",
"revision_number": 123,
"security_group_id": "<string>",
"updated_at": "2023-11-07T05:31:56Z",
"description": "Some description",
"ethertype": "IPv4",
"port_range_max": 80,
"port_range_min": 80,
"protocol": "tcp",
"remote_group_id": "<string>",
"remote_ip_prefix": "10.0.0.0/8"
}
]
}
]
}List all security groups in the specified project and region.
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.cloud.security_groups.list(
project_id=1,
region_id=1,
)
page = page.results[0]
print(page.id){
"count": 1,
"results": [
{
"created_at": "2023-11-07T05:31:56Z",
"id": "<string>",
"name": "<string>",
"project_id": 123,
"region": "<string>",
"region_id": 123,
"revision_number": 123,
"tags_v2": [
{
"key": "<string>",
"read_only": true,
"value": "<string>"
}
],
"updated_at": "2023-11-07T05:31:56Z",
"description": "Some description",
"security_group_rules": [
{
"created_at": "2023-11-07T05:31:56Z",
"direction": "egress",
"id": "<string>",
"revision_number": 123,
"security_group_id": "<string>",
"updated_at": "2023-11-07T05:31:56Z",
"description": "Some description",
"ethertype": "IPv4",
"port_range_max": 80,
"port_range_min": 80,
"protocol": "tcp",
"remote_group_id": "<string>",
"remote_ip_prefix": "10.0.0.0/8"
}
]
}
]
}API key for authentication. Make sure to include the word apikey, followed by a single space and then your token.
Example: apikey 1234$abcdef
Limit of items on a single page
x <= 1000Offset in results list
x >= 0Optional. Filter by tag keys.
Tag key. The maximum size for a key is 255 characters.
1 - 255Optional. Filter by tag key-value pairs. Must be a valid JSON string.
OK
Number of objects
x >= 0Objects
Show child attributes
Datetime when the security group was created
Security group ID
Security group name
Project ID
Region name
Region ID
The number of revisions
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
Datetime when the security group was last updated
Security group description
"Some description"
Security group rules
Show child attributes
Datetime when the rule was created
Ingress or egress, which is the direction in which the security group rule is applied
egress, ingress The ID of the security group rule
The revision number of the resource
The security group ID to associate with this security group rule
Datetime when the rule was last updated
Rule description
"Some description"
Must be IPv4 or IPv6, and addresses represented in CIDR must match the ingress or egress rules.
IPv4, IPv6 "IPv4"
The maximum port number in the range that is matched by the security group rule
0 <= x <= 6553580
The minimum port number in the range that is matched by the security group rule
0 <= x <= 6553580
Protocol
ah, any, dccp, egp, esp, gre, icmp, igmp, ipencap, ipip, ipv6-encap, ipv6-frag, ipv6-icmp, ipv6-nonxt, ipv6-opts, ipv6-route, ospf, pgm, rsvp, sctp, tcp, udp, udplite, vrrp "tcp"
The remote group UUID to associate with this security group rule
The remote IP prefix that is matched by this security group rule
"10.0.0.0/8"
Was this page helpful?