Skip to content
This repository was archived by the owner on Feb 5, 2024. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions fastly/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,43 @@ def get_event_log(self, object_id):
return FastlyEventLog(self, content)


def list_gzip(self, service_id, version_number):
"""List all gzip configurations for a particular service and version"""
content = self._fetch("/service/%s/version/%d/gzip" % (service_id, version_number))
return map(lambda x: FastlyGzip(self, x), content)


def create_gzip(self, service_id, version_number, name, cache_condition=None, content_types=None, extensions=None):
body = self._formdata({
"name": name,
"cache_condition": cache_condition,
"content_types": content_types,
"extensions": extensions
}, FastlyGzip.FIELDS)
"""Creates a new Gzip object."""
content = self._fetch("/service/%s/version/%d/gzip" % (service_id, version_number), method="POST", body=body)
return FastlyGzip(self, content)


def get_gzip(self, service_id, version_number, name):
"""Retrieves a Header object by name."""
content = self._fetch("/service/%s/version/%d/gzip/%s" % (service_id, version_number, urllib.quote(name)))
return FastlyGzip(self, content)


def update_gzip(self, service_id, version_number, name_key, **kwargs):
"""Modifies an existing Gzip object by name."""
body = self._formdata(kwargs, FastlyGzip.FIELDS)
content = self._fetch("/service/%s/version/%d/gzip/%s" % (service_id, version_number, urllib.quote(name_key)), method="PUT", body=body)
return FastlyGzip(self, content)


def delete_gzip(self, service_id, version_number, name):
"""Deletes a Gzip object by name."""
content = self._fetch("/service/%s/version/%d/gzip/%s" % (service_id, version_number, urllib.quote(name)), method="DELETE")
return self._status(content)


def list_headers(self, service_id, version_number):
"""Retrieves all Header objects for a particular Version of a Service."""
content = self._fetch("/service/%s/version/%d/header" % (service_id, version_number))
Expand Down Expand Up @@ -1328,6 +1365,18 @@ class FastlyEventLog(FastlyObject):
]


class FastlyGzip(FastlyObject, IServiceVersionObject):
"""Gzip configuration allows you to choose resources to automatically compress."""
FIELDS = [
"cache_condition",
"content_types",
"extensions",
"name",
"service_id",
"version"
]


class FastlyHeader(FastlyObject, IServiceVersionObject):
"""Header objects are used to add, modify, or delete headers from requests and responses. The header content can be simple strings or be derived from variables inside Varnish. Regular expressions can be used to customize the headers even further."""
FIELDS = [
Expand Down