コード例 #1
0
ファイル: NetworkApi.php プロジェクト: scalr/scalr
 /**
  * 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
ファイル: NetworkApi.php プロジェクト: recipe/scalr
 /**
  * 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;
 }