"""Autogenerated API"""
import requests
from argus_cli.plugin import register_command
[docs]@register_command(extending=('authentication','v1','user','apikey'))
def list(userID: int,json: bool = True, verify: bool = True, apiKey: str = "", authentication: dict = {}) -> dict:
"""List user API keys (PUBLIC)
:param int userID: ID of user
:raises AuthenticationFailedException: on 401
:raises ValidationErrorException: on 412
:raises AccessDeniedException: on 403
:raises NotFoundException: on 404
:returns: {"offset": 400, "limit": 566, "responseCode": 200, "count": 647, "metaData": {"additionalProperties": {}}, "messages": [{"message": "Indeed include listen something why or.", "messageTemplate": "People operation spring organization have election kid plan.", "field": "Huge party leave employee doctor.", "parameter": {}, "timestamp": 134388218}], "currentPage": 688, "size": 390}
"""
from requests import get
from argus_api.exceptions import http
url = "https://portal.mnemonic.no/web/api/authentication/v1/user/{userID}/apikey".format(userID=userID)
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=('authentication','v1','user','apikey'))
def initiate(userID: int, description: str = None, validSources: list = None, expirationDays: int = None,json: bool = True, verify: bool = True, apiKey: str = "", authentication: dict = {}) -> dict:
"""Initiate a new user APIkey (PUBLIC)
API keys are bound to a limited IP range. The API key initialization request must specify an IP address or subnet which the API key can be used from.Attempts to use an api key from an IP outside this IP, will result in authentication error.
To allow authentication from different IPs, issue multiple API keys.
The initiation request returns the API key, in the format it can be used both in the Argus-API-Key header, or when initiating a durable session (/apikey/authenticate).
The API key cannot be retrieved at a later stage. If the key is lost, it should be deletedand a new key should be issued.
:param int userID: ID of user
: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": 879, "limit": 463, "responseCode": 200, "count": 826, "metaData": {"additionalProperties": {}}, "messages": [{"message": "Good role sign sound again manage.", "messageTemplate": "Page size television according thought.", "field": "Husband need once against full low.", "parameter": {}, "timestamp": 199863459}], "currentPage": 401, "size": 554}
"""
from requests import post
from argus_api.exceptions import http
url = "https://portal.mnemonic.no/web/api/authentication/v1/user/{userID}/apikey".format(userID=userID)
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 description:
body.update({"description": description})
if validSources:
body.update({"validSources": validSources})
if expirationDays:
body.update({"expirationDays": expirationDays})
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=('authentication','v1','user','apikey'))
def renew(userID: int, keyID: int, expirationDays: int = None,json: bool = True, verify: bool = True, apiKey: str = "", authentication: dict = {}) -> dict:
"""Renew existing user APIkey (PUBLIC)
API keys have limited validity. This operationallows the administrator to renew a users API-key, to allow it to remain functional for a new validity period.
:param int userID: ID of user
:param int keyID: Key ID
: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": 981, "limit": 32, "responseCode": 200, "count": 342, "metaData": {"additionalProperties": {}}, "messages": [{"message": "Relationship building social week.", "messageTemplate": "Travel range behind those.", "field": "Number about kid say good long wear strategy.", "parameter": {}, "timestamp": 1063106194}], "currentPage": 897, "size": 340}
"""
from requests import put
from argus_api.exceptions import http
url = "https://portal.mnemonic.no/web/api/authentication/v1/user/{userID}/apikey/{keyID}".format(userID=userID, keyID=keyID)
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 expirationDays:
body.update({"expirationDays": expirationDays})
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=('authentication','v1','user','apikey'))
def revoke(userID: int, keyID: int,json: bool = True, verify: bool = True, apiKey: str = "", authentication: dict = {}) -> dict:
"""Delete existing user APIkey (PUBLIC)
:param int userID: ID of user
:param int keyID: Key ID
:raises AuthenticationFailedException: on 401
:raises ValidationErrorException: on 412
:raises AccessDeniedException: on 403
:raises NotFoundException: on 404
:returns: {"offset": 213, "limit": 717, "responseCode": 200, "count": 97, "metaData": {"additionalProperties": {}}, "messages": [{"message": "Character teacher compare behavior.", "messageTemplate": "Require the cost cover you second.", "field": "You enter trip they effort.", "parameter": {}, "timestamp": 191544647}], "currentPage": 500, "size": 986}
"""
from requests import delete
from argus_api.exceptions import http
url = "https://portal.mnemonic.no/web/api/authentication/v1/user/{userID}/apikey/{keyID}".format(userID=userID, keyID=keyID)
headers = {
'Content-Type': 'application/json',
'User-Agent': 'ArgusToolbelt/1.0'
}
if apiKey:
headers["Argus-API-Key"] = apiKey
elif authentication and isinstance(authentication, dict):
headers.update(authentication)
elif callable(authentication):
headers.update(authentication(url))
body = {}
response = delete(url, json=body if body else None, verify=verify, headers=headers)
errors = []
if response.status_code == 401:
raise http.AuthenticationFailedException(response)
elif response.status_code == 403:
raise http.AccessDeniedException(response)
elif response.status_code == 412:
raise http.ValidationErrorException(response)
elif response.status_code == 404:
raise http.ObjectNotFoundException(response)
return response.json() if json else response
[docs]@register_command(extending=('authentication','v1','user','apikey'))
def disable_method_for_user(userID: int, method: str,json: bool = True, verify: bool = True, apiKey: str = "", authentication: dict = {}) -> dict:
"""Disable an authentication method for a user (PUBLIC)
:param int userID: ID of user to modify
:param str method: Authentication method to enable
:raises AuthenticationFailedException: on 401
:raises ValidationFailedException: on 412
:raises AccessDeniedException: on 403
:raises UserNotFoundException: on 404
:returns: {"offset": 629, "limit": 102, "responseCode": 200, "count": 906, "metaData": {"additionalProperties": {}}, "messages": [{"message": "Ago every beyond school church project end fear.", "messageTemplate": "Able look can continue control.", "field": "Marriage actually listen method now.", "parameter": {}, "timestamp": 232574749}], "currentPage": 379, "size": 793}
"""
from requests import put
from argus_api.exceptions import http
url = "https://portal.mnemonic.no/web/api/authentication/v1/user/{userID}/disable/{method}".format(userID=userID, method=method)
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 = 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=('authentication','v1','user','apikey'))
def enable_method_for_user(userID: int, method: str,json: bool = True, verify: bool = True, apiKey: str = "", authentication: dict = {}) -> dict:
"""Enable an authentication method for a user (PUBLIC)
:param int userID: ID of user to modify
:param str method: Authentication method to enable
:raises AuthenticationFailedException: on 401
:raises ValidationFailedException: on 412
:raises AccessDeniedException: on 403
:raises UserNotFoundException: on 404
:returns: {"offset": 434, "limit": 1, "responseCode": 200, "count": 913, "metaData": {"additionalProperties": {}}, "messages": [{"message": "Billion firm high property middle instead serious someone.", "messageTemplate": "Discover various evening war it assume black.", "field": "Nor respond dog.", "parameter": {}, "timestamp": 976807680}], "currentPage": 633, "size": 523}
"""
from requests import put
from argus_api.exceptions import http
url = "https://portal.mnemonic.no/web/api/authentication/v1/user/{userID}/enable/{method}".format(userID=userID, method=method)
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 = 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=('authentication','v1','user','apikey'))
def retrieve_s_m_s_token(userID: int, tokenSuffix: str,json: bool = True, verify: bool = True, apiKey: str = "", authentication: dict = {}) -> dict:
"""Retrieve the SMS code sent to user (PUBLIC)
SMS authentication depends on the verification code sent to the user by SMS reachingthe user. When this does not happen, this method allows an administrator to retrieve the SMS code to provide the user by phone.
To retrieve the token, the user must provide the administrator with thesession token printed in the browser in the SMS code input screen.
:param int userID: User ID
:param str tokenSuffix: Token suffix
:raises AuthenticationFailedException: on 401
:raises ValidationErrorException: on 412
:raises AccessDeniedException: on 403
:raises NotFoundException: on 404
:returns: {"offset": 978, "limit": 791, "responseCode": 200, "count": 516, "metaData": {"additionalProperties": {}}, "messages": [{"message": "More conference example stop eight kind.", "messageTemplate": "Fact adult social less.", "field": "Technology brother activity great true treat have.", "parameter": {}, "timestamp": 1419336264}], "currentPage": 394, "size": 143}
"""
from requests import get
from argus_api.exceptions import http
url = "https://portal.mnemonic.no/web/api/authentication/v1/user/{userID}/sms/token/{tokenSuffix}".format(userID=userID, tokenSuffix=tokenSuffix)
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=('authentication','v1','user','apikey'))
def get_user_methods(userId: int,json: bool = True, verify: bool = True, apiKey: str = "", authentication: dict = {}) -> dict:
"""List authentication methods enabled for a specified user (PUBLIC)
:param int userId: User to fetch methods for
:raises AuthenticationFailedException: on 401
:raises AccessDeniedException: on 403
:raises UserNotFoundException: on 404
:returns: {"offset": 4, "limit": 414, "responseCode": 200, "count": 220, "data": [{"method": "SIGNATURE", "lastLoginTimestamp": 856951436, "lastLoginIP": "Card interesting group material role child.", "initialized": false, "settings": {"additionalProperties": {}}}], "metaData": {"additionalProperties": {}}, "messages": [{"message": "May let make.", "messageTemplate": "Question front adult town thank professional.", "field": "Mouth their watch however pay management suggest.", "parameter": {}, "timestamp": 420537912}], "currentPage": 926, "size": 396}
"""
from requests import get
from argus_api.exceptions import http
url = "https://portal.mnemonic.no/web/api/authentication/v1/user/{userId}/methods".format(userId=userId)
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