|
| 1 | +<?php declare(strict_types=1); |
| 2 | + |
| 3 | +namespace OpenStack\Metric\v1\Gnocchi\Models; |
| 4 | + |
| 5 | +use OpenStack\Common\Resource\OperatorResource; |
| 6 | +use OpenStack\Common\Resource\Retrievable; |
| 7 | +use OpenStack\Metric\v1\Gnocchi\Api; |
| 8 | + |
| 9 | +/** |
| 10 | + * @property Api $api |
| 11 | + */ |
| 12 | +class Resource extends OperatorResource implements Retrievable |
| 13 | +{ |
| 14 | + const RESOURCE_TYPE_GENERIC = 'generic'; |
| 15 | + |
| 16 | + /** @var string */ |
| 17 | + public $createdByUserId; |
| 18 | + |
| 19 | + /** @var string */ |
| 20 | + public $startedAt; |
| 21 | + |
| 22 | + /** @var string */ |
| 23 | + public $displayName; |
| 24 | + |
| 25 | + /** @var string */ |
| 26 | + public $revisionEnd; |
| 27 | + |
| 28 | + /** @var string */ |
| 29 | + public $userId; |
| 30 | + |
| 31 | + /** @var string */ |
| 32 | + public $createdByProjectId; |
| 33 | + |
| 34 | + /** @var string */ |
| 35 | + public $id; |
| 36 | + |
| 37 | + /** @var array */ |
| 38 | + public $metrics; |
| 39 | + |
| 40 | + /** @var string */ |
| 41 | + public $host; |
| 42 | + |
| 43 | + /** @var string */ |
| 44 | + public $imageRef; |
| 45 | + |
| 46 | + /** @var string */ |
| 47 | + public $flavorId; |
| 48 | + |
| 49 | + /** @var string */ |
| 50 | + public $serverGroup; |
| 51 | + |
| 52 | + /** @var string */ |
| 53 | + public $originalResourceId; |
| 54 | + |
| 55 | + /** @var string */ |
| 56 | + public $revisionStart; |
| 57 | + |
| 58 | + /** @var string */ |
| 59 | + public $projectId; |
| 60 | + |
| 61 | + /** @var string */ |
| 62 | + public $type; |
| 63 | + |
| 64 | + /** @var string */ |
| 65 | + public $endedAt; |
| 66 | + |
| 67 | + protected $aliases = [ |
| 68 | + 'created_by_user_id' => 'createdByUserId', |
| 69 | + 'started_at' => 'startedAt', |
| 70 | + 'display_name' => 'displayName', |
| 71 | + 'revision_end' => 'revisionEnd', |
| 72 | + 'user_id' => 'userId', |
| 73 | + 'created_by_project_id' => 'createdByProjectId', |
| 74 | + 'image_ref' => 'imageRef', |
| 75 | + 'flavor_id' => 'flavorId', |
| 76 | + 'server_group' => 'serverGroup', |
| 77 | + 'original_resource_id' => 'originalResourceId', |
| 78 | + 'revision_start' => 'revisionStart', |
| 79 | + 'project_id' => 'projectId', |
| 80 | + 'ended_at' => 'endedAt', |
| 81 | + ]; |
| 82 | + |
| 83 | + public function retrieve() |
| 84 | + { |
| 85 | + $response = $this->execute($this->api->getResource(), ['type' => $this->type, 'id' => $this->id]); |
| 86 | + $this->populateFromResponse($response); |
| 87 | + } |
| 88 | + |
| 89 | + |
| 90 | + /** |
| 91 | + * @param string $metric |
| 92 | + * |
| 93 | + * @return Metric |
| 94 | + */ |
| 95 | + public function getMetric(string $metric): Metric |
| 96 | + { |
| 97 | + $response = $this->execute($this->api->getResourceMetric(), [ |
| 98 | + 'resourceId' => $this->id, |
| 99 | + 'metric' => $metric, |
| 100 | + 'type'=> $this->type |
| 101 | + ]); |
| 102 | + $metric = $this->model(Metric::class)->populateFromResponse($response); |
| 103 | + |
| 104 | + return $metric; |
| 105 | + } |
| 106 | + |
| 107 | + public function getMetricMeasures() |
| 108 | + { |
| 109 | + |
| 110 | + } |
| 111 | + |
| 112 | + /** |
| 113 | + * @param array $options {@see \OpenStack\Metric\v1\Gnocchi\Api::getResourceMetrics} |
| 114 | + * |
| 115 | + * @return \Generator |
| 116 | + */ |
| 117 | + public function listResourceMetrics(array $options = []): \Generator |
| 118 | + { |
| 119 | + $options['resourceId'] = $this->id; |
| 120 | + |
| 121 | + return $this->model(Metric::class)->enumerate($this->api->getResourceMetrics(), $options); |
| 122 | + } |
| 123 | +} |
| 124 | + |
| 125 | + |
0 commit comments