stackit-git 0.1.0__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/git/__init__.py +43 -0
- stackit/git/api/__init__.py +4 -0
- stackit/git/api/default_api.py +1135 -0
- stackit/git/api_client.py +627 -0
- stackit/git/api_response.py +23 -0
- stackit/git/configuration.py +138 -0
- stackit/git/exceptions.py +199 -0
- stackit/git/models/__init__.py +24 -0
- stackit/git/models/create_instance_payload.py +92 -0
- stackit/git/models/instance.py +116 -0
- stackit/git/models/internal_server_error_response.py +82 -0
- stackit/git/models/list_instances.py +99 -0
- stackit/git/models/unauthorized_response.py +82 -0
- stackit/git/py.typed +0 -0
- stackit/git/rest.py +149 -0
- stackit_git-0.1.0.dist-info/LICENSE.md +201 -0
- stackit_git-0.1.0.dist-info/METADATA +45 -0
- stackit_git-0.1.0.dist-info/NOTICE.txt +2 -0
- stackit_git-0.1.0.dist-info/RECORD +20 -0
- stackit_git-0.1.0.dist-info/WHEEL +4 -0
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
STACKIT Git API
|
|
5
|
+
|
|
6
|
+
Manage STACKIT Git instances.
|
|
7
|
+
|
|
8
|
+
The version of the OpenAPI document: 1beta.0.3
|
|
9
|
+
Contact: git@stackit.cloud
|
|
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
|
+
import os
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class HostConfiguration:
|
|
19
|
+
def __init__(
|
|
20
|
+
self,
|
|
21
|
+
region=None,
|
|
22
|
+
server_index=None,
|
|
23
|
+
server_variables=None,
|
|
24
|
+
server_operation_index=None,
|
|
25
|
+
server_operation_variables=None,
|
|
26
|
+
ignore_operation_servers=False,
|
|
27
|
+
) -> None:
|
|
28
|
+
print(
|
|
29
|
+
"WARNING: STACKIT will move to a new way of specifying regions, where the region is provided\n",
|
|
30
|
+
"as a function argument instead of being set in the client configuration.\n"
|
|
31
|
+
"Once all services have migrated, the methods to specify the region in the client configuration "
|
|
32
|
+
"will be removed.",
|
|
33
|
+
)
|
|
34
|
+
"""Constructor
|
|
35
|
+
"""
|
|
36
|
+
self._base_path = "https://git.api.stackit.cloud"
|
|
37
|
+
"""Default Base url
|
|
38
|
+
"""
|
|
39
|
+
self.server_index = 0 if server_index is None else server_index
|
|
40
|
+
self.server_operation_index = server_operation_index or {}
|
|
41
|
+
"""Default server index
|
|
42
|
+
"""
|
|
43
|
+
self.server_variables = server_variables or {}
|
|
44
|
+
if region:
|
|
45
|
+
self.server_variables["region"] = "{}.".format(region)
|
|
46
|
+
self.server_operation_variables = server_operation_variables or {}
|
|
47
|
+
"""Default server variables
|
|
48
|
+
"""
|
|
49
|
+
self.ignore_operation_servers = ignore_operation_servers
|
|
50
|
+
"""Ignore operation servers
|
|
51
|
+
"""
|
|
52
|
+
|
|
53
|
+
def get_host_settings(self):
|
|
54
|
+
"""Gets an array of host settings
|
|
55
|
+
|
|
56
|
+
:return: An array of host settings
|
|
57
|
+
"""
|
|
58
|
+
return [
|
|
59
|
+
{
|
|
60
|
+
"url": "https://git.api.stackit.cloud",
|
|
61
|
+
"description": "No description provided",
|
|
62
|
+
"variables": {
|
|
63
|
+
"region": {
|
|
64
|
+
"description": "No description provided",
|
|
65
|
+
"default_value": "global",
|
|
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,199 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
STACKIT Git API
|
|
5
|
+
|
|
6
|
+
Manage STACKIT Git instances.
|
|
7
|
+
|
|
8
|
+
The version of the OpenAPI document: 1beta.0.3
|
|
9
|
+
Contact: git@stackit.cloud
|
|
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
|
+
from typing import Any, Optional
|
|
16
|
+
|
|
17
|
+
from typing_extensions import Self
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class OpenApiException(Exception):
|
|
21
|
+
"""The base exception class for all OpenAPIExceptions"""
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class ApiTypeError(OpenApiException, TypeError):
|
|
25
|
+
def __init__(self, msg, path_to_item=None, valid_classes=None, key_type=None) -> None:
|
|
26
|
+
"""Raises an exception for TypeErrors
|
|
27
|
+
|
|
28
|
+
Args:
|
|
29
|
+
msg (str): the exception message
|
|
30
|
+
|
|
31
|
+
Keyword Args:
|
|
32
|
+
path_to_item (list): a list of keys an indices to get to the
|
|
33
|
+
current_item
|
|
34
|
+
None if unset
|
|
35
|
+
valid_classes (tuple): the primitive classes that current item
|
|
36
|
+
should be an instance of
|
|
37
|
+
None if unset
|
|
38
|
+
key_type (bool): False if our value is a value in a dict
|
|
39
|
+
True if it is a key in a dict
|
|
40
|
+
False if our item is an item in a list
|
|
41
|
+
None if unset
|
|
42
|
+
"""
|
|
43
|
+
self.path_to_item = path_to_item
|
|
44
|
+
self.valid_classes = valid_classes
|
|
45
|
+
self.key_type = key_type
|
|
46
|
+
full_msg = msg
|
|
47
|
+
if path_to_item:
|
|
48
|
+
full_msg = "{0} at {1}".format(msg, render_path(path_to_item))
|
|
49
|
+
super(ApiTypeError, self).__init__(full_msg)
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
class ApiValueError(OpenApiException, ValueError):
|
|
53
|
+
def __init__(self, msg, path_to_item=None) -> None:
|
|
54
|
+
"""
|
|
55
|
+
Args:
|
|
56
|
+
msg (str): the exception message
|
|
57
|
+
|
|
58
|
+
Keyword Args:
|
|
59
|
+
path_to_item (list) the path to the exception in the
|
|
60
|
+
received_data dict. None if unset
|
|
61
|
+
"""
|
|
62
|
+
|
|
63
|
+
self.path_to_item = path_to_item
|
|
64
|
+
full_msg = msg
|
|
65
|
+
if path_to_item:
|
|
66
|
+
full_msg = "{0} at {1}".format(msg, render_path(path_to_item))
|
|
67
|
+
super(ApiValueError, self).__init__(full_msg)
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
class ApiAttributeError(OpenApiException, AttributeError):
|
|
71
|
+
def __init__(self, msg, path_to_item=None) -> None:
|
|
72
|
+
"""
|
|
73
|
+
Raised when an attribute reference or assignment fails.
|
|
74
|
+
|
|
75
|
+
Args:
|
|
76
|
+
msg (str): the exception message
|
|
77
|
+
|
|
78
|
+
Keyword Args:
|
|
79
|
+
path_to_item (None/list) the path to the exception in the
|
|
80
|
+
received_data dict
|
|
81
|
+
"""
|
|
82
|
+
self.path_to_item = path_to_item
|
|
83
|
+
full_msg = msg
|
|
84
|
+
if path_to_item:
|
|
85
|
+
full_msg = "{0} at {1}".format(msg, render_path(path_to_item))
|
|
86
|
+
super(ApiAttributeError, self).__init__(full_msg)
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
class ApiKeyError(OpenApiException, KeyError):
|
|
90
|
+
def __init__(self, msg, path_to_item=None) -> None:
|
|
91
|
+
"""
|
|
92
|
+
Args:
|
|
93
|
+
msg (str): the exception message
|
|
94
|
+
|
|
95
|
+
Keyword Args:
|
|
96
|
+
path_to_item (None/list) the path to the exception in the
|
|
97
|
+
received_data dict
|
|
98
|
+
"""
|
|
99
|
+
self.path_to_item = path_to_item
|
|
100
|
+
full_msg = msg
|
|
101
|
+
if path_to_item:
|
|
102
|
+
full_msg = "{0} at {1}".format(msg, render_path(path_to_item))
|
|
103
|
+
super(ApiKeyError, self).__init__(full_msg)
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
class ApiException(OpenApiException):
|
|
107
|
+
|
|
108
|
+
def __init__(
|
|
109
|
+
self,
|
|
110
|
+
status=None,
|
|
111
|
+
reason=None,
|
|
112
|
+
http_resp=None,
|
|
113
|
+
*,
|
|
114
|
+
body: Optional[str] = None,
|
|
115
|
+
data: Optional[Any] = None,
|
|
116
|
+
) -> None:
|
|
117
|
+
self.status = status
|
|
118
|
+
self.reason = reason
|
|
119
|
+
self.body = body
|
|
120
|
+
self.data = data
|
|
121
|
+
self.headers = None
|
|
122
|
+
|
|
123
|
+
if http_resp:
|
|
124
|
+
if self.status is None:
|
|
125
|
+
self.status = http_resp.status
|
|
126
|
+
if self.reason is None:
|
|
127
|
+
self.reason = http_resp.reason
|
|
128
|
+
if self.body is None:
|
|
129
|
+
try:
|
|
130
|
+
self.body = http_resp.data.decode("utf-8")
|
|
131
|
+
except Exception: # noqa: S110
|
|
132
|
+
pass
|
|
133
|
+
self.headers = http_resp.getheaders()
|
|
134
|
+
|
|
135
|
+
@classmethod
|
|
136
|
+
def from_response(
|
|
137
|
+
cls,
|
|
138
|
+
*,
|
|
139
|
+
http_resp,
|
|
140
|
+
body: Optional[str],
|
|
141
|
+
data: Optional[Any],
|
|
142
|
+
) -> Self:
|
|
143
|
+
if http_resp.status == 400:
|
|
144
|
+
raise BadRequestException(http_resp=http_resp, body=body, data=data)
|
|
145
|
+
|
|
146
|
+
if http_resp.status == 401:
|
|
147
|
+
raise UnauthorizedException(http_resp=http_resp, body=body, data=data)
|
|
148
|
+
|
|
149
|
+
if http_resp.status == 403:
|
|
150
|
+
raise ForbiddenException(http_resp=http_resp, body=body, data=data)
|
|
151
|
+
|
|
152
|
+
if http_resp.status == 404:
|
|
153
|
+
raise NotFoundException(http_resp=http_resp, body=body, data=data)
|
|
154
|
+
|
|
155
|
+
if 500 <= http_resp.status <= 599:
|
|
156
|
+
raise ServiceException(http_resp=http_resp, body=body, data=data)
|
|
157
|
+
raise ApiException(http_resp=http_resp, body=body, data=data)
|
|
158
|
+
|
|
159
|
+
def __str__(self):
|
|
160
|
+
"""Custom error messages for exception"""
|
|
161
|
+
error_message = "({0})\n" "Reason: {1}\n".format(self.status, self.reason)
|
|
162
|
+
if self.headers:
|
|
163
|
+
error_message += "HTTP response headers: {0}\n".format(self.headers)
|
|
164
|
+
|
|
165
|
+
if self.data or self.body:
|
|
166
|
+
error_message += "HTTP response body: {0}\n".format(self.data or self.body)
|
|
167
|
+
|
|
168
|
+
return error_message
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
class BadRequestException(ApiException):
|
|
172
|
+
pass
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
class NotFoundException(ApiException):
|
|
176
|
+
pass
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
class UnauthorizedException(ApiException):
|
|
180
|
+
pass
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
class ForbiddenException(ApiException):
|
|
184
|
+
pass
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
class ServiceException(ApiException):
|
|
188
|
+
pass
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
def render_path(path_to_item):
|
|
192
|
+
"""Returns a string representation of a path"""
|
|
193
|
+
result = ""
|
|
194
|
+
for pth in path_to_item:
|
|
195
|
+
if isinstance(pth, int):
|
|
196
|
+
result += "[{0}]".format(pth)
|
|
197
|
+
else:
|
|
198
|
+
result += "['{0}']".format(pth)
|
|
199
|
+
return result
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
# flake8: noqa
|
|
4
|
+
"""
|
|
5
|
+
STACKIT Git API
|
|
6
|
+
|
|
7
|
+
Manage STACKIT Git instances.
|
|
8
|
+
|
|
9
|
+
The version of the OpenAPI document: 1beta.0.3
|
|
10
|
+
Contact: git@stackit.cloud
|
|
11
|
+
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
|
12
|
+
|
|
13
|
+
Do not edit the class manually.
|
|
14
|
+
""" # noqa: E501 docstring might be too long
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
# import models into model package
|
|
18
|
+
from stackit.git.models.create_instance_payload import CreateInstancePayload
|
|
19
|
+
from stackit.git.models.instance import Instance
|
|
20
|
+
from stackit.git.models.internal_server_error_response import (
|
|
21
|
+
InternalServerErrorResponse,
|
|
22
|
+
)
|
|
23
|
+
from stackit.git.models.list_instances import ListInstances
|
|
24
|
+
from stackit.git.models.unauthorized_response import UnauthorizedResponse
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
STACKIT Git API
|
|
5
|
+
|
|
6
|
+
Manage STACKIT Git instances.
|
|
7
|
+
|
|
8
|
+
The version of the OpenAPI document: 1beta.0.3
|
|
9
|
+
Contact: git@stackit.cloud
|
|
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
|
+
from __future__ import annotations
|
|
16
|
+
|
|
17
|
+
import json
|
|
18
|
+
import pprint
|
|
19
|
+
import re
|
|
20
|
+
from typing import Any, ClassVar, Dict, List, Optional, Set
|
|
21
|
+
|
|
22
|
+
from pydantic import BaseModel, ConfigDict, Field, field_validator
|
|
23
|
+
from typing_extensions import Annotated, Self
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class CreateInstancePayload(BaseModel):
|
|
27
|
+
"""
|
|
28
|
+
Request a STACKIT Git instance to be created with these properties.
|
|
29
|
+
"""
|
|
30
|
+
|
|
31
|
+
name: Annotated[str, Field(min_length=5, strict=True, max_length=32)] = Field(
|
|
32
|
+
description="A user chosen name to distinguish multiple STACKIT Git instances."
|
|
33
|
+
)
|
|
34
|
+
__properties: ClassVar[List[str]] = ["name"]
|
|
35
|
+
|
|
36
|
+
@field_validator("name")
|
|
37
|
+
def name_validate_regular_expression(cls, value):
|
|
38
|
+
"""Validates the regular expression"""
|
|
39
|
+
if not re.match(r"^[a-zA-Z0-9-_]+$", value):
|
|
40
|
+
raise ValueError(r"must validate the regular expression /^[a-zA-Z0-9-_]+$/")
|
|
41
|
+
return value
|
|
42
|
+
|
|
43
|
+
model_config = ConfigDict(
|
|
44
|
+
populate_by_name=True,
|
|
45
|
+
validate_assignment=True,
|
|
46
|
+
protected_namespaces=(),
|
|
47
|
+
)
|
|
48
|
+
|
|
49
|
+
def to_str(self) -> str:
|
|
50
|
+
"""Returns the string representation of the model using alias"""
|
|
51
|
+
return pprint.pformat(self.model_dump(by_alias=True))
|
|
52
|
+
|
|
53
|
+
def to_json(self) -> str:
|
|
54
|
+
"""Returns the JSON representation of the model using alias"""
|
|
55
|
+
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
|
|
56
|
+
return json.dumps(self.to_dict())
|
|
57
|
+
|
|
58
|
+
@classmethod
|
|
59
|
+
def from_json(cls, json_str: str) -> Optional[Self]:
|
|
60
|
+
"""Create an instance of CreateInstancePayload from a JSON string"""
|
|
61
|
+
return cls.from_dict(json.loads(json_str))
|
|
62
|
+
|
|
63
|
+
def to_dict(self) -> Dict[str, Any]:
|
|
64
|
+
"""Return the dictionary representation of the model using alias.
|
|
65
|
+
|
|
66
|
+
This has the following differences from calling pydantic's
|
|
67
|
+
`self.model_dump(by_alias=True)`:
|
|
68
|
+
|
|
69
|
+
* `None` is only added to the output dict for nullable fields that
|
|
70
|
+
were set at model initialization. Other fields with value `None`
|
|
71
|
+
are ignored.
|
|
72
|
+
"""
|
|
73
|
+
excluded_fields: Set[str] = set([])
|
|
74
|
+
|
|
75
|
+
_dict = self.model_dump(
|
|
76
|
+
by_alias=True,
|
|
77
|
+
exclude=excluded_fields,
|
|
78
|
+
exclude_none=True,
|
|
79
|
+
)
|
|
80
|
+
return _dict
|
|
81
|
+
|
|
82
|
+
@classmethod
|
|
83
|
+
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
|
84
|
+
"""Create an instance of CreateInstancePayload from a dict"""
|
|
85
|
+
if obj is None:
|
|
86
|
+
return None
|
|
87
|
+
|
|
88
|
+
if not isinstance(obj, dict):
|
|
89
|
+
return cls.model_validate(obj)
|
|
90
|
+
|
|
91
|
+
_obj = cls.model_validate({"name": obj.get("name")})
|
|
92
|
+
return _obj
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
STACKIT Git API
|
|
5
|
+
|
|
6
|
+
Manage STACKIT Git instances.
|
|
7
|
+
|
|
8
|
+
The version of the OpenAPI document: 1beta.0.3
|
|
9
|
+
Contact: git@stackit.cloud
|
|
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
|
+
from __future__ import annotations
|
|
16
|
+
|
|
17
|
+
import json
|
|
18
|
+
import pprint
|
|
19
|
+
from datetime import datetime
|
|
20
|
+
from typing import Any, ClassVar, Dict, List, Optional, Set
|
|
21
|
+
|
|
22
|
+
from pydantic import BaseModel, ConfigDict, Field, field_validator
|
|
23
|
+
from typing_extensions import Annotated, Self
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class Instance(BaseModel):
|
|
27
|
+
"""
|
|
28
|
+
Describes a STACKIT Git instance.
|
|
29
|
+
"""
|
|
30
|
+
|
|
31
|
+
created: datetime = Field(description="The date and time the creation of the STACKIT GIT instance was triggered.")
|
|
32
|
+
id: Annotated[str, Field(strict=True, max_length=36)] = Field(
|
|
33
|
+
description="A auto generated unique id which identifies the STACKIT GIT instances."
|
|
34
|
+
)
|
|
35
|
+
name: Annotated[str, Field(strict=True, max_length=32)] = Field(
|
|
36
|
+
description="A user chosen name to distinguish multiple STACKIT GIT instances."
|
|
37
|
+
)
|
|
38
|
+
state: Annotated[str, Field(strict=True, max_length=32)] = Field(
|
|
39
|
+
description="The current state of the STACKIT GIT instance."
|
|
40
|
+
)
|
|
41
|
+
url: Annotated[str, Field(strict=True, max_length=2048)] = Field(
|
|
42
|
+
description="The URL for reaching the STACKIT GIT instance."
|
|
43
|
+
)
|
|
44
|
+
version: Annotated[str, Field(strict=True, max_length=20)] = Field(
|
|
45
|
+
description="The current version of STACKIT GIT deployed to the instance."
|
|
46
|
+
)
|
|
47
|
+
__properties: ClassVar[List[str]] = ["created", "id", "name", "state", "url", "version"]
|
|
48
|
+
|
|
49
|
+
@field_validator("state")
|
|
50
|
+
def state_validate_enum(cls, value):
|
|
51
|
+
"""Validates the enum"""
|
|
52
|
+
if value not in set(["Creating", "WaitingForResources", "Updating", "Deleting", "Ready", "Error"]):
|
|
53
|
+
raise ValueError(
|
|
54
|
+
"must be one of enum values ('Creating', 'WaitingForResources', 'Updating', 'Deleting', 'Ready', 'Error')"
|
|
55
|
+
)
|
|
56
|
+
return value
|
|
57
|
+
|
|
58
|
+
model_config = ConfigDict(
|
|
59
|
+
populate_by_name=True,
|
|
60
|
+
validate_assignment=True,
|
|
61
|
+
protected_namespaces=(),
|
|
62
|
+
)
|
|
63
|
+
|
|
64
|
+
def to_str(self) -> str:
|
|
65
|
+
"""Returns the string representation of the model using alias"""
|
|
66
|
+
return pprint.pformat(self.model_dump(by_alias=True))
|
|
67
|
+
|
|
68
|
+
def to_json(self) -> str:
|
|
69
|
+
"""Returns the JSON representation of the model using alias"""
|
|
70
|
+
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
|
|
71
|
+
return json.dumps(self.to_dict())
|
|
72
|
+
|
|
73
|
+
@classmethod
|
|
74
|
+
def from_json(cls, json_str: str) -> Optional[Self]:
|
|
75
|
+
"""Create an instance of Instance from a JSON string"""
|
|
76
|
+
return cls.from_dict(json.loads(json_str))
|
|
77
|
+
|
|
78
|
+
def to_dict(self) -> Dict[str, Any]:
|
|
79
|
+
"""Return the dictionary representation of the model using alias.
|
|
80
|
+
|
|
81
|
+
This has the following differences from calling pydantic's
|
|
82
|
+
`self.model_dump(by_alias=True)`:
|
|
83
|
+
|
|
84
|
+
* `None` is only added to the output dict for nullable fields that
|
|
85
|
+
were set at model initialization. Other fields with value `None`
|
|
86
|
+
are ignored.
|
|
87
|
+
"""
|
|
88
|
+
excluded_fields: Set[str] = set([])
|
|
89
|
+
|
|
90
|
+
_dict = self.model_dump(
|
|
91
|
+
by_alias=True,
|
|
92
|
+
exclude=excluded_fields,
|
|
93
|
+
exclude_none=True,
|
|
94
|
+
)
|
|
95
|
+
return _dict
|
|
96
|
+
|
|
97
|
+
@classmethod
|
|
98
|
+
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
|
99
|
+
"""Create an instance of Instance from a dict"""
|
|
100
|
+
if obj is None:
|
|
101
|
+
return None
|
|
102
|
+
|
|
103
|
+
if not isinstance(obj, dict):
|
|
104
|
+
return cls.model_validate(obj)
|
|
105
|
+
|
|
106
|
+
_obj = cls.model_validate(
|
|
107
|
+
{
|
|
108
|
+
"created": obj.get("created"),
|
|
109
|
+
"id": obj.get("id"),
|
|
110
|
+
"name": obj.get("name"),
|
|
111
|
+
"state": obj.get("state"),
|
|
112
|
+
"url": obj.get("url"),
|
|
113
|
+
"version": obj.get("version"),
|
|
114
|
+
}
|
|
115
|
+
)
|
|
116
|
+
return _obj
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
STACKIT Git API
|
|
5
|
+
|
|
6
|
+
Manage STACKIT Git instances.
|
|
7
|
+
|
|
8
|
+
The version of the OpenAPI document: 1beta.0.3
|
|
9
|
+
Contact: git@stackit.cloud
|
|
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
|
+
from __future__ import annotations
|
|
16
|
+
|
|
17
|
+
import json
|
|
18
|
+
import pprint
|
|
19
|
+
from typing import Any, ClassVar, Dict, List, Optional, Set
|
|
20
|
+
|
|
21
|
+
from pydantic import BaseModel, ConfigDict, StrictStr
|
|
22
|
+
from typing_extensions import Self
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class InternalServerErrorResponse(BaseModel):
|
|
26
|
+
"""
|
|
27
|
+
Internal server error.
|
|
28
|
+
"""
|
|
29
|
+
|
|
30
|
+
error: Optional[StrictStr] = None
|
|
31
|
+
__properties: ClassVar[List[str]] = ["error"]
|
|
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 InternalServerErrorResponse 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 InternalServerErrorResponse 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({"error": obj.get("error")})
|
|
82
|
+
return _obj
|