Source code for api.currentuser.v1.functions

"""Autogenerated API"""

from argus_cli.plugin import register_command



[docs]@register_command(extending=("currentuser","v1","functions")) def get_functions( onlyRoles: bool = None, keywords: list = None, offset: int = None, limit: int = 25, json: bool = True, verify: bool = True, apiKey: str = None, authentication: dict = {} ) -> dict: """List the current user's permission functions regardless of customer (PUBLIC) :param bool onlyRoles: Only return functions marked as roles :param list keywords: Filter functions by keywords on name and description :param int offset: Skip a number of functions :param int limit: Maximum number of returned functions :raises AuthenticationFailedException: on 401 :raises ForbiddenPermissionException: on 403 :returns: {'offset': 339, 'limit': 871, 'responseCode': 200, 'count': 92, 'data': [{'id': 495, 'name': 'Jeffrey Smith', 'description': 'Agreement week leg organization.', 'securityLevel': 'EXTERNAL', 'flags': ['ROLE']}], 'metaData': {'additionalProperties': {}}, 'messages': [{'message': 'Compare try candidate.', 'messageTemplate': 'Activity entire newspaper send tree answer form.', 'field': 'Class fight pay tree assume citizen kitchen.', 'parameter': {}, 'timestamp': 838274844}], 'currentPage': 34, 'size': 654} """ from requests import get from argus_api.exceptions import http url = "https://portal.mnemonic.no/web/api/currentuser/v1/functions".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 = { "offset": offset, "limit": limit, "onlyRoles": onlyRoles, "keywords": keywords } 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