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.
- method_sdk/__init__.py +0 -0
- method_sdk/configuration.py +654 -0
- method_sdk/errors.py +55 -0
- method_sdk/exceptions.py +220 -0
- method_sdk/inventory/__init__.py +94 -0
- method_sdk/inventory/api/__init__.py +5 -0
- method_sdk/inventory/api/inventory_api.py +1508 -0
- method_sdk/inventory/api_client.py +833 -0
- method_sdk/inventory/api_response.py +21 -0
- method_sdk/inventory/configuration.py +654 -0
- method_sdk/inventory/exceptions.py +1 -0
- method_sdk/inventory/models/__init__.py +39 -0
- method_sdk/inventory/models/access_denied_response_content.py +90 -0
- method_sdk/inventory/models/create_environment400_error_response_content.py +151 -0
- method_sdk/inventory/models/create_environment_request_content.py +88 -0
- method_sdk/inventory/models/create_environment_response_content.py +92 -0
- method_sdk/inventory/models/delete_environment400_error_response_content.py +151 -0
- method_sdk/inventory/models/delete_environment_response_content.py +92 -0
- method_sdk/inventory/models/environment.py +101 -0
- method_sdk/inventory/models/environment_not_found_response_content.py +90 -0
- method_sdk/inventory/models/environment_state.py +38 -0
- method_sdk/inventory/models/get_environment400_error_response_content.py +151 -0
- method_sdk/inventory/models/get_environment_response_content.py +92 -0
- method_sdk/inventory/models/internal_server_response_content.py +90 -0
- method_sdk/inventory/models/invalid_parameter.py +90 -0
- method_sdk/inventory/models/list_environments400_error_response_content.py +151 -0
- method_sdk/inventory/models/list_environments_response_content.py +97 -0
- method_sdk/inventory/models/malformed_request.py +90 -0
- method_sdk/inventory/models/missing_parameter.py +90 -0
- method_sdk/inventory/models/service_unavailable_response_content.py +90 -0
- method_sdk/inventory/models/throttling_response_content.py +90 -0
- method_sdk/inventory/models/unauthenticated_response_content.py +90 -0
- method_sdk/inventory/models/update_environment400_error_response_content.py +151 -0
- method_sdk/inventory/models/update_environment_request_content.py +88 -0
- method_sdk/inventory/models/update_environment_response_content.py +92 -0
- method_sdk/inventory/paginators.py +12 -0
- method_sdk/inventory/py.typed +0 -0
- method_sdk/inventory/rest.py +334 -0
- method_sdk/method_auth.py +116 -0
- method_sdk/method_error.py +36 -0
- method_sdk/pagination.py +20 -0
- method_sdk/py.typed +0 -0
- method_security_sdk-0.35.0.dist-info/METADATA +23 -0
- method_security_sdk-0.35.0.dist-info/RECORD +46 -0
- method_security_sdk-0.35.0.dist-info/WHEEL +5 -0
- method_security_sdk-0.35.0.dist-info/top_level.txt +1 -0
|
@@ -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 DeleteEnvironmentResponseContent(BaseModel):
|
|
28
|
+
"""
|
|
29
|
+
DeleteEnvironmentResponseContent
|
|
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 DeleteEnvironmentResponseContent 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 DeleteEnvironmentResponseContent 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,101 @@
|
|
|
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, field_validator
|
|
21
|
+
from typing import Any, ClassVar, Dict, List
|
|
22
|
+
from typing_extensions import Annotated
|
|
23
|
+
from method_sdk.inventory.models.environment_state import EnvironmentState
|
|
24
|
+
from typing import Optional, Set
|
|
25
|
+
from typing_extensions import Self
|
|
26
|
+
from pydantic_core import to_jsonable_python
|
|
27
|
+
|
|
28
|
+
class Environment(BaseModel):
|
|
29
|
+
"""
|
|
30
|
+
A scope of networks, domains and infrastructure to assess.
|
|
31
|
+
""" # noqa: E501
|
|
32
|
+
environment_id: Annotated[str, Field(strict=True)] = Field(description="The resource identifier (RID) of an environment.", alias="environmentId")
|
|
33
|
+
name: StrictStr = Field(description="Human-readable name. Not unique.")
|
|
34
|
+
state: EnvironmentState
|
|
35
|
+
__properties: ClassVar[List[str]] = ["environmentId", "name", "state"]
|
|
36
|
+
|
|
37
|
+
@field_validator('environment_id', mode="before")
|
|
38
|
+
def environment_id_validate_regular_expression(cls, value):
|
|
39
|
+
"""Validates the regular expression"""
|
|
40
|
+
if isinstance(value, str) and not re.match(r"^ri\.[a-z][a-z0-9-]*\.([a-z0-9][a-z0-9-]*)?\.[a-z][a-z0-9-]*\.[a-zA-Z0-9_.-]+$", value):
|
|
41
|
+
raise ValueError(r"must validate the regular expression /^ri\.[a-z][a-z0-9-]*\.([a-z0-9][a-z0-9-]*)?\.[a-z][a-z0-9-]*\.[a-zA-Z0-9_.-]+$/")
|
|
42
|
+
return value
|
|
43
|
+
|
|
44
|
+
model_config = ConfigDict(
|
|
45
|
+
validate_by_name=True,
|
|
46
|
+
validate_by_alias=True,
|
|
47
|
+
validate_assignment=True,
|
|
48
|
+
protected_namespaces=(),
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def to_str(self) -> str:
|
|
53
|
+
"""Returns the string representation of the model using alias"""
|
|
54
|
+
return pprint.pformat(self.model_dump(by_alias=True))
|
|
55
|
+
|
|
56
|
+
def to_json(self) -> str:
|
|
57
|
+
"""Returns the JSON representation of the model using alias"""
|
|
58
|
+
return json.dumps(to_jsonable_python(self.to_dict()))
|
|
59
|
+
|
|
60
|
+
@classmethod
|
|
61
|
+
def from_json(cls, json_str: str) -> Optional[Self]:
|
|
62
|
+
"""Create an instance of Environment from a JSON string"""
|
|
63
|
+
return cls.from_dict(json.loads(json_str))
|
|
64
|
+
|
|
65
|
+
def to_dict(self) -> Dict[str, Any]:
|
|
66
|
+
"""Return the dictionary representation of the model using alias.
|
|
67
|
+
|
|
68
|
+
This has the following differences from calling pydantic's
|
|
69
|
+
`self.model_dump(by_alias=True)`:
|
|
70
|
+
|
|
71
|
+
* `None` is only added to the output dict for nullable fields that
|
|
72
|
+
were set at model initialization. Other fields with value `None`
|
|
73
|
+
are ignored.
|
|
74
|
+
"""
|
|
75
|
+
excluded_fields: Set[str] = set([
|
|
76
|
+
])
|
|
77
|
+
|
|
78
|
+
_dict = self.model_dump(
|
|
79
|
+
by_alias=True,
|
|
80
|
+
exclude=excluded_fields,
|
|
81
|
+
exclude_none=True,
|
|
82
|
+
)
|
|
83
|
+
return _dict
|
|
84
|
+
|
|
85
|
+
@classmethod
|
|
86
|
+
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
|
87
|
+
"""Create an instance of Environment from a dict"""
|
|
88
|
+
if obj is None:
|
|
89
|
+
return None
|
|
90
|
+
|
|
91
|
+
if not isinstance(obj, dict):
|
|
92
|
+
return cls.model_validate(obj)
|
|
93
|
+
|
|
94
|
+
_obj = cls.model_validate({
|
|
95
|
+
"environmentId": obj.get("environmentId"),
|
|
96
|
+
"name": obj.get("name"),
|
|
97
|
+
"state": obj.get("state")
|
|
98
|
+
})
|
|
99
|
+
return _obj
|
|
100
|
+
|
|
101
|
+
|
|
@@ -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 EnvironmentNotFoundResponseContent(BaseModel):
|
|
27
|
+
"""
|
|
28
|
+
No environment has this ID.
|
|
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 EnvironmentNotFoundResponseContent 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 EnvironmentNotFoundResponseContent 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,38 @@
|
|
|
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
|
+
from enum import Enum
|
|
18
|
+
from typing_extensions import Self
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class EnvironmentState(str, Enum):
|
|
22
|
+
"""
|
|
23
|
+
EnvironmentState
|
|
24
|
+
"""
|
|
25
|
+
|
|
26
|
+
"""
|
|
27
|
+
allowed enum values
|
|
28
|
+
"""
|
|
29
|
+
CREATING = 'CREATING'
|
|
30
|
+
ACTIVE = 'ACTIVE'
|
|
31
|
+
DELETING = 'DELETING'
|
|
32
|
+
|
|
33
|
+
@classmethod
|
|
34
|
+
def from_json(cls, json_str: str) -> Self:
|
|
35
|
+
"""Create an instance of EnvironmentState from a JSON string"""
|
|
36
|
+
return cls(json.loads(json_str))
|
|
37
|
+
|
|
38
|
+
|
|
@@ -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
|
+
GETENVIRONMENT400ERRORRESPONSECONTENT_ONE_OF_SCHEMAS = ["InvalidParameter", "MalformedRequest", "MissingParameter"]
|
|
28
|
+
|
|
29
|
+
class GetEnvironment400ErrorResponseContent(BaseModel):
|
|
30
|
+
"""
|
|
31
|
+
GetEnvironment400ErrorResponseContent
|
|
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 = GetEnvironment400ErrorResponseContent.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 GetEnvironment400ErrorResponseContent 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 GetEnvironment400ErrorResponseContent 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 GetEnvironment400ErrorResponseContent 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 GetEnvironment400ErrorResponseContent 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,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 GetEnvironmentResponseContent(BaseModel):
|
|
28
|
+
"""
|
|
29
|
+
GetEnvironmentResponseContent
|
|
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 GetEnvironmentResponseContent 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 GetEnvironmentResponseContent 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,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 InternalServerResponseContent(BaseModel):
|
|
27
|
+
"""
|
|
28
|
+
An unexpected error in the gateway or the operation.
|
|
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 InternalServerResponseContent 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 InternalServerResponseContent 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
|
+
|