Skip to content

Commit 9e4cf83

Browse files
authored
Merge pull request #476 from ecloud-jay2/5145-add-type-to-ip-addresses
added nics list for ip addresses
2 parents f33da3b + b3c5820 commit 9e4cf83

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

src/eCloud/IpAddressesClient.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,35 @@ public function loadEntity($data)
2424
$this->apiToFriendly($data, $this->getEntityMap())
2525
);
2626
}
27+
28+
public function getNics($id)
29+
{
30+
$page = $this->paginatedRequest(
31+
$this->collectionPath . '/' . $id . '/nics',
32+
$currentPage = 1,
33+
$perPage = 15
34+
);
35+
if ($page->totalItems() == 0) {
36+
return [];
37+
}
38+
$nicClient = new NicClient();
39+
$page->serializeWith(function ($item) use ($nicClient) {
40+
return $nicClient->loadEntity($item);
41+
});
42+
$items = $page->getItems();
43+
if ($page->totalPages() == 1) {
44+
return $items;
45+
}
46+
while ($page->pageNumber() < $page->totalPages()) {
47+
$page = $this->getPage($page->pageNumber() + 1, $perPage);
48+
$page->serializeWith(function ($item) use ($nicClient) {
49+
return $nicClient->loadEntity($item);
50+
});
51+
$items = array_merge(
52+
$items,
53+
$page->getItems()
54+
);
55+
}
56+
return $items;
57+
}
2758
}

0 commit comments

Comments
 (0)