method-security-sdk 0.35.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 (46) hide show
  1. method_sdk/__init__.py +0 -0
  2. method_sdk/configuration.py +654 -0
  3. method_sdk/errors.py +55 -0
  4. method_sdk/exceptions.py +220 -0
  5. method_sdk/inventory/__init__.py +94 -0
  6. method_sdk/inventory/api/__init__.py +5 -0
  7. method_sdk/inventory/api/inventory_api.py +1508 -0
  8. method_sdk/inventory/api_client.py +833 -0
  9. method_sdk/inventory/api_response.py +21 -0
  10. method_sdk/inventory/configuration.py +654 -0
  11. method_sdk/inventory/exceptions.py +1 -0
  12. method_sdk/inventory/models/__init__.py +39 -0
  13. method_sdk/inventory/models/access_denied_response_content.py +90 -0
  14. method_sdk/inventory/models/create_environment400_error_response_content.py +151 -0
  15. method_sdk/inventory/models/create_environment_request_content.py +88 -0
  16. method_sdk/inventory/models/create_environment_response_content.py +92 -0
  17. method_sdk/inventory/models/delete_environment400_error_response_content.py +151 -0
  18. method_sdk/inventory/models/delete_environment_response_content.py +92 -0
  19. method_sdk/inventory/models/environment.py +101 -0
  20. method_sdk/inventory/models/environment_not_found_response_content.py +90 -0
  21. method_sdk/inventory/models/environment_state.py +38 -0
  22. method_sdk/inventory/models/get_environment400_error_response_content.py +151 -0
  23. method_sdk/inventory/models/get_environment_response_content.py +92 -0
  24. method_sdk/inventory/models/internal_server_response_content.py +90 -0
  25. method_sdk/inventory/models/invalid_parameter.py +90 -0
  26. method_sdk/inventory/models/list_environments400_error_response_content.py +151 -0
  27. method_sdk/inventory/models/list_environments_response_content.py +97 -0
  28. method_sdk/inventory/models/malformed_request.py +90 -0
  29. method_sdk/inventory/models/missing_parameter.py +90 -0
  30. method_sdk/inventory/models/service_unavailable_response_content.py +90 -0
  31. method_sdk/inventory/models/throttling_response_content.py +90 -0
  32. method_sdk/inventory/models/unauthenticated_response_content.py +90 -0
  33. method_sdk/inventory/models/update_environment400_error_response_content.py +151 -0
  34. method_sdk/inventory/models/update_environment_request_content.py +88 -0
  35. method_sdk/inventory/models/update_environment_response_content.py +92 -0
  36. method_sdk/inventory/paginators.py +12 -0
  37. method_sdk/inventory/py.typed +0 -0
  38. method_sdk/inventory/rest.py +334 -0
  39. method_sdk/method_auth.py +116 -0
  40. method_sdk/method_error.py +36 -0
  41. method_sdk/pagination.py +20 -0
  42. method_sdk/py.typed +0 -0
  43. method_security_sdk-0.35.0.dist-info/METADATA +23 -0
  44. method_security_sdk-0.35.0.dist-info/RECORD +46 -0
  45. method_security_sdk-0.35.0.dist-info/WHEEL +5 -0
  46. method_security_sdk-0.35.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,39 @@
