Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions .php_cs.dist
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
<?php

if (!file_exists(__DIR__.'/src')) {
exit(0);
}

return PhpCsFixer\Config::create()
->setRules(
[
'@PSR2' => true,
'array_syntax' => ['syntax' => 'short'],
'protected_to_private' => false
'@PSR2' => true,
'@Symfony' => true,
'array_syntax' => ['syntax' => 'short'],
'binary_operator_spaces' => ['default' => 'align'],
'protected_to_private' => false,
]
)
->setUsingCache(false)
Expand Down
50 changes: 26 additions & 24 deletions src/BlockStorage/v2/Api.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace OpenStack\BlockStorage\v2;

Expand All @@ -8,7 +10,7 @@ class Api extends AbstractApi
{
public function __construct()
{
$this->params = new Params;
$this->params = new Params();
}

public function postVolumes(): array
Expand Down Expand Up @@ -37,9 +39,9 @@ public function getVolumes(): array
'method' => 'GET',
'path' => 'volumes',
'params' => [
'limit' => $this->params->limit(),
'marker' => $this->params->marker(),
'sort' => $this->params->sort(),
'limit' => $this->params->limit(),
'marker' => $this->params->marker(),
'sort' => $this->params->sort(),
'allTenants' => $this->params->allTenants(),
],
];
Expand All @@ -62,11 +64,11 @@ public function getVolumesDetail(): array
public function getVolume(): array
{
return [
'method' => 'GET',
'path' => 'volumes/{id}',
'params' => [
'id' => $this->params->idPath()
]
'method' => 'GET',
'path' => 'volumes/{id}',
'params' => [
'id' => $this->params->idPath(),
],
];
}

Expand Down Expand Up @@ -139,10 +141,10 @@ public function postTypes(): array
public function putType(): array
{
return [
'method' => 'PUT',
'path' => 'types/{id}',
'method' => 'PUT',
'path' => 'types/{id}',
'jsonKey' => 'volume_type',
'params' => [
'params' => [
'id' => $this->params->idPath(),
'name' => $this->params->name('volume type'),
'specs' => $this->params->typeSpecs(),
Expand Down Expand Up @@ -171,10 +173,10 @@ public function deleteType(): array
public function postSnapshots(): array
{
return [
'method' => 'POST',
'path' => 'snapshots',
'method' => 'POST',
'path' => 'snapshots',
'jsonKey' => 'snapshot',
'params' => [
'params' => [
'volumeId' => $this->params->volId(),
'force' => $this->params->force(),
'name' => $this->params->snapshotName(),
Expand Down Expand Up @@ -218,10 +220,10 @@ public function getSnapshot(): array
public function putSnapshot(): array
{
return [
'method' => 'PUT',
'path' => 'snapshots/{id}',
'method' => 'PUT',
'path' => 'snapshots/{id}',
'jsonKey' => 'snapshot',
'params' => [
'params' => [
'id' => $this->params->idPath(),
'name' => $this->params->snapshotName(),
'description' => $this->params->desc(),
Expand Down Expand Up @@ -265,8 +267,8 @@ public function getQuotaSet(): array
'method' => 'GET',
'path' => 'os-quota-sets/{tenantId}',
'params' => [
'tenantId' => $this->params->idPath('quota-sets')
]
'tenantId' => $this->params->idPath('quota-sets'),
],
];
}

Expand All @@ -277,8 +279,8 @@ public function deleteQuotaSet(): array
'path' => 'os-quota-sets/{tenantId}',
'jsonKey' => 'quota_set',
'params' => [
'tenantId' => $this->params->idPath('quota-sets')
]
'tenantId' => $this->params->idPath('quota-sets'),
],
];
}

Expand All @@ -299,7 +301,7 @@ public function putQuotaSet(): array
'snapshotsIscsi' => $this->params->quotaSetSnapshotsIscsi(),
'volumes' => $this->params->quotaSetVolumes(),
'volumesIscsi' => $this->params->quotaSetVolumesIscsi(),
]
],
];
}
}
16 changes: 9 additions & 7 deletions src/BlockStorage/v2/Models/QuotaSet.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace OpenStack\BlockStorage\v2\Models;

Expand All @@ -8,7 +10,7 @@
use OpenStack\Common\Resource\Updateable;

/**
* Represents a BlockStorage v2 Quota Set
* Represents a BlockStorage v2 Quota Set.
*
* @property \OpenStack\BlockStorage\v2\Api $api
*/
Expand Down Expand Up @@ -51,22 +53,22 @@ class QuotaSet extends OperatorResource implements Retrievable, Updateable, Dele
'per_volume_gigabytes' => 'perVolumeGigabytes',
'snapshots_iscsi' => 'snapshotsIscsi',
'volumes_iscsi' => 'volumesIscsi',
'id' => 'tenantId'
'id' => 'tenantId',
];

protected $resourceKey = 'quota_set';

/**
* @inheritdoc
* {@inheritdoc}
*/
public function retrieve()
{
$response = $this->execute($this->api->getQuotaSet(), ['tenantId' => (string)$this->tenantId]);
$response = $this->execute($this->api->getQuotaSet(), ['tenantId' => (string) $this->tenantId]);
$this->populateFromResponse($response);
}

