How to use the fastly.auth.KeyAuthenticator function in fastly

To help you get started, we’ve selected a few fastly 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 fastly / fastly-py / fastly / fastly.py View on Github external
def authenticate_by_key(self, key):
        self.conn.authenticator = KeyAuthenticator(key)
github fastly / fastly-py / fastly / fastly.py View on Github external
def purge_key(self, service, key, soft=False):
        if not isinstance(self.conn.authenticator, KeyAuthenticator):
            raise AuthenticationError("This request requires an API key")

        headers = {}
        if soft:
            headers['Fastly-Soft-Purge'] = 1

        resp, data = self.conn.request('POST', '/service/%s/purge/%s' % (service, key), headers=headers)
        return resp.status == 200