public function describeKeyPairs(ListDataType $keyNameList = null, array $filter = null)
{
//Filter parameter is excluded here and can be added in the future version of method.
$result = null;
$options = array();
if ($keyNameList !== null) {
$options = array_merge($options, $keyNameList->getQueryArrayBare('KeyName'));
}
if (!empty($filter)) {
//Here we use list from another data set just to avoid duplicates.
$arr = array();
foreach ($filter as $k => $v) {
array_push($arr, array('name' => new KeyPairFilterNameType((string) $k), 'value' => (string) $v));
}
$flt = new KeyPairFilterList($arr);
$options = array_merge($options, $flt->getQueryArrayBare('Filter'));
}
$response = $this->client->call(ucfirst(__FUNCTION__), $options);
if ($response->getError() === false) {
$sxml = simplexml_load_string($response->getRawContent());
$response = null;
$result = new KeyPairList();
$result->setEc2($this->ec2);
$result->setRequestId($sxml->requestId);
if (isset($sxml->keySet->item)) {
foreach ($sxml->keySet->item as $v) {
$item = new KeyPairData();
$item->setEc2($this->ec2);
$item->keyName = (string) $v->keyName;
$item->keyFingerprint = (string) $v->keyFingerprint;
$result->append($item);
unset($item);
}
}
}
return $result;
}