public function describeSecurityGroups(ListDataType $groupName = null, ListDataType $groupId = null, SecurityGroupFilterList $filter = null)
{
$result = null;
if ($groupName !== null) {
$options = $groupName->getQueryArrayBare('GroupName');
} else {
$options = array();
}
if ($groupId !== null) {
$options = array_merge($options, $groupId->getQueryArrayBare('GroupId'));
}
if ($filter !== null) {
$options = array_merge($options, $filter->getQueryArrayBare('Filter'));
}
$response = $this->client->call(ucfirst(__FUNCTION__), $options);
if ($response->getError() === false) {
$sxml = simplexml_load_string($response->getRawContent());
$response = null;
$result = new SecurityGroupList();
$result->setEc2($this->ec2)->setRequestId((string) $sxml->requestId);
if (!empty($sxml->securityGroupInfo->item)) {
foreach ($sxml->securityGroupInfo->item as $v) {
$sgid = (string) $v->groupId;
$item = $this->ec2->getEntityManagerEnabled() ? $this->ec2->securityGroup->get($sgid) : null;
if ($item === null) {
$item = new SecurityGroupData();
$item->setEc2($this->ec2);
$bAttach = true;
} else {
$item->resetObject();
$bAttach = false;
}
$item->ownerId = (string) $v->ownerId;
$item->groupId = (string) $v->groupId;
$item->groupName = $this->exist($v->groupName) ? (string) $v->groupName : null;
$item->groupDescription = $this->exist($v->groupDescription) ? (string) $v->groupDescription : null;
$item->vpcId = $this->exist($v->vpcId) ? (string) $v->vpcId : null;
$item->setIpPermissions($this->_loadIpPermissionList($v->ipPermissions))->setIpPermissionsEgress($this->_loadIpPermissionList($v->ipPermissionsEgress))->setTagSet($this->_loadResourceTagSetList($v->tagSet));
$result->append($item);
if ($bAttach && $this->ec2->getEntityManagerEnabled()) {
$this->getEntityManager()->attach($item);
}
unset($item);
}
}
}
return $result;
}