Beispiel #1
0
    def post(self):
        """
        Publishes an item to a stream.
        """
        blockchain_name = data_ns.payload[BLOCKCHAIN_NAME_FIELD_NAME]
        stream_name = data_ns.payload[STREAM_NAME_FIELD_NAME]
        keys = data_ns.payload[KEYS_FIELD_NAME]
        data = data_ns.payload[DATA_FIELD_NAME]

        if not blockchain_name or not blockchain_name.strip():
            raise ValueError("The blockchain name can't be empty!")

        if not stream_name or not stream_name.strip():
            raise ValueError("The stream name can't be empty!")

        if not keys:
            raise ValueError("The list of keys can't be empty!")

        if not data:
            raise ValueError("The data can't be empty!")

        blockchain_name = blockchain_name.strip()
        stream_name = stream_name.strip()

        DataController.publish_item(blockchain_name, stream_name, keys, data)
        return {"status": "Data published!"}, status.HTTP_200_OK
Beispiel #2
0
    def get(self):
        """
        Provides information about keys in a stream
        """
        args = stream_keys_parser.parse_args(strict=True)

        blockchain_name = args[BLOCKCHAIN_NAME_FIELD_NAME]
        stream_name = args[STREAM_NAME_FIELD_NAME]
        stream_keys = args[KEYS_FIELD_NAME]
        verbose = args[VERBOSE_FIELD_NAME]
        count = args[COUNT_FIELD_NAME]
        start = args[START_FIELD_NAME]
        local_ordering = args[LOCAL_ORDERING_FIELD_NAME]

        if not blockchain_name or not blockchain_name.strip():
            raise ValueError("The blockchain name can't be empty!")

        if not stream_name or not stream_name.strip():
            raise ValueError("The stream name can't be empty!")

        blockchain_name = blockchain_name.strip()
        stream_name = stream_name.strip()
        json_data = DataController.get_stream_keys(
            blockchain_name,
            stream_name,
            stream_keys,
            verbose,
            count,
            start,
            local_ordering,
        )
        return json_data, status.HTTP_200_OK
Beispiel #3
0
    def get(self):
        """
        Retrieves items in stream which match all of the specified publishers in query. 
        """
        args = items_publishers_parser.parse_args(strict=True)

        blockchain_name = args[BLOCKCHAIN_NAME_FIELD_NAME]
        stream_name = args[STREAM_NAME_FIELD_NAME]
        publishers = args[PUBLISHERS_FIELD_NAME]
        verbose = args[VERBOSE_FIELD_NAME]

        if not blockchain_name or not blockchain_name.strip():
            raise ValueError("The blockchain name can't be empty!")

        if not stream_name or not stream_name.strip():
            raise ValueError("The stream name can't be empty!")

        if not publishers:
            raise ValueError("The list of publishers can't be empty!")

        blockchain_name = blockchain_name.strip()
        stream_name = stream_name.strip()
        json_data = DataController.get_items_by_publishers(
            blockchain_name, stream_name, publishers, verbose)
        return json_data, status.HTTP_200_OK
Beispiel #4
0
    def get(self):
        """
        Retrieves items in stream. 
        """

        args = base_parser.parse_args(strict=True)

        blockchain_name = args[BLOCKCHAIN_NAME_FIELD_NAME]
        stream_name = args[STREAM_NAME_FIELD_NAME]
        verbose = args[VERBOSE_FIELD_NAME]
        count = args[COUNT_FIELD_NAME]
        start = args[START_FIELD_NAME]
        local_ordering = args[LOCAL_ORDERING_FIELD_NAME]

        if not blockchain_name or not blockchain_name.strip():
            raise ValueError("The blockchain name can't be empty!")

        if not stream_name or not stream_name.strip():
            raise ValueError("The stream name can't be empty!")

        blockchain_name = blockchain_name.strip()
        stream_name = stream_name.strip()
        json_data = DataController.get_stream_items(blockchain_name,
                                                    stream_name, verbose,
                                                    count, start,
                                                    local_ordering)
        return json_data, status.HTTP_200_OK
Beispiel #5
0
    def get(self):
        """
        Retrieves items that belong to the specified key from stream, passed as a stream name to which the node must be subscribed.
        """
        args = items_key_parser.parse_args(strict=True)

        blockchain_name = args[BLOCKCHAIN_NAME_FIELD_NAME]
        stream_name = args[STREAM_NAME_FIELD_NAME]
        key = args[KEY_FIELD_NAME]
        verbose = args[VERBOSE_FIELD_NAME]
        count = args[COUNT_FIELD_NAME]
        start = args[START_FIELD_NAME]
        local_ordering = args[LOCAL_ORDERING_FIELD_NAME]

        if blockchain_name is None:
            raise ValueError("The " + BLOCKCHAIN_NAME_FIELD_NAME +
                             " parameter was not found in the request!")

        if stream_name is None:
            raise ValueError("The " + STREAM_NAME_FIELD_NAME +
                             " parameter was not found in the request!")

        if key is None:
            raise ValueError("The " + KEY_FIELD_NAME +
                             " parameter was not found in the request!")

        verbose = DataController.DEFAULT_VERBOSE_VALUE
        count = DataController.DEFAULT_ITEM_COUNT_VALUE
        start = DataController.DEFAULT_ITEM_START_VALUE
        local_ordering = DataController.DEFAULT_LOCAL_ORDERING_VALUE

        if not blockchain_name or not blockchain_name.strip():
            raise ValueError("The blockchain name can't be empty!")

        if not stream_name or not stream_name.strip():
            raise ValueError("The stream name can't be empty!")

        if not key or not key.strip():
            raise ValueError("The data key can't be empty!")

        blockchain_name = blockchain_name.strip()
        stream_name = stream_name.strip()
        key = key.strip()
        json_data = DataController.get_items_by_key(blockchain_name,
                                                    stream_name, key, verbose,
                                                    count, start,
                                                    local_ordering)
        return json_data, status.HTTP_200_OK