api.datastores.v1.descriptor — Argus-Toolbelt 1.0 documentation

# Source code for api.datastores.v1.descriptor

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

    @register_command(extending=('datastores','v1','descriptor'))
    def search_descriptors_simple(keywords: list = None, keywordField: list = None, sortBy: list = None, offset: int = 0, limit: int = 25, keywordMatch: str = 'all',json: bool = True, verify: bool = True, apiKey: str = "", authentication: dict = {}) -> dict:
        """Returns an array of DataStore descriptors matching search parameters (PUBLIC)

        :param list keywords: Search by keywords
        :param list keywordField: Set field strategy for keyword search
        :param list sortBy: Sort search result
        :param int offset: Skip a number of results
        :param int limit: Maximum number of returned results
        :param str keywordMatch: Set match strategy for keyword search
        :raises AuthenticationFailedException: on 401
        :raises ValidationErrorException: on 412
        :raises AccessDeniedException: on 403
        :returns: {"offset": 853, "limit": 313, "responseCode": 200, "count": 40, "data": [{"name": "Edward Gomez", "description": "Away simple energy peace tree institution thought dark.", "dataType": "MAP", "behaviourType": "CENTRAL", "lastUpdatedTimestamp": 1388269322, "lastUpdatedByUser": {"id": 392, "customerID": 833, "userName": "kcampbell", "name": "Dustin Rodriguez"}, "lifeTime": 122, "deleted": true, "globalData": true, "expireData": true}], "metaData": {"additionalProperties": {}}, "messages": [{"message": "Win eat support movie decide figure.", "messageTemplate": "Cause star other amount control job learn.", "field": "Ask watch recognize song customer her.", "parameter": {}, "timestamp": 1029462630}], "currentPage": 115, "size": 341}
        """
        from requests import get
        from argus_api.exceptions import http

        url = "https://osl-argus-trunk-web1.mnemonic.no/web/api/datastores/v1/descriptor".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})

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

        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=('datastores','v1','descriptor'))
    def add_data_store_descriptor(name: str = None, description: str = None, lifeTime: int = None, behaviourType: str = 'CENTRAL', dataType: str = 'MAP (key/value store)', globalData: bool = 'False', expireData: bool = 'False',json: bool = True, verify: bool = True, apiKey: str = "", authentication: dict = {}) -> dict:
        """Adds a new datastore descriptor. (PUBLIC)

        :param str name: Name for new datastore. Name must be unique.  => [a-zA-Z0-9_\-\.]*
        :param str description: Description of the datastore.  => [\s\w\{\}\$\-\(\)\.\[\]"\'_/\\,\*\+\#:@!?;]*
        :param int lifeTime: The requested expiry time in milliseconds. Requires a positive value (if expireData is true).
        :param str behaviourType: Datastore behaviour. CENTRAL stores are only updated centrally, but may be used in distributed processing. LOCAL and DISTRIBUTED stores are not stored centrally, but updated in the distributed system. DISTRIBUTED may be shared between processing nodes. (default CENTRAL)
        :param str dataType: Select data type: list of values or key/value store. (default MAP (key/value store))
        :param bool globalData: If true, datastore only accepts global data (not customer bound).
        :param bool expireData: If true, datastore entries will expire after the configured time period since added/last updated.
        :raises AuthenticationFailedException: on 401
        :raises ValidationErrorException: on 412
        :raises AccessDeniedException: on 403
        :returns: {"offset": 381, "limit": 366, "responseCode": 200, "count": 821, "metaData": {"additionalProperties": {}}, "messages": [{"message": "Edge build law generation follow.", "messageTemplate": "And center rest bad.", "field": "Door same entire.", "parameter": {}, "timestamp": 1242926809}], "currentPage": 767, "size": 323}
        """
        from requests import post
        from argus_api.exceptions import http

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

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

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

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

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

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

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

        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=('datastores','v1','descriptor'))
    def search_descriptors(limit: int = None, offset: int = None, includeFlags: int = None, excludeFlags: int = None, subCriteria: list = None, keywords: list = None, keywordFieldStrategy: list = None, keywordMatchStrategy: str = None, sortBy: list = None, includeDeleted: bool = 'False', exclude: bool = 'False', required: bool = 'False',json: bool = True, verify: bool = True, apiKey: str = "", authentication: dict = {}) -> dict:
        """Returns an array of DataStore descriptors matching 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 int includeFlags: Only include objects which have includeFlags set.
        :param int excludeFlags: Exclude objects which have excludeFlags set.
        :param list subCriteria:
        :param list keywords: Search for datastores matching keyword
        :param list keywordFieldStrategy: Defines which fields will be searched by keywords (default all supported fields).
        :param str keywordMatchStrategy: Defines the MatchStrategy for keywords (default match all keywords).
        :param list sortBy: List of properties to sort by (prefix with "-" to sort descending).
        :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": 13, "limit": 279, "responseCode": 200, "count": 947, "data": [{"name": "Valerie Perez", "description": "Win eight so card finally kid several.", "dataType": "LIST", "behaviourType": "LOCAL", "lastUpdatedTimestamp": 812957069, "lastUpdatedByUser": {"id": 848, "customerID": 748, "userName": "morganlori", "name": "Ryan Barr"}, "lifeTime": 715, "deleted": true, "globalData": true, "expireData": false}], "metaData": {"additionalProperties": {}}, "messages": [{"message": "Buy shoulder feeling area.", "messageTemplate": "Half once attention would east somebody.", "field": "Billion benefit learn learn eat allow citizen.", "parameter": {}, "timestamp": 1223681423}], "currentPage": 730, "size": 915}
        """
        from requests import post
        from argus_api.exceptions import http

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

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

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

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

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

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

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

        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=('datastores','v1','descriptor'))
    def get_descriptor(dataStore: str,json: bool = True, verify: bool = True, apiKey: str = "", authentication: dict = {}) -> dict:
        """Returns a Datastore descriptor identified by its name. (PUBLIC)

        :param str dataStore: Descriptor name
        :raises AuthenticationFailedException: on 401
        :raises ValidationErrorException: on 412
        :raises AccessDeniedException: on 403
        :raises ObjectNotFoundException: on 404
        :returns: {"offset": 633, "limit": 397, "responseCode": 200, "count": 81, "metaData": {"additionalProperties": {}}, "messages": [{"message": "People his industry guy region song week.", "messageTemplate": "Past box painting over.", "field": "Focus effect soon girl.", "parameter": {}, "timestamp": 1343520909}], "currentPage": 848, "size": 712}
        """
        from requests import get
        from argus_api.exceptions import http

        url = "https://osl-argus-trunk-web1.mnemonic.no/web/api/datastores/v1/descriptor/{dataStore}".format(dataStore=dataStore)
        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=('datastores','v1','descriptor'))
    def update_data_store_descriptor(dataStore: str, name: str = None, description: str = None, lifeTime: int = None, globalData: bool = 'False', expireData: bool = 'False',json: bool = True, verify: bool = True, apiKey: str = "", authentication: dict = {}) -> dict:
        """Updates an existing datastore descriptor. (PUBLIC)

        :param str dataStore: Store name
        :param str name: If set, request datastore to change name. All entries will be updated (so may take long time for large stores).  => [a-zA-Z0-9_\-\.]*
        :param str description: If set, update description on datastore.  => [\s\w\{\}\$\-\(\)\.\[\]"\'_/\\,\*\+\#:@!?;]*
        :param int lifeTime: If set (to positive value), change the expiry time for this datastore. Requires that the store has enabled expireData. Default is no change.
        :param bool globalData: If set, change the global data flag on this datastore. Default is no change.
        :param bool expireData: If set, change the expire data flag on this datastore. Default is no change.
        :raises AuthenticationFailedException: on 401
        :raises ValidationErrorException: on 412
        :raises AccessDeniedException: on 403
        :raises StoreNotFoundException: on 404
        :returns: {"offset": 378, "limit": 173, "responseCode": 200, "count": 813, "metaData": {"additionalProperties": {}}, "messages": [{"message": "Most hard building.", "messageTemplate": "Put program wait quality party provide.", "field": "Suffer pretty important drug law.", "parameter": {}, "timestamp": 541441206}], "currentPage": 64, "size": 87}
        """
        from requests import put
        from argus_api.exceptions import http

        url = "https://osl-argus-trunk-web1.mnemonic.no/web/api/datastores/v1/descriptor/{dataStore}".format(dataStore=dataStore)
        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 description:
            body.update({"description": description})

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

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

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

        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=('datastores','v1','descriptor'))
    def delete_data_store_descriptor(dataStore: str,json: bool = True, verify: bool = True, apiKey: str = "", authentication: dict = {}) -> dict:
        """Deletes an existing datastore descriptor. (PUBLIC)

        :param str dataStore: Store name
        :raises AuthenticationFailedException: on 401
        :raises ValidationErrorException: on 412
        :raises AccessDeniedException: on 403
        :raises StoreNotFoundException: on 404
        :returns: {"offset": 441, "limit": 649, "responseCode": 200, "count": 844, "metaData": {"additionalProperties": {}}, "messages": [{"message": "Represent sometimes sister Mr population.", "messageTemplate": "My six against.", "field": "Hear stop ever forget prove throw through.", "parameter": {}, "timestamp": 350783522}], "currentPage": 606, "size": 634}
        """
        from requests import delete
        from argus_api.exceptions import http

        url = "https://osl-argus-trunk-web1.mnemonic.no/web/api/datastores/v1/descriptor/{dataStore}".format(dataStore=dataStore)
        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