Skip to content

Commit c89b37e

Browse files
feat(api): add time range filters to event list method
1 parent 8c34748 commit c89b37e

4 files changed

Lines changed: 42 additions & 4 deletions

File tree

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 175
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/gitpod%2Fgitpod-1923b5d3865532d64d80c22746aa63991bbf227cf1cbefc8cdb14a374c4c5b89.yml
3-
openapi_spec_hash: 304200ebfa8622f5f6846895528f06e3
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/gitpod%2Fgitpod-18081d3ce0bf5a7c07f195ffcf7934a53c1822f2439270d4e03b89a3993aa3e1.yml
3+
openapi_spec_hash: 38600260362ddb6b1419e21838e97783
44
config_hash: 469d30a2d44895c8c53a5aac370a56f1

src/gitpod/resources/events.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,16 @@ def list(
8686
pageSize: 20
8787
```
8888
89+
- Filter by time range:
90+
91+
```yaml
92+
filter:
93+
from: "2024-01-01T00:00:00Z"
94+
to: "2024-02-01T00:00:00Z"
95+
pagination:
96+
pageSize: 20
97+
```
98+
8999
Args:
90100
pagination: pagination contains the pagination options for listing environments
91101
@@ -251,6 +261,16 @@ def list(
251261
pageSize: 20
252262
```
253263
264+
- Filter by time range:
265+
266+
```yaml
267+
filter:
268+
from: "2024-01-01T00:00:00Z"
269+
to: "2024-02-01T00:00:00Z"
270+
pagination:
271+
pageSize: 20
272+
```
273+
254274
Args:
255275
pagination: pagination contains the pagination options for listing environments
256276

src/gitpod/types/event_list_params.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
from __future__ import annotations
44

5-
from typing import List
5+
from typing import List, Union
6+
from datetime import datetime
67
from typing_extensions import Annotated, TypedDict
78

89
from .._types import SequenceNotStr
@@ -24,7 +25,16 @@ class EventListParams(TypedDict, total=False):
2425
"""pagination contains the pagination options for listing environments"""
2526

2627

27-
class Filter(TypedDict, total=False):
28+
_FilterReservedKeywords = TypedDict(
29+
"_FilterReservedKeywords",
30+
{
31+
"from": Union[str, datetime, None],
32+
},
33+
total=False,
34+
)
35+
36+
37+
class Filter(_FilterReservedKeywords, total=False):
2838
actor_ids: Annotated[SequenceNotStr[str], PropertyInfo(alias="actorIds")]
2939

3040
actor_principals: Annotated[List[Principal], PropertyInfo(alias="actorPrincipals")]
@@ -33,6 +43,9 @@ class Filter(TypedDict, total=False):
3343

3444
subject_types: Annotated[List[ResourceType], PropertyInfo(alias="subjectTypes")]
3545

46+
to: Annotated[Union[str, datetime, None], PropertyInfo(format="iso8601")]
47+
"""to filters audit logs created before this timestamp (exclusive)."""
48+
3649

3750
class Pagination(TypedDict, total=False):
3851
"""pagination contains the pagination options for listing environments"""

tests/api_resources/test_events.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from gitpod import Gitpod, AsyncGitpod
1111
from tests.utils import assert_matches_type
1212
from gitpod.types import EventListResponse, EventWatchResponse
13+
from gitpod._utils import parse_datetime
1314
from gitpod.pagination import SyncEntriesPage, AsyncEntriesPage
1415
from gitpod._decoders.jsonl import JSONLDecoder, AsyncJSONLDecoder
1516

@@ -34,8 +35,10 @@ def test_method_list_with_all_params(self, client: Gitpod) -> None:
3435
filter={
3536
"actor_ids": ["d2c94c27-3b76-4a42-b88c-95a85e392c68"],
3637
"actor_principals": ["PRINCIPAL_USER"],
38+
"from": parse_datetime("2019-12-27T18:11:19.117Z"),
3739
"subject_ids": ["182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"],
3840
"subject_types": ["RESOURCE_TYPE_UNSPECIFIED"],
41+
"to": parse_datetime("2019-12-27T18:11:19.117Z"),
3942
},
4043
pagination={
4144
"token": "token",
@@ -123,8 +126,10 @@ async def test_method_list_with_all_params(self, async_client: AsyncGitpod) -> N
123126
filter={
124127
"actor_ids": ["d2c94c27-3b76-4a42-b88c-95a85e392c68"],
125128
"actor_principals": ["PRINCIPAL_USER"],
129+
"from": parse_datetime("2019-12-27T18:11:19.117Z"),
126130
"subject_ids": ["182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"],
127131
"subject_types": ["RESOURCE_TYPE_UNSPECIFIED"],
132+
"to": parse_datetime("2019-12-27T18:11:19.117Z"),
128133
},
129134
pagination={
130135
"token": "token",

0 commit comments

Comments
 (0)