How to use the treq.delete function in treq

To help you get started, we’ve selected a few treq examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github glyph / lancer / lancer / _gandi.py View on Github external
def stop_responding(self, server_name, challenge, response):
        from twisted.internet import reactor
        full_name = challenge.validation_domain_name(server_name)
        subdomain = _split_zone(full_name, self._zone_name)
        url = (
            'https://dns.api.gandi.net/api/v5/domains/'
            '{zone}/records/{subdomain}/{type}'
        ).format(
            zone=self._zone_name, subdomain=subdomain, type='TXT',
        )
        if subdomain == '':
            subdomain = '@'
        response = yield treq.delete(url, headers=self._headers())
        print((yield response.text()))
        yield deferLater(reactor, self._settle_delay, lambda: None)
        print("stop settled")
github rackerlabs / otter / scripts / audit_log.py View on Github external
def clean_es(reactor):
    """
    Drops everythin from elasticsearch
    """
    return treq.delete('http://localhost:9200/_all')
github rackerlabs / otter / scripts / audit_log.py View on Github external
def clean(response):
        if response.code == 200:
            print('deleting and recreating index')
            return treq.delete('http://localhost:9200/history')
github rackerlabs / otter / otter / util / logging_treq.py View on Github external
def delete(url, **kwargs):
    """
    Wrapper around :meth:`treq.delete` that logs the request.

    See :py:func:`treq.delete`
    """
    return _log_request(treq.delete, url, **kwargs)
github opencord / voltha / voltha / adapters / adtran_olt / net / adtran_rest.py View on Github external
timeout=timeout,
                                          headers=self.REST_GET_REQUEST_HEADER)
            elif method.upper() == 'POST' or method.upper() == 'PUT':
                response = yield treq.post(url,
                                           data=data,
                                           auth=(self._username, self._password),
                                           timeout=timeout,
                                           headers=self.REST_POST_REQUEST_HEADER)
            elif method.upper() == 'PATCH':
                response = yield treq.patch(url,
                                            data=data,
                                            auth=(self._username, self._password),
                                            timeout=timeout,
                                            headers=self.REST_PATCH_REQUEST_HEADER)
            elif method.upper() == 'DELETE':
                response = yield treq.delete(url,
                                             auth=(self._username, self._password),
                                             timeout=timeout,
                                             headers=self.REST_DELETE_REQUEST_HEADER)

        except NotImplementedError:
            raise

        except (ConnectionDone, ConnectionLost):
            if is_retry:
                raise
            returnValue(self.request(method, uri, data=data, name=name,
                                     timeout=timeout, is_retry=True))

        except ConnectionClosed:
            returnValue(ConnectionClosed)