Source code for api.alarms.v1.category

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


[docs]@register_command(extending=('alarms','v1','category')) def get_categories(keywords: list = None, keywordField: list = None, offset: int = 0, limit: int = 25, keywordMatch: str = 'all',json: bool = True, verify: bool = True, apiKey: str = "", authentication: dict = {}) -> dict: """Get all categories (PUBLIC) :param list keywords: Filter categories by keywords :param list keywordField: Set field strategy for keyword search :param int offset: Skip a number of categories :param int limit: Maximum number of returned categories :param str keywordMatch: Set match strategy for keyword search :raises AuthenticationFailedException: on 401 :raises ValidationErrorException: on 412 :raises AccessDeniedException: on 403 :returns: {"offset": 456, "limit": 444, "responseCode": 200, "count": 192, "data": [{"id": 16, "info": "Me woman market wall phone bring.", "name": "Richard Smith", "flags": ["DISABLED"]}], "metaData": {"additionalProperties": {}}, "messages": [{"message": "Response enter what put measure.", "messageTemplate": "Parent condition data information night want city their.", "field": "Office identify specific card laugh summer.", "parameter": {}, "timestamp": 904638266}], "currentPage": 418, "size": 972} """ from requests import get from argus_api.exceptions import http url = "https://osl-argus-trunk-web1.mnemonic.no/web/api/alarms/v1/category".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 offset: body.update({"offset": offset}) if limit: body.update({"limit": limit}) if keywordMatch: body.update({"keywordMatch": keywordMatch}) if keywords: body.update({"keywords": keywords}) if keywordField: body.update({"keywordField": keywordField}) 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=('alarms','v1','category')) def add_category(name: str = None, info: str = None,json: bool = True, verify: bool = True, apiKey: str = "", authentication: dict = {}) -> dict: """Add new category (INTERNAL) :param str name: Name of added category. => [\s\w\{\}\$\-\(\)\.\[\]"\'_/\\,\*\+\#:@!?;]* :param str info: Description of added category. => [\s\w\{\}\$\-\(\)\.\[\]"\'_/\\,\*\+\#:@!?;]* :raises AuthenticationFailedException: on 401 :raises ValidationErrorException: on 412 :raises AccessDeniedException: on 403 :returns: {"offset": 425, "limit": 767, "responseCode": 200, "count": 460, "metaData": {"additionalProperties": {}}, "messages": [{"message": "Without design rich citizen water develop instead.", "messageTemplate": "Summer director kitchen push have purpose level.", "field": "Throw then job.", "parameter": {}, "timestamp": 1148272253}], "currentPage": 669, "size": 44} """ from requests import post from argus_api.exceptions import http url = "https://osl-argus-trunk-web1.mnemonic.no/web/api/alarms/v1/category".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 name: body.update({"name": name}) if info: body.update({"info": info}) 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=('alarms','v1','category')) def search_categories(limit: int = None, offset: int = None, subCriteria: list = None, attackCategoryID: list = None, keywords: list = None, keywordFieldStrategy: list = None, sortBy: list = None, includeFlags: list = None, excludeFlags: list = None, keywordMatchStrategy: str = 'all', includeDeleted: bool = 'False', exclude: bool = 'False', required: bool = 'False',json: bool = True, verify: bool = True, apiKey: str = "", authentication: dict = {}) -> dict: """Get all categories matching a given search criteria (PUBLIC) :param int limit: Set this value to set max number of results. By default, no restriction on result set size. :param int offset: Set this value to skip the first (offset) objects. By default, return result from first object. :param list subCriteria: :param list attackCategoryID: A set of IDs for attack categories (alarm category). :param list keywords: A set of keywords matched against categories based on the set KeywordFieldStrategy and KeywordMatchStrategy. :param list keywordFieldStrategy: KeywordFieldStrategy to define which field(s) to match against keywords. (default all) :param list sortBy: List of properties to sort by (prefix with "-" to sort descending). :param list includeFlags: Only include objects which have includeFlags set. :param list excludeFlags: Exclude objects which have excludeFlags set. :param str keywordMatchStrategy: KeywordMatchStrategy to define how to match keywords with fields. (default all) :param bool includeDeleted: Set to true to include deleted objects. By default, exclude deleted objects. :param bool exclude: Only relevant for subcriteria. If set to true, objects matching this subcriteria object will be excluded. :param bool required: Only relevant for subcriteria. If set to true, objects matching this subcriteria are required (AND-ed together with parent criteria). :raises AuthenticationFailedException: on 401 :raises ValidationErrorException: on 412 :raises AccessDeniedException: on 403 :returns: {"offset": 33, "limit": 72, "responseCode": 200, "count": 552, "data": [{"id": 0, "info": "Their garden could picture rich.", "name": "Alan Collins", "flags": ["DELETED"]}], "metaData": {"additionalProperties": {}}, "messages": [{"message": "Thought three pressure get partner.", "messageTemplate": "Since check focus natural movie sea throughout surface.", "field": "Book American away image leader.", "parameter": {}, "timestamp": 696382532}], "currentPage": 513, "size": 339} """ from requests import post from argus_api.exceptions import http url = "https://osl-argus-trunk-web1.mnemonic.no/web/api/alarms/v1/category/search".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 keywordMatchStrategy: body.update({"keywordMatchStrategy": keywordMatchStrategy}) if limit: body.update({"limit": limit}) if offset: body.update({"offset": offset}) if includeDeleted: body.update({"includeDeleted": includeDeleted}) if subCriteria: body.update({"subCriteria": subCriteria}) if exclude: body.update({"exclude": exclude}) if required: body.update({"required": required}) if attackCategoryID: body.update({"attackCategoryID": attackCategoryID}) if keywords: body.update({"keywords": keywords}) if keywordFieldStrategy: body.update({"keywordFieldStrategy": keywordFieldStrategy}) if sortBy: body.update({"sortBy": sortBy}) if includeFlags: body.update({"includeFlags": includeFlags}) if excludeFlags: body.update({"excludeFlags": excludeFlags}) 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=('alarms','v1','category')) def get_category_by_id(id: int,json: bool = True, verify: bool = True, apiKey: str = "", authentication: dict = {}) -> dict: """Get category by Id (PUBLIC) :param int id: ID of category :raises AuthenticationFailedException: on 401 :raises ValidationErrorException: on 412 :raises AccessDeniedException: on 403 :raises ObjectNotFoundException: on 404 :returns: {"offset": 567, "limit": 110, "responseCode": 200, "count": 665, "metaData": {"additionalProperties": {}}, "messages": [{"message": "Them form leave game ball blue red risk.", "messageTemplate": "Moment issue message hard later lose daughter.", "field": "Charge employee them sort task benefit nice.", "parameter": {}, "timestamp": 1375235543}], "currentPage": 997, "size": 825} """ from requests import get from argus_api.exceptions import http url = "https://osl-argus-trunk-web1.mnemonic.no/web/api/alarms/v1/category/{id}".format(id=id) 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=('alarms','v1','category')) def update_category(id: int, name: str = None, info: str = None, disabled: bool = 'False',json: bool = True, verify: bool = True, apiKey: str = "", authentication: dict = {}) -> dict: """Update existing category (INTERNAL) :param int id: ID of attack category :param str name: Update name of category. => [\s\w\{\}\$\-\(\)\.\[\]"\'_/\\,\*\+\#:@!?;]* :param str info: Update description of category. => [\s\w\{\}\$\-\(\)\.\[\]"\'_/\\,\*\+\#:@!?;]* :param bool disabled: Disable or enable category (unchanged if not set) :raises AuthenticationFailedException: on 401 :raises ValidationErrorException: on 412 :raises AccessDeniedException: on 403 :raises ObjectNotFoundException: on 404 :returns: {"offset": 492, "limit": 908, "responseCode": 200, "count": 144, "metaData": {"additionalProperties": {}}, "messages": [{"message": "Black speech oil various partner network.", "messageTemplate": "Good theory unit important least.", "field": "Everyone thank wall participant use.", "parameter": {}, "timestamp": 218025499}], "currentPage": 615, "size": 877} """ from requests import put from argus_api.exceptions import http url = "https://osl-argus-trunk-web1.mnemonic.no/web/api/alarms/v1/category/{id}".format(id=id) 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 name: body.update({"name": name}) if info: body.update({"info": info}) if disabled: body.update({"disabled": disabled}) 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=('alarms','v1','category')) def delete_category(id: int,json: bool = True, verify: bool = True, apiKey: str = "", authentication: dict = {}) -> dict: """Delete existing category (INTERNAL) :param int id: ID of attack category :raises AuthenticationFailedException: on 401 :raises ValidationErrorException: on 412 :raises AccessDeniedException: on 403 :raises ObjectNotFoundException: on 404 :returns: {"offset": 559, "limit": 171, "responseCode": 200, "count": 687, "metaData": {"additionalProperties": {}}, "messages": [{"message": "Agency difference best sometimes behavior here.", "messageTemplate": "Wind officer leave stop.", "field": "Out take pattern involve miss modern dog.", "parameter": {}, "timestamp": 988227933}], "currentPage": 557, "size": 223} """ from requests import delete from argus_api.exceptions import http url = "https://osl-argus-trunk-web1.mnemonic.no/web/api/alarms/v1/category/{id}".format(id=id) 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