@@ -5879,47 +5879,45 @@ def feed_query(self, category, filter, weeks=0, all_time=False):
5879
5879
filtered by category. The service can return a list of malware family names
5880
5880
newly added to each category, the number of unieque new samples added for each
5881
5881
malware family in a category, and a list of top 20 malware families per category
5882
- param: category: Corresponds to the verticals feed category the user is requesting to access.
5882
+ :param category: Corresponds to the verticals feed category the user is requesting to access.
5883
5883
Only one category can be requested in each query. Note that the response for the 'exploit'
5884
5884
category contains addional 'scanner_coverage' data not found in other categories.
5885
5885
Enum: 'financial', 'retail', 'ransomware', 'apt', 'exploit', 'configuration'
5886
- type: category: str
5887
- param: filter: applied to filter data to request. Enum: 'first_seen', 'counts', 'top_list'
5888
- type: filter: str
5889
- param: weeks: specifies the number of weeks for which the data will be returned in response
5890
- type: weeks: int
5891
- param: all_time: Instructs the service to return all available data for the requested category
5892
- type all_time: boolean
5886
+ :type category: str
5887
+ :param filter: applied to filter data to request. Enum: 'first_seen', 'counts', 'top_list'
5888
+ :type filter: str
5889
+ :param weeks: specifies the number of weeks for which the data will be returned in response
5890
+ :type weeks: int
5891
+ :param all_time: Instructs the service to return all available data for the requested category
5892
+ : type all_time: boolean
5893
5893
"""
5894
5894
if category not in VERTICAL_FEEDS_CATEGORIES :
5895
5895
raise WrongInputError ("Only the following categories are allowed: {category}" .format (
5896
5896
category = VERTICAL_FEEDS_CATEGORIES ))
5897
5897
5898
- if filter . lower () not in ("counts" , "top_list" , "first_seen" ):
5898
+ if filter not in ("counts" , "top_list" , "first_seen" ):
5899
5899
raise WrongInputError ("Only the following filters are allowed: 'counts', 'top_list' and 'first_seen'" )
5900
5900
5901
+ query_params = {
5902
+ "format" : "json"
5903
+ }
5904
+
5901
5905
if isinstance (weeks , int ):
5902
5906
5903
5907
if weeks not in range (0 , 30 ):
5904
5908
raise WrongInputError ("The value for weeks can be a number between 0 and 30" )
5905
5909
5906
- query_params = {
5907
- "weeks" : weeks ,
5908
- "format" : "json"
5909
- }
5910
-
5911
- raise WrongInputError ("Weeks needs to be provided as integer" )
5910
+ query_params ["weeks" ] = weeks
5912
5911
5913
5912
if all_time :
5913
+ query_params ["all_time" ] = "true"
5914
5914
5915
- query_params = {
5916
- "all_time" : "true" ,
5917
- "format" : "json"
5918
- }
5915
+ if "weeks" in query_params :
5916
+ raise WrongInputError ("The all_time parameter can not be used together with weeks." )
5919
5917
5920
5918
endpoint = self .__API_FEED_ENDPOINT .format (
5921
- category = category ,
5922
- filter = filter
5919
+ category = category ,
5920
+ filter = filter
5923
5921
)
5924
5922
5925
5923
url = self ._url .format (endpoint = endpoint )
0 commit comments