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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@
how a consumer would use the library or CLI tool (e.g. adding unit tests, updating documentation, etc) are not captured
here.

## Unreleased

### Updated

- CSV and JSON input for the CLI's bulk agent commands will now look for `agentGuid` as a column header, in addition to `agent_id`, `agentId`, and `guid`.

## 2.3.0 - 2025-03-18

### Added
Expand Down
4 changes: 2 additions & 2 deletions src/_incydr_cli/cmds/agents.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def bulk_activate(file: Path, format_: str):
Input files require a header (for CSV input) or JSON key for each object (for JSON-LINES input) to identify
which agent ID to activate.

Header and JSON key values that are accepted are: agent_id, agentId, or guid
Header and JSON key values that are accepted are: agentGuid, agent_id, agentId, or guid
"""
chunk_size = (
environ.get("incydr_batch_size") or environ.get("INCYDR_BATCH_SIZE") or 50
Expand Down Expand Up @@ -190,7 +190,7 @@ def bulk_deactivate(file: Path, format_: str):
Input files require a header (for CSV input) or JSON key for each object (for JSON-LINES input) to identify
which agent ID to deactivate.

Header and JSON key values that are accepted are: agent_id, agentId, or guid
Header and JSON key values that are accepted are: agentGuid, agent_id, agentId, or guid
"""
chunk_size = (
environ.get("incydr_batch_size") or environ.get("INCYDR_BATCH_SIZE") or 50
Expand Down
9 changes: 6 additions & 3 deletions src/_incydr_cli/cmds/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,18 @@ def user(self):


class AgentCSV(CSVModel):
agent_id: str = Field(csv_aliases=["agent_id", "agentId", "guid"])
agent_id: str = Field(csv_aliases=["agentGuid", "agent_id", "agentId", "guid"])


class AgentJSON(Model):
agent_id: Optional[str]

@root_validator(pre=True)
def _validate(cls, values): # noqa
if "agent_id" in values:
if "agentGuid" in values:
values["agent_id"] = values["agentGuid"]
return values
elif "agent_id" in values:
return values
elif "agentId" in values:
values["agent_id"] = values["agentId"]
Expand All @@ -45,5 +48,5 @@ def _validate(cls, values): # noqa
return values
else:
raise ValueError(
"A json key of 'agent_id', 'agentId', or 'guid' is required"
"A json key of 'agentGuid', 'agent_id', 'agentId', or 'guid' is required"
)