Skip to content

Commit eec8fb4

Browse files
authored
Merge pull request #254 from php-opencloud/updates
Minor Updates
2 parents 5230354 + c5cf03e commit eec8fb4

File tree

25 files changed

+358
-53
lines changed

25 files changed

+358
-53
lines changed

composer.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,15 @@
3434
},
3535
"require": {
3636
"php": "~7.0",
37-
"guzzlehttp/guzzle": "~6.1",
38-
"justinrainbow/json-schema": "~5.2"
37+
"guzzlehttp/guzzle": "^6.1",
38+
"justinrainbow/json-schema": "^5.2"
3939
},
4040
"require-dev": {
4141
"phpunit/phpunit": "^6.5",
4242
"psr/log": "^1.0",
43-
"satooshi/php-coveralls": "^2.0",
43+
"php-coveralls/php-coveralls": "^2.0",
4444
"jakub-onderka/php-parallel-lint": "^1.0",
45-
"friendsofphp/php-cs-fixer": "^2.9"
45+
"friendsofphp/php-cs-fixer": "^2.13"
4646
},
4747
"extra": {
4848
"branch-alias": {

src/BlockStorage/v2/Api.php

Lines changed: 51 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ public function postVolumes(): array
2929
'imageId' => $this->params->imageRef(),
3030
'volumeType' => $this->params->volumeType(),
3131
'metadata' => $this->params->metadata(),
32+
'projectId' => $this->params->projectId(),
3233
],
3334
];
3435
}
@@ -191,21 +192,21 @@ public function getSnapshots(): array
191192
'method' => 'GET',
192193
'path' => 'snapshots',
193194
'params' => [
194-
'marker' => $this->params->marker(),
195-
'limit' => $this->params->limit(),
196-
'sortDir' => $this->params->sortDir(),
197-
'sortKey' => $this->params->sortKey(),
195+
'marker' => $this->params->marker(),
196+
'limit' => $this->params->limit(),
197+
'sortDir' => $this->params->sortDir(),
198+
'sortKey' => $this->params->sortKey(),
199+
'allTenants' => $this->params->allTenants(),
198200
],
199201
];
200202
}
201203

202204
public function getSnapshotsDetail(): array
203205
{
204-
return [
205-
'method' => 'GET',
206-
'path' => 'snapshots/detail',
207-
'params' => [],
208-
];
206+
$api = $this->getSnapshots();
207+
$api['path'] .= '/detail';
208+
209+
return $api;
209210
}
210211

211212
public function getSnapshot(): array
@@ -304,4 +305,45 @@ public function putQuotaSet(): array
304305
],
305306
];
306307
}
308+
309+
public function postVolumeBootable(): array
310+
{
311+
return [
312+
'method' => 'POST',
313+
'path' => 'volumes/{id}/action',
314+
'jsonKey' => 'os-set_bootable',
315+
'params' => [
316+
'id' => $this->params->idPath(),
317+
'bootable' => $this->params->bootable(),
318+
],
319+
];
320+
}
321+
322+
public function postImageMetadata(): array
323+
{
324+
return [
325+
'method' => 'POST',
326+
'path' => 'volumes/{id}/action',
327+
'jsonKey' => 'os-set_image_metadata',
328+
'params' => [
329+
'id' => $this->params->idPath(),
330+
'metadata' => $this->params->metadata(),
331+
],
332+
];
333+
}
334+
335+
public function postResetStatus(): array
336+
{
337+
return [
338+
'method' => 'POST',
339+
'path' => 'volumes/{id}/action',
340+
'jsonKey' => 'os-reset_status',
341+
'params' => [
342+
'id' => $this->params->idPath(),
343+
'status' => $this->params->volumeStatus(),
344+
'migrationStatus' => $this->params->volumeMigrationStatus(),
345+
'attachStatus' => $this->params->volumeAttachStatus(),
346+
],
347+
];
348+
}
307349
}

