diff --git a/CHANGELOG.md b/CHANGELOG.md index 9f16f3a..c177b94 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/src/_incydr_cli/cmds/agents.py b/src/_incydr_cli/cmds/agents.py index 4c6dc93..ed59541 100644 --- a/src/_incydr_cli/cmds/agents.py +++ b/src/_incydr_cli/cmds/agents.py @@ -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 @@ -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 diff --git a/src/_incydr_cli/cmds/models.py b/src/_incydr_cli/cmds/models.py index a5f9515..4a91e54 100644 --- a/src/_incydr_cli/cmds/models.py +++ b/src/_incydr_cli/cmds/models.py @@ -27,7 +27,7 @@ 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): @@ -35,7 +35,10 @@ class AgentJSON(Model): @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"] @@ -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" )