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,84 @@
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, StrictStr
22
+ from pydantic_core import to_jsonable_python
23
+ from typing_extensions import Self
24
+
25
+
26
+ class BadRequestErrorResponse(BaseModel):
27
+ """
28
+ 400 Error Response.
29
+ """ # noqa: E501
30
+
31
+ error: Optional[StrictStr] = None
32
+ message: StrictStr
33
+ __properties: ClassVar[List[str]] = ["error", "message"]
34
+
35
+ model_config = ConfigDict(
36
+ validate_by_name=True,
37
+ validate_by_alias=True,
38
+ validate_assignment=True,
39
+ protected_namespaces=(),
40
+ )
41
+
42
+ def to_str(self) -> str:
43
+ """Returns the string representation of the model using alias"""
44
+ return pprint.pformat(self.model_dump(by_alias=True))
45
+
46
+ def to_json(self) -> str:
47
+ """Returns the JSON representation of the model using alias"""
48
+ return json.dumps(to_jsonable_python(self.to_dict()))
49
+
50
+ @classmethod
51
+ def from_json(cls, json_str: str) -> Optional[Self]:
52
+ """Create an instance of BadRequestErrorResponse 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 BadRequestErrorResponse 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({"error": obj.get("error"), "message": obj.get("message")})
84
+ return _obj
@@ -0,0 +1,84 @@
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, StrictStr
22
+ from pydantic_core import to_jsonable_python
23
+ from typing_extensions import Self
24
+
25
+
26
+ class ConflictErrorResponse(BaseModel):
27
+ """
28
+ 409 Error Response.
29
+ """ # noqa: E501
30
+
31
+ error: Optional[StrictStr] = None
32
+ message: StrictStr
33
+ __properties: ClassVar[List[str]] = ["error", "message"]
34
+
35
+ model_config = ConfigDict(
36
+ validate_by_name=True,
37
+ validate_by_alias=True,
38
+ validate_assignment=True,
39
+ protected_namespaces=(),
40
+ )
41
+
42
+ def to_str(self) -> str:
43
+ """Returns the string representation of the model using alias"""
44
+ return pprint.pformat(self.model_dump(by_alias=True))
45
+
46
+ def to_json(self) -> str:
47
+ """Returns the JSON representation of the model using alias"""
48
+ return json.dumps(to_jsonable_python(self.to_dict()))
49
+
50
+ @classmethod
51
+ def from_json(cls, json_str: str) -> Optional[Self]:
52
+ """Create an instance of ConflictErrorResponse 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 ConflictErrorResponse 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({"error": obj.get("error"), "message": obj.get("message")})
84
+ return _obj
@@ -0,0 +1,110 @@
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 typing import Any, ClassVar, Dict, List, Optional, Set
21
+
22
+ from pydantic import BaseModel, ConfigDict, Field, field_validator
23
+ from pydantic_core import to_jsonable_python
24
+ from typing_extensions import Annotated, Self
25
+
26
+ from stackit.registry.models.create_proxy_request import CreateProxyRequest
27
+
28
+
29
+ class CreateArtifactoryPayload(BaseModel):
30
+ """
31
+ CreateArtifactory request data.
32
+ """ # noqa: E501
33
+
34
+ name: Annotated[str, Field(min_length=5, strict=True, max_length=255)] = Field(
35
+ description="A user chosen name to distinguish multiple STACKIT Artifactories. "
36
+ )
37
+ proxy: Optional[CreateProxyRequest] = Field(
38
+ default=None,
39
+ description="If proxy configuration is provided, this project will be created as a proxy-cache for the upstream registry. ",
40
+ )
41
+ __properties: ClassVar[List[str]] = ["name", "proxy"]
42
+
43
+ @field_validator("name")
44
+ def name_validate_regular_expression(cls, value):
45
+ """Validates the regular expression"""
46
+ if not isinstance(value, str):
47
+ value = str(value)
48
+
49
+ if not re.match(r"^[a-z0-9]+(?:[._-][a-z0-9]+)*$", value):
50
+ raise ValueError(r"must validate the regular expression /^[a-z0-9]+(?:[._-][a-z0-9]+)*$/")
51
+ return value
52
+
53
+ model_config = ConfigDict(
54
+ validate_by_name=True,
55
+ validate_by_alias=True,
56
+ validate_assignment=True,
57
+ protected_namespaces=(),
58
+ )
59
+
60
+ def to_str(self) -> str:
61
+ """Returns the string representation of the model using alias"""
62
+ return pprint.pformat(self.model_dump(by_alias=True))
63
+
64
+ def to_json(self) -> str:
65
+ """Returns the JSON representation of the model using alias"""
66
+ return json.dumps(to_jsonable_python(self.to_dict()))
67
+
68
+ @classmethod
69
+ def from_json(cls, json_str: str) -> Optional[Self]:
70
+ """Create an instance of CreateArtifactoryPayload from a JSON string"""
71
+ return cls.from_dict(json.loads(json_str))
72
+
73
+ def to_dict(self) -> Dict[str, Any]:
74
+ """Return the dictionary representation of the model using alias.
75
+
76
+ This has the following differences from calling pydantic's
77
+ `self.model_dump(by_alias=True)`:
78
+
79
+ * `None` is only added to the output dict for nullable fields that
80
+ were set at model initialization. Other fields with value `None`
81
+ are ignored.
82
+ """
83
+ excluded_fields: Set[str] = set([])
84
+
85
+ _dict = self.model_dump(
86
+ by_alias=True,
87
+ exclude=excluded_fields,
88
+ exclude_none=True,
89
+ )
90
+ # override the default output from pydantic by calling `to_dict()` of proxy
91
+ if self.proxy:
92
+ _dict["proxy"] = self.proxy.to_dict()
93
+ return _dict
94
+
95
+ @classmethod
96
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
97
+ """Create an instance of CreateArtifactoryPayload from a dict"""
98
+ if obj is None:
99
+ return None
100
+
101
+ if not isinstance(obj, dict):
102
+ return cls.model_validate(obj)
103
+
104
+ _obj = cls.model_validate(
105
+ {
106
+ "name": obj.get("name"),
107
+ "proxy": CreateProxyRequest.from_dict(obj["proxy"]) if obj.get("proxy") is not None else None,
108
+ }
109
+ )
110
+ return _obj
@@ -0,0 +1,102 @@
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.credentials import Credentials
26
+
27
+
28
+ class CreateProxyRequest(BaseModel):
29
+ """
30
+ Provide an upstream repository this project is a proxy for
31
+ """ # noqa: E501
32
+
33
+ credentials: Optional[Credentials] = None
34
+ description: Optional[StrictStr] = Field(default=None, description="Description of the registry.")
35
+ registry_type: StrictStr = Field(
36
+ description="Which replication adapter to use for this registry. Discover the list of supported replication adapters, and therefore supported registry types, by calling GET /v1/projects/{projectId}/regions/{regionId}/replication/adapters "
37
+ )
38
+ url: StrictStr = Field(description="Upstream registry url to proxy")
39
+ __properties: ClassVar[List[str]] = ["credentials", "description", "registry_type", "url"]
40
+
41
+ model_config = ConfigDict(
42
+ validate_by_name=True,
43
+ validate_by_alias=True,
44
+ validate_assignment=True,
45
+ protected_namespaces=(),
46
+ )
47
+
48
+ def to_str(self) -> str:
49
+ """Returns the string representation of the model using alias"""
50
+ return pprint.pformat(self.model_dump(by_alias=True))
51
+
52
+ def to_json(self) -> str:
53
+ """Returns the JSON representation of the model using alias"""
54
+ return json.dumps(to_jsonable_python(self.to_dict()))
55
+
56
+ @classmethod
57
+ def from_json(cls, json_str: str) -> Optional[Self]:
58
+ """Create an instance of CreateProxyRequest from a JSON string"""
59
+ return cls.from_dict(json.loads(json_str))
60
+
61
+ def to_dict(self) -> Dict[str, Any]:
62
+ """Return the dictionary representation of the model using alias.
63
+
64
+ This has the following differences from calling pydantic's
65
+ `self.model_dump(by_alias=True)`:
66
+
67
+ * `None` is only added to the output dict for nullable fields that
68
+ were set at model initialization. Other fields with value `None`
69
+ are ignored.
70
+ """
71
+ excluded_fields: Set[str] = set([])
72
+
73
+ _dict = self.model_dump(
74
+ by_alias=True,
75
+ exclude=excluded_fields,
76
+ exclude_none=True,
77
+ )
78
+ # override the default output from pydantic by calling `to_dict()` of credentials
79
+ if self.credentials:
80
+ _dict["credentials"] = self.credentials.to_dict()
81
+ return _dict
82
+
83
+ @classmethod
84
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
85
+ """Create an instance of CreateProxyRequest 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(
93
+ {
94
+ "credentials": (
95
+ Credentials.from_dict(obj["credentials"]) if obj.get("credentials") is not None else None
96
+ ),
97
+ "description": obj.get("description"),
98
+ "registry_type": obj.get("registry_type"),
99
+ "url": obj.get("url"),
100
+ }
101
+ )
102
+ return _obj
@@ -0,0 +1,84 @@
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, StrictStr
22
+ from pydantic_core import to_jsonable_python
23
+ from typing_extensions import Self
24
+
25
+
26
+ class Credentials(BaseModel):
27
+ """
28
+ Credentials for upstream registry
29
+ """ # noqa: E501
30
+
31
+ access_key: StrictStr
32
+ access_secret: StrictStr
33
+ __properties: ClassVar[List[str]] = ["access_key", "access_secret"]
34
+
35
+ model_config = ConfigDict(
36
+ validate_by_name=True,
37
+ validate_by_alias=True,
38
+ validate_assignment=True,
39
+ protected_namespaces=(),
40
+ )
41
+
42
+ def to_str(self) -> str:
43
+ """Returns the string representation of the model using alias"""
44
+ return pprint.pformat(self.model_dump(by_alias=True))
45
+
46
+ def to_json(self) -> str:
47
+ """Returns the JSON representation of the model using alias"""
48
+ return json.dumps(to_jsonable_python(self.to_dict()))
49
+
50
+ @classmethod
51
+ def from_json(cls, json_str: str) -> Optional[Self]:
52
+ """Create an instance of Credentials 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 Credentials 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({"access_key": obj.get("access_key"), "access_secret": obj.get("access_secret")})
84
+ return _obj
@@ -0,0 +1,110 @@
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
+
23
+ from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr, field_validator
24
+ from pydantic_core import to_jsonable_python
25
+ from typing_extensions import Self
26
+
27
+
28
+ class ForbiddenErrorResponse(BaseModel):
29
+ """
30
+ Forbidden Error Response.
31
+ """ # noqa: E501
32
+
33
+ error: Optional[StrictStr] = None
34
+ message: StrictStr
35
+ path: Optional[StrictStr] = None
36
+ status: Optional[StrictInt] = None
37
+ timestamp: Optional[datetime] = None
38
+ __properties: ClassVar[List[str]] = ["error", "message", "path", "status", "timestamp"]
39
+
40
+ @field_validator("timestamp", mode="before")
41
+ def timestamp_change_year_zero_to_one(cls, value):
42
+ """Workaround which prevents year 0 issue"""
43
+ if isinstance(value, str):
44
+ # Check for year "0000" at the beginning of the string
45
+ # This assumes common date formats like YYYY-MM-DDTHH:MM:SS+00:00 or YYYY-MM-DDTHH:MM:SSZ
46
+ if value.startswith("0000-01-01T") and re.match(
47
+ r"^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\+\d{2}:\d{2}|Z)$", value
48
+ ):
49
+ # Workaround: Replace "0000" with "0001"
50
+ return "0001" + value[4:] # Take "0001" and append the rest of the string
51
+ return value
52
+
53
+ model_config = ConfigDict(
54
+ validate_by_name=True,
55
+ validate_by_alias=True,
56
+ validate_assignment=True,
57
+ protected_namespaces=(),
58
+ )
59
+
60
+ def to_str(self) -> str:
61
+ """Returns the string representation of the model using alias"""
62
+ return pprint.pformat(self.model_dump(by_alias=True))
63
+
64
+ def to_json(self) -> str:
65
+ """Returns the JSON representation of the model using alias"""
66
+ return json.dumps(to_jsonable_python(self.to_dict()))
67
+
68
+ @classmethod
69
+ def from_json(cls, json_str: str) -> Optional[Self]:
70
+ """Create an instance of ForbiddenErrorResponse from a JSON string"""
71
+ return cls.from_dict(json.loads(json_str))
72
+
73
+ def to_dict(self) -> Dict[str, Any]:
74
+ """Return the dictionary representation of the model using alias.
75
+
76
+ This has the following differences from calling pydantic's
77
+ `self.model_dump(by_alias=True)`:
78
+
79
+ * `None` is only added to the output dict for nullable fields that
80
+ were set at model initialization. Other fields with value `None`
81
+ are ignored.
82
+ """
83
+ excluded_fields: Set[str] = set([])
84
+
85
+ _dict = self.model_dump(
86
+ by_alias=True,
87
+ exclude=excluded_fields,
88
+ exclude_none=True,
89
+ )
90
+ return _dict
91
+
92
+ @classmethod
93
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
94
+ """Create an instance of ForbiddenErrorResponse from a dict"""
95
+ if obj is None:
96
+ return None
97
+
98
+ if not isinstance(obj, dict):
99
+ return cls.model_validate(obj)
100
+
101
+ _obj = cls.model_validate(
102
+ {
103
+ "error": obj.get("error"),
104
+ "message": obj.get("message"),
105
+ "path": obj.get("path"),
106
+ "status": obj.get("status"),
107
+ "timestamp": obj.get("timestamp"),
108
+ }
109
+ )
110
+ return _obj
@@ -0,0 +1,84 @@
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, StrictStr
22
+ from pydantic_core import to_jsonable_python
23
+ from typing_extensions import Self
24
+
25
+
26
+ class GenericErrorResponse(BaseModel):
27
+ """
28
+ Generic Error Response.
29
+ """ # noqa: E501
30
+
31
+ details: Optional[List[StrictStr]] = None
32
+ message: StrictStr
33
+ __properties: ClassVar[List[str]] = ["details", "message"]
34
+
35
+ model_config = ConfigDict(
36
+ validate_by_name=True,
37
+ validate_by_alias=True,
38
+ validate_assignment=True,
39
+ protected_namespaces=(),
40
+ )
41
+
42
+ def to_str(self) -> str:
43
+ """Returns the string representation of the model using alias"""
44
+ return pprint.pformat(self.model_dump(by_alias=True))
45
+
46
+ def to_json(self) -> str:
47
+ """Returns the JSON representation of the model using alias"""
48
+ return json.dumps(to_jsonable_python(self.to_dict()))
49
+
50
+ @classmethod
51
+ def from_json(cls, json_str: str) -> Optional[Self]:
52
+ """Create an instance of GenericErrorResponse 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 GenericErrorResponse 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({"details": obj.get("details"), "message": obj.get("message")})
84
+ return _obj