src/BlockStorage/v2/Models/Snapshot.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,16 @@ class Snapshot extends OperatorResource implements Listable, Creatable, Updateab
4747
/** @var int */
4848
public $size;
4949

50+
/** @var string */
51+
public $projectId;
52+
5053
protected $resourceKey = 'snapshot';
5154
protected $resourcesKey = 'snapshots';
5255
protected $markerKey = 'id';
5356

5457
protected $aliases = [
55-
'volume_id' => 'volumeId',
58+
'volume_id' => 'volumeId',
59+
'os-extended-snapshot-attributes:project_id' => 'projectId',
5660
];
5761

5862
/**

src/BlockStorage/v2/Models/Volume.php

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ class Volume extends OperatorResource implements Creatable, Listable, Updateable
6262
/** @var string */
6363
public $host;
6464

65+
/** @var string */
66+
public $bootable;
67+
6568
/** @var array */
6669
public $metadata = [];
6770

@@ -156,4 +159,41 @@ public function parseMetadata(ResponseInterface $response): array
156159

157160
return isset($json['metadata']) ? $json['metadata'] : [];
158161
}
162+
163+
/**
164+
* Update the bootable status for a volume, mark it as a bootable volume.
165+
*
166+
* @param bool $bootable
167+
*/
168+
public function setBootable(bool $bootable = true)
169+
{
170+
$this->execute($this->api->postVolumeBootable(), ['id' => $this->id, 'bootable' => $bootable]);
171+
}
172+
173+
/**
174+
* Sets the image metadata for a volume.
175+
*
176+
* @param array $metadata
177+
*/
178+
public function setImageMetadata(array $metadata)
179+
{
180+
$this->execute($this->api->postImageMetadata(), ['id' => $this->id, 'metadata' => $metadata]);
181+
}
182+
183+
/**
184+
* Administrator only. Resets the status, attach status, and migration status for a volume. Specify the os-reset_status action in the request body.
185+
*
186+
* @param array $options
187+
*
188+
* $options['status'] = (string) The volume status.
189+
* $options['migrationStatus'] = (string) The volume migration status.
190+
* $options['attachStatus'] = (string) The volume attach status. [OPTIONAL]
191+
*
192+
* @see https://developer.openstack.org/api-ref/block-storage/v2/index.html#volume-actions-volumes-action
193+
*/
194+
public function resetStatus(array $options)
195+
{
196+
$options = array_merge($options, ['id' => $this->id]);
197+
$this->execute($this->api->postResetStatus(), $options);
198+
}
159199
}

src/BlockStorage/v2/Params.php

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,47 @@ public function volumeType(): array
8080
];
8181
}
8282

83+
public function bootable(): array
84+
{
85+
return [
86+
'type' => self::BOOL_TYPE,
87+
'location' => self::JSON,
88+
'description' => 'Enables or disables the bootable attribute. You can boot an instance from a bootable volume.',
89+
];
90+
}
91+
92+
public function volumeStatus(): array
93+
{
94+
return [
95+
'type' => self::STRING_TYPE,
96+
'location' => self::JSON,
97+
'required' => true,
98+
'description' => 'The volume status.',
99+
];
100+
}
101+
102+
public function volumeMigrationStatus(): array
103+
{
104+
return [
105+
'type' => self::STRING_TYPE,
106+
'location' => self::JSON,
107+
'required' => false,
108+
'description' => 'The volume migration status.',
109+
'sentAs' => 'migration_status',
110+
];
111+
}
112+
113+
public function volumeAttachStatus(): array
114+
{
115+
return [
116+
'type' => self::STRING_TYPE,
117+
'location' => self::JSON,
118+
'required' => false,
119+
'description' => 'The volume attach status.',
120+
'sentAs' => 'attach_status',
121+
];
122+
}
123+
83124
public function metadata(): array
84125
{
85126
return [
@@ -226,4 +267,14 @@ public function quotaSetVolumesIscsi(): array
226267
{
227268
return $this->quotaSetLimit('volumes_iscsi', 'The number of allowed volumes iscsi');
228269
}
270+
271+
public function projectId(): array
272+
{
273+
return [
274+
'type' => self::STRING_TYPE,
275+
'location' => self::URL,
276+
'sentAs' => 'project_id',
277+
'description' => 'The UUID of the project in a multi-tenancy cloud.',
278+
];
279+
}
229280
}

src/Compute/v2/Api.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -667,6 +667,8 @@ public function postKeypair(): array
667667
'params' => [
668668
'name' => $this->isRequired($this->params->name('keypair')),
669669
'publicKey' => $this->params->keypairPublicKey(),
670+
'type' => $this->params->keypairType(),
671+
'userId' => $this->params->keypairUserId(),
670672
],
671673
];
672674
}

