Source code for api.currentuser.v1.permission.permission
"""Autogenerated API"""
from argus_cli.plugin import register_command
[docs]@register_command(extending=("currentuser","v1","permission",""))
def check_permission(
function: str,
customerID: int,
json: bool = True,
verify: bool = True,
apiKey: str = None,
authentication: dict = {}
) -> dict:
"""Validate current user permission to perform function on specific customer (PUBLIC)
:param str function: Function name
:param int customerID: Customer ID
:raises AuthenticationFailedException: on 401
:raises ValidationFailedException: on 412
:raises ForbiddenPermissionException: on 403
:raises UserNotFoundException: on 404
:returns: {'offset': 243, 'limit': 922, 'responseCode': 200, 'count': 804, 'data': {}, 'metaData': {'additionalProperties': {}}, 'messages': [{'message': 'Citizen how without new.', 'messageTemplate': 'Somebody machine yet test expect high dream director.', 'field': 'Figure occur responsibility bag task from.', 'parameter': {}, 'timestamp': 86508962}], 'currentPage': 521, 'size': 913}
"""
from requests import get
from argus_api.exceptions import http
url = "https://portal.mnemonic.no/web/api/currentuser/v1/permission/{function}/{customerID}".format(function=function, customerID=customerID)
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 = get(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