Skip to content

Commit fb790d7

Browse files
alhumawjshcodes
authored andcommitted
Adding Decommissioned operations mapping and error result
1 parent 59a8927 commit fb790d7

4 files changed

Lines changed: 18 additions & 1 deletion

File tree

src/falconpy/_endpoint/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
from .deprecated import _user_management_deprecated
6666
from .deprecated import _deprecated_operation_mapping
6767
from .deprecated import _deprecated_class_mapping
68+
from .deprecated import _decommissioned_operations
6869
from .deprecated import _zero_trust_assessment_deprecated
6970

7071
from ._admission_control_policies import _admission_control_policies_endpoints
@@ -346,6 +347,7 @@
346347
# Mapping of manually deprecated endpoints
347348
operation_deprecation_mapping = _deprecated_operation_mapping
348349
class_deprecation_mapping = _deprecated_class_mapping
350+
decommissioned_operations = _decommissioned_operations
349351

350352
# api_endpoints contains all endpoints, production and deprecated
351353
api_endpoints.extend(deprecated_endpoints)

src/falconpy/_endpoint/deprecated/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@
7676
from ._workflows import _workflows_endpoints
7777
from ._zero_trust_assessment import _zero_trust_assessment_endpoints
7878
from ._mapping import _deprecated_op_mapping, _deprecated_cls_mapping
79+
from ._mapping import _decommissioned_operations # noqa: F401
7980
from ._certificate_based_exclusions import _certificate_based_exclusions_endpoints
8081

8182
_admission_control_policies_deprecated = _admission_control_policies_endpoints

src/falconpy/_endpoint/deprecated/_mapping.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,3 +72,8 @@
7272
"Iocs": "IOC",
7373
"Detects": "Alerts"
7474
}
75+
76+
_decommissioned_operations = [
77+
"AggregateFCIncidents",
78+
"QueryIncidentIdsByFilter",
79+
]

src/falconpy/_util/_functions.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
import urllib3
5353
from urllib3.exceptions import InsecureRequestWarning
5454
from .._api_request import APIRequest
55-
from .._endpoint import operation_deprecation_mapping
55+
from .._endpoint import operation_deprecation_mapping, decommissioned_operations
5656
from .._enum import BaseURL, ContainerBaseURL
5757
from .._constant import (
5858
PREFER_NONETYPE,
@@ -203,6 +203,8 @@ def factory(*args, **kwargs):
203203
# Should only receive this in pythonic mode
204204
raise api_error
205205
except (SDKError, InvalidMethod) as bad_sdk_command:
206+
if getattr(bad_sdk_command, 'code', None) == 410:
207+
raise bad_sdk_command
206208
created = bad_sdk_command.result
207209
return created
208210
return factory
@@ -689,6 +691,13 @@ def process_service_request(calling_object: ServiceClass, # pylint: disable=R09
689691
# Log the operation ID if we have logging enabled.
690692
if calling_object.log:
691693
calling_object.log.debug("OPERATION: %s", operation_id)
694+
# Intercept decommissioned operations before making any API call.
695+
if operation_id in decommissioned_operations:
696+
_msg = (f"The {operation_id} operation has been decommissioned "
697+
f"by CrowdStrike and is no longer available.")
698+
if calling_object.log:
699+
calling_object.log.warning(_msg)
700+
return generate_error_result(message=_msg, code=410, caller=calling_object)
692701
# We have to create our headers dictionary first, as authentication happens here.
693702
# For scenarios where cloud region autodiscovery is leveraged, we cannot create
694703
# the target URL for our call to requests until we know our correct base_url.

0 commit comments

Comments
 (0)