"""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": 193, "limit": 955, "responseCode": 200, "count": 31, "metaData": {"additionalProperties": {}}, "messages": [{"message": "Trade blood available expect stand.", "messageTemplate": "Direction figure floor local government toward other thing.", "field": "Investment receive few change work.", "parameter": {}, "timestamp": 1119492054}], "currentPage": 658, "size": 896}
"""
from requests import get
from argus_api.exceptions import http
url = "https://osl-argus-trunk-web1.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": 866, "limit": 300, "responseCode": 200, "count": 919, "metaData": {"additionalProperties": {}}, "messages": [{"message": "Seat effect draw rich here student scene.", "messageTemplate": "Call its itself.", "field": "Trade increase statement wall though.", "parameter": {}, "timestamp": 464606051}], "currentPage": 670, "size": 197}
"""
from requests import post
from argus_api.exceptions import http
url = "https://osl-argus-trunk-web1.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": 421, "limit": 836, "responseCode": 200, "count": 641, "metaData": {"additionalProperties": {}}, "messages": [{"message": "Table heart change anything maybe agree fill.", "messageTemplate": "Hundred manage company despite attention such decade run.", "field": "Suggest within back camera difference.", "parameter": {}, "timestamp": 1124936409}], "currentPage": 394, "size": 984}
"""
from requests import put
from argus_api.exceptions import http
url = "https://osl-argus-trunk-web1.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": 814, "limit": 485, "responseCode": 200, "count": 984, "metaData": {"additionalProperties": {}}, "messages": [{"message": "Fight science expert management another he.", "messageTemplate": "Write move usually where.", "field": "Question nation truth gun meeting medical their can.", "parameter": {}, "timestamp": 722646660}], "currentPage": 560, "size": 844}
"""
from requests import delete
from argus_api.exceptions import http
url = "https://osl-argus-trunk-web1.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": 426, "limit": 139, "responseCode": 200, "count": 15, "metaData": {"additionalProperties": {}}, "messages": [{"message": "Reason their kid model board new explain project.", "messageTemplate": "Back field left raise feel red together.", "field": "End ok few believe federal might.", "parameter": {}, "timestamp": 1434458661}], "currentPage": 42, "size": 637}
"""
from requests import put
from argus_api.exceptions import http
url = "https://osl-argus-trunk-web1.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": 390, "limit": 388, "responseCode": 200, "count": 658, "metaData": {"additionalProperties": {}}, "messages": [{"message": "Senior large stage consumer role.", "messageTemplate": "Woman military mission pass employee.", "field": "Either present military house property though.", "parameter": {}, "timestamp": 178346936}], "currentPage": 678, "size": 947}
"""
from requests import put
from argus_api.exceptions import http
url = "https://osl-argus-trunk-web1.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": 411, "limit": 434, "responseCode": 200, "count": 325, "metaData": {"additionalProperties": {}}, "messages": [{"message": "Probably environmental become house agent go.", "messageTemplate": "Fill interest cell discuss poor plan must.", "field": "Series garden officer.", "parameter": {}, "timestamp": 461387107}], "currentPage": 383, "size": 579}
"""
from requests import get
from argus_api.exceptions import http
url = "https://osl-argus-trunk-web1.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": 26, "limit": 505, "responseCode": 200, "count": 639, "data": [{"method": "RADIUS", "lastLoginTimestamp": 848655222, "lastLoginIP": "Prepare attack spend else ready.", "initialized": true, "settings": {"additionalProperties": {}}}], "metaData": {"additionalProperties": {}}, "messages": [{"message": "Main seek stand college city.", "messageTemplate": "Sound I his defense.", "field": "Big until nothing officer.", "parameter": {}, "timestamp": 9290182}], "currentPage": 629, "size": 616}
"""
from requests import get
from argus_api.exceptions import http
url = "https://osl-argus-trunk-web1.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