Source code for api.assets.v1.service

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


[docs]@register_command(extending=('assets','v1','service')) def search_service_assets_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, vulnID: list = None, vulnRef: 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 as set of ServiceAssets 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 vulnID: Search by vulnerability ID :param list vulnRef: Search by vulnerability reference :param list includeFlag: Include certain ServiceAssets in the search result based on set flags :param list excludeFlag: Exclude certain ServiceAssets 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": 40, "limit": 749, "responseCode": 200, "count": 11, "data": [{"id": "Show security only of because.", "ownedByUser": {"id": 482, "customerID": 223, "userName": "nrobinson", "name": "John Baker II"}, "name": "Thomas Stephens", "description": "Exist party sea personal production.", "totalCvss": 783, "vulnerabilitiesCount": 741, "createdTimestamp": 1329367047, "createdByUser": {"id": 311, "customerID": 423, "userName": "nancyfranklin", "name": "Lauren Carter"}, "lastUpdatedTimestamp": 1157472603, "lastUpdatedByUser": {"id": 131, "customerID": 569, "userName": "amy79", "name": "Jeremy Chapman"}, "deletedTimestamp": 886050468, "deletedByUser": {"id": 500, "customerID": 872, "userName": "wryan", "name": "Christopher Middleton"}, "flags": ["MERGED"], "properties": {"additionalProperties": "Well full partner."}, "businessProcesses": [{"id": "Party pass little dark son east.", "name": "Joseph Hall"}], "hosts": [{"id": "Avoid minute book production anything region matter.", "name": "Jason Johnson"}]}], "metaData": {"additionalProperties": {}}, "messages": [{"message": "Sense run paper stuff history we.", "messageTemplate": "Father already civil.", "field": "Power tend beat campaign result operation.", "parameter": {}, "timestamp": 283208780}], "currentPage": 930, "size": 413} """ from requests import get from argus_api.exceptions import http url = "https://portal.mnemonic.no/web/api/assets/v1/service".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 vulnID: body.update({"vulnID": vulnID}) if vulnRef: body.update({"vulnRef": vulnRef}) 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','service')) def add_service_asset(ownerID: int = None, customerID: int = None, name: str = None, description: str = None, properties: dict = None,json: bool = True, verify: bool = True, apiKey: str = "", authentication: dict = {}) -> dict: """Creates a new ServiceAsset. (PUBLIC) :param int ownerID: User who owns the asset. :param int customerID: Customer the asset belongs to. :param str name: Name of the asset. => [\s\w\{\}\$\-\(\)\.\[\]"\'_/\\,\*\+\#:@!?;]* :param str description: Description of the asset. => [\s\w\{\}\$\-\(\)\.\[\]"\'_/\\,\*\+\#:@!?;]* :param dict properties: Custom user-defined properties. => [\s\w\{\}\$\-\(\)\.\[\]"\'_/\\,\*\+\#:@!?;]* :raises AuthenticationFailedException: on 401 :raises ValidationErrorException: on 412 :raises AccessDeniedException: on 403 :returns: {"offset": 777, "limit": 978, "responseCode": 200, "count": 763, "metaData": {"additionalProperties": {}}, "messages": [{"message": "Attention candidate hair and parent.", "messageTemplate": "Administration few reveal whole suffer both.", "field": "Scientist recent north person page.", "parameter": {}, "timestamp": 1294900305}], "currentPage": 605, "size": 602} """ from requests import post from argus_api.exceptions import http url = "https://portal.mnemonic.no/web/api/assets/v1/service".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 ownerID: body.update({"ownerID": ownerID}) if customerID: body.update({"customerID": customerID}) if name: body.update({"name": name}) if description: body.update({"description": description}) if properties: body.update({"properties": properties}) 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','service')) def search_service_assets(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, ownerID: list = None, criticality: list = None, minimumTotalCvss: int = None, maximumTotalCvss: int = None, vulnerabilityReference: list = None, vulnerabilityID: 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 ServiceAssets defined by a ServiceAssetSearchCriteria. (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 ownerID: Restrict search to specific ownerIDs :param list criticality: Restrict search to a range of criticality levels (add multiple CriticalitySearch objects to specify OR criteria). :param int minimumTotalCvss: Restrict search to a minimum total CVSS score. :param int maximumTotalCvss: Restrict search to a maximum total CVSS score. :param list vulnerabilityReference: Restrict to vulnerabilities identified by vulnerability reference. :param list vulnerabilityID: Restrict to vulnerabilities identified by vulnerability ID. :param list applicationRole: Restrict to applications with specific roles (list of role IDs). :param list timeFieldStrategy: Defines which timestamps will be included in the search (default lastUpdatedTimestamp on service). :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": 457, "limit": 863, "responseCode": 200, "count": 406, "data": [{"id": "Study participant movie gun need pick.", "ownedByUser": {"id": 123, "customerID": 844, "userName": "jeffreyjohnson", "name": "Robert Figueroa"}, "name": "Joseph Smith", "description": "Bring realize sister pressure indeed sort.", "totalCvss": 768, "vulnerabilitiesCount": 753, "createdTimestamp": 382469074, "createdByUser": {"id": 930, "customerID": 617, "userName": "nicole19", "name": "Walter Smith"}, "lastUpdatedTimestamp": 1342391645, "lastUpdatedByUser": {"id": 429, "customerID": 609, "userName": "nancylindsey", "name": "Allison Herrera"}, "deletedTimestamp": 1148464781, "deletedByUser": {"id": 199, "customerID": 645, "userName": "kristine60", "name": "Brianna Bell"}, "flags": ["DELETED_FROM_CVM"], "properties": {"additionalProperties": "Article event for."}, "businessProcesses": [{"id": "Tell need strong space chair network walk report.", "name": "Jennifer Reeves"}], "hosts": [{"id": "Use point professional.", "name": "Sean Henry"}]}], "metaData": {"additionalProperties": {}}, "messages": [{"message": "Main force moment commercial.", "messageTemplate": "Career production what.", "field": "Point assume this model indeed series.", "parameter": {}, "timestamp": 1007224723}], "currentPage": 956, "size": 491} """ from requests import post from argus_api.exceptions import http url = "https://portal.mnemonic.no/web/api/assets/v1/service/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 ownerID: body.update({"ownerID": ownerID}) if criticality: body.update({"criticality": criticality}) if minimumTotalCvss: body.update({"minimumTotalCvss": minimumTotalCvss}) if maximumTotalCvss: body.update({"maximumTotalCvss": maximumTotalCvss}) if vulnerabilityReference: body.update({"vulnerabilityReference": vulnerabilityReference}) if vulnerabilityID: body.update({"vulnerabilityID": vulnerabilityID}) 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','service')) def get_service_asset(id: str,json: bool = True, verify: bool = True, apiKey: str = "", authentication: dict = {}) -> dict: """Returns a ServiceAsset identified by its ID. (PUBLIC) :param str id: ServiceAsset ID :raises AuthenticationFailedException: on 401 :raises ValidationErrorException: on 412 :raises AccessDeniedException: on 403 :raises ObjectNotFoundException: on 404 :returns: {"offset": 69, "limit": 62, "responseCode": 200, "count": 569, "metaData": {"additionalProperties": {}}, "messages": [{"message": "Technology himself contain particularly show.", "messageTemplate": "Small follow section population this.", "field": "None simple community week fact woman sure war.", "parameter": {}, "timestamp": 969438159}], "currentPage": 410, "size": 459} """ from requests import get from argus_api.exceptions import http url = "https://portal.mnemonic.no/web/api/assets/v1/service/{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','service')) def update_service_asset(id: str, ownerID: int = None, name: str = None, description: str = None, addProperties: dict = None, deleteProperties: list = None,json: bool = True, verify: bool = True, apiKey: str = "", authentication: dict = {}) -> dict: """Updates an existing ServiceAsset. (PUBLIC) :param str id: ServiceAsset ID :param int ownerID: Change user who owns the asset. :param str name: Change name of asset. => [\s\w\{\}\$\-\(\)\.\[\]"\'_/\\,\*\+\#:@!?;]* :param str description: Change description of asset. => [\s\w\{\}\$\-\(\)\.\[\]"\'_/\\,\*\+\#:@!?;]* :param dict addProperties: Add custom properties (updates a property if key already exists). => [\s\w\{\}\$\-\(\)\.\[\]"\'_/\\,\*\+\#:@!?;]* :param list deleteProperties: Delete custom properties by key. :raises AuthenticationFailedException: on 401 :raises ValidationErrorException: on 412 :raises AccessDeniedException: on 403 :raises ObjectNotFoundException: on 404 :returns: {"offset": 63, "limit": 841, "responseCode": 200, "count": 260, "metaData": {"additionalProperties": {}}, "messages": [{"message": "Traditional interview determine.", "messageTemplate": "Loss whatever fall.", "field": "Off outside major first already hold former.", "parameter": {}, "timestamp": 1417417346}], "currentPage": 658, "size": 378} """ from requests import put from argus_api.exceptions import http url = "https://portal.mnemonic.no/web/api/assets/v1/service/{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 ownerID: body.update({"ownerID": ownerID}) if name: body.update({"name": name}) if description: body.update({"description": description}) if addProperties: body.update({"addProperties": addProperties}) if deleteProperties: body.update({"deleteProperties": deleteProperties}) 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','service')) def delete_service_asset(id: str,json: bool = True, verify: bool = True, apiKey: str = "", authentication: dict = {}) -> dict: """Marks a ServiceAsset as deleted. (PUBLIC) :param str id: ServiceAsset ID :raises AuthenticationFailedException: on 401 :raises ValidationErrorException: on 412 :raises AccessDeniedException: on 403 :raises ObjectNotFoundException: on 404 :returns: {"offset": 351, "limit": 666, "responseCode": 200, "count": 335, "metaData": {"additionalProperties": {}}, "messages": [{"message": "Course thousand child purpose my task.", "messageTemplate": "Box receive spend against.", "field": "Item hotel future lot probably hope indicate remember.", "parameter": {}, "timestamp": 666318940}], "currentPage": 569, "size": 739} """ from requests import delete from argus_api.exceptions import http url = "https://portal.mnemonic.no/web/api/assets/v1/service/{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 = 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
[docs]@register_command(extending=('assets','v1','service')) def attach_hosts_to_service(id: str, hostAssetIDs: list = None,json: bool = True, verify: bool = True, apiKey: str = "", authentication: dict = {}) -> dict: """Adds multiple HostAssets to a ServiceAsset. (PUBLIC) :param str id: ServiceAsset ID :param list hostAssetIDs: Specify hosts to add to service. :raises AuthenticationFailedException: on 401 :raises ValidationErrorException: on 412 :raises AccessDeniedException: on 403 :raises ObjectNotFoundException: on 404 :returns: {"offset": 403, "limit": 906, "responseCode": 200, "count": 746, "metaData": {"additionalProperties": {}}, "messages": [{"message": "Discuss staff million television popular message.", "messageTemplate": "Along newspaper security we scene create floor.", "field": "Event interest resource far decision.", "parameter": {}, "timestamp": 618624990}], "currentPage": 295, "size": 887} """ from requests import put from argus_api.exceptions import http url = "https://portal.mnemonic.no/web/api/assets/v1/service/{id}/attachhosts".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 hostAssetIDs: body.update({"hostAssetIDs": hostAssetIDs}) 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','service')) def detach_hosts_from_service(id: str, hostAssetIDs: list = None,json: bool = True, verify: bool = True, apiKey: str = "", authentication: dict = {}) -> dict: """Removes multiple HostAssets from a ServiceAsset. (PUBLIC) :param str id: ServiceAsset ID :param list hostAssetIDs: Specify hosts to detach from service. :raises AuthenticationFailedException: on 401 :raises ValidationErrorException: on 412 :raises AccessDeniedException: on 403 :raises ObjectNotFoundException: on 404 :returns: {"offset": 702, "limit": 686, "responseCode": 200, "count": 874, "metaData": {"additionalProperties": {}}, "messages": [{"message": "Continue food to month product.", "messageTemplate": "Part edge make daughter.", "field": "Whether sell compare.", "parameter": {}, "timestamp": 501114757}], "currentPage": 880, "size": 353} """ from requests import put from argus_api.exceptions import http url = "https://portal.mnemonic.no/web/api/assets/v1/service/{id}/detachhosts".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 hostAssetIDs: body.update({"hostAssetIDs": hostAssetIDs}) 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