Skip to content

Commit e3c1d7b

Browse files
Merge pull request #149 from code42/INTEG-2906/csv-input
Integ 2906/csv input
2 parents 99eff63 + 5450fab commit e3c1d7b

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
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+
### Updated
15+
16+
- 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`.
17+
1218
## 2.3.0 - 2025-03-18
1319

1420
### Added

src/_incydr_cli/cmds/agents.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ def bulk_activate(file: Path, format_: str):
140140
Input files require a header (for CSV input) or JSON key for each object (for JSON-LINES input) to identify
141141
which agent ID to activate.
142142
143-
Header and JSON key values that are accepted are: agent_id, agentId, or guid
143+
Header and JSON key values that are accepted are: agentGuid, agent_id, agentId, or guid
144144
"""
145145
chunk_size = (
146146
environ.get("incydr_batch_size") or environ.get("INCYDR_BATCH_SIZE") or 50
@@ -190,7 +190,7 @@ def bulk_deactivate(file: Path, format_: str):
190190
Input files require a header (for CSV input) or JSON key for each object (for JSON-LINES input) to identify
191191
which agent ID to deactivate.
192192
193-
Header and JSON key values that are accepted are: agent_id, agentId, or guid
193+
Header and JSON key values that are accepted are: agentGuid, agent_id, agentId, or guid
194194
"""
195195
chunk_size = (
196196
environ.get("incydr_batch_size") or environ.get("INCYDR_BATCH_SIZE") or 50

src/_incydr_cli/cmds/models.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,18 @@ def user(self):
2727

2828

2929
class AgentCSV(CSVModel):
30-
agent_id: str = Field(csv_aliases=["agent_id", "agentId", "guid"])
30+
agent_id: str = Field(csv_aliases=["agentGuid", "agent_id", "agentId", "guid"])
3131

3232

3333
class AgentJSON(Model):
3434
agent_id: Optional[str]
3535

3636
@root_validator(pre=True)
3737
def _validate(cls, values): # noqa
38-
if "agent_id" in values:
38+
if "agentGuid" in values:
39+
values["agent_id"] = values["agentGuid"]
40+
return values
41+
elif "agent_id" in values:
3942
return values
4043
elif "agentId" in values:
4144
values["agent_id"] = values["agentId"]
@@ -45,5 +48,5 @@ def _validate(cls, values): # noqa
4548
return values
4649
else:
4750
raise ValueError(
48-
"A json key of 'agent_id', 'agentId', or 'guid' is required"
51+
"A json key of 'agentGuid', 'agent_id', 'agentId', or 'guid' is required"
4952
)

0 commit comments

Comments
 (0)