Source code for api.currentuser.v1.functions

"""Autogenerated API"""
import requests
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 = 0, limit: int = 25,json: bool = True, verify: bool = True, apiKey: str = "", 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": 615, "limit": 993, "responseCode": 200, "count": 564, "data": [{"id": 94, "name": "Jermaine Miller", "description": "Most represent responsibility.", "securityLevel": "EXTERNAL", "flags": ["ROLE"]}], "metaData": {"additionalProperties": {}}, "messages": [{"message": "Someone teach always.", "messageTemplate": "Mean until move cultural week rather.", "field": "Cultural mention tax bit.", "parameter": {}, "timestamp": 431400117}], "currentPage": 846, "size": 145} """ from requests import get from argus_api.exceptions import http url = "https://osl-argus-trunk-web1.mnemonic.no/web/api/currentuser/v1/functions".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 offset: body.update({"offset": offset}) if limit: body.update({"limit": limit}) if onlyRoles: body.update({"onlyRoles": onlyRoles}) if keywords: body.update({"keywords": keywords}) 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