From f936b1cc9cc01248d78ea1a97ddff51c927a6c8f Mon Sep 17 00:00:00 2001 From: "Filip.Cieslik" Date: Fri, 17 Oct 2025 09:52:54 +0100 Subject: [PATCH 1/2] [AB#50522] we need to be able to apply filters to volumes on InstanceClient.php --- src/eCloud/InstanceClient.php | 53 +++++++---------------------------- 1 file changed, 10 insertions(+), 43 deletions(-) diff --git a/src/eCloud/InstanceClient.php b/src/eCloud/InstanceClient.php index 6037781d..f5af8374 100644 --- a/src/eCloud/InstanceClient.php +++ b/src/eCloud/InstanceClient.php @@ -2,6 +2,8 @@ namespace UKFast\SDK\eCloud; +use GuzzleHttp\Exception\GuzzleException; +use UKFast\SDK\eCloud\Entities\Volume; use UKFast\SDK\Entities\ClientEntityInterface; use UKFast\SDK\Exception\UKFastException; use UKFast\SDK\Traits\PageItems; @@ -82,51 +84,16 @@ public function getCredentials($id) /** * Get array of instance volumes - * @param $id - * @return mixed - * @throws \GuzzleHttp\Exception\GuzzleException + * @param string $id + * @param array $filters + * @return array + * @throws GuzzleException */ - public function getVolumes($id) + public function getVolumes($id, $filters = []) { - $page = $this->paginatedRequest( - $this->collectionPath . '/' . $id . '/volumes', - $currentPage = 1, - $perPage = 15 - ); - - if ($page->totalItems() == 0) { - return []; - } - - $volumeClient = new VolumeClient; - $page->serializeWith(function ($item) use ($volumeClient) { - return $volumeClient->loadEntity($item); - }); - - $items = $page->getItems(); - if ($page->totalPages() == 1) { - return $items; - } - - // get any remaining pages - while ($page->pageNumber() < $page->totalPages()) { - $page = $this->paginatedRequest( - $this->collectionPath . '/' . $id . '/volumes', - $currentPage++, - $perPage - ); - - $page->serializeWith(function ($item) use ($volumeClient) { - return $volumeClient->loadEntity($item); - }); - - $items = array_merge( - $items, - $page->getItems() - ); - } - - return $items; + return $this->getChildResources($id, 'volumes', function (array $data) { + return (new VolumeClient())->loadEntity($data); + }, $filters); } /** From 3fd0a06fdbf2a4967b518daa0e8a360a07acc989 Mon Sep 17 00:00:00 2001 From: "Filip.Cieslik" Date: Fri, 17 Oct 2025 12:29:34 +0100 Subject: [PATCH 2/2] [AB#50522] its an object --- src/eCloud/InstanceClient.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/eCloud/InstanceClient.php b/src/eCloud/InstanceClient.php index f5af8374..567c48ad 100644 --- a/src/eCloud/InstanceClient.php +++ b/src/eCloud/InstanceClient.php @@ -91,7 +91,7 @@ public function getCredentials($id) */ public function getVolumes($id, $filters = []) { - return $this->getChildResources($id, 'volumes', function (array $data) { + return $this->getChildResources($id, 'volumes', function ($data) { return (new VolumeClient())->loadEntity($data); }, $filters); }