# Source code for api.eventfilters.v1.filter

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

    @register_command(extending=('eventfilters','v1','filter'))
    def list(search: str = None, customerID: list = None, type: str = None, limit: int = 25, offset: int = 0,json: bool = True, verify: bool = True, apiKey: str = "", authentication: dict = {}) -> dict:
        """List filters (INTERNAL)

        :param str search: Limit result to filters matching this searchstring
        :param list customerID: Limit result to filters for this customerID
        :param str type: Limit result to filters of this type
        :param int limit: Limit result
        :param int offset: Offset result
        :raises AuthenticationFailedException: on 401
        :raises ValidationFailedException: on 412
        :raises AccessDeniedException: on 403
        :returns: {"offset": 622, "limit": 546, "responseCode": 200, "count": 477, "data": [{"revision": 633, "deleted": true, "information": "Move describe speech instead security structure fall.", "masterID": 467, "expired": false, "valid": false, "enabled": false, "index": 564, "flags": 797, "labels": ["During live without ground rock."], "description": "Too memory benefit.", "id": 431, "lastUpdatedTimestamp": 830167045, "validFromTimestamp": 1439347248, "validToTimestamp": 1014671162, "lastUpdatedByUser": {"id": 184, "customerID": 113, "userName": "smithdustin", "name": "Tyler Grant"}, "createdTimestamp": 436404805}], "metaData": {"additionalProperties": {}}, "messages": [{"message": "Front store them second its agency model.", "messageTemplate": "Wish hour expert rise true.", "field": "Keep you size box mention season high.", "parameter": {}, "timestamp": 486384201}], "currentPage": 912, "size": 17}
        """
        from requests import get
        from argus_api.exceptions import http

        url = "https://osl-argus-trunk-web1.mnemonic.no/web/api/eventfilters/v1/filter".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 limit:
            body.update({"limit": limit})

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

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

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

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

        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=('eventfilters','v1','filter'))
    def error_stats(includeDetails: bool = 'True',json: bool = True, verify: bool = True, apiKey: str = "", authentication: dict = {}) -> dict:
        """Fetch filter error statistics (INTERNAL)

        :param bool includeDetails: If true, include detailed error statistics per processing node
        :raises AuthenticationFailedException: on 401
        :raises ValidationFailedException: on 412
        :raises AccessDeniedException: on 403
        :returns: {}
        """
        from requests import get
        from argus_api.exceptions import http

        url = "https://osl-argus-trunk-web1.mnemonic.no/web/api/eventfilters/v1/filter/errorstats".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 includeDetails:
            body.update({"includeDetails": includeDetails})

        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=('eventfilters','v1','filter'))
    def hit_stats(period: int = 3600000, includeDetails: bool = 'True',json: bool = True, verify: bool = True, apiKey: str = "", authentication: dict = {}) -> dict:
        """Fetch filter error statistics (INTERNAL)

        :param int period: Time period to fetch hit stats for (milliseconds)
        :param bool includeDetails: If true, include details about hits per processing node
        :raises AuthenticationFailedException: on 401
        :raises ValidationFailedException: on 412
        :raises AccessDeniedException: on 403
        :returns: {}
        """
        from requests import get
        from argus_api.exceptions import http

        url = "https://osl-argus-trunk-web1.mnemonic.no/web/api/eventfilters/v1/filter/hitstats".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 period:
            body.update({"period": period})

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

        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=('eventfilters','v1','filter'))
    def search(limit: int = None, offset: int = None, includeFlags: int = None, excludeFlags: int = None, customerID: list = None, type: str = None, description: str = None, searchString: str = None, labels: list = None, masterID: int = None, userID: list = None, filterID: list = None, associatedCaseID: list = None, hitPeriod: int = None, minimumHits: int = None, maximumHits: int = None, sortBy: list = None, startTimestamp: int = None, endTimestamp: int = None, subCriteria: list = None, includeDeleted: bool = 'False', includeCreatedTimestamp: bool = 'False', includeLastUpdatedTimestamp: bool = 'False', excludeExpired: bool = 'False', excludeFuture: bool = 'False', excludeValid: bool = 'False',json: bool = True, verify: bool = True, apiKey: str = "", authentication: dict = {}) -> dict:
        """Search filters (INTERNAL)

        :param int limit: Limit results
        :param int offset: Offset results
        :param int includeFlags: Search objects with these flags set
        :param int excludeFlags: Exclude objects with these flags set
        :param list customerID: Limit result to objects belonging to these customers
        :param str type: Limit search to filters of this type
        :param str description: Match filters by words in description
        :param str searchString: Match filters by words in entire filter configuration
        :param list labels: Limit search to filters with any of these filters
        :param int masterID: Limit search to revisions of this master ID (by default, revisions are excluded)
        :param list userID: Limit search to filters created/updated by any of these users
        :param list filterID: Limit search to these spesific filters
        :param list associatedCaseID: Limit search to filters associated to any of the listed cases. AssociatedCaseID 0 will include filters not associated to a case.
        :param int hitPeriod: When searching by filter hits, look at hits for this period (previous time period in milliseconds)
        :param int minimumHits: Limit search to filters reporting at least this number of hits for the hit period (SLOW)
        :param int maximumHits: Limit search to filters reporting at most this number of hits for the hit period (SLOW)
        :param list sortBy: Order results by these properties (prefix with - to sort descending)
        :param int startTimestamp: Search objects from this timestamp
        :param int endTimestamp: Search objects until this timestamp
        :param list subCriteria:
        :param bool includeDeleted: Also include deleted objects (where implemented)
        :param bool includeCreatedTimestamp: When limiting filters by time, include filters by created timestamp
        :param bool includeLastUpdatedTimestamp: When limiting filters by time, include filters by last updated timestamp
        :param bool excludeExpired: Exclude filters which are expired (validToTimestamp has passed)
        :param bool excludeFuture: Exclude filters which are not yet active (validFromTimestamp is in the future)
        :param bool excludeValid: Exclude filters which are currently valid
        :raises AuthenticationFailedException: on 401
        :raises ValidationFailedException: on 412
        :raises AccessDeniedException: on 403
        :returns: {"offset": 446, "limit": 647, "responseCode": 200, "count": 658, "data": [{"revision": 896, "deleted": false, "information": "Up international cell society discover.", "masterID": 765, "expired": false, "valid": false, "enabled": true, "index": 436, "flags": 103, "labels": ["She often win current."], "description": "Accept mention tax land product side might.", "id": 883, "lastUpdatedTimestamp": 264008466, "validFromTimestamp": 532162318, "validToTimestamp": 665391918, "lastUpdatedByUser": {"id": 611, "customerID": 490, "userName": "zdecker", "name": "Tammy Tucker"}, "createdTimestamp": 582131075}], "metaData": {"additionalProperties": {}}, "messages": [{"message": "Kind drive remain clear or front.", "messageTemplate": "Financial these budget tough girl.", "field": "System contain modern indeed.", "parameter": {}, "timestamp": 1234333055}], "currentPage": 273, "size": 224}
        """
        from requests import post
        from argus_api.exceptions import http

        url = "https://osl-argus-trunk-web1.mnemonic.no/web/api/eventfilters/v1/filter/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 limit:
            body.update({"limit": limit})

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        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=('eventfilters','v1','filter'))
    def get(id: int,json: bool = True, verify: bool = True, apiKey: str = "", authentication: dict = {}) -> dict:
        """Fetch filter  (INTERNAL)

        :param int id: ID of filter to fetch
        :raises AuthenticationFailedException: on 401
        :raises ValidationFailedException: on 412
        :raises AccessDeniedException: on 403
        :raises ObjectNotFoundException: on 404
        :returns: {"offset": 845, "limit": 222, "responseCode": 200, "count": 556, "metaData": {"additionalProperties": {}}, "messages": [{"message": "Reach produce these pay party themselves.", "messageTemplate": "Decide democratic teacher exist late above fill bag.", "field": "Election various hold discuss during officer.", "parameter": {}, "timestamp": 796347506}], "currentPage": 332, "size": 977}
        """
        from requests import get
        from argus_api.exceptions import http

        url = "https://osl-argus-trunk-web1.mnemonic.no/web/api/eventfilters/v1/filter/{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

    @register_command(extending=('eventfilters','v1','filter'))
    def set_log_level(id: int, level: str = None, instanceID: int = None,json: bool = True, verify: bool = True, apiKey: str = "", authentication: dict = {}) -> dict:
        """Set log level for specified filter (INTERNAL)

        :param int id: ID of event filter
        :param str level: Log level to be set for event filter
        :param int instanceID: ID of component instance to set log level for event filter, if not provided will set across instances
        :raises AuthenticationFailedException: on 401
        :raises ValidationErrorException: on 412
        :raises AccessDeniedException: on 403
        :raises ObjectNotFoundException: on 404
        :raises OperationTimeoutException: on 408
        :returns: {}
        """
        from requests import put
        from argus_api.exceptions import http

        url = "https://osl-argus-trunk-web1.mnemonic.no/web/api/eventfilters/v1/filter/{id}/logging".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 level:
            body.update({"level": level})

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

        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=('eventfilters','v1','filter'))
    def revisions(id: int, limit: int = 25, offset: int = 0,json: bool = True, verify: bool = True, apiKey: str = "", authentication: dict = {}) -> dict:
        """Fetch filter revisions by filter ID (INTERNAL)

        :param int id: Fetch revisions for filter with this ID
        :param int limit: Limit result
        :param int offset: Offset result
        :raises AuthenticationFailedException: on 401
        :raises ValidationFailedException: on 412
        :raises AccessDeniedException: on 403
        :raises ObjectNotFoundException: on 404
        :returns: {"offset": 483, "limit": 692, "responseCode": 200, "count": 462, "data": [{"revision": 344, "deleted": true, "information": "Growth others population.", "masterID": 221, "expired": false, "valid": false, "enabled": false, "index": 123, "flags": 888, "labels": ["Cover society brother about brother recently better."], "description": "Soon son plan join then sing.", "id": 106, "lastUpdatedTimestamp": 1410962745, "validFromTimestamp": 851000157, "validToTimestamp": 1155690561, "lastUpdatedByUser": {"id": 426, "customerID": 249, "userName": "james14", "name": "Natalie Walker"}, "createdTimestamp": 86129423}], "metaData": {"additionalProperties": {}}, "messages": [{"message": "Suffer recently international end oil.", "messageTemplate": "Expect view improve record book natural health.", "field": "Western front once night back career quite.", "parameter": {}, "timestamp": 363320766}], "currentPage": 421, "size": 311}
        """
        from requests import get
        from argus_api.exceptions import http

        url = "https://osl-argus-trunk-web1.mnemonic.no/web/api/eventfilters/v1/filter/{id}/revisions".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 limit:
            body.update({"limit": limit})

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

        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