Listing security groups
GET /v2.0/security-groups
List security groups to which the project has access.
Default policy settings return only those security groups that are owned by the project of the user who submits the request, unless the request is submitted by a user with administrative rights.
Source: https://docs.openstack.org/api-ref/network/v2/index.html#list-security-groups
Request
Parameters
| Name | In | Type | Description |
|---|---|---|---|
id (Optional)
|
query | string | Filter the list result by the ID of the resource. |
tenant_id (Optional) |
query | string | Filter the list result by the ID of the project that owns the resource. |
project_id (Optional) |
query | string | Filter the list result by the ID of the project that owns the resource. |
revision_number (Optional) |
query | integer | Filter the list result by the revision number of the resource. |
name (Optional) |
query | string | Filter the list result by the human-readable name of the resource. |
description (Optional) |
query | string | Filter the list result by the human-readable description of the resource. |
shared (Optional) |
query | boolean | Filter the security group list result based on if the security group is shared to the requestor's project. |
tags (Optional) |
query | string | A list of tags to filter the list result by. Resources that match all tags in this list will be returned. Tags in query must be separated by comma. |
tags-any (Optional) |
query | string | A list of tags to filter the list result by. Resources that match any tag in this list will be returned. Tags in query must be separated by comma. |
not-tags (Optional) |
query | string | A list of tags to filter the list result by. Resources that match all tags in this list will be excluded. Tags in query must be separated by comma. |
not-tags-any (Optional) |
query | string | A list of tags to filter the list result by. Resources that match any tag in this list will be excluded. Tags in query must be separated by comma. |
sort_dir (Optional) |
query | string | Sort direction. A valid value is asc (ascending) or desc
(descending). You can specify multiple pairs of sort key and
sort direction query parameters. |
sort_key (Optional) |
query | string |
Sorts by a security group attribute. You can specify multiple pairs of sort key and sort direction query parameters. The sort keys are limited to:
|
fields (Optional) |
query | string | The fields that you want the server to return. If no fields query parameter is specified, the networking API returns all attributes allowed by the policy settings. By using the fields parameter, the API returns only the requested set of attributes. The fields parameter can be specified multiple times. For example, if you specify fields=id&fields=name in the request URL, only the id and name attributes will be returned. |
Example
# curl -ks -H 'Content-Type: application/json' -H 'X-Auth-Token: gAAAAA<...>' \ https://<node_IP_addr>:9696/v2.0/security-groups
Response
Parameters
| Name | In | Type | Description |
|---|---|---|---|
security_groups |
body | array | A list of security_group objects. |
id
|
body | string | The ID of the security group. |
tenant_id
|
body | string | The ID of the project. |
project_id
|
body | string | The ID of the project. |
created_at
|
body | string |
Time at which the resource has been created. The date and time stamp format is ISO 8601: CCYY-MM-DDThh:mm:ss±hh:mm For example, The |
updated_at |
body | string |
Time at which the resource has been updated. If the resource has
not been updated, this field will be The date and time stamp format is ISO 8601: CCYY-MM-DDThh:mm:ss±hh:mm For example, The |
revision_number
|
body | integer | The revision number of the resource. |
name
|
body | string | Human-readable name of the resource. |
description
|
body | string | A human-readable description for the resource. |
security_group_rules
|
body | array | A list of security_group_rule objects. For details, refer to Listing security group rules. |
stateful (Optional) |
body | boolean | Indicates if the security group is stateful or stateless. |
shared
|
body | boolean | Indicates whether this security group is shared to the requestor's project. |
tags
|
body | array | The list of tags on the resource. |
Status codes
Success
| Code | Reason |
|---|---|
200 - OK
|
Request was successful. |
Error
| Code | Reason |
|---|---|
401 - Unauthorized
|
User must authenticate before making a request. |
Example
{
"security_groups": [
{
"id": "bea2edb6-c99c-474a-817b-b07cffa4e930",
"name": "default",
"stateful": true,
"tenant_id": "39bbb405942f4fba80bb75e3db78e714",
"description": "Default security group",
"security_group_rules": [
{
"id": "3b954abc-ab9d-4f71-bffd-432bba7e097d",
"tenant_id": "39bbb405942f4fba80bb75e3db78e714",
"security_group_id": "bea2edb6-c99c-474a-817b-b07cffa4e930",
"ethertype": "IPv4",
"direction": "ingress",
"protocol": null,
"port_range_min": null,
"port_range_max": null,
"remote_ip_prefix": null,
"remote_address_group_id": null,
"normalized_cidr": null,
"remote_group_id": "bea2edb6-c99c-474a-817b-b07cffa4e930",
"standard_attr_id": 2,
"description": null,
"tags": [],
"created_at": "2025-03-19T13:37:01Z",
"updated_at": "2025-03-19T13:37:01Z",
"revision_number": 0,
"project_id": "39bbb405942f4fba80bb75e3db78e714"
},
{
"id": "1bb5b7bf-bd33-41ba-b09c-f9cbcbb76763",
"tenant_id": "39bbb405942f4fba80bb75e3db78e714",
"security_group_id": "bea2edb6-c99c-474a-817b-b07cffa4e930",
"ethertype": "IPv4",
"direction": "egress",
"protocol": null,
"port_range_min": null,
"port_range_max": null,
"remote_ip_prefix": null,
"remote_address_group_id": null,
"normalized_cidr": null,
"remote_group_id": null,
"standard_attr_id": 3,
"description": null,
"tags": [],
"created_at": "2025-03-19T13:37:01Z",
"updated_at": "2025-03-19T13:37:01Z",
"revision_number": 0,
"project_id": "39bbb405942f4fba80bb75e3db78e714"
},
{
"id": "55f5c0c4-58d8-4bcd-a9e5-bf52fe40a067",
"tenant_id": "39bbb405942f4fba80bb75e3db78e714",
"security_group_id": "bea2edb6-c99c-474a-817b-b07cffa4e930",
"ethertype": "IPv6",
"direction": "ingress",
"protocol": null,
"port_range_min": null,
"port_range_max": null,
"remote_ip_prefix": null,
"remote_address_group_id": null,
"normalized_cidr": null,
"remote_group_id": "bea2edb6-c99c-474a-817b-b07cffa4e930",
"standard_attr_id": 4,
"description": null,
"tags": [],
"created_at": "2025-03-19T13:37:01Z",
"updated_at": "2025-03-19T13:37:01Z",
"revision_number": 0,
"project_id": "39bbb405942f4fba80bb75e3db78e714"
},
{
"id": "6a116df9-f940-410b-8204-905fbe485bb7",
"tenant_id": "39bbb405942f4fba80bb75e3db78e714",
"security_group_id": "bea2edb6-c99c-474a-817b-b07cffa4e930",
"ethertype": "IPv6",
"direction": "egress",
"protocol": null,
"port_range_min": null,
"port_range_max": null,
"remote_ip_prefix": null,
"remote_address_group_id": null,
"normalized_cidr": null,
"remote_group_id": null,
"standard_attr_id": 5,
"description": null,
"tags": [],
"created_at": "2025-03-19T13:37:01Z",
"updated_at": "2025-03-19T13:37:01Z",
"revision_number": 0,
"project_id": "39bbb405942f4fba80bb75e3db78e714"
},
{
"id": "3be903a5-01ce-488f-93cc-5612eb2b004e",
"tenant_id": "39bbb405942f4fba80bb75e3db78e714",
"security_group_id": "bea2edb6-c99c-474a-817b-b07cffa4e930",
"ethertype": "IPv4",
"direction": "ingress",
"protocol": null,
"port_range_min": null,
"port_range_max": null,
"remote_ip_prefix": "0.0.0.0/0",
"remote_address_group_id": null,
"normalized_cidr": "0.0.0.0/0",
"remote_group_id": null,
"standard_attr_id": 6,
"description": null,
"tags": [],
"created_at": "2025-03-19T13:37:01Z",
"updated_at": "2025-03-19T13:37:01Z",
"revision_number": 0,
"project_id": "39bbb405942f4fba80bb75e3db78e714"
},
{
"id": "a0e31e23-4db5-4a30-8f6c-93c83b8a339e",
"tenant_id": "39bbb405942f4fba80bb75e3db78e714",
"security_group_id": "bea2edb6-c99c-474a-817b-b07cffa4e930",
"ethertype": "IPv6",
"direction": "ingress",
"protocol": null,
"port_range_min": null,
"port_range_max": null,
"remote_ip_prefix": "::/0",
"remote_address_group_id": null,
"normalized_cidr": "::/0",
"remote_group_id": null,
"standard_attr_id": 7,
"description": null,
"tags": [],
"created_at": "2025-03-19T13:37:01Z",
"updated_at": "2025-03-19T13:37:01Z",
"revision_number": 0,
"project_id": "39bbb405942f4fba80bb75e3db78e714"
}
],
"tags": [],
"created_at": "2025-03-19T13:37:01Z",
"updated_at": "2025-03-19T13:37:01Z",
"revision_number": 1,
"project_id": "39bbb405942f4fba80bb75e3db78e714"
}
]
}