stackit-resourcemanager 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.
- stackit/resourcemanager/__init__.py +67 -0
- stackit/resourcemanager/api/__init__.py +4 -0
- stackit/resourcemanager/api/default_api.py +2703 -0
- stackit/resourcemanager/api_client.py +626 -0
- stackit/resourcemanager/api_response.py +23 -0
- stackit/resourcemanager/configuration.py +110 -0
- stackit/resourcemanager/exceptions.py +198 -0
- stackit/resourcemanager/models/__init__.py +48 -0
- stackit/resourcemanager/models/create_project_payload.py +122 -0
- stackit/resourcemanager/models/error_response.py +94 -0
- stackit/resourcemanager/models/folder_response.py +114 -0
- stackit/resourcemanager/models/get_project_response.py +133 -0
- stackit/resourcemanager/models/lifecycle_state.py +38 -0
- stackit/resourcemanager/models/list_organization_containers_response.py +110 -0
- stackit/resourcemanager/models/list_organization_containers_response_items_inner.py +164 -0
- stackit/resourcemanager/models/list_organization_containers_response_items_inner_any_of.py +99 -0
- stackit/resourcemanager/models/list_organization_containers_response_items_inner_any_of1.py +96 -0
- stackit/resourcemanager/models/list_organizations_response.py +110 -0
- stackit/resourcemanager/models/list_organizations_response_items_inner.py +115 -0
- stackit/resourcemanager/models/list_projects_response.py +104 -0
- stackit/resourcemanager/models/member.py +82 -0
- stackit/resourcemanager/models/organization_response.py +115 -0
- stackit/resourcemanager/models/parent.py +92 -0
- stackit/resourcemanager/models/parent_list_inner.py +107 -0
- stackit/resourcemanager/models/partial_update_project_payload.py +108 -0
- stackit/resourcemanager/models/project.py +118 -0
- stackit/resourcemanager/py.typed +0 -0
- stackit/resourcemanager/rest.py +148 -0
- stackit_resourcemanager-0.0.1a0.dist-info/METADATA +65 -0
- stackit_resourcemanager-0.0.1a0.dist-info/RECORD +31 -0
- stackit_resourcemanager-0.0.1a0.dist-info/WHEEL +4 -0
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
Resource Manager API
|
|
5
|
+
|
|
6
|
+
API v2 to manage resource containers - organizations, folders, projects incl. labels ### Resource Management STACKIT resource management handles the terms _Organization_, _Folder_, _Project_, _Label_, and the hierarchical structure between them. Technically, organizations, folders, and projects are _Resource Containers_ to which a _Label_ can be attached to. The STACKIT _Resource Manager_ provides CRUD endpoints to query and to modify the state. ### Organizations STACKIT organizations are the base element to create and to use cloud-resources. An organization is bound to one customer account. Organizations have a lifecycle. - Organizations are always the root node in resource hierarchy and do not have a parent ### Projects STACKIT projects are needed to use cloud-resources. Projects serve as wrapper for underlying technical structures and processes. Projects have a lifecycle. Projects compared to folders may have different policies. - Projects are optional, but mandatory for cloud-resource usage - A project can be created having either an organization, or a folder as parent - A project must not have a project as parent - Project names under the same parent must not be unique - Root organization cannot be changed ### Label STACKIT labels are key-value pairs including a resource container reference. Labels can be defined and attached freely to resource containers by which resources can be organized and queried. - Policy-based, immutable labels may exists
|
|
7
|
+
|
|
8
|
+
The version of the OpenAPI document: 2.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://resource-manager.api.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://resource-manager.api.stackit.cloud",
|
|
51
|
+
"description": "No description provided",
|
|
52
|
+
"variables": {
|
|
53
|
+
"region": {
|
|
54
|
+
"description": "No description provided",
|
|
55
|
+
"default_value": "global",
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
}
|
|
59
|
+
]
|
|
60
|
+
|
|
61
|
+
def get_host_from_settings(self, index, variables=None, servers=None):
|
|
62
|
+
"""Gets host URL based on the index and variables
|
|
63
|
+
:param index: array index of the host settings
|
|
64
|
+
:param variables: hash of variable and the corresponding value
|
|
65
|
+
:param servers: an array of host settings or None
|
|
66
|
+
:return: URL based on host settings
|
|
67
|
+
"""
|
|
68
|
+
if index is None:
|
|
69
|
+
return self._base_path
|
|
70
|
+
|
|
71
|
+
variables = {} if variables is None else variables
|
|
72
|
+
servers = self.get_host_settings() if servers is None else servers
|
|
73
|
+
|
|
74
|
+
try:
|
|
75
|
+
server = servers[index]
|
|
76
|
+
except IndexError:
|
|
77
|
+
raise ValueError(
|
|
78
|
+
"Invalid index {0} when selecting the host settings. "
|
|
79
|
+
"Must be less than {1}".format(index, len(servers))
|
|
80
|
+
)
|
|
81
|
+
|
|
82
|
+
url = server["url"]
|
|
83
|
+
|
|
84
|
+
# go through variables and replace placeholders
|
|
85
|
+
for variable_name, variable in server.get("variables", {}).items():
|
|
86
|
+
used_value = variables.get(variable_name, variable["default_value"])
|
|
87
|
+
|
|
88
|
+
if "enum_values" in variable and used_value not in variable["enum_values"]:
|
|
89
|
+
given_value = variables[variable_name].replace(".", "")
|
|
90
|
+
valid_values = [v.replace(".", "") for v in variable["enum_values"]]
|
|
91
|
+
raise ValueError(
|
|
92
|
+
"The variable `{0}` in the host URL has invalid value '{1}'. Must be '{2}'.".format(
|
|
93
|
+
variable_name, given_value, valid_values
|
|
94
|
+
)
|
|
95
|
+
)
|
|
96
|
+
|
|
97
|
+
url = url.replace("{" + variable_name + "}", used_value)
|
|
98
|
+
|
|
99
|
+
return url
|
|
100
|
+
|
|
101
|
+
@property
|
|
102
|
+
def host(self):
|
|
103
|
+
"""Return generated host."""
|
|
104
|
+
return self.get_host_from_settings(self.server_index, variables=self.server_variables)
|
|
105
|
+
|
|
106
|
+
@host.setter
|
|
107
|
+
def host(self, value):
|
|
108
|
+
"""Fix base path."""
|
|
109
|
+
self._base_path = value
|
|
110
|
+
self.server_index = None
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
Resource Manager API
|
|
5
|
+
|
|
6
|
+
API v2 to manage resource containers - organizations, folders, projects incl. labels ### Resource Management STACKIT resource management handles the terms _Organization_, _Folder_, _Project_, _Label_, and the hierarchical structure between them. Technically, organizations, folders, and projects are _Resource Containers_ to which a _Label_ can be attached to. The STACKIT _Resource Manager_ provides CRUD endpoints to query and to modify the state. ### Organizations STACKIT organizations are the base element to create and to use cloud-resources. An organization is bound to one customer account. Organizations have a lifecycle. - Organizations are always the root node in resource hierarchy and do not have a parent ### Projects STACKIT projects are needed to use cloud-resources. Projects serve as wrapper for underlying technical structures and processes. Projects have a lifecycle. Projects compared to folders may have different policies. - Projects are optional, but mandatory for cloud-resource usage - A project can be created having either an organization, or a folder as parent - A project must not have a project as parent - Project names under the same parent must not be unique - Root organization cannot be changed ### Label STACKIT labels are key-value pairs including a resource container reference. Labels can be defined and attached freely to resource containers by which resources can be organized and queried. - Policy-based, immutable labels may exists
|
|
7
|
+
|
|
8
|
+
The version of the OpenAPI document: 2.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,48 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
# flake8: noqa
|
|
4
|
+
"""
|
|
5
|
+
Resource Manager API
|
|
6
|
+
|
|
7
|
+
API v2 to manage resource containers - organizations, folders, projects incl. labels ### Resource Management STACKIT resource management handles the terms _Organization_, _Folder_, _Project_, _Label_, and the hierarchical structure between them. Technically, organizations, folders, and projects are _Resource Containers_ to which a _Label_ can be attached to. The STACKIT _Resource Manager_ provides CRUD endpoints to query and to modify the state. ### Organizations STACKIT organizations are the base element to create and to use cloud-resources. An organization is bound to one customer account. Organizations have a lifecycle. - Organizations are always the root node in resource hierarchy and do not have a parent ### Projects STACKIT projects are needed to use cloud-resources. Projects serve as wrapper for underlying technical structures and processes. Projects have a lifecycle. Projects compared to folders may have different policies. - Projects are optional, but mandatory for cloud-resource usage - A project can be created having either an organization, or a folder as parent - A project must not have a project as parent - Project names under the same parent must not be unique - Root organization cannot be changed ### Label STACKIT labels are key-value pairs including a resource container reference. Labels can be defined and attached freely to resource containers by which resources can be organized and queried. - Policy-based, immutable labels may exists
|
|
8
|
+
|
|
9
|
+
The version of the OpenAPI document: 2.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.resourcemanager.models.create_project_payload import CreateProjectPayload
|
|
18
|
+
from stackit.resourcemanager.models.error_response import ErrorResponse
|
|
19
|
+
from stackit.resourcemanager.models.folder_response import FolderResponse
|
|
20
|
+
from stackit.resourcemanager.models.get_project_response import GetProjectResponse
|
|
21
|
+
from stackit.resourcemanager.models.lifecycle_state import LifecycleState
|
|
22
|
+
from stackit.resourcemanager.models.list_organization_containers_response import (
|
|
23
|
+
ListOrganizationContainersResponse,
|
|
24
|
+
)
|
|
25
|
+
from stackit.resourcemanager.models.list_organization_containers_response_items_inner import (
|
|
26
|
+
ListOrganizationContainersResponseItemsInner,
|
|
27
|
+
)
|
|
28
|
+
from stackit.resourcemanager.models.list_organization_containers_response_items_inner_any_of import (
|
|
29
|
+
ListOrganizationContainersResponseItemsInnerAnyOf,
|
|
30
|
+
)
|
|
31
|
+
from stackit.resourcemanager.models.list_organization_containers_response_items_inner_any_of1 import (
|
|
32
|
+
ListOrganizationContainersResponseItemsInnerAnyOf1,
|
|
33
|
+
)
|
|
34
|
+
from stackit.resourcemanager.models.list_organizations_response import (
|
|
35
|
+
ListOrganizationsResponse,
|
|
36
|
+
)
|
|
37
|
+
from stackit.resourcemanager.models.list_organizations_response_items_inner import (
|
|
38
|
+
ListOrganizationsResponseItemsInner,
|
|
39
|
+
)
|
|
40
|
+
from stackit.resourcemanager.models.list_projects_response import ListProjectsResponse
|
|
41
|
+
from stackit.resourcemanager.models.member import Member
|
|
42
|
+
from stackit.resourcemanager.models.organization_response import OrganizationResponse
|
|
43
|
+
from stackit.resourcemanager.models.parent import Parent
|
|
44
|
+
from stackit.resourcemanager.models.parent_list_inner import ParentListInner
|
|
45
|
+
from stackit.resourcemanager.models.partial_update_project_payload import (
|
|
46
|
+
PartialUpdateProjectPayload,
|
|
47
|
+
)
|
|
48
|
+
from stackit.resourcemanager.models.project import Project
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
Resource Manager API
|
|
5
|
+
|
|
6
|
+
API v2 to manage resource containers - organizations, folders, projects incl. labels ### Resource Management STACKIT resource management handles the terms _Organization_, _Folder_, _Project_, _Label_, and the hierarchical structure between them. Technically, organizations, folders, and projects are _Resource Containers_ to which a _Label_ can be attached to. The STACKIT _Resource Manager_ provides CRUD endpoints to query and to modify the state. ### Organizations STACKIT organizations are the base element to create and to use cloud-resources. An organization is bound to one customer account. Organizations have a lifecycle. - Organizations are always the root node in resource hierarchy and do not have a parent ### Projects STACKIT projects are needed to use cloud-resources. Projects serve as wrapper for underlying technical structures and processes. Projects have a lifecycle. Projects compared to folders may have different policies. - Projects are optional, but mandatory for cloud-resource usage - A project can be created having either an organization, or a folder as parent - A project must not have a project as parent - Project names under the same parent must not be unique - Root organization cannot be changed ### Label STACKIT labels are key-value pairs including a resource container reference. Labels can be defined and attached freely to resource containers by which resources can be organized and queried. - Policy-based, immutable labels may exists
|
|
7
|
+
|
|
8
|
+
The version of the OpenAPI document: 2.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
|
+
import re
|
|
19
|
+
from typing import Any, ClassVar, Dict, List, Optional, Set
|
|
20
|
+
|
|
21
|
+
from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator
|
|
22
|
+
from typing_extensions import Annotated, Self
|
|
23
|
+
|
|
24
|
+
from stackit.resourcemanager.models.member import Member
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class CreateProjectPayload(BaseModel):
|
|
28
|
+
"""
|
|
29
|
+
CreateProjectPayload
|
|
30
|
+
"""
|
|
31
|
+
|
|
32
|
+
container_parent_id: StrictStr = Field(
|
|
33
|
+
description="Identifier of the parent resource container - containerId as well as UUID identifier is supported.",
|
|
34
|
+
alias="containerParentId",
|
|
35
|
+
)
|
|
36
|
+
labels: Optional[Dict[str, StrictStr]] = Field(
|
|
37
|
+
default=None,
|
|
38
|
+
description="Labels are key-value string pairs that can be attached to a resource container. Some labels may be enforced via policies. - A label key must match the regex `[A-ZÄÜÖa-zäüöß0-9_-]{1,64}`. - A label value must match the regex `^$|[A-ZÄÜÖa-zäüöß0-9_-]{1,64}`.",
|
|
39
|
+
)
|
|
40
|
+
members: Annotated[List[Member], Field(min_length=1)] = Field(
|
|
41
|
+
description="The initial members assigned to the project. At least one subject needs to be a user, and not a client or service account."
|
|
42
|
+
)
|
|
43
|
+
name: Annotated[str, Field(strict=True)] = Field(
|
|
44
|
+
description="Project name matching the regex `^[a-zA-ZäüöÄÜÖ0-9]( ?[a-zA-ZäüöÄÜÖß0-9_+&-]){0,39}$`."
|
|
45
|
+
)
|
|
46
|
+
__properties: ClassVar[List[str]] = ["containerParentId", "labels", "members", "name"]
|
|
47
|
+
|
|
48
|
+
@field_validator("name")
|
|
49
|
+
def name_validate_regular_expression(cls, value):
|
|
50
|
+
"""Validates the regular expression"""
|
|
51
|
+
if not re.match(r"^[a-zA-ZäüöÄÜÖ0-9]( ?[a-zA-ZäüöÄÜÖß0-9_+&-]){0,39}$", value):
|
|
52
|
+
raise ValueError(
|
|
53
|
+
r"must validate the regular expression /^[a-zA-ZäüöÄÜÖ0-9]( ?[a-zA-ZäüöÄÜÖß0-9_+&-]){0,39}$/"
|
|
54
|
+
)
|
|
55
|
+
return value
|
|
56
|
+
|
|
57
|
+
model_config = ConfigDict(
|
|
58
|
+
populate_by_name=True,
|
|
59
|
+
validate_assignment=True,
|
|
60
|
+
protected_namespaces=(),
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
def to_str(self) -> str:
|
|
64
|
+
"""Returns the string representation of the model using alias"""
|
|
65
|
+
return pprint.pformat(self.model_dump(by_alias=True))
|
|
66
|
+
|
|
67
|
+
def to_json(self) -> str:
|
|
68
|
+
"""Returns the JSON representation of the model using alias"""
|
|
69
|
+
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
|
|
70
|
+
return json.dumps(self.to_dict())
|
|
71
|
+
|
|
72
|
+
@classmethod
|
|
73
|
+
def from_json(cls, json_str: str) -> Optional[Self]:
|
|
74
|
+
"""Create an instance of CreateProjectPayload from a JSON string"""
|
|
75
|
+
return cls.from_dict(json.loads(json_str))
|
|
76
|
+
|
|
77
|
+
def to_dict(self) -> Dict[str, Any]:
|
|
78
|
+
"""Return the dictionary representation of the model using alias.
|
|
79
|
+
|
|
80
|
+
This has the following differences from calling pydantic's
|
|
81
|
+
`self.model_dump(by_alias=True)`:
|
|
82
|
+
|
|
83
|
+
* `None` is only added to the output dict for nullable fields that
|
|
84
|
+
were set at model initialization. Other fields with value `None`
|
|
85
|
+
are ignored.
|
|
86
|
+
"""
|
|
87
|
+
excluded_fields: Set[str] = set([])
|
|
88
|
+
|
|
89
|
+
_dict = self.model_dump(
|
|
90
|
+
by_alias=True,
|
|
91
|
+
exclude=excluded_fields,
|
|
92
|
+
exclude_none=True,
|
|
93
|
+
)
|
|
94
|
+
# override the default output from pydantic by calling `to_dict()` of each item in members (list)
|
|
95
|
+
_items = []
|
|
96
|
+
if self.members:
|
|
97
|
+
for _item in self.members:
|
|
98
|
+
if _item:
|
|
99
|
+
_items.append(_item.to_dict())
|
|
100
|
+
_dict["members"] = _items
|
|
101
|
+
return _dict
|
|
102
|
+
|
|
103
|
+
@classmethod
|
|
104
|
+
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
|
105
|
+
"""Create an instance of CreateProjectPayload from a dict"""
|
|
106
|
+
if obj is None:
|
|
107
|
+
return None
|
|
108
|
+
|
|
109
|
+
if not isinstance(obj, dict):
|
|
110
|
+
return cls.model_validate(obj)
|
|
111
|
+
|
|
112
|
+
_obj = cls.model_validate(
|
|
113
|
+
{
|
|
114
|
+
"containerParentId": obj.get("containerParentId"),
|
|
115
|
+
"labels": obj.get("labels"),
|
|
116
|
+
"members": (
|
|
117
|
+
[Member.from_dict(_item) for _item in obj["members"]] if obj.get("members") is not None else None
|
|
118
|
+
),
|
|
119
|
+
"name": obj.get("name"),
|
|
120
|
+
}
|
|
121
|
+
)
|
|
122
|
+
return _obj
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
Resource Manager API
|
|
5
|
+
|
|
6
|
+
API v2 to manage resource containers - organizations, folders, projects incl. labels ### Resource Management STACKIT resource management handles the terms _Organization_, _Folder_, _Project_, _Label_, and the hierarchical structure between them. Technically, organizations, folders, and projects are _Resource Containers_ to which a _Label_ can be attached to. The STACKIT _Resource Manager_ provides CRUD endpoints to query and to modify the state. ### Organizations STACKIT organizations are the base element to create and to use cloud-resources. An organization is bound to one customer account. Organizations have a lifecycle. - Organizations are always the root node in resource hierarchy and do not have a parent ### Projects STACKIT projects are needed to use cloud-resources. Projects serve as wrapper for underlying technical structures and processes. Projects have a lifecycle. Projects compared to folders may have different policies. - Projects are optional, but mandatory for cloud-resource usage - A project can be created having either an organization, or a folder as parent - A project must not have a project as parent - Project names under the same parent must not be unique - Root organization cannot be changed ### Label STACKIT labels are key-value pairs including a resource container reference. Labels can be defined and attached freely to resource containers by which resources can be organized and queried. - Policy-based, immutable labels may exists
|
|
7
|
+
|
|
8
|
+
The version of the OpenAPI document: 2.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 datetime import datetime
|
|
19
|
+
from typing import Any, ClassVar, Dict, List, Optional, Set, Union
|
|
20
|
+
|
|
21
|
+
from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt, StrictStr
|
|
22
|
+
from typing_extensions import Self
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class ErrorResponse(BaseModel):
|
|
26
|
+
"""
|
|
27
|
+
ErrorResponse
|
|
28
|
+
"""
|
|
29
|
+
|
|
30
|
+
error: StrictStr = Field(description="The reason phrase of the status code.")
|
|
31
|
+
message: StrictStr = Field(description="Description of the error.")
|
|
32
|
+
path: StrictStr = Field(description="Path which was called.")
|
|
33
|
+
status: Union[StrictFloat, StrictInt] = Field(description="Http Status Code.")
|
|
34
|
+
time_stamp: datetime = Field(description="Timestamp at which the error occurred.", alias="timeStamp")
|
|
35
|
+
__properties: ClassVar[List[str]] = ["error", "message", "path", "status", "timeStamp"]
|
|
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 ErrorResponse 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 ErrorResponse 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(
|
|
86
|
+
{
|
|
87
|
+
"error": obj.get("error"),
|
|
88
|
+
"message": obj.get("message"),
|
|
89
|
+
"path": obj.get("path"),
|
|
90
|
+
"status": obj.get("status"),
|
|
91
|
+
"timeStamp": obj.get("timeStamp"),
|
|
92
|
+
}
|
|
93
|
+
)
|
|
94
|
+
return _obj
|