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
method_sdk/errors.py
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"""Typed errors for the errors Method APIs return. Generated from the Smithy model."""
|
|
2
|
+
|
|
3
|
+
from typing import Dict, Type
|
|
4
|
+
|
|
5
|
+
from method_sdk.exceptions import BadRequestException, ForbiddenException, NotFoundException, ServiceException, UnauthorizedException
|
|
6
|
+
from method_sdk.method_error import MethodError
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class AccessDenied(MethodError, ForbiddenException):
|
|
10
|
+
"""The caller isn't allowed to do this."""
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class EnvironmentNotFound(MethodError, NotFoundException):
|
|
14
|
+
"""No environment has this ID."""
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class InternalServer(MethodError, ServiceException):
|
|
18
|
+
"""An unexpected error in the gateway or the operation."""
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class InvalidParameter(MethodError, BadRequestException):
|
|
22
|
+
"""A parameter fails a constraint of the model, e.g. its length, range or pattern."""
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class MalformedRequest(MethodError, BadRequestException):
|
|
26
|
+
"""The request can't be parsed, e.g. invalid JSON or a value of the wrong type."""
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
class MissingParameter(MethodError, BadRequestException):
|
|
30
|
+
"""A required parameter is missing."""
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
class ServiceUnavailable(MethodError, ServiceException):
|
|
34
|
+
"""A dependency of the gateway is unavailable, or the gateway is overloaded."""
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
class Throttling(MethodError):
|
|
38
|
+
"""The caller exceeded its rate limit for this operation."""
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
class Unauthenticated(MethodError, UnauthorizedException):
|
|
42
|
+
"""The request has no valid bearer token."""
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
ERRORS: Dict[str, Type[MethodError]] = {
|
|
46
|
+
"com.method.errors#AccessDenied": AccessDenied,
|
|
47
|
+
"com.method.errors#EnvironmentNotFound": EnvironmentNotFound,
|
|
48
|
+
"com.method.errors#InternalServer": InternalServer,
|
|
49
|
+
"com.method.errors#InvalidParameter": InvalidParameter,
|
|
50
|
+
"com.method.errors#MalformedRequest": MalformedRequest,
|
|
51
|
+
"com.method.errors#MissingParameter": MissingParameter,
|
|
52
|
+
"com.method.errors#ServiceUnavailable": ServiceUnavailable,
|
|
53
|
+
"com.method.errors#Throttling": Throttling,
|
|
54
|
+
"com.method.errors#Unauthenticated": Unauthenticated,
|
|
55
|
+
}
|
method_sdk/exceptions.py
ADDED
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Method API
|
|
3
|
+
|
|
4
|
+
Attack surface, assets, and environments
|
|
5
|
+
|
|
6
|
+
The version of the OpenAPI document: 3
|
|
7
|
+
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
|
8
|
+
|
|
9
|
+
Do not edit the class manually.
|
|
10
|
+
""" # noqa: E501
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
from typing import Any, Optional
|
|
14
|
+
from typing_extensions import Self
|
|
15
|
+
|
|
16
|
+
class OpenApiException(Exception):
|
|
17
|
+
"""The base exception class for all OpenAPIExceptions"""
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class ApiTypeError(OpenApiException, TypeError):
|
|
21
|
+
def __init__(self, msg, path_to_item=None, valid_classes=None,
|
|
22
|
+
key_type=None) -> None:
|
|
23
|
+
""" Raises an exception for TypeErrors
|
|
24
|
+
|
|
25
|
+
Args:
|
|
26
|
+
msg (str): the exception message
|
|
27
|
+
|
|
28
|
+
Keyword Args:
|
|
29
|
+
path_to_item (list): a list of keys an indices to get to the
|
|
30
|
+
current_item
|
|
31
|
+
None if unset
|
|
32
|
+
valid_classes (tuple): the primitive classes that current item
|
|
33
|
+
should be an instance of
|
|
34
|
+
None if unset
|
|
35
|
+
key_type (bool): False if our value is a value in a dict
|
|
36
|
+
True if it is a key in a dict
|
|
37
|
+
False if our item is an item in a list
|
|
38
|
+
None if unset
|
|
39
|
+
"""
|
|
40
|
+
self.path_to_item = path_to_item
|
|
41
|
+
self.valid_classes = valid_classes
|
|
42
|
+
self.key_type = key_type
|
|
43
|
+
full_msg = msg
|
|
44
|
+
if path_to_item:
|
|
45
|
+
full_msg = "{0} at {1}".format(msg, render_path(path_to_item))
|
|
46
|
+
super(ApiTypeError, self).__init__(full_msg)
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
class ApiValueError(OpenApiException, ValueError):
|
|
50
|
+
def __init__(self, msg, path_to_item=None) -> None:
|
|
51
|
+
"""
|
|
52
|
+
Args:
|
|
53
|
+
msg (str): the exception message
|
|
54
|
+
|
|
55
|
+
Keyword Args:
|
|
56
|
+
path_to_item (list) the path to the exception in the
|
|
57
|
+
received_data dict. None if unset
|
|
58
|
+
"""
|
|
59
|
+
|
|
60
|
+
self.path_to_item = path_to_item
|
|
61
|
+
full_msg = msg
|
|
62
|
+
if path_to_item:
|
|
63
|
+
full_msg = "{0} at {1}".format(msg, render_path(path_to_item))
|
|
64
|
+
super(ApiValueError, self).__init__(full_msg)
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
class ApiAttributeError(OpenApiException, AttributeError):
|
|
68
|
+
def __init__(self, msg, path_to_item=None) -> None:
|
|
69
|
+
"""
|
|
70
|
+
Raised when an attribute reference or assignment fails.
|
|
71
|
+
|
|
72
|
+
Args:
|
|
73
|
+
msg (str): the exception message
|
|
74
|
+
|
|
75
|
+
Keyword Args:
|
|
76
|
+
path_to_item (None/list) the path to the exception in the
|
|
77
|
+
received_data dict
|
|
78
|
+
"""
|
|
79
|
+
self.path_to_item = path_to_item
|
|
80
|
+
full_msg = msg
|
|
81
|
+
if path_to_item:
|
|
82
|
+
full_msg = "{0} at {1}".format(msg, render_path(path_to_item))
|
|
83
|
+
super(ApiAttributeError, self).__init__(full_msg)
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
class ApiKeyError(OpenApiException, KeyError):
|
|
87
|
+
def __init__(self, msg, path_to_item=None) -> None:
|
|
88
|
+
"""
|
|
89
|
+
Args:
|
|
90
|
+
msg (str): the exception message
|
|
91
|
+
|
|
92
|
+
Keyword Args:
|
|
93
|
+
path_to_item (None/list) the path to the exception in the
|
|
94
|
+
received_data dict
|
|
95
|
+
"""
|
|
96
|
+
self.path_to_item = path_to_item
|
|
97
|
+
full_msg = msg
|
|
98
|
+
if path_to_item:
|
|
99
|
+
full_msg = "{0} at {1}".format(msg, render_path(path_to_item))
|
|
100
|
+
super(ApiKeyError, self).__init__(full_msg)
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
class ApiException(OpenApiException):
|
|
104
|
+
|
|
105
|
+
def __init__(
|
|
106
|
+
self,
|
|
107
|
+
status=None,
|
|
108
|
+
reason=None,
|
|
109
|
+
http_resp=None,
|
|
110
|
+
*,
|
|
111
|
+
body: Optional[str] = None,
|
|
112
|
+
data: Optional[Any] = None,
|
|
113
|
+
) -> None:
|
|
114
|
+
self.status = status
|
|
115
|
+
self.reason = reason
|
|
116
|
+
self.body = body
|
|
117
|
+
self.data = data
|
|
118
|
+
self.headers = None
|
|
119
|
+
|
|
120
|
+
if http_resp:
|
|
121
|
+
if self.status is None:
|
|
122
|
+
self.status = http_resp.status
|
|
123
|
+
if self.reason is None:
|
|
124
|
+
self.reason = http_resp.reason
|
|
125
|
+
if self.body is None:
|
|
126
|
+
try:
|
|
127
|
+
self.body = http_resp.data.decode('utf-8')
|
|
128
|
+
except Exception:
|
|
129
|
+
pass
|
|
130
|
+
self.headers = http_resp.headers
|
|
131
|
+
|
|
132
|
+
@classmethod
|
|
133
|
+
def from_response(
|
|
134
|
+
cls,
|
|
135
|
+
*,
|
|
136
|
+
http_resp,
|
|
137
|
+
body: Optional[str],
|
|
138
|
+
data: Optional[Any],
|
|
139
|
+
) -> Self:
|
|
140
|
+
from method_sdk.method_error import raise_typed_error
|
|
141
|
+
raise_typed_error(http_resp, body, data)
|
|
142
|
+
if http_resp.status == 400:
|
|
143
|
+
raise BadRequestException(http_resp=http_resp, body=body, data=data)
|
|
144
|
+
|
|
145
|
+
if http_resp.status == 401:
|
|
146
|
+
raise UnauthorizedException(http_resp=http_resp, body=body, data=data)
|
|
147
|
+
|
|
148
|
+
if http_resp.status == 403:
|
|
149
|
+
raise ForbiddenException(http_resp=http_resp, body=body, data=data)
|
|
150
|
+
|
|
151
|
+
if http_resp.status == 404:
|
|
152
|
+
raise NotFoundException(http_resp=http_resp, body=body, data=data)
|
|
153
|
+
|
|
154
|
+
# Added new conditions for 409 and 422
|
|
155
|
+
if http_resp.status == 409:
|
|
156
|
+
raise ConflictException(http_resp=http_resp, body=body, data=data)
|
|
157
|
+
|
|
158
|
+
if http_resp.status == 422:
|
|
159
|
+
raise UnprocessableEntityException(http_resp=http_resp, body=body, data=data)
|
|
160
|
+
|
|
161
|
+
if 500 <= http_resp.status <= 599:
|
|
162
|
+
raise ServiceException(http_resp=http_resp, body=body, data=data)
|
|
163
|
+
raise ApiException(http_resp=http_resp, body=body, data=data)
|
|
164
|
+
|
|
165
|
+
def __str__(self):
|
|
166
|
+
"""Custom error messages for exception"""
|
|
167
|
+
error_message = "({0})\n"\
|
|
168
|
+
"Reason: {1}\n".format(self.status, self.reason)
|
|
169
|
+
if self.headers:
|
|
170
|
+
error_message += "HTTP response headers: {0}\n".format(
|
|
171
|
+
self.headers)
|
|
172
|
+
|
|
173
|
+
if self.body:
|
|
174
|
+
error_message += "HTTP response body: {0}\n".format(self.body)
|
|
175
|
+
|
|
176
|
+
if self.data:
|
|
177
|
+
error_message += "HTTP response data: {0}\n".format(self.data)
|
|
178
|
+
|
|
179
|
+
return error_message
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
class BadRequestException(ApiException):
|
|
183
|
+
pass
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
class NotFoundException(ApiException):
|
|
187
|
+
pass
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
class UnauthorizedException(ApiException):
|
|
191
|
+
pass
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
class ForbiddenException(ApiException):
|
|
195
|
+
pass
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
class ServiceException(ApiException):
|
|
199
|
+
pass
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
class ConflictException(ApiException):
|
|
203
|
+
"""Exception for HTTP 409 Conflict."""
|
|
204
|
+
pass
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
class UnprocessableEntityException(ApiException):
|
|
208
|
+
"""Exception for HTTP 422 Unprocessable Entity."""
|
|
209
|
+
pass
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
def render_path(path_to_item):
|
|
213
|
+
"""Returns a string representation of a path"""
|
|
214
|
+
result = ""
|
|
215
|
+
for pth in path_to_item:
|
|
216
|
+
if isinstance(pth, int):
|
|
217
|
+
result += "[{0}]".format(pth)
|
|
218
|
+
else:
|
|
219
|
+
result += "['{0}']".format(pth)
|
|
220
|
+
return result
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
# flake8: noqa
|
|
4
|
+
|
|
5
|
+
"""
|
|
6
|
+
InventoryService
|
|
7
|
+
|
|
8
|
+
Attack surface, assets, and environments
|
|
9
|
+
|
|
10
|
+
The version of the OpenAPI document: 3
|
|
11
|
+
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
|
12
|
+
|
|
13
|
+
Do not edit the class manually.
|
|
14
|
+
""" # noqa: E501
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
__version__ = "0.35.0"
|
|
18
|
+
|
|
19
|
+
# Define package exports
|
|
20
|
+
__all__ = [
|
|
21
|
+
"InventoryApi",
|
|
22
|
+
"ApiResponse",
|
|
23
|
+
"ApiClient",
|
|
24
|
+
"Configuration",
|
|
25
|
+
"OpenApiException",
|
|
26
|
+
"ApiTypeError",
|
|
27
|
+
"ApiValueError",
|
|
28
|
+
"ApiKeyError",
|
|
29
|
+
"ApiAttributeError",
|
|
30
|
+
"ApiException",
|
|
31
|
+
"AccessDeniedResponseContent",
|
|
32
|
+
"CreateEnvironment400ErrorResponseContent",
|
|
33
|
+
"CreateEnvironmentRequestContent",
|
|
34
|
+
"CreateEnvironmentResponseContent",
|
|
35
|
+
"DeleteEnvironment400ErrorResponseContent",
|
|
36
|
+
"DeleteEnvironmentResponseContent",
|
|
37
|
+
"Environment",
|
|
38
|
+
"EnvironmentNotFoundResponseContent",
|
|
39
|
+
"EnvironmentState",
|
|
40
|
+
"GetEnvironment400ErrorResponseContent",
|
|
41
|
+
"GetEnvironmentResponseContent",
|
|
42
|
+
"InternalServerResponseContent",
|
|
43
|
+
"InvalidParameter",
|
|
44
|
+
"ListEnvironments400ErrorResponseContent",
|
|
45
|
+
"ListEnvironmentsResponseContent",
|
|
46
|
+
"MalformedRequest",
|
|
47
|
+
"MissingParameter",
|
|
48
|
+
"ServiceUnavailableResponseContent",
|
|
49
|
+
"ThrottlingResponseContent",
|
|
50
|
+
"UnauthenticatedResponseContent",
|
|
51
|
+
"UpdateEnvironment400ErrorResponseContent",
|
|
52
|
+
"UpdateEnvironmentRequestContent",
|
|
53
|
+
"UpdateEnvironmentResponseContent",
|
|
54
|
+
]
|
|
55
|
+
|
|
56
|
+
# import apis into sdk package
|
|
57
|
+
from method_sdk.inventory.api.inventory_api import InventoryApi as InventoryApi
|
|
58
|
+
|
|
59
|
+
# import ApiClient
|
|
60
|
+
from method_sdk.inventory.api_response import ApiResponse as ApiResponse
|
|
61
|
+
from method_sdk.inventory.api_client import ApiClient as ApiClient
|
|
62
|
+
from method_sdk.inventory.configuration import Configuration as Configuration
|
|
63
|
+
from method_sdk.inventory.exceptions import OpenApiException as OpenApiException
|
|
64
|
+
from method_sdk.inventory.exceptions import ApiTypeError as ApiTypeError
|
|
65
|
+
from method_sdk.inventory.exceptions import ApiValueError as ApiValueError
|
|
66
|
+
from method_sdk.inventory.exceptions import ApiKeyError as ApiKeyError
|
|
67
|
+
from method_sdk.inventory.exceptions import ApiAttributeError as ApiAttributeError
|
|
68
|
+
from method_sdk.inventory.exceptions import ApiException as ApiException
|
|
69
|
+
|
|
70
|
+
# import models into sdk package
|
|
71
|
+
from method_sdk.inventory.models.access_denied_response_content import AccessDeniedResponseContent as AccessDeniedResponseContent
|
|
72
|
+
from method_sdk.inventory.models.create_environment400_error_response_content import CreateEnvironment400ErrorResponseContent as CreateEnvironment400ErrorResponseContent
|
|
73
|
+
from method_sdk.inventory.models.create_environment_request_content import CreateEnvironmentRequestContent as CreateEnvironmentRequestContent
|
|
74
|
+
from method_sdk.inventory.models.create_environment_response_content import CreateEnvironmentResponseContent as CreateEnvironmentResponseContent
|
|
75
|
+
from method_sdk.inventory.models.delete_environment400_error_response_content import DeleteEnvironment400ErrorResponseContent as DeleteEnvironment400ErrorResponseContent
|
|
76
|
+
from method_sdk.inventory.models.delete_environment_response_content import DeleteEnvironmentResponseContent as DeleteEnvironmentResponseContent
|
|
77
|
+
from method_sdk.inventory.models.environment import Environment as Environment
|
|
78
|
+
from method_sdk.inventory.models.environment_not_found_response_content import EnvironmentNotFoundResponseContent as EnvironmentNotFoundResponseContent
|
|
79
|
+
from method_sdk.inventory.models.environment_state import EnvironmentState as EnvironmentState
|
|
80
|
+
from method_sdk.inventory.models.get_environment400_error_response_content import GetEnvironment400ErrorResponseContent as GetEnvironment400ErrorResponseContent
|
|
81
|
+
from method_sdk.inventory.models.get_environment_response_content import GetEnvironmentResponseContent as GetEnvironmentResponseContent
|
|
82
|
+
from method_sdk.inventory.models.internal_server_response_content import InternalServerResponseContent as InternalServerResponseContent
|
|
83
|
+
from method_sdk.inventory.models.invalid_parameter import InvalidParameter as InvalidParameter
|
|
84
|
+
from method_sdk.inventory.models.list_environments400_error_response_content import ListEnvironments400ErrorResponseContent as ListEnvironments400ErrorResponseContent
|
|
85
|
+
from method_sdk.inventory.models.list_environments_response_content import ListEnvironmentsResponseContent as ListEnvironmentsResponseContent
|
|
86
|
+
from method_sdk.inventory.models.malformed_request import MalformedRequest as MalformedRequest
|
|
87
|
+
from method_sdk.inventory.models.missing_parameter import MissingParameter as MissingParameter
|
|
88
|
+
from method_sdk.inventory.models.service_unavailable_response_content import ServiceUnavailableResponseContent as ServiceUnavailableResponseContent
|
|
89
|
+
from method_sdk.inventory.models.throttling_response_content import ThrottlingResponseContent as ThrottlingResponseContent
|
|
90
|
+
from method_sdk.inventory.models.unauthenticated_response_content import UnauthenticatedResponseContent as UnauthenticatedResponseContent
|
|
91
|
+
from method_sdk.inventory.models.update_environment400_error_response_content import UpdateEnvironment400ErrorResponseContent as UpdateEnvironment400ErrorResponseContent
|
|
92
|
+
from method_sdk.inventory.models.update_environment_request_content import UpdateEnvironmentRequestContent as UpdateEnvironmentRequestContent
|
|
93
|
+
from method_sdk.inventory.models.update_environment_response_content import UpdateEnvironmentResponseContent as UpdateEnvironmentResponseContent
|
|
94
|
+
|