Source code for api.assets.v1.service

"""Autogenerated API"""

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 = None, limit: int = 25, keywordMatch: str = "all", json: bool = True, verify: bool = True, apiKey: str = None, 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': 82, 'limit': 934, 'responseCode': 200, 'count': 170, 'data': [{'id': 'Hear debate human never door.', 'ownedByUser': {'id': 646, 'customerID': 742, 'userName': 'dana25', 'name': 'Tara Hughes'}, 'name': 'Erin Young', 'description': 'Computer maybe budget commercial.', 'totalCvss': 759, 'vulnerabilitiesCount': 252, 'createdTimestamp': 1189980692, 'createdByUser': {'id': 209, 'customerID': 542, 'userName': 'robertsmith', 'name': 'Shannon Armstrong'}, 'lastUpdatedTimestamp': 160376882, 'lastUpdatedByUser': {'id': 883, 'customerID': 60, 'userName': 'zgreen', 'name': 'Janet Martinez'}, 'deletedTimestamp': 263499927, 'deletedByUser': {'id': 825, 'customerID': 798, 'userName': 'ochoaangela', 'name': 'Angela Gill'}, 'flags': ['MERGED'], 'properties': {'additionalProperties': 'Assume little author character city.'}, 'businessProcesses': [{'id': 'Set possible administration painting whole be edge.', 'name': 'Samantha Hinton'}], 'hosts': [{'id': 'Machine environment program sense.', 'name': 'Pamela Mendoza'}]}], 'metaData': {'additionalProperties': {}}, 'messages': [{'message': 'Region see mind something relate agreement.', 'messageTemplate': 'Test hold treat wish teacher future.', 'field': 'Wrong nothing wide.', 'parameter': {}, 'timestamp': 849617715}], 'currentPage': 30, 'size': 2} """ 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/' } if apiKey: headers["Argus-API-Key"] = apiKey elif authentication and isinstance(authentication, dict): headers.update(authentication) elif callable(authentication): headers.update(authentication(url)) body = { "offset": offset, "limit": limit, "keywordMatch": keywordMatch, "keywords": keywords, "keywordField": keywordField, "name": name, "hostID": hostID, "serviceID": serviceID, "businessProcessID": businessProcessID, "customerID": customerID, "ip": ip, "port": port, "protocol": protocol, "cpe": cpe, "vulnID": vulnID, "vulnRef": vulnRef, "includeFlag": includeFlag, "excludeFlag": excludeFlag, "sortBy": sortBy } response = get(url, json=body if body else None, verify=verify, headers=headers ) 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 = None, 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': 794, 'limit': 86, 'responseCode': 200, 'count': 386, 'metaData': {'additionalProperties': {}}, 'messages': [{'message': 'Tell hope book ability.', 'messageTemplate': 'Consider far couple school.', 'field': 'Reach leader ahead which policy new course.', 'parameter': {}, 'timestamp': 92343526}], 'currentPage': 26, 'size': 465} """ 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/' } if apiKey: headers["Argus-API-Key"] = apiKey elif authentication and isinstance(authentication, dict): headers.update(authentication) elif callable(authentication): headers.update(authentication(url)) body = { "ownerID": ownerID, "customerID": customerID, "name": name, "description": description, "properties": properties } response = post(url, json=body if body else None, verify=verify, headers=headers ) 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 = None, exclude: bool = None, required: bool = None, json: bool = True, verify: bool = True, apiKey: str = None, 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': 95, 'limit': 491, 'responseCode': 200, 'count': 686, 'data': [{'id': 'Newspaper continue suggest style church personal society.', 'ownedByUser': {'id': 85, 'customerID': 504, 'userName': 'cody46', 'name': 'Kevin Fisher'}, 'name': 'Natalie Williams', 'description': 'In ready wife gas.', 'totalCvss': 918, 'vulnerabilitiesCount': 636, 'createdTimestamp': 656530535, 'createdByUser': {'id': 504, 'customerID': 603, 'userName': 'dcooper', 'name': 'Paul Johnson'}, 'lastUpdatedTimestamp': 805470699, 'lastUpdatedByUser': {'id': 955, 'customerID': 118, 'userName': 'christina94', 'name': 'Kenneth Meyer'}, 'deletedTimestamp': 545772314, 'deletedByUser': {'id': 97, 'customerID': 459, 'userName': 'jacksonjames', 'name': 'Victoria Stone'}, 'flags': ['HAS_HIGH_VULN'], 'properties': {'additionalProperties': 'Stay bank her fly certain.'}, 'businessProcesses': [{'id': 'Find all character line.', 'name': 'Christopher Jones'}], 'hosts': [{'id': 'Assume plant particular might race term finally.', 'name': 'Jessica Mccoy'}]}], 'metaData': {'additionalProperties': {}}, 'messages': [{'message': 'Two provide policy enough.', 'messageTemplate': 'Audience physical though case left specific audience five.', 'field': 'However whom collection usually if describe.', 'parameter': {}, 'timestamp': 1358404583}], 'currentPage': 188, 'size': 795} """ 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/' } if apiKey: headers["Argus-API-Key"] = apiKey elif authentication and isinstance(authentication, dict): headers.update(authentication) elif callable(authentication): headers.update(authentication(url)) body = { "limit": limit, "offset": offset, "includeDeleted": includeDeleted, "subCriteria": subCriteria, "exclude": exclude, "required": required, "customerID": customerID, "name": name, "startTimestamp": startTimestamp, "endTimestamp": endTimestamp, "keywords": keywords, "keywordMatchStrategy": keywordMatchStrategy, "timeMatchStrategy": timeMatchStrategy, "hostID": hostID, "serviceID": serviceID, "businessProcessID": businessProcessID, "ipRange": ipRange, "applicationPort": applicationPort, "applicationProtocol": applicationProtocol, "cpe": cpe, "hostCPE": hostCPE, "applicationCPE": applicationCPE, "ownerID": ownerID, "criticality": criticality, "minimumTotalCvss": minimumTotalCvss, "maximumTotalCvss": maximumTotalCvss, "vulnerabilityReference": vulnerabilityReference, "vulnerabilityID": vulnerabilityID, "applicationRole": applicationRole, "timeFieldStrategy": timeFieldStrategy, "keywordFieldStrategy": keywordFieldStrategy, "sortBy": sortBy, "includeFlags": includeFlags, "excludeFlags": excludeFlags } response = post(url, json=body if body else None, verify=verify, headers=headers ) 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 = None, 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': 29, 'limit': 478, 'responseCode': 200, 'count': 921, 'metaData': {'additionalProperties': {}}, 'messages': [{'message': 'Fear alone answer science such.', 'messageTemplate': 'Name contain take car.', 'field': 'Behind behind deal store station.', 'parameter': {}, 'timestamp': 1081663281}], 'currentPage': 898, 'size': 535} """ 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/' } 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 ) 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 = None, 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': 74, 'limit': 749, 'responseCode': 200, 'count': 756, 'metaData': {'additionalProperties': {}}, 'messages': [{'message': 'Product some million food fire enter source wrong.', 'messageTemplate': 'Pm free you arm less.', 'field': 'Statement expect move life hospital.', 'parameter': {}, 'timestamp': 155860228}], 'currentPage': 417, 'size': 56} """ 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/' } if apiKey: headers["Argus-API-Key"] = apiKey elif authentication and isinstance(authentication, dict): headers.update(authentication) elif callable(authentication): headers.update(authentication(url)) body = { "ownerID": ownerID, "name": name, "description": description, "addProperties": addProperties, "deleteProperties": deleteProperties } response = put(url, json=body if body else None, verify=verify, headers=headers ) 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 = None, 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': 805, 'limit': 198, 'responseCode': 200, 'count': 985, 'metaData': {'additionalProperties': {}}, 'messages': [{'message': 'Lay everyone forward stand understand most people.', 'messageTemplate': 'Serve sign Mrs themselves say yet hotel without.', 'field': 'Million later age theory increase old billion teach.', 'parameter': {}, 'timestamp': 509003978}], 'currentPage': 411, 'size': 677} """ 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/' } 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 ) 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 = None, 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': 205, 'limit': 233, 'responseCode': 200, 'count': 570, 'metaData': {'additionalProperties': {}}, 'messages': [{'message': 'Detail serve one during woman.', 'messageTemplate': 'Material I wait four Congress stock information sure.', 'field': 'Option political wide cell field.', 'parameter': {}, 'timestamp': 311090907}], 'currentPage': 958, 'size': 531} """ 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/' } if apiKey: headers["Argus-API-Key"] = apiKey elif authentication and isinstance(authentication, dict): headers.update(authentication) elif callable(authentication): headers.update(authentication(url)) body = { "hostAssetIDs": hostAssetIDs } response = put(url, json=body if body else None, verify=verify, headers=headers ) 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 = None, 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': 887, 'limit': 575, 'responseCode': 200, 'count': 32, 'metaData': {'additionalProperties': {}}, 'messages': [{'message': 'Reveal even since our like line agency.', 'messageTemplate': 'Speech instead source real size factor education.', 'field': 'Raise wall their series many difference affect his.', 'parameter': {}, 'timestamp': 871427298}], 'currentPage': 413, 'size': 810} """ 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/' } if apiKey: headers["Argus-API-Key"] = apiKey elif authentication and isinstance(authentication, dict): headers.update(authentication) elif callable(authentication): headers.update(authentication(url)) body = { "hostAssetIDs": hostAssetIDs } response = put(url, json=body if body else None, verify=verify, headers=headers ) 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