1
+ # coding: utf-8
2
+
3
+ # flake8: noqa
4
+ """
5
+ InventoryService
6
+
7
+ Attack surface, assets, and environments
8
+
9
+ The version of the OpenAPI document: 3
10
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
11
+
12
+ Do not edit the class manually.
13
+ """ # noqa: E501
14
+
15
+ # import models into model package
16
+ from method_sdk.inventory.models.access_denied_response_content import AccessDeniedResponseContent
17
+ from method_sdk.inventory.models.create_environment400_error_response_content import CreateEnvironment400ErrorResponseContent
18
+ from method_sdk.inventory.models.create_environment_request_content import CreateEnvironmentRequestContent
19
+ from method_sdk.inventory.models.create_environment_response_content import CreateEnvironmentResponseContent
20
+ from method_sdk.inventory.models.delete_environment400_error_response_content import DeleteEnvironment400ErrorResponseContent
21
+ from method_sdk.inventory.models.delete_environment_response_content import DeleteEnvironmentResponseContent
22
+ from method_sdk.inventory.models.environment import Environment
23
+ from method_sdk.inventory.models.environment_not_found_response_content import EnvironmentNotFoundResponseContent
24
+ from method_sdk.inventory.models.environment_state import EnvironmentState
25
+ from method_sdk.inventory.models.get_environment400_error_response_content import GetEnvironment400ErrorResponseContent
26
+ from method_sdk.inventory.models.get_environment_response_content import GetEnvironmentResponseContent
27
+ from method_sdk.inventory.models.internal_server_response_content import InternalServerResponseContent
28
+ from method_sdk.inventory.models.invalid_parameter import InvalidParameter
29
+ from method_sdk.inventory.models.list_environments400_error_response_content import ListEnvironments400ErrorResponseContent
30
+ from method_sdk.inventory.models.list_environments_response_content import ListEnvironmentsResponseContent
31
+ from method_sdk.inventory.models.malformed_request import MalformedRequest
32
+ from method_sdk.inventory.models.missing_parameter import MissingParameter
33
+ from method_sdk.inventory.models.service_unavailable_response_content import ServiceUnavailableResponseContent
34
+ from method_sdk.inventory.models.throttling_response_content import ThrottlingResponseContent
35
+ from method_sdk.inventory.models.unauthenticated_response_content import UnauthenticatedResponseContent
36
+ from method_sdk.inventory.models.update_environment400_error_response_content import UpdateEnvironment400ErrorResponseContent
37
+ from method_sdk.inventory.models.update_environment_request_content import UpdateEnvironmentRequestContent
38
+ from method_sdk.inventory.models.update_environment_response_content import UpdateEnvironmentResponseContent
39
+
@@ -0,0 +1,90 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ InventoryService
5
+
6
+ Attack surface, assets, and environments
7
+
8
+ The version of the OpenAPI document: 3
9
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
10
+
11
+ Do not edit the class manually.
12
+ """ # noqa: E501
13
+
14
+
15
+ from __future__ import annotations
16
+ import pprint
17
+ import re # noqa: F401
18
+ import json
19
+
20
+ from pydantic import BaseModel, ConfigDict, Field, StrictStr
21
+ from typing import Any, ClassVar, Dict, List, Optional
22
+ from typing import Optional, Set
23
+ from typing_extensions import Self
24
+ from pydantic_core import to_jsonable_python
25
+
26
+ class AccessDeniedResponseContent(BaseModel):
27
+ """
28
+ The caller isn't allowed to do this.
29
+ """ # noqa: E501
30
+ message: StrictStr
31
+ error_code: Optional[StrictStr] = Field(default=None, description="The error's shape name, e.g. `Throttling`.", alias="errorCode")
32
+ __properties: ClassVar[List[str]] = ["message", "errorCode"]
33
+
34
+ model_config = ConfigDict(
35
+ validate_by_name=True,
36
+ validate_by_alias=True,
37
+ validate_assignment=True,
38
+ protected_namespaces=(),
39
+ )
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 AccessDeniedResponseContent 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
+
68
+ _dict = self.model_dump(
69
+ by_alias=True,
70
+ exclude=excluded_fields,
71
+ exclude_none=True,
72
+ )
73
+ return _dict
74
+
75
+ @classmethod
76
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
77
+ """Create an instance of AccessDeniedResponseContent from a dict"""
78
+ if obj is None:
79
+ return None
80
+
81
+ if not isinstance(obj, dict):
82
+ return cls.model_validate(obj)
83
+
84
+ _obj = cls.model_validate({
85
+ "message": obj.get("message"),
86
+ "errorCode": obj.get("errorCode")
87
+ })
88
+ return _obj
89
+
90
+
@@ -0,0 +1,151 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ InventoryService
5
+
6
+ Attack surface, assets, and environments
7
+
8
+ The version of the OpenAPI document: 3
9
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
10
+
11
+ Do not edit the class manually.
12
+ """ # noqa: E501
13
+
14
+
15
+ from __future__ import annotations
16
+ import json
17
+ import pprint
18
+ from pydantic import BaseModel, ConfigDict, Field, StrictStr, ValidationError, field_validator
19
+ from typing import Any, List, Optional
20
+ from method_sdk.inventory.models.invalid_parameter import InvalidParameter
21
+ from method_sdk.inventory.models.malformed_request import MalformedRequest
22
+ from method_sdk.inventory.models.missing_parameter import MissingParameter
23
+ from pydantic import StrictStr, Field
24
+ from typing import Union, List, Set, Optional, Dict
25
+ from typing_extensions import Literal, Self
26
+
27
+ CREATEENVIRONMENT400ERRORRESPONSECONTENT_ONE_OF_SCHEMAS = ["InvalidParameter", "MalformedRequest", "MissingParameter"]
28
+
29
+ class CreateEnvironment400ErrorResponseContent(BaseModel):
30
+ """
31
+ CreateEnvironment400ErrorResponseContent
32
+ """
33
+ # data type: InvalidParameter
34
+ oneof_schema_1_validator: Optional[InvalidParameter] = None
35
+ # data type: MalformedRequest
36
+ oneof_schema_2_validator: Optional[MalformedRequest] = None
37
+ # data type: MissingParameter
38
+ oneof_schema_3_validator: Optional[MissingParameter] = None
39
+ actual_instance: Optional[Union[InvalidParameter, MalformedRequest, MissingParameter]] = None
40
+ one_of_schemas: Set[str] = { "InvalidParameter", "MalformedRequest", "MissingParameter" }
41
+
42
+ model_config = ConfigDict(
43
+ validate_assignment=True,
44
+ protected_namespaces=(),
45
+ )
46
+
47
+
48
+ def __init__(self, *args, **kwargs) -> None:
49
+ if args:
50
+ if len(args) > 1:
51
+ raise ValueError("If a position argument is used, only 1 is allowed to set `actual_instance`")
52
+ if kwargs:
53
+ raise ValueError("If a position argument is used, keyword arguments cannot be used.")
54
+ super().__init__(actual_instance=args[0])
55
+ else:
56
+ super().__init__(**kwargs)
57
+
58
+ @field_validator('actual_instance')
59
+ def actual_instance_must_validate_oneof(cls, v):
60
+ instance = CreateEnvironment400ErrorResponseContent.model_construct()
61
+ error_messages = []
62
+ match = 0
63
+ # validate data type: InvalidParameter
64
+ if not isinstance(v, InvalidParameter):
65
+ error_messages.append(f"Error! Input type `{type(v)}` is not `InvalidParameter`")
66
+ else:
67
+ match += 1
68
+ # validate data type: MalformedRequest
69
+ if not isinstance(v, MalformedRequest):
70
+ error_messages.append(f"Error! Input type `{type(v)}` is not `MalformedRequest`")
71
+ else:
72
+ match += 1
73
+ # validate data type: MissingParameter
74
+ if not isinstance(v, MissingParameter):
75
+ error_messages.append(f"Error! Input type `{type(v)}` is not `MissingParameter`")
76
+ else:
77
+ match += 1
78
+ if match > 1:
79
+ # more than 1 match
80
+ raise ValueError("Multiple matches found when setting `actual_instance` in CreateEnvironment400ErrorResponseContent with oneOf schemas: InvalidParameter, MalformedRequest, MissingParameter. Details: " + ", ".join(error_messages))
81
+ elif match == 0:
82
+ # no match
83
+ raise ValueError("No match found when setting `actual_instance` in CreateEnvironment400ErrorResponseContent with oneOf schemas: InvalidParameter, MalformedRequest, MissingParameter. Details: " + ", ".join(error_messages))
84
+ else:
85
+ return v
86
+
87
+ @classmethod
88
+ def from_dict(cls, obj: Union[str, Dict[str, Any]]) -> Self:
89
+ return cls.from_json(json.dumps(obj))
90
+
91
+ @classmethod
92
+ def from_json(cls, json_str: str) -> Self:
93
+ """Returns the object represented by the json string"""
94
+ instance = cls.model_construct()
95
+ error_messages = []
96
+ match = 0
97
+
98
+ # deserialize data into InvalidParameter
99
+ try:
100
+ instance.actual_instance = InvalidParameter.from_json(json_str)
101
+ match += 1
102
+ except (ValidationError, ValueError) as e:
103
+ error_messages.append(str(e))
104
+ # deserialize data into MalformedRequest
105
+ try:
106
+ instance.actual_instance = MalformedRequest.from_json(json_str)
107
+ match += 1
108
+ except (ValidationError, ValueError) as e:
109
+ error_messages.append(str(e))
110
+ # deserialize data into MissingParameter
111
+ try:
112
+ instance.actual_instance = MissingParameter.from_json(json_str)
113
+ match += 1
114
+ except (ValidationError, ValueError) as e:
115
+ error_messages.append(str(e))
116
+
117
+ if match > 1:
118
+ # more than 1 match
119
+ raise ValueError("Multiple matches found when deserializing the JSON string into CreateEnvironment400ErrorResponseContent with oneOf schemas: InvalidParameter, MalformedRequest, MissingParameter. Details: " + ", ".join(error_messages))
120
+ elif match == 0:
121
+ # no match
122
+ raise ValueError("No match found when deserializing the JSON string into CreateEnvironment400ErrorResponseContent with oneOf schemas: InvalidParameter, MalformedRequest, MissingParameter. Details: " + ", ".join(error_messages))
123
+ else:
124
+ return instance
125
+
126
+ def to_json(self) -> str:
127
+ """Returns the JSON representation of the actual instance"""
128
+ if self.actual_instance is None:
129
+ return "null"
130
+
131
+ if hasattr(self.actual_instance, "to_json") and callable(self.actual_instance.to_json):
132
+ return self.actual_instance.to_json()
133
+ else:
134
+ return json.dumps(self.actual_instance)
135
+
136
+ def to_dict(self) -> Optional[Union[Dict[str, Any], InvalidParameter, MalformedRequest, MissingParameter]]:
137
+ """Returns the dict representation of the actual instance"""
138
+ if self.actual_instance is None:
139
+ return None
140
+
141
+ if hasattr(self.actual_instance, "to_dict") and callable(self.actual_instance.to_dict):
142
+ return self.actual_instance.to_dict()
143
+ else:
144
+ # primitive type
145
+ return self.actual_instance
146
+
147
+ def to_str(self) -> str:
148
+ """Returns the string representation of the actual instance"""
149
+ return pprint.pformat(self.model_dump())
150
+
151
+
@@ -0,0 +1,88 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ InventoryService
5
+
6
+ Attack surface, assets, and environments
7
+
8
+ The version of the OpenAPI document: 3
9
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
10
+
11
+ Do not edit the class manually.
12
+ """ # noqa: E501
13
+
14
+
15
+ from __future__ import annotations
16
+ import pprint
17
+ import re # noqa: F401
18
+ import json
19
+
20
+ from pydantic import BaseModel, ConfigDict, Field, StrictStr
21
+ from typing import Any, ClassVar, Dict, List
22
+ from typing import Optional, Set
23
+ from typing_extensions import Self
24
+ from pydantic_core import to_jsonable_python
25
+
26
+ class CreateEnvironmentRequestContent(BaseModel):
27
+ """
28
+ CreateEnvironmentRequestContent
29
+ """ # noqa: E501
30
+ name: StrictStr = Field(description="Human-readable name. Not unique.")
31
+ __properties: ClassVar[List[str]] = ["name"]
32
+
33
+ model_config = ConfigDict(
34
+ validate_by_name=True,
35
+ validate_by_alias=True,
36
+ validate_assignment=True,
37
+ protected_namespaces=(),
38
+ )
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
+ return json.dumps(to_jsonable_python(self.to_dict()))
48
+
49
+ @classmethod
50
+ def from_json(cls, json_str: str) -> Optional[Self]:
51
+ """Create an instance of CreateEnvironmentRequestContent from a JSON string"""
52
+ return cls.from_dict(json.loads(json_str))
53
+
54
+ def to_dict(self) -> Dict[str, Any]:
55
+ """Return the dictionary representation of the model using alias.
56
+
57
+ This has the following differences from calling pydantic's
58
+ `self.model_dump(by_alias=True)`:
59
+
60
+ * `None` is only added to the output dict for nullable fields that
61
+ were set at model initialization. Other fields with value `None`
62
+ are ignored.
63
+ """
64
+ excluded_fields: Set[str] = set([
65
+ ])
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 CreateEnvironmentRequestContent 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({
84
+ "name": obj.get("name")
85
+ })
86
+ return _obj
87
+
88
+
@@ -0,0 +1,92 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ InventoryService
5
+
6
+ Attack surface, assets, and environments
7
+
8
+ The version of the OpenAPI document: 3
9
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
10
+
11
+ Do not edit the class manually.
12
+ """ # noqa: E501
13
+
14
+
15
+ from __future__ import annotations
16
+ import pprint
17
+ import re # noqa: F401
18
+ import json
19
+
20
+ from pydantic import BaseModel, ConfigDict
21
+ from typing import Any, ClassVar, Dict, List
22
+ from method_sdk.inventory.models.environment import Environment
23
+ from typing import Optional, Set
24
+ from typing_extensions import Self
25
+ from pydantic_core import to_jsonable_python
26
+
27
+ class CreateEnvironmentResponseContent(BaseModel):
28
+ """
29
+ CreateEnvironmentResponseContent
30
+ """ # noqa: E501
31
+ environment: Environment
32
+ __properties: ClassVar[List[str]] = ["environment"]
33
+
34
+ model_config = ConfigDict(
35
+ validate_by_name=True,
36
+ validate_by_alias=True,
37
+ validate_assignment=True,
38
+ protected_namespaces=(),
39
+ )
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 CreateEnvironmentResponseContent 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
+
68
+ _dict = self.model_dump(
69
+ by_alias=True,
70
+ exclude=excluded_fields,
71
+ exclude_none=True,
72
+ )
73
+ # override the default output from pydantic by calling `to_dict()` of environment
74
+ if self.environment:
75
+ _dict['environment'] = self.environment.to_dict()
76
+ return _dict
77
+
78
+ @classmethod
79
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
80
+ """Create an instance of CreateEnvironmentResponseContent 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({
88
+ "environment": Environment.from_dict(obj["environment"]) if obj.get("environment") is not None else None
89
+ })
90
+ return _obj
91
+
92
+
@@ -0,0 +1,151 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ InventoryService
5
+
6
+ Attack surface, assets, and environments
7
+
8
+ The version of the OpenAPI document: 3
9
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
10
+
11
+ Do not edit the class manually.
12
+ """ # noqa: E501
13
+
14
+
15
+ from __future__ import annotations
16
+ import json
17
+ import pprint
18
+ from pydantic import BaseModel, ConfigDict, Field, StrictStr, ValidationError, field_validator
19
+ from typing import Any, List, Optional
20
+ from method_sdk.inventory.models.invalid_parameter import InvalidParameter
21
+ from method_sdk.inventory.models.malformed_request import MalformedRequest
22
+ from method_sdk.inventory.models.missing_parameter import MissingParameter
23
+ from pydantic import StrictStr, Field
24
+ from typing import Union, List, Set, Optional, Dict
25
+ from typing_extensions import Literal, Self
26
+
27
+ DELETEENVIRONMENT400ERRORRESPONSECONTENT_ONE_OF_SCHEMAS = ["InvalidParameter", "MalformedRequest", "MissingParameter"]
28
+
29
+ class DeleteEnvironment400ErrorResponseContent(BaseModel):
30
+ """
31
+ DeleteEnvironment400ErrorResponseContent
32
+ """
33
+ # data type: InvalidParameter
34
+ oneof_schema_1_validator: Optional[InvalidParameter] = None
35
+ # data type: MalformedRequest
36
+ oneof_schema_2_validator: Optional[MalformedRequest] = None
37
+ # data type: MissingParameter
38
+ oneof_schema_3_validator: Optional[MissingParameter] = None
39
+ actual_instance: Optional[Union[InvalidParameter, MalformedRequest, MissingParameter]] = None
40
+ one_of_schemas: Set[str] = { "InvalidParameter", "MalformedRequest", "MissingParameter" }
41
+
42
+ model_config = ConfigDict(
43
+ validate_assignment=True,
44
+ protected_namespaces=(),
45
+ )
46
+
47
+
48
+ def __init__(self, *args, **kwargs) -> None:
49
+ if args:
50
+ if len(args) > 1:
51
+ raise ValueError("If a position argument is used, only 1 is allowed to set `actual_instance`")
52
+ if kwargs:
53
+ raise ValueError("If a position argument is used, keyword arguments cannot be used.")
54
+ super().__init__(actual_instance=args[0])
55
+ else:
56
+ super().__init__(**kwargs)
57
+
58
+ @field_validator('actual_instance')
59
+ def actual_instance_must_validate_oneof(cls, v):
60
+ instance = DeleteEnvironment400ErrorResponseContent.model_construct()
61
+ error_messages = []
62
+ match = 0
63
+ # validate data type: InvalidParameter
64
+ if not isinstance(v, InvalidParameter):
65
+ error_messages.append(f"Error! Input type `{type(v)}` is not `InvalidParameter`")
66
+ else:
67
+ match += 1
68
+ # validate data type: MalformedRequest
69
+ if not isinstance(v, MalformedRequest):
70
+ error_messages.append(f"Error! Input type `{type(v)}` is not `MalformedRequest`")
71
+ else:
72
+ match += 1
73
+ # validate data type: MissingParameter
74
+ if not isinstance(v, MissingParameter):
75
+ error_messages.append(f"Error! Input type `{type(v)}` is not `MissingParameter`")
76
+ else:
77
+ match += 1
78
+ if match > 1:
79
+ # more than 1 match
80
+ raise ValueError("Multiple matches found when setting `actual_instance` in DeleteEnvironment400ErrorResponseContent with oneOf schemas: InvalidParameter, MalformedRequest, MissingParameter. Details: " + ", ".join(error_messages))
81
+ elif match == 0:
82
+ # no match
83
+ raise ValueError("No match found when setting `actual_instance` in DeleteEnvironment400ErrorResponseContent with oneOf schemas: InvalidParameter, MalformedRequest, MissingParameter. Details: " + ", ".join(error_messages))
84
+ else:
85
+ return v
86
+
87
+ @classmethod
88
+ def from_dict(cls, obj: Union[str, Dict[str, Any]]) -> Self:
89
+ return cls.from_json(json.dumps(obj))
90
+
91
+ @classmethod
92
+ def from_json(cls, json_str: str) -> Self:
93
+ """Returns the object represented by the json string"""
94
+ instance = cls.model_construct()
95
+ error_messages = []
96
+ match = 0
97
+
98
+ # deserialize data into InvalidParameter
99
+ try:
100
+ instance.actual_instance = InvalidParameter.from_json(json_str)
101
+ match += 1
102
+ except (ValidationError, ValueError) as e:
103
+ error_messages.append(str(e))
104
+ # deserialize data into MalformedRequest
105
+ try:
106
+ instance.actual_instance = MalformedRequest.from_json(json_str)
107
+ match += 1
108
+ except (ValidationError, ValueError) as e:
109
+ error_messages.append(str(e))
110
+ # deserialize data into MissingParameter
111
+ try:
112
+ instance.actual_instance = MissingParameter.from_json(json_str)
113
+ match += 1
114
+ except (ValidationError, ValueError) as e:
115
+ error_messages.append(str(e))
116
+
117
+ if match > 1:
118
+ # more than 1 match
119
+ raise ValueError("Multiple matches found when deserializing the JSON string into DeleteEnvironment400ErrorResponseContent with oneOf schemas: InvalidParameter, MalformedRequest, MissingParameter. Details: " + ", ".join(error_messages))
120
+ elif match == 0:
121
+ # no match
122
+ raise ValueError("No match found when deserializing the JSON string into DeleteEnvironment400ErrorResponseContent with oneOf schemas: InvalidParameter, MalformedRequest, MissingParameter. Details: " + ", ".join(error_messages))
123
+ else:
124
+ return instance
125
+
126
+ def to_json(self) -> str:
127
+ """Returns the JSON representation of the actual instance"""
128
+ if self.actual_instance is None:
129
+ return "null"
130
+
131
+ if hasattr(self.actual_instance, "to_json") and callable(self.actual_instance.to_json):
132
+ return self.actual_instance.to_json()
133
+ else:
134
+ return json.dumps(self.actual_instance)
135
+
136
+ def to_dict(self) -> Optional[Union[Dict[str, Any], InvalidParameter, MalformedRequest, MissingParameter]]:
137
+ """Returns the dict representation of the actual instance"""
138
+ if self.actual_instance is None:
139
+ return None
140
+
141
+ if hasattr(self.actual_instance, "to_dict") and callable(self.actual_instance.to_dict):
142
+ return self.actual_instance.to_dict()
143
+ else:
144
+ # primitive type
145
+ return self.actual_instance
146
+
147
+ def to_str(self) -> str:
148
+ """Returns the string representation of the actual instance"""
149
+ return pprint.pformat(self.model_dump())
150
+
151
+