laceworksdk.api.v2.cloud_accounts
Lacework CloudAccounts API wrapper.
1# -*- coding: utf-8 -*- 2""" 3Lacework CloudAccounts API wrapper. 4""" 5 6from laceworksdk.api.crud_endpoint import CrudEndpoint 7 8 9class CloudAccountsAPI(CrudEndpoint): 10 11 def __init__(self, session): 12 """ 13 Initializes the CloudAccountsAPI object. 14 15 :param session: An instance of the HttpSession class 16 17 :return CloudAccountsAPI object. 18 """ 19 20 super().__init__(session, "CloudAccounts") 21 22 def create(self, 23 name, 24 type, 25 enabled, 26 data, 27 **request_params): 28 """ 29 A method to create a new CloudAccounts 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 CloudAccounts 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(id=guid, resource=type) 63 64 def get_by_guid(self, 65 guid): 66 """ 67 A method to get CloudAccounts objects by GUID. 68 69 :param guid: A string representing the object GUID. 70 71 :return response json 72 """ 73 74 return self.get(guid=guid) 75 76 def get_by_type(self, 77 type): 78 """ 79 A method to get CloudAccounts objects by type. 80 81 :param type: A string representing the object type. 82 83 :return response json 84 """ 85 86 return self.get(type=type) 87 88 def update(self, 89 guid, 90 name=None, 91 type=None, 92 enabled=None, 93 data=None, 94 **request_params): 95 """ 96 A method to update an CloudAccounts object. 97 98 :param guid: A string representing the object GUID. 99 :param name: A string representing the object name. 100 :param type: A string representing the object type. 101 :param enabled: A boolean/integer representing whether the object is enabled. 102 (0 or 1) 103 :param data: A JSON object matching the schema for the specified type. 104 :param request_params: Additional request parameters. 105 (provides support for parameters that may be added in the future) 106 107 :return response json 108 """ 109 110 if enabled is not None: 111 enabled = int(bool(enabled)) 112 113 return super().update( 114 id=guid, 115 name=name, 116 type=type, 117 enabled=enabled, 118 data=data, 119 **request_params 120 ) 121 122 def delete(self, 123 guid): 124 """ 125 A method to delete an CloudAccounts object. 126 127 :param guid: A string representing the object GUID. 128 129 :return response json 130 """ 131 132 return super().delete(id=guid)
10class CloudAccountsAPI(CrudEndpoint): 11 12 def __init__(self, session): 13 """ 14 Initializes the CloudAccountsAPI object. 15 16 :param session: An instance of the HttpSession class 17 18 :return CloudAccountsAPI object. 19 """ 20 21 super().__init__(session, "CloudAccounts") 22 23 def create(self, 24 name, 25 type, 26 enabled, 27 data, 28 **request_params): 29 """ 30 A method to create a new CloudAccounts 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 CloudAccounts 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(id=guid, resource=type) 64 65 def get_by_guid(self, 66 guid): 67 """ 68 A method to get CloudAccounts objects by GUID. 69 70 :param guid: A string representing the object GUID. 71 72 :return response json 73 """ 74 75 return self.get(guid=guid) 76 77 def get_by_type(self, 78 type): 79 """ 80 A method to get CloudAccounts objects by type. 81 82 :param type: A string representing the object type. 83 84 :return response json 85 """ 86 87 return self.get(type=type) 88 89 def update(self, 90 guid, 91 name=None, 92 type=None, 93 enabled=None, 94 data=None, 95 **request_params): 96 """ 97 A method to update an CloudAccounts object. 98 99 :param guid: A string representing the object GUID. 100 :param name: A string representing the object name. 101 :param type: A string representing the object type. 102 :param enabled: A boolean/integer representing whether the object is enabled. 103 (0 or 1) 104 :param data: A JSON object matching the schema for the specified type. 105 :param request_params: Additional request parameters. 106 (provides support for parameters that may be added in the future) 107 108 :return response json 109 """ 110 111 if enabled is not None: 112 enabled = int(bool(enabled)) 113 114 return super().update( 115 id=guid, 116 name=name, 117 type=type, 118 enabled=enabled, 119 data=data, 120 **request_params 121 ) 122 123 def delete(self, 124 guid): 125 """ 126 A method to delete an CloudAccounts object. 127 128 :param guid: A string representing the object GUID. 129 130 :return response json 131 """ 132 133 return super().delete(id=guid)
A class used to implement CRUD create/read/update/delete functionality for Lacework API Endpoints
CloudAccountsAPI(session)
12 def __init__(self, session): 13 """ 14 Initializes the CloudAccountsAPI object. 15 16 :param session: An instance of the HttpSession class 17 18 :return CloudAccountsAPI object. 19 """ 20 21 super().__init__(session, "CloudAccounts")
Initializes the CloudAccountsAPI object.
Parameters
- session: An instance of the HttpSession class
:return CloudAccountsAPI 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 CloudAccounts 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 CloudAccounts 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 CloudAccounts 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(id=guid, resource=type)
A method to get CloudAccounts 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):
65 def get_by_guid(self, 66 guid): 67 """ 68 A method to get CloudAccounts objects by GUID. 69 70 :param guid: A string representing the object GUID. 71 72 :return response json 73 """ 74 75 return self.get(guid=guid)
A method to get CloudAccounts objects by GUID.
Parameters
- guid: A string representing the object GUID.
:return response json
def
get_by_type(self, type):
77 def get_by_type(self, 78 type): 79 """ 80 A method to get CloudAccounts objects by type. 81 82 :param type: A string representing the object type. 83 84 :return response json 85 """ 86 87 return self.get(type=type)
A method to get CloudAccounts 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):
89 def update(self, 90 guid, 91 name=None, 92 type=None, 93 enabled=None, 94 data=None, 95 **request_params): 96 """ 97 A method to update an CloudAccounts object. 98 99 :param guid: A string representing the object GUID. 100 :param name: A string representing the object name. 101 :param type: A string representing the object type. 102 :param enabled: A boolean/integer representing whether the object is enabled. 103 (0 or 1) 104 :param data: A JSON object matching the schema for the specified type. 105 :param request_params: Additional request parameters. 106 (provides support for parameters that may be added in the future) 107 108 :return response json 109 """ 110 111 if enabled is not None: 112 enabled = int(bool(enabled)) 113 114 return super().update( 115 id=guid, 116 name=name, 117 type=type, 118 enabled=enabled, 119 data=data, 120 **request_params 121 )
A method to update an CloudAccounts 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):
123 def delete(self, 124 guid): 125 """ 126 A method to delete an CloudAccounts object. 127 128 :param guid: A string representing the object GUID. 129 130 :return response json 131 """ 132 133 return super().delete(id=guid)
A method to delete an CloudAccounts object.
Parameters
- guid: A string representing the object GUID.
:return response json