API
API connection
API connection
- class CveXplore.api.connection.api_db.ApiDatabaseCollection(address, collname, api_path=None, proxies=None, protocol='https', user_agent='CveXplore')[source]
Bases:
object
The ApiDatabaseCollection mimics the behaviour of the CveSearchCollection
- __init__(address, collname, api_path=None, proxies=None, protocol='https', user_agent='CveXplore')[source]
Create a new ApiDatabaseCollection.
- Parameters
address (tuple) – Tuple with host ip/name and port
collname (str) – Collection name
api_path (str) – The api_path parameter needs to be provided if the API runs on a non-root path. So if the API is reachable at: https://localhost/api, this parameter needs to be set to ‘api’. So it is needed to connect to api resources, defaults to ‘None’
proxies (dict) – If you need to use a proxy, you can configure individual requests with the proxies argument to any request method
protocol (str) – Protocol to use when connecting to api; defaults to ‘https’
user_agent (str) – User agent to use when connecting; defaults to CveXplore:<<version>>
- class CveXplore.api.connection.api_db.ApiDatabaseSource(address, api_path=None, proxies=None, protocol='https', user_agent='CveXplore')[source]
Bases:
object
The ApiDatabaseSource mimics the behaviour of the MongoDBConnection.
- __init__(address, api_path=None, proxies=None, protocol='https', user_agent='CveXplore')[source]
Create new instance of the ApiDatabaseSource
- Parameters
address (tuple) – Tuple with host ip/name and port
api_path (str) – The api_path parameter needs to be provided if the API runs on a non-root path. So if the API is reachable at: https://localhost/api, this parameter needs to be set to ‘api’. So it is needed to connect to api resources, defaults to ‘None’
proxies (dict) – If you need to use a proxy, you can configure individual requests with the proxies argument to any request method
protocol (str) – Protocol to use when connecting to api; defaults to ‘https’
user_agent (str) – User agent to use when connecting; defaults to CveXplore:<<version>>
API helpers
Cve Search API
- class CveXplore.api.helpers.cve_search_api.CveSearchApi(db_collection, filter=None, limit=None, skip=None, sort=None)[source]
Bases:
GenericApi
The CveSearchApi handles the different arguments in order to perform a query to a specific Cve Search api endpoint. It mimics the pymongo cursor’s behaviour to provide an ambiguous way to talk to either an API or a mongodb.
- __init__(db_collection, filter=None, limit=None, skip=None, sort=None)[source]
Create a new CveSearchApi object.
- Parameters
db_collection (ApiDatabaseCollection) – ApiDatabaseCollection object
filter (dict) – Filter to be used when querying data
limit (int) – Limit value
skip (int) – Skip value
sort (tuple) – Sort value
- __next__()
Iterate to the results and return database objects
- limit(value)[source]
Method to limit the amount of returned data
- Parameters
value (int) – Limit
- Returns
CveSearchApi object
- Return type
- skip(value)[source]
Method to skip the given amount of records before returning the data
- Parameters
value (int) – Skip
- Returns
CveSearchApi object
- Return type