Skip to content

Commit ccdcfe1

Browse files
INTEG-3142 - add type
1 parent ebb42ce commit ccdcfe1

5 files changed

Lines changed: 19 additions & 0 deletions

File tree

src/_incydr_cli/cmds/sessions.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,11 @@ def sessions():
7272
help="Limit search to sessions beginning before this date and time. "
7373
"Accepts a date/time in yyyy-MM-dd (UTC) or yyyy-MM-dd HH:MM:SS (UTC+24-hr time) format.",
7474
)
75+
@click.option(
76+
"--type",
77+
default=None,
78+
help="Limit search to sessions of this type. Acceptable types are STANDARD or ACCOUNT_TAKE_OVER"
79+
)
7580
@click.option(
7681
"--no-alerts",
7782
is_flag=True,
@@ -123,6 +128,7 @@ def search(
123128
actor_id: Optional[str] = None,
124129
start: Optional[str] = None,
125130
end: Optional[str] = None,
131+
type: Optional[str] = None,
126132
no_alerts: bool = False,
127133
risk_indicators: Optional[str] = None,
128134
state: Optional[List[str]] = None,
@@ -162,6 +168,7 @@ def search(
162168
sessions_gen = client.sessions.v1.iter_all(
163169
actor_id=actor_id,
164170
start_time=start,
171+
type=type,
165172
end_time=end,
166173
has_alerts=not no_alerts,
167174
risk_indicators=risk_indicators.split(",") if risk_indicators else None,

src/_incydr_sdk/sessions/client.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ def get_page(
3737
actor_id: str = None,
3838
start_time: Union[str, datetime, int] = None,
3939
end_time: Union[str, datetime, int] = None,
40+
type: str = None,
4041
has_alerts: bool = True,
4142
sort_key: Optional[SortKeys] = None,
4243
risk_indicators: List[str] = None,
@@ -59,6 +60,7 @@ def get_page(
5960
* **actor_id**: `str | None` - Only include items generated by this actor.
6061
* **start_time**: `datetime | str | int | None` - Only include items beginning on or after this date and time. Can be a date-formatted string, a `datetime` instance, or a POSIX `int` timestamp.
6162
* **end_time**: `datetime | str | int | None` - Only include items beginning before this date and time. Can be a date-formatted string, a `datetime` instance, or a POSIX `int` timestamp.
63+
* **type**: `str` - Only include items matching this type. Examples include STANDARD, ACCOUNT_TAKE_OVER.
6264
* **has_alerts**: `bool` - Only include items that have a matching alert status. Defaults to `True`.
6365
* **sort_key**: [`SortKeys`][items-sort-keys] - `end_time` or `score`. Value on which the results will be sorted. Defaults to `end time`.
6466
* **risk_indicators**: `List[str] | None` - List of risk indicator IDs that must be present on the items before they are returned.
@@ -93,6 +95,7 @@ def get_page(
9395
actor_id=actor_id,
9496
on_or_after=start_time,
9597
before=end_time,
98+
type=type,
9699
has_alerts=str(has_alerts).lower() if has_alerts is not None else None,
97100
order_by=sort_key,
98101
risk_indicators=risk_indicators,
@@ -113,6 +116,7 @@ def iter_all(
113116
actor_id: str = None,
114117
start_time: Union[str, datetime, int] = None,
115118
end_time: Union[str, datetime, int] = None,
119+
type: str = None,
116120
has_alerts: bool = True,
117121
sort_key: Optional[SortKeys] = None,
118122
risk_indicators: List[str] = None,
@@ -136,6 +140,7 @@ def iter_all(
136140
actor_id=actor_id,
137141
start_time=start_time,
138142
end_time=end_time,
143+
type=type,
139144
has_alerts=has_alerts,
140145
sort_key=sort_key,
141146
risk_indicators=risk_indicators,
@@ -217,6 +222,7 @@ def update_state_by_criteria(
217222
actor_id: str = None,
218223
start_time: Union[str, datetime, int] = None,
219224
end_time: Union[str, datetime, int] = None,
225+
type: str = None,
220226
has_alerts: bool = True,
221227
risk_indicators: List[str] = None,
222228
states: List[SessionStates] = None,
@@ -236,6 +242,7 @@ def update_state_by_criteria(
236242
* **actor_id**: `str | None` - The ID of the actor to limit the search to.
237243
* **start_time**: `datetime | str | int | None` - Only include items beginning on or after this date and time. Can be a date-formatted string, a `datetime` instance, or a POSIX `int` timestamp.
238244
* **end_time**: `datetime | str | int | None` - Only include items beginning before this date and time. Can be a date-formatted string, a `datetime` instance, or a POSIX `int` timestamp.
245+
* **type**: `str` - Only include items matching this type. Examples include STANDARD, ACCOUNT_TAKE_OVER.
239246
* **has_alerts**: `bool` - Only include items that have a matching alert status. Defaults to `True`.
240247
* **sort_key**: [`SortKeys`][items-sort-keys] - `end_time` or `score`. Value on which the results will be sorted. Defaults to `end time`.
241248
* **risk_indicators**: `List[str] | None` - List of risk indicator IDs that must be present on the items before they are returned.
@@ -270,6 +277,7 @@ def update_state_by_criteria(
270277
actor_id=actor_id,
271278
on_or_after=start_time,
272279
before=end_time,
280+
type=type,
273281
has_alerts=str(has_alerts).lower() if has_alerts is not None else None,
274282
risk_indicators=risk_indicators,
275283
state=states,

src/_incydr_sdk/sessions/models/models.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ class SessionsCriteriaRequest(BaseModel):
7171
actor_id: Optional[str] = None
7272
on_or_after: Optional[int] = None
7373
before: Optional[int] = None
74+
type: Optional[int] = None
7475
has_alerts: Optional[str] = None
7576
risk_indicators: Optional[List[str]] = None
7677
state: Optional[List[SessionStates]] = None

src/_incydr_sdk/sessions/models/response.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ class Session(ResponseModel):
2020
**Fields**:
2121
2222
* **actor_id**: `str` The ID of the actor that generated the session.
23+
* **type**: `str` The type of the session.
2324
* **begin_time**: `datetime` The date and time when this session began.
2425
* **content_inspection_results**: `List[ContentInspectionResult]` The results of content inspection.
2526
* **context_summary**: `str` An English summary of the contextual aspects of this session is any were identified.
@@ -42,6 +43,7 @@ class Session(ResponseModel):
4243
"""
4344

4445
actor_id: Optional[str] = Field(None, alias="actorId")
46+
type: Optional[str] = Field(None)
4547
begin_time: Optional[int] = Field(None, alias="beginTime")
4648
content_inspection_results: Optional[ContentInspectionResult] = Field(
4749
None, alias="contentInspectionResults"

tests/test_sessions.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030

3131
TEST_SESSION = {
3232
"actorId": TEST_SESSION_ID,
33+
"type": "STANDARD",
3334
"beginTime": POSIX_TS,
3435
"contentInspectionResults": {"detectedOnAlerts": ["PII"]},
3536
"contextSummary": "string",

0 commit comments

Comments
 (0)