Skip to content

Commit b1f3d8a

Browse files
authored
Merge 4a46676 into 705e6da
2 parents 705e6da + 4a46676 commit b1f3d8a

File tree

5 files changed

+211
-1
lines changed

5 files changed

+211
-1
lines changed

src/BlockStorage/v2/Api.php

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,4 +254,48 @@ public function putSnapshotMetadata(): array
254254
],
255255
];
256256
}
257+
258+
public function getQuotaSet(): array
259+
{
260+
return [
261+
'method' => 'GET',
262+
'path' => 'os-quota-sets/{tenantId}',
263+
'params' => [
264+
'tenantId' => $this->params->idPath('quota-sets')
265+
]
266+
];
267+
}
268+
269+
public function deleteQuotaSet(): array
270+
{
271+
return [
272+
'method' => 'DELETE',
273+
'path' => 'os-quota-sets/{tenantId}',
274+
'jsonKey' => 'quota_set',
275+
'params' => [
276+
'tenantId' => $this->params->idPath('quota-sets')
277+
]
278+
];
279+
}
280+
281+
public function putQuotaSet(): array
282+
{
283+
return [
284+
'method' => 'PUT',
285+
'path' => 'os-quota-sets/{tenantId}',
286+
'jsonKey' => 'quota_set',
287+
'params' => [
288+
'tenantId' => $this->params->idPath(),
289+
'backupGigabytes' => $this->params->quotaSetBackupGigabytes(),
290+
'backups' => $this->params->quotaSetBackups(),
291+
'gigabytes' => $this->params->quotaSetGigabytes(),
292+
'gigabytesIscsi' => $this->params->quotaSetGigabytesIscsi(),
293+
'perVolumeGigabytes' => $this->params->quotaSetPerVolumeGigabytes(),
294+
'snapshots' => $this->params->quotaSetSnapshots(),
295+
'snapshotsIscsi' => $this->params->quotaSetSnapshotsIscsi(),
296+
'volumes' => $this->params->quotaSetVolumes(),
297+
'volumesIscsi' => $this->params->quotaSetVolumesIscsi(),
298+
]
299+
];
300+
}
257301
}
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace OpenStack\BlockStorage\v2\Models;
4+
5+
use OpenStack\Common\Resource\Deletable;
6+
use OpenStack\Common\Resource\OperatorResource;
7+
use OpenStack\Common\Resource\Retrievable;
8+
use OpenStack\Common\Resource\Updateable;
9+
10+
/**
11+
* Represents a BlockStorage v2 Quota Set
12+
*
13+
* @property \OpenStack\BlockStorage\v2\Api $api
14+
*/
15+
class QuotaSet extends OperatorResource implements Retrievable, Updateable, Deletable
16+
{
17+
/** @var string */
18+
public $tenantId;
19+
20+
/** @var int */
21+
public $backupGigabytes;
22+
23+
/** @var int */
24+
public $backups;
25+
26+
/** @var int */
27+
public $gigabytes;
28+
29+
/** @var int */
30+
public $gigabytesIscsi;
31+
32+
/** @var int */
33+
public $perVolumeGigabytes;
34+
35+
/** @var int */
36+
public $snapshots;
37+
38+
/** @var int */
39+
public $snapshotsIscsi;
40+
41+
/** @var int */
42+
public $volumes;
43+
44+
/** @var int */
45+
public $volumesIscsi;
46+
47+
protected $aliases = [
48+
'backup_gigabytes' => 'backupGigabytes',
49+
'gigabytes' => 'gigabytes',
50+
'gigabytes_iscsi' => 'gigabytesIscsi',
51+
'per_volume_gigabytes' => 'perVolumeGigabytes',
52+
'snapshots_iscsi' => 'snapshotsIscsi',
53+
'volumes_iscsi' => 'volumesIscsi',
54+
'id' => 'tenantId'
55+
];
56+
57+
protected $resourceKey = 'quota_set';
58+
59+
/**
60+
* @inheritdoc
61+
*/
62+
public function retrieve()
63+
{
64+
$response = $this->execute($this->api->getQuotaSet(), ['tenantId' => (string)$this->tenantId]);
65+
$this->populateFromResponse($response);
66+
}
67+
68+
/**
69+
* @inheritdoc
70+
*/
71+
public function update()
72+
{
73+
$response = $this->executeWithState($this->api->putQuotaSet());
74+
$this->populateFromResponse($response);
75+
}
76+
77+
/**
78+
* @inheritdoc
79+
*/
80+
public function delete()
81+
{
82+
$response = $this->executeWithState($this->api->deleteQuotaSet());
83+
$this->populateFromResponse($response);
84+
}
85+
}