/**
* @inheritdoc
* {@inheritdoc}
*/
public function update()
{
Expand All @@ -75,7 +77,7 @@ public function update()
}

/**
* @inheritdoc
* {@inheritdoc}
*/
public function delete()
{
Expand Down
20 changes: 13 additions & 7 deletions src/BlockStorage/v2/Models/Snapshot.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace OpenStack\BlockStorage\v2\Models;

Expand Down Expand Up @@ -45,28 +47,29 @@ class Snapshot extends OperatorResource implements Listable, Creatable, Updateab
/** @var int */
public $size;

protected $resourceKey = 'snapshot';
protected $resourceKey = 'snapshot';
protected $resourcesKey = 'snapshots';
protected $markerKey = 'id';
protected $markerKey = 'id';

protected $aliases = [
'volume_id' => 'volumeId',
'volume_id' => 'volumeId',
];

/**
* @inheritdoc
* {@inheritdoc}
*/
protected function getAliases(): array
{
return parent::getAliases() + [
'created_at' => new Alias('createdAt', \DateTimeImmutable::class)
'created_at' => new Alias('createdAt', \DateTimeImmutable::class),
];
}

public function populateFromResponse(ResponseInterface $response): self
{
parent::populateFromResponse($response);
$this->metadata = $this->parseMetadata($response);

return $this;
}

Expand All @@ -84,6 +87,7 @@ public function retrieve()
public function create(array $userOptions): Creatable
{
$response = $this->execute($this->api->postSnapshots(), $userOptions);

return $this->populateFromResponse($response);
}

Expand All @@ -99,8 +103,9 @@ public function delete()

public function getMetadata(): array
{
$response = $this->executeWithState($this->api->getSnapshotMetadata());
$response = $this->executeWithState($this->api->getSnapshotMetadata());
$this->metadata = $this->parseMetadata($response);

return $this->metadata;
}

Expand All @@ -120,6 +125,7 @@ public function resetMetadata(array $metadata)
public function parseMetadata(ResponseInterface $response): array
{
$json = Utils::jsonDecode($response);

return isset($json['metadata']) ? $json['metadata'] : [];
}
}
19 changes: 13 additions & 6 deletions src/BlockStorage/v2/Models/Volume.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace OpenStack\BlockStorage\v2\Models;

use OpenStack\Common\Resource\Alias;
Expand Down Expand Up @@ -65,9 +68,9 @@ class Volume extends OperatorResource implements Creatable, Listable, Updateable
/** @var array */
public $volumeImageMetadata = [];

protected $resourceKey = 'volume';
protected $resourceKey = 'volume';
protected $resourcesKey = 'volumes';
protected $markerKey = 'id';
protected $markerKey = 'id';

protected $aliases = [
'availability_zone' => 'availabilityZone',
Expand All @@ -80,19 +83,20 @@ class Volume extends OperatorResource implements Creatable, Listable, Updateable
];

/**
* @inheritdoc
* {@inheritdoc}
*/
protected function getAliases(): array
{
return parent::getAliases() + [
'created_at' => new Alias('createdAt', \DateTimeImmutable::class)
'created_at' => new Alias('createdAt', \DateTimeImmutable::class),
];
}

public function populateFromResponse(ResponseInterface $response): self
{
parent::populateFromResponse($response);
$this->metadata = $this->parseMetadata($response);

return $this;
}

Expand All @@ -110,6 +114,7 @@ public function retrieve()
public function create(array $userOptions): Creatable
{
$response = $this->execute($this->api->postVolumes(), $userOptions);

return $this->populateFromResponse($response);
}

Expand All @@ -126,8 +131,9 @@ public function delete()

public function getMetadata(): array
{
$response = $this->executeWithState($this->api->getVolumeMetadata());
$response = $this->executeWithState($this->api->getVolumeMetadata());
$this->metadata = $this->parseMetadata($response);

return $this->metadata;
}

Expand All @@ -147,6 +153,7 @@ public function resetMetadata(array $metadata)
public function parseMetadata(ResponseInterface $response): array
{
$json = Utils::jsonDecode($response);

return isset($json['metadata']) ? $json['metadata'] : [];
}
}
7 changes: 5 additions & 2 deletions src/BlockStorage/v2/Models/VolumeAttachment.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace OpenStack\BlockStorage\v2\Models;

use OpenStack\Common\Resource\Listable;
Expand All @@ -21,6 +24,6 @@ class VolumeAttachment extends OperatorResource implements Listable
/** @var string */
public $volumeId;

protected $resourceKey = 'volumeAttachment';
protected $resourceKey = 'volumeAttachment';
protected $resourcesKey = 'volumeAttachments';
}
5 changes: 4 additions & 1 deletion src/BlockStorage/v2/Models/VolumeType.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace OpenStack\BlockStorage\v2\Models;

Expand Down Expand Up @@ -30,6 +32,7 @@ class VolumeType extends OperatorResource implements Listable, Creatable, Update
public function create(array $userOptions): Creatable
{
$response = $this->execute($this->api->postTypes(), $userOptions);

return $this->populateFromResponse($response);
}

Expand Down
Loading