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

"""Autogenerated API"""

from argus_cli.plugin import register_command



[docs]@register_command(extending=("authentication","v1","user","apikey")) def list( userID: int, json: bool = True, verify: bool = True, apiKey: str = None, 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': 657, 'limit': 505, 'responseCode': 200, 'count': 928, 'metaData': {'additionalProperties': {}}, 'messages': [{'message': 'Want lose stand energy parent trip high technology.', 'messageTemplate': 'Fund sometimes street rock office wide suffer.', 'field': 'Staff politics rule few drive.', 'parameter': {}, 'timestamp': 668346733}], 'currentPage': 85, 'size': 701} """ from requests import get from argus_api.exceptions import http url = "https://portal.mnemonic.no/web/api/authentication/v1/user/{userID}/apikey".format(userID=userID) 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 = { } 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
[docs]@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 = None, 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': 630, 'limit': 203, 'responseCode': 200, 'count': 189, 'metaData': {'additionalProperties': {}}, 'messages': [{'message': 'Relate seven reflect week page bad million.', 'messageTemplate': 'Movie camera always deal land customer.', 'field': 'Effect country science challenge still.', 'parameter': {}, 'timestamp': 1345694885}], 'currentPage': 813, 'size': 131} """ from requests import post from argus_api.exceptions import http url = "https://portal.mnemonic.no/web/api/authentication/v1/user/{userID}/apikey".format(userID=userID) 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 = { "description": description, "validSources": validSources, "expirationDays": expirationDays } response = post(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
[docs]@register_command(extending=("authentication","v1","user","apikey")) def renew( userID: int, keyID: int, expirationDays: int = None, json: bool = True, verify: bool = True, apiKey: str = None, 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': 7, 'limit': 340, 'responseCode': 200, 'count': 66, 'metaData': {'additionalProperties': {}}, 'messages': [{'message': 'That mean against short form expect focus.', 'messageTemplate': 'Run story open.', 'field': 'Half both government federal idea student lead around.', 'parameter': {}, 'timestamp': 802070110}], 'currentPage': 356, 'size': 389} """ from requests import put from argus_api.exceptions import http url = "https://portal.mnemonic.no/web/api/authentication/v1/user/{userID}/apikey/{keyID}".format(userID=userID, keyID=keyID) 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 = { "expirationDays": expirationDays } response = put(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
[docs]@register_command(extending=("authentication","v1","user","apikey")) def revoke( userID: int, keyID: int, json: bool = True, verify: bool = True, apiKey: str = None, 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': 641, 'limit': 506, 'responseCode': 200, 'count': 598, 'metaData': {'additionalProperties': {}}, 'messages': [{'message': 'History southern peace institution firm bank.', 'messageTemplate': 'Animal standard son account.', 'field': 'Speak describe truth sometimes notice.', 'parameter': {}, 'timestamp': 389148772}], 'currentPage': 607, 'size': 614} """ from requests import delete from argus_api.exceptions import http url = "https://portal.mnemonic.no/web/api/authentication/v1/user/{userID}/apikey/{keyID}".format(userID=userID, keyID=keyID) 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 = { } response = delete(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
[docs]@register_command(extending=("authentication","v1","user","apikey")) def disable_method_for_user( userID: int, method: str, json: bool = True, verify: bool = True, apiKey: str = None, 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': 202, 'limit': 990, 'responseCode': 200, 'count': 274, 'metaData': {'additionalProperties': {}}, 'messages': [{'message': 'Thousand modern article.', 'messageTemplate': 'Price should me point practice fine.', 'field': 'Several present student nice strong market.', 'parameter': {}, 'timestamp': 475395448}], 'currentPage': 271, 'size': 953} """ from requests import put from argus_api.exceptions import http url = "https://portal.mnemonic.no/web/api/authentication/v1/user/{userID}/disable/{method}".format(userID=userID, method=method) 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 = { } response = put(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
[docs]@register_command(extending=("authentication","v1","user","apikey")) def enable_method_for_user( userID: int, method: str, json: bool = True, verify: bool = True, apiKey: str = None, 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': 645, 'limit': 691, 'responseCode': 200, 'count': 534, 'metaData': {'additionalProperties': {}}, 'messages': [{'message': 'Name cup bit face.', 'messageTemplate': 'Better six center.', 'field': 'Indicate whatever final development parent book agency week.', 'parameter': {}, 'timestamp': 1390067745}], 'currentPage': 273, 'size': 732} """ from requests import put from argus_api.exceptions import http url = "https://portal.mnemonic.no/web/api/authentication/v1/user/{userID}/enable/{method}".format(userID=userID, method=method) 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 = { } response = put(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
[docs]@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 = None, 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': 450, 'limit': 374, 'responseCode': 200, 'count': 620, 'metaData': {'additionalProperties': {}}, 'messages': [{'message': 'Perform door how young those.', 'messageTemplate': 'Thus officer cell of.', 'field': 'Actually save customer each direction stand wonder.', 'parameter': {}, 'timestamp': 307839813}], 'currentPage': 494, 'size': 587} """ from requests import get from argus_api.exceptions import http url = "https://portal.mnemonic.no/web/api/authentication/v1/user/{userID}/sms/token/{tokenSuffix}".format(userID=userID, tokenSuffix=tokenSuffix) 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 = { } 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
[docs]@register_command(extending=("authentication","v1","user","apikey")) def get_user_methods( userId: int, json: bool = True, verify: bool = True, apiKey: str = None, 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': 944, 'limit': 578, 'responseCode': 200, 'count': 882, 'data': [{'method': 'OTP', 'lastLoginTimestamp': 366641719, 'lastLoginIP': 'Realize event prove forget public southern.', 'initialized': False, 'settings': {'additionalProperties': {}}}], 'metaData': {'additionalProperties': {}}, 'messages': [{'message': 'Board college technology artist.', 'messageTemplate': 'Wrong adult maybe between.', 'field': 'Themselves peace exist late you week popular.', 'parameter': {}, 'timestamp': 520843578}], 'currentPage': 594, 'size': 63} """ from requests import get from argus_api.exceptions import http url = "https://portal.mnemonic.no/web/api/authentication/v1/user/{userId}/methods".format(userId=userId) 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 = { } 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