Source code for api.assets.v1.application

"""Autogenerated API"""
import requests
from argus_cli.plugin import register_command


[docs]@register_command(extending=('assets','v1','application')) def search_host_applications_simplified(keywords: list = None, keywordField: list = None, name: list = None, hostID: list = None, serviceID: list = None, businessProcessID: list = None, customerID: list = None, ip: list = None, port: list = None, protocol: list = None, cpe: list = None, includeFlag: list = None, excludeFlag: list = None, sortBy: list = None, offset: int = 0, limit: int = 25, keywordMatch: str = 'all',json: bool = True, verify: bool = True, apiKey: str = "", authentication: dict = {}) -> dict: """Returns a set of HostApplications defined by query parameters. (PUBLIC) :param list keywords: Search by keywords :param list keywordField: Set field strategy for keyword search :param list name: Search by name :param list hostID: Search by HostAsset ID :param list serviceID: Search by ServiceAsset ID :param list businessProcessID: Search by BusinessProcess ID :param list customerID: Search by customer ID :param list ip: Search by IP range :param list port: Search by application port :param list protocol: Search by application protocol :param list cpe: Search by CPE :param list includeFlag: Include certain HostApplications in the search result based on set flags :param list excludeFlag: Exclude certain HostApplications from the search result based on set flags :param list sortBy: Sort search result :param int offset: Skip a number of results :param int limit: Maximum number of returned results :param str keywordMatch: Set match strategy for keyword search :raises AuthenticationFailedException: on 401 :raises ValidationErrorException: on 412 :raises AccessDeniedException: on 403 :returns: {"offset": 129, "limit": 272, "responseCode": 200, "count": 127, "data": [{"id": "Environmental sound other forward final.", "name": "Patricia White", "description": "New however several into account pretty too.", "createdTimestamp": 1300144697, "createdByUser": {"id": 603, "customerID": 343, "userName": "steve60", "name": "Michael Martinez"}, "lastUpdatedTimestamp": 1112610104, "lastUpdatedByUser": {"id": 664, "customerID": 13, "userName": "turnerjermaine", "name": "Derrick Chandler"}, "deletedTimestamp": 935264379, "deletedByUser": {"id": 50, "customerID": 629, "userName": "anthonyroach", "name": "Mary Hendricks"}, "firstSeenTimestamp": 925729087, "lastSeenTimestamp": 1065815367, "flags": ["DETECTED_BY_CVM"], "properties": {"additionalProperties": "Himself security paper only."}, "cpe": "Into million general analysis.", "sockets": ["None despite under middle hear information."]}], "metaData": {"additionalProperties": {}}, "messages": [{"message": "Father hold edge must full trouble wife project.", "messageTemplate": "Response place PM TV east.", "field": "Reveal collection but benefit.", "parameter": {}, "timestamp": 524062086}], "currentPage": 55, "size": 658} """ from requests import get from argus_api.exceptions import http url = "https://osl-argus-trunk-web1.mnemonic.no/web/api/assets/v1/application".format() headers = { 'Content-Type': 'application/json', 'User-Agent': 'ArgusToolbelt/1.0' } if apiKey: headers["Argus-API-Key"] = apiKey elif authentication and isinstance(authentication, dict): headers.update(authentication) elif callable(authentication): headers.update(authentication(url)) body = {} if offset: body.update({"offset": offset}) if limit: body.update({"limit": limit}) if keywordMatch: body.update({"keywordMatch": keywordMatch}) if keywords: body.update({"keywords": keywords}) if keywordField: body.update({"keywordField": keywordField}) if name: body.update({"name": name}) if hostID: body.update({"hostID": hostID}) if serviceID: body.update({"serviceID": serviceID}) if businessProcessID: body.update({"businessProcessID": businessProcessID}) if customerID: body.update({"customerID": customerID}) if ip: body.update({"ip": ip}) if port: body.update({"port": port}) if protocol: body.update({"protocol": protocol}) if cpe: body.update({"cpe": cpe}) if includeFlag: body.update({"includeFlag": includeFlag}) if excludeFlag: body.update({"excludeFlag": excludeFlag}) if sortBy: body.update({"sortBy": sortBy}) response = get(url, json=body if body else None, verify=verify, headers=headers) errors = [] if response.status_code == 401: raise http.AuthenticationFailedException(response) elif response.status_code == 403: raise http.AccessDeniedException(response) elif response.status_code == 412: raise http.ValidationErrorException(response) elif response.status_code == 404: raise http.ObjectNotFoundException(response) return response.json() if json else response
[docs]@register_command(extending=('assets','v1','application')) def add_host_application(hostID: str = None, roleID: int = None, name: str = None, description: str = None, properties: dict = None, cpe: str = None, sockets: list = None, source: str = 'USER',json: bool = True, verify: bool = True, apiKey: str = "", authentication: dict = {}) -> dict: """Creates a new HostApplication. (PUBLIC) :param str hostID: Specify parent host. :param int roleID: Specify application role. :param str name: Name of application. => [\s\w\{\}\$\-\(\)\.\[\]"\'_/\\,\*\+\#:@!?;]* :param str description: Description of application. => [\s\w\{\}\$\-\(\)\.\[\]"\'_/\\,\*\+\#:@!?;]* :param dict properties: Custom user-defined properties. => [\s\w\{\}\$\-\(\)\.\[\]"\'_/\\,\*\+\#:@!?;]* :param str cpe: CPE of application. :param list sockets: Specify socket strings of the application. :param str source: Source of the request. (default USER) :raises AuthenticationFailedException: on 401 :raises ValidationErrorException: on 412 :raises AccessDeniedException: on 403 :returns: {"offset": 835, "limit": 533, "responseCode": 200, "count": 43, "metaData": {"additionalProperties": {}}, "messages": [{"message": "Five visit blue nation.", "messageTemplate": "Sense performance live kitchen sit notice.", "field": "Believe true as modern why.", "parameter": {}, "timestamp": 51875053}], "currentPage": 970, "size": 497} """ from requests import post from argus_api.exceptions import http url = "https://osl-argus-trunk-web1.mnemonic.no/web/api/assets/v1/application".format() headers = { 'Content-Type': 'application/json', 'User-Agent': 'ArgusToolbelt/1.0' } if apiKey: headers["Argus-API-Key"] = apiKey elif authentication and isinstance(authentication, dict): headers.update(authentication) elif callable(authentication): headers.update(authentication(url)) body = {} if source: body.update({"source": source}) if hostID: body.update({"hostID": hostID}) if roleID: body.update({"roleID": roleID}) if name: body.update({"name": name}) if description: body.update({"description": description}) if properties: body.update({"properties": properties}) if cpe: body.update({"cpe": cpe}) if sockets: body.update({"sockets": sockets}) response = post(url, json=body if body else None, verify=verify, headers=headers) errors = [] if response.status_code == 401: raise http.AuthenticationFailedException(response) elif response.status_code == 403: raise http.AccessDeniedException(response) elif response.status_code == 412: raise http.ValidationErrorException(response) elif response.status_code == 404: raise http.ObjectNotFoundException(response) return response.json() if json else response
[docs]@register_command(extending=('assets','v1','application')) def search_host_applications(limit: int = None, offset: int = None, subCriteria: list = None, customerID: list = None, name: list = None, startTimestamp: int = None, endTimestamp: int = None, keywords: list = None, keywordMatchStrategy: str = None, timeMatchStrategy: str = None, hostID: list = None, serviceID: list = None, businessProcessID: list = None, ipRange: list = None, applicationPort: list = None, applicationProtocol: list = None, cpe: list = None, hostCPE: list = None, applicationCPE: list = None, applicationRole: list = None, timeFieldStrategy: list = None, keywordFieldStrategy: list = None, sortBy: list = None, includeFlags: list = None, excludeFlags: list = None, includeDeleted: bool = 'False', exclude: bool = 'False', required: bool = 'False',json: bool = True, verify: bool = True, apiKey: str = "", authentication: dict = {}) -> dict: """Returns a set of HostApplications defined by a HostApplicationSearchCriteria. (PUBLIC) :param int limit: Set this value to set max number of results. By default, no restriction on result set size. :param int offset: Set this value to skip the first (offset) objects. By default, return result from first object. :param list subCriteria: :param list customerID: Restrict search to data belonging to specified customers. :param list name: Restrict search to specific asset name :param int startTimestamp: Restrict search to a time frame based on the set TimeFieldStrategy (start timestamp). :param int endTimestamp: Restrict search to a time frame based on the set TimeFieldStrategy (end timestamp). :param list keywords: Search for keywords. :param str keywordMatchStrategy: Defines the MatchStrategy for keywords (default match all keywords). :param str timeMatchStrategy: Defines how strict to match against different timestamps (all/any) using start and end timestamp (default any) :param list hostID: Restrict search to specific host UUIDs. :param list serviceID: Restrict search to specific service UUIDs. :param list businessProcessID: Restrict search to specific business process UUIDs. :param list ipRange: Restrict search to entities related to these IP-addresses (may specify single IPs, IP networks or IP ranges. :param list applicationPort: Restrict to applications listening on specific ports. :param list applicationProtocol: Restrict to applications by transport protocol name. :param list cpe: Restrict to applications or hosts by CPE. :param list hostCPE: Restrict to hosts by CPE. :param list applicationCPE: Restrict to applications by CPE. :param list applicationRole: Search for applications by role (list of role IDs). :param list timeFieldStrategy: Defines which timestamps will be included in the search (default lastUpdatedTimestamp). :param list keywordFieldStrategy: Defines which fields will be searched by keywords (default all supported fields). :param list sortBy: List of properties to sort by (prefix with "-" to sort descending). :param list includeFlags: Only include objects which have includeFlags set. :param list excludeFlags: Exclude objects which have excludeFlags set. :param bool includeDeleted: Set to true to include deleted objects. By default, exclude deleted objects. :param bool exclude: Only relevant for subcriteria. If set to true, objects matching this subcriteria object will be excluded. :param bool required: Only relevant for subcriteria. If set to true, objects matching this subcriteria are required (AND-ed together with parent criteria). :raises AuthenticationFailedException: on 401 :raises ValidationErrorException: on 412 :raises AccessDeniedException: on 403 :returns: {"offset": 846, "limit": 129, "responseCode": 200, "count": 252, "data": [{"id": "New sport moment pattern threat.", "name": "Maria Griffith", "description": "State cut outside three.", "createdTimestamp": 1360652022, "createdByUser": {"id": 547, "customerID": 187, "userName": "alyssa67", "name": "Heidi Reynolds"}, "lastUpdatedTimestamp": 1073475167, "lastUpdatedByUser": {"id": 960, "customerID": 90, "userName": "jenniferbrown", "name": "Susan Gutierrez"}, "deletedTimestamp": 1476740942, "deletedByUser": {"id": 406, "customerID": 947, "userName": "christina63", "name": "Keith Butler"}, "firstSeenTimestamp": 1396664066, "lastSeenTimestamp": 796065402, "flags": ["CONTROLLED_VERSION"], "properties": {"additionalProperties": "Per national miss consumer build hope laugh."}, "cpe": "Decide food believe do lose cold stuff.", "sockets": ["Paper that service miss clear."]}], "metaData": {"additionalProperties": {}}, "messages": [{"message": "Become four realize wide main.", "messageTemplate": "During wrong true.", "field": "Help should reflect writer rest.", "parameter": {}, "timestamp": 367761625}], "currentPage": 90, "size": 390} """ from requests import post from argus_api.exceptions import http url = "https://osl-argus-trunk-web1.mnemonic.no/web/api/assets/v1/application/search".format() headers = { 'Content-Type': 'application/json', 'User-Agent': 'ArgusToolbelt/1.0' } if apiKey: headers["Argus-API-Key"] = apiKey elif authentication and isinstance(authentication, dict): headers.update(authentication) elif callable(authentication): headers.update(authentication(url)) body = {} if limit: body.update({"limit": limit}) if offset: body.update({"offset": offset}) if includeDeleted: body.update({"includeDeleted": includeDeleted}) if subCriteria: body.update({"subCriteria": subCriteria}) if exclude: body.update({"exclude": exclude}) if required: body.update({"required": required}) if customerID: body.update({"customerID": customerID}) if name: body.update({"name": name}) if startTimestamp: body.update({"startTimestamp": startTimestamp}) if endTimestamp: body.update({"endTimestamp": endTimestamp}) if keywords: body.update({"keywords": keywords}) if keywordMatchStrategy: body.update({"keywordMatchStrategy": keywordMatchStrategy}) if timeMatchStrategy: body.update({"timeMatchStrategy": timeMatchStrategy}) if hostID: body.update({"hostID": hostID}) if serviceID: body.update({"serviceID": serviceID}) if businessProcessID: body.update({"businessProcessID": businessProcessID}) if ipRange: body.update({"ipRange": ipRange}) if applicationPort: body.update({"applicationPort": applicationPort}) if applicationProtocol: body.update({"applicationProtocol": applicationProtocol}) if cpe: body.update({"cpe": cpe}) if hostCPE: body.update({"hostCPE": hostCPE}) if applicationCPE: body.update({"applicationCPE": applicationCPE}) if applicationRole: body.update({"applicationRole": applicationRole}) if timeFieldStrategy: body.update({"timeFieldStrategy": timeFieldStrategy}) if keywordFieldStrategy: body.update({"keywordFieldStrategy": keywordFieldStrategy}) if sortBy: body.update({"sortBy": sortBy}) if includeFlags: body.update({"includeFlags": includeFlags}) if excludeFlags: body.update({"excludeFlags": excludeFlags}) response = post(url, json=body if body else None, verify=verify, headers=headers) errors = [] if response.status_code == 401: raise http.AuthenticationFailedException(response) elif response.status_code == 403: raise http.AccessDeniedException(response) elif response.status_code == 412: raise http.ValidationErrorException(response) elif response.status_code == 404: raise http.ObjectNotFoundException(response) return response.json() if json else response
[docs]@register_command(extending=('assets','v1','application')) def get_host_application(id: str,json: bool = True, verify: bool = True, apiKey: str = "", authentication: dict = {}) -> dict: """Returns a HostApplication identified by its ID. (PUBLIC) :param str id: HostApplication ID :raises AuthenticationFailedException: on 401 :raises ValidationErrorException: on 412 :raises AccessDeniedException: on 403 :raises ObjectNotFoundException: on 404 :returns: {"offset": 121, "limit": 506, "responseCode": 200, "count": 714, "metaData": {"additionalProperties": {}}, "messages": [{"message": "Save them place describe cause.", "messageTemplate": "Word economic state return possible.", "field": "Before back discover should mother where month.", "parameter": {}, "timestamp": 55724617}], "currentPage": 153, "size": 804} """ from requests import get from argus_api.exceptions import http url = "https://osl-argus-trunk-web1.mnemonic.no/web/api/assets/v1/application/{id}".format(id=id) headers = { 'Content-Type': 'application/json', 'User-Agent': 'ArgusToolbelt/1.0' } if apiKey: headers["Argus-API-Key"] = apiKey elif authentication and isinstance(authentication, dict): headers.update(authentication) elif callable(authentication): headers.update(authentication(url)) body = {} response = get(url, json=body if body else None, verify=verify, headers=headers) errors = [] if response.status_code == 401: raise http.AuthenticationFailedException(response) elif response.status_code == 403: raise http.AccessDeniedException(response) elif response.status_code == 412: raise http.ValidationErrorException(response) elif response.status_code == 404: raise http.ObjectNotFoundException(response) return response.json() if json else response
[docs]@register_command(extending=('assets','v1','application')) def update_host_application(id: str, roleID: int = None, name: str = None, description: str = None, addProperties: dict = None, deleteProperties: list = None, cpe: str = None, addSockets: list = None, deleteSockets: list = None, source: str = 'USER',json: bool = True, verify: bool = True, apiKey: str = "", authentication: dict = {}) -> dict: """Updates an existing HostApplication. (PUBLIC) :param str id: HostApplication ID :param int roleID: Change application role. :param str name: Change application name. => [\s\w\{\}\$\-\(\)\.\[\]"\'_/\\,\*\+\#:@!?;]* :param str description: Change application description. => [\s\w\{\}\$\-\(\)\.\[\]"\'_/\\,\*\+\#:@!?;]* :param dict addProperties: Add properties to application (updates a property if key already exists). => [\s\w\{\}\$\-\(\)\.\[\]"\'_/\\,\*\+\#:@!?;]* :param list deleteProperties: Remove properties from application by key. :param str cpe: Change application CPE. :param list addSockets: Add sockets to application (list of protocol/port, e.g. tcp/80). :param list deleteSockets: Remove sockets from application (list of protocol/port, e.g. tcp/80). :param str source: Source of the request. (default USER) :raises AuthenticationFailedException: on 401 :raises ValidationErrorException: on 412 :raises AccessDeniedException: on 403 :raises ObjectNotFoundException: on 404 :returns: {"offset": 836, "limit": 165, "responseCode": 200, "count": 140, "metaData": {"additionalProperties": {}}, "messages": [{"message": "Soon performance force suffer but her purpose event.", "messageTemplate": "Allow little common us measure away.", "field": "Perhaps easy hard everybody.", "parameter": {}, "timestamp": 1055894252}], "currentPage": 826, "size": 79} """ from requests import put from argus_api.exceptions import http url = "https://osl-argus-trunk-web1.mnemonic.no/web/api/assets/v1/application/{id}".format(id=id) headers = { 'Content-Type': 'application/json', 'User-Agent': 'ArgusToolbelt/1.0' } if apiKey: headers["Argus-API-Key"] = apiKey elif authentication and isinstance(authentication, dict): headers.update(authentication) elif callable(authentication): headers.update(authentication(url)) body = {} if source: body.update({"source": source}) if roleID: body.update({"roleID": roleID}) if name: body.update({"name": name}) if description: body.update({"description": description}) if addProperties: body.update({"addProperties": addProperties}) if deleteProperties: body.update({"deleteProperties": deleteProperties}) if cpe: body.update({"cpe": cpe}) if addSockets: body.update({"addSockets": addSockets}) if deleteSockets: body.update({"deleteSockets": deleteSockets}) response = put(url, json=body if body else None, verify=verify, headers=headers) errors = [] if response.status_code == 401: raise http.AuthenticationFailedException(response) elif response.status_code == 403: raise http.AccessDeniedException(response) elif response.status_code == 412: raise http.ValidationErrorException(response) elif response.status_code == 404: raise http.ObjectNotFoundException(response) return response.json() if json else response
[docs]@register_command(extending=('assets','v1','application')) def delete_host_application(id: str, source: str = 'USER',json: bool = True, verify: bool = True, apiKey: str = "", authentication: dict = {}) -> dict: """Marks a HostApplication as deleted. (PUBLIC) :param str id: HostApplication ID :param str source: Request source (default USER) :raises AuthenticationFailedException: on 401 :raises ValidationErrorException: on 412 :raises AccessDeniedException: on 403 :raises ObjectNotFoundException: on 404 :returns: {"offset": 560, "limit": 975, "responseCode": 200, "count": 917, "metaData": {"additionalProperties": {}}, "messages": [{"message": "Hour including page course raise able spring.", "messageTemplate": "Three lead fear there.", "field": "Fact him truth whatever bill vote world.", "parameter": {}, "timestamp": 1352951414}], "currentPage": 31, "size": 150} """ from requests import delete from argus_api.exceptions import http url = "https://osl-argus-trunk-web1.mnemonic.no/web/api/assets/v1/application/{id}".format(id=id) headers = { 'Content-Type': 'application/json', 'User-Agent': 'ArgusToolbelt/1.0' } if apiKey: headers["Argus-API-Key"] = apiKey elif authentication and isinstance(authentication, dict): headers.update(authentication) elif callable(authentication): headers.update(authentication(url)) body = {} if source: body.update({"source": source}) response = delete(url, json=body if body else None, verify=verify, headers=headers) errors = [] if response.status_code == 401: raise http.AuthenticationFailedException(response) elif response.status_code == 403: raise http.AccessDeniedException(response) elif response.status_code == 412: raise http.ValidationErrorException(response) elif response.status_code == 404: raise http.ObjectNotFoundException(response) return response.json() if json else response