"""Autogenerated API"""
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 = None,
limit: int = 25,
keywordMatch: str = "all",
json: bool = True,
verify: bool = True,
apiKey: str = None,
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': 395, 'limit': 426, 'responseCode': 200, 'count': 878, 'data': [{'id': 'Those thought former turn least per near.', 'ownedByUser': {'id': 166, 'customerID': 607, 'userName': 'matthew06', 'name': 'Nicholas Martinez'}, 'name': 'Taylor Henderson', 'description': 'Congress record return guess play.', 'totalCvss': 364, 'vulnerabilitiesCount': 647, 'createdTimestamp': 670655087, 'createdByUser': {'id': 392, 'customerID': 573, 'userName': 'hlee', 'name': 'Wendy Leonard'}, 'lastUpdatedTimestamp': 1276691337, 'lastUpdatedByUser': {'id': 500, 'customerID': 411, 'userName': 'fullerjohn', 'name': 'Jillian Jensen'}, 'deletedTimestamp': 1179079842, 'deletedByUser': {'id': 361, 'customerID': 419, 'userName': 'jonathanbutler', 'name': 'Jacqueline Ruiz'}, 'flags': ['MISSING_FROM_CVM'], 'properties': {'additionalProperties': 'Professional mission account anything we follow.'}, 'firstSeenTimestamp': 12933564, 'lastSeenTimestamp': 44080731, 'lastScanTimestamp': 1508773092, 'ipAddresses': [{'host': False, 'maskBits': 514, 'ipv6': True, 'multicast': False, 'public': True, 'address': 'Son find south tell.'}], 'aliases': [{'fqdn': 'Run already oil member floor data.'}], 'services': [{'id': 'Respond get party professional region.', 'name': 'Kathy Harris'}], 'applications': [{'id': 'Of reality environment particular.', 'name': 'Debra Moore', 'description': 'Thousand religious city care.', 'createdTimestamp': 1473774753, 'lastUpdatedTimestamp': 319793551, 'deletedTimestamp': 1434276536, 'firstSeenTimestamp': 586121112, 'lastSeenTimestamp': 221816753, 'flags': ['CONTROLLED_VERSION'], 'properties': {'additionalProperties': 'Owner perhaps drop mouth.'}, 'cpe': 'Difficult continue participant financial.', 'sockets': ['Former enjoy often.']}], 'vulnerabilities': [{'id': 'Allow part occur rise another account.', 'vulnerabilityID': 'Message shoulder leave campaign.', 'references': ['Push miss attorney.'], 'name': 'Kevin Leon', 'description': 'Whatever rest newspaper travel parent source manager.', 'conclusion': 'Usually now national child cultural indeed.', 'solution': 'Home reality voice mouth try green war the.', 'rawOutput': 'Let everyone learn stay.', 'cvss': 969, 'createdTimestamp': 1267329465, 'lastUpdatedTimestamp': 1151314183, 'deletedTimestamp': 1106196342, 'firstSeenTimestamp': 65585162, 'lastSeenTimestamp': 679906854, 'resolutionTimestamp': 847398257, 'resolutionComment': 'End purpose offer run true.', 'resolution': 'UNRESOLVED', 'flags': ['DETECTED_BY_CVM'], 'properties': {'additionalProperties': 'Morning market list yard base image fact.'}, 'severity': 'info', 'socket': 'Up head effect of.'}], 'operatingSystemCPE': 'Happen safe question operation feeling.'}], 'metaData': {'additionalProperties': {}}, 'messages': [{'message': 'Him world same.', 'messageTemplate': 'Get realize wait leg spring fish first.', 'field': 'Collection team difficult after.', 'parameter': {}, 'timestamp': 821353051}], 'currentPage': 826, 'size': 676}
"""
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/'
}
if apiKey:
headers["Argus-API-Key"] = apiKey
elif authentication and isinstance(authentication, dict):
headers.update(authentication)
elif callable(authentication):
headers.update(authentication(url))
body = {
"offset": offset,
"limit": limit,
"keywordMatch": keywordMatch,
"keywords": keywords,
"keywordField": keywordField,
"name": name,
"hostID": hostID,
"serviceID": serviceID,
"businessProcessID": businessProcessID,
"customerID": customerID,
"ip": ip,
"port": port,
"protocol": protocol,
"cpe": cpe,
"vulnID": vulnID,
"vulnRef": vulnRef,
"includeFlag": includeFlag,
"excludeFlag": excludeFlag,
"sortBy": sortBy
}
response = get(url,
json=body if body else None,
verify=verify,
headers=headers
)
if response.status_code == 401:
raise http.AuthenticationFailedException(response)
elif response.status_code == 403:
raise http.AccessDeniedException(response)
elif response.status_code == 412:
raise http.ValidationErrorException(response)
elif response.status_code == 404:
raise http.ObjectNotFoundException(response)
return response.json() if json else response
[docs]@register_command(extending=("assets","v1","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 = None,
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': 52, 'limit': 251, 'responseCode': 200, 'count': 652, 'metaData': {'additionalProperties': {}}, 'messages': [{'message': 'Agreement able head.', 'messageTemplate': 'Size voice read actually just interview picture financial.', 'field': 'Explain right together.', 'parameter': {}, 'timestamp': 231690513}], 'currentPage': 209, 'size': 826}
"""
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/'
}
if apiKey:
headers["Argus-API-Key"] = apiKey
elif authentication and isinstance(authentication, dict):
headers.update(authentication)
elif callable(authentication):
headers.update(authentication(url))
body = {
"type": type,
"source": source,
"ownerID": ownerID,
"customerID": customerID,
"name": name,
"description": description,
"properties": properties,
"operatingSystemCPE": operatingSystemCPE,
"ipAddresses": ipAddresses,
"aliases": aliases
}
response = post(url,
json=body if body else None,
verify=verify,
headers=headers
)
if response.status_code == 401:
raise http.AuthenticationFailedException(response)
elif response.status_code == 403:
raise http.AccessDeniedException(response)
elif response.status_code == 412:
raise http.ValidationErrorException(response)
elif response.status_code == 404:
raise http.ObjectNotFoundException(response)
return response.json() if json else response
[docs]@register_command(extending=("assets","v1","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 = None,
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': 997, 'limit': 365, 'responseCode': 200, 'count': 723, 'metaData': {'additionalProperties': {}}, 'messages': [{'message': 'Style cut court their.', 'messageTemplate': 'Law around woman ok.', 'field': 'Over field lead test board road.', 'parameter': {}, 'timestamp': 374872856}], 'currentPage': 372, 'size': 363}
"""
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/'
}
if apiKey:
headers["Argus-API-Key"] = apiKey
elif authentication and isinstance(authentication, dict):
headers.update(authentication)
elif callable(authentication):
headers.update(authentication(url))
body = {
"source": source,
"assetVulnerabilityAddRequests": assetVulnerabilityAddRequests,
"assetVulnerabilityUpdateRequests": assetVulnerabilityUpdateRequests,
"assetVulnerabilityResolveRequests": assetVulnerabilityResolveRequests,
"assetVulnerabilityDeleteRequests": assetVulnerabilityDeleteRequests,
"hostApplicationAddRequests": hostApplicationAddRequests,
"hostApplicationUpdateRequests": hostApplicationUpdateRequests,
"hostApplicationDeleteRequests": hostApplicationDeleteRequests,
"hostAssetAddRequests": hostAssetAddRequests,
"hostAssetUpdateRequests": hostAssetUpdateRequests,
"hostAssetDeleteRequests": hostAssetDeleteRequests
}
response = put(url,
json=body if body else None,
verify=verify,
headers=headers
)
if response.status_code == 401:
raise http.AuthenticationFailedException(response)
elif response.status_code == 403:
raise http.AccessDeniedException(response)
elif response.status_code == 412:
raise http.ValidationErrorException(response)
elif response.status_code == 404:
raise http.ObjectNotFoundException(response)
return response.json() if json else response
[docs]@register_command(extending=("assets","v1","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 = None,
exclude: bool = None,
required: bool = None,
includeVulnerabilityRawOutput: bool = None,
includeVulnerabilityConclusion: bool = None,
includeVulnerabilitySolution: bool = None,
includeVulnerabilities: bool = None,
includeApplications: bool = None,
includeServices: bool = None,
connectedToService: bool = None,
json: bool = True,
verify: bool = True,
apiKey: str = None,
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': 538, 'limit': 281, 'responseCode': 200, 'count': 821, 'data': [{'id': 'Page shoulder cultural relationship great responsibility himself.', 'ownedByUser': {'id': 298, 'customerID': 455, 'userName': 'aaron86', 'name': 'Gloria Woods'}, 'name': 'Aaron Hughes', 'description': 'Economy choice unit.', 'totalCvss': 654, 'vulnerabilitiesCount': 897, 'createdTimestamp': 672179060, 'createdByUser': {'id': 425, 'customerID': 583, 'userName': 'zponce', 'name': 'Aaron Johnson'}, 'lastUpdatedTimestamp': 314636528, 'lastUpdatedByUser': {'id': 407, 'customerID': 678, 'userName': 'wwolfe', 'name': 'Maria Phillips'}, 'deletedTimestamp': 618587141, 'deletedByUser': {'id': 248, 'customerID': 761, 'userName': 'justin71', 'name': 'Ms. Shannon Wilson'}, 'flags': ['CREATED_BY_CVM'], 'properties': {'additionalProperties': 'Expect perform miss.'}, 'firstSeenTimestamp': 1265030626, 'lastSeenTimestamp': 1154042419, 'lastScanTimestamp': 1461106155, 'ipAddresses': [{'host': False, 'maskBits': 375, 'ipv6': True, 'multicast': False, 'public': False, 'address': 'Operation major technology seat stay lose.'}], 'aliases': [{'fqdn': 'Nothing hand pressure friend need.'}], 'services': [{'id': 'Likely school produce indicate.', 'name': 'Marcia Martinez'}], 'applications': [{'id': 'Try little region career moment blue reality price.', 'name': 'Raymond Rush', 'description': 'Improve seem me individual.', 'createdTimestamp': 198237260, 'lastUpdatedTimestamp': 1294782591, 'deletedTimestamp': 576509307, 'firstSeenTimestamp': 137337230, 'lastSeenTimestamp': 1500240908, 'flags': ['UPDATED_BY_CVM'], 'properties': {'additionalProperties': 'Radio building order identify everyone over policy.'}, 'cpe': 'Attorney foot like company.', 'sockets': ['Various happy none about window.']}], 'vulnerabilities': [{'id': 'Fill human happen particularly body throw.', 'vulnerabilityID': 'Feeling occur scientist pressure garden for.', 'references': ['Read card bad imagine.'], 'name': 'Catherine Andrews', 'description': 'Discuss break chance huge tell.', 'conclusion': 'Down leader fight simple fund.', 'solution': 'Arrive light issue write.', 'rawOutput': 'Conference anything sign beyond build manager.', 'cvss': 582, 'createdTimestamp': 729559987, 'lastUpdatedTimestamp': 1292555180, 'deletedTimestamp': 1323324791, 'firstSeenTimestamp': 1288476556, 'lastSeenTimestamp': 60099858, 'resolutionTimestamp': 904356071, 'resolutionComment': 'Structure opportunity road law against identify.', 'resolution': 'ACCEPTED', 'flags': ['MISSING_FROM_CVM'], 'properties': {'additionalProperties': 'Night born evidence mother because.'}, 'severity': 'medium', 'socket': 'Pretty back foreign suffer deal no mouth.'}], 'operatingSystemCPE': 'Since character within professor.'}], 'metaData': {'additionalProperties': {}}, 'messages': [{'message': 'Tree reason program approach see think age.', 'messageTemplate': 'Director practice campaign require discussion.', 'field': 'Next detail event claim open fight.', 'parameter': {}, 'timestamp': 393846466}], 'currentPage': 999, 'size': 835}
"""
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/'
}
if apiKey:
headers["Argus-API-Key"] = apiKey
elif authentication and isinstance(authentication, dict):
headers.update(authentication)
elif callable(authentication):
headers.update(authentication(url))
body = {
"limit": limit,
"offset": offset,
"includeDeleted": includeDeleted,
"subCriteria": subCriteria,
"exclude": exclude,
"required": required,
"customerID": customerID,
"name": name,
"startTimestamp": startTimestamp,
"endTimestamp": endTimestamp,
"keywords": keywords,
"keywordMatchStrategy": keywordMatchStrategy,
"timeMatchStrategy": timeMatchStrategy,
"hostID": hostID,
"serviceID": serviceID,
"businessProcessID": businessProcessID,
"ipRange": ipRange,
"applicationPort": applicationPort,
"applicationProtocol": applicationProtocol,
"cpe": cpe,
"hostCPE": hostCPE,
"applicationCPE": applicationCPE,
"ownerID": ownerID,
"criticality": criticality,
"minimumTotalCvss": minimumTotalCvss,
"maximumTotalCvss": maximumTotalCvss,
"vulnerabilityReference": vulnerabilityReference,
"vulnerabilityID": vulnerabilityID,
"applicationRole": applicationRole,
"type": type,
"timeFieldStrategy": timeFieldStrategy,
"keywordFieldStrategy": keywordFieldStrategy,
"includeVulnerabilityRawOutput": includeVulnerabilityRawOutput,
"includeVulnerabilityConclusion": includeVulnerabilityConclusion,
"includeVulnerabilitySolution": includeVulnerabilitySolution,
"includeVulnerabilities": includeVulnerabilities,
"includeApplications": includeApplications,
"includeServices": includeServices,
"connectedToService": connectedToService,
"sortBy": sortBy,
"includeFlags": includeFlags,
"excludeFlags": excludeFlags
}
response = post(url,
json=body if body else None,
verify=verify,
headers=headers
)
if response.status_code == 401:
raise http.AuthenticationFailedException(response)
elif response.status_code == 403:
raise http.AccessDeniedException(response)
elif response.status_code == 412:
raise http.ValidationErrorException(response)
elif response.status_code == 404:
raise http.ObjectNotFoundException(response)
return response.json() if json else response
[docs]@register_command(extending=("assets","v1","host"))
def get_host_asset(
id: str,
json: bool = True,
verify: bool = True,
apiKey: str = None,
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': 62, 'limit': 696, 'responseCode': 200, 'count': 71, 'metaData': {'additionalProperties': {}}, 'messages': [{'message': 'Worker within budget week usually meeting cause.', 'messageTemplate': 'Woman suddenly between.', 'field': 'Man radio natural kind.', 'parameter': {}, 'timestamp': 1140189263}], 'currentPage': 66, 'size': 946}
"""
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/'
}
if apiKey:
headers["Argus-API-Key"] = apiKey
elif authentication and isinstance(authentication, dict):
headers.update(authentication)
elif callable(authentication):
headers.update(authentication(url))
body = {
}
response = get(url,
json=body if body else None,
verify=verify,
headers=headers
)
if response.status_code == 401:
raise http.AuthenticationFailedException(response)
elif response.status_code == 403:
raise http.AccessDeniedException(response)
elif response.status_code == 412:
raise http.ValidationErrorException(response)
elif response.status_code == 404:
raise http.ObjectNotFoundException(response)
return response.json() if json else response
[docs]@register_command(extending=("assets","v1","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 = None,
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': 116, 'limit': 485, 'responseCode': 200, 'count': 544, 'metaData': {'additionalProperties': {}}, 'messages': [{'message': 'Through mention whatever a.', 'messageTemplate': 'Citizen will describe safe season camera smile.', 'field': 'Employee audience issue land major compare.', 'parameter': {}, 'timestamp': 230211509}], 'currentPage': 466, 'size': 124}
"""
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/'
}
if apiKey:
headers["Argus-API-Key"] = apiKey
elif authentication and isinstance(authentication, dict):
headers.update(authentication)
elif callable(authentication):
headers.update(authentication(url))
body = {
"source": source,
"ownerID": ownerID,
"name": name,
"description": description,
"addProperties": addProperties,
"deleteProperties": deleteProperties,
"type": type,
"operatingSystemCPE": operatingSystemCPE,
"addIpAddresses": addIpAddresses,
"deleteIpAddresses": deleteIpAddresses,
"addAliases": addAliases,
"deleteAliases": deleteAliases
}
response = put(url,
json=body if body else None,
verify=verify,
headers=headers
)
if response.status_code == 401:
raise http.AuthenticationFailedException(response)
elif response.status_code == 403:
raise http.AccessDeniedException(response)
elif response.status_code == 412:
raise http.ValidationErrorException(response)
elif response.status_code == 404:
raise http.ObjectNotFoundException(response)
return response.json() if json else response
[docs]@register_command(extending=("assets","v1","host"))
def delete_host_asset(
id: str,
source: str = "USER",
json: bool = True,
verify: bool = True,
apiKey: str = None,
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': 323, 'limit': 205, 'responseCode': 200, 'count': 853, 'metaData': {'additionalProperties': {}}, 'messages': [{'message': 'Black tonight nearly professional physical spring opportunity.', 'messageTemplate': 'Those understand career prove story.', 'field': 'Pay skin yes past course process without.', 'parameter': {}, 'timestamp': 919979182}], 'currentPage': 87, 'size': 84}
"""
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/'
}
if apiKey:
headers["Argus-API-Key"] = apiKey
elif authentication and isinstance(authentication, dict):
headers.update(authentication)
elif callable(authentication):
headers.update(authentication(url))
body = {
"source": source
}
response = delete(url,
json=body if body else None,
verify=verify,
headers=headers
)
if response.status_code == 401:
raise http.AuthenticationFailedException(response)
elif response.status_code == 403:
raise http.AccessDeniedException(response)
elif response.status_code == 412:
raise http.ValidationErrorException(response)
elif response.status_code == 404:
raise http.ObjectNotFoundException(response)
return response.json() if json else response