Source code for api.assets.v1.host

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


[docs]@register_command(extending=('assets','v1','host')) def search_host_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 HostAssets 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 HostAssets in the search result based on set flags :param list excludeFlag: Exclude certain HostAssets 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": 700, "limit": 500, "responseCode": 200, "count": 891, "data": [{"id": "Make the rate within experience.", "ownedByUser": {"id": 474, "customerID": 120, "userName": "matthew59", "name": "Michael Eaton"}, "name": "Patrick Rowe", "description": "But painting public pressure support.", "totalCvss": 674, "vulnerabilitiesCount": 606, "createdTimestamp": 368869034, "createdByUser": {"id": 726, "customerID": 945, "userName": "ecannon", "name": "Maria Mccann"}, "lastUpdatedTimestamp": 789883740, "lastUpdatedByUser": {"id": 298, "customerID": 669, "userName": "tara90", "name": "Paul White"}, "deletedTimestamp": 1409145582, "deletedByUser": {"id": 312, "customerID": 565, "userName": "melaniejackson", "name": "Savannah Murray"}, "flags": ["DELETED_FROM_CVM"], "properties": {"additionalProperties": "Green pay personal government white."}, "firstSeenTimestamp": 1432484279, "lastSeenTimestamp": 584590728, "lastScanTimestamp": 364529281, "ipAddresses": [{"host": true, "maskBits": 942, "ipv6": false, "multicast": true, "public": false, "address": "Talk no notice trouble that."}], "aliases": [{"fqdn": "Reason past real."}], "services": [{"id": "Method method everyone.", "name": "Leslie Brown"}], "applications": [{"id": "Education author both talk determine cell thought.", "name": "Jenna Jenkins", "description": "Less prevent road agree increase like specific recent.", "createdTimestamp": 1290910322, "lastUpdatedTimestamp": 630721363, "deletedTimestamp": 1301247431, "firstSeenTimestamp": 1022142152, "lastSeenTimestamp": 273539809, "flags": ["DELETED_FROM_CVM"], "properties": {"additionalProperties": "Compare shake under oil help too public."}, "cpe": "Authority direction responsibility argue way matter.", "sockets": ["Walk reduce level wide imagine clearly."]}], "vulnerabilities": [{"id": "Effect white system hope beautiful in.", "vulnerabilityID": "Fast up history particular.", "references": ["Direction stage investment herself."], "name": "Christine Simpson", "description": "Occur interesting claim stock.", "conclusion": "Program approach drive strong person.", "solution": "Staff wait story six.", "rawOutput": "Day better employee create single which.", "cvss": 273, "createdTimestamp": 906318467, "lastUpdatedTimestamp": 456935280, "deletedTimestamp": 310618325, "firstSeenTimestamp": 1087407926, "lastSeenTimestamp": 1409398477, "resolutionTimestamp": 243910728, "resolutionComment": "Color blood message increase describe current.", "resolution": "FALSE_POSITIVE", "flags": ["MISSING_FROM_CVM"], "properties": {"additionalProperties": "Small cup recognize."}, "severity": "medium", "socket": "Budget simply hold relationship audience reveal."}], "operatingSystemCPE": "Far least different enjoy far trouble."}], "metaData": {"additionalProperties": {}}, "messages": [{"message": "Position which feeling opportunity suffer contain throw.", "messageTemplate": "Because doctor specific police enjoy.", "field": "Hope choice news debate.", "parameter": {}, "timestamp": 1120411516}], "currentPage": 565, "size": 424} """ from requests import get from argus_api.exceptions import http url = "https://portal.mnemonic.no/web/api/assets/v1/host".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','host')) def add_host_asset(ownerID: int = None, customerID: int = None, name: str = None, description: str = None, properties: dict = None, operatingSystemCPE: str = None, ipAddresses: list = None, aliases: list = None, type: str = 'SERVER', source: str = 'USER',json: bool = True, verify: bool = True, apiKey: str = "", authentication: dict = {}) -> dict: """Creates a new HostAsset. (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\{\}\$\-\(\)\.\[\]"\'_/\\,\*\+\#:@!?;]* :param str operatingSystemCPE: CPE of the host operating system. :param list ipAddresses: IP address(es) of the host. :param list aliases: Aliases (domain names) of the host. :param str type: Defines if host is a client or a server. (default SERVER) :param str source: Source of the request. (default USER) :raises AuthenticationFailedException: on 401 :raises ValidationErrorException: on 412 :raises AccessDeniedException: on 403 :returns: {"offset": 921, "limit": 562, "responseCode": 200, "count": 827, "metaData": {"additionalProperties": {}}, "messages": [{"message": "Of baby factor notice letter perhaps.", "messageTemplate": "Loss charge garden performance military table scene.", "field": "Computer really past with.", "parameter": {}, "timestamp": 930891971}], "currentPage": 12, "size": 313} """ from requests import post from argus_api.exceptions import http url = "https://portal.mnemonic.no/web/api/assets/v1/host".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 type: body.update({"type": type}) if source: body.update({"source": source}) 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}) if operatingSystemCPE: body.update({"operatingSystemCPE": operatingSystemCPE}) if ipAddresses: body.update({"ipAddresses": ipAddresses}) if aliases: body.update({"aliases": aliases}) 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','host')) def bulk_update_host_asset(assetVulnerabilityAddRequests: list = None, assetVulnerabilityUpdateRequests: list = None, assetVulnerabilityResolveRequests: list = None, assetVulnerabilityDeleteRequests: list = None, hostApplicationAddRequests: list = None, hostApplicationUpdateRequests: list = None, hostApplicationDeleteRequests: list = None, hostAssetAddRequests: list = None, hostAssetUpdateRequests: list = None, hostAssetDeleteRequests: list = None, source: str = 'USER',json: bool = True, verify: bool = True, apiKey: str = "", authentication: dict = {}) -> dict: """Performs multiple updates to HostAssets in a single transaction. (PUBLIC) :param list assetVulnerabilityAddRequests: List of AssetVulnerabilityAddRequests. :param list assetVulnerabilityUpdateRequests: List of AssetVulnerabilityUpdateRequests. :param list assetVulnerabilityResolveRequests: List of AssetVulnerabilityResolveRequests. :param list assetVulnerabilityDeleteRequests: List of AssetVulnerabilityDeleteRequests. :param list hostApplicationAddRequests: List of HostApplicationAddRequests. :param list hostApplicationUpdateRequests: List of HostApplicationUpdateRequests. :param list hostApplicationDeleteRequests: List of HostApplicationDeleteRequests. :param list hostAssetAddRequests: List of HostAssetAddRequests. Adding vulnerabilities/applications to added hosts must be done in separate transaction. :param list hostAssetUpdateRequests: List of HostAssetUpdateRequests. :param list hostAssetDeleteRequests: List of HostAssetDeleteRequests. :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": 835, "limit": 223, "responseCode": 200, "count": 54, "metaData": {"additionalProperties": {}}, "messages": [{"message": "Music five itself find discussion claim else arrive.", "messageTemplate": "Per what action bill around.", "field": "Me walk environment describe relate civil image.", "parameter": {}, "timestamp": 671373210}], "currentPage": 652, "size": 469} """ from requests import put from argus_api.exceptions import http url = "https://portal.mnemonic.no/web/api/assets/v1/host".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 assetVulnerabilityAddRequests: body.update({"assetVulnerabilityAddRequests": assetVulnerabilityAddRequests}) if assetVulnerabilityUpdateRequests: body.update({"assetVulnerabilityUpdateRequests": assetVulnerabilityUpdateRequests}) if assetVulnerabilityResolveRequests: body.update({"assetVulnerabilityResolveRequests": assetVulnerabilityResolveRequests}) if assetVulnerabilityDeleteRequests: body.update({"assetVulnerabilityDeleteRequests": assetVulnerabilityDeleteRequests}) if hostApplicationAddRequests: body.update({"hostApplicationAddRequests": hostApplicationAddRequests}) if hostApplicationUpdateRequests: body.update({"hostApplicationUpdateRequests": hostApplicationUpdateRequests}) if hostApplicationDeleteRequests: body.update({"hostApplicationDeleteRequests": hostApplicationDeleteRequests}) if hostAssetAddRequests: body.update({"hostAssetAddRequests": hostAssetAddRequests}) if hostAssetUpdateRequests: body.update({"hostAssetUpdateRequests": hostAssetUpdateRequests}) if hostAssetDeleteRequests: body.update({"hostAssetDeleteRequests": hostAssetDeleteRequests}) 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','host')) def search_host_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, type: str = 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', includeVulnerabilityRawOutput: bool = 'False', includeVulnerabilityConclusion: bool = 'False', includeVulnerabilitySolution: bool = 'False', includeVulnerabilities: bool = 'False', includeApplications: bool = 'False', includeServices: bool = 'False', connectedToService: bool = 'False',json: bool = True, verify: bool = True, apiKey: str = "", authentication: dict = {}) -> dict: """Returns a set of HostAssets defined by a HostAssetSearchCriteria. (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 str type: Restrict search to a specific type of host (client or server). :param list timeFieldStrategy: Defines which timestamps will be included in the search (default lastUpdatedTimestamp on host). :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). :param bool includeVulnerabilityRawOutput: Include vulnerability rawOutput in result (default false). :param bool includeVulnerabilityConclusion: Include vulnerability conclusion in result (default false). :param bool includeVulnerabilitySolution: Include vulnerability solution in result (default false). :param bool includeVulnerabilities: Include host vulnerabilities in result (default false). :param bool includeApplications: Include host applications in result (default false). :param bool includeServices: Include related services in result (default false). :param bool connectedToService: If true, only return hosts connected to service(s). If false, return hosts not connected to any service. If not set, do not filter. :raises AuthenticationFailedException: on 401 :raises ValidationErrorException: on 412 :raises AccessDeniedException: on 403 :returns: {"offset": 468, "limit": 746, "responseCode": 200, "count": 364, "data": [{"id": "Arm candidate cup meeting that same cover.", "ownedByUser": {"id": 867, "customerID": 657, "userName": "kwhite", "name": "Donald Smith"}, "name": "Alexander Morgan", "description": "Exactly training treatment fund scientist born hospital.", "totalCvss": 846, "vulnerabilitiesCount": 216, "createdTimestamp": 877203316, "createdByUser": {"id": 160, "customerID": 415, "userName": "lisahopkins", "name": "Brian Armstrong"}, "lastUpdatedTimestamp": 826689143, "lastUpdatedByUser": {"id": 706, "customerID": 289, "userName": "dalvarez", "name": "William Garcia DDS"}, "deletedTimestamp": 1397817734, "deletedByUser": {"id": 136, "customerID": 381, "userName": "brian77", "name": "Mary Brown"}, "flags": ["UPDATED_BY_CVM"], "properties": {"additionalProperties": "Any class later analysis."}, "firstSeenTimestamp": 624667547, "lastSeenTimestamp": 251487487, "lastScanTimestamp": 1069334030, "ipAddresses": [{"host": false, "maskBits": 245, "ipv6": false, "multicast": true, "public": true, "address": "Room effort fish choose door talk."}], "aliases": [{"fqdn": "Career church fall fly human."}], "services": [{"id": "Around recognize enough yard similar ready.", "name": "Haley Watts"}], "applications": [{"id": "Mean important whose local space.", "name": "Tony Harper", "description": "Similar say east visit piece we.", "createdTimestamp": 784063238, "lastUpdatedTimestamp": 1493775590, "deletedTimestamp": 1168521787, "firstSeenTimestamp": 696407045, "lastSeenTimestamp": 949118185, "flags": ["MISSING_FROM_CVM"], "properties": {"additionalProperties": "Toward detail plan focus remain also hour one."}, "cpe": "Sport poor woman trial in.", "sockets": ["Science best weight prevent personal upon evening rest."]}], "vulnerabilities": [{"id": "Question under again seat into.", "vulnerabilityID": "American important whom stand let.", "references": ["Director want coach organization collection."], "name": "Jamie Clark", "description": "Prove test institution his high.", "conclusion": "Foot pay store include.", "solution": "Play least step beautiful green assume audience.", "rawOutput": "Read challenge might human.", "cvss": 935, "createdTimestamp": 228571607, "lastUpdatedTimestamp": 1348122011, "deletedTimestamp": 1107303135, "firstSeenTimestamp": 763948522, "lastSeenTimestamp": 325621442, "resolutionTimestamp": 386705016, "resolutionComment": "White role away where.", "resolution": "ACCEPTED", "flags": ["EXPLOIT_AVAILABLE"], "properties": {"additionalProperties": "Plan lead full democratic describe serious consumer."}, "severity": "high", "socket": "Contain anyone sea girl view then."}], "operatingSystemCPE": "Simply enough hotel through bar brother."}], "metaData": {"additionalProperties": {}}, "messages": [{"message": "Upon career recognize create man report.", "messageTemplate": "Tonight analysis year even.", "field": "Message pick authority pattern then.", "parameter": {}, "timestamp": 1437990416}], "currentPage": 3, "size": 285} """ from requests import post from argus_api.exceptions import http url = "https://portal.mnemonic.no/web/api/assets/v1/host/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 type: body.update({"type": type}) if timeFieldStrategy: body.update({"timeFieldStrategy": timeFieldStrategy}) if keywordFieldStrategy: body.update({"keywordFieldStrategy": keywordFieldStrategy}) if includeVulnerabilityRawOutput: body.update({"includeVulnerabilityRawOutput": includeVulnerabilityRawOutput}) if includeVulnerabilityConclusion: body.update({"includeVulnerabilityConclusion": includeVulnerabilityConclusion}) if includeVulnerabilitySolution: body.update({"includeVulnerabilitySolution": includeVulnerabilitySolution}) if includeVulnerabilities: body.update({"includeVulnerabilities": includeVulnerabilities}) if includeApplications: body.update({"includeApplications": includeApplications}) if includeServices: body.update({"includeServices": includeServices}) if connectedToService: body.update({"connectedToService": connectedToService}) 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','host')) def get_host_asset(id: str,json: bool = True, verify: bool = True, apiKey: str = "", authentication: dict = {}) -> dict: """Returns a HostAsset identified by its ID. (PUBLIC) :param str id: HostAsset ID :raises AuthenticationFailedException: on 401 :raises ValidationErrorException: on 412 :raises AccessDeniedException: on 403 :raises ObjectNotFoundException: on 404 :returns: {"offset": 23, "limit": 95, "responseCode": 200, "count": 548, "metaData": {"additionalProperties": {}}, "messages": [{"message": "Write doctor trial include loss evidence.", "messageTemplate": "Lot next hit prevent.", "field": "Control contain past both beat.", "parameter": {}, "timestamp": 831486135}], "currentPage": 241, "size": 181} """ from requests import get from argus_api.exceptions import http url = "https://portal.mnemonic.no/web/api/assets/v1/host/{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','host')) def update_host_asset(id: str, ownerID: int = None, name: str = None, description: str = None, addProperties: dict = None, deleteProperties: list = None, type: str = None, operatingSystemCPE: str = None, addIpAddresses: list = None, deleteIpAddresses: list = None, addAliases: list = None, deleteAliases: list = None, source: str = 'USER',json: bool = True, verify: bool = True, apiKey: str = "", authentication: dict = {}) -> dict: """Updates an existing HostAsset. (PUBLIC) :param str id: HostAsset 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. :param str type: Change type of host (client or server). :param str operatingSystemCPE: Change CPE of host. :param list addIpAddresses: Add IP address(es) to host. :param list deleteIpAddresses: Delete IP address(es) from host. :param list addAliases: Add alias(es) (domain names) to host. :param list deleteAliases: Delete alias(es) from host. :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": 606, "limit": 791, "responseCode": 200, "count": 193, "metaData": {"additionalProperties": {}}, "messages": [{"message": "Whether discussion detail without.", "messageTemplate": "Field off system certainly anyone political public.", "field": "Single drive charge performance soon section why.", "parameter": {}, "timestamp": 310775876}], "currentPage": 761, "size": 82} """ from requests import put from argus_api.exceptions import http url = "https://portal.mnemonic.no/web/api/assets/v1/host/{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 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}) if type: body.update({"type": type}) if operatingSystemCPE: body.update({"operatingSystemCPE": operatingSystemCPE}) if addIpAddresses: body.update({"addIpAddresses": addIpAddresses}) if deleteIpAddresses: body.update({"deleteIpAddresses": deleteIpAddresses}) if addAliases: body.update({"addAliases": addAliases}) if deleteAliases: body.update({"deleteAliases": deleteAliases}) 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','host')) def delete_host_asset(id: str, source: str = 'USER',json: bool = True, verify: bool = True, apiKey: str = "", authentication: dict = {}) -> dict: """Marks a HostAsset as deleted. (PUBLIC) :param str id: HostAsset 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": 584, "limit": 930, "responseCode": 200, "count": 529, "metaData": {"additionalProperties": {}}, "messages": [{"message": "Special building later cold discover various ahead.", "messageTemplate": "Many travel source finally must yet affect century.", "field": "Woman spring newspaper direction.", "parameter": {}, "timestamp": 322446910}], "currentPage": 516, "size": 417} """ from requests import delete from argus_api.exceptions import http url = "https://portal.mnemonic.no/web/api/assets/v1/host/{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