Source code for api.authentication.v1.logout
"""Autogenerated API"""
from argus_cli.plugin import register_command
[docs]@register_command(extending=("authentication","v1","logout"))
def logout(
json: bool = True,
verify: bool = True,
apiKey: str = None,
authentication: dict = {}
) -> dict:
"""Invalidate current user session (PUBLIC)
:returns: {}
"""
from requests import delete
from argus_api.exceptions import http
url = "https://portal.mnemonic.no/web/api/authentication/v1/logout".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 = 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