stackit-serviceenablement 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 Service Enablement API
5
+
6
+ STACKIT Service Enablement API
7
+
8
+ The version of the OpenAPI document: 1.1
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://service-enablement.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://service-enablement.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 Service Enablement API
5
+
6
+ STACKIT Service Enablement API
7
+
8
+ The version of the OpenAPI document: 1.1
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,25 @@
1
+ # coding: utf-8
2
+
3
+ # flake8: noqa
4
+ """
5
+ STACKIT Service Enablement API
6
+
7
+ STACKIT Service Enablement API
8
+
9
+ The version of the OpenAPI document: 1.1
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.serviceenablement.models.action_error import ActionError
18
+ from stackit.serviceenablement.models.cloud_service import CloudService
19
+ from stackit.serviceenablement.models.dependencies import Dependencies
20
+ from stackit.serviceenablement.models.list_service_status200_response import (
21
+ ListServiceStatus200Response,
22
+ )
23
+ from stackit.serviceenablement.models.parameters import Parameters
24
+ from stackit.serviceenablement.models.parameters_general import ParametersGeneral
25
+ from stackit.serviceenablement.models.service_status import ServiceStatus
@@ -0,0 +1,93 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ STACKIT Service Enablement API
5
+
6
+ STACKIT Service Enablement API
7
+
8
+ The version of the OpenAPI document: 1.1
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, field_validator
21
+ from typing_extensions import Self
22
+
23
+
24
+ class ActionError(BaseModel):
25
+ """
26
+ the last error for this service.
27
+ """
28
+
29
+ action: Optional[StrictStr] = Field(default=None, description="the last action which was triggered on this service")
30
+ code: Optional[StrictStr] = Field(default=None, description="the error code if provided by the service")
31
+ reason: Optional[StrictStr] = Field(default=None, description="the error reason provided by the service")
32
+ __properties: ClassVar[List[str]] = ["action", "code", "reason"]
33
+
34
+ @field_validator("action")
35
+ def action_validate_enum(cls, value):
36
+ """Validates the enum"""
37
+ if value is None:
38
+ return value
39
+
40
+ if value not in set(["DISABLE", "ENABLE"]):
41
+ raise ValueError("must be one of enum values ('DISABLE', 'ENABLE')")
42
+ return value
43
+
44
+ model_config = ConfigDict(
45
+ populate_by_name=True,
46
+ validate_assignment=True,
47
+ protected_namespaces=(),
48
+ )
49
+
50
+ def to_str(self) -> str:
51
+ """Returns the string representation of the model using alias"""
52
+ return pprint.pformat(self.model_dump(by_alias=True))
53
+
54
+ def to_json(self) -> str:
55
+ """Returns the JSON representation of the model using alias"""
56
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
57
+ return json.dumps(self.to_dict())
58
+
59
+ @classmethod
60
+ def from_json(cls, json_str: str) -> Optional[Self]:
61
+ """Create an instance of ActionError from a JSON string"""
62
+ return cls.from_dict(json.loads(json_str))
63
+
64
+ def to_dict(self) -> Dict[str, Any]:
65
+ """Return the dictionary representation of the model using alias.
66
+
67
+ This has the following differences from calling pydantic's
68
+ `self.model_dump(by_alias=True)`:
69
+
70
+ * `None` is only added to the output dict for nullable fields that
71
+ were set at model initialization. Other fields with value `None`
72
+ are ignored.
73
+ """
74
+ excluded_fields: Set[str] = set([])
75
+
76
+ _dict = self.model_dump(
77
+ by_alias=True,
78
+ exclude=excluded_fields,
79
+ exclude_none=True,
80
+ )
81
+ return _dict
82
+
83
+ @classmethod
84
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
85
+ """Create an instance of ActionError from a dict"""
86
+ if obj is None:
87
+ return None
88
+
89
+ if not isinstance(obj, dict):
90
+ return cls.model_validate(obj)
91
+
92
+ _obj = cls.model_validate({"action": obj.get("action"), "code": obj.get("code"), "reason": obj.get("reason")})
93
+ return _obj
@@ -0,0 +1,121 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ STACKIT Service Enablement API
5
+
6
+ STACKIT Service Enablement API
7
+
8
+ The version of the OpenAPI document: 1.1
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.serviceenablement.models.dependencies import Dependencies
25
+
26
+
27
+ class CloudService(BaseModel):
28
+ """
29
+ CloudService
30
+ """
31
+
32
+ dependencies: Optional[Dependencies] = None
33
+ labels: Optional[Dict[str, StrictStr]] = None
34
+ scope: Optional[StrictStr] = "PUBLIC"
35
+ service_id: Optional[Annotated[str, Field(min_length=10, strict=True, max_length=255)]] = Field(
36
+ default=None, description="the id of the service", alias="serviceId"
37
+ )
38
+ __properties: ClassVar[List[str]] = ["dependencies", "labels", "scope", "serviceId"]
39
+
40
+ @field_validator("scope")
41
+ def scope_validate_enum(cls, value):
42
+ """Validates the enum"""
43
+ if value is None:
44
+ return value
45
+
46
+ if value not in set(["PRIVATE", "PUBLIC"]):
47
+ raise ValueError("must be one of enum values ('PRIVATE', 'PUBLIC')")
48
+ return value
49
+
50
+ @field_validator("service_id")
51
+ def service_id_validate_regular_expression(cls, value):
52
+ """Validates the regular expression"""
53
+ if value is None:
54
+ return value
55
+
56
+ if not re.match(r"^[a-zA-Z0-9][a-zA-Z0-9._-]{1,254}$", value):
57
+ raise ValueError(r"must validate the regular expression /^[a-zA-Z0-9][a-zA-Z0-9._-]{1,254}$/")
58
+ return value
59
+
60
+ model_config = ConfigDict(
61
+ populate_by_name=True,
62
+ validate_assignment=True,
63
+ protected_namespaces=(),
64
+ )
65
+
66
+ def to_str(self) -> str:
67
+ """Returns the string representation of the model using alias"""
68
+ return pprint.pformat(self.model_dump(by_alias=True))
69
+
70
+ def to_json(self) -> str:
71
+ """Returns the JSON representation of the model using alias"""
72
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
73
+ return json.dumps(self.to_dict())
74
+
75
+ @classmethod
76
+ def from_json(cls, json_str: str) -> Optional[Self]:
77
+ """Create an instance of CloudService from a JSON string"""
78
+ return cls.from_dict(json.loads(json_str))
79
+
80
+ def to_dict(self) -> Dict[str, Any]:
81
+ """Return the dictionary representation of the model using alias.
82
+
83
+ This has the following differences from calling pydantic's
84
+ `self.model_dump(by_alias=True)`:
85
+
86
+ * `None` is only added to the output dict for nullable fields that
87
+ were set at model initialization. Other fields with value `None`
88
+ are ignored.
89
+ """
90
+ excluded_fields: Set[str] = set([])
91
+
92
+ _dict = self.model_dump(
93
+ by_alias=True,
94
+ exclude=excluded_fields,
95
+ exclude_none=True,
96
+ )
97
+ # override the default output from pydantic by calling `to_dict()` of dependencies
98
+ if self.dependencies:
99
+ _dict["dependencies"] = self.dependencies.to_dict()
100
+ return _dict
101
+
102
+ @classmethod
103
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
104
+ """Create an instance of CloudService from a dict"""
105
+ if obj is None:
106
+ return None
107
+
108
+ if not isinstance(obj, dict):
109
+ return cls.model_validate(obj)
110
+
111
+ _obj = cls.model_validate(
112
+ {
113
+ "dependencies": (
114
+ Dependencies.from_dict(obj["dependencies"]) if obj.get("dependencies") is not None else None
115
+ ),
116
+ "labels": obj.get("labels"),
117
+ "scope": obj.get("scope") if obj.get("scope") is not None else "PUBLIC",
118
+ "serviceId": obj.get("serviceId"),
119
+ }
120
+ )
121
+ return _obj
@@ -0,0 +1,88 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ STACKIT Service Enablement API
5
+
6
+ STACKIT Service Enablement API
7
+
8
+ The version of the OpenAPI document: 1.1
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
21
+ from typing_extensions import Annotated, Self
22
+
23
+
24
+ class Dependencies(BaseModel):
25
+ """
26
+ Dependencies
27
+ """
28
+
29
+ hard: Optional[List[Annotated[str, Field(min_length=10, strict=True, max_length=255)]]] = Field(
30
+ default=None,
31
+ description="a list of service IDs which this service depend on. If the service is enabled, those service are enabled as well automatically.",
32
+ )
33
+ soft: Optional[List[Annotated[str, Field(min_length=10, strict=True, max_length=255)]]] = Field(
34
+ default=None,
35
+ description="a list of service IDs which this service depend on. When they are disabled a notification is sent.",
36
+ )
37
+ __properties: ClassVar[List[str]] = ["hard", "soft"]
38
+
39
+ model_config = ConfigDict(
40
+ populate_by_name=True,
41
+ validate_assignment=True,
42
+ protected_namespaces=(),
43
+ )
44
+
45
+ def to_str(self) -> str:
46
+ """Returns the string representation of the model using alias"""
47
+ return pprint.pformat(self.model_dump(by_alias=True))
48
+
49
+ def to_json(self) -> str:
50
+ """Returns the JSON representation of the model using alias"""
51
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
52
+ return json.dumps(self.to_dict())
53
+
54
+ @classmethod
55
+ def from_json(cls, json_str: str) -> Optional[Self]:
56
+ """Create an instance of Dependencies from a JSON string"""
57
+ return cls.from_dict(json.loads(json_str))
58
+
59
+ def to_dict(self) -> Dict[str, Any]:
60
+ """Return the dictionary representation of the model using alias.
61
+
62
+ This has the following differences from calling pydantic's
63
+ `self.model_dump(by_alias=True)`:
64
+
65
+ * `None` is only added to the output dict for nullable fields that
66
+ were set at model initialization. Other fields with value `None`
67
+ are ignored.
68
+ """
69
+ excluded_fields: Set[str] = set([])
70
+
71
+ _dict = self.model_dump(
72
+ by_alias=True,
73
+ exclude=excluded_fields,
74
+ exclude_none=True,
75
+ )
76
+ return _dict
77
+
78
+ @classmethod
79
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
80
+ """Create an instance of Dependencies from a dict"""
81
+ if obj is None:
82
+ return None
83
+
84
+ if not isinstance(obj, dict):
85
+ return cls.model_validate(obj)
86
+
87
+ _obj = cls.model_validate({"hard": obj.get("hard"), "soft": obj.get("soft")})
88
+ return _obj