Skip to content

Commit

Permalink
Merge pull request #33 from Jimdo/response_objects_content_content_type
Browse files Browse the repository at this point in the history
Add support for content & content_type in response_object
  • Loading branch information
fstehle committed Sep 8, 2017
2 parents c88ee07 + f6ff4f2 commit 82eb08a
Show file tree
Hide file tree
Showing 38 changed files with 3,127 additions and 2,519 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ $ ansible-galaxy install Jimdo.fastly
| request_condition | false | string | |
| response | false | string | Ok |
| status | false | integer | 200 |
| content | false | string | |
| content_type | false | string | |

### VCL Snippets

Expand Down
6 changes: 5 additions & 1 deletion library/fastly_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -420,14 +420,18 @@ class FastlyResponseObject(FastlyObject):
'name': dict(required=True, type='str', default=None),
'request_condition': dict(required=False, type='str', default=''),
'response': dict(required=False, type='str', default='Ok'),
'status': dict(required=False, type='intstr', default='200')
'status': dict(required=False, type='intstr', default='200'),
'content': dict(required=False, type='str', default=''),
'content_type': dict(required=False, type='str', default='')
}

def __init__(self, config, validate_choices):
self.name = self.read_config(config, validate_choices, 'name')
self.request_condition = self.read_config(config, validate_choices, 'request_condition')
self.response = self.read_config(config, validate_choices, 'response')
self.status = self.read_config(config, validate_choices, 'status')
self.content = self.read_config(config, validate_choices, 'content')
self.content_type = self.read_config(config, validate_choices, 'content_type')

def sort_key(f):
return f.name
Expand Down
59 changes: 30 additions & 29 deletions tests/fixtures/cassettes/TestFastlyCacheSettings_tearDown.yml

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

