Scalr\Service\OpenStack\Services\Network\V2\NetworkApi::listSubnets PHP Method

listSubnets() public method

Lists all subnets that are accessible to the tenant who submits the request.
public listSubnets ( string $subnetId = null, Scalr\Service\OpenStack\Services\Network\Type\ListSubnetsFilter $filter = null ) : Scalr\Service\OpenStack\Type\DefaultPaginationList | object
$subnetId string optional The ID of the subnet to show detailed info
$filter Scalr\Service\OpenStack\Services\Network\Type\ListSubnetsFilter optional The filter.
return Scalr\Service\OpenStack\Type\DefaultPaginationList | object Returns the list of the subnets or one subnet
    public function listSubnets($subnetId = null, ListSubnetsFilter $filter = null)
    {
        $result = null;
        $detailed = $subnetId !== null ? sprintf("/%s", $this->escape($subnetId)) : '';
        $response = $this->getClient()->call($this->service, '/subnets' . $detailed . ($filter !== null ? '?' . $filter->getQueryString() : ''));
        if ($response->hasError() === false) {
            $result = json_decode($response->getContent());
            if (empty($detailed)) {
                $result = new DefaultPaginationList($this->service, 'subnets', $result->subnets, isset($result->subnets_links) ? $result->subnets_links : null);
            } else {
                $result = $result->subnet;
            }
        }
        return $result;
    }