laceworksdk.api.v1.suppressions
Lacework Suppressions API wrapper.
1""" 2Lacework Suppressions API wrapper. 3""" 4 5import logging 6 7logger = logging.getLogger(__name__) 8 9 10class SuppressionsAPI: 11 """ 12 Lacework Suppressions API. 13 """ 14 15 def __init__(self, session): 16 """ 17 Initializes the SuppressionsAPI object. 18 19 :param session: An instance of the HttpSession class 20 21 :return SuppressionsAPI object. 22 """ 23 24 super().__init__() 25 26 self._session = session 27 28 def create(self, 29 type, 30 data): 31 """ 32 A method to create supressions. 33 34 :param type: A string representing the type of CSP supression(s) to create. 35 ('aws', 'azure', or 'gcp') 36 :param data: A JSON object containing the supression(s) to create 37 38 :return response json 39 """ 40 41 logger.info("Creating supression(s) in Lacework...") 42 43 # Build the Suppressions request URI 44 api_uri = f"/api/v1/external/suppressions/{type}" 45 46 response = self._session.post(api_uri, data=data) 47 48 return response.json() 49 50 def get(self, 51 type, 52 recommendation_id=None): 53 """ 54 A method to get supressions. 55 56 :param type: A string representing the type of CSP suppression(s) to retreive. 57 ('aws', 'azure', or 'gcp') 58 :param recommendation_id: A string representing the recommendation ID to retreive. 59 60 :return response json 61 """ 62 63 # Log/Build the Suppressions request URI 64 if recommendation_id: 65 logger.info(f"Getting {type} suppression {recommendation_id} from Lacework...") 66 api_uri = f"/api/v1/external/suppressions/{type}/allExceptions/{recommendation_id}" 67 else: 68 logger.info(f"Getting {type} suppressions from Lacework...") 69 api_uri = f"/api/v1/external/suppressions/{type}/allExceptions" 70 71 response = self._session.get(api_uri) 72 73 return response.json() 74 75 def delete(self, 76 type, 77 data): 78 """ 79 A method to delete supressions. 80 81 :param type: A string representing the type of CSP suppression(s) to delete. 82 ('aws', 'azure', or 'gcp') 83 :param data: A JSON object containing the supression(s) to create 84 85 :return response json 86 """ 87 88 logger.info("Deleting supression(s) in Lacework...") 89 90 # Build the Suppressions request URI 91 api_uri = f"/api/v1/external/suppressions/{type}" 92 93 response = self._session.delete(api_uri, data=data) 94 95 if response.status_code == 204: 96 return response 97 else: 98 return response.json()
class
SuppressionsAPI:
11class SuppressionsAPI: 12 """ 13 Lacework Suppressions API. 14 """ 15 16 def __init__(self, session): 17 """ 18 Initializes the SuppressionsAPI object. 19 20 :param session: An instance of the HttpSession class 21 22 :return SuppressionsAPI object. 23 """ 24 25 super().__init__() 26 27 self._session = session 28 29 def create(self, 30 type, 31 data): 32 """ 33 A method to create supressions. 34 35 :param type: A string representing the type of CSP supression(s) to create. 36 ('aws', 'azure', or 'gcp') 37 :param data: A JSON object containing the supression(s) to create 38 39 :return response json 40 """ 41 42 logger.info("Creating supression(s) in Lacework...") 43 44 # Build the Suppressions request URI 45 api_uri = f"/api/v1/external/suppressions/{type}" 46 47 response = self._session.post(api_uri, data=data) 48 49 return response.json() 50 51 def get(self, 52 type, 53 recommendation_id=None): 54 """ 55 A method to get supressions. 56 57 :param type: A string representing the type of CSP suppression(s) to retreive. 58 ('aws', 'azure', or 'gcp') 59 :param recommendation_id: A string representing the recommendation ID to retreive. 60 61 :return response json 62 """ 63 64 # Log/Build the Suppressions request URI 65 if recommendation_id: 66 logger.info(f"Getting {type} suppression {recommendation_id} from Lacework...") 67 api_uri = f"/api/v1/external/suppressions/{type}/allExceptions/{recommendation_id}" 68 else: 69 logger.info(f"Getting {type} suppressions from Lacework...") 70 api_uri = f"/api/v1/external/suppressions/{type}/allExceptions" 71 72 response = self._session.get(api_uri) 73 74 return response.json() 75 76 def delete(self, 77 type, 78 data): 79 """ 80 A method to delete supressions. 81 82 :param type: A string representing the type of CSP suppression(s) to delete. 83 ('aws', 'azure', or 'gcp') 84 :param data: A JSON object containing the supression(s) to create 85 86 :return response json 87 """ 88 89 logger.info("Deleting supression(s) in Lacework...") 90 91 # Build the Suppressions request URI 92 api_uri = f"/api/v1/external/suppressions/{type}" 93 94 response = self._session.delete(api_uri, data=data) 95 96 if response.status_code == 204: 97 return response 98 else: 99 return response.json()
Lacework Suppressions API.
SuppressionsAPI(session)
16 def __init__(self, session): 17 """ 18 Initializes the SuppressionsAPI object. 19 20 :param session: An instance of the HttpSession class 21 22 :return SuppressionsAPI object. 23 """ 24 25 super().__init__() 26 27 self._session = session
Initializes the SuppressionsAPI object.
Parameters
- session: An instance of the HttpSession class
:return SuppressionsAPI object.
def
create(self, type, data):
29 def create(self, 30 type, 31 data): 32 """ 33 A method to create supressions. 34 35 :param type: A string representing the type of CSP supression(s) to create. 36 ('aws', 'azure', or 'gcp') 37 :param data: A JSON object containing the supression(s) to create 38 39 :return response json 40 """ 41 42 logger.info("Creating supression(s) in Lacework...") 43 44 # Build the Suppressions request URI 45 api_uri = f"/api/v1/external/suppressions/{type}" 46 47 response = self._session.post(api_uri, data=data) 48 49 return response.json()
A method to create supressions.
Parameters
- type: A string representing the type of CSP supression(s) to create. ('aws', 'azure', or 'gcp')
- data: A JSON object containing the supression(s) to create
:return response json
def
get(self, type, recommendation_id=None):
51 def get(self, 52 type, 53 recommendation_id=None): 54 """ 55 A method to get supressions. 56 57 :param type: A string representing the type of CSP suppression(s) to retreive. 58 ('aws', 'azure', or 'gcp') 59 :param recommendation_id: A string representing the recommendation ID to retreive. 60 61 :return response json 62 """ 63 64 # Log/Build the Suppressions request URI 65 if recommendation_id: 66 logger.info(f"Getting {type} suppression {recommendation_id} from Lacework...") 67 api_uri = f"/api/v1/external/suppressions/{type}/allExceptions/{recommendation_id}" 68 else: 69 logger.info(f"Getting {type} suppressions from Lacework...") 70 api_uri = f"/api/v1/external/suppressions/{type}/allExceptions" 71 72 response = self._session.get(api_uri) 73 74 return response.json()
A method to get supressions.
Parameters
- type: A string representing the type of CSP suppression(s) to retreive. ('aws', 'azure', or 'gcp')
- recommendation_id: A string representing the recommendation ID to retreive.
:return response json
def
delete(self, type, data):
76 def delete(self, 77 type, 78 data): 79 """ 80 A method to delete supressions. 81 82 :param type: A string representing the type of CSP suppression(s) to delete. 83 ('aws', 'azure', or 'gcp') 84 :param data: A JSON object containing the supression(s) to create 85 86 :return response json 87 """ 88 89 logger.info("Deleting supression(s) in Lacework...") 90 91 # Build the Suppressions request URI 92 api_uri = f"/api/v1/external/suppressions/{type}" 93 94 response = self._session.delete(api_uri, data=data) 95 96 if response.status_code == 204: 97 return response 98 else: 99 return response.json()
A method to delete supressions.
Parameters
- type: A string representing the type of CSP suppression(s) to delete. ('aws', 'azure', or 'gcp')
- data: A JSON object containing the supression(s) to create
:return response json