-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding AgentInfo and Inventory endpoints (#70)
* added AgentInfo, Inventory search endpoints * tweaked doc * tests: adding tests for AgentInfo and Inventory * Update laceworksdk/api/__init__.py Co-authored-by: Alan Nix <65611624+alannix-lw@users.noreply.github.com> Co-authored-by: Alan Nix <alan.nix@lacework.net> Co-authored-by: Alan Nix <65611624+alannix-lw@users.noreply.github.com>
- Loading branch information
1 parent
8ef599c
commit 2f4f189
Showing
5 changed files
with
105 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# -*- coding: utf-8 -*- | ||
""" | ||
Lacework AgentInfo API wrapper. | ||
""" | ||
|
||
from laceworksdk.api.search_endpoint import SearchEndpoint | ||
|
||
|
||
class AgentInfoAPI(SearchEndpoint): | ||
|
||
def __init__(self, session): | ||
""" | ||
Initializes the AgentInfo API object. | ||
:param session: An instance of the HttpSession class | ||
:return AgentInfoAPI object. | ||
""" | ||
|
||
super().__init__(session, "AgentInfo") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# -*- coding: utf-8 -*- | ||
""" | ||
Lacework Inventory API wrapper. | ||
""" | ||
|
||
from laceworksdk.api.search_endpoint import SearchEndpoint | ||
|
||
|
||
class InventoryAPI(SearchEndpoint): | ||
|
||
def __init__(self, session): | ||
""" | ||
Initializes the Inventory API object. | ||
:param session: An instance of the HttpSession class | ||
:return InventoryAPI object. | ||
""" | ||
|
||
super().__init__(session, "Inventory") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# -*- coding: utf-8 -*- | ||
""" | ||
Test suite for the community-developed Python SDK for interacting with Lacework APIs. | ||
""" | ||
|
||
import pytest | ||
|
||
from laceworksdk.api.v2.agent_info import ( | ||
AgentInfoAPI | ||
) | ||
from tests.api.test_search_endpoint import SearchEndpoint | ||
|
||
# Tests | ||
|
||
|
||
@pytest.fixture(scope="module") | ||
def api_object(api): | ||
return api.agent_info | ||
|
||
|
||
class TestConfigsEndpoint(SearchEndpoint): | ||
|
||
OBJECT_TYPE = AgentInfoAPI |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# -*- coding: utf-8 -*- | ||
""" | ||
Test suite for the community-developed Python SDK for interacting with Lacework APIs. | ||
""" | ||
|
||
import pytest | ||
|
||
from laceworksdk.api.v2.inventory import ( | ||
InventoryAPI | ||
) | ||
from tests.api.test_search_endpoint import SearchEndpoint | ||
|
||
# Tests | ||
|
||
|
||
@pytest.fixture(scope="module") | ||
def api_object(api): | ||
return api.inventory | ||
|
||
|
||
class TestConfigsEndpoint(SearchEndpoint): | ||
|
||
OBJECT_TYPE = InventoryAPI | ||
|
||
@pytest.mark.parametrize("dataset", ["AwsCompliance", "GcpCompliance"]) | ||
def test_api_search_by_date(self, api_object, dataset): | ||
start_time, end_time = self._get_start_end_times(self.DAY_DELTA) | ||
|
||
for attribute in self.OBJECT_MAP.keys(): | ||
response = getattr(api_object, attribute).search(json={ | ||
"timeFilters": { | ||
"startTime": start_time, | ||
"endTime": end_time | ||
}, | ||
"dataset": dataset | ||
}) | ||
|
||
self._assert_pages(response, self.MAX_PAGES) |