# Path: zaqarclient/queues/v2/core.py
# def queue_update(transport, request, name, metadata, callback=None):
# def queue_purge(transport, request, name, resource_types=None):
# def signed_url_create(transport, request, queue_name, paths=None,
#                       ttl_seconds=None, project_id=None, methods=None):
# def subscription_create(transport, request, queue_name, subscription_data):
# def subscription_get(transport, request, queue_name, subscription_id):
# def subscription_update(transport, request, queue_name, subscription_id,
#                         subscription_data):
# def subscription_delete(transport, request, queue_name, subscription_id):
# def subscription_list(transport, request, queue_name, **kwargs):
# def ping(transport, request, callback=None):
# def health(transport, request, callback=None):
# def homedoc(transport, request, callback=None):


from zaqarclient.queues.v2 import core
        self.subscriber = subscriber
        self.ttl = ttl
        self.options = kwargs.get('options', {})
        self.age = kwargs.get('age')
        self.confirmed = kwargs.get('confirmed')

        if auto_create:
            self.ensure_exists()

    def ensure_exists(self):
        """Ensures subscription exists

        This method is not race safe, the subscription could've been deleted
        right after it was called.
        """
        req, trans = self.client._request_and_transport()

        if not self.id and self.subscriber:
            subscription_data = {'subscriber': self.subscriber,
                                 'ttl': self.ttl,
                                 'options': self.options
                                 }
            subscription = core.subscription_create(trans, req,
                                                    self.queue_name,
                                                    subscription_data)

            if subscription and 'subscription_id' in subscription:
                self.id = subscription['subscription_id']

        if self.id:

# Path: zaqarclient/queues/v2/core.py
# def queue_update(transport, request, name, metadata, callback=None):
# def queue_purge(transport, request, name, resource_types=None):
# def signed_url_create(transport, request, queue_name, paths=None,
#                       ttl_seconds=None, project_id=None, methods=None):
# def subscription_create(transport, request, queue_name, subscription_data):
# def subscription_get(transport, request, queue_name, subscription_id):
# def subscription_update(transport, request, queue_name, subscription_id,
#                         subscription_data):
# def subscription_delete(transport, request, queue_name, subscription_id):
# def subscription_list(transport, request, queue_name, **kwargs):
# def ping(transport, request, callback=None):
# def health(transport, request, callback=None):
# def homedoc(transport, request, callback=None):


# Path: zaqarclient/queues/v2/subscription.py
from zaqarclient.queues.v2 import core

        self.subscriber = subscriber
        self.ttl = ttl
        self.options = kwargs.get('options', {})
        self.age = kwargs.get('age')
        self.confirmed = kwargs.get('confirmed')

        if auto_create:
            self.ensure_exists()

    def ensure_exists(self):
        """Ensures subscription exists

        This method is not race safe, the subscription could've been deleted
        right after it was called.
        """
        req, trans = self.client._request_and_transport()

        if not self.id and self.subscriber:
            subscription_data = {'subscriber': self.subscriber,
                                 'ttl': self.ttl,
                                 'options': self.options
                                 }
            subscription = core.subscription_create(trans, req,
                                                    self.queue_name,
                                                    subscription_data)

            if subscription and 'subscription_id' in subscription:
                self.id = subscription['subscription_id']

        if self.id:

            sub = core.subscription_get(trans, req, self.queue_name, self.id)