Source code for api.authentication.v1.totp

"""Autogenerated API"""
import requests
from argus_cli.plugin import register_command


[docs]@register_command(extending=('authentication','v1','totp')) def initialize(password: str = None,json: bool = True, verify: bool = True, apiKey: str = "", authentication: dict = {}) -> dict: """Initiate a new TOTP generator for the user (PUBLIC) TOTP authentication requires a TOTP generator to be set up for the user. This operation allows the user to set up a TOTP generator. This requires TOTP authentication to be enabled for the user. The TOTP initialization request also requires the user to providethe static Argus password for verification. The TOTP generator code retrieved cannot be retrieved again. It should be added directly to the TOTP generator, and should not be stored elsewhere. After initializing, the new TOTP generator is in a pending state, and will notbe active until it is verified using the verification operation. :param str password: User password to verify this request :raises AuthenticationFailedException: on 401 :raises ValidationErrorException: on 412 :raises AccessDeniedException: on 403 :raises NotFoundException: on 404 :returns: {"offset": 56, "limit": 267, "responseCode": 200, "count": 916, "metaData": {"additionalProperties": {}}, "messages": [{"message": "Firm throw parent five move law total.", "messageTemplate": "Ten already say tell serve wide executive.", "field": "More far with between every long would particular.", "parameter": {}, "timestamp": 293626485}], "currentPage": 179, "size": 338} """ from requests import post from argus_api.exceptions import http url = "https://osl-argus-trunk-web1.mnemonic.no/web/api/authentication/v1/totp".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 password: body.update({"password": password}) 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','totp')) def verify(cookie: str = None, verificationCode: str = None,json: bool = True, verify: bool = True, apiKey: str = "", authentication: dict = {}) -> dict: """Verify the pending TOTP generator for the user (PUBLIC) This operation will activate the pending generator.The verification request should contain the cookie returned from theinitialize command, as well as the current generated code. If the user has an existing generator, successfully validatingthe pending generator will invalidate the existing generator. :param str cookie: The cookie returned by the TOTP initialization request :param str verificationCode: Current code from TOTP generator, to verify correctly generated TOTP code :raises AuthenticationFailedException: on 401 :raises ValidationErrorException: on 412 :raises AccessDeniedException: on 403 :raises NotFoundException: on 404 :returns: {"offset": 497, "limit": 819, "responseCode": 200, "count": 54, "metaData": {"additionalProperties": {}}, "messages": [{"message": "Score value already commercial.", "messageTemplate": "Do according trip color great reflect.", "field": "If eat sea stay themselves.", "parameter": {}, "timestamp": 1304273238}], "currentPage": 808, "size": 788} """ from requests import put from argus_api.exceptions import http url = "https://osl-argus-trunk-web1.mnemonic.no/web/api/authentication/v1/totp".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 cookie: body.update({"cookie": cookie}) if verificationCode: body.update({"verificationCode": verificationCode}) 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','totp')) def revoke(json: bool = True, verify: bool = True, apiKey: str = "", authentication: dict = {}) -> dict: """Revoke the current TOTP generator for the user (PUBLIC) This operation invalidates the current generator config for the user. The user will need to re-initialize the TOTP generator to be able to log inusing TOTP. :raises AuthenticationFailedException: on 401 :raises ValidationErrorException: on 412 :raises AccessDeniedException: on 403 :raises NotFoundException: on 404 :returns: {"offset": 786, "limit": 532, "responseCode": 200, "count": 334, "metaData": {"additionalProperties": {}}, "messages": [{"message": "Tough exist have very.", "messageTemplate": "Identify girl clearly major.", "field": "Act player be travel blood.", "parameter": {}, "timestamp": 463633973}], "currentPage": 942, "size": 668} """ from requests import delete from argus_api.exceptions import http url = "https://osl-argus-trunk-web1.mnemonic.no/web/api/authentication/v1/totp".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 = {} 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','totp')) def authenticate(userName: str = None, domain: str = None, password: str = None, tokenCode: str = None,json: bool = True, verify: bool = True, apiKey: str = "", authentication: dict = {}) -> dict: """Initiate a new user session using TOTP authentication (PUBLIC) Requires TOTP authentication to be enabled on the server, and for the user. Use /methods to check which authentication methods are available on the server. This is a 2-factor authentication method. The authentication request should carrythe username, the static password, and the TOTP token.. Tokens cannot be reused. Attempting to authenticate with a previously used token,will cause a challenge. Wait for the tokencode to change and resubmit. :param str userName: Username to authenticate :param str domain: User domain :param str password: Static Argus password :param str tokenCode: Current code from TOTP generator :raises AuthenticationFailedException: on 401 :raises ValidationErrorException: on 412 :raises AccessDeniedException: on 403 :raises NotFoundException: on 404 :returns: {"offset": 373, "limit": 950, "responseCode": 200, "count": 512, "metaData": {"additionalProperties": {}}, "messages": [{"message": "Interest task another company simply idea.", "messageTemplate": "Any believe impact account usually.", "field": "Else work land carry organization.", "parameter": {}, "timestamp": 530103331}], "currentPage": 358, "size": 254} """ from requests import post from argus_api.exceptions import http url = "https://osl-argus-trunk-web1.mnemonic.no/web/api/authentication/v1/totp/authenticate".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 userName: body.update({"userName": userName}) if domain: body.update({"domain": domain}) if password: body.update({"password": password}) if tokenCode: body.update({"tokenCode": tokenCode}) 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