api.currentuser.v1.user — Argus-Toolbelt 1.0 documentation

# Source code for api.currentuser.v1.user

    """Autogenerated API"""
    import requests
    from argus_cli.plugin import register_command

    @register_command(extending=('currentuser','v1','user'))
    def get_current_user(json: bool = True, verify: bool = True, apiKey: str = "", authentication: dict = {}) -> dict:
        """Get the object representation of the currently logged in user (PUBLIC)

        :raises AuthenticationFailedException: on 401
        :returns: {"offset": 458, "limit": 866, "responseCode": 200, "count": 583, "metaData": {"additionalProperties": {}}, "messages": [{"message": "World name describe give.", "messageTemplate": "Protect event light hit why.", "field": "Back story mention modern.", "parameter": {}, "timestamp": 513026976}], "currentPage": 359, "size": 280}
        """
        from requests import get
        from argus_api.exceptions import http

        url = "https://portal.mnemonic.no/web/api/currentuser/v1/user".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