stackit-secretsmanager 0.0.1a0__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.
@@ -0,0 +1,111 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ STACKIT Secrets Manager API
5
+
6
+ This API provides endpoints for managing the Secrets-Manager.
7
+
8
+ The version of the OpenAPI document: 1.4.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
+
15
+ class HostConfiguration:
16
+ def __init__(
17
+ self,
18
+ region=None,
19
+ server_index=None,
20
+ server_variables=None,
21
+ server_operation_index=None,
22
+ server_operation_variables=None,
23
+ ignore_operation_servers=False,
24
+ ) -> None:
25
+ """Constructor"""
26
+ self._base_path = "https://secrets-manager.api.eu01.stackit.cloud"
27
+ """Default Base url
28
+ """
29
+ self.server_index = 0 if server_index is None else server_index
30
+ self.server_operation_index = server_operation_index or {}
31
+ """Default server index
32
+ """
33
+ self.server_variables = server_variables or {}
34
+ if region:
35
+ self.server_variables["region"] = "{}.".format(region)
36
+ self.server_operation_variables = server_operation_variables or {}
37
+ """Default server variables
38
+ """
39
+ self.ignore_operation_servers = ignore_operation_servers
40
+ """Ignore operation servers
41
+ """
42
+
43
+ def get_host_settings(self):
44
+ """Gets an array of host settings
45
+
46
+ :return: An array of host settings
47
+ """
48
+ return [
49
+ {
50
+ "url": "https://secrets-manager.api.{region}stackit.cloud",
51
+ "description": "No description provided",
52
+ "variables": {
53
+ "region": {
54
+ "description": "No description provided",
55
+ "default_value": "eu01.",
56
+ "enum_values": ["eu01."],
57
+ }
58
+ },
59
+ }
60
+ ]
61
+
62
+ def get_host_from_settings(self, index, variables=None, servers=None):
63
+ """Gets host URL based on the index and variables
64
+ :param index: array index of the host settings
65
+ :param variables: hash of variable and the corresponding value
66
+ :param servers: an array of host settings or None
67
+ :return: URL based on host settings
68
+ """
69
+ if index is None:
70
+ return self._base_path
71
+
72
+ variables = {} if variables is None else variables
73
+ servers = self.get_host_settings() if servers is None else servers
74
+
75
+ try:
76
+ server = servers[index]
77
+ except IndexError:
78
+ raise ValueError(
79
+ "Invalid index {0} when selecting the host settings. "
80
+ "Must be less than {1}".format(index, len(servers))
81
+ )
82
+
83
+ url = server["url"]
84
+
85
+ # go through variables and replace placeholders
86
+ for variable_name, variable in server.get("variables", {}).items():
87
+ used_value = variables.get(variable_name, variable["default_value"])
88
+
89
+ if "enum_values" in variable and used_value not in variable["enum_values"]:
90
+ given_value = variables[variable_name].replace(".", "")
91
+ valid_values = [v.replace(".", "") for v in variable["enum_values"]]
92
+ raise ValueError(
93
+ "The variable `{0}` in the host URL has invalid value '{1}'. Must be '{2}'.".format(
94
+ variable_name, given_value, valid_values
95
+ )
96
+ )
97
+
98
+ url = url.replace("{" + variable_name + "}", used_value)
99
+
100
+ return url
101
+
102
+ @property
103
+ def host(self):
104
+ """Return generated host."""
105
+ return self.get_host_from_settings(self.server_index, variables=self.server_variables)
106
+
107
+ @host.setter
108
+ def host(self, value):
109
+ """Fix base path."""
110
+ self._base_path = value
111
+ self.server_index = None
@@ -0,0 +1,198 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ STACKIT Secrets Manager API
5
+
6
+ This API provides endpoints for managing the Secrets-Manager.
7
+
8
+ The version of the OpenAPI document: 1.4.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,29 @@
1
+ # coding: utf-8
2
+
3
+ # flake8: noqa
4
+ """
5
+ STACKIT Secrets Manager API
6
+
7
+ This API provides endpoints for managing the Secrets-Manager.
8
+
9
+ The version of the OpenAPI document: 1.4.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.secretsmanager.models.acl import ACL
18
+ from stackit.secretsmanager.models.create_acl_payload import CreateACLPayload
19
+ from stackit.secretsmanager.models.create_instance_payload import CreateInstancePayload
20
+ from stackit.secretsmanager.models.create_user_payload import CreateUserPayload
21
+ from stackit.secretsmanager.models.instance import Instance
22
+ from stackit.secretsmanager.models.list_acls_response import ListACLsResponse
23
+ from stackit.secretsmanager.models.list_instances_response import ListInstancesResponse
24
+ from stackit.secretsmanager.models.list_users_response import ListUsersResponse
25
+ from stackit.secretsmanager.models.update_acl_payload import UpdateACLPayload
26
+ from stackit.secretsmanager.models.update_acls_payload import UpdateACLsPayload
27
+ from stackit.secretsmanager.models.update_instance_payload import UpdateInstancePayload
28
+ from stackit.secretsmanager.models.update_user_payload import UpdateUserPayload
29
+ from stackit.secretsmanager.models.user import User
@@ -0,0 +1,82 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ STACKIT Secrets Manager API
5
+
6
+ This API provides endpoints for managing the Secrets-Manager.
7
+
8
+ The version of the OpenAPI document: 1.4.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 Self
22
+
23
+
24
+ class ACL(BaseModel):
25
+ """
26
+ ACL
27
+ """
28
+
29
+ cidr: StrictStr = Field(description="The given IP/IP Range that is permitted to access.")
30
+ id: StrictStr = Field(description="A auto generated unique id which identifies the acl.")
31
+ __properties: ClassVar[List[str]] = ["cidr", "id"]
32
+
33
+ model_config = ConfigDict(
34
+ populate_by_name=True,
35
+ validate_assignment=True,
36
+ protected_namespaces=(),
37
+ )
38
+
39
+ def to_str(self) -> str:
40
+ """Returns the string representation of the model using alias"""
41
+ return pprint.pformat(self.model_dump(by_alias=True))
42
+
43
+ def to_json(self) -> str:
44
+ """Returns the JSON representation of the model using alias"""
45
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
46
+ return json.dumps(self.to_dict())
47
+
48
+ @classmethod
49
+ def from_json(cls, json_str: str) -> Optional[Self]:
50
+ """Create an instance of ACL from a JSON string"""
51
+ return cls.from_dict(json.loads(json_str))
52
+
53
+ def to_dict(self) -> Dict[str, Any]:
54
+ """Return the dictionary representation of the model using alias.
55
+
56
+ This has the following differences from calling pydantic's
57
+ `self.model_dump(by_alias=True)`:
58
+
59
+ * `None` is only added to the output dict for nullable fields that
60
+ were set at model initialization. Other fields with value `None`
61
+ are ignored.
62
+ """
63
+ excluded_fields: Set[str] = set([])
64
+
65
+ _dict = self.model_dump(
66
+ by_alias=True,
67
+ exclude=excluded_fields,
68
+ exclude_none=True,
69
+ )
70
+ return _dict
71
+
72
+ @classmethod
73
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
74
+ """Create an instance of ACL from a dict"""
75
+ if obj is None:
76
+ return None
77
+
78
+ if not isinstance(obj, dict):
79
+ return cls.model_validate(obj)
80
+
81
+ _obj = cls.model_validate({"cidr": obj.get("cidr"), "id": obj.get("id")})
82
+ return _obj
@@ -0,0 +1,81 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ STACKIT Secrets Manager API
5
+
6
+ This API provides endpoints for managing the Secrets-Manager.
7
+
8
+ The version of the OpenAPI document: 1.4.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 Self
22
+
23
+
24
+ class CreateACLPayload(BaseModel):
25
+ """
26
+ CreateACLPayload
27
+ """
28
+
29
+ cidr: StrictStr = Field(description="The given IP/IP Range that is permitted to access.")
30
+ __properties: ClassVar[List[str]] = ["cidr"]
31
+
32
+ model_config = ConfigDict(
33
+ populate_by_name=True,
34
+ validate_assignment=True,
35
+ protected_namespaces=(),
36
+ )
37
+
38
+ def to_str(self) -> str:
39
+ """Returns the string representation of the model using alias"""
40
+ return pprint.pformat(self.model_dump(by_alias=True))
41
+
42
+ def to_json(self) -> str:
43
+ """Returns the JSON representation of the model using alias"""
44
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
45
+ return json.dumps(self.to_dict())
46
+
47
+ @classmethod
48
+ def from_json(cls, json_str: str) -> Optional[Self]:
49
+ """Create an instance of CreateACLPayload from a JSON string"""
50
+ return cls.from_dict(json.loads(json_str))
51
+
52
+ def to_dict(self) -> Dict[str, Any]:
53
+ """Return the dictionary representation of the model using alias.
54
+
55
+ This has the following differences from calling pydantic's
56
+ `self.model_dump(by_alias=True)`:
57
+
58
+ * `None` is only added to the output dict for nullable fields that
59
+ were set at model initialization. Other fields with value `None`
60
+ are ignored.
61
+ """
62
+ excluded_fields: Set[str] = set([])
63
+
64
+ _dict = self.model_dump(
65
+ by_alias=True,
66
+ exclude=excluded_fields,
67
+ exclude_none=True,
68
+ )
69
+ return _dict
70
+
71
+ @classmethod
72
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
73
+ """Create an instance of CreateACLPayload from a dict"""
74
+ if obj is None:
75
+ return None
76
+
77
+ if not isinstance(obj, dict):
78
+ return cls.model_validate(obj)
79
+
80
+ _obj = cls.model_validate({"cidr": obj.get("cidr")})
81
+ return _obj
@@ -0,0 +1,81 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ STACKIT Secrets Manager API
5
+
6
+ This API provides endpoints for managing the Secrets-Manager.
7
+
8
+ The version of the OpenAPI document: 1.4.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 Self
22
+
23
+
24
+ class CreateInstancePayload(BaseModel):
25
+ """
26
+ CreateInstancePayload
27
+ """
28
+
29
+ name: StrictStr = Field(description="A user chosen name to distinguish multiple secrets manager instances.")
30
+ __properties: ClassVar[List[str]] = ["name"]
31
+
32
+ model_config = ConfigDict(
33
+ populate_by_name=True,
34
+ validate_assignment=True,
35
+ protected_namespaces=(),
36
+ )
37
+
38
+ def to_str(self) -> str:
39
+ """Returns the string representation of the model using alias"""
40
+ return pprint.pformat(self.model_dump(by_alias=True))
41
+
42
+ def to_json(self) -> str:
43
+ """Returns the JSON representation of the model using alias"""
44
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
45
+ return json.dumps(self.to_dict())
46
+
47
+ @classmethod
48
+ def from_json(cls, json_str: str) -> Optional[Self]:
49
+ """Create an instance of CreateInstancePayload from a JSON string"""
50
+ return cls.from_dict(json.loads(json_str))
51
+
52
+ def to_dict(self) -> Dict[str, Any]:
53
+ """Return the dictionary representation of the model using alias.
54
+
55
+ This has the following differences from calling pydantic's
56
+ `self.model_dump(by_alias=True)`:
57
+
58
+ * `None` is only added to the output dict for nullable fields that
59
+ were set at model initialization. Other fields with value `None`
60
+ are ignored.
61
+ """
62
+ excluded_fields: Set[str] = set([])
63
+
64
+ _dict = self.model_dump(
65
+ by_alias=True,
66
+ exclude=excluded_fields,
67
+ exclude_none=True,
68
+ )
69
+ return _dict
70
+
71
+ @classmethod
72
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
73
+ """Create an instance of CreateInstancePayload from a dict"""
74
+ if obj is None:
75
+ return None
76
+
77
+ if not isinstance(obj, dict):
78
+ return cls.model_validate(obj)
79
+
80
+ _obj = cls.model_validate({"name": obj.get("name")})
81
+ return _obj
@@ -0,0 +1,84 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ STACKIT Secrets Manager API
5
+
6
+ This API provides endpoints for managing the Secrets-Manager.
7
+
8
+ The version of the OpenAPI document: 1.4.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 Self
22
+
23
+
24
+ class CreateUserPayload(BaseModel):
25
+ """
26
+ CreateUserPayload
27
+ """
28
+
29
+ description: StrictStr = Field(description="A user chosen description to differentiate between multiple users.")
30
+ write: StrictBool = Field(
31
+ description="Is true if the user has write access to the secrets engine. Is false for a read-only user."
32
+ )
33
+ __properties: ClassVar[List[str]] = ["description", "write"]
34
+
35
+ model_config = ConfigDict(
36
+ populate_by_name=True,
37
+ validate_assignment=True,
38
+ protected_namespaces=(),
39
+ )
40
+
41
+ def to_str(self) -> str:
42
+ """Returns the string representation of the model using alias"""
43
+ return pprint.pformat(self.model_dump(by_alias=True))
44
+
45
+ def to_json(self) -> str:
46
+ """Returns the JSON representation of the model using alias"""
47
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
48
+ return json.dumps(self.to_dict())
49
+
50
+ @classmethod
51
+ def from_json(cls, json_str: str) -> Optional[Self]:
52
+ """Create an instance of CreateUserPayload from a JSON string"""
53
+ return cls.from_dict(json.loads(json_str))
54
+
55
+ def to_dict(self) -> Dict[str, Any]:
56
+ """Return the dictionary representation of the model using alias.
57
+
58
+ This has the following differences from calling pydantic's
59
+ `self.model_dump(by_alias=True)`:
60
+
61
+ * `None` is only added to the output dict for nullable fields that
62
+ were set at model initialization. Other fields with value `None`
63
+ are ignored.
64
+ """
65
+ excluded_fields: Set[str] = set([])
66
+
67
+ _dict = self.model_dump(
68
+ by_alias=True,
69
+ exclude=excluded_fields,
70
+ exclude_none=True,
71
+ )
72
+ return _dict
73
+
74
+ @classmethod
75
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
76
+ """Create an instance of CreateUserPayload from a dict"""
77
+ if obj is None:
78
+ return None
79
+
80
+ if not isinstance(obj, dict):
81
+ return cls.model_validate(obj)
82
+
83
+ _obj = cls.model_validate({"description": obj.get("description"), "write": obj.get("write")})
84
+ return _obj