diff --git a/.php_cs.dist b/.php_cs.dist
new file mode 100644
index 00000000..32d7e97e
--- /dev/null
+++ b/.php_cs.dist
@@ -0,0 +1,23 @@
+setRules(
+ [
+ '@PSR2' => true,
+ '@Symfony' => true,
+ 'array_syntax' => ['syntax' => 'short'],
+ 'binary_operator_spaces' => ['default' => 'align'],
+ 'protected_to_private' => false,
+ ]
+ )
+ ->setUsingCache(false)
+ ->setRiskyAllowed(true)
+ ->setFinder(
+ PhpCsFixer\Finder::create()
+ ->in(__DIR__.'/src')
+ ->append([__FILE__, __DIR__.'/samples'])
+ );
diff --git a/.travis.yml b/.travis.yml
index 5ca85ee1..a020a10d 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -2,8 +2,6 @@ language: php
sudo: false
-dist: precise
-
cache:
directories:
- $HOME/.composer/cache
@@ -21,16 +19,20 @@ before_install:
- cat $HOME/.phpenv/versions/$TRAVIS_PHP_VERSION/etc/conf.d/xdebug.ini > ./xdebug.ini
- phpenv config-rm xdebug.ini || true
- composer self-update
+ - if [ -n "$GH_TOKEN" ]; then composer config github-oauth.github.com ${GH_TOKEN}; fi;
before_script:
- composer install --prefer-source
- vendor/bin/parallel-lint --exclude vendor .
- - vendor/bin/php-cs-fixer fix --dry-run --diff --level psr2 .
+ - vendor/bin/php-cs-fixer fix --dry-run --diff
- phpenv config-add ./xdebug.ini
after_script:
- php vendor/bin/coveralls -v
+after_success:
+ - travis_retry php vendor/bin/php-coveralls -v
+
notifications:
email:
- jamie.hannaford@rackspace.com
diff --git a/README.md b/README.md
index a3022613..cd22c91f 100644
--- a/README.md
+++ b/README.md
@@ -1,7 +1,7 @@
# PHP OpenStack SDK
[](https://travis-ci.org/php-opencloud/openstack)
-[](https://scrutinizer-ci.com/g/php-opencloud/openstack/?branch=master)
+[](https://coveralls.io/github/php-opencloud/openstack?branch=master)
[](https://scrutinizer-ci.com/g/php-opencloud/openstack/?branch=master)
`php-opencloud/openstack` is an SDK which allows PHP developers to easily connect to OpenStack APIs in a simple and
@@ -10,21 +10,36 @@ OpenStack services, and versions of services, are supported.
## Links
-* [Official documentation](http://docs.os.php-opencloud.com/)
+* [Official documentation](https://php-openstack-sdk.readthedocs.io/en/latest/)
* [Reference documentation](http://refdocs.os.php-opencloud.com)
-* [Developer support](https://developer.rackspace.com/)
-* [Mailing list](https://groups.google.com/forum/#!forum/php-opencloud)
* [Contributing guide](/CONTRIBUTING.md)
* [Code of Conduct](/CODE_OF_CONDUCT.md)
## Getting help
- Meet us on Slack: https://phpopencloud.slack.com ([Get your invitation](https://launchpass.com/phpopencloud))
-- Report and issue: https://github.com/php-opencloud/openstack/issues
+- Report an issue: https://github.com/php-opencloud/openstack/issues
+
+
+## Version Guidance
+
+| Version | Status | PHP Version | End of life |
+| --------- | --------------------------- | ------------- | ----------------------- |
+| `^3.0` | Latest | `>=7.0` | March 2020 |
+| `^2.0` | Maintained (Bug fixes only) | `>=7.0,<7.2` | March 2018 |
+
+## Upgrade from 2.x to 3.x
+
+Due to new [object typehint](https://wiki.php.net/rfc/object-typehint) since PHP 7.2, `Object` is a reserved keyword
+thus class `OpenStack\ObjectStore\v1\Models\Object` had to be renamed to
+`OpenStack\ObjectStore\v1\Models\StorageObject`.
+
+This change was introduced in [#184](https://github.com/php-opencloud/openstack/pull/184).
## Requirements
* PHP 7.0
+* `ext-curl`
## How to install
diff --git a/composer.json b/composer.json
index 6b699598..644bbefa 100644
--- a/composer.json
+++ b/composer.json
@@ -39,16 +39,16 @@
}
],
"require": {
- "php": "~7.0",
+ "php": ">=7.0 <7.2",
"guzzlehttp/guzzle": "~6.1",
"justinrainbow/json-schema": "~5.2"
},
"require-dev": {
- "phpunit/phpunit": "~4.0",
+ "phpunit/phpunit": "^6.5",
"sami/sami": "dev-master",
- "psr/log": "~1.0",
- "satooshi/php-coveralls": "~1.0",
- "jakub-onderka/php-parallel-lint": "0.*",
- "friendsofphp/php-cs-fixer": "^1.0"
+ "psr/log": "^1.0",
+ "satooshi/php-coveralls": "^2.0",
+ "jakub-onderka/php-parallel-lint": "^1.0",
+ "friendsofphp/php-cs-fixer": "^2.9"
}
}
diff --git a/doc/_exts/samples.py b/doc/_exts/samples.py
index daa25a22..5daa1f9a 100644
--- a/doc/_exts/samples.py
+++ b/doc/_exts/samples.py
@@ -32,7 +32,10 @@ def run(self):
def visit_download_reference(self, node):
self.context.append('Show auth code')
+def depart_download_reference(self, node):
+ self.body.append(self.context.pop())
+
def setup(app):
- app.add_node(download_reference, html=(visit_download_reference, HTMLTranslator.depart_download_reference))
+ app.add_node(download_reference, html=(visit_download_reference, depart_download_reference))
app.add_directive('sample', Sample)
return {'version': '0.1'}
diff --git a/doc/conf.py b/doc/conf.py
index 201fb459..9394ea7d 100755
--- a/doc/conf.py
+++ b/doc/conf.py
@@ -23,7 +23,7 @@
lexers['php-annotations'] = PhpLexer(startinline=True, linenos=1)
primary_domain = 'php'
-extensions = ['sphinxcontrib.phpdomain', 'samples', 'refdoc']
+extensions = ['samples', 'refdoc', 'sphinx.ext.autodoc', 'sphinx.ext.autosummary', 'sphinxcontrib.phpdomain']
source_suffix = '.rst'
master_doc = 'index'
project = u'php-opencloud'
diff --git a/doc/services/compute/v2/servers.rst b/doc/services/compute/v2/servers.rst
index 7b208f51..63a10235 100644
--- a/doc/services/compute/v2/servers.rst
+++ b/doc/services/compute/v2/servers.rst
@@ -218,6 +218,14 @@ This operation will replace the root password for a server.
.. sample:: compute/v2/servers/change_server_password.php
.. refdoc:: OpenStack/Compute/v2/Models/Server.html#method_changePassword
+Reset server state
+------------------
+
+This operation will reset the state of the server.
+
+.. sample:: compute/v2/servers/reset_server_state.php
+.. refdoc:: OpenStack/Compute/v2/Models/Server.html#method_resetState
+
Reboot server
-------------
@@ -302,4 +310,4 @@ Further links
-------------
* Reference docs for Server class
-* API docs
\ No newline at end of file
+* API docs
diff --git a/doc/services/identity/v2/authentication.rst b/doc/services/identity/v2/authentication.rst
new file mode 100644
index 00000000..eb3edfc6
--- /dev/null
+++ b/doc/services/identity/v2/authentication.rst
@@ -0,0 +1,12 @@
+Authentication
+==============
+
+Identity v2.0
+-------------
+
+We recommend users to use identity v3 when possible.
+
+RackSpace cloud and OVH cloud, however, are still using Keystone v2.0. This following code will work for such providers.
+
+
+.. sample:: identity/v2/authentication.php
diff --git a/doc/services/identity/v2/index.rst b/doc/services/identity/v2/index.rst
new file mode 100644
index 00000000..d4f39ac1
--- /dev/null
+++ b/doc/services/identity/v2/index.rst
@@ -0,0 +1,7 @@
+Identity v2
+===========
+
+.. toctree::
+ :maxdepth: 3
+
+ authentication
\ No newline at end of file
diff --git a/doc/services/networking/v2/index.rst b/doc/services/networking/v2/index.rst
index 37a4f87b..2b545644 100644
--- a/doc/services/networking/v2/index.rst
+++ b/doc/services/networking/v2/index.rst
@@ -6,4 +6,8 @@ Networking v2
networks
subnets
- ports
\ No newline at end of file
+ ports
+ loadbalancers
+ loadbalancer-pools
+ loadbalancer-listeners
+ loadbalancer-healthmonitors
\ No newline at end of file
diff --git a/doc/services/networking/v2/loadbalancer-healthmonitors.rst b/doc/services/networking/v2/loadbalancer-healthmonitors.rst
index 76f8973c..5a8a27ba 100644
--- a/doc/services/networking/v2/loadbalancer-healthmonitors.rst
+++ b/doc/services/networking/v2/loadbalancer-healthmonitors.rst
@@ -1,32 +1,32 @@
LoadBalancer HealthMonitors
-=====
+===========================
Create HealthMonitor
------------
+--------------------
.. sample:: networking/v2/lbaas/healthmonitors/create.php
.. refdoc:: OpenStack/Networking/v2/Service.html#method_createLoadBalancerHealthMonitor
Get HealthMonitor
------------
+-----------------
.. sample:: networking/v2/lbaas/healthmonitors/get.php
.. refdoc:: OpenStack/Networking/v2/Service.html#method_getLoadBalancerHealthMonitor
List HealthMonitors
------------
+-------------------
.. sample:: networking/v2/lbaas/healthmonitors/list.php
.. refdoc:: OpenStack/Networking/v2/Service.html#method_listLoadBalancerHealthMonitors
Update HealthMonitor
------------
+--------------------
.. sample:: networking/v2/lbaas/healthmonitors/update.php
.. refdoc:: OpenStack/Networking/v2/Models/LoadBalancerHealthMonitor.html#method_update
Delete HealthMonitor
------------
+--------------------
.. sample:: networking/v2/lbaas/healthmonitors/delete.php
.. refdoc:: OpenStack/Networking/v2/Models/LoadBalancerHealthMonitor.html#method_delete
diff --git a/doc/services/networking/v2/loadbalancer-listeners.rst b/doc/services/networking/v2/loadbalancer-listeners.rst
index 563e2ca5..90237d86 100644
--- a/doc/services/networking/v2/loadbalancer-listeners.rst
+++ b/doc/services/networking/v2/loadbalancer-listeners.rst
@@ -1,32 +1,32 @@
LoadBalancer Listeners
-=====
+======================
Create Listener
------------
+---------------
.. sample:: networking/v2/lbaas/listeners/create.php
.. refdoc:: OpenStack/Networking/v2/Service.html#method_createLoadBalancerListener
Get Listener
------------
+------------
.. sample:: networking/v2/lbaas/listeners/get.php
.. refdoc:: OpenStack/Networking/v2/Service.html#method_getLoadBalancerListener
List Listeners
------------
+--------------
.. sample:: networking/v2/lbaas/listeners/list.php
.. refdoc:: OpenStack/Networking/v2/Service.html#method_listLoadBalancerListeners
Update Listener
------------
+---------------
.. sample:: networking/v2/lbaas/listeners/update.php
.. refdoc:: OpenStack/Networking/v2/Models/LoadBalancerListener.html#method_update
Delete Listener
------------
+---------------
.. sample:: networking/v2/lbaas/listeners/delete.php
.. refdoc:: OpenStack/Networking/v2/Models/LoadBalancerListener.html#method_delete
diff --git a/doc/services/networking/v2/loadbalancer-pools.rst b/doc/services/networking/v2/loadbalancer-pools.rst
index 90774bf8..ce148918 100644
--- a/doc/services/networking/v2/loadbalancer-pools.rst
+++ b/doc/services/networking/v2/loadbalancer-pools.rst
@@ -1,5 +1,5 @@
LoadBalancer Pools
-=====
+==================
Create Pool
-----------
@@ -8,13 +8,13 @@ Create Pool
.. refdoc:: OpenStack/Networking/v2/Service.html#method_createLoadBalancerPool
Get Pool
------------
+--------
.. sample:: networking/v2/lbaas/pools/get.php
.. refdoc:: OpenStack/Networking/v2/Service.html#method_getLoadBalancerPool
List Pools
------------
+----------
.. sample:: networking/v2/lbaas/pools/list.php
.. refdoc:: OpenStack/Networking/v2/Service.html#method_listLoadBalancerPools
@@ -32,25 +32,25 @@ Delete Pool
.. refdoc:: OpenStack/Networking/v2/Models/LoadBalancerPool.html#method_delete
Add Member
------------
+----------
.. sample:: networking/v2/lbaas/pools/add-member.php
.. refdoc:: OpenStack/Networking/v2/Models/LoadBalancerPool.html#method_addMember
Get Member
------------
+----------
.. sample:: networking/v2/lbaas/pools/get-member.php
.. refdoc:: OpenStack/Networking/v2/Models/LoadBalancerPool.html#method_getMember
Delete Member
------------
+-------------
.. sample:: networking/v2/lbaas/pools/delete-member.php
.. refdoc:: OpenStack/Networking/v2/Models/LoadBalancerPool.html#method_deleteMember
Add Health Monitor
------------
+------------------
.. sample:: networking/v2/lbaas/pools/add-healthmonitor.php
.. refdoc:: OpenStack/Networking/v2/Models/LoadBalancerPool.html#method_addHealthMonitor
diff --git a/doc/services/networking/v2/loadbalancers.rst b/doc/services/networking/v2/loadbalancers.rst
index fdc11546..1733a54d 100644
--- a/doc/services/networking/v2/loadbalancers.rst
+++ b/doc/services/networking/v2/loadbalancers.rst
@@ -1,47 +1,47 @@
LoadBalancers
-=====
+=============
Create LoadBalancer
------------
+-------------------
.. sample:: networking/v2/lbaas/loadbalancers/create.php
.. refdoc:: OpenStack/Networking/v2/Service.html#method_createLoadBalancer
Get LoadBalancer
------------
+----------------
.. sample:: networking/v2/lbaas/loadbalancers/get.php
.. refdoc:: OpenStack/Networking/v2/Service.html#method_getLoadBalancer
List LoadBalancers
------------
+------------------
.. sample:: networking/v2/lbaas/loadbalancers/list.php
.. refdoc:: OpenStack/Networking/v2/Service.html#method_listLoadBalancers
Update LoadBalancer
------------
+-------------------
.. sample:: networking/v2/lbaas/loadbalancers/update.php
.. refdoc:: OpenStack/Networking/v2/Models/LoadBalancer.html#method_update
Delete LoadBalancer
------------
+-------------------
.. sample:: networking/v2/lbaas/loadbalancers/delete.php
.. refdoc:: OpenStack/Networking/v2/Models/LoadBalancer.html#method_delete
Add Listener to LoadBalancer
------------
+----------------------------
.. sample:: networking/v2/lbaas/loadbalancers/add_listener.php
.. refdoc:: OpenStack/Networking/v2/Models/LoadBalancer.html#method_addListener
Get Stats for LoadBalancer
------------
+--------------------------
.. sample:: networking/v2/lbaas/loadbalancers/get_stats.php
.. refdoc:: OpenStack/Networking/v2/Models/LoadBalancer.html#method_getStats
Get Status Tree for LoadBalancer
------------
+--------------------------------
.. sample:: networking/v2/lbaas/loadbalancers/get_statuses.php
.. refdoc:: OpenStack/Networking/v2/Models/LoadBalancer.html#method_getStatuses
diff --git a/phpunit.xml.dist b/phpunit.xml.dist
index cf698d5b..ff7dd902 100644
--- a/phpunit.xml.dist
+++ b/phpunit.xml.dist
@@ -1,6 +1,8 @@
-
-
+
+
+
+
tests/unit
@@ -18,4 +20,4 @@
-
\ No newline at end of file
+
diff --git a/samples/compute/v2/servers/reset_server_state.php b/samples/compute/v2/servers/reset_server_state.php
new file mode 100644
index 00000000..c1664310
--- /dev/null
+++ b/samples/compute/v2/servers/reset_server_state.php
@@ -0,0 +1,21 @@
+ '{authUrl}',
+ 'region' => '{region}',
+ 'user' => [
+ 'id' => '{userId}',
+ 'password' => '{password}'
+ ],
+ 'scope' => ['project' => ['id' => '{projectId}']]
+]);
+
+$compute = $openstack->computeV2(['region' => '{region}']);
+
+$server = $compute->getServer([
+ 'id' => '{serverId}',
+]);
+
+$server->resetState();
diff --git a/samples/identity/v2/authentication.php b/samples/identity/v2/authentication.php
new file mode 100644
index 00000000..89cd14d1
--- /dev/null
+++ b/samples/identity/v2/authentication.php
@@ -0,0 +1,31 @@
+ TransportUtils::normalizeUrl($authUrl),
+ 'handler' => HandlerStack::create(),
+]);
+
+$options = [
+ 'authUrl' => $authUrl,
+ 'region' => 'RegionOne',
+ 'username' => 'foo',
+ 'password' => 'bar',
+ 'tenantName' => 'baz',
+ 'identityService' => Service::factory($httpClient),
+];
+
+/** @var OpenStack $openstack */
+$openstack = new OpenStack($options);
+
+/** @var \OpenStack\Compute\v2\Models\Server[] $servers */
+$servers = $openstack->computeV2()->listServers();
diff --git a/src/BlockStorage/v2/Api.php b/src/BlockStorage/v2/Api.php
index 9f49e8f4..3c8bbfaf 100644
--- a/src/BlockStorage/v2/Api.php
+++ b/src/BlockStorage/v2/Api.php
@@ -1,4 +1,6 @@
-params = new Params;
+ $this->params = new Params();
}
public function postVolumes(): array
@@ -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(),
],
];
@@ -65,8 +67,8 @@ public function getVolume(): array
'method' => 'GET',
'path' => 'volumes/{id}',
'params' => [
- 'id' => $this->params->idPath()
- ]
+ 'id' => $this->params->idPath(),
+ ],
];
}
@@ -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(),
@@ -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(),
@@ -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(),
@@ -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'),
+ ],
];
}
@@ -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'),
+ ],
];
}
@@ -299,7 +301,7 @@ public function putQuotaSet(): array
'snapshotsIscsi' => $this->params->quotaSetSnapshotsIscsi(),
'volumes' => $this->params->quotaSetVolumes(),
'volumesIscsi' => $this->params->quotaSetVolumesIscsi(),
- ]
+ ],
];
}
}
diff --git a/src/BlockStorage/v2/Models/QuotaSet.php b/src/BlockStorage/v2/Models/QuotaSet.php
index 6c9db98c..d2805248 100644
--- a/src/BlockStorage/v2/Models/QuotaSet.php
+++ b/src/BlockStorage/v2/Models/QuotaSet.php
@@ -1,4 +1,6 @@
- '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()
{
@@ -75,7 +77,7 @@ public function update()
}
/**
- * @inheritdoc
+ * {@inheritdoc}
*/
public function delete()
{
diff --git a/src/BlockStorage/v2/Models/Snapshot.php b/src/BlockStorage/v2/Models/Snapshot.php
index 64dc11d1..3138648b 100644
--- a/src/BlockStorage/v2/Models/Snapshot.php
+++ b/src/BlockStorage/v2/Models/Snapshot.php
@@ -1,4 +1,6 @@
- 'volumeId',
];
/**
- * @inheritdoc
+ * {@inheritdoc}
*/
protected function getAliases(): array
{
return parent::getAliases() + [
- 'created_at' => new Alias('createdAt', \DateTimeImmutable::class)
+ 'created_at' => new Alias('createdAt', \DateTimeImmutable::class),
];
}
@@ -67,6 +69,7 @@ public function populateFromResponse(ResponseInterface $response): self
{
parent::populateFromResponse($response);
$this->metadata = $this->parseMetadata($response);
+
return $this;
}
@@ -84,6 +87,7 @@ public function retrieve()
public function create(array $userOptions): Creatable
{
$response = $this->execute($this->api->postSnapshots(), $userOptions);
+
return $this->populateFromResponse($response);
}
@@ -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;
}
@@ -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'] : [];
}
}
diff --git a/src/BlockStorage/v2/Models/Volume.php b/src/BlockStorage/v2/Models/Volume.php
index dbf5ef84..88fbb79d 100644
--- a/src/BlockStorage/v2/Models/Volume.php
+++ b/src/BlockStorage/v2/Models/Volume.php
@@ -1,4 +1,7 @@
- 'availabilityZone',
@@ -80,12 +83,12 @@ 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),
];
}
@@ -93,6 +96,7 @@ public function populateFromResponse(ResponseInterface $response): self
{
parent::populateFromResponse($response);
$this->metadata = $this->parseMetadata($response);
+
return $this;
}
@@ -110,6 +114,7 @@ public function retrieve()
public function create(array $userOptions): Creatable
{
$response = $this->execute($this->api->postVolumes(), $userOptions);
+
return $this->populateFromResponse($response);
}
@@ -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;
}
@@ -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'] : [];
}
}
diff --git a/src/BlockStorage/v2/Models/VolumeAttachment.php b/src/BlockStorage/v2/Models/VolumeAttachment.php
index 6d85b7b4..48b6e374 100644
--- a/src/BlockStorage/v2/Models/VolumeAttachment.php
+++ b/src/BlockStorage/v2/Models/VolumeAttachment.php
@@ -1,4 +1,7 @@
-execute($this->api->postTypes(), $userOptions);
+
return $this->populateFromResponse($response);
}
diff --git a/src/BlockStorage/v2/Params.php b/src/BlockStorage/v2/Params.php
index 000fa4e0..86dd4051 100644
--- a/src/BlockStorage/v2/Params.php
+++ b/src/BlockStorage/v2/Params.php
@@ -1,4 +1,6 @@
- self::STRING_TYPE,
'location' => self::JSON,
'sentAs' => 'source_volid',
- 'description' => 'To create a volume from an existing volume, specify the ID of the existing volume. The ' .
+ 'description' => 'To create a volume from an existing volume, specify the ID of the existing volume. The '.
'volume is created with the same size as the source volume.',
];
}
@@ -42,7 +44,7 @@ public function snapshotId(): array
'type' => self::STRING_TYPE,
'location' => self::JSON,
'sentAs' => 'snapshot_id',
- 'description' => 'To create a volume from an existing snapshot, specify the ID of the existing volume ' .
+ 'description' => 'To create a volume from an existing snapshot, specify the ID of the existing volume '.
'snapshot. The volume is created in same availability zone and with same size as the snapshot.',
];
}
@@ -63,7 +65,7 @@ public function imageRef(): array
'type' => self::STRING_TYPE,
'location' => self::JSON,
'sentAs' => 'imageRef',
- 'description' => 'The ID of the image from which you want to create the volume. Required to create a ' .
+ 'description' => 'The ID of the image from which you want to create the volume. Required to create a '.
'bootable volume.',
];
}
@@ -89,17 +91,17 @@ public function metadata(): array
'description' => << self::STRING_TYPE,
- 'location' => self::QUERY,
- 'description' => "Comma-separated list of sort keys and optional sort directions in the form of " .
- "[:]. A valid direction is asc (ascending) or desc (descending)."
+ 'type' => self::STRING_TYPE,
+ 'location' => self::QUERY,
+ 'description' => 'Comma-separated list of sort keys and optional sort directions in the form of '.
+ '[:]. A valid direction is asc (ascending) or desc (descending).',
];
}
@@ -124,10 +126,10 @@ public function idPath(): array
public function typeSpecs(): array
{
return [
- 'type' => self::OBJECT_TYPE,
- 'location' => self::JSON,
- 'description' => 'A key and value pair that contains additional specifications that are associated with ' .
- 'the volume type. Examples include capabilities, capacity, compression, and so on, depending on the ' .
+ 'type' => self::OBJECT_TYPE,
+ 'location' => self::JSON,
+ 'description' => 'A key and value pair that contains additional specifications that are associated with '.
+ 'the volume type. Examples include capabilities, capacity, compression, and so on, depending on the '.
'storage driver in use.',
];
}
@@ -148,7 +150,7 @@ public function force(): array
return [
'type' => self::BOOL_TYPE,
'location' => self::JSON,
- 'description' => 'Indicate whether to snapshot, even if the volume is attached. Default is false.'
+ 'description' => 'Indicate whether to snapshot, even if the volume is attached. Default is false.',
];
}
@@ -159,7 +161,7 @@ public function snapshotName(): array
'location' => self::JSON,
];
}
-
+
protected function quotaSetLimit($sentAs, $description): array
{
return [
diff --git a/src/BlockStorage/v2/Service.php b/src/BlockStorage/v2/Service.php
index 17f07280..084594dc 100644
--- a/src/BlockStorage/v2/Service.php
+++ b/src/BlockStorage/v2/Service.php
@@ -1,4 +1,6 @@
-api->getVolumesDetail() : $this->api->getVolumes();
+ $def = (true === $detail) ? $this->api->getVolumesDetail() : $this->api->getVolumes();
+
return $this->model(Volume::class)->enumerate($def, $userOptions);
}
/**
- * @param string $volumeId The UUID of the volume being retrieved.
+ * @param string $volumeId the UUID of the volume being retrieved
*
* @return Volume
*/
@@ -49,6 +52,7 @@ public function getVolume(string $volumeId): Volume
{
$volume = $this->model(Volume::class);
$volume->populateFromArray(['id' => $volumeId]);
+
return $volume;
}
@@ -79,6 +83,7 @@ public function getVolumeType(string $typeId): VolumeType
{
$type = $this->model(VolumeType::class);
$type->populateFromArray(['id' => $typeId]);
+
return $type;
}
@@ -97,7 +102,8 @@ public function createSnapshot(array $userOptions): Snapshot
*/
public function listSnapshots(bool $detail = false, array $userOptions = []): \Generator
{
- $def = ($detail === true) ? $this->api->getSnapshotsDetail() : $this->api->getSnapshots();
+ $def = (true === $detail) ? $this->api->getSnapshotsDetail() : $this->api->getSnapshots();
+
return $this->model(Snapshot::class)->enumerate($def, $userOptions);
}
@@ -110,11 +116,12 @@ public function getSnapshot(string $snapshotId): Snapshot
{
$snapshot = $this->model(Snapshot::class);
$snapshot->populateFromArray(['id' => $snapshotId]);
+
return $snapshot;
}
/**
- * Shows A Quota for a tenant
+ * Shows A Quota for a tenant.
*
* @param string $tenantId
*
diff --git a/src/Common/Api/AbstractApi.php b/src/Common/Api/AbstractApi.php
index 49d4d456..1d5126e1 100644
--- a/src/Common/Api/AbstractApi.php
+++ b/src/Common/Api/AbstractApi.php
@@ -1,4 +1,6 @@
- sprintf("The unique ID, or identifier, for the %s", $type),
+ 'description' => sprintf('The unique ID, or identifier, for the %s', $type),
'type' => self::STRING_TYPE,
'location' => self::JSON,
];
@@ -72,29 +74,28 @@ public function idPath(): array
public function name(string $resource): array
{
return [
- 'description' => sprintf("The name of the %s", $resource),
+ 'description' => sprintf('The name of the %s', $resource),
'type' => self::STRING_TYPE,
'location' => self::JSON,
];
}
-
public function sortDir(): array
{
return [
'type' => self::STRING_TYPE,
'location' => self::QUERY,
- 'description' => "Sorts by one or more sets of attribute and sort direction combinations.",
- 'enum' => ['asc', 'desc']
+ 'description' => 'Sorts by one or more sets of attribute and sort direction combinations.',
+ 'enum' => ['asc', 'desc'],
];
}
public function sortKey(): array
{
return [
- 'type' => self::STRING_TYPE,
- 'location' => self::QUERY,
- 'description' => "Sorts by one or more sets of attribute and sort direction combinations.",
+ 'type' => self::STRING_TYPE,
+ 'location' => self::QUERY,
+ 'description' => 'Sorts by one or more sets of attribute and sort direction combinations.',
];
}
diff --git a/src/Common/Api/ApiInterface.php b/src/Common/Api/ApiInterface.php
index dfa1dc30..149c1f03 100644
--- a/src/Common/Api/ApiInterface.php
+++ b/src/Common/Api/ApiInterface.php
@@ -1,4 +1,6 @@
-method = $definition['method'];
- $this->path = $definition['path'];
+ $this->path = $definition['path'];
if (isset($definition['jsonKey'])) {
$this->jsonKey = $definition['jsonKey'];
@@ -116,7 +116,8 @@ public static function toParamArray(array $data): array
*
* @param array $userValues The user-defined values
*
- * @return bool TRUE if validation passes
+ * @return bool TRUE if validation passes
+ *
* @throws \Exception If validate fails
*/
public function validate(array $userValues): bool
diff --git a/src/Common/Api/OperatorInterface.php b/src/Common/Api/OperatorInterface.php
index 0337872e..7bb10059 100644
--- a/src/Common/Api/OperatorInterface.php
+++ b/src/Common/Api/OperatorInterface.php
@@ -1,4 +1,6 @@
-client = $client;
- $this->api = $api;
+ $this->api = $api;
}
/**
@@ -34,6 +35,7 @@ public function __construct(ClientInterface $client, ApiInterface $api)
* removed to provide easier access to normal state, such as resource attributes.
*
* @codeCoverageIgnore
+ *
* @return array
*/
public function __debugInfo()
@@ -56,8 +58,8 @@ public function __debugInfo()
* {@see Promise} object. In order for this to happen, the called methods need to be in the
* following format: `createAsync`, where `create` is the sequential method being wrapped.
*
- * @param $methodName The name of the method being invoked.
- * @param $args The arguments to be passed to the sequential method.
+ * @param $methodName the name of the method being invoked
+ * @param $args the arguments to be passed to the sequential method
*
* @throws \RuntimeException If method does not exist
*
@@ -69,7 +71,7 @@ public function __call($methodName, $args)
return new \RuntimeException(sprintf('%s::%s is not defined', get_class($this), $name));
};
- if (substr($methodName, -5) === 'Async') {
+ if ('Async' === substr($methodName, -5)) {
$realMethod = substr($methodName, 0, -5);
if (!method_exists($this, $realMethod)) {
throw $e($realMethod);
@@ -102,21 +104,22 @@ public function getOperation(array $definition): Operation
* @param bool $async
*
* @return mixed
+ *
* @throws \Exception
*/
protected function sendRequest(Operation $operation, array $userValues = [], bool $async = false)
{
$operation->validate($userValues);
- $options = (new RequestSerializer)->serializeOptions($operation, $userValues);
- $method = $async ? 'requestAsync' : 'request';
- $uri = uri_template($operation->getPath(), $userValues);
+ $options = (new RequestSerializer())->serializeOptions($operation, $userValues);
+ $method = $async ? 'requestAsync' : 'request';
+ $uri = uri_template($operation->getPath(), $userValues);
return $this->client->$method($operation->getMethod(), $uri, $options);
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function execute(array $definition, array $userValues = []): ResponseInterface
{
@@ -124,7 +127,7 @@ public function execute(array $definition, array $userValues = []): ResponseInte
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function executeAsync(array $definition, array $userValues = []): PromiseInterface
{
@@ -132,7 +135,7 @@ public function executeAsync(array $definition, array $userValues = []): Promise
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function model(string $class, $data = null): ResourceInterface
{
@@ -147,6 +150,7 @@ public function model(string $class, $data = null): ResourceInterface
} elseif (is_array($data)) {
$model->populateFromArray($data);
}
+
return $model;
}
}
diff --git a/src/Common/Api/Parameter.php b/src/Common/Api/Parameter.php
index 15ab8369..389c626f 100644
--- a/src/Common/Api/Parameter.php
+++ b/src/Common/Api/Parameter.php
@@ -1,4 +1,6 @@
-hydrate($data);
- $this->required = (bool)$this->required;
+ $this->required = (bool) $this->required;
$this->stockLocation($data);
$this->stockItemSchema($data);
@@ -137,7 +137,7 @@ private function stockLocation(array $data)
$this->location = isset($data['location']) ? $data['location'] : self::DEFAULT_LOCATION;
if (!AbstractParams::isSupportedLocation($this->location)) {
- throw new \RuntimeException(sprintf("%s is not a permitted location", $this->location));
+ throw new \RuntimeException(sprintf('%s is not a permitted location', $this->location));
}
}
@@ -151,7 +151,7 @@ private function stockItemSchema(array $data)
private function stockProperties(array $data)
{
if (isset($data['properties'])) {
- if ($this->name && stripos($this->name, 'metadata') !== false) {
+ if ($this->name && false !== stripos($this->name, 'metadata')) {
$this->properties = new Parameter($data['properties']);
} else {
foreach ($data['properties'] as $name => $property) {
@@ -178,7 +178,7 @@ public function getName(): string
*/
public function isRequired(): bool
{
- return $this->required === true;
+ return true === $this->required;
}
/**
@@ -186,7 +186,8 @@ public function isRequired(): bool
*
* @param $userValues The value provided by the user
*
- * @return bool TRUE if the validation passes
+ * @return bool TRUE if the validation passes
+ *
* @throws \Exception If validation fails
*/
public function validate($userValues): bool
@@ -205,9 +206,11 @@ public function validate($userValues): bool
private function validateEnums($userValues)
{
- if (!empty($this->enum) && $this->type == 'string' && !in_array($userValues, $this->enum)) {
+ if (!empty($this->enum) && 'string' == $this->type && !in_array($userValues, $this->enum)) {
throw new \Exception(sprintf(
- 'The only permitted values are %s. You provided %s', implode(', ', $this->enum), print_r($userValues, true)
+ 'The only permitted values are %s. You provided %s',
+ implode(', ', $this->enum),
+ print_r($userValues, true)
));
}
}
@@ -217,7 +220,10 @@ private function validateType($userValues)
if (!$this->hasCorrectType($userValues)) {
throw new \Exception(sprintf(
'The key provided "%s" has the wrong value type. You provided %s (%s) but was expecting %s',
- $this->name, print_r($userValues, true), gettype($userValues), $this->type
+ $this->name,
+ print_r($userValues, true),
+ gettype($userValues),
+ $this->type
));
}
}
@@ -243,11 +249,12 @@ private function validateObject($userValues)
* @param string $key The name of the child parameter
*
* @returns Parameter
+ *
* @throws \Exception
*/
private function getNestedProperty($key): Parameter
{
- if ($this->name && stripos($this->name, 'metadata') !== false && $this->properties instanceof Parameter) {
+ if ($this->name && false !== stripos($this->name, 'metadata') && $this->properties instanceof Parameter) {
return $this->properties;
} elseif (isset($this->properties[$key])) {
return $this->properties[$key];
@@ -273,7 +280,7 @@ private function hasCorrectType($userValue): bool
// For params defined as objects, we'll let the user get away with
// passing in an associative array - since it's effectively a hash
- if ($this->type == 'object' && $isAssociative($userValue)) {
+ if ('object' == $this->type && $isAssociative($userValue)) {
return true;
}
@@ -286,7 +293,7 @@ private function hasCorrectType($userValue): bool
}
// allow string nulls
- if ($this->type == 'string' && $userValue === null) {
+ if ('string' == $this->type && null === $userValue) {
return true;
}
@@ -294,23 +301,23 @@ private function hasCorrectType($userValue): bool
}
/**
- * Indicates whether this parameter represents an array type
+ * Indicates whether this parameter represents an array type.
*
* @return bool
*/
public function isArray(): bool
{
- return $this->type == 'array' && $this->itemSchema instanceof Parameter;
+ return 'array' == $this->type && $this->itemSchema instanceof Parameter;
}
/**
- * Indicates whether this parameter represents an object type
+ * Indicates whether this parameter represents an object type.
*
* @return bool
*/
public function isObject(): bool
{
- return $this->type == 'object' && !empty($this->properties);
+ return 'object' == $this->type && !empty($this->properties);
}
public function getLocation(): string
@@ -351,7 +358,7 @@ public function getItemSchema()
}
/**
- * Sets the name of the parameter to a new value
+ * Sets the name of the parameter to a new value.
*
* @param string $name
*/
@@ -371,6 +378,7 @@ public function getProperty(string $name)
{
if ($this->properties instanceof Parameter) {
$this->properties->setName($name);
+
return $this->properties;
}
@@ -389,6 +397,6 @@ public function getPrefix(): string
public function getPrefixedName(): string
{
- return $this->prefix . $this->getName();
+ return $this->prefix.$this->getName();
}
}
diff --git a/src/Common/ArrayAccessTrait.php b/src/Common/ArrayAccessTrait.php
index f0319f88..beecc1d0 100644
--- a/src/Common/ArrayAccessTrait.php
+++ b/src/Common/ArrayAccessTrait.php
@@ -1,16 +1,16 @@
-nextHandler = $nextHandler;
+ $this->nextHandler = $nextHandler;
$this->tokenGenerator = $tokenGenerator;
- $this->token = $token;
+ $this->token = $token;
}
/**
@@ -71,6 +73,6 @@ public function __invoke(RequestInterface $request, array $options)
*/
private function shouldIgnore(RequestInterface $request): bool
{
- return strpos((string) $request->getUri(), 'tokens') !== false && $request->getMethod() == 'POST';
+ return false !== strpos((string) $request->getUri(), 'tokens') && 'POST' == $request->getMethod();
}
}
diff --git a/src/Common/Auth/Catalog.php b/src/Common/Auth/Catalog.php
index dca0bfc7..14747f03 100644
--- a/src/Common/Auth/Catalog.php
+++ b/src/Common/Auth/Catalog.php
@@ -1,4 +1,6 @@
-docDomain . $link;
+ $link = $this->docDomain.$link;
try {
return $this->client->request('HEAD', $link)->getStatusCode() < 400;
@@ -76,29 +76,30 @@ private function linkIsValid(string $link): bool
* @param MessageInterface $message
*
* @codeCoverageIgnore
+ *
* @return string
*/
public function str(MessageInterface $message): string
{
if ($message instanceof RequestInterface) {
- $msg = trim($message->getMethod() . ' '
- . $message->getRequestTarget())
- . ' HTTP/' . $message->getProtocolVersion();
+ $msg = trim($message->getMethod().' '
+ .$message->getRequestTarget())
+ .' HTTP/'.$message->getProtocolVersion();
if (!$message->hasHeader('host')) {
- $msg .= "\r\nHost: " . $message->getUri()->getHost();
+ $msg .= "\r\nHost: ".$message->getUri()->getHost();
}
} elseif ($message instanceof ResponseInterface) {
- $msg = 'HTTP/' . $message->getProtocolVersion() . ' '
- . $message->getStatusCode() . ' '
- . $message->getReasonPhrase();
+ $msg = 'HTTP/'.$message->getProtocolVersion().' '
+ .$message->getStatusCode().' '
+ .$message->getReasonPhrase();
}
foreach ($message->getHeaders() as $name => $values) {
- $msg .= "\r\n{$name}: " . implode(', ', $values);
+ $msg .= "\r\n{$name}: ".implode(', ', $values);
}
if (ini_get('memory_limit') < 0 || $message->getBody()->getSize() < ini_get('memory_limit')) {
- $msg .= "\r\n\r\n" . $message->getBody();
+ $msg .= "\r\n\r\n".$message->getBody();
}
return $msg;
@@ -116,20 +117,23 @@ public function httpError(RequestInterface $request, ResponseInterface $response
{
$message = $this->header('HTTP Error');
- $message .= sprintf("The remote server returned a \"%d %s\" error for the following transaction:\n\n",
- $response->getStatusCode(), $response->getReasonPhrase());
+ $message .= sprintf(
+ "The remote server returned a \"%d %s\" error for the following transaction:\n\n",
+ $response->getStatusCode(),
+ $response->getReasonPhrase()
+ );
$message .= $this->header('Request');
- $message .= trim($this->str($request)) . PHP_EOL . PHP_EOL;
+ $message .= trim($this->str($request)).PHP_EOL.PHP_EOL;
$message .= $this->header('Response');
- $message .= trim($this->str($response)) . PHP_EOL . PHP_EOL;
+ $message .= trim($this->str($response)).PHP_EOL.PHP_EOL;
$message .= $this->header('Further information');
$message .= $this->getStatusCodeMessage($response->getStatusCode());
- $message .= "Visit http://docs.php-opencloud.com/en/latest/http-codes for more information about debugging "
- . "HTTP status codes, or file a support issue on https://github.com/php-opencloud/openstack/issues.";
+ $message .= 'Visit http://docs.php-opencloud.com/en/latest/http-codes for more information about debugging '
+ .'HTTP status codes, or file a support issue on https://github.com/php-opencloud/openstack/issues.';
$e = new BadResponseError($message);
$e->setRequest($request);
@@ -155,7 +159,7 @@ private function getStatusCodeMessage(int $statusCode): string
*
* @param string $expectedType The type that was expected from the user
* @param mixed $userValue The incorrect value the user actually provided
- * @param string|null $furtherLink A link to further information if necessary (optional).
+ * @param string|null $furtherLink a link to further information if necessary (optional)
*
* @return UserInputError
*/
@@ -163,13 +167,16 @@ public function userInputError(string $expectedType, $userValue, string $further
{
$message = $this->header('User Input Error');
- $message .= sprintf("%s was expected, but the following value was passed in:\n\n%s\n",
- $expectedType, print_r($userValue, true));
+ $message .= sprintf(
+ "%s was expected, but the following value was passed in:\n\n%s\n",
+ $expectedType,
+ print_r($userValue, true)
+ );
- $message .= "Please ensure that the value adheres to the expectation above. ";
+ $message .= 'Please ensure that the value adheres to the expectation above. ';
if ($furtherLink && $this->linkIsValid($furtherLink)) {
- $message .= sprintf("Visit %s for more information about input arguments. ", $this->docDomain . $furtherLink);
+ $message .= sprintf('Visit %s for more information about input arguments. ', $this->docDomain.$furtherLink);
}
$message .= 'If you run into trouble, please open a support issue on https://github.com/php-opencloud/openstack/issues.';
diff --git a/src/Common/Error/NotImplementedError.php b/src/Common/Error/NotImplementedError.php
index c97a4309..7b29c0c5 100644
--- a/src/Common/Error/NotImplementedError.php
+++ b/src/Common/Error/NotImplementedError.php
@@ -1,11 +1,11 @@
-$property = $value;
}
}
diff --git a/src/Common/JsonPath.php b/src/Common/JsonPath.php
index 4444dbbc..346da5ed 100644
--- a/src/Common/JsonPath.php
+++ b/src/Common/JsonPath.php
@@ -1,10 +1,12 @@
-['foo' => ['bar' => ['baz' => 'some_value']]]
*
@@ -19,8 +21,6 @@
* $jsonPath->set('foo.bar.baz', 'new_value');
* $val = $jsonPath->get('foo.bar.baz');
*
- *
- * @package OpenStack\Common
*/
class JsonPath
{
@@ -37,7 +37,7 @@ public function __construct($structure)
}
/**
- * Set a node in the structure
+ * Set a node in the structure.
*
* @param $path The XPath to use
* @param $value The new value of the node
@@ -101,8 +101,6 @@ public function get(string $path)
*
* @param $path
* @param $json
- *
- * @return null
*/
private function getPath(string $path, $json)
{
diff --git a/src/Common/JsonSchema/JsonPatch.php b/src/Common/JsonSchema/JsonPatch.php
index eb6c6e0a..15f65525 100644
--- a/src/Common/JsonSchema/JsonPatch.php
+++ b/src/Common/JsonSchema/JsonPatch.php
@@ -1,4 +1,6 @@
-makeDiff($src, $dest);
+ return (new static())->makeDiff($src, $dest);
}
public function makeDiff($srcStruct, $desStruct, string $path = ''): array
@@ -98,11 +100,11 @@ protected function path(string $root, $path): string
{
$path = (string) $path;
- if ($path === '_empty_') {
+ if ('_empty_' === $path) {
$path = '';
}
- return rtrim($root, '/') . '/' . ltrim($path, '/');
+ return rtrim($root, '/').'/'.ltrim($path, '/');
}
protected function makePatch(string $op, string $path, $val = null): array
diff --git a/src/Common/JsonSchema/Schema.php b/src/Common/JsonSchema/Schema.php
index d86fb409..36396d5e 100644
--- a/src/Common/JsonSchema/Schema.php
+++ b/src/Common/JsonSchema/Schema.php
@@ -1,4 +1,6 @@
-body = (object) $body;
+ $this->body = (object) $body;
$this->validator = $validator ?: new Validator();
}
@@ -23,7 +25,7 @@ public function getPropertyPaths(): array
$paths = [];
foreach ($this->body->properties as $propertyName => $property) {
- $paths[] = sprintf("/%s", $propertyName);
+ $paths[] = sprintf('/%s', $propertyName);
}
return $paths;
@@ -31,12 +33,12 @@ public function getPropertyPaths(): array
public function normalizeObject($subject, array $aliases): \stdClass
{
- $out = new \stdClass;
+ $out = new \stdClass();
foreach ($this->body->properties as $propertyName => $property) {
$name = $aliases[$propertyName] ?? $propertyName;
- if (isset($property->readOnly) && $property->readOnly === true) {
+ if (isset($property->readOnly) && true === $property->readOnly) {
continue;
} elseif (property_exists($subject, $name)) {
$out->$propertyName = $subject->$name;
diff --git a/src/Common/Resource/AbstractResource.php b/src/Common/Resource/AbstractResource.php
index a3f2f51a..bfa1ef89 100644
--- a/src/Common/Resource/AbstractResource.php
+++ b/src/Common/Resource/AbstractResource.php
@@ -1,4 +1,6 @@
- 'fooBar'
*
@@ -42,9 +42,9 @@ abstract class AbstractResource implements ResourceInterface, Serializable
*
* @return AbstractResource
*/
- public function populateFromResponse(ResponseInterface $response): self
+ public function populateFromResponse(ResponseInterface $response)
{
- if (strpos($response->getHeaderLine('Content-Type'), 'application/json') === 0) {
+ if (0 === strpos($response->getHeaderLine('Content-Type'), 'application/json')) {
$json = Utils::jsonDecode($response);
if (!empty($json)) {
$this->populateFromArray(Utils::flattenJson($json, $this->resourceKey));
@@ -61,7 +61,7 @@ public function populateFromResponse(ResponseInterface $response): self
*
* @return mixed|void
*/
- public function populateFromArray(array $array): self
+ public function populateFromArray(array $array)
{
$aliases = $this->getAliases();
@@ -82,7 +82,7 @@ public function populateFromArray(array $array): self
}
/**
- * Constructs alias objects
+ * Constructs alias objects.
*
* @return Alias[]
*/
@@ -90,7 +90,7 @@ protected function getAliases(): array
{
$aliases = [];
- foreach ((array)$this->aliases as $alias => $property) {
+ foreach ((array) $this->aliases as $alias => $property) {
$aliases[$alias] = new Alias($property);
}
@@ -142,10 +142,16 @@ public function serialize(): \stdClass
foreach ((new \ReflectionClass($this))->getProperties(\ReflectionProperty::IS_PUBLIC) as $property) {
$name = $property->getName();
- $val = $this->{$name};
+ $val = $this->{$name};
$fn = function ($val) {
- return ($val instanceof Serializable) ? $val->serialize() : $val;
+ if ($val instanceof Serializable) {
+ return $val->serialize();
+ } elseif ($val instanceof \DateTimeImmutable) {
+ return $val->format('c');
+ } else {
+ return $val;
+ }
};
if (is_array($val)) {
diff --git a/src/Common/Resource/Alias.php b/src/Common/Resource/Alias.php
index 6746246b..400339aa 100644
--- a/src/Common/Resource/Alias.php
+++ b/src/Common/Resource/Alias.php
@@ -1,10 +1,9 @@
-isList = $list;
+ $this->isList = $list;
$this->propertyName = $propertyName;
- $this->className = $className && class_exists($className) ? $className : null;
+ $this->className = $className && class_exists($className) ? $className : null;
}
/**
@@ -42,15 +41,16 @@ public function __construct(string $propertyName, string $className = null, bool
*/
public function getValue(ResourceInterface $resource, $value)
{
- if ($value === null || !$this->className) {
+ if (null === $value || !$this->className) {
return $value;
} elseif ($this->isList && is_array($value)) {
$array = [];
foreach ($value as $subVal) {
$array[] = $resource->model($this->className, $subVal);
}
+
return $array;
- } elseif ($this->className === \DateTimeImmutable::class) {
+ } elseif (\DateTimeImmutable::class === $this->className) {
return new \DateTimeImmutable($value);
}
diff --git a/src/Common/Resource/Creatable.php b/src/Common/Resource/Creatable.php
index 92346eb2..797f3cd4 100644
--- a/src/Common/Resource/Creatable.php
+++ b/src/Common/Resource/Creatable.php
@@ -1,11 +1,11 @@
-shouldHalt($timeout, $startTime)) {
+ if (true === $response || $this->shouldHalt($timeout, $startTime)) {
break;
}
@@ -80,7 +80,7 @@ public function waitWithCallback(callable $fn, $timeout = 60, int $sleepPeriod =
*/
private function shouldHalt($timeout, int $startTime)
{
- if ($timeout === false) {
+ if (false === $timeout) {
return false;
}
@@ -108,7 +108,7 @@ public function waitUntilDeleted($timeout = 60, int $sleepPeriod = 1)
try {
$this->retrieve();
} catch (BadResponseError $e) {
- if ($e->getResponse()->getStatusCode() === 404) {
+ if (404 === $e->getResponse()->getStatusCode()) {
break;
}
throw $e;
diff --git a/src/Common/Resource/Iterator.php b/src/Common/Resource/Iterator.php
index a9cf0704..76b18af4 100644
--- a/src/Common/Resource/Iterator.php
+++ b/src/Common/Resource/Iterator.php
@@ -1,4 +1,6 @@
-resourcesKey);
- if ($response->getStatusCode() === 204 || empty($json)) {
+ if (204 === $response->getStatusCode() || empty($json)) {
return false;
}
@@ -88,7 +90,7 @@ public function __invoke()
break;
}
- $this->count++;
+ ++$this->count;
yield $this->assembleResource($resourceData);
}
diff --git a/src/Common/Resource/Listable.php b/src/Common/Resource/Listable.php
index d6c8caf0..9b8744ee 100644
--- a/src/Common/Resource/Listable.php
+++ b/src/Common/Resource/Listable.php
@@ -1,11 +1,11 @@
-resourcesKey;
if (!$resourcesKey) {
- $class = substr(static::class, strrpos(static::class, '\\') + 1);
- $resourcesKey = strtolower(preg_replace('/([a-z])([A-Z])/', '$1_$2', $class)) . 's';
+ $class = substr(static::class, strrpos(static::class, '\\') + 1);
+ $resourcesKey = strtolower(preg_replace('/([a-z])([A-Z])/', '$1_$2', $class)).'s';
}
return $resourcesKey;
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function enumerate(array $def, array $userVals = [], callable $mapFn = null): \Generator
{
@@ -82,12 +82,14 @@ public function enumerate(array $def, array $userVals = [], callable $mapFn = nu
if ($marker) {
$userVals['marker'] = $marker;
}
+
return $this->sendRequest($operation, $userVals);
};
$resourceFn = function (array $data) {
$resource = $this->newInstance();
$resource->populateFromArray($data);
+
return $resource;
};
@@ -99,12 +101,13 @@ public function enumerate(array $def, array $userVals = [], callable $mapFn = nu
];
$iterator = new Iterator($opts, $requestFn, $resourceFn);
+
return $iterator();
}
public function extractMultipleInstances(ResponseInterface $response, string $key = null): array
{
- $key = $key ?: $this->getResourcesKey();
+ $key = $key ?: $this->getResourcesKey();
$resourcesData = Utils::jsonDecode($response)[$key];
$resources = [];
@@ -118,14 +121,14 @@ public function extractMultipleInstances(ResponseInterface $response, string $ke
protected function getService()
{
- $class = static::class;
- $service = substr($class, 0, strpos($class, 'Models') - 1) . '\\Service';
+ $class = static::class;
+ $service = substr($class, 0, strpos($class, 'Models') - 1).'\\Service';
return new $service($this->client, $this->api);
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function model(string $class, $data = null): ResourceInterface
{
diff --git a/src/Common/Resource/ResourceInterface.php b/src/Common/Resource/ResourceInterface.php
index 7c5ea40b..60420593 100644
--- a/src/Common/Resource/ResourceInterface.php
+++ b/src/Common/Resource/ResourceInterface.php
@@ -1,4 +1,6 @@
- 'publicURL'];
/**
- * @param array $globalOptions Options that will be applied to every service created by this builder.
- * Eventually they will be merged (and if necessary overridden) by the
- * service-specific options passed in.
- * @param string $rootNamespace API classes' root namespace
+ * @param array $globalOptions Options that will be applied to every service created by this builder.
+ * Eventually they will be merged (and if necessary overridden) by the
+ * service-specific options passed in.
+ * @param string $rootNamespace API classes' root namespace
*/
public function __construct(array $globalOptions = [], $rootNamespace = 'OpenStack')
{
@@ -49,12 +49,12 @@ public function __construct(array $globalOptions = [], $rootNamespace = 'OpenSta
private function getClasses($namespace)
{
- $namespace = $this->rootNamespace . '\\' . $namespace;
+ $namespace = $this->rootNamespace.'\\'.$namespace;
$classes = [$namespace.'\\Api', $namespace.'\\Service'];
foreach ($classes as $class) {
if (!class_exists($class)) {
- throw new \RuntimeException(sprintf("%s does not exist", $class));
+ throw new \RuntimeException(sprintf('%s does not exist', $class));
}
}
@@ -89,12 +89,12 @@ public function createService(string $namespace, array $serviceOptions = []): Se
private function stockHttpClient(array &$options, string $serviceName)
{
if (!isset($options['httpClient']) || !($options['httpClient'] instanceof ClientInterface)) {
- if (stripos($serviceName, 'identity') !== false) {
+ if (false !== stripos($serviceName, 'identity')) {
$baseUrl = $options['authUrl'];
- $stack = $this->getStack($options['authHandler']);
+ $stack = $this->getStack($options['authHandler']);
} else {
list($token, $baseUrl) = $options['identityService']->authenticate($options);
- $stack = $this->getStack($options['authHandler'], $token);
+ $stack = $this->getStack($options['authHandler'], $token);
}
$microVersion = $options['microVersion'] ?? null;
@@ -136,6 +136,7 @@ private function getStack(callable $authHandler, Token $token = null): HandlerSt
{
$stack = HandlerStack::create();
$stack->push(Middleware::authHandler($authHandler, $token));
+
return $stack;
}
@@ -153,6 +154,7 @@ private function httpClient(string $baseUrl, HandlerStack $stack, string $servic
if (isset($this->globalOptions['requestOptions'])) {
$clientOptions = array_merge($this->globalOptions['requestOptions'], $clientOptions);
}
+
return new Client($clientOptions);
}
@@ -166,7 +168,8 @@ private function mergeOptions(array $serviceOptions): array
if (!isset($options['identityService']) || !($options['identityService'] instanceof IdentityService)) {
throw new \InvalidArgumentException(sprintf(
- '"identityService" must be specified and implement %s', IdentityService::class
+ '"identityService" must be specified and implement %s',
+ IdentityService::class
));
}
diff --git a/src/Common/Service/ServiceInterface.php b/src/Common/Service/ServiceInterface.php
index d7408883..b0c2b6d4 100644
--- a/src/Common/Service/ServiceInterface.php
+++ b/src/Common/Service/ServiceInterface.php
@@ -1,4 +1,6 @@
-getName();
if ($path = $param->getPath()) {
$jsonPath = new JsonPath($json);
- $jsonPath->set(sprintf("%s.%s", $path, $name), $userValue);
+ $jsonPath->set(sprintf('%s.%s', $path, $name), $userValue);
$json = $jsonPath->getStructure();
} elseif ($name) {
$json[$name] = $userValue;
@@ -52,6 +52,7 @@ private function stockArrayJson(Parameter $param, array $userValue): array
foreach ($userValue as $item) {
$elems = $this->stockJson($param->getItemSchema(), $item, $elems);
}
+
return $elems;
}
@@ -69,6 +70,7 @@ private function stockObjectJson(Parameter $param, \stdClass $userValue): array
foreach ($userValue as $key => $val) {
$object = $this->stockJson($param->getProperty($key), $val, $object);
}
+
return $object;
}
@@ -101,7 +103,8 @@ private function serializeObjectValue($value)
} elseif (!($value instanceof \stdClass)) {
throw new \InvalidArgumentException(sprintf(
'When an object value is provided, it must either be \stdClass or implement the Serializable '
- . 'interface, you provided %s', print_r($value, true)
+ .'interface, you provided %s',
+ print_r($value, true)
));
}
}
diff --git a/src/Common/Transport/Middleware.php b/src/Common/Transport/Middleware.php
index d79828d7..e344b4fb 100644
--- a/src/Common/Transport/Middleware.php
+++ b/src/Common/Transport/Middleware.php
@@ -1,8 +1,9 @@
-getJsonKey()) {
$options['json'] = [$key => $options['json']];
}
- if (strpos(json_encode($options['json']), '\/') !== false) {
- $options['body'] = json_encode($options['json'], JSON_UNESCAPED_SLASHES);
+ if (false !== strpos(json_encode($options['json']), '\/')) {
+ $options['body'] = json_encode($options['json'], JSON_UNESCAPED_SLASHES);
$options['headers']['Content-Type'] = 'application/json';
unset($options['json']);
}
@@ -65,7 +64,7 @@ private function stockHeader(Parameter $schema, $paramValue, array &$options)
{
$paramName = $schema->getName();
- if (stripos($paramName, 'metadata') !== false) {
+ if (false !== stripos($paramName, 'metadata')) {
return $this->stockMetadataHeader($schema, $paramValue, $options);
}
@@ -82,7 +81,7 @@ private function stockMetadataHeader(Parameter $schema, $paramValue, array &$opt
private function stockJson(Parameter $schema, $paramValue, array &$options)
{
- $json = isset($options['json']) ? $options['json'] : [];
+ $json = isset($options['json']) ? $options['json'] : [];
$options['json'] = $this->jsonSerializer->stockJson($schema, $paramValue, $json);
}
diff --git a/src/Common/Transport/Utils.php b/src/Common/Transport/Utils.php
index 7217d446..88155f39 100644
--- a/src/Common/Transport/Utils.php
+++ b/src/Common/Transport/Utils.php
@@ -1,4 +1,6 @@
- 'JSON_ERROR_DEPTH - Maximum stack depth exceeded',
+ JSON_ERROR_DEPTH => 'JSON_ERROR_DEPTH - Maximum stack depth exceeded',
JSON_ERROR_STATE_MISMATCH => 'JSON_ERROR_STATE_MISMATCH - Underflow or the modes mismatch',
- JSON_ERROR_CTRL_CHAR => 'JSON_ERROR_CTRL_CHAR - Unexpected control character found',
- JSON_ERROR_SYNTAX => 'JSON_ERROR_SYNTAX - Syntax error, malformed JSON',
- JSON_ERROR_UTF8 => 'JSON_ERROR_UTF8 - Malformed UTF-8 characters, possibly incorrectly encoded'
+ JSON_ERROR_CTRL_CHAR => 'JSON_ERROR_CTRL_CHAR - Unexpected control character found',
+ JSON_ERROR_SYNTAX => 'JSON_ERROR_SYNTAX - Syntax error, malformed JSON',
+ JSON_ERROR_UTF8 => 'JSON_ERROR_UTF8 - Malformed UTF-8 characters, possibly incorrectly encoded',
];
$responseBody = (string) $response->getBody();
- if (strlen($responseBody) === 0) {
+ if (0 === strlen($responseBody)) {
return $responseBody;
}
@@ -29,7 +31,7 @@ public static function jsonDecode(ResponseInterface $response, bool $assoc = tru
if (JSON_ERROR_NONE !== json_last_error()) {
$last = json_last_error();
throw new \InvalidArgumentException(
- 'Unable to parse JSON data: ' . (isset($jsonErrors[$last]) ? $jsonErrors[$last] : 'Unknown error')
+ 'Unable to parse JSON data: '.(isset($jsonErrors[$last]) ? $jsonErrors[$last] : 'Unknown error')
);
}
@@ -39,8 +41,8 @@ public static function jsonDecode(ResponseInterface $response, bool $assoc = tru
/**
* Method for flattening a nested array.
*
- * @param array $data The nested array
- * @param string $key The key to extract
+ * @param array $data The nested array
+ * @param string $key The key to extract
*
* @return array
*/
@@ -55,17 +57,17 @@ public static function flattenJson($data, string $key = null)
* Append the http:// prefix if not present, and add a
* closing url separator when missing.
*
- * @param string $url The url representation.
+ * @param string $url the url representation
*
* @return string
*/
public static function normalizeUrl(string $url): string
{
- if (strpos($url, 'http') === false) {
- $url = 'http://' . $url;
+ if (false === strpos($url, 'http')) {
+ $url = 'http://'.$url;
}
- return rtrim($url, '/') . '/';
+ return rtrim($url, '/').'/';
}
/**
@@ -78,11 +80,11 @@ public static function normalizeUrl(string $url): string
*/
public static function addPaths(UriInterface $uri, ...$paths): UriInterface
{
- return uri_for(rtrim((string) $uri, '/') . '/' . implode('/', $paths));
+ return uri_for(rtrim((string) $uri, '/').'/'.implode('/', $paths));
}
public static function appendPath(UriInterface $uri, $path): UriInterface
{
- return uri_for(rtrim((string) $uri, '/') . '/' . $path);
+ return uri_for(rtrim((string) $uri, '/').'/'.$path);
}
}
diff --git a/src/Compute/v2/Api.php b/src/Compute/v2/Api.php
index be982b2b..369b4245 100644
--- a/src/Compute/v2/Api.php
+++ b/src/Compute/v2/Api.php
@@ -1,4 +1,6 @@
- 'GET',
- 'path' => 'limits',
- 'params' => []
+ 'path' => 'limits',
+ 'params' => [],
];
}
@@ -44,6 +45,7 @@ public function getFlavorsDetail(): array
{
$op = $this->getFlavors();
$op['path'] .= '/detail';
+
return $op;
}
@@ -52,24 +54,24 @@ public function getFlavor(): array
return [
'method' => 'GET',
'path' => 'flavors/{id}',
- 'params' => ['id' => $this->params->urlId('flavor')]
+ 'params' => ['id' => $this->params->urlId('flavor')],
];
}
public function postFlavors(): array
{
return [
- 'method' => 'POST',
- 'path' => 'flavors',
+ 'method' => 'POST',
+ 'path' => 'flavors',
'jsonKey' => 'flavor',
- 'params' => [
+ 'params' => [
'id' => $this->notRequired($this->params->id('flavor')),
'name' => $this->isRequired($this->params->name('flavor')),
'ram' => $this->params->flavorRam(),
'vcpus' => $this->params->flavorVcpus(),
'swap' => $this->params->flavorSwap(),
'disk' => $this->params->flavorDisk(),
- ]
+ ],
];
}
@@ -79,8 +81,8 @@ public function deleteFlavor(): array
'method' => 'DELETE',
'path' => 'flavors/{id}',
'params' => [
- 'id' => $this->params->idPath()
- ]
+ 'id' => $this->params->idPath(),
+ ],
];
}
@@ -105,6 +107,7 @@ public function getImagesDetail(): array
{
$op = $this->getImages();
$op['path'] .= '/detail';
+
return $op;
}
@@ -113,7 +116,7 @@ public function getImage(): array
return [
'method' => 'GET',
'path' => 'images/{id}',
- 'params' => ['id' => $this->params->urlId('image')]
+ 'params' => ['id' => $this->params->urlId('image')],
];
}
@@ -122,7 +125,7 @@ public function deleteImage(): array
return [
'method' => 'DELETE',
'path' => 'images/{id}',
- 'params' => ['id' => $this->params->urlId('image')]
+ 'params' => ['id' => $this->params->urlId('image')],
];
}
@@ -131,7 +134,7 @@ public function getImageMetadata(): array
return [
'method' => 'GET',
'path' => 'images/{id}/metadata',
- 'params' => ['id' => $this->params->urlId('image')]
+ 'params' => ['id' => $this->params->urlId('image')],
];
}
@@ -143,7 +146,7 @@ public function putImageMetadata(): array
'params' => [
'id' => $this->params->urlId('image'),
'metadata' => $this->params->metadata(),
- ]
+ ],
];
}
@@ -154,8 +157,8 @@ public function postImageMetadata(): array
'path' => 'images/{id}/metadata',
'params' => [
'id' => $this->params->urlId('image'),
- 'metadata' => $this->params->metadata()
- ]
+ 'metadata' => $this->params->metadata(),
+ ],
];
}
@@ -167,7 +170,7 @@ public function getImageMetadataKey(): array
'params' => [
'id' => $this->params->urlId('image'),
'key' => $this->params->key(),
- ]
+ ],
];
}
@@ -179,7 +182,7 @@ public function deleteImageMetadataKey(): array
'params' => [
'id' => $this->params->urlId('image'),
'key' => $this->params->key(),
- ]
+ ],
];
}
@@ -200,8 +203,8 @@ public function postServer(): array
'availabilityZone' => $this->params->availabilityZone(),
'networks' => $this->params->networks(),
'blockDeviceMapping' => $this->params->blockDeviceMapping(),
- 'keyName' => $this->params->keyName()
- ]
+ 'keyName' => $this->params->keyName(),
+ ],
];
}
@@ -219,7 +222,7 @@ public function getServers(): array
'name' => $this->params->filterName(),
'status' => $this->params->filterStatus('server'),
'host' => $this->params->filterHost(),
- 'allTenants' => $this->params->allTenants()
+ 'allTenants' => $this->params->allTenants(),
],
];
}
@@ -228,6 +231,7 @@ public function getServersDetail(): array
{
$definition = $this->getServers();
$definition['path'] .= '/detail';
+
return $definition;
}
@@ -279,6 +283,18 @@ public function changeServerPassword(): array
];
}
+ public function resetServerState(): array
+ {
+ return [
+ 'method' => 'POST',
+ 'path' => 'servers/{id}/action',
+ 'params' => [
+ 'id' => $this->params->urlId('server'),
+ 'resetState' => $this->params->resetState(),
+ ],
+ ];
+ }
+
public function rebootServer(): array
{
return [
@@ -292,26 +308,26 @@ public function rebootServer(): array
];
}
- public function startServer() : array
+ public function startServer(): array
{
return [
'method' => 'POST',
'path' => 'servers/{id}/action',
'params' => [
- 'id' => $this->params->urlId('server'),
- 'os-start' => $this->params->nullAction()
+ 'id' => $this->params->urlId('server'),
+ 'os-start' => $this->params->nullAction(),
],
];
}
- public function stopServer() : array
+ public function stopServer(): array
{
return [
'method' => 'POST',
'path' => 'servers/{id}/action',
'params' => [
- 'id' => $this->params->urlId('server'),
- 'os-stop' => $this->params->nullAction()
+ 'id' => $this->params->urlId('server'),
+ 'os-stop' => $this->params->nullAction(),
],
];
}
@@ -440,52 +456,52 @@ public function createServerImage(): array
public function getVncConsole(): array
{
return [
- 'method' => 'POST',
- 'path' => 'servers/{id}/action',
+ 'method' => 'POST',
+ 'path' => 'servers/{id}/action',
'jsonKey' => 'os-getVNCConsole',
- 'params' => [
- 'id' => $this->params->urlId('server'),
- 'type' => $this->params->consoleType()
- ]
+ 'params' => [
+ 'id' => $this->params->urlId('server'),
+ 'type' => $this->params->consoleType(),
+ ],
];
}
public function getSpiceConsole(): array
{
return [
- 'method' => 'POST',
- 'path' => 'servers/{id}/action',
+ 'method' => 'POST',
+ 'path' => 'servers/{id}/action',
'jsonKey' => 'os-getSPICEConsole',
- 'params' => [
- 'id' => $this->params->urlId('server'),
- 'type' => $this->params->consoleType()
- ]
+ 'params' => [
+ 'id' => $this->params->urlId('server'),
+ 'type' => $this->params->consoleType(),
+ ],
];
}
public function getSerialConsole(): array
{
return [
- 'method' => 'POST',
- 'path' => 'servers/{id}/action',
+ 'method' => 'POST',
+ 'path' => 'servers/{id}/action',
'jsonKey' => 'os-getSerialConsole',
- 'params' => [
- 'id' => $this->params->urlId('server'),
- 'type' => $this->params->consoleType()
- ]
+ 'params' => [
+ 'id' => $this->params->urlId('server'),
+ 'type' => $this->params->consoleType(),
+ ],
];
}
public function getRDPConsole(): array
{
return [
- 'method' => 'POST',
- 'path' => 'servers/{id}/action',
+ 'method' => 'POST',
+ 'path' => 'servers/{id}/action',
'jsonKey' => 'os-getRDPConsole',
- 'params' => [
- 'id' => $this->params->urlId('server'),
- 'type' => $this->params->consoleType()
- ]
+ 'params' => [
+ 'id' => $this->params->urlId('server'),
+ 'type' => $this->params->consoleType(),
+ ],
];
}
@@ -517,8 +533,8 @@ public function getInterfaceAttachments(): array
'path' => 'servers/{id}/os-interface',
'jsonKey' => 'interfaceAttachments',
'params' => [
- 'id' => $this->params->urlId('server')
- ]
+ 'id' => $this->params->urlId('server'),
+ ],
];
}
@@ -529,8 +545,8 @@ public function getInterfaceAttachment(): array
'path' => 'servers/{id}/os-interface/{portId}',
'params' => [
'id' => $this->params->urlId('server'),
- 'portId' => $this->params->portId()
- ]
+ 'portId' => $this->params->portId(),
+ ],
];
}
@@ -546,7 +562,7 @@ public function postInterfaceAttachment(): array
'networkId' => $this->notRequired($this->params->networkId()),
'fixedIpAddresses' => $this->notRequired($this->params->fixedIpAddresses()),
'tag' => $this->notRequired($this->params->tag()),
- ]
+ ],
];
}
@@ -557,8 +573,8 @@ public function deleteInterfaceAttachment(): array
'path' => 'servers/{id}/os-interface/{portId}',
'params' => [
'id' => $this->params->urlId('image'),
- 'portId' => $this->params->portId()
- ]
+ 'portId' => $this->params->portId(),
+ ],
];
}
@@ -567,7 +583,7 @@ public function getServerMetadata(): array
return [
'method' => 'GET',
'path' => 'servers/{id}/metadata',
- 'params' => ['id' => $this->params->urlId('server')]
+ 'params' => ['id' => $this->params->urlId('server')],
];
}
@@ -578,8 +594,8 @@ public function putServerMetadata(): array
'path' => 'servers/{id}/metadata',
'params' => [
'id' => $this->params->urlId('server'),
- 'metadata' => $this->params->metadata()
- ]
+ 'metadata' => $this->params->metadata(),
+ ],
];
}
@@ -590,8 +606,8 @@ public function postServerMetadata(): array
'path' => 'servers/{id}/metadata',
'params' => [
'id' => $this->params->urlId('server'),
- 'metadata' => $this->params->metadata()
- ]
+ 'metadata' => $this->params->metadata(),
+ ],
];
}
@@ -603,7 +619,7 @@ public function getServerMetadataKey(): array
'params' => [
'id' => $this->params->urlId('server'),
'key' => $this->params->key(),
- ]
+ ],
];
}
@@ -615,7 +631,7 @@ public function deleteServerMetadataKey(): array
'params' => [
'id' => $this->params->urlId('server'),
'key' => $this->params->key(),
- ]
+ ],
];
}
@@ -625,8 +641,8 @@ public function getKeypair(): array
'method' => 'GET',
'path' => 'os-keypairs/{name}',
'params' => [
- 'name' => $this->isRequired($this->params->keypairName()),
- 'userId' => $this->params->userId()
+ 'name' => $this->isRequired($this->params->keypairName()),
+ 'userId' => $this->params->userId(),
],
];
}
@@ -637,7 +653,7 @@ public function getKeypairs(): array
'method' => 'GET',
'path' => 'os-keypairs',
'params' => [
- 'userId' => $this->params->userId()
+ 'userId' => $this->params->userId(),
],
];
}
@@ -645,13 +661,13 @@ public function getKeypairs(): array
public function postKeypair(): array
{
return [
- 'method' => 'POST',
- 'path' => 'os-keypairs',
+ 'method' => 'POST',
+ 'path' => 'os-keypairs',
'jsonKey' => 'keypair',
- 'params' => [
- 'name' => $this->isRequired($this->params->name('keypair')),
+ 'params' => [
+ 'name' => $this->isRequired($this->params->name('keypair')),
'publicKey' => $this->params->keypairPublicKey(),
- ]
+ ],
];
}
@@ -661,18 +677,18 @@ public function deleteKeypair(): array
'method' => 'DELETE',
'path' => 'os-keypairs/{name}',
'params' => [
- 'name' => $this->isRequired($this->params->keypairName())
- ]
+ 'name' => $this->isRequired($this->params->keypairName()),
+ ],
];
}
public function postSecurityGroup(): array
{
return [
- 'method' => 'POST',
- 'path' => 'servers/{id}/action',
+ 'method' => 'POST',
+ 'path' => 'servers/{id}/action',
'jsonKey' => 'addSecurityGroup',
- 'params' => [
+ 'params' => [
'id' => $this->params->urlId('server'),
'name' => $this->isRequired($this->params->name('securityGroup')),
],
@@ -682,10 +698,10 @@ public function postSecurityGroup(): array
public function deleteSecurityGroup(): array
{
return [
- 'method' => 'POST',
- 'path' => 'servers/{id}/action',
+ 'method' => 'POST',
+ 'path' => 'servers/{id}/action',
'jsonKey' => 'removeSecurityGroup',
- 'params' => [
+ 'params' => [
'id' => $this->params->urlId('server'),
'name' => $this->isRequired($this->params->name('securityGroup')),
],
@@ -699,7 +715,7 @@ public function getSecurityGroups(): array
'path' => 'servers/{id}/os-security-groups',
'jsonKey' => 'security_groups',
'params' => [
- 'id' => $this->params->urlId('server')
+ 'id' => $this->params->urlId('server'),
],
];
}
@@ -707,25 +723,25 @@ public function getSecurityGroups(): array
public function getVolumeAttachments(): array
{
return [
- 'method' => 'GET',
- 'path' => 'servers/{id}/os-volume_attachments',
+ 'method' => 'GET',
+ 'path' => 'servers/{id}/os-volume_attachments',
'jsonKey' => 'volumeAttachments',
- 'params' => [
- 'id' => $this->params->urlId('server')
- ]
+ 'params' => [
+ 'id' => $this->params->urlId('server'),
+ ],
];
}
public function postVolumeAttachments(): array
{
return [
- 'method' => 'POST',
- 'path' => 'servers/{id}/os-volume_attachments',
+ 'method' => 'POST',
+ 'path' => 'servers/{id}/os-volume_attachments',
'jsonKey' => 'volumeAttachment',
- 'params' => [
- 'id' => $this->params->urlId('server'),
- 'volumeId' => $this->params->volumeId()
- ]
+ 'params' => [
+ 'id' => $this->params->urlId('server'),
+ 'volumeId' => $this->params->volumeId(),
+ ],
];
}
@@ -733,11 +749,11 @@ public function deleteVolumeAttachments(): array
{
return [
'method' => 'DELETE',
- 'path' => 'servers/{id}/os-volume_attachments/{attachmentId}',
+ 'path' => 'servers/{id}/os-volume_attachments/{attachmentId}',
'params' => [
- 'id' => $this->params->urlId('server'),
- 'attachmentId' => $this->params->attachmentId()
- ]
+ 'id' => $this->params->urlId('server'),
+ 'attachmentId' => $this->params->attachmentId(),
+ ],
];
}
@@ -747,7 +763,7 @@ public function getHypervisorStatistics(): array
'method' => 'GET',
'path' => 'os-hypervisors/statistics',
'params' => [
- ]
+ ],
];
}
@@ -759,7 +775,7 @@ public function getHypervisors(): array
'jsonKey' => 'hypervisors',
'params' => [
'limit' => $this->params->limit(),
- 'marker' => $this->params->marker()
+ 'marker' => $this->params->marker(),
],
];
}
@@ -777,7 +793,7 @@ public function getHypervisor(): array
return [
'method' => 'GET',
'path' => 'os-hypervisors/{id}',
- 'params' => ['id' => $this->params->urlId('id')]
+ 'params' => ['id' => $this->params->urlId('id')],
];
}
@@ -788,8 +804,8 @@ public function getAvailabilityZones(): array
'path' => 'os-availability-zone/detail',
'params' => [
'limit' => $this->params->limit(),
- 'marker' => $this->params->marker()
- ]
+ 'marker' => $this->params->marker(),
+ ],
];
}
@@ -800,8 +816,8 @@ public function getHosts(): array
'path' => 'os-hosts',
'params' => [
'limit' => $this->params->limit(),
- 'marker' => $this->params->marker()
- ]
+ 'marker' => $this->params->marker(),
+ ],
];
}
@@ -810,7 +826,7 @@ public function getHost(): array
return [
'method' => 'GET',
'path' => 'os-hosts/{name}',
- 'params' => ['name' => $this->params->urlId('name')]
+ 'params' => ['name' => $this->params->urlId('name')],
];
}
@@ -820,8 +836,8 @@ public function getQuotaSet(): array
'method' => 'GET',
'path' => 'os-quota-sets/{tenantId}',
'params' => [
- 'tenantId' => $this->params->urlId('quota-sets')
- ]
+ 'tenantId' => $this->params->urlId('quota-sets'),
+ ],
];
}
@@ -840,8 +856,8 @@ public function deleteQuotaSet(): array
'path' => 'os-quota-sets/{tenantId}',
'jsonKey' => 'quota_set',
'params' => [
- 'tenantId' => $this->params->urlId('quota-sets')
- ]
+ 'tenantId' => $this->params->urlId('quota-sets'),
+ ],
];
}
@@ -868,7 +884,7 @@ public function putQuotaSet(): array
'securityGroups' => $this->notRequired($this->params->quotaSetLimitSecurityGroups()),
'serverGroups' => $this->notRequired($this->params->quotaSetLimitServerGroups()),
'serverGroupMembers' => $this->notRequired($this->params->quotaSetLimitServerGroupMembers()),
- ]
+ ],
];
}
}
diff --git a/src/Compute/v2/Enum.php b/src/Compute/v2/Enum.php
index b9cbfa79..84e8f591 100644
--- a/src/Compute/v2/Enum.php
+++ b/src/Compute/v2/Enum.php
@@ -1,19 +1,19 @@
-execute($this->api->postFlavors(), $userOptions);
+
return $this->populateFromResponse($response);
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function delete()
{
diff --git a/src/Compute/v2/Models/Host.php b/src/Compute/v2/Models/Host.php
index f824c909..e9092116 100644
--- a/src/Compute/v2/Models/Host.php
+++ b/src/Compute/v2/Models/Host.php
@@ -1,9 +1,9 @@
- 'name'
+ 'host_name' => 'name',
];
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function retrieve()
{
diff --git a/src/Compute/v2/Models/Hypervisor.php b/src/Compute/v2/Models/Hypervisor.php
index 47f95fb5..e18cd5df 100644
--- a/src/Compute/v2/Models/Hypervisor.php
+++ b/src/Compute/v2/Models/Hypervisor.php
@@ -1,4 +1,6 @@
- 'vcpusUsed',
'cpu_info' => 'cpuInfo',
'current_workload' => 'currentWorkload',
- 'disk_available_least' => 'diskAvailableLeast'
+ 'disk_available_least' => 'diskAvailableLeast',
];
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function retrieve()
{
diff --git a/src/Compute/v2/Models/HypervisorStatistic.php b/src/Compute/v2/Models/HypervisorStatistic.php
index e73501b0..b9bf0e0f 100644
--- a/src/Compute/v2/Models/HypervisorStatistic.php
+++ b/src/Compute/v2/Models/HypervisorStatistic.php
@@ -1,14 +1,13 @@
- new Alias('created', \DateTimeImmutable::class),
- 'updated' => new Alias('updated', \DateTimeImmutable::class)
+ 'updated' => new Alias('updated', \DateTimeImmutable::class),
];
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function retrieve()
{
- $response = $this->execute($this->api->getImage(), ['id' => (string)$this->id]);
+ $response = $this->execute($this->api->getImage(), ['id' => (string) $this->id]);
$this->populateFromResponse($response);
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function delete()
{
- $this->execute($this->api->deleteImage(), ['id' => (string)$this->id]);
+ $this->execute($this->api->deleteImage(), ['id' => (string) $this->id]);
}
/**
@@ -87,6 +89,7 @@ public function delete()
public function getMetadata(): array
{
$response = $this->execute($this->api->getImageMetadata(), ['id' => $this->id]);
+
return $this->parseMetadata($response);
}
@@ -98,7 +101,7 @@ public function getMetadata(): array
*/
public function resetMetadata(array $metadata)
{
- $response = $this->execute($this->api->putImageMetadata(), ['id' => $this->id, 'metadata' => $metadata]);
+ $response = $this->execute($this->api->putImageMetadata(), ['id' => $this->id, 'metadata' => $metadata]);
$this->metadata = $this->parseMetadata($response);
}
@@ -111,7 +114,7 @@ public function resetMetadata(array $metadata)
*/
public function mergeMetadata(array $metadata)
{
- $response = $this->execute($this->api->postImageMetadata(), ['id' => $this->id, 'metadata' => $metadata]);
+ $response = $this->execute($this->api->postImageMetadata(), ['id' => $this->id, 'metadata' => $metadata]);
$this->metadata = $this->parseMetadata($response);
}
@@ -124,9 +127,10 @@ public function mergeMetadata(array $metadata)
*/
public function getMetadataItem(string $key)
{
- $response = $this->execute($this->api->getImageMetadataKey(), ['id' => $this->id, 'key' => $key]);
- $value = $this->parseMetadata($response)[$key];
+ $response = $this->execute($this->api->getImageMetadataKey(), ['id' => $this->id, 'key' => $key]);
+ $value = $this->parseMetadata($response)[$key];
$this->metadata[$key] = $value;
+
return $value;
}
diff --git a/src/Compute/v2/Models/Keypair.php b/src/Compute/v2/Models/Keypair.php
index 8a270729..4bd2625e 100644
--- a/src/Compute/v2/Models/Keypair.php
+++ b/src/Compute/v2/Models/Keypair.php
@@ -1,4 +1,6 @@
- 'publicKey',
+ 'public_key' => 'publicKey',
'private_key' => 'privateKey',
- 'user_id' => 'userId',
+ 'user_id' => 'userId',
];
- protected $resourceKey = 'keypair';
+ protected $resourceKey = 'keypair';
protected $resourcesKey = 'keypairs';
/**
- * @inheritdoc
+ * {@inheritdoc}
*/
protected function getAliases(): array
{
return parent::getAliases() + [
- 'created_at' => new Alias('createdAt', \DateTimeImmutable::class)
+ 'created_at' => new Alias('createdAt', \DateTimeImmutable::class),
];
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function retrieve()
{
@@ -72,11 +74,12 @@ public function retrieve()
public function create(array $userOptions): Creatable
{
$response = $this->execute($this->api->postKeypair(), $userOptions);
+
return $this->populateFromResponse($response);
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function populateFromArray(array $array): self
{
@@ -84,7 +87,7 @@ public function populateFromArray(array $array): self
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function delete()
{
diff --git a/src/Compute/v2/Models/Limit.php b/src/Compute/v2/Models/Limit.php
index f13871c4..ad4051b6 100644
--- a/src/Compute/v2/Models/Limit.php
+++ b/src/Compute/v2/Models/Limit.php
@@ -1,11 +1,13 @@
-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 delete()
{
@@ -160,7 +166,7 @@ public function delete()
}
/**
- * @inheritdoc
+ * {@inheritdoc}
*/
public function update()
{
diff --git a/src/Compute/v2/Models/Server.php b/src/Compute/v2/Models/Server.php
index cc206f62..1378da05 100644
--- a/src/Compute/v2/Models/Server.php
+++ b/src/Compute/v2/Models/Server.php
@@ -1,4 +1,6 @@
- 'blockDeviceMapping',
@@ -117,7 +114,7 @@ class Server extends OperatorResource implements
];
/**
- * @inheritdoc
+ * {@inheritdoc}
*/
protected function getAliases(): array
{
@@ -125,12 +122,12 @@ protected function getAliases(): array
'image' => new Alias('image', Image::class),
'flavor' => new Alias('flavor', Flavor::class),
'created' => new Alias('created', \DateTimeImmutable::class),
- 'updated' => new Alias('updated', \DateTimeImmutable::class)
+ 'updated' => new Alias('updated', \DateTimeImmutable::class),
];
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*
* @param array $userOptions {@see \OpenStack\Compute\v2\Api::postServer}
*/
@@ -141,11 +138,12 @@ public function create(array $userOptions): Creatable
}
$response = $this->execute($this->api->postServer(), $userOptions);
+
return $this->populateFromResponse($response);
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function update()
{
@@ -154,7 +152,7 @@ public function update()
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function delete()
{
@@ -162,7 +160,7 @@ public function delete()
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function retrieve()
{
@@ -183,6 +181,17 @@ public function changePassword(string $newPassword)
]);
}
+ /**
+ * Issue a resetState call to the server.
+ */
+ public function resetState()
+ {
+ $this->execute($this->api->resetServerState(), [
+ 'id' => $this->id,
+ 'resetState' => ['state' => 'active'],
+ ]);
+ }
+
/**
* Reboots the server.
*
@@ -201,24 +210,24 @@ public function reboot(string $type = Enum::REBOOT_SOFT)
}
/**
- * Starts server
+ * Starts server.
*/
public function start()
{
$this->execute($this->api->startServer(), [
- 'id' => $this->id,
- 'os-start' => null
+ 'id' => $this->id,
+ 'os-start' => null,
]);
}
/**
- * Stops server
+ * Stops server.
*/
public function stop()
{
$this->execute($this->api->stopServer(), [
- 'id' => $this->id,
- 'os-stop' => null
+ 'id' => $this->id,
+ 'os-stop' => null,
]);
}
@@ -230,7 +239,7 @@ public function stop()
public function rebuild(array $options)
{
$options['id'] = $this->id;
- $response = $this->execute($this->api->rebuildServer(), $options);
+ $response = $this->execute($this->api->rebuildServer(), $options);
$this->populateFromResponse($response);
}
@@ -239,12 +248,13 @@ public function rebuild(array $options)
* Rescues the server.
*
* @param array $options {@see \OpenStack\Compute\v2\Api::rescueServer}
+ *
* @return string
*/
public function rescue(array $options): string
{
$options['id'] = $this->id;
- $response = $this->execute($this->api->rescueServer(), $options);
+ $response = $this->execute($this->api->rescueServer(), $options);
return Utils::jsonDecode($response)['adminPass'];
}
@@ -261,7 +271,7 @@ public function unrescue()
* Resizes the server to a new flavor. Once this operation is complete and server has transitioned
* to an active state, you will either need to call {@see confirmResize()} or {@see revertResize()}.
*
- * @param string $flavorId The UUID of the new flavor your server will be based on.
+ * @param string $flavorId the UUID of the new flavor your server will be based on
*/
public function resize(string $flavorId)
{
@@ -292,7 +302,8 @@ public function revertResize()
/**
* Gets the console output of the server.
*
- * @param int $length The number of lines, by default all lines will be returned.
+ * @param int $length the number of lines, by default all lines will be returned
+ *
* @return string
*/
public function getConsoleOutput(int $length = -1): string
@@ -301,8 +312,8 @@ public function getConsoleOutput(int $length = -1): string
$response = $this->execute($definition, [
'os-getConsoleOutput' => new \stdClass(),
- 'id' => $this->id,
- 'length' => $length,
+ 'id' => $this->id,
+ 'length' => $length,
]);
return Utils::jsonDecode($response)['output'];
@@ -311,53 +322,57 @@ public function getConsoleOutput(int $length = -1): string
/**
* Gets a VNC console for a server.
*
- * @param string $type The type of VNC console: novnc|xvpvnc.
- * Defaults to novnc.
+ * @param string $type The type of VNC console: novnc|xvpvnc.
+ * Defaults to novnc.
*
* @return array
*/
public function getVncConsole($type = Enum::CONSOLE_NOVNC): array
{
$response = $this->execute($this->api->getVncConsole(), ['id' => $this->id, 'type' => $type]);
+
return Utils::jsonDecode($response)['console'];
}
/**
* Gets a RDP console for a server.
*
- * @param string $type The type of VNC console: rdp-html5 (default).
+ * @param string $type the type of VNC console: rdp-html5 (default)
*
* @return array
*/
public function getRDPConsole($type = Enum::CONSOLE_RDP_HTML5): array
{
$response = $this->execute($this->api->getRDPConsole(), ['id' => $this->id, 'type' => $type]);
+
return Utils::jsonDecode($response)['console'];
}
/**
* Gets a Spice console for a server.
*
- * @param string $type The type of VNC console: spice-html5.
+ * @param string $type the type of VNC console: spice-html5
*
* @return array
*/
public function getSpiceConsole($type = Enum::CONSOLE_SPICE_HTML5): array
{
$response = $this->execute($this->api->getSpiceConsole(), ['id' => $this->id, 'type' => $type]);
+
return Utils::jsonDecode($response)['console'];
}
/**
* Gets a serial console for a server.
*
- * @param string $type The type of VNC console: serial.
+ * @param string $type the type of VNC console: serial
*
* @return array
*/
public function getSerialConsole($type = Enum::CONSOLE_SERIAL): array
{
$response = $this->execute($this->api->getSerialConsole(), ['id' => $this->id, 'type' => $type]);
+
return Utils::jsonDecode($response)['console'];
}
@@ -383,13 +398,14 @@ public function listAddresses(array $options = []): array
{
$options['id'] = $this->id;
- $data = (isset($options['networkLabel'])) ? $this->api->getAddressesByNetwork() : $this->api->getAddresses();
+ $data = (isset($options['networkLabel'])) ? $this->api->getAddressesByNetwork() : $this->api->getAddresses();
$response = $this->execute($data, $options);
+
return Utils::jsonDecode($response)['addresses'];
}
/**
- * Returns Generator for InterfaceAttachment
+ * Returns Generator for InterfaceAttachment.
*
* @return \Generator
*/
@@ -401,14 +417,15 @@ public function listInterfaceAttachments(array $options = []): \Generator
/**
* Gets an interface attachment.
*
- * @param string $portId The unique ID of the port.
+ * @param string $portId the unique ID of the port
+ *
* @return InterfaceAttachment
*/
public function getInterfaceAttachment(string $portId): InterfaceAttachment
{
$response = $this->execute($this->api->getInterfaceAttachment(), [
'id' => $this->id,
- 'portId' => $portId
+ 'portId' => $portId,
]);
return $this->model(InterfaceAttachment::class)->populateFromResponse($response);
@@ -418,6 +435,7 @@ public function getInterfaceAttachment(string $portId): InterfaceAttachment
* Creates an interface attachment.
*
* @param array $userOptions {@see \OpenStack\Compute\v2\Api::postInterfaceAttachment}
+ *
* @return InterfaceAttachment
*/
public function createInterfaceAttachment(array $userOptions): InterfaceAttachment
@@ -427,6 +445,7 @@ public function createInterfaceAttachment(array $userOptions): InterfaceAttachme
}
$response = $this->execute($this->api->postInterfaceAttachment(), array_merge($userOptions, ['id' => $this->id]));
+
return $this->model(InterfaceAttachment::class)->populateFromResponse($response);
}
@@ -438,7 +457,7 @@ public function createInterfaceAttachment(array $userOptions): InterfaceAttachme
public function detachInterface(string $portId)
{
$this->execute($this->api->deleteInterfaceAttachment(), [
- 'id' => $this->id,
+ 'id' => $this->id,
'portId' => $portId,
]);
}
@@ -451,6 +470,7 @@ public function detachInterface(string $portId)
public function getMetadata(): array
{
$response = $this->execute($this->api->getServerMetadata(), ['id' => $this->id]);
+
return $this->parseMetadata($response);
}
@@ -462,7 +482,7 @@ public function getMetadata(): array
*/
public function resetMetadata(array $metadata)
{
- $response = $this->execute($this->api->putServerMetadata(), ['id' => $this->id, 'metadata' => $metadata]);
+ $response = $this->execute($this->api->putServerMetadata(), ['id' => $this->id, 'metadata' => $metadata]);
$this->metadata = $this->parseMetadata($response);
}
@@ -477,7 +497,7 @@ public function resetMetadata(array $metadata)
*/
public function mergeMetadata(array $metadata)
{
- $response = $this->execute($this->api->postServerMetadata(), ['id' => $this->id, 'metadata' => $metadata]);
+ $response = $this->execute($this->api->postServerMetadata(), ['id' => $this->id, 'metadata' => $metadata]);
$this->metadata = $this->parseMetadata($response);
}
@@ -490,9 +510,10 @@ public function mergeMetadata(array $metadata)
*/
public function getMetadataItem(string $key)
{
- $response = $this->execute($this->api->getServerMetadataKey(), ['id' => $this->id, 'key' => $key]);
- $value = $this->parseMetadata($response)[$key];
+ $response = $this->execute($this->api->getServerMetadataKey(), ['id' => $this->id, 'key' => $key]);
+ $value = $this->parseMetadata($response)[$key];
$this->metadata[$key] = $value;
+
return $value;
}
@@ -510,15 +531,14 @@ public function deleteMetadataItem(string $key)
$this->execute($this->api->deleteServerMetadataKey(), ['id' => $this->id, 'key' => $key]);
}
-
/**
- * Add security group to a server (addSecurityGroup action)
+ * Add security group to a server (addSecurityGroup action).
*
* @param array $options {@see \OpenStack\Compute\v2\Api::postSecurityGroup}
*
* @return SecurityGroup
*/
- public function addSecurityGroup(array $options) : SecurityGroup
+ public function addSecurityGroup(array $options): SecurityGroup
{
$options['id'] = $this->id;
@@ -528,7 +548,7 @@ public function addSecurityGroup(array $options) : SecurityGroup
}
/**
- * Add security group to a server (addSecurityGroup action)
+ * Add security group to a server (addSecurityGroup action).
*
* @param array $options {@see \OpenStack\Compute\v2\Api::deleteSecurityGroup}
*/
@@ -544,7 +564,7 @@ public function parseMetadata(ResponseInterface $response): array
}
/**
- * Returns Generator for SecurityGroups
+ * Returns Generator for SecurityGroups.
*
* @return \Generator
*/
@@ -553,9 +573,8 @@ public function listSecurityGroups(): \Generator
return $this->model(SecurityGroup::class)->enumerate($this->api->getSecurityGroups(), ['id' => $this->id]);
}
-
/**
- * Returns Generator for VolumeAttachment
+ * Returns Generator for VolumeAttachment.
*
* @return \Generator
*/
@@ -565,7 +584,7 @@ public function listVolumeAttachments(): \Generator
}
/**
- * Attach a volume and returns volume that was attached
+ * Attach a volume and returns volume that was attached.
*
* @param $volumeId
*
@@ -579,11 +598,9 @@ public function attachVolume(string $volumeId): VolumeAttachment
}
/**
- * Detach a volume
+ * Detach a volume.
*
* @param $attachmentId
- *
- * @return void
*/
public function detachVolume(string $attachmentId)
{
diff --git a/src/Compute/v2/Params.php b/src/Compute/v2/Params.php
index d541c464..b0a5b9d5 100644
--- a/src/Compute/v2/Params.php
+++ b/src/Compute/v2/Params.php
@@ -1,4 +1,6 @@
- self::OBJECT_TYPE,
+ 'location' => self::JSON,
+ 'sentAs' => 'os-resetState',
+ 'required' => true,
+ 'properties' => [
+ 'state' => ['type' => self::STRING_TYPE],
+ ],
+ ];
+ }
+
public function minDisk(): array
{
return [
@@ -47,7 +62,7 @@ public function filterChangesSince($type)
'location' => self::QUERY,
'sentAs' => 'changes-since',
'description' => sprintf(
- "Return %ss which have been changed since a certain time. This value needs to be in an ISO 8601 format.",
+ 'Return %ss which have been changed since a certain time. This value needs to be in an ISO 8601 format.',
$type
),
];
@@ -57,7 +72,7 @@ public function flavorServer(): array
{
return [
'location' => self::QUERY,
- 'description' => sprintf("Return images which are associated with a server. This value needs to be in a URL format.")
+ 'description' => sprintf('Return images which are associated with a server. This value needs to be in a URL format.'),
];
}
@@ -66,9 +81,9 @@ public function filterStatus(string $type): array
return [
'location' => self::QUERY,
'description' => sprintf(
- "Return %ss that have a particular status, such as \"ACTIVE\".",
+ 'Return %ss that have a particular status, such as "ACTIVE".',
$type
- )
+ ),
];
}
@@ -175,7 +190,7 @@ public function fixedIpAddresses(): array
'description' => 'A list of ip addresses which this interface will be associated with',
'items' => [
'type' => self::OBJECT_TYPE,
- 'properties' => ['ip_address' => ['type' => self::STRING_TYPE]]
+ 'properties' => ['ip_address' => ['type' => self::STRING_TYPE]],
],
];
}
@@ -192,7 +207,7 @@ public function metadata(): array
'description' => << [
'path' => [
'type' => self::STRING_TYPE,
- 'description' => 'The path, on the filesystem, where the personality file will be placed'
+ 'description' => 'The path, on the filesystem, where the personality file will be placed',
],
'contents' => [
'type' => self::STRING_TYPE,
- 'description' => 'Base64-encoded content of the personality file'
+ 'description' => 'Base64-encoded content of the personality file',
],
- ]
+ ],
],
'description' => << 'A list of security group objects which this server will be associated with',
'items' => [
'type' => self::OBJECT_TYPE,
- 'properties' => ['name' => $this->name('security group')]
+ 'properties' => ['name' => $this->name('security group')],
],
];
}
@@ -285,8 +299,8 @@ public function networks(): array
a networks object. The port status must be DOWN. Required if you omit the uuid attribute.
EOL
],
- ]
- ]
+ ],
+ ],
];
}
@@ -342,7 +356,7 @@ public function blockDeviceMapping(): array
'sentAs' => 'volume_size',
'description' => 'Size of the volume created if we are doing vol creation',
],
- ]
+ ],
],
];
}
@@ -411,7 +425,7 @@ public function nullAction(): array
return [
'type' => self::NULL_TYPE,
'location' => self::JSON,
- 'required' => true
+ 'required' => true,
];
}
@@ -454,10 +468,10 @@ public function keypairName(): array
public function userId(): array
{
return [
- 'type' => self::STRING_TYPE,
- 'sentAs' => 'user_id',
- 'location' => self::QUERY,
- 'description' => 'This allows administrative users to operate key-pairs of specified user ID. Requires micro version 2.10.'
+ 'type' => self::STRING_TYPE,
+ 'sentAs' => 'user_id',
+ 'location' => self::QUERY,
+ 'description' => 'This allows administrative users to operate key-pairs of specified user ID. Requires micro version 2.10.',
];
}
@@ -465,7 +479,7 @@ public function flavorRam(): array
{
return [
'type' => self::INT_TYPE,
- 'location' => self::JSON
+ 'location' => self::JSON,
];
}
@@ -473,7 +487,7 @@ public function flavorVcpus(): array
{
return [
'type' => self::INT_TYPE,
- 'location' => self::JSON
+ 'location' => self::JSON,
];
}
@@ -481,7 +495,7 @@ public function flavorDisk(): array
{
return [
'type' => self::INT_TYPE,
- 'location' => self::JSON
+ 'location' => self::JSON,
];
}
@@ -489,7 +503,7 @@ public function flavorSwap(): array
{
return [
'type' => self::INT_TYPE,
- 'location' => self::JSON
+ 'location' => self::JSON,
];
}
@@ -515,7 +529,7 @@ public function consoleType(): array
return [
'type' => self::STRING_TYPE,
'location' => self::JSON,
- 'required' => true
+ 'required' => true,
];
}
@@ -541,7 +555,7 @@ protected function quotaSetLimit($sentAs, $description): array
'type' => self::INT_TYPE,
'location' => self::JSON,
'sentAs' => $sentAs,
- 'description' => $description
+ 'description' => $description,
];
}
@@ -551,7 +565,7 @@ public function quotaSetLimitForce(): array
'type' => self::BOOLEAN_TYPE,
'location' => self::JSON,
'sentAs' => 'force',
- 'description' => 'You can force the update even if the quota has already been used and the reserved quota exceeds the new quota'
+ 'description' => 'You can force the update even if the quota has already been used and the reserved quota exceeds the new quota',
];
}
diff --git a/src/Compute/v2/Service.php b/src/Compute/v2/Service.php
index fe4590df..b2c8c9b5 100644
--- a/src/Compute/v2/Service.php
+++ b/src/Compute/v2/Service.php
@@ -1,4 +1,6 @@
-api->getServersDetail() : $this->api->getServers();
+ $def = (true === $detailed) ? $this->api->getServersDetail() : $this->api->getServers();
+
return $this->model(Server::class)->enumerate($def, $options, $mapFn);
}
/**
* Retrieve a server object without calling the remote API. Any values provided in the array will populate the
* empty object, allowing you greater control without the expense of network transactions. To call the remote API
- * and have the response populate the object, call {@see Server::retrieve}. For example:
+ * and have the response populate the object, call {@see Server::retrieve}. For example:.
*
* $server = $service->getServer(['id' => '{serverId}']);
*
@@ -66,6 +69,7 @@ public function getServer(array $options = []): Server
{
$server = $this->model(Server::class);
$server->populateFromArray($options);
+
return $server;
}
@@ -73,14 +77,15 @@ public function getServer(array $options = []): Server
* List flavors.
*
* @param array $options {@see \OpenStack\Compute\v2\Api::getFlavors}
- * @param callable $mapFn A callable function that will be invoked on every iteration of the list.
- * @param bool $detailed Set to true to fetch flavors' details.
+ * @param callable $mapFn a callable function that will be invoked on every iteration of the list
+ * @param bool $detailed set to true to fetch flavors' details
*
* @return \Generator
*/
public function listFlavors(array $options = [], callable $mapFn = null, bool $detailed = false): \Generator
{
- $def = $detailed === true ? $this->api->getFlavorsDetail() : $this->api->getFlavors();
+ $def = true === $detailed ? $this->api->getFlavorsDetail() : $this->api->getFlavors();
+
return $this->model(Flavor::class)->enumerate($def, $options, $mapFn);
}
@@ -98,6 +103,7 @@ public function getFlavor(array $options = []): Flavor
{
$flavor = $this->model(Flavor::class);
$flavor->populateFromArray($options);
+
return $flavor;
}
@@ -117,7 +123,7 @@ public function createFlavor(array $options = []): Flavor
* List images.
*
* @param array $options {@see \OpenStack\Compute\v2\Api::getImages}
- * @param callable $mapFn A callable function that will be invoked on every iteration of the list.
+ * @param callable $mapFn a callable function that will be invoked on every iteration of the list
*
* @return \Generator
*/
@@ -140,6 +146,7 @@ public function getImage(array $options = []): Image
{
$image = $this->model(Image::class);
$image->populateFromArray($options);
+
return $image;
}
@@ -147,7 +154,7 @@ public function getImage(array $options = []): Image
* List key pairs.
*
* @param array $options {@see \OpenStack\Compute\v2\Api::getKeyPairs}
- * @param callable $mapFn A callable function that will be invoked on every iteration of the list.
+ * @param callable $mapFn a callable function that will be invoked on every iteration of the list
*
* @return \Generator
*/
@@ -157,7 +164,7 @@ public function listKeypairs(array $options = [], callable $mapFn = null): \Gene
}
/**
- * Create or import keypair
+ * Create or import keypair.
*
* @param array $options
*
@@ -169,7 +176,7 @@ public function createKeypair(array $options): Keypair
}
/**
- * Get keypair
+ * Get keypair.
*
* @param array $options
*
@@ -179,11 +186,12 @@ public function getKeypair(array $options = []): Keypair
{
$keypair = $this->model(Keypair::class);
$keypair->populateFromArray($options);
+
return $keypair;
}
/**
- * Shows rate and absolute limits for the tenant
+ * Shows rate and absolute limits for the tenant.
*
* @return Limit
*/
@@ -191,6 +199,7 @@ public function getLimits(): Limit
{
$limits = $this->model(Limit::class);
$limits->populateFromResponse($this->execute($this->api->getLimits(), []));
+
return $limits;
}
@@ -203,6 +212,7 @@ public function getHypervisorStatistics(): HypervisorStatistic
{
$statistics = $this->model(HypervisorStatistic::class);
$statistics->populateFromResponse($this->execute($this->api->getHypervisorStatistics(), []));
+
return $statistics;
}
@@ -212,13 +222,14 @@ public function getHypervisorStatistics(): HypervisorStatistic
* @param bool $detailed Determines whether detailed information will be returned. If FALSE is specified, only
* the ID, name and links attributes are returned, saving bandwidth.
* @param array $options {@see \OpenStack\Compute\v2\Api::getHypervisors}
- * @param callable $mapFn A callable function that will be invoked on every iteration of the list.
+ * @param callable $mapFn a callable function that will be invoked on every iteration of the list
*
* @return \Generator
*/
public function listHypervisors(bool $detailed = false, array $options = [], callable $mapFn = null): \Generator
{
- $def = ($detailed === true) ? $this->api->getHypervisorsDetail() : $this->api->getHypervisors();
+ $def = (true === $detailed) ? $this->api->getHypervisorsDetail() : $this->api->getHypervisors();
+
return $this->model(Hypervisor::class)->enumerate($def, $options, $mapFn);
}
@@ -232,6 +243,7 @@ public function listHypervisors(bool $detailed = false, array $options = [], cal
public function getHypervisor(array $options = []): Hypervisor
{
$hypervisor = $this->model(Hypervisor::class);
+
return $hypervisor->populateFromArray($options);
}
@@ -239,7 +251,7 @@ public function getHypervisor(array $options = []): Hypervisor
* List hosts.
*
* @param array $options {@see \OpenStack\Compute\v2\Api::getHosts}
- * @param callable $mapFn A callable function that will be invoked on every iteration of the list.
+ * @param callable $mapFn a callable function that will be invoked on every iteration of the list
*
* @return \Generator
*/
@@ -251,7 +263,7 @@ public function listHosts(array $options = [], callable $mapFn = null): \Generat
/**
* Retrieve a host object without calling the remote API. Any values provided in the array will populate the
* empty object, allowing you greater control without the expense of network transactions. To call the remote API
- * and have the response populate the object, call {@see Host::retrieve}. For example:
+ * and have the response populate the object, call {@see Host::retrieve}. For example:.
*
* $server = $service->getHost(['name' => '{name}']);
*
@@ -264,14 +276,15 @@ public function getHost(array $options = []): Host
{
$host = $this->model(Host::class);
$host->populateFromArray($options);
+
return $host;
}
/**
- * List AZs
+ * List AZs.
*
* @param array $options {@see \OpenStack\Compute\v2\Api::getAvailabilityZones}
- * @param callable $mapFn A callable function that will be invoked on every iteration of the list.
+ * @param callable $mapFn a callable function that will be invoked on every iteration of the list
*
* @return \Generator
*/
@@ -281,10 +294,10 @@ public function listAvailabilityZones(array $options = [], callable $mapFn = nul
}
/**
- * Shows A Quota for a tenant
+ * Shows A Quota for a tenant.
*
* @param string $tenantId
- * @param bool $detailed
+ * @param bool $detailed
*
* @return QuotaSet
*/
diff --git a/src/Identity/v2/Api.php b/src/Identity/v2/Api.php
index 38623d80..5024b359 100644
--- a/src/Identity/v2/Api.php
+++ b/src/Identity/v2/Api.php
@@ -1,4 +1,6 @@
- 'tokens',
'params' => [
'username' => [
- 'type' => 'string',
+ 'type' => 'string',
'required' => true,
- 'path' => 'auth.passwordCredentials'
+ 'path' => 'auth.passwordCredentials',
],
'password' => [
- 'type' => 'string',
+ 'type' => 'string',
'required' => true,
- 'path' => 'auth.passwordCredentials'
+ 'path' => 'auth.passwordCredentials',
],
'tenantId' => [
'type' => 'string',
@@ -34,7 +34,7 @@ public function postToken(): array
'tenantName' => [
'type' => 'string',
'path' => 'auth',
- ]
+ ],
],
];
}
diff --git a/src/Identity/v2/Models/Catalog.php b/src/Identity/v2/Models/Catalog.php
index 6081507a..161396a9 100644
--- a/src/Identity/v2/Models/Catalog.php
+++ b/src/Identity/v2/Models/Catalog.php
@@ -1,4 +1,6 @@
- new Alias('entries', Entry::class, true)
+ 'entries' => new Alias('entries', Entry::class, true),
];
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function populateFromResponse(ResponseInterface $response): self
{
@@ -61,7 +61,10 @@ public function getServiceUrl(
throw new \RuntimeException(sprintf(
"Endpoint URL could not be found in the catalog for this service.\nName: %s\nType: %s\nRegion: %s\nURL type: %s",
- $serviceName, $serviceType, $region, $urlType
+ $serviceName,
+ $serviceType,
+ $region,
+ $urlType
));
}
}
diff --git a/src/Identity/v2/Models/Endpoint.php b/src/Identity/v2/Models/Endpoint.php
index b0c215e9..e58f9f18 100644
--- a/src/Identity/v2/Models/Endpoint.php
+++ b/src/Identity/v2/Models/Endpoint.php
@@ -1,4 +1,6 @@
- new Alias('endpoints', Endpoint::class, true)
+ 'endpoints' => new Alias('endpoints', Endpoint::class, true),
];
}
@@ -45,7 +45,7 @@ public function matches(string $name, string $type): bool
}
/**
- * Retrieves the catalog entry's URL according to a specific region and URL type
+ * Retrieves the catalog entry's URL according to a specific region and URL type.
*
* @param string $region
* @param string $urlType
@@ -60,6 +60,6 @@ public function getEndpointUrl(string $region, string $urlType): string
}
}
- return "";
+ return '';
}
}
diff --git a/src/Identity/v2/Models/Tenant.php b/src/Identity/v2/Models/Tenant.php
index 9f85a839..bd83cb6b 100644
--- a/src/Identity/v2/Models/Tenant.php
+++ b/src/Identity/v2/Models/Tenant.php
@@ -1,4 +1,6 @@
- new Alias('tenant', Tenant::class),
'expires' => new Alias('expires', \DateTimeImmutable::class),
- 'issued_at' => new Alias('issuedAt', \DateTimeImmutable::class)
+ 'issued_at' => new Alias('issuedAt', \DateTimeImmutable::class),
];
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function populateFromResponse(ResponseInterface $response): self
{
diff --git a/src/Identity/v2/Service.php b/src/Identity/v2/Service.php
index ebc246ac..cded85fa 100644
--- a/src/Identity/v2/Service.php
+++ b/src/Identity/v2/Service.php
@@ -1,4 +1,6 @@
-execute($this->api->postToken(), $options);
+
return $this->model(Token::class, $response);
}
}
diff --git a/src/Identity/v3/Api.php b/src/Identity/v3/Api.php
index fc206f49..325e3ac1 100644
--- a/src/Identity/v3/Api.php
+++ b/src/Identity/v3/Api.php
@@ -1,4 +1,6 @@
- $this->params->user(),
'tokenId' => $this->params->tokenBody(),
'scope' => $this->params->scope(),
- ]
+ ],
];
}
@@ -30,7 +32,7 @@ public function getTokens(): array
return [
'method' => 'GET',
'path' => 'auth/tokens',
- 'params' => ['tokenId' => $this->params->tokenId()]
+ 'params' => ['tokenId' => $this->params->tokenId()],
];
}
@@ -39,7 +41,7 @@ public function headTokens(): array
return [
'method' => 'HEAD',
'path' => 'auth/tokens',
- 'params' => ['tokenId' => $this->params->tokenId()]
+ 'params' => ['tokenId' => $this->params->tokenId()],
];
}
@@ -48,7 +50,7 @@ public function deleteTokens(): array
return [
'method' => 'DELETE',
'path' => 'auth/tokens',
- 'params' => ['tokenId' => $this->params->tokenId()]
+ 'params' => ['tokenId' => $this->params->tokenId()],
];
}
@@ -59,10 +61,10 @@ public function postServices(): array
'path' => 'services',
'jsonKey' => 'service',
'params' => [
- 'name' => $this->params->name('service'),
- 'type' => $this->params->type('service'),
+ 'name' => $this->params->name('service'),
+ 'type' => $this->params->type('service'),
'description' => $this->params->desc('service'),
- ]
+ ],
];
}
@@ -71,7 +73,7 @@ public function getServices(): array
return [
'method' => 'GET',
'path' => 'services',
- 'params' => ['type' => $this->params->typeQuery()]
+ 'params' => ['type' => $this->params->typeQuery()],
];
}
@@ -80,7 +82,7 @@ public function getService(): array
return [
'method' => 'GET',
'path' => 'services/{id}',
- 'params' => ['id' => $this->params->idUrl('service')]
+ 'params' => ['id' => $this->params->idUrl('service')],
];
}
@@ -95,7 +97,7 @@ public function patchService(): array
'name' => $this->params->name('service'),
'type' => $this->params->type('service'),
'description' => $this->params->desc('service'),
- ]
+ ],
];
}
@@ -104,7 +106,7 @@ public function deleteService(): array
return [
'method' => 'DELETE',
'path' => 'services/{id}',
- 'params' => ['id' => $this->params->idUrl('service')]
+ 'params' => ['id' => $this->params->idUrl('service')],
];
}
@@ -120,7 +122,7 @@ public function postEndpoints(): array
'region' => $this->params->region(),
'url' => $this->params->endpointUrl(),
'serviceId' => $this->params->serviceId(),
- ]
+ ],
];
}
@@ -132,7 +134,7 @@ public function getEndpoints(): array
'params' => [
'interface' => $this->query($this->params->interf()),
'serviceId' => $this->query($this->params->serviceId()),
- ]
+ ],
];
}
@@ -142,8 +144,8 @@ public function getEndpoint(): array
'method' => 'GET',
'path' => 'endpoints/{id}',
'params' => [
- 'id' => $this->params->idUrl('service')
- ]
+ 'id' => $this->params->idUrl('service'),
+ ],
];
}
@@ -160,7 +162,7 @@ public function patchEndpoint(): array
'region' => $this->params->region(),
'url' => $this->params->endpointUrl(),
'serviceId' => $this->params->serviceId(),
- ]
+ ],
];
}
@@ -169,7 +171,7 @@ public function deleteEndpoint(): array
return [
'method' => 'DELETE',
'path' => 'endpoints/{id}',
- 'params' => ['id' => $this->params->idUrl('endpoint')]
+ 'params' => ['id' => $this->params->idUrl('endpoint')],
];
}
@@ -183,7 +185,7 @@ public function postDomains(): array
'name' => $this->isRequired($this->params->name('domain')),
'enabled' => $this->params->enabled('domain'),
'description' => $this->params->desc('domain'),
- ]
+ ],
];
}
@@ -195,7 +197,7 @@ public function getDomains(): array
'params' => [
'name' => $this->query($this->params->name('domain')),
'enabled' => $this->query($this->params->enabled('domain')),
- ]
+ ],
];
}
@@ -204,7 +206,7 @@ public function getDomain(): array
return [
'method' => 'GET',
'path' => 'domains/{id}',
- 'params' => ['id' => $this->params->idUrl('domain')]
+ 'params' => ['id' => $this->params->idUrl('domain')],
];
}
@@ -219,7 +221,7 @@ public function patchDomain(): array
'name' => $this->params->name('domain'),
'enabled' => $this->params->enabled('domain'),
'description' => $this->params->desc('domain'),
- ]
+ ],
];
}
@@ -228,7 +230,7 @@ public function deleteDomain(): array
return [
'method' => 'DELETE',
'path' => 'domains/{id}',
- 'params' => ['id' => $this->params->idUrl('domain')]
+ 'params' => ['id' => $this->params->idUrl('domain')],
];
}
@@ -240,7 +242,7 @@ public function getUserRoles(): array
'params' => [
'domainId' => $this->params->idUrl('domain'),
'userId' => $this->params->idUrl('user'),
- ]
+ ],
];
}
@@ -253,7 +255,7 @@ public function putUserRoles(): array
'domainId' => $this->params->idUrl('domain'),
'userId' => $this->params->idUrl('user'),
'roleId' => $this->params->idUrl('role'),
- ]
+ ],
];
}
@@ -266,7 +268,7 @@ public function headUserRole(): array
'domainId' => $this->params->idUrl('domain'),
'userId' => $this->params->idUrl('user'),
'roleId' => $this->params->idUrl('role'),
- ]
+ ],
];
}
@@ -279,7 +281,7 @@ public function deleteUserRole(): array
'domainId' => $this->params->idUrl('domain'),
'userId' => $this->params->idUrl('user'),
'roleId' => $this->params->idUrl('role'),
- ]
+ ],
];
}
@@ -291,7 +293,7 @@ public function getGroupRoles(): array
'params' => [
'domainId' => $this->params->idUrl('domain'),
'groupId' => $this->params->idUrl('group'),
- ]
+ ],
];
}
@@ -304,7 +306,7 @@ public function putGroupRole(): array
'domainId' => $this->params->idUrl('domain'),
'groupId' => $this->params->idUrl('group'),
'roleId' => $this->params->idUrl('role'),
- ]
+ ],
];
}
@@ -317,7 +319,7 @@ public function headGroupRole(): array
'domainId' => $this->params->idUrl('domain'),
'groupId' => $this->params->idUrl('group'),
'roleId' => $this->params->idUrl('role'),
- ]
+ ],
];
}
@@ -330,7 +332,7 @@ public function deleteGroupRole(): array
'domainId' => $this->params->idUrl('domain'),
'groupId' => $this->params->idUrl('group'),
'roleId' => $this->params->idUrl('role'),
- ]
+ ],
];
}
@@ -345,8 +347,8 @@ public function postProjects(): array
'domainId' => $this->params->domainId('project'),
'parentId' => $this->params->parentId(),
'enabled' => $this->params->enabled('project'),
- 'name' => $this->isRequired($this->params->name('project'))
- ]
+ 'name' => $this->isRequired($this->params->name('project')),
+ ],
];
}
@@ -359,7 +361,7 @@ public function getProjects(): array
'domainId' => $this->query($this->params->domainId('project')),
'enabled' => $this->query($this->params->enabled('project')),
'name' => $this->query($this->params->name('project')),
- ]
+ ],
];
}
@@ -368,7 +370,7 @@ public function getProject(): array
return [
'method' => 'GET',
'path' => 'projects/{id}',
- 'params' => ['id' => $this->params->idUrl('project')]
+ 'params' => ['id' => $this->params->idUrl('project')],
];
}
@@ -385,7 +387,7 @@ public function patchProject(): array
'parentId' => $this->params->parentId(),
'enabled' => $this->params->enabled('project'),
'name' => $this->params->name('project'),
- ]
+ ],
];
}
@@ -394,7 +396,7 @@ public function deleteProject(): array
return [
'method' => 'DELETE',
'path' => 'projects/{id}',
- 'params' => ['id' => $this->params->idUrl('project')]
+ 'params' => ['id' => $this->params->idUrl('project')],
];
}
@@ -406,7 +408,7 @@ public function getProjectUserRoles(): array
'params' => [
'projectId' => $this->params->idUrl('project'),
'userId' => $this->params->idUrl('user'),
- ]
+ ],
];
}
@@ -419,7 +421,7 @@ public function putProjectUserRole(): array
'projectId' => $this->params->idUrl('project'),
'userId' => $this->params->idUrl('user'),
'roleId' => $this->params->idUrl('role'),
- ]
+ ],
];
}
@@ -432,7 +434,7 @@ public function headProjectUserRole(): array
'projectId' => $this->params->idUrl('project'),
'userId' => $this->params->idUrl('user'),
'roleId' => $this->params->idUrl('role'),
- ]
+ ],
];
}
@@ -445,7 +447,7 @@ public function deleteProjectUserRole(): array
'projectId' => $this->params->idUrl('project'),
'userId' => $this->params->idUrl('user'),
'roleId' => $this->params->idUrl('role'),
- ]
+ ],
];
}
@@ -457,7 +459,7 @@ public function getProjectGroupRoles(): array
'params' => [
'projectId' => $this->params->idUrl('project'),
'groupId' => $this->params->idUrl('group'),
- ]
+ ],
];
}
@@ -470,7 +472,7 @@ public function putProjectGroupRole(): array
'projectId' => $this->params->idUrl('project'),
'groupId' => $this->params->idUrl('group'),
'roleId' => $this->params->idUrl('role'),
- ]
+ ],
];
}
@@ -483,7 +485,7 @@ public function headProjectGroupRole(): array
'projectId' => $this->params->idUrl('project'),
'groupId' => $this->params->idUrl('group'),
'roleId' => $this->params->idUrl('role'),
- ]
+ ],
];
}
@@ -496,7 +498,7 @@ public function deleteProjectGroupRole(): array
'projectId' => $this->params->idUrl('project'),
'groupId' => $this->params->idUrl('group'),
'roleId' => $this->params->idUrl('role'),
- ]
+ ],
];
}
@@ -514,7 +516,7 @@ public function postUsers(): array
'enabled' => $this->params->enabled('user'),
'name' => $this->isRequired($this->params->name('user')),
'password' => $this->params->password(),
- ]
+ ],
];
}
@@ -527,7 +529,7 @@ public function getUsers(): array
'domainId' => $this->query($this->params->domainId('user')),
'enabled' => $this->query($this->params->enabled('user')),
'name' => $this->query($this->params->name('user')),
- ]
+ ],
];
}
@@ -536,7 +538,7 @@ public function getUser(): array
return [
'method' => 'GET',
'path' => 'users/{id}',
- 'params' => ['id' => $this->params->idUrl('user')]
+ 'params' => ['id' => $this->params->idUrl('user')],
];
}
@@ -553,7 +555,7 @@ public function patchUser(): array
'email' => $this->params->email(),
'enabled' => $this->params->enabled('user'),
'password' => $this->params->password(),
- ]
+ ],
];
}
@@ -562,7 +564,7 @@ public function deleteUser(): array
return [
'method' => 'DELETE',
'path' => 'users/{id}',
- 'params' => ['id' => $this->params->idUrl('user')]
+ 'params' => ['id' => $this->params->idUrl('user')],
];
}
@@ -571,7 +573,7 @@ public function getUserGroups(): array
return [
'method' => 'GET',
'path' => 'users/{id}/groups',
- 'params' => ['id' => $this->params->idUrl('user')]
+ 'params' => ['id' => $this->params->idUrl('user')],
];
}
@@ -580,7 +582,7 @@ public function getUserProjects(): array
return [
'method' => 'GET',
'path' => 'users/{id}/projects',
- 'params' => ['id' => $this->params->idUrl('user')]
+ 'params' => ['id' => $this->params->idUrl('user')],
];
}
@@ -593,8 +595,8 @@ public function postGroups(): array
'params' => [
'description' => $this->params->desc('group'),
'domainId' => $this->params->domainId('group'),
- 'name' => $this->params->name('group')
- ]
+ 'name' => $this->params->name('group'),
+ ],
];
}
@@ -603,7 +605,7 @@ public function getGroups(): array
return [
'method' => 'GET',
'path' => 'groups',
- 'params' => ['domainId' => $this->query($this->params->domainId('group'))]
+ 'params' => ['domainId' => $this->query($this->params->domainId('group'))],
];
}
@@ -612,7 +614,7 @@ public function getGroup(): array
return [
'method' => 'GET',
'path' => 'groups/{id}',
- 'params' => ['id' => $this->params->idUrl('group')]
+ 'params' => ['id' => $this->params->idUrl('group')],
];
}
@@ -625,8 +627,8 @@ public function patchGroup(): array
'params' => [
'id' => $this->params->idUrl('group'),
'description' => $this->params->desc('group'),
- 'name' => $this->params->name('group')
- ]
+ 'name' => $this->params->name('group'),
+ ],
];
}
@@ -635,7 +637,7 @@ public function deleteGroup(): array
return [
'method' => 'DELETE',
'path' => 'groups/{id}',
- 'params' => ['id' => $this->params->idUrl('group')]
+ 'params' => ['id' => $this->params->idUrl('group')],
];
}
@@ -644,7 +646,7 @@ public function getGroupUsers(): array
return [
'method' => 'GET',
'path' => 'groups/{id}/users',
- 'params' => ['id' => $this->params->idUrl('group')]
+ 'params' => ['id' => $this->params->idUrl('group')],
];
}
@@ -656,7 +658,7 @@ public function putGroupUser(): array
'params' => [
'groupId' => $this->params->idUrl('group'),
'userId' => $this->params->idUrl('user'),
- ]
+ ],
];
}
@@ -668,7 +670,7 @@ public function deleteGroupUser(): array
'params' => [
'groupId' => $this->params->idUrl('group'),
'userId' => $this->params->idUrl('user'),
- ]
+ ],
];
}
@@ -680,7 +682,7 @@ public function headGroupUser(): array
'params' => [
'groupId' => $this->params->idUrl('group'),
'userId' => $this->params->idUrl('user'),
- ]
+ ],
];
}
@@ -694,7 +696,7 @@ public function postCredentials(): array
'projectId' => $this->params->projectId(),
'type' => $this->params->type('credential'),
'userId' => $this->params->userId(),
- ]
+ ],
];
}
@@ -703,7 +705,7 @@ public function getCredentials(): array
return [
'method' => 'GET',
'path' => 'credentials',
- 'params' => []
+ 'params' => [],
];
}
@@ -712,7 +714,7 @@ public function getCredential(): array
return [
'method' => 'GET',
'path' => 'credentials/{id}',
- 'params' => ['id' => $this->params->idUrl('credential')]
+ 'params' => ['id' => $this->params->idUrl('credential')],
];
}
@@ -721,7 +723,7 @@ public function patchCredential(): array
return [
'method' => 'PATCH',
'path' => 'credentials/{id}',
- 'params' => ['id' => $this->params->idUrl('credential')] + $this->postCredentials()['params']
+ 'params' => ['id' => $this->params->idUrl('credential')] + $this->postCredentials()['params'],
];
}
@@ -730,7 +732,7 @@ public function deleteCredential(): array
return [
'method' => 'DELETE',
'path' => 'credentials/{id}',
- 'params' => ['id' => $this->params->idUrl('credential')]
+ 'params' => ['id' => $this->params->idUrl('credential')],
];
}
@@ -740,7 +742,7 @@ public function postRoles(): array
'method' => 'POST',
'path' => 'roles',
'jsonKey' => 'role',
- 'params' => ['name' => $this->isRequired($this->params->name('role'))]
+ 'params' => ['name' => $this->isRequired($this->params->name('role'))],
];
}
@@ -749,7 +751,7 @@ public function getRoles(): array
return [
'method' => 'GET',
'path' => 'roles',
- 'params' => ['name' => $this->query($this->params->name('role'))]
+ 'params' => ['name' => $this->query($this->params->name('role'))],
];
}
@@ -758,7 +760,7 @@ public function deleteRole(): array
return [
'method' => 'DELETE',
'path' => 'roles/{id}',
- 'params' => ['id' => $this->params->idUrl('role')]
+ 'params' => ['id' => $this->params->idUrl('role')],
];
}
@@ -774,7 +776,7 @@ public function getRoleAssignments(): array
'domainId' => $this->params->domainIdQuery(),
'projectId' => $this->params->projectIdQuery(),
'effective' => $this->params->effective(),
- ]
+ ],
];
}
@@ -784,12 +786,12 @@ public function postPolicies(): array
'method' => 'POST',
'path' => 'policies',
'jsonKey' => 'policy',
- 'params' => [
+ 'params' => [
'blob' => $this->params->blob(),
'projectId' => $this->params->projectId('policy'),
'type' => $this->params->type('policy'),
- 'userId' => $this->params->userId('policy')
- ]
+ 'userId' => $this->params->userId('policy'),
+ ],
];
}
@@ -798,7 +800,7 @@ public function getPolicies(): array
return [
'method' => 'GET',
'path' => 'policies',
- 'params' => ['type' => $this->query($this->params->type('policy'))]
+ 'params' => ['type' => $this->query($this->params->type('policy'))],
];
}
@@ -807,23 +809,23 @@ public function getPolicy(): array
return [
'method' => 'GET',
'path' => 'policies/{id}',
- 'params' => ['id' => $this->params->idUrl('policy')]
+ 'params' => ['id' => $this->params->idUrl('policy')],
];
}
public function patchPolicy(): array
{
return [
- 'method' => 'PATCH',
- 'path' => 'policies/{id}',
+ 'method' => 'PATCH',
+ 'path' => 'policies/{id}',
'jsonKey' => 'policy',
- 'params' => [
+ 'params' => [
'id' => $this->params->idUrl('policy'),
'blob' => $this->params->blob(),
'projectId' => $this->params->projectId('policy'),
'type' => $this->params->type('policy'),
'userId' => $this->params->userId(),
- ]
+ ],
];
}
@@ -832,7 +834,7 @@ public function deletePolicy(): array
return [
'method' => 'DELETE',
'path' => 'policies/{id}',
- 'params' => ['id' => $this->params->idUrl('policy')]
+ 'params' => ['id' => $this->params->idUrl('policy')],
];
}
}
diff --git a/src/Identity/v3/Enum.php b/src/Identity/v3/Enum.php
index 10c6167d..1a6b1c60 100644
--- a/src/Identity/v3/Enum.php
+++ b/src/Identity/v3/Enum.php
@@ -1,4 +1,6 @@
- new Alias('role', Role::class),
'user' => new Alias('user', User::class),
- 'group' => new Alias('group', Group::class)
+ 'group' => new Alias('group', Group::class),
];
}
}
diff --git a/src/Identity/v3/Models/Catalog.php b/src/Identity/v3/Models/Catalog.php
index 9fc1a7f9..cc6a1b5c 100644
--- a/src/Identity/v3/Models/Catalog.php
+++ b/src/Identity/v3/Models/Catalog.php
@@ -1,4 +1,6 @@
- new Alias('services', Service::class, true)
+ 'services' => new Alias('services', Service::class, true),
];
}
@@ -35,12 +37,12 @@ public function populateFromArray(array $data): self
/**
* Retrieve a base URL for a service, according to its catalog name, type, region.
*
- * @param string $name The name of the service as it appears in the catalog.
- * @param string $type The type of the service as it appears in the catalog.
- * @param string $region The region of the service as it appears in the catalog.
- * @param string $urlType Unused.
+ * @param string $name the name of the service as it appears in the catalog
+ * @param string $type the type of the service as it appears in the catalog
+ * @param string $region the region of the service as it appears in the catalog
+ * @param string $urlType unused
*
- * @return false|string FALSE if no URL found
+ * @return false|string FALSE if no URL found
*/
public function getServiceUrl(string $name, string $type, string $region, string $urlType): string
{
@@ -56,7 +58,10 @@ public function getServiceUrl(string $name, string $type, string $region, string
throw new \RuntimeException(sprintf(
"Endpoint URL could not be found in the catalog for this service.\nName: %s\nType: %s\nRegion: %s\nURL type: %s",
- $name, $type, $region, $urlType
+ $name,
+ $type,
+ $region,
+ $urlType
));
}
}
diff --git a/src/Identity/v3/Models/Credential.php b/src/Identity/v3/Models/Credential.php
index b81a0ff1..0c7bcdb5 100644
--- a/src/Identity/v3/Models/Credential.php
+++ b/src/Identity/v3/Models/Credential.php
@@ -1,4 +1,6 @@
-execute($this->api->postCredentials(), $data);
+
return $this->populateFromResponse($response);
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function retrieve()
{
@@ -56,7 +59,7 @@ public function retrieve()
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function update()
{
@@ -65,7 +68,7 @@ public function update()
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function delete()
{
diff --git a/src/Identity/v3/Models/Domain.php b/src/Identity/v3/Models/Domain.php
index 02b1530b..516ead1f 100644
--- a/src/Identity/v3/Models/Domain.php
+++ b/src/Identity/v3/Models/Domain.php
@@ -1,4 +1,6 @@
-execute($this->api->postDomains(), $data);
+
return $this->populateFromResponse($response);
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function retrieve()
{
@@ -54,7 +57,7 @@ public function retrieve()
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function update()
{
@@ -63,7 +66,7 @@ public function update()
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function delete()
{
@@ -78,6 +81,7 @@ public function delete()
public function listUserRoles(array $options = []): \Generator
{
$options['domainId'] = $this->id;
+
return $this->model(Role::class)->enumerate($this->api->getUserRoles(), $options);
}
@@ -98,6 +102,7 @@ public function checkUserRole(array $options = []): bool
{
try {
$this->execute($this->api->headUserRole(), ['domainId' => $this->id] + $options);
+
return true;
} catch (BadResponseError $e) {
return false;
@@ -120,6 +125,7 @@ public function revokeUserRole(array $options = [])
public function listGroupRoles(array $options = []): \Generator
{
$options['domainId'] = $this->id;
+
return $this->model(Role::class)->enumerate($this->api->getGroupRoles(), $options);
}
@@ -140,6 +146,7 @@ public function checkGroupRole(array $options = []): bool
{
try {
$this->execute($this->api->headGroupRole(), ['domainId' => $this->id] + $options);
+
return true;
} catch (BadResponseError $e) {
return false;
diff --git a/src/Identity/v3/Models/Endpoint.php b/src/Identity/v3/Models/Endpoint.php
index 36e11909..775768a4 100644
--- a/src/Identity/v3/Models/Endpoint.php
+++ b/src/Identity/v3/Models/Endpoint.php
@@ -1,4 +1,6 @@
- 'serviceId'];
+ protected $aliases = ['service_id' => 'serviceId'];
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*
* @param array $data {@see \OpenStack\Identity\v3\Api::postEndpoints}
*/
public function create(array $data): Creatable
{
$response = $this->execute($this->api->postEndpoints(), $data);
+
return $this->populateFromResponse($response);
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function retrieve()
{
@@ -59,7 +62,7 @@ public function retrieve()
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function update()
{
@@ -68,7 +71,7 @@ public function update()
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function delete()
{
diff --git a/src/Identity/v3/Models/Group.php b/src/Identity/v3/Models/Group.php
index b16d7db2..65f4658f 100644
--- a/src/Identity/v3/Models/Group.php
+++ b/src/Identity/v3/Models/Group.php
@@ -1,4 +1,6 @@
- 'domainId'];
- protected $resourceKey = 'group';
+ protected $resourceKey = 'group';
protected $resourcesKey = 'groups';
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*
* @param array $data {@see \OpenStack\Identity\v3\Api::postGroups}
*/
public function create(array $data): Creatable
{
$response = $this->execute($this->api->postGroups(), $data);
+
return $this->populateFromResponse($response);
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function retrieve()
{
@@ -56,7 +59,7 @@ public function retrieve()
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function update()
{
@@ -65,7 +68,7 @@ public function update()
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function delete()
{
@@ -80,6 +83,7 @@ public function delete()
public function listUsers(array $options = []): \Generator
{
$options['id'] = $this->id;
+
return $this->model(User::class)->enumerate($this->api->getGroupUsers(), $options);
}
@@ -108,6 +112,7 @@ public function checkMembership(array $options): bool
{
try {
$this->execute($this->api->headGroupUser(), ['groupId' => $this->id] + $options);
+
return true;
} catch (BadResponseError $e) {
return false;
diff --git a/src/Identity/v3/Models/Policy.php b/src/Identity/v3/Models/Policy.php
index 6e2fc63e..9d100a5e 100644
--- a/src/Identity/v3/Models/Policy.php
+++ b/src/Identity/v3/Models/Policy.php
@@ -1,4 +1,6 @@
- 'projectId',
- 'user_id' => 'userId'
+ 'user_id' => 'userId',
];
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*
* @param array $data {@see \OpenStack\Identity\v3\Api::postPolicies}
*/
public function create(array $data): Creatable
{
$response = $this->execute($this->api->postPolicies(), $data);
+
return $this->populateFromResponse($response);
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function retrieve()
{
@@ -61,7 +64,7 @@ public function retrieve()
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function update()
{
@@ -70,7 +73,7 @@ public function update()
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function delete()
{
diff --git a/src/Identity/v3/Models/Project.php b/src/Identity/v3/Models/Project.php
index 01f92fb0..8f323618 100644
--- a/src/Identity/v3/Models/Project.php
+++ b/src/Identity/v3/Models/Project.php
@@ -1,4 +1,6 @@
- 'parentId',
];
- protected $resourceKey = 'project';
+ protected $resourceKey = 'project';
protected $resourcesKey = 'projects';
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*
* @param array $data {@see \OpenStack\Identity\v3\Api::postProjects}
*/
@@ -53,11 +55,12 @@ public function create(array $data): Creatable
{
$response = $this->execute($this->api->postProjects(), $data);
$this->populateFromResponse($response);
+
return $this;
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function retrieve()
{
@@ -66,7 +69,7 @@ public function retrieve()
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function update()
{
@@ -75,7 +78,7 @@ public function update()
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function delete()
{
@@ -90,6 +93,7 @@ public function delete()
public function listUserRoles(array $options = []): \Generator
{
$options['projectId'] = $this->id;
+
return $this->model(Role::class)->enumerate($this->api->getProjectUserRoles(), $options);
}
@@ -110,6 +114,7 @@ public function checkUserRole(array $options): bool
{
try {
$this->execute($this->api->headProjectUserRole(), ['projectId' => $this->id] + $options);
+
return true;
} catch (BadResponseError $e) {
return false;
@@ -132,6 +137,7 @@ public function revokeUserRole(array $options)
public function listGroupRoles(array $options = []): \Generator
{
$options['projectId'] = $this->id;
+
return $this->model(Role::class)->enumerate($this->api->getProjectGroupRoles(), $options);
}
@@ -152,6 +158,7 @@ public function checkGroupRole(array $options): bool
{
try {
$this->execute($this->api->headProjectGroupRole(), ['projectId' => $this->id] + $options);
+
return true;
} catch (BadResponseError $e) {
return false;
diff --git a/src/Identity/v3/Models/Role.php b/src/Identity/v3/Models/Role.php
index 5dbc1719..d694dccf 100644
--- a/src/Identity/v3/Models/Role.php
+++ b/src/Identity/v3/Models/Role.php
@@ -1,4 +1,6 @@
-execute($this->api->postRoles(), $data);
+
return $this->populateFromResponse($response);
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function delete()
{
diff --git a/src/Identity/v3/Models/Service.php b/src/Identity/v3/Models/Service.php
index 8207c1f6..6b58c088 100644
--- a/src/Identity/v3/Models/Service.php
+++ b/src/Identity/v3/Models/Service.php
@@ -1,4 +1,6 @@
- new Alias('endpoints', Endpoint::class, true)
+ 'endpoints' => new Alias('endpoints', Endpoint::class, true),
];
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*
* @param array $data {@see \OpenStack\Identity\v3\Api::postServices}
*/
public function create(array $data): Creatable
{
$response = $this->execute($this->api->postServices(), $data);
+
return $this->populateFromResponse($response);
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function retrieve()
{
@@ -67,7 +70,7 @@ public function retrieve()
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function update()
{
@@ -76,7 +79,7 @@ public function update()
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function delete()
{
@@ -96,10 +99,10 @@ private function typeMatches(string $value): bool
/**
* Retrieve the base URL for a service.
*
- * @param string $name The name of the service as it appears in the catalog.
- * @param string $type The type of the service as it appears in the catalog.
- * @param string $region The region of the service as it appears in the catalog.
- * @param string $interface The interface of the service as it appears in the catalog.
+ * @param string $name the name of the service as it appears in the catalog
+ * @param string $type the type of the service as it appears in the catalog
+ * @param string $region the region of the service as it appears in the catalog
+ * @param string $interface the interface of the service as it appears in the catalog
*
* @return string|false
*/
diff --git a/src/Identity/v3/Models/Token.php b/src/Identity/v3/Models/Token.php
index de430798..935f409f 100644
--- a/src/Identity/v3/Models/Token.php
+++ b/src/Identity/v3/Models/Token.php
@@ -1,4 +1,6 @@
- new Alias('project', Project::class),
'catalog' => new Alias('catalog', Catalog::class),
'user' => new Alias('user', User::class),
- 'issued_at' => new Alias('issued', \DateTimeImmutable::class)
+ 'issued_at' => new Alias('issued', \DateTimeImmutable::class),
];
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function populateFromResponse(ResponseInterface $response)
{
parent::populateFromResponse($response);
$this->id = $response->getHeaderLine('X-Subject-Token');
+
return $this;
}
@@ -80,7 +83,7 @@ public function getId(): string
}
/**
- * @return bool TRUE if the token has expired (and is invalid); FALSE otherwise.
+ * @return bool TRUE if the token has expired (and is invalid); FALSE otherwise
*/
public function hasExpired(): bool
{
@@ -88,7 +91,7 @@ public function hasExpired(): bool
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function retrieve()
{
@@ -97,7 +100,7 @@ public function retrieve()
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*
* @param array $data {@see \OpenStack\Identity\v3\Api::postTokens}
*/
@@ -108,8 +111,8 @@ public function create(array $data): Creatable
if (!isset($data['user']['id']) && empty($data['user']['domain'])) {
throw new \InvalidArgumentException(
'When authenticating with a username, you must also provide either the domain name or domain ID to '
- . 'which the user belongs to. Alternatively, if you provide a user ID instead, you do not need to '
- . 'provide domain information.'
+ .'which the user belongs to. Alternatively, if you provide a user ID instead, you do not need to '
+ .'provide domain information.'
);
}
} elseif (isset($data['tokenId'])) {
@@ -119,11 +122,11 @@ public function create(array $data): Creatable
}
$response = $this->execute($this->api->postTokens(), $data);
- $token = $this->populateFromResponse($response);
+ $token = $this->populateFromResponse($response);
// Cache response as an array to export if needed.
// Added key `id` which is auth token from HTTP header X-Subject-Token
- $this->cachedToken = Utils::flattenJson(Utils::jsonDecode($response), $this->resourceKey);
+ $this->cachedToken = Utils::flattenJson(Utils::jsonDecode($response), $this->resourceKey);
$this->cachedToken['id'] = $token->id;
return $token;
diff --git a/src/Identity/v3/Models/User.php b/src/Identity/v3/Models/User.php
index 84200420..3645e87d 100644
--- a/src/Identity/v3/Models/User.php
+++ b/src/Identity/v3/Models/User.php
@@ -1,4 +1,6 @@
- 'domainId',
- 'default_project_id' => 'defaultProjectId'
+ 'default_project_id' => 'defaultProjectId',
];
- protected $resourceKey = 'user';
+ protected $resourceKey = 'user';
protected $resourcesKey = 'users';
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*
* @param array $data {@see \OpenStack\Identity\v3\Api::postUsers}
*/
public function create(array $data): Creatable
{
$response = $this->execute($this->api->postUsers(), $data);
+
return $this->populateFromResponse($response);
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function retrieve()
{
@@ -67,7 +70,7 @@ public function retrieve()
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function update()
{
@@ -76,7 +79,7 @@ public function update()
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function delete()
{
@@ -89,6 +92,7 @@ public function delete()
public function listGroups(): \Generator
{
$options['id'] = $this->id;
+
return $this->model(Group::class)->enumerate($this->api->getUserGroups(), $options);
}
diff --git a/src/Identity/v3/Params.php b/src/Identity/v3/Params.php
index 9a160c70..998025a0 100644
--- a/src/Identity/v3/Params.php
+++ b/src/Identity/v3/Params.php
@@ -1,4 +1,6 @@
- [
'type' => self::STRING_TYPE,
- 'description' => 'The username of the user'
+ 'description' => 'The username of the user',
],
'password' => [
'type' => self::STRING_TYPE,
- 'description' => 'The password of the user'
+ 'description' => 'The password of the user',
],
- 'domain' => $this->domain()
- ]
+ 'domain' => $this->domain(),
+ ],
];
}
@@ -59,8 +61,8 @@ public function scope(): array
'path' => 'auth',
'properties' => [
'project' => $this->project(),
- 'domain' => $this->domain()
- ]
+ 'domain' => $this->domain(),
+ ],
];
}
@@ -69,7 +71,7 @@ public function typeQuery(): array
return [
'type' => 'string',
'location' => 'query',
- 'description' => 'Filters all the available services according to a given type'
+ 'description' => 'Filters all the available services according to a given type',
];
}
@@ -108,7 +110,7 @@ public function serviceId(): array
return [
'type' => 'string',
'sentAs' => 'service_id',
- 'description' => $this->id('service')['description'] . ' that this endpoint belongs to',
+ 'description' => $this->id('service')['description'].' that this endpoint belongs to',
];
}
@@ -153,7 +155,7 @@ public function projectIdQuery(): array
return [
'sentAs' => 'scope.project.id',
'location' => 'query',
- 'description' => 'Filter by project ID'
+ 'description' => 'Filter by project ID',
];
}
@@ -162,7 +164,7 @@ public function domainIdQuery(): array
return [
'sentAs' => 'scope.domain.id',
'location' => 'query',
- 'description' => $this->id('domain')['description'] . ' associated with the role assignments',
+ 'description' => $this->id('domain')['description'].' associated with the role assignments',
];
}
@@ -171,7 +173,7 @@ public function roleIdQuery(): array
return [
'sentAs' => 'role.id',
'location' => 'query',
- 'description' => 'Filter by role ID'
+ 'description' => 'Filter by role ID',
];
}
@@ -180,7 +182,7 @@ public function groupIdQuery(): array
return [
'sentAs' => 'group.id',
'location' => 'query',
- 'description' => 'Filter by group ID'
+ 'description' => 'Filter by group ID',
];
}
@@ -189,7 +191,7 @@ public function userIdQuery(): array
return [
'sentAs' => 'user.id',
'location' => 'query',
- 'description' => 'Filter by user ID'
+ 'description' => 'Filter by user ID',
];
}
@@ -200,7 +202,7 @@ public function domain(): array
'properties' => [
'id' => $this->id('domain'),
'name' => $this->name('domain'),
- ]
+ ],
];
}
@@ -212,7 +214,7 @@ public function project(): array
'id' => $this->id('project'),
'name' => $this->name('project'),
'domain' => $this->domain(),
- ]
+ ],
];
}
@@ -221,7 +223,7 @@ public function idUrl($type)
return [
'required' => true,
'location' => self::URL,
- 'description' => sprintf("The unique ID, or identifier, for the %s", $type)
+ 'description' => sprintf('The unique ID, or identifier, for the %s', $type),
];
}
@@ -230,7 +232,7 @@ public function tokenId(): array
return [
'location' => self::HEADER,
'sentAs' => 'X-Subject-Token',
- 'description' => 'The unique token ID'
+ 'description' => 'The unique token ID',
];
}
@@ -238,7 +240,7 @@ public function domainId($type)
{
return [
'sentAs' => 'domain_id',
- 'description' => sprintf("%s associated with this %s", $this->id('domain')['description'], $type),
+ 'description' => sprintf('%s associated with this %s', $this->id('domain')['description'], $type),
];
}
@@ -256,14 +258,14 @@ public function parentId(): array
public function type($resource)
{
return [
- 'description' => sprintf("The type of the %s", $resource),
+ 'description' => sprintf('The type of the %s', $resource),
];
}
public function desc($resource)
{
return [
- 'description' => sprintf("A human-friendly summary that explains what the %s does", $resource)
+ 'description' => sprintf('A human-friendly summary that explains what the %s does', $resource),
];
}
@@ -272,10 +274,10 @@ public function enabled($resource)
return [
'type' => self::BOOL_TYPE,
'description' => sprintf(
- "Indicates whether this %s is enabled or not. If not, the %s will be unavailable for use.",
+ 'Indicates whether this %s is enabled or not. If not, the %s will be unavailable for use.',
$resource,
$resource
- )
+ ),
];
}
@@ -294,7 +296,7 @@ public function projectId(): array
{
return [
'sentAs' => 'project_id',
- 'description' => $this->id('project')
+ 'description' => $this->id('project'),
];
}
@@ -302,7 +304,7 @@ public function userId(): array
{
return [
'sentAs' => 'user_id',
- 'description' => $this->id('user')
+ 'description' => $this->id('user'),
];
}
@@ -310,7 +312,7 @@ public function blob(): array
{
return [
'type' => 'string',
- 'description' => "This does something, but it's not explained in the docs (as of writing this)"
+ 'description' => "This does something, but it's not explained in the docs (as of writing this)",
];
}
}
diff --git a/src/Identity/v3/Service.php b/src/Identity/v3/Service.php
index 4fca5626..6b11a0bd 100644
--- a/src/Identity/v3/Service.php
+++ b/src/Identity/v3/Service.php
@@ -1,4 +1,6 @@
-export()`
+ * Generates authentication token from cached token using `$token->export()`.
*
* @param array $cachedToken {@see \OpenStack\Identity\v3\Models\Token::export}
*
@@ -67,7 +73,7 @@ public function generateTokenFromCache(array $cachedToken): Models\Token
}
/**
- * Generates a new authentication token
+ * Generates a new authentication token.
*
* @param array $options {@see \OpenStack\Identity\v3\Api::postTokens}
*
@@ -102,6 +108,7 @@ public function validateToken(string $id): bool
{
try {
$this->execute($this->api->headTokens(), ['tokenId' => $id]);
+
return true;
} catch (BadResponseError $e) {
return false;
diff --git a/src/Images/v2/Api.php b/src/Images/v2/Api.php
index 6a28ffea..0616763f 100644
--- a/src/Images/v2/Api.php
+++ b/src/Images/v2/Api.php
@@ -1,4 +1,6 @@
-params = new Params;
+ $this->params = new Params();
$this->basePath = 'v2/';
}
@@ -18,7 +20,7 @@ public function postImages(): array
{
return [
'method' => 'POST',
- 'path' => $this->basePath . 'images',
+ 'path' => $this->basePath.'images',
'params' => [
'name' => $this->params->imageName(),
'visibility' => $this->params->visibility(),
@@ -36,7 +38,7 @@ public function getImages(): array
{
return [
'method' => 'GET',
- 'path' => $this->basePath . 'images',
+ 'path' => $this->basePath.'images',
'params' => [
'limit' => $this->params->limit(),
'marker' => $this->params->marker(),
@@ -58,7 +60,7 @@ public function getImage(): array
{
return [
'method' => 'GET',
- 'path' => $this->basePath . 'images/{id}',
+ 'path' => $this->basePath.'images/{id}',
'params' => ['id' => $this->params->idPath()],
];
}
@@ -67,7 +69,7 @@ public function patchImage(): array
{
return [
'method' => 'PATCH',
- 'path' => $this->basePath . 'images/{id}',
+ 'path' => $this->basePath.'images/{id}',
'params' => [
'id' => $this->params->idPath(),
'patchDoc' => $this->params->patchDoc(),
@@ -80,7 +82,7 @@ public function deleteImage(): array
{
return [
'method' => 'DELETE',
- 'path' => $this->basePath . 'images/{id}',
+ 'path' => $this->basePath.'images/{id}',
'params' => ['id' => $this->params->idPath()],
];
}
@@ -89,7 +91,7 @@ public function reactivateImage(): array
{
return [
'method' => 'POST',
- 'path' => $this->basePath . 'images/{id}/actions/reactivate',
+ 'path' => $this->basePath.'images/{id}/actions/reactivate',
'params' => ['id' => $this->params->idPath()],
];
}
@@ -98,7 +100,7 @@ public function deactivateImage(): array
{
return [
'method' => 'POST',
- 'path' => $this->basePath . 'images/{id}/actions/deactivate',
+ 'path' => $this->basePath.'images/{id}/actions/deactivate',
'params' => ['id' => $this->params->idPath()],
];
}
@@ -107,12 +109,12 @@ public function postImageData(): array
{
return [
'method' => 'PUT',
- 'path' => $this->basePath . 'images/{id}/file',
+ 'path' => $this->basePath.'images/{id}/file',
'params' => [
'id' => $this->params->idPath(),
'data' => $this->params->data(),
'contentType' => $this->params->contentType(),
- ]
+ ],
];
}
@@ -120,8 +122,8 @@ public function getImageData(): array
{
return [
'method' => 'GET',
- 'path' => $this->basePath . 'images/{id}/file',
- 'params' => ['id' => $this->params->idPath()]
+ 'path' => $this->basePath.'images/{id}/file',
+ 'params' => ['id' => $this->params->idPath()],
];
}
@@ -129,7 +131,7 @@ public function getImageSchema(): array
{
return [
'method' => 'GET',
- 'path' => $this->basePath . 'schemas/image',
+ 'path' => $this->basePath.'schemas/image',
'params' => [],
];
}
@@ -138,7 +140,7 @@ public function postImageMembers(): array
{
return [
'method' => 'POST',
- 'path' => $this->basePath . 'images/{imageId}/members',
+ 'path' => $this->basePath.'images/{imageId}/members',
'params' => [
'imageId' => $this->params->idPath(),
'id' => $this->params->memberId(),
@@ -150,7 +152,7 @@ public function getImageMembers(): array
{
return [
'method' => 'GET',
- 'path' => $this->basePath . 'images/{imageId}/members',
+ 'path' => $this->basePath.'images/{imageId}/members',
'params' => ['imageId' => $this->params->idPath()],
];
}
@@ -159,7 +161,7 @@ public function getImageMember(): array
{
return [
'method' => 'GET',
- 'path' => $this->basePath . 'images/{imageId}/members/{id}',
+ 'path' => $this->basePath.'images/{imageId}/members/{id}',
'params' => [
'imageId' => $this->params->idPath(),
'id' => $this->params->idPath(),
@@ -171,7 +173,7 @@ public function deleteImageMember(): array
{
return [
'method' => 'DELETE',
- 'path' => $this->basePath . 'images/{imageId}/members/{id}',
+ 'path' => $this->basePath.'images/{imageId}/members/{id}',
'params' => [
'imageId' => $this->params->idPath(),
'id' => $this->params->idPath(),
@@ -183,7 +185,7 @@ public function putImageMember(): array
{
return [
'method' => 'PUT',
- 'path' => $this->basePath . 'images/{imageId}/members/{id}',
+ 'path' => $this->basePath.'images/{imageId}/members/{id}',
'params' => [
'imageId' => $this->params->idPath(),
'id' => $this->params->idPath(),
diff --git a/src/Images/v2/JsonPatch.php b/src/Images/v2/JsonPatch.php
index 860950fd..0108ac85 100644
--- a/src/Images/v2/JsonPatch.php
+++ b/src/Images/v2/JsonPatch.php
@@ -1,4 +1,6 @@
- $changeSet) {
- if ($changeSet['op'] == 'remove' && in_array($changeSet['path'], $restrictedProps)) {
+ if ('remove' == $changeSet['op'] && in_array($changeSet['path'], $restrictedProps)) {
unset($diff[$i]);
}
}
@@ -16,7 +18,7 @@ public function disableRestrictedPropRemovals(array $diff, array $restrictedProp
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*
* We need to override the proper way to handle objects because Glance v2 does not
* support whole document replacement with empty JSON pointers.
diff --git a/src/Images/v2/Models/Image.php b/src/Images/v2/Models/Image.php
index 3b731241..033eaa87 100644
--- a/src/Images/v2/Models/Image.php
+++ b/src/Images/v2/Models/Image.php
@@ -1,8 +1,9 @@
- new Alias('createdAt', \DateTimeImmutable::class),
'updated_at' => new Alias('updatedAt', \DateTimeImmutable::class),
'fileUri' => new Alias('fileUri', \GuzzleHttp\Psr7\Uri::class),
- 'schemaUri' => new Alias('schemaUri', \GuzzleHttp\Psr7\Uri::class)
+ 'schemaUri' => new Alias('schemaUri', \GuzzleHttp\Psr7\Uri::class),
];
}
@@ -117,6 +118,7 @@ public function populateFromArray(array $data): self
public function create(array $data): Creatable
{
$response = $this->execute($this->api->postImages(), $data);
+
return $this->populateFromResponse($response);
}
@@ -129,7 +131,7 @@ public function retrieve()
private function getSchema(): Schema
{
if (null === $this->jsonSchema) {
- $response = $this->execute($this->api->getImageSchema());
+ $response = $this->execute($this->api->getImageSchema());
$this->jsonSchema = new Schema(Utils::jsonDecode($response, false));
}
@@ -162,14 +164,14 @@ function (Alias $a) {
// formulate diff
$patch = new JsonPatch();
- $diff = $patch->disableRestrictedPropRemovals($patch->diff($src, $des), $schema->getPropertyPaths());
- $json = json_encode($diff, JSON_UNESCAPED_SLASHES);
+ $diff = $patch->disableRestrictedPropRemovals($patch->diff($src, $des), $schema->getPropertyPaths());
+ $json = json_encode($diff, JSON_UNESCAPED_SLASHES);
// execute patch operation
$response = $this->execute($this->api->patchImage(), [
'id' => $this->id,
'patchDoc' => $json,
- 'contentType' => 'application/openstack-images-v2.1-json-patch'
+ 'contentType' => 'application/openstack-images-v2.1-json-patch',
]);
$this->populateFromResponse($response);
@@ -202,6 +204,7 @@ public function uploadData(StreamInterface $stream)
public function downloadData(): StreamInterface
{
$response = $this->executeWithState($this->api->getImageData());
+
return $response->getBody();
}
diff --git a/src/Images/v2/Models/Member.php b/src/Images/v2/Models/Member.php
index 056e7c49..8bbea59d 100644
--- a/src/Images/v2/Models/Member.php
+++ b/src/Images/v2/Models/Member.php
@@ -1,4 +1,6 @@
- new Alias('createdAt', \DateTimeImmutable::class),
- 'updated_at' => new Alias('updatedAt', \DateTimeImmutable::class)
+ 'updated_at' => new Alias('updatedAt', \DateTimeImmutable::class),
];
}
public function create(array $userOptions): Creatable
{
$response = $this->executeWithState($this->api->postImageMembers());
+
return $this->populateFromResponse($response);
}
diff --git a/src/Images/v2/Models/Schema.php b/src/Images/v2/Models/Schema.php
index d15f743d..44532fab 100644
--- a/src/Images/v2/Models/Schema.php
+++ b/src/Images/v2/Models/Schema.php
@@ -1,4 +1,6 @@
-properties as $propertyName => &$property) {
- if (strpos($property->description, 'READ-ONLY') !== false) {
+ if (false !== strpos($property->description, 'READ-ONLY')) {
$property->readOnly = true;
}
}
diff --git a/src/Images/v2/Params.php b/src/Images/v2/Params.php
index d2e0b299..cd2fff80 100644
--- a/src/Images/v2/Params.php
+++ b/src/Images/v2/Params.php
@@ -1,4 +1,6 @@
-name('image'), [
- 'description' => 'Name for the image. The name of an image is not unique to an Image service node. The ' .
+ 'description' => 'Name for the image. The name of an image is not unique to an Image service node. The '.
'API cannot expect users to know the names of images owned by others.',
'required' => true,
]);
@@ -22,7 +24,7 @@ public function visibility(): array
'location' => self::JSON,
'type' => self::STRING_TYPE,
'description' => 'Image visibility. Public or private. Default is public.',
- 'enum' => ['private', 'public']
+ 'enum' => ['private', 'public'],
];
}
@@ -32,7 +34,7 @@ public function tags(): array
'location' => self::JSON,
'type' => self::ARRAY_TYPE,
'description' => 'Image tags',
- 'items' => ['type' => self::STRING_TYPE]
+ 'items' => ['type' => self::STRING_TYPE],
];
}
@@ -206,7 +208,7 @@ public function status(): array
return [
'location' => self::JSON,
'type' => self::STRING_TYPE,
- "enum" => ["pending", "accepted", "rejected"],
+ 'enum' => ['pending', 'accepted', 'rejected'],
];
}
}
diff --git a/src/Images/v2/Service.php b/src/Images/v2/Service.php
index 0ef13367..5e6c91bb 100644
--- a/src/Images/v2/Service.php
+++ b/src/Images/v2/Service.php
@@ -1,4 +1,6 @@
-model(Image::class);
$image->populateFromArray(['id' => $id]);
+
return $image;
}
}
diff --git a/src/Metric/v1/Gnocchi/Api.php b/src/Metric/v1/Gnocchi/Api.php
index 5ba41ac1..9ffb23ac 100644
--- a/src/Metric/v1/Gnocchi/Api.php
+++ b/src/Metric/v1/Gnocchi/Api.php
@@ -1,4 +1,6 @@
- $this->params->granularity(),
'aggregation' => $this->params->aggregation(),
'start' => $this->params->measureStart(),
- 'stop' => $this->params->measureStop()
+ 'stop' => $this->params->measureStop(),
],
];
}
diff --git a/src/Metric/v1/Gnocchi/Models/Metric.php b/src/Metric/v1/Gnocchi/Models/Metric.php
index e87691c0..71b489ca 100644
--- a/src/Metric/v1/Gnocchi/Models/Metric.php
+++ b/src/Metric/v1/Gnocchi/Models/Metric.php
@@ -1,4 +1,6 @@
- new Alias('resource', Resource::class)
+ 'resource' => new Alias('resource', Resource::class),
];
}
diff --git a/src/Metric/v1/Gnocchi/Models/Resource.php b/src/Metric/v1/Gnocchi/Models/Resource.php
index 0114896e..fa2c93cf 100644
--- a/src/Metric/v1/Gnocchi/Models/Resource.php
+++ b/src/Metric/v1/Gnocchi/Models/Resource.php
@@ -1,4 +1,6 @@
- self::QUERY,
- 'type' => self::STRING_TYPE
+ 'type' => self::STRING_TYPE,
];
}
private function measureTimestamp(string $sentAs): array
{
return [
- 'location' => self::QUERY,
- 'type' => self::STRING_TYPE,
- 'sentAs' => $sentAs,
- 'description' => 'Measure start timestamp which can be either a floating number (UNIX epoch) or an ISO8601 formatted timestamp'
+ 'location' => self::QUERY,
+ 'type' => self::STRING_TYPE,
+ 'sentAs' => $sentAs,
+ 'description' => 'Measure start timestamp which can be either a floating number (UNIX epoch) or an ISO8601 formatted timestamp',
];
}
diff --git a/src/Metric/v1/Gnocchi/Service.php b/src/Metric/v1/Gnocchi/Service.php
index 249236cc..f70bcfba 100644
--- a/src/Metric/v1/Gnocchi/Service.php
+++ b/src/Metric/v1/Gnocchi/Service.php
@@ -1,4 +1,6 @@
-injectGenericType($options);
- /** @var Resource $resource */
+ /** @var resource $resource */
$resource = $this->model(Resource::class);
$resource->populateFromArray($options);
@@ -78,7 +78,7 @@ public function searchResources(array $options = []): \Generator
$options['criteria'] = json_encode($options['criteria']);
}
- /**
+ /*
* We need to manually add content-type header to this request
* since searchResources method sends RAW request body.
*/
@@ -117,9 +117,10 @@ public function listMetrics(array $options = []): \Generator
}
/**
- * If options does not have type, this will inject $options['type'] = 'generic'
+ * If options does not have type, this will inject $options['type'] = 'generic'.
*
* @internal
+ *
* @param array $options
*/
private function injectGenericType(array &$options)
diff --git a/src/Networking/v2/Api.php b/src/Networking/v2/Api.php
index 6329ab2a..47a0abc2 100644
--- a/src/Networking/v2/Api.php
+++ b/src/Networking/v2/Api.php
@@ -1,4 +1,6 @@
- 'GET',
- 'path' => $this->pathPrefix . '/networks/{id}',
+ 'path' => $this->pathPrefix.'/networks/{id}',
'params' => ['id' => $this->params->urlId('network')],
];
}
@@ -32,7 +33,7 @@ public function getNetworks(): array
{
return [
'method' => 'GET',
- 'path' => $this->pathPrefix . '/networks',
+ 'path' => $this->pathPrefix.'/networks',
'params' => [
'name' => $this->params->queryName(),
'tenantId' => $this->params->queryTenantId(),
@@ -44,7 +45,7 @@ public function getNetworks(): array
public function postNetwork(): array
{
return [
- 'path' => $this->pathPrefix . '/networks',
+ 'path' => $this->pathPrefix.'/networks',
'method' => 'POST',
'jsonKey' => 'network',
'params' => [
@@ -60,7 +61,7 @@ public function postNetwork(): array
public function postNetworks(): array
{
return [
- 'path' => $this->pathPrefix . '/networks',
+ 'path' => $this->pathPrefix.'/networks',
'method' => 'POST',
'jsonKey' => '',
'params' => [
@@ -84,7 +85,7 @@ public function putNetwork(): array
{
return [
'method' => 'PUT',
- 'path' => $this->pathPrefix . '/networks/{id}',
+ 'path' => $this->pathPrefix.'/networks/{id}',
'jsonKey' => 'network',
'params' => [
'id' => $this->params->urlId('network'),
@@ -99,7 +100,7 @@ public function deleteNetwork(): array
{
return [
'method' => 'DELETE',
- 'path' => $this->pathPrefix . '/networks/{id}',
+ 'path' => $this->pathPrefix.'/networks/{id}',
'params' => ['id' => $this->params->urlId('network')],
];
}
@@ -108,7 +109,7 @@ public function getSubnet(): array
{
return [
'method' => 'GET',
- 'path' => $this->pathPrefix . '/subnets/{id}',
+ 'path' => $this->pathPrefix.'/subnets/{id}',
'params' => ['id' => $this->params->urlId('network')],
];
}
@@ -117,10 +118,10 @@ public function getSubnets(): array
{
return [
'method' => 'GET',
- 'path' => $this->pathPrefix . '/subnets',
+ 'path' => $this->pathPrefix.'/subnets',
'params' => [
- 'name' => $this->params->queryName(),
- 'tenantId' => $this->params->queryTenantId()
+ 'name' => $this->params->queryName(),
+ 'tenantId' => $this->params->queryTenantId(),
],
];
}
@@ -128,7 +129,7 @@ public function getSubnets(): array
public function postSubnet(): array
{
return [
- 'path' => $this->pathPrefix . '/subnets',
+ 'path' => $this->pathPrefix.'/subnets',
'method' => 'POST',
'jsonKey' => 'subnet',
'params' => [
@@ -149,7 +150,7 @@ public function postSubnet(): array
public function postSubnets(): array
{
return [
- 'path' => $this->pathPrefix . '/subnets',
+ 'path' => $this->pathPrefix.'/subnets',
'method' => 'POST',
'params' => [
'subnets' => [
@@ -168,7 +169,7 @@ public function putSubnet(): array
{
return [
'method' => 'PUT',
- 'path' => $this->pathPrefix . '/subnets/{id}',
+ 'path' => $this->pathPrefix.'/subnets/{id}',
'jsonKey' => 'subnet',
'params' => [
'id' => $this->params->urlId('subnet'),
@@ -185,7 +186,7 @@ public function deleteSubnet(): array
{
return [
'method' => 'DELETE',
- 'path' => $this->pathPrefix . '/subnets/{id}',
+ 'path' => $this->pathPrefix.'/subnets/{id}',
'params' => ['id' => $this->params->urlId('subnet')],
];
}
@@ -194,7 +195,7 @@ public function getPorts(): array
{
return [
'method' => 'GET',
- 'path' => $this->pathPrefix . '/ports',
+ 'path' => $this->pathPrefix.'/ports',
'params' => [
'status' => $this->params->statusQuery(),
'displayName' => $this->params->displayNameQuery(),
@@ -214,7 +215,7 @@ public function postSinglePort(): array
{
return [
'method' => 'POST',
- 'path' => $this->pathPrefix . '/ports',
+ 'path' => $this->pathPrefix.'/ports',
'jsonKey' => 'port',
'params' => [
'name' => $this->params->name('port'),
@@ -237,7 +238,7 @@ public function postMultiplePorts(): array
{
return [
'method' => 'POST',
- 'path' => $this->pathPrefix . '/ports',
+ 'path' => $this->pathPrefix.'/ports',
'params' => [
'ports' => [
'type' => Params::ARRAY_TYPE,
@@ -254,7 +255,7 @@ public function getPort(): array
{
return [
'method' => 'GET',
- 'path' => $this->pathPrefix . '/ports/{id}',
+ 'path' => $this->pathPrefix.'/ports/{id}',
'params' => ['id' => $this->params->idPath()],
];
}
@@ -263,7 +264,7 @@ public function putPort(): array
{
return [
'method' => 'PUT',
- 'path' => $this->pathPrefix . '/ports/{id}',
+ 'path' => $this->pathPrefix.'/ports/{id}',
'jsonKey' => 'port',
'params' => [
'id' => $this->params->idPath(),
@@ -287,7 +288,7 @@ public function deletePort(): array
{
return [
'method' => 'DELETE',
- 'path' => $this->pathPrefix . '/ports/{id}',
+ 'path' => $this->pathPrefix.'/ports/{id}',
'params' => ['id' => $this->params->idPath()],
];
}
@@ -296,8 +297,8 @@ public function getQuotas(): array
{
return [
'method' => 'GET',
- 'path' => $this->pathPrefix . '/quotas',
- 'params' => []
+ 'path' => $this->pathPrefix.'/quotas',
+ 'params' => [],
];
}
@@ -305,8 +306,8 @@ public function getQuota(): array
{
return [
'method' => 'GET',
- 'path' => $this->pathPrefix . '/quotas/{tenantId}',
- 'params' => []
+ 'path' => $this->pathPrefix.'/quotas/{tenantId}',
+ 'params' => [],
];
}
@@ -314,8 +315,8 @@ public function getQuotaDefault(): array
{
return [
'method' => 'GET',
- 'path' => $this->pathPrefix . '/quotas/{tenantId}/default',
- 'params' => []
+ 'path' => $this->pathPrefix.'/quotas/{tenantId}/default',
+ 'params' => [],
];
}
@@ -323,7 +324,7 @@ public function putQuota(): array
{
return [
'method' => 'PUT',
- 'path' => $this->pathPrefix . '/quotas/{tenantId}',
+ 'path' => $this->pathPrefix.'/quotas/{tenantId}',
'jsonKey' => 'quota',
'params' => [
'tenantId' => $this->params->idPath(),
@@ -336,18 +337,18 @@ public function putQuota(): array
'securityGroupRule' => $this->params->quotaLimitSecurityGroupRule(),
'subnet' => $this->params->quotaLimitSubnet(),
'subnetpool' => $this->params->quotaLimitSubnetPool(),
- ]
+ ],
];
}
- public function deleteQuota() : array
+ public function deleteQuota(): array
{
return [
'method' => 'DELETE',
- 'path' => $this->pathPrefix . '/quotas/{tenantId}',
+ 'path' => $this->pathPrefix.'/quotas/{tenantId}',
'params' => [
- 'tenantId' => $this->params->idPath()
- ]
+ 'tenantId' => $this->params->idPath(),
+ ],
];
}
@@ -355,8 +356,8 @@ public function getLoadBalancers(): array
{
return [
'method' => 'GET',
- 'path' => $this->pathPrefix . '/lbaas/loadbalancers',
- 'params' => []
+ 'path' => $this->pathPrefix.'/lbaas/loadbalancers',
+ 'params' => [],
];
}
@@ -364,8 +365,8 @@ public function getLoadBalancer(): array
{
return [
'method' => 'GET',
- 'path' => $this->pathPrefix . '/lbaas/loadbalancers/{id}',
- 'params' => []
+ 'path' => $this->pathPrefix.'/lbaas/loadbalancers/{id}',
+ 'params' => [],
];
}
@@ -373,7 +374,7 @@ public function postLoadBalancer(): array
{
return [
'method' => 'POST',
- 'path' => $this->pathPrefix . '/lbaas/loadbalancers',
+ 'path' => $this->pathPrefix.'/lbaas/loadbalancers',
'jsonKey' => 'loadbalancer',
'params' => [
'name' => $this->params->name('loadbalancer'),
@@ -382,8 +383,8 @@ public function postLoadBalancer(): array
'vipSubnetId' => $this->params->vipSubnetId(),
'vipAddress' => $this->params->vipAddress(),
'adminStateUp' => $this->params->adminStateUp(),
- 'provider' => $this->params->provider()
- ]
+ 'provider' => $this->params->provider(),
+ ],
];
}
@@ -391,25 +392,25 @@ public function putLoadBalancer(): array
{
return [
'method' => 'PUT',
- 'path' => $this->pathPrefix . '/lbaas/loadbalancers/{id}',
+ 'path' => $this->pathPrefix.'/lbaas/loadbalancers/{id}',
'jsonKey' => 'loadbalancer',
'params' => [
'id' => $this->params->idPath(),
'name' => $this->params->name('loadbalancer'),
'description' => $this->params->descriptionJson(),
- 'AdminStateUp' => $this->params->adminStateUp()
- ]
+ 'AdminStateUp' => $this->params->adminStateUp(),
+ ],
];
}
- public function deleteLoadBalancer() : array
+ public function deleteLoadBalancer(): array
{
return [
'method' => 'DELETE',
- 'path' => $this->pathPrefix . '/lbaas/loadbalancers/{id}',
+ 'path' => $this->pathPrefix.'/lbaas/loadbalancers/{id}',
'params' => [
- 'id' => $this->params->idPath()
- ]
+ 'id' => $this->params->idPath(),
+ ],
];
}
@@ -417,8 +418,8 @@ public function getLoadBalancerListeners(): array
{
return [
'method' => 'GET',
- 'path' => $this->pathPrefix . '/lbaas/listeners',
- 'params' => []
+ 'path' => $this->pathPrefix.'/lbaas/listeners',
+ 'params' => [],
];
}
@@ -426,8 +427,8 @@ public function getLoadBalancerListener(): array
{
return [
'method' => 'GET',
- 'path' => $this->pathPrefix . '/lbaas/listeners/{id}',
- 'params' => []
+ 'path' => $this->pathPrefix.'/lbaas/listeners/{id}',
+ 'params' => [],
];
}
@@ -435,7 +436,7 @@ public function postLoadBalancerListener(): array
{
return [
'method' => 'POST',
- 'path' => $this->pathPrefix . '/lbaas/listeners',
+ 'path' => $this->pathPrefix.'/lbaas/listeners',
'jsonKey' => 'listener',
'params' => [
'name' => $this->params->name('listener'),
@@ -445,8 +446,8 @@ public function postLoadBalancerListener(): array
'protocolPort' => $this->params->protocolPort(),
'tenantId' => $this->params->tenantId(),
'adminStateUp' => $this->params->adminStateUp(),
- 'connectionLimit' => $this->params->connectionLimit()
- ]
+ 'connectionLimit' => $this->params->connectionLimit(),
+ ],
];
}
@@ -454,26 +455,26 @@ public function putLoadBalancerListener(): array
{
return [
'method' => 'PUT',
- 'path' => $this->pathPrefix . '/lbaas/listeners/{id}',
+ 'path' => $this->pathPrefix.'/lbaas/listeners/{id}',
'jsonKey' => 'listener',
'params' => [
'id' => $this->params->idPath(),
'name' => $this->params->name('listener'),
'description' => $this->params->descriptionJson(),
'adminStateUp' => $this->params->adminStateUp(),
- 'connectionLimit' => $this->params->connectionLimit()
- ]
+ 'connectionLimit' => $this->params->connectionLimit(),
+ ],
];
}
- public function deleteLoadBalancerListener() : array
+ public function deleteLoadBalancerListener(): array
{
return [
'method' => 'DELETE',
- 'path' => $this->pathPrefix . '/lbaas/listeners/{id}',
+ 'path' => $this->pathPrefix.'/lbaas/listeners/{id}',
'params' => [
- 'id' => $this->params->idPath()
- ]
+ 'id' => $this->params->idPath(),
+ ],
];
}
@@ -481,8 +482,8 @@ public function getLoadBalancerPools(): array
{
return [
'method' => 'GET',
- 'path' => $this->pathPrefix . '/lbaas/pools',
- 'params' => []
+ 'path' => $this->pathPrefix.'/lbaas/pools',
+ 'params' => [],
];
}
@@ -490,8 +491,8 @@ public function getLoadBalancerPool(): array
{
return [
'method' => 'GET',
- 'path' => $this->pathPrefix . '/lbaas/pools/{id}',
- 'params' => []
+ 'path' => $this->pathPrefix.'/lbaas/pools/{id}',
+ 'params' => [],
];
}
@@ -499,7 +500,7 @@ public function postLoadBalancerPool(): array
{
return [
'method' => 'POST',
- 'path' => $this->pathPrefix . '/lbaas/pools',
+ 'path' => $this->pathPrefix.'/lbaas/pools',
'jsonKey' => 'pool',
'params' => [
'name' => $this->params->name('pool'),
@@ -508,8 +509,8 @@ public function postLoadBalancerPool(): array
'protocol' => $this->params->protocol(),
'lbAlgorithm' => $this->params->lbAlgorithm(),
'listenerId' => $this->params->listenerId(),
- 'sessionPersistence' => $this->params->sessionPersistence()
- ]
+ 'sessionPersistence' => $this->params->sessionPersistence(),
+ ],
];
}
@@ -517,7 +518,7 @@ public function putLoadBalancerPool(): array
{
return [
'method' => 'PUT',
- 'path' => $this->pathPrefix . '/lbaas/pools/{id}',
+ 'path' => $this->pathPrefix.'/lbaas/pools/{id}',
'jsonKey' => 'pool',
'params' => [
'id' => $this->params->idPath(),
@@ -525,19 +526,19 @@ public function putLoadBalancerPool(): array
'description' => $this->params->descriptionJson(),
'adminStateUp' => $this->params->adminStateUp(),
'lbAlgorithm' => $this->params->lbAlgorithm(),
- 'sessionPersistence' => $this->params->sessionPersistence()
- ]
+ 'sessionPersistence' => $this->params->sessionPersistence(),
+ ],
];
}
- public function deleteLoadBalancerPool() : array
+ public function deleteLoadBalancerPool(): array
{
return [
'method' => 'DELETE',
- 'path' => $this->pathPrefix . '/lbaas/pools/{id}',
+ 'path' => $this->pathPrefix.'/lbaas/pools/{id}',
'params' => [
- 'id' => $this->params->idPath()
- ]
+ 'id' => $this->params->idPath(),
+ ],
];
}
@@ -545,10 +546,10 @@ public function getLoadBalancerMembers(): array
{
return [
'method' => 'GET',
- 'path' => $this->pathPrefix . '/lbaas/pools/{poolId}/members',
+ 'path' => $this->pathPrefix.'/lbaas/pools/{poolId}/members',
'params' => [
- 'poolId' => $this->params->poolId()
- ]
+ 'poolId' => $this->params->poolId(),
+ ],
];
}
@@ -556,11 +557,11 @@ public function getLoadBalancerMember(): array
{
return [
'method' => 'GET',
- 'path' => $this->pathPrefix . '/lbaas/pools/{poolId}/members/{id}',
+ 'path' => $this->pathPrefix.'/lbaas/pools/{poolId}/members/{id}',
'params' => [
'id' => $this->params->idPath('member'),
- 'poolId' => $this->params->poolId()
- ]
+ 'poolId' => $this->params->poolId(),
+ ],
];
}
@@ -568,7 +569,7 @@ public function postLoadBalancerMember(): array
{
return [
'method' => 'POST',
- 'path' => $this->pathPrefix . '/lbaas/pools/{poolId}/members',
+ 'path' => $this->pathPrefix.'/lbaas/pools/{poolId}/members',
'jsonKey' => 'member',
'params' => [
'poolId' => $this->params->poolId(),
@@ -576,8 +577,8 @@ public function postLoadBalancerMember(): array
'protocolPort' => $this->params->protocolPort(),
'adminStateUp' => $this->params->adminStateUp(),
'weight' => $this->params->weight(),
- 'subnetId' => $this->params->subnetId()
- ]
+ 'subnetId' => $this->params->subnetId(),
+ ],
];
}
@@ -585,26 +586,26 @@ public function putLoadBalancerMember(): array
{
return [
'method' => 'PUT',
- 'path' => $this->pathPrefix . '/lbaas/pools/{poolId}/members/{id}',
+ 'path' => $this->pathPrefix.'/lbaas/pools/{poolId}/members/{id}',
'jsonKey' => 'member',
'params' => [
'poolId' => $this->params->poolId(),
'id' => $this->params->idPath(),
'weight' => $this->params->weight(),
- 'adminStateUp' => $this->params->adminStateUp()
- ]
+ 'adminStateUp' => $this->params->adminStateUp(),
+ ],
];
}
- public function deleteLoadBalancerMember() : array
+ public function deleteLoadBalancerMember(): array
{
return [
'method' => 'DELETE',
- 'path' => $this->pathPrefix . '/lbaas/pools/{poolId}/members/{id}',
+ 'path' => $this->pathPrefix.'/lbaas/pools/{poolId}/members/{id}',
'params' => [
'poolId' => $this->params->poolId(),
- 'id' => $this->params->idPath()
- ]
+ 'id' => $this->params->idPath(),
+ ],
];
}
@@ -612,10 +613,10 @@ public function getLoadBalancerStats(): array
{
return [
'method' => 'GET',
- 'path' => $this->pathPrefix . '/lbaas/loadbalancers/{loadbalancerId}/stats',
+ 'path' => $this->pathPrefix.'/lbaas/loadbalancers/{loadbalancerId}/stats',
'params' => [
- 'loadbalancerId' => $this->params->loadBalancerIdUrl()
- ]
+ 'loadbalancerId' => $this->params->loadBalancerIdUrl(),
+ ],
];
}
@@ -623,10 +624,10 @@ public function getLoadBalancerStatuses(): array
{
return [
'method' => 'GET',
- 'path' => $this->pathPrefix . '/lbaas/loadbalancers/{loadbalancerId}/statuses',
+ 'path' => $this->pathPrefix.'/lbaas/loadbalancers/{loadbalancerId}/statuses',
'params' => [
- 'loadbalancerId' => $this->params->loadBalancerIdUrl()
- ]
+ 'loadbalancerId' => $this->params->loadBalancerIdUrl(),
+ ],
];
}
@@ -634,8 +635,8 @@ public function getLoadBalancerHealthMonitors(): array
{
return [
'method' => 'GET',
- 'path' => $this->pathPrefix . '/lbaas/healthmonitors',
- 'params' => []
+ 'path' => $this->pathPrefix.'/lbaas/healthmonitors',
+ 'params' => [],
];
}
@@ -643,10 +644,10 @@ public function getLoadBalancerHealthMonitor(): array
{
return [
'method' => 'GET',
- 'path' => $this->pathPrefix . '/lbaas/healthmonitors/{id}',
+ 'path' => $this->pathPrefix.'/lbaas/healthmonitors/{id}',
'params' => [
- 'id' => $this->params->idPath()
- ]
+ 'id' => $this->params->idPath(),
+ ],
];
}
@@ -654,7 +655,7 @@ public function postLoadBalancerHealthMonitor(): array
{
return [
'method' => 'POST',
- 'path' => $this->pathPrefix . '/lbaas/healthmonitors',
+ 'path' => $this->pathPrefix.'/lbaas/healthmonitors',
'jsonKey' => 'healthmonitor',
'params' => [
'type' => $this->params->type(),
@@ -666,8 +667,8 @@ public function postLoadBalancerHealthMonitor(): array
'adminStateUp' => $this->params->adminStateUp(),
'httpMethod' => $this->params->httpMethod(),
'urlPath' => $this->params->urlPath(),
- 'expectedCodes' => $this->params->expectedCodes()
- ]
+ 'expectedCodes' => $this->params->expectedCodes(),
+ ],
];
}
@@ -675,7 +676,7 @@ public function putLoadBalancerHealthMonitor(): array
{
return [
'method' => 'PUT',
- 'path' => $this->pathPrefix . '/lbaas/healthmonitors/{id}',
+ 'path' => $this->pathPrefix.'/lbaas/healthmonitors/{id}',
'jsonKey' => 'healthmonitor',
'params' => [
'id' => $this->params->idPath(),
@@ -685,19 +686,19 @@ public function putLoadBalancerHealthMonitor(): array
'maxRetries' => $this->params->maxRetries(),
'httpMethod' => $this->params->httpMethod(),
'urlPath' => $this->params->urlPath(),
- 'expectedCodes' => $this->params->expectedCodes()
- ]
+ 'expectedCodes' => $this->params->expectedCodes(),
+ ],
];
}
- public function deleteLoadBalancerHealthMonitor() : array
+ public function deleteLoadBalancerHealthMonitor(): array
{
return [
'method' => 'DELETE',
- 'path' => $this->pathPrefix . '/lbaas/healthmonitors/{id}',
+ 'path' => $this->pathPrefix.'/lbaas/healthmonitors/{id}',
'params' => [
- 'id' => $this->params->idPath()
- ]
+ 'id' => $this->params->idPath(),
+ ],
];
}
}
diff --git a/src/Networking/v2/Extensions/Layer3/Api.php b/src/Networking/v2/Extensions/Layer3/Api.php
index ff02f0b3..b9ab4517 100644
--- a/src/Networking/v2/Extensions/Layer3/Api.php
+++ b/src/Networking/v2/Extensions/Layer3/Api.php
@@ -17,7 +17,7 @@ public function postFloatingIps(): array
{
return [
'method' => 'POST',
- 'path' => $this->pathPrefix . '/floatingips',
+ 'path' => $this->pathPrefix.'/floatingips',
'jsonKey' => 'floatingip',
'params' => [
'tenantId' => $this->params->tenantIdJson(),
@@ -33,7 +33,7 @@ public function getFloatingIps(): array
{
return [
'method' => 'GET',
- 'path' => $this->pathPrefix . '/floatingips',
+ 'path' => $this->pathPrefix.'/floatingips',
'params' => [
'tenantId' => $this->params->queryTenantId(),
],
@@ -44,7 +44,7 @@ public function putFloatingIp(): array
{
return [
'method' => 'PUT',
- 'path' => $this->pathPrefix . '/floatingips/{id}',
+ 'path' => $this->pathPrefix.'/floatingips/{id}',
'jsonKey' => 'floatingip',
'params' => [
'id' => $this->params->idPath(),
@@ -60,7 +60,7 @@ public function getFloatingIp(): array
{
return [
'method' => 'GET',
- 'path' => $this->pathPrefix . '/floatingips/{id}',
+ 'path' => $this->pathPrefix.'/floatingips/{id}',
'params' => [
'id' => $this->params->idPath(),
'portId' => $this->params->portIdJson(),
@@ -72,7 +72,7 @@ public function deleteFloatingIp(): array
{
return [
'method' => 'DELETE',
- 'path' => $this->pathPrefix . '/floatingips/{id}',
+ 'path' => $this->pathPrefix.'/floatingips/{id}',
'params' => [
'id' => $this->params->idPath(),
],
@@ -83,7 +83,7 @@ public function postRouters(): array
{
return [
'method' => 'POST',
- 'path' => $this->pathPrefix . '/routers',
+ 'path' => $this->pathPrefix.'/routers',
'jsonKey' => 'router',
'params' => [
'name' => $this->params->nameJson(),
@@ -100,10 +100,10 @@ public function getRouters(): array
{
return [
'method' => 'GET',
- 'path' => $this->pathPrefix . '/routers',
+ 'path' => $this->pathPrefix.'/routers',
'params' => [
- 'name' => $this->params->queryName(),
- 'tenantId' => $this->params->queryTenantId()
+ 'name' => $this->params->queryName(),
+ 'tenantId' => $this->params->queryTenantId(),
],
];
}
@@ -112,7 +112,7 @@ public function putRouter(): array
{
return [
'method' => 'PUT',
- 'path' => $this->pathPrefix . '/routers/{id}',
+ 'path' => $this->pathPrefix.'/routers/{id}',
'jsonKey' => 'router',
'params' => [
'id' => $this->params->idPath(),
@@ -127,7 +127,7 @@ public function getRouter(): array
{
return [
'method' => 'GET',
- 'path' => $this->pathPrefix . '/routers/{id}',
+ 'path' => $this->pathPrefix.'/routers/{id}',
'params' => [
'id' => $this->params->idPath(),
],
@@ -138,7 +138,7 @@ public function deleteRouter(): array
{
return [
'method' => 'DELETE',
- 'path' => $this->pathPrefix . '/routers/{id}',
+ 'path' => $this->pathPrefix.'/routers/{id}',
'params' => [
'id' => $this->params->idPath(),
],
@@ -149,7 +149,7 @@ public function putAddInterface()
{
return [
'method' => 'PUT',
- 'path' => $this->pathPrefix . '/routers/{id}/add_router_interface',
+ 'path' => $this->pathPrefix.'/routers/{id}/add_router_interface',
'params' => [
'id' => $this->params->idPath(),
'subnetId' => $this->params->subnetId(),
@@ -162,7 +162,7 @@ public function putRemoveInterface()
{
return [
'method' => 'PUT',
- 'path' => $this->pathPrefix . '/routers/{id}/remove_router_interface',
+ 'path' => $this->pathPrefix.'/routers/{id}/remove_router_interface',
'params' => [
'id' => $this->params->idPath(),
'subnetId' => $this->params->subnetId(),
diff --git a/src/Networking/v2/Extensions/Layer3/Models/FixedIp.php b/src/Networking/v2/Extensions/Layer3/Models/FixedIp.php
index 9b5b65f3..55145135 100644
--- a/src/Networking/v2/Extensions/Layer3/Models/FixedIp.php
+++ b/src/Networking/v2/Extensions/Layer3/Models/FixedIp.php
@@ -13,6 +13,6 @@ class FixedIp extends AbstractResource
public $ip;
protected $aliases = [
- 'subnet_id' => 'subnetId'
+ 'subnet_id' => 'subnetId',
];
}
diff --git a/src/Networking/v2/Extensions/Layer3/Models/FloatingIp.php b/src/Networking/v2/Extensions/Layer3/Models/FloatingIp.php
index 700cbb4b..44973ddc 100644
--- a/src/Networking/v2/Extensions/Layer3/Models/FloatingIp.php
+++ b/src/Networking/v2/Extensions/Layer3/Models/FloatingIp.php
@@ -48,12 +48,13 @@ class FloatingIp extends OperatorResource implements Listable, Creatable, Retrie
'port_id' => 'portId',
];
- protected $resourceKey = 'floatingip';
+ protected $resourceKey = 'floatingip';
protected $resourcesKey = 'floatingips';
public function create(array $userOptions): Creatable
{
$response = $this->execute($this->api->postFloatingIps(), $userOptions);
+
return $this->populateFromResponse($response);
}
diff --git a/src/Networking/v2/Extensions/Layer3/Models/GatewayInfo.php b/src/Networking/v2/Extensions/Layer3/Models/GatewayInfo.php
index 0be0ef40..ce735b1b 100644
--- a/src/Networking/v2/Extensions/Layer3/Models/GatewayInfo.php
+++ b/src/Networking/v2/Extensions/Layer3/Models/GatewayInfo.php
@@ -22,12 +22,12 @@ class GatewayInfo extends AbstractResource
];
/**
- * @inheritdoc
+ * {@inheritdoc}
*/
protected function getAliases(): array
{
return parent::getAliases() + [
- 'fixed_ips' => new Alias('fixedIps', FixedIp::class, true)
+ 'fixed_ips' => new Alias('fixedIps', FixedIp::class, true),
];
}
}
diff --git a/src/Networking/v2/Extensions/Layer3/Models/Router.php b/src/Networking/v2/Extensions/Layer3/Models/Router.php
index b4831cb9..e05858b2 100644
--- a/src/Networking/v2/Extensions/Layer3/Models/Router.php
+++ b/src/Networking/v2/Extensions/Layer3/Models/Router.php
@@ -48,18 +48,19 @@ class Router extends OperatorResource implements Listable, Creatable, Retrievabl
];
/**
- * @inheritdoc
+ * {@inheritdoc}
*/
protected function getAliases(): array
{
return parent::getAliases() + [
- 'external_gateway_info' => new Alias('externalGatewayInfo', GatewayInfo::class)
+ 'external_gateway_info' => new Alias('externalGatewayInfo', GatewayInfo::class),
];
}
public function create(array $userOptions): Creatable
{
$response = $this->execute($this->api->postRouters(), $userOptions);
+
return $this->populateFromResponse($response);
}
diff --git a/src/Networking/v2/Extensions/SecurityGroups/Api.php b/src/Networking/v2/Extensions/SecurityGroups/Api.php
index 0d9b4df7..1e715faa 100644
--- a/src/Networking/v2/Extensions/SecurityGroups/Api.php
+++ b/src/Networking/v2/Extensions/SecurityGroups/Api.php
@@ -15,7 +15,7 @@ public function __construct()
/**
* Returns information about GET security-groups/{security_group_id} HTTP
- * operation
+ * operation.
*
* @return array
*/
@@ -23,13 +23,13 @@ public function getSecurityGroups()
{
return [
'method' => 'GET',
- 'path' => $this->pathPrefix . '/security-groups',
+ 'path' => $this->pathPrefix.'/security-groups',
'params' => [],
];
}
/**
- * Returns information about POST security-groups HTTP operation
+ * Returns information about POST security-groups HTTP operation.
*
* @return array
*/
@@ -37,7 +37,7 @@ public function postSecurityGroups()
{
return [
'method' => 'POST',
- 'path' => $this->pathPrefix . '/security-groups',
+ 'path' => $this->pathPrefix.'/security-groups',
'jsonKey' => 'security_group',
'params' => [
'description' => $this->params->descriptionJson(),
@@ -47,7 +47,7 @@ public function postSecurityGroups()
}
/**
- * Returns information about PUT security-groups HTTP operation
+ * Returns information about PUT security-groups HTTP operation.
*
* @return array
*/
@@ -55,7 +55,7 @@ public function putSecurityGroups()
{
return [
'method' => 'PUT',
- 'path' => $this->pathPrefix . '/security-groups/{id}',
+ 'path' => $this->pathPrefix.'/security-groups/{id}',
'jsonKey' => 'security_group',
'params' => [
'id' => $this->params->idPath(),
@@ -67,7 +67,7 @@ public function putSecurityGroups()
/**
* Returns information about GET security-groups/{security_group_id} HTTP
- * operation
+ * operation.
*
* @return array
*/
@@ -75,7 +75,7 @@ public function getSecurityGroup()
{
return [
'method' => 'GET',
- 'path' => $this->pathPrefix . '/security-groups/{id}',
+ 'path' => $this->pathPrefix.'/security-groups/{id}',
'params' => [
'id' => $this->params->idPath(),
],
@@ -84,7 +84,7 @@ public function getSecurityGroup()
/**
* Returns information about DELETE security-groups/{security_group_id} HTTP
- * operation
+ * operation.
*
* @return array
*/
@@ -92,7 +92,7 @@ public function deleteSecurityGroup()
{
return [
'method' => 'DELETE',
- 'path' => $this->pathPrefix . '/security-groups/{id}',
+ 'path' => $this->pathPrefix.'/security-groups/{id}',
'params' => [
'id' => $this->params->idPath(),
],
@@ -100,7 +100,7 @@ public function deleteSecurityGroup()
}
/**
- * Returns information about GET security-group-rules HTTP operation
+ * Returns information about GET security-group-rules HTTP operation.
*
* @return array
*/
@@ -108,13 +108,13 @@ public function getSecurityRules()
{
return [
'method' => 'GET',
- 'path' => $this->pathPrefix . '/security-group-rules',
+ 'path' => $this->pathPrefix.'/security-group-rules',
'params' => [],
];
}
/**
- * Returns information about POST security-group-rules HTTP operation
+ * Returns information about POST security-group-rules HTTP operation.
*
* @return array
*/
@@ -122,7 +122,7 @@ public function postSecurityRules()
{
return [
'method' => 'POST',
- 'path' => $this->pathPrefix . '/security-group-rules',
+ 'path' => $this->pathPrefix.'/security-group-rules',
'jsonKey' => 'security_group_rule',
'params' => [
'direction' => $this->params->directionJson(),
@@ -140,7 +140,7 @@ public function postSecurityRules()
/**
* Returns information about DELETE
- * security-group-rules/{rules-security-groups-id} HTTP operation
+ * security-group-rules/{rules-security-groups-id} HTTP operation.
*
* @return array
*/
@@ -148,7 +148,7 @@ public function deleteSecurityRule()
{
return [
'method' => 'DELETE',
- 'path' => $this->pathPrefix . '/security-group-rules/{id}',
+ 'path' => $this->pathPrefix.'/security-group-rules/{id}',
'params' => [
'id' => $this->params->idPath(),
],
@@ -157,7 +157,7 @@ public function deleteSecurityRule()
/**
* Returns information about GET
- * security-group-rules/{rules-security-groups-id} HTTP operation
+ * security-group-rules/{rules-security-groups-id} HTTP operation.
*
* @return array
*/
@@ -165,7 +165,7 @@ public function getSecurityRule()
{
return [
'method' => 'GET',
- 'path' => $this->pathPrefix . '/security-group-rules/{id}',
+ 'path' => $this->pathPrefix.'/security-group-rules/{id}',
'params' => [
'id' => $this->params->idPath(),
],
diff --git a/src/Networking/v2/Extensions/SecurityGroups/Models/SecurityGroup.php b/src/Networking/v2/Extensions/SecurityGroups/Models/SecurityGroup.php
index b4989fb5..5812c6b5 100644
--- a/src/Networking/v2/Extensions/SecurityGroups/Models/SecurityGroup.php
+++ b/src/Networking/v2/Extensions/SecurityGroups/Models/SecurityGroup.php
@@ -1,4 +1,6 @@
- new Alias('securityGroupRules', SecurityGroupRule::class, true),
- 'rules' => new Alias('securityGroupRules', SecurityGroupRule::class, true)
+ 'rules' => new Alias('securityGroupRules', SecurityGroupRule::class, true),
];
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function create(array $userOptions): Creatable
{
$response = $this->execute($this->api->postSecurityGroups(), $userOptions);
+
return $this->populateFromResponse($response);
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function delete()
{
@@ -78,7 +81,7 @@ public function delete()
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function retrieve()
{
diff --git a/src/Networking/v2/Extensions/SecurityGroups/Models/SecurityGroupRule.php b/src/Networking/v2/Extensions/SecurityGroups/Models/SecurityGroupRule.php
index de50807b..54064cd0 100644
--- a/src/Networking/v2/Extensions/SecurityGroups/Models/SecurityGroupRule.php
+++ b/src/Networking/v2/Extensions/SecurityGroups/Models/SecurityGroupRule.php
@@ -1,4 +1,6 @@
-execute($this->api->postSecurityRules(), $userOptions);
+
return $this->populateFromResponse($response);
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function delete()
{
@@ -96,7 +99,7 @@ public function delete()
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function retrieve()
{
diff --git a/src/Networking/v2/Extensions/SecurityGroups/Params.php b/src/Networking/v2/Extensions/SecurityGroups/Params.php
index 38f10beb..09f4c24f 100644
--- a/src/Networking/v2/Extensions/SecurityGroups/Params.php
+++ b/src/Networking/v2/Extensions/SecurityGroups/Params.php
@@ -8,7 +8,7 @@ public function directionJson()
{
return [
'type' => self::STRING_TYPE,
- 'description' => "Ingress or egress: the direction in which the security group rule is applied. For a compute instance, an ingress security group rule is applied to incoming (ingress) traffic for that instance. An egress rule is applied to traffic leaving the instance.",
+ 'description' => 'Ingress or egress: the direction in which the security group rule is applied. For a compute instance, an ingress security group rule is applied to incoming (ingress) traffic for that instance. An egress rule is applied to traffic leaving the instance.',
];
}
@@ -16,7 +16,7 @@ public function ethertypeJson()
{
return [
'type' => self::STRING_TYPE,
- 'description' => "Must be IPv4 or IPv6, and addresses represented in CIDR must match the ingress or egress rules.",
+ 'description' => 'Must be IPv4 or IPv6, and addresses represented in CIDR must match the ingress or egress rules.',
];
}
@@ -24,7 +24,7 @@ public function idJson()
{
return [
'type' => self::STRING_TYPE,
- 'description' => "The UUID of the security group rule.",
+ 'description' => 'The UUID of the security group rule.',
];
}
@@ -33,7 +33,7 @@ public function portRangeMaxJson()
return [
'type' => self::STRING_TYPE,
'sentAs' => 'port_range_max',
- 'description' => "The maximum port number in the range that is matched by the security group rule. The port_range_min attribute constrains the port_range_max attribute. If the protocol is ICMP, this value must be an ICMP type.",
+ 'description' => 'The maximum port number in the range that is matched by the security group rule. The port_range_min attribute constrains the port_range_max attribute. If the protocol is ICMP, this value must be an ICMP type.',
];
}
@@ -42,7 +42,7 @@ public function portRangeMinJson()
return [
'sentAs' => 'port_range_min',
'type' => self::STRING_TYPE,
- 'description' => "The minimum port number in the range that is matched by the security group rule. If the protocol is TCP or UDP, this value must be less than or equal to the port_range_max attribute value. If the protocol is ICMP, this value must be an ICMP type.",
+ 'description' => 'The minimum port number in the range that is matched by the security group rule. If the protocol is TCP or UDP, this value must be less than or equal to the port_range_max attribute value. If the protocol is ICMP, this value must be an ICMP type.',
];
}
@@ -50,7 +50,7 @@ public function protocolJson()
{
return [
'type' => self::STRING_TYPE,
- 'description' => "The protocol that is matched by the security group rule. Value is null, icmp, icmpv6, tcp, or udp.",
+ 'description' => 'The protocol that is matched by the security group rule. Value is null, icmp, icmpv6, tcp, or udp.',
];
}
@@ -59,7 +59,7 @@ public function remoteGroupIdJson()
return [
'sentAs' => 'remote_group_id',
'type' => self::STRING_TYPE,
- 'description' => "The remote group UUID to associate with this security group rule. You can specify either the remote_group_id or remote_ip_prefix attribute in the request body.",
+ 'description' => 'The remote group UUID to associate with this security group rule. You can specify either the remote_group_id or remote_ip_prefix attribute in the request body.',
];
}
@@ -68,7 +68,7 @@ public function remoteIpPrefixJson()
return [
'sentAs' => 'remote_ip_prefix',
'type' => self::STRING_TYPE,
- 'description' => "The remote IP prefix to associate with this security group rule. You can specify either the remote_group_id or remote_ip_prefix attribute in the request body. This attribute value matches the IP prefix as the source IP address of the IP packet.",
+ 'description' => 'The remote IP prefix to associate with this security group rule. You can specify either the remote_group_id or remote_ip_prefix attribute in the request body. This attribute value matches the IP prefix as the source IP address of the IP packet.',
];
}
@@ -77,7 +77,7 @@ public function securityGroupIdJson()
return [
'sentAs' => 'security_group_id',
'type' => self::STRING_TYPE,
- 'description' => "The UUID of the security group.",
+ 'description' => 'The UUID of the security group.',
];
}
@@ -86,7 +86,7 @@ public function tenantIdJson()
return [
'sentAs' => 'tenant_id',
'type' => self::STRING_TYPE,
- 'description' => "The UUID of the tenant who owns the security group rule. Only administrative users can specify a tenant UUID other than their own.",
+ 'description' => 'The UUID of the tenant who owns the security group rule. Only administrative users can specify a tenant UUID other than their own.',
];
}
}
diff --git a/src/Networking/v2/Models/InterfaceAttachment.php b/src/Networking/v2/Models/InterfaceAttachment.php
index 9a4038eb..46b430d7 100644
--- a/src/Networking/v2/Models/InterfaceAttachment.php
+++ b/src/Networking/v2/Models/InterfaceAttachment.php
@@ -1,4 +1,7 @@
- 'ipAddress',
'fixed_ips' => 'fixedIps',
'port_state' => 'portState',
- 'server_id' => 'serverId'
+ 'server_id' => 'serverId',
];
}
diff --git a/src/Networking/v2/Models/LoadBalancer.php b/src/Networking/v2/Models/LoadBalancer.php
index d0ba20c7..bb4a4ae4 100644
--- a/src/Networking/v2/Models/LoadBalancer.php
+++ b/src/Networking/v2/Models/LoadBalancer.php
@@ -1,4 +1,6 @@
- 'tenantId',
@@ -80,35 +82,36 @@ class LoadBalancer extends OperatorResource implements Creatable, Retrievable, U
];
/**
- * @inheritdoc
+ * {@inheritdoc}
*/
protected function getAliases(): array
{
return parent::getAliases() + [
- 'listeners' => new Alias('listeners', LoadBalancerListener::class, true)
+ 'listeners' => new Alias('listeners', LoadBalancerListener::class, true),
];
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function create(array $userOptions): Creatable
{
$response = $this->execute($this->api->postLoadBalancer(), $userOptions);
+
return $this->populateFromResponse($response);
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function retrieve()
{
- $response = $this->execute($this->api->getLoadBalancer(), ['id' => (string)$this->id]);
+ $response = $this->execute($this->api->getLoadBalancer(), ['id' => (string) $this->id]);
$this->populateFromResponse($response);
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function update()
{
@@ -117,7 +120,7 @@ public function update()
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function delete()
{
@@ -125,19 +128,21 @@ public function delete()
}
/**
- * Add a listener to this load balancer
+ * Add a listener to this load balancer.
*
* @param array $userOptions
+ *
* @return LoadBalancerListener
*/
public function addListener(array $userOptions = []): LoadBalancerListener
{
$userOptions = array_merge(['loadbalancerId' => $this->id], $userOptions);
+
return $this->model(LoadBalancerListener::class)->create($userOptions);
}
/**
- * Get stats for this loadbalancer
+ * Get stats for this loadbalancer.
*
* @return LoadBalancerStat
*/
@@ -145,11 +150,12 @@ public function getStats(): LoadBalancerStat
{
$model = $this->model(LoadBalancerStat::class, ['loadbalancerId' => $this->id]);
$model->retrieve();
+
return $model;
}
/**
- * Get the status tree for this loadbalancer
+ * Get the status tree for this loadbalancer.
*
* @return LoadBalancerStatus
*/
@@ -157,6 +163,7 @@ public function getStatuses(): LoadBalancerStatus
{
$model = $this->model(LoadBalancerStatus::class, ['loadbalancerId' => $this->id]);
$model->retrieve();
+
return $model;
}
}
diff --git a/src/Networking/v2/Models/LoadBalancerHealthMonitor.php b/src/Networking/v2/Models/LoadBalancerHealthMonitor.php
index 9e062e0a..1322e589 100644
--- a/src/Networking/v2/Models/LoadBalancerHealthMonitor.php
+++ b/src/Networking/v2/Models/LoadBalancerHealthMonitor.php
@@ -1,4 +1,6 @@
- 'tenantId',
@@ -103,35 +105,36 @@ class LoadBalancerHealthMonitor extends OperatorResource implements Creatable, R
];
/**
- * @inheritdoc
+ * {@inheritdoc}
*/
protected function getAliases(): array
{
return parent::getAliases() + [
- 'pools' => new Alias('pools', LoadBalancerPool::class, true)
+ 'pools' => new Alias('pools', LoadBalancerPool::class, true),
];
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function create(array $userOptions): Creatable
{
$response = $this->execute($this->api->postLoadBalancerHealthMonitor(), $userOptions);
+
return $this->populateFromResponse($response);
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function retrieve()
{
- $response = $this->execute($this->api->getLoadBalancerHealthMonitor(), ['id' => (string)$this->id]);
+ $response = $this->execute($this->api->getLoadBalancerHealthMonitor(), ['id' => (string) $this->id]);
$this->populateFromResponse($response);
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function update()
{
@@ -140,7 +143,7 @@ public function update()
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function delete()
{
diff --git a/src/Networking/v2/Models/LoadBalancerListener.php b/src/Networking/v2/Models/LoadBalancerListener.php
index b8af397a..2ab1254b 100644
--- a/src/Networking/v2/Models/LoadBalancerListener.php
+++ b/src/Networking/v2/Models/LoadBalancerListener.php
@@ -1,4 +1,6 @@
- 'tenantId',
@@ -102,36 +104,37 @@ class LoadBalancerListener extends OperatorResource implements Creatable, Retrie
];
/**
- * @inheritdoc
+ * {@inheritdoc}
*/
protected function getAliases(): array
{
return parent::getAliases() + [
'pools' => new Alias('pools', LoadBalancerPool::class, true),
- 'loadbalancers' => new Alias('loadbalancers', LoadBalancerPool::class, true)
+ 'loadbalancers' => new Alias('loadbalancers', LoadBalancerPool::class, true),
];
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function create(array $userOptions): Creatable
{
$response = $this->execute($this->api->postLoadBalancerListener(), $userOptions);
+
return $this->populateFromResponse($response);
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function retrieve()
{
- $response = $this->execute($this->api->getLoadBalancerListener(), ['id' => (string)$this->id]);
+ $response = $this->execute($this->api->getLoadBalancerListener(), ['id' => (string) $this->id]);
$this->populateFromResponse($response);
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function update()
{
@@ -140,7 +143,7 @@ public function update()
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function delete()
{
diff --git a/src/Networking/v2/Models/LoadBalancerMember.php b/src/Networking/v2/Models/LoadBalancerMember.php
index 7dc5d894..a8d01c2b 100644
--- a/src/Networking/v2/Models/LoadBalancerMember.php
+++ b/src/Networking/v2/Models/LoadBalancerMember.php
@@ -1,4 +1,6 @@
- 'tenantId',
@@ -76,42 +78,43 @@ class LoadBalancerMember extends OperatorResource implements Creatable, Retrieva
'subnet_id' => 'subnetId',
'pool_id' => 'poolId',
'operating_status' => 'operatingStatus',
- 'provisioning_status' => 'provisioningStatus'
+ 'provisioning_status' => 'provisioningStatus',
];
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function create(array $userOptions): Creatable
{
$userOptions = array_merge(['poolId' => $this->poolId], $userOptions);
- $response = $this->execute($this->api->postLoadBalancerMember(), $userOptions);
+ $response = $this->execute($this->api->postLoadBalancerMember(), $userOptions);
+
return $this->populateFromResponse($response);
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function retrieve()
{
- $response = $this->execute($this->api->getLoadBalancerMember(), ['poolId' => (string)$this->poolId, 'id' => (string)$this->id]);
+ $response = $this->execute($this->api->getLoadBalancerMember(), ['poolId' => (string) $this->poolId, 'id' => (string) $this->id]);
$this->populateFromResponse($response);
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function update()
{
- $response = $this->executeWithState($this->api->putLoadBalancerMember(), ['poolId' => (string)$this->poolId, 'id' => (string)$this->id]);
+ $response = $this->executeWithState($this->api->putLoadBalancerMember(), ['poolId' => (string) $this->poolId, 'id' => (string) $this->id]);
$this->populateFromResponse($response);
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function delete()
{
- $this->executeWithState($this->api->deleteLoadBalancerMember(), ['poolId' => (string)$this->poolId, 'id' => (string)$this->id]);
+ $this->executeWithState($this->api->deleteLoadBalancerMember(), ['poolId' => (string) $this->poolId, 'id' => (string) $this->id]);
}
}
diff --git a/src/Networking/v2/Models/LoadBalancerPool.php b/src/Networking/v2/Models/LoadBalancerPool.php
index f25ff759..4da0be95 100644
--- a/src/Networking/v2/Models/LoadBalancerPool.php
+++ b/src/Networking/v2/Models/LoadBalancerPool.php
@@ -1,4 +1,6 @@
- 'tenantId',
@@ -102,37 +104,38 @@ class LoadBalancerPool extends OperatorResource implements Creatable, Retrievabl
];
/**
- * @inheritdoc
+ * {@inheritdoc}
*/
protected function getAliases(): array
{
return parent::getAliases() + [
'listeners' => new Alias('listeners', LoadBalancerListener::class, true),
'members' => new Alias('members', LoadBalancerMember::class, true),
- 'healthmonitors' => new Alias('healthmonitors', LoadBalancerHealthMonitor::class, true)
+ 'healthmonitors' => new Alias('healthmonitors', LoadBalancerHealthMonitor::class, true),
];
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function create(array $userOptions): Creatable
{
$response = $this->execute($this->api->postLoadBalancerPool(), $userOptions);
+
return $this->populateFromResponse($response);
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function retrieve()
{
- $response = $this->execute($this->api->getLoadBalancerPool(), ['id' => (string)$this->id]);
+ $response = $this->execute($this->api->getLoadBalancerPool(), ['id' => (string) $this->id]);
$this->populateFromResponse($response);
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function update()
{
@@ -141,7 +144,7 @@ public function update()
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function delete()
{
@@ -149,20 +152,22 @@ public function delete()
}
/**
- * Add a member to this pool
+ * Add a member to this pool.
*
* @param array $userOptions
*/
public function addMember(array $userOptions = []): LoadBalancerMember
{
$userOptions = array_merge(['poolId' => $this->id], $userOptions);
+
return $this->model(LoadBalancerMember::class)->create($userOptions);
}
/**
- * Get an instance of a member
+ * Get an instance of a member.
*
* @param string $memberId
+ *
* @return LoadBalancerMember
*/
public function getMember(string $memberId): LoadBalancerMember
@@ -171,7 +176,7 @@ public function getMember(string $memberId): LoadBalancerMember
}
/**
- * Delete a member
+ * Delete a member.
*
* @param string $memberId
*/
@@ -181,14 +186,16 @@ public function deleteMember(string $memberId)
}
/**
- * Add a healthmonitor to this load balancer pool
+ * Add a healthmonitor to this load balancer pool.
*
* @param array $userOptions
+ *
* @return LoadBalancerHealthMonitor
*/
public function addHealthMonitor(array $userOptions = []): LoadBalancerHealthMonitor
{
$userOptions = array_merge(['poolId' => $this->id], $userOptions);
+
return $this->model(LoadBalancerHealthMonitor::class)->create($userOptions);
}
}
diff --git a/src/Networking/v2/Models/LoadBalancerStat.php b/src/Networking/v2/Models/LoadBalancerStat.php
index 500af336..eccf3f25 100644
--- a/src/Networking/v2/Models/LoadBalancerStat.php
+++ b/src/Networking/v2/Models/LoadBalancerStat.php
@@ -1,4 +1,6 @@
- 'bytesOut',
'total_connections' => 'totalConnections',
'active_connections' => 'activeConnections',
- 'loadbalancer_id' => 'loadbalancerId'
+ 'loadbalancer_id' => 'loadbalancerId',
];
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function retrieve()
{
- $response = $this->execute($this->api->getLoadBalancerStats(), ['loadbalancerId' => (string)$this->loadbalancerId]);
+ $response = $this->execute($this->api->getLoadBalancerStats(), ['loadbalancerId' => (string) $this->loadbalancerId]);
$this->populateFromResponse($response);
}
}
diff --git a/src/Networking/v2/Models/LoadBalancerStatus.php b/src/Networking/v2/Models/LoadBalancerStatus.php
index 75c84b70..dbcf1de4 100644
--- a/src/Networking/v2/Models/LoadBalancerStatus.php
+++ b/src/Networking/v2/Models/LoadBalancerStatus.php
@@ -1,4 +1,6 @@
- new Alias('listeners', LoadBalancerListener::class, true)
+ 'listeners' => new Alias('listeners', LoadBalancerListener::class, true),
];
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function retrieve()
{
- $response = $this->execute($this->api->getLoadBalancerStatuses(), ['loadbalancerId' => (string)$this->loadbalancerId]);
- $json = Utils::jsonDecode($response);
+ $response = $this->execute($this->api->getLoadBalancerStatuses(), ['loadbalancerId' => (string) $this->loadbalancerId]);
+ $json = Utils::jsonDecode($response);
$this->populateFromArray($json[$this->resourceKey]['loadbalancer']);
}
}
diff --git a/src/Networking/v2/Models/Network.php b/src/Networking/v2/Models/Network.php
index a96ec795..ab92bfa6 100644
--- a/src/Networking/v2/Models/Network.php
+++ b/src/Networking/v2/Models/Network.php
@@ -1,4 +1,6 @@
- 'tenantId',
];
- protected $resourceKey = 'network';
+ protected $resourceKey = 'network';
protected $resourcesKey = 'networks';
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function retrieve()
{
- $response = $this->execute($this->api->getNetwork(), ['id' => (string)$this->id]);
+ $response = $this->execute($this->api->getNetwork(), ['id' => (string) $this->id]);
$this->populateFromResponse($response);
}
@@ -66,22 +68,24 @@ public function retrieve()
public function bulkCreate(array $data): array
{
$response = $this->execute($this->api->postNetworks(), ['networks' => $data]);
+
return $this->extractMultipleInstances($response);
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*
* @param array $data {@see \OpenStack\Networking\v2\Api::postNetwork}
*/
public function create(array $data): Creatable
{
$response = $this->execute($this->api->postNetwork(), $data);
+
return $this->populateFromResponse($response);
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function update()
{
@@ -90,7 +94,7 @@ public function update()
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function delete()
{
diff --git a/src/Networking/v2/Models/Port.php b/src/Networking/v2/Models/Port.php
index b5abf8ac..e67b123b 100644
--- a/src/Networking/v2/Models/Port.php
+++ b/src/Networking/v2/Models/Port.php
@@ -1,4 +1,6 @@
-execute($this->api->postSinglePort(), $userOptions);
+
return $this->populateFromResponse($response);
}
public function bulkCreate(array $userOptions): array
{
$response = $this->execute($this->api->postMultiplePorts(), ['ports' => $userOptions]);
+
return $this->extractMultipleInstances($response);
}
public function retrieve()
{
- $response = $this->execute($this->api->getPort(), ['id' => (string)$this->id]);
+ $response = $this->execute($this->api->getPort(), ['id' => (string) $this->id]);
$this->populateFromResponse($response);
}
diff --git a/src/Networking/v2/Models/Quota.php b/src/Networking/v2/Models/Quota.php
index dc4105e2..3398d1dc 100644
--- a/src/Networking/v2/Models/Quota.php
+++ b/src/Networking/v2/Models/Quota.php
@@ -1,4 +1,6 @@
- 'tenantId',
@@ -76,16 +78,16 @@ class Quota extends OperatorResource implements Retrievable, Updateable, Deletab
];
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function retrieve()
{
- $response = $this->execute($this->api->getQuota(), ['tenantId' => (string)$this->tenantId]);
+ $response = $this->execute($this->api->getQuota(), ['tenantId' => (string) $this->tenantId]);
$this->populateFromResponse($response);
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function update()
{
@@ -94,7 +96,7 @@ public function update()
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function delete()
{
diff --git a/src/Networking/v2/Models/Subnet.php b/src/Networking/v2/Models/Subnet.php
index 9c3f18ea..142a9ddf 100644
--- a/src/Networking/v2/Models/Subnet.php
+++ b/src/Networking/v2/Models/Subnet.php
@@ -1,4 +1,6 @@
- 'hostRoutes',
'ip_version' => 'ipVersion',
'gateway_ip' => 'gatewayIp',
- 'tenant_id' => 'tenantId'
+ 'tenant_id' => 'tenantId',
];
- protected $resourceKey = 'subnet';
+ protected $resourceKey = 'subnet';
protected $resourcesKey = 'subnets';
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function retrieve()
{
- $response = $this->execute($this->api->getSubnet(), ['id' => (string)$this->id]);
+ $response = $this->execute($this->api->getSubnet(), ['id' => (string) $this->id]);
$this->populateFromResponse($response);
}
@@ -85,22 +87,24 @@ public function retrieve()
public function bulkCreate(array $data): array
{
$response = $this->execute($this->api->postSubnets(), ['subnets' => $data]);
+
return $this->extractMultipleInstances($response);
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*
* @param array $data {@see \OpenStack\Networking\v2\Api::postSubnet}
*/
public function create(array $data): Creatable
{
$response = $this->execute($this->api->postSubnet(), $data);
+
return $this->populateFromResponse($response);
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function update()
{
@@ -109,7 +113,7 @@ public function update()
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function delete()
{
@@ -117,13 +121,13 @@ public function delete()
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
protected function getAttrs(array $keys)
{
$output = parent::getAttrs($keys);
- if ($this->gatewayIp === '') {
+ if ('' === $this->gatewayIp) {
$output['gatewayIp'] = null;
}
diff --git a/src/Networking/v2/Params.php b/src/Networking/v2/Params.php
index 9e444d76..178f5b75 100644
--- a/src/Networking/v2/Params.php
+++ b/src/Networking/v2/Params.php
@@ -1,4 +1,6 @@
- self::ARRAY_TYPE,
'sentAs' => 'dns_nameservers',
'description' => 'A list of DNS name servers for the subnet.',
- 'items' => [
+ 'items' => [
'type' => self::STRING_TYPE,
'description' => 'The nameserver',
],
@@ -293,20 +295,20 @@ public function fixedIps(): array
port, specify multiple entries in this field. Each entry consists of IP address (ipAddress)
and the subnet ID from which the IP address is assigned (subnetId)',
'items' => [
- 'type' => self::OBJECT_TYPE,
+ 'type' => self::OBJECT_TYPE,
'properties' => [
'ipAddress' => [
- 'type' => self::STRING_TYPE,
- 'sentAs' => 'ip_address',
- 'description' => 'If you specify only an IP address, OpenStack Networking tries to allocate the IP address if the address is a valid IP for any of the subnets on the specified network.'
+ 'type' => self::STRING_TYPE,
+ 'sentAs' => 'ip_address',
+ 'description' => 'If you specify only an IP address, OpenStack Networking tries to allocate the IP address if the address is a valid IP for any of the subnets on the specified network.',
],
'subnetId' => [
- 'type' => self::STRING_TYPE,
- 'sentAs' => 'subnet_id',
- 'description' => 'Subnet id. If you specify only a subnet ID, OpenStack Networking allocates an available IP from that subnet to the port.'
- ]
- ]
- ]
+ 'type' => self::STRING_TYPE,
+ 'sentAs' => 'subnet_id',
+ 'description' => 'Subnet id. If you specify only a subnet ID, OpenStack Networking allocates an available IP from that subnet to the port.',
+ ],
+ ],
+ ],
];
}
@@ -427,10 +429,10 @@ public function routerAccessibleJson(): array
protected function quotaLimit(string $sentAs, string $description): array
{
return [
- 'type' => self::INT_TYPE,
- 'location' => self::JSON,
- 'sentAs' => $sentAs,
- 'description' => $description
+ 'type' => self::INT_TYPE,
+ 'location' => self::JSON,
+ 'sentAs' => $sentAs,
+ 'description' => $description,
];
}
@@ -629,7 +631,7 @@ public function delay(): array
return [
'type' => self::INT_TYPE,
'location' => self::JSON,
- 'description' => 'The interval in seconds between health checks.'
+ 'description' => 'The interval in seconds between health checks.',
];
}
@@ -638,7 +640,7 @@ public function timeout(): array
return [
'type' => self::INT_TYPE,
'location' => self::JSON,
- 'description' => 'The time in seconds that a health check times out.'
+ 'description' => 'The time in seconds that a health check times out.',
];
}
@@ -648,7 +650,7 @@ public function maxRetries(): array
'type' => self::INT_TYPE,
'location' => self::JSON,
'sentAs' => 'max_retries',
- 'description' => 'Number of failed health checks before marked as OFFLINE.'
+ 'description' => 'Number of failed health checks before marked as OFFLINE.',
];
}
@@ -658,7 +660,7 @@ public function httpMethod(): array
'type' => self::STRING_TYPE,
'location' => self::JSON,
'sentAs' => 'http_method',
- 'description' => 'The default value for this attribute is GET.'
+ 'description' => 'The default value for this attribute is GET.',
];
}
@@ -668,7 +670,7 @@ public function urlPath(): array
'type' => self::STRING_TYPE,
'location' => self::JSON,
'sentAs' => 'url_path',
- 'description' => 'The default value is "/"'
+ 'description' => 'The default value is "/"',
];
}
@@ -678,7 +680,7 @@ public function expectedCodes(): array
'type' => self::STRING_TYPE,
'location' => self::JSON,
'sentAs' => 'expected_codes',
- 'description' => 'The expected http status codes to get from a successful health check. Defaults to 200. (comma separated)'
+ 'description' => 'The expected http status codes to get from a successful health check. Defaults to 200. (comma separated)',
];
}
@@ -687,7 +689,7 @@ public function type(): array
return [
'type' => self::STRING_TYPE,
'location' => self::JSON,
- 'description' => 'The type of health monitor. Must be one of TCP, HTTP, HTTPS'
+ 'description' => 'The type of health monitor. Must be one of TCP, HTTP, HTTPS',
];
}
}
diff --git a/src/Networking/v2/Service.php b/src/Networking/v2/Service.php
index 68afdc46..6a1e0f93 100644
--- a/src/Networking/v2/Service.php
+++ b/src/Networking/v2/Service.php
@@ -1,4 +1,6 @@
-params = new Params;
+ $this->params = new Params();
}
public function getAccount(): array
diff --git a/src/ObjectStore/v1/Models/Account.php b/src/ObjectStore/v1/Models/Account.php
index cd280411..3ef03e2a 100644
--- a/src/ObjectStore/v1/Models/Account.php
+++ b/src/ObjectStore/v1/Models/Account.php
@@ -1,4 +1,6 @@
-containerCount = $response->getHeaderLine('X-Account-Container-Count');
- $this->objectCount = $response->getHeaderLine('X-Account-Object-Count');
- $this->bytesUsed = $response->getHeaderLine('X-Account-Bytes-Used');
- $this->tempUrl = $response->getHeaderLine('X-Account-Meta-Temp-URL-Key');
- $this->metadata = $this->parseMetadata($response);
+ $this->objectCount = $response->getHeaderLine('X-Account-Object-Count');
+ $this->bytesUsed = $response->getHeaderLine('X-Account-Bytes-Used');
+ $this->tempUrl = $response->getHeaderLine('X-Account-Meta-Temp-URL-Key');
+ $this->metadata = $this->parseMetadata($response);
return $this;
}
@@ -61,7 +63,7 @@ public function retrieve()
*/
public function mergeMetadata(array $metadata)
{
- $response = $this->execute($this->api->postAccount(), ['metadata' => $metadata]);
+ $response = $this->execute($this->api->postAccount(), ['metadata' => $metadata]);
$this->metadata = $this->parseMetadata($response);
}
@@ -81,7 +83,7 @@ public function resetMetadata(array $metadata)
}
}
- $response = $this->execute($this->api->postAccount(), $options);
+ $response = $this->execute($this->api->postAccount(), $options);
$this->metadata = $this->parseMetadata($response);
}
@@ -91,6 +93,7 @@ public function resetMetadata(array $metadata)
public function getMetadata(): array
{
$response = $this->execute($this->api->headAccount());
+
return $this->parseMetadata($response);
}
}
diff --git a/src/ObjectStore/v1/Models/Container.php b/src/ObjectStore/v1/Models/Container.php
index 52704546..db3a18d5 100644
--- a/src/ObjectStore/v1/Models/Container.php
+++ b/src/ObjectStore/v1/Models/Container.php
@@ -1,4 +1,6 @@
-objectCount = $response->getHeaderLine('X-Container-Object-Count');
- $this->bytesUsed = $response->getHeaderLine('X-Container-Bytes-Used');
- $this->metadata = $this->parseMetadata($response);
+ $this->bytesUsed = $response->getHeaderLine('X-Container-Bytes-Used');
+ $this->metadata = $this->parseMetadata($response);
return $this;
}
@@ -54,14 +56,22 @@ public function populateFromResponse(ResponseInterface $response): self
* Retrieves a collection of object resources in the form of a generator.
*
* @param array $options {@see \OpenStack\ObjectStore\v1\Api::getContainer}
- * @param callable|null $mapFn Allows a function to be mapped over each element.
+ * @param callable|null $mapFn allows a function to be mapped over each element
*
* @return \Generator
*/
public function listObjects(array $options = [], callable $mapFn = null): \Generator
{
$options = array_merge($options, ['name' => $this->name, 'format' => 'json']);
- return $this->model(Object::class)->enumerate($this->api->getContainer(), $options, $mapFn);
+
+ $appendContainerNameFn = function (Object $resource) use ($mapFn) {
+ $resource->containerName = $this->name;
+ if ($mapFn) {
+ call_user_func_array($mapFn, [&$resource]);
+ }
+ };
+
+ return $this->model(Object::class)->enumerate($this->api->getContainer(), $options, $appendContainerNameFn);
}
/**
@@ -101,7 +111,7 @@ public function delete()
*/
public function mergeMetadata(array $metadata)
{
- $response = $this->execute($this->api->postContainer(), ['name' => $this->name, 'metadata' => $metadata]);
+ $response = $this->execute($this->api->postContainer(), ['name' => $this->name, 'metadata' => $metadata]);
$this->metadata = $this->parseMetadata($response);
}
@@ -122,7 +132,7 @@ public function resetMetadata(array $metadata)
}
}
- $response = $this->execute($this->api->postContainer(), $options);
+ $response = $this->execute($this->api->postContainer(), $options);
$this->metadata = $this->parseMetadata($response);
}
@@ -132,6 +142,7 @@ public function resetMetadata(array $metadata)
public function getMetadata(): array
{
$response = $this->executeWithState($this->api->headContainer());
+
return $this->parseMetadata($response);
}
@@ -142,7 +153,7 @@ public function getMetadata(): array
*
* @param string $name The name of the object
*
- * @return Object
+ * @return object
*/
public function getObject($name): Object
{
@@ -152,20 +163,21 @@ public function getObject($name): Object
/**
* Identifies whether an object exists in this container.
*
- * @param string $name The name of the object.
+ * @param string $name the name of the object
*
- * @return bool TRUE if the object exists, FALSE if it does not.
+ * @return bool TRUE if the object exists, FALSE if it does not
*
- * @throws BadResponseError For any other HTTP error which does not have a 404 Not Found status.
- * @throws \Exception For any other type of fatal error.
+ * @throws BadResponseError for any other HTTP error which does not have a 404 Not Found status
+ * @throws \Exception for any other type of fatal error
*/
public function objectExists(string $name): bool
{
try {
$this->getObject($name)->retrieve();
+
return true;
} catch (BadResponseError $e) {
- if ($e->getResponse()->getStatusCode() === 404) {
+ if (404 === $e->getResponse()->getStatusCode()) {
return false;
}
throw $e;
@@ -177,7 +189,7 @@ public function objectExists(string $name): bool
*
* @param array $data {@see \OpenStack\ObjectStore\v1\Api::putObject}
*
- * @return Object
+ * @return object
*/
public function createObject(array $data): Object
{
@@ -195,7 +207,7 @@ public function createObject(array $data): Object
* @param string $data['segmentPrefix'] The prefix that will come before each segment. If omitted, a default
* is used: name/timestamp/filesize
*
- * @return Object
+ * @return object
*/
public function createLargeObject(array $data): Object
{
@@ -203,10 +215,10 @@ public function createLargeObject(array $data): Object
$stream = $data['stream'];
$segmentSize = isset($data['segmentSize']) ? $data['segmentSize'] : 1073741824;
- $segmentContainer = isset($data['segmentContainer']) ? $data['segmentContainer'] : $this->name . '_segments';
+ $segmentContainer = isset($data['segmentContainer']) ? $data['segmentContainer'] : $this->name.'_segments';
$segmentPrefix = isset($data['segmentPrefix'])
? $data['segmentPrefix']
- : sprintf("%s/%s/%d", $data['name'], microtime(true), $stream->getSize());
+ : sprintf('%s/%s/%d', $data['name'], microtime(true), $stream->getSize());
/** @var \OpenStack\ObjectStore\v1\Service $service */
$service = $this->getService();
@@ -219,7 +231,7 @@ public function createLargeObject(array $data): Object
while (!$stream->eof() && $count < round($stream->getSize() / $segmentSize)) {
$promises[] = $this->model(Object::class)->createAsync([
- 'name' => sprintf("%s/%d", $segmentPrefix, ++$count),
+ 'name' => sprintf('%s/%d', $segmentPrefix, ++$count),
'stream' => new LimitStream($stream, $segmentSize, ($count - 1) * $segmentSize),
'containerName' => $segmentContainer,
]);
@@ -231,7 +243,7 @@ public function createLargeObject(array $data): Object
return $this->createObject([
'name' => $data['name'],
- 'objectManifest' => sprintf("%s/%s", $segmentContainer, $segmentPrefix),
+ 'objectManifest' => sprintf('%s/%s', $segmentContainer, $segmentPrefix),
]);
}
}
diff --git a/src/ObjectStore/v1/Models/MetadataTrait.php b/src/ObjectStore/v1/Models/MetadataTrait.php
index 9529dbab..f4006aed 100644
--- a/src/ObjectStore/v1/Models/MetadataTrait.php
+++ b/src/ObjectStore/v1/Models/MetadataTrait.php
@@ -1,4 +1,6 @@
-getHeaders() as $header => $value) {
if (0 === strpos($header, static::METADATA_PREFIX)) {
- $name = substr($header, strlen(static::METADATA_PREFIX));
+ $name = substr($header, strlen(static::METADATA_PREFIX));
$metadata[$name] = $response->getHeader($header)[0];
}
}
diff --git a/src/ObjectStore/v1/Models/Object.php b/src/ObjectStore/v1/Models/Object.php
index 2f255817..cb76691f 100644
--- a/src/ObjectStore/v1/Models/Object.php
+++ b/src/ObjectStore/v1/Models/Object.php
@@ -1,8 +1,11 @@
- 'contentLength'];
+
+ protected $aliases = [
+ 'bytes' => 'contentLength',
+ 'content_type' => 'contentType',
+ 'subdir' => 'name',
+ ];
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function getAliases(): array
+ {
+ return parent::getAliases() + [
+ 'last_modified' => new Alias('lastModified', \DateTimeImmutable::class),
+ ];
+ }
/**
* {@inheritdoc}
@@ -63,11 +81,11 @@ public function populateFromResponse(ResponseInterface $response): self
*/
private function populateHeaders(ResponseInterface $response): self
{
- $this->hash = $response->getHeaderLine('ETag');
+ $this->hash = $response->getHeaderLine('ETag');
$this->contentLength = $response->getHeaderLine('Content-Length');
- $this->lastModified = $response->getHeaderLine('Last-Modified');
- $this->contentType = $response->getHeaderLine('Content-Type');
- $this->metadata = $this->parseMetadata($response);
+ $this->lastModified = $response->getHeaderLine('Last-Modified');
+ $this->contentType = $response->getHeaderLine('Content-Type');
+ $this->metadata = $this->parseMetadata($response);
return $this;
}
@@ -89,8 +107,22 @@ public function getPublicUri(): Uri
*/
public function create(array $data): Creatable
{
- $response = $this->execute($this->api->putObject(), $data + ['containerName' => $this->containerName]);
- return $this->populateFromResponse($response);
+ // Override containerName from input params only if local instance contains containerName attr
+ if ($this->containerName) {
+ $data['containerName'] = $this->containerName;
+ }
+
+ $response = $this->execute($this->api->putObject(), $data);
+ $storageObject = $this->populateFromResponse($response);
+
+ // Repopulate data for this newly created object instance
+ // due to the response from API does not contain object name and containerName
+ $storageObject = $storageObject->populateFromArray([
+ 'name' => $data['name'],
+ 'containerName' => $data['containerName'],
+ ]);
+
+ return $storageObject;
}
/**
@@ -112,7 +144,6 @@ public function retrieve()
*
* @return StreamInterface
*/
-
public function download(array $data = []): StreamInterface
{
$data += ['name' => $this->name, 'containerName' => $this->containerName];
@@ -152,7 +183,7 @@ public function mergeMetadata(array $metadata)
'metadata' => array_merge($metadata, $this->getMetadata()),
];
- $response = $this->execute($this->api->postObject(), $options);
+ $response = $this->execute($this->api->postObject(), $options);
$this->metadata = $this->parseMetadata($response);
}
@@ -167,7 +198,7 @@ public function resetMetadata(array $metadata)
'metadata' => $metadata,
];
- $response = $this->execute($this->api->postObject(), $options);
+ $response = $this->execute($this->api->postObject(), $options);
$this->metadata = $this->parseMetadata($response);
}
@@ -177,6 +208,7 @@ public function resetMetadata(array $metadata)
public function getMetadata(): array
{
$response = $this->executeWithState($this->api->headObject());
+
return $this->parseMetadata($response);
}
}
diff --git a/src/ObjectStore/v1/Params.php b/src/ObjectStore/v1/Params.php
index 44e39594..dfc15177 100644
--- a/src/ObjectStore/v1/Params.php
+++ b/src/ObjectStore/v1/Params.php
@@ -1,4 +1,6 @@
- self::HEADER,
- 'sentAs' => sprintf("X-%s-Meta-Temp-URL-Key", ucfirst($type)),
+ 'sentAs' => sprintf('X-%s-Meta-Temp-URL-Key', ucfirst($type)),
'description' => 'The secret key value for temporary URLs.',
];
}
@@ -66,7 +68,7 @@ public function tempUrlKey2($type)
{
return [
'location' => self::HEADER,
- 'sentAs' => sprintf("X-%s-Meta-Temp-URL-Key-2", ucfirst($type)),
+ 'sentAs' => sprintf('X-%s-Meta-Temp-URL-Key-2', ucfirst($type)),
'description' => << 'header',
- 'sentAs' => sprintf("X-%s-Read", ucfirst($type)),
+ 'sentAs' => sprintf('X-%s-Read', ucfirst($type)),
'description' => << self::HEADER,
- 'sentAs' => sprintf("X-%s-Write", ucfirst($type)),
+ 'sentAs' => sprintf('X-%s-Write', ucfirst($type)),
'description' => 'Like `readAccess` parameter, but for write access.',
];
}
public function metadata($type, $remove = false)
{
- if ($remove == true) {
- $type = 'Remove-' . ucfirst($type);
+ if (true == $remove) {
+ $type = 'Remove-'.ucfirst($type);
}
return [
'location' => self::HEADER,
'type' => self::OBJECT_TYPE,
- 'prefix' => sprintf("X-%s-Meta-", ucfirst($type)),
+ 'prefix' => sprintf('X-%s-Meta-', ucfirst($type)),
'properties' => [
'type' => self::STRING_TYPE,
],
diff --git a/src/ObjectStore/v1/Service.php b/src/ObjectStore/v1/Service.php
index cd27e5a9..27ba97c3 100644
--- a/src/ObjectStore/v1/Service.php
+++ b/src/ObjectStore/v1/Service.php
@@ -1,4 +1,6 @@
- 'json']);
+
return $this->model(Container::class)->enumerate($this->api->getAccount(), $options, $mapFn);
}
@@ -66,16 +69,18 @@ public function createContainer(array $data): Container
*
* @param string $name The name of the container
*
- * @return bool TRUE if exists, FALSE if it doesn't
+ * @return bool TRUE if exists, FALSE if it doesn't
+ *
* @throws BadResponseError Thrown for any non 404 status error
*/
public function containerExists(string $name): bool
{
try {
$this->execute($this->api->headContainer(), ['name' => $name]);
+
return true;
} catch (BadResponseError $e) {
- if ($e->getResponse()->getStatusCode() === 404) {
+ if (404 === $e->getResponse()->getStatusCode()) {
return false;
}
throw $e;
diff --git a/src/OpenStack.php b/src/OpenStack.php
index d1e02f20..b88a7b77 100644
--- a/src/OpenStack.php
+++ b/src/OpenStack.php
@@ -1,4 +1,6 @@
- 'nova', 'catalogType' => 'compute'];
+
return $this->builder->createService('Compute\\v2', array_merge($defaults, $options));
}
/**
* Creates a new Networking v2 service.
*
- * @param array $options Options that will be used in configuring the service.
+ * @param array $options options that will be used in configuring the service
*
* @return \OpenStack\Networking\v2\Service
*/
public function networkingV2(array $options = []): \OpenStack\Networking\v2\Service
{
$defaults = ['catalogName' => 'neutron', 'catalogType' => 'network'];
+
return $this->builder->createService('Networking\\v2', array_merge($defaults, $options));
}
/**
* Creates a new Networking v2 Layer 3 service.
*
- * @param array $options Options that will be used in configuring the service.
+ * @param array $options options that will be used in configuring the service
*
* @return \OpenStack\Networking\v2\Extensions\Layer3\Service
*/
public function networkingV2ExtLayer3(array $options = []): \OpenStack\Networking\v2\Extensions\Layer3\Service
{
$defaults = ['catalogName' => 'neutron', 'catalogType' => 'network'];
+
return $this->builder->createService('Networking\\v2\\Extensions\\Layer3', array_merge($defaults, $options));
}
/**
* Creates a new Networking v2 Layer 3 service.
*
- * @param array $options Options that will be used in configuring the service.
+ * @param array $options options that will be used in configuring the service
*
* @return \OpenStack\Networking\v2\Extensions\SecurityGroups\Service
*/
public function networkingV2ExtSecGroups(array $options = []): \OpenStack\Networking\v2\Extensions\SecurityGroups\Service
{
$defaults = ['catalogName' => 'neutron', 'catalogType' => 'network'];
+
return $this->builder->createService('Networking\\v2\\Extensions\\SecurityGroups', array_merge($defaults, $options));
}
/**
* Creates a new Identity v2 service.
*
- * @param array $options Options that will be used in configuring the service.
+ * @param array $options options that will be used in configuring the service
*
* @return \OpenStack\Identity\v2\Service
*/
public function identityV2(array $options = []): \OpenStack\Identity\v2\Service
{
$defaults = ['catalogName' => 'keystone', 'catalogType' => 'identity'];
+
return $this->builder->createService('Identity\\v2', array_merge($defaults, $options));
}
/**
* Creates a new Identity v3 service.
*
- * @param array $options Options that will be used in configuring the service.
+ * @param array $options options that will be used in configuring the service
*
* @return \OpenStack\Identity\v3\Service
*/
public function identityV3(array $options = []): \OpenStack\Identity\v3\Service
{
$defaults = ['catalogName' => 'keystone', 'catalogType' => 'identity'];
+
return $this->builder->createService('Identity\\v3', array_merge($defaults, $options));
}
/**
* Creates a new Object Store v1 service.
*
- * @param array $options Options that will be used in configuring the service.
+ * @param array $options options that will be used in configuring the service
*
* @return \OpenStack\ObjectStore\v1\Service
*/
public function objectStoreV1(array $options = []): \OpenStack\ObjectStore\v1\Service
{
$defaults = ['catalogName' => 'swift', 'catalogType' => 'object-store'];
+
return $this->builder->createService('ObjectStore\\v1', array_merge($defaults, $options));
}
/**
* Creates a new Block Storage v2 service.
*
- * @param array $options Options that will be used in configuring the service.
+ * @param array $options options that will be used in configuring the service
*
* @return \OpenStack\BlockStorage\v2\Service
*/
public function blockStorageV2(array $options = []): \OpenStack\BlockStorage\v2\Service
{
$defaults = ['catalogName' => 'cinderv2', 'catalogType' => 'volumev2'];
+
return $this->builder->createService('BlockStorage\\v2', array_merge($defaults, $options));
}
/**
* Creates a new Images v2 service.
*
- * @param array $options Options that will be used in configuring the service.
+ * @param array $options options that will be used in configuring the service
*
* @return \OpenStack\Images\v2\Service
*/
public function imagesV2(array $options = []): \OpenStack\Images\v2\Service
{
$defaults = ['catalogName' => 'glance', 'catalogType' => 'image'];
+
return $this->builder->createService('Images\\v2', array_merge($defaults, $options));
}
/**
- * Creates a new Gnocchi Metric service v1
+ * Creates a new Gnocchi Metric service v1.
*
* @param array $options
*
diff --git a/tests/integration/Compute/v2/CoreTest.php b/tests/integration/Compute/v2/CoreTest.php
index ae4c644c..eb829b73 100644
--- a/tests/integration/Compute/v2/CoreTest.php
+++ b/tests/integration/Compute/v2/CoreTest.php
@@ -672,7 +672,8 @@ private function attachVolumeToServer()
$this->volume->waitUntil('in-use');
- $this->logStep('Attached volume {volumeId} to server {serverId} with volume attachment id {volumeAttachmentId}',
+ $this->logStep(
+ 'Attached volume {volumeId} to server {serverId} with volume attachment id {volumeAttachmentId}',
array_merge($replacements, ['{volumeAttachmentId}' => $volumeAttachment->id])
);
}
diff --git a/tests/integration/TestCase.php b/tests/integration/TestCase.php
index cebb1953..f382e301 100644
--- a/tests/integration/TestCase.php
+++ b/tests/integration/TestCase.php
@@ -5,7 +5,7 @@
use OpenStack\Common\Resource\Deletable;
use Psr\Log\LoggerInterface;
-abstract class TestCase extends \PHPUnit_Framework_TestCase implements TestInterface
+abstract class TestCase extends \PHPUnit\Framework\TestCase implements TestInterface
{
protected $logger;
private $startPoint;
diff --git a/tests/unit/Common/Api/OperationTest.php b/tests/unit/Common/Api/OperationTest.php
index 36adf3bd..68e0eaa9 100644
--- a/tests/unit/Common/Api/OperationTest.php
+++ b/tests/unit/Common/Api/OperationTest.php
@@ -6,7 +6,7 @@
use OpenStack\Common\Api\Parameter;
use OpenStack\Test\Fixtures\ComputeV2Api;
-class OperationTest extends \PHPUnit_Framework_TestCase
+class OperationTest extends \PHPUnit\Framework\TestCase
{
private $operation;
diff --git a/tests/unit/Common/Api/OperatorTraitTest.php b/tests/unit/Common/Api/OperatorTraitTest.php
index c0589141..813eddcd 100644
--- a/tests/unit/Common/Api/OperatorTraitTest.php
+++ b/tests/unit/Common/Api/OperatorTraitTest.php
@@ -48,6 +48,8 @@ public function test_it_sends_a_request_when_operations_are_executed()
$this->client->request('GET', 'test', ['headers' => []])->willReturn(new Response());
$this->operator->execute($this->def, []);
+
+ $this->addToAssertionCount(1);
}
public function test_it_sends_a_request_when_async_operations_are_executed()
@@ -55,6 +57,8 @@ public function test_it_sends_a_request_when_async_operations_are_executed()
$this->client->requestAsync('GET', 'test', ['headers' => []])->willReturn(new Promise());
$this->operator->executeAsync($this->def, []);
+
+ $this->addToAssertionCount(1);
}
public function test_it_wraps_sequential_ops_in_promise_when_async_is_appended_to_method_name()
@@ -90,10 +94,12 @@ public function test_it_returns_a_model_instance()
{
$this->assertInstanceOf(ResourceInterface::class, $this->operator->model(TestResource::class));
}
+
public function test_it_populates_models_from_response()
{
$this->assertInstanceOf(ResourceInterface::class, $this->operator->model(TestResource::class, new Response(200)));
}
+
public function test_it_populates_models_from_arrays()
{
$data = ['flavor' => [], 'image' => []];
diff --git a/tests/unit/Common/Api/ParameterTest.php b/tests/unit/Common/Api/ParameterTest.php
index 79aaa118..320d25be 100644
--- a/tests/unit/Common/Api/ParameterTest.php
+++ b/tests/unit/Common/Api/ParameterTest.php
@@ -5,7 +5,7 @@
use OpenStack\Common\Api\Parameter;
use OpenStack\Test\Fixtures\ComputeV2Api;
-class ParameterTest extends \PHPUnit_Framework_TestCase
+class ParameterTest extends \PHPUnit\Framework\TestCase
{
private $param;
private $data;
diff --git a/tests/unit/Common/Error/BuilderTest.php b/tests/unit/Common/Error/BuilderTest.php
index 0c91e697..f5710a1b 100644
--- a/tests/unit/Common/Error/BuilderTest.php
+++ b/tests/unit/Common/Error/BuilderTest.php
@@ -13,12 +13,12 @@
use OpenStack\Common\Error\Builder;
use OpenStack\Common\Error\UserInputError;
-class BuilderTest extends \PHPUnit_Framework_TestCase
+class BuilderTest extends \PHPUnit\Framework\TestCase
{
private $builder;
private $client;
- public function __construct()
+ public function setUp()
{
$this->client = $this->prophesize(ClientInterface::class);
$this->builder = new Builder($this->client->reveal());
diff --git a/tests/unit/Common/JsonPathTest.php b/tests/unit/Common/JsonPathTest.php
index 5648e327..42edb91c 100644
--- a/tests/unit/Common/JsonPathTest.php
+++ b/tests/unit/Common/JsonPathTest.php
@@ -4,7 +4,7 @@
use OpenStack\Common\JsonPath;
-class JsonPathTest extends \PHPUnit_Framework_TestCase
+class JsonPathTest extends \PHPUnit\Framework\TestCase
{
private $jsonPath;
diff --git a/tests/unit/Common/Transport/JsonSerializerTest.php b/tests/unit/Common/Transport/JsonSerializerTest.php
index 652c7219..50a54e5a 100644
--- a/tests/unit/Common/Transport/JsonSerializerTest.php
+++ b/tests/unit/Common/Transport/JsonSerializerTest.php
@@ -8,7 +8,7 @@
use OpenStack\Common\Resource\OperatorResource;
use OpenStack\Common\Transport\JsonSerializer;
-class JsonSerializerTest extends \PHPUnit_Framework_TestCase
+class JsonSerializerTest extends \PHPUnit\Framework\TestCase
{
/** @var JsonSerializer */
private $serializer;
diff --git a/tests/unit/Networking/v2/Extensions/Layer3/Models/FloatingIpTest.php b/tests/unit/Networking/v2/Extensions/Layer3/Models/FloatingIpTest.php
index fe757adc..f7e5e51f 100644
--- a/tests/unit/Networking/v2/Extensions/Layer3/Models/FloatingIpTest.php
+++ b/tests/unit/Networking/v2/Extensions/Layer3/Models/FloatingIpTest.php
@@ -49,20 +49,34 @@ public function test_it_retrieves()
$this->floatingIp->retrieve();
- $this->assertEquals('376da547-b977-4cfe-9cba-275c80debf57',
- $this->floatingIp->floatingNetworkId);
- $this->assertEquals('d23abc8d-2991-4a55-ba98-2aaea84cc72f',
- $this->floatingIp->routerId);
- $this->assertEquals('10.0.0.3',
- $this->floatingIp->fixedIpAddress);
- $this->assertEquals('172.24.4.228',
- $this->floatingIp->floatingIpAddress);
- $this->assertEquals('4969c491a3c74ee4af974e6d800c62de',
- $this->floatingIp->tenantId);
+ $this->assertEquals(
+ '376da547-b977-4cfe-9cba-275c80debf57',
+ $this->floatingIp->floatingNetworkId
+ );
+ $this->assertEquals(
+ 'd23abc8d-2991-4a55-ba98-2aaea84cc72f',
+ $this->floatingIp->routerId
+ );
+ $this->assertEquals(
+ '10.0.0.3',
+ $this->floatingIp->fixedIpAddress
+ );
+ $this->assertEquals(
+ '172.24.4.228',
+ $this->floatingIp->floatingIpAddress
+ );
+ $this->assertEquals(
+ '4969c491a3c74ee4af974e6d800c62de',
+ $this->floatingIp->tenantId
+ );
$this->assertEquals('ACTIVE', $this->floatingIp->status);
- $this->assertEquals('ce705c24-c1ef-408a-bda3-7bbd946164ab',
- $this->floatingIp->portId);
- $this->assertEquals('2f245a7b-796b-4f26-9cf9-9e82d248fda7',
- $this->floatingIp->id);
+ $this->assertEquals(
+ 'ce705c24-c1ef-408a-bda3-7bbd946164ab',
+ $this->floatingIp->portId
+ );
+ $this->assertEquals(
+ '2f245a7b-796b-4f26-9cf9-9e82d248fda7',
+ $this->floatingIp->id
+ );
}
}
diff --git a/tests/unit/ObjectStore/v1/Fixtures/GET_Container.resp b/tests/unit/ObjectStore/v1/Fixtures/GET_Container.resp
index ae021339..856af9c3 100644
--- a/tests/unit/ObjectStore/v1/Fixtures/GET_Container.resp
+++ b/tests/unit/ObjectStore/v1/Fixtures/GET_Container.resp
@@ -21,7 +21,7 @@ Date: Wed, 15 Jan 2014 16:57:35 GMT
"hash": "ed076287532e86365e841e92bfc50d8c",
"last_modified": "2014-01-15T16:37:43.427570",
"bytes": 12,
- "name": "helloworld",
- "content_type": "application/octet-stream"
+ "name": "helloworld.json",
+ "content_type": "application/json"
}
]
\ No newline at end of file
diff --git a/tests/unit/ObjectStore/v1/Models/ContainerTest.php b/tests/unit/ObjectStore/v1/Models/ContainerTest.php
index 6e83b8a4..50517c74 100644
--- a/tests/unit/ObjectStore/v1/Models/ContainerTest.php
+++ b/tests/unit/ObjectStore/v1/Models/ContainerTest.php
@@ -116,7 +116,8 @@ public function test_It_Create_Objects()
$this->setupMock('PUT', self::NAME . '/' . $objectName, $content, $headers, 'Created');
- $this->container->createObject([
+ /** @var Object $storageObject */
+ $storageObject = $this->container->createObject([
'name' => $objectName,
'content' => $content,
'contentType' => $headers['Content-Type'],
@@ -125,6 +126,9 @@ public function test_It_Create_Objects()
'deleteAfter' => $headers['X-Delete-After'],
'metadata' => ['Author' => 'foo', 'genre' => 'bar'],
]);
+
+ $this->assertEquals('foo.txt', $storageObject->name);
+ $this->assertEquals(self::NAME, $storageObject->containerName);
}
public function test_it_lists_objects()
@@ -134,8 +138,37 @@ public function test_it_lists_objects()
->shouldBeCalled()
->willReturn($this->getFixture('GET_Container'));
- foreach ($this->container->listObjects(['limit' => 2]) as $object) {
- $this->assertInstanceOf(Object::class, $object);
+ $objects = iterator_to_array($this->container->listObjects(['limit' => 2]));
+
+ $this->assertEquals(2, count($objects));
+
+ $expected = [
+ [
+ 'name' => 'goodbye',
+ 'contentLength' => '14',
+ 'lastModified' => new \DateTimeImmutable('2014-01-15T16:41:49.390270'),
+ 'contentType' => 'application/octet-stream',
+ 'hash' => '451e372e48e0f6b1114fa0724aa79fa1'
+ ],
+ [
+ 'name' => 'helloworld.json',
+ 'contentLength' => '12',
+ 'lastModified' => new \DateTimeImmutable('2014-01-15T16:37:43.427570'),
+ 'contentType' => 'application/json',
+ 'hash' => 'ed076287532e86365e841e92bfc50d8c'
+ ],
+ ];
+
+ for ($i = 0; $i < count($objects); $i++)
+ {
+ $exp = $expected[$i];
+ /** @var Object $obj */
+ $obj = $objects[$i];
+
+ foreach ($exp as $attr => $attrVal)
+ {
+ $this->assertEquals($attrVal, $obj->{$attr});
+ }
}
}
diff --git a/tests/unit/TestCase.php b/tests/unit/TestCase.php
index 3a372dd0..30f14879 100644
--- a/tests/unit/TestCase.php
+++ b/tests/unit/TestCase.php
@@ -8,7 +8,7 @@
use GuzzleHttp\Psr7\Response;
use Prophecy\Argument;
-abstract class TestCase extends \PHPUnit_Framework_TestCase
+abstract class TestCase extends \PHPUnit\Framework\TestCase
{
/** @var \Prophecy\Prophecy\ObjectProphecy */
protected $client;