laceworksdk.api.v1.recommendations

Lacework Recommendations API wrapper.

 1"""
 2Lacework Recommendations API wrapper.
 3"""
 4
 5import logging
 6
 7logger = logging.getLogger(__name__)
 8
 9
10class RecommendationsAPI:
11    """
12    Lacework Recommendations API.
13    """
14
15    def __init__(self, session):
16        """
17        Initializes the RecommendationsAPI object.
18
19        :param session: An instance of the HttpSession class
20
21        :return RecommendationsAPI object.
22        """
23
24        super().__init__()
25
26        self._session = session
27
28    def get(self,
29            type):
30        """
31        A method to get all compliance recommendations for the specified Cloud Service Provider.
32
33        :param type: A string representing the type of CSP recommendations to retreive.
34            ('aws', 'azure', or 'gcp')
35
36        :return response json
37        """
38
39        logger.info(f"Getting {type} recommendations from Lacework...")
40
41        # Build the Recommendations request URI
42        api_uri = f"/api/v1/external/recommendations/{type}"
43
44        response = self._session.get(api_uri)
45
46        return response.json()
47
48    def update(self,
49               type,
50               data):
51        """
52        A method to update compliance recommendations for the specified Cloud Service Provider.
53
54        :param type: A string representing the type of CSP recommendations to update.
55            ('aws', 'azure', or 'gcp')
56        :param data: A JSON object representing which checks to enable/disable.
57
58        :return response json
59        """
60
61        logger.info(f"Updating {type} recommendations in Lacework...")
62
63        # Build the Recommendations request URI
64        api_uri = f"/api/v1/external/recommendations/{type}"
65
66        response = self._session.patch(api_uri, data=data)
67
68        return response.json()
class RecommendationsAPI:
11class RecommendationsAPI:
12    """
13    Lacework Recommendations API.
14    """
15
16    def __init__(self, session):
17        """
18        Initializes the RecommendationsAPI object.
19
20        :param session: An instance of the HttpSession class
21
22        :return RecommendationsAPI object.
23        """
24
25        super().__init__()
26
27        self._session = session
28
29    def get(self,
30            type):
31        """
32        A method to get all compliance recommendations for the specified Cloud Service Provider.
33
34        :param type: A string representing the type of CSP recommendations to retreive.
35            ('aws', 'azure', or 'gcp')
36
37        :return response json
38        """
39
40        logger.info(f"Getting {type} recommendations from Lacework...")
41
42        # Build the Recommendations request URI
43        api_uri = f"/api/v1/external/recommendations/{type}"
44
45        response = self._session.get(api_uri)
46
47        return response.json()
48
49    def update(self,
50               type,
51               data):
52        """
53        A method to update compliance recommendations for the specified Cloud Service Provider.
54
55        :param type: A string representing the type of CSP recommendations to update.
56            ('aws', 'azure', or 'gcp')
57        :param data: A JSON object representing which checks to enable/disable.
58
59        :return response json
60        """
61
62        logger.info(f"Updating {type} recommendations in Lacework...")
63
64        # Build the Recommendations request URI
65        api_uri = f"/api/v1/external/recommendations/{type}"
66
67        response = self._session.patch(api_uri, data=data)
68
69        return response.json()

Lacework Recommendations API.

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

Initializes the RecommendationsAPI object.

Parameters
  • session: An instance of the HttpSession class

:return RecommendationsAPI object.

def get(self, type):
29    def get(self,
30            type):
31        """
32        A method to get all compliance recommendations for the specified Cloud Service Provider.
33
34        :param type: A string representing the type of CSP recommendations to retreive.
35            ('aws', 'azure', or 'gcp')
36
37        :return response json
38        """
39
40        logger.info(f"Getting {type} recommendations from Lacework...")
41
42        # Build the Recommendations request URI
43        api_uri = f"/api/v1/external/recommendations/{type}"
44
45        response = self._session.get(api_uri)
46
47        return response.json()

A method to get all compliance recommendations for the specified Cloud Service Provider.

Parameters
  • type: A string representing the type of CSP recommendations to retreive. ('aws', 'azure', or 'gcp')

:return response json

def update(self, type, data):
49    def update(self,
50               type,
51               data):
52        """
53        A method to update compliance recommendations for the specified Cloud Service Provider.
54
55        :param type: A string representing the type of CSP recommendations to update.
56            ('aws', 'azure', or 'gcp')
57        :param data: A JSON object representing which checks to enable/disable.
58
59        :return response json
60        """
61
62        logger.info(f"Updating {type} recommendations in Lacework...")
63
64        # Build the Recommendations request URI
65        api_uri = f"/api/v1/external/recommendations/{type}"
66
67        response = self._session.patch(api_uri, data=data)
68
69        return response.json()

A method to update compliance recommendations for the specified Cloud Service Provider.

Parameters
  • type: A string representing the type of CSP recommendations to update. ('aws', 'azure', or 'gcp')
  • data: A JSON object representing which checks to enable/disable.

:return response json