src/BlockStorage/v2/Params.php

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,4 +159,69 @@ public function snapshotName(): array
159159
'location' => self::JSON,
160160
];
161161
}
162+
163+
protected function quotaSetLimit($sentAs, $description): array
164+
{
165+
return [
166+
'type' => self::INT_TYPE,
167+
'location' => self::JSON,
168+
'sentAs' => $sentAs,
169+
'description' => $description,
170+
];
171+
}
172+
173+
public function quotaSetLimitInstances(): array
174+
{
175+
return $this->quotaSetLimit('instances', 'The number of allowed instances for each tenant.');
176+
}
177+
178+
public function quotaSetBackupGigabytes(): array
179+
{
180+
return $this->quotaSetLimit('backup_gigabytes', 'Total size of back-up storage (GiB)');
181+
}
182+
183+
public function quotaSetBackups(): array
184+
{
185+
return $this->quotaSetLimit('backups', 'The number of allowed back-ups');
186+
}
187+
188+
public function quotaSetGigabytes(): array
189+
{
190+
return $this->quotaSetLimit('gigabytes', 'Total Size of Volumes and Snapshots (GiB)');
191+
}
192+
193+
public function quotaSetGigabytesIscsi(): array
194+
{
195+
return $this->quotaSetLimit('gigabytes_iscsi', 'Total Size of Volumes and Snapshots iscsi (GiB)');
196+
}
197+
198+
public function quotaSetTenantId(): array
199+
{
200+
return $this->quotaSetLimit('id', 'Tenant Id');
201+
}
202+
203+
public function quotaSetPerVolumeGigabytes(): array
204+
{
205+
return $this->quotaSetLimit('per_volume_gigabytes', 'Allowed size per Volume (GiB)');
206+
}
207+
208+
public function quotaSetSnapshots(): array
209+
{
210+
return $this->quotaSetLimit('snapshots', 'The number of allowed snapshots');
211+
}
212+
213+
public function quotaSetSnapshotsIscsi(): array
214+
{
215+
return $this->quotaSetLimit('snapshots_iscsi', 'The number of allowed snapshots iscsi');
216+
}
217+
218+
public function quotaSetVolumes(): array
219+
{
220+
return $this->quotaSetLimit('volumes', 'The number of allowed volumes');
221+
}
222+
223+
public function quotaSetVolumesIscsi(): array
224+
{
225+
return $this->quotaSetLimit('volumes_iscsi', 'The number of allowed volumes iscsi');
226+
}
162227
}

src/BlockStorage/v2/Service.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace OpenStack\BlockStorage\v2;
44

5+
use OpenStack\BlockStorage\v2\Models\QuotaSet;
56
use OpenStack\BlockStorage\v2\Models\Snapshot;
67
use OpenStack\BlockStorage\v2\Models\Volume;
78
use OpenStack\BlockStorage\v2\Models\VolumeType;
@@ -111,4 +112,19 @@ public function getSnapshot(string $snapshotId): Snapshot
111112
$snapshot->populateFromArray(['id' => $snapshotId]);
112113
return $snapshot;
113114
}
115+
116+
/**
117+
* Shows A Quota for a tenant
118+
*
119+
* @param string $tenantId
120+
*
121+
* @return QuotaSet
122+
*/
123+
public function getQuotaSet(string $tenantId): QuotaSet
124+
{
125+
$quotaSet = $this->model(QuotaSet::class);
126+
$quotaSet->populateFromResponse($this->execute($this->api->getQuotaSet(), ['tenantId' => $tenantId]));
127+
128+
return $quotaSet;
129+
}
114130
}

src/Networking/v2/Params.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ public function enableDhcp(): array
119119
public function dnsNameservers(): array
120120
{
121121
return [
122-
'type' => self::STRING_TYPE,
122+
'type' => self::ARRAY_TYPE,
123123
'sentAs' => 'dns_nameservers',
124124
'description' => 'A list of DNS name servers for the subnet.',
125125
];

0 commit comments

Comments
 (0)