Skip to content

Commit

Permalink
eventsv2 api support (#78)
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Droessler authored Aug 10, 2022
1 parent a279172 commit 608d898
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 32 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ local/
# Virtual Environments
.venv/
venv/
env/

# Test artifacts
.cache/
Expand Down
2 changes: 1 addition & 1 deletion jupyter/laceworkjupyter/features/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,4 @@ def get_evidence_from_event_id(event_id, client=None, minutes=10, ctx=None):
'value': event_id
}],
}
return client.evidence.search(json=search_filter)
return client.events.search(json=search_filter)
6 changes: 2 additions & 4 deletions laceworksdk/api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
from .v1.compliance import ComplianceAPI
from .v1.custom_compliance_config import CustomComplianceConfigAPI
from .v1.download_file import DownloadFileAPI
from .v1.events import EventsAPI
from .v1.integrations import IntegrationsAPI
from .v1.recommendations import RecommendationsAPI
from .v1.run_reports import RunReportsAPI
Expand All @@ -36,7 +35,7 @@
from .v2.contract_info import ContractInfoAPI
from .v2.datasources import DatasourcesAPI
from .v2.entities import EntitiesAPI
from .v2.evidence import EvidenceAPI
from .v2.events import EventsAPIv2
from .v2.inventory import InventoryAPI
from .v2.organization_info import OrganizationInfoAPI
from .v2.policies import PoliciesAPI
Expand Down Expand Up @@ -153,8 +152,7 @@ def __init__(self,
self.contract_info = ContractInfoAPI(self._session)
self.datasources = DatasourcesAPI(self._session)
self.entities = EntitiesAPI(self._session)
self.events = EventsAPI(self._session)
self.evidence = EvidenceAPI(self._session)
self.events = EventsAPIv2(self._session)
self.files = DownloadFileAPI(self._session)
self.inventory = InventoryAPI(self._session)
self.integrations = IntegrationsAPI(self._session)
Expand Down
2 changes: 1 addition & 1 deletion laceworksdk/api/v1/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
logger = logging.getLogger(__name__)


class EventsAPI:
class EventsAPIv1:
"""
Lacework Events API.
"""
Expand Down
24 changes: 24 additions & 0 deletions laceworksdk/api/v2/events.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# -*- coding: utf-8 -*-
"""
Lacework Events API wrapper.
"""

from laceworksdk.api.search_endpoint import SearchEndpoint
from laceworksdk.api.v1.events import EventsAPIv1

class EventsAPIv2(EventsAPIv1, SearchEndpoint):

def __init__(self, session):
"""
Initializes the EventsAPI object.
:param session: An instance of the HttpSession class
:return EventsAPI object.
"""

# The need to pass "Events" into the v1 init() is tied
# to the super() call within the v1 init()
super(EventsAPIv1, self).__init__(session, "Events")

super(SearchEndpoint, self).__init__(session, "Events")
20 changes: 0 additions & 20 deletions laceworksdk/api/v2/evidence.py

This file was deleted.

2 changes: 1 addition & 1 deletion tests/api/v1/test_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from datetime import datetime, timedelta, timezone

from laceworksdk.api.v1.events import EventsAPI
from laceworksdk.api.v2.events import EventsAPIv2 as EventsAPI


# Build start/end times
Expand Down
8 changes: 3 additions & 5 deletions tests/api/v2/test_evidence.py → tests/api/v2/test_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,18 @@

import pytest

from laceworksdk.api.v2.evidence import (
EvidenceAPI
)
from laceworksdk.api.v2.events import EventsAPIv2 as EventsAPI
from tests.api.test_search_endpoint import SearchEndpoint

# Tests


@pytest.fixture(scope="module")
def api_object(api):
return api.evidence
return api.events


@pytest.mark.flaky_test
class TestEvidenceEndpoint(SearchEndpoint):

OBJECT_TYPE = EvidenceAPI
OBJECT_TYPE = EventsAPI

0 comments on commit 608d898

Please sign in to comment.