Skip to content

Commit 2911211

Browse files
Merge pull request #143 from code42/INTEG-2869
Prevent incorrect validation errors on server response
2 parents d0725eb + 8d4f0ba commit 2911211

File tree

9 files changed

+31
-18
lines changed

9 files changed

+31
-18
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@
99
how a consumer would use the library or CLI tool (e.g. adding unit tests, updating documentation, etc) are not captured
1010
here.
1111

12+
## Unreleased
13+
14+
### Fixed
15+
16+
- A bug where in some rare cases searching file events could cause the SDK to throw a validation error on the server's correct response.
17+
1218
## 2.2.2 - 2025-01-08
1319

1420
### Fixed

src/_incydr_sdk/agents/models.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from datetime import datetime
44
from typing import List
55
from typing import Optional
6+
from typing import Union
67

78
from pydantic import BaseModel
89
from pydantic import Field
@@ -63,7 +64,7 @@ class Agent(ResponseModel):
6364
machine_id: Optional[str] = Field(alias="machineId")
6465
serial_number: Optional[str] = Field(alias="serialNumber")
6566
active: Optional[bool]
66-
agent_type: Optional[AgentType] = Field(alias="agentType")
67+
agent_type: Optional[Union[AgentType, str]] = Field(alias="agentType")
6768
agent_health_issue_types: Optional[List[str]] = Field(alias="agentHealthIssueTypes")
6869
app_version: Optional[str] = Field(alias="appVersion")
6970
product_version: Optional[str] = Field(alias="productVersion")
@@ -98,10 +99,10 @@ class AgentUpdateRequest(BaseModel):
9899

99100
class QueryAgentsRequest(BaseModel):
100101
active: Optional[bool]
101-
agentType: Optional[AgentType]
102+
agentType: Optional[Union[AgentType, str]]
102103
agentHealthy: Optional[bool]
103104
anyOfAgentHealthIssueTypes: Optional[List[str]]
104-
srtKey: Optional[SortKeys]
105+
srtKey: Optional[Union[SortKeys, str]]
105106
srtDir: Optional[str]
106107
pageSize: Optional[int]
107108
page: Optional[int]

src/_incydr_sdk/audit_log/models.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from typing import Dict
66
from typing import List
77
from typing import Optional
8+
from typing import Union
89

910
from pydantic import BaseModel
1011
from pydantic import Field
@@ -63,7 +64,7 @@ class QueryExportRequest(Model):
6364
dateRange: Optional[DateRange]
6465
eventTypes: Optional[List[str]]
6566
resourceIds: Optional[List[str]]
66-
userTypes: Optional[List[UserTypes]]
67+
userTypes: Optional[List[Union[UserTypes, str]]]
6768

6869

6970
class QueryAuditLogRequest(Model):
@@ -75,4 +76,4 @@ class QueryAuditLogRequest(Model):
7576
page: int
7677
pageSize: int
7778
resourceIds: Optional[List[str]]
78-
userTypes: Optional[List[UserTypes]]
79+
userTypes: Optional[List[Union[UserTypes, str]]]

src/_incydr_sdk/cases/models.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from datetime import datetime
44
from typing import List
55
from typing import Optional
6+
from typing import Union
67

