Пример #1
0
 /**
  * ListPorts action (GET /ports[/port-id])
  *
  * Lists all ports to which the tenant has access.
  *
  * @param   string          $portId optional The ID of the port to show detailed info
  * @param   ListPortsFilter $filter The filter options
  * @return  DefaultPaginationList|object Returns the list of the ports or the information about one port
  * @throws  RestClientException
  */
 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;
 }
Пример #2
0
 /**
  * ListPorts action (GET /ports[/port-id])
  *
  * Lists all ports to which the tenant has access.
  *
  * @param   string                $portId optional The ID of the port to show detailed info
  * @param   ListPortsFilter|array $filter The filter options
  * @return  DefaultPaginationList|object Returns the list of the ports or the information about one port
  * @throws  RestClientException
  */
 public function listPorts($portId = null, $filter = null)
 {
     if ($filter !== null && !$filter instanceof ListPortsFilter) {
         $filter = ListPortsFilter::initArray($filter);
     }
     return $this->getApiHandler()->listPorts($portId, $filter);
 }
Пример #3
0
 /**
  * ListPorts action (GET /ports[/port-id])
  *
  * Lists all ports to which the tenant has access.
  *
  * @param   string          $portId optional The ID of the port to show detailed info
  * @param   ListPortsFilter $filter The filter options
  * @return  array|object Returns the list of the ports or the information about one port
  * @throws  RestClientException
  */
 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());
         $result = empty($detailed) ? $result->ports : $result->port;
     }
     return $result;
 }