diff --git a/composer.json b/composer.json index 61716b598..d3d27d277 100644 --- a/composer.json +++ b/composer.json @@ -34,7 +34,7 @@ "pear/archive_tar": "1.4.3", "pear/pear-core-minimal": "^v1.10", "phpseclib/phpseclib": "2.0.4", - "php-opencloud/openstack": "3.0.4", + "php-opencloud/openstack": "3.0.5", "pimple/pimple": "3.2.3", "punic/punic": "^1.6", "sabre/dav": "^3.2.0", diff --git a/composer.lock b/composer.lock index 8f3d95e04..a7aac9830 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "321d46e4ce553783ee3f93842d33db93", + "content-hash": "beb88b5d90900fd5280d77f2fb2de50b", "packages": [ { "name": "aws/aws-sdk-php", @@ -1913,16 +1913,16 @@ }, { "name": "php-opencloud/openstack", - "version": "v3.0.4", + "version": "v3.0.5", "source": { "type": "git", "url": "https://github.com/php-opencloud/openstack.git", - "reference": "92109146fb6f4168afc5a27dfdc6f2c8317a0e29" + "reference": "2883c92cdfe05d4a11533497c2b74cc018c7cf0b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-opencloud/openstack/zipball/92109146fb6f4168afc5a27dfdc6f2c8317a0e29", - "reference": "92109146fb6f4168afc5a27dfdc6f2c8317a0e29", + "url": "https://api.github.com/repos/php-opencloud/openstack/zipball/2883c92cdfe05d4a11533497c2b74cc018c7cf0b", + "reference": "2883c92cdfe05d4a11533497c2b74cc018c7cf0b", "shasum": "" }, "require": { @@ -1932,11 +1932,11 @@ }, "require-dev": { "friendsofphp/php-cs-fixer": "^2.9", - "jakub-onderka/php-parallel-lint": "0.*", + "jakub-onderka/php-parallel-lint": "^1.0", "phpunit/phpunit": "^6.5", - "psr/log": "~1.0", + "psr/log": "^1.0", "sami/sami": "dev-master", - "satooshi/php-coveralls": "~1.0" + "satooshi/php-coveralls": "^2.0" }, "type": "library", "extra": { @@ -1973,7 +1973,7 @@ "php", "sdk" ], - "time": "2018-02-16T08:28:10+00:00" + "time": "2018-03-13T10:03:02+00:00" }, { "name": "phpseclib/phpseclib", diff --git a/composer/ClassLoader.php b/composer/ClassLoader.php index dc02dfb11..2c72175e7 100644 --- a/composer/ClassLoader.php +++ b/composer/ClassLoader.php @@ -379,9 +379,9 @@ private function findFileWithExtension($class, $ext) $subPath = substr($subPath, 0, $lastPos); $search = $subPath.'\\'; if (isset($this->prefixDirsPsr4[$search])) { - $pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1); foreach ($this->prefixDirsPsr4[$search] as $dir) { - if (file_exists($file = $dir . $pathEnd)) { + $length = $this->prefixLengthsPsr4[$first][$search]; + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $length))) { return $file; } } diff --git a/composer/autoload_classmap.php b/composer/autoload_classmap.php index 8465d80e9..2a7e4dcfb 100644 --- a/composer/autoload_classmap.php +++ b/composer/autoload_classmap.php @@ -882,21 +882,6 @@ 'Icewind\\Streams\\PathWrapper' => $vendorDir . '/icewind/streams/src/PathWrapper.php', 'Icewind\\Streams\\RetryWrapper' => $vendorDir . '/icewind/streams/src/RetryWrapper.php', 'Icewind\\Streams\\SeekableWrapper' => $vendorDir . '/icewind/streams/src/SeekableWrapper.php', - 'Icewind\\Streams\\Tests\\CallbackWrapperTest' => $vendorDir . '/icewind/streams/tests/CallbackWrapperTest.php', - 'Icewind\\Streams\\Tests\\CountWrapperTest' => $vendorDir . '/icewind/streams/tests/CountWrapperTest.php', - 'Icewind\\Streams\\Tests\\DirectoryFilter' => $vendorDir . '/icewind/streams/tests/DirectoryFilter.php', - 'Icewind\\Streams\\Tests\\DirectoryWrapper' => $vendorDir . '/icewind/streams/tests/DirectoryWrapper.php', - 'Icewind\\Streams\\Tests\\DirectoryWrapperDummy' => $vendorDir . '/icewind/streams/tests/DirectoryWrapper.php', - 'Icewind\\Streams\\Tests\\DirectoryWrapperNull' => $vendorDir . '/icewind/streams/tests/DirectoryWrapper.php', - 'Icewind\\Streams\\Tests\\FailWrapper' => $vendorDir . '/icewind/streams/tests/RetryWrapper.php', - 'Icewind\\Streams\\Tests\\IteratorDirectory' => $vendorDir . '/icewind/streams/tests/IteratorDirectory.php', - 'Icewind\\Streams\\Tests\\NullWrapperTest' => $vendorDir . '/icewind/streams/tests/NullWrapperTest.php', - 'Icewind\\Streams\\Tests\\PartialWrapper' => $vendorDir . '/icewind/streams/tests/RetryWrapper.php', - 'Icewind\\Streams\\Tests\\PathWrapper' => $vendorDir . '/icewind/streams/tests/PathWrapper.php', - 'Icewind\\Streams\\Tests\\RetryWrapperTest' => $vendorDir . '/icewind/streams/tests/RetryWrapper.php', - 'Icewind\\Streams\\Tests\\SeekableWrapper' => $vendorDir . '/icewind/streams/tests/SeekableWrapper.php', - 'Icewind\\Streams\\Tests\\UrlCallBack' => $vendorDir . '/icewind/streams/tests/UrlCallBack.php', - 'Icewind\\Streams\\Tests\\WrapperTest' => $vendorDir . '/icewind/streams/tests/WrapperTest.php', 'Icewind\\Streams\\Url' => $vendorDir . '/icewind/streams/src/Url.php', 'Icewind\\Streams\\UrlCallback' => $vendorDir . '/icewind/streams/src/UrlCallBack.php', 'Icewind\\Streams\\Wrapper' => $vendorDir . '/icewind/streams/src/Wrapper.php', @@ -1589,10 +1574,6 @@ 'SearchDAV\\Query\\Order' => $vendorDir . '/icewind/searchdav/src/Query/Order.php', 'SearchDAV\\Query\\Query' => $vendorDir . '/icewind/searchdav/src/Query/Query.php', 'SearchDAV\\Query\\Scope' => $vendorDir . '/icewind/searchdav/src/Query/Scope.php', - 'SearchDAV\\Test\\DummyBackend' => $vendorDir . '/icewind/searchdav/tests/DummyBackend.php', - 'SearchDAV\\Test\\PathHelperTest' => $vendorDir . '/icewind/searchdav/tests/PathHelperTest.php', - 'SearchDAV\\Test\\QueryParserTest' => $vendorDir . '/icewind/searchdav/tests/QueryParserTest.php', - 'SearchDAV\\Test\\SearchPluginTest' => $vendorDir . '/icewind/searchdav/tests/SearchPluginTest.php', 'SearchDAV\\XML\\BasicSearch' => $vendorDir . '/icewind/searchdav/src/XML/BasicSearch.php', 'SearchDAV\\XML\\BasicSearchSchema' => $vendorDir . '/icewind/searchdav/src/XML/BasicSearchSchema.php', 'SearchDAV\\XML\\Limit' => $vendorDir . '/icewind/searchdav/src/XML/Limit.php', diff --git a/composer/autoload_real.php b/composer/autoload_real.php index 72e1b9c01..448f7f479 100644 --- a/composer/autoload_real.php +++ b/composer/autoload_real.php @@ -24,7 +24,7 @@ public static function getLoader() spl_autoload_unregister(array('ComposerAutoloaderInit2f23f73bc0cc116b4b1eee1521aa8652', 'loadClassLoader')); $includePaths = require __DIR__ . '/include_paths.php'; - $includePaths[] = get_include_path(); + array_push($includePaths, get_include_path()); set_include_path(implode(PATH_SEPARATOR, $includePaths)); $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded()); diff --git a/composer/autoload_static.php b/composer/autoload_static.php index 07a86167c..d4f02519f 100644 --- a/composer/autoload_static.php +++ b/composer/autoload_static.php @@ -1243,21 +1243,6 @@ class ComposerStaticInit2f23f73bc0cc116b4b1eee1521aa8652 'Icewind\\Streams\\PathWrapper' => __DIR__ . '/..' . '/icewind/streams/src/PathWrapper.php', 'Icewind\\Streams\\RetryWrapper' => __DIR__ . '/..' . '/icewind/streams/src/RetryWrapper.php', 'Icewind\\Streams\\SeekableWrapper' => __DIR__ . '/..' . '/icewind/streams/src/SeekableWrapper.php', - 'Icewind\\Streams\\Tests\\CallbackWrapperTest' => __DIR__ . '/..' . '/icewind/streams/tests/CallbackWrapperTest.php', - 'Icewind\\Streams\\Tests\\CountWrapperTest' => __DIR__ . '/..' . '/icewind/streams/tests/CountWrapperTest.php', - 'Icewind\\Streams\\Tests\\DirectoryFilter' => __DIR__ . '/..' . '/icewind/streams/tests/DirectoryFilter.php', - 'Icewind\\Streams\\Tests\\DirectoryWrapper' => __DIR__ . '/..' . '/icewind/streams/tests/DirectoryWrapper.php', - 'Icewind\\Streams\\Tests\\DirectoryWrapperDummy' => __DIR__ . '/..' . '/icewind/streams/tests/DirectoryWrapper.php', - 'Icewind\\Streams\\Tests\\DirectoryWrapperNull' => __DIR__ . '/..' . '/icewind/streams/tests/DirectoryWrapper.php', - 'Icewind\\Streams\\Tests\\FailWrapper' => __DIR__ . '/..' . '/icewind/streams/tests/RetryWrapper.php', - 'Icewind\\Streams\\Tests\\IteratorDirectory' => __DIR__ . '/..' . '/icewind/streams/tests/IteratorDirectory.php', - 'Icewind\\Streams\\Tests\\NullWrapperTest' => __DIR__ . '/..' . '/icewind/streams/tests/NullWrapperTest.php', - 'Icewind\\Streams\\Tests\\PartialWrapper' => __DIR__ . '/..' . '/icewind/streams/tests/RetryWrapper.php', - 'Icewind\\Streams\\Tests\\PathWrapper' => __DIR__ . '/..' . '/icewind/streams/tests/PathWrapper.php', - 'Icewind\\Streams\\Tests\\RetryWrapperTest' => __DIR__ . '/..' . '/icewind/streams/tests/RetryWrapper.php', - 'Icewind\\Streams\\Tests\\SeekableWrapper' => __DIR__ . '/..' . '/icewind/streams/tests/SeekableWrapper.php', - 'Icewind\\Streams\\Tests\\UrlCallBack' => __DIR__ . '/..' . '/icewind/streams/tests/UrlCallBack.php', - 'Icewind\\Streams\\Tests\\WrapperTest' => __DIR__ . '/..' . '/icewind/streams/tests/WrapperTest.php', 'Icewind\\Streams\\Url' => __DIR__ . '/..' . '/icewind/streams/src/Url.php', 'Icewind\\Streams\\UrlCallback' => __DIR__ . '/..' . '/icewind/streams/src/UrlCallBack.php', 'Icewind\\Streams\\Wrapper' => __DIR__ . '/..' . '/icewind/streams/src/Wrapper.php', @@ -1950,10 +1935,6 @@ class ComposerStaticInit2f23f73bc0cc116b4b1eee1521aa8652 'SearchDAV\\Query\\Order' => __DIR__ . '/..' . '/icewind/searchdav/src/Query/Order.php', 'SearchDAV\\Query\\Query' => __DIR__ . '/..' . '/icewind/searchdav/src/Query/Query.php', 'SearchDAV\\Query\\Scope' => __DIR__ . '/..' . '/icewind/searchdav/src/Query/Scope.php', - 'SearchDAV\\Test\\DummyBackend' => __DIR__ . '/..' . '/icewind/searchdav/tests/DummyBackend.php', - 'SearchDAV\\Test\\PathHelperTest' => __DIR__ . '/..' . '/icewind/searchdav/tests/PathHelperTest.php', - 'SearchDAV\\Test\\QueryParserTest' => __DIR__ . '/..' . '/icewind/searchdav/tests/QueryParserTest.php', - 'SearchDAV\\Test\\SearchPluginTest' => __DIR__ . '/..' . '/icewind/searchdav/tests/SearchPluginTest.php', 'SearchDAV\\XML\\BasicSearch' => __DIR__ . '/..' . '/icewind/searchdav/src/XML/BasicSearch.php', 'SearchDAV\\XML\\BasicSearchSchema' => __DIR__ . '/..' . '/icewind/searchdav/src/XML/BasicSearchSchema.php', 'SearchDAV\\XML\\Limit' => __DIR__ . '/..' . '/icewind/searchdav/src/XML/Limit.php', diff --git a/composer/installed.json b/composer/installed.json index 4e76e85a2..7649c01be 100644 --- a/composer/installed.json +++ b/composer/installed.json @@ -1972,72 +1972,6 @@ "exception" ] }, - { - "name": "php-opencloud/openstack", - "version": "v3.0.4", - "version_normalized": "3.0.4.0", - "source": { - "type": "git", - "url": "https://github.com/php-opencloud/openstack.git", - "reference": "92109146fb6f4168afc5a27dfdc6f2c8317a0e29" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-opencloud/openstack/zipball/92109146fb6f4168afc5a27dfdc6f2c8317a0e29", - "reference": "92109146fb6f4168afc5a27dfdc6f2c8317a0e29", - "shasum": "" - }, - "require": { - "guzzlehttp/guzzle": "~6.1", - "justinrainbow/json-schema": "~5.2", - "php": "~7.0" - }, - "require-dev": { - "friendsofphp/php-cs-fixer": "^2.9", - "jakub-onderka/php-parallel-lint": "0.*", - "phpunit/phpunit": "^6.5", - "psr/log": "~1.0", - "sami/sami": "dev-master", - "satooshi/php-coveralls": "~1.0" - }, - "time": "2018-02-16T08:28:10+00:00", - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.0-dev" - } - }, - "installation-source": "dist", - "autoload": { - "psr-4": { - "OpenStack\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "Apache-2.0" - ], - "authors": [ - { - "name": "Jamie Hannaford", - "email": "jamie.hannaford@rackspace.com", - "homepage": "https://github.com/jamiehannaford" - }, - { - "name": "Ha Phan", - "email": "thanhha.work@gmail.com", - "homepage": "https://github.com/haphan" - } - ], - "description": "PHP SDK for OpenStack APIs. Supports BlockStorage, Compute, Identity, Images, Networking and Metric Gnocchi", - "homepage": "https://github.com/php-opencloud/openstack", - "keywords": [ - "Openstack", - "api", - "php", - "sdk" - ] - }, { "name": "phpseclib/phpseclib", "version": "2.0.4", @@ -3423,5 +3357,71 @@ ], "description": "Symfony Translation Component", "homepage": "https://symfony.com" + }, + { + "name": "php-opencloud/openstack", + "version": "v3.0.5", + "version_normalized": "3.0.5.0", + "source": { + "type": "git", + "url": "https://github.com/php-opencloud/openstack.git", + "reference": "2883c92cdfe05d4a11533497c2b74cc018c7cf0b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-opencloud/openstack/zipball/2883c92cdfe05d4a11533497c2b74cc018c7cf0b", + "reference": "2883c92cdfe05d4a11533497c2b74cc018c7cf0b", + "shasum": "" + }, + "require": { + "guzzlehttp/guzzle": "~6.1", + "justinrainbow/json-schema": "~5.2", + "php": "~7.0" + }, + "require-dev": { + "friendsofphp/php-cs-fixer": "^2.9", + "jakub-onderka/php-parallel-lint": "^1.0", + "phpunit/phpunit": "^6.5", + "psr/log": "^1.0", + "sami/sami": "dev-master", + "satooshi/php-coveralls": "^2.0" + }, + "time": "2018-03-13T10:03:02+00:00", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-4": { + "OpenStack\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "Jamie Hannaford", + "email": "jamie.hannaford@rackspace.com", + "homepage": "https://github.com/jamiehannaford" + }, + { + "name": "Ha Phan", + "email": "thanhha.work@gmail.com", + "homepage": "https://github.com/haphan" + } + ], + "description": "PHP SDK for OpenStack APIs. Supports BlockStorage, Compute, Identity, Images, Networking and Metric Gnocchi", + "homepage": "https://github.com/php-opencloud/openstack", + "keywords": [ + "Openstack", + "api", + "php", + "sdk" + ] } ] diff --git a/php-opencloud/openstack/.php_cs.dist b/php-opencloud/openstack/.php_cs.dist index fa9348700..32d7e97ef 100644 --- a/php-opencloud/openstack/.php_cs.dist +++ b/php-opencloud/openstack/.php_cs.dist @@ -1,13 +1,17 @@ setRules( [ - '@PSR2' => true, - 'array_syntax' => ['syntax' => 'short'], - 'protected_to_private' => false + '@PSR2' => true, + '@Symfony' => true, + 'array_syntax' => ['syntax' => 'short'], + 'binary_operator_spaces' => ['default' => 'align'], + 'protected_to_private' => false, ] ) ->setUsingCache(false) diff --git a/php-opencloud/openstack/README.md b/php-opencloud/openstack/README.md index 81c94f829..199b6e169 100644 --- a/php-opencloud/openstack/README.md +++ b/php-opencloud/openstack/README.md @@ -1,7 +1,7 @@ # PHP OpenStack SDK [![Build Status](https://travis-ci.org/php-opencloud/openstack.svg?branch=master)](https://travis-ci.org/php-opencloud/openstack) -[![Code Coverage](https://scrutinizer-ci.com/g/php-opencloud/openstack/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/php-opencloud/openstack/?branch=master) +[![Coverage Status](https://coveralls.io/repos/github/php-opencloud/openstack/badge.svg?branch=master)](https://coveralls.io/github/php-opencloud/openstack?branch=master) [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/php-opencloud/openstack/badges/quality-score.png?b=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 @@ -15,28 +15,31 @@ OpenStack services, and versions of services, are supported. * [Contributing guide](/CONTRIBUTING.md) * [Code of Conduct](/CODE_OF_CONDUCT.md) -## Backward incompatibility +## Getting help + +- Meet us on Slack: https://phpopencloud.slack.com ([Get your invitation](https://launchpass.com/phpopencloud)) +- Report an issue: https://github.com/php-opencloud/openstack/issues -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`. See [#184](https://github.com/php-opencloud/openstack/pull/184) for -details. -### Version Guidance +## Version Guidance -| Version | Status | PHP Version | Life span | +| Version | Status | PHP Version | End of life | | --------- | --------------------------- | ------------- | ----------------------- | -| `^2.0` | Maintained (Bug fixes only) | `>=7.0,<7.2` | March 2016 - March 2018 | -| `^3.0` | Latest | `^7.0` | March 2018 - March 2020 | +| `^3.0` | Latest | `>=7.0` | March 2020 | +| `^2.0` | Maintained (Bug fixes only) | `>=7.0,<7.2` | March 2018 | -## 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 +## 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 @@ -51,4 +54,4 @@ taken the time to write a [contributing guide](CONTRIBUTING.md) for folks intere If you're not sure how you can get involved, feel free to [submit an issue](https://github.com/php-opencloud/openstack/issues/new) or [contact us](https://developer.rackspace.com/support/). You don't need to be a PHP expert - all members of the -community are welcome! +community are welcome! \ No newline at end of file diff --git a/php-opencloud/openstack/composer.json b/php-opencloud/openstack/composer.json index 8d82623f6..7abc54b22 100644 --- a/php-opencloud/openstack/composer.json +++ b/php-opencloud/openstack/composer.json @@ -46,9 +46,9 @@ "require-dev": { "phpunit/phpunit": "^6.5", "sami/sami": "dev-master", - "psr/log": "~1.0", - "satooshi/php-coveralls": "~1.0", - "jakub-onderka/php-parallel-lint": "0.*", + "psr/log": "^1.0", + "satooshi/php-coveralls": "^2.0", + "jakub-onderka/php-parallel-lint": "^1.0", "friendsofphp/php-cs-fixer": "^2.9" }, "extra": { diff --git a/php-opencloud/openstack/phpunit.xml.dist b/php-opencloud/openstack/phpunit.xml.dist index 2493eb9ea..032b639b4 100644 --- a/php-opencloud/openstack/phpunit.xml.dist +++ b/php-opencloud/openstack/phpunit.xml.dist @@ -1,6 +1,8 @@ - + + + tests/unit diff --git a/php-opencloud/openstack/src/BlockStorage/v2/Api.php b/php-opencloud/openstack/src/BlockStorage/v2/Api.php index 9f49e8f4c..6b591bab1 100644 --- a/php-opencloud/openstack/src/BlockStorage/v2/Api.php +++ b/php-opencloud/openstack/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(), ], ]; @@ -62,11 +64,11 @@ public function getVolumesDetail(): array public function getVolume(): array { return [ - 'method' => 'GET', - 'path' => 'volumes/{id}', - 'params' => [ - 'id' => $this->params->idPath() - ] + 'method' => 'GET', + 'path' => 'volumes/{id}', + 'params' => [ + 'id' => $this->params->idPath(), + ], ]; } @@ -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/php-opencloud/openstack/src/BlockStorage/v2/Models/QuotaSet.php b/php-opencloud/openstack/src/BlockStorage/v2/Models/QuotaSet.php index 6c9db98c6..d28052484 100644 --- a/php-opencloud/openstack/src/BlockStorage/v2/Models/QuotaSet.php +++ b/php-opencloud/openstack/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/php-opencloud/openstack/src/BlockStorage/v2/Models/Snapshot.php b/php-opencloud/openstack/src/BlockStorage/v2/Models/Snapshot.php index 64dc11d11..fde510f96 100644 --- a/php-opencloud/openstack/src/BlockStorage/v2/Models/Snapshot.php +++ b/php-opencloud/openstack/src/BlockStorage/v2/Models/Snapshot.php @@ -1,4 +1,6 @@ - 'volumeId', + 'volume_id' => 'volumeId', ]; /** - * @inheritdoc + * {@inheritdoc} */ protected function getAliases(): array { return parent::getAliases() + [ - 'created_at' => new Alias('createdAt', \DateTimeImmutable::class) + 'created_at' => new Alias('createdAt', \DateTimeImmutable::class), ]; } @@ -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/php-opencloud/openstack/src/BlockStorage/v2/Models/Volume.php b/php-opencloud/openstack/src/BlockStorage/v2/Models/Volume.php index dbf5ef848..88fbb79d7 100644 --- a/php-opencloud/openstack/src/BlockStorage/v2/Models/Volume.php +++ b/php-opencloud/openstack/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/php-opencloud/openstack/src/BlockStorage/v2/Models/VolumeAttachment.php b/php-opencloud/openstack/src/BlockStorage/v2/Models/VolumeAttachment.php index 6d85b7b40..48b6e374e 100644 --- a/php-opencloud/openstack/src/BlockStorage/v2/Models/VolumeAttachment.php +++ b/php-opencloud/openstack/src/BlockStorage/v2/Models/VolumeAttachment.php @@ -1,4 +1,7 @@ -execute($this->api->postTypes(), $userOptions); + return $this->populateFromResponse($response); } diff --git a/php-opencloud/openstack/src/BlockStorage/v2/Params.php b/php-opencloud/openstack/src/BlockStorage/v2/Params.php index 000fa4e06..86dd40512 100644 --- a/php-opencloud/openstack/src/BlockStorage/v2/Params.php +++ b/php-opencloud/openstack/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/php-opencloud/openstack/src/BlockStorage/v2/Service.php b/php-opencloud/openstack/src/BlockStorage/v2/Service.php index 17f072809..084594dc4 100644 --- a/php-opencloud/openstack/src/BlockStorage/v2/Service.php +++ b/php-opencloud/openstack/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/php-opencloud/openstack/src/Common/Api/AbstractApi.php b/php-opencloud/openstack/src/Common/Api/AbstractApi.php index 49d4d456e..1d5126e17 100644 --- a/php-opencloud/openstack/src/Common/Api/AbstractApi.php +++ b/php-opencloud/openstack/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/php-opencloud/openstack/src/Common/Api/ApiInterface.php b/php-opencloud/openstack/src/Common/Api/ApiInterface.php index dfa1dc302..149c1f03c 100644 --- a/php-opencloud/openstack/src/Common/Api/ApiInterface.php +++ b/php-opencloud/openstack/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/php-opencloud/openstack/src/Common/Api/OperatorInterface.php b/php-opencloud/openstack/src/Common/Api/OperatorInterface.php index 0337872e1..7bb100595 100644 --- a/php-opencloud/openstack/src/Common/Api/OperatorInterface.php +++ b/php-opencloud/openstack/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/php-opencloud/openstack/src/Common/Api/Parameter.php b/php-opencloud/openstack/src/Common/Api/Parameter.php index 136ff0161..389c626f2 100644 --- a/php-opencloud/openstack/src/Common/Api/Parameter.php +++ b/php-opencloud/openstack/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,7 +206,7 @@ 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), @@ -248,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]; @@ -278,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; } @@ -291,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; } @@ -299,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 @@ -356,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 */ @@ -376,6 +378,7 @@ public function getProperty(string $name) { if ($this->properties instanceof Parameter) { $this->properties->setName($name); + return $this->properties; } @@ -394,6 +397,6 @@ public function getPrefix(): string public function getPrefixedName(): string { - return $this->prefix . $this->getName(); + return $this->prefix.$this->getName(); } } diff --git a/php-opencloud/openstack/src/Common/ArrayAccessTrait.php b/php-opencloud/openstack/src/Common/ArrayAccessTrait.php index f0319f881..beecc1d03 100644 --- a/php-opencloud/openstack/src/Common/ArrayAccessTrait.php +++ b/php-opencloud/openstack/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/php-opencloud/openstack/src/Common/Auth/Catalog.php b/php-opencloud/openstack/src/Common/Auth/Catalog.php index dca0bfc7d..14747f034 100644 --- a/php-opencloud/openstack/src/Common/Auth/Catalog.php +++ b/php-opencloud/openstack/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; @@ -123,16 +124,16 @@ public function httpError(RequestInterface $request, ResponseInterface $response ); $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); @@ -158,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 */ @@ -172,10 +173,10 @@ public function userInputError(string $expectedType, $userValue, string $further 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/php-opencloud/openstack/src/Common/Error/NotImplementedError.php b/php-opencloud/openstack/src/Common/Error/NotImplementedError.php index c97a4309a..7b29c0c51 100644 --- a/php-opencloud/openstack/src/Common/Error/NotImplementedError.php +++ b/php-opencloud/openstack/src/Common/Error/NotImplementedError.php @@ -1,11 +1,11 @@ -$property = $value; } } diff --git a/php-opencloud/openstack/src/Common/JsonPath.php b/php-opencloud/openstack/src/Common/JsonPath.php index 4444dbbc0..346da5eda 100644 --- a/php-opencloud/openstack/src/Common/JsonPath.php +++ b/php-opencloud/openstack/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/php-opencloud/openstack/src/Common/JsonSchema/JsonPatch.php b/php-opencloud/openstack/src/Common/JsonSchema/JsonPatch.php index ca69f7928..55f93abe3 100644 --- a/php-opencloud/openstack/src/Common/JsonSchema/JsonPatch.php +++ b/php-opencloud/openstack/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 @@ -99,11 +101,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/php-opencloud/openstack/src/Common/JsonSchema/Schema.php b/php-opencloud/openstack/src/Common/JsonSchema/Schema.php index d86fb4091..36396d5ee 100644 --- a/php-opencloud/openstack/src/Common/JsonSchema/Schema.php +++ b/php-opencloud/openstack/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/php-opencloud/openstack/src/Common/Resource/AbstractResource.php b/php-opencloud/openstack/src/Common/Resource/AbstractResource.php index c10968eb2..bfa1ef89b 100644 --- a/php-opencloud/openstack/src/Common/Resource/AbstractResource.php +++ b/php-opencloud/openstack/src/Common/Resource/AbstractResource.php @@ -1,4 +1,6 @@ - 'fooBar' * @@ -44,7 +44,7 @@ abstract class AbstractResource implements ResourceInterface, Serializable */ 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)); @@ -82,7 +82,7 @@ public function populateFromArray(array $array) } /** - * 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,7 +142,7 @@ 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) { if ($val instanceof Serializable) { diff --git a/php-opencloud/openstack/src/Common/Resource/Alias.php b/php-opencloud/openstack/src/Common/Resource/Alias.php index 6746246b0..400339aa1 100644 --- a/php-opencloud/openstack/src/Common/Resource/Alias.php +++ b/php-opencloud/openstack/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/php-opencloud/openstack/src/Common/Resource/Creatable.php b/php-opencloud/openstack/src/Common/Resource/Creatable.php index 92346eb20..797f3cd42 100644 --- a/php-opencloud/openstack/src/Common/Resource/Creatable.php +++ b/php-opencloud/openstack/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/php-opencloud/openstack/src/Common/Resource/Iterator.php b/php-opencloud/openstack/src/Common/Resource/Iterator.php index a9cf0704b..76b18af43 100644 --- a/php-opencloud/openstack/src/Common/Resource/Iterator.php +++ b/php-opencloud/openstack/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/php-opencloud/openstack/src/Common/Resource/Listable.php b/php-opencloud/openstack/src/Common/Resource/Listable.php index d6c8caf07..9b8744ee7 100644 --- a/php-opencloud/openstack/src/Common/Resource/Listable.php +++ b/php-opencloud/openstack/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/php-opencloud/openstack/src/Common/Resource/ResourceInterface.php b/php-opencloud/openstack/src/Common/Resource/ResourceInterface.php index 7c5ea40b9..60420593b 100644 --- a/php-opencloud/openstack/src/Common/Resource/ResourceInterface.php +++ b/php-opencloud/openstack/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); } diff --git a/php-opencloud/openstack/src/Common/Service/ServiceInterface.php b/php-opencloud/openstack/src/Common/Service/ServiceInterface.php index d7408883d..b0c2b6d47 100644 --- a/php-opencloud/openstack/src/Common/Service/ServiceInterface.php +++ b/php-opencloud/openstack/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,7 @@ 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', + .'interface, you provided %s', print_r($value, true) )); } diff --git a/php-opencloud/openstack/src/Common/Transport/Middleware.php b/php-opencloud/openstack/src/Common/Transport/Middleware.php index d79828d77..e344b4fba 100644 --- a/php-opencloud/openstack/src/Common/Transport/Middleware.php +++ b/php-opencloud/openstack/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/php-opencloud/openstack/src/Common/Transport/Utils.php b/php-opencloud/openstack/src/Common/Transport/Utils.php index 7217d4464..88155f398 100644 --- a/php-opencloud/openstack/src/Common/Transport/Utils.php +++ b/php-opencloud/openstack/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/php-opencloud/openstack/src/Compute/v2/Api.php b/php-opencloud/openstack/src/Compute/v2/Api.php index 2baf7ba41..d6b235d73 100644 --- a/php-opencloud/openstack/src/Compute/v2/Api.php +++ b/php-opencloud/openstack/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,7 +283,6 @@ public function changeServerPassword(): array ]; } - public function resetServerState(): array { return [ @@ -287,8 +290,8 @@ public function resetServerState(): array 'path' => 'servers/{id}/action', 'params' => [ 'id' => $this->params->urlId('server'), - 'resetState' => $this->params->resetState() - ] + 'resetState' => $this->params->resetState(), + ], ]; } @@ -305,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() + 'method' => 'POST', + 'path' => 'servers/{id}/action', + 'params' => [ + '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() + 'method' => 'POST', + 'path' => 'servers/{id}/action', + 'params' => [ + 'id' => $this->params->urlId('server'), + 'os-stop' => $this->params->nullAction(), ], ]; } @@ -355,9 +358,9 @@ public function rescueServer(): array 'path' => 'servers/{id}/action', 'jsonKey' => 'rescue', 'params' => [ - 'id' => $this->params->urlId('server'), - 'imageId' => $this->params->rescueImageId(), - 'adminPass' => $this->notRequired($this->params->password()), + 'id' => $this->params->urlId('server'), + 'imageId' => $this->params->rescueImageId(), + 'adminPass' => $this->notRequired($this->params->password()), ], ]; } @@ -365,9 +368,9 @@ public function rescueServer(): array public function unrescueServer(): array { return [ - 'method' => 'POST', - 'path' => 'servers/{id}/action', - 'params' => [ + 'method' => 'POST', + 'path' => 'servers/{id}/action', + 'params' => [ 'id' => $this->params->urlId('server'), 'unrescue' => $this->params->nullAction(), ], @@ -427,9 +430,9 @@ public function getConsoleOutput(): array public function getAllConsoleOutput(): array { return [ - 'method' => 'POST', - 'path' => 'servers/{id}/action', - 'params' => [ + 'method' => 'POST', + 'path' => 'servers/{id}/action', + 'params' => [ 'id' => $this->params->urlId('server'), 'os-getConsoleOutput' => $this->params->emptyObject(), ], @@ -453,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(), + ], ]; } @@ -530,20 +533,20 @@ public function getInterfaceAttachments(): array 'path' => 'servers/{id}/os-interface', 'jsonKey' => 'interfaceAttachments', 'params' => [ - 'id' => $this->params->urlId('server') - ] + 'id' => $this->params->urlId('server'), + ], ]; } public function getInterfaceAttachment(): array { return [ - 'method' => 'GET', - 'path' => 'servers/{id}/os-interface/{portId}', - 'params' => [ + 'method' => 'GET', + 'path' => 'servers/{id}/os-interface/{portId}', + 'params' => [ 'id' => $this->params->urlId('server'), - 'portId' => $this->params->portId() - ] + 'portId' => $this->params->portId(), + ], ]; } @@ -559,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()), - ] + ], ]; } @@ -570,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(), + ], ]; } @@ -580,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')], ]; } @@ -591,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(), + ], ]; } @@ -603,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(), + ], ]; } @@ -616,7 +619,7 @@ public function getServerMetadataKey(): array 'params' => [ 'id' => $this->params->urlId('server'), 'key' => $this->params->key(), - ] + ], ]; } @@ -628,7 +631,7 @@ public function deleteServerMetadataKey(): array 'params' => [ 'id' => $this->params->urlId('server'), 'key' => $this->params->key(), - ] + ], ]; } @@ -638,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(), ], ]; } @@ -650,7 +653,7 @@ public function getKeypairs(): array 'method' => 'GET', 'path' => 'os-keypairs', 'params' => [ - 'userId' => $this->params->userId() + 'userId' => $this->params->userId(), ], ]; } @@ -658,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(), - ] + ], ]; } @@ -674,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')), ], @@ -695,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')), ], @@ -712,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'), ], ]; } @@ -720,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(), + ], ]; } @@ -746,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(), + ], ]; } @@ -760,7 +763,7 @@ public function getHypervisorStatistics(): array 'method' => 'GET', 'path' => 'os-hypervisors/statistics', 'params' => [ - ] + ], ]; } @@ -772,7 +775,7 @@ public function getHypervisors(): array 'jsonKey' => 'hypervisors', 'params' => [ 'limit' => $this->params->limit(), - 'marker' => $this->params->marker() + 'marker' => $this->params->marker(), ], ]; } @@ -790,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')], ]; } @@ -801,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(), + ], ]; } @@ -813,8 +816,8 @@ public function getHosts(): array 'path' => 'os-hosts', 'params' => [ 'limit' => $this->params->limit(), - 'marker' => $this->params->marker() - ] + 'marker' => $this->params->marker(), + ], ]; } @@ -823,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')], ]; } @@ -833,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'), + ], ]; } @@ -853,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'), + ], ]; } @@ -881,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/php-opencloud/openstack/src/Compute/v2/Enum.php b/php-opencloud/openstack/src/Compute/v2/Enum.php index b9cbfa79c..84e8f5912 100644 --- a/php-opencloud/openstack/src/Compute/v2/Enum.php +++ b/php-opencloud/openstack/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/php-opencloud/openstack/src/Compute/v2/Models/Host.php b/php-opencloud/openstack/src/Compute/v2/Models/Host.php index f824c909a..e9092116b 100644 --- a/php-opencloud/openstack/src/Compute/v2/Models/Host.php +++ b/php-opencloud/openstack/src/Compute/v2/Models/Host.php @@ -1,9 +1,9 @@ - 'name' + 'host_name' => 'name', ]; /** - * {@inheritDoc} + * {@inheritdoc} */ public function retrieve() { diff --git a/php-opencloud/openstack/src/Compute/v2/Models/Hypervisor.php b/php-opencloud/openstack/src/Compute/v2/Models/Hypervisor.php index 47f95fb5e..e18cd5df3 100644 --- a/php-opencloud/openstack/src/Compute/v2/Models/Hypervisor.php +++ b/php-opencloud/openstack/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/php-opencloud/openstack/src/Compute/v2/Models/HypervisorStatistic.php b/php-opencloud/openstack/src/Compute/v2/Models/HypervisorStatistic.php index e73501b01..b9bf0e0fc 100644 --- a/php-opencloud/openstack/src/Compute/v2/Models/HypervisorStatistic.php +++ b/php-opencloud/openstack/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/php-opencloud/openstack/src/Compute/v2/Models/Keypair.php b/php-opencloud/openstack/src/Compute/v2/Models/Keypair.php index 8a270729a..4bd2625e6 100644 --- a/php-opencloud/openstack/src/Compute/v2/Models/Keypair.php +++ b/php-opencloud/openstack/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/php-opencloud/openstack/src/Compute/v2/Models/Limit.php b/php-opencloud/openstack/src/Compute/v2/Models/Limit.php index f13871c4e..ad4051b6a 100644 --- a/php-opencloud/openstack/src/Compute/v2/Models/Limit.php +++ b/php-opencloud/openstack/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/php-opencloud/openstack/src/Compute/v2/Models/Server.php b/php-opencloud/openstack/src/Compute/v2/Models/Server.php index 8f8e98c30..d976c34ef 100644 --- a/php-opencloud/openstack/src/Compute/v2/Models/Server.php +++ b/php-opencloud/openstack/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() { @@ -190,7 +188,7 @@ public function resetState() { $this->execute($this->api->resetServerState(), [ 'id' => $this->id, - 'resetState' => ['state' => 'active'] + 'resetState' => ['state' => 'active'], ]); } @@ -212,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, ]); } @@ -241,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); } @@ -250,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']; } @@ -272,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) { @@ -303,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 @@ -312,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']; @@ -322,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']; } @@ -394,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 */ @@ -412,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); @@ -429,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 @@ -438,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); } @@ -449,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, ]); } @@ -462,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); } @@ -473,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); } @@ -488,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); } @@ -501,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; } @@ -521,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; @@ -539,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} */ @@ -555,7 +564,7 @@ public function parseMetadata(ResponseInterface $response): array } /** - * Returns Generator for SecurityGroups + * Returns Generator for SecurityGroups. * * @return \Generator */ @@ -564,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 */ @@ -576,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 * @@ -584,17 +592,15 @@ public function listVolumeAttachments(): \Generator */ public function attachVolume(string $volumeId): VolumeAttachment { - $response = $this->execute($this->api->postVolumeAttachments(), ['id' => $this->id, 'volumeId' => $volumeId]); + $response = $this->execute($this->api->postVolumeAttachments(), ['id' => $this->id, 'volumeId' => $volumeId]); return $this->model(VolumeAttachment::class)->populateFromResponse($response); } /** - * Detach a volume + * Detach a volume. * * @param $attachmentId - * - * @return void */ public function detachVolume(string $attachmentId) { diff --git a/php-opencloud/openstack/src/Compute/v2/Params.php b/php-opencloud/openstack/src/Compute/v2/Params.php index 00af11c3f..c071c934f 100644 --- a/php-opencloud/openstack/src/Compute/v2/Params.php +++ b/php-opencloud/openstack/src/Compute/v2/Params.php @@ -1,4 +1,6 @@ - 'os-resetState', 'required' => true, 'properties' => [ - 'state' => ['type' => self::STRING_TYPE] - ] + 'state' => ['type' => self::STRING_TYPE], + ], ]; } @@ -60,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 ), ]; @@ -70,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.'), ]; } @@ -79,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 - ) + ), ]; } @@ -188,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]], ], ]; } @@ -205,33 +207,32 @@ public function metadata(): array 'description' => << self::ARRAY_TYPE, - 'items' => [ + 'type' => self::ARRAY_TYPE, + 'items' => [ 'type' => self::OBJECT_TYPE, 'properties' => [ - 'path' => [ + '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')], ], ]; } @@ -281,7 +282,7 @@ public function networks(): array a networks object. EOT , - 'items' => [ + 'items' => [ 'type' => self::OBJECT_TYPE, 'properties' => [ 'uuid' => [ @@ -298,8 +299,8 @@ public function networks(): array a networks object. The port status must be DOWN. Required if you omit the uuid attribute. EOL ], - ] - ] + ], + ], ]; } @@ -313,14 +314,14 @@ public function blockDeviceMapping(): array available, and the volume attach_status in OpenStack Block Storage DB must be detached. EOL , - 'items' => [ + 'items' => [ 'type' => self::OBJECT_TYPE, 'properties' => [ - 'uuid' => [ + 'uuid' => [ 'type' => self::STRING_TYPE, 'description' => 'The unique ID for the volume which the server is to be booted from.', ], - 'bootIndex' => [ + 'bootIndex' => [ 'type' => self::INT_TYPE, 'sentAs' => 'boot_index', 'description' => 'Indicates a number designating the boot order of the device. Use -1 for the boot volume, choose 0 for an attached volume.', @@ -330,32 +331,32 @@ public function blockDeviceMapping(): array 'sentAs' => 'delete_on_termination', 'description' => 'To delete the boot volume when the server stops, specify true. Otherwise, specify false.', ], - 'guestFormat' => [ + 'guestFormat' => [ 'type' => self::STRING_TYPE, 'sentAs' => 'guest_format', 'description' => 'Specifies the guest server disk file system format, such as "ephemeral" or "swap".', ], - 'destinationType' => [ + 'destinationType' => [ 'type' => self::STRING_TYPE, 'sentAs' => 'destination_type', 'description' => 'Describes where the volume comes from. Choices are "local" or "volume". When using "volume" the volume ID', ], - 'sourceType' => [ + 'sourceType' => [ 'type' => self::STRING_TYPE, 'sentAs' => 'source_type', 'description' => 'Describes the volume source type for the volume. Choices are "blank", "snapshot", "volume", or "image".', ], - 'deviceName' => [ + 'deviceName' => [ 'type' => self::STRING_TYPE, 'sentAs' => 'device_name', 'description' => 'Describes a path to the device for the volume you want to use to boot the server.', ], - 'volumeSize' => [ + 'volumeSize' => [ 'type' => self::INT_TYPE, 'sentAs' => 'volume_size', 'description' => 'Size of the volume created if we are doing vol creation', ], - ] + ], ], ]; } @@ -424,7 +425,7 @@ public function nullAction(): array return [ 'type' => self::NULL_TYPE, 'location' => self::JSON, - 'required' => true + 'required' => true, ]; } @@ -467,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.', ]; } @@ -478,7 +479,7 @@ public function flavorRam(): array { return [ 'type' => self::INT_TYPE, - 'location' => self::JSON + 'location' => self::JSON, ]; } @@ -486,7 +487,7 @@ public function flavorVcpus(): array { return [ 'type' => self::INT_TYPE, - 'location' => self::JSON + 'location' => self::JSON, ]; } @@ -494,7 +495,7 @@ public function flavorDisk(): array { return [ 'type' => self::INT_TYPE, - 'location' => self::JSON + 'location' => self::JSON, ]; } @@ -502,7 +503,7 @@ public function flavorSwap(): array { return [ 'type' => self::INT_TYPE, - 'location' => self::JSON + 'location' => self::JSON, ]; } @@ -528,7 +529,7 @@ public function consoleType(): array return [ 'type' => self::STRING_TYPE, 'location' => self::JSON, - 'required' => true + 'required' => true, ]; } @@ -544,7 +545,7 @@ public function consoleLogLength(): array public function emptyObject(): array { return [ - 'type' => self::OBJECT_TYPE, + 'type' => self::OBJECT_TYPE, ]; } @@ -554,7 +555,7 @@ protected function quotaSetLimit($sentAs, $description): array 'type' => self::INT_TYPE, 'location' => self::JSON, 'sentAs' => $sentAs, - 'description' => $description + 'description' => $description, ]; } @@ -564,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/php-opencloud/openstack/src/Compute/v2/Service.php b/php-opencloud/openstack/src/Compute/v2/Service.php index fe4590df0..b2c8c9b55 100644 --- a/php-opencloud/openstack/src/Compute/v2/Service.php +++ b/php-opencloud/openstack/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/php-opencloud/openstack/src/Identity/v2/Api.php b/php-opencloud/openstack/src/Identity/v2/Api.php index 38623d80f..5024b3597 100644 --- a/php-opencloud/openstack/src/Identity/v2/Api.php +++ b/php-opencloud/openstack/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/php-opencloud/openstack/src/Identity/v2/Models/Catalog.php b/php-opencloud/openstack/src/Identity/v2/Models/Catalog.php index f2cd02c26..161396a96 100644 --- a/php-opencloud/openstack/src/Identity/v2/Models/Catalog.php +++ b/php-opencloud/openstack/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 { diff --git a/php-opencloud/openstack/src/Identity/v2/Models/Endpoint.php b/php-opencloud/openstack/src/Identity/v2/Models/Endpoint.php index b0c215e9c..e58f9f18b 100644 --- a/php-opencloud/openstack/src/Identity/v2/Models/Endpoint.php +++ b/php-opencloud/openstack/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/php-opencloud/openstack/src/Identity/v2/Models/Tenant.php b/php-opencloud/openstack/src/Identity/v2/Models/Tenant.php index 9f85a8394..bd83cb6b0 100644 --- a/php-opencloud/openstack/src/Identity/v2/Models/Tenant.php +++ b/php-opencloud/openstack/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/php-opencloud/openstack/src/Identity/v2/Service.php b/php-opencloud/openstack/src/Identity/v2/Service.php index ebc246ac1..cded85fa5 100644 --- a/php-opencloud/openstack/src/Identity/v2/Service.php +++ b/php-opencloud/openstack/src/Identity/v2/Service.php @@ -1,4 +1,6 @@ -execute($this->api->postToken(), $options); + return $this->model(Token::class, $response); } } diff --git a/php-opencloud/openstack/src/Identity/v3/Api.php b/php-opencloud/openstack/src/Identity/v3/Api.php index fc206f499..325e3ac17 100644 --- a/php-opencloud/openstack/src/Identity/v3/Api.php +++ b/php-opencloud/openstack/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/php-opencloud/openstack/src/Identity/v3/Enum.php b/php-opencloud/openstack/src/Identity/v3/Enum.php index 10c6167d9..1a6b1c60a 100644 --- a/php-opencloud/openstack/src/Identity/v3/Enum.php +++ b/php-opencloud/openstack/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/php-opencloud/openstack/src/Identity/v3/Models/Catalog.php b/php-opencloud/openstack/src/Identity/v3/Models/Catalog.php index 55b39c4a4..cc6a1b5c0 100644 --- a/php-opencloud/openstack/src/Identity/v3/Models/Catalog.php +++ b/php-opencloud/openstack/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 { diff --git a/php-opencloud/openstack/src/Identity/v3/Models/Credential.php b/php-opencloud/openstack/src/Identity/v3/Models/Credential.php index b81a0ff17..0c7bcdb59 100644 --- a/php-opencloud/openstack/src/Identity/v3/Models/Credential.php +++ b/php-opencloud/openstack/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/php-opencloud/openstack/src/Identity/v3/Models/Domain.php b/php-opencloud/openstack/src/Identity/v3/Models/Domain.php index 02b1530bc..516ead1fb 100644 --- a/php-opencloud/openstack/src/Identity/v3/Models/Domain.php +++ b/php-opencloud/openstack/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/php-opencloud/openstack/src/Identity/v3/Models/Endpoint.php b/php-opencloud/openstack/src/Identity/v3/Models/Endpoint.php index 36e119097..775768a46 100644 --- a/php-opencloud/openstack/src/Identity/v3/Models/Endpoint.php +++ b/php-opencloud/openstack/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/php-opencloud/openstack/src/Identity/v3/Models/Group.php b/php-opencloud/openstack/src/Identity/v3/Models/Group.php index b16d7db24..65f4658f0 100644 --- a/php-opencloud/openstack/src/Identity/v3/Models/Group.php +++ b/php-opencloud/openstack/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/php-opencloud/openstack/src/Identity/v3/Models/Policy.php b/php-opencloud/openstack/src/Identity/v3/Models/Policy.php index 6e2fc63ec..9d100a5e2 100644 --- a/php-opencloud/openstack/src/Identity/v3/Models/Policy.php +++ b/php-opencloud/openstack/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/php-opencloud/openstack/src/Identity/v3/Models/Project.php b/php-opencloud/openstack/src/Identity/v3/Models/Project.php index 01f92fb0c..8f3236181 100644 --- a/php-opencloud/openstack/src/Identity/v3/Models/Project.php +++ b/php-opencloud/openstack/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/php-opencloud/openstack/src/Identity/v3/Models/Role.php b/php-opencloud/openstack/src/Identity/v3/Models/Role.php index 5dbc17198..d694dccfa 100644 --- a/php-opencloud/openstack/src/Identity/v3/Models/Role.php +++ b/php-opencloud/openstack/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/php-opencloud/openstack/src/Identity/v3/Models/Service.php b/php-opencloud/openstack/src/Identity/v3/Models/Service.php index 8207c1f69..6b58c0884 100644 --- a/php-opencloud/openstack/src/Identity/v3/Models/Service.php +++ b/php-opencloud/openstack/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/php-opencloud/openstack/src/Identity/v3/Models/Token.php b/php-opencloud/openstack/src/Identity/v3/Models/Token.php index de4307982..935f409fb 100644 --- a/php-opencloud/openstack/src/Identity/v3/Models/Token.php +++ b/php-opencloud/openstack/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/php-opencloud/openstack/src/Identity/v3/Models/User.php b/php-opencloud/openstack/src/Identity/v3/Models/User.php index 842004201..3645e87d9 100644 --- a/php-opencloud/openstack/src/Identity/v3/Models/User.php +++ b/php-opencloud/openstack/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/php-opencloud/openstack/src/Identity/v3/Params.php b/php-opencloud/openstack/src/Identity/v3/Params.php index 9a160c703..f001d3c48 100644 --- a/php-opencloud/openstack/src/Identity/v3/Params.php +++ b/php-opencloud/openstack/src/Identity/v3/Params.php @@ -1,4 +1,6 @@ - self::OBJECT_TYPE, 'path' => 'auth.identity.password', 'properties' => [ - 'id' => [ + 'id' => [ 'type' => self::STRING_TYPE, 'description' => $this->id('user'), ], - 'name' => [ + 'name' => [ '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/php-opencloud/openstack/src/Identity/v3/Service.php b/php-opencloud/openstack/src/Identity/v3/Service.php index b29261cd1..6b11a0bd2 100644 --- a/php-opencloud/openstack/src/Identity/v3/Service.php +++ b/php-opencloud/openstack/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} * @@ -72,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} * @@ -107,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/php-opencloud/openstack/src/Images/v2/Api.php b/php-opencloud/openstack/src/Images/v2/Api.php index 6a28ffea6..0616763f9 100644 --- a/php-opencloud/openstack/src/Images/v2/Api.php +++ b/php-opencloud/openstack/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/php-opencloud/openstack/src/Images/v2/JsonPatch.php b/php-opencloud/openstack/src/Images/v2/JsonPatch.php index 860950fda..0108ac855 100644 --- a/php-opencloud/openstack/src/Images/v2/JsonPatch.php +++ b/php-opencloud/openstack/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/php-opencloud/openstack/src/Images/v2/Models/Image.php b/php-opencloud/openstack/src/Images/v2/Models/Image.php index 3b7312414..033eaa87e 100644 --- a/php-opencloud/openstack/src/Images/v2/Models/Image.php +++ b/php-opencloud/openstack/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/php-opencloud/openstack/src/Images/v2/Models/Member.php b/php-opencloud/openstack/src/Images/v2/Models/Member.php index 056e7c49e..c9138b0ee 100644 --- a/php-opencloud/openstack/src/Images/v2/Models/Member.php +++ b/php-opencloud/openstack/src/Images/v2/Models/Member.php @@ -1,4 +1,6 @@ - 'id', - 'image_id' => 'imageId', + 'member_id' => 'id', + 'image_id' => 'imageId', ]; /** - * @inheritdoc + * {@inheritdoc} */ protected function getAliases(): array { return parent::getAliases() + [ 'created_at' => 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/php-opencloud/openstack/src/Images/v2/Models/Schema.php b/php-opencloud/openstack/src/Images/v2/Models/Schema.php index d15f743da..44532fab2 100644 --- a/php-opencloud/openstack/src/Images/v2/Models/Schema.php +++ b/php-opencloud/openstack/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/php-opencloud/openstack/src/Images/v2/Params.php b/php-opencloud/openstack/src/Images/v2/Params.php index d2e0b2997..94a7c9c61 100644 --- a/php-opencloud/openstack/src/Images/v2/Params.php +++ b/php-opencloud/openstack/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, + '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/php-opencloud/openstack/src/Images/v2/Service.php b/php-opencloud/openstack/src/Images/v2/Service.php index 0ef133678..5e6c91bb9 100644 --- a/php-opencloud/openstack/src/Images/v2/Service.php +++ b/php-opencloud/openstack/src/Images/v2/Service.php @@ -1,4 +1,6 @@ -model(Image::class); $image->populateFromArray(['id' => $id]); + return $image; } } diff --git a/php-opencloud/openstack/src/Metric/v1/Gnocchi/Api.php b/php-opencloud/openstack/src/Metric/v1/Gnocchi/Api.php index 5ba41ac1f..9ffb23ac4 100644 --- a/php-opencloud/openstack/src/Metric/v1/Gnocchi/Api.php +++ b/php-opencloud/openstack/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/php-opencloud/openstack/src/Metric/v1/Gnocchi/Models/Metric.php b/php-opencloud/openstack/src/Metric/v1/Gnocchi/Models/Metric.php index e87691c0b..71b489caa 100644 --- a/php-opencloud/openstack/src/Metric/v1/Gnocchi/Models/Metric.php +++ b/php-opencloud/openstack/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/php-opencloud/openstack/src/Metric/v1/Gnocchi/Models/Resource.php b/php-opencloud/openstack/src/Metric/v1/Gnocchi/Models/Resource.php index 0114896e8..fa2c93cfa 100644 --- a/php-opencloud/openstack/src/Metric/v1/Gnocchi/Models/Resource.php +++ b/php-opencloud/openstack/src/Metric/v1/Gnocchi/Models/Resource.php @@ -1,4 +1,6 @@ - self::QUERY, - 'type' => self::STRING_TYPE + 'location' => self::QUERY, + '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/php-opencloud/openstack/src/Metric/v1/Gnocchi/Service.php b/php-opencloud/openstack/src/Metric/v1/Gnocchi/Service.php index 249236cc6..f70bcfbaa 100644 --- a/php-opencloud/openstack/src/Metric/v1/Gnocchi/Service.php +++ b/php-opencloud/openstack/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/php-opencloud/openstack/src/Networking/v2/Api.php b/php-opencloud/openstack/src/Networking/v2/Api.php index 6329ab2a5..11733b7af 100644 --- a/php-opencloud/openstack/src/Networking/v2/Api.php +++ b/php-opencloud/openstack/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() - ] + 'id' => $this->params->idPath('member'), + '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/php-opencloud/openstack/src/Networking/v2/Extensions/Layer3/Api.php b/php-opencloud/openstack/src/Networking/v2/Extensions/Layer3/Api.php index ff02f0b3e..b9ab45172 100644 --- a/php-opencloud/openstack/src/Networking/v2/Extensions/Layer3/Api.php +++ b/php-opencloud/openstack/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/php-opencloud/openstack/src/Networking/v2/Extensions/Layer3/Models/FixedIp.php b/php-opencloud/openstack/src/Networking/v2/Extensions/Layer3/Models/FixedIp.php index 9b5b65f34..551451356 100644 --- a/php-opencloud/openstack/src/Networking/v2/Extensions/Layer3/Models/FixedIp.php +++ b/php-opencloud/openstack/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/php-opencloud/openstack/src/Networking/v2/Extensions/Layer3/Models/FloatingIp.php b/php-opencloud/openstack/src/Networking/v2/Extensions/Layer3/Models/FloatingIp.php index 700cbb4b1..44973ddc5 100644 --- a/php-opencloud/openstack/src/Networking/v2/Extensions/Layer3/Models/FloatingIp.php +++ b/php-opencloud/openstack/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/php-opencloud/openstack/src/Networking/v2/Extensions/Layer3/Models/GatewayInfo.php b/php-opencloud/openstack/src/Networking/v2/Extensions/Layer3/Models/GatewayInfo.php index 0be0ef40f..ce735b1b6 100644 --- a/php-opencloud/openstack/src/Networking/v2/Extensions/Layer3/Models/GatewayInfo.php +++ b/php-opencloud/openstack/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/php-opencloud/openstack/src/Networking/v2/Extensions/Layer3/Models/Router.php b/php-opencloud/openstack/src/Networking/v2/Extensions/Layer3/Models/Router.php index b4831cb9e..abd53e7fb 100644 --- a/php-opencloud/openstack/src/Networking/v2/Extensions/Layer3/Models/Router.php +++ b/php-opencloud/openstack/src/Networking/v2/Extensions/Layer3/Models/Router.php @@ -43,23 +43,24 @@ class Router extends OperatorResource implements Listable, Creatable, Retrievabl protected $resourceKey = 'router'; protected $aliases = [ - 'admin_state_up' => 'adminStateUp', - 'tenant_id' => 'tenantId', + 'admin_state_up' => 'adminStateUp', + 'tenant_id' => 'tenantId', ]; /** - * @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/php-opencloud/openstack/src/Networking/v2/Extensions/SecurityGroups/Api.php b/php-opencloud/openstack/src/Networking/v2/Extensions/SecurityGroups/Api.php index 0d9b4df7b..1e715faa5 100644 --- a/php-opencloud/openstack/src/Networking/v2/Extensions/SecurityGroups/Api.php +++ b/php-opencloud/openstack/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/php-opencloud/openstack/src/Networking/v2/Extensions/SecurityGroups/Models/SecurityGroup.php b/php-opencloud/openstack/src/Networking/v2/Extensions/SecurityGroups/Models/SecurityGroup.php index b4989fb55..5812c6b5e 100644 --- a/php-opencloud/openstack/src/Networking/v2/Extensions/SecurityGroups/Models/SecurityGroup.php +++ b/php-opencloud/openstack/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/php-opencloud/openstack/src/Networking/v2/Extensions/SecurityGroups/Models/SecurityGroupRule.php b/php-opencloud/openstack/src/Networking/v2/Extensions/SecurityGroups/Models/SecurityGroupRule.php index de50807bf..54064cd04 100644 --- a/php-opencloud/openstack/src/Networking/v2/Extensions/SecurityGroups/Models/SecurityGroupRule.php +++ b/php-opencloud/openstack/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/php-opencloud/openstack/src/Networking/v2/Extensions/SecurityGroups/Params.php b/php-opencloud/openstack/src/Networking/v2/Extensions/SecurityGroups/Params.php index 38f10beb7..09f4c24f5 100644 --- a/php-opencloud/openstack/src/Networking/v2/Extensions/SecurityGroups/Params.php +++ b/php-opencloud/openstack/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/php-opencloud/openstack/src/Networking/v2/Models/InterfaceAttachment.php b/php-opencloud/openstack/src/Networking/v2/Models/InterfaceAttachment.php index 9a4038ebe..46b430d72 100644 --- a/php-opencloud/openstack/src/Networking/v2/Models/InterfaceAttachment.php +++ b/php-opencloud/openstack/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/php-opencloud/openstack/src/Networking/v2/Models/LoadBalancer.php b/php-opencloud/openstack/src/Networking/v2/Models/LoadBalancer.php index d0ba20c70..bb4a4ae4a 100644 --- a/php-opencloud/openstack/src/Networking/v2/Models/LoadBalancer.php +++ b/php-opencloud/openstack/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/php-opencloud/openstack/src/Networking/v2/Models/LoadBalancerHealthMonitor.php b/php-opencloud/openstack/src/Networking/v2/Models/LoadBalancerHealthMonitor.php index 9e062e0a3..1322e589b 100644 --- a/php-opencloud/openstack/src/Networking/v2/Models/LoadBalancerHealthMonitor.php +++ b/php-opencloud/openstack/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/php-opencloud/openstack/src/Networking/v2/Models/LoadBalancerListener.php b/php-opencloud/openstack/src/Networking/v2/Models/LoadBalancerListener.php index b8af397a9..2ab1254b3 100644 --- a/php-opencloud/openstack/src/Networking/v2/Models/LoadBalancerListener.php +++ b/php-opencloud/openstack/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/php-opencloud/openstack/src/Networking/v2/Models/LoadBalancerMember.php b/php-opencloud/openstack/src/Networking/v2/Models/LoadBalancerMember.php index 7dc5d894a..a8d01c2b1 100644 --- a/php-opencloud/openstack/src/Networking/v2/Models/LoadBalancerMember.php +++ b/php-opencloud/openstack/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/php-opencloud/openstack/src/Networking/v2/Models/LoadBalancerPool.php b/php-opencloud/openstack/src/Networking/v2/Models/LoadBalancerPool.php index f25ff7596..4da0be958 100644 --- a/php-opencloud/openstack/src/Networking/v2/Models/LoadBalancerPool.php +++ b/php-opencloud/openstack/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/php-opencloud/openstack/src/Networking/v2/Models/LoadBalancerStat.php b/php-opencloud/openstack/src/Networking/v2/Models/LoadBalancerStat.php index 500af336d..eccf3f254 100644 --- a/php-opencloud/openstack/src/Networking/v2/Models/LoadBalancerStat.php +++ b/php-opencloud/openstack/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/php-opencloud/openstack/src/Networking/v2/Models/LoadBalancerStatus.php b/php-opencloud/openstack/src/Networking/v2/Models/LoadBalancerStatus.php index 75c84b70d..dbcf1de45 100644 --- a/php-opencloud/openstack/src/Networking/v2/Models/LoadBalancerStatus.php +++ b/php-opencloud/openstack/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/php-opencloud/openstack/src/Networking/v2/Models/Network.php b/php-opencloud/openstack/src/Networking/v2/Models/Network.php index a96ec7958..ab92bfa6d 100644 --- a/php-opencloud/openstack/src/Networking/v2/Models/Network.php +++ b/php-opencloud/openstack/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/php-opencloud/openstack/src/Networking/v2/Models/Port.php b/php-opencloud/openstack/src/Networking/v2/Models/Port.php index b5abf8ac0..e67b123b6 100644 --- a/php-opencloud/openstack/src/Networking/v2/Models/Port.php +++ b/php-opencloud/openstack/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/php-opencloud/openstack/src/Networking/v2/Models/Quota.php b/php-opencloud/openstack/src/Networking/v2/Models/Quota.php index dc4105e22..3398d1dca 100644 --- a/php-opencloud/openstack/src/Networking/v2/Models/Quota.php +++ b/php-opencloud/openstack/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/php-opencloud/openstack/src/Networking/v2/Models/Subnet.php b/php-opencloud/openstack/src/Networking/v2/Models/Subnet.php index 9c3f18ead..142a9ddf8 100644 --- a/php-opencloud/openstack/src/Networking/v2/Models/Subnet.php +++ b/php-opencloud/openstack/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/php-opencloud/openstack/src/Networking/v2/Params.php b/php-opencloud/openstack/src/Networking/v2/Params.php index 9e444d76e..abbe9dc40 100644 --- a/php-opencloud/openstack/src/Networking/v2/Params.php +++ b/php-opencloud/openstack/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', ], @@ -132,16 +134,16 @@ public function dnsNameservers(): array public function allocationPools(): array { return [ - 'type' => self::ARRAY_TYPE, - 'sentAs' => 'allocation_pools', - 'items' => [ + 'type' => self::ARRAY_TYPE, + 'sentAs' => 'allocation_pools', + 'items' => [ 'type' => self::OBJECT_TYPE, 'properties' => [ 'start' => [ 'type' => self::STRING_TYPE, 'description' => 'The start address for the allocation pools', ], - 'end' => [ + 'end' => [ 'type' => self::STRING_TYPE, 'description' => 'The end address for the allocation pools', ], @@ -154,16 +156,16 @@ public function allocationPools(): array public function hostRoutes(): array { return [ - 'type' => self::ARRAY_TYPE, - 'sentAs' => 'host_routes', - 'items' => [ + 'type' => self::ARRAY_TYPE, + 'sentAs' => 'host_routes', + 'items' => [ 'type' => self::OBJECT_TYPE, 'properties' => [ 'destination' => [ 'type' => self::STRING_TYPE, 'description' => 'Destination for static route', ], - 'nexthop' => [ + 'nexthop' => [ 'type' => self::STRING_TYPE, 'description' => 'Nexthop for the destination', ], @@ -292,21 +294,21 @@ public function fixedIps(): array 'description' => 'The IP addresses for the port. If you would like to assign multiple IP addresses for the 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, + 'items' => [ + '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.', + ], + ], + ], ]; } @@ -353,7 +355,7 @@ public function allowedAddrPairs(): array 'type' => self::OBJECT_TYPE, 'description' => 'A MAC addr/IP addr pair', 'properties' => [ - 'ipAddress' => [ + 'ipAddress' => [ 'sentAs' => 'ip_address', 'type' => self::STRING_TYPE, 'location' => self::JSON, @@ -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/php-opencloud/openstack/src/Networking/v2/Service.php b/php-opencloud/openstack/src/Networking/v2/Service.php index 68afdc46c..6a1e0f932 100644 --- a/php-opencloud/openstack/src/Networking/v2/Service.php +++ b/php-opencloud/openstack/src/Networking/v2/Service.php @@ -1,4 +1,6 @@ -params = new Params; + $this->params = new Params(); } public function getAccount(): array diff --git a/php-opencloud/openstack/src/ObjectStore/v1/Models/Account.php b/php-opencloud/openstack/src/ObjectStore/v1/Models/Account.php index cd280411e..3ef03e2af 100644 --- a/php-opencloud/openstack/src/ObjectStore/v1/Models/Account.php +++ b/php-opencloud/openstack/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/php-opencloud/openstack/src/ObjectStore/v1/Models/Container.php b/php-opencloud/openstack/src/ObjectStore/v1/Models/Container.php index 80407d749..f9c76b829 100644 --- a/php-opencloud/openstack/src/ObjectStore/v1/Models/Container.php +++ b/php-opencloud/openstack/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,7 +56,7 @@ 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 */ @@ -109,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); } @@ -130,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); } @@ -140,6 +142,7 @@ public function resetMetadata(array $metadata) public function getMetadata(): array { $response = $this->executeWithState($this->api->headContainer()); + return $this->parseMetadata($response); } @@ -160,20 +163,21 @@ public function getObject($name): StorageObject /** * 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; @@ -185,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): StorageObject { @@ -211,10 +215,10 @@ public function createLargeObject(array $data): StorageObject $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(); @@ -227,7 +231,7 @@ public function createLargeObject(array $data): StorageObject while (!$stream->eof() && $count < round($stream->getSize() / $segmentSize)) { $promises[] = $this->model(StorageObject::class)->createAsync([ - 'name' => sprintf("%s/%d", $segmentPrefix, ++$count), + 'name' => sprintf('%s/%d', $segmentPrefix, ++$count), 'stream' => new LimitStream($stream, $segmentSize, ($count - 1) * $segmentSize), 'containerName' => $segmentContainer, ]); @@ -239,7 +243,7 @@ public function createLargeObject(array $data): StorageObject return $this->createObject([ 'name' => $data['name'], - 'objectManifest' => sprintf("%s/%s", $segmentContainer, $segmentPrefix), + 'objectManifest' => sprintf('%s/%s', $segmentContainer, $segmentPrefix), ]); } } diff --git a/php-opencloud/openstack/src/ObjectStore/v1/Models/MetadataTrait.php b/php-opencloud/openstack/src/ObjectStore/v1/Models/MetadataTrait.php index 9529dbab4..f4006aedb 100644 --- a/php-opencloud/openstack/src/ObjectStore/v1/Models/MetadataTrait.php +++ b/php-opencloud/openstack/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/php-opencloud/openstack/src/ObjectStore/v1/Models/StorageObject.php b/php-opencloud/openstack/src/ObjectStore/v1/Models/StorageObject.php index dad23c69e..5ab52ad6c 100644 --- a/php-opencloud/openstack/src/ObjectStore/v1/Models/StorageObject.php +++ b/php-opencloud/openstack/src/ObjectStore/v1/Models/StorageObject.php @@ -1,4 +1,6 @@ - 'contentLength', + 'bytes' => 'contentLength', 'content_type' => 'contentType', - 'subdir' => 'name', + 'subdir' => 'name', ]; /** - * @inheritdoc + * {@inheritdoc} */ protected function getAliases(): array { @@ -79,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; } @@ -110,14 +112,14 @@ public function create(array $data): Creatable $data['containerName'] = $this->containerName; } - $response = $this->execute($this->api->putObject(), $data); + $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'] + 'containerName' => $data['containerName'], ]); return $storageObject; @@ -142,7 +144,6 @@ public function retrieve() * * @return StreamInterface */ - public function download(array $data = []): StreamInterface { $data += ['name' => $this->name, 'containerName' => $this->containerName]; @@ -182,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); } @@ -192,12 +193,12 @@ public function mergeMetadata(array $metadata) public function resetMetadata(array $metadata) { $options = [ - 'containerName' => $this->containerName, - 'name' => $this->name, - 'metadata' => $metadata, + 'containerName' => $this->containerName, + 'name' => $this->name, + 'metadata' => $metadata, ]; - $response = $this->execute($this->api->postObject(), $options); + $response = $this->execute($this->api->postObject(), $options); $this->metadata = $this->parseMetadata($response); } @@ -207,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/php-opencloud/openstack/src/ObjectStore/v1/Params.php b/php-opencloud/openstack/src/ObjectStore/v1/Params.php index 44e39594b..bdff7a5c1 100644 --- a/php-opencloud/openstack/src/ObjectStore/v1/Params.php +++ b/php-opencloud/openstack/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)), - 'properties' => [ + 'location' => self::HEADER, + 'type' => self::OBJECT_TYPE, + 'prefix' => sprintf('X-%s-Meta-', ucfirst($type)), + 'properties' => [ 'type' => self::STRING_TYPE, ], 'description' => << '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/php-opencloud/openstack/src/OpenStack.php b/php-opencloud/openstack/src/OpenStack.php index d1e02f207..b88a7b777 100644 --- a/php-opencloud/openstack/src/OpenStack.php +++ b/php-opencloud/openstack/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 *