@@ -30,15 +30,7 @@ samples try to use the file `.chronicle_credentials.json` in the user's home
3030directory. If this file is not found, you need to specify it explicitly by
3131adding the following argument to the sample's command-line:
3232
33- ``` shell 
34- -c < file_path> 
35- ``` 
36- 
37- or
38- 
39- ``` shell 
40- --credentials_file < file_path> 
41- ``` 
33+ ` shell -c <file_path> `  or ` shell --credentials_file <file_path> ` 
4234
4335## Usage  
4436
@@ -60,8 +52,166 @@ python3 -m lists.<sample_name> -h
6052
6153### Lists API v1alpha  
6254
63- ``` 
55+ ``` shell 
6456python -m lists.v1alpha.create_list -h
6557python -m lists.v1alpha.get_list -h
6658python -m lists.v1alpha.patch_list -h
6759``` 
60+ 
61+ ## Installing the Chronicle REST API CLI  
62+ 
63+ Install the CLI from source
64+ ``` 
65+ python setup.py install 
66+ ``` 
67+ 
68+ Alternatively, install the CLI from source using make
69+ ``` 
70+ make install 
71+ ``` 
72+ 
73+ Build the wheel file
74+ ``` 
75+ make dist 
76+ ``` 
77+ 
78+ ## Using the Chronicle REST API CLI  
79+ 
80+ The CLI provides a unified command-line interface for Chronicle APIs.
81+ The CLI follows this pattern:
82+ ``` 
83+ chronicle [common options] COMMAND_GROUP COMMAND [command options] 
84+ ``` 
85+ 
86+ ### Common Options  
87+ 
88+ Common options can be provided either via command-line arguments or environment
89+ variables:
90+ 
91+ |  CLI Option         |  Environment Variable        |  Description                   | 
92+ | --------------------| ----------------------------| --------------------------------| 
93+ |  --credentials-file |  CHRONICLE_CREDENTIALS_FILE |  Path to service account file   | 
94+ |  --project-id       |  CHRONICLE_PROJECT_ID       |  GCP project id or number       | 
95+ |  --project-instance |  CHRONICLE_INSTANCE         |  Chronicle instance ID (uuid)   | 
96+ |  --region           |  CHRONICLE_REGION           |  Region where project is located| 
97+ 
98+ You can set these options in a ` .env `  file in your project root:
99+ 
100+ ``` bash 
101+ #  .env file
102+ CHRONICLE_CREDENTIALS_FILE=path/to/credentials.json
103+ CHRONICLE_PROJECT_ID=your-project-id
104+ CHRONICLE_INSTANCE=your-instance-id
105+ CHRONICLE_REGION=your-region
106+ ``` 
107+ 
108+ The CLI will use values from the ` .env `  file or a file provided with the
109+ ` --env-file `  parameter. Command-line options take precedence over environment
110+ variables.
111+ 
112+ ### Command Groups  
113+ 
114+ #### Detection API  
115+ ``` bash 
116+ chronicle detect < command-group>  < command>  [options]
117+ ``` 
118+ 
119+ Available command groups:
120+ 
121+ -  ` alerts ` 
122+   -  ` get <alert-id> ` : Get alert by ID
123+   -  ` update <alert-id> ` : Update an alert
124+   -  ` bulk-update ` : Bulk update alerts matching a filter
125+ 
126+ -  ` detections ` 
127+   -  ` get <detection-id> ` : Get detection by ID
128+   -  ` list [--filter <filter>] ` : List detections
129+ 
130+ -  ` rules ` 
131+   -  ` create ` : Create a new rule
132+   -  ` get <rule-id> ` : Get rule by ID
133+   -  ` delete <rule-id> ` : Delete a rule
134+   -  ` enable <rule-id> ` : Enable a rule
135+   -  ` list [--filter <filter>] ` : List rules
136+ 
137+ -  ` retrohunts ` 
138+   -  ` create ` : Create a new retrohunt
139+   -  ` get <retrohunt-id> ` : Get retrohunt by ID
140+ 
141+ -  ` errors ` 
142+   -  ` list [--filter <filter>] ` : List errors
143+ 
144+ -  ` rulesets ` 
145+   -  ` batch-update ` : Batch update rule set deployments
146+ 
147+ #### Ingestion API  
148+ ``` bash 
149+ chronicle ingestion < command>  [options]
150+ ``` 
151+ 
152+ Available commands:
153+ 
154+ -  ` import-events ` : Import events into Chronicle
155+ -  ` get-event <event-id> ` : Get event details
156+ -  ` batch-get-events ` : Batch retrieve events
157+ 
158+ #### Search API  
159+ ``` bash 
160+ chronicle search < command>  [options]
161+ ``` 
162+ 
163+ Available commands:
164+ 
165+ -  ` find-asset-events [--filter <filter>] ` : Find events for an asset
166+ -  ` find-raw-logs [--filter <filter>] ` : Search raw logs
167+ -  ` find-udm-events [--filter <filter>] ` : Find UDM events
168+ 
169+ #### Lists API  
170+ ``` bash 
171+ chronicle lists < command>  [options]
172+ ``` 
173+ 
174+ Available commands:
175+ 
176+ -  ` create <name> [--description <desc>] --lines <json-array> ` : Create a new list
177+ -  ` get <list-id> ` : Get list by ID
178+ -  `patch <list-id > [ --description <desc >] 
179+   [ --lines-to-add <json-array >]  \ 
180+   [ --lines-to-remove <json-array >] `: Update an existing list
181+ 
182+ ### Examples  
183+ 
184+ Using environment variables (after setting up .env):
185+ ``` bash 
186+ #  Get an alert
187+ chronicle detect alerts get --alert-id ABC123 --env-file=.env
188+ 
189+ #  Create a list
190+ chronicle lists create --name " blocklist"   --description " Blocked IPs"   \
191+  --lines ' ["1.1.1.1", "2.2.2.2"]'   \
192+  --env-file=.env
193+ 
194+ #  Search for events
195+ chronicle search find-raw-logs --filter " timestamp.seconds > 1600000000"   \
196+  --env-file=.env
197+ 
198+ #  Override a specific environment variable
199+ chronicle --region us-central1 detect alerts get --alert-id ABC123 \
200+  --env-file=.env
201+ ``` 
202+ 
203+ ## Running Individual Scripts  
204+ 
205+ You can also run individual API sample scripts directly.
206+ Each script supports the ` -h `  flag to show available options:
207+ 
208+ ``` bash 
209+ #  Get help for a specific script
210+ python -m detect.v1alpha.get_alert -h
211+ python -m search.v1alpha.find_asset_events -h
212+ python -m lists.v1alpha.patch_list -h
213+ ``` 
214+ 
215+ ## License  
216+ 
217+ Apache 2.0 - See [ LICENSE] ( LICENSE )  for more information.
0 commit comments