Example #1
0
 /**
  * Lists default security rules in a resource group.
  *
  * @param string $subscriptionId     Subscription Id
  * @param string $resourceGroupName  Name of Resource Group
  * @param string $securityGroupName  Name of Security Group
  *
  * @return SecurityRuleList Object with response
  */
 public function getDefaultList($subscriptionId, $resourceGroupName, $securityGroupName)
 {
     $result = null;
     $path = '/subscriptions/' . $subscriptionId . '/resourceGroups/' . $resourceGroupName . NetworkService::ENDPOINT_MICROSOFT_NETWORK . '/networkSecurityGroups/' . $securityGroupName . '/defaultSecurityRules';
     $request = $this->getClient()->prepareRequest($path, 'GET', $this->getApiVersion());
     $response = $this->getClient()->call($request);
     if (!$response->hasError()) {
         $resultArray = $response->getResult();
         $result = new SecurityRuleList();
         foreach ($resultArray as $array) {
             $result->append(SecurityRuleData::initArray($array));
         }
     }
     return $result;
 }
Example #2
0
 /**
  * Gets Security Rules list
  *
  * @param   array|SecurityRuleList $securityRules
  * @return  SecurityRuleList
  */
 private function getRuleList($securityRules)
 {
     if (!$securityRules instanceof SecurityRuleList) {
         $securityRuleList = new SecurityRuleList();
         foreach ($securityRules as $securityRule) {
             if (!$securityRule instanceof SecurityRuleData) {
                 $securityRuleData = SecurityRuleData::initArray($securityRule);
             } else {
                 $securityRuleData = $securityRule;
             }
             $securityRuleList->append($securityRuleData);
         }
     } else {
         $securityRuleList = $securityRules;
     }
     return $securityRuleList;
 }