stackit-runcommand 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/runcommand/__init__.py +48 -0
- stackit/runcommand/api/__init__.py +4 -0
- stackit/runcommand/api/default_api.py +1345 -0
- stackit/runcommand/api_client.py +627 -0
- stackit/runcommand/api_response.py +23 -0
- stackit/runcommand/configuration.py +112 -0
- stackit/runcommand/exceptions.py +199 -0
- stackit/runcommand/models/__init__.py +29 -0
- stackit/runcommand/models/command_details.py +122 -0
- stackit/runcommand/models/command_template.py +84 -0
- stackit/runcommand/models/command_template_response.py +99 -0
- stackit/runcommand/models/command_template_schema.py +103 -0
- stackit/runcommand/models/commands.py +113 -0
- stackit/runcommand/models/create_command_payload.py +85 -0
- stackit/runcommand/models/error_response.py +85 -0
- stackit/runcommand/models/get_commands_response.py +93 -0
- stackit/runcommand/models/model_field.py +98 -0
- stackit/runcommand/models/new_command_response.py +82 -0
- stackit/runcommand/models/parameters_schema.py +89 -0
- stackit/runcommand/models/properties.py +112 -0
- stackit/runcommand/py.typed +0 -0
- stackit/runcommand/rest.py +149 -0
- stackit_runcommand-0.0.1a0.dist-info/METADATA +44 -0
- stackit_runcommand-0.0.1a0.dist-info/RECORD +25 -0
- stackit_runcommand-0.0.1a0.dist-info/WHEEL +4 -0
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
STACKIT Run Commands Service API
|
|
5
|
+
|
|
6
|
+
API endpoints for the STACKIT Run Commands Service API
|
|
7
|
+
|
|
8
|
+
The version of the OpenAPI document: 1.0
|
|
9
|
+
Contact: support@stackit.de
|
|
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
|
+
class HostConfiguration:
|
|
17
|
+
def __init__(
|
|
18
|
+
self,
|
|
19
|
+
region=None,
|
|
20
|
+
server_index=None,
|
|
21
|
+
server_variables=None,
|
|
22
|
+
server_operation_index=None,
|
|
23
|
+
server_operation_variables=None,
|
|
24
|
+
ignore_operation_servers=False,
|
|
25
|
+
) -> None:
|
|
26
|
+
"""Constructor"""
|
|
27
|
+
self._base_path = "https://run-command.api.eu01.stackit.cloud"
|
|
28
|
+
"""Default Base url
|
|
29
|
+
"""
|
|
30
|
+
self.server_index = 0 if server_index is None else server_index
|
|
31
|
+
self.server_operation_index = server_operation_index or {}
|
|
32
|
+
"""Default server index
|
|
33
|
+
"""
|
|
34
|
+
self.server_variables = server_variables or {}
|
|
35
|
+
if region:
|
|
36
|
+
self.server_variables["region"] = "{}.".format(region)
|
|
37
|
+
self.server_operation_variables = server_operation_variables or {}
|
|
38
|
+
"""Default server variables
|
|
39
|
+
"""
|
|
40
|
+
self.ignore_operation_servers = ignore_operation_servers
|
|
41
|
+
"""Ignore operation servers
|
|
42
|
+
"""
|
|
43
|
+
|
|
44
|
+
def get_host_settings(self):
|
|
45
|
+
"""Gets an array of host settings
|
|
46
|
+
|
|
47
|
+
:return: An array of host settings
|
|
48
|
+
"""
|
|
49
|
+
return [
|
|
50
|
+
{
|
|
51
|
+
"url": "https://run-command.api.{region}stackit.cloud",
|
|
52
|
+
"description": "No description provided",
|
|
53
|
+
"variables": {
|
|
54
|
+
"region": {
|
|
55
|
+
"description": "No description provided",
|
|
56
|
+
"default_value": "eu01.",
|
|
57
|
+
"enum_values": ["eu01."],
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
}
|
|
61
|
+
]
|
|
62
|
+
|
|
63
|
+
def get_host_from_settings(self, index, variables=None, servers=None):
|
|
64
|
+
"""Gets host URL based on the index and variables
|
|
65
|
+
:param index: array index of the host settings
|
|
66
|
+
:param variables: hash of variable and the corresponding value
|
|
67
|
+
:param servers: an array of host settings or None
|
|
68
|
+
:return: URL based on host settings
|
|
69
|
+
"""
|
|
70
|
+
if index is None:
|
|
71
|
+
return self._base_path
|
|
72
|
+
|
|
73
|
+
variables = {} if variables is None else variables
|
|
74
|
+
servers = self.get_host_settings() if servers is None else servers
|
|
75
|
+
|
|
76
|
+
try:
|
|
77
|
+
server = servers[index]
|
|
78
|
+
except IndexError:
|
|
79
|
+
raise ValueError(
|
|
80
|
+
"Invalid index {0} when selecting the host settings. "
|
|
81
|
+
"Must be less than {1}".format(index, len(servers))
|
|
82
|
+
)
|
|
83
|
+
|
|
84
|
+
url = server["url"]
|
|
85
|
+
|
|
86
|
+
# go through variables and replace placeholders
|
|
87
|
+
for variable_name, variable in server.get("variables", {}).items():
|
|
88
|
+
used_value = variables.get(variable_name, variable["default_value"])
|
|
89
|
+
|
|
90
|
+
if "enum_values" in variable and used_value not in variable["enum_values"]:
|
|
91
|
+
given_value = variables[variable_name].replace(".", "")
|
|
92
|
+
valid_values = [v.replace(".", "") for v in variable["enum_values"]]
|
|
93
|
+
raise ValueError(
|
|
94
|
+
"The variable `{0}` in the host URL has invalid value '{1}'. Must be '{2}'.".format(
|
|
95
|
+
variable_name, given_value, valid_values
|
|
96
|
+
)
|
|
97
|
+
)
|
|
98
|
+
|
|
99
|
+
url = url.replace("{" + variable_name + "}", used_value)
|
|
100
|
+
|
|
101
|
+
return url
|
|
102
|
+
|
|
103
|
+
@property
|
|
104
|
+
def host(self):
|
|
105
|
+
"""Return generated host."""
|
|
106
|
+
return self.get_host_from_settings(self.server_index, variables=self.server_variables)
|
|
107
|
+
|
|
108
|
+
@host.setter
|
|
109
|
+
def host(self, value):
|
|
110
|
+
"""Fix base path."""
|
|
111
|
+
self._base_path = value
|
|
112
|
+
self.server_index = None
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
STACKIT Run Commands Service API
|
|
5
|
+
|
|
6
|
+
API endpoints for the STACKIT Run Commands Service API
|
|
7
|
+
|
|
8
|
+
The version of the OpenAPI document: 1.0
|
|
9
|
+
Contact: support@stackit.de
|
|
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,29 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
# flake8: noqa
|
|
4
|
+
"""
|
|
5
|
+
STACKIT Run Commands Service API
|
|
6
|
+
|
|
7
|
+
API endpoints for the STACKIT Run Commands Service API
|
|
8
|
+
|
|
9
|
+
The version of the OpenAPI document: 1.0
|
|
10
|
+
Contact: support@stackit.de
|
|
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.runcommand.models.command_details import CommandDetails
|
|
19
|
+
from stackit.runcommand.models.command_template import CommandTemplate
|
|
20
|
+
from stackit.runcommand.models.command_template_response import CommandTemplateResponse
|
|
21
|
+
from stackit.runcommand.models.command_template_schema import CommandTemplateSchema
|
|
22
|
+
from stackit.runcommand.models.commands import Commands
|
|
23
|
+
from stackit.runcommand.models.create_command_payload import CreateCommandPayload
|
|
24
|
+
from stackit.runcommand.models.error_response import ErrorResponse
|
|
25
|
+
from stackit.runcommand.models.get_commands_response import GetCommandsResponse
|
|
26
|
+
from stackit.runcommand.models.model_field import ModelField
|
|
27
|
+
from stackit.runcommand.models.new_command_response import NewCommandResponse
|
|
28
|
+
from stackit.runcommand.models.parameters_schema import ParametersSchema
|
|
29
|
+
from stackit.runcommand.models.properties import Properties
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
STACKIT Run Commands Service API
|
|
5
|
+
|
|
6
|
+
API endpoints for the STACKIT Run Commands Service API
|
|
7
|
+
|
|
8
|
+
The version of the OpenAPI document: 1.0
|
|
9
|
+
Contact: support@stackit.de
|
|
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, Field, StrictInt, StrictStr, field_validator
|
|
22
|
+
from typing_extensions import Self
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class CommandDetails(BaseModel):
|
|
26
|
+
"""
|
|
27
|
+
CommandDetails
|
|
28
|
+
"""
|
|
29
|
+
|
|
30
|
+
command_template_name: Optional[StrictStr] = Field(default=None, alias="commandTemplateName")
|
|
31
|
+
command_template_title: Optional[StrictStr] = Field(default=None, alias="commandTemplateTitle")
|
|
32
|
+
exit_code: Optional[StrictInt] = Field(default=None, alias="exitCode")
|
|
33
|
+
finished_at: Optional[StrictStr] = Field(default=None, alias="finishedAt")
|
|
34
|
+
id: Optional[StrictInt] = None
|
|
35
|
+
output: Optional[StrictStr] = None
|
|
36
|
+
script: Optional[StrictStr] = None
|
|
37
|
+
started_at: Optional[StrictStr] = Field(default=None, alias="startedAt")
|
|
38
|
+
status: Optional[StrictStr] = None
|
|
39
|
+
__properties: ClassVar[List[str]] = [
|
|
40
|
+
"commandTemplateName",
|
|
41
|
+
"commandTemplateTitle",
|
|
42
|
+
"exitCode",
|
|
43
|
+
"finishedAt",
|
|
44
|
+
"id",
|
|
45
|
+
"output",
|
|
46
|
+
"script",
|
|
47
|
+
"startedAt",
|
|
48
|
+
"status",
|
|
49
|
+
]
|
|
50
|
+
|
|
51
|
+
@field_validator("status")
|
|
52
|
+
def status_validate_enum(cls, value):
|
|
53
|
+
"""Validates the enum"""
|
|
54
|
+
if value is None:
|
|
55
|
+
return value
|
|
56
|
+
|
|
57
|
+
if value not in set(["pending", "running", "completed", "failed"]):
|
|
58
|
+
raise ValueError("must be one of enum values ('pending', 'running', 'completed', 'failed')")
|
|
59
|
+
return value
|
|
60
|
+
|
|
61
|
+
model_config = ConfigDict(
|
|
62
|
+
populate_by_name=True,
|
|
63
|
+
validate_assignment=True,
|
|
64
|
+
protected_namespaces=(),
|
|
65
|
+
)
|
|
66
|
+
|
|
67
|
+
def to_str(self) -> str:
|
|
68
|
+
"""Returns the string representation of the model using alias"""
|
|
69
|
+
return pprint.pformat(self.model_dump(by_alias=True))
|
|
70
|
+
|
|
71
|
+
def to_json(self) -> str:
|
|
72
|
+
"""Returns the JSON representation of the model using alias"""
|
|
73
|
+
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
|
|
74
|
+
return json.dumps(self.to_dict())
|
|
75
|
+
|
|
76
|
+
@classmethod
|
|
77
|
+
def from_json(cls, json_str: str) -> Optional[Self]:
|
|
78
|
+
"""Create an instance of CommandDetails from a JSON string"""
|
|
79
|
+
return cls.from_dict(json.loads(json_str))
|
|
80
|
+
|
|
81
|
+
def to_dict(self) -> Dict[str, Any]:
|
|
82
|
+
"""Return the dictionary representation of the model using alias.
|
|
83
|
+
|
|
84
|
+
This has the following differences from calling pydantic's
|
|
85
|
+
`self.model_dump(by_alias=True)`:
|
|
86
|
+
|
|
87
|
+
* `None` is only added to the output dict for nullable fields that
|
|
88
|
+
were set at model initialization. Other fields with value `None`
|
|
89
|
+
are ignored.
|
|
90
|
+
"""
|
|
91
|
+
excluded_fields: Set[str] = set([])
|
|
92
|
+
|
|
93
|
+
_dict = self.model_dump(
|
|
94
|
+
by_alias=True,
|
|
95
|
+
exclude=excluded_fields,
|
|
96
|
+
exclude_none=True,
|
|
97
|
+
)
|
|
98
|
+
return _dict
|
|
99
|
+
|
|
100
|
+
@classmethod
|
|
101
|
+
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
|
102
|
+
"""Create an instance of CommandDetails from a dict"""
|
|
103
|
+
if obj is None:
|
|
104
|
+
return None
|
|
105
|
+
|
|
106
|
+
if not isinstance(obj, dict):
|
|
107
|
+
return cls.model_validate(obj)
|
|
108
|
+
|
|
109
|
+
_obj = cls.model_validate(
|
|
110
|
+
{
|
|
111
|
+
"commandTemplateName": obj.get("commandTemplateName"),
|
|
112
|
+
"commandTemplateTitle": obj.get("commandTemplateTitle"),
|
|
113
|
+
"exitCode": obj.get("exitCode"),
|
|
114
|
+
"finishedAt": obj.get("finishedAt"),
|
|
115
|
+
"id": obj.get("id"),
|
|
116
|
+
"output": obj.get("output"),
|
|
117
|
+
"script": obj.get("script"),
|
|
118
|
+
"startedAt": obj.get("startedAt"),
|
|
119
|
+
"status": obj.get("status"),
|
|
120
|
+
}
|
|
121
|
+
)
|
|
122
|
+
return _obj
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
STACKIT Run Commands Service API
|
|
5
|
+
|
|
6
|
+
API endpoints for the STACKIT Run Commands Service API
|
|
7
|
+
|
|
8
|
+
The version of the OpenAPI document: 1.0
|
|
9
|
+
Contact: support@stackit.de
|
|
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, Field, StrictStr
|
|
22
|
+
from typing_extensions import Self
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class CommandTemplate(BaseModel):
|
|
26
|
+
"""
|
|
27
|
+
CommandTemplate
|
|
28
|
+
"""
|
|
29
|
+
|
|
30
|
+
name: Optional[StrictStr] = None
|
|
31
|
+
os_type: Optional[List[StrictStr]] = Field(default=None, alias="osType")
|
|
32
|
+
title: Optional[StrictStr] = None
|
|
33
|
+
__properties: ClassVar[List[str]] = ["name", "osType", "title"]
|
|
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 CommandTemplate 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 CommandTemplate 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({"name": obj.get("name"), "osType": obj.get("osType"), "title": obj.get("title")})
|
|
84
|
+
return _obj
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
STACKIT Run Commands Service API
|
|
5
|
+
|
|
6
|
+
API endpoints for the STACKIT Run Commands Service API
|
|
7
|
+
|
|
8
|
+
The version of the OpenAPI document: 1.0
|
|
9
|
+
Contact: support@stackit.de
|
|
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
|
|
22
|
+
from typing_extensions import Self
|
|
23
|
+
|
|
24
|
+
from stackit.runcommand.models.command_template import CommandTemplate
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class CommandTemplateResponse(BaseModel):
|
|
28
|
+
"""
|
|
29
|
+
CommandTemplateResponse
|
|
30
|
+
"""
|
|
31
|
+
|
|
32
|
+
items: Optional[List[CommandTemplate]] = None
|
|
33
|
+
__properties: ClassVar[List[str]] = ["items"]
|
|
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 CommandTemplateResponse 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
|
+
# override the default output from pydantic by calling `to_dict()` of each item in items (list)
|
|
73
|
+
_items = []
|
|
74
|
+
if self.items:
|
|
75
|
+
for _item in self.items:
|
|
76
|
+
if _item:
|
|
77
|
+
_items.append(_item.to_dict())
|
|
78
|
+
_dict["items"] = _items
|
|
79
|
+
return _dict
|
|
80
|
+
|
|
81
|
+
@classmethod
|
|
82
|
+
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
|
83
|
+
"""Create an instance of CommandTemplateResponse from a dict"""
|
|
84
|
+
if obj is None:
|
|
85
|
+
return None
|
|
86
|
+
|
|
87
|
+
if not isinstance(obj, dict):
|
|
88
|
+
return cls.model_validate(obj)
|
|
89
|
+
|
|
90
|
+
_obj = cls.model_validate(
|
|
91
|
+
{
|
|
92
|
+
"items": (
|
|
93
|
+
[CommandTemplate.from_dict(_item) for _item in obj["items"]]
|
|
94
|
+
if obj.get("items") is not None
|
|
95
|
+
else None
|
|
96
|
+
)
|
|
97
|
+
}
|
|
98
|
+
)
|
|
99
|
+
return _obj
|