stackit-registry 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.
Files changed (33) hide show
  1. stackit/registry/__init__.py +111 -0
  2. stackit/registry/api/__init__.py +4 -0
  3. stackit/registry/api/default_api.py +1767 -0
  4. stackit/registry/api_client.py +650 -0
  5. stackit/registry/api_response.py +22 -0
  6. stackit/registry/configuration.py +163 -0
  7. stackit/registry/exceptions.py +218 -0
  8. stackit/registry/models/__init__.py +38 -0
  9. stackit/registry/models/artifactory.py +131 -0
  10. stackit/registry/models/artifactory_list.py +105 -0
  11. stackit/registry/models/bad_request_error_response.py +84 -0
  12. stackit/registry/models/conflict_error_response.py +84 -0
  13. stackit/registry/models/create_artifactory_payload.py +110 -0
  14. stackit/registry/models/create_proxy_request.py +102 -0
  15. stackit/registry/models/credentials.py +84 -0
  16. stackit/registry/models/forbidden_error_response.py +110 -0
  17. stackit/registry/models/generic_error_response.py +84 -0
  18. stackit/registry/models/internal_server_error_response.py +84 -0
  19. stackit/registry/models/not_found_error_response.py +84 -0
  20. stackit/registry/models/patch_artifactory_payload.py +90 -0
  21. stackit/registry/models/proxy.py +102 -0
  22. stackit/registry/models/redacted_credentials.py +83 -0
  23. stackit/registry/models/replication_adapter.py +100 -0
  24. stackit/registry/models/replication_adapter_list.py +105 -0
  25. stackit/registry/models/unauthorized_error_response.py +110 -0
  26. stackit/registry/models/update_proxy_request.py +98 -0
  27. stackit/registry/py.typed +0 -0
  28. stackit/registry/rest.py +164 -0
  29. stackit_registry-0.1.0.dist-info/METADATA +47 -0
  30. stackit_registry-0.1.0.dist-info/RECORD +33 -0
  31. stackit_registry-0.1.0.dist-info/WHEEL +4 -0
  32. stackit_registry-0.1.0.dist-info/licenses/LICENSE.md +201 -0
  33. stackit_registry-0.1.0.dist-info/licenses/NOTICE.txt +2 -0
