laceworksdk.api.v2.alert_channels
Lacework AlertChannels API wrapper.
1# -*- coding: utf-8 -*- 2""" 3Lacework AlertChannels API wrapper. 4""" 5 6from laceworksdk.api.crud_endpoint import CrudEndpoint 7 8 9class AlertChannelsAPI(CrudEndpoint): 10 11 def __init__(self, session): 12 """ 13 Initializes the AlertChannelsAPI object. 14 15 :param session: An instance of the HttpSession class 16 17 :return AlertChannelsAPI object. 18 """ 19 20 super().__init__(session, "AlertChannels") 21 22 def create(self, 23 name, 24 type, 25 enabled, 26 data, 27 **request_params): 28 """ 29 A method to create a new AlertChannels object. 30 31 :param name: A string representing the object name. 32 :param type: A string representing the object type. 33 :param enabled: A boolean/integer representing whether the object is enabled. 34 (0 or 1) 35 :param data: A JSON object matching the schema for the specified type. 36 :param request_params: Additional request parameters. 37 (provides support for parameters that may be added in the future) 38 39 :return response json 40 """ 41 42 return super().create( 43 name=name, 44 type=type, 45 enabled=int(bool(enabled)), 46 data=data, 47 **request_params 48 ) 49 50 def get(self, 51 guid=None, 52 type=None): 53 """ 54 A method to get AlertChannels objects. 55 56 :param guid: A string representing the object GUID. 57 :param type: A string representing the object type. 58 59 :return response json 60 """ 61 62 return super().get( 63 id=guid, 64 resource=type 65 ) 66 67 def get_by_guid(self, 68 guid): 69 """ 70 A method to get AlertChannels objects by GUID. 71 72 :param guid: A string representing the object GUID. 73 74 :return response json 75 """ 76 77 return self.get(guid=guid) 78 79 def get_by_type(self, 80 type): 81 """ 82 A method to get AlertChannels objects by type. 83 84 :param type: A string representing the object type. 85 86 :return response json 87 """ 88 89 return self.get(type=type) 90 91 def update(self, 92 guid, 93 name=None, 94 type=None, 95 enabled=None, 96 data=None, 97 **request_params): 98 """ 99 A method to update an AlertChannels object. 100 101 :param guid: A string representing the object GUID. 102 :param name: A string representing the object name. 103 :param type: A string representing the object type. 104 :param enabled: A boolean/integer representing whether the object is enabled. 105 (0 or 1) 106 :param data: A JSON object matching the schema for the specified type. 107 :param request_params: Additional request parameters. 108 (provides support for parameters that may be added in the future) 109 110 :return response json 111 """ 112 113 if enabled is not None: 114 enabled = int(bool(enabled)) 115 116 return super().update( 117 id=guid, 118 name=name, 119 type=type, 120 enabled=enabled, 121 data=data, 122 **request_params 123 ) 124 125 def delete(self, 126 guid): 127 """ 128 A method to delete an AlertChannels object. 129 130 :param guid: A string representing the object GUID. 131 132 :return response json 133 """ 134 135 return super().delete(id=guid) 136 137 def test(self, 138 guid): 139 """ 140 A method to test an AlertChannels object. 141 142 :param guid: A string representing the object GUID. 143 144 :return response json 145 """ 146 147 response = self._session.post(self.build_url(resource=guid, action="test")) 148 149 return response
10class AlertChannelsAPI(CrudEndpoint): 11 12 def __init__(self, session): 13 """ 14 Initializes the AlertChannelsAPI object. 15 16 :param session: An instance of the HttpSession class 17 18 :return AlertChannelsAPI object. 19 """ 20 21 super().__init__(session, "AlertChannels") 22 23 def create(self, 24 name, 25 type, 26 enabled, 27 data, 28 **request_params): 29 """ 30 A method to create a new AlertChannels object. 31 32 :param name: A string representing the object name. 33 :param type: A string representing the object type. 34 :param enabled: A boolean/integer representing whether the object is enabled. 35 (0 or 1) 36 :param data: A JSON object matching the schema for the specified type. 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 return super().create( 44 name=name, 45 type=type, 46 enabled=int(bool(enabled)), 47 data=data, 48 **request_params 49 ) 50 51 def get(self, 52 guid=None, 53 type=None): 54 """ 55 A method to get AlertChannels objects. 56 57 :param guid: A string representing the object GUID. 58 :param type: A string representing the object type. 59 60 :return response json 61 """ 62 63 return super().get( 64 id=guid, 65 resource=type 66 ) 67 68 def get_by_guid(self, 69 guid): 70 """ 71 A method to get AlertChannels objects by GUID. 72 73 :param guid: A string representing the object GUID. 74 75 :return response json 76 """ 77 78 return self.get(guid=guid) 79 80 def get_by_type(self, 81 type): 82 """ 83 A method to get AlertChannels objects by type. 84 85 :param type: A string representing the object type. 86 87 :return response json 88 """ 89 90 return self.get(type=type) 91 92 def update(self, 93 guid, 94 name=None, 95 type=None, 96 enabled=None, 97 data=None, 98 **request_params): 99 """ 100 A method to update an AlertChannels object. 101 102 :param guid: A string representing the object GUID. 103 :param name: A string representing the object name. 104 :param type: A string representing the object type. 105 :param enabled: A boolean/integer representing whether the object is enabled. 106 (0 or 1) 107 :param data: A JSON object matching the schema for the specified type. 108 :param request_params: Additional request parameters. 109 (provides support for parameters that may be added in the future) 110 111 :return response json 112 """ 113 114 if enabled is not None: 115 enabled = int(bool(enabled)) 116 117 return super().update( 118 id=guid, 119 name=name, 120 type=type, 121 enabled=enabled, 122 data=data, 123 **request_params 124 ) 125 126 def delete(self, 127 guid): 128 """ 129 A method to delete an AlertChannels object. 130 131 :param guid: A string representing the object GUID. 132 133 :return response json 134 """ 135 136 return super().delete(id=guid) 137 138 def test(self, 139 guid): 140 """ 141 A method to test an AlertChannels object. 142 143 :param guid: A string representing the object GUID. 144 145 :return response json 146 """ 147 148 response = self._session.post(self.build_url(resource=guid, action="test")) 149 150 return response
A class used to implement CRUD create/read/update/delete functionality for Lacework API Endpoints
AlertChannelsAPI(session)
12 def __init__(self, session): 13 """ 14 Initializes the AlertChannelsAPI object. 15 16 :param session: An instance of the HttpSession class 17 18 :return AlertChannelsAPI object. 19 """ 20 21 super().__init__(session, "AlertChannels")
Initializes the AlertChannelsAPI object.
Parameters
- session: An instance of the HttpSession class
:return AlertChannelsAPI object.
def
create(self, name, type, enabled, data, **request_params):
23 def create(self, 24 name, 25 type, 26 enabled, 27 data, 28 **request_params): 29 """ 30 A method to create a new AlertChannels object. 31 32 :param name: A string representing the object name. 33 :param type: A string representing the object type. 34 :param enabled: A boolean/integer representing whether the object is enabled. 35 (0 or 1) 36 :param data: A JSON object matching the schema for the specified type. 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 return super().create( 44 name=name, 45 type=type, 46 enabled=int(bool(enabled)), 47 data=data, 48 **request_params 49 )
A method to create a new AlertChannels object.
Parameters
- name: A string representing the object name.
- type: A string representing the object type.
- enabled: A boolean/integer representing whether the object is enabled. (0 or 1)
- data: A JSON object matching the schema for the specified type.
- request_params: Additional request parameters. (provides support for parameters that may be added in the future)
:return response json
def
get(self, guid=None, type=None):
51 def get(self, 52 guid=None, 53 type=None): 54 """ 55 A method to get AlertChannels objects. 56 57 :param guid: A string representing the object GUID. 58 :param type: A string representing the object type. 59 60 :return response json 61 """ 62 63 return super().get( 64 id=guid, 65 resource=type 66 )
A method to get AlertChannels objects.
Parameters
- guid: A string representing the object GUID.
- type: A string representing the object type.
:return response json
def
get_by_guid(self, guid):
68 def get_by_guid(self, 69 guid): 70 """ 71 A method to get AlertChannels objects by GUID. 72 73 :param guid: A string representing the object GUID. 74 75 :return response json 76 """ 77 78 return self.get(guid=guid)
A method to get AlertChannels objects by GUID.
Parameters
- guid: A string representing the object GUID.
:return response json
def
get_by_type(self, type):
80 def get_by_type(self, 81 type): 82 """ 83 A method to get AlertChannels objects by type. 84 85 :param type: A string representing the object type. 86 87 :return response json 88 """ 89 90 return self.get(type=type)
A method to get AlertChannels objects by type.
Parameters
- type: A string representing the object type.
:return response json
def
update( self, guid, name=None, type=None, enabled=None, data=None, **request_params):
92 def update(self, 93 guid, 94 name=None, 95 type=None, 96 enabled=None, 97 data=None, 98 **request_params): 99 """ 100 A method to update an AlertChannels object. 101 102 :param guid: A string representing the object GUID. 103 :param name: A string representing the object name. 104 :param type: A string representing the object type. 105 :param enabled: A boolean/integer representing whether the object is enabled. 106 (0 or 1) 107 :param data: A JSON object matching the schema for the specified type. 108 :param request_params: Additional request parameters. 109 (provides support for parameters that may be added in the future) 110 111 :return response json 112 """ 113 114 if enabled is not None: 115 enabled = int(bool(enabled)) 116 117 return super().update( 118 id=guid, 119 name=name, 120 type=type, 121 enabled=enabled, 122 data=data, 123 **request_params 124 )
A method to update an AlertChannels object.
Parameters
- guid: A string representing the object GUID.
- name: A string representing the object name.
- type: A string representing the object type.
- enabled: A boolean/integer representing whether the object is enabled. (0 or 1)
- data: A JSON object matching the schema for the specified type.
- request_params: Additional request parameters. (provides support for parameters that may be added in the future)
:return response json
def
delete(self, guid):
126 def delete(self, 127 guid): 128 """ 129 A method to delete an AlertChannels object. 130 131 :param guid: A string representing the object GUID. 132 133 :return response json 134 """ 135 136 return super().delete(id=guid)
A method to delete an AlertChannels object.
Parameters
- guid: A string representing the object GUID.
:return response json
def
test(self, guid):
138 def test(self, 139 guid): 140 """ 141 A method to test an AlertChannels object. 142 143 :param guid: A string representing the object GUID. 144 145 :return response json 146 """ 147 148 response = self._session.post(self.build_url(resource=guid, action="test")) 149 150 return response
A method to test an AlertChannels object.
Parameters
- guid: A string representing the object GUID.
:return response json