Skip to content

Commit ce6ab21

Browse files
committed
Fixed code review. Added php docblock
1 parent 1e20134 commit ce6ab21

File tree

5 files changed

+54
-9
lines changed

5 files changed

+54
-9
lines changed

src/Metric/v1/Gnocchi/Api.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ public function getResource(): array
3333
'path' => $this->pathPrefix.'/resource/{type}/{id}',
3434
'method' => 'GET',
3535
'params' => [
36-
'id' => $this->params->idUrl('resource'),
36+
'id' => $this->params->idUrl('resource'),
37+
'type' => $this->params->resourceType(),
3738
],
3839
];
3940
}

src/Metric/v1/Gnocchi/Models/Resource.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ public function retrieve()
8686
$this->populateFromResponse($response);
8787
}
8888

89-
9089
/**
9190
* @param string $metric
9291
*

src/Metric/v1/Gnocchi/Models/ResourceType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php declare(strict_types=1);
22

3-
namespace OpenStack\Metric\v1\Gnocchi;
3+
namespace OpenStack\Metric\v1\Gnocchi\Models;
44

55
use OpenStack\Common\Resource\OperatorResource;
66

src/Metric/v1/Gnocchi/Params.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function headerContentType(): array
4545
];
4646
}
4747

48-
public function idUrl($type)
48+
public function idUrl($type): array
4949
{
5050
return [
5151
'required' => true,
@@ -54,7 +54,7 @@ public function idUrl($type)
5454
];
5555
}
5656

57-
public function granularity()
57+
public function granularity(): array
5858
{
5959
return [
6060
'location' => self::QUERY,
@@ -63,7 +63,7 @@ public function granularity()
6363
];
6464
}
6565

66-
public function aggregation()
66+
public function aggregation(): array
6767
{
6868
return [
6969
'location' => self::QUERY,

src/Metric/v1/Gnocchi/Service.php

Lines changed: 48 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,23 @@
1616
*/
1717
class Service extends AbstractService
1818
{
19+
/**
20+
* Retrieves a collection of \OpenStack\Metric\v1\Gnocchi\Models\ResourceType type in a generator format.
21+
*
22+
* @return \Generator
23+
*/
1924
public function listResourceTypes(): \Generator
2025
{
2126
return $this->model(ResourceType::class)->enumerate($this->api->getResourceTypes(), []);
2227
}
2328

29+
/**
30+
* Retrieves a collection of \OpenStack\Metric\v1\Gnocchi\Models\Resource type in a generator format.
31+
*
32+
* @param array $options {@see \OpenStack\Metric\v1\Gnocchi\Api::getResources}
33+
*
34+
* @return \Generator
35+
*/
2436
public function listResources(array $options = []): \Generator
2537
{
2638
$this->injectGenericType($options);
@@ -29,20 +41,31 @@ public function listResources(array $options = []): \Generator
2941
}
3042

3143
/**
44+
* Retrieves a Resource object and populates its unique identifier object. This operation will not perform a GET or
45+
* HEAD request by default; you will need to call retrieve() if you want to pull in remote state from the API.
46+
*
3247
* @param array $options
3348
*
34-
* @return \OpenStack\Metric\v1\Gnocchi\Models\Resource
49+
* @return Resource
3550
*/
36-
public function getResource(array $options = []): \OpenStack\Metric\v1\Gnocchi\Models\Resource
51+
public function getResource(array $options = []): Resource
3752
{
3853
$this->injectGenericType($options);
3954

55+
/** @var Resource $resource */
4056
$resource = $this->model(Resource::class);
4157
$resource->populateFromArray($options);
4258

4359
return $resource;
4460
}
4561

62+
/**
63+
* Retrieves a collection of \OpenStack\Metric\v1\Gnocchi\Models\Resource type in a generator format.
64+
*
65+
* @param array $options {@see \OpenStack\Metric\v1\Gnocchi\Api::searchResources}
66+
*
67+
* @return \Generator
68+
*/
4669
public function searchResources(array $options = []): \Generator
4770
{
4871
$this->injectGenericType($options);
@@ -64,19 +87,41 @@ public function searchResources(array $options = []): \Generator
6487
return $this->model(Resource::class)->enumerate($this->api->searchResources(), $options);
6588
}
6689

67-
public function getMetric($id): Metric
90+
/**
91+
* Retrieves a Metric object and populates its unique identifier object. This operation will not perform a GET or
92+
* HEAD request by default; you will need to call retrieve() if you want to pull in remote state from the API.
93+
*
94+
* @param string $id
95+
*
96+
* @return Metric
97+
*/
98+
public function getMetric(string $id): Metric
6899
{
100+
/** @var Metric $metric */
69101
$metric = $this->model(Metric::class);
70102
$metric->populateFromArray(['id' => $id]);
71103

72104
return $metric;
73105
}
74106

107+
/**
108+
* Retrieves a collection of Metric type in a generator format.
109+
*
110+
* @param array $options {@see \OpenStack\Metric\v1\Gnocchi\Api::getMetrics}
111+
*
112+
* @return \Generator
113+
*/
75114
public function listMetrics(array $options = []): \Generator
76115
{
77116
return $this->model(Metric::class)->enumerate($this->api->getMetrics(), $options);
78117
}
79118

119+
/**
120+
* If options does not have type, this will inject $options['type'] = 'generic'
121+
*
122+
* @internal
123+
* @param array $options
124+
*/
80125
private function injectGenericType(array &$options)
81126
{
82127
if (empty($options) || !isset($options['type'])) {

0 commit comments

Comments
 (0)