/** * Gets the routers list * * This operation returns a list of routers to which the tenant has access. * Default policy settings return only those routers that are owned by the tenant who submits the request, * unless the request is submitted by an user with administrative rights. * Users can control which attributes should be returned by using the fields query parameter. * Additionally, results can be filtered by using query string parameters. * * @param string $routerId optional The ID of the router to show detailed info * @param ListRoutersFilter|array $filter optional The filter options * @param array $fields optional The list of the fields to show * @return DefaultPaginationList|object Returns the list of the routers or the information about one router * @throws RestClientException */ public function listRouters($routerId = null, $filter = null, array $fields = null) { if ($filter !== null && !$filter instanceof ListRoutersFilter) { $filter = ListRoutersFilter::initArray($filter); } return $this->getApiHandler()->listRouters($routerId, $filter, $fields); }
/** * Gets the routers list * * This operation returns a list of routers to which the tenant has access. * Default policy settings return only those routers that are owned by the tenant who submits the request, * unless the request is submitted by an user with administrative rights. * Users can control which attributes should be returned by using the fields query parameter. * Additionally, results can be filtered by using query string parameters. * * @param string $routerId optional The ID of the router to show detailed info * @param ListRoutersFilter $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 router or the information about one router * @throws RestClientException */ public function listRouters($routerId = null, ListRoutersFilter $filter = null, array $fields = null) { $result = null; $detailed = $routerId !== null ? sprintf("/%s", $this->escape($routerId)) : ''; if (!empty($fields)) { $acceptedFields = array('status', 'name', 'admin_state_up', 'id', 'tenant_id', 'external_gateway_info', 'admin_state_up'); $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, '/routers' . $detailed . $querystr); if ($response->hasError() === false) { $result = json_decode($response->getContent()); if (empty($detailed)) { $result = new DefaultPaginationList($this->service, 'routers', $result->routers, isset($result->routers_links) ? $result->routers_links : null); } else { $result = $result->router; } } return $result; }