stackit-kms 0.0.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- stackit/kms/__init__.py +61 -0
- stackit/kms/api/__init__.py +4 -0
- stackit/kms/api/default_api.py +7038 -0
- stackit/kms/api_client.py +626 -0
- stackit/kms/api_response.py +23 -0
- stackit/kms/configuration.py +138 -0
- stackit/kms/exceptions.py +198 -0
- stackit/kms/models/__init__.py +42 -0
- stackit/kms/models/algorithm.py +45 -0
- stackit/kms/models/backend.py +35 -0
- stackit/kms/models/create_key_payload.py +105 -0
- stackit/kms/models/create_key_ring_payload.py +86 -0
- stackit/kms/models/create_wrapping_key_payload.py +101 -0
- stackit/kms/models/decrypt_payload.py +81 -0
- stackit/kms/models/decrypted_data.py +81 -0
- stackit/kms/models/encrypt_payload.py +81 -0
- stackit/kms/models/encrypted_data.py +81 -0
- stackit/kms/models/http_error.py +81 -0
- stackit/kms/models/import_key_payload.py +86 -0
- stackit/kms/models/key.py +150 -0
- stackit/kms/models/key_list.py +92 -0
- stackit/kms/models/key_ring.py +107 -0
- stackit/kms/models/key_ring_list.py +96 -0
- stackit/kms/models/purpose.py +38 -0
- stackit/kms/models/sign_payload.py +81 -0
- stackit/kms/models/signed_data.py +82 -0
- stackit/kms/models/verified_data.py +81 -0
- stackit/kms/models/verify_payload.py +82 -0
- stackit/kms/models/version.py +138 -0
- stackit/kms/models/version_list.py +96 -0
- stackit/kms/models/wrapping_algorithm.py +42 -0
- stackit/kms/models/wrapping_key.py +139 -0
- stackit/kms/models/wrapping_key_list.py +98 -0
- stackit/kms/models/wrapping_purpose.py +36 -0
- stackit/kms/py.typed +0 -0
- stackit/kms/rest.py +148 -0
- stackit_kms-0.0.1.dist-info/LICENSE.md +201 -0
- stackit_kms-0.0.1.dist-info/METADATA +45 -0
- stackit_kms-0.0.1.dist-info/RECORD +40 -0
- stackit_kms-0.0.1.dist-info/WHEEL +4 -0
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
STACKIT Key Management Service API
|
|
5
|
+
|
|
6
|
+
This API provides endpoints for managing keys and key rings.
|
|
7
|
+
|
|
8
|
+
The version of the OpenAPI document: 1beta.0.0
|
|
9
|
+
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
|
10
|
+
|
|
11
|
+
Do not edit the class manually.
|
|
12
|
+
""" # noqa: E501 docstring might be too long
|
|
13
|
+
|
|
14
|
+
import os
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class HostConfiguration:
|
|
18
|
+
def __init__(
|
|
19
|
+
self,
|
|
20
|
+
region=None,
|
|
21
|
+
server_index=None,
|
|
22
|
+
server_variables=None,
|
|
23
|
+
server_operation_index=None,
|
|
24
|
+
server_operation_variables=None,
|
|
25
|
+
ignore_operation_servers=False,
|
|
26
|
+
) -> None:
|
|
27
|
+
print(
|
|
28
|
+
"WARNING: STACKIT will move to a new way of specifying regions, where the region is provided\n",
|
|
29
|
+
"as a function argument instead of being set in the client configuration.\n"
|
|
30
|
+
"Once all services have migrated, the methods to specify the region in the client configuration "
|
|
31
|
+
"will be removed.",
|
|
32
|
+
)
|
|
33
|
+
"""Constructor
|
|
34
|
+
"""
|
|
35
|
+
self._base_path = "https://kms.api.eu01.stackit.cloud"
|
|
36
|
+
"""Default Base url
|
|
37
|
+
"""
|
|
38
|
+
self.server_index = 0 if server_index is None else server_index
|
|
39
|
+
self.server_operation_index = server_operation_index or {}
|
|
40
|
+
"""Default server index
|
|
41
|
+
"""
|
|
42
|
+
self.server_variables = server_variables or {}
|
|
43
|
+
if region:
|
|
44
|
+
self.server_variables["region"] = "{}.".format(region)
|
|
45
|
+
self.server_operation_variables = server_operation_variables or {}
|
|
46
|
+
"""Default server variables
|
|
47
|
+
"""
|
|
48
|
+
self.ignore_operation_servers = ignore_operation_servers
|
|
49
|
+
"""Ignore operation servers
|
|
50
|
+
"""
|
|
51
|
+
|
|
52
|
+
def get_host_settings(self):
|
|
53
|
+
"""Gets an array of host settings
|
|
54
|
+
|
|
55
|
+
:return: An array of host settings
|
|
56
|
+
"""
|
|
57
|
+
return [
|
|
58
|
+
{
|
|
59
|
+
"url": "https://kms.api.{region}stackit.cloud",
|
|
60
|
+
"description": "No description provided",
|
|
61
|
+
"variables": {
|
|
62
|
+
"region": {
|
|
63
|
+
"description": "No description provided",
|
|
64
|
+
"default_value": "eu01.",
|
|
65
|
+
"enum_values": ["eu01."],
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
}
|
|
69
|
+
]
|
|
70
|
+
|
|
71
|
+
def get_host_from_settings(self, index, variables=None, servers=None):
|
|
72
|
+
"""Gets host URL based on the index and variables
|
|
73
|
+
:param index: array index of the host settings
|
|
74
|
+
:param variables: hash of variable and the corresponding value
|
|
75
|
+
:param servers: an array of host settings or None
|
|
76
|
+
:error: if a region is given for a global url
|
|
77
|
+
:return: URL based on host settings
|
|
78
|
+
"""
|
|
79
|
+
if index is None:
|
|
80
|
+
return self._base_path
|
|
81
|
+
|
|
82
|
+
variables = {} if variables is None else variables
|
|
83
|
+
servers = self.get_host_settings() if servers is None else servers
|
|
84
|
+
|
|
85
|
+
try:
|
|
86
|
+
server = servers[index]
|
|
87
|
+
except IndexError:
|
|
88
|
+
raise ValueError(
|
|
89
|
+
"Invalid index {0} when selecting the host settings. "
|
|
90
|
+
"Must be less than {1}".format(index, len(servers))
|
|
91
|
+
)
|
|
92
|
+
|
|
93
|
+
url = server["url"]
|
|
94
|
+
|
|
95
|
+
# check if environment variable was provided for region
|
|
96
|
+
# if nothing was set this is None
|
|
97
|
+
region_env = os.environ.get("STACKIT_REGION")
|
|
98
|
+
|
|
99
|
+
# go through variables and replace placeholders
|
|
100
|
+
for variable_name, variable in server.get("variables", {}).items():
|
|
101
|
+
# If a region is provided by the user for a global url
|
|
102
|
+
# return an error (except for providing via environment variable).
|
|
103
|
+
# The region is provided as a function argument instead of being set in the client configuration.
|
|
104
|
+
if (
|
|
105
|
+
variable_name == "region"
|
|
106
|
+
and (variable["default_value"] == "global" or variable["default_value"] == "")
|
|
107
|
+
and region_env is None
|
|
108
|
+
and variables.get(variable_name) is not None
|
|
109
|
+
):
|
|
110
|
+
raise ValueError(
|
|
111
|
+
"this API does not support setting a region in the the client configuration, "
|
|
112
|
+
"please check if the region can be specified as a function parameter"
|
|
113
|
+
)
|
|
114
|
+
used_value = variables.get(variable_name, variable["default_value"])
|
|
115
|
+
|
|
116
|
+
if "enum_values" in variable and used_value not in variable["enum_values"]:
|
|
117
|
+
given_value = variables[variable_name].replace(".", "")
|
|
118
|
+
valid_values = [v.replace(".", "") for v in variable["enum_values"]]
|
|
119
|
+
raise ValueError(
|
|
120
|
+
"The variable `{0}` in the host URL has invalid value '{1}'. Must be '{2}'.".format(
|
|
121
|
+
variable_name, given_value, valid_values
|
|
122
|
+
)
|
|
123
|
+
)
|
|
124
|
+
|
|
125
|
+
url = url.replace("{" + variable_name + "}", used_value)
|
|
126
|
+
|
|
127
|
+
return url
|
|
128
|
+
|
|
129
|
+
@property
|
|
130
|
+
def host(self):
|
|
131
|
+
"""Return generated host."""
|
|
132
|
+
return self.get_host_from_settings(self.server_index, variables=self.server_variables)
|
|
133
|
+
|
|
134
|
+
@host.setter
|
|
135
|
+
def host(self, value):
|
|
136
|
+
"""Fix base path."""
|
|
137
|
+
self._base_path = value
|
|
138
|
+
self.server_index = None
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
STACKIT Key Management Service API
|
|
5
|
+
|
|
6
|
+
This API provides endpoints for managing keys and key rings.
|
|
7
|
+
|
|
8
|
+
The version of the OpenAPI document: 1beta.0.0
|
|
9
|
+
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
|
10
|
+
|
|
11
|
+
Do not edit the class manually.
|
|
12
|
+
""" # noqa: E501 docstring might be too long
|
|
13
|
+
|
|
14
|
+
from typing import Any, Optional
|
|
15
|
+
|
|
16
|
+
from typing_extensions import Self
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class OpenApiException(Exception):
|
|
20
|
+
"""The base exception class for all OpenAPIExceptions"""
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class ApiTypeError(OpenApiException, TypeError):
|
|
24
|
+
def __init__(self, msg, path_to_item=None, valid_classes=None, key_type=None) -> None:
|
|
25
|
+
"""Raises an exception for TypeErrors
|
|
26
|
+
|
|
27
|
+
Args:
|
|
28
|
+
msg (str): the exception message
|
|
29
|
+
|
|
30
|
+
Keyword Args:
|
|
31
|
+
path_to_item (list): a list of keys an indices to get to the
|
|
32
|
+
current_item
|
|
33
|
+
None if unset
|
|
34
|
+
valid_classes (tuple): the primitive classes that current item
|
|
35
|
+
should be an instance of
|
|
36
|
+
None if unset
|
|
37
|
+
key_type (bool): False if our value is a value in a dict
|
|
38
|
+
True if it is a key in a dict
|
|
39
|
+
False if our item is an item in a list
|
|
40
|
+
None if unset
|
|
41
|
+
"""
|
|
42
|
+
self.path_to_item = path_to_item
|
|
43
|
+
self.valid_classes = valid_classes
|
|
44
|
+
self.key_type = key_type
|
|
45
|
+
full_msg = msg
|
|
46
|
+
if path_to_item:
|
|
47
|
+
full_msg = "{0} at {1}".format(msg, render_path(path_to_item))
|
|
48
|
+
super(ApiTypeError, self).__init__(full_msg)
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
class ApiValueError(OpenApiException, ValueError):
|
|
52
|
+
def __init__(self, msg, path_to_item=None) -> None:
|
|
53
|
+
"""
|
|
54
|
+
Args:
|
|
55
|
+
msg (str): the exception message
|
|
56
|
+
|
|
57
|
+
Keyword Args:
|
|
58
|
+
path_to_item (list) the path to the exception in the
|
|
59
|
+
received_data dict. None if unset
|
|
60
|
+
"""
|
|
61
|
+
|
|
62
|
+
self.path_to_item = path_to_item
|
|
63
|
+
full_msg = msg
|
|
64
|
+
if path_to_item:
|
|
65
|
+
full_msg = "{0} at {1}".format(msg, render_path(path_to_item))
|
|
66
|
+
super(ApiValueError, self).__init__(full_msg)
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
class ApiAttributeError(OpenApiException, AttributeError):
|
|
70
|
+
def __init__(self, msg, path_to_item=None) -> None:
|
|
71
|
+
"""
|
|
72
|
+
Raised when an attribute reference or assignment fails.
|
|
73
|
+
|
|
74
|
+
Args:
|
|
75
|
+
msg (str): the exception message
|
|
76
|
+
|
|
77
|
+
Keyword Args:
|
|
78
|
+
path_to_item (None/list) the path to the exception in the
|
|
79
|
+
received_data dict
|
|
80
|
+
"""
|
|
81
|
+
self.path_to_item = path_to_item
|
|
82
|
+
full_msg = msg
|
|
83
|
+
if path_to_item:
|
|
84
|
+
full_msg = "{0} at {1}".format(msg, render_path(path_to_item))
|
|
85
|
+
super(ApiAttributeError, self).__init__(full_msg)
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
class ApiKeyError(OpenApiException, KeyError):
|
|
89
|
+
def __init__(self, msg, path_to_item=None) -> None:
|
|
90
|
+
"""
|
|
91
|
+
Args:
|
|
92
|
+
msg (str): the exception message
|
|
93
|
+
|
|
94
|
+
Keyword Args:
|
|
95
|
+
path_to_item (None/list) the path to the exception in the
|
|
96
|
+
received_data dict
|
|
97
|
+
"""
|
|
98
|
+
self.path_to_item = path_to_item
|
|
99
|
+
full_msg = msg
|
|
100
|
+
if path_to_item:
|
|
101
|
+
full_msg = "{0} at {1}".format(msg, render_path(path_to_item))
|
|
102
|
+
super(ApiKeyError, self).__init__(full_msg)
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
class ApiException(OpenApiException):
|
|
106
|
+
|
|
107
|
+
def __init__(
|
|
108
|
+
self,
|
|
109
|
+
status=None,
|
|
110
|
+
reason=None,
|
|
111
|
+
http_resp=None,
|
|
112
|
+
*,
|
|
113
|
+
body: Optional[str] = None,
|
|
114
|
+
data: Optional[Any] = None,
|
|
115
|
+
) -> None:
|
|
116
|
+
self.status = status
|
|
117
|
+
self.reason = reason
|
|
118
|
+
self.body = body
|
|
119
|
+
self.data = data
|
|
120
|
+
self.headers = None
|
|
121
|
+
|
|
122
|
+
if http_resp:
|
|
123
|
+
if self.status is None:
|
|
124
|
+
self.status = http_resp.status
|
|
125
|
+
if self.reason is None:
|
|
126
|
+
self.reason = http_resp.reason
|
|
127
|
+
if self.body is None:
|
|
128
|
+
try:
|
|
129
|
+
self.body = http_resp.data.decode("utf-8")
|
|
130
|
+
except Exception: # noqa: S110
|
|
131
|
+
pass
|
|
132
|
+
self.headers = http_resp.getheaders()
|
|
133
|
+
|
|
134
|
+
@classmethod
|
|
135
|
+
def from_response(
|
|
136
|
+
cls,
|
|
137
|
+
*,
|
|
138
|
+
http_resp,
|
|
139
|
+
body: Optional[str],
|
|
140
|
+
data: Optional[Any],
|
|
141
|
+
) -> Self:
|
|
142
|
+
if http_resp.status == 400:
|
|
143
|
+
raise BadRequestException(http_resp=http_resp, body=body, data=data)
|
|
144
|
+
|
|
145
|
+
if http_resp.status == 401:
|
|
146
|
+
raise UnauthorizedException(http_resp=http_resp, body=body, data=data)
|
|
147
|
+
|
|
148
|
+
if http_resp.status == 403:
|
|
149
|
+
raise ForbiddenException(http_resp=http_resp, body=body, data=data)
|
|
150
|
+
|
|
151
|
+
if http_resp.status == 404:
|
|
152
|
+
raise NotFoundException(http_resp=http_resp, body=body, data=data)
|
|
153
|
+
|
|
154
|
+
if 500 <= http_resp.status <= 599:
|
|
155
|
+
raise ServiceException(http_resp=http_resp, body=body, data=data)
|
|
156
|
+
raise ApiException(http_resp=http_resp, body=body, data=data)
|
|
157
|
+
|
|
158
|
+
def __str__(self):
|
|
159
|
+
"""Custom error messages for exception"""
|
|
160
|
+
error_message = "({0})\n" "Reason: {1}\n".format(self.status, self.reason)
|
|
161
|
+
if self.headers:
|
|
162
|
+
error_message += "HTTP response headers: {0}\n".format(self.headers)
|
|
163
|
+
|
|
164
|
+
if self.data or self.body:
|
|
165
|
+
error_message += "HTTP response body: {0}\n".format(self.data or self.body)
|
|
166
|
+
|
|
167
|
+
return error_message
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
class BadRequestException(ApiException):
|
|
171
|
+
pass
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
class NotFoundException(ApiException):
|
|
175
|
+
pass
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
class UnauthorizedException(ApiException):
|
|
179
|
+
pass
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
class ForbiddenException(ApiException):
|
|
183
|
+
pass
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
class ServiceException(ApiException):
|
|
187
|
+
pass
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
def render_path(path_to_item):
|
|
191
|
+
"""Returns a string representation of a path"""
|
|
192
|
+
result = ""
|
|
193
|
+
for pth in path_to_item:
|
|
194
|
+
if isinstance(pth, int):
|
|
195
|
+
result += "[{0}]".format(pth)
|
|
196
|
+
else:
|
|
197
|
+
result += "['{0}']".format(pth)
|
|
198
|
+
return result
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
# flake8: noqa
|
|
4
|
+
"""
|
|
5
|
+
STACKIT Key Management Service API
|
|
6
|
+
|
|
7
|
+
This API provides endpoints for managing keys and key rings.
|
|
8
|
+
|
|
9
|
+
The version of the OpenAPI document: 1beta.0.0
|
|
10
|
+
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
|
11
|
+
|
|
12
|
+
Do not edit the class manually.
|
|
13
|
+
""" # noqa: E501 docstring might be too long
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
# import models into model package
|
|
17
|
+
from stackit.kms.models.algorithm import Algorithm
|
|
18
|
+
from stackit.kms.models.backend import Backend
|
|
19
|
+
from stackit.kms.models.create_key_payload import CreateKeyPayload
|
|
20
|
+
from stackit.kms.models.create_key_ring_payload import CreateKeyRingPayload
|
|
21
|
+
from stackit.kms.models.create_wrapping_key_payload import CreateWrappingKeyPayload
|
|
22
|
+
from stackit.kms.models.decrypt_payload import DecryptPayload
|
|
23
|
+
from stackit.kms.models.decrypted_data import DecryptedData
|
|
24
|
+
from stackit.kms.models.encrypt_payload import EncryptPayload
|
|
25
|
+
from stackit.kms.models.encrypted_data import EncryptedData
|
|
26
|
+
from stackit.kms.models.http_error import HttpError
|
|
27
|
+
from stackit.kms.models.import_key_payload import ImportKeyPayload
|
|
28
|
+
from stackit.kms.models.key import Key
|
|
29
|
+
from stackit.kms.models.key_list import KeyList
|
|
30
|
+
from stackit.kms.models.key_ring import KeyRing
|
|
31
|
+
from stackit.kms.models.key_ring_list import KeyRingList
|
|
32
|
+
from stackit.kms.models.purpose import Purpose
|
|
33
|
+
from stackit.kms.models.sign_payload import SignPayload
|
|
34
|
+
from stackit.kms.models.signed_data import SignedData
|
|
35
|
+
from stackit.kms.models.verified_data import VerifiedData
|
|
36
|
+
from stackit.kms.models.verify_payload import VerifyPayload
|
|
37
|
+
from stackit.kms.models.version import Version
|
|
38
|
+
from stackit.kms.models.version_list import VersionList
|
|
39
|
+
from stackit.kms.models.wrapping_algorithm import WrappingAlgorithm
|
|
40
|
+
from stackit.kms.models.wrapping_key import WrappingKey
|
|
41
|
+
from stackit.kms.models.wrapping_key_list import WrappingKeyList
|
|
42
|
+
from stackit.kms.models.wrapping_purpose import WrappingPurpose
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
STACKIT Key Management Service API
|
|
5
|
+
|
|
6
|
+
This API provides endpoints for managing keys and key rings.
|
|
7
|
+
|
|
8
|
+
The version of the OpenAPI document: 1beta.0.0
|
|
9
|
+
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
|
10
|
+
|
|
11
|
+
Do not edit the class manually.
|
|
12
|
+
""" # noqa: E501 docstring might be too long
|
|
13
|
+
|
|
14
|
+
from __future__ import annotations
|
|
15
|
+
|
|
16
|
+
import json
|
|
17
|
+
from enum import Enum
|
|
18
|
+
|
|
19
|
+
from typing_extensions import Self
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class Algorithm(str, Enum):
|
|
23
|
+
"""
|
|
24
|
+
The algorithm the key material uses.
|
|
25
|
+
"""
|
|
26
|
+
|
|
27
|
+
"""
|
|
28
|
+
allowed enum values
|
|
29
|
+
"""
|
|
30
|
+
AES_256_GCM = "aes_256_gcm"
|
|
31
|
+
RSA_2048_OAEP_SHA256 = "rsa_2048_oaep_sha256"
|
|
32
|
+
RSA_3072_OAEP_SHA256 = "rsa_3072_oaep_sha256"
|
|
33
|
+
RSA_4096_OAEP_SHA256 = "rsa_4096_oaep_sha256"
|
|
34
|
+
RSA_4096_OAEP_SHA512 = "rsa_4096_oaep_sha512"
|
|
35
|
+
HMAC_SHA256 = "hmac_sha256"
|
|
36
|
+
HMAC_SHA384 = "hmac_sha384"
|
|
37
|
+
HMAC_SHA512 = "hmac_sha512"
|
|
38
|
+
ECDSA_P256_SHA256 = "ecdsa_p256_sha256"
|
|
39
|
+
ECDSA_P384_SHA384 = "ecdsa_p384_sha384"
|
|
40
|
+
ECDSA_P521_SHA512 = "ecdsa_p521_sha512"
|
|
41
|
+
|
|
42
|
+
@classmethod
|
|
43
|
+
def from_json(cls, json_str: str) -> Self:
|
|
44
|
+
"""Create an instance of Algorithm from a JSON string"""
|
|
45
|
+
return cls(json.loads(json_str))
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
STACKIT Key Management Service API
|
|
5
|
+
|
|
6
|
+
This API provides endpoints for managing keys and key rings.
|
|
7
|
+
|
|
8
|
+
The version of the OpenAPI document: 1beta.0.0
|
|
9
|
+
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
|
10
|
+
|
|
11
|
+
Do not edit the class manually.
|
|
12
|
+
""" # noqa: E501 docstring might be too long
|
|
13
|
+
|
|
14
|
+
from __future__ import annotations
|
|
15
|
+
|
|
16
|
+
import json
|
|
17
|
+
from enum import Enum
|
|
18
|
+
|
|
19
|
+
from typing_extensions import Self
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class Backend(str, Enum):
|
|
23
|
+
"""
|
|
24
|
+
The backend that is responsible for maintaining this key.
|
|
25
|
+
"""
|
|
26
|
+
|
|
27
|
+
"""
|
|
28
|
+
allowed enum values
|
|
29
|
+
"""
|
|
30
|
+
SOFTWARE = "software"
|
|
31
|
+
|
|
32
|
+
@classmethod
|
|
33
|
+
def from_json(cls, json_str: str) -> Self:
|
|
34
|
+
"""Create an instance of Backend from a JSON string"""
|
|
35
|
+
return cls(json.loads(json_str))
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
STACKIT Key Management Service API
|
|
5
|
+
|
|
6
|
+
This API provides endpoints for managing keys and key rings.
|
|
7
|
+
|
|
8
|
+
The version of the OpenAPI document: 1beta.0.0
|
|
9
|
+
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
|
10
|
+
|
|
11
|
+
Do not edit the class manually.
|
|
12
|
+
""" # noqa: E501 docstring might be too long
|
|
13
|
+
|
|
14
|
+
from __future__ import annotations
|
|
15
|
+
|
|
16
|
+
import json
|
|
17
|
+
import pprint
|
|
18
|
+
from typing import Any, ClassVar, Dict, List, Optional, Set
|
|
19
|
+
|
|
20
|
+
from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictStr
|
|
21
|
+
from typing_extensions import Annotated, Self
|
|
22
|
+
|
|
23
|
+
from stackit.kms.models.algorithm import Algorithm
|
|
24
|
+
from stackit.kms.models.backend import Backend
|
|
25
|
+
from stackit.kms.models.purpose import Purpose
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class CreateKeyPayload(BaseModel):
|
|
29
|
+
"""
|
|
30
|
+
CreateKeyPayload
|
|
31
|
+
"""
|
|
32
|
+
|
|
33
|
+
algorithm: Algorithm
|
|
34
|
+
backend: Backend
|
|
35
|
+
description: Optional[StrictStr] = Field(
|
|
36
|
+
default=None, description="A user chosen description to distinguish multiple keys."
|
|
37
|
+
)
|
|
38
|
+
display_name: Annotated[str, Field(strict=True, max_length=64)] = Field(
|
|
39
|
+
description="The display name to distinguish multiple keys.", alias="displayName"
|
|
40
|
+
)
|
|
41
|
+
import_only: Optional[StrictBool] = Field(
|
|
42
|
+
default=False, description="States whether versions can be created or only imported.", alias="importOnly"
|
|
43
|
+
)
|
|
44
|
+
purpose: Purpose
|
|
45
|
+
__properties: ClassVar[List[str]] = ["algorithm", "backend", "description", "displayName", "importOnly", "purpose"]
|
|
46
|
+
|
|
47
|
+
model_config = ConfigDict(
|
|
48
|
+
populate_by_name=True,
|
|
49
|
+
validate_assignment=True,
|
|
50
|
+
protected_namespaces=(),
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
def to_str(self) -> str:
|
|
54
|
+
"""Returns the string representation of the model using alias"""
|
|
55
|
+
return pprint.pformat(self.model_dump(by_alias=True))
|
|
56
|
+
|
|
57
|
+
def to_json(self) -> str:
|
|
58
|
+
"""Returns the JSON representation of the model using alias"""
|
|
59
|
+
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
|
|
60
|
+
return json.dumps(self.to_dict())
|
|
61
|
+
|
|
62
|
+
@classmethod
|
|
63
|
+
def from_json(cls, json_str: str) -> Optional[Self]:
|
|
64
|
+
"""Create an instance of CreateKeyPayload from a JSON string"""
|
|
65
|
+
return cls.from_dict(json.loads(json_str))
|
|
66
|
+
|
|
67
|
+
def to_dict(self) -> Dict[str, Any]:
|
|
68
|
+
"""Return the dictionary representation of the model using alias.
|
|
69
|
+
|
|
70
|
+
This has the following differences from calling pydantic's
|
|
71
|
+
`self.model_dump(by_alias=True)`:
|
|
72
|
+
|
|
73
|
+
* `None` is only added to the output dict for nullable fields that
|
|
74
|
+
were set at model initialization. Other fields with value `None`
|
|
75
|
+
are ignored.
|
|
76
|
+
"""
|
|
77
|
+
excluded_fields: Set[str] = set([])
|
|
78
|
+
|
|
79
|
+
_dict = self.model_dump(
|
|
80
|
+
by_alias=True,
|
|
81
|
+
exclude=excluded_fields,
|
|
82
|
+
exclude_none=True,
|
|
83
|
+
)
|
|
84
|
+
return _dict
|
|
85
|
+
|
|
86
|
+
@classmethod
|
|
87
|
+
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
|
88
|
+
"""Create an instance of CreateKeyPayload from a dict"""
|
|
89
|
+
if obj is None:
|
|
90
|
+
return None
|
|
91
|
+
|
|
92
|
+
if not isinstance(obj, dict):
|
|
93
|
+
return cls.model_validate(obj)
|
|
94
|
+
|
|
95
|
+
_obj = cls.model_validate(
|
|
96
|
+
{
|
|
97
|
+
"algorithm": obj.get("algorithm"),
|
|
98
|
+
"backend": obj.get("backend"),
|
|
99
|
+
"description": obj.get("description"),
|
|
100
|
+
"displayName": obj.get("displayName"),
|
|
101
|
+
"importOnly": obj.get("importOnly") if obj.get("importOnly") is not None else False,
|
|
102
|
+
"purpose": obj.get("purpose"),
|
|
103
|
+
}
|
|
104
|
+
)
|
|
105
|
+
return _obj
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
STACKIT Key Management Service API
|
|
5
|
+
|
|
6
|
+
This API provides endpoints for managing keys and key rings.
|
|
7
|
+
|
|
8
|
+
The version of the OpenAPI document: 1beta.0.0
|
|
9
|
+
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
|
10
|
+
|
|
11
|
+
Do not edit the class manually.
|
|
12
|
+
""" # noqa: E501 docstring might be too long
|
|
13
|
+
|
|
14
|
+
from __future__ import annotations
|
|
15
|
+
|
|
16
|
+
import json
|
|
17
|
+
import pprint
|
|
18
|
+
from typing import Any, ClassVar, Dict, List, Optional, Set
|
|
19
|
+
|
|
20
|
+
from pydantic import BaseModel, ConfigDict, Field, StrictStr
|
|
21
|
+
from typing_extensions import Annotated, Self
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class CreateKeyRingPayload(BaseModel):
|
|
25
|
+
"""
|
|
26
|
+
CreateKeyRingPayload
|
|
27
|
+
"""
|
|
28
|
+
|
|
29
|
+
description: Optional[StrictStr] = Field(
|
|
30
|
+
default=None, description="A user chosen description to distinguish multiple key rings."
|
|
31
|
+
)
|
|
32
|
+
display_name: Annotated[str, Field(strict=True, max_length=64)] = Field(
|
|
33
|
+
description="The display name to distinguish multiple key rings.", alias="displayName"
|
|
34
|
+
)
|
|
35
|
+
__properties: ClassVar[List[str]] = ["description", "displayName"]
|
|
36
|
+
|
|
37
|
+
model_config = ConfigDict(
|
|
38
|
+
populate_by_name=True,
|
|
39
|
+
validate_assignment=True,
|
|
40
|
+
protected_namespaces=(),
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
def to_str(self) -> str:
|
|
44
|
+
"""Returns the string representation of the model using alias"""
|
|
45
|
+
return pprint.pformat(self.model_dump(by_alias=True))
|
|
46
|
+
|
|
47
|
+
def to_json(self) -> str:
|
|
48
|
+
"""Returns the JSON representation of the model using alias"""
|
|
49
|
+
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
|
|
50
|
+
return json.dumps(self.to_dict())
|
|
51
|
+
|
|
52
|
+
@classmethod
|
|
53
|
+
def from_json(cls, json_str: str) -> Optional[Self]:
|
|
54
|
+
"""Create an instance of CreateKeyRingPayload from a JSON string"""
|
|
55
|
+
return cls.from_dict(json.loads(json_str))
|
|
56
|
+
|
|
57
|
+
def to_dict(self) -> Dict[str, Any]:
|
|
58
|
+
"""Return the dictionary representation of the model using alias.
|
|
59
|
+
|
|
60
|
+
This has the following differences from calling pydantic's
|
|
61
|
+
`self.model_dump(by_alias=True)`:
|
|
62
|
+
|
|
63
|
+
* `None` is only added to the output dict for nullable fields that
|
|
64
|
+
were set at model initialization. Other fields with value `None`
|
|
65
|
+
are ignored.
|
|
66
|
+
"""
|
|
67
|
+
excluded_fields: Set[str] = set([])
|
|
68
|
+
|
|
69
|
+
_dict = self.model_dump(
|
|
70
|
+
by_alias=True,
|
|
71
|
+
exclude=excluded_fields,
|
|
72
|
+
exclude_none=True,
|
|
73
|
+
)
|
|
74
|
+
return _dict
|
|
75
|
+
|
|
76
|
+
@classmethod
|
|
77
|
+
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
|
78
|
+
"""Create an instance of CreateKeyRingPayload from a dict"""
|
|
79
|
+
if obj is None:
|
|
80
|
+
return None
|
|
81
|
+
|
|
82
|
+
if not isinstance(obj, dict):
|
|
83
|
+
return cls.model_validate(obj)
|
|
84
|
+
|
|
85
|
+
_obj = cls.model_validate({"description": obj.get("description"), "displayName": obj.get("displayName")})
|
|
86
|
+
return _obj
|