From 827a14ff0e8eaba16c920e303ee5526e673f5fc7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=BCdiger=20Schmitz?= <152157960+bahkauv70@users.noreply.github.com> Date: Mon, 28 Apr 2025 14:37:11 +0200 Subject: [PATCH] feat(kms): generate code, add support files, add example --- CHANGELOG.md | 2 + examples/kms/list_keyrings.py | 15 + services/kms/CHANGELOG.md | 2 + services/kms/LICENSE.md | 201 + services/kms/README.md | 23 + services/kms/pyproject.toml | 99 + services/kms/src/stackit/kms/__init__.py | 61 + services/kms/src/stackit/kms/api/__init__.py | 4 + .../kms/src/stackit/kms/api/default_api.py | 7038 +++++++++++++++++ services/kms/src/stackit/kms/api_client.py | 626 ++ services/kms/src/stackit/kms/api_response.py | 23 + services/kms/src/stackit/kms/configuration.py | 138 + services/kms/src/stackit/kms/exceptions.py | 198 + .../kms/src/stackit/kms/models/__init__.py | 42 + .../kms/src/stackit/kms/models/algorithm.py | 45 + .../kms/src/stackit/kms/models/backend.py | 35 + .../stackit/kms/models/create_key_payload.py | 105 + .../kms/models/create_key_ring_payload.py | 86 + .../kms/models/create_wrapping_key_payload.py | 101 + .../src/stackit/kms/models/decrypt_payload.py | 81 + .../src/stackit/kms/models/decrypted_data.py | 81 + .../src/stackit/kms/models/encrypt_payload.py | 81 + .../src/stackit/kms/models/encrypted_data.py | 81 + .../kms/src/stackit/kms/models/http_error.py | 81 + .../stackit/kms/models/import_key_payload.py | 86 + services/kms/src/stackit/kms/models/key.py | 150 + .../kms/src/stackit/kms/models/key_list.py | 92 + .../kms/src/stackit/kms/models/key_ring.py | 107 + .../src/stackit/kms/models/key_ring_list.py | 96 + .../kms/src/stackit/kms/models/purpose.py | 38 + .../src/stackit/kms/models/sign_payload.py | 81 + .../kms/src/stackit/kms/models/signed_data.py | 82 + .../src/stackit/kms/models/verified_data.py | 81 + .../src/stackit/kms/models/verify_payload.py | 82 + .../kms/src/stackit/kms/models/version.py | 138 + .../src/stackit/kms/models/version_list.py | 96 + .../stackit/kms/models/wrapping_algorithm.py | 42 + .../src/stackit/kms/models/wrapping_key.py | 139 + .../stackit/kms/models/wrapping_key_list.py | 98 + .../stackit/kms/models/wrapping_purpose.py | 36 + services/kms/src/stackit/kms/py.typed | 0 services/kms/src/stackit/kms/rest.py | 148 + 42 files changed, 10841 insertions(+) create mode 100644 examples/kms/list_keyrings.py create mode 100644 services/kms/CHANGELOG.md create mode 100644 services/kms/LICENSE.md create mode 100644 services/kms/README.md create mode 100644 services/kms/pyproject.toml create mode 100644 services/kms/src/stackit/kms/__init__.py create mode 100644 services/kms/src/stackit/kms/api/__init__.py create mode 100644 services/kms/src/stackit/kms/api/default_api.py create mode 100644 services/kms/src/stackit/kms/api_client.py create mode 100644 services/kms/src/stackit/kms/api_response.py create mode 100644 services/kms/src/stackit/kms/configuration.py create mode 100644 services/kms/src/stackit/kms/exceptions.py create mode 100644 services/kms/src/stackit/kms/models/__init__.py create mode 100644 services/kms/src/stackit/kms/models/algorithm.py create mode 100644 services/kms/src/stackit/kms/models/backend.py create mode 100644 services/kms/src/stackit/kms/models/create_key_payload.py create mode 100644 services/kms/src/stackit/kms/models/create_key_ring_payload.py create mode 100644 services/kms/src/stackit/kms/models/create_wrapping_key_payload.py create mode 100644 services/kms/src/stackit/kms/models/decrypt_payload.py create mode 100644 services/kms/src/stackit/kms/models/decrypted_data.py create mode 100644 services/kms/src/stackit/kms/models/encrypt_payload.py create mode 100644 services/kms/src/stackit/kms/models/encrypted_data.py create mode 100644 services/kms/src/stackit/kms/models/http_error.py create mode 100644 services/kms/src/stackit/kms/models/import_key_payload.py create mode 100644 services/kms/src/stackit/kms/models/key.py create mode 100644 services/kms/src/stackit/kms/models/key_list.py create mode 100644 services/kms/src/stackit/kms/models/key_ring.py create mode 100644 services/kms/src/stackit/kms/models/key_ring_list.py create mode 100644 services/kms/src/stackit/kms/models/purpose.py create mode 100644 services/kms/src/stackit/kms/models/sign_payload.py create mode 100644 services/kms/src/stackit/kms/models/signed_data.py create mode 100644 services/kms/src/stackit/kms/models/verified_data.py create mode 100644 services/kms/src/stackit/kms/models/verify_payload.py create mode 100644 services/kms/src/stackit/kms/models/version.py create mode 100644 services/kms/src/stackit/kms/models/version_list.py create mode 100644 services/kms/src/stackit/kms/models/wrapping_algorithm.py create mode 100644 services/kms/src/stackit/kms/models/wrapping_key.py create mode 100644 services/kms/src/stackit/kms/models/wrapping_key_list.py create mode 100644 services/kms/src/stackit/kms/models/wrapping_purpose.py create mode 100644 services/kms/src/stackit/kms/py.typed create mode 100644 services/kms/src/stackit/kms/rest.py diff --git a/CHANGELOG.md b/CHANGELOG.md index 9ae6c477..d8466f2b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ - **Feature:** Add new methods `create_logs_alertgroups`, `delete_logs_alertgroup`, `get_logs_alertgroup`, `list_logs_alertgroups`, `update_logs_alertgroup` - `git`: [v0.1.0](services/git/CHANGELOG.md#v010-2025-04-23) - **New**: STACKIT Git module can be used to manage STACKIT Git +- `kms`: [v0.0.1](services/kms/CHANGELOG.md#v001-2025-04-28) + - **New module:** Initial publication of Key Management Service API ## Release (2025-03-27) diff --git a/examples/kms/list_keyrings.py b/examples/kms/list_keyrings.py new file mode 100644 index 00000000..dca80d60 --- /dev/null +++ b/examples/kms/list_keyrings.py @@ -0,0 +1,15 @@ +import os + +from stackit.kms.api.default_api import DefaultApi +from stackit.core.configuration import Configuration + +project_id = os.getenv("PROJECT_ID") +region = os.getenv("REGION") + +# Create a new API client, that uses default authentication and configuration +config = Configuration() +client = DefaultApi(config) + +# List all logme instances +for keyring in client.list_key_rings(project_id, region).key_rings: + print(keyring.id, keyring.description) diff --git a/services/kms/CHANGELOG.md b/services/kms/CHANGELOG.md new file mode 100644 index 00000000..581797ca --- /dev/null +++ b/services/kms/CHANGELOG.md @@ -0,0 +1,2 @@ +## v0.0.1 (2025-04-28) +- **New module:** Initial publication of Key Management Service API diff --git a/services/kms/LICENSE.md b/services/kms/LICENSE.md new file mode 100644 index 00000000..7e2f0648 --- /dev/null +++ b/services/kms/LICENSE.md @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright 2025 Schwarz IT KG + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/services/kms/README.md b/services/kms/README.md new file mode 100644 index 00000000..3f06fb25 --- /dev/null +++ b/services/kms/README.md @@ -0,0 +1,23 @@ +# stackit.kms +This API provides endpoints for managing keys and key rings. + + + +This package is part of the STACKIT Python SDK. For additional information, please visit the [GitHub repository](https://github.com/stackitcloud/git@github.com:stackitcloud/stackit-sdk-go.git) of the SDK. + + +## Installation & Usage +### pip install + +```sh +pip install stackit-kms +``` + +Then import the package: +```python +import stackit.kms +``` + +## Getting Started + +[Examples](https://github.com/stackitcloud/stackit-sdk-python/tree/main/examples) for the usage of the package can be found in the [GitHub repository](https://github.com/stackitcloud/stackit-sdk-python) of the SDK. \ No newline at end of file diff --git a/services/kms/pyproject.toml b/services/kms/pyproject.toml new file mode 100644 index 00000000..1de3ee73 --- /dev/null +++ b/services/kms/pyproject.toml @@ -0,0 +1,99 @@ +[project] +name = "stackit-kms" + +[tool.poetry] +name = "stackit-kms" +version = "v0.0.1" +authors = [ + "STACKIT Developer Tools ", +] +description = "STACKIT Key Management Service API" +readme = "README.md" +#license = "NoLicense" +classifiers = [ + "Programming Language :: Python :: 3", + "License :: OSI Approved :: Apache Software License", + "Operating System :: OS Independent", +] +packages = [ + { include = "stackit", from="src" } +] + +[tool.poetry.dependencies] +python = ">=3.8,<4.0" +stackit-core = ">=0.0.1a" +requests = ">=2.32.3" +pydantic = ">=2.9.2" +python-dateutil = ">=2.9.0.post0" + +[tool.poetry.group.dev.dependencies] +black = ">=24.8.0" +pytest = ">=8.3.3" +flake8 = [ + { version= ">=5.0.3", python="<3.12"}, + { version= ">=6.0.1", python=">=3.12"} +] +flake8-black = ">=0.3.6" +flake8-pyproject = ">=1.2.3" +autoimport = ">=1.6.1" +flake8-eol = ">=0.0.8" +flake8-eradicate = ">=1.5.0" +flake8-bandit = ">=4.1.1" +flake8-bugbear = ">=23.1.14" +flake8-quotes = ">=3.4.0" +isort = ">=5.13.2" + +[project.urls] +Homepage = "https://github.com/stackitcloud/git@github.com:stackitcloud/stackit-sdk-go.git" +Issues = "https://github.com/stackitcloud/git@github.com:stackitcloud/stackit-sdk-go.git/issues" + +[build-system] +requires = ["setuptools", "poetry-core"] +build-backend = "poetry.core.masonry.api" + +[tool.pytest.ini_options] +pythonpath = [ + "src" +] +testpaths = [ + "tests" +] + +[tool.black] +line-length = 120 +exclude = """ +/( + .eggs + | .git + | .hg + | .mypy_cache + | .nox + | .pants.d + | .tox + | .venv + | _build + | buck-out + | build + | dist + | node_modules + | venv +)/ +""" + +[tool.isort] +profile = 'black' + +[tool.flake8] +exclude= [".eggs", ".git", ".hg", ".mypy_cache", ".tox", ".venv", ".devcontainer", "venv", "_build", "buck-out", "build", "dist"] +statistics = true +show-source = false +max-line-length = 120 +# E203,W503 and E704 are incompatible with the formatter black +# W291 needs to be disabled because some doc-strings get generated with trailing whitespace but black won't re-format comments +ignore = ["E203", "W503", "E704", "W291"] +inline-quotes = '"' +docstring-quotes = '"""' +multiline-quotes = '"""' +ban-relative-imports = true +# Exclude generated code +extend-exclude = [ "src/stackit/*/models/*", "src/stackit/*/api/*", "src/stackit/*/*.py" ] \ No newline at end of file diff --git a/services/kms/src/stackit/kms/__init__.py b/services/kms/src/stackit/kms/__init__.py new file mode 100644 index 00000000..7ada5189 --- /dev/null +++ b/services/kms/src/stackit/kms/__init__.py @@ -0,0 +1,61 @@ +# coding: utf-8 + +# flake8: noqa + +""" + STACKIT Key Management Service API + + This API provides endpoints for managing keys and key rings. + + The version of the OpenAPI document: 1beta.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 docstring might be too long + + +__version__ = "1.0.0" + +# import apis into sdk package +from stackit.kms.api.default_api import DefaultApi +from stackit.kms.api_client import ApiClient + +# import ApiClient +from stackit.kms.api_response import ApiResponse +from stackit.kms.configuration import HostConfiguration +from stackit.kms.exceptions import ( + ApiAttributeError, + ApiException, + ApiKeyError, + ApiTypeError, + ApiValueError, + OpenApiException, +) + +# import models into sdk package +from stackit.kms.models.algorithm import Algorithm +from stackit.kms.models.backend import Backend +from stackit.kms.models.create_key_payload import CreateKeyPayload +from stackit.kms.models.create_key_ring_payload import CreateKeyRingPayload +from stackit.kms.models.create_wrapping_key_payload import CreateWrappingKeyPayload +from stackit.kms.models.decrypt_payload import DecryptPayload +from stackit.kms.models.decrypted_data import DecryptedData +from stackit.kms.models.encrypt_payload import EncryptPayload +from stackit.kms.models.encrypted_data import EncryptedData +from stackit.kms.models.http_error import HttpError +from stackit.kms.models.import_key_payload import ImportKeyPayload +from stackit.kms.models.key import Key +from stackit.kms.models.key_list import KeyList +from stackit.kms.models.key_ring import KeyRing +from stackit.kms.models.key_ring_list import KeyRingList +from stackit.kms.models.purpose import Purpose +from stackit.kms.models.sign_payload import SignPayload +from stackit.kms.models.signed_data import SignedData +from stackit.kms.models.verified_data import VerifiedData +from stackit.kms.models.verify_payload import VerifyPayload +from stackit.kms.models.version import Version +from stackit.kms.models.version_list import VersionList +from stackit.kms.models.wrapping_algorithm import WrappingAlgorithm +from stackit.kms.models.wrapping_key import WrappingKey +from stackit.kms.models.wrapping_key_list import WrappingKeyList +from stackit.kms.models.wrapping_purpose import WrappingPurpose diff --git a/services/kms/src/stackit/kms/api/__init__.py b/services/kms/src/stackit/kms/api/__init__.py new file mode 100644 index 00000000..1ffebf4f --- /dev/null +++ b/services/kms/src/stackit/kms/api/__init__.py @@ -0,0 +1,4 @@ +# flake8: noqa + +# import apis into api package +from stackit.kms.api.default_api import DefaultApi diff --git a/services/kms/src/stackit/kms/api/default_api.py b/services/kms/src/stackit/kms/api/default_api.py new file mode 100644 index 00000000..304b08d3 --- /dev/null +++ b/services/kms/src/stackit/kms/api/default_api.py @@ -0,0 +1,7038 @@ +# coding: utf-8 + +""" + STACKIT Key Management Service API + + This API provides endpoints for managing keys and key rings. + + The version of the OpenAPI document: 1beta.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 docstring might be too long + +from typing import Any, Dict, List, Optional, Tuple, Union + +from pydantic import ( + Field, + StrictFloat, + StrictInt, + StrictStr, + validate_call, +) +from stackit.core.configuration import Configuration +from typing_extensions import Annotated + +from stackit.kms.api_client import ApiClient, RequestSerialized +from stackit.kms.api_response import ApiResponse +from stackit.kms.models.create_key_payload import CreateKeyPayload +from stackit.kms.models.create_key_ring_payload import CreateKeyRingPayload +from stackit.kms.models.create_wrapping_key_payload import CreateWrappingKeyPayload +from stackit.kms.models.decrypt_payload import DecryptPayload +from stackit.kms.models.decrypted_data import DecryptedData +from stackit.kms.models.encrypt_payload import EncryptPayload +from stackit.kms.models.encrypted_data import EncryptedData +from stackit.kms.models.import_key_payload import ImportKeyPayload +from stackit.kms.models.key import Key +from stackit.kms.models.key_list import KeyList +from stackit.kms.models.key_ring import KeyRing +from stackit.kms.models.key_ring_list import KeyRingList +from stackit.kms.models.sign_payload import SignPayload +from stackit.kms.models.signed_data import SignedData +from stackit.kms.models.verified_data import VerifiedData +from stackit.kms.models.verify_payload import VerifyPayload +from stackit.kms.models.version import Version +from stackit.kms.models.version_list import VersionList +from stackit.kms.models.wrapping_key import WrappingKey +from stackit.kms.models.wrapping_key_list import WrappingKeyList +from stackit.kms.rest import RESTResponseType + + +class DefaultApi: + """NOTE: This class is auto generated by OpenAPI Generator + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + def __init__(self, configuration: Configuration = None) -> None: + if configuration is None: + configuration = Configuration() + self.configuration = configuration + self.api_client = ApiClient(self.configuration) + + @validate_call + def create_key( + self, + project_id: Annotated[StrictStr, Field(description="The STACKIT portal project UUID the key ring is part of.")], + region_id: Annotated[StrictStr, Field(description="The STACKIT region name the key ring is located in.")], + key_ring_id: Annotated[StrictStr, Field(description="The key ring UUID.")], + create_key_payload: CreateKeyPayload, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> Key: + """Create key + + Creates a new key for the given key ring. + + :param project_id: The STACKIT portal project UUID the key ring is part of. (required) + :type project_id: str + :param region_id: The STACKIT region name the key ring is located in. (required) + :type region_id: str + :param key_ring_id: The key ring UUID. (required) + :type key_ring_id: str + :param create_key_payload: (required) + :type create_key_payload: CreateKeyPayload + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 docstring might be too long + + _param = self._create_key_serialize( + project_id=project_id, + region_id=region_id, + key_ring_id=key_ring_id, + create_key_payload=create_key_payload, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "Key", + "400": "HttpError", + "401": "HttpError", + "404": "HttpError", + "500": "HttpError", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + @validate_call + def create_key_with_http_info( + self, + project_id: Annotated[StrictStr, Field(description="The STACKIT portal project UUID the key ring is part of.")], + region_id: Annotated[StrictStr, Field(description="The STACKIT region name the key ring is located in.")], + key_ring_id: Annotated[StrictStr, Field(description="The key ring UUID.")], + create_key_payload: CreateKeyPayload, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[Key]: + """Create key + + Creates a new key for the given key ring. + + :param project_id: The STACKIT portal project UUID the key ring is part of. (required) + :type project_id: str + :param region_id: The STACKIT region name the key ring is located in. (required) + :type region_id: str + :param key_ring_id: The key ring UUID. (required) + :type key_ring_id: str + :param create_key_payload: (required) + :type create_key_payload: CreateKeyPayload + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 docstring might be too long + + _param = self._create_key_serialize( + project_id=project_id, + region_id=region_id, + key_ring_id=key_ring_id, + create_key_payload=create_key_payload, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "Key", + "400": "HttpError", + "401": "HttpError", + "404": "HttpError", + "500": "HttpError", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + @validate_call + def create_key_without_preload_content( + self, + project_id: Annotated[StrictStr, Field(description="The STACKIT portal project UUID the key ring is part of.")], + region_id: Annotated[StrictStr, Field(description="The STACKIT region name the key ring is located in.")], + key_ring_id: Annotated[StrictStr, Field(description="The key ring UUID.")], + create_key_payload: CreateKeyPayload, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Create key + + Creates a new key for the given key ring. + + :param project_id: The STACKIT portal project UUID the key ring is part of. (required) + :type project_id: str + :param region_id: The STACKIT region name the key ring is located in. (required) + :type region_id: str + :param key_ring_id: The key ring UUID. (required) + :type key_ring_id: str + :param create_key_payload: (required) + :type create_key_payload: CreateKeyPayload + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 docstring might be too long + + _param = self._create_key_serialize( + project_id=project_id, + region_id=region_id, + key_ring_id=key_ring_id, + create_key_payload=create_key_payload, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "Key", + "400": "HttpError", + "401": "HttpError", + "404": "HttpError", + "500": "HttpError", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + return response_data.response + + def _create_key_serialize( + self, + project_id, + region_id, + key_ring_id, + create_key_payload, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = {} + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if project_id is not None: + _path_params["projectId"] = project_id + if region_id is not None: + _path_params["regionId"] = region_id + if key_ring_id is not None: + _path_params["keyRingId"] = key_ring_id + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + if create_key_payload is not None: + _body_params = create_key_payload + + # set the HTTP header `Accept` + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept(["application/json"]) + + # set the HTTP header `Content-Type` + if _content_type: + _header_params["Content-Type"] = _content_type + else: + _default_content_type = self.api_client.select_header_content_type(["application/json"]) + if _default_content_type is not None: + _header_params["Content-Type"] = _default_content_type + + # authentication setting + _auth_settings: List[str] = [] + + return self.api_client.param_serialize( + method="POST", + resource_path="/v1beta/projects/{projectId}/regions/{regionId}/keyrings/{keyRingId}/keys", + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth, + ) + + @validate_call + def create_key_ring( + self, + project_id: Annotated[StrictStr, Field(description="The STACKIT portal project UUID the key ring is part of.")], + region_id: Annotated[StrictStr, Field(description="The STACKIT region name the key ring is located in.")], + create_key_ring_payload: CreateKeyRingPayload, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> KeyRing: + """Create key ring + + Creates a new key ring within the project. + + :param project_id: The STACKIT portal project UUID the key ring is part of. (required) + :type project_id: str + :param region_id: The STACKIT region name the key ring is located in. (required) + :type region_id: str + :param create_key_ring_payload: (required) + :type create_key_ring_payload: CreateKeyRingPayload + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 docstring might be too long + + _param = self._create_key_ring_serialize( + project_id=project_id, + region_id=region_id, + create_key_ring_payload=create_key_ring_payload, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "201": "KeyRing", + "400": "HttpError", + "401": "HttpError", + "500": "HttpError", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + @validate_call + def create_key_ring_with_http_info( + self, + project_id: Annotated[StrictStr, Field(description="The STACKIT portal project UUID the key ring is part of.")], + region_id: Annotated[StrictStr, Field(description="The STACKIT region name the key ring is located in.")], + create_key_ring_payload: CreateKeyRingPayload, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[KeyRing]: + """Create key ring + + Creates a new key ring within the project. + + :param project_id: The STACKIT portal project UUID the key ring is part of. (required) + :type project_id: str + :param region_id: The STACKIT region name the key ring is located in. (required) + :type region_id: str + :param create_key_ring_payload: (required) + :type create_key_ring_payload: CreateKeyRingPayload + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 docstring might be too long + + _param = self._create_key_ring_serialize( + project_id=project_id, + region_id=region_id, + create_key_ring_payload=create_key_ring_payload, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "201": "KeyRing", + "400": "HttpError", + "401": "HttpError", + "500": "HttpError", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + @validate_call + def create_key_ring_without_preload_content( + self, + project_id: Annotated[StrictStr, Field(description="The STACKIT portal project UUID the key ring is part of.")], + region_id: Annotated[StrictStr, Field(description="The STACKIT region name the key ring is located in.")], + create_key_ring_payload: CreateKeyRingPayload, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Create key ring + + Creates a new key ring within the project. + + :param project_id: The STACKIT portal project UUID the key ring is part of. (required) + :type project_id: str + :param region_id: The STACKIT region name the key ring is located in. (required) + :type region_id: str + :param create_key_ring_payload: (required) + :type create_key_ring_payload: CreateKeyRingPayload + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 docstring might be too long + + _param = self._create_key_ring_serialize( + project_id=project_id, + region_id=region_id, + create_key_ring_payload=create_key_ring_payload, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "201": "KeyRing", + "400": "HttpError", + "401": "HttpError", + "500": "HttpError", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + return response_data.response + + def _create_key_ring_serialize( + self, + project_id, + region_id, + create_key_ring_payload, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = {} + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if project_id is not None: + _path_params["projectId"] = project_id + if region_id is not None: + _path_params["regionId"] = region_id + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + if create_key_ring_payload is not None: + _body_params = create_key_ring_payload + + # set the HTTP header `Accept` + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept(["application/json"]) + + # set the HTTP header `Content-Type` + if _content_type: + _header_params["Content-Type"] = _content_type + else: + _default_content_type = self.api_client.select_header_content_type(["application/json"]) + if _default_content_type is not None: + _header_params["Content-Type"] = _default_content_type + + # authentication setting + _auth_settings: List[str] = [] + + return self.api_client.param_serialize( + method="POST", + resource_path="/v1beta/projects/{projectId}/regions/{regionId}/keyrings", + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth, + ) + + @validate_call + def create_wrapping_key( + self, + project_id: Annotated[StrictStr, Field(description="The STACKIT portal project UUID the key ring is part of.")], + region_id: Annotated[StrictStr, Field(description="The STACKIT region name the key ring is located in.")], + key_ring_id: Annotated[StrictStr, Field(description="The key ring UUID.")], + create_wrapping_key_payload: CreateWrappingKeyPayload, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> WrappingKey: + """Create wrapping key + + Creates a new wrapping key for the given key ring. + + :param project_id: The STACKIT portal project UUID the key ring is part of. (required) + :type project_id: str + :param region_id: The STACKIT region name the key ring is located in. (required) + :type region_id: str + :param key_ring_id: The key ring UUID. (required) + :type key_ring_id: str + :param create_wrapping_key_payload: (required) + :type create_wrapping_key_payload: CreateWrappingKeyPayload + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 docstring might be too long + + _param = self._create_wrapping_key_serialize( + project_id=project_id, + region_id=region_id, + key_ring_id=key_ring_id, + create_wrapping_key_payload=create_wrapping_key_payload, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "WrappingKey", + "400": "HttpError", + "401": "HttpError", + "404": "HttpError", + "500": "HttpError", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + @validate_call + def create_wrapping_key_with_http_info( + self, + project_id: Annotated[StrictStr, Field(description="The STACKIT portal project UUID the key ring is part of.")], + region_id: Annotated[StrictStr, Field(description="The STACKIT region name the key ring is located in.")], + key_ring_id: Annotated[StrictStr, Field(description="The key ring UUID.")], + create_wrapping_key_payload: CreateWrappingKeyPayload, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[WrappingKey]: + """Create wrapping key + + Creates a new wrapping key for the given key ring. + + :param project_id: The STACKIT portal project UUID the key ring is part of. (required) + :type project_id: str + :param region_id: The STACKIT region name the key ring is located in. (required) + :type region_id: str + :param key_ring_id: The key ring UUID. (required) + :type key_ring_id: str + :param create_wrapping_key_payload: (required) + :type create_wrapping_key_payload: CreateWrappingKeyPayload + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 docstring might be too long + + _param = self._create_wrapping_key_serialize( + project_id=project_id, + region_id=region_id, + key_ring_id=key_ring_id, + create_wrapping_key_payload=create_wrapping_key_payload, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "WrappingKey", + "400": "HttpError", + "401": "HttpError", + "404": "HttpError", + "500": "HttpError", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + @validate_call + def create_wrapping_key_without_preload_content( + self, + project_id: Annotated[StrictStr, Field(description="The STACKIT portal project UUID the key ring is part of.")], + region_id: Annotated[StrictStr, Field(description="The STACKIT region name the key ring is located in.")], + key_ring_id: Annotated[StrictStr, Field(description="The key ring UUID.")], + create_wrapping_key_payload: CreateWrappingKeyPayload, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Create wrapping key + + Creates a new wrapping key for the given key ring. + + :param project_id: The STACKIT portal project UUID the key ring is part of. (required) + :type project_id: str + :param region_id: The STACKIT region name the key ring is located in. (required) + :type region_id: str + :param key_ring_id: The key ring UUID. (required) + :type key_ring_id: str + :param create_wrapping_key_payload: (required) + :type create_wrapping_key_payload: CreateWrappingKeyPayload + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 docstring might be too long + + _param = self._create_wrapping_key_serialize( + project_id=project_id, + region_id=region_id, + key_ring_id=key_ring_id, + create_wrapping_key_payload=create_wrapping_key_payload, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "WrappingKey", + "400": "HttpError", + "401": "HttpError", + "404": "HttpError", + "500": "HttpError", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + return response_data.response + + def _create_wrapping_key_serialize( + self, + project_id, + region_id, + key_ring_id, + create_wrapping_key_payload, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = {} + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if project_id is not None: + _path_params["projectId"] = project_id + if region_id is not None: + _path_params["regionId"] = region_id + if key_ring_id is not None: + _path_params["keyRingId"] = key_ring_id + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + if create_wrapping_key_payload is not None: + _body_params = create_wrapping_key_payload + + # set the HTTP header `Accept` + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept(["application/json"]) + + # set the HTTP header `Content-Type` + if _content_type: + _header_params["Content-Type"] = _content_type + else: + _default_content_type = self.api_client.select_header_content_type(["application/json"]) + if _default_content_type is not None: + _header_params["Content-Type"] = _default_content_type + + # authentication setting + _auth_settings: List[str] = [] + + return self.api_client.param_serialize( + method="POST", + resource_path="/v1beta/projects/{projectId}/regions/{regionId}/keyrings/{keyRingId}/wrappingkeys", + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth, + ) + + @validate_call + def decrypt( + self, + project_id: Annotated[StrictStr, Field(description="The STACKIT portal project UUID the key ring is part of.")], + region_id: Annotated[StrictStr, Field(description="The STACKIT region name the key ring is located in.")], + key_ring_id: Annotated[StrictStr, Field(description="The key ring UUID.")], + key_id: Annotated[StrictStr, Field(description="The key UUID.")], + version_number: Annotated[StrictInt, Field(description="The version number.")], + decrypt_payload: DecryptPayload, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> DecryptedData: + """Decrypt + + Decrypts data using the given key version. + + :param project_id: The STACKIT portal project UUID the key ring is part of. (required) + :type project_id: str + :param region_id: The STACKIT region name the key ring is located in. (required) + :type region_id: str + :param key_ring_id: The key ring UUID. (required) + :type key_ring_id: str + :param key_id: The key UUID. (required) + :type key_id: str + :param version_number: The version number. (required) + :type version_number: int + :param decrypt_payload: (required) + :type decrypt_payload: DecryptPayload + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 docstring might be too long + + _param = self._decrypt_serialize( + project_id=project_id, + region_id=region_id, + key_ring_id=key_ring_id, + key_id=key_id, + version_number=version_number, + decrypt_payload=decrypt_payload, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "DecryptedData", + "400": "HttpError", + "401": "HttpError", + "404": "HttpError", + "409": "HttpError", + "500": "HttpError", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + @validate_call + def decrypt_with_http_info( + self, + project_id: Annotated[StrictStr, Field(description="The STACKIT portal project UUID the key ring is part of.")], + region_id: Annotated[StrictStr, Field(description="The STACKIT region name the key ring is located in.")], + key_ring_id: Annotated[StrictStr, Field(description="The key ring UUID.")], + key_id: Annotated[StrictStr, Field(description="The key UUID.")], + version_number: Annotated[StrictInt, Field(description="The version number.")], + decrypt_payload: DecryptPayload, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[DecryptedData]: + """Decrypt + + Decrypts data using the given key version. + + :param project_id: The STACKIT portal project UUID the key ring is part of. (required) + :type project_id: str + :param region_id: The STACKIT region name the key ring is located in. (required) + :type region_id: str + :param key_ring_id: The key ring UUID. (required) + :type key_ring_id: str + :param key_id: The key UUID. (required) + :type key_id: str + :param version_number: The version number. (required) + :type version_number: int + :param decrypt_payload: (required) + :type decrypt_payload: DecryptPayload + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 docstring might be too long + + _param = self._decrypt_serialize( + project_id=project_id, + region_id=region_id, + key_ring_id=key_ring_id, + key_id=key_id, + version_number=version_number, + decrypt_payload=decrypt_payload, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "DecryptedData", + "400": "HttpError", + "401": "HttpError", + "404": "HttpError", + "409": "HttpError", + "500": "HttpError", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + @validate_call + def decrypt_without_preload_content( + self, + project_id: Annotated[StrictStr, Field(description="The STACKIT portal project UUID the key ring is part of.")], + region_id: Annotated[StrictStr, Field(description="The STACKIT region name the key ring is located in.")], + key_ring_id: Annotated[StrictStr, Field(description="The key ring UUID.")], + key_id: Annotated[StrictStr, Field(description="The key UUID.")], + version_number: Annotated[StrictInt, Field(description="The version number.")], + decrypt_payload: DecryptPayload, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Decrypt + + Decrypts data using the given key version. + + :param project_id: The STACKIT portal project UUID the key ring is part of. (required) + :type project_id: str + :param region_id: The STACKIT region name the key ring is located in. (required) + :type region_id: str + :param key_ring_id: The key ring UUID. (required) + :type key_ring_id: str + :param key_id: The key UUID. (required) + :type key_id: str + :param version_number: The version number. (required) + :type version_number: int + :param decrypt_payload: (required) + :type decrypt_payload: DecryptPayload + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 docstring might be too long + + _param = self._decrypt_serialize( + project_id=project_id, + region_id=region_id, + key_ring_id=key_ring_id, + key_id=key_id, + version_number=version_number, + decrypt_payload=decrypt_payload, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "DecryptedData", + "400": "HttpError", + "401": "HttpError", + "404": "HttpError", + "409": "HttpError", + "500": "HttpError", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + return response_data.response + + def _decrypt_serialize( + self, + project_id, + region_id, + key_ring_id, + key_id, + version_number, + decrypt_payload, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = {} + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if project_id is not None: + _path_params["projectId"] = project_id + if region_id is not None: + _path_params["regionId"] = region_id + if key_ring_id is not None: + _path_params["keyRingId"] = key_ring_id + if key_id is not None: + _path_params["keyId"] = key_id + if version_number is not None: + _path_params["versionNumber"] = version_number + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + if decrypt_payload is not None: + _body_params = decrypt_payload + + # set the HTTP header `Accept` + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept(["application/json"]) + + # set the HTTP header `Content-Type` + if _content_type: + _header_params["Content-Type"] = _content_type + else: + _default_content_type = self.api_client.select_header_content_type(["application/json"]) + if _default_content_type is not None: + _header_params["Content-Type"] = _default_content_type + + # authentication setting + _auth_settings: List[str] = [] + + return self.api_client.param_serialize( + method="POST", + resource_path="/v1beta/projects/{projectId}/regions/{regionId}/keyrings/{keyRingId}/keys/{keyId}/versions/{versionNumber}/decrypt", + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth, + ) + + @validate_call + def delete_key( + self, + project_id: Annotated[StrictStr, Field(description="The STACKIT portal project UUID the key ring is part of.")], + region_id: Annotated[StrictStr, Field(description="The STACKIT region name the key ring is located in.")], + key_ring_id: Annotated[StrictStr, Field(description="The key ring UUID.")], + key_id: Annotated[StrictStr, Field(description="The key UUID.")], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> None: + """Delete key + + Schedules the deletion of the given key + + :param project_id: The STACKIT portal project UUID the key ring is part of. (required) + :type project_id: str + :param region_id: The STACKIT region name the key ring is located in. (required) + :type region_id: str + :param key_ring_id: The key ring UUID. (required) + :type key_ring_id: str + :param key_id: The key UUID. (required) + :type key_id: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 docstring might be too long + + _param = self._delete_key_serialize( + project_id=project_id, + region_id=region_id, + key_ring_id=key_ring_id, + key_id=key_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "202": None, + "400": "HttpError", + "401": "HttpError", + "404": "HttpError", + "500": "HttpError", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + @validate_call + def delete_key_with_http_info( + self, + project_id: Annotated[StrictStr, Field(description="The STACKIT portal project UUID the key ring is part of.")], + region_id: Annotated[StrictStr, Field(description="The STACKIT region name the key ring is located in.")], + key_ring_id: Annotated[StrictStr, Field(description="The key ring UUID.")], + key_id: Annotated[StrictStr, Field(description="The key UUID.")], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[None]: + """Delete key + + Schedules the deletion of the given key + + :param project_id: The STACKIT portal project UUID the key ring is part of. (required) + :type project_id: str + :param region_id: The STACKIT region name the key ring is located in. (required) + :type region_id: str + :param key_ring_id: The key ring UUID. (required) + :type key_ring_id: str + :param key_id: The key UUID. (required) + :type key_id: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 docstring might be too long + + _param = self._delete_key_serialize( + project_id=project_id, + region_id=region_id, + key_ring_id=key_ring_id, + key_id=key_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "202": None, + "400": "HttpError", + "401": "HttpError", + "404": "HttpError", + "500": "HttpError", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + @validate_call + def delete_key_without_preload_content( + self, + project_id: Annotated[StrictStr, Field(description="The STACKIT portal project UUID the key ring is part of.")], + region_id: Annotated[StrictStr, Field(description="The STACKIT region name the key ring is located in.")], + key_ring_id: Annotated[StrictStr, Field(description="The key ring UUID.")], + key_id: Annotated[StrictStr, Field(description="The key UUID.")], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Delete key + + Schedules the deletion of the given key + + :param project_id: The STACKIT portal project UUID the key ring is part of. (required) + :type project_id: str + :param region_id: The STACKIT region name the key ring is located in. (required) + :type region_id: str + :param key_ring_id: The key ring UUID. (required) + :type key_ring_id: str + :param key_id: The key UUID. (required) + :type key_id: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 docstring might be too long + + _param = self._delete_key_serialize( + project_id=project_id, + region_id=region_id, + key_ring_id=key_ring_id, + key_id=key_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "202": None, + "400": "HttpError", + "401": "HttpError", + "404": "HttpError", + "500": "HttpError", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + return response_data.response + + def _delete_key_serialize( + self, + project_id, + region_id, + key_ring_id, + key_id, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = {} + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if project_id is not None: + _path_params["projectId"] = project_id + if region_id is not None: + _path_params["regionId"] = region_id + if key_ring_id is not None: + _path_params["keyRingId"] = key_ring_id + if key_id is not None: + _path_params["keyId"] = key_id + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + + # set the HTTP header `Accept` + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept(["application/json"]) + + # authentication setting + _auth_settings: List[str] = [] + + return self.api_client.param_serialize( + method="DELETE", + resource_path="/v1beta/projects/{projectId}/regions/{regionId}/keyrings/{keyRingId}/keys/{keyId}", + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth, + ) + + @validate_call + def delete_key_ring( + self, + project_id: Annotated[StrictStr, Field(description="The STACKIT portal project UUID the key ring is part of.")], + region_id: Annotated[StrictStr, Field(description="The STACKIT region name the key ring is located in.")], + key_ring_id: Annotated[StrictStr, Field(description="The key ring UUID.")], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> None: + """Delete keyring + + Deletes the given key ring if it is empty + + :param project_id: The STACKIT portal project UUID the key ring is part of. (required) + :type project_id: str + :param region_id: The STACKIT region name the key ring is located in. (required) + :type region_id: str + :param key_ring_id: The key ring UUID. (required) + :type key_ring_id: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 docstring might be too long + + _param = self._delete_key_ring_serialize( + project_id=project_id, + region_id=region_id, + key_ring_id=key_ring_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "204": None, + "400": "HttpError", + "401": "HttpError", + "404": "HttpError", + "500": "HttpError", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + @validate_call + def delete_key_ring_with_http_info( + self, + project_id: Annotated[StrictStr, Field(description="The STACKIT portal project UUID the key ring is part of.")], + region_id: Annotated[StrictStr, Field(description="The STACKIT region name the key ring is located in.")], + key_ring_id: Annotated[StrictStr, Field(description="The key ring UUID.")], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[None]: + """Delete keyring + + Deletes the given key ring if it is empty + + :param project_id: The STACKIT portal project UUID the key ring is part of. (required) + :type project_id: str + :param region_id: The STACKIT region name the key ring is located in. (required) + :type region_id: str + :param key_ring_id: The key ring UUID. (required) + :type key_ring_id: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 docstring might be too long + + _param = self._delete_key_ring_serialize( + project_id=project_id, + region_id=region_id, + key_ring_id=key_ring_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "204": None, + "400": "HttpError", + "401": "HttpError", + "404": "HttpError", + "500": "HttpError", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + @validate_call + def delete_key_ring_without_preload_content( + self, + project_id: Annotated[StrictStr, Field(description="The STACKIT portal project UUID the key ring is part of.")], + region_id: Annotated[StrictStr, Field(description="The STACKIT region name the key ring is located in.")], + key_ring_id: Annotated[StrictStr, Field(description="The key ring UUID.")], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Delete keyring + + Deletes the given key ring if it is empty + + :param project_id: The STACKIT portal project UUID the key ring is part of. (required) + :type project_id: str + :param region_id: The STACKIT region name the key ring is located in. (required) + :type region_id: str + :param key_ring_id: The key ring UUID. (required) + :type key_ring_id: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 docstring might be too long + + _param = self._delete_key_ring_serialize( + project_id=project_id, + region_id=region_id, + key_ring_id=key_ring_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "204": None, + "400": "HttpError", + "401": "HttpError", + "404": "HttpError", + "500": "HttpError", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + return response_data.response + + def _delete_key_ring_serialize( + self, + project_id, + region_id, + key_ring_id, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = {} + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if project_id is not None: + _path_params["projectId"] = project_id + if region_id is not None: + _path_params["regionId"] = region_id + if key_ring_id is not None: + _path_params["keyRingId"] = key_ring_id + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + + # set the HTTP header `Accept` + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept(["application/json"]) + + # authentication setting + _auth_settings: List[str] = [] + + return self.api_client.param_serialize( + method="DELETE", + resource_path="/v1beta/projects/{projectId}/regions/{regionId}/keyrings/{keyRingId}", + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth, + ) + + @validate_call + def destroy_version( + self, + project_id: Annotated[StrictStr, Field(description="The STACKIT portal project UUID the key ring is part of.")], + region_id: Annotated[StrictStr, Field(description="The STACKIT region name the key ring is located in.")], + key_ring_id: Annotated[StrictStr, Field(description="The key ring UUID.")], + key_id: Annotated[StrictStr, Field(description="The key UUID.")], + version_number: Annotated[StrictInt, Field(description="The version number.")], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> None: + """Destroy version + + Removes the key material of a version permanently. + + :param project_id: The STACKIT portal project UUID the key ring is part of. (required) + :type project_id: str + :param region_id: The STACKIT region name the key ring is located in. (required) + :type region_id: str + :param key_ring_id: The key ring UUID. (required) + :type key_ring_id: str + :param key_id: The key UUID. (required) + :type key_id: str + :param version_number: The version number. (required) + :type version_number: int + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 docstring might be too long + + _param = self._destroy_version_serialize( + project_id=project_id, + region_id=region_id, + key_ring_id=key_ring_id, + key_id=key_id, + version_number=version_number, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "204": None, + "400": "HttpError", + "401": "HttpError", + "404": "HttpError", + "500": "HttpError", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + @validate_call + def destroy_version_with_http_info( + self, + project_id: Annotated[StrictStr, Field(description="The STACKIT portal project UUID the key ring is part of.")], + region_id: Annotated[StrictStr, Field(description="The STACKIT region name the key ring is located in.")], + key_ring_id: Annotated[StrictStr, Field(description="The key ring UUID.")], + key_id: Annotated[StrictStr, Field(description="The key UUID.")], + version_number: Annotated[StrictInt, Field(description="The version number.")], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[None]: + """Destroy version + + Removes the key material of a version permanently. + + :param project_id: The STACKIT portal project UUID the key ring is part of. (required) + :type project_id: str + :param region_id: The STACKIT region name the key ring is located in. (required) + :type region_id: str + :param key_ring_id: The key ring UUID. (required) + :type key_ring_id: str + :param key_id: The key UUID. (required) + :type key_id: str + :param version_number: The version number. (required) + :type version_number: int + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 docstring might be too long + + _param = self._destroy_version_serialize( + project_id=project_id, + region_id=region_id, + key_ring_id=key_ring_id, + key_id=key_id, + version_number=version_number, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "204": None, + "400": "HttpError", + "401": "HttpError", + "404": "HttpError", + "500": "HttpError", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + @validate_call + def destroy_version_without_preload_content( + self, + project_id: Annotated[StrictStr, Field(description="The STACKIT portal project UUID the key ring is part of.")], + region_id: Annotated[StrictStr, Field(description="The STACKIT region name the key ring is located in.")], + key_ring_id: Annotated[StrictStr, Field(description="The key ring UUID.")], + key_id: Annotated[StrictStr, Field(description="The key UUID.")], + version_number: Annotated[StrictInt, Field(description="The version number.")], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Destroy version + + Removes the key material of a version permanently. + + :param project_id: The STACKIT portal project UUID the key ring is part of. (required) + :type project_id: str + :param region_id: The STACKIT region name the key ring is located in. (required) + :type region_id: str + :param key_ring_id: The key ring UUID. (required) + :type key_ring_id: str + :param key_id: The key UUID. (required) + :type key_id: str + :param version_number: The version number. (required) + :type version_number: int + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 docstring might be too long + + _param = self._destroy_version_serialize( + project_id=project_id, + region_id=region_id, + key_ring_id=key_ring_id, + key_id=key_id, + version_number=version_number, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "204": None, + "400": "HttpError", + "401": "HttpError", + "404": "HttpError", + "500": "HttpError", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + return response_data.response + + def _destroy_version_serialize( + self, + project_id, + region_id, + key_ring_id, + key_id, + version_number, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = {} + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if project_id is not None: + _path_params["projectId"] = project_id + if region_id is not None: + _path_params["regionId"] = region_id + if key_ring_id is not None: + _path_params["keyRingId"] = key_ring_id + if key_id is not None: + _path_params["keyId"] = key_id + if version_number is not None: + _path_params["versionNumber"] = version_number + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + + # set the HTTP header `Accept` + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept(["application/json"]) + + # authentication setting + _auth_settings: List[str] = [] + + return self.api_client.param_serialize( + method="POST", + resource_path="/v1beta/projects/{projectId}/regions/{regionId}/keyrings/{keyRingId}/keys/{keyId}/versions/{versionNumber}/destroy", + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth, + ) + + @validate_call + def disable_version( + self, + project_id: Annotated[StrictStr, Field(description="The STACKIT portal project UUID the key ring is part of.")], + region_id: Annotated[StrictStr, Field(description="The STACKIT region name the key ring is located in.")], + key_ring_id: Annotated[StrictStr, Field(description="The key ring UUID.")], + key_id: Annotated[StrictStr, Field(description="The key UUID.")], + version_number: Annotated[StrictInt, Field(description="The version number.")], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> None: + """Disable version + + Disables the given version. + + :param project_id: The STACKIT portal project UUID the key ring is part of. (required) + :type project_id: str + :param region_id: The STACKIT region name the key ring is located in. (required) + :type region_id: str + :param key_ring_id: The key ring UUID. (required) + :type key_ring_id: str + :param key_id: The key UUID. (required) + :type key_id: str + :param version_number: The version number. (required) + :type version_number: int + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 docstring might be too long + + _param = self._disable_version_serialize( + project_id=project_id, + region_id=region_id, + key_ring_id=key_ring_id, + key_id=key_id, + version_number=version_number, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "204": None, + "400": "HttpError", + "401": "HttpError", + "404": "HttpError", + "500": "HttpError", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + @validate_call + def disable_version_with_http_info( + self, + project_id: Annotated[StrictStr, Field(description="The STACKIT portal project UUID the key ring is part of.")], + region_id: Annotated[StrictStr, Field(description="The STACKIT region name the key ring is located in.")], + key_ring_id: Annotated[StrictStr, Field(description="The key ring UUID.")], + key_id: Annotated[StrictStr, Field(description="The key UUID.")], + version_number: Annotated[StrictInt, Field(description="The version number.")], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[None]: + """Disable version + + Disables the given version. + + :param project_id: The STACKIT portal project UUID the key ring is part of. (required) + :type project_id: str + :param region_id: The STACKIT region name the key ring is located in. (required) + :type region_id: str + :param key_ring_id: The key ring UUID. (required) + :type key_ring_id: str + :param key_id: The key UUID. (required) + :type key_id: str + :param version_number: The version number. (required) + :type version_number: int + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 docstring might be too long + + _param = self._disable_version_serialize( + project_id=project_id, + region_id=region_id, + key_ring_id=key_ring_id, + key_id=key_id, + version_number=version_number, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "204": None, + "400": "HttpError", + "401": "HttpError", + "404": "HttpError", + "500": "HttpError", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + @validate_call + def disable_version_without_preload_content( + self, + project_id: Annotated[StrictStr, Field(description="The STACKIT portal project UUID the key ring is part of.")], + region_id: Annotated[StrictStr, Field(description="The STACKIT region name the key ring is located in.")], + key_ring_id: Annotated[StrictStr, Field(description="The key ring UUID.")], + key_id: Annotated[StrictStr, Field(description="The key UUID.")], + version_number: Annotated[StrictInt, Field(description="The version number.")], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Disable version + + Disables the given version. + + :param project_id: The STACKIT portal project UUID the key ring is part of. (required) + :type project_id: str + :param region_id: The STACKIT region name the key ring is located in. (required) + :type region_id: str + :param key_ring_id: The key ring UUID. (required) + :type key_ring_id: str + :param key_id: The key UUID. (required) + :type key_id: str + :param version_number: The version number. (required) + :type version_number: int + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 docstring might be too long + + _param = self._disable_version_serialize( + project_id=project_id, + region_id=region_id, + key_ring_id=key_ring_id, + key_id=key_id, + version_number=version_number, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "204": None, + "400": "HttpError", + "401": "HttpError", + "404": "HttpError", + "500": "HttpError", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + return response_data.response + + def _disable_version_serialize( + self, + project_id, + region_id, + key_ring_id, + key_id, + version_number, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = {} + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if project_id is not None: + _path_params["projectId"] = project_id + if region_id is not None: + _path_params["regionId"] = region_id + if key_ring_id is not None: + _path_params["keyRingId"] = key_ring_id + if key_id is not None: + _path_params["keyId"] = key_id + if version_number is not None: + _path_params["versionNumber"] = version_number + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + + # set the HTTP header `Accept` + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept(["application/json"]) + + # authentication setting + _auth_settings: List[str] = [] + + return self.api_client.param_serialize( + method="POST", + resource_path="/v1beta/projects/{projectId}/regions/{regionId}/keyrings/{keyRingId}/keys/{keyId}/versions/{versionNumber}/disable", + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth, + ) + + @validate_call + def enable_version( + self, + project_id: Annotated[StrictStr, Field(description="The STACKIT portal project UUID the key ring is part of.")], + region_id: Annotated[StrictStr, Field(description="The STACKIT region name the key ring is located in.")], + key_ring_id: Annotated[StrictStr, Field(description="The key ring UUID.")], + key_id: Annotated[StrictStr, Field(description="The key UUID.")], + version_number: Annotated[StrictInt, Field(description="The version number.")], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> None: + """Enable version + + Enables the given version. + + :param project_id: The STACKIT portal project UUID the key ring is part of. (required) + :type project_id: str + :param region_id: The STACKIT region name the key ring is located in. (required) + :type region_id: str + :param key_ring_id: The key ring UUID. (required) + :type key_ring_id: str + :param key_id: The key UUID. (required) + :type key_id: str + :param version_number: The version number. (required) + :type version_number: int + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 docstring might be too long + + _param = self._enable_version_serialize( + project_id=project_id, + region_id=region_id, + key_ring_id=key_ring_id, + key_id=key_id, + version_number=version_number, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "204": None, + "400": "HttpError", + "401": "HttpError", + "404": "HttpError", + "500": "HttpError", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + @validate_call + def enable_version_with_http_info( + self, + project_id: Annotated[StrictStr, Field(description="The STACKIT portal project UUID the key ring is part of.")], + region_id: Annotated[StrictStr, Field(description="The STACKIT region name the key ring is located in.")], + key_ring_id: Annotated[StrictStr, Field(description="The key ring UUID.")], + key_id: Annotated[StrictStr, Field(description="The key UUID.")], + version_number: Annotated[StrictInt, Field(description="The version number.")], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[None]: + """Enable version + + Enables the given version. + + :param project_id: The STACKIT portal project UUID the key ring is part of. (required) + :type project_id: str + :param region_id: The STACKIT region name the key ring is located in. (required) + :type region_id: str + :param key_ring_id: The key ring UUID. (required) + :type key_ring_id: str + :param key_id: The key UUID. (required) + :type key_id: str + :param version_number: The version number. (required) + :type version_number: int + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 docstring might be too long + + _param = self._enable_version_serialize( + project_id=project_id, + region_id=region_id, + key_ring_id=key_ring_id, + key_id=key_id, + version_number=version_number, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "204": None, + "400": "HttpError", + "401": "HttpError", + "404": "HttpError", + "500": "HttpError", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + @validate_call + def enable_version_without_preload_content( + self, + project_id: Annotated[StrictStr, Field(description="The STACKIT portal project UUID the key ring is part of.")], + region_id: Annotated[StrictStr, Field(description="The STACKIT region name the key ring is located in.")], + key_ring_id: Annotated[StrictStr, Field(description="The key ring UUID.")], + key_id: Annotated[StrictStr, Field(description="The key UUID.")], + version_number: Annotated[StrictInt, Field(description="The version number.")], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Enable version + + Enables the given version. + + :param project_id: The STACKIT portal project UUID the key ring is part of. (required) + :type project_id: str + :param region_id: The STACKIT region name the key ring is located in. (required) + :type region_id: str + :param key_ring_id: The key ring UUID. (required) + :type key_ring_id: str + :param key_id: The key UUID. (required) + :type key_id: str + :param version_number: The version number. (required) + :type version_number: int + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 docstring might be too long + + _param = self._enable_version_serialize( + project_id=project_id, + region_id=region_id, + key_ring_id=key_ring_id, + key_id=key_id, + version_number=version_number, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "204": None, + "400": "HttpError", + "401": "HttpError", + "404": "HttpError", + "500": "HttpError", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + return response_data.response + + def _enable_version_serialize( + self, + project_id, + region_id, + key_ring_id, + key_id, + version_number, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = {} + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if project_id is not None: + _path_params["projectId"] = project_id + if region_id is not None: + _path_params["regionId"] = region_id + if key_ring_id is not None: + _path_params["keyRingId"] = key_ring_id + if key_id is not None: + _path_params["keyId"] = key_id + if version_number is not None: + _path_params["versionNumber"] = version_number + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + + # set the HTTP header `Accept` + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept(["application/json"]) + + # authentication setting + _auth_settings: List[str] = [] + + return self.api_client.param_serialize( + method="POST", + resource_path="/v1beta/projects/{projectId}/regions/{regionId}/keyrings/{keyRingId}/keys/{keyId}/versions/{versionNumber}/enable", + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth, + ) + + @validate_call + def encrypt( + self, + project_id: Annotated[StrictStr, Field(description="The STACKIT portal project UUID the key ring is part of.")], + region_id: Annotated[StrictStr, Field(description="The STACKIT region name the key ring is located in.")], + key_ring_id: Annotated[StrictStr, Field(description="The key ring UUID.")], + key_id: Annotated[StrictStr, Field(description="The key UUID.")], + version_number: Annotated[StrictInt, Field(description="The version number.")], + encrypt_payload: EncryptPayload, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> EncryptedData: + """Encrypt + + Encrypts data using the given key version. + + :param project_id: The STACKIT portal project UUID the key ring is part of. (required) + :type project_id: str + :param region_id: The STACKIT region name the key ring is located in. (required) + :type region_id: str + :param key_ring_id: The key ring UUID. (required) + :type key_ring_id: str + :param key_id: The key UUID. (required) + :type key_id: str + :param version_number: The version number. (required) + :type version_number: int + :param encrypt_payload: (required) + :type encrypt_payload: EncryptPayload + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 docstring might be too long + + _param = self._encrypt_serialize( + project_id=project_id, + region_id=region_id, + key_ring_id=key_ring_id, + key_id=key_id, + version_number=version_number, + encrypt_payload=encrypt_payload, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "EncryptedData", + "400": "HttpError", + "401": "HttpError", + "404": "HttpError", + "409": "HttpError", + "500": "HttpError", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + @validate_call + def encrypt_with_http_info( + self, + project_id: Annotated[StrictStr, Field(description="The STACKIT portal project UUID the key ring is part of.")], + region_id: Annotated[StrictStr, Field(description="The STACKIT region name the key ring is located in.")], + key_ring_id: Annotated[StrictStr, Field(description="The key ring UUID.")], + key_id: Annotated[StrictStr, Field(description="The key UUID.")], + version_number: Annotated[StrictInt, Field(description="The version number.")], + encrypt_payload: EncryptPayload, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[EncryptedData]: + """Encrypt + + Encrypts data using the given key version. + + :param project_id: The STACKIT portal project UUID the key ring is part of. (required) + :type project_id: str + :param region_id: The STACKIT region name the key ring is located in. (required) + :type region_id: str + :param key_ring_id: The key ring UUID. (required) + :type key_ring_id: str + :param key_id: The key UUID. (required) + :type key_id: str + :param version_number: The version number. (required) + :type version_number: int + :param encrypt_payload: (required) + :type encrypt_payload: EncryptPayload + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 docstring might be too long + + _param = self._encrypt_serialize( + project_id=project_id, + region_id=region_id, + key_ring_id=key_ring_id, + key_id=key_id, + version_number=version_number, + encrypt_payload=encrypt_payload, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "EncryptedData", + "400": "HttpError", + "401": "HttpError", + "404": "HttpError", + "409": "HttpError", + "500": "HttpError", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + @validate_call + def encrypt_without_preload_content( + self, + project_id: Annotated[StrictStr, Field(description="The STACKIT portal project UUID the key ring is part of.")], + region_id: Annotated[StrictStr, Field(description="The STACKIT region name the key ring is located in.")], + key_ring_id: Annotated[StrictStr, Field(description="The key ring UUID.")], + key_id: Annotated[StrictStr, Field(description="The key UUID.")], + version_number: Annotated[StrictInt, Field(description="The version number.")], + encrypt_payload: EncryptPayload, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Encrypt + + Encrypts data using the given key version. + + :param project_id: The STACKIT portal project UUID the key ring is part of. (required) + :type project_id: str + :param region_id: The STACKIT region name the key ring is located in. (required) + :type region_id: str + :param key_ring_id: The key ring UUID. (required) + :type key_ring_id: str + :param key_id: The key UUID. (required) + :type key_id: str + :param version_number: The version number. (required) + :type version_number: int + :param encrypt_payload: (required) + :type encrypt_payload: EncryptPayload + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 docstring might be too long + + _param = self._encrypt_serialize( + project_id=project_id, + region_id=region_id, + key_ring_id=key_ring_id, + key_id=key_id, + version_number=version_number, + encrypt_payload=encrypt_payload, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "EncryptedData", + "400": "HttpError", + "401": "HttpError", + "404": "HttpError", + "409": "HttpError", + "500": "HttpError", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + return response_data.response + + def _encrypt_serialize( + self, + project_id, + region_id, + key_ring_id, + key_id, + version_number, + encrypt_payload, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = {} + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if project_id is not None: + _path_params["projectId"] = project_id + if region_id is not None: + _path_params["regionId"] = region_id + if key_ring_id is not None: + _path_params["keyRingId"] = key_ring_id + if key_id is not None: + _path_params["keyId"] = key_id + if version_number is not None: + _path_params["versionNumber"] = version_number + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + if encrypt_payload is not None: + _body_params = encrypt_payload + + # set the HTTP header `Accept` + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept(["application/json"]) + + # set the HTTP header `Content-Type` + if _content_type: + _header_params["Content-Type"] = _content_type + else: + _default_content_type = self.api_client.select_header_content_type(["application/json"]) + if _default_content_type is not None: + _header_params["Content-Type"] = _default_content_type + + # authentication setting + _auth_settings: List[str] = [] + + return self.api_client.param_serialize( + method="POST", + resource_path="/v1beta/projects/{projectId}/regions/{regionId}/keyrings/{keyRingId}/keys/{keyId}/versions/{versionNumber}/encrypt", + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth, + ) + + @validate_call + def get_key( + self, + project_id: Annotated[StrictStr, Field(description="The STACKIT portal project UUID the key ring is part of.")], + region_id: Annotated[StrictStr, Field(description="The STACKIT region name the key ring is located in.")], + key_ring_id: Annotated[StrictStr, Field(description="The key ring UUID.")], + key_id: Annotated[StrictStr, Field(description="The key UUID.")], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> Key: + """Get key + + Returns the details for the given key. + + :param project_id: The STACKIT portal project UUID the key ring is part of. (required) + :type project_id: str + :param region_id: The STACKIT region name the key ring is located in. (required) + :type region_id: str + :param key_ring_id: The key ring UUID. (required) + :type key_ring_id: str + :param key_id: The key UUID. (required) + :type key_id: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 docstring might be too long + + _param = self._get_key_serialize( + project_id=project_id, + region_id=region_id, + key_ring_id=key_ring_id, + key_id=key_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "Key", + "400": "HttpError", + "401": "HttpError", + "404": "HttpError", + "500": "HttpError", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + @validate_call + def get_key_with_http_info( + self, + project_id: Annotated[StrictStr, Field(description="The STACKIT portal project UUID the key ring is part of.")], + region_id: Annotated[StrictStr, Field(description="The STACKIT region name the key ring is located in.")], + key_ring_id: Annotated[StrictStr, Field(description="The key ring UUID.")], + key_id: Annotated[StrictStr, Field(description="The key UUID.")], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[Key]: + """Get key + + Returns the details for the given key. + + :param project_id: The STACKIT portal project UUID the key ring is part of. (required) + :type project_id: str + :param region_id: The STACKIT region name the key ring is located in. (required) + :type region_id: str + :param key_ring_id: The key ring UUID. (required) + :type key_ring_id: str + :param key_id: The key UUID. (required) + :type key_id: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 docstring might be too long + + _param = self._get_key_serialize( + project_id=project_id, + region_id=region_id, + key_ring_id=key_ring_id, + key_id=key_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "Key", + "400": "HttpError", + "401": "HttpError", + "404": "HttpError", + "500": "HttpError", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + @validate_call + def get_key_without_preload_content( + self, + project_id: Annotated[StrictStr, Field(description="The STACKIT portal project UUID the key ring is part of.")], + region_id: Annotated[StrictStr, Field(description="The STACKIT region name the key ring is located in.")], + key_ring_id: Annotated[StrictStr, Field(description="The key ring UUID.")], + key_id: Annotated[StrictStr, Field(description="The key UUID.")], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Get key + + Returns the details for the given key. + + :param project_id: The STACKIT portal project UUID the key ring is part of. (required) + :type project_id: str + :param region_id: The STACKIT region name the key ring is located in. (required) + :type region_id: str + :param key_ring_id: The key ring UUID. (required) + :type key_ring_id: str + :param key_id: The key UUID. (required) + :type key_id: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 docstring might be too long + + _param = self._get_key_serialize( + project_id=project_id, + region_id=region_id, + key_ring_id=key_ring_id, + key_id=key_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "Key", + "400": "HttpError", + "401": "HttpError", + "404": "HttpError", + "500": "HttpError", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + return response_data.response + + def _get_key_serialize( + self, + project_id, + region_id, + key_ring_id, + key_id, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = {} + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if project_id is not None: + _path_params["projectId"] = project_id + if region_id is not None: + _path_params["regionId"] = region_id + if key_ring_id is not None: + _path_params["keyRingId"] = key_ring_id + if key_id is not None: + _path_params["keyId"] = key_id + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + + # set the HTTP header `Accept` + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept(["application/json"]) + + # authentication setting + _auth_settings: List[str] = [] + + return self.api_client.param_serialize( + method="GET", + resource_path="/v1beta/projects/{projectId}/regions/{regionId}/keyrings/{keyRingId}/keys/{keyId}", + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth, + ) + + @validate_call + def get_key_ring( + self, + project_id: Annotated[StrictStr, Field(description="The STACKIT portal project UUID the key ring is part of.")], + region_id: Annotated[StrictStr, Field(description="The STACKIT region name the key ring is located in.")], + key_ring_id: Annotated[StrictStr, Field(description="The key ring UUID.")], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> KeyRing: + """Get key ring + + Returns the details for the given key ring. + + :param project_id: The STACKIT portal project UUID the key ring is part of. (required) + :type project_id: str + :param region_id: The STACKIT region name the key ring is located in. (required) + :type region_id: str + :param key_ring_id: The key ring UUID. (required) + :type key_ring_id: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 docstring might be too long + + _param = self._get_key_ring_serialize( + project_id=project_id, + region_id=region_id, + key_ring_id=key_ring_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "KeyRing", + "400": "HttpError", + "401": "HttpError", + "404": "HttpError", + "500": "HttpError", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + @validate_call + def get_key_ring_with_http_info( + self, + project_id: Annotated[StrictStr, Field(description="The STACKIT portal project UUID the key ring is part of.")], + region_id: Annotated[StrictStr, Field(description="The STACKIT region name the key ring is located in.")], + key_ring_id: Annotated[StrictStr, Field(description="The key ring UUID.")], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[KeyRing]: + """Get key ring + + Returns the details for the given key ring. + + :param project_id: The STACKIT portal project UUID the key ring is part of. (required) + :type project_id: str + :param region_id: The STACKIT region name the key ring is located in. (required) + :type region_id: str + :param key_ring_id: The key ring UUID. (required) + :type key_ring_id: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 docstring might be too long + + _param = self._get_key_ring_serialize( + project_id=project_id, + region_id=region_id, + key_ring_id=key_ring_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "KeyRing", + "400": "HttpError", + "401": "HttpError", + "404": "HttpError", + "500": "HttpError", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + @validate_call + def get_key_ring_without_preload_content( + self, + project_id: Annotated[StrictStr, Field(description="The STACKIT portal project UUID the key ring is part of.")], + region_id: Annotated[StrictStr, Field(description="The STACKIT region name the key ring is located in.")], + key_ring_id: Annotated[StrictStr, Field(description="The key ring UUID.")], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Get key ring + + Returns the details for the given key ring. + + :param project_id: The STACKIT portal project UUID the key ring is part of. (required) + :type project_id: str + :param region_id: The STACKIT region name the key ring is located in. (required) + :type region_id: str + :param key_ring_id: The key ring UUID. (required) + :type key_ring_id: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 docstring might be too long + + _param = self._get_key_ring_serialize( + project_id=project_id, + region_id=region_id, + key_ring_id=key_ring_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "KeyRing", + "400": "HttpError", + "401": "HttpError", + "404": "HttpError", + "500": "HttpError", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + return response_data.response + + def _get_key_ring_serialize( + self, + project_id, + region_id, + key_ring_id, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = {} + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if project_id is not None: + _path_params["projectId"] = project_id + if region_id is not None: + _path_params["regionId"] = region_id + if key_ring_id is not None: + _path_params["keyRingId"] = key_ring_id + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + + # set the HTTP header `Accept` + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept(["application/json"]) + + # authentication setting + _auth_settings: List[str] = [] + + return self.api_client.param_serialize( + method="GET", + resource_path="/v1beta/projects/{projectId}/regions/{regionId}/keyrings/{keyRingId}", + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth, + ) + + @validate_call + def get_version( + self, + project_id: Annotated[StrictStr, Field(description="The STACKIT portal project UUID the key ring is part of.")], + region_id: Annotated[StrictStr, Field(description="The STACKIT region name the key ring is located in.")], + key_ring_id: Annotated[StrictStr, Field(description="The key ring UUID.")], + key_id: Annotated[StrictStr, Field(description="The key UUID.")], + version_number: Annotated[StrictInt, Field(description="The version number.")], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> Version: + """Get version + + Returns the details for the given version. + + :param project_id: The STACKIT portal project UUID the key ring is part of. (required) + :type project_id: str + :param region_id: The STACKIT region name the key ring is located in. (required) + :type region_id: str + :param key_ring_id: The key ring UUID. (required) + :type key_ring_id: str + :param key_id: The key UUID. (required) + :type key_id: str + :param version_number: The version number. (required) + :type version_number: int + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 docstring might be too long + + _param = self._get_version_serialize( + project_id=project_id, + region_id=region_id, + key_ring_id=key_ring_id, + key_id=key_id, + version_number=version_number, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "Version", + "400": "HttpError", + "401": "HttpError", + "404": "HttpError", + "500": "HttpError", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + @validate_call + def get_version_with_http_info( + self, + project_id: Annotated[StrictStr, Field(description="The STACKIT portal project UUID the key ring is part of.")], + region_id: Annotated[StrictStr, Field(description="The STACKIT region name the key ring is located in.")], + key_ring_id: Annotated[StrictStr, Field(description="The key ring UUID.")], + key_id: Annotated[StrictStr, Field(description="The key UUID.")], + version_number: Annotated[StrictInt, Field(description="The version number.")], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[Version]: + """Get version + + Returns the details for the given version. + + :param project_id: The STACKIT portal project UUID the key ring is part of. (required) + :type project_id: str + :param region_id: The STACKIT region name the key ring is located in. (required) + :type region_id: str + :param key_ring_id: The key ring UUID. (required) + :type key_ring_id: str + :param key_id: The key UUID. (required) + :type key_id: str + :param version_number: The version number. (required) + :type version_number: int + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 docstring might be too long + + _param = self._get_version_serialize( + project_id=project_id, + region_id=region_id, + key_ring_id=key_ring_id, + key_id=key_id, + version_number=version_number, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "Version", + "400": "HttpError", + "401": "HttpError", + "404": "HttpError", + "500": "HttpError", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + @validate_call + def get_version_without_preload_content( + self, + project_id: Annotated[StrictStr, Field(description="The STACKIT portal project UUID the key ring is part of.")], + region_id: Annotated[StrictStr, Field(description="The STACKIT region name the key ring is located in.")], + key_ring_id: Annotated[StrictStr, Field(description="The key ring UUID.")], + key_id: Annotated[StrictStr, Field(description="The key UUID.")], + version_number: Annotated[StrictInt, Field(description="The version number.")], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Get version + + Returns the details for the given version. + + :param project_id: The STACKIT portal project UUID the key ring is part of. (required) + :type project_id: str + :param region_id: The STACKIT region name the key ring is located in. (required) + :type region_id: str + :param key_ring_id: The key ring UUID. (required) + :type key_ring_id: str + :param key_id: The key UUID. (required) + :type key_id: str + :param version_number: The version number. (required) + :type version_number: int + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 docstring might be too long + + _param = self._get_version_serialize( + project_id=project_id, + region_id=region_id, + key_ring_id=key_ring_id, + key_id=key_id, + version_number=version_number, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "Version", + "400": "HttpError", + "401": "HttpError", + "404": "HttpError", + "500": "HttpError", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + return response_data.response + + def _get_version_serialize( + self, + project_id, + region_id, + key_ring_id, + key_id, + version_number, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = {} + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if project_id is not None: + _path_params["projectId"] = project_id + if region_id is not None: + _path_params["regionId"] = region_id + if key_ring_id is not None: + _path_params["keyRingId"] = key_ring_id + if key_id is not None: + _path_params["keyId"] = key_id + if version_number is not None: + _path_params["versionNumber"] = version_number + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + + # set the HTTP header `Accept` + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept(["application/json"]) + + # authentication setting + _auth_settings: List[str] = [] + + return self.api_client.param_serialize( + method="GET", + resource_path="/v1beta/projects/{projectId}/regions/{regionId}/keyrings/{keyRingId}/keys/{keyId}/versions/{versionNumber}", + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth, + ) + + @validate_call + def get_wrapping_key( + self, + project_id: Annotated[StrictStr, Field(description="The STACKIT portal project UUID the key ring is part of.")], + region_id: Annotated[StrictStr, Field(description="The STACKIT region name the key ring is located in.")], + key_ring_id: Annotated[StrictStr, Field(description="The key ring UUID.")], + wrapping_key_id: Annotated[StrictStr, Field(description="The wrapping key UUID.")], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> WrappingKey: + """Get wrapping key + + Returns the details for the given wrapping key. + + :param project_id: The STACKIT portal project UUID the key ring is part of. (required) + :type project_id: str + :param region_id: The STACKIT region name the key ring is located in. (required) + :type region_id: str + :param key_ring_id: The key ring UUID. (required) + :type key_ring_id: str + :param wrapping_key_id: The wrapping key UUID. (required) + :type wrapping_key_id: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 docstring might be too long + + _param = self._get_wrapping_key_serialize( + project_id=project_id, + region_id=region_id, + key_ring_id=key_ring_id, + wrapping_key_id=wrapping_key_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "WrappingKey", + "400": "HttpError", + "401": "HttpError", + "404": "HttpError", + "500": "HttpError", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + @validate_call + def get_wrapping_key_with_http_info( + self, + project_id: Annotated[StrictStr, Field(description="The STACKIT portal project UUID the key ring is part of.")], + region_id: Annotated[StrictStr, Field(description="The STACKIT region name the key ring is located in.")], + key_ring_id: Annotated[StrictStr, Field(description="The key ring UUID.")], + wrapping_key_id: Annotated[StrictStr, Field(description="The wrapping key UUID.")], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[WrappingKey]: + """Get wrapping key + + Returns the details for the given wrapping key. + + :param project_id: The STACKIT portal project UUID the key ring is part of. (required) + :type project_id: str + :param region_id: The STACKIT region name the key ring is located in. (required) + :type region_id: str + :param key_ring_id: The key ring UUID. (required) + :type key_ring_id: str + :param wrapping_key_id: The wrapping key UUID. (required) + :type wrapping_key_id: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 docstring might be too long + + _param = self._get_wrapping_key_serialize( + project_id=project_id, + region_id=region_id, + key_ring_id=key_ring_id, + wrapping_key_id=wrapping_key_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "WrappingKey", + "400": "HttpError", + "401": "HttpError", + "404": "HttpError", + "500": "HttpError", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + @validate_call + def get_wrapping_key_without_preload_content( + self, + project_id: Annotated[StrictStr, Field(description="The STACKIT portal project UUID the key ring is part of.")], + region_id: Annotated[StrictStr, Field(description="The STACKIT region name the key ring is located in.")], + key_ring_id: Annotated[StrictStr, Field(description="The key ring UUID.")], + wrapping_key_id: Annotated[StrictStr, Field(description="The wrapping key UUID.")], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Get wrapping key + + Returns the details for the given wrapping key. + + :param project_id: The STACKIT portal project UUID the key ring is part of. (required) + :type project_id: str + :param region_id: The STACKIT region name the key ring is located in. (required) + :type region_id: str + :param key_ring_id: The key ring UUID. (required) + :type key_ring_id: str + :param wrapping_key_id: The wrapping key UUID. (required) + :type wrapping_key_id: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 docstring might be too long + + _param = self._get_wrapping_key_serialize( + project_id=project_id, + region_id=region_id, + key_ring_id=key_ring_id, + wrapping_key_id=wrapping_key_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "WrappingKey", + "400": "HttpError", + "401": "HttpError", + "404": "HttpError", + "500": "HttpError", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + return response_data.response + + def _get_wrapping_key_serialize( + self, + project_id, + region_id, + key_ring_id, + wrapping_key_id, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = {} + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if project_id is not None: + _path_params["projectId"] = project_id + if region_id is not None: + _path_params["regionId"] = region_id + if key_ring_id is not None: + _path_params["keyRingId"] = key_ring_id + if wrapping_key_id is not None: + _path_params["wrappingKeyId"] = wrapping_key_id + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + + # set the HTTP header `Accept` + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept(["application/json"]) + + # authentication setting + _auth_settings: List[str] = [] + + return self.api_client.param_serialize( + method="GET", + resource_path="/v1beta/projects/{projectId}/regions/{regionId}/keyrings/{keyRingId}/wrappingkeys/{wrappingKeyId}", + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth, + ) + + @validate_call + def import_key( + self, + project_id: Annotated[StrictStr, Field(description="The STACKIT portal project UUID the key ring is part of.")], + region_id: Annotated[StrictStr, Field(description="The STACKIT region name the key ring is located in.")], + key_ring_id: Annotated[StrictStr, Field(description="The key ring UUID.")], + key_id: Annotated[StrictStr, Field(description="The key UUID.")], + import_key_payload: ImportKeyPayload, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> Key: + """Import key + + Imports a new version to the given key. + + :param project_id: The STACKIT portal project UUID the key ring is part of. (required) + :type project_id: str + :param region_id: The STACKIT region name the key ring is located in. (required) + :type region_id: str + :param key_ring_id: The key ring UUID. (required) + :type key_ring_id: str + :param key_id: The key UUID. (required) + :type key_id: str + :param import_key_payload: (required) + :type import_key_payload: ImportKeyPayload + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 docstring might be too long + + _param = self._import_key_serialize( + project_id=project_id, + region_id=region_id, + key_ring_id=key_ring_id, + key_id=key_id, + import_key_payload=import_key_payload, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "Key", + "400": "HttpError", + "401": "HttpError", + "404": "HttpError", + "409": "HttpError", + "500": "HttpError", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + @validate_call + def import_key_with_http_info( + self, + project_id: Annotated[StrictStr, Field(description="The STACKIT portal project UUID the key ring is part of.")], + region_id: Annotated[StrictStr, Field(description="The STACKIT region name the key ring is located in.")], + key_ring_id: Annotated[StrictStr, Field(description="The key ring UUID.")], + key_id: Annotated[StrictStr, Field(description="The key UUID.")], + import_key_payload: ImportKeyPayload, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[Key]: + """Import key + + Imports a new version to the given key. + + :param project_id: The STACKIT portal project UUID the key ring is part of. (required) + :type project_id: str + :param region_id: The STACKIT region name the key ring is located in. (required) + :type region_id: str + :param key_ring_id: The key ring UUID. (required) + :type key_ring_id: str + :param key_id: The key UUID. (required) + :type key_id: str + :param import_key_payload: (required) + :type import_key_payload: ImportKeyPayload + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 docstring might be too long + + _param = self._import_key_serialize( + project_id=project_id, + region_id=region_id, + key_ring_id=key_ring_id, + key_id=key_id, + import_key_payload=import_key_payload, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "Key", + "400": "HttpError", + "401": "HttpError", + "404": "HttpError", + "409": "HttpError", + "500": "HttpError", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + @validate_call + def import_key_without_preload_content( + self, + project_id: Annotated[StrictStr, Field(description="The STACKIT portal project UUID the key ring is part of.")], + region_id: Annotated[StrictStr, Field(description="The STACKIT region name the key ring is located in.")], + key_ring_id: Annotated[StrictStr, Field(description="The key ring UUID.")], + key_id: Annotated[StrictStr, Field(description="The key UUID.")], + import_key_payload: ImportKeyPayload, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Import key + + Imports a new version to the given key. + + :param project_id: The STACKIT portal project UUID the key ring is part of. (required) + :type project_id: str + :param region_id: The STACKIT region name the key ring is located in. (required) + :type region_id: str + :param key_ring_id: The key ring UUID. (required) + :type key_ring_id: str + :param key_id: The key UUID. (required) + :type key_id: str + :param import_key_payload: (required) + :type import_key_payload: ImportKeyPayload + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 docstring might be too long + + _param = self._import_key_serialize( + project_id=project_id, + region_id=region_id, + key_ring_id=key_ring_id, + key_id=key_id, + import_key_payload=import_key_payload, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "Key", + "400": "HttpError", + "401": "HttpError", + "404": "HttpError", + "409": "HttpError", + "500": "HttpError", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + return response_data.response + + def _import_key_serialize( + self, + project_id, + region_id, + key_ring_id, + key_id, + import_key_payload, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = {} + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if project_id is not None: + _path_params["projectId"] = project_id + if region_id is not None: + _path_params["regionId"] = region_id + if key_ring_id is not None: + _path_params["keyRingId"] = key_ring_id + if key_id is not None: + _path_params["keyId"] = key_id + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + if import_key_payload is not None: + _body_params = import_key_payload + + # set the HTTP header `Accept` + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept(["application/json"]) + + # set the HTTP header `Content-Type` + if _content_type: + _header_params["Content-Type"] = _content_type + else: + _default_content_type = self.api_client.select_header_content_type(["application/json"]) + if _default_content_type is not None: + _header_params["Content-Type"] = _default_content_type + + # authentication setting + _auth_settings: List[str] = [] + + return self.api_client.param_serialize( + method="POST", + resource_path="/v1beta/projects/{projectId}/regions/{regionId}/keyrings/{keyRingId}/keys/{keyId}/import", + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth, + ) + + @validate_call + def list_key_rings( + self, + project_id: Annotated[StrictStr, Field(description="The STACKIT portal project UUID the key ring is part of.")], + region_id: Annotated[StrictStr, Field(description="The STACKIT region name the key ring is located in.")], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> KeyRingList: + """List key rings + + Returns a list of all key rings within the project. + + :param project_id: The STACKIT portal project UUID the key ring is part of. (required) + :type project_id: str + :param region_id: The STACKIT region name the key ring is located in. (required) + :type region_id: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 docstring might be too long + + _param = self._list_key_rings_serialize( + project_id=project_id, + region_id=region_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "KeyRingList", + "400": "HttpError", + "401": "HttpError", + "500": "HttpError", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + @validate_call + def list_key_rings_with_http_info( + self, + project_id: Annotated[StrictStr, Field(description="The STACKIT portal project UUID the key ring is part of.")], + region_id: Annotated[StrictStr, Field(description="The STACKIT region name the key ring is located in.")], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[KeyRingList]: + """List key rings + + Returns a list of all key rings within the project. + + :param project_id: The STACKIT portal project UUID the key ring is part of. (required) + :type project_id: str + :param region_id: The STACKIT region name the key ring is located in. (required) + :type region_id: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 docstring might be too long + + _param = self._list_key_rings_serialize( + project_id=project_id, + region_id=region_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "KeyRingList", + "400": "HttpError", + "401": "HttpError", + "500": "HttpError", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + @validate_call + def list_key_rings_without_preload_content( + self, + project_id: Annotated[StrictStr, Field(description="The STACKIT portal project UUID the key ring is part of.")], + region_id: Annotated[StrictStr, Field(description="The STACKIT region name the key ring is located in.")], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """List key rings + + Returns a list of all key rings within the project. + + :param project_id: The STACKIT portal project UUID the key ring is part of. (required) + :type project_id: str + :param region_id: The STACKIT region name the key ring is located in. (required) + :type region_id: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 docstring might be too long + + _param = self._list_key_rings_serialize( + project_id=project_id, + region_id=region_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "KeyRingList", + "400": "HttpError", + "401": "HttpError", + "500": "HttpError", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + return response_data.response + + def _list_key_rings_serialize( + self, + project_id, + region_id, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = {} + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if project_id is not None: + _path_params["projectId"] = project_id + if region_id is not None: + _path_params["regionId"] = region_id + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + + # set the HTTP header `Accept` + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept(["application/json"]) + + # authentication setting + _auth_settings: List[str] = [] + + return self.api_client.param_serialize( + method="GET", + resource_path="/v1beta/projects/{projectId}/regions/{regionId}/keyrings", + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth, + ) + + @validate_call + def list_keys( + self, + project_id: Annotated[StrictStr, Field(description="The STACKIT portal project UUID the key ring is part of.")], + region_id: Annotated[StrictStr, Field(description="The STACKIT region name the key ring is located in.")], + key_ring_id: Annotated[StrictStr, Field(description="The key ring UUID.")], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> KeyList: + """List keys + + Returns the keys for the given key ring. + + :param project_id: The STACKIT portal project UUID the key ring is part of. (required) + :type project_id: str + :param region_id: The STACKIT region name the key ring is located in. (required) + :type region_id: str + :param key_ring_id: The key ring UUID. (required) + :type key_ring_id: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 docstring might be too long + + _param = self._list_keys_serialize( + project_id=project_id, + region_id=region_id, + key_ring_id=key_ring_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "KeyList", + "400": "HttpError", + "401": "HttpError", + "404": "HttpError", + "500": "HttpError", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + @validate_call + def list_keys_with_http_info( + self, + project_id: Annotated[StrictStr, Field(description="The STACKIT portal project UUID the key ring is part of.")], + region_id: Annotated[StrictStr, Field(description="The STACKIT region name the key ring is located in.")], + key_ring_id: Annotated[StrictStr, Field(description="The key ring UUID.")], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[KeyList]: + """List keys + + Returns the keys for the given key ring. + + :param project_id: The STACKIT portal project UUID the key ring is part of. (required) + :type project_id: str + :param region_id: The STACKIT region name the key ring is located in. (required) + :type region_id: str + :param key_ring_id: The key ring UUID. (required) + :type key_ring_id: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 docstring might be too long + + _param = self._list_keys_serialize( + project_id=project_id, + region_id=region_id, + key_ring_id=key_ring_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "KeyList", + "400": "HttpError", + "401": "HttpError", + "404": "HttpError", + "500": "HttpError", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + @validate_call + def list_keys_without_preload_content( + self, + project_id: Annotated[StrictStr, Field(description="The STACKIT portal project UUID the key ring is part of.")], + region_id: Annotated[StrictStr, Field(description="The STACKIT region name the key ring is located in.")], + key_ring_id: Annotated[StrictStr, Field(description="The key ring UUID.")], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """List keys + + Returns the keys for the given key ring. + + :param project_id: The STACKIT portal project UUID the key ring is part of. (required) + :type project_id: str + :param region_id: The STACKIT region name the key ring is located in. (required) + :type region_id: str + :param key_ring_id: The key ring UUID. (required) + :type key_ring_id: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 docstring might be too long + + _param = self._list_keys_serialize( + project_id=project_id, + region_id=region_id, + key_ring_id=key_ring_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "KeyList", + "400": "HttpError", + "401": "HttpError", + "404": "HttpError", + "500": "HttpError", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + return response_data.response + + def _list_keys_serialize( + self, + project_id, + region_id, + key_ring_id, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = {} + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if project_id is not None: + _path_params["projectId"] = project_id + if region_id is not None: + _path_params["regionId"] = region_id + if key_ring_id is not None: + _path_params["keyRingId"] = key_ring_id + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + + # set the HTTP header `Accept` + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept(["application/json"]) + + # authentication setting + _auth_settings: List[str] = [] + + return self.api_client.param_serialize( + method="GET", + resource_path="/v1beta/projects/{projectId}/regions/{regionId}/keyrings/{keyRingId}/keys", + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth, + ) + + @validate_call + def list_versions( + self, + project_id: Annotated[StrictStr, Field(description="The STACKIT portal project UUID the key ring is part of.")], + region_id: Annotated[StrictStr, Field(description="The STACKIT region name the key ring is located in.")], + key_ring_id: Annotated[StrictStr, Field(description="The key ring UUID.")], + key_id: Annotated[StrictStr, Field(description="The key UUID.")], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> VersionList: + """List versions + + Returns a list of all versions of a given key. + + :param project_id: The STACKIT portal project UUID the key ring is part of. (required) + :type project_id: str + :param region_id: The STACKIT region name the key ring is located in. (required) + :type region_id: str + :param key_ring_id: The key ring UUID. (required) + :type key_ring_id: str + :param key_id: The key UUID. (required) + :type key_id: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 docstring might be too long + + _param = self._list_versions_serialize( + project_id=project_id, + region_id=region_id, + key_ring_id=key_ring_id, + key_id=key_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "VersionList", + "400": "HttpError", + "401": "HttpError", + "404": "HttpError", + "500": "HttpError", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + @validate_call + def list_versions_with_http_info( + self, + project_id: Annotated[StrictStr, Field(description="The STACKIT portal project UUID the key ring is part of.")], + region_id: Annotated[StrictStr, Field(description="The STACKIT region name the key ring is located in.")], + key_ring_id: Annotated[StrictStr, Field(description="The key ring UUID.")], + key_id: Annotated[StrictStr, Field(description="The key UUID.")], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[VersionList]: + """List versions + + Returns a list of all versions of a given key. + + :param project_id: The STACKIT portal project UUID the key ring is part of. (required) + :type project_id: str + :param region_id: The STACKIT region name the key ring is located in. (required) + :type region_id: str + :param key_ring_id: The key ring UUID. (required) + :type key_ring_id: str + :param key_id: The key UUID. (required) + :type key_id: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 docstring might be too long + + _param = self._list_versions_serialize( + project_id=project_id, + region_id=region_id, + key_ring_id=key_ring_id, + key_id=key_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "VersionList", + "400": "HttpError", + "401": "HttpError", + "404": "HttpError", + "500": "HttpError", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + @validate_call + def list_versions_without_preload_content( + self, + project_id: Annotated[StrictStr, Field(description="The STACKIT portal project UUID the key ring is part of.")], + region_id: Annotated[StrictStr, Field(description="The STACKIT region name the key ring is located in.")], + key_ring_id: Annotated[StrictStr, Field(description="The key ring UUID.")], + key_id: Annotated[StrictStr, Field(description="The key UUID.")], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """List versions + + Returns a list of all versions of a given key. + + :param project_id: The STACKIT portal project UUID the key ring is part of. (required) + :type project_id: str + :param region_id: The STACKIT region name the key ring is located in. (required) + :type region_id: str + :param key_ring_id: The key ring UUID. (required) + :type key_ring_id: str + :param key_id: The key UUID. (required) + :type key_id: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 docstring might be too long + + _param = self._list_versions_serialize( + project_id=project_id, + region_id=region_id, + key_ring_id=key_ring_id, + key_id=key_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "VersionList", + "400": "HttpError", + "401": "HttpError", + "404": "HttpError", + "500": "HttpError", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + return response_data.response + + def _list_versions_serialize( + self, + project_id, + region_id, + key_ring_id, + key_id, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = {} + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if project_id is not None: + _path_params["projectId"] = project_id + if region_id is not None: + _path_params["regionId"] = region_id + if key_ring_id is not None: + _path_params["keyRingId"] = key_ring_id + if key_id is not None: + _path_params["keyId"] = key_id + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + + # set the HTTP header `Accept` + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept(["application/json"]) + + # authentication setting + _auth_settings: List[str] = [] + + return self.api_client.param_serialize( + method="GET", + resource_path="/v1beta/projects/{projectId}/regions/{regionId}/keyrings/{keyRingId}/keys/{keyId}/versions", + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth, + ) + + @validate_call + def list_wrapping_keys( + self, + project_id: Annotated[StrictStr, Field(description="The STACKIT portal project UUID the key ring is part of.")], + region_id: Annotated[StrictStr, Field(description="The STACKIT region name the key ring is located in.")], + key_ring_id: Annotated[StrictStr, Field(description="The key ring UUID.")], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> WrappingKeyList: + """List wrapping keys + + Returns the wrapping keys for the given key ring. + + :param project_id: The STACKIT portal project UUID the key ring is part of. (required) + :type project_id: str + :param region_id: The STACKIT region name the key ring is located in. (required) + :type region_id: str + :param key_ring_id: The key ring UUID. (required) + :type key_ring_id: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 docstring might be too long + + _param = self._list_wrapping_keys_serialize( + project_id=project_id, + region_id=region_id, + key_ring_id=key_ring_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "WrappingKeyList", + "400": "HttpError", + "401": "HttpError", + "404": "HttpError", + "500": "HttpError", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + @validate_call + def list_wrapping_keys_with_http_info( + self, + project_id: Annotated[StrictStr, Field(description="The STACKIT portal project UUID the key ring is part of.")], + region_id: Annotated[StrictStr, Field(description="The STACKIT region name the key ring is located in.")], + key_ring_id: Annotated[StrictStr, Field(description="The key ring UUID.")], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[WrappingKeyList]: + """List wrapping keys + + Returns the wrapping keys for the given key ring. + + :param project_id: The STACKIT portal project UUID the key ring is part of. (required) + :type project_id: str + :param region_id: The STACKIT region name the key ring is located in. (required) + :type region_id: str + :param key_ring_id: The key ring UUID. (required) + :type key_ring_id: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 docstring might be too long + + _param = self._list_wrapping_keys_serialize( + project_id=project_id, + region_id=region_id, + key_ring_id=key_ring_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "WrappingKeyList", + "400": "HttpError", + "401": "HttpError", + "404": "HttpError", + "500": "HttpError", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + @validate_call + def list_wrapping_keys_without_preload_content( + self, + project_id: Annotated[StrictStr, Field(description="The STACKIT portal project UUID the key ring is part of.")], + region_id: Annotated[StrictStr, Field(description="The STACKIT region name the key ring is located in.")], + key_ring_id: Annotated[StrictStr, Field(description="The key ring UUID.")], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """List wrapping keys + + Returns the wrapping keys for the given key ring. + + :param project_id: The STACKIT portal project UUID the key ring is part of. (required) + :type project_id: str + :param region_id: The STACKIT region name the key ring is located in. (required) + :type region_id: str + :param key_ring_id: The key ring UUID. (required) + :type key_ring_id: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 docstring might be too long + + _param = self._list_wrapping_keys_serialize( + project_id=project_id, + region_id=region_id, + key_ring_id=key_ring_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "WrappingKeyList", + "400": "HttpError", + "401": "HttpError", + "404": "HttpError", + "500": "HttpError", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + return response_data.response + + def _list_wrapping_keys_serialize( + self, + project_id, + region_id, + key_ring_id, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = {} + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if project_id is not None: + _path_params["projectId"] = project_id + if region_id is not None: + _path_params["regionId"] = region_id + if key_ring_id is not None: + _path_params["keyRingId"] = key_ring_id + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + + # set the HTTP header `Accept` + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept(["application/json"]) + + # authentication setting + _auth_settings: List[str] = [] + + return self.api_client.param_serialize( + method="GET", + resource_path="/v1beta/projects/{projectId}/regions/{regionId}/keyrings/{keyRingId}/wrappingkeys", + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth, + ) + + @validate_call + def restore_key( + self, + project_id: Annotated[StrictStr, Field(description="The STACKIT portal project UUID the key ring is part of.")], + region_id: Annotated[StrictStr, Field(description="The STACKIT region name the key ring is located in.")], + key_ring_id: Annotated[StrictStr, Field(description="The key ring UUID.")], + key_id: Annotated[StrictStr, Field(description="The key UUID.")], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> None: + """Restore deleted key + + Restores the given key from being deleted. + + :param project_id: The STACKIT portal project UUID the key ring is part of. (required) + :type project_id: str + :param region_id: The STACKIT region name the key ring is located in. (required) + :type region_id: str + :param key_ring_id: The key ring UUID. (required) + :type key_ring_id: str + :param key_id: The key UUID. (required) + :type key_id: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 docstring might be too long + + _param = self._restore_key_serialize( + project_id=project_id, + region_id=region_id, + key_ring_id=key_ring_id, + key_id=key_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": None, + "400": "HttpError", + "401": "HttpError", + "404": "HttpError", + "500": "HttpError", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + @validate_call + def restore_key_with_http_info( + self, + project_id: Annotated[StrictStr, Field(description="The STACKIT portal project UUID the key ring is part of.")], + region_id: Annotated[StrictStr, Field(description="The STACKIT region name the key ring is located in.")], + key_ring_id: Annotated[StrictStr, Field(description="The key ring UUID.")], + key_id: Annotated[StrictStr, Field(description="The key UUID.")], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[None]: + """Restore deleted key + + Restores the given key from being deleted. + + :param project_id: The STACKIT portal project UUID the key ring is part of. (required) + :type project_id: str + :param region_id: The STACKIT region name the key ring is located in. (required) + :type region_id: str + :param key_ring_id: The key ring UUID. (required) + :type key_ring_id: str + :param key_id: The key UUID. (required) + :type key_id: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 docstring might be too long + + _param = self._restore_key_serialize( + project_id=project_id, + region_id=region_id, + key_ring_id=key_ring_id, + key_id=key_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": None, + "400": "HttpError", + "401": "HttpError", + "404": "HttpError", + "500": "HttpError", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + @validate_call + def restore_key_without_preload_content( + self, + project_id: Annotated[StrictStr, Field(description="The STACKIT portal project UUID the key ring is part of.")], + region_id: Annotated[StrictStr, Field(description="The STACKIT region name the key ring is located in.")], + key_ring_id: Annotated[StrictStr, Field(description="The key ring UUID.")], + key_id: Annotated[StrictStr, Field(description="The key UUID.")], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Restore deleted key + + Restores the given key from being deleted. + + :param project_id: The STACKIT portal project UUID the key ring is part of. (required) + :type project_id: str + :param region_id: The STACKIT region name the key ring is located in. (required) + :type region_id: str + :param key_ring_id: The key ring UUID. (required) + :type key_ring_id: str + :param key_id: The key UUID. (required) + :type key_id: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 docstring might be too long + + _param = self._restore_key_serialize( + project_id=project_id, + region_id=region_id, + key_ring_id=key_ring_id, + key_id=key_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": None, + "400": "HttpError", + "401": "HttpError", + "404": "HttpError", + "500": "HttpError", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + return response_data.response + + def _restore_key_serialize( + self, + project_id, + region_id, + key_ring_id, + key_id, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = {} + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if project_id is not None: + _path_params["projectId"] = project_id + if region_id is not None: + _path_params["regionId"] = region_id + if key_ring_id is not None: + _path_params["keyRingId"] = key_ring_id + if key_id is not None: + _path_params["keyId"] = key_id + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + + # set the HTTP header `Accept` + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept(["application/json"]) + + # authentication setting + _auth_settings: List[str] = [] + + return self.api_client.param_serialize( + method="POST", + resource_path="/v1beta/projects/{projectId}/regions/{regionId}/keyrings/{keyRingId}/keys/{keyId}/restore", + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth, + ) + + @validate_call + def restore_version( + self, + project_id: Annotated[StrictStr, Field(description="The STACKIT portal project UUID the key ring is part of.")], + region_id: Annotated[StrictStr, Field(description="The STACKIT region name the key ring is located in.")], + key_ring_id: Annotated[StrictStr, Field(description="The key ring UUID.")], + key_id: Annotated[StrictStr, Field(description="The key UUID.")], + version_number: Annotated[StrictInt, Field(description="The version number.")], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> None: + """Restore version + + Restores the given version from being destroyed + + :param project_id: The STACKIT portal project UUID the key ring is part of. (required) + :type project_id: str + :param region_id: The STACKIT region name the key ring is located in. (required) + :type region_id: str + :param key_ring_id: The key ring UUID. (required) + :type key_ring_id: str + :param key_id: The key UUID. (required) + :type key_id: str + :param version_number: The version number. (required) + :type version_number: int + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 docstring might be too long + + _param = self._restore_version_serialize( + project_id=project_id, + region_id=region_id, + key_ring_id=key_ring_id, + key_id=key_id, + version_number=version_number, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "204": None, + "400": "HttpError", + "401": "HttpError", + "404": "HttpError", + "500": "HttpError", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + @validate_call + def restore_version_with_http_info( + self, + project_id: Annotated[StrictStr, Field(description="The STACKIT portal project UUID the key ring is part of.")], + region_id: Annotated[StrictStr, Field(description="The STACKIT region name the key ring is located in.")], + key_ring_id: Annotated[StrictStr, Field(description="The key ring UUID.")], + key_id: Annotated[StrictStr, Field(description="The key UUID.")], + version_number: Annotated[StrictInt, Field(description="The version number.")], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[None]: + """Restore version + + Restores the given version from being destroyed + + :param project_id: The STACKIT portal project UUID the key ring is part of. (required) + :type project_id: str + :param region_id: The STACKIT region name the key ring is located in. (required) + :type region_id: str + :param key_ring_id: The key ring UUID. (required) + :type key_ring_id: str + :param key_id: The key UUID. (required) + :type key_id: str + :param version_number: The version number. (required) + :type version_number: int + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 docstring might be too long + + _param = self._restore_version_serialize( + project_id=project_id, + region_id=region_id, + key_ring_id=key_ring_id, + key_id=key_id, + version_number=version_number, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "204": None, + "400": "HttpError", + "401": "HttpError", + "404": "HttpError", + "500": "HttpError", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + @validate_call + def restore_version_without_preload_content( + self, + project_id: Annotated[StrictStr, Field(description="The STACKIT portal project UUID the key ring is part of.")], + region_id: Annotated[StrictStr, Field(description="The STACKIT region name the key ring is located in.")], + key_ring_id: Annotated[StrictStr, Field(description="The key ring UUID.")], + key_id: Annotated[StrictStr, Field(description="The key UUID.")], + version_number: Annotated[StrictInt, Field(description="The version number.")], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Restore version + + Restores the given version from being destroyed + + :param project_id: The STACKIT portal project UUID the key ring is part of. (required) + :type project_id: str + :param region_id: The STACKIT region name the key ring is located in. (required) + :type region_id: str + :param key_ring_id: The key ring UUID. (required) + :type key_ring_id: str + :param key_id: The key UUID. (required) + :type key_id: str + :param version_number: The version number. (required) + :type version_number: int + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 docstring might be too long + + _param = self._restore_version_serialize( + project_id=project_id, + region_id=region_id, + key_ring_id=key_ring_id, + key_id=key_id, + version_number=version_number, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "204": None, + "400": "HttpError", + "401": "HttpError", + "404": "HttpError", + "500": "HttpError", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + return response_data.response + + def _restore_version_serialize( + self, + project_id, + region_id, + key_ring_id, + key_id, + version_number, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = {} + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if project_id is not None: + _path_params["projectId"] = project_id + if region_id is not None: + _path_params["regionId"] = region_id + if key_ring_id is not None: + _path_params["keyRingId"] = key_ring_id + if key_id is not None: + _path_params["keyId"] = key_id + if version_number is not None: + _path_params["versionNumber"] = version_number + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + + # set the HTTP header `Accept` + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept(["application/json"]) + + # authentication setting + _auth_settings: List[str] = [] + + return self.api_client.param_serialize( + method="POST", + resource_path="/v1beta/projects/{projectId}/regions/{regionId}/keyrings/{keyRingId}/keys/{keyId}/versions/{versionNumber}/restore", + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth, + ) + + @validate_call + def rotate_key( + self, + project_id: Annotated[StrictStr, Field(description="The STACKIT portal project UUID the key ring is part of.")], + region_id: Annotated[StrictStr, Field(description="The STACKIT region name the key ring is located in.")], + key_ring_id: Annotated[StrictStr, Field(description="The key ring UUID.")], + key_id: Annotated[StrictStr, Field(description="The key UUID.")], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> Key: + """Rotate key + + Rotates the given key. + + :param project_id: The STACKIT portal project UUID the key ring is part of. (required) + :type project_id: str + :param region_id: The STACKIT region name the key ring is located in. (required) + :type region_id: str + :param key_ring_id: The key ring UUID. (required) + :type key_ring_id: str + :param key_id: The key UUID. (required) + :type key_id: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 docstring might be too long + + _param = self._rotate_key_serialize( + project_id=project_id, + region_id=region_id, + key_ring_id=key_ring_id, + key_id=key_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "Key", + "400": "HttpError", + "401": "HttpError", + "403": "HttpError", + "404": "HttpError", + "409": "HttpError", + "500": "HttpError", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + @validate_call + def rotate_key_with_http_info( + self, + project_id: Annotated[StrictStr, Field(description="The STACKIT portal project UUID the key ring is part of.")], + region_id: Annotated[StrictStr, Field(description="The STACKIT region name the key ring is located in.")], + key_ring_id: Annotated[StrictStr, Field(description="The key ring UUID.")], + key_id: Annotated[StrictStr, Field(description="The key UUID.")], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[Key]: + """Rotate key + + Rotates the given key. + + :param project_id: The STACKIT portal project UUID the key ring is part of. (required) + :type project_id: str + :param region_id: The STACKIT region name the key ring is located in. (required) + :type region_id: str + :param key_ring_id: The key ring UUID. (required) + :type key_ring_id: str + :param key_id: The key UUID. (required) + :type key_id: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 docstring might be too long + + _param = self._rotate_key_serialize( + project_id=project_id, + region_id=region_id, + key_ring_id=key_ring_id, + key_id=key_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "Key", + "400": "HttpError", + "401": "HttpError", + "403": "HttpError", + "404": "HttpError", + "409": "HttpError", + "500": "HttpError", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + @validate_call + def rotate_key_without_preload_content( + self, + project_id: Annotated[StrictStr, Field(description="The STACKIT portal project UUID the key ring is part of.")], + region_id: Annotated[StrictStr, Field(description="The STACKIT region name the key ring is located in.")], + key_ring_id: Annotated[StrictStr, Field(description="The key ring UUID.")], + key_id: Annotated[StrictStr, Field(description="The key UUID.")], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Rotate key + + Rotates the given key. + + :param project_id: The STACKIT portal project UUID the key ring is part of. (required) + :type project_id: str + :param region_id: The STACKIT region name the key ring is located in. (required) + :type region_id: str + :param key_ring_id: The key ring UUID. (required) + :type key_ring_id: str + :param key_id: The key UUID. (required) + :type key_id: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 docstring might be too long + + _param = self._rotate_key_serialize( + project_id=project_id, + region_id=region_id, + key_ring_id=key_ring_id, + key_id=key_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "Key", + "400": "HttpError", + "401": "HttpError", + "403": "HttpError", + "404": "HttpError", + "409": "HttpError", + "500": "HttpError", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + return response_data.response + + def _rotate_key_serialize( + self, + project_id, + region_id, + key_ring_id, + key_id, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = {} + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if project_id is not None: + _path_params["projectId"] = project_id + if region_id is not None: + _path_params["regionId"] = region_id + if key_ring_id is not None: + _path_params["keyRingId"] = key_ring_id + if key_id is not None: + _path_params["keyId"] = key_id + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + + # set the HTTP header `Accept` + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept(["application/json"]) + + # authentication setting + _auth_settings: List[str] = [] + + return self.api_client.param_serialize( + method="POST", + resource_path="/v1beta/projects/{projectId}/regions/{regionId}/keyrings/{keyRingId}/keys/{keyId}/rotate", + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth, + ) + + @validate_call + def sign( + self, + project_id: Annotated[StrictStr, Field(description="The STACKIT portal project UUID the key ring is part of.")], + region_id: Annotated[StrictStr, Field(description="The STACKIT region name the key ring is located in.")], + key_ring_id: Annotated[StrictStr, Field(description="The key ring UUID.")], + key_id: Annotated[StrictStr, Field(description="The key UUID.")], + version_number: Annotated[StrictInt, Field(description="The version number.")], + sign_payload: SignPayload, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> SignedData: + """Sign + + Sign data using the given key version as secret. + + :param project_id: The STACKIT portal project UUID the key ring is part of. (required) + :type project_id: str + :param region_id: The STACKIT region name the key ring is located in. (required) + :type region_id: str + :param key_ring_id: The key ring UUID. (required) + :type key_ring_id: str + :param key_id: The key UUID. (required) + :type key_id: str + :param version_number: The version number. (required) + :type version_number: int + :param sign_payload: (required) + :type sign_payload: SignPayload + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 docstring might be too long + + _param = self._sign_serialize( + project_id=project_id, + region_id=region_id, + key_ring_id=key_ring_id, + key_id=key_id, + version_number=version_number, + sign_payload=sign_payload, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "SignedData", + "400": "HttpError", + "401": "HttpError", + "404": "HttpError", + "409": "HttpError", + "500": "HttpError", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + @validate_call + def sign_with_http_info( + self, + project_id: Annotated[StrictStr, Field(description="The STACKIT portal project UUID the key ring is part of.")], + region_id: Annotated[StrictStr, Field(description="The STACKIT region name the key ring is located in.")], + key_ring_id: Annotated[StrictStr, Field(description="The key ring UUID.")], + key_id: Annotated[StrictStr, Field(description="The key UUID.")], + version_number: Annotated[StrictInt, Field(description="The version number.")], + sign_payload: SignPayload, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[SignedData]: + """Sign + + Sign data using the given key version as secret. + + :param project_id: The STACKIT portal project UUID the key ring is part of. (required) + :type project_id: str + :param region_id: The STACKIT region name the key ring is located in. (required) + :type region_id: str + :param key_ring_id: The key ring UUID. (required) + :type key_ring_id: str + :param key_id: The key UUID. (required) + :type key_id: str + :param version_number: The version number. (required) + :type version_number: int + :param sign_payload: (required) + :type sign_payload: SignPayload + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 docstring might be too long + + _param = self._sign_serialize( + project_id=project_id, + region_id=region_id, + key_ring_id=key_ring_id, + key_id=key_id, + version_number=version_number, + sign_payload=sign_payload, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "SignedData", + "400": "HttpError", + "401": "HttpError", + "404": "HttpError", + "409": "HttpError", + "500": "HttpError", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + @validate_call + def sign_without_preload_content( + self, + project_id: Annotated[StrictStr, Field(description="The STACKIT portal project UUID the key ring is part of.")], + region_id: Annotated[StrictStr, Field(description="The STACKIT region name the key ring is located in.")], + key_ring_id: Annotated[StrictStr, Field(description="The key ring UUID.")], + key_id: Annotated[StrictStr, Field(description="The key UUID.")], + version_number: Annotated[StrictInt, Field(description="The version number.")], + sign_payload: SignPayload, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Sign + + Sign data using the given key version as secret. + + :param project_id: The STACKIT portal project UUID the key ring is part of. (required) + :type project_id: str + :param region_id: The STACKIT region name the key ring is located in. (required) + :type region_id: str + :param key_ring_id: The key ring UUID. (required) + :type key_ring_id: str + :param key_id: The key UUID. (required) + :type key_id: str + :param version_number: The version number. (required) + :type version_number: int + :param sign_payload: (required) + :type sign_payload: SignPayload + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 docstring might be too long + + _param = self._sign_serialize( + project_id=project_id, + region_id=region_id, + key_ring_id=key_ring_id, + key_id=key_id, + version_number=version_number, + sign_payload=sign_payload, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "SignedData", + "400": "HttpError", + "401": "HttpError", + "404": "HttpError", + "409": "HttpError", + "500": "HttpError", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + return response_data.response + + def _sign_serialize( + self, + project_id, + region_id, + key_ring_id, + key_id, + version_number, + sign_payload, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = {} + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if project_id is not None: + _path_params["projectId"] = project_id + if region_id is not None: + _path_params["regionId"] = region_id + if key_ring_id is not None: + _path_params["keyRingId"] = key_ring_id + if key_id is not None: + _path_params["keyId"] = key_id + if version_number is not None: + _path_params["versionNumber"] = version_number + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + if sign_payload is not None: + _body_params = sign_payload + + # set the HTTP header `Accept` + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept(["application/json"]) + + # set the HTTP header `Content-Type` + if _content_type: + _header_params["Content-Type"] = _content_type + else: + _default_content_type = self.api_client.select_header_content_type(["application/json"]) + if _default_content_type is not None: + _header_params["Content-Type"] = _default_content_type + + # authentication setting + _auth_settings: List[str] = [] + + return self.api_client.param_serialize( + method="POST", + resource_path="/v1beta/projects/{projectId}/regions/{regionId}/keyrings/{keyRingId}/keys/{keyId}/versions/{versionNumber}/sign", + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth, + ) + + @validate_call + def verify( + self, + project_id: Annotated[StrictStr, Field(description="The STACKIT portal project UUID the key ring is part of.")], + region_id: Annotated[StrictStr, Field(description="The STACKIT region name the key ring is located in.")], + key_ring_id: Annotated[StrictStr, Field(description="The key ring UUID.")], + key_id: Annotated[StrictStr, Field(description="The key UUID.")], + version_number: Annotated[StrictInt, Field(description="The version number.")], + verify_payload: VerifyPayload, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> VerifiedData: + """Verify + + Verify data using the given key version as secret. + + :param project_id: The STACKIT portal project UUID the key ring is part of. (required) + :type project_id: str + :param region_id: The STACKIT region name the key ring is located in. (required) + :type region_id: str + :param key_ring_id: The key ring UUID. (required) + :type key_ring_id: str + :param key_id: The key UUID. (required) + :type key_id: str + :param version_number: The version number. (required) + :type version_number: int + :param verify_payload: (required) + :type verify_payload: VerifyPayload + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 docstring might be too long + + _param = self._verify_serialize( + project_id=project_id, + region_id=region_id, + key_ring_id=key_ring_id, + key_id=key_id, + version_number=version_number, + verify_payload=verify_payload, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "VerifiedData", + "400": "HttpError", + "401": "HttpError", + "404": "HttpError", + "409": "HttpError", + "500": "HttpError", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + @validate_call + def verify_with_http_info( + self, + project_id: Annotated[StrictStr, Field(description="The STACKIT portal project UUID the key ring is part of.")], + region_id: Annotated[StrictStr, Field(description="The STACKIT region name the key ring is located in.")], + key_ring_id: Annotated[StrictStr, Field(description="The key ring UUID.")], + key_id: Annotated[StrictStr, Field(description="The key UUID.")], + version_number: Annotated[StrictInt, Field(description="The version number.")], + verify_payload: VerifyPayload, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[VerifiedData]: + """Verify + + Verify data using the given key version as secret. + + :param project_id: The STACKIT portal project UUID the key ring is part of. (required) + :type project_id: str + :param region_id: The STACKIT region name the key ring is located in. (required) + :type region_id: str + :param key_ring_id: The key ring UUID. (required) + :type key_ring_id: str + :param key_id: The key UUID. (required) + :type key_id: str + :param version_number: The version number. (required) + :type version_number: int + :param verify_payload: (required) + :type verify_payload: VerifyPayload + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 docstring might be too long + + _param = self._verify_serialize( + project_id=project_id, + region_id=region_id, + key_ring_id=key_ring_id, + key_id=key_id, + version_number=version_number, + verify_payload=verify_payload, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "VerifiedData", + "400": "HttpError", + "401": "HttpError", + "404": "HttpError", + "409": "HttpError", + "500": "HttpError", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + @validate_call + def verify_without_preload_content( + self, + project_id: Annotated[StrictStr, Field(description="The STACKIT portal project UUID the key ring is part of.")], + region_id: Annotated[StrictStr, Field(description="The STACKIT region name the key ring is located in.")], + key_ring_id: Annotated[StrictStr, Field(description="The key ring UUID.")], + key_id: Annotated[StrictStr, Field(description="The key UUID.")], + version_number: Annotated[StrictInt, Field(description="The version number.")], + verify_payload: VerifyPayload, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Verify + + Verify data using the given key version as secret. + + :param project_id: The STACKIT portal project UUID the key ring is part of. (required) + :type project_id: str + :param region_id: The STACKIT region name the key ring is located in. (required) + :type region_id: str + :param key_ring_id: The key ring UUID. (required) + :type key_ring_id: str + :param key_id: The key UUID. (required) + :type key_id: str + :param version_number: The version number. (required) + :type version_number: int + :param verify_payload: (required) + :type verify_payload: VerifyPayload + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 docstring might be too long + + _param = self._verify_serialize( + project_id=project_id, + region_id=region_id, + key_ring_id=key_ring_id, + key_id=key_id, + version_number=version_number, + verify_payload=verify_payload, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "VerifiedData", + "400": "HttpError", + "401": "HttpError", + "404": "HttpError", + "409": "HttpError", + "500": "HttpError", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + return response_data.response + + def _verify_serialize( + self, + project_id, + region_id, + key_ring_id, + key_id, + version_number, + verify_payload, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = {} + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if project_id is not None: + _path_params["projectId"] = project_id + if region_id is not None: + _path_params["regionId"] = region_id + if key_ring_id is not None: + _path_params["keyRingId"] = key_ring_id + if key_id is not None: + _path_params["keyId"] = key_id + if version_number is not None: + _path_params["versionNumber"] = version_number + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + if verify_payload is not None: + _body_params = verify_payload + + # set the HTTP header `Accept` + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept(["application/json"]) + + # set the HTTP header `Content-Type` + if _content_type: + _header_params["Content-Type"] = _content_type + else: + _default_content_type = self.api_client.select_header_content_type(["application/json"]) + if _default_content_type is not None: + _header_params["Content-Type"] = _default_content_type + + # authentication setting + _auth_settings: List[str] = [] + + return self.api_client.param_serialize( + method="POST", + resource_path="/v1beta/projects/{projectId}/regions/{regionId}/keyrings/{keyRingId}/keys/{keyId}/versions/{versionNumber}/verify", + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth, + ) diff --git a/services/kms/src/stackit/kms/api_client.py b/services/kms/src/stackit/kms/api_client.py new file mode 100644 index 00000000..05fadaca --- /dev/null +++ b/services/kms/src/stackit/kms/api_client.py @@ -0,0 +1,626 @@ +# coding: utf-8 + +""" + STACKIT Key Management Service API + + This API provides endpoints for managing keys and key rings. + + The version of the OpenAPI document: 1beta.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 docstring might be too long + +import datetime +import json +import mimetypes +import os +import re +import tempfile +from enum import Enum +from typing import Dict, List, Optional, Tuple, Union +from urllib.parse import quote + +from dateutil.parser import parse +from pydantic import SecretStr +from stackit.core.configuration import Configuration + +import stackit.kms.models +from stackit.kms import rest +from stackit.kms.api_response import ApiResponse +from stackit.kms.api_response import T as ApiResponseT +from stackit.kms.configuration import HostConfiguration +from stackit.kms.exceptions import ( + ApiException, +) + + +RequestSerialized = Tuple[str, str, Dict[str, str], Optional[str], List[str]] + + +class ApiClient: + """Generic API client for OpenAPI client library builds. + + OpenAPI generic API client. This client handles the client- + server communication, and is invariant across implementations. Specifics of + the methods and models for each application are generated from the OpenAPI + templates. + + :param configuration: .Configuration object for this client + :param header_name: a header to pass when making calls to the API. + :param header_value: a header value to pass when making calls to + the API. + :param cookie: a cookie to include in the header when making calls + to the API + """ + + PRIMITIVE_TYPES = (float, bool, bytes, str, int) + NATIVE_TYPES_MAPPING = { + "int": int, + "long": int, # TODO remove as only py3 is supported? + "float": float, + "str": str, + "bool": bool, + "date": datetime.date, + "datetime": datetime.datetime, + "object": object, + } + + def __init__(self, configuration, header_name=None, header_value=None, cookie=None) -> None: + self.config: Configuration = configuration + + if self.config.custom_endpoint is None: + host_config = HostConfiguration(region=self.config.region, server_index=self.config.server_index) + self.host = host_config.host + else: + self.host = self.config.custom_endpoint + + self.rest_client = rest.RESTClientObject(self.config) + self.default_headers = {} + if header_name is not None: + self.default_headers[header_name] = header_value + self.cookie = cookie + # Set default User-Agent. + self.user_agent = "OpenAPI-Generator/1.0.0/python" + + def __enter__(self): + return self + + def __exit__(self, exc_type, exc_value, traceback): + pass + + @property + def user_agent(self): + """User agent for this API client""" + return self.default_headers["User-Agent"] + + @user_agent.setter + def user_agent(self, value): + self.default_headers["User-Agent"] = value + + def set_default_header(self, header_name, header_value): + self.default_headers[header_name] = header_value + + _default = None + + @classmethod + def get_default(cls): + """Return new instance of ApiClient. + + This method returns newly created, based on default constructor, + object of ApiClient class or returns a copy of default + ApiClient. + + :return: The ApiClient object. + """ + if cls._default is None: + cls._default = ApiClient() + return cls._default + + @classmethod + def set_default(cls, default): + """Set default instance of ApiClient. + + It stores default ApiClient. + + :param default: object of ApiClient. + """ + cls._default = default + + def param_serialize( + self, + method, + resource_path, + path_params=None, + query_params=None, + header_params=None, + body=None, + post_params=None, + files=None, + auth_settings=None, + collection_formats=None, + _host=None, + _request_auth=None, + ) -> RequestSerialized: + """Builds the HTTP request params needed by the request. + :param method: Method to call. + :param resource_path: Path to method endpoint. + :param path_params: Path parameters in the url. + :param query_params: Query parameters in the url. + :param header_params: Header parameters to be + placed in the request header. + :param body: Request body. + :param post_params dict: Request post form parameters, + for `application/x-www-form-urlencoded`, `multipart/form-data`. + :param auth_settings list: Auth Settings names for the request. + :param files dict: key -> filename, value -> filepath, + for `multipart/form-data`. + :param collection_formats: dict of collection formats for path, query, + header, and post parameters. + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the authentication + in the spec for a single request. + :return: tuple of form (path, http_method, query_params, header_params, + body, post_params, files) + """ + + # header parameters + header_params = header_params or {} + header_params.update(self.default_headers) + if self.cookie: + header_params["Cookie"] = self.cookie + if header_params: + header_params = self.sanitize_for_serialization(header_params) + header_params = dict(self.parameters_to_tuples(header_params, collection_formats)) + + # path parameters + if path_params: + path_params = self.sanitize_for_serialization(path_params) + path_params = self.parameters_to_tuples(path_params, collection_formats) + for k, v in path_params: + # specified safe chars, encode everything + resource_path = resource_path.replace("{%s}" % k, quote(str(v))) + + # post parameters + if post_params or files: + post_params = post_params if post_params else [] + post_params = self.sanitize_for_serialization(post_params) + post_params = self.parameters_to_tuples(post_params, collection_formats) + if files: + post_params.extend(self.files_parameters(files)) + + # body + if body: + body = self.sanitize_for_serialization(body) + + # request url + if _host is None: + url = self.host + resource_path + else: + # use server/host defined in path or operation instead + url = _host + resource_path + + # query parameters + if query_params: + query_params = self.sanitize_for_serialization(query_params) + url_query = self.parameters_to_url_query(query_params, collection_formats) + url += "?" + url_query + + return method, url, header_params, body, post_params + + def call_api( + self, method, url, header_params=None, body=None, post_params=None, _request_timeout=None + ) -> rest.RESTResponse: + """Makes the HTTP request (synchronous) + :param method: Method to call. + :param url: Path to method endpoint. + :param header_params: Header parameters to be + placed in the request header. + :param body: Request body. + :param post_params dict: Request post form parameters, + for `application/x-www-form-urlencoded`, `multipart/form-data`. + :param _request_timeout: timeout setting for this request. + :return: RESTResponse + """ + + try: + # perform request and return response + response_data = self.rest_client.request( + method, + url, + headers=header_params, + body=body, + post_params=post_params, + _request_timeout=_request_timeout, + ) + + except ApiException as e: + raise e + + return response_data + + def response_deserialize( + self, response_data: rest.RESTResponse, response_types_map: Optional[Dict[str, ApiResponseT]] = None + ) -> ApiResponse[ApiResponseT]: + """Deserializes response into an object. + :param response_data: RESTResponse object to be deserialized. + :param response_types_map: dict of response types. + :return: ApiResponse + """ + + msg = "RESTResponse.read() must be called before passing it to response_deserialize()" + if response_data.data is None: + raise ValueError(msg) + + response_type = response_types_map.get(str(response_data.status), None) + if not response_type and isinstance(response_data.status, int) and 100 <= response_data.status <= 599: + # if not found, look for '1XX', '2XX', etc. + response_type = response_types_map.get(str(response_data.status)[0] + "XX", None) + + # deserialize response data + response_text = None + return_data = None + try: + if response_type == "bytearray": + return_data = response_data.data + elif response_type == "file": + return_data = self.__deserialize_file(response_data) + elif response_type is not None: + match = None + content_type = response_data.getheader("content-type") + if content_type is not None: + match = re.search(r"charset=([a-zA-Z\-\d]+)[\s;]?", content_type) + encoding = match.group(1) if match else "utf-8" + response_text = response_data.data.decode(encoding) + return_data = self.deserialize(response_text, response_type, content_type) + finally: + if not 200 <= response_data.status <= 299: + raise ApiException.from_response( + http_resp=response_data, + body=response_text, + data=return_data, + ) + + return ApiResponse( + status_code=response_data.status, + data=return_data, + headers=response_data.getheaders(), + raw_data=response_data.data, + ) + + def sanitize_for_serialization(self, obj): + """Builds a JSON POST object. + + If obj is None, return None. + If obj is SecretStr, return obj.get_secret_value() + If obj is str, int, long, float, bool, return directly. + If obj is datetime.datetime, datetime.date + convert to string in iso8601 format. + If obj is list, sanitize each element in the list. + If obj is dict, return the dict. + If obj is OpenAPI model, return the properties dict. + + :param obj: The data to serialize. + :return: The serialized form of data. + """ + if obj is None: + return None + elif isinstance(obj, Enum): + return obj.value + elif isinstance(obj, SecretStr): + return obj.get_secret_value() + elif isinstance(obj, self.PRIMITIVE_TYPES): + return obj + elif isinstance(obj, list): + return [self.sanitize_for_serialization(sub_obj) for sub_obj in obj] + elif isinstance(obj, tuple): + return tuple(self.sanitize_for_serialization(sub_obj) for sub_obj in obj) + elif isinstance(obj, (datetime.datetime, datetime.date)): + return obj.isoformat() + + elif isinstance(obj, dict): + obj_dict = obj + else: + # Convert model obj to dict except + # attributes `openapi_types`, `attribute_map` + # and attributes which value is not None. + # Convert attribute name to json key in + # model definition for request. + if hasattr(obj, "to_dict") and callable(obj.to_dict): + obj_dict = obj.to_dict() + else: + obj_dict = obj.__dict__ + + return {key: self.sanitize_for_serialization(val) for key, val in obj_dict.items()} + + def deserialize(self, response_text: str, response_type: str, content_type: Optional[str]): + """Deserializes response into an object. + + :param response: RESTResponse object to be deserialized. + :param response_type: class literal for + deserialized object, or string of class name. + :param content_type: content type of response. + + :return: deserialized object. + """ + + # fetch data from response object + if content_type is None: + try: + data = json.loads(response_text) + except ValueError: + data = response_text + elif content_type.startswith("application/json"): + if response_text == "": + data = "" + else: + data = json.loads(response_text) + elif content_type.startswith("text/plain"): + data = response_text + else: + raise ApiException(status=0, reason="Unsupported content type: {0}".format(content_type)) + + return self.__deserialize(data, response_type) + + def __deserialize(self, data, klass): + """Deserializes dict, list, str into an object. + + :param data: dict, list or str. + :param klass: class literal, or string of class name. + + :return: object. + """ + if data is None: + return None + + if isinstance(klass, str): + if klass.startswith("List["): + m = re.match(r"List\[(.*)]", klass) + if m is None: + raise ValueError("Malformed List type definition") + sub_kls = m.group(1) + return [self.__deserialize(sub_data, sub_kls) for sub_data in data] + + if klass.startswith("Dict["): + m = re.match(r"Dict\[([^,]*), (.*)]", klass) + if m is None: + raise ValueError("Malformed Dict type definition") + sub_kls = m.group(2) + return {k: self.__deserialize(v, sub_kls) for k, v in data.items()} + + # convert str to class + if klass in self.NATIVE_TYPES_MAPPING: + klass = self.NATIVE_TYPES_MAPPING[klass] + else: + klass = getattr(stackit.kms.models, klass) + + if klass in self.PRIMITIVE_TYPES: + return self.__deserialize_primitive(data, klass) + elif klass == object: + return self.__deserialize_object(data) + elif klass == datetime.date: + return self.__deserialize_date(data) + elif klass == datetime.datetime: + return self.__deserialize_datetime(data) + elif issubclass(klass, Enum): + return self.__deserialize_enum(data, klass) + else: + return self.__deserialize_model(data, klass) + + def parameters_to_tuples(self, params, collection_formats): + """Get parameters as list of tuples, formatting collections. + + :param params: Parameters as dict or list of two-tuples + :param dict collection_formats: Parameter collection formats + :return: Parameters as list of tuples, collections formatted + """ + new_params: List[Tuple[str, str]] = [] + if collection_formats is None: + collection_formats = {} + for k, v in params.items() if isinstance(params, dict) else params: + if k in collection_formats: + collection_format = collection_formats[k] + if collection_format == "multi": + new_params.extend((k, value) for value in v) + else: + if collection_format == "ssv": + delimiter = " " + elif collection_format == "tsv": + delimiter = "\t" + elif collection_format == "pipes": + delimiter = "|" + else: # csv is the default + delimiter = "," + new_params.append((k, delimiter.join(str(value) for value in v))) + else: + new_params.append((k, v)) + return new_params + + def parameters_to_url_query(self, params, collection_formats): + """Get parameters as list of tuples, formatting collections. + + :param params: Parameters as dict or list of two-tuples + :param dict collection_formats: Parameter collection formats + :return: URL query string (e.g. a=Hello%20World&b=123) + """ + new_params: List[Tuple[str, str]] = [] + if collection_formats is None: + collection_formats = {} + for k, v in params.items() if isinstance(params, dict) else params: + if isinstance(v, bool): + v = str(v).lower() + if isinstance(v, (int, float)): + v = str(v) + if isinstance(v, dict): + v = json.dumps(v) + + if k in collection_formats: + collection_format = collection_formats[k] + if collection_format == "multi": + new_params.extend((k, str(value)) for value in v) + else: + if collection_format == "ssv": + delimiter = " " + elif collection_format == "tsv": + delimiter = "\t" + elif collection_format == "pipes": + delimiter = "|" + else: # csv is the default + delimiter = "," + new_params.append((k, delimiter.join(quote(str(value)) for value in v))) + else: + new_params.append((k, quote(str(v)))) + + return "&".join(["=".join(map(str, item)) for item in new_params]) + + def files_parameters(self, files: Dict[str, Union[str, bytes]]): + """Builds form parameters. + + :param files: File parameters. + :return: Form parameters with files. + """ + params = [] + for k, v in files.items(): + if isinstance(v, str): + with open(v, "rb") as f: + filename = os.path.basename(f.name) + filedata = f.read() + elif isinstance(v, bytes): + filename = k + filedata = v + else: + raise ValueError("Unsupported file value") + mimetype = mimetypes.guess_type(filename)[0] or "application/octet-stream" + params.append(tuple([k, tuple([filename, filedata, mimetype])])) + return params + + def select_header_accept(self, accepts: List[str]) -> Optional[str]: + """Returns `Accept` based on an array of accepts provided. + + :param accepts: List of headers. + :return: Accept (e.g. application/json). + """ + if not accepts: + return None + + for accept in accepts: + if re.search("json", accept, re.IGNORECASE): + return accept + + return accepts[0] + + def select_header_content_type(self, content_types): + """Returns `Content-Type` based on an array of content_types provided. + + :param content_types: List of content-types. + :return: Content-Type (e.g. application/json). + """ + if not content_types: + return None + + for content_type in content_types: + if re.search("json", content_type, re.IGNORECASE): + return content_type + + return content_types[0] + + def __deserialize_file(self, response): + """Deserializes body to file + + Saves response body into a file in a temporary folder, + using the filename from the `Content-Disposition` header if provided. + + handle file downloading + save response body into a tmp file and return the instance + + :param response: RESTResponse. + :return: file path. + """ + fd, path = tempfile.mkstemp(dir=self.configuration.temp_folder_path) + os.close(fd) + os.remove(path) + + content_disposition = response.getheader("Content-Disposition") + if content_disposition: + m = re.search(r'filename=[\'"]?([^\'"\s]+)[\'"]?', content_disposition) + if m is None: + raise ValueError("Unexpected 'content-disposition' header value") + filename = m.group(1) + path = os.path.join(os.path.dirname(path), filename) + + with open(path, "wb") as f: + f.write(response.data) + + return path + + def __deserialize_primitive(self, data, klass): + """Deserializes string to primitive type. + + :param data: str. + :param klass: class literal. + + :return: int, long, float, str, bool. + """ + try: + return klass(data) + except UnicodeEncodeError: + return str(data) + except TypeError: + return data + + def __deserialize_object(self, value): + """Return an original value. + + :return: object. + """ + return value + + def __deserialize_date(self, string): + """Deserializes string to date. + + :param string: str. + :return: date. + """ + try: + return parse(string).date() + except ImportError: + return string + except ValueError: + raise rest.ApiException(status=0, reason="Failed to parse `{0}` as date object".format(string)) + + def __deserialize_datetime(self, string): + """Deserializes string to datetime. + + The string should be in iso8601 datetime format. + + :param string: str. + :return: datetime. + """ + try: + return parse(string) + except ImportError: + return string + except ValueError: + raise rest.ApiException(status=0, reason=("Failed to parse `{0}` as datetime object".format(string))) + + def __deserialize_enum(self, data, klass): + """Deserializes primitive type to enum. + + :param data: primitive type. + :param klass: class literal. + :return: enum value. + """ + try: + return klass(data) + except ValueError: + raise rest.ApiException(status=0, reason=("Failed to parse `{0}` as `{1}`".format(data, klass))) + + def __deserialize_model(self, data, klass): + """Deserializes list or dict to model. + + :param data: dict, list. + :param klass: class literal. + :return: model object. + """ + + return klass.from_dict(data) diff --git a/services/kms/src/stackit/kms/api_response.py b/services/kms/src/stackit/kms/api_response.py new file mode 100644 index 00000000..b3ba14a1 --- /dev/null +++ b/services/kms/src/stackit/kms/api_response.py @@ -0,0 +1,23 @@ +"""API response object.""" + +from __future__ import annotations + +from typing import Generic, Mapping, Optional, TypeVar + +from pydantic import BaseModel, Field, StrictBytes, StrictInt + + +T = TypeVar("T") + + +class ApiResponse(BaseModel, Generic[T]): + """ + API response object + """ + + status_code: StrictInt = Field(description="HTTP status code") + headers: Optional[Mapping[str, str]] = Field(None, description="HTTP headers") + data: T = Field(description="Deserialized data given the data type") + raw_data: StrictBytes = Field(description="Raw data (HTTP response body)") + + model_config = {"arbitrary_types_allowed": True} diff --git a/services/kms/src/stackit/kms/configuration.py b/services/kms/src/stackit/kms/configuration.py new file mode 100644 index 00000000..dfc615d5 --- /dev/null +++ b/services/kms/src/stackit/kms/configuration.py @@ -0,0 +1,138 @@ +# coding: utf-8 + +""" + STACKIT Key Management Service API + + This API provides endpoints for managing keys and key rings. + + The version of the OpenAPI document: 1beta.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 docstring might be too long + +import os + + +class HostConfiguration: + def __init__( + self, + region=None, + server_index=None, + server_variables=None, + server_operation_index=None, + server_operation_variables=None, + ignore_operation_servers=False, + ) -> None: + print( + "WARNING: STACKIT will move to a new way of specifying regions, where the region is provided\n", + "as a function argument instead of being set in the client configuration.\n" + "Once all services have migrated, the methods to specify the region in the client configuration " + "will be removed.", + ) + """Constructor + """ + self._base_path = "https://kms.api.eu01.stackit.cloud" + """Default Base url + """ + self.server_index = 0 if server_index is None else server_index + self.server_operation_index = server_operation_index or {} + """Default server index + """ + self.server_variables = server_variables or {} + if region: + self.server_variables["region"] = "{}.".format(region) + self.server_operation_variables = server_operation_variables or {} + """Default server variables + """ + self.ignore_operation_servers = ignore_operation_servers + """Ignore operation servers + """ + + def get_host_settings(self): + """Gets an array of host settings + + :return: An array of host settings + """ + return [ + { + "url": "https://kms.api.{region}stackit.cloud", + "description": "No description provided", + "variables": { + "region": { + "description": "No description provided", + "default_value": "eu01.", + "enum_values": ["eu01."], + } + }, + } + ] + + def get_host_from_settings(self, index, variables=None, servers=None): + """Gets host URL based on the index and variables + :param index: array index of the host settings + :param variables: hash of variable and the corresponding value + :param servers: an array of host settings or None + :error: if a region is given for a global url + :return: URL based on host settings + """ + if index is None: + return self._base_path + + variables = {} if variables is None else variables + servers = self.get_host_settings() if servers is None else servers + + try: + server = servers[index] + except IndexError: + raise ValueError( + "Invalid index {0} when selecting the host settings. " + "Must be less than {1}".format(index, len(servers)) + ) + + url = server["url"] + + # check if environment variable was provided for region + # if nothing was set this is None + region_env = os.environ.get("STACKIT_REGION") + + # go through variables and replace placeholders + for variable_name, variable in server.get("variables", {}).items(): + # If a region is provided by the user for a global url + # return an error (except for providing via environment variable). + # The region is provided as a function argument instead of being set in the client configuration. + if ( + variable_name == "region" + and (variable["default_value"] == "global" or variable["default_value"] == "") + and region_env is None + and variables.get(variable_name) is not None + ): + raise ValueError( + "this API does not support setting a region in the the client configuration, " + "please check if the region can be specified as a function parameter" + ) + used_value = variables.get(variable_name, variable["default_value"]) + + if "enum_values" in variable and used_value not in variable["enum_values"]: + given_value = variables[variable_name].replace(".", "") + valid_values = [v.replace(".", "") for v in variable["enum_values"]] + raise ValueError( + "The variable `{0}` in the host URL has invalid value '{1}'. Must be '{2}'.".format( + variable_name, given_value, valid_values + ) + ) + + url = url.replace("{" + variable_name + "}", used_value) + + return url + + @property + def host(self): + """Return generated host.""" + return self.get_host_from_settings(self.server_index, variables=self.server_variables) + + @host.setter + def host(self, value): + """Fix base path.""" + self._base_path = value + self.server_index = None diff --git a/services/kms/src/stackit/kms/exceptions.py b/services/kms/src/stackit/kms/exceptions.py new file mode 100644 index 00000000..7e9a4dd3 --- /dev/null +++ b/services/kms/src/stackit/kms/exceptions.py @@ -0,0 +1,198 @@ +# coding: utf-8 + +""" + STACKIT Key Management Service API + + This API provides endpoints for managing keys and key rings. + + The version of the OpenAPI document: 1beta.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 docstring might be too long + +from typing import Any, Optional + +from typing_extensions import Self + + +class OpenApiException(Exception): + """The base exception class for all OpenAPIExceptions""" + + +class ApiTypeError(OpenApiException, TypeError): + def __init__(self, msg, path_to_item=None, valid_classes=None, key_type=None) -> None: + """Raises an exception for TypeErrors + + Args: + msg (str): the exception message + + Keyword Args: + path_to_item (list): a list of keys an indices to get to the + current_item + None if unset + valid_classes (tuple): the primitive classes that current item + should be an instance of + None if unset + key_type (bool): False if our value is a value in a dict + True if it is a key in a dict + False if our item is an item in a list + None if unset + """ + self.path_to_item = path_to_item + self.valid_classes = valid_classes + self.key_type = key_type + full_msg = msg + if path_to_item: + full_msg = "{0} at {1}".format(msg, render_path(path_to_item)) + super(ApiTypeError, self).__init__(full_msg) + + +class ApiValueError(OpenApiException, ValueError): + def __init__(self, msg, path_to_item=None) -> None: + """ + Args: + msg (str): the exception message + + Keyword Args: + path_to_item (list) the path to the exception in the + received_data dict. None if unset + """ + + self.path_to_item = path_to_item + full_msg = msg + if path_to_item: + full_msg = "{0} at {1}".format(msg, render_path(path_to_item)) + super(ApiValueError, self).__init__(full_msg) + + +class ApiAttributeError(OpenApiException, AttributeError): + def __init__(self, msg, path_to_item=None) -> None: + """ + Raised when an attribute reference or assignment fails. + + Args: + msg (str): the exception message + + Keyword Args: + path_to_item (None/list) the path to the exception in the + received_data dict + """ + self.path_to_item = path_to_item + full_msg = msg + if path_to_item: + full_msg = "{0} at {1}".format(msg, render_path(path_to_item)) + super(ApiAttributeError, self).__init__(full_msg) + + +class ApiKeyError(OpenApiException, KeyError): + def __init__(self, msg, path_to_item=None) -> None: + """ + Args: + msg (str): the exception message + + Keyword Args: + path_to_item (None/list) the path to the exception in the + received_data dict + """ + self.path_to_item = path_to_item + full_msg = msg + if path_to_item: + full_msg = "{0} at {1}".format(msg, render_path(path_to_item)) + super(ApiKeyError, self).__init__(full_msg) + + +class ApiException(OpenApiException): + + def __init__( + self, + status=None, + reason=None, + http_resp=None, + *, + body: Optional[str] = None, + data: Optional[Any] = None, + ) -> None: + self.status = status + self.reason = reason + self.body = body + self.data = data + self.headers = None + + if http_resp: + if self.status is None: + self.status = http_resp.status + if self.reason is None: + self.reason = http_resp.reason + if self.body is None: + try: + self.body = http_resp.data.decode("utf-8") + except Exception: # noqa: S110 + pass + self.headers = http_resp.getheaders() + + @classmethod + def from_response( + cls, + *, + http_resp, + body: Optional[str], + data: Optional[Any], + ) -> Self: + if http_resp.status == 400: + raise BadRequestException(http_resp=http_resp, body=body, data=data) + + if http_resp.status == 401: + raise UnauthorizedException(http_resp=http_resp, body=body, data=data) + + if http_resp.status == 403: + raise ForbiddenException(http_resp=http_resp, body=body, data=data) + + if http_resp.status == 404: + raise NotFoundException(http_resp=http_resp, body=body, data=data) + + if 500 <= http_resp.status <= 599: + raise ServiceException(http_resp=http_resp, body=body, data=data) + raise ApiException(http_resp=http_resp, body=body, data=data) + + def __str__(self): + """Custom error messages for exception""" + error_message = "({0})\n" "Reason: {1}\n".format(self.status, self.reason) + if self.headers: + error_message += "HTTP response headers: {0}\n".format(self.headers) + + if self.data or self.body: + error_message += "HTTP response body: {0}\n".format(self.data or self.body) + + return error_message + + +class BadRequestException(ApiException): + pass + + +class NotFoundException(ApiException): + pass + + +class UnauthorizedException(ApiException): + pass + + +class ForbiddenException(ApiException): + pass + + +class ServiceException(ApiException): + pass + + +def render_path(path_to_item): + """Returns a string representation of a path""" + result = "" + for pth in path_to_item: + if isinstance(pth, int): + result += "[{0}]".format(pth) + else: + result += "['{0}']".format(pth) + return result diff --git a/services/kms/src/stackit/kms/models/__init__.py b/services/kms/src/stackit/kms/models/__init__.py new file mode 100644 index 00000000..0174b5aa --- /dev/null +++ b/services/kms/src/stackit/kms/models/__init__.py @@ -0,0 +1,42 @@ +# coding: utf-8 + +# flake8: noqa +""" + STACKIT Key Management Service API + + This API provides endpoints for managing keys and key rings. + + The version of the OpenAPI document: 1beta.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 docstring might be too long + + +# import models into model package +from stackit.kms.models.algorithm import Algorithm +from stackit.kms.models.backend import Backend +from stackit.kms.models.create_key_payload import CreateKeyPayload +from stackit.kms.models.create_key_ring_payload import CreateKeyRingPayload +from stackit.kms.models.create_wrapping_key_payload import CreateWrappingKeyPayload +from stackit.kms.models.decrypt_payload import DecryptPayload +from stackit.kms.models.decrypted_data import DecryptedData +from stackit.kms.models.encrypt_payload import EncryptPayload +from stackit.kms.models.encrypted_data import EncryptedData +from stackit.kms.models.http_error import HttpError +from stackit.kms.models.import_key_payload import ImportKeyPayload +from stackit.kms.models.key import Key +from stackit.kms.models.key_list import KeyList +from stackit.kms.models.key_ring import KeyRing +from stackit.kms.models.key_ring_list import KeyRingList +from stackit.kms.models.purpose import Purpose +from stackit.kms.models.sign_payload import SignPayload +from stackit.kms.models.signed_data import SignedData +from stackit.kms.models.verified_data import VerifiedData +from stackit.kms.models.verify_payload import VerifyPayload +from stackit.kms.models.version import Version +from stackit.kms.models.version_list import VersionList +from stackit.kms.models.wrapping_algorithm import WrappingAlgorithm +from stackit.kms.models.wrapping_key import WrappingKey +from stackit.kms.models.wrapping_key_list import WrappingKeyList +from stackit.kms.models.wrapping_purpose import WrappingPurpose diff --git a/services/kms/src/stackit/kms/models/algorithm.py b/services/kms/src/stackit/kms/models/algorithm.py new file mode 100644 index 00000000..e4900daf --- /dev/null +++ b/services/kms/src/stackit/kms/models/algorithm.py @@ -0,0 +1,45 @@ +# coding: utf-8 + +""" + STACKIT Key Management Service API + + This API provides endpoints for managing keys and key rings. + + The version of the OpenAPI document: 1beta.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 docstring might be too long + +from __future__ import annotations + +import json +from enum import Enum + +from typing_extensions import Self + + +class Algorithm(str, Enum): + """ + The algorithm the key material uses. + """ + + """ + allowed enum values + """ + AES_256_GCM = "aes_256_gcm" + RSA_2048_OAEP_SHA256 = "rsa_2048_oaep_sha256" + RSA_3072_OAEP_SHA256 = "rsa_3072_oaep_sha256" + RSA_4096_OAEP_SHA256 = "rsa_4096_oaep_sha256" + RSA_4096_OAEP_SHA512 = "rsa_4096_oaep_sha512" + HMAC_SHA256 = "hmac_sha256" + HMAC_SHA384 = "hmac_sha384" + HMAC_SHA512 = "hmac_sha512" + ECDSA_P256_SHA256 = "ecdsa_p256_sha256" + ECDSA_P384_SHA384 = "ecdsa_p384_sha384" + ECDSA_P521_SHA512 = "ecdsa_p521_sha512" + + @classmethod + def from_json(cls, json_str: str) -> Self: + """Create an instance of Algorithm from a JSON string""" + return cls(json.loads(json_str)) diff --git a/services/kms/src/stackit/kms/models/backend.py b/services/kms/src/stackit/kms/models/backend.py new file mode 100644 index 00000000..9e2117e3 --- /dev/null +++ b/services/kms/src/stackit/kms/models/backend.py @@ -0,0 +1,35 @@ +# coding: utf-8 + +""" + STACKIT Key Management Service API + + This API provides endpoints for managing keys and key rings. + + The version of the OpenAPI document: 1beta.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 docstring might be too long + +from __future__ import annotations + +import json +from enum import Enum + +from typing_extensions import Self + + +class Backend(str, Enum): + """ + The backend that is responsible for maintaining this key. + """ + + """ + allowed enum values + """ + SOFTWARE = "software" + + @classmethod + def from_json(cls, json_str: str) -> Self: + """Create an instance of Backend from a JSON string""" + return cls(json.loads(json_str)) diff --git a/services/kms/src/stackit/kms/models/create_key_payload.py b/services/kms/src/stackit/kms/models/create_key_payload.py new file mode 100644 index 00000000..d43a89e4 --- /dev/null +++ b/services/kms/src/stackit/kms/models/create_key_payload.py @@ -0,0 +1,105 @@ +# coding: utf-8 + +""" + STACKIT Key Management Service API + + This API provides endpoints for managing keys and key rings. + + The version of the OpenAPI document: 1beta.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 docstring might be too long + +from __future__ import annotations + +import json +import pprint +from typing import Any, ClassVar, Dict, List, Optional, Set + +from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictStr +from typing_extensions import Annotated, Self + +from stackit.kms.models.algorithm import Algorithm +from stackit.kms.models.backend import Backend +from stackit.kms.models.purpose import Purpose + + +class CreateKeyPayload(BaseModel): + """ + CreateKeyPayload + """ + + algorithm: Algorithm + backend: Backend + description: Optional[StrictStr] = Field( + default=None, description="A user chosen description to distinguish multiple keys." + ) + display_name: Annotated[str, Field(strict=True, max_length=64)] = Field( + description="The display name to distinguish multiple keys.", alias="displayName" + ) + import_only: Optional[StrictBool] = Field( + default=False, description="States whether versions can be created or only imported.", alias="importOnly" + ) + purpose: Purpose + __properties: ClassVar[List[str]] = ["algorithm", "backend", "description", "displayName", "importOnly", "purpose"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of CreateKeyPayload from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of CreateKeyPayload from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "algorithm": obj.get("algorithm"), + "backend": obj.get("backend"), + "description": obj.get("description"), + "displayName": obj.get("displayName"), + "importOnly": obj.get("importOnly") if obj.get("importOnly") is not None else False, + "purpose": obj.get("purpose"), + } + ) + return _obj diff --git a/services/kms/src/stackit/kms/models/create_key_ring_payload.py b/services/kms/src/stackit/kms/models/create_key_ring_payload.py new file mode 100644 index 00000000..943dfc02 --- /dev/null +++ b/services/kms/src/stackit/kms/models/create_key_ring_payload.py @@ -0,0 +1,86 @@ +# coding: utf-8 + +""" + STACKIT Key Management Service API + + This API provides endpoints for managing keys and key rings. + + The version of the OpenAPI document: 1beta.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 docstring might be too long + +from __future__ import annotations + +import json +import pprint +from typing import Any, ClassVar, Dict, List, Optional, Set + +from pydantic import BaseModel, ConfigDict, Field, StrictStr +from typing_extensions import Annotated, Self + + +class CreateKeyRingPayload(BaseModel): + """ + CreateKeyRingPayload + """ + + description: Optional[StrictStr] = Field( + default=None, description="A user chosen description to distinguish multiple key rings." + ) + display_name: Annotated[str, Field(strict=True, max_length=64)] = Field( + description="The display name to distinguish multiple key rings.", alias="displayName" + ) + __properties: ClassVar[List[str]] = ["description", "displayName"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of CreateKeyRingPayload from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of CreateKeyRingPayload from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({"description": obj.get("description"), "displayName": obj.get("displayName")}) + return _obj diff --git a/services/kms/src/stackit/kms/models/create_wrapping_key_payload.py b/services/kms/src/stackit/kms/models/create_wrapping_key_payload.py new file mode 100644 index 00000000..b454775a --- /dev/null +++ b/services/kms/src/stackit/kms/models/create_wrapping_key_payload.py @@ -0,0 +1,101 @@ +# coding: utf-8 + +""" + STACKIT Key Management Service API + + This API provides endpoints for managing keys and key rings. + + The version of the OpenAPI document: 1beta.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 docstring might be too long + +from __future__ import annotations + +import json +import pprint +from typing import Any, ClassVar, Dict, List, Optional, Set + +from pydantic import BaseModel, ConfigDict, Field, StrictStr +from typing_extensions import Annotated, Self + +from stackit.kms.models.backend import Backend +from stackit.kms.models.wrapping_algorithm import WrappingAlgorithm +from stackit.kms.models.wrapping_purpose import WrappingPurpose + + +class CreateWrappingKeyPayload(BaseModel): + """ + CreateWrappingKeyPayload + """ + + algorithm: WrappingAlgorithm + backend: Backend + description: Optional[StrictStr] = Field( + default=None, description="A user chosen description to distinguish multiple wrapping keys." + ) + display_name: Annotated[str, Field(strict=True, max_length=64)] = Field( + description="The display name to distinguish multiple wrapping keys.", alias="displayName" + ) + purpose: WrappingPurpose + __properties: ClassVar[List[str]] = ["algorithm", "backend", "description", "displayName", "purpose"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of CreateWrappingKeyPayload from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of CreateWrappingKeyPayload from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "algorithm": obj.get("algorithm"), + "backend": obj.get("backend"), + "description": obj.get("description"), + "displayName": obj.get("displayName"), + "purpose": obj.get("purpose"), + } + ) + return _obj diff --git a/services/kms/src/stackit/kms/models/decrypt_payload.py b/services/kms/src/stackit/kms/models/decrypt_payload.py new file mode 100644 index 00000000..456205a6 --- /dev/null +++ b/services/kms/src/stackit/kms/models/decrypt_payload.py @@ -0,0 +1,81 @@ +# coding: utf-8 + +""" + STACKIT Key Management Service API + + This API provides endpoints for managing keys and key rings. + + The version of the OpenAPI document: 1beta.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 docstring might be too long + +from __future__ import annotations + +import json +import pprint +from typing import Any, ClassVar, Dict, List, Optional, Set, Union + +from pydantic import BaseModel, ConfigDict, Field, StrictBytes, StrictStr +from typing_extensions import Self + + +class DecryptPayload(BaseModel): + """ + DecryptPayload + """ + + data: Union[StrictBytes, StrictStr] = Field(description="The data that has to be decrypted. Encoded in base64.") + __properties: ClassVar[List[str]] = ["data"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of DecryptPayload from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of DecryptPayload from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({"data": obj.get("data")}) + return _obj diff --git a/services/kms/src/stackit/kms/models/decrypted_data.py b/services/kms/src/stackit/kms/models/decrypted_data.py new file mode 100644 index 00000000..3956ae77 --- /dev/null +++ b/services/kms/src/stackit/kms/models/decrypted_data.py @@ -0,0 +1,81 @@ +# coding: utf-8 + +""" + STACKIT Key Management Service API + + This API provides endpoints for managing keys and key rings. + + The version of the OpenAPI document: 1beta.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 docstring might be too long + +from __future__ import annotations + +import json +import pprint +from typing import Any, ClassVar, Dict, List, Optional, Set, Union + +from pydantic import BaseModel, ConfigDict, Field, StrictBytes, StrictStr +from typing_extensions import Self + + +class DecryptedData(BaseModel): + """ + DecryptedData + """ + + data: Union[StrictBytes, StrictStr] = Field(description="The decrypted data. Encoded in base64.") + __properties: ClassVar[List[str]] = ["data"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of DecryptedData from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of DecryptedData from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({"data": obj.get("data")}) + return _obj diff --git a/services/kms/src/stackit/kms/models/encrypt_payload.py b/services/kms/src/stackit/kms/models/encrypt_payload.py new file mode 100644 index 00000000..38aa91de --- /dev/null +++ b/services/kms/src/stackit/kms/models/encrypt_payload.py @@ -0,0 +1,81 @@ +# coding: utf-8 + +""" + STACKIT Key Management Service API + + This API provides endpoints for managing keys and key rings. + + The version of the OpenAPI document: 1beta.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 docstring might be too long + +from __future__ import annotations + +import json +import pprint +from typing import Any, ClassVar, Dict, List, Optional, Set, Union + +from pydantic import BaseModel, ConfigDict, Field, StrictBytes, StrictStr +from typing_extensions import Self + + +class EncryptPayload(BaseModel): + """ + EncryptPayload + """ + + data: Union[StrictBytes, StrictStr] = Field(description="The data that has to be encrypted. Encoded in base64.") + __properties: ClassVar[List[str]] = ["data"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of EncryptPayload from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of EncryptPayload from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({"data": obj.get("data")}) + return _obj diff --git a/services/kms/src/stackit/kms/models/encrypted_data.py b/services/kms/src/stackit/kms/models/encrypted_data.py new file mode 100644 index 00000000..07ec43e2 --- /dev/null +++ b/services/kms/src/stackit/kms/models/encrypted_data.py @@ -0,0 +1,81 @@ +# coding: utf-8 + +""" + STACKIT Key Management Service API + + This API provides endpoints for managing keys and key rings. + + The version of the OpenAPI document: 1beta.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 docstring might be too long + +from __future__ import annotations + +import json +import pprint +from typing import Any, ClassVar, Dict, List, Optional, Set, Union + +from pydantic import BaseModel, ConfigDict, Field, StrictBytes, StrictStr +from typing_extensions import Self + + +class EncryptedData(BaseModel): + """ + EncryptedData + """ + + data: Union[StrictBytes, StrictStr] = Field(description="The encrypted data. Encoded in base64.") + __properties: ClassVar[List[str]] = ["data"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of EncryptedData from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of EncryptedData from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({"data": obj.get("data")}) + return _obj diff --git a/services/kms/src/stackit/kms/models/http_error.py b/services/kms/src/stackit/kms/models/http_error.py new file mode 100644 index 00000000..491c52dc --- /dev/null +++ b/services/kms/src/stackit/kms/models/http_error.py @@ -0,0 +1,81 @@ +# coding: utf-8 + +""" + STACKIT Key Management Service API + + This API provides endpoints for managing keys and key rings. + + The version of the OpenAPI document: 1beta.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 docstring might be too long + +from __future__ import annotations + +import json +import pprint +from typing import Any, ClassVar, Dict, List, Optional, Set + +from pydantic import BaseModel, ConfigDict, Field, StrictStr +from typing_extensions import Self + + +class HttpError(BaseModel): + """ + HttpError + """ + + message: StrictStr = Field(description="A string that gives a short information about what went wrong.") + __properties: ClassVar[List[str]] = ["message"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of HttpError from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of HttpError from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({"message": obj.get("message")}) + return _obj diff --git a/services/kms/src/stackit/kms/models/import_key_payload.py b/services/kms/src/stackit/kms/models/import_key_payload.py new file mode 100644 index 00000000..81dbd60c --- /dev/null +++ b/services/kms/src/stackit/kms/models/import_key_payload.py @@ -0,0 +1,86 @@ +# coding: utf-8 + +""" + STACKIT Key Management Service API + + This API provides endpoints for managing keys and key rings. + + The version of the OpenAPI document: 1beta.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 docstring might be too long + +from __future__ import annotations + +import json +import pprint +from typing import Any, ClassVar, Dict, List, Optional, Set + +from pydantic import BaseModel, ConfigDict, Field, StrictStr +from typing_extensions import Self + + +class ImportKeyPayload(BaseModel): + """ + ImportKeyPayload + """ + + wrapped_key: StrictStr = Field( + description="The wrapped key material that has to be imported. Encoded in base64.", alias="wrappedKey" + ) + wrapping_key_id: StrictStr = Field( + description="The unique id of the wrapping key the key material has been wrapped with.", alias="wrappingKeyId" + ) + __properties: ClassVar[List[str]] = ["wrappedKey", "wrappingKeyId"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of ImportKeyPayload from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of ImportKeyPayload from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({"wrappedKey": obj.get("wrappedKey"), "wrappingKeyId": obj.get("wrappingKeyId")}) + return _obj diff --git a/services/kms/src/stackit/kms/models/key.py b/services/kms/src/stackit/kms/models/key.py new file mode 100644 index 00000000..105c02a6 --- /dev/null +++ b/services/kms/src/stackit/kms/models/key.py @@ -0,0 +1,150 @@ +# coding: utf-8 + +""" + STACKIT Key Management Service API + + This API provides endpoints for managing keys and key rings. + + The version of the OpenAPI document: 1beta.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 docstring might be too long + +from __future__ import annotations + +import json +import pprint +from datetime import datetime +from typing import Any, ClassVar, Dict, List, Optional, Set + +from pydantic import ( + BaseModel, + ConfigDict, + Field, + StrictBool, + StrictStr, + field_validator, +) +from typing_extensions import Annotated, Self + +from stackit.kms.models.algorithm import Algorithm +from stackit.kms.models.backend import Backend +from stackit.kms.models.purpose import Purpose + + +class Key(BaseModel): + """ + Key + """ + + algorithm: Algorithm + backend: Backend + created_at: datetime = Field( + description="The date and time the creation of the key was triggered.", alias="createdAt" + ) + deletion_date: Optional[datetime] = Field( + default=None, + description="This date is set when a key is pending deletion and refers to the scheduled date of deletion", + alias="deletionDate", + ) + description: Optional[Annotated[str, Field(strict=True, max_length=256)]] = Field( + default=None, description="A user chosen description to distinguish multiple keys." + ) + display_name: Annotated[str, Field(strict=True, max_length=64)] = Field( + description="The display name to distinguish multiple keys.", alias="displayName" + ) + id: StrictStr = Field(description="A auto generated unique id which identifies the keys.") + import_only: Optional[StrictBool] = Field( + default=False, description="States whether versions can be created or only imported.", alias="importOnly" + ) + key_ring_id: StrictStr = Field( + description="The unique id of the key ring this key is assigned to.", alias="keyRingId" + ) + purpose: Purpose + state: StrictStr = Field(description="The current state of the key.") + __properties: ClassVar[List[str]] = [ + "algorithm", + "backend", + "createdAt", + "deletionDate", + "description", + "displayName", + "id", + "importOnly", + "keyRingId", + "purpose", + "state", + ] + + @field_validator("state") + def state_validate_enum(cls, value): + """Validates the enum""" + if value not in set(["active", "version_not_ready", "deleted"]): + raise ValueError("must be one of enum values ('active', 'version_not_ready', 'deleted')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of Key from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of Key from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "algorithm": obj.get("algorithm"), + "backend": obj.get("backend"), + "createdAt": obj.get("createdAt"), + "deletionDate": obj.get("deletionDate"), + "description": obj.get("description"), + "displayName": obj.get("displayName"), + "id": obj.get("id"), + "importOnly": obj.get("importOnly") if obj.get("importOnly") is not None else False, + "keyRingId": obj.get("keyRingId"), + "purpose": obj.get("purpose"), + "state": obj.get("state"), + } + ) + return _obj diff --git a/services/kms/src/stackit/kms/models/key_list.py b/services/kms/src/stackit/kms/models/key_list.py new file mode 100644 index 00000000..094ffd9e --- /dev/null +++ b/services/kms/src/stackit/kms/models/key_list.py @@ -0,0 +1,92 @@ +# coding: utf-8 + +""" + STACKIT Key Management Service API + + This API provides endpoints for managing keys and key rings. + + The version of the OpenAPI document: 1beta.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 docstring might be too long + +from __future__ import annotations + +import json +import pprint +from typing import Any, ClassVar, Dict, List, Optional, Set + +from pydantic import BaseModel, ConfigDict +from typing_extensions import Self + +from stackit.kms.models.key import Key + + +class KeyList(BaseModel): + """ + KeyList + """ + + keys: List[Key] + __properties: ClassVar[List[str]] = ["keys"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of KeyList from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in keys (list) + _items = [] + if self.keys: + for _item in self.keys: + if _item: + _items.append(_item.to_dict()) + _dict["keys"] = _items + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of KeyList from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + {"keys": [Key.from_dict(_item) for _item in obj["keys"]] if obj.get("keys") is not None else None} + ) + return _obj diff --git a/services/kms/src/stackit/kms/models/key_ring.py b/services/kms/src/stackit/kms/models/key_ring.py new file mode 100644 index 00000000..fb87edfb --- /dev/null +++ b/services/kms/src/stackit/kms/models/key_ring.py @@ -0,0 +1,107 @@ +# coding: utf-8 + +""" + STACKIT Key Management Service API + + This API provides endpoints for managing keys and key rings. + + The version of the OpenAPI document: 1beta.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 docstring might be too long + +from __future__ import annotations + +import json +import pprint +from datetime import datetime +from typing import Any, ClassVar, Dict, List, Optional, Set + +from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from typing_extensions import Annotated, Self + + +class KeyRing(BaseModel): + """ + KeyRing + """ + + created_at: datetime = Field( + description="The date and time the creation of the key ring was triggered.", alias="createdAt" + ) + description: Optional[Annotated[str, Field(strict=True, max_length=256)]] = Field( + default=None, description="A user chosen description to distinguish multiple key rings." + ) + display_name: Annotated[str, Field(strict=True, max_length=64)] = Field( + description="The display name to distinguish multiple key rings.", alias="displayName" + ) + id: StrictStr = Field(description="A auto generated unique id which identifies the key ring.") + state: StrictStr = Field(description="The current state of the key ring.") + __properties: ClassVar[List[str]] = ["createdAt", "description", "displayName", "id", "state"] + + @field_validator("state") + def state_validate_enum(cls, value): + """Validates the enum""" + if value not in set(["active", "deleted"]): + raise ValueError("must be one of enum values ('active', 'deleted')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of KeyRing from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of KeyRing from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "createdAt": obj.get("createdAt"), + "description": obj.get("description"), + "displayName": obj.get("displayName"), + "id": obj.get("id"), + "state": obj.get("state"), + } + ) + return _obj diff --git a/services/kms/src/stackit/kms/models/key_ring_list.py b/services/kms/src/stackit/kms/models/key_ring_list.py new file mode 100644 index 00000000..854e24b0 --- /dev/null +++ b/services/kms/src/stackit/kms/models/key_ring_list.py @@ -0,0 +1,96 @@ +# coding: utf-8 + +""" + STACKIT Key Management Service API + + This API provides endpoints for managing keys and key rings. + + The version of the OpenAPI document: 1beta.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 docstring might be too long + +from __future__ import annotations + +import json +import pprint +from typing import Any, ClassVar, Dict, List, Optional, Set + +from pydantic import BaseModel, ConfigDict, Field +from typing_extensions import Self + +from stackit.kms.models.key_ring import KeyRing + + +class KeyRingList(BaseModel): + """ + KeyRingList + """ + + key_rings: List[KeyRing] = Field(alias="keyRings") + __properties: ClassVar[List[str]] = ["keyRings"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of KeyRingList from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in key_rings (list) + _items = [] + if self.key_rings: + for _item in self.key_rings: + if _item: + _items.append(_item.to_dict()) + _dict["keyRings"] = _items + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of KeyRingList from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "keyRings": ( + [KeyRing.from_dict(_item) for _item in obj["keyRings"]] if obj.get("keyRings") is not None else None + ) + } + ) + return _obj diff --git a/services/kms/src/stackit/kms/models/purpose.py b/services/kms/src/stackit/kms/models/purpose.py new file mode 100644 index 00000000..c884ab13 --- /dev/null +++ b/services/kms/src/stackit/kms/models/purpose.py @@ -0,0 +1,38 @@ +# coding: utf-8 + +""" + STACKIT Key Management Service API + + This API provides endpoints for managing keys and key rings. + + The version of the OpenAPI document: 1beta.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 docstring might be too long + +from __future__ import annotations + +import json +from enum import Enum + +from typing_extensions import Self + + +class Purpose(str, Enum): + """ + The purpose of the key. + """ + + """ + allowed enum values + """ + SYMMETRIC_ENCRYPT_DECRYPT = "symmetric_encrypt_decrypt" + ASYMMETRIC_ENCRYPT_DECRYPT = "asymmetric_encrypt_decrypt" + MESSAGE_AUTHENTICATION_CODE = "message_authentication_code" + ASYMMETRIC_SIGN_VERIFY = "asymmetric_sign_verify" + + @classmethod + def from_json(cls, json_str: str) -> Self: + """Create an instance of Purpose from a JSON string""" + return cls(json.loads(json_str)) diff --git a/services/kms/src/stackit/kms/models/sign_payload.py b/services/kms/src/stackit/kms/models/sign_payload.py new file mode 100644 index 00000000..f1d49d0a --- /dev/null +++ b/services/kms/src/stackit/kms/models/sign_payload.py @@ -0,0 +1,81 @@ +# coding: utf-8 + +""" + STACKIT Key Management Service API + + This API provides endpoints for managing keys and key rings. + + The version of the OpenAPI document: 1beta.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 docstring might be too long + +from __future__ import annotations + +import json +import pprint +from typing import Any, ClassVar, Dict, List, Optional, Set, Union + +from pydantic import BaseModel, ConfigDict, Field, StrictBytes, StrictStr +from typing_extensions import Self + + +class SignPayload(BaseModel): + """ + SignPayload + """ + + data: Union[StrictBytes, StrictStr] = Field(description="The data that has to be signed. Encoded in base64.") + __properties: ClassVar[List[str]] = ["data"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of SignPayload from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of SignPayload from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({"data": obj.get("data")}) + return _obj diff --git a/services/kms/src/stackit/kms/models/signed_data.py b/services/kms/src/stackit/kms/models/signed_data.py new file mode 100644 index 00000000..45f67aad --- /dev/null +++ b/services/kms/src/stackit/kms/models/signed_data.py @@ -0,0 +1,82 @@ +# coding: utf-8 + +""" + STACKIT Key Management Service API + + This API provides endpoints for managing keys and key rings. + + The version of the OpenAPI document: 1beta.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 docstring might be too long + +from __future__ import annotations + +import json +import pprint +from typing import Any, ClassVar, Dict, List, Optional, Set, Union + +from pydantic import BaseModel, ConfigDict, Field, StrictBytes, StrictStr +from typing_extensions import Self + + +class SignedData(BaseModel): + """ + SignedData + """ + + data: Union[StrictBytes, StrictStr] = Field(description="The data that was signed. Encoded in base64.") + signature: Union[StrictBytes, StrictStr] = Field(description="The signature of the data. Encoded in base64.") + __properties: ClassVar[List[str]] = ["data", "signature"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of SignedData from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of SignedData from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({"data": obj.get("data"), "signature": obj.get("signature")}) + return _obj diff --git a/services/kms/src/stackit/kms/models/verified_data.py b/services/kms/src/stackit/kms/models/verified_data.py new file mode 100644 index 00000000..a28daa78 --- /dev/null +++ b/services/kms/src/stackit/kms/models/verified_data.py @@ -0,0 +1,81 @@ +# coding: utf-8 + +""" + STACKIT Key Management Service API + + This API provides endpoints for managing keys and key rings. + + The version of the OpenAPI document: 1beta.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 docstring might be too long + +from __future__ import annotations + +import json +import pprint +from typing import Any, ClassVar, Dict, List, Optional, Set + +from pydantic import BaseModel, ConfigDict, Field, StrictBool +from typing_extensions import Self + + +class VerifiedData(BaseModel): + """ + VerifiedData + """ + + valid: StrictBool = Field(description="Whether or not the data has a valid signature.") + __properties: ClassVar[List[str]] = ["valid"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of VerifiedData from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of VerifiedData from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({"valid": obj.get("valid")}) + return _obj diff --git a/services/kms/src/stackit/kms/models/verify_payload.py b/services/kms/src/stackit/kms/models/verify_payload.py new file mode 100644 index 00000000..08b63d62 --- /dev/null +++ b/services/kms/src/stackit/kms/models/verify_payload.py @@ -0,0 +1,82 @@ +# coding: utf-8 + +""" + STACKIT Key Management Service API + + This API provides endpoints for managing keys and key rings. + + The version of the OpenAPI document: 1beta.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 docstring might be too long + +from __future__ import annotations + +import json +import pprint +from typing import Any, ClassVar, Dict, List, Optional, Set, Union + +from pydantic import BaseModel, ConfigDict, Field, StrictBytes, StrictStr +from typing_extensions import Self + + +class VerifyPayload(BaseModel): + """ + VerifyPayload + """ + + data: Union[StrictBytes, StrictStr] = Field(description="The data to be verified. Encoded in base64.") + signature: Union[StrictBytes, StrictStr] = Field(description="The signature of the data. Encoded in base64.") + __properties: ClassVar[List[str]] = ["data", "signature"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of VerifyPayload from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of VerifyPayload from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({"data": obj.get("data"), "signature": obj.get("signature")}) + return _obj diff --git a/services/kms/src/stackit/kms/models/version.py b/services/kms/src/stackit/kms/models/version.py new file mode 100644 index 00000000..57e75eec --- /dev/null +++ b/services/kms/src/stackit/kms/models/version.py @@ -0,0 +1,138 @@ +# coding: utf-8 + +""" + STACKIT Key Management Service API + + This API provides endpoints for managing keys and key rings. + + The version of the OpenAPI document: 1beta.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 docstring might be too long + +from __future__ import annotations + +import json +import pprint +from datetime import datetime +from typing import Any, ClassVar, Dict, List, Optional, Set + +from pydantic import ( + BaseModel, + ConfigDict, + Field, + StrictBool, + StrictInt, + StrictStr, + field_validator, +) +from typing_extensions import Self + + +class Version(BaseModel): + """ + Version + """ + + created_at: datetime = Field( + description="The date and time the creation of the key was triggered.", alias="createdAt" + ) + destroy_date: Optional[datetime] = Field( + default=None, + description="The scheduled date when a version's key material will be erased completely from the backend", + alias="destroyDate", + ) + disabled: Optional[StrictBool] = Field(default=False, description="States whether versions is enabled or disabled.") + key_id: StrictStr = Field(description="The unique id of the key this version is assigned to.", alias="keyId") + key_ring_id: StrictStr = Field( + description="The unique id of the key ring the key of this version is assigned to.", alias="keyRingId" + ) + number: StrictInt = Field(description="A sequential number which identifies the key versions.") + public_key: Optional[StrictStr] = Field( + default=None, + description="The public key of the key version. Only present in asymmetric keys.", + alias="publicKey", + ) + state: StrictStr = Field(description="The current state of the key.") + __properties: ClassVar[List[str]] = [ + "createdAt", + "destroyDate", + "disabled", + "keyId", + "keyRingId", + "number", + "publicKey", + "state", + ] + + @field_validator("state") + def state_validate_enum(cls, value): + """Validates the enum""" + if value not in set(["active", "key_material_not_ready", "key_material_invalid", "disabled", "destroyed"]): + raise ValueError( + "must be one of enum values ('active', 'key_material_not_ready', 'key_material_invalid', 'disabled', 'destroyed')" + ) + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of Version from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of Version from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "createdAt": obj.get("createdAt"), + "destroyDate": obj.get("destroyDate"), + "disabled": obj.get("disabled") if obj.get("disabled") is not None else False, + "keyId": obj.get("keyId"), + "keyRingId": obj.get("keyRingId"), + "number": obj.get("number"), + "publicKey": obj.get("publicKey"), + "state": obj.get("state"), + } + ) + return _obj diff --git a/services/kms/src/stackit/kms/models/version_list.py b/services/kms/src/stackit/kms/models/version_list.py new file mode 100644 index 00000000..2c38db76 --- /dev/null +++ b/services/kms/src/stackit/kms/models/version_list.py @@ -0,0 +1,96 @@ +# coding: utf-8 + +""" + STACKIT Key Management Service API + + This API provides endpoints for managing keys and key rings. + + The version of the OpenAPI document: 1beta.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 docstring might be too long + +from __future__ import annotations + +import json +import pprint +from typing import Any, ClassVar, Dict, List, Optional, Set + +from pydantic import BaseModel, ConfigDict +from typing_extensions import Self + +from stackit.kms.models.version import Version + + +class VersionList(BaseModel): + """ + VersionList + """ + + versions: List[Version] + __properties: ClassVar[List[str]] = ["versions"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of VersionList from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in versions (list) + _items = [] + if self.versions: + for _item in self.versions: + if _item: + _items.append(_item.to_dict()) + _dict["versions"] = _items + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of VersionList from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "versions": ( + [Version.from_dict(_item) for _item in obj["versions"]] if obj.get("versions") is not None else None + ) + } + ) + return _obj diff --git a/services/kms/src/stackit/kms/models/wrapping_algorithm.py b/services/kms/src/stackit/kms/models/wrapping_algorithm.py new file mode 100644 index 00000000..e2581909 --- /dev/null +++ b/services/kms/src/stackit/kms/models/wrapping_algorithm.py @@ -0,0 +1,42 @@ +# coding: utf-8 + +""" + STACKIT Key Management Service API + + This API provides endpoints for managing keys and key rings. + + The version of the OpenAPI document: 1beta.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 docstring might be too long + +from __future__ import annotations + +import json +from enum import Enum + +from typing_extensions import Self + + +class WrappingAlgorithm(str, Enum): + """ + The wrapping algorithm used to wrap the key to import. + """ + + """ + allowed enum values + """ + RSA_2048_OAEP_SHA256 = "rsa_2048_oaep_sha256" + RSA_3072_OAEP_SHA256 = "rsa_3072_oaep_sha256" + RSA_4096_OAEP_SHA256 = "rsa_4096_oaep_sha256" + RSA_4096_OAEP_SHA512 = "rsa_4096_oaep_sha512" + RSA_2048_OAEP_SHA256_AES_256_KEY_WRAP = "rsa_2048_oaep_sha256_aes_256_key_wrap" + RSA_3072_OAEP_SHA256_AES_256_KEY_WRAP = "rsa_3072_oaep_sha256_aes_256_key_wrap" + RSA_4096_OAEP_SHA256_AES_256_KEY_WRAP = "rsa_4096_oaep_sha256_aes_256_key_wrap" + RSA_4096_OAEP_SHA512_AES_256_KEY_WRAP = "rsa_4096_oaep_sha512_aes_256_key_wrap" + + @classmethod + def from_json(cls, json_str: str) -> Self: + """Create an instance of WrappingAlgorithm from a JSON string""" + return cls(json.loads(json_str)) diff --git a/services/kms/src/stackit/kms/models/wrapping_key.py b/services/kms/src/stackit/kms/models/wrapping_key.py new file mode 100644 index 00000000..2da70114 --- /dev/null +++ b/services/kms/src/stackit/kms/models/wrapping_key.py @@ -0,0 +1,139 @@ +# coding: utf-8 + +""" + STACKIT Key Management Service API + + This API provides endpoints for managing keys and key rings. + + The version of the OpenAPI document: 1beta.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 docstring might be too long + +from __future__ import annotations + +import json +import pprint +from datetime import datetime +from typing import Any, ClassVar, Dict, List, Optional, Set + +from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from typing_extensions import Annotated, Self + +from stackit.kms.models.backend import Backend +from stackit.kms.models.wrapping_algorithm import WrappingAlgorithm +from stackit.kms.models.wrapping_purpose import WrappingPurpose + + +class WrappingKey(BaseModel): + """ + WrappingKey + """ + + algorithm: WrappingAlgorithm + backend: Backend + created_at: datetime = Field( + description="The date and time the creation of the wrapping key was triggered.", alias="createdAt" + ) + description: Optional[Annotated[str, Field(strict=True, max_length=256)]] = Field( + default=None, description="A user chosen description to distinguish multiple wrapping keys." + ) + display_name: Annotated[str, Field(strict=True, max_length=64)] = Field( + description="The display name to distinguish multiple wrapping keys.", alias="displayName" + ) + expires_at: datetime = Field(description="The date and time the wrapping key will expire.", alias="expiresAt") + id: StrictStr = Field(description="A auto generated unique id which identifies the wrapping keys.") + key_ring_id: StrictStr = Field( + description="The unique id of the key ring this wrapping key is assigned to.", alias="keyRingId" + ) + public_key: Optional[StrictStr] = Field( + default=None, description="The public key of the wrapping key.", alias="publicKey" + ) + purpose: WrappingPurpose + state: StrictStr = Field(description="The current state of the wrapping key.") + __properties: ClassVar[List[str]] = [ + "algorithm", + "backend", + "createdAt", + "description", + "displayName", + "expiresAt", + "id", + "keyRingId", + "publicKey", + "purpose", + "state", + ] + + @field_validator("state") + def state_validate_enum(cls, value): + """Validates the enum""" + if value not in set(["active", "key_material_not_ready", "expired", "deleting"]): + raise ValueError("must be one of enum values ('active', 'key_material_not_ready', 'expired', 'deleting')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of WrappingKey from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of WrappingKey from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "algorithm": obj.get("algorithm"), + "backend": obj.get("backend"), + "createdAt": obj.get("createdAt"), + "description": obj.get("description"), + "displayName": obj.get("displayName"), + "expiresAt": obj.get("expiresAt"), + "id": obj.get("id"), + "keyRingId": obj.get("keyRingId"), + "publicKey": obj.get("publicKey"), + "purpose": obj.get("purpose"), + "state": obj.get("state"), + } + ) + return _obj diff --git a/services/kms/src/stackit/kms/models/wrapping_key_list.py b/services/kms/src/stackit/kms/models/wrapping_key_list.py new file mode 100644 index 00000000..43c4068f --- /dev/null +++ b/services/kms/src/stackit/kms/models/wrapping_key_list.py @@ -0,0 +1,98 @@ +# coding: utf-8 + +""" + STACKIT Key Management Service API + + This API provides endpoints for managing keys and key rings. + + The version of the OpenAPI document: 1beta.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 docstring might be too long + +from __future__ import annotations + +import json +import pprint +from typing import Any, ClassVar, Dict, List, Optional, Set + +from pydantic import BaseModel, ConfigDict, Field +from typing_extensions import Self + +from stackit.kms.models.wrapping_key import WrappingKey + + +class WrappingKeyList(BaseModel): + """ + WrappingKeyList + """ + + wrapping_keys: List[WrappingKey] = Field(alias="wrappingKeys") + __properties: ClassVar[List[str]] = ["wrappingKeys"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of WrappingKeyList from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in wrapping_keys (list) + _items = [] + if self.wrapping_keys: + for _item in self.wrapping_keys: + if _item: + _items.append(_item.to_dict()) + _dict["wrappingKeys"] = _items + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of WrappingKeyList from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "wrappingKeys": ( + [WrappingKey.from_dict(_item) for _item in obj["wrappingKeys"]] + if obj.get("wrappingKeys") is not None + else None + ) + } + ) + return _obj diff --git a/services/kms/src/stackit/kms/models/wrapping_purpose.py b/services/kms/src/stackit/kms/models/wrapping_purpose.py new file mode 100644 index 00000000..3165f82b --- /dev/null +++ b/services/kms/src/stackit/kms/models/wrapping_purpose.py @@ -0,0 +1,36 @@ +# coding: utf-8 + +""" + STACKIT Key Management Service API + + This API provides endpoints for managing keys and key rings. + + The version of the OpenAPI document: 1beta.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 docstring might be too long + +from __future__ import annotations + +import json +from enum import Enum + +from typing_extensions import Self + + +class WrappingPurpose(str, Enum): + """ + The wrapping purpose for the wrapping key. + """ + + """ + allowed enum values + """ + WRAP_SYMMETRIC_KEY = "wrap_symmetric_key" + WRAP_ASYMMETRIC_KEY = "wrap_asymmetric_key" + + @classmethod + def from_json(cls, json_str: str) -> Self: + """Create an instance of WrappingPurpose from a JSON string""" + return cls(json.loads(json_str)) diff --git a/services/kms/src/stackit/kms/py.typed b/services/kms/src/stackit/kms/py.typed new file mode 100644 index 00000000..e69de29b diff --git a/services/kms/src/stackit/kms/rest.py b/services/kms/src/stackit/kms/rest.py new file mode 100644 index 00000000..c9b3a128 --- /dev/null +++ b/services/kms/src/stackit/kms/rest.py @@ -0,0 +1,148 @@ +# coding: utf-8 + +""" + STACKIT Key Management Service API + + This API provides endpoints for managing keys and key rings. + + The version of the OpenAPI document: 1beta.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 docstring might be too long + +import io +import json +import re + +import requests +from stackit.core.authorization import Authorization +from stackit.core.configuration import Configuration + +from stackit.kms.exceptions import ApiException, ApiValueError + + +RESTResponseType = requests.Response + + +class RESTResponse(io.IOBase): + + def __init__(self, resp) -> None: + self.response = resp + self.status = resp.status_code + self.reason = resp.reason + self.data = None + + def read(self): + if self.data is None: + self.data = self.response.content + return self.data + + def getheaders(self): + """Returns a dictionary of the response headers.""" + return self.response.headers + + def getheader(self, name, default=None): + """Returns a given response header.""" + return self.response.headers.get(name, default) + + +class RESTClientObject: + def __init__(self, config: Configuration) -> None: + self.session = config.custom_http_session if config.custom_http_session else requests.Session() + authorization = Authorization(config) + self.session.auth = authorization.auth_method + + def request(self, method, url, headers=None, body=None, post_params=None, _request_timeout=None): + """Perform requests. + + :param method: http request method + :param url: http request url + :param headers: http request headers + :param body: request json body, for `application/json` + :param post_params: request post parameters, + `application/x-www-form-urlencoded` + and `multipart/form-data` + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + """ + method = method.upper() + if method not in ["GET", "HEAD", "DELETE", "POST", "PUT", "PATCH", "OPTIONS"]: + raise ValueError("Method %s not allowed", method) + + if post_params and body: + raise ApiValueError("body parameter cannot be used with post_params parameter.") + + post_params = post_params or {} + headers = headers or {} + + try: + # For `POST`, `PUT`, `PATCH`, `OPTIONS`, `DELETE` + if method in ["POST", "PUT", "PATCH", "OPTIONS", "DELETE"]: + + # no content type provided or payload is json + content_type = headers.get("Content-Type") + if not content_type or re.search("json", content_type, re.IGNORECASE): + request_body = None + if body is not None: + request_body = json.dumps(body) + r = self.session.request( + method, + url, + data=request_body, + headers=headers, + ) + elif content_type == "application/x-www-form-urlencoded": + r = self.session.request( + method, + url, + params=post_params, + headers=headers, + ) + elif content_type == "multipart/form-data": + # must del headers['Content-Type'], or the correct + # Content-Type which generated by urllib3 will be + # overwritten. + del headers["Content-Type"] + # Ensures that dict objects are serialized + post_params = [(a, json.dumps(b)) if isinstance(b, dict) else (a, b) for a, b in post_params] + r = self.session.request( + method, + url, + files=post_params, + headers=headers, + ) + # Pass a `string` parameter directly in the body to support + # other content types than JSON when `body` argument is + # provided in serialized form. + elif isinstance(body, str) or isinstance(body, bytes): + r = self.session.request( + method, + url, + data=body, + headers=headers, + ) + elif headers["Content-Type"] == "text/plain" and isinstance(body, bool): + request_body = "true" if body else "false" + r = self.session.request(method, url, data=request_body, headers=headers) + else: + # Cannot generate the request from given parameters + msg = """Cannot prepare a request message for provided + arguments. Please check that your arguments match + declared content type.""" + raise ApiException(status=0, reason=msg) + # For `GET`, `HEAD` + else: + r = self.session.request( + method, + url, + params={}, + headers=headers, + ) + except requests.exceptions.SSLError as e: + msg = "\n".join([type(e).__name__, str(e)]) + raise ApiException(status=0, reason=msg) + + return RESTResponse(r)