@@ -0,0 +1,163 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ STACKIT Container Registry API
5
+
6
+ STACKIT Container Registry management API.
7
+
8
+ The version of the OpenAPI document: 1.0.0
9
+ Contact: devex_development@stackit.cloud
10
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
11
+
12
+ Do not edit the class manually.
13
+ """ # noqa: E501
14
+
15
+ import sys
16
+ from typing import Dict, List, Optional, TypedDict
17
+
18
+ from typing_extensions import NotRequired
19
+
20
+ import os
21
+
22
+ ServerVariablesT = Dict[str, str]
23
+
24
+
25
+ class HostSettingVariable(TypedDict):
26
+ description: str
27
+ default_value: str
28
+ enum_values: List[str]
29
+
30
+
31
+ class HostSetting(TypedDict):
32
+ url: str
33
+ description: str
34
+ variables: NotRequired[Dict[str, HostSettingVariable]]
35
+
36
+
37
+ class HostConfiguration:
38
+ def __init__(
39
+ self,
40
+ region=None,
41
+ server_index=None,
42
+ server_variables=None,
43
+ server_operation_index=None,
44
+ server_operation_variables=None,
45
+ ignore_operation_servers=False,
46
+ ) -> None:
47
+ print(
48
+ "WARNING: STACKIT will move to a new way of specifying regions, where the region is provided\n",
49
+ "as a function argument instead of being set in the client configuration.\n"
50
+ "Once all services have migrated, the methods to specify the region in the client configuration "
51
+ "will be removed.",
52
+ file=sys.stderr,
53
+ )
54
+ """Constructor
55
+ """
56
+ self._base_path = "https://registry.api.stackit.cloud"
57
+ """Default Base url
58
+ """
59
+ self.server_index = 0 if server_index is None else server_index
60
+ self.server_operation_index = server_operation_index or {}
61
+ """Default server index
62
+ """
63
+ self.server_variables = server_variables or {}
64
+ if region:
65
+ self.server_variables["region"] = "{}.".format(region)
66
+ self.server_operation_variables = server_operation_variables or {}
67
+ """Default server variables
68
+ """
69
+ self.ignore_operation_servers = ignore_operation_servers
70
+ """Ignore operation servers
71
+ """
72
+
73
+ def get_host_settings(self) -> List[HostSetting]:
74
+ """Gets an array of host settings
75
+
76
+ :return: An array of host settings
77
+ """
78
+ return [
79
+ {
80
+ "url": "https://registry.api.stackit.cloud",
81
+ "description": "No description provided",
82
+ "variables": {
83
+ "region": {
84
+ "description": "No description provided",
85
+ "default_value": "global",
86
+ }
87
+ },
88
+ }
89
+ ]
90
+
91
+ def get_host_from_settings(
92
+ self,
93
+ index: Optional[int],
94
+ variables: Optional[ServerVariablesT] = None,
95
+ servers: Optional[List[HostSetting]] = None,
96
+ ) -> str:
97
+ """Gets host URL based on the index and variables
98
+ :param index: array index of the host settings
99
+ :param variables: hash of variable and the corresponding value
100
+ :param servers: an array of host settings or None
101
+ :error: if a region is given for a global url
102
+ :return: URL based on host settings
103
+ """
104
+ if index is None:
105
+ return self._base_path
106
+
107
+ variables = {} if variables is None else variables
108
+ servers = self.get_host_settings() if servers is None else servers
109
+
110
+ try:
111
+ server = servers[index]
112
+ except IndexError:
113
+ raise ValueError(
114
+ "Invalid index {0} when selecting the host settings. "
115
+ "Must be less than {1}".format(index, len(servers))
116
+ )
117
+
118
+ url = server["url"]
119
+
120
+ # check if environment variable was provided for region
121
+ # if nothing was set this is None
122
+ region_env = os.environ.get("STACKIT_REGION")
123
+
124
+ # go through variables and replace placeholders
125
+ for variable_name, variable in server.get("variables", {}).items():
126
+ # If a region is provided by the user for a global url
127
+ # return an error (except for providing via environment variable).
128
+ # The region is provided as a function argument instead of being set in the client configuration.
129
+ if (
130
+ variable_name == "region"
131
+ and (variable["default_value"] == "global" or variable["default_value"] == "")
132
+ and region_env is None
133
+ and variables.get(variable_name) is not None
134
+ ):
135
+ raise ValueError(
136
+ "this API does not support setting a region in the client configuration, "
137
+ "please check if the region can be specified as a function parameter"
138
+ )
139
+ used_value = variables.get(variable_name, variable["default_value"])
140
+
141
+ if "enum_values" in variable and used_value not in variable["enum_values"]:
142
+ given_value = variables[variable_name].replace(".", "")
143
+ valid_values = [v.replace(".", "") for v in variable["enum_values"]]
144
+ raise ValueError(
145
+ "The variable `{0}` in the host URL has invalid value '{1}'. Must be '{2}'.".format(
146
+ variable_name, given_value, valid_values
147
+ )
148
+ )
149
+
150
+ url = url.replace("{" + variable_name + "}", used_value)
151
+
152
+ return url
153
+
154
+ @property
155
+ def host(self) -> str:
156
+ """Return generated host."""
157
+ return self.get_host_from_settings(self.server_index, variables=self.server_variables)
158
+
159
+ @host.setter
160
+ def host(self, value: str) -> None:
161
+ """Fix base path."""
162
+ self._base_path = value
163
+ self.server_index = None
@@ -0,0 +1,218 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ STACKIT Container Registry API
5
+
6
+ STACKIT Container Registry management API.
7
+
8
+ The version of the OpenAPI document: 1.0.0
9
+ Contact: devex_development@stackit.cloud
10
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
11
+
12
+ Do not edit the class manually.
13
+ """ # noqa: E501
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.headers
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
+ # Added new conditions for 409 and 422
156
+ if http_resp.status == 409:
157
+ raise ConflictException(http_resp=http_resp, body=body, data=data)
158
+
159
+ if http_resp.status == 422:
160
+ raise UnprocessableEntityException(http_resp=http_resp, body=body, data=data)
161
+
162
+ if 500 <= http_resp.status <= 599:
163
+ raise ServiceException(http_resp=http_resp, body=body, data=data)
164
+ raise ApiException(http_resp=http_resp, body=body, data=data)
165
+
166
+ def __str__(self):
167
+ """Custom error messages for exception"""
168
+ error_message = "({0})\n" "Reason: {1}\n".format(self.status, self.reason)
169
+ if self.headers:
170
+ error_message += "HTTP response headers: {0}\n".format(self.headers)
171
+
172
+ if self.data or self.body:
173
+ error_message += "HTTP response body: {0}\n".format(self.data or self.body)
174
+
175
+ return error_message
176
+
177
+
178
+ class BadRequestException(ApiException):
179
+ pass
180
+
181
+
182
+ class NotFoundException(ApiException):
183
+ pass
184
+
185
+
186
+ class UnauthorizedException(ApiException):
187
+ pass
188
+
189
+
190
+ class ForbiddenException(ApiException):
191
+ pass
192
+
193
+
194
+ class ServiceException(ApiException):
195
+ pass
196
+
197
+
198
+ class ConflictException(ApiException):
199
+ """Exception for HTTP 409 Conflict."""
200
+
201
+ pass
202
+
203
+
204
+ class UnprocessableEntityException(ApiException):
205
+ """Exception for HTTP 422 Unprocessable Entity."""
206
+
207
+ pass
208
+
209
+
210
+ def render_path(path_to_item):
211
+ """Returns a string representation of a path"""
212
+ result = ""
213
+ for pth in path_to_item:
214
+ if isinstance(pth, int):
215
+ result += "[{0}]".format(pth)
216
+ else:
217
+ result += "['{0}']".format(pth)
218
+ return result
@@ -0,0 +1,38 @@
1
+ # coding: utf-8
2
+
3
+ # flake8: noqa
4
+ """
5
+ STACKIT Container Registry API
6
+
7
+ STACKIT Container Registry management API.
8
+
9
+ The version of the OpenAPI document: 1.0.0
10
+ Contact: devex_development@stackit.cloud
11
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
12
+
13
+ Do not edit the class manually.
14
+ """ # noqa: E501
15
+
16
+ # import models into model package
17
+ from stackit.registry.models.artifactory import Artifactory
18
+ from stackit.registry.models.artifactory_list import ArtifactoryList
19
+ from stackit.registry.models.bad_request_error_response import BadRequestErrorResponse
20
+ from stackit.registry.models.conflict_error_response import ConflictErrorResponse
21
+ from stackit.registry.models.create_artifactory_payload import CreateArtifactoryPayload
22
+ from stackit.registry.models.create_proxy_request import CreateProxyRequest
23
+ from stackit.registry.models.credentials import Credentials
24
+ from stackit.registry.models.forbidden_error_response import ForbiddenErrorResponse
25
+ from stackit.registry.models.generic_error_response import GenericErrorResponse
26
+ from stackit.registry.models.internal_server_error_response import (
27
+ InternalServerErrorResponse,
28
+ )
29
+ from stackit.registry.models.not_found_error_response import NotFoundErrorResponse
30
+ from stackit.registry.models.patch_artifactory_payload import PatchArtifactoryPayload
31
+ from stackit.registry.models.proxy import Proxy
32
+ from stackit.registry.models.redacted_credentials import RedactedCredentials
33
+ from stackit.registry.models.replication_adapter import ReplicationAdapter
34
+ from stackit.registry.models.replication_adapter_list import ReplicationAdapterList
35
+ from stackit.registry.models.unauthorized_error_response import (
36
+ UnauthorizedErrorResponse,
37
+ )
38
+ from stackit.registry.models.update_proxy_request import UpdateProxyRequest
@@ -0,0 +1,131 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ STACKIT Container Registry API
5
+
6
+ STACKIT Container Registry management API.
7
+
8
+ The version of the OpenAPI document: 1.0.0
9
+ Contact: devex_development@stackit.cloud
10
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
11
+
12
+ Do not edit the class manually.
13
+ """ # noqa: E501
14
+
15
+ from __future__ import annotations
16
+
17
+ import json
18
+ import pprint
19
+ import re # noqa: F401
20
+ from datetime import datetime
21
+ from typing import Any, ClassVar, Dict, List, Optional, Set
22
+ from uuid import UUID
23
+
24
+ from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr, field_validator
25
+ from pydantic_core import to_jsonable_python
26
+ from typing_extensions import Annotated, Self
27
+
28
+ from stackit.registry.models.proxy import Proxy
29
+
30
+
31
+ class Artifactory(BaseModel):
32
+ """
33
+ Artifactory Information.
34
+ """ # noqa: E501
35
+
36
+ consumed_quota_bytes: StrictInt = Field(description="How many bytes of quota is consumed. Read Only.")
37
+ create_time: datetime = Field(
38
+ description="The date and time the creation of the STACKIT Artifactory was triggered."
39
+ )
40
+ id: UUID = Field(description="A auto generated unique id which identifies the STACKIT Artifactory.")
41
+ name: Annotated[str, Field(strict=True, max_length=255)] = Field(
42
+ description="A user chosen name to distinguish multiple STACKIT Artifactories."
43
+ )
44
+ proxy: Optional[Proxy] = None
45
+ state: StrictStr = Field(description="The current state of the STACKIT Artifactory.")
46
+ url: StrictStr = Field(description="The base URL of the STACKIT Artifactory.")
47
+ __properties: ClassVar[List[str]] = ["consumed_quota_bytes", "create_time", "id", "name", "proxy", "state", "url"]
48
+
49
+ @field_validator("create_time", mode="before")
50
+ def create_time_change_year_zero_to_one(cls, value):
51
+ """Workaround which prevents year 0 issue"""
52
+ if isinstance(value, str):
53
+ # Check for year "0000" at the beginning of the string
54
+ # This assumes common date formats like YYYY-MM-DDTHH:MM:SS+00:00 or YYYY-MM-DDTHH:MM:SSZ
55
+ if value.startswith("0000-01-01T") and re.match(
56
+ r"^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\+\d{2}:\d{2}|Z)$", value
57
+ ):
58
+ # Workaround: Replace "0000" with "0001"
59
+ return "0001" + value[4:] # Take "0001" and append the rest of the string
60
+ return value
61
+
62
+ @field_validator("state")
63
+ def state_validate_enum(cls, value):
64
+ """Validates the enum"""
65
+ if value not in set(["Reconciling", "Active", "Deleted", "Error"]):
66
+ raise ValueError("must be one of enum values ('Reconciling', 'Active', 'Deleted', 'Error')")
67
+ return value
68
+
69
+ model_config = ConfigDict(
70
+ validate_by_name=True,
71
+ validate_by_alias=True,
72
+ validate_assignment=True,
73
+ protected_namespaces=(),
74
+ )
75
+
76
+ def to_str(self) -> str:
77
+ """Returns the string representation of the model using alias"""
78
+ return pprint.pformat(self.model_dump(by_alias=True))
79
+
80
+ def to_json(self) -> str:
81
+ """Returns the JSON representation of the model using alias"""
82
+ return json.dumps(to_jsonable_python(self.to_dict()))
83
+
84
+ @classmethod
85
+ def from_json(cls, json_str: str) -> Optional[Self]:
86
+ """Create an instance of Artifactory from a JSON string"""
87
+ return cls.from_dict(json.loads(json_str))
88
+
89
+ def to_dict(self) -> Dict[str, Any]:
90
+ """Return the dictionary representation of the model using alias.
91
+
92
+ This has the following differences from calling pydantic's
93
+ `self.model_dump(by_alias=True)`:
94
+
95
+ * `None` is only added to the output dict for nullable fields that
96
+ were set at model initialization. Other fields with value `None`
97
+ are ignored.
98
+ """
99
+ excluded_fields: Set[str] = set([])
100
+
101
+ _dict = self.model_dump(
102
+ by_alias=True,
103
+ exclude=excluded_fields,
104
+ exclude_none=True,
105
+ )
106
+ # override the default output from pydantic by calling `to_dict()` of proxy
107
+ if self.proxy:
108
+ _dict["proxy"] = self.proxy.to_dict()
109
+ return _dict
110
+
111
+ @classmethod
112
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
113
+ """Create an instance of Artifactory from a dict"""
114
+ if obj is None:
115
+ return None
116
+
117
+ if not isinstance(obj, dict):
118
+ return cls.model_validate(obj)
119
+
120
+ _obj = cls.model_validate(
121
+ {
122
+ "consumed_quota_bytes": obj.get("consumed_quota_bytes"),
123
+ "create_time": obj.get("create_time"),
124
+ "id": obj.get("id"),
125
+ "name": obj.get("name"),
126
+ "proxy": Proxy.from_dict(obj["proxy"]) if obj.get("proxy") is not None else None,
127
+ "state": obj.get("state"),
128
+ "url": obj.get("url"),
129
+ }
130
+ )
131
+ return _obj
@@ -0,0 +1,105 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ STACKIT Container Registry API
5
+
6
+ STACKIT Container Registry management API.
7
+
8
+ The version of the OpenAPI document: 1.0.0
9
+ Contact: devex_development@stackit.cloud
10
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
11
+
12
+ Do not edit the class manually.
13
+ """ # noqa: E501
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 pydantic_core import to_jsonable_python
23
+ from typing_extensions import Self
24
+
25
+ from stackit.registry.models.artifactory import Artifactory
26
+
27
+
28
+ class ArtifactoryList(BaseModel):
29
+ """
30
+ A list of artifactories inside a STACKIT project.
31
+ """ # noqa: E501
32
+
33
+ artifactories: List[Artifactory]
34
+ next_page_token: Optional[StrictStr] = Field(
35
+ default=None,
36
+ description="A token to retrieve the next page of results. Pass this value as `page_token` in the subsequent request. If empty, there are no more pages.",
37
+ )
38
+ __properties: ClassVar[List[str]] = ["artifactories", "next_page_token"]
39
+
40
+ model_config = ConfigDict(
41
+ validate_by_name=True,
42
+ validate_by_alias=True,
43
+ validate_assignment=True,
44
+ protected_namespaces=(),
45
+ )
46
+
47
+ def to_str(self) -> str:
48
+ """Returns the string representation of the model using alias"""
49
+ return pprint.pformat(self.model_dump(by_alias=True))
50
+
51
+ def to_json(self) -> str:
52
+ """Returns the JSON representation of the model using alias"""
53
+ return json.dumps(to_jsonable_python(self.to_dict()))
54
+
55
+ @classmethod
56
+ def from_json(cls, json_str: str) -> Optional[Self]:
57
+ """Create an instance of ArtifactoryList from a JSON string"""
58
+ return cls.from_dict(json.loads(json_str))
59
+
60
+ def to_dict(self) -> Dict[str, Any]:
61
+ """Return the dictionary representation of the model using alias.
62
+
63
+ This has the following differences from calling pydantic's
64
+ `self.model_dump(by_alias=True)`:
65
+
66
+ * `None` is only added to the output dict for nullable fields that
67
+ were set at model initialization. Other fields with value `None`
68
+ are ignored.
69
+ """
70
+ excluded_fields: Set[str] = set([])
71
+
72
+ _dict = self.model_dump(
73
+ by_alias=True,
74
+ exclude=excluded_fields,
75
+ exclude_none=True,
76
+ )
77
+ # override the default output from pydantic by calling `to_dict()` of each item in artifactories (list)
78
+ _items = []
79
+ if self.artifactories:
80
+ for _item_artifactories in self.artifactories:
81
+ if _item_artifactories:
82
+ _items.append(_item_artifactories.to_dict())
83
+ _dict["artifactories"] = _items
84
+ return _dict
85
+
86
+ @classmethod
87
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
88
+ """Create an instance of ArtifactoryList from a dict"""
89
+ if obj is None:
90
+ return None
91
+
92
+ if not isinstance(obj, dict):
93
+ return cls.model_validate(obj)
94
+
95
+ _obj = cls.model_validate(
96
+ {
97
+ "artifactories": (
98
+ [Artifactory.from_dict(_item) for _item in obj["artifactories"]]
99
+ if obj.get("artifactories") is not None
100
+ else None
101
+ ),
102
+ "next_page_token": obj.get("next_page_token"),
103
+ }
104
+ )
105
+ return _obj