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

listPorts() public method

Lists all ports to which the tenant has access.
public listPorts ( string $portId = null, Scalr\Service\OpenStack\Services\Network\Type\ListPortsFilter $filter = null ) : Scalr\Service\OpenStack\Type\DefaultPaginationList | object
$portId string optional The ID of the port to show detailed info
$filter Scalr\Service\OpenStack\Services\Network\Type\ListPortsFilter The filter options
return Scalr\Service\OpenStack\Type\DefaultPaginationList | object Returns the list of the ports or the information about one port
    public function listPorts($portId = null, ListPortsFilter $filter = null)
    {
        $result = null;
        $detailed = $portId !== null ? sprintf("/%s", $this->escape($portId)) : '';
        $response = $this->getClient()->call($this->service, '/ports' . $detailed . ($filter !== null ? '?' . $filter->getQueryString() : ''));
        if ($response->hasError() === false) {
            $result = json_decode($response->getContent());
            if (empty($detailed)) {
                $result = new DefaultPaginationList($this->service, 'ports', $result->ports, isset($result->ports_links) ? $result->ports_links : null);
            } else {
                $result = $result->port;
            }
        }
        return $result;
    }