Example #1
0
 /**
  * Sets InterfaceList
  *
  * @param   array|InterfaceList  $networkInterfaces
  * @return  SecurityGroupProperties
  */
 public function setNetworkInterfaces($networkInterfaces = null)
 {
     if (!$networkInterfaces instanceof InterfaceList) {
         $networkInterfaceList = new InterfaceList();
         foreach ($networkInterfaces as $networkInterface) {
             if (!$networkInterface instanceof InterfaceData) {
                 $networkInterfaceData = InterfaceData::initArray($networkInterface);
             } else {
                 $networkInterfaceData = $networkInterface;
             }
             $networkInterfaceList->append($networkInterfaceData);
         }
     } else {
         $networkInterfaceList = $networkInterfaces;
     }
     return $this->__call(__FUNCTION__, [$networkInterfaceList]);
 }
Example #2
0
 /**
  * Lists all networks in a subscription or resource group.
  *
  * @param string $subscriptionId    Subscription Id
  * @param string $resourceGroupName optional Name of Resource Group
  *
  * @return InterfaceList Object with response
  */
 public function getList($subscriptionId, $resourceGroupName = null)
 {
     $result = null;
     $path = '/subscriptions/' . $subscriptionId;
     if (isset($resourceGroupName)) {
         $path .= '/resourceGroups/' . $resourceGroupName;
     }
     $path .= NetworkService::ENDPOINT_MICROSOFT_NETWORK . '/networkInterfaces';
     $request = $this->getClient()->prepareRequest($path, 'GET', $this->getApiVersion());
     $response = $this->getClient()->call($request);
     if (!$response->hasError()) {
         $resultArray = $response->getResult();
         $result = new InterfaceList();
         foreach ($resultArray as $array) {
             $result->append(InterfaceData::initArray($array));
         }
     }
     return $result;
 }