src/Compute/v2/Models/Keypair.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ class Keypair extends OperatorResource implements Listable, Retrievable, Deletab
3737
/** @var string */
3838
public $userId;
3939

40+
/** @var string */
41+
public $type;
42+
4043
/** @var string */
4144
public $id;
4245

@@ -47,6 +50,7 @@ class Keypair extends OperatorResource implements Listable, Retrievable, Deletab
4750
'public_key' => 'publicKey',
4851
'private_key' => 'privateKey',
4952
'user_id' => 'userId',
53+
'type' => 'type',
5054
];
5155

5256
protected $resourceKey = 'keypair';

src/Compute/v2/Params.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,25 @@ public function userId(): array
475475
];
476476
}
477477

478+
public function keypairUserId(): array
479+
{
480+
return [
481+
'type' => self::STRING_TYPE,
482+
'sentAs' => 'user_id',
483+
'location' => self::JSON,
484+
'description' => 'This allows administrative users to upload keys for other users than themselves. Requires micro version 2.10.',
485+
];
486+
}
487+
488+
public function keypairType(): array
489+
{
490+
return [
491+
'type' => self::STRING_TYPE,
492+
'location' => self::JSON,
493+
'description' => 'The type of the keypair. Allowed values are ssh or x509. Require micro version 2.2.',
494+
];
495+
}
496+
478497
public function flavorRam(): array
479498
{
480499
return [

src/Networking/v2/Api.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,10 @@ public function getNetworks(): array
3535
'method' => 'GET',
3636
'path' => $this->pathPrefix.'/networks',
3737
'params' => [
38-
'name' => $this->params->queryName(),
39-
'tenantId' => $this->params->queryTenantId(),
40-
'status' => $this->params->queryStatus(),
38+
'name' => $this->params->queryName(),
39+
'tenantId' => $this->params->queryTenantId(),
40+
'status' => $this->params->queryStatus(),
41+
'routerExternal' => $this->params->queryRouterExternal(),
4142
],
4243
];
4344
}
@@ -201,7 +202,7 @@ public function getPorts(): array
201202
'displayName' => $this->params->displayNameQuery(),
202203
'adminState' => $this->params->adminStateQuery(),
203204
'networkId' => $this->notRequired($this->params->networkId()),
204-
'tenantId' => $this->params->tenantId(),
205+
'tenantId' => $this->params->tenantIdQuery(),
205206
'deviceOwner' => $this->params->deviceOwnerQuery(),
206207
'macAddress' => $this->params->macAddrQuery(),
207208
'portId' => $this->params->portIdQuery(),
@@ -230,6 +231,7 @@ public function postSinglePort(): array
230231
'allowedAddressPairs' => $this->params->allowedAddrPairs(),
231232
'deviceOwner' => $this->params->deviceOwner(),
232233
'deviceId' => $this->params->deviceId(),
234+
'portSecurityEnabled' => $this->params->portSecurityEnabled(),
233235
],
234236
];
235237
}

src/Networking/v2/Extensions/Layer3/Models/FixedIp.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ class FixedIp extends AbstractResource
1313
public $ip;
1414

1515
protected $aliases = [
16-
'subnet_id' => 'subnetId',
16+
'subnet_id' => 'subnetId',
17+
'ip_address' => 'ip',
1718
];
1819
}

0 commit comments

Comments
 (0)