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": 507, "limit": 118, "responseCode": 200, "count": 96, "data": [{"id": "Either need practice weight me people some.", "ownedByUser": {"id": 663, "customerID": 343, "userName": "john95", "name": "Ryan Richards"}, "name": "Steven Wood", "description": "Garden central friend employee onto moment.", "totalCvss": 386, "vulnerabilitiesCount": 721, "createdTimestamp": 504845559, "createdByUser": {"id": 236, "customerID": 572, "userName": "gatestamara", "name": "Miss Jessica Myers"}, "lastUpdatedTimestamp": 1198345314, "lastUpdatedByUser": {"id": 785, "customerID": 351, "userName": "ipadilla", "name": "David Knight"}, "deletedTimestamp": 1385236381, "deletedByUser": {"id": 589, "customerID": 317, "userName": "dalebowen", "name": "Steven Sullivan"}, "flags": ["DELETED"], "properties": {"additionalProperties": "Four yourself right owner."}, "firstSeenTimestamp": 895616699, "lastSeenTimestamp": 303175482, "lastScanTimestamp": 1306160240, "ipAddresses": [{"host": false, "maskBits": 149, "ipv6": true, "multicast": true, "public": false, "address": "Heavy live eight miss great well push."}], "aliases": [{"fqdn": "Mouth bill safe Mr."}], "services": [{"id": "Design difference expert second wish field.", "name": "Michael Sullivan"}], "applications": [{"id": "Run knowledge also despite power quite.", "name": "Samuel Bass", "description": "Case approach there why sing marriage strategy suffer.", "createdTimestamp": 635722591, "lastUpdatedTimestamp": 2617576, "deletedTimestamp": 2814425, "firstSeenTimestamp": 711605920, "lastSeenTimestamp": 322666376, "flags": ["MISSING_FROM_CVM"], "properties": {"additionalProperties": "Participant free development my policy soon any."}, "cpe": "Item would note begin term.", "sockets": ["Know least whom what good hundred."]}], "vulnerabilities": [{"id": "Blue politics tough state.", "vulnerabilityID": "Could chance performance edge tell probably.", "references": ["Eight record road current."], "name": "Terrance Lee", "description": "Week sign cup where sister just participant.", "conclusion": "Car level parent society thank scientist.", "solution": "Us along kind increase fly market manager.", "rawOutput": "Capital pretty behind quality world.", "cvss": 950, "createdTimestamp": 750195419, "lastUpdatedTimestamp": 829967952, "deletedTimestamp": 465276206, "firstSeenTimestamp": 485124631, "lastSeenTimestamp": 1041173878, "resolutionTimestamp": 939993144, "resolutionComment": "Forget system exist sound defense beautiful result particular.", "resolution": "UNRESOLVED", "flags": ["CREATED_BY_CVM"], "properties": {"additionalProperties": "Attorney sound event describe rock blood break country."}, "severity": "info", "socket": "Seek wear consumer degree economy as."}], "operatingSystemCPE": "Some part writer our raise theory born smile."}], "metaData": {"additionalProperties": {}}, "messages": [{"message": "Recognize skill wonder professor film take able economic.", "messageTemplate": "Say range message eat behind not.", "field": "Dinner region treatment mention.", "parameter": {}, "timestamp": 51701074}], "currentPage": 173, "size": 507} """ from requests import get from argus_api.exceptions import http url = "https://osl-argus-trunk-web1.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": 1, "limit": 537, "responseCode": 200, "count": 519, "metaData": {"additionalProperties": {}}, "messages": [{"message": "Say different again happy main north.", "messageTemplate": "Culture husband design.", "field": "Natural number million moment others think religious indicate.", "parameter": {}, "timestamp": 801805390}], "currentPage": 847, "size": 892} """ from requests import post from argus_api.exceptions import http url = "https://osl-argus-trunk-web1.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": 63, "limit": 650, "responseCode": 200, "count": 443, "metaData": {"additionalProperties": {}}, "messages": [{"message": "Yes line high beyond time water require.", "messageTemplate": "Sort effect market bill.", "field": "Ago choice wait lay service training small.", "parameter": {}, "timestamp": 500036626}], "currentPage": 7, "size": 583} """ from requests import put from argus_api.exceptions import http url = "https://osl-argus-trunk-web1.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": 264, "limit": 131, "responseCode": 200, "count": 260, "data": [{"id": "Investment probably decision country yard worker term together.", "ownedByUser": {"id": 153, "customerID": 996, "userName": "brian88", "name": "William Lee"}, "name": "Maureen Ortiz", "description": "We speak special good.", "totalCvss": 277, "vulnerabilitiesCount": 558, "createdTimestamp": 1132686718, "createdByUser": {"id": 621, "customerID": 164, "userName": "austin44", "name": "Andrea Alexander"}, "lastUpdatedTimestamp": 423351883, "lastUpdatedByUser": {"id": 618, "customerID": 249, "userName": "fuentesmegan", "name": "Michael Mckee"}, "deletedTimestamp": 59328897, "deletedByUser": {"id": 573, "customerID": 80, "userName": "donnavasquez", "name": "Jose Vazquez"}, "flags": ["DETECTED_BY_CVM"], "properties": {"additionalProperties": "Bar finally girl hotel movie happen actually."}, "firstSeenTimestamp": 358990782, "lastSeenTimestamp": 135112269, "lastScanTimestamp": 1300540895, "ipAddresses": [{"host": true, "maskBits": 52, "ipv6": true, "multicast": true, "public": true, "address": "Low nor later close time why."}], "aliases": [{"fqdn": "Put truth great might."}], "services": [{"id": "Whole even short choose step stand.", "name": "Richard Young"}], "applications": [{"id": "Man author middle own six past trouble.", "name": "Rebecca Duncan", "description": "Ground yard nearly single majority where.", "createdTimestamp": 669391324, "lastUpdatedTimestamp": 1422566856, "deletedTimestamp": 1420996974, "firstSeenTimestamp": 424585522, "lastSeenTimestamp": 1290594798, "flags": ["UPDATED_BY_CVM"], "properties": {"additionalProperties": "Economic eight far away run shoulder."}, "cpe": "Today half task want.", "sockets": ["Try international structure knowledge nearly growth accept."]}], "vulnerabilities": [{"id": "Probably bar place.", "vulnerabilityID": "Husband black course newspaper forward way name.", "references": ["Money end huge body cup identify."], "name": "Donna Oneal", "description": "Into she why.", "conclusion": "Yet be air again from.", "solution": "Office himself think current possible wife your.", "rawOutput": "Sort reality public able real.", "cvss": 386, "createdTimestamp": 751571948, "lastUpdatedTimestamp": 1181158461, "deletedTimestamp": 226309301, "firstSeenTimestamp": 952168912, "lastSeenTimestamp": 235697233, "resolutionTimestamp": 1257904148, "resolutionComment": "Almost at hair.", "resolution": "NO_LONGER_VULNERABLE", "flags": ["DELETED_FROM_CVM"], "properties": {"additionalProperties": "Reveal already similar market."}, "severity": "medium", "socket": "Mouth each job father strong."}], "operatingSystemCPE": "Personal teach side behavior first."}], "metaData": {"additionalProperties": {}}, "messages": [{"message": "Material paper great mean sometimes whose.", "messageTemplate": "Per research end personal eight order.", "field": "Team whose customer around expert wide movement win.", "parameter": {}, "timestamp": 897649906}], "currentPage": 374, "size": 249} """ from requests import post from argus_api.exceptions import http url = "https://osl-argus-trunk-web1.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": 15, "limit": 998, "responseCode": 200, "count": 991, "metaData": {"additionalProperties": {}}, "messages": [{"message": "Your those pattern perhaps.", "messageTemplate": "Seem social maybe network suggest affect.", "field": "Little idea themselves while figure trip.", "parameter": {}, "timestamp": 752167821}], "currentPage": 129, "size": 637} """ from requests import get from argus_api.exceptions import http url = "https://osl-argus-trunk-web1.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": 38, "limit": 343, "responseCode": 200, "count": 410, "metaData": {"additionalProperties": {}}, "messages": [{"message": "Along ok require spring occur happen.", "messageTemplate": "Security discussion mind art whose similar throughout.", "field": "They movie huge be.", "parameter": {}, "timestamp": 484096583}], "currentPage": 433, "size": 769} """ from requests import put from argus_api.exceptions import http url = "https://osl-argus-trunk-web1.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": 682, "limit": 963, "responseCode": 200, "count": 412, "metaData": {"additionalProperties": {}}, "messages": [{"message": "Determine rest standard.", "messageTemplate": "Culture red out vote challenge total.", "field": "Still main defense without kind water area.", "parameter": {}, "timestamp": 31594892}], "currentPage": 380, "size": 46} """ from requests import delete from argus_api.exceptions import http url = "https://osl-argus-trunk-web1.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