|
23 | 23 | from lists.v1alpha import create_list |
24 | 24 | from lists.v1alpha import get_list |
25 | 25 | from lists.v1alpha import patch_list |
26 | | -from reference_lists.v1alpha import create_reference_list |
27 | | -from reference_lists.v1alpha import get_reference_list |
28 | | -from reference_lists.v1alpha import list_reference_lists |
29 | 26 | from sdk.commands.common import add_common_options |
30 | 27 |
|
31 | 28 | SCOPES = [ |
@@ -137,116 +134,7 @@ def patch_list_cmd(credentials_file, project_id, project_instance, region, |
137 | 134 | print(json.dumps(result, indent=2)) |
138 | 135 |
|
139 | 136 |
|
140 | | -@lists.group() |
141 | | -def reference(): |
142 | | - """Reference Lists API commands.""" |
143 | | - pass |
144 | | - |
145 | | - |
146 | | -@reference.command("create") |
147 | | -@add_common_options |
148 | | -@click.option( |
149 | | - "--reference-list-id", |
150 | | - required=True, |
151 | | - help="ID to use for the new reference list.", |
152 | | -) |
153 | | -@click.option( |
154 | | - "--entries", |
155 | | - required=True, |
156 | | - help="JSON array of strings to add to the reference list.", |
157 | | -) |
158 | | -@click.option( |
159 | | - "--syntax-type", |
160 | | - type=click.Choice([ |
161 | | - "REFERENCE_LIST_SYNTAX_TYPE_UNSPECIFIED", |
162 | | - "REFERENCE_LIST_SYNTAX_TYPE_PLAIN_TEXT_STRING", |
163 | | - "REFERENCE_LIST_SYNTAX_TYPE_REGEX", "REFERENCE_LIST_SYNTAX_TYPE_CIDR" |
164 | | - ]), |
165 | | - default="REFERENCE_LIST_SYNTAX_TYPE_PLAIN_TEXT_STRING", |
166 | | - help="Type of entries in the list.", |
167 | | -) |
168 | | -@click.option( |
169 | | - "--scope-names", |
170 | | - help="Optional JSON array of scope names.", |
171 | | -) |
172 | | -@click.option( |
173 | | - "--description", |
174 | | - help="Optional description of the reference list.", |
175 | | -) |
176 | | -def create_reference_list_cmd(credentials_file, project_id, project_instance, |
177 | | - region, reference_list_id, entries, syntax_type, |
178 | | - scope_names, description): |
179 | | - """Create a new reference list.""" |
180 | | - auth_session = chronicle_auth.initialize_http_session( |
181 | | - credentials_file, |
182 | | - SCOPES, |
183 | | - ) |
184 | 137 |
|
185 | | - entries_list = json.loads(entries) |
186 | | - scope_names_list = json.loads(scope_names) if scope_names else None |
187 | 138 |
|
188 | | - result = create_reference_list.create_reference_list( |
189 | | - auth_session, |
190 | | - project_id, |
191 | | - project_instance, |
192 | | - region, |
193 | | - reference_list_id, |
194 | | - entries_list, |
195 | | - syntax_type, |
196 | | - scope_names_list, |
197 | | - description, |
198 | | - ) |
199 | | - print(json.dumps(result, indent=2)) |
200 | 139 |
|
201 | 140 |
|
202 | | -@reference.command("get") |
203 | | -@add_common_options |
204 | | -@click.option( |
205 | | - "--reference-list-id", |
206 | | - required=True, |
207 | | - help="ID of the reference list to retrieve.", |
208 | | -) |
209 | | -def get_reference_list_cmd(credentials_file, project_id, project_instance, |
210 | | - region, reference_list_id): |
211 | | - """Get a reference list by ID.""" |
212 | | - auth_session = chronicle_auth.initialize_http_session( |
213 | | - credentials_file, |
214 | | - SCOPES, |
215 | | - ) |
216 | | - result = get_reference_list.get_reference_list( |
217 | | - auth_session, |
218 | | - project_id, |
219 | | - project_instance, |
220 | | - region, |
221 | | - reference_list_id, |
222 | | - ) |
223 | | - print(json.dumps(result, indent=2)) |
224 | | - |
225 | | - |
226 | | -@reference.command("list") |
227 | | -@add_common_options |
228 | | -@click.option( |
229 | | - "--page-size", |
230 | | - type=int, |
231 | | - help="Optional maximum number of reference lists to return.", |
232 | | -) |
233 | | -@click.option( |
234 | | - "--page-token", |
235 | | - help="Optional page token from a previous response for pagination.", |
236 | | -) |
237 | | -def list_reference_lists_cmd(credentials_file, project_id, project_instance, |
238 | | - region, page_size, page_token): |
239 | | - """List reference lists.""" |
240 | | - auth_session = chronicle_auth.initialize_http_session( |
241 | | - credentials_file, |
242 | | - SCOPES, |
243 | | - ) |
244 | | - result = list_reference_lists.list_reference_lists( |
245 | | - auth_session, |
246 | | - project_id, |
247 | | - project_instance, |
248 | | - region, |
249 | | - page_size, |
250 | | - page_token, |
251 | | - ) |
252 | | - print(json.dumps(result, indent=2)) |
0 commit comments