Skip to content
This repository has been archived by the owner on Nov 14, 2024. It is now read-only.

Commit

Permalink
Add backend bucket signed URL key (for CDN) support (#209)
Browse files Browse the repository at this point in the history
Signed-off-by: Modular Magician <[email protected]>
  • Loading branch information
modular-magician authored and rambleraptor committed May 20, 2019
1 parent d7717f3 commit 6bd136c
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 3 deletions.
34 changes: 34 additions & 0 deletions lib/ansible/modules/cloud/google/gcp_compute_backend_bucket.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,23 @@
description:
- Cloud Storage bucket name.
required: true
cdn_policy:
description:
- Cloud CDN configuration for this Backend Bucket.
required: false
version_added: 2.8
suboptions:
signed_url_cache_max_age_sec:
description:
- Maximum number of seconds the response to a signed URL request will be considered
fresh. Defaults to 1hr (3600s). After this time period, the response will
be revalidated before being served.
- 'When serving responses to signed URL requests, Cloud CDN will internally
behave as though all responses from this backend had a "Cache-Control: public,
max-age=[TTL]" header, regardless of any existing Cache-Control header.
The actual headers served in responses will not be altered.'
required: false
default: '3600'
description:
description:
- An optional textual description of the resource; provided by the client when
Expand Down Expand Up @@ -108,6 +125,23 @@
- Cloud Storage bucket name.
returned: success
type: str
cdnPolicy:
description:
- Cloud CDN configuration for this Backend Bucket.
returned: success
type: complex
contains:
signedUrlCacheMaxAgeSec:
description:
- Maximum number of seconds the response to a signed URL request will be considered
fresh. Defaults to 1hr (3600s). After this time period, the response will
be revalidated before being served.
- 'When serving responses to signed URL requests, Cloud CDN will internally
behave as though all responses from this backend had a "Cache-Control: public,
max-age=[TTL]" header, regardless of any existing Cache-Control header. The
actual headers served in responses will not be altered.'
returned: success
type: int
creationTimestamp:
description:
- Creation timestamp in RFC3339 text format.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,23 @@
- Cloud Storage bucket name.
returned: success
type: str
cdnPolicy:
description:
- Cloud CDN configuration for this Backend Bucket.
returned: success
type: complex
contains:
signedUrlCacheMaxAgeSec:
description:
- Maximum number of seconds the response to a signed URL request will be
considered fresh. Defaults to 1hr (3600s). After this time period, the
response will be revalidated before being served.
- 'When serving responses to signed URL requests, Cloud CDN will internally
behave as though all responses from this backend had a "Cache-Control:
public, max-age=[TTL]" header, regardless of any existing Cache-Control
header. The actual headers served in responses will not be altered.'
returned: success
type: int
creationTimestamp:
description:
- Creation timestamp in RFC3339 text format.
Expand Down
40 changes: 37 additions & 3 deletions lib/ansible/modules/cloud/google/gcp_compute_backend_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,18 @@
or query_string_blacklist, not both.
- "'&' and '=' will be percent encoded and not treated as delimiters."
required: false
signed_url_cache_max_age_sec:
description:
- Maximum number of seconds the response to a signed URL request will be considered
fresh, defaults to 1hr (3600s). After this time period, the response will
be revalidated before being served.
- 'When serving responses to signed URL requests, Cloud CDN will internally
behave as though all responses from this backend had a "Cache-Control: public,
max-age=[TTL]" header, regardless of any existing Cache-Control header.
The actual headers served in responses will not be altered.'
required: false
default: '3600'
version_added: 2.8
connection_draining:
description:
- Settings for connection draining.
Expand Down Expand Up @@ -476,6 +488,17 @@
- "'&' and '=' will be percent encoded and not treated as delimiters."
returned: success
type: list
signedUrlCacheMaxAgeSec:
description:
- Maximum number of seconds the response to a signed URL request will be considered
fresh, defaults to 1hr (3600s). After this time period, the response will
be revalidated before being served.
- 'When serving responses to signed URL requests, Cloud CDN will internally
behave as though all responses from this backend had a "Cache-Control: public,
max-age=[TTL]" header, regardless of any existing Cache-Control header. The
actual headers served in responses will not be altered.'
returned: success
type: int
connectionDraining:
description:
- Settings for connection draining.
Expand Down Expand Up @@ -646,7 +669,8 @@ def main():
query_string_blacklist=dict(type='list', elements='str'),
query_string_whitelist=dict(type='list', elements='str'),
),
)
),
signed_url_cache_max_age_sec=dict(default=3600, type='int'),
),
),
connection_draining=dict(type='dict', options=dict(draining_timeout_sec=dict(type='int'))),
Expand Down Expand Up @@ -923,10 +947,20 @@ def __init__(self, request, module):
self.request = {}

def to_request(self):
return remove_nones_from_dict({u'cacheKeyPolicy': BackendServiceCachekeypolicy(self.request.get('cache_key_policy', {}), self.module).to_request()})
return remove_nones_from_dict(
{
u'cacheKeyPolicy': BackendServiceCachekeypolicy(self.request.get('cache_key_policy', {}), self.module).to_request(),
u'signedUrlCacheMaxAgeSec': self.request.get('signed_url_cache_max_age_sec'),
}
)

def from_response(self):
return remove_nones_from_dict({u'cacheKeyPolicy': BackendServiceCachekeypolicy(self.request.get(u'cacheKeyPolicy', {}), self.module).from_response()})
return remove_nones_from_dict(
{
u'cacheKeyPolicy': BackendServiceCachekeypolicy(self.request.get(u'cacheKeyPolicy', {}), self.module).from_response(),
u'signedUrlCacheMaxAgeSec': self.request.get(u'signedUrlCacheMaxAgeSec'),
}
)


class BackendServiceCachekeypolicy(object):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,17 @@
- "'&' and '=' will be percent encoded and not treated as delimiters."
returned: success
type: list
signedUrlCacheMaxAgeSec:
description:
- Maximum number of seconds the response to a signed URL request will be
considered fresh, defaults to 1hr (3600s). After this time period, the
response will be revalidated before being served.
- 'When serving responses to signed URL requests, Cloud CDN will internally
behave as though all responses from this backend had a "Cache-Control:
public, max-age=[TTL]" header, regardless of any existing Cache-Control
header. The actual headers served in responses will not be altered.'
returned: success
type: int
connectionDraining:
description:
- Settings for connection draining.
Expand Down

0 comments on commit 6bd136c

Please sign in to comment.