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

# Source code for api.currentuser.v1.picture

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

    @register_command(extending=('currentuser','v1','picture'))
    def get_profile_picture(json: bool = True, verify: bool = True, apiKey: str = "", authentication: dict = {}) -> dict:
        """Get current user's profile picture (PUBLIC)

        :raises AuthenticationFailedException: on 401
        :raises AccessDeniedException: on 403
        :raises ProfilePictureNotFoundException: on 404
        :returns: {}
        """
        from requests import get
        from argus_api.exceptions import http

        url = "https://osl-argus-trunk-web1.mnemonic.no/web/api/currentuser/v1/picture".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

    @register_command(extending=('currentuser','v1','picture'))
    def update_profile_picture(picture: str = None,json: bool = True, verify: bool = True, apiKey: str = "", authentication: dict = {}) -> dict:
        """Set current user's profile picture (PUBLIC)

        :param str picture: Image data url
        :raises AuthenticationFailedException: on 401
        :raises AccessDeniedException: on 403
        :returns: {"offset": 787, "limit": 587, "responseCode": 200, "count": 363, "metaData": {"additionalProperties": {}}, "messages": [{"message": "Stop performance ground woman then.", "messageTemplate": "Show space different development believe sit.", "field": "Prevent nor wide effort parent able speak.", "parameter": {}, "timestamp": 1276081163}], "currentPage": 231, "size": 385}
        """
        from requests import put
        from argus_api.exceptions import http

        url = "https://osl-argus-trunk-web1.mnemonic.no/web/api/currentuser/v1/picture".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 picture:
            body.update({"picture": picture})

        response = put(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