78
from pydantic import BaseModel
89
from pydantic import Extra
@@ -48,7 +49,7 @@ class Case(ResponseModel, validate_assignment=True):
4849
updated_at: Optional[datetime] = Field(allow_mutation=False, alias="updatedAt")
4950
subject: Optional[str]
5051
subject_username: Optional[str] = Field(alias="subjectUsername")
51-
status: CaseStatus
52+
status: Union[CaseStatus, str]
5253
assignee: Optional[str]
5354
assignee_username: Optional[str] = Field(
5455
allow_mutation=False, alias="assigneeUsername"
@@ -152,7 +153,7 @@ class FileEvent(Model):
152153
description="Lists indicators that the data may be exposed.",
153154
example=["OutsideTrustedDomains", "IsPublic"],
154155
)
155-
file_availability: Optional[FileAvailability] = Field(
156+
file_availability: Optional[Union[FileAvailability, str]] = Field(
156157
None,
157158
alias="fileAvailability",
158159
description="The download availability status of the file associated with the event.",
@@ -170,7 +171,7 @@ class FileEvent(Model):
170171
description="The file location on the user's device; a path forward or backslash should be included at the end of the filepath. Possibly null if the file event occurred on a cloud provider.",
171172
example="/Users/casey/Documents/",
172173
)
173-
risk_indicators: Optional[List[RiskIndicator]] = Field(
174+
risk_indicators: Optional[List[Union[RiskIndicator, str]]] = Field(
174175
None,
175176
alias="riskIndicators",
176177
description="List of risk indicators identified for this event. If more than one risk indicator applies to this event, the sum of all indicators determines the total risk score.",

src/_incydr_sdk/file_events/models/event.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from datetime import datetime
22
from typing import List
33
from typing import Optional
4+
from typing import Union
45

56
from pydantic import Field
67

@@ -226,7 +227,7 @@ class Report(Model):
226227
description="The display name of the report.",
227228
example="Top Accounts Report",
228229
)
229-
type: Optional[ReportType] = Field(
230+
type: Optional[Union[ReportType, str]] = Field(
230231
description='Indicates if the report is "REPORT_TYPE_AD_HOC" or "REPORT_TYPE_SAVED".',
231232
example="REPORT_TYPE_SAVED",
232233
)

src/_incydr_sdk/queries/file_events.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141

4242
class Filter(BaseModel):
4343
term: str
44-
operator: Operator
44+
operator: Union[Operator, str]
4545
value: Optional[Union[int, str]]
4646

4747
class Config:

src/_incydr_sdk/trusted_activities/models.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from datetime import datetime
44
from typing import List
55
from typing import Optional
6+
from typing import Union
67

78
from pydantic import Extra
89
from pydantic import Field
@@ -15,7 +16,7 @@
1516

1617

1718
class ProviderObject(Model):
18-
name: Optional[Name] = Field(
19+
name: Optional[Union[Name, str]] = Field(
1920
None,
2021
description="The name of a provider for a specified activity action.\n ### Supported providers for trusted "
2122
"activity type and actions\n\n - `DOMAIN`\n - `CLOUD_SHARE`\n - `BOX`\n - "
@@ -26,7 +27,7 @@ class ProviderObject(Model):
2627

2728

2829
class ActivityAction(Model):
29-
type: Optional[ActivityType] = Field(
30+
type: Optional[Union[ActivityType, str]] = Field(
3031
None,
3132
description="The type of an activity action.\n### Supported trusted activity types for each activity action "
3233
"type\n\n- `CLOUD_SHARE` \n - `DOMAIN`\n- `CLOUD_SYNC` \n - `DOMAIN`\n - `ACCOUNT_NAME`\n- "
@@ -40,7 +41,7 @@ class ActivityAction(Model):
4041

4142

4243
class ActivityActionGroup(Model):
43-
name: Optional[Name] = Field(
44+
name: Optional[Union[Name, str]] = Field(
4445
Name.DEFAULT,
4546
description="The name of the activity action group. Currently, only `DEFAULT` activity action group is "
4647
"supported.",
@@ -85,10 +86,10 @@ class TrustedActivity(ResponseModel, validate_assignment=True):
8586
description: Optional[str] = Field(
8687
None, description="A description of the trusted activity."
8788
)
88-
principal_type: Optional[PrincipalType] = Field(
89+
principal_type: Optional[Union[PrincipalType, str]] = Field(
8990
None, alias="principalType", allow_mutation=False
9091
)
91-
type: Optional[ActivityType] = Field(
92+
type: Optional[Union[ActivityType, str]] = Field(
9293
None, description="The type of the trusted activity.", alias="type"
9394
)
9495
update_time: Optional[datetime] = Field(
@@ -129,7 +130,7 @@ class UpdateTrustedActivity(Model, extra=Extra.ignore):
129130
description="Whether the trusted activity represents a high value source",
130131
alias="isHighValueSource",
131132
)
132-
type: Optional[ActivityType] = Field(
133+
type: Optional[Union[ActivityType, str]] = Field(
133134
None,
134135
description="The type of the trusted activity.\n\nNote: The `ACCOUNT_NAME` trusted activity type requires "
135136
"agent version 1.5.0 or later for Incydr \nProfessional, Enterprise, Gov F2, and Horizon product "

src/_incydr_sdk/watchlists/models/requests.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from typing import List
22
from typing import Optional
3+
from typing import Union
34

45
from pydantic import BaseModel
56
from pydantic import constr
@@ -50,7 +51,7 @@ class CreateWatchlistRequest(BaseModel):
5051
description="The required title for a custom watchlist.",
5152
example="My Custom List",
5253
)
53-
watchlistType: WatchlistType
54+
watchlistType: Union[WatchlistType, str]
5455

5556
class Config:
5657
use_enum_values = True

src/_incydr_sdk/watchlists/models/responses.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from datetime import datetime
44
from typing import List
55
from typing import Optional
6+
from typing import Union
67

78
from pydantic import Field
89

@@ -242,7 +243,7 @@ class Watchlist(ResponseModel):
242243
description: Optional[str] = Field(
243244
None, description="Description for a custom watchlist."
244245
)
245-
list_type: WatchlistType = Field(alias="listType")
246+
list_type: Union[WatchlistType, str] = Field(alias="listType")
246247
stats: Optional[WatchlistStats] = None
247248
tenant_id: Optional[str] = Field(
248249
None, description="A unique tenant ID.", alias="tenantId"

0 commit comments

Comments
 (0)