Skip to content

Commit 2a83417

Browse files
committed
Allow fetching flavors’ details
1 parent c2bafcf commit 2a83417

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

src/Compute/v2/Api.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function getFlavors(): array
4242

4343
public function getFlavorsDetail(): array
4444
{
45-
$op = $this->getAll();
45+
$op = $this->getFlavors();
4646
$op['path'] .= '/detail';
4747
return $op;
4848
}
@@ -103,7 +103,7 @@ public function getImages(): array
103103

104104
public function getImagesDetail(): array
105105
{
106-
$op = $this->getAll();
106+
$op = $this->getImages();
107107
$op['path'] .= '/detail';
108108
return $op;
109109
}

src/Compute/v2/Service.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,16 @@ public function getServer(array $options = []): Server
7070
/**
7171
* List flavors.
7272
*
73-
* @param array $options {@see \OpenStack\Compute\v2\Api::getFlavors}
74-
* @param callable $mapFn A callable function that will be invoked on every iteration of the list.
73+
* @param array $options {@see \OpenStack\Compute\v2\Api::getFlavors}
74+
* @param callable $mapFn A callable function that will be invoked on every iteration of the list.
75+
* @param bool $detailed Set to true to fetch flavors' details.
7576
*
7677
* @return \Generator
7778
*/
78-
public function listFlavors(array $options = [], callable $mapFn = null): \Generator
79+
public function listFlavors(array $options = [], callable $mapFn = null, bool $detailed = false): \Generator
7980
{
80-
return $this->model(Flavor::class)->enumerate($this->api->getFlavors(), $options, $mapFn);
81+
$def = $detailed === true ? $this->api->getFlavorsDetail() : $this->api->getFlavors();
82+
return $this->model(Flavor::class)->enumerate($def, $options, $mapFn);
8183
}
8284

8385
/**

0 commit comments

Comments
 (0)