api.authentication.v1.user.user_apikey — Argus-Toolbelt 1.0 documentation

# Source code for api.authentication.v1.user.user_apikey

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

    @register_command(extending=('authentication','v1','user','apikey'))
    def list(userID: int,json: bool = True, verify: bool = True, apiKey: str = "", authentication: dict = {}) -> dict:
        """List user API keys (PUBLIC)

        :param int userID: ID of user
        :raises AuthenticationFailedException: on 401
        :raises ValidationErrorException: on 412
        :raises AccessDeniedException: on 403
        :raises NotFoundException: on 404
        :returns: {"offset": 278, "limit": 873, "responseCode": 200, "count": 454, "metaData": {"additionalProperties": {}}, "messages": [{"message": "Power image until to hand financial.", "messageTemplate": "Guy military account difficult.", "field": "Return very relate me course hold.", "parameter": {}, "timestamp": 670675737}], "currentPage": 258, "size": 821}
        """
        from requests import get
        from argus_api.exceptions import http

        url = "https://osl-argus-trunk-web1.mnemonic.no/web/api/authentication/v1/user/{userID}/apikey".format(userID=userID)
        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=('authentication','v1','user','apikey'))
    def initiate(userID: int, description: str = None, validSources: list = None, expirationDays: int = None,json: bool = True, verify: bool = True, apiKey: str = "", authentication: dict = {}) -> dict:
        """Initiate a new user APIkey (PUBLIC)
    API keys are bound to a limited IP range. The API key initialization request must specify an IP address or subnet which the API key can be used from.Attempts to use an api key from an IP outside this IP, will result in authentication error.

    To allow authentication from different IPs, issue multiple API keys.

    The initiation request returns the API key, in the format it can be used both in the Argus-API-Key header, or when initiating a durable session (/apikey/authenticate).

    The API key cannot be retrieved at a later stage. If the key is lost, it should be deletedand a new key should be issued.

        :param int userID: ID of user
        :param str description: [\s\w\{\}\$\-\(\)\.\[\]"\'_/\\,\*\+\#:@!?;]*
        :param list validSources: Client IP/CIDR networks which the api key will be valid for.
        :param int expirationDays: Requested expiration days, 0 means unlimited. Default is 3 months. If user does not have permissions to specify expiration period, an error will be returned.
        :raises AuthenticationFailedException: on 401
        :raises ValidationErrorException: on 412
        :raises AccessDeniedException: on 403
        :raises NotFoundException: on 404
        :returns: {"offset": 197, "limit": 209, "responseCode": 200, "count": 783, "metaData": {"additionalProperties": {}}, "messages": [{"message": "Be defense find culture moment crime white election.", "messageTemplate": "Open head parent chair look effort eye arrive.", "field": "Fall shoulder analysis mention tonight along.", "parameter": {}, "timestamp": 498736599}], "currentPage": 568, "size": 936}
        """
        from requests import post
        from argus_api.exceptions import http

        url = "https://osl-argus-trunk-web1.mnemonic.no/web/api/authentication/v1/user/{userID}/apikey".format(userID=userID)
        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 description:
            body.update({"description": description})

        if validSources:
            body.update({"validSources": validSources})

        if expirationDays:
            body.update({"expirationDays": expirationDays})

        response = post(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=('authentication','v1','user','apikey'))
    def renew(userID: int, keyID: int, expirationDays: int = None,json: bool = True, verify: bool = True, apiKey: str = "", authentication: dict = {}) -> dict:
        """Renew existing user APIkey (PUBLIC)
    API keys have limited validity. This operationallows the administrator to renew a users API-key, to allow it to remain functional for a new validity period.

        :param int userID: ID of user
        :param int keyID: Key ID
        :param int expirationDays: Requested expiration days, 0 means unlimited. Default is 3 months. If user does not have permissions to specify expiration period, an error will be returned.
        :raises AuthenticationFailedException: on 401
        :raises ValidationErrorException: on 412
        :raises AccessDeniedException: on 403
        :raises NotFoundException: on 404
        :returns: {"offset": 273, "limit": 309, "responseCode": 200, "count": 239, "metaData": {"additionalProperties": {}}, "messages": [{"message": "Contain hotel citizen cup available.", "messageTemplate": "Low drop garden a over.", "field": "Back wall television.", "parameter": {}, "timestamp": 1265832801}], "currentPage": 509, "size": 952}
        """
        from requests import put
        from argus_api.exceptions import http

        url = "https://osl-argus-trunk-web1.mnemonic.no/web/api/authentication/v1/user/{userID}/apikey/{keyID}".format(userID=userID, keyID=keyID)
        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 expirationDays:
            body.update({"expirationDays": expirationDays})

        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

    @register_command(extending=('authentication','v1','user','apikey'))
    def revoke(userID: int, keyID: int,json: bool = True, verify: bool = True, apiKey: str = "", authentication: dict = {}) -> dict:
        """Delete existing user APIkey (PUBLIC)

        :param int userID: ID of user
        :param int keyID: Key ID
        :raises AuthenticationFailedException: on 401
        :raises ValidationErrorException: on 412
        :raises AccessDeniedException: on 403
        :raises NotFoundException: on 404
        :returns: {"offset": 355, "limit": 482, "responseCode": 200, "count": 684, "metaData": {"additionalProperties": {}}, "messages": [{"message": "Sell southern quality college myself actually meet.", "messageTemplate": "Continue stuff affect cell feel mind offer.", "field": "New employee knowledge voice alone both.", "parameter": {}, "timestamp": 195894018}], "currentPage": 163, "size": 361}
        """
        from requests import delete
        from argus_api.exceptions import http

        url = "https://osl-argus-trunk-web1.mnemonic.no/web/api/authentication/v1/user/{userID}/apikey/{keyID}".format(userID=userID, keyID=keyID)
        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 = delete(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=('authentication','v1','user','apikey'))
    def disable_method_for_user(userID: int, method: str,json: bool = True, verify: bool = True, apiKey: str = "", authentication: dict = {}) -> dict:
        """Disable an authentication method for a user (PUBLIC)

        :param int userID: ID of user to modify
        :param str method: Authentication method to enable
        :raises AuthenticationFailedException: on 401
        :raises ValidationFailedException: on 412
        :raises AccessDeniedException: on 403
        :raises UserNotFoundException: on 404
        :returns: {"offset": 354, "limit": 255, "responseCode": 200, "count": 366, "metaData": {"additionalProperties": {}}, "messages": [{"message": "Thousand her season agree.", "messageTemplate": "Certain action all over floor.", "field": "Data drop plan paper partner safe peace.", "parameter": {}, "timestamp": 790229026}], "currentPage": 123, "size": 197}
        """
        from requests import put
        from argus_api.exceptions import http

        url = "https://osl-argus-trunk-web1.mnemonic.no/web/api/authentication/v1/user/{userID}/disable/{method}".format(userID=userID, method=method)
        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 = 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

    @register_command(extending=('authentication','v1','user','apikey'))
    def enable_method_for_user(userID: int, method: str,json: bool = True, verify: bool = True, apiKey: str = "", authentication: dict = {}) -> dict:
        """Enable an authentication method for a user (PUBLIC)

        :param int userID: ID of user to modify
        :param str method: Authentication method to enable
        :raises AuthenticationFailedException: on 401
        :raises ValidationFailedException: on 412
        :raises AccessDeniedException: on 403
        :raises UserNotFoundException: on 404
        :returns: {"offset": 837, "limit": 802, "responseCode": 200, "count": 783, "metaData": {"additionalProperties": {}}, "messages": [{"message": "Forget indicate remain management international enjoy.", "messageTemplate": "Allow cause many.", "field": "Argue fact discussion.", "parameter": {}, "timestamp": 253471648}], "currentPage": 681, "size": 14}
        """
        from requests import put
        from argus_api.exceptions import http

        url = "https://osl-argus-trunk-web1.mnemonic.no/web/api/authentication/v1/user/{userID}/enable/{method}".format(userID=userID, method=method)
        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 = 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

    @register_command(extending=('authentication','v1','user','apikey'))
    def setup(userID: int, userName: str = None,json: bool = True, verify: bool = True, apiKey: str = "", authentication: dict = {}) -> dict:
        """Configure user LDAP settings (INTERNAL)

        :param int userID: User ID
        :param str userName: LDAP username to set for user
        :raises AuthenticationFailedException: on 401
        :raises ValidationErrorException: on 412
        :raises AccessDeniedException: on 403
        :raises NotFoundException: on 404
        :returns: {"offset": 366, "limit": 303, "responseCode": 200, "count": 686, "metaData": {"additionalProperties": {}}, "messages": [{"message": "Here with many affect other learn.", "messageTemplate": "Decision his develop likely.", "field": "Toward sea wear alone public picture use.", "parameter": {}, "timestamp": 275074431}], "currentPage": 294, "size": 198}
        """
        from requests import put
        from argus_api.exceptions import http

        url = "https://osl-argus-trunk-web1.mnemonic.no/web/api/authentication/v1/user/{userID}/ldap".format(userID=userID)
        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 userName:
            body.update({"userName": userName})

        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

    @register_command(extending=('authentication','v1','user','apikey'))
    def download_public_key(userID: int,json: bool = True, verify: bool = True, apiKey: str = "", authentication: dict = {}) -> dict:
        """Download user public key (INTERNAL)

        :param int userID: User ID
        :raises AuthenticationFailedException: on 401
        :raises ValidationErrorException: on 412
        :raises AccessDeniedException: on 403
        :raises NotFoundException: on 404
        :returns: {}
        """
        from requests import get
        from argus_api.exceptions import http

        url = "https://osl-argus-trunk-web1.mnemonic.no/web/api/authentication/v1/user/{userID}/signature/pubkey".format(userID=userID)
        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=('authentication','v1','user','apikey'))
    def reset_and_download_private_key(userID: int,json: bool = True, verify: bool = True, apiKey: str = "", authentication: dict = {}) -> dict:
        """Reset and download user private key (INTERNAL)

        :param int userID: User ID
        :raises AuthenticationFailedException: on 401
        :raises ValidationErrorException: on 412
        :raises AccessDeniedException: on 403
        :raises NotFoundException: on 404
        :returns: {}
        """
        from requests import post
        from argus_api.exceptions import http

        url = "https://osl-argus-trunk-web1.mnemonic.no/web/api/authentication/v1/user/{userID}/signature/reset".format(userID=userID)
        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 = post(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=('authentication','v1','user','apikey'))
    def retrieve_s_m_s_token(userID: int, tokenSuffix: str,json: bool = True, verify: bool = True, apiKey: str = "", authentication: dict = {}) -> dict:
        """Retrieve the SMS code sent to user (PUBLIC)
    SMS authentication depends on the verification code sent to the user by SMS reachingthe user. When this does not happen, this method allows an administrator to retrieve the SMS code to provide the user by phone.

    To retrieve the token, the user must provide the administrator with thesession token printed in the browser in the SMS code input screen.

        :param int userID: User ID
        :param str tokenSuffix: Token suffix
        :raises AuthenticationFailedException: on 401
        :raises ValidationErrorException: on 412
        :raises AccessDeniedException: on 403
        :raises NotFoundException: on 404
        :returns: {"offset": 777, "limit": 438, "responseCode": 200, "count": 225, "metaData": {"additionalProperties": {}}, "messages": [{"message": "Mrs financial industry write discuss from baby investment.", "messageTemplate": "Through believe in officer design cause.", "field": "Grow world role ok strong look push right.", "parameter": {}, "timestamp": 983484116}], "currentPage": 758, "size": 271}
        """
        from requests import get
        from argus_api.exceptions import http

        url = "https://osl-argus-trunk-web1.mnemonic.no/web/api/authentication/v1/user/{userID}/sms/token/{tokenSuffix}".format(userID=userID, tokenSuffix=tokenSuffix)
        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=('authentication','v1','user','apikey'))
    def get_user_methods(userId: int,json: bool = True, verify: bool = True, apiKey: str = "", authentication: dict = {}) -> dict:
        """List authentication methods enabled for a specified user (PUBLIC)

        :param int userId: User to fetch methods for
        :raises AuthenticationFailedException: on 401
        :raises AccessDeniedException: on 403
        :raises UserNotFoundException: on 404
        :returns: {"offset": 1000, "limit": 391, "responseCode": 200, "count": 141, "data": [{"method": "TOTP", "lastLoginTimestamp": 1109825220, "lastLoginIP": "Plant degree where statement yeah.", "initialized": false, "settings": {"additionalProperties": {}}}], "metaData": {"additionalProperties": {}}, "messages": [{"message": "Treat suggest television drop fill letter.", "messageTemplate": "Themselves bad reduce blood between.", "field": "Reach talk tonight north paper offer apply.", "parameter": {}, "timestamp": 1265262392}], "currentPage": 205, "size": 68}
        """
        from requests import get
        from argus_api.exceptions import http

        url = "https://osl-argus-trunk-web1.mnemonic.no/web/api/authentication/v1/user/{userId}/methods".format(userId=userId)
        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