laceworksdk.api.v2.policy_exceptions
Lacework Exceptions API wrapper.
1# -*- coding: utf-8 -*- 2""" 3Lacework Exceptions API wrapper. 4""" 5 6from laceworksdk.api.crud_endpoint import CrudEndpoint 7 8 9class PolicyExceptionsAPI(CrudEndpoint): 10 11 def __init__(self, session): 12 """ 13 Initializes the PolicyExceptionsAPI object. 14 15 :param session: An instance of the HttpSession class 16 17 :return PolicyExceptionsAPI object. 18 """ 19 20 super().__init__(session, "Exceptions") 21 22 def create(self, 23 policy_id, 24 description, 25 constraints, 26 **request_params): 27 """ 28 A method to create a new Exceptions object. 29 30 :param policy_id: A string representing the object policy ID. 31 :param description: A string representing the object description. 32 :param constraints: A string representing the object contraints. 33 :obj 34 :param field_key: A string representing the contraint key 35 ('accountIds', 'resourceNames', 'regionNames' and 'resourceTags') 36 :param field_values: An array of strings representing constraint values 37 :param request_params: Additional request parameters. 38 (provides support for parameters that may be added in the future) 39 40 :return response json 41 """ 42 43 params = self.build_dict_from_items( 44 policy_id=policy_id 45 ) 46 47 return super().create( 48 params=params, 49 description=description, 50 constraints=constraints, 51 **request_params 52 ) 53 54 def get(self, 55 exception_id=None, 56 policy_id=None): 57 """ 58 A method to get Exceptions objects. 59 60 :param exception_id: A string representing the exception ID. 61 :param policy_id: A string representing the object policy ID. 62 63 :return response json 64 """ 65 66 return super().get(id=exception_id, policy_id=policy_id) 67 68 def get_by_id(self, 69 exception_id, 70 policy_id): 71 """ 72 A method to get a Exceptions object by policy ID. 73 74 :param exception_id: A string representing the exception ID. 75 :param policy_id: A string representing the object policy ID. 76 77 :return response json 78 """ 79 80 return self.get( 81 exception_id=exception_id, 82 policy_id=policy_id 83 ) 84 85 def update(self, 86 exception_id, 87 policy_id, 88 description=None, 89 constraints=None, 90 **request_params): 91 """ 92 A method to create a new Exceptions object. 93 94 :param exception_id: A string representing the exception ID. 95 :param policy_id: A string representing the object policy ID. 96 :param description: A string representing the object description. 97 :param constraints: A string representing the object contraints. 98 :obj 99 :param field_key: A string representing the contraint key 100 ('accountIds', 'resourceNames', 'regionNames' and 'resourceTags') 101 :param field_values: An array of strings representing constraint values 102 :param request_params: Additional request parameters. 103 (provides support for parameters that may be added in the future) 104 105 :return response json 106 """ 107 108 params = self.build_dict_from_items( 109 policy_id=policy_id 110 ) 111 112 return super().update( 113 id=exception_id, 114 params=params, 115 description=description, 116 constraints=constraints, 117 **request_params 118 ) 119 120 def delete(self, 121 exception_id, 122 policy_id): 123 """ 124 A method to delete an Exceptions object. 125 126 :param exception_id: A string representing the exception ID. 127 :param policy_id: A string representing the object policy ID. 128 129 :return response json 130 """ 131 132 params = self.build_dict_from_items( 133 policy_id=policy_id 134 ) 135 136 return super().delete(id=exception_id, params=params)
10class PolicyExceptionsAPI(CrudEndpoint): 11 12 def __init__(self, session): 13 """ 14 Initializes the PolicyExceptionsAPI object. 15 16 :param session: An instance of the HttpSession class 17 18 :return PolicyExceptionsAPI object. 19 """ 20 21 super().__init__(session, "Exceptions") 22 23 def create(self, 24 policy_id, 25 description, 26 constraints, 27 **request_params): 28 """ 29 A method to create a new Exceptions object. 30 31 :param policy_id: A string representing the object policy ID. 32 :param description: A string representing the object description. 33 :param constraints: A string representing the object contraints. 34 :obj 35 :param field_key: A string representing the contraint key 36 ('accountIds', 'resourceNames', 'regionNames' and 'resourceTags') 37 :param field_values: An array of strings representing constraint values 38 :param request_params: Additional request parameters. 39 (provides support for parameters that may be added in the future) 40 41 :return response json 42 """ 43 44 params = self.build_dict_from_items( 45 policy_id=policy_id 46 ) 47 48 return super().create( 49 params=params, 50 description=description, 51 constraints=constraints, 52 **request_params 53 ) 54 55 def get(self, 56 exception_id=None, 57 policy_id=None): 58 """ 59 A method to get Exceptions objects. 60 61 :param exception_id: A string representing the exception ID. 62 :param policy_id: A string representing the object policy ID. 63 64 :return response json 65 """ 66 67 return super().get(id=exception_id, policy_id=policy_id) 68 69 def get_by_id(self, 70 exception_id, 71 policy_id): 72 """ 73 A method to get a Exceptions object by policy ID. 74 75 :param exception_id: A string representing the exception ID. 76 :param policy_id: A string representing the object policy ID. 77 78 :return response json 79 """ 80 81 return self.get( 82 exception_id=exception_id, 83 policy_id=policy_id 84 ) 85 86 def update(self, 87 exception_id, 88 policy_id, 89 description=None, 90 constraints=None, 91 **request_params): 92 """ 93 A method to create a new Exceptions object. 94 95 :param exception_id: A string representing the exception ID. 96 :param policy_id: A string representing the object policy ID. 97 :param description: A string representing the object description. 98 :param constraints: A string representing the object contraints. 99 :obj 100 :param field_key: A string representing the contraint key 101 ('accountIds', 'resourceNames', 'regionNames' and 'resourceTags') 102 :param field_values: An array of strings representing constraint values 103 :param request_params: Additional request parameters. 104 (provides support for parameters that may be added in the future) 105 106 :return response json 107 """ 108 109 params = self.build_dict_from_items( 110 policy_id=policy_id 111 ) 112 113 return super().update( 114 id=exception_id, 115 params=params, 116 description=description, 117 constraints=constraints, 118 **request_params 119 ) 120 121 def delete(self, 122 exception_id, 123 policy_id): 124 """ 125 A method to delete an Exceptions object. 126 127 :param exception_id: A string representing the exception ID. 128 :param policy_id: A string representing the object policy ID. 129 130 :return response json 131 """ 132 133 params = self.build_dict_from_items( 134 policy_id=policy_id 135 ) 136 137 return super().delete(id=exception_id, params=params)
A class used to implement CRUD create/read/update/delete functionality for Lacework API Endpoints
PolicyExceptionsAPI(session)
12 def __init__(self, session): 13 """ 14 Initializes the PolicyExceptionsAPI object. 15 16 :param session: An instance of the HttpSession class 17 18 :return PolicyExceptionsAPI object. 19 """ 20 21 super().__init__(session, "Exceptions")
Initializes the PolicyExceptionsAPI object.
Parameters
- session: An instance of the HttpSession class
:return PolicyExceptionsAPI object.
def
create(self, policy_id, description, constraints, **request_params):
23 def create(self, 24 policy_id, 25 description, 26 constraints, 27 **request_params): 28 """ 29 A method to create a new Exceptions object. 30 31 :param policy_id: A string representing the object policy ID. 32 :param description: A string representing the object description. 33 :param constraints: A string representing the object contraints. 34 :obj 35 :param field_key: A string representing the contraint key 36 ('accountIds', 'resourceNames', 'regionNames' and 'resourceTags') 37 :param field_values: An array of strings representing constraint values 38 :param request_params: Additional request parameters. 39 (provides support for parameters that may be added in the future) 40 41 :return response json 42 """ 43 44 params = self.build_dict_from_items( 45 policy_id=policy_id 46 ) 47 48 return super().create( 49 params=params, 50 description=description, 51 constraints=constraints, 52 **request_params 53 )
A method to create a new Exceptions object.
Parameters
- policy_id: A string representing the object policy ID.
- description: A string representing the object description.
- constraints: A string representing the object contraints. :obj :param field_key: A string representing the contraint key ('accountIds', 'resourceNames', 'regionNames' and 'resourceTags') :param field_values: An array of strings representing constraint values
- request_params: Additional request parameters. (provides support for parameters that may be added in the future)
:return response json
def
get(self, exception_id=None, policy_id=None):
55 def get(self, 56 exception_id=None, 57 policy_id=None): 58 """ 59 A method to get Exceptions objects. 60 61 :param exception_id: A string representing the exception ID. 62 :param policy_id: A string representing the object policy ID. 63 64 :return response json 65 """ 66 67 return super().get(id=exception_id, policy_id=policy_id)
A method to get Exceptions objects.
Parameters
- exception_id: A string representing the exception ID.
- policy_id: A string representing the object policy ID.
:return response json
def
get_by_id(self, exception_id, policy_id):
69 def get_by_id(self, 70 exception_id, 71 policy_id): 72 """ 73 A method to get a Exceptions object by policy ID. 74 75 :param exception_id: A string representing the exception ID. 76 :param policy_id: A string representing the object policy ID. 77 78 :return response json 79 """ 80 81 return self.get( 82 exception_id=exception_id, 83 policy_id=policy_id 84 )
A method to get a Exceptions object by policy ID.
Parameters
- exception_id: A string representing the exception ID.
- policy_id: A string representing the object policy ID.
:return response json
def
update( self, exception_id, policy_id, description=None, constraints=None, **request_params):
86 def update(self, 87 exception_id, 88 policy_id, 89 description=None, 90 constraints=None, 91 **request_params): 92 """ 93 A method to create a new Exceptions object. 94 95 :param exception_id: A string representing the exception ID. 96 :param policy_id: A string representing the object policy ID. 97 :param description: A string representing the object description. 98 :param constraints: A string representing the object contraints. 99 :obj 100 :param field_key: A string representing the contraint key 101 ('accountIds', 'resourceNames', 'regionNames' and 'resourceTags') 102 :param field_values: An array of strings representing constraint values 103 :param request_params: Additional request parameters. 104 (provides support for parameters that may be added in the future) 105 106 :return response json 107 """ 108 109 params = self.build_dict_from_items( 110 policy_id=policy_id 111 ) 112 113 return super().update( 114 id=exception_id, 115 params=params, 116 description=description, 117 constraints=constraints, 118 **request_params 119 )
A method to create a new Exceptions object.
Parameters
- exception_id: A string representing the exception ID.
- policy_id: A string representing the object policy ID.
- description: A string representing the object description.
- constraints: A string representing the object contraints. :obj :param field_key: A string representing the contraint key ('accountIds', 'resourceNames', 'regionNames' and 'resourceTags') :param field_values: An array of strings representing constraint values
- request_params: Additional request parameters. (provides support for parameters that may be added in the future)
:return response json
def
delete(self, exception_id, policy_id):
121 def delete(self, 122 exception_id, 123 policy_id): 124 """ 125 A method to delete an Exceptions object. 126 127 :param exception_id: A string representing the exception ID. 128 :param policy_id: A string representing the object policy ID. 129 130 :return response json 131 """ 132 133 params = self.build_dict_from_items( 134 policy_id=policy_id 135 ) 136 137 return super().delete(id=exception_id, params=params)
A method to delete an Exceptions object.
Parameters
- exception_id: A string representing the exception ID.
- policy_id: A string representing the object policy ID.
:return response json