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": 415, "limit": 72, "responseCode": 200, "count": 35, "data": [{"id": "Relationship Mrs something.", "ownedByUser": {"id": 865, "customerID": 112, "userName": "reginaldwilliams", "name": "Nicholas Yoder"}, "name": "Jennifer Bell", "description": "Her world cultural.", "totalCvss": 608, "vulnerabilitiesCount": 303, "createdTimestamp": 370470572, "createdByUser": {"id": 271, "customerID": 533, "userName": "anthony94", "name": "Karen Rose"}, "lastUpdatedTimestamp": 679484395, "lastUpdatedByUser": {"id": 205, "customerID": 140, "userName": "ccobb", "name": "Timothy Jackson"}, "deletedTimestamp": 1098419185, "deletedByUser": {"id": 24, "customerID": 117, "userName": "stoutangela", "name": "Daniel Lara"}, "flags": ["MISSING_FROM_CVM"], "properties": {"additionalProperties": "Recent keep team particularly sister."}, "businessProcesses": [{"id": "Glass gas life.", "name": "Mr. Jeffrey Hudson"}], "hosts": [{"id": "Change big consumer whom forget.", "name": "Jesse Garner"}]}], "metaData": {"additionalProperties": {}}, "messages": [{"message": "News occur surface.", "messageTemplate": "Learn sport boy kitchen pretty human.", "field": "Marriage try discuss thought away.", "parameter": {}, "timestamp": 67308549}], "currentPage": 691, "size": 401} """ from requests import get from argus_api.exceptions import http url = "https://osl-argus-trunk-web1.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": 660, "limit": 6, "responseCode": 200, "count": 682, "metaData": {"additionalProperties": {}}, "messages": [{"message": "Should large everyone friend itself.", "messageTemplate": "Health say find left detail.", "field": "Peace bag hotel usually fund skill free prove.", "parameter": {}, "timestamp": 613548495}], "currentPage": 726, "size": 627} """ from requests import post from argus_api.exceptions import http url = "https://osl-argus-trunk-web1.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": 159, "limit": 986, "responseCode": 200, "count": 640, "data": [{"id": "Early local operation executive.", "ownedByUser": {"id": 112, "customerID": 710, "userName": "pwilliams", "name": "Andre Duke"}, "name": "Nicole Yates", "description": "Someone book kind rock cup identify.", "totalCvss": 383, "vulnerabilitiesCount": 600, "createdTimestamp": 215130053, "createdByUser": {"id": 897, "customerID": 166, "userName": "qwilson", "name": "Jacqueline Holden"}, "lastUpdatedTimestamp": 1508074781, "lastUpdatedByUser": {"id": 82, "customerID": 730, "userName": "gilmorecameron", "name": "Jill Luna"}, "deletedTimestamp": 1006481602, "deletedByUser": {"id": 24, "customerID": 369, "userName": "katiedavenport", "name": "Christina Nguyen"}, "flags": ["UPDATED_BY_CVM"], "properties": {"additionalProperties": "Condition than animal defense Mr meet."}, "businessProcesses": [{"id": "Ever bill specific process.", "name": "Leonard Roberts"}], "hosts": [{"id": "Garden approach tax each artist.", "name": "Andrew Sloan"}]}], "metaData": {"additionalProperties": {}}, "messages": [{"message": "Poor race year may.", "messageTemplate": "Matter with exactly grow artist reason help.", "field": "Spend song player low.", "parameter": {}, "timestamp": 252457619}], "currentPage": 139, "size": 404} """ from requests import post from argus_api.exceptions import http url = "https://osl-argus-trunk-web1.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": 275, "limit": 704, "responseCode": 200, "count": 873, "metaData": {"additionalProperties": {}}, "messages": [{"message": "Where visit decide.", "messageTemplate": "Be on prepare nor ask American.", "field": "Behind paper book early.", "parameter": {}, "timestamp": 1116600417}], "currentPage": 730, "size": 249} """ from requests import get from argus_api.exceptions import http url = "https://osl-argus-trunk-web1.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": 706, "limit": 544, "responseCode": 200, "count": 4, "metaData": {"additionalProperties": {}}, "messages": [{"message": "Thus woman cold like production management.", "messageTemplate": "Consider follow picture by word sort.", "field": "Material start Republican rest yard according policy.", "parameter": {}, "timestamp": 141048487}], "currentPage": 941, "size": 782} """ from requests import put from argus_api.exceptions import http url = "https://osl-argus-trunk-web1.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": 348, "limit": 287, "responseCode": 200, "count": 580, "metaData": {"additionalProperties": {}}, "messages": [{"message": "It throw example black.", "messageTemplate": "Head concern early do room system actually.", "field": "Build key own road oil night sure.", "parameter": {}, "timestamp": 647723156}], "currentPage": 958, "size": 771} """ from requests import delete from argus_api.exceptions import http url = "https://osl-argus-trunk-web1.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": 583, "limit": 676, "responseCode": 200, "count": 320, "metaData": {"additionalProperties": {}}, "messages": [{"message": "Public answer tax address much.", "messageTemplate": "Drop day win those their.", "field": "Speak movement as spend fly.", "parameter": {}, "timestamp": 1348688965}], "currentPage": 131, "size": 388} """ from requests import put from argus_api.exceptions import http url = "https://osl-argus-trunk-web1.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": 797, "limit": 911, "responseCode": 200, "count": 751, "metaData": {"additionalProperties": {}}, "messages": [{"message": "Picture where east we social.", "messageTemplate": "Me something he build protect.", "field": "Night continue when that.", "parameter": {}, "timestamp": 311274374}], "currentPage": 908, "size": 833} """ from requests import put from argus_api.exceptions import http url = "https://osl-argus-trunk-web1.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