Source code for api.currentuser.v1.authmethods
"""Autogenerated API"""
import requests
from argus_cli.plugin import register_command
[docs]@register_command(extending=('currentuser','v1','authmethods'))
def get_current_user_methods(json: bool = True, verify: bool = True, apiKey: str = "", authentication: dict = {}) -> dict:
"""List the current users valid authentication methods (PUBLIC)
:raises AuthenticationFailedException: on 401
:raises ValidationFailedException: on 412
:raises AccessDeniedException: on 403
:raises UserNotFoundException: on 404
:returns: {"offset": 705, "limit": 126, "responseCode": 200, "count": 794, "data": [{"method": "OTP", "lastLoginTimestamp": 1447540604, "lastLoginIP": "Trip board another popular trip president.", "initialized": true, "settings": {"additionalProperties": {}}}], "metaData": {"additionalProperties": {}}, "messages": [{"message": "To day fight else television.", "messageTemplate": "Establish artist money result hand.", "field": "Away southern staff notice people kind pull.", "parameter": {}, "timestamp": 299413401}], "currentPage": 779, "size": 658}
"""
from requests import get
from argus_api.exceptions import http
url = "https://portal.mnemonic.no/web/api/currentuser/v1/authmethods".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 = 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