/** * Gets the list of the security groups (GET /lb/security-groups[/security-groups-id]) * * @param string $id optional * The ID of the security group to view * * @param ListSecurityGroupsFilter|array $filter optional * The filter options. Filter doesn't apply to detailed info * * @param array $fields optional * The list of the fields to show * * @return DefaultPaginationList|object Returns the list of the security groups or specified security group * @throws RestClientException */ public function listSecurityGroups($id = null, $filter = null, $fields = null) { if ($filter !== null && !$filter instanceof ListSecurityGroupsFilter) { $filter = ListSecurityGroupsFilter::initArray($filter); } return $this->getApiHandler()->listSecurityGroups($id, $filter, $fields); }
/** * Gets the list of the security groups * * @param string $id optional * The ID of the security group to view * * @param ListSecurityGroupsFilter $filter optional * The filter options. Filter doesn't apply to detailed info * * @param array $fields optional * The list of the fields to show * * @return DefaultPaginationList|object Returns the list of the security groups or specified security group * @throws RestClientException */ public function listSecurityGroups($id = null, ListSecurityGroupsFilter $filter = null, array $fields = null) { $result = null; $detailed = $id !== null ? sprintf("/%s", $this->escape($id)) : ''; if (!empty($fields)) { $acceptedFields = ['name', 'description', 'id', 'tenant_id', 'security_group_rules']; $fields = join('&fields=', array_map("rawurlencode", array_intersect(array_values($fields), $acceptedFields))); } $querystr = ($filter !== null && $detailed == '' ? $filter->getQueryString() : '') . ($fields ? '&fields=' . $fields : ''); $querystr = !empty($querystr) ? '?' . ltrim($querystr, '&') : ''; $response = $this->getClient()->call($this->service, '/security-groups' . $detailed . $querystr); if ($response->hasError() === false) { $result = json_decode($response->getContent()); if (empty($detailed)) { $result = new DefaultPaginationList($this->service, 'security_groups', $result->security_groups, isset($result->security_groups_links) ? $result->security_groups_links : null); } else { $result = $result->security_group; } } return $result; }