From 688bb3eefeafc48b549673edf62edfce8a3544d5 Mon Sep 17 00:00:00 2001 From: Konstantin Babushkin Date: Wed, 17 Jan 2024 14:53:08 +0100 Subject: [PATCH 01/50] fix index links --- doc/index.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/index.rst b/doc/index.rst index 0feb0b93..9c4bfbda 100644 --- a/doc/index.rst +++ b/doc/index.rst @@ -49,6 +49,6 @@ Contributing If you'd like to contribute to the project, or require help running the unit/integration tests, please view the `contributing guidelines`_. -.. _Composer installation instructions: `https://getcomposer.org/doc/00-intro.md` -.. _Github repo: `https://github.com/php-opencloud/openstack` -.. _contributing guidelines: `https://github.com/php-opencloud/openstack/blob/master/CONTRIBUTING.md` +.. _Composer installation instructions: https://getcomposer.org/doc/00-intro.md +.. _Github repo: https://github.com/php-opencloud/openstack +.. _contributing guidelines: https://github.com/php-opencloud/openstack/blob/master/CONTRIBUTING.md From ebf3ad627c171f7456727ff88f68d3061b7d280a Mon Sep 17 00:00:00 2001 From: Konstantin Babushkin Date: Wed, 17 Jan 2024 15:51:23 +0100 Subject: [PATCH 02/50] check adding index to toc --- doc/index.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/doc/index.rst b/doc/index.rst index 9c4bfbda..da198744 100644 --- a/doc/index.rst +++ b/doc/index.rst @@ -1,6 +1,11 @@ Welcome to the OpenStack SDK for PHP! ===================================== +.. toctree:: + :hidden: + + index + Requirements ------------ From 179be75419bb3bcf48822f52bb9908a30ae4f279 Mon Sep 17 00:00:00 2001 From: Konstantin Babushkin Date: Wed, 17 Jan 2024 15:53:34 +0100 Subject: [PATCH 03/50] check adding index to toc --- doc/index.rst | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/doc/index.rst b/doc/index.rst index da198744..d0f17128 100644 --- a/doc/index.rst +++ b/doc/index.rst @@ -1,11 +1,6 @@ Welcome to the OpenStack SDK for PHP! ===================================== -.. toctree:: - :hidden: - - index - Requirements ------------ @@ -34,15 +29,6 @@ application’s PHP files: This assumes your application's PHP files are located in the same folder as ``vendor/``. If your files are located elsewhere, please supply the path to vendor/autoload.php in the require statement above. -Supported services ------------------- - -.. toctree:: - :glob: - :maxdepth: 1 - - services/**/index - Help and support ---------------- @@ -57,3 +43,14 @@ If you'd like to contribute to the project, or require help running the unit/int .. _Composer installation instructions: https://getcomposer.org/doc/00-intro.md .. _Github repo: https://github.com/php-opencloud/openstack .. _contributing guidelines: https://github.com/php-opencloud/openstack/blob/master/CONTRIBUTING.md + +Table of contents +----------------- + +.. toctree:: + :glob: + :maxdepth: 1 + + index + services/**/index + From ef5df8adef5cb8702df0b35c1a3ffc12f2985a03 Mon Sep 17 00:00:00 2001 From: Konstantin Babushkin Date: Wed, 17 Jan 2024 16:00:21 +0100 Subject: [PATCH 04/50] playing with toc --- doc/index.rst | 47 +++++++++++++-------------------------------- doc/quick-start.rst | 32 ++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 34 deletions(-) create mode 100644 doc/quick-start.rst diff --git a/doc/index.rst b/doc/index.rst index d0f17128..a8e1f236 100644 --- a/doc/index.rst +++ b/doc/index.rst @@ -1,33 +1,24 @@ Welcome to the OpenStack SDK for PHP! ===================================== -Requirements ------------- - -* PHP >= 7, < 9 -* cURL extension - -Installation ------------- - -You must install this library through Composer: +About +----- -.. code-block:: bash +OpenStack SDK allows PHP developers to easily connect to OpenStack APIs in a simple and idiomatic way. +This binding is specifically designed for OpenStack APIs, but other provider SDKs are available. +Multiple OpenStack services, and versions of services, are supported. - composer require php-opencloud/openstack - -If you do not have Composer installed, please read the `Composer installation instructions`_. - -Once you have installed the SDK as a dependency of your project, you will need to load Composer’s autoloader -(which registers all the required namespaces). To do this, place the following line of PHP code at the top of your -application’s PHP files: +.. toctree:: + quick-start -.. code-block:: php +Supported services +------------------ - require 'vendor/autoload.php'; +.. toctree:: + :glob: + :maxdepth: 1 -This assumes your application's PHP files are located in the same folder as ``vendor/``. If your files are located -elsewhere, please supply the path to vendor/autoload.php in the require statement above. + services/**/index Help and support ---------------- @@ -40,17 +31,5 @@ Contributing If you'd like to contribute to the project, or require help running the unit/integration tests, please view the `contributing guidelines`_. -.. _Composer installation instructions: https://getcomposer.org/doc/00-intro.md .. _Github repo: https://github.com/php-opencloud/openstack .. _contributing guidelines: https://github.com/php-opencloud/openstack/blob/master/CONTRIBUTING.md - -Table of contents ------------------ - -.. toctree:: - :glob: - :maxdepth: 1 - - index - services/**/index - diff --git a/doc/quick-start.rst b/doc/quick-start.rst new file mode 100644 index 00000000..4b2c12f3 --- /dev/null +++ b/doc/quick-start.rst @@ -0,0 +1,32 @@ +Quick start +=========== + +Requirements +------------ + +* PHP >= 7, < 9 +* cURL extension + +Installation +------------ + +You must install this library through Composer: + +.. code-block:: bash + + composer require php-opencloud/openstack + +If you do not have Composer installed, please read the `Composer installation instructions`_. + +Once you have installed the SDK as a dependency of your project, you will need to load Composer’s autoloader +(which registers all the required namespaces). To do this, place the following line of PHP code at the top of your +application’s PHP files: + +.. code-block:: php + + require 'vendor/autoload.php'; + +This assumes your application's PHP files are located in the same folder as ``vendor/``. If your files are located +elsewhere, please supply the path to vendor/autoload.php in the require statement above. + +.. _Composer installation instructions: https://getcomposer.org/doc/00-intro.md From 807a13b0e2d44af97ca8befa104384a261de59aa Mon Sep 17 00:00:00 2001 From: Konstantin Babushkin Date: Wed, 17 Jan 2024 17:00:55 +0100 Subject: [PATCH 05/50] add OpenStack creation --- doc/quick-start.rst | 41 ++++++++++++++++++++++++++++++ doc/services/identity/v3/index.rst | 14 ++++++++++ 2 files changed, 55 insertions(+) diff --git a/doc/quick-start.rst b/doc/quick-start.rst index 4b2c12f3..d9c444c3 100644 --- a/doc/quick-start.rst +++ b/doc/quick-start.rst @@ -18,6 +18,9 @@ You must install this library through Composer: If you do not have Composer installed, please read the `Composer installation instructions`_. +Include the autoloader +---------------------- + Once you have installed the SDK as a dependency of your project, you will need to load Composer’s autoloader (which registers all the required namespaces). To do this, place the following line of PHP code at the top of your application’s PHP files: @@ -29,4 +32,42 @@ application’s PHP files: This assumes your application's PHP files are located in the same folder as ``vendor/``. If your files are located elsewhere, please supply the path to vendor/autoload.php in the require statement above. +Creating a client +----------------- + +To create a client, you will need to provide the following information: +* The identity service URL (``authUrl``) +* The region in which you want to operate (``region``) +* The credentials of the user you want to authenticate (``user``), (``tokenId``), (``cachedToken``) + or (``application_credential``) + +Only the ``authUrl`` is mandatory to create a client. But you will have to provide the ``region`` and ``user`` +to each service you create. So it is recommended to provide them when creating the client. + +There are different ways to provide the authentication credentials. See the `Token generation`_ section for +the full list of options. Here is an example of how to create a client with a user id and password: + +.. code-block:: php + $openstack = new OpenStack\OpenStack([ + 'authUrl' => '{authUrl}', + 'region' => '{region}', + 'user' => [ + 'id' => '{userId}', + 'password' => '{password}' + ], + ]); + +Here is an example of how to create a client with application credentials: + +.. code-block:: php + $openstack = new OpenStack\OpenStack([ + 'authUrl' => '{authUrl}', + 'region' => '{region}', + 'application_credential' => [ + 'id' => '{applicationCredentialId}', + 'secret' => '{secret}' + ] + ]); + .. _Composer installation instructions: https://getcomposer.org/doc/00-intro.md +.. _Token generation: /services/identity/v3/tokens diff --git a/doc/services/identity/v3/index.rst b/doc/services/identity/v3/index.rst index 6520cc7b..d06b8c69 100644 --- a/doc/services/identity/v3/index.rst +++ b/doc/services/identity/v3/index.rst @@ -1,6 +1,20 @@ Identity v3 =========== +Creating the service +-------------------- + +Service can be created via `identityV3` method of `OpenStack` object: +.. code-block:: php + $service = $openstack->identityV3(); + +A list of additional options can be passed to the method. For example, to change the region: +.. code-block:: php + $service = $openstack->identityV3(['region' => '{region}']); + +Service methods +--------------- + .. toctree:: :maxdepth: 3 From 23d1685e13e48ecaf7740575f21618489b34c98f Mon Sep 17 00:00:00 2001 From: Konstantin Babushkin Date: Wed, 17 Jan 2024 17:04:30 +0100 Subject: [PATCH 06/50] add OpenStack creation --- doc/quick-start.rst | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/doc/quick-start.rst b/doc/quick-start.rst index d9c444c3..b14ad64f 100644 --- a/doc/quick-start.rst +++ b/doc/quick-start.rst @@ -36,10 +36,11 @@ Creating a client ----------------- To create a client, you will need to provide the following information: + * The identity service URL (``authUrl``) * The region in which you want to operate (``region``) * The credentials of the user you want to authenticate (``user``), (``tokenId``), (``cachedToken``) - or (``application_credential``) +or (``application_credential``) Only the ``authUrl`` is mandatory to create a client. But you will have to provide the ``region`` and ``user`` to each service you create. So it is recommended to provide them when creating the client. @@ -48,6 +49,7 @@ There are different ways to provide the authentication credentials. See the `Tok the full list of options. Here is an example of how to create a client with a user id and password: .. code-block:: php + $openstack = new OpenStack\OpenStack([ 'authUrl' => '{authUrl}', 'region' => '{region}', @@ -60,6 +62,7 @@ the full list of options. Here is an example of how to create a client with a us Here is an example of how to create a client with application credentials: .. code-block:: php + $openstack = new OpenStack\OpenStack([ 'authUrl' => '{authUrl}', 'region' => '{region}', From 692b5142f78161740c0331d18815ced440825d28 Mon Sep 17 00:00:00 2001 From: Konstantin Babushkin Date: Wed, 17 Jan 2024 17:07:51 +0100 Subject: [PATCH 07/50] fix OpenStack creation --- doc/quick-start.rst | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/doc/quick-start.rst b/doc/quick-start.rst index b14ad64f..c4a94b62 100644 --- a/doc/quick-start.rst +++ b/doc/quick-start.rst @@ -46,7 +46,9 @@ Only the ``authUrl`` is mandatory to create a client. But you will have to provi to each service you create. So it is recommended to provide them when creating the client. There are different ways to provide the authentication credentials. See the `Token generation`_ section for -the full list of options. Here is an example of how to create a client with a user id and password: +the full list of options. + +Here is an example of how to create a client with a user id and password: .. code-block:: php @@ -73,4 +75,4 @@ Here is an example of how to create a client with application credentials: ]); .. _Composer installation instructions: https://getcomposer.org/doc/00-intro.md -.. _Token generation: /services/identity/v3/tokens +.. _Token generation: services/identity/v3/tokens From ef887d441c53eb26865acf94a4cf0073f6598e3e Mon Sep 17 00:00:00 2001 From: Konstantin Babushkin Date: Wed, 17 Jan 2024 17:10:11 +0100 Subject: [PATCH 08/50] fix OpenStack creation --- doc/quick-start.rst | 3 ++- doc/services/identity/v3/index.rst | 7 ++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/doc/quick-start.rst b/doc/quick-start.rst index c4a94b62..1492a093 100644 --- a/doc/quick-start.rst +++ b/doc/quick-start.rst @@ -46,7 +46,8 @@ Only the ``authUrl`` is mandatory to create a client. But you will have to provi to each service you create. So it is recommended to provide them when creating the client. There are different ways to provide the authentication credentials. See the `Token generation`_ section for -the full list of options. +the full list of options. You should provide credentials to the `OpenStack` constructor as an array the same way +you provide options to `generateToken` method of the `Identity` service. Here is an example of how to create a client with a user id and password: diff --git a/doc/services/identity/v3/index.rst b/doc/services/identity/v3/index.rst index d06b8c69..8c161650 100644 --- a/doc/services/identity/v3/index.rst +++ b/doc/services/identity/v3/index.rst @@ -5,15 +5,16 @@ Creating the service -------------------- Service can be created via `identityV3` method of `OpenStack` object: + .. code-block:: php + $service = $openstack->identityV3(); A list of additional options can be passed to the method. For example, to change the region: + .. code-block:: php - $service = $openstack->identityV3(['region' => '{region}']); -Service methods ---------------- + $service = $openstack->identityV3(['region' => '{region}']); .. toctree:: :maxdepth: 3 From 09c629fc62f73c40e7ab0734a52200c7fb5dce78 Mon Sep 17 00:00:00 2001 From: Konstantin Babushkin Date: Wed, 17 Jan 2024 17:15:00 +0100 Subject: [PATCH 09/50] fix OpenStack creation --- doc/quick-start.rst | 11 +++++------ doc/services/identity/v3/create.rst | 13 +++++++++++++ doc/services/identity/v3/index.rst | 16 +++------------- 3 files changed, 21 insertions(+), 19 deletions(-) create mode 100644 doc/services/identity/v3/create.rst diff --git a/doc/quick-start.rst b/doc/quick-start.rst index 1492a093..24ebaa5a 100644 --- a/doc/quick-start.rst +++ b/doc/quick-start.rst @@ -39,15 +39,15 @@ To create a client, you will need to provide the following information: * The identity service URL (``authUrl``) * The region in which you want to operate (``region``) -* The credentials of the user you want to authenticate (``user``), (``tokenId``), (``cachedToken``) -or (``application_credential``) +* The credentials of the user you want to authenticate: ``user``, ``tokenId``, ``cachedToken`` + or ``application_credential`` Only the ``authUrl`` is mandatory to create a client. But you will have to provide the ``region`` and ``user`` to each service you create. So it is recommended to provide them when creating the client. -There are different ways to provide the authentication credentials. See the `Token generation`_ section for -the full list of options. You should provide credentials to the `OpenStack` constructor as an array the same way -you provide options to `generateToken` method of the `Identity` service. +There are different ways to provide the authentication credentials. See the :doc:`services/identity/v3/tokens` +section for the full list of options. You should provide credentials to the `OpenStack` constructor as an array +the same way you provide options to ``generateToken`` method of the ``Identity`` service. Here is an example of how to create a client with a user id and password: @@ -76,4 +76,3 @@ Here is an example of how to create a client with application credentials: ]); .. _Composer installation instructions: https://getcomposer.org/doc/00-intro.md -.. _Token generation: services/identity/v3/tokens diff --git a/doc/services/identity/v3/create.rst b/doc/services/identity/v3/create.rst new file mode 100644 index 00000000..57dd890c --- /dev/null +++ b/doc/services/identity/v3/create.rst @@ -0,0 +1,13 @@ +Creating the service +==================== + +Service can be created via ``identityV3`` method of ``OpenStack`` object: + +.. code-block:: php + + $service = $openstack->identityV3(); + +A list of additional options can be passed to the method. For example, to change the region: + +.. code-block:: php + $service = $openstack->identityV3(['region' => '{region}']); diff --git a/doc/services/identity/v3/index.rst b/doc/services/identity/v3/index.rst index 8c161650..e282b0b0 100644 --- a/doc/services/identity/v3/index.rst +++ b/doc/services/identity/v3/index.rst @@ -1,24 +1,14 @@ Identity v3 =========== -Creating the service --------------------- -Service can be created via `identityV3` method of `OpenStack` object: - -.. code-block:: php - - $service = $openstack->identityV3(); - -A list of additional options can be passed to the method. For example, to change the region: - -.. code-block:: php - - $service = $openstack->identityV3(['region' => '{region}']); +Service methods +--------------- .. toctree:: :maxdepth: 3 + create application-credentials credentials domains From 7cc793c0a445164e333797df2fe9a35bbf61f698 Mon Sep 17 00:00:00 2001 From: Konstantin Babushkin Date: Wed, 17 Jan 2024 17:46:12 +0100 Subject: [PATCH 10/50] doc fixes --- doc/quick-start.rst | 18 ++++++++++++++++++ doc/services/identity/v3/create.rst | 1 + doc/services/identity/v3/index.rst | 4 ---- .../add_application_credential.php | 7 +------ .../delete_application_credential.php | 7 +------ .../show_application_credential.php | 7 +------ tests/sample/SampleManager.php | 3 +-- 7 files changed, 23 insertions(+), 24 deletions(-) diff --git a/doc/quick-start.rst b/doc/quick-start.rst index 24ebaa5a..fbcad26a 100644 --- a/doc/quick-start.rst +++ b/doc/quick-start.rst @@ -75,4 +75,22 @@ Here is an example of how to create a client with application credentials: ] ]); +You can specify the scope of the token: + +.. code-block:: php + + $openstack = new OpenStack\OpenStack([ + 'authUrl' => '{authUrl}', + 'region' => '{region}', + 'user' => [ + 'id' => '{userId}', + 'password' => '{password}' + ], + 'scope' => [ + 'project' => [ + 'id' => '{projectId}' + ], + ], + ]); + .. _Composer installation instructions: https://getcomposer.org/doc/00-intro.md diff --git a/doc/services/identity/v3/create.rst b/doc/services/identity/v3/create.rst index 57dd890c..38adb151 100644 --- a/doc/services/identity/v3/create.rst +++ b/doc/services/identity/v3/create.rst @@ -10,4 +10,5 @@ Service can be created via ``identityV3`` method of ``OpenStack`` object: A list of additional options can be passed to the method. For example, to change the region: .. code-block:: php + $service = $openstack->identityV3(['region' => '{region}']); diff --git a/doc/services/identity/v3/index.rst b/doc/services/identity/v3/index.rst index e282b0b0..df78f886 100644 --- a/doc/services/identity/v3/index.rst +++ b/doc/services/identity/v3/index.rst @@ -1,10 +1,6 @@ Identity v3 =========== - -Service methods ---------------- - .. toctree:: :maxdepth: 3 diff --git a/samples/Identity/v3/application_credentials/add_application_credential.php b/samples/Identity/v3/application_credentials/add_application_credential.php index ae92e376..be71f042 100644 --- a/samples/Identity/v3/application_credentials/add_application_credential.php +++ b/samples/Identity/v3/application_credentials/add_application_credential.php @@ -9,14 +9,9 @@ 'id' => '{userId}', 'password' => '{password}' ], - 'scope' => [ - 'project' => [ - 'id' => '{projectId}' - ] - ] ]); -$identity = $openstack->identityV3(['region' => '{region}']); +$identity = $openstack->identityV3(); $user = $identity->getUser('{userId}'); $applicationCredential = $user->createApplicationCredential([ diff --git a/samples/Identity/v3/application_credentials/delete_application_credential.php b/samples/Identity/v3/application_credentials/delete_application_credential.php index 23619cce..5ce70855 100644 --- a/samples/Identity/v3/application_credentials/delete_application_credential.php +++ b/samples/Identity/v3/application_credentials/delete_application_credential.php @@ -9,14 +9,9 @@ 'id' => '{userId}', 'password' => '{password}' ], - 'scope' => [ - 'project' => [ - 'id' => '{projectId}' - ] - ] ]); -$identity = $openstack->identityV3(['region' => '{region}']); +$identity = $openstack->identityV3(); $user = $identity->getUser('{userId}'); $applicationCredential = $user->getApplicationCredential('{applicationCredentialId}'); diff --git a/samples/Identity/v3/application_credentials/show_application_credential.php b/samples/Identity/v3/application_credentials/show_application_credential.php index 704c63d3..a7db5f80 100644 --- a/samples/Identity/v3/application_credentials/show_application_credential.php +++ b/samples/Identity/v3/application_credentials/show_application_credential.php @@ -9,14 +9,9 @@ 'id' => '{userId}', 'password' => '{password}' ], - 'scope' => [ - 'project' => [ - 'id' => '{projectId}' - ] - ] ]); -$identity = $openstack->identityV3(['region' => '{region}']); +$identity = $openstack->identityV3(); $user = $identity->getUser('{userId}'); $applicationCredential = $user->getApplicationCredential('{applicationCredentialId}'); diff --git a/tests/sample/SampleManager.php b/tests/sample/SampleManager.php index 585c84b0..cda017d9 100644 --- a/tests/sample/SampleManager.php +++ b/tests/sample/SampleManager.php @@ -2,7 +2,6 @@ namespace OpenStack\Sample; -use OpenStack\Integration\SampleManagerInterface; use RuntimeException; class SampleManager @@ -98,7 +97,7 @@ public function write(string $path, array $replacements): string } $content = strtr(file_get_contents($sampleFile), $replacements); - $content = str_replace("'vendor/'", "'" . dirname(dirname(__DIR__)) . DIRECTORY_SEPARATOR . "vendor'", $content); + $content = str_replace("'vendor/'", "'" . dirname(__DIR__, 2) . DIRECTORY_SEPARATOR . "vendor'", $content); $subst = $this->getConnectionTemplate(); $content = preg_replace('/\([^)]+\)/', '', $content, 1); From 70f27c304d990b434e823110ab3144e1d28fd945 Mon Sep 17 00:00:00 2001 From: Konstantin Babushkin Date: Wed, 17 Jan 2024 18:45:41 +0100 Subject: [PATCH 11/50] add collapsible auth code --- doc/_exts/samples.py | 37 +++++++++++++++---------------- doc/conf.py | 9 +++++++- doc/requirements.txt | 3 ++- doc/services/images/v2/images.rst | 2 +- 4 files changed, 29 insertions(+), 22 deletions(-) diff --git a/doc/_exts/samples.py b/doc/_exts/samples.py index bb11d3eb..ed50b764 100644 --- a/doc/_exts/samples.py +++ b/doc/_exts/samples.py @@ -1,33 +1,32 @@ from docutils import nodes -from sphinx.addnodes import download_reference from sphinx.directives.code import LiteralInclude +from sphinx_toolbox.collapse import CollapseNode import re + class Sample(LiteralInclude): - def run(self): - self.arguments[0] = "/../samples/" + self.arguments[0] - self.options['language'] = 'php' + def run(self): + self.arguments[0] = "/../samples/" + self.arguments[0] + self.options['language'] = 'php' - pattern = r"[\s+]?(\<\?php.*?]\);)" + pattern = r"[\s+]?(\<\?php.*?]\);)" - code_block = super(Sample, self).run()[0] - string = str(code_block[0]) + code_block = super(Sample, self).run()[0] + string = str(code_block[0]) - match = re.match(pattern, string, re.S) - if match is None: - return [code_block] + match = re.match(pattern, string, re.S) + if match is None: + return [code_block] - auth_str = match.group(1).strip() - main_str = re.sub(pattern, "", string, 0, re.S).strip() + auth_str = match.group(1).strip() + main_str = re.sub(pattern, "", string, 0, re.S).strip() - show_hide_btn = download_reference(reftarget=self.arguments[0]) + return [ + CollapseNode(nodes.literal_block(auth_str, auth_str, language="php"), "show auth code"), + nodes.literal_block(main_str, main_str, language="php")] - return [ - show_hide_btn, - nodes.literal_block(auth_str, auth_str, language="php"), - nodes.literal_block(main_str, main_str, language="php")] def setup(app): - app.add_directive('sample', Sample) - return {'version': '0.1'} + app.add_directive('sample', Sample) + return {'version': '0.1'} diff --git a/doc/conf.py b/doc/conf.py index 16f6c857..502106f4 100755 --- a/doc/conf.py +++ b/doc/conf.py @@ -23,7 +23,14 @@ lexers['php-annotations'] = PhpLexer(startinline=True, linenos=1) primary_domain = 'php' -extensions = ['samples', 'refdoc', 'sphinx.ext.autodoc', 'sphinx.ext.autosummary', 'sphinxcontrib.phpdomain'] +extensions = [ + 'samples', + 'refdoc', + 'sphinx.ext.autodoc', + 'sphinx.ext.autosummary', + 'sphinxcontrib.phpdomain', + 'sphinx_toolbox.collapse', +] source_suffix = '.rst' master_doc = 'index' project = u'php-opencloud' diff --git a/doc/requirements.txt b/doc/requirements.txt index 6c439f25..76b768dc 100644 --- a/doc/requirements.txt +++ b/doc/requirements.txt @@ -1,2 +1,3 @@ sphinxcontrib-phpdomain>=0.11.0 -sphinx-rtd-theme>=0.5.1 \ No newline at end of file +sphinx-rtd-theme>=0.5.1 +sphinx-toolbox>=3.5.0 \ No newline at end of file diff --git a/doc/services/images/v2/images.rst b/doc/services/images/v2/images.rst index d01af019..04df1b0c 100644 --- a/doc/services/images/v2/images.rst +++ b/doc/services/images/v2/images.rst @@ -18,7 +18,7 @@ List images .. include:: /common/generators.rst List images sorted ------------ +------------------ Possible values for sort_key are: From dc8d9d67b422129a0a1c9cd12db881bad64c8172 Mon Sep 17 00:00:00 2001 From: Konstantin Babushkin Date: Wed, 17 Jan 2024 18:57:08 +0100 Subject: [PATCH 12/50] add collapsible auth code --- doc/_exts/samples.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/doc/_exts/samples.py b/doc/_exts/samples.py index ed50b764..b3728a82 100644 --- a/doc/_exts/samples.py +++ b/doc/_exts/samples.py @@ -23,8 +23,13 @@ def run(self): main_str = re.sub(pattern, "", string, 0, re.S).strip() return [ - CollapseNode(nodes.literal_block(auth_str, auth_str, language="php"), "show auth code"), - nodes.literal_block(main_str, main_str, language="php")] + CollapseNode( + "", + "show auth code", + nodes.literal_block(auth_str, auth_str, language="php") + ), + nodes.literal_block(main_str, main_str, language="php") + ] def setup(app): From 34b838e2f28ac53dd5f89f714205a63bd563bd96 Mon Sep 17 00:00:00 2001 From: Konstantin Babushkin Date: Wed, 17 Jan 2024 19:32:16 +0100 Subject: [PATCH 13/50] add collapsible auth code --- doc/_exts/samples.py | 1 + doc/_static/css/custom.css | 3 +++ doc/conf.py | 7 +++++++ 3 files changed, 11 insertions(+) create mode 100644 doc/_static/css/custom.css diff --git a/doc/_exts/samples.py b/doc/_exts/samples.py index b3728a82..20c8504d 100644 --- a/doc/_exts/samples.py +++ b/doc/_exts/samples.py @@ -26,6 +26,7 @@ def run(self): CollapseNode( "", "show auth code", + nodes.literal_block("This is example", "This is example"), nodes.literal_block(auth_str, auth_str, language="php") ), nodes.literal_block(main_str, main_str, language="php") diff --git a/doc/_static/css/custom.css b/doc/_static/css/custom.css new file mode 100644 index 00000000..7e72ee0b --- /dev/null +++ b/doc/_static/css/custom.css @@ -0,0 +1,3 @@ +summary { + cursor: pointer; +} \ No newline at end of file diff --git a/doc/conf.py b/doc/conf.py index 502106f4..9eeb9c88 100755 --- a/doc/conf.py +++ b/doc/conf.py @@ -46,6 +46,13 @@ # Output file base name for HTML help builder. htmlhelp_basename = 'php-openclouddoc' +# These folders are copied to the documentation's HTML output +html_static_path = ['_static'] + +html_css_files = [ + 'css/custom.css', +] + latex_documents = [ ('index', 'php-opencloud.tex', u'php-opencloud Documentation', u'Jamie Hannaford', 'manual'), From 074efe4ff803b05f7d931e3f38ad78aa319dea72 Mon Sep 17 00:00:00 2001 From: Konstantin Babushkin Date: Wed, 17 Jan 2024 23:02:21 +0100 Subject: [PATCH 14/50] add collapsible auth code --- doc/_exts/samples.py | 22 +++++++++++++-- doc/index.rst | 3 +- doc/install.rst | 35 +++++++++++++++++++++++ doc/{quick-start.rst => use.rst} | 48 +++++--------------------------- 4 files changed, 63 insertions(+), 45 deletions(-) create mode 100644 doc/install.rst rename doc/{quick-start.rst => use.rst} (55%) diff --git a/doc/_exts/samples.py b/doc/_exts/samples.py index 20c8504d..18eebb39 100644 --- a/doc/_exts/samples.py +++ b/doc/_exts/samples.py @@ -1,5 +1,6 @@ from docutils import nodes from sphinx.directives.code import LiteralInclude +from sphinx.util.nodes import make_refnode from sphinx_toolbox.collapse import CollapseNode import re @@ -22,11 +23,26 @@ def run(self): auth_str = match.group(1).strip() main_str = re.sub(pattern, "", string, 0, re.S).strip() + env = self.state.document.settings.env + ref_node = make_refnode( + env.app.builder, + fromdocname=env.docname, + todocname='use', + targetid='', + child=nodes.Text('Use OpenStack library') + ) + return [ CollapseNode( - "", - "show auth code", - nodes.literal_block("This is example", "This is example"), + '', + 'show auth code', + nodes.paragraph( + '', + '', + nodes.Text('Example of how to create OpenStack object. See '), + ref_node, + nodes.Text(' for all options.') + ), nodes.literal_block(auth_str, auth_str, language="php") ), nodes.literal_block(main_str, main_str, language="php") diff --git a/doc/index.rst b/doc/index.rst index a8e1f236..58867d43 100644 --- a/doc/index.rst +++ b/doc/index.rst @@ -9,7 +9,8 @@ This binding is specifically designed for OpenStack APIs, but other provider SDK Multiple OpenStack services, and versions of services, are supported. .. toctree:: - quick-start + install + use Supported services ------------------ diff --git a/doc/install.rst b/doc/install.rst new file mode 100644 index 00000000..edca2d95 --- /dev/null +++ b/doc/install.rst @@ -0,0 +1,35 @@ +Quick Start +=========== + +Requirements +------------ + +* PHP >= 7, < 9 +* cURL extension + +Installation +------------ + +You must install this library through Composer: + +.. code-block:: bash + + composer require php-opencloud/openstack + +If you do not have Composer installed, please read the `Composer installation instructions`_. + +Include the autoloader +---------------------- + +Once you have installed the SDK as a dependency of your project, you will need to load Composer’s autoloader +(which registers all the required namespaces). To do this, place the following line of PHP code at the top of your +application’s PHP files: + +.. code-block:: php + + require 'vendor/autoload.php'; + +This assumes your application's PHP files are located in the same folder as ``vendor/``. If your files are located +elsewhere, please supply the path to vendor/autoload.php in the require statement above. + +.. _Composer installation instructions: https://getcomposer.org/doc/00-intro.md diff --git a/doc/quick-start.rst b/doc/use.rst similarity index 55% rename from doc/quick-start.rst rename to doc/use.rst index fbcad26a..491f2d73 100644 --- a/doc/quick-start.rst +++ b/doc/use.rst @@ -1,49 +1,17 @@ -Quick start -=========== +Use OpenStack library +===================== -Requirements ------------- - -* PHP >= 7, < 9 -* cURL extension - -Installation ------------- - -You must install this library through Composer: - -.. code-block:: bash - - composer require php-opencloud/openstack - -If you do not have Composer installed, please read the `Composer installation instructions`_. - -Include the autoloader ----------------------- - -Once you have installed the SDK as a dependency of your project, you will need to load Composer’s autoloader -(which registers all the required namespaces). To do this, place the following line of PHP code at the top of your -application’s PHP files: - -.. code-block:: php - - require 'vendor/autoload.php'; - -This assumes your application's PHP files are located in the same folder as ``vendor/``. If your files are located -elsewhere, please supply the path to vendor/autoload.php in the require statement above. - -Creating a client ------------------ - -To create a client, you will need to provide the following information: +In order to access services you have to create the client object. To do it, you will need to provide the +following information: * The identity service URL (``authUrl``) * The region in which you want to operate (``region``) * The credentials of the user you want to authenticate: ``user``, ``tokenId``, ``cachedToken`` or ``application_credential`` -Only the ``authUrl`` is mandatory to create a client. But you will have to provide the ``region`` and ``user`` -to each service you create. So it is recommended to provide them when creating the client. +Only the ``authUrl`` is mandatory to create the client. But you will have to provide the ``region`` and user +credentials to each service you create. So it is recommended to provide them when creating the client which +would propagate these options to each service. There are different ways to provide the authentication credentials. See the :doc:`services/identity/v3/tokens` section for the full list of options. You should provide credentials to the `OpenStack` constructor as an array @@ -92,5 +60,3 @@ You can specify the scope of the token: ], ], ]); - -.. _Composer installation instructions: https://getcomposer.org/doc/00-intro.md From 6e851df559cf03b2a7680388e66aa6d0a0a6b224 Mon Sep 17 00:00:00 2001 From: Konstantin Babushkin Date: Wed, 17 Jan 2024 23:07:22 +0100 Subject: [PATCH 15/50] fix styling --- doc/_exts/samples.py | 2 +- doc/_static/css/custom.css | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/_exts/samples.py b/doc/_exts/samples.py index 18eebb39..d3e3b116 100644 --- a/doc/_exts/samples.py +++ b/doc/_exts/samples.py @@ -35,7 +35,7 @@ def run(self): return [ CollapseNode( '', - 'show auth code', + 'show full code', nodes.paragraph( '', '', diff --git a/doc/_static/css/custom.css b/doc/_static/css/custom.css index 7e72ee0b..33e75d96 100644 --- a/doc/_static/css/custom.css +++ b/doc/_static/css/custom.css @@ -1,3 +1,4 @@ summary { + margin-bottom: 1rem; cursor: pointer; } \ No newline at end of file From b545ad3b07e59b95671d4fcd3d4a6a46a785d6ae Mon Sep 17 00:00:00 2001 From: Konstantin Babushkin Date: Wed, 17 Jan 2024 23:11:13 +0100 Subject: [PATCH 16/50] typo --- doc/_exts/samples.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/_exts/samples.py b/doc/_exts/samples.py index d3e3b116..35d0d681 100644 --- a/doc/_exts/samples.py +++ b/doc/_exts/samples.py @@ -39,7 +39,7 @@ def run(self): nodes.paragraph( '', '', - nodes.Text('Example of how to create OpenStack object. See '), + nodes.Text('Example on how to create OpenStack object. See '), ref_node, nodes.Text(' for all options.') ), From d23c1e4138f3466e8a3c620fd6b7996f56bfff2c Mon Sep 17 00:00:00 2001 From: Konstantin Babushkin Date: Thu, 18 Jan 2024 08:02:59 +0100 Subject: [PATCH 17/50] add collapsible auth code --- doc/_exts/samples.py | 4 ++-- doc/index.rst | 2 +- doc/install.rst | 12 ++++++------ doc/services/identity/v3/application-credentials.rst | 12 ++++++------ doc/services/identity/v3/create.rst | 4 ++-- doc/{use.rst => setup.rst} | 6 +++--- 6 files changed, 20 insertions(+), 20 deletions(-) rename doc/{use.rst => setup.rst} (95%) diff --git a/doc/_exts/samples.py b/doc/_exts/samples.py index 35d0d681..92979bff 100644 --- a/doc/_exts/samples.py +++ b/doc/_exts/samples.py @@ -27,9 +27,9 @@ def run(self): ref_node = make_refnode( env.app.builder, fromdocname=env.docname, - todocname='use', + todocname='setup', targetid='', - child=nodes.Text('Use OpenStack library') + child=nodes.Text('Setup') ) return [ diff --git a/doc/index.rst b/doc/index.rst index 58867d43..9ee7c4db 100644 --- a/doc/index.rst +++ b/doc/index.rst @@ -10,7 +10,7 @@ Multiple OpenStack services, and versions of services, are supported. .. toctree:: install - use + setup Supported services ------------------ diff --git a/doc/install.rst b/doc/install.rst index edca2d95..fa2868e8 100644 --- a/doc/install.rst +++ b/doc/install.rst @@ -1,5 +1,5 @@ -Quick Start -=========== +Installation +============ Requirements ------------ @@ -7,8 +7,8 @@ Requirements * PHP >= 7, < 9 * cURL extension -Installation ------------- +Install via composer +-------------------- You must install this library through Composer: @@ -18,8 +18,8 @@ You must install this library through Composer: If you do not have Composer installed, please read the `Composer installation instructions`_. -Include the autoloader ----------------------- +Include autoloader +------------------ Once you have installed the SDK as a dependency of your project, you will need to load Composer’s autoloader (which registers all the required namespaces). To do this, place the following line of PHP code at the top of your diff --git a/doc/services/identity/v3/application-credentials.rst b/doc/services/identity/v3/application-credentials.rst index c45b393f..917c03b6 100644 --- a/doc/services/identity/v3/application-credentials.rst +++ b/doc/services/identity/v3/application-credentials.rst @@ -1,17 +1,17 @@ Application Credentials ======================= -Add application credential --------------------------- +Create +------ .. sample:: Identity/v3/application_credentials/add_application_credential.php -Show application credential details ------------------------------------ +Read +---- .. sample:: Identity/v3/application_credentials/show_application_credential.php -Delete application credential ------------------------------ +Delete +------ .. sample:: Identity/v3/application_credentials/delete_application_credential.php diff --git a/doc/services/identity/v3/create.rst b/doc/services/identity/v3/create.rst index 38adb151..5efd3a36 100644 --- a/doc/services/identity/v3/create.rst +++ b/doc/services/identity/v3/create.rst @@ -1,5 +1,5 @@ -Creating the service -==================== +Create Service +============== Service can be created via ``identityV3`` method of ``OpenStack`` object: diff --git a/doc/use.rst b/doc/setup.rst similarity index 95% rename from doc/use.rst rename to doc/setup.rst index 491f2d73..22357bdd 100644 --- a/doc/use.rst +++ b/doc/setup.rst @@ -1,5 +1,5 @@ -Use OpenStack library -===================== +Setup +===== In order to access services you have to create the client object. To do it, you will need to provide the following information: @@ -14,7 +14,7 @@ credentials to each service you create. So it is recommended to provide them whe would propagate these options to each service. There are different ways to provide the authentication credentials. See the :doc:`services/identity/v3/tokens` -section for the full list of options. You should provide credentials to the `OpenStack` constructor as an array +section for the full list of options. You should provide credentials to the ``OpenStack`` constructor as an array the same way you provide options to ``generateToken`` method of the ``Identity`` service. Here is an example of how to create a client with a user id and password: From 67a36de0492903736ebfe3d0b73016a77039feed Mon Sep 17 00:00:00 2001 From: Konstantin Babushkin Date: Thu, 18 Jan 2024 08:57:52 +0100 Subject: [PATCH 18/50] add collapsible auth code --- doc/_exts/samples.py | 2 +- doc/services/identity/v3/create.rst | 2 +- doc/services/identity/v3/tokens.rst | 6 ---- doc/setup.rst | 31 +++++++++++++++++++++ samples/Setup/application_credential_id.php | 12 ++++++++ samples/Setup/from_id.php | 9 ++++++ samples/Setup/scoped_to_project_id.php | 15 ++++++++++ samples/Setup/scoped_to_project_name.php | 20 +++++++++++++ samples/Setup/user_id.php | 21 ++++++++++++++ samples/Setup/username.php | 15 ++++++++++ 10 files changed, 125 insertions(+), 8 deletions(-) create mode 100644 samples/Setup/application_credential_id.php create mode 100644 samples/Setup/from_id.php create mode 100644 samples/Setup/scoped_to_project_id.php create mode 100644 samples/Setup/scoped_to_project_name.php create mode 100644 samples/Setup/user_id.php create mode 100644 samples/Setup/username.php diff --git a/doc/_exts/samples.py b/doc/_exts/samples.py index 92979bff..83439f3a 100644 --- a/doc/_exts/samples.py +++ b/doc/_exts/samples.py @@ -35,7 +35,7 @@ def run(self): return [ CollapseNode( '', - 'show full code', + 'auth code example', nodes.paragraph( '', '', diff --git a/doc/services/identity/v3/create.rst b/doc/services/identity/v3/create.rst index 5efd3a36..1101f36f 100644 --- a/doc/services/identity/v3/create.rst +++ b/doc/services/identity/v3/create.rst @@ -1,7 +1,7 @@ Create Service ============== -Service can be created via ``identityV3`` method of ``OpenStack`` object: +Service can be created via ``identityV3()`` method of ``OpenStack`` object: .. code-block:: php diff --git a/doc/services/identity/v3/tokens.rst b/doc/services/identity/v3/tokens.rst index 4802065a..ca10930a 100644 --- a/doc/services/identity/v3/tokens.rst +++ b/doc/services/identity/v3/tokens.rst @@ -1,12 +1,6 @@ Tokens ====== -Authenticate (generate) token ------------------------------ - -.. refdoc:: OpenStack/Identity/v3/Service.html#method_createService - - Generate token with user ID ~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/doc/setup.rst b/doc/setup.rst index 22357bdd..a1b11135 100644 --- a/doc/setup.rst +++ b/doc/setup.rst @@ -17,6 +17,37 @@ There are different ways to provide the authentication credentials. See the :doc section for the full list of options. You should provide credentials to the ``OpenStack`` constructor as an array the same way you provide options to ``generateToken`` method of the ``Identity`` service. +Authenticate with user ID +~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. sample:: Setup/user_id.php + +Authenticate with username +~~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. sample:: Setup/username.php + +Authenticate application credential ID +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. sample:: Setup/application_credential_id.php + +Generate token from ID +~~~~~~~~~~~~~~~~~~~~~~ + +.. sample:: Setup/from_id.php + +Generate token scoped to project ID +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. sample:: Identity/v3/tokens/generate_token_scoped_to_project_id.php + +Generate token scoped to project name +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. sample:: Identity/v3/tokens/generate_token_scoped_to_project_name.php + + Here is an example of how to create a client with a user id and password: .. code-block:: php diff --git a/samples/Setup/application_credential_id.php b/samples/Setup/application_credential_id.php new file mode 100644 index 00000000..64a6cd84 --- /dev/null +++ b/samples/Setup/application_credential_id.php @@ -0,0 +1,12 @@ + '{authUrl}', + 'region' => '{region}', + 'application_credential' => [ + 'id' => '{applicationCredentialId}', + 'secret' => '{secret}', + ], +]); \ No newline at end of file diff --git a/samples/Setup/from_id.php b/samples/Setup/from_id.php new file mode 100644 index 00000000..8727447f --- /dev/null +++ b/samples/Setup/from_id.php @@ -0,0 +1,9 @@ + '{authUrl}', + 'region' => '{region}', + 'tokenId' => '{tokenId}', +]); diff --git a/samples/Setup/scoped_to_project_id.php b/samples/Setup/scoped_to_project_id.php new file mode 100644 index 00000000..50035574 --- /dev/null +++ b/samples/Setup/scoped_to_project_id.php @@ -0,0 +1,15 @@ + '{authUrl}', + 'region' => '{region}', + 'user' => [ + 'id' => '{userId}', + 'password' => '{password}', + ], + 'scope' => [ + 'project' => ['id' => '{projectId}'], + ], +]); diff --git a/samples/Setup/scoped_to_project_name.php b/samples/Setup/scoped_to_project_name.php new file mode 100644 index 00000000..6b681609 --- /dev/null +++ b/samples/Setup/scoped_to_project_name.php @@ -0,0 +1,20 @@ + '{authUrl}', + 'region' => '{region}', + 'user' => [ + 'id' => '{userId}', + 'password' => '{password}' + ], + 'scope' => [ + 'project' => [ + 'name' => '{projectName}', + 'domain' => [ + 'id' => '{domainId}' + ] + ] + ] +]); \ No newline at end of file diff --git a/samples/Setup/user_id.php b/samples/Setup/user_id.php new file mode 100644 index 00000000..70e7dd64 --- /dev/null +++ b/samples/Setup/user_id.php @@ -0,0 +1,21 @@ + '{authUrl}', + 'region' => '{region}', + 'user' => [ + 'id' => '{userId}', + 'password' => '{password}' + ] +]); + +$identity = $openstack->identityV3(); + +$token = $identity->generateToken([ + 'user' => [ + 'id' => '{userId}', + 'password' => '{password}' + ] +]); diff --git a/samples/Setup/username.php b/samples/Setup/username.php new file mode 100644 index 00000000..83458a00 --- /dev/null +++ b/samples/Setup/username.php @@ -0,0 +1,15 @@ + '{authUrl}', + 'region' => '{region}', + 'user' => [ + 'name' => '{username}', + 'password' => '{password}', + 'domain' => [ + 'id' => '{domainId}' + ] + ] +]); \ No newline at end of file From 3971434f934a0c57be82510b0b5e2869e085484f Mon Sep 17 00:00:00 2001 From: Konstantin Babushkin Date: Thu, 18 Jan 2024 09:09:08 +0100 Subject: [PATCH 19/50] fix docs --- doc/services/identity/v3/application-credentials.rst | 10 ++++++++++ doc/services/identity/v3/create.rst | 6 +++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/doc/services/identity/v3/application-credentials.rst b/doc/services/identity/v3/application-credentials.rst index 917c03b6..433414dd 100644 --- a/doc/services/identity/v3/application-credentials.rst +++ b/doc/services/identity/v3/application-credentials.rst @@ -1,6 +1,16 @@ Application Credentials ======================= +Application credentials provide a way to delegate a user’s authorization to an application without sharing the user’s +password authentication. This is a useful security measure, especially for situations where the user’s identification +is provided by an external source, such as LDAP or a single-sign-on service. Instead of storing user passwords in +config files, a user creates an application credential for a specific project, with all or a subset of the role assignments +they have on that project, and then stores the application credential identifier and secret in the config file. + +See the `Official documentation `_ + +You must :doc:`create the service ` first to use this resource. + Create ------ diff --git a/doc/services/identity/v3/create.rst b/doc/services/identity/v3/create.rst index 1101f36f..5cbc18eb 100644 --- a/doc/services/identity/v3/create.rst +++ b/doc/services/identity/v3/create.rst @@ -1,14 +1,14 @@ Create Service ============== -Service can be created via ``identityV3()`` method of ``OpenStack`` object: +Service can be created via ``identityV3()`` method of the ``OpenStack`` object: .. code-block:: php - $service = $openstack->identityV3(); + $identity = $openstack->identityV3(); A list of additional options can be passed to the method. For example, to change the region: .. code-block:: php - $service = $openstack->identityV3(['region' => '{region}']); + $identity = $openstack->identityV3(['region' => '{region}']); From 200360e2143dfc6cfed4f33be31770c63dbb3013 Mon Sep 17 00:00:00 2001 From: Konstantin Babushkin Date: Thu, 18 Jan 2024 09:11:33 +0100 Subject: [PATCH 20/50] fix docs --- doc/services/identity/v3/application-credentials.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/services/identity/v3/application-credentials.rst b/doc/services/identity/v3/application-credentials.rst index 433414dd..b6f781f2 100644 --- a/doc/services/identity/v3/application-credentials.rst +++ b/doc/services/identity/v3/application-credentials.rst @@ -7,9 +7,9 @@ is provided by an external source, such as LDAP or a single-sign-on service. Ins config files, a user creates an application credential for a specific project, with all or a subset of the role assignments they have on that project, and then stores the application credential identifier and secret in the config file. -See the `Official documentation `_ +More information can be found in the `official documentation `_. -You must :doc:`create the service ` first to use this resource. +You must :doc:`create the service `_ first to use this resource. Create ------ From a8da1e0f7d3d4b959ea342c75f939f108bab9681 Mon Sep 17 00:00:00 2001 From: Konstantin Babushkin Date: Thu, 18 Jan 2024 09:16:47 +0100 Subject: [PATCH 21/50] fix docs --- doc/services/identity/v3/application-credentials.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/services/identity/v3/application-credentials.rst b/doc/services/identity/v3/application-credentials.rst index b6f781f2..3bc54cb2 100644 --- a/doc/services/identity/v3/application-credentials.rst +++ b/doc/services/identity/v3/application-credentials.rst @@ -9,7 +9,7 @@ they have on that project, and then stores the application credential identifier More information can be found in the `official documentation `_. -You must :doc:`create the service `_ first to use this resource. +In order to work with application credentials you have to :doc:`create the service `_ first. Create ------ From 8b2f4e61033182f03b0153b9546cb509cacdad9c Mon Sep 17 00:00:00 2001 From: Konstantin Babushkin Date: Thu, 18 Jan 2024 09:18:15 +0100 Subject: [PATCH 22/50] remove code example --- doc/_exts/samples.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/doc/_exts/samples.py b/doc/_exts/samples.py index 83439f3a..14cc1393 100644 --- a/doc/_exts/samples.py +++ b/doc/_exts/samples.py @@ -32,7 +32,7 @@ def run(self): child=nodes.Text('Setup') ) - return [ + """" CollapseNode( '', 'auth code example', @@ -45,6 +45,9 @@ def run(self): ), nodes.literal_block(auth_str, auth_str, language="php") ), + """ + + return [ nodes.literal_block(main_str, main_str, language="php") ] From e2da944fe21b53890b647171a41ebeba5b7dad6b Mon Sep 17 00:00:00 2001 From: Konstantin Babushkin Date: Thu, 18 Jan 2024 09:25:52 +0100 Subject: [PATCH 23/50] testing docs --- doc/services/identity/v3/create.rst | 12 ++++++------ doc/services/identity/v3/index.rst | 19 ++++++++++++++++++- samples/Identity/v3/create.php | 14 ++++++++++++++ samples/Identity/v3/create_with_region.php | 14 ++++++++++++++ 4 files changed, 52 insertions(+), 7 deletions(-) create mode 100644 samples/Identity/v3/create.php create mode 100644 samples/Identity/v3/create_with_region.php diff --git a/doc/services/identity/v3/create.rst b/doc/services/identity/v3/create.rst index 5cbc18eb..c6598ab8 100644 --- a/doc/services/identity/v3/create.rst +++ b/doc/services/identity/v3/create.rst @@ -1,14 +1,14 @@ Create Service ============== -Service can be created via ``identityV3()`` method of the ``OpenStack`` object: +OpenStack Identity API v3. It is used to manage the `OpenStack Keystone service `_. + +More information can be found in the `official documentation `_. -.. code-block:: php +Service can be created via ``identityV3()`` method of the ``OpenStack`` object: - $identity = $openstack->identityV3(); +.. sample:: Identity/v3/create.php A list of additional options can be passed to the method. For example, to change the region: -.. code-block:: php - - $identity = $openstack->identityV3(['region' => '{region}']); +.. sample:: Identity/v3/create_with_region.php diff --git a/doc/services/identity/v3/index.rst b/doc/services/identity/v3/index.rst index df78f886..9a991969 100644 --- a/doc/services/identity/v3/index.rst +++ b/doc/services/identity/v3/index.rst @@ -1,10 +1,27 @@ Identity v3 =========== +OpenStack Identity API v3. It is used to manage the `OpenStack Keystone service `_. + +More information can be found in the `official documentation `_. + +Create Service +============== + +Service can be created via ``identityV3()`` method of the ``OpenStack`` object: + +.. sample:: Identity/v3/create.php + +A list of additional options can be passed to the method. For example, to change the region: + +.. sample:: Identity/v3/create_with_region.php + +Resources +========= + .. toctree:: :maxdepth: 3 - create application-credentials credentials domains diff --git a/samples/Identity/v3/create.php b/samples/Identity/v3/create.php new file mode 100644 index 00000000..90da3ffb --- /dev/null +++ b/samples/Identity/v3/create.php @@ -0,0 +1,14 @@ + '{authUrl}', + 'region' => '{region}', + 'user' => [ + 'id' => '{userId}', + 'password' => '{password}' + ], +]); + +$identity = $openstack->identityV3(['region' => '{region}']); \ No newline at end of file diff --git a/samples/Identity/v3/create_with_region.php b/samples/Identity/v3/create_with_region.php new file mode 100644 index 00000000..276938ab --- /dev/null +++ b/samples/Identity/v3/create_with_region.php @@ -0,0 +1,14 @@ + '{authUrl}', + 'region' => '{region}', + 'user' => [ + 'id' => '{userId}', + 'password' => '{password}' + ], +]); + +$identity = $openstack->identityV3(); \ No newline at end of file From 51e45c71036f70e7fbb243346bfed649fa603b9e Mon Sep 17 00:00:00 2001 From: Konstantin Babushkin Date: Thu, 18 Jan 2024 09:29:48 +0100 Subject: [PATCH 24/50] testing docs --- doc/index.rst | 2 +- doc/services/identity/v3/index.rst | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/index.rst b/doc/index.rst index 9ee7c4db..ae2b0009 100644 --- a/doc/index.rst +++ b/doc/index.rst @@ -17,7 +17,7 @@ Supported services .. toctree:: :glob: - :maxdepth: 1 + :maxdepth: 0 services/**/index diff --git a/doc/services/identity/v3/index.rst b/doc/services/identity/v3/index.rst index 9a991969..40b0414d 100644 --- a/doc/services/identity/v3/index.rst +++ b/doc/services/identity/v3/index.rst @@ -20,7 +20,7 @@ Resources ========= .. toctree:: - :maxdepth: 3 + :maxdepth: 2 application-credentials credentials From 0f00809f09fb462a1afed17ab8b3c44414d3b4ed Mon Sep 17 00:00:00 2001 From: Konstantin Babushkin Date: Thu, 18 Jan 2024 09:33:18 +0100 Subject: [PATCH 25/50] testing docs --- .../identity/v3/application-credentials.rst | 2 +- doc/services/identity/v3/create.rst | 6 ++---- doc/services/identity/v3/index.rst | 14 ++------------ 3 files changed, 5 insertions(+), 17 deletions(-) diff --git a/doc/services/identity/v3/application-credentials.rst b/doc/services/identity/v3/application-credentials.rst index 3bc54cb2..4fd81e54 100644 --- a/doc/services/identity/v3/application-credentials.rst +++ b/doc/services/identity/v3/application-credentials.rst @@ -9,7 +9,7 @@ they have on that project, and then stores the application credential identifier More information can be found in the `official documentation `_. -In order to work with application credentials you have to :doc:`create the service `_ first. +In order to work with application credentials you have to :doc:`create the service `_ first. Create ------ diff --git a/doc/services/identity/v3/create.rst b/doc/services/identity/v3/create.rst index c6598ab8..110897e4 100644 --- a/doc/services/identity/v3/create.rst +++ b/doc/services/identity/v3/create.rst @@ -1,10 +1,6 @@ Create Service ============== -OpenStack Identity API v3. It is used to manage the `OpenStack Keystone service `_. - -More information can be found in the `official documentation `_. - Service can be created via ``identityV3()`` method of the ``OpenStack`` object: .. sample:: Identity/v3/create.php @@ -12,3 +8,5 @@ Service can be created via ``identityV3()`` method of the ``OpenStack`` object: A list of additional options can be passed to the method. For example, to change the region: .. sample:: Identity/v3/create_with_region.php + +See :doc:`/setup`_ for list of available authentication options. \ No newline at end of file diff --git a/doc/services/identity/v3/index.rst b/doc/services/identity/v3/index.rst index 40b0414d..1c89b2d7 100644 --- a/doc/services/identity/v3/index.rst +++ b/doc/services/identity/v3/index.rst @@ -5,23 +5,13 @@ OpenStack Identity API v3. It is used to manage the `OpenStack Keystone service More information can be found in the `official documentation `_. -Create Service -============== - -Service can be created via ``identityV3()`` method of the ``OpenStack`` object: - -.. sample:: Identity/v3/create.php - -A list of additional options can be passed to the method. For example, to change the region: - -.. sample:: Identity/v3/create_with_region.php - Resources ========= .. toctree:: - :maxdepth: 2 + :maxdepth: 3 + create application-credentials credentials domains From 42877761055c96cc97007a2ab77f7895421a1a5a Mon Sep 17 00:00:00 2001 From: Konstantin Babushkin Date: Thu, 18 Jan 2024 09:41:24 +0100 Subject: [PATCH 26/50] testing docs --- .../identity/v3/application-credentials.rst | 2 +- doc/services/identity/v3/create.rst | 6 +- doc/services/identity/v3/index.rst | 5 ++ doc/setup.rst | 61 +++---------------- samples/Identity/v3/create.php | 2 +- samples/Identity/v3/create_with_region.php | 2 +- samples/Setup/user_id.php | 11 +--- 7 files changed, 20 insertions(+), 69 deletions(-) diff --git a/doc/services/identity/v3/application-credentials.rst b/doc/services/identity/v3/application-credentials.rst index 4fd81e54..dd279983 100644 --- a/doc/services/identity/v3/application-credentials.rst +++ b/doc/services/identity/v3/application-credentials.rst @@ -9,7 +9,7 @@ they have on that project, and then stores the application credential identifier More information can be found in the `official documentation `_. -In order to work with application credentials you have to :doc:`create the service `_ first. +In order to work with application credentials you have to :doc:`create the service ` first. Create ------ diff --git a/doc/services/identity/v3/create.rst b/doc/services/identity/v3/create.rst index 110897e4..b94864db 100644 --- a/doc/services/identity/v3/create.rst +++ b/doc/services/identity/v3/create.rst @@ -1,12 +1,12 @@ Create Service ============== -Service can be created via ``identityV3()`` method of the ``OpenStack`` object: +In order to work with the service you have to :doc:`setup the client ` first. + +Service can be created via ``identityV3()`` method of the ``OpenStack`` object. .. sample:: Identity/v3/create.php A list of additional options can be passed to the method. For example, to change the region: .. sample:: Identity/v3/create_with_region.php - -See :doc:`/setup`_ for list of available authentication options. \ No newline at end of file diff --git a/doc/services/identity/v3/index.rst b/doc/services/identity/v3/index.rst index 1c89b2d7..20106b32 100644 --- a/doc/services/identity/v3/index.rst +++ b/doc/services/identity/v3/index.rst @@ -5,6 +5,11 @@ OpenStack Identity API v3. It is used to manage the `OpenStack Keystone service More information can be found in the `official documentation `_. +.. toctree:: + :maxdepth: 3 + + create + Resources ========= diff --git a/doc/setup.rst b/doc/setup.rst index a1b11135..267b2547 100644 --- a/doc/setup.rst +++ b/doc/setup.rst @@ -32,62 +32,17 @@ Authenticate application credential ID .. sample:: Setup/application_credential_id.php -Generate token from ID -~~~~~~~~~~~~~~~~~~~~~~ +Authenticate from ID +~~~~~~~~~~~~~~~~~~~~ .. sample:: Setup/from_id.php -Generate token scoped to project ID -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Scope to project ID +~~~~~~~~~~~~~~~~~~~ -.. sample:: Identity/v3/tokens/generate_token_scoped_to_project_id.php +.. sample:: Setup/scoped_to_project_id.php -Generate token scoped to project name -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Scope to project name +~~~~~~~~~~~~~~~~~~~~~ -.. sample:: Identity/v3/tokens/generate_token_scoped_to_project_name.php - - -Here is an example of how to create a client with a user id and password: - -.. code-block:: php - - $openstack = new OpenStack\OpenStack([ - 'authUrl' => '{authUrl}', - 'region' => '{region}', - 'user' => [ - 'id' => '{userId}', - 'password' => '{password}' - ], - ]); - -Here is an example of how to create a client with application credentials: - -.. code-block:: php - - $openstack = new OpenStack\OpenStack([ - 'authUrl' => '{authUrl}', - 'region' => '{region}', - 'application_credential' => [ - 'id' => '{applicationCredentialId}', - 'secret' => '{secret}' - ] - ]); - -You can specify the scope of the token: - -.. code-block:: php - - $openstack = new OpenStack\OpenStack([ - 'authUrl' => '{authUrl}', - 'region' => '{region}', - 'user' => [ - 'id' => '{userId}', - 'password' => '{password}' - ], - 'scope' => [ - 'project' => [ - 'id' => '{projectId}' - ], - ], - ]); +.. sample:: Setup/scoped_to_project_name.php \ No newline at end of file diff --git a/samples/Identity/v3/create.php b/samples/Identity/v3/create.php index 90da3ffb..276938ab 100644 --- a/samples/Identity/v3/create.php +++ b/samples/Identity/v3/create.php @@ -11,4 +11,4 @@ ], ]); -$identity = $openstack->identityV3(['region' => '{region}']); \ No newline at end of file +$identity = $openstack->identityV3(); \ No newline at end of file diff --git a/samples/Identity/v3/create_with_region.php b/samples/Identity/v3/create_with_region.php index 276938ab..90da3ffb 100644 --- a/samples/Identity/v3/create_with_region.php +++ b/samples/Identity/v3/create_with_region.php @@ -11,4 +11,4 @@ ], ]); -$identity = $openstack->identityV3(); \ No newline at end of file +$identity = $openstack->identityV3(['region' => '{region}']); \ No newline at end of file diff --git a/samples/Setup/user_id.php b/samples/Setup/user_id.php index 70e7dd64..53948b51 100644 --- a/samples/Setup/user_id.php +++ b/samples/Setup/user_id.php @@ -9,13 +9,4 @@ 'id' => '{userId}', 'password' => '{password}' ] -]); - -$identity = $openstack->identityV3(); - -$token = $identity->generateToken([ - 'user' => [ - 'id' => '{userId}', - 'password' => '{password}' - ] -]); +]); \ No newline at end of file From 8e9c1b5ffe9f02e11eb52e80b340b116d0e5221b Mon Sep 17 00:00:00 2001 From: Konstantin Babushkin Date: Thu, 18 Jan 2024 09:44:03 +0100 Subject: [PATCH 27/50] testing docs --- doc/services/identity/v3/index.rst | 8 -------- 1 file changed, 8 deletions(-) diff --git a/doc/services/identity/v3/index.rst b/doc/services/identity/v3/index.rst index 20106b32..037473ed 100644 --- a/doc/services/identity/v3/index.rst +++ b/doc/services/identity/v3/index.rst @@ -5,14 +5,6 @@ OpenStack Identity API v3. It is used to manage the `OpenStack Keystone service More information can be found in the `official documentation `_. -.. toctree:: - :maxdepth: 3 - - create - -Resources -========= - .. toctree:: :maxdepth: 3 From b12a1a09aa7dfcf00408727ad909136c24ddb158 Mon Sep 17 00:00:00 2001 From: Konstantin Babushkin Date: Thu, 18 Jan 2024 09:46:21 +0100 Subject: [PATCH 28/50] show authentication samples --- doc/_exts/samples.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/_exts/samples.py b/doc/_exts/samples.py index 14cc1393..28124fbb 100644 --- a/doc/_exts/samples.py +++ b/doc/_exts/samples.py @@ -22,6 +22,8 @@ def run(self): auth_str = match.group(1).strip() main_str = re.sub(pattern, "", string, 0, re.S).strip() + if main_str == '': + return [code_block] env = self.state.document.settings.env ref_node = make_refnode( From 9cabf4c93ffac67386224f08b9ff1f49ce1b818b Mon Sep 17 00:00:00 2001 From: Konstantin Babushkin Date: Thu, 18 Jan 2024 09:46:58 +0100 Subject: [PATCH 29/50] fix link --- doc/services/identity/v3/application-credentials.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/services/identity/v3/application-credentials.rst b/doc/services/identity/v3/application-credentials.rst index dd279983..d963ec72 100644 --- a/doc/services/identity/v3/application-credentials.rst +++ b/doc/services/identity/v3/application-credentials.rst @@ -9,7 +9,7 @@ they have on that project, and then stores the application credential identifier More information can be found in the `official documentation `_. -In order to work with application credentials you have to :doc:`create the service ` first. +In order to work with application credentials you have to :doc:`create the service ` first. Create ------ From 92d48d25499959522c4dd2a7265688d1886654bc Mon Sep 17 00:00:00 2001 From: Konstantin Babushkin Date: Thu, 18 Jan 2024 11:14:48 +0100 Subject: [PATCH 30/50] credentials doc --- .../identity/v3/application-credentials.rst | 6 +-- doc/services/identity/v3/credentials.rst | 45 +++++++++---------- ..._application_credential.php => create.php} | 0 ..._application_credential.php => delete.php} | 0 ...ow_application_credential.php => read.php} | 0 .../credentials/{add_cred.php => create.php} | 3 +- .../{delete_cred.php => delete.php} | 3 +- .../credentials/{list_creds.php => list.php} | 3 +- .../v3/credentials/{get_cred.php => read.php} | 5 +-- .../{update_cred.php => update.php} | 9 ++-- .../Identity/v3/ApplicationCredentialTest.php | 16 +++---- 11 files changed, 42 insertions(+), 48 deletions(-) rename samples/Identity/v3/application_credentials/{add_application_credential.php => create.php} (100%) rename samples/Identity/v3/application_credentials/{delete_application_credential.php => delete.php} (100%) rename samples/Identity/v3/application_credentials/{show_application_credential.php => read.php} (100%) rename samples/Identity/v3/credentials/{add_cred.php => create.php} (77%) rename samples/Identity/v3/credentials/{delete_cred.php => delete.php} (72%) rename samples/Identity/v3/credentials/{list_creds.php => list.php} (75%) rename samples/Identity/v3/credentials/{get_cred.php => read.php} (60%) rename samples/Identity/v3/credentials/{update_cred.php => update.php} (53%) diff --git a/doc/services/identity/v3/application-credentials.rst b/doc/services/identity/v3/application-credentials.rst index d963ec72..85d82cc0 100644 --- a/doc/services/identity/v3/application-credentials.rst +++ b/doc/services/identity/v3/application-credentials.rst @@ -14,14 +14,14 @@ In order to work with application credentials you have to :doc:`create the servi Create ------ -.. sample:: Identity/v3/application_credentials/add_application_credential.php +.. sample:: Identity/v3/application_credentials/create.php Read ---- -.. sample:: Identity/v3/application_credentials/show_application_credential.php +.. sample:: Identity/v3/application_credentials/read.php Delete ------ -.. sample:: Identity/v3/application_credentials/delete_application_credential.php +.. sample:: Identity/v3/application_credentials/delete.php diff --git a/doc/services/identity/v3/credentials.rst b/doc/services/identity/v3/credentials.rst index 56a1e55e..c00e5f63 100644 --- a/doc/services/identity/v3/credentials.rst +++ b/doc/services/identity/v3/credentials.rst @@ -1,41 +1,40 @@ Credentials =========== -Add credential --------------- +In exchange for a set of authentication credentials that the user submits, the Identity service generates and returns +a token. A token represents the authenticated identity of a user and, optionally, grants authorization on a specific +project or domain. -Create a secret/access pair for use with ec2 style auth. This operation will generates a new set of credentials that -map the user/tenant pair. +More information can be found in the `official documentation `_. + +List +---- -.. sample:: Identity/v3/credentials/add_cred.php -.. refdoc:: OpenStack/Identity/v3/Service.html#method_createCredential +.. sample:: Identity/v3/credentials/list.php -List credentials ----------------- +Create +------ -List all credentials for a given user. +Create a secret/access pair for use with ec2 style auth. This operation will generates a new set of credentials that +map the user/tenant pair. -.. sample:: Identity/v3/credentials/list_creds.php -.. refdoc:: OpenStack/Identity/v3/Service.html#method_listCredentials +.. sample:: Identity/v3/credentials/create.php -Show credential details ------------------------ +Read +---- Retrieve a user's access/secret pair by the access key. -.. sample:: Identity/v3/credentials/get_cred.php -.. refdoc:: OpenStack/Identity/v3/Service.html#method_getCredential +.. sample:: Identity/v3/credentials/get.php -Update credential ------------------ +Update +------ -.. sample:: Identity/v3/credentials/update_cred.php -.. refdoc:: OpenStack/Identity/v3/Models/Credential.html#method_update +.. sample:: Identity/v3/credentials/update.php -Delete credential ------------------ +Delete +------ Delete a user's access/secret pair. -.. sample:: Identity/v3/credentials/delete_cred.php -.. refdoc:: OpenStack/Identity/v3/Models/Credential.html#method_delete +.. sample:: Identity/v3/credentials/delete.php diff --git a/samples/Identity/v3/application_credentials/add_application_credential.php b/samples/Identity/v3/application_credentials/create.php similarity index 100% rename from samples/Identity/v3/application_credentials/add_application_credential.php rename to samples/Identity/v3/application_credentials/create.php diff --git a/samples/Identity/v3/application_credentials/delete_application_credential.php b/samples/Identity/v3/application_credentials/delete.php similarity index 100% rename from samples/Identity/v3/application_credentials/delete_application_credential.php rename to samples/Identity/v3/application_credentials/delete.php diff --git a/samples/Identity/v3/application_credentials/show_application_credential.php b/samples/Identity/v3/application_credentials/read.php similarity index 100% rename from samples/Identity/v3/application_credentials/show_application_credential.php rename to samples/Identity/v3/application_credentials/read.php diff --git a/samples/Identity/v3/credentials/add_cred.php b/samples/Identity/v3/credentials/create.php similarity index 77% rename from samples/Identity/v3/credentials/add_cred.php rename to samples/Identity/v3/credentials/create.php index 76563879..339f5d8b 100644 --- a/samples/Identity/v3/credentials/add_cred.php +++ b/samples/Identity/v3/credentials/create.php @@ -9,10 +9,9 @@ 'id' => '{userId}', 'password' => '{password}' ], - 'scope' => ['project' => ['id' => '{projectId}']] ]); -$identity = $openstack->identityV3(['region' => '{region}']); +$identity = $openstack->identityV3(); $credential = $identity->createCredential([ 'blob' => '{blob}', diff --git a/samples/Identity/v3/credentials/delete_cred.php b/samples/Identity/v3/credentials/delete.php similarity index 72% rename from samples/Identity/v3/credentials/delete_cred.php rename to samples/Identity/v3/credentials/delete.php index 6b5bfef3..09b6fe43 100644 --- a/samples/Identity/v3/credentials/delete_cred.php +++ b/samples/Identity/v3/credentials/delete.php @@ -9,10 +9,9 @@ 'id' => '{userId}', 'password' => '{password}' ], - 'scope' => ['project' => ['id' => '{projectId}']] ]); -$identity = $openstack->identityV3(['region' => '{region}']); +$identity = $openstack->identityV3(); $credential = $identity->getCredential('credentialId'); $credential->delete(); diff --git a/samples/Identity/v3/credentials/list_creds.php b/samples/Identity/v3/credentials/list.php similarity index 75% rename from samples/Identity/v3/credentials/list_creds.php rename to samples/Identity/v3/credentials/list.php index 6ed4a38e..8f8041f9 100644 --- a/samples/Identity/v3/credentials/list_creds.php +++ b/samples/Identity/v3/credentials/list.php @@ -9,10 +9,9 @@ 'id' => '{userId}', 'password' => '{password}' ], - 'scope' => ['project' => ['id' => '{projectId}']] ]); -$identity = $openstack->identityV3(['region' => '{region}']); +$identity = $openstack->identityV3(); foreach ($identity->listCredentials() as $credential) { /** @var $credential \OpenStack\Identity\v3\Models\Credential */ diff --git a/samples/Identity/v3/credentials/get_cred.php b/samples/Identity/v3/credentials/read.php similarity index 60% rename from samples/Identity/v3/credentials/get_cred.php rename to samples/Identity/v3/credentials/read.php index b06ba11c..c03e8de0 100644 --- a/samples/Identity/v3/credentials/get_cred.php +++ b/samples/Identity/v3/credentials/read.php @@ -9,10 +9,9 @@ 'id' => '{userId}', 'password' => '{password}' ], - 'scope' => ['project' => ['id' => '{projectId}']] ]); -$identity = $openstack->identityV3(['region' => '{region}']); +$identity = $openstack->identityV3(); -$credential = $identity->getCredential('credentialId'); +$credential = $identity->getCredential('{credentialId}'); $credential->retrieve(); diff --git a/samples/Identity/v3/credentials/update_cred.php b/samples/Identity/v3/credentials/update.php similarity index 53% rename from samples/Identity/v3/credentials/update_cred.php rename to samples/Identity/v3/credentials/update.php index e8fa51b3..c0b603f4 100644 --- a/samples/Identity/v3/credentials/update_cred.php +++ b/samples/Identity/v3/credentials/update.php @@ -9,14 +9,13 @@ 'id' => '{userId}', 'password' => '{password}' ], - 'scope' => ['project' => ['id' => '{projectId}']] ]); -$identity = $openstack->identityV3(['region' => '{region}']); +$identity = $openstack->identityV3(); -$credential = $identity->getCredential('credentialId'); +$credential = $identity->getCredential('{credentialId}'); -$credential->type = 'foo'; -$credential->blob = 'bar'; +$credential->type = '{type}'; +$credential->blob = '{blob}'; $credential->update(); diff --git a/tests/sample/Identity/v3/ApplicationCredentialTest.php b/tests/sample/Identity/v3/ApplicationCredentialTest.php index 42be5d25..a93f715a 100644 --- a/tests/sample/Identity/v3/ApplicationCredentialTest.php +++ b/tests/sample/Identity/v3/ApplicationCredentialTest.php @@ -8,14 +8,14 @@ class ApplicationCredentialTest extends TestCase { - public function testAdd(): ApplicationCredential + public function testCreate(): ApplicationCredential { $name = $this->randomStr(); $description = $this->randomStr(); /** @var $applicationCredential \OpenStack\Identity\v3\Models\ApplicationCredential */ require_once $this->sampleFile( - 'application_credentials/add_application_credential.php', + 'application_credentials/create.php', [ '{name}' => $name, '{description}' => $description, @@ -30,7 +30,7 @@ public function testAdd(): ApplicationCredential } /** - * @depends testAdd + * @depends testCreate */ public function testGenerateToken(ApplicationCredential $applicationCredential) { @@ -48,13 +48,13 @@ public function testGenerateToken(ApplicationCredential $applicationCredential) } /** - * @depends testAdd + * @depends testCreate */ - public function testRetrieve(ApplicationCredential $originalApplicationCredential) + public function testRead(ApplicationCredential $originalApplicationCredential) { /** @var $applicationCredential \OpenStack\Identity\v3\Models\ApplicationCredential */ require_once $this->sampleFile( - 'application_credentials/show_application_credential.php', + 'application_credentials/read.php', ['{applicationCredentialId}' => $originalApplicationCredential->id] ); @@ -64,7 +64,7 @@ public function testRetrieve(ApplicationCredential $originalApplicationCredentia } /** - * @depends testAdd + * @depends testCreate */ public function testDelete(ApplicationCredential $applicationCredential) { @@ -78,7 +78,7 @@ public function testDelete(ApplicationCredential $applicationCredential) $this->assertTrue($token->validate()); require_once $this->sampleFile( - 'application_credentials/delete_application_credential.php', + 'application_credentials/delete.php', [ '{applicationCredentialId}' => $applicationCredential->id, ] From ee326c7f88069db9efdd4da40bb1a13733c2d087 Mon Sep 17 00:00:00 2001 From: Konstantin Babushkin Date: Thu, 18 Jan 2024 12:04:35 +0100 Subject: [PATCH 31/50] - add osdoc - remove unused blocks in sample - add /common/service.rst --- doc/_exts/osdoc.py | 31 ++++++++++++ doc/_exts/samples.py | 27 ---------- doc/common/service.rst | 1 + .../identity/v3/application-credentials.rst | 4 +- doc/services/identity/v3/credentials.rst | 14 +++--- doc/services/identity/v3/domains.rst | 49 ++++++++----------- doc/services/identity/v3/endpoints.rst | 5 ++ .../Identity/v3/domains/check_group_role.php | 7 +-- .../Identity/v3/domains/check_user_role.php | 7 +-- .../v3/domains/{add_domain.php => create.php} | 7 +-- .../domains/{delete_domain.php => delete.php} | 7 +-- .../Identity/v3/domains/grant_group_role.php | 7 +-- .../Identity/v3/domains/grant_user_role.php | 7 +-- .../v3/domains/{list_domains.php => list.php} | 7 +-- .../Identity/v3/domains/list_group_roles.php | 7 +-- .../Identity/v3/domains/list_user_roles.php | 7 +-- .../v3/domains/{show_domain.php => read.php} | 7 +-- .../Identity/v3/domains/revoke_group_role.php | 7 +-- .../Identity/v3/domains/revoke_user_role.php | 7 +-- .../domains/{update_domain.php => update.php} | 7 +-- tests/sample/Identity/v3/DomainTest.php | 12 ++--- 21 files changed, 88 insertions(+), 146 deletions(-) create mode 100644 doc/_exts/osdoc.py create mode 100644 doc/common/service.rst rename samples/Identity/v3/domains/{add_domain.php => create.php} (71%) rename samples/Identity/v3/domains/{delete_domain.php => delete.php} (66%) rename samples/Identity/v3/domains/{list_domains.php => list.php} (69%) rename samples/Identity/v3/domains/{show_domain.php => read.php} (66%) rename samples/Identity/v3/domains/{update_domain.php => update.php} (68%) diff --git a/doc/_exts/osdoc.py b/doc/_exts/osdoc.py new file mode 100644 index 00000000..73d7f88c --- /dev/null +++ b/doc/_exts/osdoc.py @@ -0,0 +1,31 @@ +from docutils.parsers.rst import Directive +from docutils import nodes + + +class OsDoc(Directive): + required_arguments = 1 + has_content = True + + def run(self): + full_url = self.arguments[0] + title = 'official documentation' + + text = [] + text.extend([ + nodes.Text('More information can be found in the '), + nodes.reference(title, title, internal=False, refuri=self.arguments[0]), + nodes.Text('.') + ]) + + return [nodes.paragraph( + '', + '', + nodes.Text('More information can be found in the '), + nodes.reference(title, title, internal=False, refuri=full_url), + nodes.Text('.') + )] + + +def setup(app): + app.add_directive('osdoc', OsDoc) + return {'version': '0.1'} diff --git a/doc/_exts/samples.py b/doc/_exts/samples.py index 28124fbb..36e7348b 100644 --- a/doc/_exts/samples.py +++ b/doc/_exts/samples.py @@ -1,7 +1,5 @@ from docutils import nodes from sphinx.directives.code import LiteralInclude -from sphinx.util.nodes import make_refnode -from sphinx_toolbox.collapse import CollapseNode import re @@ -20,35 +18,10 @@ def run(self): if match is None: return [code_block] - auth_str = match.group(1).strip() main_str = re.sub(pattern, "", string, 0, re.S).strip() if main_str == '': return [code_block] - env = self.state.document.settings.env - ref_node = make_refnode( - env.app.builder, - fromdocname=env.docname, - todocname='setup', - targetid='', - child=nodes.Text('Setup') - ) - - """" - CollapseNode( - '', - 'auth code example', - nodes.paragraph( - '', - '', - nodes.Text('Example on how to create OpenStack object. See '), - ref_node, - nodes.Text(' for all options.') - ), - nodes.literal_block(auth_str, auth_str, language="php") - ), - """ - return [ nodes.literal_block(main_str, main_str, language="php") ] diff --git a/doc/common/service.rst b/doc/common/service.rst new file mode 100644 index 00000000..6d0479df --- /dev/null +++ b/doc/common/service.rst @@ -0,0 +1 @@ +In order to work with application credentials you have to :doc:`create the service ` first. \ No newline at end of file diff --git a/doc/services/identity/v3/application-credentials.rst b/doc/services/identity/v3/application-credentials.rst index 85d82cc0..45ad5583 100644 --- a/doc/services/identity/v3/application-credentials.rst +++ b/doc/services/identity/v3/application-credentials.rst @@ -7,7 +7,9 @@ is provided by an external source, such as LDAP or a single-sign-on service. Ins config files, a user creates an application credential for a specific project, with all or a subset of the role assignments they have on that project, and then stores the application credential identifier and secret in the config file. -More information can be found in the `official documentation `_. +.. osdoc:: https://docs.openstack.org/keystone/latest/user/application_credentials.html + +.. include:: /common/service.rst In order to work with application credentials you have to :doc:`create the service ` first. diff --git a/doc/services/identity/v3/credentials.rst b/doc/services/identity/v3/credentials.rst index c00e5f63..18e07f56 100644 --- a/doc/services/identity/v3/credentials.rst +++ b/doc/services/identity/v3/credentials.rst @@ -5,12 +5,9 @@ In exchange for a set of authentication credentials that the user submits, the I a token. A token represents the authenticated identity of a user and, optionally, grants authorization on a specific project or domain. -More information can be found in the `official documentation `_. +.. osdoc:: https://docs.openstack.org/api-ref/identity/v3/index.html#credentials -List ----- - -.. sample:: Identity/v3/credentials/list.php +In order to work with credentials you have to :doc:`create the service ` first. Create ------ @@ -25,7 +22,7 @@ Read Retrieve a user's access/secret pair by the access key. -.. sample:: Identity/v3/credentials/get.php +.. sample:: Identity/v3/credentials/read.php Update ------ @@ -38,3 +35,8 @@ Delete Delete a user's access/secret pair. .. sample:: Identity/v3/credentials/delete.php + +List +---- + +.. sample:: Identity/v3/credentials/list.php diff --git a/doc/services/identity/v3/domains.rst b/doc/services/identity/v3/domains.rst index 409059d9..1e2f359d 100644 --- a/doc/services/identity/v3/domains.rst +++ b/doc/services/identity/v3/domains.rst @@ -1,80 +1,73 @@ Domains ======= -Add domain ----------- +A domain is a collection of users, groups, and projects. Each group and project is owned by exactly one domain. -.. sample:: Identity/v3/domains/add_domain.php -.. refdoc:: OpenStack/Identity/v3/Service.html#method_createDomain +.. osdoc:: https://docs.openstack.org/keystone/latest/getting-started/architecture.html#domains -List domains ------------- +In order to work with domains you have to :doc:`create the service ` first. -.. sample:: Identity/v3/domains/list_domains.php -.. refdoc:: OpenStack/Identity/v3/Service.html#method_listDomains +Create +------ -Show domain details -------------------- +.. sample:: Identity/v3/domains/create.php -.. sample:: Identity/v3/domains/show_domain.php -.. refdoc:: OpenStack/Identity/v3/Service.html#method_getDomain +Read +---- -Update domain -------------- +.. sample:: Identity/v3/domains/read.php -.. sample:: Identity/v3/domains/update_domain.php -.. refdoc:: OpenStack/Identity/v3/Models/Domain.html#method_update +Update +------ -Delete domain -------------- +.. sample:: Identity/v3/domains/update.php -.. sample:: Identity/v3/domains/delete_domain.php -.. refdoc:: OpenStack/Identity/v3/Models/Domain.html#method_delete +Delete +------ + +.. sample:: Identity/v3/domains/delete.php + +List +---- + +.. sample:: Identity/v3/domains/list.php List roles for domain user -------------------------- .. sample:: Identity/v3/domains/list_user_roles.php -.. refdoc:: OpenStack/Identity/v3/Models/Domain.html#method_listUserRoles Grant role to domain user ------------------------- .. sample:: Identity/v3/domains/grant_user_role.php -.. refdoc:: OpenStack/Identity/v3/Models/Domain.html#method_grantUserRole Check role for domain user -------------------------- .. sample:: Identity/v3/domains/check_user_role.php -.. refdoc:: OpenStack/Identity/v3/Models/Domain.html#method_checkUserRole Revoke role for domain user --------------------------- .. sample:: Identity/v3/domains/revoke_user_role.php -.. refdoc:: OpenStack/Identity/v3/Models/Domain.html#method_revokeUserRole List roles for domain group --------------------------- .. sample:: Identity/v3/domains/list_group_roles.php -.. refdoc:: OpenStack/Identity/v3/Models/Domain.html#method_listGroupRoles Grant role to domain group -------------------------- .. sample:: Identity/v3/domains/grant_group_role.php -.. refdoc:: OpenStack/Identity/v3/Models/Domain.html#method_grantGroupRole Check role for domain group --------------------------- .. sample:: Identity/v3/domains/check_group_role.php -.. refdoc:: OpenStack/Identity/v3/Models/Domain.html#method_checkGroupRole Revoke role for domain group ---------------------------- .. sample:: Identity/v3/domains/revoke_group_role.php -.. refdoc:: OpenStack/Identity/v3/Models/Domain.html#method_revokeGroupRole diff --git a/doc/services/identity/v3/endpoints.rst b/doc/services/identity/v3/endpoints.rst index d5d99e6a..27178343 100644 --- a/doc/services/identity/v3/endpoints.rst +++ b/doc/services/identity/v3/endpoints.rst @@ -1,6 +1,11 @@ Endpoints ========= +Each service should have one or more related endpoints. An endpoint is essentially a base URL for +an API, along with some metadata about the endpoint itself and represents a set of URL endpoints for +OpenStack web services. + + Add endpoints ------------- diff --git a/samples/Identity/v3/domains/check_group_role.php b/samples/Identity/v3/domains/check_group_role.php index 1c96160d..50ca6dd6 100644 --- a/samples/Identity/v3/domains/check_group_role.php +++ b/samples/Identity/v3/domains/check_group_role.php @@ -9,14 +9,9 @@ 'id' => '{userId}', 'password' => '{password}' ], - 'scope' => [ - 'project' => [ - 'id' => '{projectId}' - ] - ] ]); -$identity = $openstack->identityV3(['region' => '{region}']); +$identity = $openstack->identityV3(); $domain = $identity->getDomain('{domainId}'); diff --git a/samples/Identity/v3/domains/check_user_role.php b/samples/Identity/v3/domains/check_user_role.php index 4f4b3152..e2bf4200 100644 --- a/samples/Identity/v3/domains/check_user_role.php +++ b/samples/Identity/v3/domains/check_user_role.php @@ -9,14 +9,9 @@ 'id' => '{userId}', 'password' => '{password}' ], - 'scope' => [ - 'project' => [ - 'id' => '{projectId}' - ] - ] ]); -$identity = $openstack->identityV3(['region' => '{region}']); +$identity = $openstack->identityV3(); $domain = $identity->getDomain('{domainId}'); diff --git a/samples/Identity/v3/domains/add_domain.php b/samples/Identity/v3/domains/create.php similarity index 71% rename from samples/Identity/v3/domains/add_domain.php rename to samples/Identity/v3/domains/create.php index bd8b5239..4ff25cfe 100644 --- a/samples/Identity/v3/domains/add_domain.php +++ b/samples/Identity/v3/domains/create.php @@ -9,14 +9,9 @@ 'id' => '{userId}', 'password' => '{password}' ], - 'scope' => [ - 'project' => [ - 'id' => '{projectId}' - ] - ] ]); -$identity = $openstack->identityV3(['region' => '{region}']); +$identity = $openstack->identityV3(); $domain = $identity->createDomain([ 'description' => '{description}', diff --git a/samples/Identity/v3/domains/delete_domain.php b/samples/Identity/v3/domains/delete.php similarity index 66% rename from samples/Identity/v3/domains/delete_domain.php rename to samples/Identity/v3/domains/delete.php index 590aa36d..fd99463b 100644 --- a/samples/Identity/v3/domains/delete_domain.php +++ b/samples/Identity/v3/domains/delete.php @@ -9,14 +9,9 @@ 'id' => '{userId}', 'password' => '{password}' ], - 'scope' => [ - 'project' => [ - 'id' => '{projectId}' - ] - ] ]); -$identity = $openstack->identityV3(['region' => '{region}']); +$identity = $openstack->identityV3(); $domain = $identity->getDomain('{domainId}'); $domain->delete(); diff --git a/samples/Identity/v3/domains/grant_group_role.php b/samples/Identity/v3/domains/grant_group_role.php index af1bc176..24f0e6b9 100644 --- a/samples/Identity/v3/domains/grant_group_role.php +++ b/samples/Identity/v3/domains/grant_group_role.php @@ -9,14 +9,9 @@ 'id' => '{userId}', 'password' => '{password}' ], - 'scope' => [ - 'project' => [ - 'id' => '{projectId}' - ] - ] ]); -$identity = $openstack->identityV3(['region' => '{region}']); +$identity = $openstack->identityV3(); $domain = $identity->getDomain('{domainId}'); diff --git a/samples/Identity/v3/domains/grant_user_role.php b/samples/Identity/v3/domains/grant_user_role.php index c305759e..65592911 100644 --- a/samples/Identity/v3/domains/grant_user_role.php +++ b/samples/Identity/v3/domains/grant_user_role.php @@ -9,14 +9,9 @@ 'id' => '{userId}', 'password' => '{password}' ], - 'scope' => [ - 'project' => [ - 'id' => '{projectId}' - ] - ] ]); -$identity = $openstack->identityV3(['region' => '{region}']); +$identity = $openstack->identityV3(); $domain = $identity->getDomain('{domainId}'); diff --git a/samples/Identity/v3/domains/list_domains.php b/samples/Identity/v3/domains/list.php similarity index 69% rename from samples/Identity/v3/domains/list_domains.php rename to samples/Identity/v3/domains/list.php index d08cc1c8..817c6b26 100644 --- a/samples/Identity/v3/domains/list_domains.php +++ b/samples/Identity/v3/domains/list.php @@ -9,14 +9,9 @@ 'id' => '{userId}', 'password' => '{password}' ], - 'scope' => [ - 'project' => [ - 'id' => '{projectId}' - ] - ] ]); -$identity = $openstack->identityV3(['region' => '{region}']); +$identity = $openstack->identityV3(); foreach ($identity->listDomains() as $domain) { /** @var $domain \OpenStack\Identity\v3\Models\Domain */ diff --git a/samples/Identity/v3/domains/list_group_roles.php b/samples/Identity/v3/domains/list_group_roles.php index 1b7b89c3..58a360ca 100644 --- a/samples/Identity/v3/domains/list_group_roles.php +++ b/samples/Identity/v3/domains/list_group_roles.php @@ -9,14 +9,9 @@ 'id' => '{userId}', 'password' => '{password}' ], - 'scope' => [ - 'project' => [ - 'id' => '{projectId}' - ] - ] ]); -$identity = $openstack->identityV3(['region' => '{region}']); +$identity = $openstack->identityV3(); $domain = $identity->getDomain('{domainId}'); diff --git a/samples/Identity/v3/domains/list_user_roles.php b/samples/Identity/v3/domains/list_user_roles.php index d9a7cfb1..c19d61f7 100644 --- a/samples/Identity/v3/domains/list_user_roles.php +++ b/samples/Identity/v3/domains/list_user_roles.php @@ -9,14 +9,9 @@ 'id' => '{userId}', 'password' => '{password}' ], - 'scope' => [ - 'project' => [ - 'id' => '{projectId}' - ] - ] ]); -$identity = $openstack->identityV3(['region' => '{region}']); +$identity = $openstack->identityV3(); $domain = $identity->getDomain('{domainId}'); diff --git a/samples/Identity/v3/domains/show_domain.php b/samples/Identity/v3/domains/read.php similarity index 66% rename from samples/Identity/v3/domains/show_domain.php rename to samples/Identity/v3/domains/read.php index c84b29d5..ebd9431e 100644 --- a/samples/Identity/v3/domains/show_domain.php +++ b/samples/Identity/v3/domains/read.php @@ -9,14 +9,9 @@ 'id' => '{userId}', 'password' => '{password}' ], - 'scope' => [ - 'project' => [ - 'id' => '{projectId}' - ] - ] ]); -$identity = $openstack->identityV3(['region' => '{region}']); +$identity = $openstack->identityV3(); $domain = $identity->getDomain('{domainId}'); $domain->retrieve(); diff --git a/samples/Identity/v3/domains/revoke_group_role.php b/samples/Identity/v3/domains/revoke_group_role.php index decb28fb..394834a2 100644 --- a/samples/Identity/v3/domains/revoke_group_role.php +++ b/samples/Identity/v3/domains/revoke_group_role.php @@ -9,14 +9,9 @@ 'id' => '{userId}', 'password' => '{password}' ], - 'scope' => [ - 'project' => [ - 'id' => '{projectId}' - ] - ] ]); -$identity = $openstack->identityV3(['region' => '{region}']); +$identity = $openstack->identityV3(); $domain = $identity->getDomain('{domainId}'); diff --git a/samples/Identity/v3/domains/revoke_user_role.php b/samples/Identity/v3/domains/revoke_user_role.php index fcc6ca93..c109927a 100644 --- a/samples/Identity/v3/domains/revoke_user_role.php +++ b/samples/Identity/v3/domains/revoke_user_role.php @@ -9,14 +9,9 @@ 'id' => '{userId}', 'password' => '{password}' ], - 'scope' => [ - 'project' => [ - 'id' => '{projectId}' - ] - ] ]); -$identity = $openstack->identityV3(['region' => '{region}']); +$identity = $openstack->identityV3(); $domain = $identity->getDomain('{domainId}'); diff --git a/samples/Identity/v3/domains/update_domain.php b/samples/Identity/v3/domains/update.php similarity index 68% rename from samples/Identity/v3/domains/update_domain.php rename to samples/Identity/v3/domains/update.php index 97208e19..b3633d9b 100644 --- a/samples/Identity/v3/domains/update_domain.php +++ b/samples/Identity/v3/domains/update.php @@ -9,14 +9,9 @@ 'id' => '{userId}', 'password' => '{password}' ], - 'scope' => [ - 'project' => [ - 'id' => '{projectId}' - ] - ] ]); -$identity = $openstack->identityV3(['region' => '{region}']); +$identity = $openstack->identityV3(); $domain = $identity->getDomain('{domainId}'); diff --git a/tests/sample/Identity/v3/DomainTest.php b/tests/sample/Identity/v3/DomainTest.php index d852f2ad..2c6b4dd6 100644 --- a/tests/sample/Identity/v3/DomainTest.php +++ b/tests/sample/Identity/v3/DomainTest.php @@ -14,7 +14,7 @@ public function testCreate(): Domain /** @var $domain \OpenStack\Identity\v3\Models\Domain */ require_once $this->sampleFile( - 'domains/add_domain.php', + 'domains/create.php', [ '{name}' => $name, '{description}' => $description, @@ -34,7 +34,7 @@ public function testList(Domain $createdDomain) { $found = false; require_once $this->sampleFile( - 'domains/list_domains.php', + 'domains/list.php', [ '/** @var $domain \OpenStack\Identity\v3\Models\Domain */' => <<<'PHP' /** @var $domain \OpenStack\Identity\v3\Models\Domain */ @@ -51,10 +51,10 @@ public function testList(Domain $createdDomain) /** * @depends testCreate */ - public function testShow(Domain $createdDomain) + public function testRead(Domain $createdDomain) { /** @var $domain \OpenStack\Identity\v3\Models\Domain */ - require_once $this->sampleFile('domains/show_domain.php', ['{domainId}' => $createdDomain->id]); + require_once $this->sampleFile('domains/read.php', ['{domainId}' => $createdDomain->id]); $this->assertInstanceOf(Domain::class, $domain); $this->assertEquals($createdDomain->id, $domain->id); $this->assertEquals($createdDomain->name, $domain->name); @@ -252,7 +252,7 @@ public function testRevokeUserRole(Domain $createdDomain, array $createdRoleAndU public function testUpdate(Domain $createdDomain) { $this->assertTrue($createdDomain->enabled); - require_once $this->sampleFile('domains/update_domain.php', ['{domainId}' => $createdDomain->id]); + require_once $this->sampleFile('domains/update.php', ['{domainId}' => $createdDomain->id]); $createdDomain->retrieve(); $this->assertFalse($createdDomain->enabled); } @@ -262,7 +262,7 @@ public function testUpdate(Domain $createdDomain) */ public function testDelete(Domain $createdDomain) { - require_once $this->sampleFile('domains/delete_domain.php', ['{domainId}' => $createdDomain->id]); + require_once $this->sampleFile('domains/delete.php', ['{domainId}' => $createdDomain->id]); $found = false; foreach ($this->getService()->listDomains() as $domain) { if ($domain->id === $createdDomain->id) { From a313d7c9b1711f005a9659ffe2faa8dbb698bb65 Mon Sep 17 00:00:00 2001 From: Konstantin Babushkin Date: Thu, 18 Jan 2024 12:09:40 +0100 Subject: [PATCH 32/50] fix osdoc --- doc/conf.py | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/conf.py b/doc/conf.py index 9eeb9c88..1c8818fc 100755 --- a/doc/conf.py +++ b/doc/conf.py @@ -26,6 +26,7 @@ extensions = [ 'samples', 'refdoc', + 'osdoc', 'sphinx.ext.autodoc', 'sphinx.ext.autosummary', 'sphinxcontrib.phpdomain', From 9cc49299aa8440d78eabeb515830fddc56e47565 Mon Sep 17 00:00:00 2001 From: Konstantin Babushkin Date: Thu, 18 Jan 2024 12:19:18 +0100 Subject: [PATCH 33/50] check include --- doc/common/service.rst | 2 +- doc/services/identity/v3/application-credentials.rst | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/doc/common/service.rst b/doc/common/service.rst index 6d0479df..ce86944a 100644 --- a/doc/common/service.rst +++ b/doc/common/service.rst @@ -1 +1 @@ -In order to work with application credentials you have to :doc:`create the service ` first. \ No newline at end of file +In order to work with |models| you have to :doc:`create the service ` first. \ No newline at end of file diff --git a/doc/services/identity/v3/application-credentials.rst b/doc/services/identity/v3/application-credentials.rst index 45ad5583..f2c81a6d 100644 --- a/doc/services/identity/v3/application-credentials.rst +++ b/doc/services/identity/v3/application-credentials.rst @@ -1,6 +1,8 @@ Application Credentials ======================= +.. |models| replace:: application credentials + Application credentials provide a way to delegate a user’s authorization to an application without sharing the user’s password authentication. This is a useful security measure, especially for situations where the user’s identification is provided by an external source, such as LDAP or a single-sign-on service. Instead of storing user passwords in @@ -11,8 +13,6 @@ they have on that project, and then stores the application credential identifier .. include:: /common/service.rst -In order to work with application credentials you have to :doc:`create the service ` first. - Create ------ @@ -27,3 +27,4 @@ Delete ------ .. sample:: Identity/v3/application_credentials/delete.php + From 404f5816e83ead9ac155558bce325b9067381903 Mon Sep 17 00:00:00 2001 From: Konstantin Babushkin Date: Thu, 18 Jan 2024 15:16:59 +0100 Subject: [PATCH 34/50] added service.rst --- doc/services/identity/v3/application-credentials.rst | 4 ++-- doc/services/identity/v3/credentials.rst | 4 +++- doc/services/identity/v3/domains.rst | 4 +++- doc/services/identity/v3/endpoints.rst | 6 ++++++ 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/doc/services/identity/v3/application-credentials.rst b/doc/services/identity/v3/application-credentials.rst index f2c81a6d..ad8009fd 100644 --- a/doc/services/identity/v3/application-credentials.rst +++ b/doc/services/identity/v3/application-credentials.rst @@ -1,8 +1,6 @@ Application Credentials ======================= -.. |models| replace:: application credentials - Application credentials provide a way to delegate a user’s authorization to an application without sharing the user’s password authentication. This is a useful security measure, especially for situations where the user’s identification is provided by an external source, such as LDAP or a single-sign-on service. Instead of storing user passwords in @@ -11,6 +9,8 @@ they have on that project, and then stores the application credential identifier .. osdoc:: https://docs.openstack.org/keystone/latest/user/application_credentials.html +.. |models| replace:: application credentials + .. include:: /common/service.rst Create diff --git a/doc/services/identity/v3/credentials.rst b/doc/services/identity/v3/credentials.rst index 18e07f56..23a753c6 100644 --- a/doc/services/identity/v3/credentials.rst +++ b/doc/services/identity/v3/credentials.rst @@ -7,7 +7,9 @@ project or domain. .. osdoc:: https://docs.openstack.org/api-ref/identity/v3/index.html#credentials -In order to work with credentials you have to :doc:`create the service ` first. +.. |models| replace:: credentials + +.. include:: /common/service.rst Create ------ diff --git a/doc/services/identity/v3/domains.rst b/doc/services/identity/v3/domains.rst index 1e2f359d..c5ddb653 100644 --- a/doc/services/identity/v3/domains.rst +++ b/doc/services/identity/v3/domains.rst @@ -5,7 +5,9 @@ A domain is a collection of users, groups, and projects. Each group and project .. osdoc:: https://docs.openstack.org/keystone/latest/getting-started/architecture.html#domains -In order to work with domains you have to :doc:`create the service ` first. +.. |models| replace:: domains + +.. include:: /common/service.rst Create ------ diff --git a/doc/services/identity/v3/endpoints.rst b/doc/services/identity/v3/endpoints.rst index 27178343..a70911aa 100644 --- a/doc/services/identity/v3/endpoints.rst +++ b/doc/services/identity/v3/endpoints.rst @@ -5,6 +5,12 @@ Each service should have one or more related endpoints. An endpoint is essential an API, along with some metadata about the endpoint itself and represents a set of URL endpoints for OpenStack web services. +.. osdoc:: https://docs.openstack.org/api-ref/identity/v3/index.html#service-catalog-and-endpoints + +.. |models| replace:: endpoints + +.. include:: /common/service.rst + Add endpoints ------------- From 933bf4baf634a563463ea7c6fe187a23c6336de3 Mon Sep 17 00:00:00 2001 From: Konstantin Babushkin Date: Fri, 19 Jan 2024 09:06:32 +0100 Subject: [PATCH 35/50] fix documentation for identity v2 and v3 --- doc/_exts/samples.py | 9 ++++ doc/services/identity/v2/authentication.rst | 12 ----- doc/services/identity/v2/index.rst | 8 ++-- doc/services/identity/v3/endpoints.rst | 36 +++++++-------- doc/services/identity/v3/groups.rst | 44 ++++++++++-------- doc/services/identity/v3/policies.rst | 27 +---------- doc/services/identity/v3/projects.rst | 46 +++++++++++-------- doc/services/identity/v3/roles.rst | 26 +++++++---- doc/services/identity/v3/services.rst | 41 ++++++++++------- doc/services/identity/v3/tokens.rst | 20 +++++++- doc/services/identity/v3/users.rst | 46 ++++++++++--------- .../{add_endpoint.php => create.php} | 7 +-- .../{delete_endpoint.php => delete.php} | 7 +-- .../{list_endpoints.php => list.php} | 7 +-- .../endpoints/{get_endpoint.php => read.php} | 8 +--- .../{update_endpoint.php => update.php} | 7 +-- samples/Identity/v3/groups/add_user.php | 7 +-- .../v3/groups/check_user_membership.php | 12 +---- .../v3/groups/{add_group.php => create.php} | 7 +-- .../groups/{delete_group.php => delete.php} | 7 +-- .../v3/groups/{list_groups.php => list.php} | 7 +-- samples/Identity/v3/groups/list_users.php | 7 +-- .../v3/groups/{get_group.php => read.php} | 7 +-- samples/Identity/v3/groups/remove_user.php | 7 +-- .../groups/{update_group.php => update.php} | 7 +-- .../Identity/v3/projects/check_group_role.php | 7 +-- .../Identity/v3/projects/check_user_role.php | 7 +-- .../projects/{add_project.php => create.php} | 7 +-- .../{delete_project.php => delete.php} | 7 +-- .../Identity/v3/projects/grant_group_role.php | 7 +-- .../Identity/v3/projects/grant_user_role.php | 7 +-- .../projects/{list_projects.php => list.php} | 7 +-- .../Identity/v3/projects/list_group_roles.php | 7 +-- .../Identity/v3/projects/list_user_roles.php | 7 +-- .../v3/projects/{get_project.php => read.php} | 7 +-- .../v3/projects/revoke_group_role.php | 7 +-- .../Identity/v3/projects/revoke_user_role.php | 7 +-- .../{update_project.php => update.php} | 7 +-- .../v3/roles/{add_role.php => create.php} | 5 -- .../v3/roles/{list_roles.php => list.php} | 5 -- .../Identity/v3/roles/list_assignments.php | 5 -- .../services/{add_service.php => create.php} | 7 +-- .../{delete_service.php => delete.php} | 7 +-- .../services/{list_services.php => list.php} | 7 +-- .../v3/services/{get_service.php => read.php} | 7 +-- .../{update_service.php => update.php} | 7 +-- .../v3/tokens/export_authentication_token.php | 3 -- .../v3/tokens/generate_token_from_id.php | 5 -- .../generate_token_scoped_to_project_id.php | 3 -- .../generate_token_scoped_to_project_name.php | 7 --- ...e_token_with_application_credential_id.php | 3 -- .../v3/tokens/generate_token_with_user_id.php | 3 -- .../tokens/generate_token_with_username.php | 6 --- samples/Identity/v3/tokens/revoke_token.php | 5 +- .../use_cached_authentication_token.php | 3 -- samples/Identity/v3/tokens/validate_token.php | 5 +- .../v3/users/{add_user.php => create.php} | 1 - .../v3/users/{delete_user.php => delete.php} | 5 -- .../v3/users/{list_users.php => list.php} | 5 -- samples/Identity/v3/users/list_groups.php | 5 -- samples/Identity/v3/users/list_projects.php | 5 -- .../v3/users/{get_user.php => read.php} | 5 -- .../v3/users/{update_user.php => update.php} | 5 -- tests/sample/Identity/v3/EndpointTest.php | 16 +++---- tests/sample/Identity/v3/GroupTest.php | 34 +++++++------- tests/sample/Identity/v3/ProjectTest.php | 34 +++++++------- tests/sample/Identity/v3/RoleTest.php | 10 ++-- tests/sample/Identity/v3/ServiceTest.php | 20 ++++---- tests/sample/Identity/v3/UserTest.php | 26 +++++------ 69 files changed, 272 insertions(+), 502 deletions(-) delete mode 100644 doc/services/identity/v2/authentication.rst rename samples/Identity/v3/endpoints/{add_endpoint.php => create.php} (76%) rename samples/Identity/v3/endpoints/{delete_endpoint.php => delete.php} (67%) rename samples/Identity/v3/endpoints/{list_endpoints.php => list.php} (70%) rename samples/Identity/v3/endpoints/{get_endpoint.php => read.php} (65%) rename samples/Identity/v3/endpoints/{update_endpoint.php => update.php} (71%) rename samples/Identity/v3/groups/{add_group.php => create.php} (69%) rename samples/Identity/v3/groups/{delete_group.php => delete.php} (66%) rename samples/Identity/v3/groups/{list_groups.php => list.php} (69%) rename samples/Identity/v3/groups/{get_group.php => read.php} (66%) rename samples/Identity/v3/groups/{update_group.php => update.php} (70%) rename samples/Identity/v3/projects/{add_project.php => create.php} (71%) rename samples/Identity/v3/projects/{delete_project.php => delete.php} (66%) rename samples/Identity/v3/projects/{list_projects.php => list.php} (65%) rename samples/Identity/v3/projects/{get_project.php => read.php} (66%) rename samples/Identity/v3/projects/{update_project.php => update.php} (68%) rename samples/Identity/v3/roles/{add_role.php => create.php} (78%) rename samples/Identity/v3/roles/{list_roles.php => list.php} (80%) rename samples/Identity/v3/services/{add_service.php => create.php} (69%) rename samples/Identity/v3/services/{delete_service.php => delete.php} (66%) rename samples/Identity/v3/services/{list_services.php => list.php} (69%) rename samples/Identity/v3/services/{get_service.php => read.php} (67%) rename samples/Identity/v3/services/{update_service.php => update.php} (69%) rename samples/Identity/v3/users/{add_user.php => create.php} (91%) rename samples/Identity/v3/users/{delete_user.php => delete.php} (78%) rename samples/Identity/v3/users/{list_users.php => list.php} (80%) rename samples/Identity/v3/users/{get_user.php => read.php} (78%) rename samples/Identity/v3/users/{update_user.php => update.php} (81%) diff --git a/doc/_exts/samples.py b/doc/_exts/samples.py index 36e7348b..4bae923e 100644 --- a/doc/_exts/samples.py +++ b/doc/_exts/samples.py @@ -1,9 +1,15 @@ from docutils import nodes +from docutils.parsers.rst import directives from sphinx.directives.code import LiteralInclude import re +from sphinx.util.typing import OptionSpec + class Sample(LiteralInclude): + option_spec: OptionSpec = { + 'full': directives.flag, + } def run(self): self.arguments[0] = "/../samples/" + self.arguments[0] @@ -12,6 +18,9 @@ def run(self): pattern = r"[\s+]?(\<\?php.*?]\);)" code_block = super(Sample, self).run()[0] + if 'force' in self.options: + return [code_block] + string = str(code_block[0]) match = re.match(pattern, string, re.S) diff --git a/doc/services/identity/v2/authentication.rst b/doc/services/identity/v2/authentication.rst deleted file mode 100644 index 6f5d515f..00000000 --- a/doc/services/identity/v2/authentication.rst +++ /dev/null @@ -1,12 +0,0 @@ -Authentication -============== - -Identity v2.0 -------------- - -We recommend users to use identity v3 when possible. - -RackSpace cloud and OVH cloud, however, are still using Keystone v2.0. This following code will work for such providers. - - -.. sample:: Identity/v2/authentication.php diff --git a/doc/services/identity/v2/index.rst b/doc/services/identity/v2/index.rst index d4f39ac1..c4960b9f 100644 --- a/doc/services/identity/v2/index.rst +++ b/doc/services/identity/v2/index.rst @@ -1,7 +1,9 @@ Identity v2 =========== -.. toctree:: - :maxdepth: 3 +We recommend users to use Identity v3 when possible. - authentication \ No newline at end of file +Some public, however, are still using Keystone v2.0. This following code will work for such providers. + +.. sample:: Identity/v2/authentication.php + :full: diff --git a/doc/services/identity/v3/endpoints.rst b/doc/services/identity/v3/endpoints.rst index a70911aa..252b0771 100644 --- a/doc/services/identity/v3/endpoints.rst +++ b/doc/services/identity/v3/endpoints.rst @@ -12,32 +12,28 @@ OpenStack web services. .. include:: /common/service.rst -Add endpoints -------------- +Create +------ -.. sample:: Identity/v3/endpoints/add_endpoint.php -.. refdoc:: OpenStack/Identity/v3/Service.html#method_createEndpoint +.. sample:: Identity/v3/endpoints/create.php -Get endpoint ------------- +Read +---- -.. sample:: Identity/v3/endpoints/get_endpoint.php -.. refdoc:: OpenStack/Identity/v3/Service.html#method_getEndpoint +.. sample:: Identity/v3/endpoints/read.php -List endpoints --------------- -.. sample:: Identity/v3/endpoints/list_endpoints.php -.. refdoc:: OpenStack/Identity/v3/Service.html#method_listEndpoints +Update +------ + +.. sample:: Identity/v3/endpoints/update.php -Update endpoint ---------------- +Delete +------ -.. sample:: Identity/v3/endpoints/update_endpoint.php -.. refdoc:: OpenStack/Identity/v3/Models/Endpoint.html#method_update +.. sample:: Identity/v3/endpoints/delete.php -Delete endpoint ---------------- +List +-------------- -.. sample:: Identity/v3/endpoints/delete_endpoint.php -.. refdoc:: OpenStack/Identity/v3/Models/Endpoint.html#method_delete +.. sample:: Identity/v3/endpoints/list.php diff --git a/doc/services/identity/v3/groups.rst b/doc/services/identity/v3/groups.rst index 4fc03775..62cb75f0 100644 --- a/doc/services/identity/v3/groups.rst +++ b/doc/services/identity/v3/groups.rst @@ -1,35 +1,39 @@ Groups ====== -Add group ---------- +Groups are a container representing a collection of users. A group itself must be owned by a specific domain, +and hence all group names are not globally unique, but only unique to their domain. -.. sample:: Identity/v3/groups/add_group.php -.. refdoc:: OpenStack/Identity/v3/Service.html#method_createGroup +.. osdoc:: https://docs.openstack.org/api-ref/identity/v3/index.html#groups -List groups ------------ +.. |models| replace:: groups -.. sample:: Identity/v3/groups/list_groups.php -.. refdoc:: OpenStack/Identity/v3/Service.html#method_listGroups +.. include:: /common/service.rst -Show group details ------------------- +Create +------ -.. sample:: Identity/v3/groups/get_group.php -.. refdoc:: OpenStack/Identity/v3/Service.html#method_getGroup +.. sample:: Identity/v3/groups/create.php -Update group ------------- +Read +---- -.. sample:: Identity/v3/groups/update_group.php -.. refdoc:: OpenStack/Identity/v3/Models/Group.html#method_update +.. sample:: Identity/v3/groups/read.php -Delete group ------------- +Update +------ -.. sample:: Identity/v3/groups/delete_group.php -.. refdoc:: OpenStack/Identity/v3/Models/Group.html#method_delete +.. sample:: Identity/v3/groups/update.php + +Delete +------ + +.. sample:: Identity/v3/groups/delete.php + +List +---- + +.. sample:: Identity/v3/groups/list.php List users in a group --------------------- diff --git a/doc/services/identity/v3/policies.rst b/doc/services/identity/v3/policies.rst index 6900ff01..4202951b 100644 --- a/doc/services/identity/v3/policies.rst +++ b/doc/services/identity/v3/policies.rst @@ -1,29 +1,6 @@ Policies ======== -.. warning:: Due to lack of information in upstream documentation, we are unable to offer code samples for this resource yet. +.. warning:: The policies API is deprecated. Keystone is not a policy management service. Do not use this. -Add policy ----------- - -.. refdoc:: OpenStack/Identity/v3/Service.html#method_createPolicy - -List policies -------------- - -.. refdoc:: OpenStack/Identity/v3/Service.html#method_listPolicies - -Show policy details -------------------- - -.. refdoc:: OpenStack/Identity/v3/Service.html#method_getPolicy - -Update policy -------------- - -.. refdoc:: OpenStack/Identity/v3/Models/Policy.html#method_update - -Delete policy -------------- - -.. refdoc:: OpenStack/Identity/v3/Models/Policy.html#method_delete +.. osdoc:: https://docs.openstack.org/api-ref/identity/v3/index.html#policies diff --git a/doc/services/identity/v3/projects.rst b/doc/services/identity/v3/projects.rst index 1de4f2ab..5e25bbdf 100644 --- a/doc/services/identity/v3/projects.rst +++ b/doc/services/identity/v3/projects.rst @@ -1,35 +1,41 @@ Projects ======== -Add project ------------ +Projects represent the base unit of ownership in OpenStack, in that all resources in OpenStack should be owned +by a specific project. A project itself must be owned by a specific domain, and hence all project names +are not globally unique, but unique to their domain. If the domain for a project is not specified, then it is added +to the default domain. -.. sample:: Identity/v3/projects/add_project.php -.. refdoc:: OpenStack/Identity/v3/Service.html#method_createProject +.. osdoc:: https://docs.openstack.org/api-ref/identity/v3/index.html#projects -List projects -------------- +.. |models| replace:: projects -.. sample:: Identity/v3/projects/list_projects.php -.. refdoc:: OpenStack/Identity/v3/Service.html#method_listProjects +.. include:: /common/service.rst -Show project details --------------------- +Create +------ -.. sample:: Identity/v3/projects/get_project.php -.. refdoc:: OpenStack/Identity/v3/Service.html#method_getProject +.. sample:: Identity/v3/projects/create.php -Update project --------------- +Read +---- -.. sample:: Identity/v3/projects/update_project.php -.. refdoc:: OpenStack/Identity/v3/Models/Project.html#method_update +.. sample:: Identity/v3/projects/read.php -Delete project --------------- +Update +------ -.. sample:: Identity/v3/projects/delete_project.php -.. refdoc:: OpenStack/Identity/v3/Models/Project.html#method_delete +.. sample:: Identity/v3/projects/update.php + +Delete +------ + +.. sample:: Identity/v3/projects/delete.php + +List +---- + +.. sample:: Identity/v3/projects/list.php List roles for project user --------------------------- diff --git a/doc/services/identity/v3/roles.rst b/doc/services/identity/v3/roles.rst index 143dabee..2a60f1f4 100644 --- a/doc/services/identity/v3/roles.rst +++ b/doc/services/identity/v3/roles.rst @@ -1,20 +1,28 @@ Roles ===== -Add role --------- +OpenStack services typically determine whether a user’s API request should be allowed using Role Based Access Control (RBAC). +For OpenStack this means the service compares the roles that user has on the project (as indicated by the roles in the token), +against the roles required for the API in question (as defined in the service’s policy file). A user obtains roles +on a project by having these assigned to them via the Identity service API. -.. sample:: Identity/v3/roles/add_role.php -.. refdoc:: OpenStack/Identity/v3/Models/Project.html#method_createRole +.. osdoc:: https://docs.openstack.org/api-ref/identity/v3/index.html#roles -List roles ----------- +.. |models| replace:: roles -.. sample:: Identity/v3/roles/list_roles.php -.. refdoc:: OpenStack/Identity/v3/Models/Project.html#method_listRoles +.. include:: /common/service.rst + +Create +------ + +.. sample:: Identity/v3/roles/create.php + +List +---- + +.. sample:: Identity/v3/roles/list.php List role assignments --------------------- .. sample:: Identity/v3/roles/list_assignments.php -.. refdoc:: OpenStack/Identity/v3/Models/Project.html#method_listRoleAssignments diff --git a/doc/services/identity/v3/services.rst b/doc/services/identity/v3/services.rst index 39276162..338ce18f 100644 --- a/doc/services/identity/v3/services.rst +++ b/doc/services/identity/v3/services.rst @@ -1,26 +1,35 @@ Services ======== -Add service ------------ +A service is an OpenStack web service that you can access through a URL, i.e. an endpoint. -.. sample:: Identity/v3/services/add_service.php -.. refdoc:: OpenStack/Identity/v3/Service.html#method_createService +.. osdoc:: https://docs.openstack.org/api-ref/identity/v3/index.html#roles -List services -------------- +.. |models| replace:: services -.. sample:: Identity/v3/services/list_services.php -.. refdoc:: OpenStack/Identity/v3/Service.html#method_listServices +.. include:: /common/service.rst -Show service details --------------------- +Create +------ -.. sample:: Identity/v3/services/get_service.php -.. refdoc:: OpenStack/Identity/v3/Service.html#method_getService +.. sample:: Identity/v3/services/create.php -Delete service --------------- +Read +---- -.. sample:: Identity/v3/services/delete_service.php -.. refdoc:: OpenStack/Identity/v3/Models/Service.html#method_delete \ No newline at end of file +.. sample:: Identity/v3/services/read.php + +Update +------ + +.. sample:: Identity/v3/services/update.php + +Delete +------ + +.. sample:: Identity/v3/services/delete.php + +List +---- + +.. sample:: Identity/v3/services/list.php diff --git a/doc/services/identity/v3/tokens.rst b/doc/services/identity/v3/tokens.rst index ca10930a..26cde921 100644 --- a/doc/services/identity/v3/tokens.rst +++ b/doc/services/identity/v3/tokens.rst @@ -1,6 +1,16 @@ Tokens ====== +Tokens are used to authenticate and authorize your interactions with OpenStack APIs. Tokens come in many scopes, +representing various authorization and sources of identity. + +.. osdoc:: https://docs.openstack.org/keystone/latest/admin/tokens-overview.html + +Generate token +-------------- + +Token is generated when you create the ``OpenStack`` object. You can also generate another token using the following methods. + Generate token with user ID ~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -9,6 +19,9 @@ Generate token with user ID Generate token with username ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Since usernames will not be unique across an entire OpenStack installation, when authenticating with them, +you must also provide your domain ID. You do not have to do this if you authenticate with a user ID. + .. sample:: Identity/v3/tokens/generate_token_with_username.php Generate token with application credential ID @@ -30,19 +43,20 @@ Generate token scoped to project ID Generate token scoped to project name ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Since project names will not be unique across an entire OpenStack installation, when authenticating with them you must +also provide your domain ID. You do not have to do this if you authenticate with a project ID. + .. sample:: Identity/v3/tokens/generate_token_scoped_to_project_name.php Validate token -------------- .. sample:: Identity/v3/tokens/validate_token.php -.. refdoc:: OpenStack/Identity/v3/Service.html#method_validateToken Revoke token ------------ .. sample:: Identity/v3/tokens/revoke_token.php -.. refdoc:: OpenStack/Identity/v3/Service.html#method_revokeToken Cache authentication token -------------------------- @@ -67,6 +81,7 @@ Generate token and persist to file ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. sample:: Identity/v3/tokens/export_authentication_token.php + :full: For scalability, it is recommended that cached tokens are stored in persistent storage such as memcache or redis instead @@ -76,3 +91,4 @@ Initialize Open Stack using cached authentication token ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. sample:: Identity/v3/tokens/use_cached_authentication_token.php + :full: diff --git a/doc/services/identity/v3/users.rst b/doc/services/identity/v3/users.rst index 3453c3dc..c11f7ee3 100644 --- a/doc/services/identity/v3/users.rst +++ b/doc/services/identity/v3/users.rst @@ -1,44 +1,46 @@ Users ===== -Add user --------- +A user is an individual API consumer that is owned by a domain. A role explicitly associates a user with projects +or domains. A user with no assigned roles has no access to OpenStack resources. -.. sample:: Identity/v3/users/add_user.php -.. refdoc:: OpenStack/Identity/v3/Service.html#method_createUser +.. osdoc:: https://docs.openstack.org/api-ref/identity/v3/index.html#users -List users ----------- +.. |models| replace:: users -.. sample:: Identity/v3/users/list_users.php -.. refdoc:: OpenStack/Identity/v3/Service.html#method_listUsers +.. include:: /common/service.rst -Show user details ------------------ +Create +------ -.. sample:: Identity/v3/users/get_user.php -.. refdoc:: OpenStack/Identity/v3/Service.html#method_getUser +.. sample:: Identity/v3/users/create.php -Update user ------------ +Read +---- -.. sample:: Identity/v3/users/update_user.php -.. refdoc:: OpenStack/Identity/v3/Models/User.html#method_update +.. sample:: Identity/v3/users/read.php -Delete user ------------ +Update +------ -.. sample:: Identity/v3/users/delete_user.php -.. refdoc:: OpenStack/Identity/v3/Models/User.html#method_delete +.. sample:: Identity/v3/users/update.php + +Delete +------ + +.. sample:: Identity/v3/users/delete.php + +List +---- + +.. sample:: Identity/v3/users/list.php List groups for user -------------------- .. sample:: Identity/v3/users/list_groups.php -.. refdoc:: OpenStack/Identity/v3/Models/User.html#method_listGroups List projects for user ---------------------- .. sample:: Identity/v3/users/list_projects.php -.. refdoc:: OpenStack/Identity/v3/Models/User.html#method_listProjects diff --git a/samples/Identity/v3/endpoints/add_endpoint.php b/samples/Identity/v3/endpoints/create.php similarity index 76% rename from samples/Identity/v3/endpoints/add_endpoint.php rename to samples/Identity/v3/endpoints/create.php index b123bf3f..1e774e62 100644 --- a/samples/Identity/v3/endpoints/add_endpoint.php +++ b/samples/Identity/v3/endpoints/create.php @@ -9,14 +9,9 @@ 'id' => '{userId}', 'password' => '{password}' ], - 'scope' => [ - 'project' => [ - 'id' => '{projectId}' - ] - ] ]); -$identity = $openstack->identityV3(['region' => '{region}']); +$identity = $openstack->identityV3(); $endpoint = $identity->createEndpoint([ 'interface' => \OpenStack\Identity\v3\Enum::INTERFACE_INTERNAL, diff --git a/samples/Identity/v3/endpoints/delete_endpoint.php b/samples/Identity/v3/endpoints/delete.php similarity index 67% rename from samples/Identity/v3/endpoints/delete_endpoint.php rename to samples/Identity/v3/endpoints/delete.php index 56cafda7..b25e469d 100644 --- a/samples/Identity/v3/endpoints/delete_endpoint.php +++ b/samples/Identity/v3/endpoints/delete.php @@ -9,14 +9,9 @@ 'id' => '{userId}', 'password' => '{password}' ], - 'scope' => [ - 'project' => [ - 'id' => '{projectId}' - ] - ] ]); -$identity = $openstack->identityV3(['region' => '{region}']); +$identity = $openstack->identityV3(); $endpoint = $identity->getEndpoint('{endpointId}'); $endpoint->delete(); diff --git a/samples/Identity/v3/endpoints/list_endpoints.php b/samples/Identity/v3/endpoints/list.php similarity index 70% rename from samples/Identity/v3/endpoints/list_endpoints.php rename to samples/Identity/v3/endpoints/list.php index 24d39a0e..f53612eb 100644 --- a/samples/Identity/v3/endpoints/list_endpoints.php +++ b/samples/Identity/v3/endpoints/list.php @@ -9,14 +9,9 @@ 'id' => '{userId}', 'password' => '{password}' ], - 'scope' => [ - 'project' => [ - 'id' => '{projectId}' - ] - ] ]); -$identity = $openstack->identityV3(['region' => '{region}']); +$identity = $openstack->identityV3(); foreach ($identity->listEndpoints() as $endpoint) { /** @var $endpoint \OpenStack\Identity\v3\Models\Endpoint */ diff --git a/samples/Identity/v3/endpoints/get_endpoint.php b/samples/Identity/v3/endpoints/read.php similarity index 65% rename from samples/Identity/v3/endpoints/get_endpoint.php rename to samples/Identity/v3/endpoints/read.php index 9d869360..05bbc236 100644 --- a/samples/Identity/v3/endpoints/get_endpoint.php +++ b/samples/Identity/v3/endpoints/read.php @@ -9,13 +9,9 @@ 'id' => '{userId}', 'password' => '{password}' ], - 'scope' => [ - 'project' => [ - 'id' => '{projectId}' - ] - ] ]); -$identity = $openstack->identityV3(['region' => '{region}']); +$identity = $openstack->identityV3(); $endpoint = $identity->getEndpoint('{endpointId}'); +$endpoint->retrieve(); diff --git a/samples/Identity/v3/endpoints/update_endpoint.php b/samples/Identity/v3/endpoints/update.php similarity index 71% rename from samples/Identity/v3/endpoints/update_endpoint.php rename to samples/Identity/v3/endpoints/update.php index c77a0d8a..e2fdf73a 100644 --- a/samples/Identity/v3/endpoints/update_endpoint.php +++ b/samples/Identity/v3/endpoints/update.php @@ -9,14 +9,9 @@ 'id' => '{userId}', 'password' => '{password}' ], - 'scope' => [ - 'project' => [ - 'id' => '{projectId}' - ] - ] ]); -$identity = $openstack->identityV3(['region' => '{region}']); +$identity = $openstack->identityV3(); $endpoint = $identity->getEndpoint('{endpointId}'); diff --git a/samples/Identity/v3/groups/add_user.php b/samples/Identity/v3/groups/add_user.php index 01c28c71..3d8edabb 100644 --- a/samples/Identity/v3/groups/add_user.php +++ b/samples/Identity/v3/groups/add_user.php @@ -9,14 +9,9 @@ 'id' => '{userId}', 'password' => '{password}' ], - 'scope' => [ - 'project' => [ - 'id' => '{projectId}' - ] - ] ]); -$identity = $openstack->identityV3(['region' => '{region}']); +$identity = $openstack->identityV3(); $group = $identity->getGroup('{groupId}'); diff --git a/samples/Identity/v3/groups/check_user_membership.php b/samples/Identity/v3/groups/check_user_membership.php index 64caabab..ba6d76a2 100644 --- a/samples/Identity/v3/groups/check_user_membership.php +++ b/samples/Identity/v3/groups/check_user_membership.php @@ -9,18 +9,10 @@ 'id' => '{userId}', 'password' => '{password}' ], - 'scope' => [ - 'project' => [ - 'id' => '{projectId}' - ] - ] ]); -$identity = $openstack->identityV3(['region' => '{region}']); +$identity = $openstack->identityV3(); $group = $identity->getGroup('{groupId}'); -$result = $group->checkMembership(['userId' => '{groupUserId}']); - -if (true === $result) { -} +$hasMembership = $group->checkMembership(['userId' => '{groupUserId}']); diff --git a/samples/Identity/v3/groups/add_group.php b/samples/Identity/v3/groups/create.php similarity index 69% rename from samples/Identity/v3/groups/add_group.php rename to samples/Identity/v3/groups/create.php index b389a5b6..66455bdb 100644 --- a/samples/Identity/v3/groups/add_group.php +++ b/samples/Identity/v3/groups/create.php @@ -9,14 +9,9 @@ 'id' => '{userId}', 'password' => '{password}' ], - 'scope' => [ - 'project' => [ - 'id' => '{projectId}' - ] - ] ]); -$identity = $openstack->identityV3(['region' => '{region}']); +$identity = $openstack->identityV3(); $group = $identity->createGroup([ 'description' => '{description}', diff --git a/samples/Identity/v3/groups/delete_group.php b/samples/Identity/v3/groups/delete.php similarity index 66% rename from samples/Identity/v3/groups/delete_group.php rename to samples/Identity/v3/groups/delete.php index be29565c..d29e2012 100644 --- a/samples/Identity/v3/groups/delete_group.php +++ b/samples/Identity/v3/groups/delete.php @@ -9,14 +9,9 @@ 'id' => '{userId}', 'password' => '{password}' ], - 'scope' => [ - 'project' => [ - 'id' => '{projectId}' - ] - ] ]); -$identity = $openstack->identityV3(['region' => '{region}']); +$identity = $openstack->identityV3(); $group = $identity->getGroup('{groupId}'); diff --git a/samples/Identity/v3/groups/list_groups.php b/samples/Identity/v3/groups/list.php similarity index 69% rename from samples/Identity/v3/groups/list_groups.php rename to samples/Identity/v3/groups/list.php index cee3577e..5d1e038f 100644 --- a/samples/Identity/v3/groups/list_groups.php +++ b/samples/Identity/v3/groups/list.php @@ -9,14 +9,9 @@ 'id' => '{userId}', 'password' => '{password}' ], - 'scope' => [ - 'project' => [ - 'id' => '{projectId}' - ] - ] ]); -$identity = $openstack->identityV3(['region' => '{region}']); +$identity = $openstack->identityV3(); foreach ($identity->listGroups() as $group) { /** @var $group \OpenStack\Identity\v3\Models\Group */ diff --git a/samples/Identity/v3/groups/list_users.php b/samples/Identity/v3/groups/list_users.php index 40dc45c0..d1652b2b 100644 --- a/samples/Identity/v3/groups/list_users.php +++ b/samples/Identity/v3/groups/list_users.php @@ -9,14 +9,9 @@ 'id' => '{userId}', 'password' => '{password}' ], - 'scope' => [ - 'project' => [ - 'id' => '{projectId}' - ] - ] ]); -$identity = $openstack->identityV3(['region' => '{region}']); +$identity = $openstack->identityV3(); $group = $identity->getGroup('{groupId}'); diff --git a/samples/Identity/v3/groups/get_group.php b/samples/Identity/v3/groups/read.php similarity index 66% rename from samples/Identity/v3/groups/get_group.php rename to samples/Identity/v3/groups/read.php index da4d8f0f..b2b3c653 100644 --- a/samples/Identity/v3/groups/get_group.php +++ b/samples/Identity/v3/groups/read.php @@ -9,14 +9,9 @@ 'id' => '{userId}', 'password' => '{password}' ], - 'scope' => [ - 'project' => [ - 'id' => '{projectId}' - ] - ] ]); -$identity = $openstack->identityV3(['region' => '{region}']); +$identity = $openstack->identityV3(); $group = $identity->getGroup('{groupId}'); $group->retrieve(); diff --git a/samples/Identity/v3/groups/remove_user.php b/samples/Identity/v3/groups/remove_user.php index 7a975c0c..b7210ba9 100644 --- a/samples/Identity/v3/groups/remove_user.php +++ b/samples/Identity/v3/groups/remove_user.php @@ -9,14 +9,9 @@ 'id' => '{userId}', 'password' => '{password}' ], - 'scope' => [ - 'project' => [ - 'id' => '{projectId}' - ] - ] ]); -$identity = $openstack->identityV3(['region' => '{region}']); +$identity = $openstack->identityV3(); $group = $identity->getGroup('{groupId}'); diff --git a/samples/Identity/v3/groups/update_group.php b/samples/Identity/v3/groups/update.php similarity index 70% rename from samples/Identity/v3/groups/update_group.php rename to samples/Identity/v3/groups/update.php index 71f8234d..9cfabdfe 100644 --- a/samples/Identity/v3/groups/update_group.php +++ b/samples/Identity/v3/groups/update.php @@ -9,14 +9,9 @@ 'id' => '{userId}', 'password' => '{password}' ], - 'scope' => [ - 'project' => [ - 'id' => '{projectId}' - ] - ] ]); -$identity = $openstack->identityV3(['region' => '{region}']); +$identity = $openstack->identityV3(); $group = $identity->getGroup('{groupId}'); diff --git a/samples/Identity/v3/projects/check_group_role.php b/samples/Identity/v3/projects/check_group_role.php index 0fc01cd4..1f38cd3b 100644 --- a/samples/Identity/v3/projects/check_group_role.php +++ b/samples/Identity/v3/projects/check_group_role.php @@ -9,14 +9,9 @@ 'id' => '{userId}', 'password' => '{password}' ], - 'scope' => [ - 'project' => [ - 'id' => '{projectId}' - ] - ] ]); -$identity = $openstack->identityV3(['region' => '{region}']); +$identity = $openstack->identityV3(); $project = $identity->getProject('{id}'); diff --git a/samples/Identity/v3/projects/check_user_role.php b/samples/Identity/v3/projects/check_user_role.php index 2704b406..2d5736ae 100644 --- a/samples/Identity/v3/projects/check_user_role.php +++ b/samples/Identity/v3/projects/check_user_role.php @@ -9,14 +9,9 @@ 'id' => '{userId}', 'password' => '{password}' ], - 'scope' => [ - 'project' => [ - 'id' => '{projectId}' - ] - ] ]); -$identity = $openstack->identityV3(['region' => '{region}']); +$identity = $openstack->identityV3(); $project = $identity->getProject('{id}'); diff --git a/samples/Identity/v3/projects/add_project.php b/samples/Identity/v3/projects/create.php similarity index 71% rename from samples/Identity/v3/projects/add_project.php rename to samples/Identity/v3/projects/create.php index 0dcd0d25..f6debd3f 100644 --- a/samples/Identity/v3/projects/add_project.php +++ b/samples/Identity/v3/projects/create.php @@ -9,14 +9,9 @@ 'id' => '{userId}', 'password' => '{password}' ], - 'scope' => [ - 'project' => [ - 'id' => '{projectId}' - ] - ] ]); -$identity = $openstack->identityV3(['region' => '{region}']); +$identity = $openstack->identityV3(); $project = $identity->createProject([ 'description' => '{description}', diff --git a/samples/Identity/v3/projects/delete_project.php b/samples/Identity/v3/projects/delete.php similarity index 66% rename from samples/Identity/v3/projects/delete_project.php rename to samples/Identity/v3/projects/delete.php index 2ce0c387..1401a242 100644 --- a/samples/Identity/v3/projects/delete_project.php +++ b/samples/Identity/v3/projects/delete.php @@ -9,14 +9,9 @@ 'id' => '{userId}', 'password' => '{password}' ], - 'scope' => [ - 'project' => [ - 'id' => '{projectId}' - ] - ] ]); -$identity = $openstack->identityV3(['region' => '{region}']); +$identity = $openstack->identityV3(); $project = $identity->getProject('{id}'); diff --git a/samples/Identity/v3/projects/grant_group_role.php b/samples/Identity/v3/projects/grant_group_role.php index 8bec285c..8fd69fde 100644 --- a/samples/Identity/v3/projects/grant_group_role.php +++ b/samples/Identity/v3/projects/grant_group_role.php @@ -9,14 +9,9 @@ 'id' => '{userId}', 'password' => '{password}' ], - 'scope' => [ - 'project' => [ - 'id' => '{projectId}' - ] - ] ]); -$identity = $openstack->identityV3(['region' => '{region}']); +$identity = $openstack->identityV3(); $project = $identity->getProject('{id}'); diff --git a/samples/Identity/v3/projects/grant_user_role.php b/samples/Identity/v3/projects/grant_user_role.php index 6acb4b74..be3721f0 100644 --- a/samples/Identity/v3/projects/grant_user_role.php +++ b/samples/Identity/v3/projects/grant_user_role.php @@ -9,14 +9,9 @@ 'id' => '{userId}', 'password' => '{password}' ], - 'scope' => [ - 'project' => [ - 'id' => '{projectId}' - ] - ] ]); -$identity = $openstack->identityV3(['region' => '{region}']); +$identity = $openstack->identityV3(); $project = $identity->getProject('{id}'); diff --git a/samples/Identity/v3/projects/list_projects.php b/samples/Identity/v3/projects/list.php similarity index 65% rename from samples/Identity/v3/projects/list_projects.php rename to samples/Identity/v3/projects/list.php index 07890bdf..3fc190bf 100644 --- a/samples/Identity/v3/projects/list_projects.php +++ b/samples/Identity/v3/projects/list.php @@ -9,14 +9,9 @@ 'id' => '{userId}', 'password' => '{password}' ], - 'scope' => [ - 'project' => [ - 'id' => '{projectId}' - ] - ] ]); -$identity = $openstack->identityV3(['region' => '{region}']); +$identity = $openstack->identityV3(); foreach ($identity->listProjects() as $project) { } diff --git a/samples/Identity/v3/projects/list_group_roles.php b/samples/Identity/v3/projects/list_group_roles.php index b678e0a7..ef64004d 100644 --- a/samples/Identity/v3/projects/list_group_roles.php +++ b/samples/Identity/v3/projects/list_group_roles.php @@ -9,14 +9,9 @@ 'id' => '{userId}', 'password' => '{password}' ], - 'scope' => [ - 'project' => [ - 'id' => '{projectId}' - ] - ] ]); -$identity = $openstack->identityV3(['region' => '{region}']); +$identity = $openstack->identityV3(); $project = $identity->getProject('{id}'); diff --git a/samples/Identity/v3/projects/list_user_roles.php b/samples/Identity/v3/projects/list_user_roles.php index 11d96f49..d943d978 100644 --- a/samples/Identity/v3/projects/list_user_roles.php +++ b/samples/Identity/v3/projects/list_user_roles.php @@ -9,14 +9,9 @@ 'id' => '{userId}', 'password' => '{password}' ], - 'scope' => [ - 'project' => [ - 'id' => '{projectId}' - ] - ] ]); -$identity = $openstack->identityV3(['region' => '{region}']); +$identity = $openstack->identityV3(); $project = $identity->getProject('{id}'); diff --git a/samples/Identity/v3/projects/get_project.php b/samples/Identity/v3/projects/read.php similarity index 66% rename from samples/Identity/v3/projects/get_project.php rename to samples/Identity/v3/projects/read.php index 8e548ade..50d993ea 100644 --- a/samples/Identity/v3/projects/get_project.php +++ b/samples/Identity/v3/projects/read.php @@ -9,14 +9,9 @@ 'id' => '{userId}', 'password' => '{password}' ], - 'scope' => [ - 'project' => [ - 'id' => '{projectId}' - ] - ] ]); -$identity = $openstack->identityV3(['region' => '{region}']); +$identity = $openstack->identityV3(); $project = $identity->getProject('{id}'); $project->retrieve(); diff --git a/samples/Identity/v3/projects/revoke_group_role.php b/samples/Identity/v3/projects/revoke_group_role.php index 8011a3e5..85e13597 100644 --- a/samples/Identity/v3/projects/revoke_group_role.php +++ b/samples/Identity/v3/projects/revoke_group_role.php @@ -9,14 +9,9 @@ 'id' => '{userId}', 'password' => '{password}' ], - 'scope' => [ - 'project' => [ - 'id' => '{projectId}' - ] - ] ]); -$identity = $openstack->identityV3(['region' => '{region}']); +$identity = $openstack->identityV3(); $project = $identity->getProject('{id}'); diff --git a/samples/Identity/v3/projects/revoke_user_role.php b/samples/Identity/v3/projects/revoke_user_role.php index cd910562..b8d4c390 100644 --- a/samples/Identity/v3/projects/revoke_user_role.php +++ b/samples/Identity/v3/projects/revoke_user_role.php @@ -9,14 +9,9 @@ 'id' => '{userId}', 'password' => '{password}' ], - 'scope' => [ - 'project' => [ - 'id' => '{projectId}' - ] - ] ]); -$identity = $openstack->identityV3(['region' => '{region}']); +$identity = $openstack->identityV3(); $project = $identity->getProject('{id}'); diff --git a/samples/Identity/v3/projects/update_project.php b/samples/Identity/v3/projects/update.php similarity index 68% rename from samples/Identity/v3/projects/update_project.php rename to samples/Identity/v3/projects/update.php index 862185bb..d35b9de6 100644 --- a/samples/Identity/v3/projects/update_project.php +++ b/samples/Identity/v3/projects/update.php @@ -9,14 +9,9 @@ 'id' => '{userId}', 'password' => '{password}' ], - 'scope' => [ - 'project' => [ - 'id' => '{projectId}' - ] - ] ]); -$identity = $openstack->identityV3(['region' => '{region}']); +$identity = $openstack->identityV3(); $project = $identity->getProject('{id}'); diff --git a/samples/Identity/v3/roles/add_role.php b/samples/Identity/v3/roles/create.php similarity index 78% rename from samples/Identity/v3/roles/add_role.php rename to samples/Identity/v3/roles/create.php index 41a759d1..bf82ec08 100644 --- a/samples/Identity/v3/roles/add_role.php +++ b/samples/Identity/v3/roles/create.php @@ -9,11 +9,6 @@ 'id' => '{userId}', 'password' => '{password}' ], - 'scope' => [ - 'project' => [ - 'id' => '{projectId}' - ] - ] ]); $identity = $openstack->identityV3(); diff --git a/samples/Identity/v3/roles/list_roles.php b/samples/Identity/v3/roles/list.php similarity index 80% rename from samples/Identity/v3/roles/list_roles.php rename to samples/Identity/v3/roles/list.php index a5388a36..22e650c8 100644 --- a/samples/Identity/v3/roles/list_roles.php +++ b/samples/Identity/v3/roles/list.php @@ -9,11 +9,6 @@ 'id' => '{userId}', 'password' => '{password}' ], - 'scope' => [ - 'project' => [ - 'id' => '{projectId}' - ] - ] ]); $identity = $openstack->identityV3(); diff --git a/samples/Identity/v3/roles/list_assignments.php b/samples/Identity/v3/roles/list_assignments.php index b39543b0..9b929804 100644 --- a/samples/Identity/v3/roles/list_assignments.php +++ b/samples/Identity/v3/roles/list_assignments.php @@ -9,11 +9,6 @@ 'id' => '{userId}', 'password' => '{password}' ], - 'scope' => [ - 'project' => [ - 'id' => '{projectId}' - ] - ] ]); $identity = $openstack->identityV3(); diff --git a/samples/Identity/v3/services/add_service.php b/samples/Identity/v3/services/create.php similarity index 69% rename from samples/Identity/v3/services/add_service.php rename to samples/Identity/v3/services/create.php index ac4a5c36..f4d24a69 100644 --- a/samples/Identity/v3/services/add_service.php +++ b/samples/Identity/v3/services/create.php @@ -9,14 +9,9 @@ 'id' => '{userId}', 'password' => '{password}' ], - 'scope' => [ - 'project' => [ - 'id' => '{projectId}' - ] - ] ]); -$identity = $openstack->identityV3(['region' => '{region}']); +$identity = $openstack->identityV3(); $service = $identity->createService([ 'name' => '{serviceName}', diff --git a/samples/Identity/v3/services/delete_service.php b/samples/Identity/v3/services/delete.php similarity index 66% rename from samples/Identity/v3/services/delete_service.php rename to samples/Identity/v3/services/delete.php index cdd62f45..d5c01a1d 100644 --- a/samples/Identity/v3/services/delete_service.php +++ b/samples/Identity/v3/services/delete.php @@ -9,14 +9,9 @@ 'id' => '{userId}', 'password' => '{password}' ], - 'scope' => [ - 'project' => [ - 'id' => '{projectId}' - ] - ] ]); -$identity = $openstack->identityV3(['region' => '{region}']); +$identity = $openstack->identityV3(); $service = $identity->getService('{serviceId}'); $service->delete(); diff --git a/samples/Identity/v3/services/list_services.php b/samples/Identity/v3/services/list.php similarity index 69% rename from samples/Identity/v3/services/list_services.php rename to samples/Identity/v3/services/list.php index 8b501e1a..e506411f 100644 --- a/samples/Identity/v3/services/list_services.php +++ b/samples/Identity/v3/services/list.php @@ -9,14 +9,9 @@ 'id' => '{userId}', 'password' => '{password}' ], - 'scope' => [ - 'project' => [ - 'id' => '{projectId}' - ] - ] ]); -$identity = $openstack->identityV3(['region' => '{region}']); +$identity = $openstack->identityV3(); foreach ($identity->listServices() as $service) { /** @var $service \OpenStack\Identity\v3\Models\Service */ diff --git a/samples/Identity/v3/services/get_service.php b/samples/Identity/v3/services/read.php similarity index 67% rename from samples/Identity/v3/services/get_service.php rename to samples/Identity/v3/services/read.php index f8cf1949..65d59493 100644 --- a/samples/Identity/v3/services/get_service.php +++ b/samples/Identity/v3/services/read.php @@ -9,14 +9,9 @@ 'id' => '{userId}', 'password' => '{password}' ], - 'scope' => [ - 'project' => [ - 'id' => '{projectId}' - ] - ] ]); -$identity = $openstack->identityV3(['region' => '{region}']); +$identity = $openstack->identityV3(); $service = $identity->getService('{serviceId}'); $service->retrieve(); diff --git a/samples/Identity/v3/services/update_service.php b/samples/Identity/v3/services/update.php similarity index 69% rename from samples/Identity/v3/services/update_service.php rename to samples/Identity/v3/services/update.php index 600c80fd..26af68f0 100644 --- a/samples/Identity/v3/services/update_service.php +++ b/samples/Identity/v3/services/update.php @@ -9,14 +9,9 @@ 'id' => '{userId}', 'password' => '{password}' ], - 'scope' => [ - 'project' => [ - 'id' => '{projectId}' - ] - ] ]); -$identity = $openstack->identityV3(['region' => '{region}']); +$identity = $openstack->identityV3(); $service = $identity->getService('{serviceId}'); diff --git a/samples/Identity/v3/tokens/export_authentication_token.php b/samples/Identity/v3/tokens/export_authentication_token.php index 995a6430..818152ed 100644 --- a/samples/Identity/v3/tokens/export_authentication_token.php +++ b/samples/Identity/v3/tokens/export_authentication_token.php @@ -10,9 +10,6 @@ 'password' => '{password}', 'domain' => ['id' => '{domainId}'] ], - 'scope' => [ - 'project' => ['id' => '{projectId}'] - ] ]; $openstack = new OpenStack\OpenStack($params); diff --git a/samples/Identity/v3/tokens/generate_token_from_id.php b/samples/Identity/v3/tokens/generate_token_from_id.php index 38821c68..b25096f2 100644 --- a/samples/Identity/v3/tokens/generate_token_from_id.php +++ b/samples/Identity/v3/tokens/generate_token_from_id.php @@ -9,11 +9,6 @@ 'id' => '{userId}', 'password' => '{password}' ], - 'scope' => [ - 'project' => [ - 'id' => '{projectId}' - ] - ] ]); $identity = $openstack->identityV3(); diff --git a/samples/Identity/v3/tokens/generate_token_scoped_to_project_id.php b/samples/Identity/v3/tokens/generate_token_scoped_to_project_id.php index 7cfed1d2..15960c8a 100644 --- a/samples/Identity/v3/tokens/generate_token_scoped_to_project_id.php +++ b/samples/Identity/v3/tokens/generate_token_scoped_to_project_id.php @@ -9,9 +9,6 @@ 'id' => '{userId}', 'password' => '{password}' ], - 'scope' => [ - 'project' => ['id' => '{projectId}'] - ] ]); $identity = $openstack->identityV3(); diff --git a/samples/Identity/v3/tokens/generate_token_scoped_to_project_name.php b/samples/Identity/v3/tokens/generate_token_scoped_to_project_name.php index 5b84a1b1..78476941 100644 --- a/samples/Identity/v3/tokens/generate_token_scoped_to_project_name.php +++ b/samples/Identity/v3/tokens/generate_token_scoped_to_project_name.php @@ -9,17 +9,10 @@ 'id' => '{userId}', 'password' => '{password}' ], - 'scope' => [ - 'project' => ['id' => '{projectId}'] - ] ]); $identity = $openstack->identityV3(); -// Since project names will not be unique across an entire OpenStack installation, -// when authenticating with them you must also provide your domain ID. You do -// not have to do this if you authenticate with a project ID. - $token = $identity->generateToken([ 'user' => [ 'id' => '{userId}', diff --git a/samples/Identity/v3/tokens/generate_token_with_application_credential_id.php b/samples/Identity/v3/tokens/generate_token_with_application_credential_id.php index b64e8a28..408dba47 100644 --- a/samples/Identity/v3/tokens/generate_token_with_application_credential_id.php +++ b/samples/Identity/v3/tokens/generate_token_with_application_credential_id.php @@ -9,9 +9,6 @@ 'id' => '{userId}', 'password' => '{password}' ], - 'scope' => [ - 'project' => ['id' => '{projectId}'] - ] ]); $identity = $openstack->identityV3(); diff --git a/samples/Identity/v3/tokens/generate_token_with_user_id.php b/samples/Identity/v3/tokens/generate_token_with_user_id.php index 0a0b475c..71969741 100644 --- a/samples/Identity/v3/tokens/generate_token_with_user_id.php +++ b/samples/Identity/v3/tokens/generate_token_with_user_id.php @@ -9,9 +9,6 @@ 'id' => '{userId}', 'password' => '{password}' ], - 'scope' => [ - 'project' => ['id' => '{projectId}'] - ] ]); $identity = $openstack->identityV3(); diff --git a/samples/Identity/v3/tokens/generate_token_with_username.php b/samples/Identity/v3/tokens/generate_token_with_username.php index 632de736..ceb07143 100644 --- a/samples/Identity/v3/tokens/generate_token_with_username.php +++ b/samples/Identity/v3/tokens/generate_token_with_username.php @@ -10,16 +10,10 @@ 'password' => '{password}', 'domain' => ['id' => '{domainId}'] ], - 'scope' => [ - 'project' => ['id' => '{projectId}'] - ] ]); $identity = $openstack->identityV3(); -// Since usernames will not be unique across an entire OpenStack installation, -// when authenticating with them, you must also provide your domain ID. You do -// not have to do this if you authenticate with a user ID. $token = $identity->generateToken([ 'user' => [ 'name' => '{username}', diff --git a/samples/Identity/v3/tokens/revoke_token.php b/samples/Identity/v3/tokens/revoke_token.php index e25882c9..de8f9675 100644 --- a/samples/Identity/v3/tokens/revoke_token.php +++ b/samples/Identity/v3/tokens/revoke_token.php @@ -10,11 +10,8 @@ 'password' => '{password}', 'domain' => ['id' => '{domainId}'] ], - 'scope' => [ - 'project' => ['id' => '{projectId}'] - ] ]); -$identity = $openstack->identityV3(['region' => '{region}']); +$identity = $openstack->identityV3(); $identity->revokeToken('{tokenId}'); diff --git a/samples/Identity/v3/tokens/use_cached_authentication_token.php b/samples/Identity/v3/tokens/use_cached_authentication_token.php index ddc40a73..464d476d 100644 --- a/samples/Identity/v3/tokens/use_cached_authentication_token.php +++ b/samples/Identity/v3/tokens/use_cached_authentication_token.php @@ -10,9 +10,6 @@ 'password' => '{password}', 'domain' => ['id' => '{domainId}'] ], - 'scope' => [ - 'project' => ['id' => '{projectId}'] - ] ]; $token = json_decode(file_get_contents('token.json'), true); diff --git a/samples/Identity/v3/tokens/validate_token.php b/samples/Identity/v3/tokens/validate_token.php index 7302d965..ef9dcb59 100644 --- a/samples/Identity/v3/tokens/validate_token.php +++ b/samples/Identity/v3/tokens/validate_token.php @@ -10,12 +10,9 @@ 'password' => '{password}', 'domain' => ['id' => '{domainId}'] ], - 'scope' => [ - 'project' => ['id' => '{projectId}'] - ] ]); -$identity = $openstack->identityV3(['region' => '{region}']); +$identity = $openstack->identityV3(); $result = $identity->validateToken('{tokenId}'); diff --git a/samples/Identity/v3/users/add_user.php b/samples/Identity/v3/users/create.php similarity index 91% rename from samples/Identity/v3/users/add_user.php rename to samples/Identity/v3/users/create.php index 892e67c7..38a066e0 100644 --- a/samples/Identity/v3/users/add_user.php +++ b/samples/Identity/v3/users/create.php @@ -9,7 +9,6 @@ 'id' => '{userId}', 'password' => '{password}' ], - 'scope' => ['project' => ['id' => '{projectId}']] ]); $identity = $openstack->identityV3(); diff --git a/samples/Identity/v3/users/delete_user.php b/samples/Identity/v3/users/delete.php similarity index 78% rename from samples/Identity/v3/users/delete_user.php rename to samples/Identity/v3/users/delete.php index 3dc90d20..715a7a09 100644 --- a/samples/Identity/v3/users/delete_user.php +++ b/samples/Identity/v3/users/delete.php @@ -9,11 +9,6 @@ 'id' => '{userId}', 'password' => '{password}' ], - 'scope' => [ - 'project' => [ - 'id' => '{projectId}' - ] - ] ]); $identity = $openstack->identityV3(); diff --git a/samples/Identity/v3/users/list_users.php b/samples/Identity/v3/users/list.php similarity index 80% rename from samples/Identity/v3/users/list_users.php rename to samples/Identity/v3/users/list.php index b03b3a73..a52becd9 100644 --- a/samples/Identity/v3/users/list_users.php +++ b/samples/Identity/v3/users/list.php @@ -9,11 +9,6 @@ 'id' => '{userId}', 'password' => '{password}' ], - 'scope' => [ - 'project' => [ - 'id' => '{projectId}' - ] - ] ]); $identity = $openstack->identityV3(); diff --git a/samples/Identity/v3/users/list_groups.php b/samples/Identity/v3/users/list_groups.php index af554436..f2156d8e 100644 --- a/samples/Identity/v3/users/list_groups.php +++ b/samples/Identity/v3/users/list_groups.php @@ -9,11 +9,6 @@ 'id' => '{userId}', 'password' => '{password}' ], - 'scope' => [ - 'project' => [ - 'id' => '{projectId}' - ] - ] ]); $identity = $openstack->identityV3(); diff --git a/samples/Identity/v3/users/list_projects.php b/samples/Identity/v3/users/list_projects.php index 9e36f21e..edae2e9d 100644 --- a/samples/Identity/v3/users/list_projects.php +++ b/samples/Identity/v3/users/list_projects.php @@ -9,11 +9,6 @@ 'id' => '{userId}', 'password' => '{password}' ], - 'scope' => [ - 'project' => [ - 'id' => '{projectId}' - ] - ] ]); $identity = $openstack->identityV3(); diff --git a/samples/Identity/v3/users/get_user.php b/samples/Identity/v3/users/read.php similarity index 78% rename from samples/Identity/v3/users/get_user.php rename to samples/Identity/v3/users/read.php index df4924b4..432da367 100644 --- a/samples/Identity/v3/users/get_user.php +++ b/samples/Identity/v3/users/read.php @@ -9,11 +9,6 @@ 'id' => '{userId}', 'password' => '{password}' ], - 'scope' => [ - 'project' => [ - 'id' => '{projectId}' - ] - ] ]); $identity = $openstack->identityV3(); diff --git a/samples/Identity/v3/users/update_user.php b/samples/Identity/v3/users/update.php similarity index 81% rename from samples/Identity/v3/users/update_user.php rename to samples/Identity/v3/users/update.php index 2c4dc2b5..0bb3af76 100644 --- a/samples/Identity/v3/users/update_user.php +++ b/samples/Identity/v3/users/update.php @@ -9,11 +9,6 @@ 'id' => '{userId}', 'password' => '{password}' ], - 'scope' => [ - 'project' => [ - 'id' => '{projectId}' - ] - ] ]); $identity = $openstack->identityV3(); diff --git a/tests/sample/Identity/v3/EndpointTest.php b/tests/sample/Identity/v3/EndpointTest.php index e9bc4e68..4aec0854 100644 --- a/tests/sample/Identity/v3/EndpointTest.php +++ b/tests/sample/Identity/v3/EndpointTest.php @@ -8,13 +8,13 @@ class EndpointTest extends TestCase { - public function testAdd(): Endpoint + public function testCreate(): Endpoint { $service = $this->getService()->createService(['name' => $this->randomStr(), 'type' => 'volume', 'description' => $this->randomStr()]); /** @var $endpoint \OpenStack\Identity\v3\Models\Endpoint */ require_once $this->sampleFile( - 'endpoints/add_endpoint.php', + 'endpoints/create.php', [ '{endpointName}' => $this->randomStr(), '{serviceId}' => $service->id, @@ -28,13 +28,13 @@ public function testAdd(): Endpoint } /** - * @depends testAdd + * @depends testCreate */ public function testList(Endpoint $createdEndpoint) { $found = false; require_once $this->sampleFile( - 'endpoints/list_endpoints.php', + 'endpoints/list.php', [ '/** @var $endpoint \OpenStack\Identity\v3\Models\Endpoint */' => <<<'PHP' /** @var $endpoint \OpenStack\Identity\v3\Models\Endpoint */ @@ -50,14 +50,14 @@ public function testList(Endpoint $createdEndpoint) } /** - * @depends testAdd + * @depends testCreate */ public function testUpdate(Endpoint $createdEndpoint) { $this->assertEquals(Enum::INTERFACE_INTERNAL, $createdEndpoint->interface); require_once $this->sampleFile( - 'endpoints/update_endpoint.php', + 'endpoints/update.php', [ '{endpointId}' => $createdEndpoint->id, ] @@ -68,12 +68,12 @@ public function testUpdate(Endpoint $createdEndpoint) } /** - * @depends testAdd + * @depends testCreate */ public function testDelete(Endpoint $createdEndpoint) { require_once $this->sampleFile( - 'endpoints/delete_endpoint.php', + 'endpoints/delete.php', [ '{endpointId}' => $createdEndpoint->id, ] diff --git a/tests/sample/Identity/v3/GroupTest.php b/tests/sample/Identity/v3/GroupTest.php index 602fa7ff..e910e2de 100644 --- a/tests/sample/Identity/v3/GroupTest.php +++ b/tests/sample/Identity/v3/GroupTest.php @@ -7,14 +7,14 @@ class GroupTest extends TestCase { - public function testAdd(): array + public function testCreate(): array { $name = $this->randomStr(); $description = $this->randomStr(); /** @var $group \OpenStack\Identity\v3\Models\Group */ require_once $this->sampleFile( - 'groups/add_group.php', + 'groups/create.php', [ '{name}' => $name, '{description}' => $description, @@ -31,7 +31,7 @@ public function testAdd(): array } /** - * @depends testAdd + * @depends testCreate */ public function testAddUser(array $groupAndUser): void { @@ -53,7 +53,7 @@ public function testAddUser(array $groupAndUser): void } /** - * @depends testAdd + * @depends testCreate */ public function testCheckMembership(array $groupAndUser): void { @@ -61,7 +61,7 @@ public function testCheckMembership(array $groupAndUser): void /** @var $createdUser \OpenStack\Identity\v3\Models\User */ [$createdGroup, $createdUser] = $groupAndUser; - /** @var $result bool */ + /** @var $hasMembership bool */ require_once $this->sampleFile( 'groups/check_user_membership.php', [ @@ -70,11 +70,11 @@ public function testCheckMembership(array $groupAndUser): void ] ); - $this->assertTrue($result); + $this->assertTrue($hasMembership); } /** - * @depends testAdd + * @depends testCreate */ public function testListUsers(array $groupAndUser): void { @@ -101,7 +101,7 @@ public function testListUsers(array $groupAndUser): void } /** - * @depends testAdd + * @depends testCreate */ public function testRemoveUser(array $groupAndUser): void { @@ -123,16 +123,16 @@ public function testRemoveUser(array $groupAndUser): void } /** - * @depends testAdd + * @depends testCreate */ - public function testGet(array $groupAndUser): void + public function testRead(array $groupAndUser): void { /** @var $createdGroup \OpenStack\Identity\v3\Models\Group */ [$createdGroup] = $groupAndUser; /** @var $group \OpenStack\Identity\v3\Models\Group */ require_once $this->sampleFile( - 'groups/get_group.php', + 'groups/read.php', [ '{groupId}' => $createdGroup->id, ] @@ -144,7 +144,7 @@ public function testGet(array $groupAndUser): void } /** - * @depends testAdd + * @depends testCreate */ public function testUpdate(array $groupAndUser): void { @@ -155,7 +155,7 @@ public function testUpdate(array $groupAndUser): void $newDescription = $this->randomStr(); require_once $this->sampleFile( - 'groups/update_group.php', + 'groups/update.php', [ '{groupId}' => $createdGroup->id, '{name}' => $newName, @@ -169,7 +169,7 @@ public function testUpdate(array $groupAndUser): void } /** - * @depends testAdd + * @depends testCreate */ public function testList(array $groupAndUser): void { @@ -178,7 +178,7 @@ public function testList(array $groupAndUser): void $found = false; require_once $this->sampleFile( - 'groups/list_groups.php', + 'groups/list.php', [ '{groupId}' => $createdGroup->id, '/** @var $group \OpenStack\Identity\v3\Models\Group */' => <<<'PHP' @@ -196,7 +196,7 @@ public function testList(array $groupAndUser): void /** - * @depends testAdd + * @depends testCreate */ public function testDelete(array $groupAndUser): void { @@ -204,7 +204,7 @@ public function testDelete(array $groupAndUser): void [$createdGroup] = $groupAndUser; require_once $this->sampleFile( - 'groups/delete_group.php', + 'groups/delete.php', [ '{groupId}' => $createdGroup->id, ] diff --git a/tests/sample/Identity/v3/ProjectTest.php b/tests/sample/Identity/v3/ProjectTest.php index ea72d79e..5e54a05a 100644 --- a/tests/sample/Identity/v3/ProjectTest.php +++ b/tests/sample/Identity/v3/ProjectTest.php @@ -7,11 +7,11 @@ class ProjectTest extends TestCase { - public function testAdd(): Project + public function testCreate(): Project { /** @var $project \OpenStack\Identity\v3\Models\Project */ require_once $this->sampleFile( - 'projects/add_project.php', + 'projects/create.php', ['{name}' => $this->randomStr(), '{description}' => $this->randomStr()] ); $this->assertInstanceOf(Project::class, $project); @@ -20,19 +20,19 @@ public function testAdd(): Project } /** - * @depends testAdd + * @depends testCreate */ - public function testGet(Project $createdProject) + public function testRead(Project $createdProject) { /** @var $project \OpenStack\Identity\v3\Models\Project */ - require_once $this->sampleFile('projects/get_project.php', ['{id}' => $createdProject->id]); + require_once $this->sampleFile('projects/read.php', ['{id}' => $createdProject->id]); $this->assertInstanceOf(Project::class, $project); $this->assertEquals($createdProject->id, $project->id); $this->assertEquals($createdProject->name, $project->name); } /** - * @depends testAdd + * @depends testCreate */ public function testGrantGroupRole(Project $createdProject): array { @@ -55,7 +55,7 @@ public function testGrantGroupRole(Project $createdProject): array } /** - * @depends testAdd + * @depends testCreate * @depends testGrantGroupRole */ public function testCheckGroupRole(Project $createdProject, array $createdRoleAndGroup) @@ -76,7 +76,7 @@ public function testCheckGroupRole(Project $createdProject, array $createdRoleAn } /** - * @depends testAdd + * @depends testCreate * @depends testGrantGroupRole */ public function testListGroupRoles(Project $createdProject, array $createdRoleAndGroup) @@ -103,7 +103,7 @@ public function testListGroupRoles(Project $createdProject, array $createdRoleAn } /** - * @depends testAdd + * @depends testCreate * @depends testGrantGroupRole */ public function testRevokeGroupRole(Project $createdProject, array $createdRoleAndGroup) @@ -125,7 +125,7 @@ public function testRevokeGroupRole(Project $createdProject, array $createdRoleA } /** - * @depends testAdd + * @depends testCreate */ public function testGrantUserRole(Project $createdProject): array { @@ -147,7 +147,7 @@ public function testGrantUserRole(Project $createdProject): array } /** - * @depends testAdd + * @depends testCreate * @depends testGrantUserRole */ public function testCheckUserRole(Project $createdProject, array $createdRoleAndUser) @@ -168,7 +168,7 @@ public function testCheckUserRole(Project $createdProject, array $createdRoleAnd } /** - * @depends testAdd + * @depends testCreate * @depends testGrantUserRole */ public function testListUserRoles(Project $createdProject, array $createdRoleAndUser) @@ -195,7 +195,7 @@ public function testListUserRoles(Project $createdProject, array $createdRoleAnd } /** - * @depends testAdd + * @depends testCreate * @depends testGrantUserRole */ public function testRevokeUserRole(Project $createdProject, array $createdRoleAndUser) @@ -217,24 +217,24 @@ public function testRevokeUserRole(Project $createdProject, array $createdRoleAn } /** - * @depends testAdd + * @depends testCreate */ public function testUpdate(Project $createdProject) { $this->assertTrue($createdProject->enabled); - require_once $this->sampleFile('projects/update_project.php', ['{id}' => $createdProject->id]); + require_once $this->sampleFile('projects/update.php', ['{id}' => $createdProject->id]); $createdProject->retrieve(); $this->assertFalse($createdProject->enabled); } /** - * @depends testAdd + * @depends testCreate */ public function testDelete(Project $createdProject) { - require_once $this->sampleFile('projects/delete_project.php', ['{id}' => $createdProject->id]); + require_once $this->sampleFile('projects/delete.php', ['{id}' => $createdProject->id]); $found = false; foreach ($this->getService()->listProjects() as $project) { diff --git a/tests/sample/Identity/v3/RoleTest.php b/tests/sample/Identity/v3/RoleTest.php index 059a1b66..77648be6 100644 --- a/tests/sample/Identity/v3/RoleTest.php +++ b/tests/sample/Identity/v3/RoleTest.php @@ -6,23 +6,23 @@ class RoleTest extends TestCase { - public function testAdd(): Role + public function testCeate(): Role { /** @var $role \OpenStack\Identity\v3\Models\Role */ - require_once $this->sampleFile('roles/add_role.php', ['{name}' => $this->randomStr()]); + require_once $this->sampleFile('roles/create.php', ['{name}' => $this->randomStr()]); $this->assertInstanceOf(Role::class, $role); return $role; } /** - * @depends testAdd + * @depends testCeate */ public function testList(Role $createdRole): void { $found = false; require_once $this->sampleFile( - 'roles/list_roles.php', + 'roles/list.php', [ '/** @var $role \OpenStack\Identity\v3\Models\Role */' => <<<'PHP' /** @var $role \OpenStack\Identity\v3\Models\Role */ @@ -38,7 +38,7 @@ public function testList(Role $createdRole): void } /** - * @depends testAdd + * @depends testCeate */ public function testListAssignments(Role $createdRole): void { diff --git a/tests/sample/Identity/v3/ServiceTest.php b/tests/sample/Identity/v3/ServiceTest.php index 48e4d11a..a93148d5 100644 --- a/tests/sample/Identity/v3/ServiceTest.php +++ b/tests/sample/Identity/v3/ServiceTest.php @@ -7,11 +7,11 @@ class ServiceTest extends TestCase { - public function testAdd(): \OpenStack\Identity\v3\Models\Service + public function testCreate(): \OpenStack\Identity\v3\Models\Service { /** @var $service \OpenStack\Identity\v3\Models\Service */ require_once $this->sampleFile( - 'services/add_service.php', + 'services/create.php', [ '{serviceName}' => $this->randomStr(), '{serviceType}' => $this->randomStr(), @@ -23,13 +23,13 @@ public function testAdd(): \OpenStack\Identity\v3\Models\Service } /** - * @depends testAdd + * @depends testCreate */ public function testList(\OpenStack\Identity\v3\Models\Service $createdService) { $found = false; require_once $this->sampleFile( - 'services/list_services.php', + 'services/list.php', [ '/** @var $service \OpenStack\Identity\v3\Models\Service */' => <<<'PHP' /** @var $service \OpenStack\Identity\v3\Models\Service */ @@ -45,14 +45,14 @@ public function testList(\OpenStack\Identity\v3\Models\Service $createdService) } /** - * @depends testAdd + * @depends testCreate */ public function testUpdate(\OpenStack\Identity\v3\Models\Service $createdService) { $newDescription = $this->randomStr(); require_once $this->sampleFile( - 'services/update_service.php', + 'services/update.php', [ '{serviceId}' => $createdService->id, '{description}' => $newDescription, @@ -64,13 +64,13 @@ public function testUpdate(\OpenStack\Identity\v3\Models\Service $createdService } /** - * @depends testAdd + * @depends testCreate */ public function testGet(\OpenStack\Identity\v3\Models\Service $createdService) { /** @var $service \OpenStack\Identity\v3\Models\Service */ require_once $this->sampleFile( - 'services/get_service.php', + 'services/read.php', [ '{serviceId}' => $createdService->id, ] @@ -82,12 +82,12 @@ public function testGet(\OpenStack\Identity\v3\Models\Service $createdService) } /** - * @depends testAdd + * @depends testCreate */ public function testDelete(\OpenStack\Identity\v3\Models\Service $createdService) { require_once $this->sampleFile( - 'services/delete_service.php', + 'services/delete.php', [ '{serviceId}' => $createdService->id, ] diff --git a/tests/sample/Identity/v3/UserTest.php b/tests/sample/Identity/v3/UserTest.php index 2fabbe46..313cbc50 100644 --- a/tests/sample/Identity/v3/UserTest.php +++ b/tests/sample/Identity/v3/UserTest.php @@ -7,14 +7,14 @@ class UserTest extends TestCase { - public function testAdd(): User + public function testCreate(): User { $domain = $this->getService()->createDomain(['name' => $this->randomStr()]); $project = $this->getService()->createProject(['name' => $this->randomStr(), 'domainId' => $domain->id]); /** @var $user \OpenStack\Identity\v3\Models\User */ require_once $this->sampleFile( - 'users/add_user.php', + 'users/create.php', [ '{defaultProjectId}' => $project->id, '{description}' => $this->randomStr(), @@ -31,12 +31,12 @@ public function testAdd(): User } /** - * @depends testAdd + * @depends testCreate */ - public function testGet(User $createdUser): void + public function testRead(User $createdUser): void { /** @var $user \OpenStack\Identity\v3\Models\User */ - require_once $this->sampleFile('users/get_user.php', ['{id}' => $createdUser->id]); + require_once $this->sampleFile('users/read.php', ['{id}' => $createdUser->id]); $this->assertInstanceOf(User::class, $user); $this->assertEquals($createdUser->id, $user->id); @@ -45,13 +45,13 @@ public function testGet(User $createdUser): void } /** - * @depends testAdd + * @depends testCreate */ public function testList(User $createdUser): void { $found = false; require_once $this->sampleFile( - 'users/list_users.php', + 'users/list.php', [ '/** @var $user \OpenStack\Identity\v3\Models\User */' => <<<'PHP' /** @var $user \OpenStack\Identity\v3\Models\User */ @@ -67,7 +67,7 @@ public function testList(User $createdUser): void } /** - * @depends testAdd + * @depends testCreate */ public function testListGroups(User $createdUser): void { @@ -93,7 +93,7 @@ public function testListGroups(User $createdUser): void } /** - * @depends testAdd + * @depends testCreate */ public function testListProjects(User $createdUser): void { @@ -121,7 +121,7 @@ public function testListProjects(User $createdUser): void } /** - * @depends testAdd + * @depends testCreate */ public function testUpdate(User $createdUser): void { @@ -129,7 +129,7 @@ public function testUpdate(User $createdUser): void $newDescription = $this->randomStr(); require_once $this->sampleFile( - 'users/update_user.php', + 'users/update.php', [ '{id}' => $createdUser->id, '{name}' => $newName, @@ -144,11 +144,11 @@ public function testUpdate(User $createdUser): void } /** - * @depends testAdd + * @depends testCreate */ public function testDelete(User $createdUser): void { - require_once $this->sampleFile('users/delete_user.php', ['{id}' => $createdUser->id]); + require_once $this->sampleFile('users/delete.php', ['{id}' => $createdUser->id]); $found = false; foreach ($this->getService()->listUsers() as $user) { From a3d279211375383dfc6c95bf189afb5f98fb5a56 Mon Sep 17 00:00:00 2001 From: Konstantin Babushkin Date: Fri, 19 Jan 2024 09:34:07 +0100 Subject: [PATCH 36/50] clarify auth docs --- doc/services/identity/v3/create.rst | 2 ++ doc/setup.rst | 33 +++++++++------------ samples/Identity/v3/create_with_region.php | 1 - samples/Setup/scoped_to_project_id.php | 15 ---------- samples/Setup/scoped_to_project_name.php | 20 ------------- samples/Setup/{from_id.php => token_id.php} | 0 6 files changed, 16 insertions(+), 55 deletions(-) delete mode 100644 samples/Setup/scoped_to_project_id.php delete mode 100644 samples/Setup/scoped_to_project_name.php rename samples/Setup/{from_id.php => token_id.php} (100%) diff --git a/doc/services/identity/v3/create.rst b/doc/services/identity/v3/create.rst index b94864db..4290c48e 100644 --- a/doc/services/identity/v3/create.rst +++ b/doc/services/identity/v3/create.rst @@ -6,7 +6,9 @@ In order to work with the service you have to :doc:`setup the client ` f Service can be created via ``identityV3()`` method of the ``OpenStack`` object. .. sample:: Identity/v3/create.php + :full: A list of additional options can be passed to the method. For example, to change the region: .. sample:: Identity/v3/create_with_region.php + :full: diff --git a/doc/setup.rst b/doc/setup.rst index 267b2547..119303e8 100644 --- a/doc/setup.rst +++ b/doc/setup.rst @@ -17,32 +17,27 @@ There are different ways to provide the authentication credentials. See the :doc section for the full list of options. You should provide credentials to the ``OpenStack`` constructor as an array the same way you provide options to ``generateToken`` method of the ``Identity`` service. -Authenticate with user ID -~~~~~~~~~~~~~~~~~~~~~~~~~ - -.. sample:: Setup/user_id.php - Authenticate with username -~~~~~~~~~~~~~~~~~~~~~~~~~~ +-------------------------- -.. sample:: Setup/username.php +The most common way to authenticate is using the username and password of the user. You should also provide the Domain ID +as usernames will not be unique across an entire OpenStack installation -Authenticate application credential ID -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +.. sample:: Setup/username.php -.. sample:: Setup/application_credential_id.php +Authenticate with user ID +-------------------------- -Authenticate from ID -~~~~~~~~~~~~~~~~~~~~ +.. sample:: Setup/user_id.php -.. sample:: Setup/from_id.php +Authenticate application credential ID +-------------------------------------- -Scope to project ID -~~~~~~~~~~~~~~~~~~~ +.. sample:: Setup/application_credential_id.php -.. sample:: Setup/scoped_to_project_id.php +Authenticate using token ID +-------------------------- -Scope to project name -~~~~~~~~~~~~~~~~~~~~~ +If you already have a valid token, you can use it to authenticate. -.. sample:: Setup/scoped_to_project_name.php \ No newline at end of file +.. sample:: Setup/token_id.php diff --git a/samples/Identity/v3/create_with_region.php b/samples/Identity/v3/create_with_region.php index 90da3ffb..e51fa957 100644 --- a/samples/Identity/v3/create_with_region.php +++ b/samples/Identity/v3/create_with_region.php @@ -4,7 +4,6 @@ $openstack = new OpenStack\OpenStack([ 'authUrl' => '{authUrl}', - 'region' => '{region}', 'user' => [ 'id' => '{userId}', 'password' => '{password}' diff --git a/samples/Setup/scoped_to_project_id.php b/samples/Setup/scoped_to_project_id.php deleted file mode 100644 index 50035574..00000000 --- a/samples/Setup/scoped_to_project_id.php +++ /dev/null @@ -1,15 +0,0 @@ - '{authUrl}', - 'region' => '{region}', - 'user' => [ - 'id' => '{userId}', - 'password' => '{password}', - ], - 'scope' => [ - 'project' => ['id' => '{projectId}'], - ], -]); diff --git a/samples/Setup/scoped_to_project_name.php b/samples/Setup/scoped_to_project_name.php deleted file mode 100644 index 6b681609..00000000 --- a/samples/Setup/scoped_to_project_name.php +++ /dev/null @@ -1,20 +0,0 @@ - '{authUrl}', - 'region' => '{region}', - 'user' => [ - 'id' => '{userId}', - 'password' => '{password}' - ], - 'scope' => [ - 'project' => [ - 'name' => '{projectName}', - 'domain' => [ - 'id' => '{domainId}' - ] - ] - ] -]); \ No newline at end of file diff --git a/samples/Setup/from_id.php b/samples/Setup/token_id.php similarity index 100% rename from samples/Setup/from_id.php rename to samples/Setup/token_id.php From 3572575252eaf8c3ed5afe928214d97ffa7c82bc Mon Sep 17 00:00:00 2001 From: Konstantin Babushkin Date: Fri, 19 Jan 2024 09:42:03 +0100 Subject: [PATCH 37/50] fix samples --- doc/_exts/samples.py | 2 +- doc/services/identity/v2/index.rst | 2 +- samples/Identity/v2/authentication.php | 2 -- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/doc/_exts/samples.py b/doc/_exts/samples.py index 4bae923e..7c3910a0 100644 --- a/doc/_exts/samples.py +++ b/doc/_exts/samples.py @@ -18,7 +18,7 @@ def run(self): pattern = r"[\s+]?(\<\?php.*?]\);)" code_block = super(Sample, self).run()[0] - if 'force' in self.options: + if 'full' in self.options: return [code_block] string = str(code_block[0]) diff --git a/doc/services/identity/v2/index.rst b/doc/services/identity/v2/index.rst index c4960b9f..b0000411 100644 --- a/doc/services/identity/v2/index.rst +++ b/doc/services/identity/v2/index.rst @@ -3,7 +3,7 @@ Identity v2 We recommend users to use Identity v3 when possible. -Some public, however, are still using Keystone v2.0. This following code will work for such providers. +Some public clouds, however, might still use Keystone v2. This following code will work for such providers. .. sample:: Identity/v2/authentication.php :full: diff --git a/samples/Identity/v2/authentication.php b/samples/Identity/v2/authentication.php index 89cd14d1..eb03c73d 100644 --- a/samples/Identity/v2/authentication.php +++ b/samples/Identity/v2/authentication.php @@ -24,8 +24,6 @@ 'identityService' => Service::factory($httpClient), ]; -/** @var OpenStack $openstack */ $openstack = new OpenStack($options); -/** @var \OpenStack\Compute\v2\Models\Server[] $servers */ $servers = $openstack->computeV2()->listServers(); From 090571a4720751cd683e7984b4221d0054cf38ca Mon Sep 17 00:00:00 2001 From: Konstantin Babushkin Date: Fri, 19 Jan 2024 13:19:38 +0100 Subject: [PATCH 38/50] - Block Storage - exclude common dir --- doc/conf.py | 2 +- doc/services/block-storage/v2/index.rst | 2 +- doc/services/block-storage/v3/create.rst | 12 +++ doc/services/block-storage/v3/index.rst | 9 ++- doc/services/block-storage/v3/snapshots.rst | 18 +++-- .../block-storage/v3/volume-types.rst | 58 ++++++-------- doc/services/block-storage/v3/volumes.rst | 75 ++++++++----------- doc/services/identity/v3/create.rst | 2 - doc/setup.rst | 4 +- samples/BlockStorage/v2/create.php | 14 ++++ samples/BlockStorage/v2/create_service.php | 12 --- samples/BlockStorage/v3/create.php | 14 ++++ .../BlockStorage/v3/create_with_region.php | 13 ++++ .../BlockStorage/v3/volume_types/create.php | 6 +- .../BlockStorage/v3/volume_types/delete.php | 6 +- samples/BlockStorage/v3/volume_types/list.php | 6 +- .../v3/volume_types/{get.php => read.php} | 7 +- .../BlockStorage/v3/volume_types/update.php | 6 +- samples/BlockStorage/v3/volumes/create.php | 16 ++-- .../v3/volumes/create_from_image.php | 14 ++-- .../v3/volumes/create_from_snapshot.php | 6 +- .../v3/volumes/create_from_source_volume.php | 19 ----- .../v3/volumes/create_from_volume.php | 21 ++++++ samples/BlockStorage/v3/volumes/delete.php | 6 +- samples/BlockStorage/v3/volumes/list.php | 6 +- .../BlockStorage/v3/volumes/list_detail.php | 6 +- .../v3/volumes/{get.php => read.php} | 7 +- samples/BlockStorage/v3/volumes/update.php | 6 +- tests/sample/BlockStorage/v3/VolumeTest.php | 8 +- .../sample/BlockStorage/v3/VolumeTypeTest.php | 8 +- 30 files changed, 221 insertions(+), 168 deletions(-) create mode 100644 doc/services/block-storage/v3/create.rst create mode 100644 samples/BlockStorage/v2/create.php delete mode 100644 samples/BlockStorage/v2/create_service.php create mode 100644 samples/BlockStorage/v3/create.php create mode 100644 samples/BlockStorage/v3/create_with_region.php rename samples/BlockStorage/v3/volume_types/{get.php => read.php} (66%) delete mode 100644 samples/BlockStorage/v3/volumes/create_from_source_volume.php create mode 100644 samples/BlockStorage/v3/volumes/create_from_volume.php rename samples/BlockStorage/v3/volumes/{get.php => read.php} (65%) diff --git a/doc/conf.py b/doc/conf.py index 1c8818fc..c5ad539a 100755 --- a/doc/conf.py +++ b/doc/conf.py @@ -38,7 +38,7 @@ copyright = u'2015-2023, PHP OpenCloud & contributors' version = '1.12' release = '1.12.1' -exclude_patterns = ['_build'] +exclude_patterns = ['_build', 'common'] pygments_style = 'sphinx' html_theme = 'sphinx_rtd_theme' diff --git a/doc/services/block-storage/v2/index.rst b/doc/services/block-storage/v2/index.rst index 9e046e31..602969ab 100644 --- a/doc/services/block-storage/v2/index.rst +++ b/doc/services/block-storage/v2/index.rst @@ -6,4 +6,4 @@ It is recommended to use Block Storage v3 API instead. However most of endpoints to use Block Storage v2 API, you can use the change `$openstack->blockStorageV3()` to `$openstack->blockStorageV2()` in examples. In most cases it will work without any other changes. -.. sample:: BlockStorage/v2/create_service.php +.. sample:: BlockStorage/v2/create.php diff --git a/doc/services/block-storage/v3/create.rst b/doc/services/block-storage/v3/create.rst new file mode 100644 index 00000000..288b0371 --- /dev/null +++ b/doc/services/block-storage/v3/create.rst @@ -0,0 +1,12 @@ +Create Service +============== + +In order to work with the service you have to :doc:`setup the client ` first. + +Service can be created via ``blockStorageV3()`` method of the ``OpenStack`` object. + +.. sample:: BlockStorage/v3/create.php + +A list of additional options can be passed to the method. For example, to change the region: + +.. sample:: BlockStorage/v3/create_with_region.php diff --git a/doc/services/block-storage/v3/index.rst b/doc/services/block-storage/v3/index.rst index d012ed56..62bdd764 100644 --- a/doc/services/block-storage/v3/index.rst +++ b/doc/services/block-storage/v3/index.rst @@ -2,8 +2,9 @@ Block Storage v3 ================ .. toctree:: - :maxdepth: 3 + :maxdepth: 3 - volumes - volume-types - snapshots + create + volumes + volume-types + snapshots diff --git a/doc/services/block-storage/v3/snapshots.rst b/doc/services/block-storage/v3/snapshots.rst index e3aea5f5..60b25f1b 100644 --- a/doc/services/block-storage/v3/snapshots.rst +++ b/doc/services/block-storage/v3/snapshots.rst @@ -1,18 +1,26 @@ Snapshots ========= -List volumes ------------- +a read-only point in time copy of a volume. The snapshot can be created from a volume that is currently in use +or in an available state. The snapshot can then be used to create a new volume. + +.. osdoc:: https://docs.openstack.org/api-ref/block-storage/v3/#volume-snapshots-snapshots + +.. |models| replace:: snapshots + +.. include:: /common/service.rst + +List +---- .. sample:: BlockStorage/v3/snapshots/list.php -.. refdoc:: OpenStack/BlockStorage/v2/Service.html#method_listSnapshots Each iteration will return a php:class:`Snapshot` instance . .. include:: /common/generators.rst -List volumes sorted -~~~~~~~~~~~~~~~~~~~ +List sorted +~~~~~~~~~~~ Possible values for sort_key are: diff --git a/doc/services/block-storage/v3/volume-types.rst b/doc/services/block-storage/v3/volume-types.rst index b89d0222..e052e010 100644 --- a/doc/services/block-storage/v3/volume-types.rst +++ b/doc/services/block-storage/v3/volume-types.rst @@ -1,59 +1,45 @@ Volume Types ============ -Listing volume types --------------------- -.. sample:: BlockStorage/v3/volume_types/list.php -.. refdoc:: OpenStack/BlockStorage/v2/Service.html#method_listVolumeTypes +Volume type is a group of volume policies. They can be used to specify which driver must be used on volume creation. -Each iteration will return a :php:class:`VolumeType` instance . +.. osdoc:: https://docs.openstack.org/api-ref/block-storage/v3/#volumes-volumes -.. include:: /common/generators.rst +.. |models| replace:: volume types +.. include:: /common/service.rst -Create volume type ------------------- +Create +------ -The only attributes that are required when creating a volume are a name. The simplest example -would therefore be this: +The only attributes that are required when creating a volume are a name. .. sample:: BlockStorage/v3/volume_types/create.php -.. refdoc:: OpenStack/BlockStorage/v2/Service.html#method_createVolumeType - - -Retrieve details of a volume type ---------------------------------- - -When retrieving a volume type, sometimes you only want to operate on it - say to update or delete it. If this is the -case, then there is no need to perform an initial GET request to the API: - -.. sample:: BlockStorage/v3/volume_types/get.php - -If, however, you *do* want to retrieve all the details of a remote volume type from the API, you just call: -.. code-block:: php - $volumeType->retrieve(); +Read +---- -which will update the state of the local object. This gives you an element of control over your app's performance. +.. sample:: BlockStorage/v3/volume_types/read.php -.. refdoc:: OpenStack/BlockStorage/v2/Service.html#method_getVolumeType - -Update a volume type --------------------- - -The first step when updating a volume type is modifying the attributes you want updated. By default, only a volume -type's name can be edited. +Update +------ .. sample:: BlockStorage/v3/volume_types/update.php -.. refdoc:: OpenStack/BlockStorage/v2/Models/VolumeType.html#method_update -Delete volume type ------------------- +Delete +------ To permanently delete a volume type: .. sample:: BlockStorage/v3/volume_types/delete.php -.. refdoc:: OpenStack/BlockStorage/v2/Models/VolumeType.html#method_delete \ No newline at end of file + +List +---- +.. sample:: BlockStorage/v3/volume_types/list.php + +Each iteration will return a :php:class:`VolumeType` instance . + +.. include:: /common/generators.rst diff --git a/doc/services/block-storage/v3/volumes.rst b/doc/services/block-storage/v3/volumes.rst index 82843b6c..1f0c2dfa 100644 --- a/doc/services/block-storage/v3/volumes.rst +++ b/doc/services/block-storage/v3/volumes.rst @@ -1,26 +1,17 @@ Volumes ======= -List volumes ------------- +A volume is a detachable block storage device similar to a USB hard drive. You can attach a volume to an instance, and +if the volume is of an appropriate volume type, a volume can be attached to multiple instances. -.. sample:: BlockStorage/v3/volumes/list.php -.. refdoc:: OpenStack/BlockStorage/v2/Service.html#method_listVolumes - -Each iteration will return a php:class:`Volume` instance . +.. osdoc:: https://docs.openstack.org/api-ref/block-storage/v3/#volumes-volumes -.. include:: /common/generators.rst +.. |models| replace:: volumes -Detailed information -~~~~~~~~~~~~~~~~~~~~ +.. include:: /common/service.rst -By default, only the ``id``, ``links`` and ``name`` attributes are returned. To return *all* information -for a flavor, you must enable detailed information, like so: - -.. sample:: BlockStorage/v3/volumes/list_detail.php - -Create volume -------------- +Create +------ The only attributes that are required when creating a volume are a size in GiB. The simplest example would therefore be this: @@ -30,8 +21,6 @@ would therefore be this: You can further configure your new volume, however, by following the below sections, which instruct you how to add specific functionality. -.. refdoc:: OpenStack/BlockStorage/v2/Service.html#method_createVolume - Create from image ~~~~~~~~~~~~~~~~~ @@ -42,44 +31,46 @@ Create from snapshot .. sample:: BlockStorage/v3/volumes/create_from_snapshot.php -Create from source volume -~~~~~~~~~~~~~~~~~~~~~~~~~ - -.. sample:: BlockStorage/v3/volumes/create_from_source_volume.php +Create from volume +~~~~~~~~~~~~~~~~~~ +.. sample:: BlockStorage/v3/volumes/create_from_volume.php -Retrieve volume details ------------------------ -When retrieving a volume, sometimes you only want to operate on it - say to update or delete it. If this is the case, -then there is no need to perform an initial GET request to the API: +Read +---- .. sample:: BlockStorage/v3/volumes/get.php -If, however, you *do* want to retrieve all the details of a remote volume from the API, you just call: -.. code-block:: php +Update +------ - $volume->retrieve(); +The first step when updating a volume is modifying the attributes you want updated. Only a volume's name +and description can be edited. -which will update the state of the local object. This gives you an element of control over your app's performance. +.. sample:: BlockStorage/v3/volumes/update.php -.. refdoc:: OpenStack/BlockStorage/v2/Service.html#method_getVolume +Delete +------ +To permanently delete a volume: -Update volume -------------- +.. sample:: BlockStorage/v3/volumes/delete.php -The first step when updating a volume is modifying the attributes you want updated. By default, only a volume's name -and description can be edited. +List +---- -.. sample:: BlockStorage/v3/volumes/update.php -.. refdoc:: OpenStack/BlockStorage/v2/Models/Volume.html#method_update +.. sample:: BlockStorage/v3/volumes/list.php -Delete volume -------------- +Each iteration will return a php:class:`Volume` instance . -To permanently delete a volume: +.. include:: /common/generators.rst -.. sample:: BlockStorage/v3/volumes/delete.php -.. refdoc:: OpenStack/BlockStorage/v2/Models/Volume.html#method_delete \ No newline at end of file +Detailed information +~~~~~~~~~~~~~~~~~~~~ + +By default, only the ``id``, ``links`` and ``name`` attributes are returned. To return *all* information +for a flavor, you must enable detailed information: + +.. sample:: BlockStorage/v3/volumes/list_detail.php diff --git a/doc/services/identity/v3/create.rst b/doc/services/identity/v3/create.rst index 4290c48e..b94864db 100644 --- a/doc/services/identity/v3/create.rst +++ b/doc/services/identity/v3/create.rst @@ -6,9 +6,7 @@ In order to work with the service you have to :doc:`setup the client ` f Service can be created via ``identityV3()`` method of the ``OpenStack`` object. .. sample:: Identity/v3/create.php - :full: A list of additional options can be passed to the method. For example, to change the region: .. sample:: Identity/v3/create_with_region.php - :full: diff --git a/doc/setup.rst b/doc/setup.rst index 119303e8..96fa2957 100644 --- a/doc/setup.rst +++ b/doc/setup.rst @@ -26,7 +26,7 @@ as usernames will not be unique across an entire OpenStack installation .. sample:: Setup/username.php Authenticate with user ID --------------------------- +------------------------- .. sample:: Setup/user_id.php @@ -36,7 +36,7 @@ Authenticate application credential ID .. sample:: Setup/application_credential_id.php Authenticate using token ID --------------------------- +--------------------------- If you already have a valid token, you can use it to authenticate. diff --git a/samples/BlockStorage/v2/create.php b/samples/BlockStorage/v2/create.php new file mode 100644 index 00000000..eab4bfb9 --- /dev/null +++ b/samples/BlockStorage/v2/create.php @@ -0,0 +1,14 @@ + '{authUrl}', + 'region' => '{region}', + 'user' => [ + 'id' => '{userId}', + 'password' => '{password}', + ], +]); + +$service = $openstack->blockStorageV2(); diff --git a/samples/BlockStorage/v2/create_service.php b/samples/BlockStorage/v2/create_service.php deleted file mode 100644 index fbed17dc..00000000 --- a/samples/BlockStorage/v2/create_service.php +++ /dev/null @@ -1,12 +0,0 @@ - '{authUrl}', - 'region' => '{region}', - 'user' => ['id' => '{userId}', 'password' => '{password}'], - 'scope' => ['project' => ['id' => '{projectId}']] -]); - -$service = $openstack->blockStorageV3(); diff --git a/samples/BlockStorage/v3/create.php b/samples/BlockStorage/v3/create.php new file mode 100644 index 00000000..eab4bfb9 --- /dev/null +++ b/samples/BlockStorage/v3/create.php @@ -0,0 +1,14 @@ + '{authUrl}', + 'region' => '{region}', + 'user' => [ + 'id' => '{userId}', + 'password' => '{password}', + ], +]); + +$service = $openstack->blockStorageV2(); diff --git a/samples/BlockStorage/v3/create_with_region.php b/samples/BlockStorage/v3/create_with_region.php new file mode 100644 index 00000000..e51fa957 --- /dev/null +++ b/samples/BlockStorage/v3/create_with_region.php @@ -0,0 +1,13 @@ + '{authUrl}', + 'user' => [ + 'id' => '{userId}', + 'password' => '{password}' + ], +]); + +$identity = $openstack->identityV3(['region' => '{region}']); \ No newline at end of file diff --git a/samples/BlockStorage/v3/volume_types/create.php b/samples/BlockStorage/v3/volume_types/create.php index 92a8eb45..abed4941 100644 --- a/samples/BlockStorage/v3/volume_types/create.php +++ b/samples/BlockStorage/v3/volume_types/create.php @@ -5,8 +5,10 @@ $openstack = new OpenStack\OpenStack([ 'authUrl' => '{authUrl}', 'region' => '{region}', - 'user' => ['id' => '{userId}', 'password' => '{password}'], - 'scope' => ['project' => ['id' => '{projectId}']] + 'user' => [ + 'id' => '{userId}', + 'password' => '{password}'] + , ]); $service = $openstack->blockStorageV3(); diff --git a/samples/BlockStorage/v3/volume_types/delete.php b/samples/BlockStorage/v3/volume_types/delete.php index c8a68b75..f0e9a2f7 100644 --- a/samples/BlockStorage/v3/volume_types/delete.php +++ b/samples/BlockStorage/v3/volume_types/delete.php @@ -5,8 +5,10 @@ $openstack = new OpenStack\OpenStack([ 'authUrl' => '{authUrl}', 'region' => '{region}', - 'user' => ['id' => '{userId}', 'password' => '{password}'], - 'scope' => ['project' => ['id' => '{projectId}']] + 'user' => [ + 'id' => '{userId}', + 'password' => '{password}'] + , ]); $service = $openstack->blockStorageV3(); diff --git a/samples/BlockStorage/v3/volume_types/list.php b/samples/BlockStorage/v3/volume_types/list.php index 288a183e..23857289 100644 --- a/samples/BlockStorage/v3/volume_types/list.php +++ b/samples/BlockStorage/v3/volume_types/list.php @@ -5,8 +5,10 @@ $openstack = new OpenStack\OpenStack([ 'authUrl' => '{authUrl}', 'region' => '{region}', - 'user' => ['id' => '{userId}', 'password' => '{password}'], - 'scope' => ['project' => ['id' => '{projectId}']] + 'user' => [ + 'id' => '{userId}', + 'password' => '{password}'] + , ]); $service = $openstack->blockStorageV3(); diff --git a/samples/BlockStorage/v3/volume_types/get.php b/samples/BlockStorage/v3/volume_types/read.php similarity index 66% rename from samples/BlockStorage/v3/volume_types/get.php rename to samples/BlockStorage/v3/volume_types/read.php index fc86ab57..b254c8ea 100644 --- a/samples/BlockStorage/v3/volume_types/get.php +++ b/samples/BlockStorage/v3/volume_types/read.php @@ -5,10 +5,13 @@ $openstack = new OpenStack\OpenStack([ 'authUrl' => '{authUrl}', 'region' => '{region}', - 'user' => ['id' => '{userId}', 'password' => '{password}'], - 'scope' => ['project' => ['id' => '{projectId}']] + 'user' => [ + 'id' => '{userId}', + 'password' => '{password}'] + , ]); $service = $openstack->blockStorageV3(); $volumeType = $service->getVolumeType('{volumeTypeId}'); +$volumeType->retrieve(); \ No newline at end of file diff --git a/samples/BlockStorage/v3/volume_types/update.php b/samples/BlockStorage/v3/volume_types/update.php index edcd9dec..bdd08ab5 100644 --- a/samples/BlockStorage/v3/volume_types/update.php +++ b/samples/BlockStorage/v3/volume_types/update.php @@ -5,8 +5,10 @@ $openstack = new OpenStack\OpenStack([ 'authUrl' => '{authUrl}', 'region' => '{region}', - 'user' => ['id' => '{userId}', 'password' => '{password}'], - 'scope' => ['project' => ['id' => '{projectId}']] + 'user' => [ + 'id' => '{userId}', + 'password' => '{password}'] + , ]); $service = $openstack->blockStorageV3(); diff --git a/samples/BlockStorage/v3/volumes/create.php b/samples/BlockStorage/v3/volumes/create.php index b8fd9308..0af2293b 100644 --- a/samples/BlockStorage/v3/volumes/create.php +++ b/samples/BlockStorage/v3/volumes/create.php @@ -5,16 +5,18 @@ $openstack = new OpenStack\OpenStack([ 'authUrl' => '{authUrl}', 'region' => '{region}', - 'user' => ['id' => '{userId}', 'password' => '{password}'], - 'scope' => ['project' => ['id' => '{projectId}']] + 'user' => [ + 'id' => '{userId}', + 'password' => '{password}', + ], ]); $service = $openstack->blockStorageV3(); $volume = $service->createVolume([ - 'description' => '{description}', - 'size' => '{size}', - 'name' => '{name}', - 'volumeType' => '{volumeType}', - 'metadata' => ['{key1}' => '{val1}'], + 'description' => '{description}', + 'size' => '{size}', + 'name' => '{name}', + 'volumeType' => '{volumeType}', + 'metadata' => ['{key1}' => '{val1}'], ]); diff --git a/samples/BlockStorage/v3/volumes/create_from_image.php b/samples/BlockStorage/v3/volumes/create_from_image.php index 81d36d9e..b561c353 100644 --- a/samples/BlockStorage/v3/volumes/create_from_image.php +++ b/samples/BlockStorage/v3/volumes/create_from_image.php @@ -5,15 +5,17 @@ $openstack = new OpenStack\OpenStack([ 'authUrl' => '{authUrl}', 'region' => '{region}', - 'user' => ['id' => '{userId}', 'password' => '{password}'], - 'scope' => ['project' => ['id' => '{projectId}']] + 'user' => [ + 'id' => '{userId}', + 'password' => '{password}', + ], ]); $service = $openstack->blockStorageV3(); $volume = $service->createVolume([ - 'description' => '{description}', - 'size' => '{size}', - 'name' => '{name}', - 'sourceVolumeId' => '{snapshotId}', + 'description' => '{description}', + 'size' => '{size}', + 'name' => '{name}', + 'imageId' => '{imageId}', ]); diff --git a/samples/BlockStorage/v3/volumes/create_from_snapshot.php b/samples/BlockStorage/v3/volumes/create_from_snapshot.php index a88c2d44..2c9de9c8 100644 --- a/samples/BlockStorage/v3/volumes/create_from_snapshot.php +++ b/samples/BlockStorage/v3/volumes/create_from_snapshot.php @@ -5,8 +5,10 @@ $openstack = new OpenStack\OpenStack([ 'authUrl' => '{authUrl}', 'region' => '{region}', - 'user' => ['id' => '{userId}', 'password' => '{password}'], - 'scope' => ['project' => ['id' => '{projectId}']] + 'user' => [ + 'id' => '{userId}', + 'password' => '{password}', + ], ]); $service = $openstack->blockStorageV3(); diff --git a/samples/BlockStorage/v3/volumes/create_from_source_volume.php b/samples/BlockStorage/v3/volumes/create_from_source_volume.php deleted file mode 100644 index 571e1231..00000000 --- a/samples/BlockStorage/v3/volumes/create_from_source_volume.php +++ /dev/null @@ -1,19 +0,0 @@ - '{authUrl}', - 'region' => '{region}', - 'user' => ['id' => '{userId}', 'password' => '{password}'], - 'scope' => ['project' => ['id' => '{projectId}']] -]); - -$service = $openstack->blockStorageV3(); - -$volume = $service->createVolume([ - 'description' => '{description}', - 'size' => '{size}', - 'name' => '{name}', - 'imageId' => '{snapshotId}', -]); diff --git a/samples/BlockStorage/v3/volumes/create_from_volume.php b/samples/BlockStorage/v3/volumes/create_from_volume.php new file mode 100644 index 00000000..a72ed00c --- /dev/null +++ b/samples/BlockStorage/v3/volumes/create_from_volume.php @@ -0,0 +1,21 @@ + '{authUrl}', + 'region' => '{region}', + 'user' => [ + 'id' => '{userId}', + 'password' => '{password}', + ], +]); + +$service = $openstack->blockStorageV3(); + +$volume = $service->createVolume([ + 'description' => '{description}', + 'size' => '{size}', + 'name' => '{name}', + 'sourceVolumeId' => '{volumeId}', +]); diff --git a/samples/BlockStorage/v3/volumes/delete.php b/samples/BlockStorage/v3/volumes/delete.php index 1821ca9e..8776244f 100644 --- a/samples/BlockStorage/v3/volumes/delete.php +++ b/samples/BlockStorage/v3/volumes/delete.php @@ -5,8 +5,10 @@ $openstack = new OpenStack\OpenStack([ 'authUrl' => '{authUrl}', 'region' => '{region}', - 'user' => ['id' => '{userId}', 'password' => '{password}'], - 'scope' => ['project' => ['id' => '{projectId}']] + 'user' => [ + 'id' => '{userId}', + 'password' => '{password}', + ], ]); $service = $openstack->blockStorageV3(); diff --git a/samples/BlockStorage/v3/volumes/list.php b/samples/BlockStorage/v3/volumes/list.php index a067b304..5f88fa84 100644 --- a/samples/BlockStorage/v3/volumes/list.php +++ b/samples/BlockStorage/v3/volumes/list.php @@ -5,8 +5,10 @@ $openstack = new OpenStack\OpenStack([ 'authUrl' => '{authUrl}', 'region' => '{region}', - 'user' => ['id' => '{userId}', 'password' => '{password}'], - 'scope' => ['project' => ['id' => '{projectId}']] + 'user' => [ + 'id' => '{userId}', + 'password' => '{password}', + ], ]); $service = $openstack->blockStorageV3(); diff --git a/samples/BlockStorage/v3/volumes/list_detail.php b/samples/BlockStorage/v3/volumes/list_detail.php index e495fbc3..2029d32c 100644 --- a/samples/BlockStorage/v3/volumes/list_detail.php +++ b/samples/BlockStorage/v3/volumes/list_detail.php @@ -5,8 +5,10 @@ $openstack = new OpenStack\OpenStack([ 'authUrl' => '{authUrl}', 'region' => '{region}', - 'user' => ['id' => '{userId}', 'password' => '{password}'], - 'scope' => ['project' => ['id' => '{projectId}']] + 'user' => [ + 'id' => '{userId}', + 'password' => '{password}', + ], ]); $service = $openstack->blockStorageV3(); diff --git a/samples/BlockStorage/v3/volumes/get.php b/samples/BlockStorage/v3/volumes/read.php similarity index 65% rename from samples/BlockStorage/v3/volumes/get.php rename to samples/BlockStorage/v3/volumes/read.php index 184c02af..d1de298e 100644 --- a/samples/BlockStorage/v3/volumes/get.php +++ b/samples/BlockStorage/v3/volumes/read.php @@ -5,10 +5,13 @@ $openstack = new OpenStack\OpenStack([ 'authUrl' => '{authUrl}', 'region' => '{region}', - 'user' => ['id' => '{userId}', 'password' => '{password}'], - 'scope' => ['project' => ['id' => '{projectId}']] + 'user' => [ + 'id' => '{userId}', + 'password' => '{password}', + ], ]); $service = $openstack->blockStorageV3(); $volume = $service->getVolume('{volumeId}'); +$volume->retrieve(); \ No newline at end of file diff --git a/samples/BlockStorage/v3/volumes/update.php b/samples/BlockStorage/v3/volumes/update.php index 371d12e8..d2ead417 100644 --- a/samples/BlockStorage/v3/volumes/update.php +++ b/samples/BlockStorage/v3/volumes/update.php @@ -5,8 +5,10 @@ $openstack = new OpenStack\OpenStack([ 'authUrl' => '{authUrl}', 'region' => '{region}', - 'user' => ['id' => '{userId}', 'password' => '{password}'], - 'scope' => ['project' => ['id' => '{projectId}']], + 'user' => [ + 'id' => '{userId}', + 'password' => '{password}', + ], ]); $service = $openstack->blockStorageV3(); diff --git a/tests/sample/BlockStorage/v3/VolumeTest.php b/tests/sample/BlockStorage/v3/VolumeTest.php index d598c26c..1f48a017 100644 --- a/tests/sample/BlockStorage/v3/VolumeTest.php +++ b/tests/sample/BlockStorage/v3/VolumeTest.php @@ -35,16 +35,18 @@ public function testCreate(): Volume /** * @depends testCreate */ - public function testGet(Volume $createdVolume) + public function testRead(Volume $createdVolume) { /** @var Volume $volume */ - require_once $this->sampleFile('volumes/get.php', [ + require_once $this->sampleFile('volumes/read.php', [ '{volumeId}' => $createdVolume->id, ]); $this->assertInstanceOf(Volume::class, $volume); $this->assertEquals($createdVolume->id, $volume->id); - $this->assertNull($volume->description); + $this->assertEquals($createdVolume->name, $volume->name); + $this->assertEquals($createdVolume->size, $volume->size); + $this->assertEquals($createdVolume->description, $volume->description); } /** diff --git a/tests/sample/BlockStorage/v3/VolumeTypeTest.php b/tests/sample/BlockStorage/v3/VolumeTypeTest.php index 94f8f4ab..05aa6b51 100644 --- a/tests/sample/BlockStorage/v3/VolumeTypeTest.php +++ b/tests/sample/BlockStorage/v3/VolumeTypeTest.php @@ -2,7 +2,6 @@ namespace OpenStack\Sample\BlockStorage\v3; -use OpenStack\BlockStorage\v2\Models\Snapshot; use OpenStack\BlockStorage\v2\Models\VolumeType; use OpenStack\Common\Error\BadResponseError; @@ -24,16 +23,13 @@ public function testCreate(): VolumeType /** * @depends testCreate */ - public function testGet(VolumeType $createdVolumeType) + public function testRead(VolumeType $createdVolumeType) { /** @var VolumeType $volumeType */ - require_once $this->sampleFile('volume_types/get.php', ['{volumeTypeId}' => $createdVolumeType->id]); + require_once $this->sampleFile('volume_types/read.php', ['{volumeTypeId}' => $createdVolumeType->id]); $this->assertInstanceOf(VolumeType::class, $volumeType); $this->assertEquals($createdVolumeType->id, $volumeType->id); - $this->assertNull($volumeType->name); - - $volumeType->retrieve(); $this->assertEquals($createdVolumeType->name, $volumeType->name); } From d349536f3817dabbc4d1ae44c6cd46811f543ef9 Mon Sep 17 00:00:00 2001 From: Konstantin Babushkin Date: Fri, 19 Jan 2024 13:22:18 +0100 Subject: [PATCH 39/50] fix sample name --- doc/services/block-storage/v3/volumes.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/services/block-storage/v3/volumes.rst b/doc/services/block-storage/v3/volumes.rst index 1f0c2dfa..9805616f 100644 --- a/doc/services/block-storage/v3/volumes.rst +++ b/doc/services/block-storage/v3/volumes.rst @@ -40,7 +40,7 @@ Create from volume Read ---- -.. sample:: BlockStorage/v3/volumes/get.php +.. sample:: BlockStorage/v3/volumes/read.php Update From fdfd5b65ef8810982c76874bc5af6fbebebd0c4a Mon Sep 17 00:00:00 2001 From: Konstantin Babushkin Date: Fri, 19 Jan 2024 17:43:29 +0100 Subject: [PATCH 40/50] fix compute v2 --- doc/services/block-storage/v3/index.rst | 5 ++ doc/services/block-storage/v3/snapshots.rst | 2 +- doc/services/compute/v2/create.rst | 12 +++ doc/services/compute/v2/flavors.rst | 46 +++++------- doc/services/compute/v2/images.rst | 18 ++--- doc/services/compute/v2/index.rst | 6 ++ doc/services/compute/v2/servers.rst | 73 ++++++------------- doc/services/compute/v2/states.rst | 2 +- doc/services/identity/v3/create.rst | 6 +- doc/services/identity/v3/index.rst | 2 +- samples/BlockStorage/v3/create.php | 2 +- .../BlockStorage/v3/create_with_region.php | 2 +- samples/Compute/v2/create.php | 14 ++++ samples/Compute/v2/create_with_region.php | 13 ++++ .../flavors/{create_flavor.php => create.php} | 5 +- .../flavors/{delete_flavor.php => delete.php} | 4 +- samples/Compute/v2/flavors/get_flavor.php | 24 ------ .../v2/flavors/{list_flavors.php => list.php} | 5 +- samples/Compute/v2/flavors/read.php | 17 +++++ .../servers/{create_server.php => create.php} | 3 +- .../servers/{delete_server.php => delete.php} | 3 +- samples/Compute/v2/servers/get_server.php | 24 ------ .../v2/servers/{list_servers.php => list.php} | 5 +- samples/Compute/v2/servers/read.php | 17 +++++ .../servers/{update_server.php => update.php} | 9 +-- src/Compute/v2/Service.php | 34 ++++----- tests/sample/Compute/v2/FlavorTest.php | 10 +-- tests/sample/Compute/v2/ServerTest.php | 9 +-- 28 files changed, 175 insertions(+), 197 deletions(-) create mode 100644 doc/services/compute/v2/create.rst create mode 100644 samples/Compute/v2/create.php create mode 100644 samples/Compute/v2/create_with_region.php rename samples/Compute/v2/flavors/{create_flavor.php => create.php} (69%) rename samples/Compute/v2/flavors/{delete_flavor.php => delete.php} (78%) delete mode 100644 samples/Compute/v2/flavors/get_flavor.php rename samples/Compute/v2/flavors/{list_flavors.php => list.php} (68%) create mode 100644 samples/Compute/v2/flavors/read.php rename samples/Compute/v2/servers/{create_server.php => create.php} (85%) rename samples/Compute/v2/servers/{delete_server.php => delete.php} (72%) delete mode 100644 samples/Compute/v2/servers/get_server.php rename samples/Compute/v2/servers/{list_servers.php => list.php} (60%) create mode 100644 samples/Compute/v2/servers/read.php rename samples/Compute/v2/servers/{update_server.php => update.php} (54%) diff --git a/doc/services/block-storage/v3/index.rst b/doc/services/block-storage/v3/index.rst index 62bdd764..7c8acfbd 100644 --- a/doc/services/block-storage/v3/index.rst +++ b/doc/services/block-storage/v3/index.rst @@ -1,6 +1,11 @@ Block Storage v3 ================ +OpenStack Block Storage API v3 (Cinder). Cinder is the OpenStack Block Storage service for providing volumes +to Nova virtual machines, Ironic bare metal hosts, containers and more. + +.. osdoc:: https://docs.openstack.org/api-ref/block-storage/v3/ + .. toctree:: :maxdepth: 3 diff --git a/doc/services/block-storage/v3/snapshots.rst b/doc/services/block-storage/v3/snapshots.rst index 60b25f1b..c2cfa83d 100644 --- a/doc/services/block-storage/v3/snapshots.rst +++ b/doc/services/block-storage/v3/snapshots.rst @@ -1,7 +1,7 @@ Snapshots ========= -a read-only point in time copy of a volume. The snapshot can be created from a volume that is currently in use +A snapshot is read-only point in time copy of a volume. The snapshot can be created from a volume that is currently in use or in an available state. The snapshot can then be used to create a new volume. .. osdoc:: https://docs.openstack.org/api-ref/block-storage/v3/#volume-snapshots-snapshots diff --git a/doc/services/compute/v2/create.rst b/doc/services/compute/v2/create.rst new file mode 100644 index 00000000..288b0371 --- /dev/null +++ b/doc/services/compute/v2/create.rst @@ -0,0 +1,12 @@ +Create Service +============== + +In order to work with the service you have to :doc:`setup the client ` first. + +Service can be created via ``blockStorageV3()`` method of the ``OpenStack`` object. + +.. sample:: BlockStorage/v3/create.php + +A list of additional options can be passed to the method. For example, to change the region: + +.. sample:: BlockStorage/v3/create_with_region.php diff --git a/doc/services/compute/v2/flavors.rst b/doc/services/compute/v2/flavors.rst index 6d71b734..7fb2409a 100644 --- a/doc/services/compute/v2/flavors.rst +++ b/doc/services/compute/v2/flavors.rst @@ -1,46 +1,36 @@ Flavors ======= -List flavors ------------- +Flavors define the compute, memory, and storage capacity of nova computing instances. To put it simply, a flavor is +an available hardware configuration for a server. It defines the size of a virtual server that can be launched. -.. sample:: Compute/v2/flavors/list_flavors.php -.. refdoc:: OpenStack/Compute/v2/Service.html#method_listFlavors +.. osdoc:: https://docs.openstack.org/nova/latest/user/flavors.html -Each iteration will return a :php:class:`Flavor` instance . - -.. include:: /common/generators.rst - -Detailed information -~~~~~~~~~~~~~~~~~~~~ +.. |models| replace:: flavors -By default, only the ``id``, ``links`` and ``name`` attributes are returned. To return *all* information -for a flavor, you must pass ``true`` as the last parameter, like so: +.. include:: /common/service.rst -.. code-block:: php +Read +---- - $flavors = $service->listFlavors([], function ($flavor) { - return $flavor; - }, true); +.. sample:: Compute/v2/flavors/read.php -Retrieve a flavor ------------------ +List +---- -.. sample:: Compute/v2/flavors/get_flavor.php -.. refdoc:: OpenStack/Compute/v2/Service.html#method_getFlavor +.. sample:: Compute/v2/flavors/list.php -When retrieving a flavor, sometimes you only want to operate on it. If this is the case, -then there is no need to perform an initial ``GET`` request to the server: +Each iteration will return a :php:class:`Flavor` instance . -.. code-block:: php +.. include:: /common/generators.rst - // Get an unpopulated object - $flavor = $service->getFlavor(['id' => '{flavorId}']); +Detailed information +~~~~~~~~~~~~~~~~~~~~ -If, however, you *do* want to retrieve all the details of a remote flavor from the API, you just call: +By default, only the ``id``, ``links`` and ``name`` attributes are returned. To return *all* information +for a flavor, you must pass ``true`` as the last parameter, like so: .. code-block:: php - $flavor->retrieve(); + $flavors = $service->listFlavors([], null, true); -which will update the state of the local object. This gives you an element of control over your app's performance. diff --git a/doc/services/compute/v2/images.rst b/doc/services/compute/v2/images.rst index 6a2ce6e7..519884d3 100644 --- a/doc/services/compute/v2/images.rst +++ b/doc/services/compute/v2/images.rst @@ -1,6 +1,12 @@ Images ====== +.. warning:: + These APIs are proxy calls to the :doc:`/services/images/v2/`Image service. + Nova has deprecated all the proxy APIs and users should use the native APIs instead. + +.. osdoc:: https://docs.openstack.org/api-ref/compute/#images-deprecated + List images ----------- @@ -9,7 +15,6 @@ List images Each iteration will return an :apiref:Image instance _. .. include:: /common/generators.rst -.. refdoc:: OpenStack/Compute/v2/Service.html#method_listImages Detailed information ~~~~~~~~~~~~~~~~~~~~ @@ -28,7 +33,6 @@ When retrieving an image, sometimes you only want to operate on it - say to upda then there is no need to perform an initial GET request to the server: .. sample:: Compute/v2/images/get_image.php -.. refdoc:: OpenStack/Compute/v2/Service.html#method_getImage If, however, you *do* want to retrieve all the details of a remote image from the API, you just call: @@ -42,7 +46,6 @@ Delete an image --------------- .. sample:: Compute/v2/images/delete_image.php -.. refdoc:: OpenStack/Compute/v2/Models/Image.html#method_delete Retrieve metadata ----------------- @@ -53,8 +56,6 @@ This operation will retrieve the existing metadata for an image: $metadata = $image->getMetadata(); -.. refdoc:: OpenStack/Compute/v2/Models/Image.html#method_getMetadata - Reset metadata -------------- @@ -63,8 +64,6 @@ Reset metadata This operation will _replace_ all existing metadata with whatever is provided in the request. Any existing metadata not specified in the request will be deleted. -.. refdoc:: OpenStack/Compute/v2/Models/Image.html#method_resetMetadata - Merge metadata -------------- @@ -77,8 +76,6 @@ will be added. Any existing keys that are not specified in the request will rema 'foo' => 'bar', ]); -.. refdoc:: OpenStack/Compute/v2/Models/Image.html#method_mergeMetadata - Retrieve image metadata item ---------------------------- @@ -88,12 +85,9 @@ This operation allows you to retrieve the value for a specific metadata item: $itemValue = $image->getMetadataItem('key'); -.. refdoc:: OpenStack/Compute/v2/Models/Image.html#method_getMetadataItem - Delete image metadata item -------------------------- This operation allows you to remove a specific metadata item: .. sample:: Compute/v2/images/delete_image_metadata_item.php -.. refdoc:: OpenStack/Compute/v2/Models/Image.html#method_deleteMetadataItem \ No newline at end of file diff --git a/doc/services/compute/v2/index.rst b/doc/services/compute/v2/index.rst index cd9b4fd4..26190cda 100644 --- a/doc/services/compute/v2/index.rst +++ b/doc/services/compute/v2/index.rst @@ -1,9 +1,15 @@ Compute v2 ========== +OpenStack Compute (Nova) API Version 2. Nova is the OpenStack project that provides a way to provision compute instances +(aka virtual servers). + +.. osdoc:: https://docs.openstack.org/api-ref/compute/ + .. toctree:: :maxdepth: 3 + create servers flavors images diff --git a/doc/services/compute/v2/servers.rst b/doc/services/compute/v2/servers.rst index eb6ed7ea..a4f27d09 100644 --- a/doc/services/compute/v2/servers.rst +++ b/doc/services/compute/v2/servers.rst @@ -1,17 +1,24 @@ Servers ======= -Listing servers ---------------- +Server is the main resource in the Compute API. It represents a virtual machine. + +.. osdoc:: https://docs.openstack.org/api-ref/compute/#servers-servers + +.. |models| replace:: servers + +.. include:: /common/service.rst + +List +---- To list a collection of servers, you run: -.. sample:: Compute/v2/servers/list_servers.php +.. sample:: Compute/v2/servers/list.php Each iteration will return a :apiref:Server instance . .. include:: /common/generators.rst -.. refdoc:: OpenStack/Compute/v2/Service.html#method_listServers Detailed information ~~~~~~~~~~~~~~~~~~~~ @@ -38,19 +45,17 @@ parameters which are documented in the reference documentation. 'flavorId' => 'performance1-1', ]); -Create a server ---------------- +Create +------ The only attributes that are required when creating a server are a name, flavor ID and image ID. The simplest example would therefore be this: -.. sample:: Compute/v2/servers/create_server.php +.. sample:: Compute/v2/servers/create.php You can further configure your new server, however, by following the below sections, which instruct you how to add specific functionality. They are interoperable and can work together. -.. refdoc:: OpenStack/Compute/v2/Service.html#method_createServer - Security groups ~~~~~~~~~~~~~~~ @@ -133,40 +138,25 @@ when the server is launched, use this option: 'baz' => 'bar', ]; -Retrieve a server ------------------ - -When retrieving a server, sometimes you only want to operate on it - say to update or delete it. If this is the case, -then there is no need to perform an initial GET request to the server: - -.. sample:: Compute/v2/servers/get_server.php +Read +---- -If, however, you *do* want to retrieve all the details of a remote server from the API, you just call: +.. sample:: Compute/v2/servers/read.php -.. code-block:: php - - $server->retrieve(); - -which will update the state of the local object. This gives you an element of control over your app's performance. - -.. refdoc:: OpenStack/Compute/v2/Service.html#method_getServer - -Update a server ---------------- +Update +------ The first step when updating a server is modifying the attributes you want updated. By default, only a server's name, IPv4 and IPv6 IPs, and its auto disk config attributes can be edited. .. sample:: Compute/v2/servers/update_server.php -.. refdoc:: OpenStack/Compute/v2/Models/Server.html#method_update -Delete a server +Delete --------------- To permanently delete a server: -.. sample:: Compute/v2/servers/delete_server.php -.. refdoc:: OpenStack/Compute/v2/Models/Server.html#method_delete +.. sample:: Compute/v2/servers/delete.php Retrieve metadata ----------------- @@ -174,7 +164,6 @@ Retrieve metadata This operation will retrieve the existing metadata for a server: .. sample:: Compute/v2/servers/get_server_metadata.php -.. refdoc:: OpenStack/Compute/v2/Models/Server.html#method_getMetadata Reset metadata -------------- @@ -183,7 +172,6 @@ This operation will _replace_ all existing metadata with whatever is provided in not specified in the request will be deleted. .. sample:: Compute/v2/servers/reset_server_metadata.php -.. refdoc:: OpenStack/Compute/v2/Models/Server.html#method_resetMetadata Merge metadata -------------- @@ -192,7 +180,6 @@ This operation will _merge_ specified metadata with what already exists. Existin will be added. Any existing keys that are not specified in the request will remain unaffected. .. sample:: Compute/v2/servers/merge_server_metadata.php -.. refdoc:: OpenStack/Compute/v2/Models/Server.html#method_mergeMetadata Retrieve metadata item ---------------------- @@ -200,7 +187,6 @@ Retrieve metadata item This operation allows you to retrieve the value for a specific metadata item: .. sample:: Compute/v2/servers/get_server_metadata_item.php -.. refdoc:: OpenStack/Compute/v2/Models/Server.html#method_getMetadataItem Delete metadata item -------------------- @@ -208,7 +194,6 @@ Delete metadata item This operation allows you to remove a specific metadata item: .. sample:: Compute/v2/servers/delete_server_metadata_item.php -.. refdoc:: OpenStack/Compute/v2/Models/Server.html#method_deleteMetadataItem Change root password -------------------- @@ -216,7 +201,6 @@ Change root password This operation will replace the root password for a server. .. sample:: Compute/v2/servers/change_server_password.php -.. refdoc:: OpenStack/Compute/v2/Models/Server.html#method_changePassword Reset server state ------------------ @@ -224,7 +208,6 @@ Reset server state This operation will reset the state of the server. .. sample:: Compute/v2/servers/reset_server_state.php -.. refdoc:: OpenStack/Compute/v2/Models/Server.html#method_resetState Reboot server ------------- @@ -233,7 +216,6 @@ This operation will reboot a server. You can specify HARD reboot by passing argu Otherwise, the default is a SOFT reboot. .. sample:: Compute/v2/servers/reboot_server.php -.. refdoc:: OpenStack/Compute/v2/Models/Server.html#method_reboot Rebuild server -------------- @@ -243,7 +225,6 @@ system. It will shutdown, re-image and then reboot your instance. Any data saved the rebuild is performed. .. sample:: Compute/v2/servers/rebuild_server.php -.. refdoc:: OpenStack/Compute/v2/Models/Server.html#method_rebuild Resize server ------------- @@ -253,7 +234,6 @@ transition to a VERIFY_RESIZE state and a VM status of RESIZED. You will either resize in order to continue. .. sample:: Compute/v2/servers/resize_server.php -.. refdoc:: OpenStack/Compute/v2/Models/Server.html#method_resize Confirm server resize --------------------- @@ -263,7 +243,6 @@ VERIFY_RESIZE and a VM status of RESIZED. Once this operation completes, the ser ACTIVE state and a migration status of confirmed. .. sample:: Compute/v2/servers/confirm_server_resize.php -.. refdoc:: OpenStack/Compute/v2/Models/Server.html#method_confirmResize Revert server resize -------------------- @@ -273,7 +252,6 @@ VERIFY_RESIZE and a VM status of RESIZED. Once this operation completes, the ser ACTIVE state and a migration status of reverted. .. sample:: Compute/v2/servers/revert_server_resize.php -.. refdoc:: OpenStack/Compute/v2/Models/Server.html#method_revertResize Create server image ------------------- @@ -282,7 +260,6 @@ This operation will create a new server image. The only required option is the n additional metadata: .. sample:: Compute/v2/images/create_server_image.php -.. refdoc:: OpenStack/Compute/v2/Models/Server.html#method_createImage List server IP addresses ------------------------ @@ -303,11 +280,3 @@ You can also refine by network label: $ipAddresses = $server->listAddresses([ 'networkLabel' => '{networkLabel}', ]); - -.. refdoc:: OpenStack/Compute/v2/Models/Server.html#method_listAddresses - -Further links -------------- - -* Reference docs for Server class -* API docs diff --git a/doc/services/compute/v2/states.rst b/doc/services/compute/v2/states.rst index 5a1106f0..ac75810c 100644 --- a/doc/services/compute/v2/states.rst +++ b/doc/services/compute/v2/states.rst @@ -1,5 +1,5 @@ Server states -------------- +============= Servers contain a status attribute that indicates the current server state. You can filter on the server status when you complete a list servers request. The server status is returned in the response body. The server status is one of diff --git a/doc/services/identity/v3/create.rst b/doc/services/identity/v3/create.rst index b94864db..c32b7699 100644 --- a/doc/services/identity/v3/create.rst +++ b/doc/services/identity/v3/create.rst @@ -3,10 +3,10 @@ Create Service In order to work with the service you have to :doc:`setup the client ` first. -Service can be created via ``identityV3()`` method of the ``OpenStack`` object. +Service can be created via ``computeV2()`` method of the ``OpenStack`` object. -.. sample:: Identity/v3/create.php +.. sample:: Compute/v3/create.php A list of additional options can be passed to the method. For example, to change the region: -.. sample:: Identity/v3/create_with_region.php +.. sample:: Compute/v3/create_with_region.php diff --git a/doc/services/identity/v3/index.rst b/doc/services/identity/v3/index.rst index 037473ed..be1cebdf 100644 --- a/doc/services/identity/v3/index.rst +++ b/doc/services/identity/v3/index.rst @@ -3,7 +3,7 @@ Identity v3 OpenStack Identity API v3. It is used to manage the `OpenStack Keystone service `_. -More information can be found in the `official documentation `_. +.. osdoc:: https://docs.openstack.org/api-ref/identity/v3/index.html .. toctree:: :maxdepth: 3 diff --git a/samples/BlockStorage/v3/create.php b/samples/BlockStorage/v3/create.php index eab4bfb9..c2cde0e1 100644 --- a/samples/BlockStorage/v3/create.php +++ b/samples/BlockStorage/v3/create.php @@ -11,4 +11,4 @@ ], ]); -$service = $openstack->blockStorageV2(); +$service = $openstack->blockStorageV3(); diff --git a/samples/BlockStorage/v3/create_with_region.php b/samples/BlockStorage/v3/create_with_region.php index e51fa957..ff100cf0 100644 --- a/samples/BlockStorage/v3/create_with_region.php +++ b/samples/BlockStorage/v3/create_with_region.php @@ -10,4 +10,4 @@ ], ]); -$identity = $openstack->identityV3(['region' => '{region}']); \ No newline at end of file +$identity = $openstack->blockStorageV3(['region' => '{region}']); \ No newline at end of file diff --git a/samples/Compute/v2/create.php b/samples/Compute/v2/create.php new file mode 100644 index 00000000..15d202f3 --- /dev/null +++ b/samples/Compute/v2/create.php @@ -0,0 +1,14 @@ + '{authUrl}', + 'region' => '{region}', + 'user' => [ + 'id' => '{userId}', + 'password' => '{password}', + ], +]); + +$service = $openstack->computeV2(); diff --git a/samples/Compute/v2/create_with_region.php b/samples/Compute/v2/create_with_region.php new file mode 100644 index 00000000..b4ecfe30 --- /dev/null +++ b/samples/Compute/v2/create_with_region.php @@ -0,0 +1,13 @@ + '{authUrl}', + 'user' => [ + 'id' => '{userId}', + 'password' => '{password}' + ], +]); + +$identity = $openstack->computeV2(['region' => '{region}']); \ No newline at end of file diff --git a/samples/Compute/v2/flavors/create_flavor.php b/samples/Compute/v2/flavors/create.php similarity index 69% rename from samples/Compute/v2/flavors/create_flavor.php rename to samples/Compute/v2/flavors/create.php index ee88ba57..0dc5ff19 100644 --- a/samples/Compute/v2/flavors/create_flavor.php +++ b/samples/Compute/v2/flavors/create.php @@ -7,12 +7,11 @@ 'region' => '{region}', 'user' => [ 'id' => '{userId}', - 'password' => '{password}' + 'password' => '{password}', ], - 'scope' => ['project' => ['id' => '{projectId}']] ]); -$compute = $openstack->computeV2(['region' => '{region}']); +$compute = $openstack->computeV2(); $flavor = $compute->createFlavor([ 'name' => '{flavorName}', diff --git a/samples/Compute/v2/flavors/delete_flavor.php b/samples/Compute/v2/flavors/delete.php similarity index 78% rename from samples/Compute/v2/flavors/delete_flavor.php rename to samples/Compute/v2/flavors/delete.php index 53d20117..91828cde 100644 --- a/samples/Compute/v2/flavors/delete_flavor.php +++ b/samples/Compute/v2/flavors/delete.php @@ -7,13 +7,11 @@ 'region' => '{region}', 'user' => [ 'id' => '{userId}', - 'password' => '{password}' + 'password' => '{password}', ], - 'scope' => ['project' => ['id' => '{projectId}']] ]); $compute = $openstack->computeV2(['region' => '{region}']); - $flavor = $compute->getFlavor(['id' => '{flavorId}']); $flavor->delete(); diff --git a/samples/Compute/v2/flavors/get_flavor.php b/samples/Compute/v2/flavors/get_flavor.php deleted file mode 100644 index acaa4dc2..00000000 --- a/samples/Compute/v2/flavors/get_flavor.php +++ /dev/null @@ -1,24 +0,0 @@ - '{authUrl}', - 'region' => '{region}', - 'user' => [ - 'id' => '{userId}', - 'password' => '{password}' - ], - 'scope' => ['project' => ['id' => '{projectId}']] -]); - -$compute = $openstack->computeV2(['region' => '{region}']); - -$flavor = $compute->getFlavor(['id' => '{flavorId}']); - -// By default, this will return an empty Flavor object and NOT hit the API. -// This is convenient for when you want to use the object for operations -// that do not require an initial GET request. To retrieve the flavor's details, -// run the following, which *will* call the API with a GET request: - -$flavor->retrieve(); diff --git a/samples/Compute/v2/flavors/list_flavors.php b/samples/Compute/v2/flavors/list.php similarity index 68% rename from samples/Compute/v2/flavors/list_flavors.php rename to samples/Compute/v2/flavors/list.php index b14eaaee..7b7730fa 100644 --- a/samples/Compute/v2/flavors/list_flavors.php +++ b/samples/Compute/v2/flavors/list.php @@ -7,12 +7,11 @@ 'region' => '{region}', 'user' => [ 'id' => '{userId}', - 'password' => '{password}' + 'password' => '{password}', ], - 'scope' => ['project' => ['id' => '{projectId}']] ]); -$compute = $openstack->computeV2(['region' => '{region}']); +$compute = $openstack->computeV2(); $flavors = $compute->listFlavors(); diff --git a/samples/Compute/v2/flavors/read.php b/samples/Compute/v2/flavors/read.php new file mode 100644 index 00000000..9ce8edbd --- /dev/null +++ b/samples/Compute/v2/flavors/read.php @@ -0,0 +1,17 @@ + '{authUrl}', + 'region' => '{region}', + 'user' => [ + 'id' => '{userId}', + 'password' => '{password}' + ], +]); + +$compute = $openstack->computeV2(); + +$flavor = $compute->getFlavor(['id' => '{flavorId}']); +$flavor->retrieve(); diff --git a/samples/Compute/v2/servers/create_server.php b/samples/Compute/v2/servers/create.php similarity index 85% rename from samples/Compute/v2/servers/create_server.php rename to samples/Compute/v2/servers/create.php index 73a9fc06..e99355e0 100644 --- a/samples/Compute/v2/servers/create_server.php +++ b/samples/Compute/v2/servers/create.php @@ -9,10 +9,9 @@ 'id' => '{userId}', 'password' => '{password}' ], - 'scope' => ['project' => ['id' => '{projectId}']] ]); -$compute = $openstack->computeV2(['region' => '{region}']); +$compute = $openstack->computeV2(); $options = [ // Required diff --git a/samples/Compute/v2/servers/delete_server.php b/samples/Compute/v2/servers/delete.php similarity index 72% rename from samples/Compute/v2/servers/delete_server.php rename to samples/Compute/v2/servers/delete.php index 48bf850f..58cd4a3a 100644 --- a/samples/Compute/v2/servers/delete_server.php +++ b/samples/Compute/v2/servers/delete.php @@ -9,10 +9,9 @@ 'id' => '{userId}', 'password' => '{password}' ], - 'scope' => ['project' => ['id' => '{projectId}']] ]); -$compute = $openstack->computeV2(['region' => '{region}']); +$compute = $openstack->computeV2(); $server = $compute->getServer(['id' => '{serverId}']); diff --git a/samples/Compute/v2/servers/get_server.php b/samples/Compute/v2/servers/get_server.php deleted file mode 100644 index 7ba12d3c..00000000 --- a/samples/Compute/v2/servers/get_server.php +++ /dev/null @@ -1,24 +0,0 @@ - '{authUrl}', - 'region' => '{region}', - 'user' => [ - 'id' => '{userId}', - 'password' => '{password}' - ], - 'scope' => ['project' => ['id' => '{projectId}']] -]); - -$compute = $openstack->computeV2(['region' => '{region}']); - -$server = $compute->getServer(['id' => '{serverId}']); - -// By default, this will return an empty Server object and NOT hit the API. -// This is convenient for when you want to use the object for operations -// that do not require an initial GET request. To retrieve the server's details, -// run the following, which *will* call the API with a GET request: - -$server->retrieve(); diff --git a/samples/Compute/v2/servers/list_servers.php b/samples/Compute/v2/servers/list.php similarity index 60% rename from samples/Compute/v2/servers/list_servers.php rename to samples/Compute/v2/servers/list.php index f853af64..f96bd4a4 100644 --- a/samples/Compute/v2/servers/list_servers.php +++ b/samples/Compute/v2/servers/list.php @@ -9,12 +9,11 @@ 'id' => '{userId}', 'password' => '{password}' ], - 'scope' => ['project' => ['id' => '{projectId}']] ]); -$compute = $openstack->computeV2(['region' => '{region}']); +$compute = $openstack->computeV2(); -$servers = $compute->listServers(['imageId' => '{imageId}']); +$servers = $compute->listServers(); foreach ($servers as $server) { } diff --git a/samples/Compute/v2/servers/read.php b/samples/Compute/v2/servers/read.php new file mode 100644 index 00000000..442086c6 --- /dev/null +++ b/samples/Compute/v2/servers/read.php @@ -0,0 +1,17 @@ + '{authUrl}', + 'region' => '{region}', + 'user' => [ + 'id' => '{userId}', + 'password' => '{password}', + ], +]); + +$compute = $openstack->computeV2(); + +$server = $compute->getServer(['id' => '{serverId}']); +$server->retrieve(); diff --git a/samples/Compute/v2/servers/update_server.php b/samples/Compute/v2/servers/update.php similarity index 54% rename from samples/Compute/v2/servers/update_server.php rename to samples/Compute/v2/servers/update.php index 088d586f..1ee83ed7 100644 --- a/samples/Compute/v2/servers/update_server.php +++ b/samples/Compute/v2/servers/update.php @@ -7,16 +7,13 @@ 'region' => '{region}', 'user' => [ 'id' => '{userId}', - 'password' => '{password}' + 'password' => '{password}', ], - 'scope' => ['project' => ['id' => '{projectId}']] ]); -$compute = $openstack->computeV2(['region' => '{region}']); +$compute = $openstack->computeV2(); -$server = $compute->getServer([ - 'id' => '{serverId}', -]); +$server = $compute->getServer(['id' => '{serverId}']); $server->name = '{newName}'; $server->update(); diff --git a/src/Compute/v2/Service.php b/src/Compute/v2/Service.php index 8090d8d0..a34557b3 100644 --- a/src/Compute/v2/Service.php +++ b/src/Compute/v2/Service.php @@ -37,10 +37,10 @@ public function createServer(array $options): Server /** * List servers. * - * @param bool $detailed Determines whether detailed information will be returned. If FALSE is specified, only + * @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::getServers} - * @param callable $mapFn a callable function that will be invoked on every iteration of the list + * @param array $options {@see \OpenStack\Compute\v2\Api::getServers} + * @param callable|null $mapFn a callable function that will be invoked on every iteration of the list * * @return \Generator */ @@ -72,9 +72,9 @@ 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 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 * * @return \Generator */ @@ -114,8 +114,8 @@ public function createFlavor(array $options = []): Flavor /** * List images. * - * @param array $options {@see \OpenStack\Compute\v2\Api::getImages} - * @param callable|null $mapFn a callable function that will be invoked on every iteration of the list + * @param array $options {@see \OpenStack\Compute\v2\Api::getImages} + * @param callable|null $mapFn a callable function that will be invoked on every iteration of the list * * @return \Generator */ @@ -143,8 +143,8 @@ 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 array $options {@see \OpenStack\Compute\v2\Api::getKeyPairs} + * @param callable $mapFn a callable function that will be invoked on every iteration of the list * * @return \Generator */ @@ -197,10 +197,10 @@ public function getHypervisorStatistics(): HypervisorStatistic /** * List hypervisors. * - * @param bool $detailed Determines whether detailed information will be returned. If FALSE is specified, only + * @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 array $options {@see \OpenStack\Compute\v2\Api::getHypervisors} + * @param callable $mapFn a callable function that will be invoked on every iteration of the list * * @return \Generator */ @@ -224,8 +224,8 @@ 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 array $options {@see \OpenStack\Compute\v2\Api::getHosts} + * @param callable $mapFn a callable function that will be invoked on every iteration of the list * * @return \Generator */ @@ -255,8 +255,8 @@ public function getHost(array $options = []): Host /** * 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 array $options {@see \OpenStack\Compute\v2\Api::getAvailabilityZones} + * @param callable $mapFn a callable function that will be invoked on every iteration of the list * * @return \Generator */ diff --git a/tests/sample/Compute/v2/FlavorTest.php b/tests/sample/Compute/v2/FlavorTest.php index 61a4708b..540e93c2 100644 --- a/tests/sample/Compute/v2/FlavorTest.php +++ b/tests/sample/Compute/v2/FlavorTest.php @@ -12,7 +12,7 @@ public function testCreate(): Flavor $name = $this->randomStr(); /** @var $flavor \OpenStack\Compute\v2\Models\Flavor */ - require_once $this->sampleFile('flavors/create_flavor.php', ['{flavorName}' => $name]); + require_once $this->sampleFile('flavors/create.php', ['{flavorName}' => $name]); $this->assertInstanceOf(Flavor::class, $flavor); $this->assertEquals($name, $flavor->name); @@ -27,7 +27,7 @@ public function testList(Flavor $createdFlavor) { $found = false; require_once $this->sampleFile( - 'flavors/list_flavors.php', + 'flavors/list.php', [ '/** @var \OpenStack\Compute\v2\Models\Flavor $flavor */' => <<<'PHP' /** @var \OpenStack\Compute\v2\Models\Flavor $flavor */ @@ -45,10 +45,10 @@ public function testList(Flavor $createdFlavor) /** * @depends testCreate */ - public function testGet(Flavor $createdFlavor) + public function testRead(Flavor $createdFlavor) { /** @var \OpenStack\Compute\v2\Models\Flavor $flavor */ - require_once $this->sampleFile('flavors/get_flavor.php', ['{flavorId}' => $createdFlavor->id]); + require_once $this->sampleFile('flavors/read.php', ['{flavorId}' => $createdFlavor->id]); $this->assertInstanceOf(Flavor::class, $flavor); $this->assertEquals($createdFlavor->id, $flavor->id); @@ -60,7 +60,7 @@ public function testGet(Flavor $createdFlavor) */ public function testDelete(Flavor $createdFlavor) { - require_once $this->sampleFile('flavors/delete_flavor.php', ['{flavorId}' => $createdFlavor->id]); + require_once $this->sampleFile('flavors/delete.php', ['{flavorId}' => $createdFlavor->id]); foreach ($this->getService()->listFlavors() as $flavor) { $this->assertNotEquals($createdFlavor->id, $flavor->id); diff --git a/tests/sample/Compute/v2/ServerTest.php b/tests/sample/Compute/v2/ServerTest.php index 721e46df..5b69b481 100644 --- a/tests/sample/Compute/v2/ServerTest.php +++ b/tests/sample/Compute/v2/ServerTest.php @@ -10,7 +10,6 @@ class ServerTest extends TestCase { - public function testCreate(): Server { $flavorId = getenv('OS_FLAVOR'); @@ -37,7 +36,7 @@ public function testCreate(): Server ]; /** @var $server \OpenStack\Compute\v2\Models\Server */ - require_once $this->sampleFile('servers/create_server.php', $replacements); + require_once $this->sampleFile('servers/create.php', $replacements); $server->waitUntilActive(); @@ -55,7 +54,7 @@ public function testUpdate(Server $createdServer) { $newName = $this->randomStr(); - require_once $this->sampleFile('servers/update_server.php', [ + require_once $this->sampleFile('servers/update.php', [ '{serverId}' => $createdServer->id, '{newName}' => $newName, ]); @@ -72,7 +71,7 @@ public function testUpdate(Server $createdServer) public function testGet(Server $createdServer) { /** @var \OpenStack\Compute\v2\Models\Server $server */ - require_once $this->sampleFile('servers/get_server.php', ['{serverId}' => $createdServer->id]); + require_once $this->sampleFile('servers/read.php', ['{serverId}' => $createdServer->id]); $this->assertInstanceOf(Server::class, $server); $this->assertEquals($createdServer->id, $server->id); @@ -343,7 +342,7 @@ public function testGetConsoleOutput(Server $createdServer) */ public function testDelete(Server $createdServer) { - require_once $this->sampleFile('servers/delete_server.php', ['{serverId}' => $createdServer->id]); + require_once $this->sampleFile('servers/delete.php', ['{serverId}' => $createdServer->id]); // Needed so that subnet and network can be removed $createdServer->waitUntilDeleted(); From a14ea626af65c0ee94cad46064c2c3106529e4fb Mon Sep 17 00:00:00 2001 From: k0ka Date: Fri, 19 Jan 2024 16:45:28 +0000 Subject: [PATCH 41/50] Apply php-cs-fixer changes --- src/Compute/v2/Service.php | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/src/Compute/v2/Service.php b/src/Compute/v2/Service.php index a34557b3..3dc1fd4c 100644 --- a/src/Compute/v2/Service.php +++ b/src/Compute/v2/Service.php @@ -37,10 +37,10 @@ public function createServer(array $options): Server /** * List servers. * - * @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::getServers} - * @param callable|null $mapFn a callable function that will be invoked on every iteration of the list + * @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::getServers} + * @param callable|null $mapFn a callable function that will be invoked on every iteration of the list * * @return \Generator */ @@ -72,9 +72,9 @@ 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 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 * * @return \Generator */ @@ -114,8 +114,8 @@ public function createFlavor(array $options = []): Flavor /** * List images. * - * @param array $options {@see \OpenStack\Compute\v2\Api::getImages} - * @param callable|null $mapFn a callable function that will be invoked on every iteration of the list + * @param array $options {@see \OpenStack\Compute\v2\Api::getImages} + * @param callable|null $mapFn a callable function that will be invoked on every iteration of the list * * @return \Generator */ @@ -143,8 +143,8 @@ 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 array $options {@see \OpenStack\Compute\v2\Api::getKeyPairs} + * @param callable $mapFn a callable function that will be invoked on every iteration of the list * * @return \Generator */ @@ -197,10 +197,10 @@ public function getHypervisorStatistics(): HypervisorStatistic /** * List hypervisors. * - * @param bool $detailed Determines whether detailed information will be returned. If FALSE is specified, only + * @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 array $options {@see \OpenStack\Compute\v2\Api::getHypervisors} + * @param callable $mapFn a callable function that will be invoked on every iteration of the list * * @return \Generator */ @@ -224,8 +224,8 @@ 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 array $options {@see \OpenStack\Compute\v2\Api::getHosts} + * @param callable $mapFn a callable function that will be invoked on every iteration of the list * * @return \Generator */ @@ -255,8 +255,8 @@ public function getHost(array $options = []): Host /** * 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 array $options {@see \OpenStack\Compute\v2\Api::getAvailabilityZones} + * @param callable $mapFn a callable function that will be invoked on every iteration of the list * * @return \Generator */ From d22523ef65395cc0e50b8368568e80528066c449 Mon Sep 17 00:00:00 2001 From: Konstantin Babushkin Date: Fri, 19 Jan 2024 19:57:08 +0100 Subject: [PATCH 42/50] images service doc --- doc/services/images/v2/create.rst | 12 ++++ doc/services/images/v2/images.rst | 67 ++++++++++--------- doc/services/images/v2/index.rst | 6 ++ doc/services/images/v2/members.rst | 41 ++++++------ samples/Compute/v2/create.php | 2 +- samples/Compute/v2/create_with_region.php | 2 +- samples/Images/v2/create.php | 14 ++++ samples/Images/v2/create_with_region.php | 13 ++++ samples/Images/v2/images/create.php | 6 +- samples/Images/v2/images/deactivate.php | 6 +- samples/Images/v2/images/delete.php | 13 ++-- .../Images/v2/images/download_binary_data.php | 7 +- samples/Images/v2/images/list.php | 11 +-- samples/Images/v2/images/list_sorted.php | 10 ++- samples/Images/v2/images/reactivate.php | 6 +- .../Images/v2/images/{get.php => read.php} | 6 +- samples/Images/v2/images/update.php | 6 +- .../Images/v2/images/upload_binary_data.php | 6 +- samples/Images/v2/members/add.php | 14 ---- samples/Images/v2/members/create.php | 16 +++++ samples/Images/v2/members/delete.php | 14 ++-- samples/Images/v2/members/get.php | 14 ---- samples/Images/v2/members/list.php | 10 +-- samples/Images/v2/members/read.php | 17 +++++ samples/Images/v2/members/update_status.php | 15 +++-- tests/sample/Images/v2/ImageTest.php | 5 +- tests/sample/Images/v2/MemberTest.php | 8 +-- 27 files changed, 215 insertions(+), 132 deletions(-) create mode 100644 doc/services/images/v2/create.rst create mode 100644 samples/Images/v2/create.php create mode 100644 samples/Images/v2/create_with_region.php rename samples/Images/v2/images/{get.php => read.php} (66%) delete mode 100644 samples/Images/v2/members/add.php create mode 100644 samples/Images/v2/members/create.php delete mode 100644 samples/Images/v2/members/get.php create mode 100644 samples/Images/v2/members/read.php diff --git a/doc/services/images/v2/create.rst b/doc/services/images/v2/create.rst new file mode 100644 index 00000000..43d3c0b5 --- /dev/null +++ b/doc/services/images/v2/create.rst @@ -0,0 +1,12 @@ +Create Service +============== + +In order to work with the service you have to :doc:`setup the client ` first. + +Service can be created via ``imagesV2()`` method of the ``OpenStack`` object. + +.. sample:: Image/v2/create.php + +A list of additional options can be passed to the method. For example, to change the region: + +.. sample:: Image/v2/create_with_region.php diff --git a/doc/services/images/v2/images.rst b/doc/services/images/v2/images.rst index 04df1b0c..746f44fa 100644 --- a/doc/services/images/v2/images.rst +++ b/doc/services/images/v2/images.rst @@ -1,24 +1,47 @@ Images ====== -Create image ------------- +A collection of files for a specific operating system (OS) that you use to create or rebuild a server. +OpenStack provides pre-built images. You can also create custom images, or snapshots, from servers +that you have launched. Custom images can be used for data backups or as “gold” images for additional servers. + +.. osdoc:: https://docs.openstack.org/api-ref/image/v2/index.html#images + +.. |models| replace:: images + +.. include:: /common/service.rst + +Create +------ The only required attribute when creating a new image is ``name``. .. sample:: Images/v2/images/create.php -.. refdoc:: OpenStack/Images/v2/Service.html#method_createImage -List images ------------ +Read +---- + +.. sample:: Images/v2/images/read.php + +Update +------ + +.. sample:: Images/v2/images/update.php + +Delete +------ + +.. sample:: Images/v2/images/delete.php + +List +---- .. sample:: Images/v2/images/list.php -.. refdoc:: OpenStack/Images/v2/Service.html#method_listImages .. include:: /common/generators.rst List images sorted ------------------- +~~~~~~~~~~~~~~~~~~ Possible values for sort_key are: @@ -31,37 +54,17 @@ Possible values for sort_dir are: .. sample:: Images/v2/images/list_sorted.php -Show image details ------------------- - -.. sample:: Images/v2/images/get.php -.. refdoc:: OpenStack/Images/v2/Service.html#method_getImage - -Update image ------------- - -.. sample:: Images/v2/images/update.php -.. refdoc:: OpenStack/Images/v2/Models/Image.html#method_update - -Delete image ------------- - -.. sample:: Images/v2/images/delete.php -.. refdoc:: OpenStack/Images/v2/Models/Image.html#method_delete - -Reactivate image ----------------- +Reactivate +---------- .. sample:: Images/v2/images/reactivate.php -.. refdoc:: OpenStack/Images/v2/Models/Image.html#method_reactivate -Deactivate image ----------------- +Deactivate +---------- If you try to download a deactivated image, a Forbidden error is returned. .. sample:: Images/v2/images/deactivate.php -.. refdoc:: OpenStack/Images/v2/Models/Image.html#method_deactivate Upload binary data ------------------ @@ -76,10 +79,8 @@ Before you can store binary image data, you must meet the following precondition The size of the data that you want to store must not exceed the size that the Image service allows. .. sample:: Images/v2/images/upload_binary_data.php -.. refdoc:: OpenStack/Images/v2/Models/Image.html#method_uploadData Download binary data -------------------- .. sample:: Images/v2/images/download_binary_data.php -.. refdoc:: OpenStack/Images/v2/Models/Image.html#method_downloadData \ No newline at end of file diff --git a/doc/services/images/v2/index.rst b/doc/services/images/v2/index.rst index de7b3284..ef059e98 100644 --- a/doc/services/images/v2/index.rst +++ b/doc/services/images/v2/index.rst @@ -1,8 +1,14 @@ Images v2 ========= +OpenStack Image (Glance) API Version 2. The project provides a service where users can upload and discover +data assets that are meant to be used with other services. + +.. osdoc:: https://docs.openstack.org/api-ref/image/v2/index.html + .. toctree:: :maxdepth: 3 + create images members \ No newline at end of file diff --git a/doc/services/images/v2/members.rst b/doc/services/images/v2/members.rst index 08abc547..87f8f2f0 100644 --- a/doc/services/images/v2/members.rst +++ b/doc/services/images/v2/members.rst @@ -1,34 +1,37 @@ Image Members ============= -Add member to image -------------------- +Image member is a project which can access a given VM image within Image service. -.. sample:: Images/v2/members/add.php -.. refdoc:: OpenStack/Images/v2/Models/Image.html#method_addMember +.. osdoc:: https://docs.openstack.org/api-ref/image/v2/index.html#sharing -List image members ------------------- +.. |models| replace:: image members -.. sample:: Images/v2/members/list.php -.. refdoc:: OpenStack/Images/v2/Models/Image.html#method_listMembers +.. include:: /common/service.rst -.. include:: /common/generators.rst +Create +------ -Show member details -------------------- +.. sample:: Images/v2/members/create.php -.. sample:: Images/v2/members/get.php -.. refdoc:: OpenStack/Images/v2/Models/Image.html#method_getMember +Read +---- -Remove member from image ------------------------- +.. sample:: Images/v2/members/read.php + +Delete +------ .. sample:: Images/v2/members/delete.php -.. refdoc:: OpenStack/Images/v2/Models/Member.html#method_delete -Update status of image member ------------------------------ +List +---- + +.. sample:: Images/v2/members/list.php + +.. include:: /common/generators.rst + +Update Status +------------- .. sample:: Images/v2/members/update_status.php -.. refdoc:: OpenStack/Images/v2/Models/Member.html#method_updateStatus \ No newline at end of file diff --git a/samples/Compute/v2/create.php b/samples/Compute/v2/create.php index 15d202f3..0fe40101 100644 --- a/samples/Compute/v2/create.php +++ b/samples/Compute/v2/create.php @@ -11,4 +11,4 @@ ], ]); -$service = $openstack->computeV2(); +$compute = $openstack->computeV2(); diff --git a/samples/Compute/v2/create_with_region.php b/samples/Compute/v2/create_with_region.php index b4ecfe30..48a1c184 100644 --- a/samples/Compute/v2/create_with_region.php +++ b/samples/Compute/v2/create_with_region.php @@ -10,4 +10,4 @@ ], ]); -$identity = $openstack->computeV2(['region' => '{region}']); \ No newline at end of file +$compute = $openstack->computeV2(['region' => '{region}']); \ No newline at end of file diff --git a/samples/Images/v2/create.php b/samples/Images/v2/create.php new file mode 100644 index 00000000..b0a98a8c --- /dev/null +++ b/samples/Images/v2/create.php @@ -0,0 +1,14 @@ + '{authUrl}', + 'region' => '{region}', + 'user' => [ + 'id' => '{userId}', + 'password' => '{password}', + ], +]); + +$service = $openstack->imagesV2(); diff --git a/samples/Images/v2/create_with_region.php b/samples/Images/v2/create_with_region.php new file mode 100644 index 00000000..91c5e21b --- /dev/null +++ b/samples/Images/v2/create_with_region.php @@ -0,0 +1,13 @@ + '{authUrl}', + 'user' => [ + 'id' => '{userId}', + 'password' => '{password}' + ], +]); + +$service = $openstack->imagesV2(['region' => '{region}']); \ No newline at end of file diff --git a/samples/Images/v2/images/create.php b/samples/Images/v2/images/create.php index e2fec9bd..501760a1 100644 --- a/samples/Images/v2/images/create.php +++ b/samples/Images/v2/images/create.php @@ -5,8 +5,10 @@ $openstack = new OpenStack\OpenStack([ 'authUrl' => '{authUrl}', 'region' => '{region}', - 'user' => ['id' => '{userId}', 'password' => '{password}'], - 'scope' => ['project' => ['id' => '{projectId}']] + 'user' => [ + 'id' => '{userId}', + 'password' => '{password}', + ], ]); $service = $openstack->imagesV2(); diff --git a/samples/Images/v2/images/deactivate.php b/samples/Images/v2/images/deactivate.php index fd604d64..6b973551 100644 --- a/samples/Images/v2/images/deactivate.php +++ b/samples/Images/v2/images/deactivate.php @@ -5,8 +5,10 @@ $openstack = new OpenStack\OpenStack([ 'authUrl' => '{authUrl}', 'region' => '{region}', - 'user' => ['id' => '{userId}', 'password' => '{password}'], - 'scope' => ['project' => ['id' => '{projectId}']] + 'user' => [ + 'id' => '{userId}', + 'password' => '{password}', + ], ]); $service = $openstack->imagesV2(); diff --git a/samples/Images/v2/images/delete.php b/samples/Images/v2/images/delete.php index 69b48eb6..8a2f31c8 100644 --- a/samples/Images/v2/images/delete.php +++ b/samples/Images/v2/images/delete.php @@ -5,10 +5,13 @@ $openstack = new OpenStack\OpenStack([ 'authUrl' => '{authUrl}', 'region' => '{region}', - 'user' => ['id' => '{userId}', 'password' => '{password}'], - 'scope' => ['project' => ['id' => '{projectId}']] + 'user' => [ + 'id' => '{userId}', + 'password' => '{password}', + ], ]); -$openstack->imagesV2() - ->getImage('{imageId}') - ->delete(); +$service = $openstack->imagesV2(); + +$image = $service->getImage('{imageId}'); +$image->delete(); diff --git a/samples/Images/v2/images/download_binary_data.php b/samples/Images/v2/images/download_binary_data.php index 74f434ef..20a4a69d 100644 --- a/samples/Images/v2/images/download_binary_data.php +++ b/samples/Images/v2/images/download_binary_data.php @@ -5,13 +5,14 @@ $openstack = new OpenStack\OpenStack([ 'authUrl' => '{authUrl}', 'region' => '{region}', - 'user' => ['id' => '{userId}', 'password' => '{password}'], - 'scope' => ['project' => ['id' => '{projectId}']] + 'user' => [ + 'id' => '{userId}', + 'password' => '{password}', + ], ]); $service = $openstack->imagesV2(); $image = $service->getImage('{imageId}'); -/** @var \GuzzleHttp\Psr7\Stream $stream */ $stream = $image->downloadData(); diff --git a/samples/Images/v2/images/list.php b/samples/Images/v2/images/list.php index 42a714c6..8574678b 100644 --- a/samples/Images/v2/images/list.php +++ b/samples/Images/v2/images/list.php @@ -5,12 +5,15 @@ $openstack = new OpenStack\OpenStack([ 'authUrl' => '{authUrl}', 'region' => '{region}', - 'user' => ['id' => '{userId}', 'password' => '{password}'], - 'scope' => ['project' => ['id' => '{projectId}']] + 'user' => [ + 'id' => '{userId}', + 'password' => '{password}', + ], ]); -$images = $openstack->imagesV2() - ->listImages(); +$service = $openstack->imagesV2(); + +$images = $service->listImages(); foreach ($images as $image) { /** @var \OpenStack\Images\v2\Models\Image $image */ diff --git a/samples/Images/v2/images/list_sorted.php b/samples/Images/v2/images/list_sorted.php index 07f85f62..2b0f8044 100644 --- a/samples/Images/v2/images/list_sorted.php +++ b/samples/Images/v2/images/list_sorted.php @@ -5,11 +5,15 @@ $openstack = new OpenStack\OpenStack([ 'authUrl' => '{authUrl}', 'region' => '{region}', - 'user' => ['id' => '{userId}', 'password' => '{password}'], - 'scope' => ['project' => ['id' => '{projectId}']] + 'user' => [ + 'id' => '{userId}', + 'password' => '{password}', + ], ]); -$images = $openstack->imagesV2()->listImages(['sortKey' => '{sortKey}', 'sortDir' => '{sortDir}']); +$service = $openstack->imagesV2(); + +$images = $service->listImages(['sortKey' => '{sortKey}', 'sortDir' => '{sortDir}']); foreach ($images as $image) { /** @var \OpenStack\Images\v2\Models\Image $image */ diff --git a/samples/Images/v2/images/reactivate.php b/samples/Images/v2/images/reactivate.php index 3b7730c1..f37c3e93 100644 --- a/samples/Images/v2/images/reactivate.php +++ b/samples/Images/v2/images/reactivate.php @@ -5,8 +5,10 @@ $openstack = new OpenStack\OpenStack([ 'authUrl' => '{authUrl}', 'region' => '{region}', - 'user' => ['id' => '{userId}', 'password' => '{password}'], - 'scope' => ['project' => ['id' => '{projectId}']] + 'user' => [ + 'id' => '{userId}', + 'password' => '{password}', + ], ]); $service = $openstack->imagesV2(); diff --git a/samples/Images/v2/images/get.php b/samples/Images/v2/images/read.php similarity index 66% rename from samples/Images/v2/images/get.php rename to samples/Images/v2/images/read.php index 680dc80b..83c7240a 100644 --- a/samples/Images/v2/images/get.php +++ b/samples/Images/v2/images/read.php @@ -5,8 +5,10 @@ $openstack = new OpenStack\OpenStack([ 'authUrl' => '{authUrl}', 'region' => '{region}', - 'user' => ['id' => '{userId}', 'password' => '{password}'], - 'scope' => ['project' => ['id' => '{projectId}']] + 'user' => [ + 'id' => '{userId}', + 'password' => '{password}', + ], ]); $service = $openstack->imagesV2(); diff --git a/samples/Images/v2/images/update.php b/samples/Images/v2/images/update.php index 0778bcae..dcb86537 100644 --- a/samples/Images/v2/images/update.php +++ b/samples/Images/v2/images/update.php @@ -5,8 +5,10 @@ $openstack = new OpenStack\OpenStack([ 'authUrl' => '{authUrl}', 'region' => '{region}', - 'user' => ['id' => '{userId}', 'password' => '{password}'], - 'scope' => ['project' => ['id' => '{projectId}']] + 'user' => [ + 'id' => '{userId}', + 'password' => '{password}', + ], ]); $service = $openstack->imagesV2(); diff --git a/samples/Images/v2/images/upload_binary_data.php b/samples/Images/v2/images/upload_binary_data.php index 152f55a0..ef5018a1 100644 --- a/samples/Images/v2/images/upload_binary_data.php +++ b/samples/Images/v2/images/upload_binary_data.php @@ -5,8 +5,10 @@ $openstack = new OpenStack\OpenStack([ 'authUrl' => '{authUrl}', 'region' => '{region}', - 'user' => ['id' => '{userId}', 'password' => '{password}'], - 'scope' => ['project' => ['id' => '{projectId}']] + 'user' => [ + 'id' => '{userId}', + 'password' => '{password}', + ], ]); $service = $openstack->imagesV2(); diff --git a/samples/Images/v2/members/add.php b/samples/Images/v2/members/add.php deleted file mode 100644 index 092fdbba..00000000 --- a/samples/Images/v2/members/add.php +++ /dev/null @@ -1,14 +0,0 @@ - '{authUrl}', - 'region' => '{region}', - 'user' => ['id' => '{userId}', 'password' => '{password}'], - 'scope' => ['project' => ['id' => '{projectId}']], -]); - -$member = $openstack->imagesV2() - ->getImage('{imageId}') - ->addMember('{projectId}'); diff --git a/samples/Images/v2/members/create.php b/samples/Images/v2/members/create.php new file mode 100644 index 00000000..dc387eeb --- /dev/null +++ b/samples/Images/v2/members/create.php @@ -0,0 +1,16 @@ + '{authUrl}', + 'region' => '{region}', + 'user' => [ + 'id' => '{userId}', + 'password' => '{password}', + ], +]); + +$service = $openstack->imagesV2(); +$image = $service->getImage('{imageId}'); +$member = $image->addMember('{projectId}'); diff --git a/samples/Images/v2/members/delete.php b/samples/Images/v2/members/delete.php index 6040895a..4f3fcfa7 100644 --- a/samples/Images/v2/members/delete.php +++ b/samples/Images/v2/members/delete.php @@ -5,11 +5,13 @@ $openstack = new OpenStack\OpenStack([ 'authUrl' => '{authUrl}', 'region' => '{region}', - 'user' => ['id' => '{userId}', 'password' => '{password}'], - 'scope' => ['project' => ['id' => '{projectId}']] + 'user' => [ + 'id' => '{userId}', + 'password' => '{password}', + ], ]); -$openstack->imagesV2() - ->getImage('{imageId}') - ->getMember('{projectId}') - ->delete(); +$service = $openstack->imagesV2(); +$image = $service->getImage('{imageId}'); +$member = $image->getMember('{projectId}'); +$member->delete(); diff --git a/samples/Images/v2/members/get.php b/samples/Images/v2/members/get.php deleted file mode 100644 index f824ead0..00000000 --- a/samples/Images/v2/members/get.php +++ /dev/null @@ -1,14 +0,0 @@ - '{authUrl}', - 'region' => '{region}', - 'user' => ['id' => '{userId}', 'password' => '{password}'], - 'scope' => ['project' => ['id' => '{projectId}']] -]); - -$member = $openstack->imagesV2() - ->getImage('{imageId}') - ->getMember('{tenantId}'); diff --git a/samples/Images/v2/members/list.php b/samples/Images/v2/members/list.php index fb14aa8e..4e19cef1 100644 --- a/samples/Images/v2/members/list.php +++ b/samples/Images/v2/members/list.php @@ -5,12 +5,14 @@ $openstack = new OpenStack\OpenStack([ 'authUrl' => '{authUrl}', 'region' => '{region}', - 'user' => ['id' => '{userId}', 'password' => '{password}'], - 'scope' => ['project' => ['id' => '{projectId}']] + 'user' => [ + 'id' => '{userId}', + 'password' => '{password}', + ], ]); -$image = $openstack->imagesV2() - ->getImage('{imageId}'); +$service = $openstack->imagesV2(); +$image = $service->getImage('{imageId}'); foreach ($image->listMembers() as $member) { } diff --git a/samples/Images/v2/members/read.php b/samples/Images/v2/members/read.php new file mode 100644 index 00000000..33456add --- /dev/null +++ b/samples/Images/v2/members/read.php @@ -0,0 +1,17 @@ + '{authUrl}', + 'region' => '{region}', + 'user' => [ + 'id' => '{userId}', + 'password' => '{password}', + ], +]); + +$service = $openstack->imagesV2(); +$image = $service->getImage('{imageId}'); +$member = $image->getMember('{projectId}'); +$member->retrieve(); diff --git a/samples/Images/v2/members/update_status.php b/samples/Images/v2/members/update_status.php index 30f33e93..cb830df8 100644 --- a/samples/Images/v2/members/update_status.php +++ b/samples/Images/v2/members/update_status.php @@ -7,11 +7,14 @@ $openstack = new OpenStack\OpenStack([ 'authUrl' => '{authUrl}', 'region' => '{region}', - 'user' => ['id' => '{userId}', 'password' => '{password}'], - 'scope' => ['project' => ['id' => '{projectId}']] + 'user' => [ + 'id' => '{userId}', + 'password' => '{password}', + ], ]); -$openstack->imagesV2() - ->getImage('{imageId}') - ->getMember('{projectId}') - ->updateStatus(Member::STATUS_ACCEPTED); +$service = $openstack->imagesV2(); + +$image = $service->getImage('{imageId}'); +$member = $image->getMember('{projectId}'); +$member->updateStatus(Member::STATUS_ACCEPTED); diff --git a/tests/sample/Images/v2/ImageTest.php b/tests/sample/Images/v2/ImageTest.php index f8b583eb..af524d3f 100644 --- a/tests/sample/Images/v2/ImageTest.php +++ b/tests/sample/Images/v2/ImageTest.php @@ -7,7 +7,6 @@ class ImageTest extends TestCase { - public function testCreate(): Image { /** @var Image $image */ @@ -54,11 +53,11 @@ public function testList(Image $createdImage) /** * @depends testCreate */ - public function testGet(Image $createdImage) + public function testRead(Image $createdImage) { /** @var Image $image */ require_once $this->sampleFile( - 'images/get.php', + 'images/read.php', [ '{imageId}' => $createdImage->id, ] diff --git a/tests/sample/Images/v2/MemberTest.php b/tests/sample/Images/v2/MemberTest.php index 0ebd10f6..df3893b1 100644 --- a/tests/sample/Images/v2/MemberTest.php +++ b/tests/sample/Images/v2/MemberTest.php @@ -8,7 +8,7 @@ class MemberTest extends TestCase { - public function testAdd(): Member + public function testCreate(): Member { $image = $this->getService()->createImage([ 'name' => $this->randomStr(), @@ -18,14 +18,14 @@ public function testAdd(): Member ]); /** @var Member $member */ - require_once $this->sampleFile('members/add.php', ['{imageId}' => $image->id,]); + require_once $this->sampleFile('members/create.php', ['{imageId}' => $image->id,]); $this->assertInstanceOf(Member::class, $member); return $member; } /** - * @depends testAdd + * @depends testCreate */ public function testUpdateStatus(Member $createdMember) { @@ -41,7 +41,7 @@ public function testUpdateStatus(Member $createdMember) } /** - * @depends testAdd + * @depends testCreate */ public function testDelete(Member $createdMember) { From fa2bcd98a4db6f5446ad2b14698d18920a537179 Mon Sep 17 00:00:00 2001 From: Konstantin Babushkin Date: Sat, 20 Jan 2024 15:23:43 +0100 Subject: [PATCH 43/50] unify create-service docs --- doc/common/create-service.rst | 18 ++++++++++++++++++ doc/conf.py | 1 + doc/requirements.txt | 3 ++- doc/services/block-storage/v2/index.rst | 2 +- doc/services/block-storage/v3/create.rst | 13 ++----------- doc/services/compute/v2/images.rst | 2 +- doc/services/compute/v2/servers.rst | 2 +- doc/services/identity/v3/create.rst | 13 ++----------- doc/services/images/v2/create.rst | 13 ++----------- samples/BlockStorage/v3/create.php | 14 -------------- samples/BlockStorage/v3/create_with_region.php | 13 ------------- samples/Compute/v2/create.php | 14 -------------- samples/Compute/v2/create_with_region.php | 13 ------------- samples/Identity/v3/create.php | 14 -------------- samples/Identity/v3/create_with_region.php | 13 ------------- 15 files changed, 30 insertions(+), 118 deletions(-) create mode 100644 doc/common/create-service.rst delete mode 100644 samples/BlockStorage/v3/create.php delete mode 100644 samples/BlockStorage/v3/create_with_region.php delete mode 100644 samples/Compute/v2/create.php delete mode 100644 samples/Compute/v2/create_with_region.php delete mode 100644 samples/Identity/v3/create.php delete mode 100644 samples/Identity/v3/create_with_region.php diff --git a/doc/common/create-service.rst b/doc/common/create-service.rst new file mode 100644 index 00000000..799043dd --- /dev/null +++ b/doc/common/create-service.rst @@ -0,0 +1,18 @@ +Create Service +============== + +In order to work with the service you have to :doc:`setup the client ` first. + +Service can be created via :substitution-code:`|method|()` method of the ``OpenStack`` object. + +.. code-block:: php + :substitutions: + + $service = $openstack->|method|(); + +A list of additional options can be passed to the method. For example, to change the region: + +.. code-block:: php + :substitutions: + + $service = $openstack->|method|(['region' => '{region}']); diff --git a/doc/conf.py b/doc/conf.py index c5ad539a..14803257 100755 --- a/doc/conf.py +++ b/doc/conf.py @@ -31,6 +31,7 @@ 'sphinx.ext.autosummary', 'sphinxcontrib.phpdomain', 'sphinx_toolbox.collapse', + 'sphinx_substitution_extensions', ] source_suffix = '.rst' master_doc = 'index' diff --git a/doc/requirements.txt b/doc/requirements.txt index 76b768dc..505737dd 100644 --- a/doc/requirements.txt +++ b/doc/requirements.txt @@ -1,3 +1,4 @@ sphinxcontrib-phpdomain>=0.11.0 sphinx-rtd-theme>=0.5.1 -sphinx-toolbox>=3.5.0 \ No newline at end of file +sphinx-toolbox>=3.5.0 +sphinx-substitution-extensions \ No newline at end of file diff --git a/doc/services/block-storage/v2/index.rst b/doc/services/block-storage/v2/index.rst index 602969ab..e67c6a42 100644 --- a/doc/services/block-storage/v2/index.rst +++ b/doc/services/block-storage/v2/index.rst @@ -3,7 +3,7 @@ Block Storage v2 Block Storage v2 API is deprecated since Pike release and was removed in the Xena release. It is recommended to use Block Storage v3 API instead. However most of endpoints are identical, so if you still need -to use Block Storage v2 API, you can use the change `$openstack->blockStorageV3()` to `$openstack->blockStorageV2()` in examples. +to use Block Storage v2 API, you can use the change ``$openstack->blockStorageV3()`` to ``$openstack->blockStorageV2()`` in examples. In most cases it will work without any other changes. .. sample:: BlockStorage/v2/create.php diff --git a/doc/services/block-storage/v3/create.rst b/doc/services/block-storage/v3/create.rst index 288b0371..80998dcc 100644 --- a/doc/services/block-storage/v3/create.rst +++ b/doc/services/block-storage/v3/create.rst @@ -1,12 +1,3 @@ -Create Service -============== +.. |method| replace:: blockStorageV3 -In order to work with the service you have to :doc:`setup the client ` first. - -Service can be created via ``blockStorageV3()`` method of the ``OpenStack`` object. - -.. sample:: BlockStorage/v3/create.php - -A list of additional options can be passed to the method. For example, to change the region: - -.. sample:: BlockStorage/v3/create_with_region.php +.. include:: /common/create-service.rst \ No newline at end of file diff --git a/doc/services/compute/v2/images.rst b/doc/services/compute/v2/images.rst index 519884d3..9ca8e4b7 100644 --- a/doc/services/compute/v2/images.rst +++ b/doc/services/compute/v2/images.rst @@ -2,7 +2,7 @@ Images ====== .. warning:: - These APIs are proxy calls to the :doc:`/services/images/v2/`Image service. + These APIs are proxy calls to the :doc:`/services/images/v2/index` Image service. Nova has deprecated all the proxy APIs and users should use the native APIs instead. .. osdoc:: https://docs.openstack.org/api-ref/compute/#images-deprecated diff --git a/doc/services/compute/v2/servers.rst b/doc/services/compute/v2/servers.rst index a4f27d09..4865771d 100644 --- a/doc/services/compute/v2/servers.rst +++ b/doc/services/compute/v2/servers.rst @@ -149,7 +149,7 @@ Update The first step when updating a server is modifying the attributes you want updated. By default, only a server's name, IPv4 and IPv6 IPs, and its auto disk config attributes can be edited. -.. sample:: Compute/v2/servers/update_server.php +.. sample:: Compute/v2/servers/update.php Delete --------------- diff --git a/doc/services/identity/v3/create.rst b/doc/services/identity/v3/create.rst index c32b7699..9f0c6d3a 100644 --- a/doc/services/identity/v3/create.rst +++ b/doc/services/identity/v3/create.rst @@ -1,12 +1,3 @@ -Create Service -============== +.. |method| replace:: identityV3 -In order to work with the service you have to :doc:`setup the client ` first. - -Service can be created via ``computeV2()`` method of the ``OpenStack`` object. - -.. sample:: Compute/v3/create.php - -A list of additional options can be passed to the method. For example, to change the region: - -.. sample:: Compute/v3/create_with_region.php +.. include:: /common/create-service.rst diff --git a/doc/services/images/v2/create.rst b/doc/services/images/v2/create.rst index 43d3c0b5..b5415107 100644 --- a/doc/services/images/v2/create.rst +++ b/doc/services/images/v2/create.rst @@ -1,12 +1,3 @@ -Create Service -============== +.. |method| replace:: imagesV2 -In order to work with the service you have to :doc:`setup the client ` first. - -Service can be created via ``imagesV2()`` method of the ``OpenStack`` object. - -.. sample:: Image/v2/create.php - -A list of additional options can be passed to the method. For example, to change the region: - -.. sample:: Image/v2/create_with_region.php +.. include:: /common/create-service.rst diff --git a/samples/BlockStorage/v3/create.php b/samples/BlockStorage/v3/create.php deleted file mode 100644 index c2cde0e1..00000000 --- a/samples/BlockStorage/v3/create.php +++ /dev/null @@ -1,14 +0,0 @@ - '{authUrl}', - 'region' => '{region}', - 'user' => [ - 'id' => '{userId}', - 'password' => '{password}', - ], -]); - -$service = $openstack->blockStorageV3(); diff --git a/samples/BlockStorage/v3/create_with_region.php b/samples/BlockStorage/v3/create_with_region.php deleted file mode 100644 index ff100cf0..00000000 --- a/samples/BlockStorage/v3/create_with_region.php +++ /dev/null @@ -1,13 +0,0 @@ - '{authUrl}', - 'user' => [ - 'id' => '{userId}', - 'password' => '{password}' - ], -]); - -$identity = $openstack->blockStorageV3(['region' => '{region}']); \ No newline at end of file diff --git a/samples/Compute/v2/create.php b/samples/Compute/v2/create.php deleted file mode 100644 index 0fe40101..00000000 --- a/samples/Compute/v2/create.php +++ /dev/null @@ -1,14 +0,0 @@ - '{authUrl}', - 'region' => '{region}', - 'user' => [ - 'id' => '{userId}', - 'password' => '{password}', - ], -]); - -$compute = $openstack->computeV2(); diff --git a/samples/Compute/v2/create_with_region.php b/samples/Compute/v2/create_with_region.php deleted file mode 100644 index 48a1c184..00000000 --- a/samples/Compute/v2/create_with_region.php +++ /dev/null @@ -1,13 +0,0 @@ - '{authUrl}', - 'user' => [ - 'id' => '{userId}', - 'password' => '{password}' - ], -]); - -$compute = $openstack->computeV2(['region' => '{region}']); \ No newline at end of file diff --git a/samples/Identity/v3/create.php b/samples/Identity/v3/create.php deleted file mode 100644 index 276938ab..00000000 --- a/samples/Identity/v3/create.php +++ /dev/null @@ -1,14 +0,0 @@ - '{authUrl}', - 'region' => '{region}', - 'user' => [ - 'id' => '{userId}', - 'password' => '{password}' - ], -]); - -$identity = $openstack->identityV3(); \ No newline at end of file diff --git a/samples/Identity/v3/create_with_region.php b/samples/Identity/v3/create_with_region.php deleted file mode 100644 index e51fa957..00000000 --- a/samples/Identity/v3/create_with_region.php +++ /dev/null @@ -1,13 +0,0 @@ - '{authUrl}', - 'user' => [ - 'id' => '{userId}', - 'password' => '{password}' - ], -]); - -$identity = $openstack->identityV3(['region' => '{region}']); \ No newline at end of file From 7af31ed010f355577b6037c74a5490f29d496926 Mon Sep 17 00:00:00 2001 From: Konstantin Babushkin Date: Sun, 21 Jan 2024 12:28:12 +0100 Subject: [PATCH 44/50] upgrade object store docs --- doc/services/compute/v2/create.rst | 13 +-- doc/services/object-store/v1/account.rst | 19 +++- doc/services/object-store/v1/containers.rst | 47 ++++---- doc/services/object-store/v1/create.rst | 3 + doc/services/object-store/v1/index.rst | 9 +- doc/services/object-store/v1/objects.rst | 107 ++++++++---------- .../ObjectStore/v1/account/get_metadata.php | 1 - .../ObjectStore/v1/account/merge_metadata.php | 1 - .../v1/account/{get.php => read.php} | 5 +- .../ObjectStore/v1/account/reset_metadata.php | 2 - samples/ObjectStore/v1/containers/create.php | 5 +- samples/ObjectStore/v1/containers/delete.php | 10 +- .../v1/containers/get_metadata.php | 9 +- samples/ObjectStore/v1/containers/list.php | 1 - .../v1/containers/merge_metadata.php | 1 - .../v1/containers/{get.php => read.php} | 5 +- .../v1/containers/reset_metadata.php | 2 - .../ObjectStore/v1/objects/check_exists.php | 8 +- samples/ObjectStore/v1/objects/copy.php | 15 +-- samples/ObjectStore/v1/objects/create.php | 14 +-- .../v1/objects/create_from_stream.php | 18 ++- .../v1/objects/create_large_object.php | 27 ++--- samples/ObjectStore/v1/objects/delete.php | 10 +- samples/ObjectStore/v1/objects/download.php | 10 +- .../v1/objects/download_stream.php | 10 +- .../ObjectStore/v1/objects/get_metadata.php | 10 +- samples/ObjectStore/v1/objects/list.php | 5 +- .../ObjectStore/v1/objects/merge_metadata.php | 18 +-- .../v1/objects/{get.php => read.php} | 9 +- .../ObjectStore/v1/objects/reset_metadata.php | 18 +-- .../SecurityGroups/Models/SecurityGroup.php | 3 + .../Models/SecurityGroupRule.php | 3 + src/ObjectStore/v1/Models/Container.php | 2 + tests/sample/ObjectStore/v1/ContainerTest.php | 3 +- tests/sample/ObjectStore/v1/ObjectTest.php | 9 +- 35 files changed, 206 insertions(+), 226 deletions(-) create mode 100644 doc/services/object-store/v1/create.rst rename samples/ObjectStore/v1/account/{get.php => read.php} (64%) rename samples/ObjectStore/v1/containers/{get.php => read.php} (65%) rename samples/ObjectStore/v1/objects/{get.php => read.php} (58%) diff --git a/doc/services/compute/v2/create.rst b/doc/services/compute/v2/create.rst index 288b0371..07800c76 100644 --- a/doc/services/compute/v2/create.rst +++ b/doc/services/compute/v2/create.rst @@ -1,12 +1,3 @@ -Create Service -============== +.. |method| replace:: objectStoreV1 -In order to work with the service you have to :doc:`setup the client ` first. - -Service can be created via ``blockStorageV3()`` method of the ``OpenStack`` object. - -.. sample:: BlockStorage/v3/create.php - -A list of additional options can be passed to the method. For example, to change the region: - -.. sample:: BlockStorage/v3/create_with_region.php +.. include:: /common/create-service.rst diff --git a/doc/services/object-store/v1/account.rst b/doc/services/object-store/v1/account.rst index 12a4a31e..bf33c1ce 100644 --- a/doc/services/object-store/v1/account.rst +++ b/doc/services/object-store/v1/account.rst @@ -1,19 +1,27 @@ Account ======= -Show account details --------------------- +Account represents the top-level of the hierarchy. Your service provider creates your account and you own all resources +in that account. The account defines a namespace for containers. In the OpenStack environment, account is synonymous +with a project or tenant. + +.. osdoc:: https://docs.openstack.org/api-ref/object-store/#accounts + +.. |models| replace:: accounts + +.. include:: /common/service.rst + +Read +---- To work with an Object Store account, you must first retrieve an account object like so: -.. sample:: ObjectStore/v1/account/get.php -.. refdoc:: OpenStack/ObjectStore/v1/Service.html#method_getAccount +.. sample:: ObjectStore/v1/account/read.php Get account metadata -------------------- .. sample:: ObjectStore/v1/account/get_metadata.php -.. refdoc:: OpenStack/ObjectStore/v1/Models/Account.html#method_getMetadata Replace all metadata with new values ------------------------------------ @@ -76,4 +84,3 @@ the metadata of the account will now be: To reset metadata, you must run: .. sample:: ObjectStore/v1/account/merge_metadata.php -.. refdoc:: OpenStack/ObjectStore/v1/Models/Account.html#method_mergeMetadata \ No newline at end of file diff --git a/doc/services/object-store/v1/containers.rst b/doc/services/object-store/v1/containers.rst index 18b2d656..a1dbb384 100644 --- a/doc/services/object-store/v1/containers.rst +++ b/doc/services/object-store/v1/containers.rst @@ -1,32 +1,39 @@ Containers ========== -Show details for a container ----------------------------- +Container defines a namespace for objects. An object with the same name in two different containers represents +two different objects. -.. sample:: ObjectStore/v1/containers/get.php -.. refdoc:: OpenStack/ObjectStore/v1/Service.html#method_getContainer +.. osdoc:: https://docs.openstack.org/api-ref/object-store/#containers -At this point, the object returned is *empty* because we did not execute a HTTP request to receive the state of the -container from the API. This is in accordance with one of the SDK's general policies of not assuming too much at the -expense of performance. +.. |models| replace:: containers -To synchronize the local object's state with the remote API, you can run: +.. include:: /common/service.rst -.. code-block:: php +Read +---- + +.. sample:: ObjectStore/v1/containers/read.php - $container->retrieve(); +You can read the content of a container: + +.. code-block:: php printf("%s container has %d objects and %d bytes", $container->name, $container->objectCount, $container->bytesUsed); -and all of the local properties will match those of the remote resource. +Delete +------ -List containers ---------------- +.. sample:: ObjectStore/v1/containers/delete.php + +The API will only accept DELETE requests on containers when they are empty. If you have a container with any objects +inside, the operation will fail. + +List +---- .. sample:: ObjectStore/v1/containers/list.php -.. refdoc:: OpenStack/ObjectStore/v1/Service.html#method_listContainers When listing containers, you must be aware that not *all* information about a container is returned in a collection. Very often only the object count, bytes used and container name will be exposed. If you would like to @@ -43,20 +50,10 @@ container. .. include:: /common/generators.rst -Delete container ----------------- - -.. sample:: ObjectStore/v1/containers/delete.php -.. refdoc:: OpenStack/ObjectStore/v1/Models/Container.html#method_delete - -The API will only accept DELETE requests on containers when they are empty. If you have a container with any objects -inside, the operation will fail. - Get metadata ------------ .. sample:: ObjectStore/v1/containers/get_metadata.php -.. refdoc:: OpenStack/ObjectStore/v1/Models/Container.html#method_getMetadata The returned value will be a standard associative array, or hash, containing arbitrary key/value pairs. These will correspond to the values set either when the container was created, or when a previous ``mergeMetadata`` or @@ -66,7 +63,6 @@ Replace all metadata with new values ------------------------------------ .. sample:: ObjectStore/v1/containers/reset_metadata.php -.. refdoc:: OpenStack/ObjectStore/v1/Models/Container.html#method_resetMetadata In order to replace all existing metadata with a set of new values, you can use this operation. Any existing metadata items which not specified in the new set will be removed. For example, say an account has the following metadata @@ -96,7 +92,6 @@ Merge new metadata values with existing --------------------------------------- .. sample:: ObjectStore/v1/containers/merge_metadata.php -.. refdoc:: OpenStack/ObjectStore/v1/Models/Container.html#method_mergeMetadata In order to merge a set of new metadata values with the existing metadata set, you can use this operation. Any existing metadata items which are not specified in the new set will be preserved. For example, say an account has the following diff --git a/doc/services/object-store/v1/create.rst b/doc/services/object-store/v1/create.rst new file mode 100644 index 00000000..4791fe57 --- /dev/null +++ b/doc/services/object-store/v1/create.rst @@ -0,0 +1,3 @@ +.. |method| replace:: + +.. include:: /common/create-service.rst diff --git a/doc/services/object-store/v1/index.rst b/doc/services/object-store/v1/index.rst index a6637dbc..83e52e19 100644 --- a/doc/services/object-store/v1/index.rst +++ b/doc/services/object-store/v1/index.rst @@ -2,8 +2,9 @@ Object Store v1 =============== .. toctree:: - :maxdepth: 3 + :maxdepth: 3 - account - containers - objects \ No newline at end of file + create + account + containers + objects \ No newline at end of file diff --git a/doc/services/object-store/v1/objects.rst b/doc/services/object-store/v1/objects.rst index 7b326b15..69686955 100644 --- a/doc/services/object-store/v1/objects.rst +++ b/doc/services/object-store/v1/objects.rst @@ -1,48 +1,61 @@ Objects ======= -Show details for an object --------------------------- +Object stores data content, such as documents, images, and so on. You can also store custom metadata with an object. -.. sample:: ObjectStore/v1/objects/get.php -.. refdoc:: OpenStack/ObjectStore/v1/Models/Container.html#method_getObject +.. osdoc:: https://docs.openstack.org/api-ref/object-store/#objects -At this point, the object returned is *empty* because we did not execute a HTTP request to receive the state of the -container from the API. This is in accordance with one of the SDK's general policies of not assuming too much at the -expense of performance. +.. |models| replace:: objects -To synchronize the local object's state with the remote API, you can run: +.. include:: /common/service.rst -.. code-block:: php +Create +------ - $object->retrieve(); +When creating an object, you can upload its content according to a string representation: - printf("%s/%s is %d bytes long and was last modified on %s", - $object->containerName, $object->name, $object->contentLength, $object->lastModified); +.. sample:: ObjectStore/v1/objects/create.php -and all of the local properties will match those of the remote resource. The ``retrieve`` call, although fetching all -of the object's metadata, will not download the object's content. To do this, see the next section. +If that is not optimal or convenient, you can use a stream instead. Any instance of ``\Psr\Http\Message\StreamInterface`` +is acceptable. For example, to use a normal Guzzle stream: -Download an object ------------------- +.. sample:: ObjectStore/v1/objects/create_from_stream.php -.. sample:: ObjectStore/v1/objects/download.php -.. refdoc:: OpenStack/ObjectStore/v1/Models/StorageObject.html#method_download +Create a large object (over 5GB) +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -As you will notice, a Stream_ object is returned by this call. For more information about dealing with streams, please -consult `Guzzle's docs`_. +For large objects (those over 5GB), you will need to use a concept in Swift called Dynamic Large Objects (DLO). When +uploading, this is what happens under the hood: -By default, the whole body of the object is fetched before the function returns, set the ``'requestOptions'`` key of -parameter ``$data`` to ``['stream' => true]`` to get the stream before the end of download. +1. The large file is separated into smaller segments +2. Each segment is uploaded +3. A manifest file is created which, when requested by clients, will concatenate all the segments as a single file -.. _Stream: https://github.com/guzzle/streams/blob/master/src/Stream.php -.. _Guzzle's docs: https://guzzle.readthedocs.org/en/5.3/streams.html +To upload a DLO, you need to call: -List objects ------------- +.. sample:: ObjectStore/v1/objects/create_large_object.php + +Read +---- + +.. sample:: ObjectStore/v1/objects/read.php + +You can read properties of an object: + +.. code-block:: php + + printf("%s/%s is %d bytes long and was last modified on %s", + $object->containerName, $object->name, $object->contentLength, $object->lastModified); + +Delete +------ + +.. sample:: ObjectStore/v1/objects/delete.php + +List +---- .. sample:: ObjectStore/v1/objects/list.php -.. refdoc:: OpenStack/ObjectStore/v1/Models/Container.html#method_listObjects When listing objects, you must be aware that not *all* information about a container is returned in a collection. Very often only the MD5 hash, last modified date, bytes used, content type and object name will be @@ -59,51 +72,29 @@ If you have a large collection of $object, this will slow things down because yo .. include:: /common/generators.rst -Create an object ----------------- - -When creating an object, you can upload its content according to a string representation: - -.. sample:: ObjectStore/v1/objects/create.php -.. refdoc:: OpenStack/ObjectStore/v1/Models/Container.html#method_createObject - -If that is not optimal or convenient, you can use a stream instead. Any instance of ``\Psr\Http\Message\StreamInterface`` -is acceptable. For example, to use a normal Guzzle stream: - -.. sample:: ObjectStore/v1/objects/create_from_stream.php - -Create a large object (over 5GB) --------------------------------- +Download an object +------------------ -For large objects (those over 5GB), you will need to use a concept in Swift called Dynamic Large Objects (DLO). When -uploading, this is what happens under the hood: +.. sample:: ObjectStore/v1/objects/download.php -1. The large file is separated into smaller segments -2. Each segment is uploaded -3. A manifest file is created which, when requested by clients, will concatenate all the segments as a single file +As you will notice, a Stream_ object is returned by this call. For more information about dealing with streams, please +consult `Guzzle's docs`_. -To upload a DLO, you need to call: +By default, the whole body of the object is fetched before the function returns, set the ``'requestOptions'`` key of +parameter ``$data`` to ``['stream' => true]`` to get the stream before the end of download. -.. sample:: ObjectStore/v1/objects/create_large_object.php -.. refdoc:: OpenStack/ObjectStore/v1/Models/Container.html#method_createLargeObject +.. _Stream: https://github.com/guzzle/streams/blob/master/src/Stream.php +.. _Guzzle's docs: https://guzzle.readthedocs.org/en/5.3/streams.html Copy object ----------- .. sample:: ObjectStore/v1/objects/copy.php -.. refdoc:: OpenStack/ObjectStore/v1/Models/StorageObject.html#method_copy - -Delete object -------------- - -.. sample:: ObjectStore/v1/objects/delete.php -.. refdoc:: OpenStack/ObjectStore/v1/Models/StorageObject.html#method_delete Get metadata ------------ .. sample:: ObjectStore/v1/objects/get_metadata.php -.. refdoc:: OpenStack/ObjectStore/v1/Models/StorageObject.html#method_getMetadata The returned value will be a standard associative array, or hash, containing arbitrary key/value pairs. These will correspond to the values set either when the object was created, or when a previous ``mergeMetadata`` or diff --git a/samples/ObjectStore/v1/account/get_metadata.php b/samples/ObjectStore/v1/account/get_metadata.php index af9e63c9..196a0358 100644 --- a/samples/ObjectStore/v1/account/get_metadata.php +++ b/samples/ObjectStore/v1/account/get_metadata.php @@ -9,7 +9,6 @@ 'id' => '{userId}', 'password' => '{password}' ], - 'scope' => ['project' => ['id' => '{projectId}']] ]); $service = $openstack->objectStoreV1(); diff --git a/samples/ObjectStore/v1/account/merge_metadata.php b/samples/ObjectStore/v1/account/merge_metadata.php index 77e77d16..e77a9e74 100644 --- a/samples/ObjectStore/v1/account/merge_metadata.php +++ b/samples/ObjectStore/v1/account/merge_metadata.php @@ -9,7 +9,6 @@ 'id' => '{userId}', 'password' => '{password}' ], - 'scope' => ['project' => ['id' => '{projectId}']] ]); $service = $openstack->objectStoreV1(); diff --git a/samples/ObjectStore/v1/account/get.php b/samples/ObjectStore/v1/account/read.php similarity index 64% rename from samples/ObjectStore/v1/account/get.php rename to samples/ObjectStore/v1/account/read.php index 0c4a1d68..c96d92ea 100644 --- a/samples/ObjectStore/v1/account/get.php +++ b/samples/ObjectStore/v1/account/read.php @@ -9,8 +9,7 @@ 'id' => '{userId}', 'password' => '{password}' ], - 'scope' => ['project' => ['id' => '{projectId}']] ]); -$account = $openstack->objectStoreV1() - ->getAccount(); +$service = $openstack->objectStoreV1(); +$account = $service->getAccount(); diff --git a/samples/ObjectStore/v1/account/reset_metadata.php b/samples/ObjectStore/v1/account/reset_metadata.php index 9d79c4b4..33ae3520 100644 --- a/samples/ObjectStore/v1/account/reset_metadata.php +++ b/samples/ObjectStore/v1/account/reset_metadata.php @@ -9,11 +9,9 @@ 'id' => '{userId}', 'password' => '{password}' ], - 'scope' => ['project' => ['id' => '{projectId}']] ]); $service = $openstack->objectStoreV1(); - $account = $service->getAccount(); $account->resetMetadata([ diff --git a/samples/ObjectStore/v1/containers/create.php b/samples/ObjectStore/v1/containers/create.php index 8e867604..98435ce5 100644 --- a/samples/ObjectStore/v1/containers/create.php +++ b/samples/ObjectStore/v1/containers/create.php @@ -7,13 +7,12 @@ 'region' => '{region}', 'user' => [ 'id' => '{userId}', - 'password' => '{password}' + 'password' => '{password}', ], - 'scope' => ['project' => ['id' => '{projectId}']] ]); $service = $openstack->objectStoreV1(); $container = $service->createContainer([ - 'name' => '{containerName}' + 'name' => '{containerName}', ]); diff --git a/samples/ObjectStore/v1/containers/delete.php b/samples/ObjectStore/v1/containers/delete.php index 25ae38df..da5c06ed 100644 --- a/samples/ObjectStore/v1/containers/delete.php +++ b/samples/ObjectStore/v1/containers/delete.php @@ -7,11 +7,11 @@ 'region' => '{region}', 'user' => [ 'id' => '{userId}', - 'password' => '{password}' + 'password' => '{password}', ], - 'scope' => ['project' => ['id' => '{projectId}']] ]); -$openstack->objectStoreV1() - ->getContainer('{containerName}') - ->delete(); +$service = $openstack->objectStoreV1(); +$container = $service->getContainer('{containerName}'); + +$container->delete(); diff --git a/samples/ObjectStore/v1/containers/get_metadata.php b/samples/ObjectStore/v1/containers/get_metadata.php index aded49ae..7d75d2fd 100644 --- a/samples/ObjectStore/v1/containers/get_metadata.php +++ b/samples/ObjectStore/v1/containers/get_metadata.php @@ -9,10 +9,9 @@ 'id' => '{userId}', 'password' => '{password}' ], - 'scope' => ['project' => ['id' => '{projectId}']] ]); -/** @var array $metadata */ -$metadata = $openstack->objectStoreV1() - ->getContainer('{containerName}') - ->getMetadata(); +$service = $openstack->objectStoreV1(); +$container = $service->getContainer('{containerName}'); + +$metadata = $container->getMetadata(); diff --git a/samples/ObjectStore/v1/containers/list.php b/samples/ObjectStore/v1/containers/list.php index 2cf9d401..2723be81 100644 --- a/samples/ObjectStore/v1/containers/list.php +++ b/samples/ObjectStore/v1/containers/list.php @@ -9,7 +9,6 @@ 'id' => '{userId}', 'password' => '{password}' ], - 'scope' => ['project' => ['id' => '{projectId}']] ]); $service = $openstack->objectStoreV1(); diff --git a/samples/ObjectStore/v1/containers/merge_metadata.php b/samples/ObjectStore/v1/containers/merge_metadata.php index accf9923..d2a6e504 100644 --- a/samples/ObjectStore/v1/containers/merge_metadata.php +++ b/samples/ObjectStore/v1/containers/merge_metadata.php @@ -9,7 +9,6 @@ 'id' => '{userId}', 'password' => '{password}' ], - 'scope' => ['project' => ['id' => '{projectId}']] ]); $service = $openstack->objectStoreV1(); diff --git a/samples/ObjectStore/v1/containers/get.php b/samples/ObjectStore/v1/containers/read.php similarity index 65% rename from samples/ObjectStore/v1/containers/get.php rename to samples/ObjectStore/v1/containers/read.php index 8d764cd5..685c82db 100644 --- a/samples/ObjectStore/v1/containers/get.php +++ b/samples/ObjectStore/v1/containers/read.php @@ -9,9 +9,8 @@ 'id' => '{userId}', 'password' => '{password}', ], - 'scope' => ['project' => ['id' => '{projectId}']], ]); -$container = $openstack->objectStoreV1() - ->getContainer('{containerName}'); +$service = $openstack->objectStoreV1(); +$container = $service->getContainer('{containerName}'); $container->retrieve(); diff --git a/samples/ObjectStore/v1/containers/reset_metadata.php b/samples/ObjectStore/v1/containers/reset_metadata.php index 7c1e056d..60329ce7 100644 --- a/samples/ObjectStore/v1/containers/reset_metadata.php +++ b/samples/ObjectStore/v1/containers/reset_metadata.php @@ -9,11 +9,9 @@ 'id' => '{userId}', 'password' => '{password}' ], - 'scope' => ['project' => ['id' => '{projectId}']] ]); $service = $openstack->objectStoreV1(); - $container = $service->getContainer('{containerName}'); $container->resetMetadata([ diff --git a/samples/ObjectStore/v1/objects/check_exists.php b/samples/ObjectStore/v1/objects/check_exists.php index 50b3b65e..0d6e72de 100644 --- a/samples/ObjectStore/v1/objects/check_exists.php +++ b/samples/ObjectStore/v1/objects/check_exists.php @@ -9,9 +9,9 @@ 'id' => '{userId}', 'password' => '{password}', ], - 'scope' => ['project' => ['id' => '{projectId}']], ]); -$exists = $openstack->objectStoreV1() - ->getContainer('{containerName}') - ->objectExists('{objectName}'); +$service = $openstack->objectStoreV1(); +$container = $service->getContainer('{containerName}'); + +$exists = $container->objectExists('{objectName}'); \ No newline at end of file diff --git a/samples/ObjectStore/v1/objects/copy.php b/samples/ObjectStore/v1/objects/copy.php index 0790be82..80bd233a 100644 --- a/samples/ObjectStore/v1/objects/copy.php +++ b/samples/ObjectStore/v1/objects/copy.php @@ -9,12 +9,13 @@ 'id' => '{userId}', 'password' => '{password}', ], - 'scope' => ['project' => ['id' => '{projectId}']], ]); -$openstack->objectStoreV1() - ->getContainer('{containerName}') - ->getObject('{objectName}') - ->copy([ - 'destination' => '{newContainerName}/{newObjectName}', - ]); +$service = $openstack->objectStoreV1(); +$container = $service->getContainer('{containerName}'); +$object = $container->getObject('{objectName}'); + +$object->copy([ + 'destination' => '{newContainerName}/{newObjectName}', +]); + diff --git a/samples/ObjectStore/v1/objects/create.php b/samples/ObjectStore/v1/objects/create.php index 65be7f88..5549f09d 100644 --- a/samples/ObjectStore/v1/objects/create.php +++ b/samples/ObjectStore/v1/objects/create.php @@ -9,13 +9,11 @@ 'id' => '{userId}', 'password' => '{password}', ], - 'scope' => ['project' => ['id' => '{projectId}']], ]); -/** @var \OpenStack\ObjectStore\v1\Models\StorageObject $object */ -$object = $openstack->objectStoreV1() - ->getContainer('{containerName}') - ->createObject([ - 'name' => '{objectName}', - 'content' => '{objectContent}', - ]); +$service = $openstack->objectStoreV1(); +$container = $service->getContainer('{containerName}'); +$container->createObject([ + 'name' => '{objectName}', + 'content' => '{objectContent}', +]); diff --git a/samples/ObjectStore/v1/objects/create_from_stream.php b/samples/ObjectStore/v1/objects/create_from_stream.php index eed9fa20..461d4b20 100644 --- a/samples/ObjectStore/v1/objects/create_from_stream.php +++ b/samples/ObjectStore/v1/objects/create_from_stream.php @@ -2,27 +2,23 @@ require 'vendor/autoload.php'; -use GuzzleHttp\Psr7\Stream; - $openstack = new OpenStack\OpenStack([ 'authUrl' => '{authUrl}', 'region' => '{region}', 'user' => [ 'id' => '{userId}', - 'password' => '{password}' + 'password' => '{password}', ], - 'scope' => ['project' => ['id' => '{projectId}']] ]); // You can use any instance of \Psr\Http\Message\StreamInterface -$stream = new Stream(fopen('/path/to/object.txt', 'r')); +$stream = new \GuzzleHttp\Psr7\Stream(fopen('/path/to/object.txt', 'r')); + +$service = $openstack->objectStoreV1(); +$container = $service->getContainer('{containerName}'); -$options = [ +$object = $container->createObject([ 'name' => '{objectName}', 'stream' => $stream, -]; +]); -/** @var \OpenStack\ObjectStore\v1\Models\StorageObject $object */ -$object = $openstack->objectStoreV1() - ->getContainer('{containerName}') - ->createObject($options); diff --git a/samples/ObjectStore/v1/objects/create_large_object.php b/samples/ObjectStore/v1/objects/create_large_object.php index 52f03b3f..8b99ca3b 100644 --- a/samples/ObjectStore/v1/objects/create_large_object.php +++ b/samples/ObjectStore/v1/objects/create_large_object.php @@ -2,32 +2,29 @@ require 'vendor/autoload.php'; -use Guzzle\Stream\Stream; - $openstack = new OpenStack\OpenStack([ 'authUrl' => '{authUrl}', 'region' => '{region}', 'user' => [ 'id' => '{userId}', - 'password' => '{password}' + 'password' => '{password}', ], - 'scope' => ['project' => ['id' => '{projectId}']] ]); $options = [ - 'name' => 'object_name.txt', - 'stream' => new Stream(fopen('/path/to/large_object.mov', 'r')), ]; -// optional: specify the size of each segment in bytes -$options['segmentSize'] = 1073741824; +$service = $openstack->objectStoreV1(); +$container = $service->getContainer('{containerName}'); -// optional: specify the container where the segments live. This does not necessarily have to be the -// same as the container which holds the manifest file -$options['segmentContainer'] = 'test_segments'; +$object = $container->createObject([ + 'name' => '{objectName}', + 'stream' => new \GuzzleHttp\Psr7\Stream(fopen('/path/to/large_object.mov', 'r')), + // optional: specify the size of each segment in bytes + 'segmentSize' => 1073741824, -/** @var \OpenStack\ObjectStore\v1\Models\StorageObject $object */ -$object = $openstack->objectStoreV1() - ->getContainer('test') - ->createLargeObject($options); + // optional: specify the container where the segments live. This does not necessarily have to be the + // same as the container which holds the manifest file + 'segmentContainer' => 'test_segments', +]); diff --git a/samples/ObjectStore/v1/objects/delete.php b/samples/ObjectStore/v1/objects/delete.php index 548e53bd..6392b4aa 100644 --- a/samples/ObjectStore/v1/objects/delete.php +++ b/samples/ObjectStore/v1/objects/delete.php @@ -9,10 +9,10 @@ 'id' => '{userId}', 'password' => '{password}', ], - 'scope' => ['project' => ['id' => '{projectId}']], ]); -$openstack->objectStoreV1() - ->getContainer('{containerName}') - ->getObject('{objectName}') - ->delete(); +$service = $openstack->objectStoreV1(); +$container = $service->getContainer('{containerName}'); +$object = $container->getObject('{objectName}'); + +$object->delete(); diff --git a/samples/ObjectStore/v1/objects/download.php b/samples/ObjectStore/v1/objects/download.php index 158c096a..dfc3f8af 100644 --- a/samples/ObjectStore/v1/objects/download.php +++ b/samples/ObjectStore/v1/objects/download.php @@ -9,10 +9,10 @@ 'id' => '{userId}', 'password' => '{password}', ], - 'scope' => ['project' => ['id' => '{projectId}']], ]); -$stream = $openstack->objectStoreV1() - ->getContainer('{containerName}') - ->getObject('{objectName}') - ->download(); +$service = $openstack->objectStoreV1(); +$container = $service->getContainer('{containerName}'); +$object = $container->getObject('{objectName}'); + +$object->download(); diff --git a/samples/ObjectStore/v1/objects/download_stream.php b/samples/ObjectStore/v1/objects/download_stream.php index 3d235b24..fb6bd32e 100644 --- a/samples/ObjectStore/v1/objects/download_stream.php +++ b/samples/ObjectStore/v1/objects/download_stream.php @@ -9,10 +9,10 @@ 'id' => '{userId}', 'password' => '{password}', ], - 'scope' => ['project' => ['id' => '{projectId}']], ]); -$stream = $openstack->objectStoreV1() - ->getContainer('{containerName}') - ->getObject('{objectName}') - ->download(['requestOptions' => ['stream' => true]]); +$service = $openstack->objectStoreV1(); +$container = $service->getContainer('{containerName}'); +$object = $container->getObject('{objectName}'); + +$object->download(['requestOptions' => ['stream' => true]]); diff --git a/samples/ObjectStore/v1/objects/get_metadata.php b/samples/ObjectStore/v1/objects/get_metadata.php index dbb871a5..51d49c87 100644 --- a/samples/ObjectStore/v1/objects/get_metadata.php +++ b/samples/ObjectStore/v1/objects/get_metadata.php @@ -9,10 +9,10 @@ 'id' => '{userId}', 'password' => '{password}', ], - 'scope' => ['project' => ['id' => '{projectId}']], ]); -$metadata = $openstack->objectStoreV1() - ->getContainer('{containerName}') - ->getObject('{objectName}') - ->getMetadata(); +$service = $openstack->objectStoreV1(); +$container = $service->getContainer('{containerName}'); +$object = $container->getObject('{objectName}'); + +$metadata = $object->getMetadata(); diff --git a/samples/ObjectStore/v1/objects/list.php b/samples/ObjectStore/v1/objects/list.php index 713cacec..54475db0 100644 --- a/samples/ObjectStore/v1/objects/list.php +++ b/samples/ObjectStore/v1/objects/list.php @@ -9,11 +9,10 @@ 'id' => '{userId}', 'password' => '{password}', ], - 'scope' => ['project' => ['id' => '{projectId}']], ]); -$container = $openstack->objectStoreV1() - ->getContainer('{containerName}'); +$service = $openstack->objectStoreV1(); +$container = $service->getContainer('{containerName}'); foreach ($container->listObjects() as $object) { /** @var \OpenStack\ObjectStore\v1\Models\StorageObject $object */ diff --git a/samples/ObjectStore/v1/objects/merge_metadata.php b/samples/ObjectStore/v1/objects/merge_metadata.php index 04c6c793..f6c3b500 100644 --- a/samples/ObjectStore/v1/objects/merge_metadata.php +++ b/samples/ObjectStore/v1/objects/merge_metadata.php @@ -7,15 +7,15 @@ 'region' => '{region}', 'user' => [ 'id' => '{userId}', - 'password' => '{password}' + 'password' => '{password}', ], - 'scope' => ['project' => ['id' => '{projectId}']] ]); -$openstack->objectStoreV1() - ->getContainer('{containerName}') - ->getObject('{objectName}') - ->mergeMetadata([ - '{key_1}' => '{val_1}', - '{key_2}' => '{val_2}', - ]); +$service = $openstack->objectStoreV1(); +$container = $service->getContainer('{containerName}'); +$object = $container->getObject('{objectName}'); + +$object->mergeMetadata([ + '{key_1}' => '{val_1}', + '{key_2}' => '{val_2}', +]); diff --git a/samples/ObjectStore/v1/objects/get.php b/samples/ObjectStore/v1/objects/read.php similarity index 58% rename from samples/ObjectStore/v1/objects/get.php rename to samples/ObjectStore/v1/objects/read.php index aeae0ad7..21c11a5a 100644 --- a/samples/ObjectStore/v1/objects/get.php +++ b/samples/ObjectStore/v1/objects/read.php @@ -9,9 +9,10 @@ 'id' => '{userId}', 'password' => '{password}', ], - 'scope' => ['project' => ['id' => '{projectId}']], ]); -$object = $openstack->objectStoreV1() - ->getContainer('{containerName}') - ->getObject('{objectName}'); +$service = $openstack->objectStoreV1(); +$container = $service->getContainer('{containerName}'); +$object = $container->getObject('{objectName}'); + +$object->retrieve(); \ No newline at end of file diff --git a/samples/ObjectStore/v1/objects/reset_metadata.php b/samples/ObjectStore/v1/objects/reset_metadata.php index 6c83e647..407298eb 100644 --- a/samples/ObjectStore/v1/objects/reset_metadata.php +++ b/samples/ObjectStore/v1/objects/reset_metadata.php @@ -7,15 +7,15 @@ 'region' => '{region}', 'user' => [ 'id' => '{userId}', - 'password' => '{password}' + 'password' => '{password}', ], - 'scope' => ['project' => ['id' => '{projectId}']] ]); -$openstack->objectStoreV1() - ->getContainer('{containerName}') - ->getObject('{objectName}') - ->resetMetadata([ - '{key_1}' => '{val_1}', - '{key_2}' => '{val_2}', - ]); +$service = $openstack->objectStoreV1(); +$container = $service->getContainer('{containerName}'); +$object = $container->getObject('{objectName}'); + +$object->resetMetadata([ + '{key_1}' => '{val_1}', + '{key_2}' => '{val_2}', +]); diff --git a/src/Networking/v2/Extensions/SecurityGroups/Models/SecurityGroup.php b/src/Networking/v2/Extensions/SecurityGroups/Models/SecurityGroup.php index 215fad49..1b09a2e4 100644 --- a/src/Networking/v2/Extensions/SecurityGroups/Models/SecurityGroup.php +++ b/src/Networking/v2/Extensions/SecurityGroups/Models/SecurityGroup.php @@ -59,6 +59,9 @@ protected function getAliases(): array ]; } + /** + * {@inheritdoc} + */ public function create(array $userOptions): Creatable { $response = $this->execute($this->api->postSecurityGroups(), $userOptions); diff --git a/src/Networking/v2/Extensions/SecurityGroups/Models/SecurityGroupRule.php b/src/Networking/v2/Extensions/SecurityGroups/Models/SecurityGroupRule.php index 825a2f51..4d0319dc 100644 --- a/src/Networking/v2/Extensions/SecurityGroups/Models/SecurityGroupRule.php +++ b/src/Networking/v2/Extensions/SecurityGroups/Models/SecurityGroupRule.php @@ -80,6 +80,9 @@ class SecurityGroupRule extends OperatorResource implements Creatable, Listable, protected $resourcesKey = 'security_group_rules'; + /** + * {@inheritdoc} + */ public function create(array $userOptions): Creatable { $response = $this->execute($this->api->postSecurityRules(), $userOptions); diff --git a/src/ObjectStore/v1/Models/Container.php b/src/ObjectStore/v1/Models/Container.php index 6448694e..fa935026 100644 --- a/src/ObjectStore/v1/Models/Container.php +++ b/src/ObjectStore/v1/Models/Container.php @@ -79,6 +79,8 @@ public function retrieve() /** * @param array $userOptions {@see \OpenStack\ObjectStore\v1\Api::putContainer} + * + * @return self */ public function create(array $userOptions): Creatable { diff --git a/tests/sample/ObjectStore/v1/ContainerTest.php b/tests/sample/ObjectStore/v1/ContainerTest.php index 426ae3ca..6e25ee1c 100644 --- a/tests/sample/ObjectStore/v1/ContainerTest.php +++ b/tests/sample/ObjectStore/v1/ContainerTest.php @@ -22,13 +22,14 @@ public function testCreate(): Container /** * @depends testCreate */ - public function testGet(Container $createdContainer) + public function testRead(Container $createdContainer) { /** @var \OpenStack\ObjectStore\v1\Models\Container $container */ require_once $this->sampleFile('containers/get.php', ['{containerName}' => $createdContainer->name]); $this->assertInstanceOf(Container::class, $container); $this->assertEquals($createdContainer->name, $container->name); + $this->assertEquals($createdContainer->objectCount, $container->objectCount); $this->assertEquals([], $container->metadata); } diff --git a/tests/sample/ObjectStore/v1/ObjectTest.php b/tests/sample/ObjectStore/v1/ObjectTest.php index 731490af..6f71e7f3 100644 --- a/tests/sample/ObjectStore/v1/ObjectTest.php +++ b/tests/sample/ObjectStore/v1/ObjectTest.php @@ -99,17 +99,20 @@ public function testDownloadStream(StorageObject $createdObject) /** * @depends testCreate */ - public function testGet(StorageObject $createdObject) + public function testRead(StorageObject $createdObject) { /** @var StorageObject $object */ - require_once $this->sampleFile('objects/get.php', [ + require_once $this->sampleFile('objects/read.php', [ '{containerName}' => $createdObject->containerName, '{objectName}' => $createdObject->name, ]); $this->assertInstanceOf(StorageObject::class, $object); $this->assertEquals($createdObject->name, $object->name); - $this->assertEquals(null, $object->metadata); + $this->assertEquals($createdObject->containerName, $object->containerName); + $this->assertEquals($createdObject->contentLength, $object->contentLength); + $this->assertEquals($createdObject->hash, $object->hash); + $this->assertEquals([], $object->metadata); } /** From 8eba7609bb3c7e1aa831a21f2a642c248af0ed98 Mon Sep 17 00:00:00 2001 From: Konstantin Babushkin Date: Tue, 30 Jan 2024 09:48:21 +0100 Subject: [PATCH 45/50] new docs for networking --- doc/services/networking/v2/create.rst | 3 + doc/services/networking/v2/index.rst | 6 ++ .../v2/loadbalancer-healthmonitors.rst | 40 +++++++------ .../networking/v2/loadbalancer-listeners.rst | 39 ++++++------ .../networking/v2/loadbalancer-pools.rst | 37 ++++++------ doc/services/networking/v2/loadbalancers.rst | 59 +++++++++++-------- doc/services/networking/v2/networks.rst | 36 ++++++----- doc/services/networking/v2/ports.rst | 38 +++++++----- doc/services/networking/v2/subnets.rst | 38 +++++++----- doc/services/object-store/v1/create.rst | 2 +- .../v2/lbaas/healthmonitors/get.php | 23 -------- .../v2/lbaas/healthmonitors/read.php | 17 ++++++ .../v2/lbaas/listeners/{get.php => read.php} | 10 +--- .../v2/lbaas/loadbalancers/get_statuses.php | 3 +- .../lbaas/loadbalancers/{get.php => read.php} | 0 .../v2/lbaas/pools/{get.php => read.php} | 9 +-- samples/Networking/v2/networks/create.php | 17 ++---- .../Networking/v2/networks/create_batch.php | 20 ++----- samples/Networking/v2/networks/delete.php | 10 +--- samples/Networking/v2/networks/get.php | 28 --------- samples/Networking/v2/networks/read.php | 17 ++++++ samples/Networking/v2/networks/update.php | 10 +--- samples/Networking/v2/ports/create.php | 12 ++-- samples/Networking/v2/ports/create_batch.php | 14 +++-- .../v2/ports/create_with_fixed_ips.php | 10 ++-- samples/Networking/v2/ports/delete.php | 10 ++-- samples/Networking/v2/ports/list.php | 10 ++-- .../Networking/v2/ports/{get.php => read.php} | 9 ++- samples/Networking/v2/ports/update.php | 10 ++-- .../Networking/v2/subnets/create_batch.php | 31 ++++------ .../v2/subnets/create_with_gateway_ip.php | 18 ++---- .../v2/subnets/create_with_host_routes.php | 14 +---- samples/Networking/v2/subnets/delete.php | 10 +--- samples/Networking/v2/subnets/get.php | 28 --------- samples/Networking/v2/subnets/read.php | 17 ++++++ samples/Networking/v2/subnets/update.php | 12 +--- tests/sample/Networking/v2/NetworkTest.php | 2 +- tests/sample/Networking/v2/PortTest.php | 2 +- 38 files changed, 312 insertions(+), 359 deletions(-) create mode 100644 doc/services/networking/v2/create.rst delete mode 100644 samples/Networking/v2/lbaas/healthmonitors/get.php create mode 100644 samples/Networking/v2/lbaas/healthmonitors/read.php rename samples/Networking/v2/lbaas/listeners/{get.php => read.php} (54%) rename samples/Networking/v2/lbaas/loadbalancers/{get.php => read.php} (100%) rename samples/Networking/v2/lbaas/pools/{get.php => read.php} (59%) delete mode 100644 samples/Networking/v2/networks/get.php create mode 100644 samples/Networking/v2/networks/read.php rename samples/Networking/v2/ports/{get.php => read.php} (64%) delete mode 100644 samples/Networking/v2/subnets/get.php create mode 100644 samples/Networking/v2/subnets/read.php diff --git a/doc/services/networking/v2/create.rst b/doc/services/networking/v2/create.rst new file mode 100644 index 00000000..05f45843 --- /dev/null +++ b/doc/services/networking/v2/create.rst @@ -0,0 +1,3 @@ +.. |method| replace:: networkingV2 + +.. include:: /common/create-service.rst diff --git a/doc/services/networking/v2/index.rst b/doc/services/networking/v2/index.rst index 2b545644..0eafffd9 100644 --- a/doc/services/networking/v2/index.rst +++ b/doc/services/networking/v2/index.rst @@ -1,9 +1,15 @@ Networking v2 ============= +OpenStack Networking (Neutron) API Version 2. The project provides “network connectivity as a service” between +interface devices (e.g., vNICs) managed by other OpenStack services (e.g., nova). + +.. osdoc:: https://docs.openstack.org/api-ref/network/v2/index.html + .. toctree:: :maxdepth: 3 + create networks subnets ports diff --git a/doc/services/networking/v2/loadbalancer-healthmonitors.rst b/doc/services/networking/v2/loadbalancer-healthmonitors.rst index e383a2ff..c177f6f4 100644 --- a/doc/services/networking/v2/loadbalancer-healthmonitors.rst +++ b/doc/services/networking/v2/loadbalancer-healthmonitors.rst @@ -1,32 +1,36 @@ LoadBalancer HealthMonitors =========================== -Create HealthMonitor --------------------- +.. warning:: + Load balancing functions accessed via the neutron endpoint are deprecated and will be removed in a future release. + Users are strongly encouraged to migrate to using the octavia endpoint. + This library does not support the octavia endpoint yet. + Consider `helping `_ us to implement it . -.. sample:: Networking/v2/lbaas/healthmonitors/create.php -.. refdoc:: OpenStack/Networking/v2/Service.html#method_createLoadBalancerHealthMonitor +.. osdoc:: https://docs.openstack.org/api-ref/network/v2/index.html#load-balancer-as-a-service-2-0-deprecated -Get HealthMonitor ------------------ +Create +------ -.. sample:: Networking/v2/lbaas/healthmonitors/get.php -.. refdoc:: OpenStack/Networking/v2/Service.html#method_getLoadBalancerHealthMonitor +.. sample:: Networking/v2/lbaas/healthmonitors/create.php -List HealthMonitors -------------------- +Read +---- -.. sample:: Networking/v2/lbaas/healthmonitors/list.php -.. refdoc:: OpenStack/Networking/v2/Service.html#method_listLoadBalancerHealthMonitors +.. sample:: Networking/v2/lbaas/healthmonitors/read.php -Update HealthMonitor --------------------- +Update +------ .. sample:: Networking/v2/lbaas/healthmonitors/update.php -.. refdoc:: OpenStack/Networking/v2/Models/LoadBalancerHealthMonitor.html#method_update -Delete HealthMonitor --------------------- +Delete +------ .. sample:: Networking/v2/lbaas/healthmonitors/delete.php -.. refdoc:: OpenStack/Networking/v2/Models/LoadBalancerHealthMonitor.html#method_delete + +List +---- + +.. sample:: Networking/v2/lbaas/healthmonitors/list.php + diff --git a/doc/services/networking/v2/loadbalancer-listeners.rst b/doc/services/networking/v2/loadbalancer-listeners.rst index a99a1df5..1cc5624f 100644 --- a/doc/services/networking/v2/loadbalancer-listeners.rst +++ b/doc/services/networking/v2/loadbalancer-listeners.rst @@ -1,32 +1,35 @@ LoadBalancer Listeners ====================== -Create Listener ---------------- +.. warning:: + Load balancing functions accessed via the neutron endpoint are deprecated and will be removed in a future release. + Users are strongly encouraged to migrate to using the octavia endpoint. + This library does not support the octavia endpoint yet. + Consider `helping `_ us to implement it . -.. sample:: Networking/v2/lbaas/listeners/create.php -.. refdoc:: OpenStack/Networking/v2/Service.html#method_createLoadBalancerListener +.. osdoc:: https://docs.openstack.org/api-ref/network/v2/index.html#load-balancer-as-a-service-2-0-deprecated -Get Listener ------------- +Create +------ -.. sample:: Networking/v2/lbaas/listeners/get.php -.. refdoc:: OpenStack/Networking/v2/Service.html#method_getLoadBalancerListener +.. sample:: Networking/v2/lbaas/listeners/create.php -List Listeners --------------- +Read +---- -.. sample:: Networking/v2/lbaas/listeners/list.php -.. refdoc:: OpenStack/Networking/v2/Service.html#method_listLoadBalancerListeners +.. sample:: Networking/v2/lbaas/listeners/read.php -Update Listener ---------------- +Update +------ .. sample:: Networking/v2/lbaas/listeners/update.php -.. refdoc:: OpenStack/Networking/v2/Models/LoadBalancerListener.html#method_update -Delete Listener ---------------- +Delete +------ .. sample:: Networking/v2/lbaas/listeners/delete.php -.. refdoc:: OpenStack/Networking/v2/Models/LoadBalancerListener.html#method_delete + +List +---- + +.. sample:: Networking/v2/lbaas/listeners/list.php diff --git a/doc/services/networking/v2/loadbalancer-pools.rst b/doc/services/networking/v2/loadbalancer-pools.rst index 891b487d..7100b55e 100644 --- a/doc/services/networking/v2/loadbalancer-pools.rst +++ b/doc/services/networking/v2/loadbalancer-pools.rst @@ -1,56 +1,55 @@ LoadBalancer Pools ================== -Create Pool ------------ +.. warning:: + Load balancing functions accessed via the neutron endpoint are deprecated and will be removed in a future release. + Users are strongly encouraged to migrate to using the octavia endpoint. + This library does not support the octavia endpoint yet. + Consider `helping `_ us to implement it . + +.. osdoc:: https://docs.openstack.org/api-ref/network/v2/index.html#load-balancer-as-a-service-2-0-deprecated + +Create +------ .. sample:: Networking/v2/lbaas/pools/create.php -.. refdoc:: OpenStack/Networking/v2/Service.html#method_createLoadBalancerPool -Get Pool --------- +Read +---- -.. sample:: Networking/v2/lbaas/pools/get.php -.. refdoc:: OpenStack/Networking/v2/Service.html#method_getLoadBalancerPool +.. sample:: Networking/v2/lbaas/pools/read.php -List Pools ----------- +List +---- .. sample:: Networking/v2/lbaas/pools/list.php -.. refdoc:: OpenStack/Networking/v2/Service.html#method_listLoadBalancerPools -Update Pool +Update ----------- .. sample:: Networking/v2/lbaas/pools/update.php -.. refdoc:: OpenStack/Networking/v2/Models/LoadBalancerPool.html#method_update -Delete Pool ------------ +Delete +------ .. sample:: Networking/v2/lbaas/pools/delete.php -.. refdoc:: OpenStack/Networking/v2/Models/LoadBalancerPool.html#method_delete Add Member ---------- .. sample:: Networking/v2/lbaas/pools/add-member.php -.. refdoc:: OpenStack/Networking/v2/Models/LoadBalancerPool.html#method_addMember Get Member ---------- .. sample:: Networking/v2/lbaas/pools/get-member.php -.. refdoc:: OpenStack/Networking/v2/Models/LoadBalancerPool.html#method_getMember Delete Member ------------- .. sample:: Networking/v2/lbaas/pools/delete-member.php -.. refdoc:: OpenStack/Networking/v2/Models/LoadBalancerPool.html#method_deleteMember Add Health Monitor ------------------ .. sample:: Networking/v2/lbaas/pools/add-healthmonitor.php -.. refdoc:: OpenStack/Networking/v2/Models/LoadBalancerPool.html#method_addHealthMonitor diff --git a/doc/services/networking/v2/loadbalancers.rst b/doc/services/networking/v2/loadbalancers.rst index a04ae815..7185b39f 100644 --- a/doc/services/networking/v2/loadbalancers.rst +++ b/doc/services/networking/v2/loadbalancers.rst @@ -1,47 +1,54 @@ LoadBalancers ============= -Create LoadBalancer -------------------- +.. warning:: + Load balancing functions accessed via the neutron endpoint are deprecated and will be removed in a future release. + Users are strongly encouraged to migrate to using the octavia endpoint. + This library does not support the octavia endpoint yet. + Consider `helping `_ us to implement it . -.. sample:: Networking/v2/lbaas/loadbalancers/create.php -.. refdoc:: OpenStack/Networking/v2/Service.html#method_createLoadBalancer +.. osdoc:: https://docs.openstack.org/api-ref/network/v2/index.html#load-balancer-as-a-service-2-0-deprecated -Get LoadBalancer ----------------- +.. |models| replace:: load balancers -.. sample:: Networking/v2/lbaas/loadbalancers/get.php -.. refdoc:: OpenStack/Networking/v2/Service.html#method_getLoadBalancer +.. include:: /common/service.rst -List LoadBalancers ------------------- +Create +------ -.. sample:: Networking/v2/lbaas/loadbalancers/list.php -.. refdoc:: OpenStack/Networking/v2/Service.html#method_listLoadBalancers +.. sample:: Networking/v2/lbaas/loadbalancers/create.php -Update LoadBalancer -------------------- +Read +---- + +.. sample:: Networking/v2/lbaas/loadbalancers/read.php + +Update +------ .. sample:: Networking/v2/lbaas/loadbalancers/update.php -.. refdoc:: OpenStack/Networking/v2/Models/LoadBalancer.html#method_update -Delete LoadBalancer -------------------- +Delete +------ .. sample:: Networking/v2/lbaas/loadbalancers/delete.php -.. refdoc:: OpenStack/Networking/v2/Models/LoadBalancer.html#method_delete -Add Listener to LoadBalancer ----------------------------- +List +---- + +.. sample:: Networking/v2/lbaas/loadbalancers/list.php + +Add Listener +------------ + .. sample:: Networking/v2/lbaas/loadbalancers/add_listener.php -.. refdoc:: OpenStack/Networking/v2/Models/LoadBalancer.html#method_addListener -Get Stats for LoadBalancer --------------------------- +Get Stats +--------- + .. sample:: Networking/v2/lbaas/loadbalancers/get_stats.php -.. refdoc:: OpenStack/Networking/v2/Models/LoadBalancer.html#method_getStats -Get Status Tree for LoadBalancer +Get Status Tree -------------------------------- + .. sample:: Networking/v2/lbaas/loadbalancers/get_statuses.php -.. refdoc:: OpenStack/Networking/v2/Models/LoadBalancer.html#method_getStatuses diff --git a/doc/services/networking/v2/networks.rst b/doc/services/networking/v2/networks.rst index 27719c39..f066427a 100644 --- a/doc/services/networking/v2/networks.rst +++ b/doc/services/networking/v2/networks.rst @@ -1,32 +1,38 @@ Networks ======== -Create network +Network represents an isolated Layer-2 networking segment within the cloud. It can be shared across tenants, +or isolated to a single tenant. + +.. osdoc:: https://docs.openstack.org/api-ref/network/v2/index.html#layer-2-networking + +.. |models| replace:: networks + +.. include:: /common/service.rst + +Create -------------- .. sample:: Networking/v2/networks/create.php -.. refdoc:: OpenStack/Networking/v2/networks/Service.html#method_createNetwork -Create networks ---------------- +Batch +~~~~~ + +To create multiple networks in a single request, use the following code: .. sample:: Networking/v2/networks/create_batch.php -.. refdoc:: OpenStack/Networking/v2/networks/Service.html#method_createNetworks -Get network ------------ +Read +---- -.. sample:: Networking/v2/networks/get.php -.. refdoc:: OpenStack/Networking/v2/networks/Service.html#method_getNetwork +.. sample:: Networking/v2/networks/read.php -Update network --------------- +Update +------ .. sample:: Networking/v2/networks/update.php -.. refdoc:: OpenStack/Networking/v2/networks/Models/Network.html#method_update -Delete network --------------- +Delete +------ .. sample:: Networking/v2/networks/delete.php -.. refdoc:: OpenStack/Networking/v2/networks/Models/Network.html#method_delete \ No newline at end of file diff --git a/doc/services/networking/v2/ports.rst b/doc/services/networking/v2/ports.rst index 7efc7e90..34011301 100644 --- a/doc/services/networking/v2/ports.rst +++ b/doc/services/networking/v2/ports.rst @@ -1,32 +1,38 @@ Ports ===== -Create port ------------ +A port is a connection point for attaching a single device, such as the NIC of a virtual server, to a virtual network. +The port also describes the associated network configuration, such as the MAC and IP addresses to be used on that port. + +.. osdoc:: https://docs.openstack.org/api-ref/network/v2/index.html#ports + +.. |models| replace:: ports + +.. include:: /common/service.rst + +Create +------ .. sample:: Networking/v2/ports/create.php -.. refdoc:: OpenStack/Networking/v2/ports/Service.html#method_createPort -Create ports ------------- +Batch +~~~~~ + +To create multiple ports in a single request, use the following code: .. sample:: Networking/v2/ports/create_batch.php -.. refdoc:: OpenStack/Networking/v2/ports/Service.html#method_createPorts -Get port --------- +Read +---- -.. sample:: Networking/v2/ports/get.php -.. refdoc:: OpenStack/Networking/v2/ports/Service.html#method_getPort +.. sample:: Networking/v2/ports/read.php -Update port ------------ +Update +------ .. sample:: Networking/v2/ports/update.php -.. refdoc:: OpenStack/Networking/v2/ports/Models/Port.html#method_update -Delete port ------------ +Delete +------ .. sample:: Networking/v2/ports/delete.php -.. refdoc:: OpenStack/Networking/v2/ports/Models/Port.html#method_delete \ No newline at end of file diff --git a/doc/services/networking/v2/subnets.rst b/doc/services/networking/v2/subnets.rst index 39b50901..bbd92196 100644 --- a/doc/services/networking/v2/subnets.rst +++ b/doc/services/networking/v2/subnets.rst @@ -1,34 +1,42 @@ Subnets ======= -Create subnet -------------- +A block of IP addresses and associated configuration state. This is also known as the native IPAM (IP Address Management) +provided by the networking service for both project and provider networks. Subnets are used to allocate IP addresses +when new ports are created on a network. + +.. osdoc:: https://docs.openstack.org/api-ref/network/v2/index.html#subnets + +.. |models| replace:: subnets + +.. include:: /common/service.rst + +Create +------ .. sample:: Networking/v2/subnets/create.php -.. refdoc:: OpenStack/Networking/v2/subnets/Service.html#method_createSubnet -To create a subnet with gateway IP: +With gateway IP +~~~~~~~~~~~~~~~ .. sample:: Networking/v2/subnets/create_with_gateway_ip.php -To create a subnet with host routes: +With host routes +~~~~~~~~~~~~~~~~ .. sample:: Networking/v2/subnets/create_with_host_routes.php -Get subnet ----------- +Read +---- -.. sample:: Networking/v2/subnets/get.php -.. refdoc:: OpenStack/Networking/v2/subnets/Service.html#method_getSubnet +.. sample:: Networking/v2/subnets/read.php -Update subnet -------------- +Update +------ .. sample:: Networking/v2/subnets/update.php -.. refdoc:: OpenStack/Networking/v2/subnets/Models/Subnet.html#method_update -Delete subnet -------------- +Delete +------ .. sample:: Networking/v2/subnets/delete.php -.. refdoc:: OpenStack/Networking/v2/subnets/Models/Subnet.html#method_delete \ No newline at end of file diff --git a/doc/services/object-store/v1/create.rst b/doc/services/object-store/v1/create.rst index 4791fe57..07800c76 100644 --- a/doc/services/object-store/v1/create.rst +++ b/doc/services/object-store/v1/create.rst @@ -1,3 +1,3 @@ -.. |method| replace:: +.. |method| replace:: objectStoreV1 .. include:: /common/create-service.rst diff --git a/samples/Networking/v2/lbaas/healthmonitors/get.php b/samples/Networking/v2/lbaas/healthmonitors/get.php deleted file mode 100644 index 1b848062..00000000 --- a/samples/Networking/v2/lbaas/healthmonitors/get.php +++ /dev/null @@ -1,23 +0,0 @@ - '{authUrl}', - 'region' => '{region}', - 'user' => [ - 'id' => '{userId}', - 'password' => '{password}' - ], - 'scope' => [ - 'project' => [ - 'id' => '{projectId}' - ] - ] -]); - -$networking = $openstack->networkingV2(); - -// Get the health monitor -$healthmonitor = $networking->getLoadBalancerHealthMonitor('{healthmonitorId}'); -$healthmonitor->retrieve(); diff --git a/samples/Networking/v2/lbaas/healthmonitors/read.php b/samples/Networking/v2/lbaas/healthmonitors/read.php new file mode 100644 index 00000000..58ce8108 --- /dev/null +++ b/samples/Networking/v2/lbaas/healthmonitors/read.php @@ -0,0 +1,17 @@ + '{authUrl}', + 'region' => '{region}', + 'user' => [ + 'id' => '{userId}', + 'password' => '{password}' + ], +]); + +$service = $openstack->networkingV2(); +$healthMonitor = $service->getLoadBalancerHealthMonitor('{healthMonitorId}'); + +$healthMonitor->retrieve(); diff --git a/samples/Networking/v2/lbaas/listeners/get.php b/samples/Networking/v2/lbaas/listeners/read.php similarity index 54% rename from samples/Networking/v2/lbaas/listeners/get.php rename to samples/Networking/v2/lbaas/listeners/read.php index 7c9b4305..cba83f94 100644 --- a/samples/Networking/v2/lbaas/listeners/get.php +++ b/samples/Networking/v2/lbaas/listeners/read.php @@ -9,15 +9,9 @@ 'id' => '{userId}', 'password' => '{password}' ], - 'scope' => [ - 'project' => [ - 'id' => '{projectId}' - ] - ] ]); -$networking = $openstack->networkingV2(); +$service = $openstack->networkingV2(); +$listener = $service->getLoadBalancerListener('{listenerId}'); -// Get the listener -$listener = $networking->getLoadBalancerListener('{listenerId}'); $listener->retrieve(); diff --git a/samples/Networking/v2/lbaas/loadbalancers/get_statuses.php b/samples/Networking/v2/lbaas/loadbalancers/get_statuses.php index cd4c165d..40e3132e 100644 --- a/samples/Networking/v2/lbaas/loadbalancers/get_statuses.php +++ b/samples/Networking/v2/lbaas/loadbalancers/get_statuses.php @@ -18,7 +18,6 @@ $networking = $openstack->networkingV2(); -// Get the loadbalancer $lb = $networking->getLoadBalancer('{loadbalancerId}'); -$stats = $lb->getStats(); +$status = $lb->getStatuses(); diff --git a/samples/Networking/v2/lbaas/loadbalancers/get.php b/samples/Networking/v2/lbaas/loadbalancers/read.php similarity index 100% rename from samples/Networking/v2/lbaas/loadbalancers/get.php rename to samples/Networking/v2/lbaas/loadbalancers/read.php diff --git a/samples/Networking/v2/lbaas/pools/get.php b/samples/Networking/v2/lbaas/pools/read.php similarity index 59% rename from samples/Networking/v2/lbaas/pools/get.php rename to samples/Networking/v2/lbaas/pools/read.php index 734336a8..8c48db7f 100644 --- a/samples/Networking/v2/lbaas/pools/get.php +++ b/samples/Networking/v2/lbaas/pools/read.php @@ -9,15 +9,10 @@ 'id' => '{userId}', 'password' => '{password}' ], - 'scope' => [ - 'project' => [ - 'id' => '{projectId}' - ] - ] ]); -$networking = $openstack->networkingV2(); +$read = $openstack->networkingV2(); // Get the pool -$pool = $networking->getLoadBalancerPool('{poolId}'); +$pool = $read->getLoadBalancerPool('{poolId}'); $pool->retrieve(); diff --git a/samples/Networking/v2/networks/create.php b/samples/Networking/v2/networks/create.php index 5b794822..e6632053 100644 --- a/samples/Networking/v2/networks/create.php +++ b/samples/Networking/v2/networks/create.php @@ -7,21 +7,12 @@ 'region' => '{region}', 'user' => [ 'id' => '{userId}', - 'password' => '{password}' + 'password' => '{password}', ], - 'scope' => [ - 'project' => [ - 'id' => '{projectId}' - ] - ] ]); -$networking = $openstack->networkingV2(); - -$options = [ +$service = $openstack->networkingV2(); +$network = $service->createNetwork([ 'name' => '{networkName}', 'adminStateUp' => true, -]; - -// Create the network -$network = $networking->createNetwork($options); +]); diff --git a/samples/Networking/v2/networks/create_batch.php b/samples/Networking/v2/networks/create_batch.php index 4f499f8b..07395cdd 100644 --- a/samples/Networking/v2/networks/create_batch.php +++ b/samples/Networking/v2/networks/create_batch.php @@ -7,24 +7,16 @@ 'region' => '{region}', 'user' => [ 'id' => '{userId}', - 'password' => '{password}' + 'password' => '{password}', ], - 'scope' => [ - 'project' => [ - 'id' => '{projectId}' - ] - ] ]); -$networking = $openstack->networkingV2(); - -$options = [ +$service = $openstack->networkingV2(); +$networks = $service->createNetworks([ [ - 'name' => '{networkName1}' + 'name' => '{networkName1}', ], [ - 'name' => '{networkName2}' + 'name' => '{networkName2}', ], -]; - -$networks = $networking->createNetworks($options); +]); diff --git a/samples/Networking/v2/networks/delete.php b/samples/Networking/v2/networks/delete.php index 87325d91..3965aa15 100644 --- a/samples/Networking/v2/networks/delete.php +++ b/samples/Networking/v2/networks/delete.php @@ -9,15 +9,9 @@ 'id' => '{userId}', 'password' => '{password}' ], - 'scope' => [ - 'project' => [ - 'id' => '{projectId}' - ] - ] ]); -$networking = $openstack->networkingV2(); - -$network = $networking->getNetwork('{networkId}'); +$service = $openstack->networkingV2(); +$network = $service->getNetwork('{networkId}'); $network->delete(); diff --git a/samples/Networking/v2/networks/get.php b/samples/Networking/v2/networks/get.php deleted file mode 100644 index bda39d2d..00000000 --- a/samples/Networking/v2/networks/get.php +++ /dev/null @@ -1,28 +0,0 @@ - '{authUrl}', - 'region' => '{region}', - 'user' => [ - 'id' => '{userId}', - 'password' => '{password}' - ], - 'scope' => [ - 'project' => [ - 'id' => '{projectId}' - ] - ] -]); - -$networking = $openstack->networkingV2(); - -$network = $networking->getNetwork('{networkId}'); - -// By default, this will return an empty Network object and NOT hit the API. -// This is convenient for when you want to use the object for operations -// that do not require an initial GET request. To retrieve the network's details, -// run the following, which *will* call the API with a GET request: - -$network->retrieve(); diff --git a/samples/Networking/v2/networks/read.php b/samples/Networking/v2/networks/read.php new file mode 100644 index 00000000..4b9dcee5 --- /dev/null +++ b/samples/Networking/v2/networks/read.php @@ -0,0 +1,17 @@ + '{authUrl}', + 'region' => '{region}', + 'user' => [ + 'id' => '{userId}', + 'password' => '{password}' + ], +]); + +$service = $openstack->networkingV2(); +$network = $service->getNetwork('{networkId}'); + +$network->retrieve(); diff --git a/samples/Networking/v2/networks/update.php b/samples/Networking/v2/networks/update.php index 01e9422c..06c03cbb 100644 --- a/samples/Networking/v2/networks/update.php +++ b/samples/Networking/v2/networks/update.php @@ -9,16 +9,10 @@ 'id' => '{userId}', 'password' => '{password}' ], - 'scope' => [ - 'project' => [ - 'id' => '{projectId}' - ] - ] ]); -$networking = $openstack->networkingV2(); - -$network = $networking->getNetwork('{networkId}'); +$service = $openstack->networkingV2(); +$network = $service->getNetwork('{networkId}'); $network->name = '{newName}'; $network->update(); diff --git a/samples/Networking/v2/ports/create.php b/samples/Networking/v2/ports/create.php index 285ed652..9312d3f2 100644 --- a/samples/Networking/v2/ports/create.php +++ b/samples/Networking/v2/ports/create.php @@ -5,14 +5,16 @@ $openstack = new OpenStack\OpenStack([ 'authUrl' => '{authUrl}', 'region' => '{region}', - 'user' => ['id' => '{userId}', 'password' => '{password}'], - 'scope' => ['project' => ['id' => '{projectId}']] + 'user' => [ + 'id' => '{userId}', + 'password' => '{password}', + ], ]); -$networking = $openstack->networkingV2(); +$service = $openstack->networkingV2(); -$port = $networking->createPort([ +$port = $service->createPort([ 'name' => '{portName}', 'networkId' => '{networkId}', - 'adminStateUp' => true + 'adminStateUp' => true, ]); diff --git a/samples/Networking/v2/ports/create_batch.php b/samples/Networking/v2/ports/create_batch.php index f5206a1e..7c32b811 100644 --- a/samples/Networking/v2/ports/create_batch.php +++ b/samples/Networking/v2/ports/create_batch.php @@ -5,21 +5,23 @@ $openstack = new OpenStack\OpenStack([ 'authUrl' => '{authUrl}', 'region' => '{region}', - 'user' => ['id' => '{userId}', 'password' => '{password}'], - 'scope' => ['project' => ['id' => '{projectId}']] + 'user' => [ + 'id' => '{userId}', + 'password' => '{password}', + ], ]); -$networking = $openstack->networkingV2(); +$service = $openstack->networkingV2(); -$ports = $networking->createPorts([ +$ports = $service->createPorts([ [ 'name' => '{name1}', 'networkId' => '{networkId1}', - 'adminStateUp' => true + 'adminStateUp' => true, ], [ 'name' => '{name2}', 'networkId' => '{networkId2}', - 'adminStateUp' => true + 'adminStateUp' => true, ], ]); diff --git a/samples/Networking/v2/ports/create_with_fixed_ips.php b/samples/Networking/v2/ports/create_with_fixed_ips.php index ae28661a..4d96884f 100644 --- a/samples/Networking/v2/ports/create_with_fixed_ips.php +++ b/samples/Networking/v2/ports/create_with_fixed_ips.php @@ -5,13 +5,15 @@ $openstack = new OpenStack\OpenStack([ 'authUrl' => '{authUrl}', 'region' => '{region}', - 'user' => ['id' => '{userId}', 'password' => '{password}'], - 'scope' => ['project' => ['id' => '{projectId}']] + 'user' => [ + 'id' => '{userId}', + 'password' => '{password}' + ], ]); -$networking = $openstack->networkingV2(); +$service = $openstack->networkingV2(); -$port = $networking->createPort([ +$port = $service->createPort([ 'name' => '{portName}', 'networkId' => '{networkId}', 'adminStateUp' => true, diff --git a/samples/Networking/v2/ports/delete.php b/samples/Networking/v2/ports/delete.php index 5c8f338d..2c6a8884 100644 --- a/samples/Networking/v2/ports/delete.php +++ b/samples/Networking/v2/ports/delete.php @@ -5,11 +5,13 @@ $openstack = new OpenStack\OpenStack([ 'authUrl' => '{authUrl}', 'region' => '{region}', - 'user' => ['id' => '{userId}', 'password' => '{password}'], - 'scope' => ['project' => ['id' => '{projectId}']] + 'user' => [ + 'id' => '{userId}', + 'password' => '{password}', + ], ]); -$networking = $openstack->networkingV2(); +$service = $openstack->networkingV2(); +$port = $service->getPort('{portId}'); -$port = $networking->getPort('{portId}'); $port->delete(); diff --git a/samples/Networking/v2/ports/list.php b/samples/Networking/v2/ports/list.php index 0442d566..19b8039c 100644 --- a/samples/Networking/v2/ports/list.php +++ b/samples/Networking/v2/ports/list.php @@ -5,12 +5,14 @@ $openstack = new OpenStack\OpenStack([ 'authUrl' => '{authUrl}', 'region' => '{region}', - 'user' => ['id' => '{userId}', 'password' => '{password}'], - 'scope' => ['project' => ['id' => '{projectId}']] + 'user' => [ + 'id' => '{userId}', + 'password' => '{password}', + ], ]); -$networking = $openstack->networkingV2(); +$service = $openstack->networkingV2(); -foreach ($networking->listPorts() as $port) { +foreach ($service->listPorts() as $port) { /** @var \OpenStack\Networking\v2\Models\Port $port */ } diff --git a/samples/Networking/v2/ports/get.php b/samples/Networking/v2/ports/read.php similarity index 64% rename from samples/Networking/v2/ports/get.php rename to samples/Networking/v2/ports/read.php index 7e0d960c..3e00a29e 100644 --- a/samples/Networking/v2/ports/get.php +++ b/samples/Networking/v2/ports/read.php @@ -5,10 +5,13 @@ $openstack = new OpenStack\OpenStack([ 'authUrl' => '{authUrl}', 'region' => '{region}', - 'user' => ['id' => '{userId}', 'password' => '{password}'], - 'scope' => ['project' => ['id' => '{projectId}']] + 'user' => [ + 'id' => '{userId}', + 'password' => '{password}', + ], ]); $networking = $openstack->networkingV2(); - $port = $networking->getPort('{portId}'); + +$port->retrieve(); diff --git a/samples/Networking/v2/ports/update.php b/samples/Networking/v2/ports/update.php index a8f39e65..4d2682e3 100644 --- a/samples/Networking/v2/ports/update.php +++ b/samples/Networking/v2/ports/update.php @@ -5,12 +5,14 @@ $openstack = new OpenStack\OpenStack([ 'authUrl' => '{authUrl}', 'region' => '{region}', - 'user' => ['id' => '{userId}', 'password' => '{password}'], - 'scope' => ['project' => ['id' => '{projectId}']] + 'user' => [ + 'id' => '{userId}', + 'password' => '{password}', + ], ]); -$networking = $openstack->networkingV2(); +$service = $openstack->networkingV2(); +$port = $service->getPort('{portId}'); -$port = $networking->getPort('{portId}'); $port->name = '{newName}'; $port->update(); diff --git a/samples/Networking/v2/subnets/create_batch.php b/samples/Networking/v2/subnets/create_batch.php index 79c60aab..5d4599c4 100644 --- a/samples/Networking/v2/subnets/create_batch.php +++ b/samples/Networking/v2/subnets/create_batch.php @@ -7,30 +7,23 @@ 'region' => '{region}', 'user' => [ 'id' => '{userId}', - 'password' => '{password}' + 'password' => '{password}', ], - 'scope' => [ - 'project' => [ - 'id' => '{projectId}' - ] - ] ]); -$networking = $openstack->networkingV2(); +$service = $openstack->networkingV2(); -$options = [ +$subnets = $service->createSubnets([ [ - 'name' => '{subnetName1}', - 'networkId' => '{networkId1}', - 'ipVersion' => 4, - 'cidr' => '192.168.199.0/24', + 'name' => '{subnetName1}', + 'networkId' => '{networkId1}', + 'ipVersion' => 4, + 'cidr' => '192.168.199.0/24', ], [ - 'name' => '{subnetName2}', - 'networkId' => '{networkId2}', - 'ipVersion' => 4, - 'cidr' => '10.56.4.0/22', + 'name' => '{subnetName2}', + 'networkId' => '{networkId2}', + 'ipVersion' => 4, + 'cidr' => '10.56.4.0/22', ], -]; - -$subnets = $networking->createSubnets($options); +]); diff --git a/samples/Networking/v2/subnets/create_with_gateway_ip.php b/samples/Networking/v2/subnets/create_with_gateway_ip.php index 168837f3..8c07deeb 100644 --- a/samples/Networking/v2/subnets/create_with_gateway_ip.php +++ b/samples/Networking/v2/subnets/create_with_gateway_ip.php @@ -7,24 +7,16 @@ 'region' => '{region}', 'user' => [ 'id' => '{userId}', - 'password' => '{password}' + 'password' => '{password}', ], - 'scope' => [ - 'project' => [ - 'id' => '{projectId}' - ] - ] ]); -$networking = $openstack->networkingV2(); +$service = $openstack->networkingV2(); -$options = [ +$subnet = $service->createSubnet([ 'name' => '{subnetName}', 'networkId' => '{networkId}', 'ipVersion' => 4, 'cidr' => '192.168.199.0/25', - 'gatewayIp' => '192.168.199.128' -]; - -// Create the subnet -$subnet = $networking->createSubnet($options); + 'gatewayIp' => '192.168.199.128', +]); diff --git a/samples/Networking/v2/subnets/create_with_host_routes.php b/samples/Networking/v2/subnets/create_with_host_routes.php index a58ed79a..5b4d53c1 100644 --- a/samples/Networking/v2/subnets/create_with_host_routes.php +++ b/samples/Networking/v2/subnets/create_with_host_routes.php @@ -9,16 +9,11 @@ 'id' => '{userId}', 'password' => '{password}' ], - 'scope' => [ - 'project' => [ - 'id' => '{projectId}' - ] - ] ]); -$networking = $openstack->networkingV2(); +$service = $openstack->networkingV2(); -$options = [ +$subnet = $service->createSubnet([ 'name' => '{subnetName}', 'networkId' => '{networkId}', 'ipVersion' => 4, @@ -27,7 +22,4 @@ 'destination' => '1.1.1.0/24', 'nexthop' => '192.168.19.20' ]] -]; - -// Create the subnet -$subnet = $networking->createSubnet($options); +]); diff --git a/samples/Networking/v2/subnets/delete.php b/samples/Networking/v2/subnets/delete.php index ffc13f6c..4d00eac7 100644 --- a/samples/Networking/v2/subnets/delete.php +++ b/samples/Networking/v2/subnets/delete.php @@ -9,15 +9,9 @@ 'id' => '{userId}', 'password' => '{password}' ], - 'scope' => [ - 'project' => [ - 'id' => '{projectId}' - ] - ] ]); -$networking = $openstack->networkingV2(); - -$subnet = $networking->getSubnet('{subnetId}'); +$service = $openstack->networkingV2(); +$subnet = $service->getSubnet('{subnetId}'); $subnet->delete(); diff --git a/samples/Networking/v2/subnets/get.php b/samples/Networking/v2/subnets/get.php deleted file mode 100644 index b519abce..00000000 --- a/samples/Networking/v2/subnets/get.php +++ /dev/null @@ -1,28 +0,0 @@ - '{authUrl}', - 'region' => '{region}', - 'user' => [ - 'id' => '{userId}', - 'password' => '{password}' - ], - 'scope' => [ - 'project' => [ - 'id' => '{projectId}' - ] - ] -]); - -$networking = $openstack->networkingV2(); - -$subnet = $networking->getSubnet('{subnetId}'); - -// By default, this will return an empty Subnet object and NOT hit the API. -// This is convenient for when you want to use the object for operations -// that do not require an initial GET request. To retrieve the subnet's details, -// run the following, which *will* call the API with a GET request: - -$subnet->retrieve(); diff --git a/samples/Networking/v2/subnets/read.php b/samples/Networking/v2/subnets/read.php new file mode 100644 index 00000000..4cc15fc9 --- /dev/null +++ b/samples/Networking/v2/subnets/read.php @@ -0,0 +1,17 @@ + '{authUrl}', + 'region' => '{region}', + 'user' => [ + 'id' => '{userId}', + 'password' => '{password}', + ], +]); + +$service = $openstack->networkingV2(); +$subnet = $service->getSubnet('{subnetId}'); + +$subnet->retrieve(); diff --git a/samples/Networking/v2/subnets/update.php b/samples/Networking/v2/subnets/update.php index cbff505f..e0d35f10 100644 --- a/samples/Networking/v2/subnets/update.php +++ b/samples/Networking/v2/subnets/update.php @@ -7,18 +7,12 @@ 'region' => '{region}', 'user' => [ 'id' => '{userId}', - 'password' => '{password}' + 'password' => '{password}', ], - 'scope' => [ - 'project' => [ - 'id' => '{projectId}' - ] - ] ]); -$networking = $openstack->networkingV2(); - -$subnet = $networking->getSubnet('{subnetId}'); +$service = $openstack->networkingV2(); +$subnet = $service->getSubnet('{subnetId}'); $subnet->name = '{newName}'; $subnet->update(); diff --git a/tests/sample/Networking/v2/NetworkTest.php b/tests/sample/Networking/v2/NetworkTest.php index 5b360f0d..1151eae9 100644 --- a/tests/sample/Networking/v2/NetworkTest.php +++ b/tests/sample/Networking/v2/NetworkTest.php @@ -56,7 +56,7 @@ public function testUpdate(Network $createdNetwork) public function testRetrieve(Network $createdNetwork) { /** @var \OpenStack\Networking\v2\Models\Network $network */ - require_once $this->sampleFile('networks/get.php', ['{networkId}' => $createdNetwork->id]); + require_once $this->sampleFile('networks/read.php', ['{networkId}' => $createdNetwork->id]); $this->assertInstanceOf(Network::class, $network); $this->assertEquals($createdNetwork->id, $network->id); diff --git a/tests/sample/Networking/v2/PortTest.php b/tests/sample/Networking/v2/PortTest.php index 040c4879..1c31920f 100644 --- a/tests/sample/Networking/v2/PortTest.php +++ b/tests/sample/Networking/v2/PortTest.php @@ -101,7 +101,7 @@ public function testGet(Port $createdPort) { /** @var $port \OpenStack\Networking\v2\Models\Port */ require_once $this->sampleFile( - 'ports/get.php', + 'ports/read.php', [ '{portId}' => $createdPort->id, ]); From e4fe49c2a317b2e0067b1fb642d18d6153718aba Mon Sep 17 00:00:00 2001 From: Konstantin Babushkin Date: Tue, 30 Jan 2024 10:19:47 +0100 Subject: [PATCH 46/50] final fixes --- doc/services/object-store/v1/index.rst | 5 +++++ samples/ObjectStore/v1/account/read.php | 2 ++ samples/ObjectStore/v1/containers/read.php | 3 ++- tests/sample/Networking/v2/NetworkTest.php | 2 +- tests/sample/Networking/v2/PortTest.php | 5 +---- tests/sample/Networking/v2/SubnetTest.php | 4 ++-- 6 files changed, 13 insertions(+), 8 deletions(-) diff --git a/doc/services/object-store/v1/index.rst b/doc/services/object-store/v1/index.rst index 83e52e19..5d699059 100644 --- a/doc/services/object-store/v1/index.rst +++ b/doc/services/object-store/v1/index.rst @@ -1,6 +1,11 @@ Object Store v1 =============== +Object store (Swift) API Version 1. Swift is a highly available, distributed, eventually consistent object/blob store. +Organizations can use Swift to store lots of data efficiently, safely, and cheaply. + +.. osdoc:: https://docs.openstack.org/api-ref/object-store/ + .. toctree:: :maxdepth: 3 diff --git a/samples/ObjectStore/v1/account/read.php b/samples/ObjectStore/v1/account/read.php index c96d92ea..82490797 100644 --- a/samples/ObjectStore/v1/account/read.php +++ b/samples/ObjectStore/v1/account/read.php @@ -13,3 +13,5 @@ $service = $openstack->objectStoreV1(); $account = $service->getAccount(); + +$account->retrieve(); \ No newline at end of file diff --git a/samples/ObjectStore/v1/containers/read.php b/samples/ObjectStore/v1/containers/read.php index 685c82db..4f7b4206 100644 --- a/samples/ObjectStore/v1/containers/read.php +++ b/samples/ObjectStore/v1/containers/read.php @@ -13,4 +13,5 @@ $service = $openstack->objectStoreV1(); $container = $service->getContainer('{containerName}'); -$container->retrieve(); + +$container->retrieve(); \ No newline at end of file diff --git a/tests/sample/Networking/v2/NetworkTest.php b/tests/sample/Networking/v2/NetworkTest.php index 1151eae9..df6a6532 100644 --- a/tests/sample/Networking/v2/NetworkTest.php +++ b/tests/sample/Networking/v2/NetworkTest.php @@ -53,7 +53,7 @@ public function testUpdate(Network $createdNetwork) /** * @depends testCreate */ - public function testRetrieve(Network $createdNetwork) + public function testRead(Network $createdNetwork) { /** @var \OpenStack\Networking\v2\Models\Network $network */ require_once $this->sampleFile('networks/read.php', ['{networkId}' => $createdNetwork->id]); diff --git a/tests/sample/Networking/v2/PortTest.php b/tests/sample/Networking/v2/PortTest.php index 1c31920f..05e08b5f 100644 --- a/tests/sample/Networking/v2/PortTest.php +++ b/tests/sample/Networking/v2/PortTest.php @@ -97,7 +97,7 @@ public function testList(Port $createdPort) /** * @depends testCreate */ - public function testGet(Port $createdPort) + public function testRead(Port $createdPort) { /** @var $port \OpenStack\Networking\v2\Models\Port */ require_once $this->sampleFile( @@ -108,9 +108,6 @@ public function testGet(Port $createdPort) $this->assertInstanceOf(Port::class, $port); $this->assertNotEmpty($port->id); - $this->assertEmpty($port->name); - - $port->retrieve(); $this->assertNotEmpty($port->name); } diff --git a/tests/sample/Networking/v2/SubnetTest.php b/tests/sample/Networking/v2/SubnetTest.php index 05b55b82..0beb40f7 100644 --- a/tests/sample/Networking/v2/SubnetTest.php +++ b/tests/sample/Networking/v2/SubnetTest.php @@ -100,10 +100,10 @@ public function testUpdate(Subnet $createdSubnet) /** * @depends testCreate */ - public function testRetrieve(Subnet $createdSubnet) + public function testRead(Subnet $createdSubnet) { /** @var $subnet \OpenStack\Networking\v2\Models\Subnet */ - require_once $this->sampleFile('subnets/get.php', ['{subnetId}' => $createdSubnet->id]); + require_once $this->sampleFile('subnets/read.php', ['{subnetId}' => $createdSubnet->id]); $this->assertInstanceOf(Subnet::class, $subnet); $this->assertEquals($subnet->id, $subnet->id); From 6b4feaefff18465294c1a5e91dd54668ddc9cad4 Mon Sep 17 00:00:00 2001 From: Konstantin Babushkin Date: Tue, 30 Jan 2024 11:27:46 +0100 Subject: [PATCH 47/50] run tests --- samples/Networking/v2/securityGroups/create.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/samples/Networking/v2/securityGroups/create.php b/samples/Networking/v2/securityGroups/create.php index 572626d5..9da8dce0 100644 --- a/samples/Networking/v2/securityGroups/create.php +++ b/samples/Networking/v2/securityGroups/create.php @@ -7,9 +7,8 @@ 'region' => '{region}', 'user' => [ 'id' => '{userId}', - 'password' => '{password}' + 'password' => '{password}', ], - 'scope' => ['project' => ['id' => '{projectId}']] ]); $networking = $openstack->networkingV2(); From c8b197e71ed1bc38d1e4278ec1745c3fd9ce0a86 Mon Sep 17 00:00:00 2001 From: Konstantin Babushkin Date: Tue, 30 Jan 2024 11:42:56 +0100 Subject: [PATCH 48/50] fix test --- tests/sample/ObjectStore/v1/ContainerTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/sample/ObjectStore/v1/ContainerTest.php b/tests/sample/ObjectStore/v1/ContainerTest.php index 6e25ee1c..a68a2348 100644 --- a/tests/sample/ObjectStore/v1/ContainerTest.php +++ b/tests/sample/ObjectStore/v1/ContainerTest.php @@ -25,7 +25,7 @@ public function testCreate(): Container public function testRead(Container $createdContainer) { /** @var \OpenStack\ObjectStore\v1\Models\Container $container */ - require_once $this->sampleFile('containers/get.php', ['{containerName}' => $createdContainer->name]); + require_once $this->sampleFile('containers/read.php', ['{containerName}' => $createdContainer->name]); $this->assertInstanceOf(Container::class, $container); $this->assertEquals($createdContainer->name, $container->name); From 2a0446cd6671a452b9be1dd055ed979d5c1f3ad4 Mon Sep 17 00:00:00 2001 From: Konstantin Babushkin Date: Tue, 30 Jan 2024 12:04:29 +0100 Subject: [PATCH 49/50] fix test --- tests/sample/ObjectStore/v1/ContainerTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/sample/ObjectStore/v1/ContainerTest.php b/tests/sample/ObjectStore/v1/ContainerTest.php index a68a2348..a24999db 100644 --- a/tests/sample/ObjectStore/v1/ContainerTest.php +++ b/tests/sample/ObjectStore/v1/ContainerTest.php @@ -29,7 +29,7 @@ public function testRead(Container $createdContainer) $this->assertInstanceOf(Container::class, $container); $this->assertEquals($createdContainer->name, $container->name); - $this->assertEquals($createdContainer->objectCount, $container->objectCount); + $this->assertEquals(0, $container->objectCount); $this->assertEquals([], $container->metadata); } From 82d75b5ad2a9aec2b78e65ebb6cc15e602a35656 Mon Sep 17 00:00:00 2001 From: Konstantin Babushkin Date: Tue, 30 Jan 2024 12:27:20 +0100 Subject: [PATCH 50/50] fix tests --- samples/ObjectStore/v1/objects/create.php | 2 +- samples/ObjectStore/v1/objects/download.php | 2 +- samples/ObjectStore/v1/objects/download_stream.php | 2 +- tests/sample/ObjectStore/v1/ObjectTest.php | 2 ++ 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/samples/ObjectStore/v1/objects/create.php b/samples/ObjectStore/v1/objects/create.php index 5549f09d..12d955ab 100644 --- a/samples/ObjectStore/v1/objects/create.php +++ b/samples/ObjectStore/v1/objects/create.php @@ -13,7 +13,7 @@ $service = $openstack->objectStoreV1(); $container = $service->getContainer('{containerName}'); -$container->createObject([ +$object = $container->createObject([ 'name' => '{objectName}', 'content' => '{objectContent}', ]); diff --git a/samples/ObjectStore/v1/objects/download.php b/samples/ObjectStore/v1/objects/download.php index dfc3f8af..97d033f9 100644 --- a/samples/ObjectStore/v1/objects/download.php +++ b/samples/ObjectStore/v1/objects/download.php @@ -15,4 +15,4 @@ $container = $service->getContainer('{containerName}'); $object = $container->getObject('{objectName}'); -$object->download(); +$stream = $object->download(); diff --git a/samples/ObjectStore/v1/objects/download_stream.php b/samples/ObjectStore/v1/objects/download_stream.php index fb6bd32e..9d63366d 100644 --- a/samples/ObjectStore/v1/objects/download_stream.php +++ b/samples/ObjectStore/v1/objects/download_stream.php @@ -15,4 +15,4 @@ $container = $service->getContainer('{containerName}'); $object = $container->getObject('{objectName}'); -$object->download(['requestOptions' => ['stream' => true]]); +$stream = $object->download(['requestOptions' => ['stream' => true]]); diff --git a/tests/sample/ObjectStore/v1/ObjectTest.php b/tests/sample/ObjectStore/v1/ObjectTest.php index 6f71e7f3..9ba1181e 100644 --- a/tests/sample/ObjectStore/v1/ObjectTest.php +++ b/tests/sample/ObjectStore/v1/ObjectTest.php @@ -101,6 +101,8 @@ public function testDownloadStream(StorageObject $createdObject) */ public function testRead(StorageObject $createdObject) { + $createdObject->retrieve(); + /** @var StorageObject $object */ require_once $this->sampleFile('objects/read.php', [ '{containerName}' => $createdObject->containerName,