def create_subscription(self, entity): '''Create a subscription. Methods emits :py:const:`opentaxii.signals.SUBSCRIPTION_CREATED` signal. :param `opentaxii.taxii.entities.SubscriptionEntity` entity: subscription entity in question. :return: updated subscription entity :rtype: :py:class:`opentaxii.taxii.entities.SubscriptionEntity` ''' created = self.api.create_subscription(entity) SUBSCRIPTION_CREATED.send(self, subscription=created) return created
from opentaxii.signals import ( CONTENT_BLOCK_CREATED, INBOX_MESSAGE_CREATED, SUBSCRIPTION_CREATED ) def post_create_content_block(manager, content_block, collection_ids, service_id): print 'Content block id=%s (collections=%s, service_id=%s) was created' % ( content_block.id, ', '.join(map(str, collection_ids)), service_id) def post_create_inbox_message(manager, inbox_message): print 'Inbox message id=%s was created' % inbox_message.id def post_create_subscription(manager, subscription): print 'Subscription id=%s (service_id=%s) was created' % (subscription.id, subscription.service_id) CONTENT_BLOCK_CREATED.connect(post_create_content_block) INBOX_MESSAGE_CREATED.connect(post_create_inbox_message) SUBSCRIPTION_CREATED.connect(post_create_subscription)