Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 38 additions & 6 deletions src/orb/resources/events/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,8 @@ def search(
self,
*,
event_ids: List[str],
timeframe_end: Union[str, datetime, None] | NotGiven = NOT_GIVEN,
timeframe_start: Union[str, datetime, None] | NotGiven = NOT_GIVEN,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
Expand Down Expand Up @@ -510,8 +512,15 @@ def search(

Args:
event_ids: This is an explicit array of IDs to filter by. Note that an event's ID is the
idempotency_key that was originally used for ingestion. Values in this array
will be treated case sensitively.
idempotency_key that was originally used for ingestion, and this only supports
events that have not been amended. Values in this array will be treated case
sensitively.

timeframe_end: The end of the timeframe, exclusive, in which to search events. If not
specified, the current time is used.

timeframe_start: The start of the timeframe, inclusive, in which to search events. If not
specified, the one week ago is used.

extra_headers: Send extra headers

Expand All @@ -525,7 +534,14 @@ def search(
"""
return self._post(
"/events/search",
body=maybe_transform({"event_ids": event_ids}, event_search_params.EventSearchParams),
body=maybe_transform(
{
"event_ids": event_ids,
"timeframe_end": timeframe_end,
"timeframe_start": timeframe_start,
},
event_search_params.EventSearchParams,
),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
Expand Down Expand Up @@ -984,6 +1000,8 @@ async def search(
self,
*,
event_ids: List[str],
timeframe_end: Union[str, datetime, None] | NotGiven = NOT_GIVEN,
timeframe_start: Union[str, datetime, None] | NotGiven = NOT_GIVEN,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
Expand Down Expand Up @@ -1013,8 +1031,15 @@ async def search(

Args:
event_ids: This is an explicit array of IDs to filter by. Note that an event's ID is the
idempotency_key that was originally used for ingestion. Values in this array
will be treated case sensitively.
idempotency_key that was originally used for ingestion, and this only supports
events that have not been amended. Values in this array will be treated case
sensitively.

timeframe_end: The end of the timeframe, exclusive, in which to search events. If not
specified, the current time is used.

timeframe_start: The start of the timeframe, inclusive, in which to search events. If not
specified, the one week ago is used.

extra_headers: Send extra headers

Expand All @@ -1028,7 +1053,14 @@ async def search(
"""
return await self._post(
"/events/search",
body=maybe_transform({"event_ids": event_ids}, event_search_params.EventSearchParams),
body=maybe_transform(
{
"event_ids": event_ids,
"timeframe_end": timeframe_end,
"timeframe_start": timeframe_start,
},
event_search_params.EventSearchParams,
),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
Expand Down
22 changes: 19 additions & 3 deletions src/orb/types/event_search_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@

from __future__ import annotations

from typing import List
from typing_extensions import Required, TypedDict
from typing import List, Union
from datetime import datetime
from typing_extensions import Required, Annotated, TypedDict

from .._utils import PropertyInfo

__all__ = ["EventSearchParams"]

Expand All @@ -13,5 +16,18 @@ class EventSearchParams(TypedDict, total=False):
"""This is an explicit array of IDs to filter by.

Note that an event's ID is the idempotency_key that was originally used for
ingestion. Values in this array will be treated case sensitively.
ingestion, and this only supports events that have not been amended. Values in
this array will be treated case sensitively.
"""

timeframe_end: Annotated[Union[str, datetime, None], PropertyInfo(format="iso8601")]
"""The end of the timeframe, exclusive, in which to search events.

If not specified, the current time is used.
"""

timeframe_start: Annotated[Union[str, datetime, None], PropertyInfo(format="iso8601")]
"""The start of the timeframe, inclusive, in which to search events.

If not specified, the one week ago is used.
"""
2 changes: 1 addition & 1 deletion src/orb/types/event_search_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class Data(BaseModel):
for safe request retries.
"""

customer_id: str
customer_id: Optional[str]
"""The Orb Customer identifier"""

event_name: str
Expand Down
26 changes: 22 additions & 4 deletions tests/api_resources/test_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,14 +167,23 @@ def test_raw_response_ingest(self, client: Orb) -> None:
@parametrize
def test_method_search(self, client: Orb) -> None:
event = client.events.search(
event_ids=["string", "string", "string"],
event_ids=["string"],
)
assert_matches_type(EventSearchResponse, event, path=["response"])

@parametrize
def test_method_search_with_all_params(self, client: Orb) -> None:
event = client.events.search(
event_ids=["string"],
timeframe_end=parse_datetime("2019-12-27T18:11:19.117Z"),
timeframe_start=parse_datetime("2019-12-27T18:11:19.117Z"),
)
assert_matches_type(EventSearchResponse, event, path=["response"])

@parametrize
def test_raw_response_search(self, client: Orb) -> None:
response = client.events.with_raw_response.search(
event_ids=["string", "string", "string"],
event_ids=["string"],
)
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
event = response.parse()
Expand Down Expand Up @@ -327,14 +336,23 @@ async def test_raw_response_ingest(self, client: AsyncOrb) -> None:
@parametrize
async def test_method_search(self, client: AsyncOrb) -> None:
event = await client.events.search(
event_ids=["string", "string", "string"],
event_ids=["string"],
)
assert_matches_type(EventSearchResponse, event, path=["response"])

@parametrize
async def test_method_search_with_all_params(self, client: AsyncOrb) -> None:
event = await client.events.search(
event_ids=["string"],
timeframe_end=parse_datetime("2019-12-27T18:11:19.117Z"),
timeframe_start=parse_datetime("2019-12-27T18:11:19.117Z"),
)
assert_matches_type(EventSearchResponse, event, path=["response"])

@parametrize
async def test_raw_response_search(self, client: AsyncOrb) -> None:
response = await client.events.with_raw_response.search(
event_ids=["string", "string", "string"],
event_ids=["string"],
)
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
event = response.parse()
Expand Down