55 changes: 27 additions & 28 deletions tests/fixtures/cassettes/TestFastlyCondition_tearDown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,84 +6,83 @@ interactions:
method: GET
uri: https://api.fastly.com/service/search?name=Fastly%20Ansible%20Module%20Test
response:
body: {string: !!python/unicode '{"name":"Fastly Ansible Module Test","deleted_at":null,"versions":[{"testing":false,"locked":false,"number":1,"active":false,"service_id":"1mcyKR4xSI08Nsw6992gS8","staging":false,"created_at":"2017-09-08T10:34:01+00:00","deleted_at":null,"comment":"","updated_at":"2017-09-08T10:34:01+00:00","deployed":false},{"testing":false,"locked":true,"number":2,"active":false,"service_id":"1mcyKR4xSI08Nsw6992gS8","staging":false,"created_at":"2017-09-08T10:34:02+00:00","deleted_at":null,"comment":"","updated_at":"2017-09-08T10:34:12+00:00","deployed":false},{"testing":false,"locked":true,"number":3,"active":false,"service_id":"1mcyKR4xSI08Nsw6992gS8","staging":false,"created_at":"2017-09-08T10:34:08+00:00","deleted_at":null,"comment":"","updated_at":"2017-09-08T10:34:18+00:00","deployed":false},{"testing":false,"number":4,"service_id":"1mcyKR4xSI08Nsw6992gS8","staging":false,"deployed":false,"locked":true,"active":true,"comment":""}],"created_at":"2017-09-08T10:34:01+00:00","customer_id":"15DqjG1ON0S28gluYrATvC","comment":"","updated_at":"2017-09-08T10:34:01+00:00","id":"1mcyKR4xSI08Nsw6992gS8"}'}
body: {string: !!python/unicode '{"name":"Fastly Ansible Module Test","deleted_at":null,"versions":[{"testing":false,"locked":false,"number":1,"active":false,"service_id":"5zX2fj2xHiyXtElLzcxpC0","staging":false,"created_at":"2017-09-08T11:20:50+00:00","deleted_at":null,"comment":"","updated_at":"2017-09-08T11:20:50+00:00","deployed":false},{"testing":false,"locked":true,"number":2,"active":false,"service_id":"5zX2fj2xHiyXtElLzcxpC0","staging":false,"created_at":"2017-09-08T11:20:51+00:00","deleted_at":null,"comment":"","updated_at":"2017-09-08T11:21:00+00:00","deployed":false},{"testing":false,"locked":true,"number":3,"active":false,"service_id":"5zX2fj2xHiyXtElLzcxpC0","staging":false,"created_at":"2017-09-08T11:20:56+00:00","deleted_at":null,"comment":"","updated_at":"2017-09-08T11:21:06+00:00","deployed":false},{"testing":false,"number":4,"service_id":"5zX2fj2xHiyXtElLzcxpC0","staging":false,"deployed":false,"locked":true,"active":true,"comment":""}],"created_at":"2017-09-08T11:20:50+00:00","customer_id":"15DqjG1ON0S28gluYrATvC","comment":"","updated_at":"2017-09-08T11:20:50+00:00","id":"5zX2fj2xHiyXtElLzcxpC0"}'}
headers:
accept-ranges: [bytes]
age: ['0']
cache-control: [no-cache]
connection: [keep-alive]
content-length: ['1100']
content-type: [application/json]
date: ['Fri, 08 Sep 2017 10:34:18 GMT']
date: ['Fri, 08 Sep 2017 11:21:07 GMT']
status: [200 OK]
vary: [Accept-Encoding]
via: [1.1 varnish, 1.1 varnish]
x-cache: ['MISS, MISS']
x-cache-hits: ['0, 0']
x-served-by: ['app-slwdc9051-SL, cache-fra1220-FRA']
x-timer: ['S1504866858.489368,VS0,VE163']
x-served-by: ['app-slwdc9051-SL, cache-fra1240-FRA']
x-timer: ['S1504869667.340541,VS0,VE158']
status: {code: 200, message: OK}
- request:
body: null
headers:
Content-Type: [application/json]
method: GET
uri: https://api.fastly.com/service/1mcyKR4xSI08Nsw6992gS8/details
uri: https://api.fastly.com/service/5zX2fj2xHiyXtElLzcxpC0/details
response:
body: {string: !!python/unicode '{"name":"Fastly Ansible Module Test","deleted_at":null,"versions":[{"testing":false,"locked":false,"number":1,"active":false,"service_id":"1mcyKR4xSI08Nsw6992gS8","staging":false,"created_at":"2017-09-08T10:34:01+00:00","deleted_at":null,"comment":"","updated_at":"2017-09-08T10:34:01+00:00","deployed":false},{"testing":false,"locked":true,"number":2,"active":false,"service_id":"1mcyKR4xSI08Nsw6992gS8","staging":false,"created_at":"2017-09-08T10:34:02+00:00","deleted_at":null,"comment":"","updated_at":"2017-09-08T10:34:12+00:00","deployed":false},{"testing":false,"locked":true,"number":3,"active":false,"service_id":"1mcyKR4xSI08Nsw6992gS8","staging":false,"created_at":"2017-09-08T10:34:08+00:00","deleted_at":null,"comment":"","updated_at":"2017-09-08T10:34:18+00:00","deployed":false},{"testing":false,"locked":true,"number":4,"active":true,"service_id":"1mcyKR4xSI08Nsw6992gS8","staging":false,"created_at":"2017-09-08T10:34:14+00:00","deleted_at":null,"comment":"","updated_at":"2017-09-08T10:34:18+00:00","deployed":false}],"created_at":"2017-09-08T10:34:01+00:00","customer_id":"15DqjG1ON0S28gluYrATvC","comment":"","updated_at":"2017-09-08T10:34:01+00:00","id":"1mcyKR4xSI08Nsw6992gS8","version":{"testing":false,"number":4,"service_id":"1mcyKR4xSI08Nsw6992gS8","staging":false,"updated_at":"2017-09-08T10:34:18+00:00","deployed":false,"locked":true,"active":true,"deleted_at":null,"created_at":"2017-09-08T10:34:14+00:00","comment":"","acls":[],"backends":[{"max_tls_version":null,"ssl_ca_cert":null,"auto_loadbalance":false,"ssl_check_cert":true,"shield":null,"hostname":null,"ssl_client_cert":null,"error_threshold":0,"request_condition":"","first_byte_timeout":15000,"ssl_cert_hostname":null,"weight":100,"client_cert":null,"address":"127.0.0.1","ssl_hostname":null,"ssl_sni_hostname":null,"min_tls_version":null,"ipv6":null,"ipv4":"127.0.0.1","connect_timeout":1000,"ssl_ciphers":null,"name":"localhost","healthcheck":null,"port":80,"max_conn":200,"use_ssl":false,"comment":"","between_bytes_timeout":10000,"ssl_client_key":null}],"cache_settings":[],"conditions":[{"priority":"0","statement":"req.url
body: {string: !!python/unicode '{"name":"Fastly Ansible Module Test","deleted_at":null,"versions":[{"testing":false,"locked":false,"number":1,"active":false,"service_id":"5zX2fj2xHiyXtElLzcxpC0","staging":false,"created_at":"2017-09-08T11:20:50+00:00","deleted_at":null,"comment":"","updated_at":"2017-09-08T11:20:50+00:00","deployed":false},{"testing":false,"locked":true,"number":2,"active":false,"service_id":"5zX2fj2xHiyXtElLzcxpC0","staging":false,"created_at":"2017-09-08T11:20:51+00:00","deleted_at":null,"comment":"","updated_at":"2017-09-08T11:21:00+00:00","deployed":false},{"testing":false,"locked":true,"number":3,"active":false,"service_id":"5zX2fj2xHiyXtElLzcxpC0","staging":false,"created_at":"2017-09-08T11:20:56+00:00","deleted_at":null,"comment":"","updated_at":"2017-09-08T11:21:06+00:00","deployed":false},{"testing":false,"locked":true,"number":4,"active":true,"service_id":"5zX2fj2xHiyXtElLzcxpC0","staging":false,"created_at":"2017-09-08T11:21:02+00:00","deleted_at":null,"comment":"","updated_at":"2017-09-08T11:21:06+00:00","deployed":false}],"created_at":"2017-09-08T11:20:50+00:00","customer_id":"15DqjG1ON0S28gluYrATvC","comment":"","updated_at":"2017-09-08T11:20:50+00:00","id":"5zX2fj2xHiyXtElLzcxpC0","version":{"testing":false,"number":4,"service_id":"5zX2fj2xHiyXtElLzcxpC0","staging":false,"updated_at":"2017-09-08T11:21:06+00:00","deployed":false,"locked":true,"active":true,"deleted_at":null,"created_at":"2017-09-08T11:21:02+00:00","comment":"","acls":[],"backends":[{"max_tls_version":null,"ssl_ca_cert":null,"auto_loadbalance":false,"ssl_check_cert":true,"shield":null,"hostname":null,"ssl_client_cert":null,"error_threshold":0,"request_condition":"","first_byte_timeout":15000,"ssl_cert_hostname":null,"weight":100,"client_cert":null,"address":"127.0.0.1","ssl_hostname":null,"ssl_sni_hostname":null,"min_tls_version":null,"ipv6":null,"ipv4":"127.0.0.1","connect_timeout":1000,"ssl_ciphers":null,"name":"localhost","healthcheck":null,"port":80,"max_conn":200,"use_ssl":false,"comment":"","between_bytes_timeout":10000,"ssl_client_key":null}],"cache_settings":[],"conditions":[{"priority":"0","statement":"req.url
~ \"^/some_asset.js\"","comment":"","name":"condition-name","type":"CACHE"}],"dictionaries":[],"directors":[],"domains":[{"comment":"","name":"example8000.com"}],"gzips":[],"headers":[{"priority":"100","src":"\"public,
max-age=86400\"","name":"Set cache control header","substitution":"","ignore_if_set":"0","cache_condition":"condition-name","request_condition":null,"regex":"","response_condition":null,"action":"set","type":"cache","dst":"http.Cache-Control"}],"healthchecks":[],"request_settings":[],"response_objects":[{"request_condition":"","content_type":null,"status":"200","response":"Ok","name":"Set
200 status code","content":null,"cache_condition":""}],"snippets":[],"vcls":[],"wordpress":[],"settings":{"general.default_ttl":3600,"general.default_host":"","general.default_pci":0}},"active_version":{"testing":false,"number":4,"service_id":"1mcyKR4xSI08Nsw6992gS8","staging":false,"updated_at":"2017-09-08T10:34:18+00:00","deployed":false,"locked":true,"active":true,"deleted_at":null,"created_at":"2017-09-08T10:34:14+00:00","comment":"","acls":[],"backends":[{"max_tls_version":null,"ssl_ca_cert":null,"auto_loadbalance":false,"ssl_check_cert":true,"shield":null,"hostname":null,"ssl_client_cert":null,"error_threshold":0,"request_condition":"","first_byte_timeout":15000,"ssl_cert_hostname":null,"weight":100,"client_cert":null,"address":"127.0.0.1","ssl_hostname":null,"ssl_sni_hostname":null,"min_tls_version":null,"ipv6":null,"ipv4":"127.0.0.1","connect_timeout":1000,"ssl_ciphers":null,"name":"localhost","healthcheck":null,"port":80,"max_conn":200,"use_ssl":false,"comment":"","between_bytes_timeout":10000,"ssl_client_key":null}],"cache_settings":[],"conditions":[{"priority":"0","statement":"req.url
max-age=86400\"","name":"Set cache control header","substitution":"","ignore_if_set":"0","cache_condition":"condition-name","request_condition":null,"regex":"","response_condition":null,"action":"set","type":"cache","dst":"http.Cache-Control"}],"healthchecks":[],"request_settings":[],"response_objects":[{"request_condition":"","content_type":"","status":"200","response":"Ok","name":"Set
200 status code","content":"","cache_condition":""}],"snippets":[],"vcls":[],"wordpress":[],"settings":{"general.default_ttl":3600,"general.default_host":"","general.default_pci":0}},"active_version":{"testing":false,"number":4,"service_id":"5zX2fj2xHiyXtElLzcxpC0","staging":false,"updated_at":"2017-09-08T11:21:06+00:00","deployed":false,"locked":true,"active":true,"deleted_at":null,"created_at":"2017-09-08T11:21:02+00:00","comment":"","acls":[],"backends":[{"max_tls_version":null,"ssl_ca_cert":null,"auto_loadbalance":false,"ssl_check_cert":true,"shield":null,"hostname":null,"ssl_client_cert":null,"error_threshold":0,"request_condition":"","first_byte_timeout":15000,"ssl_cert_hostname":null,"weight":100,"client_cert":null,"address":"127.0.0.1","ssl_hostname":null,"ssl_sni_hostname":null,"min_tls_version":null,"ipv6":null,"ipv4":"127.0.0.1","connect_timeout":1000,"ssl_ciphers":null,"name":"localhost","healthcheck":null,"port":80,"max_conn":200,"use_ssl":false,"comment":"","between_bytes_timeout":10000,"ssl_client_key":null}],"cache_settings":[],"conditions":[{"priority":"0","statement":"req.url
~ \"^/some_asset.js\"","comment":"","name":"condition-name","type":"CACHE"}],"dictionaries":[],"directors":[],"domains":[{"comment":"","name":"example8000.com"}],"gzips":[],"headers":[{"priority":"100","src":"\"public,
max-age=86400\"","name":"Set cache control header","substitution":"","ignore_if_set":"0","cache_condition":"condition-name","request_condition":null,"regex":"","response_condition":null,"action":"set","type":"cache","dst":"http.Cache-Control"}],"healthchecks":[],"request_settings":[],"response_objects":[{"request_condition":"","content_type":null,"status":"200","response":"Ok","name":"Set
200 status code","content":null,"cache_condition":""}],"snippets":[],"vcls":[],"wordpress":[],"settings":{"general.default_ttl":3600,"general.default_host":"","general.default_pci":0}}}'}
max-age=86400\"","name":"Set cache control header","substitution":"","ignore_if_set":"0","cache_condition":"condition-name","request_condition":null,"regex":"","response_condition":null,"action":"set","type":"cache","dst":"http.Cache-Control"}],"healthchecks":[],"request_settings":[],"response_objects":[{"request_condition":"","content_type":"","status":"200","response":"Ok","name":"Set
200 status code","content":"","cache_condition":""}],"snippets":[],"vcls":[],"wordpress":[],"settings":{"general.default_ttl":3600,"general.default_host":"","general.default_pci":0}}}'}
headers:
accept-ranges: [bytes]
age: ['0']
cache-control: [no-cache]
connection: [keep-alive]
content-length: ['4641']
content-length: ['4633']
content-type: [application/json]
date: ['Fri, 08 Sep 2017 10:34:18 GMT']
date: ['Fri, 08 Sep 2017 11:21:07 GMT']
status: [200 OK]
vary: [Accept-Encoding]
via: [1.1 varnish, 1.1 varnish]
x-cache: ['MISS, MISS']
x-cache-hits: ['0, 0']
x-served-by: ['app-slwdc9051-SL, cache-fra1247-FRA']
x-timer: ['S1504866859.697405,VS0,VE126']
x-served-by: ['app-slwdc9051-SL, cache-fra1224-FRA']
x-timer: ['S1504869668.544437,VS0,VE130']
status: {code: 200, message: OK}
- request:
body: null
headers:
Content-Type: [application/json]
method: PUT
uri: https://api.fastly.com/service/1mcyKR4xSI08Nsw6992gS8/version/4/deactivate
uri: https://api.fastly.com/service/5zX2fj2xHiyXtElLzcxpC0/version/4/deactivate
response:
body: {string: !!python/unicode '{"testing":false,"locked":true,"number":4,"active":false,"service_id":"1mcyKR4xSI08Nsw6992gS8","staging":false,"created_at":"2017-09-08T10:34:14+00:00","deleted_at":null,"comment":"","updated_at":"2017-09-08T10:34:18+00:00","deployed":false}'}
body: {string: !!python/unicode '{"testing":false,"locked":true,"number":4,"active":false,"service_id":"5zX2fj2xHiyXtElLzcxpC0","staging":false,"created_at":"2017-09-08T11:21:02+00:00","deleted_at":null,"comment":"","updated_at":"2017-09-08T11:21:06+00:00","deployed":false}'}
headers:
accept-ranges: [bytes]
cache-control: [no-cache]
connection: [keep-alive]
content-length: ['241']
content-type: [application/json]
date: ['Fri, 08 Sep 2017 10:34:19 GMT']
fastly-ratelimit-remaining: ['644']
fastly-ratelimit-reset: ['1504868400']
date: ['Fri, 08 Sep 2017 11:21:08 GMT']
fastly-ratelimit-remaining: ['687']
fastly-ratelimit-reset: ['1504872000']
status: [200 OK]
vary: [Accept-Encoding]
via: [1.1 varnish, 1.1 varnish]
x-cache: ['MISS, MISS']
x-cache-hits: ['0, 0']
x-served-by: ['app-slwdc9051-SL, cache-fra1241-FRA']
x-timer: ['S1504866859.864219,VS0,VE268']
x-served-by: ['app-slwdc9051-SL, cache-fra1221-FRA']
x-timer: ['S1504869668.720511,VS0,VE573']
status: {code: 200, message: OK}
- request:
body: null
headers:
Content-Type: [application/json]
method: DELETE
uri: https://api.fastly.com/service/1mcyKR4xSI08Nsw6992gS8
uri: https://api.fastly.com/service/5zX2fj2xHiyXtElLzcxpC0
response:
body: {string: !!python/unicode '{"status":"ok"}'}
headers:
Expand All @@ -92,15 +91,15 @@ interactions:
connection: [keep-alive]
content-length: ['15']
content-type: [application/json]
date: ['Fri, 08 Sep 2017 10:34:19 GMT']
fastly-ratelimit-remaining: ['643']
fastly-ratelimit-reset: ['1504868400']
date: ['Fri, 08 Sep 2017 11:21:09 GMT']
fastly-ratelimit-remaining: ['686']
fastly-ratelimit-reset: ['1504872000']
status: [200 OK]
vary: [Accept-Encoding]
via: [1.1 varnish, 1.1 varnish]
x-cache: ['MISS, MISS']
x-cache-hits: ['0, 0']
x-served-by: ['app-slwdc9051-SL, cache-fra1224-FRA']
x-timer: ['S1504866859.182953,VS0,VE546']
x-served-by: ['app-slwdc9051-SL, cache-fra1236-FRA']
x-timer: ['S1504869668.425310,VS0,VE586']
status: {code: 200, message: OK}
version: 1

0 comments on commit 82eb08a

Please sign in to comment.