示例#1
0
    def test_feed_subscription_request(self):
        manage_feed_subscription_request1 = tm10.ManageFeedSubscriptionRequest(
            message_id=tm10.generate_message_id(),  # Required
            feed_name='SomeFeedName',   # Required
            action=tm10.ACT_UNSUBSCRIBE,  # Required
            subscription_id='SubsId056',  # Required for unsubscribe, prohibited otherwise
            delivery_parameters=delivery_parameters1)  # Required

        round_trip_message(manage_feed_subscription_request1)
示例#2
0
    def __subscription_status_request(self,
                                      action,
                                      collection_name,
                                      subscription_id=None,
                                      uri=None):
        request_parameters = dict(message_id=self._generate_id(),
                                  action=action,
                                  feed_name=collection_name,
                                  subscription_id=subscription_id)

        request = tm10.ManageFeedSubscriptionRequest(**request_parameters)
        response = self._execute_request(
            request, uri=uri, service_type=const.SVC_FEED_MANAGEMENT)

        return to_subscription_response_entity(response, version=10)
示例#3
0
    def subscribe(
        self,
        collection_name,
        inbox_service=None,
        content_bindings=None,
        uri=None,
        count_only=False,
    ):
        """Create a subscription.

        Sends a subscription request with action `SUBSCRIBE`.

        if ``uri`` is not provided, client will try to discover services and
        find Collection Management Service among them.

        Content Binding subtypes are not supported in TAXII Specification v1.0.

        :param str collection_name: target feed name
        :param `cabby.entities.InboxService` inbox_service:
                Inbox Service that will accept content pushed by TAXII Server
                in the context of this subscription
        :param list content_bindings: a list of strings or
                :py:class:`cabby.entities.ContentBinding` entities
        :param str uri: URI path to a specific Collection Management service
        :param bool count_only: IGNORED. Count Only is not supported in
               TAXII 1.0 and added here only for method unification purpose.

        :return: subscription information response
        :rtype: :py:class:`cabby.entities.SubscriptionResponse`

        :raises ValueError:
                if URI provided is invalid or schema is not supported
        :raises `cabby.exceptions.HTTPError`:
                if HTTP error happened
        :raises `cabby.exceptions.UnsuccessfulStatusError`:
                if Status Message received and status_type is not `SUCCESS`
        :raises `cabby.exceptions.ServiceNotFoundError`:
                if no service found
        :raises `cabby.exceptions.AmbiguousServicesError`:
                more than one service with type specified
        :raises `cabby.exceptions.NoURIProvidedError`:
                no URI provided and client can't discover services
        """

        request_parameters = dict(
            message_id=self._generate_id(),
            action=const.ACT_SUBSCRIBE,
            feed_name=collection_name,
        )

        if inbox_service:
            binding = (inbox_service.message_bindings[0]
                       if inbox_service.message_bindings else "")
            delivery_parameters = tm10.DeliveryParameters(
                inbox_protocol=inbox_service.protocol,
                inbox_address=inbox_service.address,
                delivery_message_binding=binding,
            )
            if content_bindings:
                delivery_parameters["content_bindings"] = [
                    tm10.ContentBinding(cb.binding_id)
                    for cb in content_bindings
                ]

            request_parameters["delivery_parameters"] = delivery_parameters

        request = tm10.ManageFeedSubscriptionRequest(**request_parameters)
        response = self._execute_request(
            request, uri=uri, service_type=const.SVC_FEED_MANAGEMENT)

        return to_subscription_response_entity(response, version=10)