"""Autogenerated API"""
from argus_cli.plugin import register_command
[docs]@register_command(extending=("authentication","v1","apikey"))
def list(
json: bool = True,
verify: bool = True,
apiKey: str = None,
authentication: dict = {}
) -> dict:
"""List current user apikeys (PUBLIC)
:raises AuthenticationFailedException: on 401
:raises ValidationErrorException: on 412
:raises AccessDeniedException: on 403
:raises NotFoundException: on 404
:returns: {'offset': 883, 'limit': 56, 'responseCode': 200, 'count': 937, 'metaData': {'additionalProperties': {}}, 'messages': [{'message': 'Notice individual must air responsibility really thus until.', 'messageTemplate': 'Left budget space recent moment really several.', 'field': 'Onto order news specific.', 'parameter': {}, 'timestamp': 377017322}], 'currentPage': 769, 'size': 669}
"""
from requests import get
from argus_api.exceptions import http
url = "https://portal.mnemonic.no/web/api/authentication/v1/apikey".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 = {
}
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=("authentication","v1","apikey"))
def initiate(
password: str = None,
description: str = None,
validSources: list = None,
expirationDays: int = None,
json: bool = True,
verify: bool = True,
apiKey: str = None,
authentication: dict = {}
) -> dict:
"""Initiate a new apikey for current user (PUBLIC)
:param str password: User password to verify this request
:param str description: [\s\w\{\}\$\-\(\)\.\[\]"\'_/\\,\*\+\#:@!?;]*
:param list validSources: Client IP/CIDR networks which the api key will be valid for.
:param int expirationDays: Requested expiration days, 0 means unlimited. Default is 3 months. If user does not have permissions to specify expiration period, an error will be returned.
:raises AuthenticationFailedException: on 401
:raises ValidationErrorException: on 412
:raises AccessDeniedException: on 403
:raises NotFoundException: on 404
:returns: {'offset': 674, 'limit': 617, 'responseCode': 200, 'count': 174, 'metaData': {'additionalProperties': {}}, 'messages': [{'message': 'Grow daughter red rich weight artist fact why.', 'messageTemplate': 'Member throughout production.', 'field': 'Store mission great sit trip send white sing.', 'parameter': {}, 'timestamp': 959582511}], 'currentPage': 567, 'size': 10}
"""
from requests import post
from argus_api.exceptions import http
url = "https://portal.mnemonic.no/web/api/authentication/v1/apikey".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 = {
"password": password,
"description": description,
"validSources": validSources,
"expirationDays": expirationDays
}
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=("authentication","v1","apikey"))
def authenticate(
apikey: str = None,
json: bool = True,
verify: bool = True,
apiKey: str = None,
authentication: dict = {}
) -> dict:
"""Initiate a new user session using API key (PUBLIC)
Requires password authentication to be enabled on the server, and for the userUse /methods to check which authentication methods are available on the server.
Use this operation to create a session to last across multiple requests.This might be useful for some legacy operations which require a web session, or for performance reasons if performing a large number of requests.
End session using /logout
For one-shot requests, use Argus-API-Key header.
:param str apikey:
:raises AuthenticationFailedException: on 401
:raises ValidationErrorException: on 412
:returns: {'offset': 994, 'limit': 111, 'responseCode': 200, 'count': 788, 'metaData': {'additionalProperties': {}}, 'messages': [{'message': 'Home yeah green face.', 'messageTemplate': 'Course clearly hundred control.', 'field': 'Rock understand door century that consumer five.', 'parameter': {}, 'timestamp': 1025321583}], 'currentPage': 983, 'size': 491}
"""
from requests import post
from argus_api.exceptions import http
url = "https://portal.mnemonic.no/web/api/authentication/v1/apikey/authenticate".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 = {
"apikey": apikey
}
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=("authentication","v1","apikey"))
def renew(
keyID: int,
password: str = None,
expirationDays: int = None,
json: bool = True,
verify: bool = True,
apiKey: str = None,
authentication: dict = {}
) -> dict:
"""Renew an apikey for current user (PUBLIC)
API keys have limited validity. This operationallows the user to renew a key, to allow it to remain functional for a new validity period.
:param int keyID: Key ID
:param str password: User password to verify this request
:param int expirationDays: Requested expiration days, 0 means unlimited. Default is 3 months. If user does not have permissions to specify expiration period, an error will be returned.
:raises AuthenticationFailedException: on 401
:raises ValidationErrorException: on 412
:raises AccessDeniedException: on 403
:raises NotFoundException: on 404
:returns: {'offset': 669, 'limit': 9, 'responseCode': 200, 'count': 82, 'metaData': {'additionalProperties': {}}, 'messages': [{'message': 'Themselves government these risk nor.', 'messageTemplate': 'Art under him.', 'field': 'Important particular cut wait.', 'parameter': {}, 'timestamp': 379061703}], 'currentPage': 974, 'size': 510}
"""
from requests import put
from argus_api.exceptions import http
url = "https://portal.mnemonic.no/web/api/authentication/v1/apikey/{keyID}".format(keyID=keyID)
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 = {
"password": password,
"expirationDays": expirationDays
}
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=("authentication","v1","apikey"))
def revoke(
keyID: int,
json: bool = True,
verify: bool = True,
apiKey: str = None,
authentication: dict = {}
) -> dict:
"""Revoke an apikey from current user (PUBLIC)
:param int keyID: Key ID
:raises AuthenticationFailedException: on 401
:raises ValidationErrorException: on 412
:raises AccessDeniedException: on 403
:raises NotFoundException: on 404
:returns: {'offset': 893, 'limit': 38, 'responseCode': 200, 'count': 271, 'metaData': {'additionalProperties': {}}, 'messages': [{'message': 'Affect official themselves attorney there often.', 'messageTemplate': 'Sound production employee fish significant.', 'field': 'Against soldier ever activity.', 'parameter': {}, 'timestamp': 824269441}], 'currentPage': 331, 'size': 523}
"""
from requests import delete
from argus_api.exceptions import http
url = "https://portal.mnemonic.no/web/api/authentication/v1/apikey/{keyID}".format(keyID=keyID)
headers = {
'Content-Type': 'application/json',
'User-Agent': 'ArgusToolbelt/'
}
if apiKey:
headers["Argus-API-Key"] = apiKey
elif authentication and isinstance(authentication, dict):
headers.update(authentication)
elif callable(authentication):
headers.update(authentication(url))
body = {
}
response = delete(url,
json=body if body else None,
verify=verify,
headers=headers
)
if response.status_code == 401:
raise http.AuthenticationFailedException(response)
elif response.status_code == 403:
raise http.AccessDeniedException(response)
elif response.status_code == 412:
raise http.ValidationErrorException(response)
elif response.status_code == 404:
raise http.ObjectNotFoundException(response)
return response.json() if json else response