laceworksdk.api.v1.run_reports

Lacework Run Reports API wrapper.

 1"""
 2Lacework Run Reports API wrapper.
 3"""
 4
 5import logging
 6
 7logger = logging.getLogger(__name__)
 8
 9
10class RunReportsAPI:
11    """
12    Lacework RunReports API.
13    """
14
15    def __init__(self, session):
16        """
17        Initializes the RunReportsAPI object.
18
19        :param session: An instance of the HttpSession class
20
21        :return RunReportsAPI object.
22        """
23
24        super().__init__()
25
26        self._session = session
27
28    def run_report(self,
29                   type,
30                   account_id):
31        """
32        A method to initiate a compliance assessment.
33
34        :param type: A string representing the type of compliance assessment to initiate.
35        :param account_id: A string representing the account identifier for which to initiate a compliance assessment.
36
37        :return response json
38        """
39
40        logger.info(f"Initiating '{type}' compliance assessment in Lacework...")
41
42        # Build the Run Report request URI
43        api_uri = f"/api/v1/external/runReport/{type}/{account_id}"
44
45        response = self._session.post(api_uri)
46
47        return response.json()
48
49    def aws(self,
50            aws_account_id):
51        """
52        A method to initiate a compliance assessment for an AWS account.
53
54        :param aws_account_id: A string representing which AWS account to assess.
55
56        :return response json
57        """
58
59        return self.run_report("aws", aws_account_id)
60
61    def azure(self,
62              azure_tenant_id):
63        """
64        A method to initiate a compliance assessment for an Azure tenant.
65
66        :param azure_tenant_id: A string representing which Azure tenant to assess.
67
68        :return response json
69        """
70
71        return self.run_report("azure", azure_tenant_id)
72
73    def gcp(self,
74            gcp_project_id):
75        """
76        A method to initiate a compliance assessment for a GCP project.
77
78        :param gcp_project_id: A string representing which GCP project to assess.
79
80        :return response json
81        """
82
83        return self.run_report("gcp", gcp_project_id)
84
85    def integration(self,
86                    integration_guid):
87        """
88        A method to run a compliance report based on a Lacework integration GUID.
89
90        :param integration_guid: A string representing the Lacework integration ID to query.
91
92        :return response json
93        """
94
95        return self.run_report("integration", integration_guid)
class RunReportsAPI:
11class RunReportsAPI:
12    """
13    Lacework RunReports API.
14    """
15
16    def __init__(self, session):
17        """
18        Initializes the RunReportsAPI object.
19
20        :param session: An instance of the HttpSession class
21
22        :return RunReportsAPI object.
23        """
24
25        super().__init__()
26
27        self._session = session
28
29    def run_report(self,
30                   type,
31                   account_id):
32        """
33        A method to initiate a compliance assessment.
34
35        :param type: A string representing the type of compliance assessment to initiate.
36        :param account_id: A string representing the account identifier for which to initiate a compliance assessment.
37
38        :return response json
39        """
40
41        logger.info(f"Initiating '{type}' compliance assessment in Lacework...")
42
43        # Build the Run Report request URI
44        api_uri = f"/api/v1/external/runReport/{type}/{account_id}"
45
46        response = self._session.post(api_uri)
47
48        return response.json()
49
50    def aws(self,
51            aws_account_id):
52        """
53        A method to initiate a compliance assessment for an AWS account.
54
55        :param aws_account_id: A string representing which AWS account to assess.
56
57        :return response json
58        """
59
60        return self.run_report("aws", aws_account_id)
61
62    def azure(self,
63              azure_tenant_id):
64        """
65        A method to initiate a compliance assessment for an Azure tenant.
66
67        :param azure_tenant_id: A string representing which Azure tenant to assess.
68
69        :return response json
70        """
71
72        return self.run_report("azure", azure_tenant_id)
73
74    def gcp(self,
75            gcp_project_id):
76        """
77        A method to initiate a compliance assessment for a GCP project.
78
79        :param gcp_project_id: A string representing which GCP project to assess.
80
81        :return response json
82        """
83
84        return self.run_report("gcp", gcp_project_id)
85
86    def integration(self,
87                    integration_guid):
88        """
89        A method to run a compliance report based on a Lacework integration GUID.
90
91        :param integration_guid: A string representing the Lacework integration ID to query.
92
93        :return response json
94        """
95
96        return self.run_report("integration", integration_guid)

Lacework RunReports API.

RunReportsAPI(session)
16    def __init__(self, session):
17        """
18        Initializes the RunReportsAPI object.
19
20        :param session: An instance of the HttpSession class
21
22        :return RunReportsAPI object.
23        """
24
25        super().__init__()
26
27        self._session = session

Initializes the RunReportsAPI object.

Parameters
  • session: An instance of the HttpSession class

:return RunReportsAPI object.

def run_report(self, type, account_id):
29    def run_report(self,
30                   type,
31                   account_id):
32        """
33        A method to initiate a compliance assessment.
34
35        :param type: A string representing the type of compliance assessment to initiate.
36        :param account_id: A string representing the account identifier for which to initiate a compliance assessment.
37
38        :return response json
39        """
40
41        logger.info(f"Initiating '{type}' compliance assessment in Lacework...")
42
43        # Build the Run Report request URI
44        api_uri = f"/api/v1/external/runReport/{type}/{account_id}"
45
46        response = self._session.post(api_uri)
47
48        return response.json()

A method to initiate a compliance assessment.

Parameters
  • type: A string representing the type of compliance assessment to initiate.
  • account_id: A string representing the account identifier for which to initiate a compliance assessment.

:return response json

def aws(self, aws_account_id):
50    def aws(self,
51            aws_account_id):
52        """
53        A method to initiate a compliance assessment for an AWS account.
54
55        :param aws_account_id: A string representing which AWS account to assess.
56
57        :return response json
58        """
59
60        return self.run_report("aws", aws_account_id)

A method to initiate a compliance assessment for an AWS account.

Parameters
  • aws_account_id: A string representing which AWS account to assess.

:return response json

def azure(self, azure_tenant_id):
62    def azure(self,
63              azure_tenant_id):
64        """
65        A method to initiate a compliance assessment for an Azure tenant.
66
67        :param azure_tenant_id: A string representing which Azure tenant to assess.
68
69        :return response json
70        """
71
72        return self.run_report("azure", azure_tenant_id)

A method to initiate a compliance assessment for an Azure tenant.

Parameters
  • azure_tenant_id: A string representing which Azure tenant to assess.

:return response json

def gcp(self, gcp_project_id):
74    def gcp(self,
75            gcp_project_id):
76        """
77        A method to initiate a compliance assessment for a GCP project.
78
79        :param gcp_project_id: A string representing which GCP project to assess.
80
81        :return response json
82        """
83
84        return self.run_report("gcp", gcp_project_id)

A method to initiate a compliance assessment for a GCP project.

Parameters
  • gcp_project_id: A string representing which GCP project to assess.

:return response json

def integration(self, integration_guid):
86    def integration(self,
87                    integration_guid):
88        """
89        A method to run a compliance report based on a Lacework integration GUID.
90
91        :param integration_guid: A string representing the Lacework integration ID to query.
92
93        :return response json
94        """
95
96        return self.run_report("integration", integration_guid)

A method to run a compliance report based on a Lacework integration GUID.

Parameters
  • integration_guid: A string representing the Lacework integration ID to query.

:return response json