@@ -157,8 +157,7 @@ def search_domains(self,
157
157
"""
158
158
demisto .debug (f'Searching domains with query: { query } ' )
159
159
url_suffix = 'explore/domain/search'
160
-
161
- # Build parameters dictionary with only non-None values
160
+
162
161
params = {k : v for k , v in {
163
162
'query' : query ,
164
163
'start_date' : start_date ,
@@ -169,7 +168,41 @@ def search_domains(self,
169
168
}.items () if v is not None }
170
169
171
170
return self ._http_request ('GET' , url_suffix , params = params )
171
+
172
+ def list_domain_infratags (self , domains : list , cluster : Optional [bool ] = False , mode : Optional [str ] = 'live' , match : Optional [str ] = 'self' , as_of : Optional [str ] = None ) -> dict :
173
+ """
174
+ Get infratags for multiple domains with optional clustering and additional filtering options.
175
+
176
+ Args:
177
+ domains (list): A list of domains to retrieve infratags for.
178
+ cluster (bool, optional): Whether to cluster the results. Defaults to False.
179
+ mode (str, optional): Mode for the lookup, either 'live' (default) or 'padns'.
180
+ match (str, optional): Handling of self-hosted infrastructure, either 'self' (default) or 'full'.
181
+ as_of (str, optional): Date or timestamp for filtering the data.
172
182
183
+ Returns:
184
+ dict: A dictionary containing infratags for the provided domains.
185
+ """
186
+ demisto .debug (f'Fetching infratags for domains: { domains } with cluster={ cluster } , mode={ mode } , match={ match } , as_of={ as_of } ' )
187
+
188
+ # Loop through the domains to create individual requests
189
+ results = {}
190
+ for domain in domains :
191
+ url = f'https://api.silentpush.com/api/v1/merge-api/explore/domain/infratag/{ domain } '
192
+ data = {
193
+ 'cluster' : cluster ,
194
+ 'mode' : mode ,
195
+ 'match' : match ,
196
+ 'as_of' : as_of
197
+ }
198
+ try :
199
+ response = self ._http_request ('GET' , url , params = data ) # Assuming GET method for this endpoint
200
+ results [domain ] = response
201
+ except Exception as e :
202
+ demisto .error (f"Error fetching infratags for domain { domain } : { str (e )} " )
203
+ results [domain ] = {"error" : str (e )}
204
+
205
+ return results
173
206
174
207
def test_module (client : Client ) -> str :
175
208
"""
@@ -215,7 +248,6 @@ def list_domain_information_command(client: Client, args: dict) -> CommandResult
215
248
"""
216
249
domain = args .get ('domain' , 'silentpush.com' )
217
250
demisto .debug (f'Processing domain: { domain } ' )
218
-
219
251
raw_response = client .list_domain_information (domain )
220
252
demisto .debug (f'Response from API: { raw_response } ' )
221
253
@@ -256,7 +288,6 @@ def get_domain_certificates_command(client: Client, args: dict) -> CommandResult
256
288
257
289
def search_domains_command (client : Client , args : dict ) -> CommandResults :
258
290
259
- # Extract parameters from args with type conversion
260
291
query = args .get ('query' )
261
292
start_date = args .get ('start_date' )
262
293
end_date = args .get ('end_date' )
@@ -284,6 +315,47 @@ def search_domains_command(client: Client, args: dict) -> CommandResults:
284
315
readable_output = readable_output ,
285
316
raw_response = raw_response
286
317
)
318
+
319
+ def list_domain_infratags_command (client : Client , args : dict ) -> CommandResults :
320
+ """
321
+ Command handler for fetching infratags for multiple domains.
322
+
323
+ Args:
324
+ client (Client): The client instance to fetch the data.
325
+ args (dict): The arguments passed to the command, including domains, clustering option, and optional filters.
326
+
327
+ Returns:
328
+ CommandResults: The command results containing readable output and the raw response.
329
+ """
330
+
331
+ domains = argToList (args .get ('domains' , '' ))
332
+ cluster = argToBoolean (args .get ('cluster' , False ))
333
+ mode = args .get ('mode' , 'live' ) # Default to 'live'
334
+ match = args .get ('match' , 'self' ) # Default to 'self'
335
+ as_of = args .get ('as_of' , None ) # Default to None
336
+
337
+ if not domains :
338
+ raise ValueError ('"domains" argument is required and cannot be empty.' )
339
+
340
+ demisto .debug (f'Processing infratags for domains: { domains } with cluster={ cluster } , mode={ mode } , match={ match } , as_of={ as_of } ' )
341
+
342
+ try :
343
+ raw_response = client .list_domain_infratags (domains , cluster , mode , match , as_of )
344
+ demisto .debug (f'Response from API: { raw_response } ' )
345
+ except Exception as e :
346
+ demisto .error (f'Error occurred while fetching infratags: { str (e )} ' )
347
+ raise
348
+
349
+ readable_output = tableToMarkdown ('Domain Infratags' , raw_response .get ('results' , []))
350
+
351
+ return CommandResults (
352
+ outputs_prefix = 'SilentPush.InfraTags' ,
353
+ outputs_key_field = 'domain' ,
354
+ outputs = raw_response ,
355
+ readable_output = readable_output ,
356
+ raw_response = raw_response
357
+ )
358
+
287
359
288
360
289
361
''' MAIN FUNCTION '''
@@ -326,6 +398,7 @@ def main():
326
398
'silentpush-list-domain-information' : list_domain_information_command ,
327
399
'silentpush-get-domain-certificates' : get_domain_certificates_command ,
328
400
'silentpush-search-domains' : search_domains_command ,
401
+ 'silentpush-list-domain-infratags' : list_domain_infratags_command ,
329
402
}
330
403
331
404
if command in command_handlers :
0 commit comments