def create(self, queue, subscriber, ttl, options, project=None): sub_container = utils._subscriber_container(queue, project) slug = uuidutils.generate_uuid() try: utils._put_or_create_container( self._client, sub_container, quote_plus(subscriber), contents=slug, headers={'x-delete-after': ttl, 'if-none-match': '*'}) except swiftclient.ClientException as exc: if exc.http_status == 412: return raise container = utils._subscription_container(queue, project) data = {'id': slug, 'source': queue, 'subscriber': subscriber, 'options': options, 'ttl': ttl, 'confirmed': False} utils._put_or_create_container( self._client, container, slug, contents=jsonutils.dumps(data), content_type='application/json', headers={'x-delete-after': ttl}) return slug
def update(self, queue, subscription_id, project=None, **kwargs): container = utils._subscription_container(queue, project) data = self.get(queue, subscription_id, project) data.pop('age') ttl = data['ttl'] if 'subscriber' in kwargs: sub_container = utils._subscriber_container(queue, project) try: self._client.put_object( sub_container, quote_plus(kwargs['subscriber']), contents=subscription_id, headers={'x-delete-after': ttl, 'if-none-match': '*'}) except swiftclient.ClientException as exc: if exc.http_status == 412: raise errors.SubscriptionAlreadyExists() raise self._client.delete_object(sub_container, quote_plus(data['subscriber'])) data.update(kwargs) self._client.put_object(container, subscription_id, contents=jsonutils.dumps(data), content_type='application/json', headers={'x-delete-after': ttl})
def create(self, queue, subscriber, ttl, options, project=None): sub_container = utils._subscriber_container(queue, project) slug = uuidutils.generate_uuid() try: utils._put_or_create_container(self._client, sub_container, quote_plus(subscriber), contents=slug, headers={ 'x-delete-after': ttl, 'if-none-match': '*' }) except swiftclient.ClientException as exc: if exc.http_status == 412: return raise container = utils._subscription_container(queue, project) data = { 'id': slug, 'source': queue, 'subscriber': subscriber, 'options': options, 'ttl': ttl, 'confirmed': False } utils._put_or_create_container(self._client, container, slug, contents=jsonutils.dumps(data), content_type='application/json', headers={'x-delete-after': ttl}) return slug
def update(self, queue, subscription_id, project=None, **kwargs): container = utils._subscription_container(queue, project) data = self.get(queue, subscription_id, project) data.pop('age') ttl = data['ttl'] if 'subscriber' in kwargs: sub_container = utils._subscriber_container(queue, project) try: self._client.put_object(sub_container, quote_plus(kwargs['subscriber']), contents=subscription_id, headers={ 'x-delete-after': ttl, 'if-none-match': '*' }) except swiftclient.ClientException as exc: if exc.http_status == 412: raise errors.SubscriptionAlreadyExists() raise self._client.delete_object(sub_container, quote_plus(data['subscriber'])) data.update(kwargs) self._client.put_object(container, subscription_id, contents=jsonutils.dumps(data), content_type='application/json', headers={'x-delete-after': ttl})
def delete(self, queue, subscription_id, project=None): try: data = self.get(queue, subscription_id, project) except errors.SubscriptionDoesNotExist: return sub_container = utils._subscriber_container(queue, project) try: self._client.delete_object(sub_container, quote_plus(data['subscriber'])) except swiftclient.ClientException as exc: if exc.http_status != 404: raise container = utils._subscription_container(queue, project) try: self._client.delete_object(container, subscription_id) except swiftclient.ClientException as exc: if exc.http_status != 404: raise
def delete(self, queue, subscription_id, project=None): try: data = self.get(queue, subscription_id, project) except errors.SubscriptionDoesNotExist: return sub_container = utils._subscriber_container(queue, project) try: self._client.delete_object(sub_container, quote_plus(data['subscriber'])) except swiftclient.ClientException as exc: if exc.http_status != 404: raise container = utils._subscription_container(queue, project) try: self._client.delete_object(container, subscription_id) except swiftclient.ClientException as exc: if exc.http_status != 404: raise
def get_with_subscriber(self, queue, subscriber, project=None): sub_container = utils._subscriber_container(queue, project) headers, obj = self._client.get_object(sub_container, quote_plus(subscriber)) return self.get(queue, obj, project)
def get_with_subscriber(self, queue, subscriber, project=None): sub_container = utils._subscriber_container(queue, project) headers, obj = self._client.get_object(sub_container, quote_plus(subscriber)) return self.get(queue, obj, project)