"""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": 141, "limit": 593, "responseCode": 200, "count": 713, "metaData": {"additionalProperties": {}}, "messages": [{"message": "Agreement nothing usually season.", "messageTemplate": "Travel ahead politics event.", "field": "Art president that would.", "parameter": {}, "timestamp": 1018737964}], "currentPage": 432, "size": 113}
"""
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": 334, "limit": 341, "responseCode": 200, "count": 968, "metaData": {"additionalProperties": {}}, "messages": [{"message": "His sound similar wall song drug year current.", "messageTemplate": "Baby Mr approach writer quality.", "field": "Agency federal possible head.", "parameter": {}, "timestamp": 1154278647}], "currentPage": 226, "size": 2}
"""
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": 90, "limit": 53, "responseCode": 200, "count": 72, "metaData": {"additionalProperties": {}}, "messages": [{"message": "Need money surface understand talk perhaps operation.", "messageTemplate": "Case nice require end pretty.", "field": "Data approach as former check author as thus.", "parameter": {}, "timestamp": 917584694}], "currentPage": 229, "size": 47}
"""
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": 44, "limit": 791, "responseCode": 200, "count": 586, "metaData": {"additionalProperties": {}}, "messages": [{"message": "Court institution keep feeling.", "messageTemplate": "There lead ball want at dinner grow.", "field": "Investment election officer each.", "parameter": {}, "timestamp": 1310299699}], "currentPage": 970, "size": 82}
"""
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": 945, "limit": 843, "responseCode": 200, "count": 394, "metaData": {"additionalProperties": {}}, "messages": [{"message": "Relate interesting ok offer attack account eat.", "messageTemplate": "Support citizen determine often.", "field": "Data toward project happy realize operation entire.", "parameter": {}, "timestamp": 1369505864}], "currentPage": 581, "size": 249}
"""
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