Source code for api.authentication.v1.apikey

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


[docs]@register_command(extending=('authentication','v1','apikey')) def list(json: bool = True, verify: bool = True, apiKey: str = "", authentication: dict = {}) -> dict: """List current user apikeys (PUBLIC) :raises AuthenticationFailedException: on 401 :raises ValidationErrorException: on 412 :raises AccessDeniedException: on 403 :raises NotFoundException: on 404 :returns: {"offset": 957, "limit": 564, "responseCode": 200, "count": 456, "metaData": {"additionalProperties": {}}, "messages": [{"message": "Maybe strong speech direction.", "messageTemplate": "Analysis development brother boy almost guess.", "field": "Rest heavy provide money of.", "parameter": {}, "timestamp": 660335617}], "currentPage": 209, "size": 172} """ from requests import get from argus_api.exceptions import http url = "https://osl-argus-trunk-web1.mnemonic.no/web/api/authentication/v1/apikey".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
[docs]@register_command(extending=('authentication','v1','apikey')) def initiate(password: str = None, description: str = None, validSources: list = None, expirationDays: int = None,json: bool = True, verify: bool = True, apiKey: str = "", authentication: dict = {}) -> dict: """Initiate a new apikey for current user (PUBLIC) :param str password: User password to verify this request :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": 310, "limit": 795, "responseCode": 200, "count": 279, "metaData": {"additionalProperties": {}}, "messages": [{"message": "Do special there window newspaper.", "messageTemplate": "Speak throughout let capital discuss treatment.", "field": "Reality prevent public then myself indicate radio.", "parameter": {}, "timestamp": 596866863}], "currentPage": 418, "size": 393} """ from requests import post from argus_api.exceptions import http url = "https://osl-argus-trunk-web1.mnemonic.no/web/api/authentication/v1/apikey".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 password: body.update({"password": password}) 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
[docs]@register_command(extending=('authentication','v1','apikey')) def authenticate(apikey: str = None,json: bool = True, verify: bool = True, apiKey: str = "", authentication: dict = {}) -> dict: """Initiate a new user session using API key (PUBLIC) Requires password authentication to be enabled on the server, and for the userUse /methods to check which authentication methods are available on the server. Use this operation to create a session to last across multiple requests.This might be useful for some legacy operations which require a web session, or for performance reasons if performing a large number of requests. End session using /logout For one-shot requests, use Argus-API-Key header. :param str apikey: :raises AuthenticationFailedException: on 401 :raises ValidationErrorException: on 412 :returns: {"offset": 391, "limit": 699, "responseCode": 200, "count": 922, "metaData": {"additionalProperties": {}}, "messages": [{"message": "Wide today do test system weight yourself.", "messageTemplate": "Tax night factor general if summer.", "field": "Home your lay yard.", "parameter": {}, "timestamp": 420383578}], "currentPage": 443, "size": 941} """ from requests import post from argus_api.exceptions import http url = "https://osl-argus-trunk-web1.mnemonic.no/web/api/authentication/v1/apikey/authenticate".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 apikey: body.update({"apikey": apikey}) 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
[docs]@register_command(extending=('authentication','v1','apikey')) def renew(keyID: int, password: str = None, expirationDays: int = None,json: bool = True, verify: bool = True, apiKey: str = "", authentication: dict = {}) -> dict: """Renew an apikey for current user (PUBLIC) API keys have limited validity. This operationallows the user to renew a key, to allow it to remain functional for a new validity period. :param int keyID: Key ID :param str password: User password to verify this request :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": 800, "limit": 437, "responseCode": 200, "count": 227, "metaData": {"additionalProperties": {}}, "messages": [{"message": "National teacher yes similar stand available.", "messageTemplate": "Someone against child age sense left turn manager.", "field": "Yet likely best woman produce hour wish.", "parameter": {}, "timestamp": 1129919428}], "currentPage": 389, "size": 148} """ from requests import put from argus_api.exceptions import http url = "https://osl-argus-trunk-web1.mnemonic.no/web/api/authentication/v1/apikey/{keyID}".format(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 password: body.update({"password": password}) 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
[docs]@register_command(extending=('authentication','v1','apikey')) def revoke(keyID: int,json: bool = True, verify: bool = True, apiKey: str = "", authentication: dict = {}) -> dict: """Revoke an apikey from current user (PUBLIC) :param int keyID: Key ID :raises AuthenticationFailedException: on 401 :raises ValidationErrorException: on 412 :raises AccessDeniedException: on 403 :raises NotFoundException: on 404 :returns: {"offset": 731, "limit": 748, "responseCode": 200, "count": 565, "metaData": {"additionalProperties": {}}, "messages": [{"message": "Daughter second particularly image.", "messageTemplate": "Part speech often sometimes appear continue arrive.", "field": "New today in challenge fill ability know lead.", "parameter": {}, "timestamp": 966999637}], "currentPage": 637, "size": 761} """ from requests import delete from argus_api.exceptions import http url = "https://osl-argus-trunk-web1.mnemonic.no/web/api/authentication/v1/apikey/{keyID}".format(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