From 1792ac2f1d2d4b8a137450cda62a36167a22c1fd Mon Sep 17 00:00:00 2001 From: oscarDovao <31310209+oscarDovao@users.noreply.github.com> Date: Tue, 26 Nov 2019 09:37:35 +0000 Subject: [PATCH 01/37] Service waf component (#5) * service waf component new API implemented --- fastly/client.go | 5 + fastly/fixtures/wafs/cleanup.yaml | 29 +- fastly/fixtures/wafs/condition/cleanup.yaml | 15 +- fastly/fixtures/wafs/condition/create.yaml | 25 +- fastly/fixtures/wafs/create.yaml | 23 +- fastly/fixtures/wafs/create_service.yaml | 51 ++++ fastly/fixtures/wafs/delete.yaml | 18 +- fastly/fixtures/wafs/delete_service.yaml | 45 ++++ fastly/fixtures/wafs/get.yaml | 15 +- fastly/fixtures/wafs/list.yaml | 15 +- fastly/fixtures/wafs/logging/cleanup.yaml | 15 +- fastly/fixtures/wafs/logging/create.yaml | 27 +- .../wafs/response_object/cleanup.yaml | 15 +- .../wafs/response_object/cleanup_another.yaml | 16 +- .../fixtures/wafs/response_object/create.yaml | 25 +- .../wafs/response_object/create_another.yaml | 23 +- fastly/fixtures/wafs/update.yaml | 21 +- fastly/fixtures/wafs/version.yaml | 23 +- fastly/waf.go | 252 ++++++++++++++---- fastly/waf_test.go | 241 +++++++++-------- 20 files changed, 585 insertions(+), 314 deletions(-) create mode 100644 fastly/fixtures/wafs/create_service.yaml create mode 100644 fastly/fixtures/wafs/delete_service.yaml diff --git a/fastly/client.go b/fastly/client.go index 64c306a99..9cb108763 100644 --- a/fastly/client.go +++ b/fastly/client.go @@ -241,6 +241,11 @@ func (c *Client) Delete(p string, ro *RequestOptions) (*http.Response, error) { return c.Request("DELETE", p, ro) } +// DeleteJSON issues an HTTP DELETE request. +func (c *Client) DeleteJSON(p string, i interface{}, ro *RequestOptions) (*http.Response, error) { + return c.RequestJSONAPI("DELETE", p, i, ro) +} + // Request makes an HTTP request against the HTTPClient using the given verb, // Path, and request options. func (c *Client) Request(verb, p string, ro *RequestOptions) (*http.Response, error) { diff --git a/fastly/fixtures/wafs/cleanup.yaml b/fastly/fixtures/wafs/cleanup.yaml index 49b7c7b79..d71246fa2 100644 --- a/fastly/fixtures/wafs/cleanup.yaml +++ b/fastly/fixtures/wafs/cleanup.yaml @@ -2,38 +2,41 @@ version: 1 interactions: - request: - body: "" + body: | + {"data":{"type":"waf_firewall","id":"59onHkuKX28AMcf0gOojis","attributes":{"service_version_number":"2"}}} form: {} headers: + Accept: + - application/vnd.api+json + Content-Type: + - application/vnd.api+json User-Agent: - - FastlyGo/1.10.0 (+github.com/fastly/go-fastly; go1.12) - url: https://api.fastly.com/service/7i6HN3TK9wS159v2gPAZ8A/version/34/wafs/1NGmubiAYnKMtCvXWAeszf + - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) + url: https://api.fastly.com/waf/firewalls/59onHkuKX28AMcf0gOojis method: DELETE response: - body: "" + body: '{"errors":[{"title":"Resource not found","detail":"We could not find a + resource matching the one in your request"}]}' headers: Accept-Ranges: - bytes - bytes Date: - - Fri, 15 May 2020 15:35:18 GMT + - Tue, 12 Nov 2019 16:10:25 GMT Status: - - 204 No Content + - 404 Not Found Strict-Transport-Security: - max-age=31536000 Via: - 1.1 varnish - - 1.1 varnish X-Cache: - MISS, MISS X-Cache-Hits: - 0, 0 - X-Content-Type-Options: - - nosniff X-Served-By: - - cache-control-slwdc9035-CONTROL-SLWDC, cache-sea4480-SEA + - cache-control-slwdc9036-CONTROL-SLWDC, cache-lcy19279-LCY X-Timer: - - S1589556919.811961,VS0,VE135 - status: 204 No Content - code: 204 + - S1573575025.472733,VS0,VE128 + status: 404 Not Found + code: 404 duration: "" diff --git a/fastly/fixtures/wafs/condition/cleanup.yaml b/fastly/fixtures/wafs/condition/cleanup.yaml index a4ba23645..a4e0e644b 100644 --- a/fastly/fixtures/wafs/condition/cleanup.yaml +++ b/fastly/fixtures/wafs/condition/cleanup.yaml @@ -6,8 +6,8 @@ interactions: form: {} headers: User-Agent: - - FastlyGo/1.10.0 (+github.com/fastly/go-fastly; go1.12) - url: https://api.fastly.com/service/7i6HN3TK9wS159v2gPAZ8A/version/34/condition/test-waf-condition + - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) + url: https://api.fastly.com/service/6gkEdARZ3mPzhQvdi2YH3j/version/2/condition/WAF_Prefetch method: DELETE response: body: '{"status":"ok"}' @@ -20,11 +20,11 @@ interactions: Content-Type: - application/json Date: - - Fri, 15 May 2020 15:35:19 GMT + - Tue, 12 Nov 2019 16:10:26 GMT Fastly-Ratelimit-Remaining: - - "956" + - "969" Fastly-Ratelimit-Reset: - - "1589558400" + - "1573578000" Status: - 200 OK Strict-Transport-Security: @@ -33,15 +33,14 @@ interactions: - Accept-Encoding Via: - 1.1 varnish - - 1.1 varnish X-Cache: - MISS, MISS X-Cache-Hits: - 0, 0 X-Served-By: - - cache-control-slwdc9035-CONTROL-SLWDC, cache-sea4480-SEA + - cache-control-slwdc9035-CONTROL-SLWDC, cache-lcy19279-LCY X-Timer: - - S1589556919.233553,VS0,VE226 + - S1573575026.978734,VS0,VE248 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/wafs/condition/create.yaml b/fastly/fixtures/wafs/condition/create.yaml index 4296819d4..7be6f8dac 100644 --- a/fastly/fixtures/wafs/condition/create.yaml +++ b/fastly/fixtures/wafs/condition/create.yaml @@ -2,14 +2,14 @@ version: 1 interactions: - request: - body: Service=7i6HN3TK9wS159v2gPAZ8A&Version=34&name=test-waf-condition&priority=1&statement=req.url~%2B%22index.html%22&type=PREFETCH + body: Service=6gkEdARZ3mPzhQvdi2YH3j&Version=2&name=WAF_Prefetch&priority=1&statement=req.url~%2B%22index.html%22&type=PREFETCH form: Service: - - 7i6HN3TK9wS159v2gPAZ8A + - 6gkEdARZ3mPzhQvdi2YH3j Version: - - "34" + - "2" name: - - test-waf-condition + - WAF_Prefetch priority: - "1" statement: @@ -20,11 +20,11 @@ interactions: Content-Type: - application/x-www-form-urlencoded User-Agent: - - FastlyGo/1.10.0 (+github.com/fastly/go-fastly; go1.12) - url: https://api.fastly.com/service/7i6HN3TK9wS159v2gPAZ8A/version/34/condition + - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) + url: https://api.fastly.com/service/6gkEdARZ3mPzhQvdi2YH3j/version/2/condition method: POST response: - body: '{"name":"test-waf-condition","priority":"1","statement":"req.url~+\"index.html\"","type":"PREFETCH","service_id":"7i6HN3TK9wS159v2gPAZ8A","version":"34","created_at":"2020-05-15T15:35:15Z","deleted_at":null,"updated_at":"2020-05-15T15:35:15Z","comment":""}' + body: '{"name":"WAF_Prefetch","priority":"1","statement":"req.url~+\"index.html\"","type":"PREFETCH","service_id":"6gkEdARZ3mPzhQvdi2YH3j","version":"2","comment":"","deleted_at":null,"updated_at":"2019-11-12T16:10:22Z","created_at":"2019-11-12T16:10:22Z"}' headers: Accept-Ranges: - bytes @@ -34,11 +34,11 @@ interactions: Content-Type: - application/json Date: - - Fri, 15 May 2020 15:35:15 GMT + - Tue, 12 Nov 2019 16:10:22 GMT Fastly-Ratelimit-Remaining: - - "961" + - "974" Fastly-Ratelimit-Reset: - - "1589558400" + - "1573578000" Status: - 200 OK Strict-Transport-Security: @@ -47,15 +47,14 @@ interactions: - Accept-Encoding Via: - 1.1 varnish - - 1.1 varnish X-Cache: - MISS, MISS X-Cache-Hits: - 0, 0 X-Served-By: - - cache-control-slwdc9036-CONTROL-SLWDC, cache-sea4480-SEA + - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19279-LCY X-Timer: - - S1589556915.486965,VS0,VE184 + - S1573575022.958487,VS0,VE181 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/wafs/create.yaml b/fastly/fixtures/wafs/create.yaml index 31cfa528f..1571375eb 100644 --- a/fastly/fixtures/wafs/create.yaml +++ b/fastly/fixtures/wafs/create.yaml @@ -3,7 +3,7 @@ version: 1 interactions: - request: body: | - {"data":{"type":"waf","attributes":{"prefetch_condition":"test-waf-condition","response":"test-response-object"}}} + {"data":{"type":"waf_firewall","attributes":{"prefetch_condition":"WAF_Prefetch","response":"WAf_Response","service_id":"6gkEdARZ3mPzhQvdi2YH3j","service_version_number":"2"}}} form: {} headers: Accept: @@ -11,28 +11,27 @@ interactions: Content-Type: - application/vnd.api+json User-Agent: - - FastlyGo/1.10.0 (+github.com/fastly/go-fastly; go1.12) - url: https://api.fastly.com/service/7i6HN3TK9wS159v2gPAZ8A/version/34/wafs + - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) + url: https://api.fastly.com/waf/firewalls method: POST response: - body: '{"data":{"id":"1NGmubiAYnKMtCvXWAeszf","type":"waf","attributes":{"last_push":null,"prefetch_condition":"test-waf-condition","response":"test-response-object","version":34,"service_id":"7i6HN3TK9wS159v2gPAZ8A","disabled":false,"rule_statuses_log_count":0,"rule_statuses_block_count":0,"rule_statuses_disabled_count":0},"relationships":{"configuration_set":{"data":{"id":"6wvihQHbaCG7NBPTfm20S9","type":"configuration_set"}},"owasp":{"data":{"id":"7Voa4ckWs2CEQ3jewO2xr2","type":"owasp"}}}}}' + body: '{"data":{"id":"59onHkuKX28AMcf0gOojis","type":"waf_firewall","attributes":{"service_id":"6gkEdARZ3mPzhQvdi2YH3j","prefetch_condition":"WAF_Prefetch","response":"WAf_Response","disabled":false,"service_version_number":2,"created_at":"2019-11-12T16:10:23Z","updated_at":"2019-11-12T16:10:23Z","active_rules_trustwave_log_count":0,"active_rules_trustwave_block_count":0,"active_rules_fastly_log_count":0,"active_rules_fastly_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_score_count":0}}}' headers: Accept-Ranges: - bytes - bytes Content-Length: - - "490" + - "542" Content-Type: - application/vnd.api+json Date: - - Fri, 15 May 2020 15:35:16 GMT + - Tue, 12 Nov 2019 16:10:23 GMT Status: - - 200 OK + - 201 Created Strict-Transport-Security: - max-age=31536000 Via: - 1.1 varnish - - 1.1 varnish X-Cache: - MISS, MISS X-Cache-Hits: @@ -40,9 +39,9 @@ interactions: X-Content-Type-Options: - nosniff X-Served-By: - - cache-control-slwdc9036-CONTROL-SLWDC, cache-sea4480-SEA + - cache-control-slwdc9036-CONTROL-SLWDC, cache-lcy19279-LCY X-Timer: - - S1589556916.960533,VS0,VE924 - status: 200 OK - code: 200 + - S1573575023.603740,VS0,VE737 + status: 201 Created + code: 201 duration: "" diff --git a/fastly/fixtures/wafs/create_service.yaml b/fastly/fixtures/wafs/create_service.yaml new file mode 100644 index 000000000..3dff2ba24 --- /dev/null +++ b/fastly/fixtures/wafs/create_service.yaml @@ -0,0 +1,51 @@ +--- +version: 1 +interactions: +- request: + body: comment=go-fastly+client+test&name=test_service_service + form: + comment: + - go-fastly client test + name: + - test_service_service + headers: + Content-Type: + - application/x-www-form-urlencoded + User-Agent: + - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) + url: https://api.fastly.com/service + method: POST + response: + body: '{"customer_id":"WpqWFjTA4lk2N1g0GY2HH","comment":"go-fastly client test","name":"test_service_service","publish_key":"3b94816c86b3a740fe97cbfa2c1f24d00a3317d8","deleted_at":null,"created_at":"2019-11-12T16:10:20Z","updated_at":"2019-11-12T16:10:20Z","id":"6gkEdARZ3mPzhQvdi2YH3j","type":"vcl","versions":[{"service_id":"6gkEdARZ3mPzhQvdi2YH3j","deployed":false,"staging":false,"active":false,"updated_at":"2019-11-12T16:10:20Z","created_at":"2019-11-12T16:10:20Z","locked":false,"deleted_at":null,"testing":false,"number":1,"comment":""}]}' + headers: + Accept-Ranges: + - bytes + Cache-Control: + - no-cache + Content-Type: + - application/json + Date: + - Tue, 12 Nov 2019 16:10:20 GMT + Fastly-Ratelimit-Remaining: + - "977" + Fastly-Ratelimit-Reset: + - "1573578000" + Status: + - 200 OK + Strict-Transport-Security: + - max-age=31536000 + Vary: + - Accept-Encoding + Via: + - 1.1 varnish + X-Cache: + - MISS, MISS + X-Cache-Hits: + - 0, 0 + X-Served-By: + - cache-control-slwdc9035-CONTROL-SLWDC, cache-lcy19279-LCY + X-Timer: + - S1573575020.114176,VS0,VE526 + status: 200 OK + code: 200 + duration: "" diff --git a/fastly/fixtures/wafs/delete.yaml b/fastly/fixtures/wafs/delete.yaml index 93608a87d..bb1ae658b 100644 --- a/fastly/fixtures/wafs/delete.yaml +++ b/fastly/fixtures/wafs/delete.yaml @@ -2,12 +2,17 @@ version: 1 interactions: - request: - body: "" + body: | + {"data":{"type":"waf_firewall","id":"59onHkuKX28AMcf0gOojis","attributes":{"service_version_number":"2"}}} form: {} headers: + Accept: + - application/vnd.api+json + Content-Type: + - application/vnd.api+json User-Agent: - - FastlyGo/1.10.0 (+github.com/fastly/go-fastly; go1.12) - url: https://api.fastly.com/service/7i6HN3TK9wS159v2gPAZ8A/version/34/wafs/1NGmubiAYnKMtCvXWAeszf + - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) + url: https://api.fastly.com/waf/firewalls/59onHkuKX28AMcf0gOojis method: DELETE response: body: "" @@ -16,14 +21,13 @@ interactions: - bytes - bytes Date: - - Fri, 15 May 2020 15:35:18 GMT + - Tue, 12 Nov 2019 16:10:24 GMT Status: - 204 No Content Strict-Transport-Security: - max-age=31536000 Via: - 1.1 varnish - - 1.1 varnish X-Cache: - MISS, MISS X-Cache-Hits: @@ -31,9 +35,9 @@ interactions: X-Content-Type-Options: - nosniff X-Served-By: - - cache-control-slwdc9037-CONTROL-SLWDC, cache-sea4480-SEA + - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19279-LCY X-Timer: - - S1589556918.208271,VS0,VE291 + - S1573575025.533117,VS0,VE317 status: 204 No Content code: 204 duration: "" diff --git a/fastly/fixtures/wafs/delete_service.yaml b/fastly/fixtures/wafs/delete_service.yaml new file mode 100644 index 000000000..c5a50fc5b --- /dev/null +++ b/fastly/fixtures/wafs/delete_service.yaml @@ -0,0 +1,45 @@ +--- +version: 1 +interactions: +- request: + body: "" + form: {} + headers: + User-Agent: + - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) + url: https://api.fastly.com/service/6gkEdARZ3mPzhQvdi2YH3j + method: DELETE + response: + body: '{"status":"ok"}' + headers: + Accept-Ranges: + - bytes + Cache-Control: + - no-cache + Content-Type: + - application/json + Date: + - Tue, 12 Nov 2019 16:10:27 GMT + Fastly-Ratelimit-Remaining: + - "967" + Fastly-Ratelimit-Reset: + - "1573578000" + Status: + - 200 OK + Strict-Transport-Security: + - max-age=31536000 + Vary: + - Accept-Encoding + Via: + - 1.1 varnish + X-Cache: + - MISS, MISS + X-Cache-Hits: + - 0, 0 + X-Served-By: + - cache-control-slwdc9036-CONTROL-SLWDC, cache-lcy19279-LCY + X-Timer: + - S1573575027.804178,VS0,VE215 + status: 200 OK + code: 200 + duration: "" diff --git a/fastly/fixtures/wafs/get.yaml b/fastly/fixtures/wafs/get.yaml index 2c9b7abd9..6e8c7a9d5 100644 --- a/fastly/fixtures/wafs/get.yaml +++ b/fastly/fixtures/wafs/get.yaml @@ -6,11 +6,11 @@ interactions: form: {} headers: User-Agent: - - FastlyGo/1.10.0 (+github.com/fastly/go-fastly; go1.12) - url: https://api.fastly.com/service/7i6HN3TK9wS159v2gPAZ8A/version/34/wafs/1NGmubiAYnKMtCvXWAeszf + - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) + url: https://api.fastly.com/waf/firewalls/59onHkuKX28AMcf0gOojis?filter%5Bservice_version_number%5D=2 method: GET response: - body: '{"data":{"id":"1NGmubiAYnKMtCvXWAeszf","type":"waf","attributes":{"last_push":null,"prefetch_condition":"test-waf-condition","response":"test-response-object","version":34,"service_id":"7i6HN3TK9wS159v2gPAZ8A","disabled":false,"rule_statuses_log_count":0,"rule_statuses_block_count":0,"rule_statuses_disabled_count":0},"relationships":{"configuration_set":{"data":{"id":"6wvihQHbaCG7NBPTfm20S9","type":"configuration_set"}}}}}' + body: '{"data":{"id":"59onHkuKX28AMcf0gOojis","type":"waf_firewall","attributes":{"service_id":"6gkEdARZ3mPzhQvdi2YH3j","prefetch_condition":"WAF_Prefetch","response":"WAf_Response","disabled":false,"service_version_number":2,"created_at":"2019-11-12T16:10:23Z","updated_at":"2019-11-12T16:10:23Z","active_rules_trustwave_log_count":0,"active_rules_trustwave_block_count":0,"active_rules_fastly_log_count":0,"active_rules_fastly_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_score_count":0}}}' headers: Accept-Ranges: - bytes @@ -20,18 +20,17 @@ interactions: - "0" - "0" Content-Length: - - "426" + - "542" Content-Type: - application/vnd.api+json Date: - - Fri, 15 May 2020 15:35:17 GMT + - Tue, 12 Nov 2019 16:10:23 GMT Status: - 200 OK Strict-Transport-Security: - max-age=31536000 Via: - 1.1 varnish - - 1.1 varnish X-Cache: - MISS, MISS X-Cache-Hits: @@ -39,9 +38,9 @@ interactions: X-Content-Type-Options: - nosniff X-Served-By: - - cache-control-slwdc9036-CONTROL-SLWDC, cache-sea4480-SEA + - cache-control-slwdc9036-CONTROL-SLWDC, cache-lcy19279-LCY X-Timer: - - S1589556917.123551,VS0,VE170 + - S1573575024.630073,VS0,VE173 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/wafs/list.yaml b/fastly/fixtures/wafs/list.yaml index 2ab404386..98b35052b 100644 --- a/fastly/fixtures/wafs/list.yaml +++ b/fastly/fixtures/wafs/list.yaml @@ -6,11 +6,11 @@ interactions: form: {} headers: User-Agent: - - FastlyGo/1.10.0 (+github.com/fastly/go-fastly; go1.12) - url: https://api.fastly.com/service/7i6HN3TK9wS159v2gPAZ8A/version/34/wafs + - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) + url: https://api.fastly.com/waf/firewalls?filter%5Bservice_id%5D=6gkEdARZ3mPzhQvdi2YH3j&filter%5Bservice_version_number%5D=2 method: GET response: - body: '{"data":[{"id":"1NGmubiAYnKMtCvXWAeszf","type":"waf","attributes":{"last_push":null,"prefetch_condition":"test-waf-condition","response":"test-response-object","version":34,"service_id":"7i6HN3TK9wS159v2gPAZ8A","disabled":false,"rule_statuses_log_count":0,"rule_statuses_block_count":0,"rule_statuses_disabled_count":0}}],"links":{"last":"https://api.fastly.com/service/7i6HN3TK9wS159v2gPAZ8A/version/34/wafs?page[number]=1\u0026page[size]=100","first":"https://api.fastly.com/service/7i6HN3TK9wS159v2gPAZ8A/version/34/wafs?page[number]=1\u0026page[size]=100"},"meta":{"current_page":1,"per_page":100,"record_count":1,"total_pages":1}}' + body: '{"data":[{"id":"59onHkuKX28AMcf0gOojis","type":"waf_firewall","attributes":{"service_id":"6gkEdARZ3mPzhQvdi2YH3j","prefetch_condition":"WAF_Prefetch","response":"WAf_Response","disabled":false,"service_version_number":2,"created_at":"2019-11-12T16:10:23Z","updated_at":"2019-11-12T16:10:23Z","active_rules_trustwave_log_count":0,"active_rules_trustwave_block_count":0,"active_rules_fastly_log_count":0,"active_rules_fastly_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_score_count":0}}],"links":{"last":"https://api.fastly.com/waf/firewalls?filter[service_id]=6gkEdARZ3mPzhQvdi2YH3j\u0026filter[service_version_number]=2\u0026page[number]=1\u0026page[size]=100","first":"https://api.fastly.com/waf/firewalls?filter[service_id]=6gkEdARZ3mPzhQvdi2YH3j\u0026filter[service_version_number]=2\u0026page[number]=1\u0026page[size]=100"},"meta":{"current_page":1,"per_page":100,"record_count":1,"total_pages":1}}' headers: Accept-Ranges: - bytes @@ -20,18 +20,17 @@ interactions: - "0" - "0" Content-Length: - - "635" + - "961" Content-Type: - application/vnd.api+json Date: - - Fri, 15 May 2020 15:35:17 GMT + - Tue, 12 Nov 2019 16:10:23 GMT Status: - 200 OK Strict-Transport-Security: - max-age=31536000 Via: - 1.1 varnish - - 1.1 varnish X-Cache: - MISS, MISS X-Cache-Hits: @@ -39,9 +38,9 @@ interactions: X-Content-Type-Options: - nosniff X-Served-By: - - cache-control-slwdc9035-CONTROL-SLWDC, cache-sea4480-SEA + - cache-control-slwdc9036-CONTROL-SLWDC, cache-lcy19279-LCY X-Timer: - - S1589556917.899550,VS0,VE203 + - S1573575023.349598,VS0,VE175 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/wafs/logging/cleanup.yaml b/fastly/fixtures/wafs/logging/cleanup.yaml index d2dd2b0a2..8f68141da 100644 --- a/fastly/fixtures/wafs/logging/cleanup.yaml +++ b/fastly/fixtures/wafs/logging/cleanup.yaml @@ -6,8 +6,8 @@ interactions: form: {} headers: User-Agent: - - FastlyGo/1.10.0 (+github.com/fastly/go-fastly; go1.12) - url: https://api.fastly.com/service/7i6HN3TK9wS159v2gPAZ8A/version/34/logging/syslog/test-syslog + - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) + url: https://api.fastly.com/service/6gkEdARZ3mPzhQvdi2YH3j/version/2/logging/syslog/test-syslog method: DELETE response: body: '{"status":"ok"}' @@ -20,11 +20,11 @@ interactions: Content-Type: - application/json Date: - - Fri, 15 May 2020 15:35:19 GMT + - Tue, 12 Nov 2019 16:10:26 GMT Fastly-Ratelimit-Remaining: - - "955" + - "968" Fastly-Ratelimit-Reset: - - "1589558400" + - "1573578000" Status: - 200 OK Strict-Transport-Security: @@ -33,15 +33,14 @@ interactions: - Accept-Encoding Via: - 1.1 varnish - - 1.1 varnish X-Cache: - MISS, MISS X-Cache-Hits: - 0, 0 X-Served-By: - - cache-control-slwdc9037-CONTROL-SLWDC, cache-sea4480-SEA + - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19279-LCY X-Timer: - - S1589556919.477481,VS0,VE287 + - S1573575026.284242,VS0,VE480 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/wafs/logging/create.yaml b/fastly/fixtures/wafs/logging/create.yaml index d6a098ab7..39a22af1a 100644 --- a/fastly/fixtures/wafs/logging/create.yaml +++ b/fastly/fixtures/wafs/logging/create.yaml @@ -2,12 +2,20 @@ version: 1 interactions: - request: +<<<<<<< HEAD body: Service=7i6HN3TK9wS159v2gPAZ8A&Version=34&address=example.com&format=format&format_version=2&hostname=example.com&message_type=classic&name=test-syslog&port=1234&token=abcd1234 +======= + body: Service=6gkEdARZ3mPzhQvdi2YH3j&Version=2&address=example.com&format=format&format_version=2&hostname=example.com&message_type=classic&name=test-syslog&port=1234&token=abcd1234 +>>>>>>> Service waf component (#5) form: Service: - - 7i6HN3TK9wS159v2gPAZ8A + - 6gkEdARZ3mPzhQvdi2YH3j Version: +<<<<<<< HEAD - "34" +======= + - "2" +>>>>>>> Service waf component (#5) address: - example.com format: @@ -28,11 +36,11 @@ interactions: Content-Type: - application/x-www-form-urlencoded User-Agent: - - FastlyGo/1.10.0 (+github.com/fastly/go-fastly; go1.12) - url: https://api.fastly.com/service/7i6HN3TK9wS159v2gPAZ8A/version/34/logging/syslog + - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) + url: https://api.fastly.com/service/6gkEdARZ3mPzhQvdi2YH3j/version/2/logging/syslog method: POST response: - body: '{"address":"example.com","format":"format","format_version":"2","hostname":"example.com","message_type":"classic","name":"test-syslog","port":"1234","token":"abcd1234","service_id":"7i6HN3TK9wS159v2gPAZ8A","version":"34","tls_client_key":null,"tls_client_cert":null,"tls_ca_cert":null,"deleted_at":null,"updated_at":"2020-05-15T15:35:15Z","response_condition":"","tls_hostname":null,"use_tls":"0","public_key":null,"created_at":"2020-05-15T15:35:15Z","ipv4":null,"placement":null}' + body: '{"address":"example.com","format":"format","format_version":"2","hostname":"example.com","message_type":"classic","name":"test-syslog","port":"1234","token":"abcd1234","service_id":"6gkEdARZ3mPzhQvdi2YH3j","version":"2","tls_hostname":null,"public_key":null,"use_tls":"0","deleted_at":null,"response_condition":"","tls_ca_cert":null,"placement":null,"updated_at":"2019-11-12T16:10:21Z","ipv4":null,"created_at":"2019-11-12T16:10:21Z","tls_client_cert":null,"tls_client_key":null}' headers: Accept-Ranges: - bytes @@ -42,11 +50,11 @@ interactions: Content-Type: - application/json Date: - - Fri, 15 May 2020 15:35:15 GMT + - Tue, 12 Nov 2019 16:10:21 GMT Fastly-Ratelimit-Remaining: - - "962" + - "975" Fastly-Ratelimit-Reset: - - "1589558400" + - "1573578000" Status: - 200 OK Strict-Transport-Security: @@ -55,15 +63,14 @@ interactions: - Accept-Encoding Via: - 1.1 varnish - - 1.1 varnish X-Cache: - MISS, MISS X-Cache-Hits: - 0, 0 X-Served-By: - - cache-control-slwdc9035-CONTROL-SLWDC, cache-sea4480-SEA + - cache-control-slwdc9036-CONTROL-SLWDC, cache-lcy19279-LCY X-Timer: - - S1589556915.903632,VS0,VE563 + - S1573575021.168593,VS0,VE780 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/wafs/response_object/cleanup.yaml b/fastly/fixtures/wafs/response_object/cleanup.yaml index 51c8c27fd..17d361ad9 100644 --- a/fastly/fixtures/wafs/response_object/cleanup.yaml +++ b/fastly/fixtures/wafs/response_object/cleanup.yaml @@ -6,8 +6,8 @@ interactions: form: {} headers: User-Agent: - - FastlyGo/1.10.0 (+github.com/fastly/go-fastly; go1.12) - url: https://api.fastly.com/service/7i6HN3TK9wS159v2gPAZ8A/version/34/response_object/test-response-object + - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) + url: https://api.fastly.com/service/6gkEdARZ3mPzhQvdi2YH3j/version/2/response_object/WAf_Response method: DELETE response: body: '{"status":"ok"}' @@ -20,11 +20,11 @@ interactions: Content-Type: - application/json Date: - - Fri, 15 May 2020 15:35:19 GMT + - Tue, 12 Nov 2019 16:10:25 GMT Fastly-Ratelimit-Remaining: - - "957" + - "970" Fastly-Ratelimit-Reset: - - "1589558400" + - "1573578000" Status: - 200 OK Strict-Transport-Security: @@ -33,15 +33,14 @@ interactions: - Accept-Encoding Via: - 1.1 varnish - - 1.1 varnish X-Cache: - MISS, MISS X-Cache-Hits: - 0, 0 X-Served-By: - - cache-control-slwdc9035-CONTROL-SLWDC, cache-sea4480-SEA + - cache-control-slwdc9036-CONTROL-SLWDC, cache-lcy19279-LCY X-Timer: - - S1589556919.961846,VS0,VE250 + - S1573575026.606832,VS0,VE339 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/wafs/response_object/cleanup_another.yaml b/fastly/fixtures/wafs/response_object/cleanup_another.yaml index 18c67d621..646820e68 100644 --- a/fastly/fixtures/wafs/response_object/cleanup_another.yaml +++ b/fastly/fixtures/wafs/response_object/cleanup_another.yaml @@ -6,8 +6,13 @@ interactions: form: {} headers: User-Agent: +<<<<<<< HEAD - FastlyGo/1.10.0 (+github.com/fastly/go-fastly; go1.12) url: https://api.fastly.com/service/7i6HN3TK9wS159v2gPAZ8A/version/34/response_object/test-response-object-2 +======= + - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) + url: https://api.fastly.com/service/6gkEdARZ3mPzhQvdi2YH3j/version/2/response_object/test-response-object-2 +>>>>>>> Service waf component (#5) method: DELETE response: body: '{"status":"ok"}' @@ -20,11 +25,11 @@ interactions: Content-Type: - application/json Date: - - Fri, 15 May 2020 15:35:18 GMT + - Tue, 12 Nov 2019 16:10:25 GMT Fastly-Ratelimit-Remaining: - - "958" + - "971" Fastly-Ratelimit-Reset: - - "1589558400" + - "1573578000" Status: - 200 OK Strict-Transport-Security: @@ -33,15 +38,14 @@ interactions: - Accept-Encoding Via: - 1.1 varnish - - 1.1 varnish X-Cache: - MISS, MISS X-Cache-Hits: - 0, 0 X-Served-By: - - cache-control-slwdc9035-CONTROL-SLWDC, cache-sea4480-SEA + - cache-control-slwdc9035-CONTROL-SLWDC, cache-lcy19279-LCY X-Timer: - - S1589556919.517725,VS0,VE276 + - S1573575025.955392,VS0,VE478 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/wafs/response_object/create.yaml b/fastly/fixtures/wafs/response_object/create.yaml index 19e936361..68c3247a3 100644 --- a/fastly/fixtures/wafs/response_object/create.yaml +++ b/fastly/fixtures/wafs/response_object/create.yaml @@ -2,18 +2,18 @@ version: 1 interactions: - request: - body: Service=7i6HN3TK9wS159v2gPAZ8A&Version=34&content=abcd&content_type=text%2Fplain&name=test-response-object&response=Ok&status=200 + body: Service=6gkEdARZ3mPzhQvdi2YH3j&Version=2&content=abcd&content_type=text%2Fplain&name=WAf_Response&response=Ok&status=200 form: Service: - - 7i6HN3TK9wS159v2gPAZ8A + - 6gkEdARZ3mPzhQvdi2YH3j Version: - - "34" + - "2" content: - abcd content_type: - text/plain name: - - test-response-object + - WAf_Response response: - Ok status: @@ -22,11 +22,11 @@ interactions: Content-Type: - application/x-www-form-urlencoded User-Agent: - - FastlyGo/1.10.0 (+github.com/fastly/go-fastly; go1.12) - url: https://api.fastly.com/service/7i6HN3TK9wS159v2gPAZ8A/version/34/response_object + - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) + url: https://api.fastly.com/service/6gkEdARZ3mPzhQvdi2YH3j/version/2/response_object method: POST response: - body: '{"content":"abcd","content_type":"text/plain","name":"test-response-object","response":"Ok","status":"200","service_id":"7i6HN3TK9wS159v2gPAZ8A","version":"34","deleted_at":null,"updated_at":"2020-05-15T15:35:15Z","request_condition":"","cache_condition":"","created_at":"2020-05-15T15:35:15Z"}' + body: '{"content":"abcd","content_type":"text/plain","name":"WAf_Response","response":"Ok","status":"200","service_id":"6gkEdARZ3mPzhQvdi2YH3j","version":"2","created_at":"2019-11-12T16:10:22Z","deleted_at":null,"updated_at":"2019-11-12T16:10:22Z","cache_condition":"","request_condition":""}' headers: Accept-Ranges: - bytes @@ -36,11 +36,11 @@ interactions: Content-Type: - application/json Date: - - Fri, 15 May 2020 15:35:15 GMT + - Tue, 12 Nov 2019 16:10:22 GMT Fastly-Ratelimit-Remaining: - - "960" + - "973" Fastly-Ratelimit-Reset: - - "1589558400" + - "1573578000" Status: - 200 OK Strict-Transport-Security: @@ -49,15 +49,14 @@ interactions: - Accept-Encoding Via: - 1.1 varnish - - 1.1 varnish X-Cache: - MISS, MISS X-Cache-Hits: - 0, 0 X-Served-By: - - cache-control-slwdc9035-CONTROL-SLWDC, cache-sea4480-SEA + - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19279-LCY X-Timer: - - S1589556916.685716,VS0,VE256 + - S1573575022.149894,VS0,VE343 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/wafs/response_object/create_another.yaml b/fastly/fixtures/wafs/response_object/create_another.yaml index 8eb72de2f..e423104d2 100644 --- a/fastly/fixtures/wafs/response_object/create_another.yaml +++ b/fastly/fixtures/wafs/response_object/create_another.yaml @@ -2,12 +2,12 @@ version: 1 interactions: - request: - body: Service=7i6HN3TK9wS159v2gPAZ8A&Version=34&content=efgh&content_type=text%2Fplain&name=test-response-object-2&response=Ok&status=200 + body: Service=6gkEdARZ3mPzhQvdi2YH3j&Version=2&content=efgh&content_type=text%2Fplain&name=test-response-object-2&response=Ok&status=200 form: Service: - - 7i6HN3TK9wS159v2gPAZ8A + - 6gkEdARZ3mPzhQvdi2YH3j Version: - - "34" + - "2" content: - efgh content_type: @@ -22,11 +22,11 @@ interactions: Content-Type: - application/x-www-form-urlencoded User-Agent: - - FastlyGo/1.10.0 (+github.com/fastly/go-fastly; go1.12) - url: https://api.fastly.com/service/7i6HN3TK9wS159v2gPAZ8A/version/34/response_object + - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) + url: https://api.fastly.com/service/6gkEdARZ3mPzhQvdi2YH3j/version/2/response_object method: POST response: - body: '{"content":"efgh","content_type":"text/plain","name":"test-response-object-2","response":"Ok","status":"200","service_id":"7i6HN3TK9wS159v2gPAZ8A","version":"34","request_condition":"","created_at":"2020-05-15T15:35:17Z","deleted_at":null,"cache_condition":"","updated_at":"2020-05-15T15:35:17Z"}' + body: '{"content":"efgh","content_type":"text/plain","name":"test-response-object-2","response":"Ok","status":"200","service_id":"6gkEdARZ3mPzhQvdi2YH3j","version":"2","deleted_at":null,"updated_at":"2019-11-12T16:10:24Z","request_condition":"","created_at":"2019-11-12T16:10:24Z","cache_condition":""}' headers: Accept-Ranges: - bytes @@ -36,11 +36,11 @@ interactions: Content-Type: - application/json Date: - - Fri, 15 May 2020 15:35:17 GMT + - Tue, 12 Nov 2019 16:10:24 GMT Fastly-Ratelimit-Remaining: - - "959" + - "972" Fastly-Ratelimit-Reset: - - "1589558400" + - "1573578000" Status: - 200 OK Strict-Transport-Security: @@ -49,15 +49,14 @@ interactions: - Accept-Encoding Via: - 1.1 varnish - - 1.1 varnish X-Cache: - MISS, MISS X-Cache-Hits: - 0, 0 X-Served-By: - - cache-control-slwdc9036-CONTROL-SLWDC, cache-sea4480-SEA + - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19279-LCY X-Timer: - - S1589556917.459714,VS0,VE278 + - S1573575024.828564,VS0,VE366 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/wafs/update.yaml b/fastly/fixtures/wafs/update.yaml index c02b1c80b..5097ed347 100644 --- a/fastly/fixtures/wafs/update.yaml +++ b/fastly/fixtures/wafs/update.yaml @@ -3,7 +3,7 @@ version: 1 interactions: - request: body: | - {"data":{"type":"waf","id":"1NGmubiAYnKMtCvXWAeszf","attributes":{"response":"test-response-object-2"}}} + {"data":{"type":"waf_firewall","id":"59onHkuKX28AMcf0gOojis","attributes":{"prefetch_condition":"","response":"test-response-object-2","service_id":"6gkEdARZ3mPzhQvdi2YH3j","service_version_number":"2"}}} form: {} headers: Accept: @@ -11,14 +11,14 @@ interactions: Content-Type: - application/vnd.api+json User-Agent: - - FastlyGo/1.10.0 (+github.com/fastly/go-fastly; go1.12) - url: https://api.fastly.com/service/7i6HN3TK9wS159v2gPAZ8A/version/34/wafs/1NGmubiAYnKMtCvXWAeszf + - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) + url: https://api.fastly.com/waf/firewalls/59onHkuKX28AMcf0gOojis method: PATCH response: - body: '{"data":{"id":"1NGmubiAYnKMtCvXWAeszf","type":"waf","attributes":{"last_push":null,"prefetch_condition":"test-waf-condition","response":"test-response-object-2","version":34,"service_id":"7i6HN3TK9wS159v2gPAZ8A","disabled":false,"rule_statuses_log_count":0,"rule_statuses_block_count":0,"rule_statuses_disabled_count":0},"relationships":{"configuration_set":{"data":{"id":"6wvihQHbaCG7NBPTfm20S9","type":"configuration_set"}},"owasp":{"data":{"id":"7Voa4ckWs2CEQ3jewO2xr2","type":"owasp"}}}},"meta":{"warnings":[{"title":"This + body: '{"data":{"id":"59onHkuKX28AMcf0gOojis","type":"waf_firewall","attributes":{"service_id":"6gkEdARZ3mPzhQvdi2YH3j","prefetch_condition":"","response":"test-response-object-2","disabled":false,"service_version_number":2,"created_at":"2019-11-12T16:10:23Z","updated_at":"2019-11-12T16:10:23Z","active_rules_trustwave_log_count":0,"active_rules_trustwave_block_count":0,"active_rules_fastly_log_count":0,"active_rules_fastly_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_score_count":0}},"meta":{"warnings":[{"title":"This version of this service must be active","detail":"You may only update the WAF - VCL on an active version of a service. The version 34 of service 7i6HN3TK9wS159v2gPAZ8A - is not active. You may activate it through https://manage.fastly.com or through + VCL on an active version of a service. The version 2 of service 6gkEdARZ3mPzhQvdi2YH3j + is not active. You may activate it through https://app.fastly.com or through the API: https://docs.fastly.com/api/config#version Be sure to review the version''s changes before activating it."}]}}' headers: @@ -26,18 +26,17 @@ interactions: - bytes - bytes Content-Length: - - "894" + - "938" Content-Type: - application/vnd.api+json Date: - - Fri, 15 May 2020 15:35:18 GMT + - Tue, 12 Nov 2019 16:10:24 GMT Status: - 200 OK Strict-Transport-Security: - max-age=31536000 Via: - 1.1 varnish - - 1.1 varnish X-Cache: - MISS, MISS X-Cache-Hits: @@ -45,9 +44,9 @@ interactions: X-Content-Type-Options: - nosniff X-Served-By: - - cache-control-slwdc9035-CONTROL-SLWDC, cache-sea4480-SEA + - cache-control-slwdc9035-CONTROL-SLWDC, cache-lcy19279-LCY X-Timer: - - S1589556918.755702,VS0,VE318 + - S1573575024.240097,VS0,VE283 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/wafs/version.yaml b/fastly/fixtures/wafs/version.yaml index 86b06a2b0..987ac8298 100644 --- a/fastly/fixtures/wafs/version.yaml +++ b/fastly/fixtures/wafs/version.yaml @@ -2,19 +2,27 @@ version: 1 interactions: - request: - body: Service=7i6HN3TK9wS159v2gPAZ8A + body: Service=6gkEdARZ3mPzhQvdi2YH3j form: Service: - - 7i6HN3TK9wS159v2gPAZ8A + - 6gkEdARZ3mPzhQvdi2YH3j headers: Content-Type: - application/x-www-form-urlencoded User-Agent: +<<<<<<< HEAD - FastlyGo/1.10.0 (+github.com/fastly/go-fastly; go1.12) url: https://api.fastly.com/service/7i6HN3TK9wS159v2gPAZ8A/version method: POST response: body: '{"service_id":"7i6HN3TK9wS159v2gPAZ8A","number":34}' +======= + - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) + url: https://api.fastly.com/service/6gkEdARZ3mPzhQvdi2YH3j/version + method: POST + response: + body: '{"service_id":"6gkEdARZ3mPzhQvdi2YH3j","number":2}' +>>>>>>> Service waf component (#5) headers: Accept-Ranges: - bytes @@ -24,11 +32,11 @@ interactions: Content-Type: - application/json Date: - - Fri, 15 May 2020 15:35:14 GMT + - Tue, 12 Nov 2019 16:10:21 GMT Fastly-Ratelimit-Remaining: - - "963" + - "976" Fastly-Ratelimit-Reset: - - "1589558400" + - "1573578000" Status: - 200 OK Strict-Transport-Security: @@ -37,15 +45,14 @@ interactions: - Accept-Encoding Via: - 1.1 varnish - - 1.1 varnish X-Cache: - MISS, MISS X-Cache-Hits: - 0, 0 X-Served-By: - - cache-control-slwdc9037-CONTROL-SLWDC, cache-sea4480-SEA + - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19279-LCY X-Timer: - - S1589556915.603940,VS0,VE279 + - S1573575021.764746,VS0,VE374 status: 200 OK code: 200 duration: "" diff --git a/fastly/waf.go b/fastly/waf.go index 19f9f182a..a01f356f3 100644 --- a/fastly/waf.go +++ b/fastly/waf.go @@ -22,13 +22,27 @@ type WAFConfigurationSet struct { // WAF is the information about a firewall object. type WAF struct { - ID string `jsonapi:"primary,waf"` - Version int `jsonapi:"attr,version"` - PrefetchCondition string `jsonapi:"attr,prefetch_condition"` - Response string `jsonapi:"attr,response"` - LastPush *time.Time `jsonapi:"attr,last_push,iso8601"` + ID string `jsonapi:"primary,waf_firewall"` + ServiceID string `jsonapi:"attr,service_id"` + ServiceVersion int `jsonapi:"attr,service_version_number"` + PrefetchCondition string `jsonapi:"attr,prefetch_condition"` + Response string `jsonapi:"attr,response"` + Disabled bool `jsonapi:"attr,disabled"` + CreatedAt *time.Time `jsonapi:"attr,created_at,iso8601"` + UpdatedAt *time.Time `jsonapi:"attr,updated_at,iso8601"` + ActiveRulesTrustwaveLogCount int `jsonapi:"attr,active_rules_trustwave_log_count"` + ActiveRulesTrustwaveBlockCount int `jsonapi:"attr,active_rules_trustwave_block_count"` + ActiveRulesFastlyLogCount int `jsonapi:"attr,active_rules_fastly_log_count"` + ActiveRulesFastlyBlockCount int `jsonapi:"attr,active_rules_fastly_block_count"` + ActiveRulesOWASPLogCount int `jsonapi:"attr,active_rules_owasp_log_count"` + ActiveRulesOWASPBlockCount int `jsonapi:"attr,active_rules_owasp_block_count"` + ActiveRulesOWASPScoreCount int `jsonapi:"attr,active_rules_owasp_score_count"` +} - ConfigurationSet *WAFConfigurationSet `jsonapi:"relation,configuration_set"` +// WAFResponse an object containing the list of WAF results. +type WAFResponse struct { + Items []*WAF + Info infoResponse } // wafType is used for reflection because JSONAPI wants to know what it's @@ -37,30 +51,62 @@ var wafType = reflect.TypeOf(new(WAF)) // ListWAFsInput is used as input to the ListWAFs function. type ListWAFsInput struct { - // Service is the ID of the service (required). - Service string - - // Version is the specific configuration version (required). - Version int + // Limit the number of returned firewalls. + PageSize int + // Request a specific page of firewalls. + PageNumber int + // Specify the service ID of the returned firewalls. + FilterService string + // Specify the version of the service for the firewalls. + FilterVersion int + // Include relationships. Optional, comma-separated values. Permitted values: waf_firewall_versions. + Include string } -// ListWAFs returns the list of wafs for the configuration version. -func (c *Client) ListWAFs(i *ListWAFsInput) ([]*WAF, error) { - if i.Service == "" { - return nil, ErrMissingService +func (i *ListWAFsInput) formatFilters() map[string]string { + + result := map[string]string{} + pairings := map[string]interface{}{ + "page[size]": i.PageSize, + "page[number]": i.PageNumber, + "filter[service_id]": i.FilterService, + "filter[service_version_number]": i.FilterVersion, + "include": i.Include, } - if i.Version == 0 { - return nil, ErrMissingVersion + for key, value := range pairings { + switch t := reflect.TypeOf(value).String(); t { + case "string": + if value != "" { + result[key] = value.(string) + } + case "int": + if value != 0 { + result[key] = strconv.Itoa(value.(int)) + } + } } + return result +} - path := fmt.Sprintf("/service/%s/version/%d/wafs", i.Service, i.Version) - resp, err := c.Get(path, nil) +// ListWAFs returns the list of wafs for the configuration version. +func (c *Client) ListWAFs(i *ListWAFsInput) (*WAFResponse, error) { + + resp, err := c.Get("/waf/firewalls", &RequestOptions{ + Params: i.formatFilters(), + }) if err != nil { return nil, err } - data, err := jsonapi.UnmarshalManyPayload(resp.Body, wafType) + var buf bytes.Buffer + tee := io.TeeReader(resp.Body, &buf) + + info, err := getResponseInfo(tee) + if err != nil { + return nil, err + } + data, err := jsonapi.UnmarshalManyPayload(bytes.NewReader(buf.Bytes()), wafType) if err != nil { return nil, err } @@ -73,19 +119,22 @@ func (c *Client) ListWAFs(i *ListWAFsInput) ([]*WAF, error) { } wafs[i] = typed } - return wafs, nil + + return &WAFResponse{ + Items: wafs, + Info: info, + }, nil } // CreateWAFInput is used as input to the CreateWAF function. type CreateWAFInput struct { // Service is the ID of the service. Version is the specific configuration // version. Both fields are required. - Service string - Version int - - ID string `jsonapi:"primary,waf"` - PrefetchCondition string `jsonapi:"attr,prefetch_condition,omitempty"` - Response string `jsonapi:"attr,response,omitempty"` + ID string `jsonapi:"primary,waf_firewall"` + Service string `jsonapi:"attr,service_id"` + Version string `jsonapi:"attr,service_version_number"` + PrefetchCondition string `jsonapi:"attr,prefetch_condition"` + Response string `jsonapi:"attr,response"` } // CreateWAF creates a new Fastly WAF. @@ -94,11 +143,11 @@ func (c *Client) CreateWAF(i *CreateWAFInput) (*WAF, error) { return nil, ErrMissingService } - if i.Version == 0 { + if i.Version == "" { return nil, ErrMissingVersion } - path := fmt.Sprintf("/service/%s/version/%d/wafs", i.Service, i.Version) + path := "/waf/firewalls" resp, err := c.PostJSONAPI(path, i, nil) if err != nil { return nil, err @@ -116,18 +165,18 @@ type GetWAFInput struct { // Service is the ID of the service. Version is the specific configuration // version. Both fields are required. Service string - Version int - + Version string // ID is the id of the WAF to get. ID string } +// GetWAF gets details for given WAF func (c *Client) GetWAF(i *GetWAFInput) (*WAF, error) { if i.Service == "" { return nil, ErrMissingService } - if i.Version == 0 { + if i.Version == "" { return nil, ErrMissingVersion } @@ -135,8 +184,12 @@ func (c *Client) GetWAF(i *GetWAFInput) (*WAF, error) { return nil, ErrMissingWAFID } - path := fmt.Sprintf("/service/%s/version/%d/wafs/%s", i.Service, i.Version, i.ID) - resp, err := c.Get(path, nil) + path := fmt.Sprintf("/waf/firewalls/%s", i.ID) + resp, err := c.Get(path, &RequestOptions{ + Params: map[string]string{ + "filter[service_version_number]": i.Version, + }, + }) if err != nil { return nil, err } @@ -152,12 +205,11 @@ func (c *Client) GetWAF(i *GetWAFInput) (*WAF, error) { type UpdateWAFInput struct { // Service is the ID of the service. Version is the specific configuration // version. Both fields are required. - Service string - Version int - - ID string `jsonapi:"primary,waf"` - PrefetchCondition string `jsonapi:"attr,prefetch_condition,omitempty"` - Response string `jsonapi:"attr,response,omitempty"` + ID string `jsonapi:"primary,waf_firewall"` + Service string `jsonapi:"attr,service_id"` + Version string `jsonapi:"attr,service_version_number"` + PrefetchCondition string `jsonapi:"attr,prefetch_condition"` + Response string `jsonapi:"attr,response"` } // UpdateWAF updates a specific WAF. @@ -166,7 +218,7 @@ func (c *Client) UpdateWAF(i *UpdateWAFInput) (*WAF, error) { return nil, ErrMissingService } - if i.Version == 0 { + if i.Version == "" { return nil, ErrMissingVersion } @@ -174,7 +226,7 @@ func (c *Client) UpdateWAF(i *UpdateWAFInput) (*WAF, error) { return nil, ErrMissingWAFID } - path := fmt.Sprintf("/service/%s/version/%d/wafs/%s", i.Service, i.Version, i.ID) + path := fmt.Sprintf("/waf/firewalls/%s", i.ID) resp, err := c.PatchJSONAPI(path, i, nil) if err != nil { return nil, err @@ -187,32 +239,93 @@ func (c *Client) UpdateWAF(i *UpdateWAFInput) (*WAF, error) { return &waf, nil } -// DeleteWAFInput is used as input to the DeleteWAFInput function. -type DeleteWAFInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int +// EnableWAF updates a specific WAF. +func (c *Client) EnableWAF(id string) error { - // ID is the id of the WAF to delete. - ID string + if id == "" { + return ErrMissingWAFID + } + + path := fmt.Sprintf("/waf/firewalls/%s/enable", id) + resp, err := c.PatchJSONAPI(path, &UpdateWAFInput{}, nil) + if err != nil { + return err + } + + var waf WAF + if err := jsonapi.UnmarshalPayload(resp.Body, &waf); err != nil { + return err + } + return nil } -func (c *Client) DeleteWAF(i *DeleteWAFInput) error { - if i.Service == "" { - return ErrMissingService +// DisableWAF disables a WAF. +func (c *Client) DisableWAF(id string) error { + + if id == "" { + return ErrMissingWAFID + } + + path := fmt.Sprintf("/waf/firewalls/%s/disable", id) + resp, err := c.PatchJSONAPI(path, &UpdateWAFInput{}, nil) + if err != nil { + return err + } + + var waf WAF + if err := jsonapi.UnmarshalPayload(resp.Body, &waf); err != nil { + return err + } + return nil +} + +// DeployWAFInput is the input configuration used to deploy a WAF. +type DeployWAFInput struct { + // These are the ID and version of the WAF. + ID string + Version int +} + +// DeployWAFVersion deploys (i.e. activates) a WAF by version. +func (c *Client) DeployWAFVersion(i *DeployWAFInput) error { + + if i.ID == "" { + return ErrMissingWAFID } if i.Version == 0 { return ErrMissingVersion } + path := fmt.Sprintf("/waf/firewalls/%s/versions/%d", i.ID, i.Version) + _, err := c.PostJSONAPI(path, i, nil) + if err != nil { + return err + } + return nil +} + +// DeleteWAFInput is used as input to the DeleteWAFInput function. +type DeleteWAFInput struct { + // This is the WAF ID. + ID string `jsonapi:"primary,waf_firewall"` + // The service version. + Version string `jsonapi:"attr,service_version_number"` +} + +// DeleteWAF deletes a given WAF from its service. +func (c *Client) DeleteWAF(i *DeleteWAFInput) error { + + if i.Version == "" { + return ErrMissingVersion + } + if i.ID == "" { return ErrMissingWAFID } - path := fmt.Sprintf("/service/%s/version/%d/wafs/%s", i.Service, i.Version, i.ID) - _, err := c.Delete(path, nil) + path := fmt.Sprintf("/waf/firewalls/%s", i.ID) + _, err := c.DeleteJSON(path, i, nil) return err } @@ -741,6 +854,12 @@ type linksResponse struct { Links paginationInfo `json:"links"` } +// infoResponse is used to pull the links and meta from the result. +type infoResponse struct { + Links paginationInfo `json:"links"` + Meta metaInfo `json:"meta"` +} + // paginationInfo stores links to searches related to the current one, showing // any information about additional results being stored on another page type paginationInfo struct { @@ -754,6 +873,14 @@ type GetWAFRuleStatusesResponse struct { Rules []*WAFRuleStatus } +// metaInfo stores information about the result returned by the server. +type metaInfo struct { + CurrentPage int `json:"current_page,omitempty"` + PerPage int `json:"per_page,omitempty"` + RecordCount int `json:"record_count,omitempty"` + TotalPages int `json:"total_pages,omitempty"` +} + // getPages parses a response to get the pagination data without destroying // the reader we receive as "resp.Body"; this essentially copies resp.Body // and returns it so we can use it again. @@ -771,6 +898,21 @@ func getPages(body io.Reader) (paginationInfo, io.Reader, error) { return pages.Links, bytes.NewReader(buf.Bytes()), nil } +// getResponseInfo parses a response to get the pagination and metadata info. +func getResponseInfo(body io.Reader) (infoResponse, error) { + + bodyBytes, err := ioutil.ReadAll(body) + if err != nil { + return infoResponse{}, err + } + + var info infoResponse + if err := json.Unmarshal(bodyBytes, &info); err != nil { + return infoResponse{}, err + } + return info, nil +} + // GetWAFRuleStatusInput specifies the parameters for the GetWAFRuleStatus call. type GetWAFRuleStatusInput struct { ID int diff --git a/fastly/waf_test.go b/fastly/waf_test.go index 9dfc8acdc..65ab71eaa 100644 --- a/fastly/waf_test.go +++ b/fastly/waf_test.go @@ -3,23 +3,27 @@ package fastly import ( "bytes" "io/ioutil" + "reflect" + "strconv" "testing" ) func TestClient_WAFs(t *testing.T) { t.Parallel() - var err error - var tv *Version - record(t, "wafs/version", func(c *Client) { - tv = testVersion(t, c) - }) + fixtureBase := "wafs/" + + testService := createTestService(t, fixtureBase+"create_service", "service") + defer deleteTestService(t, fixtureBase+"delete_service", testService.ID) + + tv := createTestVersion(t, fixtureBase+"/version", testService.ID) + var err error // Enable logging on the service - we cannot create wafs without logging // enabled - record(t, "wafs/logging/create", func(c *Client) { + record(t, fixtureBase+"/logging/create", func(c *Client) { _, err = c.CreateSyslog(&CreateSyslogInput{ - Service: testServiceID, + Service: testService.ID, Version: tv.Number, Name: "test-syslog", Address: "example.com", @@ -35,9 +39,9 @@ func TestClient_WAFs(t *testing.T) { t.Fatal(err) } defer func() { - record(t, "wafs/logging/cleanup", func(c *Client) { + record(t, fixtureBase+"/logging/cleanup", func(c *Client) { c.DeleteSyslog(&DeleteSyslogInput{ - Service: testServiceID, + Service: testService.ID, Version: tv.Number, Name: "test-syslog", }) @@ -46,11 +50,11 @@ func TestClient_WAFs(t *testing.T) { // Create a condition - we cannot create a waf without attaching a condition var condition *Condition - record(t, "wafs/condition/create", func(c *Client) { + record(t, fixtureBase+"/condition/create", func(c *Client) { condition, err = c.CreateCondition(&CreateConditionInput{ - Service: testServiceID, + Service: testService.ID, Version: tv.Number, - Name: "test-waf-condition", + Name: "WAF_Prefetch", Statement: "req.url~+\"index.html\"", Type: "PREFETCH", // This must be a prefetch condition Priority: 1, @@ -60,22 +64,22 @@ func TestClient_WAFs(t *testing.T) { t.Fatal(err) } defer func() { - record(t, "wafs/condition/cleanup", func(c *Client) { + record(t, fixtureBase+"/condition/cleanup", func(c *Client) { c.DeleteCondition(&DeleteConditionInput{ - Service: testServiceID, + Service: testService.ID, Version: tv.Number, - Name: "test-waf-condition", + Name: condition.Name, }) }) }() // Create a response object var ro *ResponseObject - record(t, "wafs/response_object/create", func(c *Client) { + record(t, fixtureBase+"/response_object/create", func(c *Client) { ro, err = c.CreateResponseObject(&CreateResponseObjectInput{ - Service: testServiceID, + Service: testService.ID, Version: tv.Number, - Name: "test-response-object", + Name: "WAf_Response", Status: 200, Response: "Ok", Content: "abcd", @@ -86,9 +90,9 @@ func TestClient_WAFs(t *testing.T) { t.Fatal(err) } defer func() { - record(t, "wafs/response_object/cleanup", func(c *Client) { + record(t, fixtureBase+"/response_object/cleanup", func(c *Client) { c.DeleteResponseObject(&DeleteResponseObjectInput{ - Service: testServiceID, + Service: testService.ID, Version: tv.Number, Name: ro.Name, }) @@ -97,10 +101,10 @@ func TestClient_WAFs(t *testing.T) { // Create var waf *WAF - record(t, "wafs/create", func(c *Client) { + record(t, fixtureBase+"/create", func(c *Client) { waf, err = c.CreateWAF(&CreateWAFInput{ - Service: testServiceID, - Version: tv.Number, + Service: testService.ID, + Version: strconv.Itoa(tv.Number), PrefetchCondition: condition.Name, Response: ro.Name, }) @@ -110,26 +114,25 @@ func TestClient_WAFs(t *testing.T) { } // List - var wafs []*WAF - record(t, "wafs/list", func(c *Client) { - wafs, err = c.ListWAFs(&ListWAFsInput{ - Service: testServiceID, - Version: tv.Number, + var wafsResp *WAFResponse + record(t, fixtureBase+"/list", func(c *Client) { + wafsResp, err = c.ListWAFs(&ListWAFsInput{ + FilterService: testService.ID, + FilterVersion: tv.Number, }) }) if err != nil { t.Fatal(err) } - if len(wafs) < 1 { - t.Errorf("bad wafs: %v", wafs) + if len(wafsResp.Items) < 0 { + t.Errorf("bad wafs: %v", wafsResp.Items) } // Ensure deleted defer func() { - record(t, "wafs/cleanup", func(c *Client) { + record(t, fixtureBase+"/cleanup", func(c *Client) { c.DeleteWAF(&DeleteWAFInput{ - Service: testServiceID, - Version: tv.Number, + Version: strconv.Itoa(tv.Number), ID: waf.ID, }) }) @@ -137,10 +140,10 @@ func TestClient_WAFs(t *testing.T) { // Get var nwaf *WAF - record(t, "wafs/get", func(c *Client) { + record(t, fixtureBase+"/get", func(c *Client) { nwaf, err = c.GetWAF(&GetWAFInput{ - Service: testServiceID, - Version: tv.Number, + Service: testService.ID, + Version: strconv.Itoa(tv.Number), ID: waf.ID, }) }) @@ -178,9 +181,9 @@ func TestClient_WAFs(t *testing.T) { // Update // Create a new response object to attach var nro *ResponseObject - record(t, "wafs/response_object/create_another", func(c *Client) { + record(t, fixtureBase+"/response_object/create_another", func(c *Client) { nro, err = c.CreateResponseObject(&CreateResponseObjectInput{ - Service: testServiceID, + Service: testService.ID, Version: tv.Number, Name: "test-response-object-2", Status: 200, @@ -193,19 +196,19 @@ func TestClient_WAFs(t *testing.T) { t.Fatal(err) } defer func() { - record(t, "wafs/response_object/cleanup_another", func(c *Client) { + record(t, fixtureBase+"/response_object/cleanup_another", func(c *Client) { c.DeleteResponseObject(&DeleteResponseObjectInput{ - Service: testServiceID, + Service: testService.ID, Version: tv.Number, Name: nro.Name, }) }) }() var uwaf *WAF - record(t, "wafs/update", func(c *Client) { + record(t, fixtureBase+"/update", func(c *Client) { uwaf, err = c.UpdateWAF(&UpdateWAFInput{ - Service: testServiceID, - Version: tv.Number, + Service: testService.ID, + Version: strconv.Itoa(tv.Number), ID: waf.ID, Response: nro.Name, }) @@ -242,10 +245,9 @@ func TestClient_WAFs(t *testing.T) { } // Delete - record(t, "wafs/delete", func(c *Client) { + record(t, fixtureBase+"/delete", func(c *Client) { err = c.DeleteWAF(&DeleteWAFInput{ - Service: testServiceID, - Version: tv.Number, + Version: strconv.Itoa(tv.Number), ID: waf.ID, }) }) @@ -255,62 +257,88 @@ func TestClient_WAFs(t *testing.T) { } -func TestClient_ListWAFs_validation(t *testing.T) { +func TestClient_CreateWAF_validation(t *testing.T) { var err error - _, err = testClient.ListWAFs(&ListWAFsInput{ + _, err = testClient.CreateWAF(&CreateWAFInput{ Service: "", }) if err != ErrMissingService { t.Errorf("bad error: %s", err) } - _, err = testClient.ListWAFs(&ListWAFsInput{ + _, err = testClient.CreateWAF(&CreateWAFInput{ Service: "foo", - Version: 0, + Version: "", }) if err != ErrMissingVersion { t.Errorf("bad error: %s", err) } } -func TestClient_CreateWAF_validation(t *testing.T) { +func TestClient_GetWAF_validation(t *testing.T) { var err error - _, err = testClient.CreateWAF(&CreateWAFInput{ + _, err = testClient.GetWAF(&GetWAFInput{ Service: "", }) if err != ErrMissingService { t.Errorf("bad error: %s", err) } - _, err = testClient.CreateWAF(&CreateWAFInput{ + _, err = testClient.GetWAF(&GetWAFInput{ Service: "foo", - Version: 0, + Version: "", }) if err != ErrMissingVersion { t.Errorf("bad error: %s", err) } + + _, err = testClient.GetWAF(&GetWAFInput{ + Service: "foo", + Version: "1", + }) + if err != ErrMissingWAFID { + t.Errorf("bad error: %s", err) + } } -func TestClient_GetWAF_validation(t *testing.T) { +func TestClient_UpdateWAF_validation(t *testing.T) { var err error - _, err = testClient.GetWAF(&GetWAFInput{ + _, err = testClient.UpdateWAF(&UpdateWAFInput{ Service: "", }) if err != ErrMissingService { t.Errorf("bad error: %s", err) } - _, err = testClient.GetWAF(&GetWAFInput{ + _, err = testClient.UpdateWAF(&UpdateWAFInput{ Service: "foo", - Version: 0, + Version: "", }) if err != ErrMissingVersion { t.Errorf("bad error: %s", err) } - _, err = testClient.GetWAF(&GetWAFInput{ + _, err = testClient.UpdateWAF(&UpdateWAFInput{ Service: "foo", - Version: 1, + Version: "1", + ID: "", + }) + if err != ErrMissingWAFID { + t.Errorf("bad error: %s", err) + } +} + +func TestClient_DeleteWAF_validation(t *testing.T) { + var err error + err = testClient.DeleteWAF(&DeleteWAFInput{ + Version: "", + }) + if err != ErrMissingVersion { + t.Errorf("bad error: %s", err) + } + + err = testClient.DeleteWAF(&DeleteWAFInput{ + Version: "1", ID: "", }) if err != ErrMissingWAFID { @@ -318,60 +346,45 @@ func TestClient_GetWAF_validation(t *testing.T) { } } -// -// func TestClient_UpdateWAF_validation(t *testing.T) { -// var err error -// _, err = testClient.UpdateWAF(&UpdateWAFInput{ -// Service: "", -// }) -// if err != ErrMissingService { -// t.Errorf("bad error: %s", err) -// } -// -// _, err = testClient.UpdateWAF(&UpdateWAFInput{ -// Service: "foo", -// Version: 0, -// }) -// if err != ErrMissingVersion { -// t.Errorf("bad error: %s", err) -// } -// -// _, err = testClient.UpdateWAF(&UpdateWAFInput{ -// Service: "foo", -// Version: 1, -// WAFID: "", -// }) -// if err != ErrMissingWAFID { -// t.Errorf("bad error: %s", err) -// } -// } -// -// func TestClient_DeleteWAF_validation(t *testing.T) { -// var err error -// err = testClient.DeleteWAF(&DeleteWAFInput{ -// Service: "", -// }) -// if err != ErrMissingService { -// t.Errorf("bad error: %s", err) -// } -// -// err = testClient.DeleteWAF(&DeleteWAFInput{ -// Service: "foo", -// Version: 0, -// }) -// if err != ErrMissingVersion { -// t.Errorf("bad error: %s", err) -// } -// -// err = testClient.DeleteWAF(&DeleteWAFInput{ -// Service: "foo", -// Version: 1, -// WAFID: "", -// }) -// if err != ErrMissingWAFID { -// t.Errorf("bad error: %s", err) -// } -// } +func TestClient_listWAFs_formatFilters(t *testing.T) { + cases := []struct { + remote *ListWAFsInput + local map[string]string + }{ + { + remote: &ListWAFsInput{ + FilterService: "service1", + FilterVersion: 1, + }, + local: map[string]string{ + "filter[service_id]": "service1", + "filter[service_version_number]": "1", + }, + }, + { + remote: &ListWAFsInput{ + FilterService: "service1", + FilterVersion: 1, + PageSize: 2, + PageNumber: 2, + Include: "included", + }, + local: map[string]string{ + "filter[service_id]": "service1", + "filter[service_version_number]": "1", + "page[size]": "2", + "page[number]": "2", + "include": "included", + }, + }, + } + for _, c := range cases { + out := c.remote.formatFilters() + if !reflect.DeepEqual(out, c.local) { + t.Fatalf("Error matching:\nexpected: %#v\n got: %#v", c.local, out) + } + } +} func TestUpdateWAFRuleStatusesInput_validate(t *testing.T) { tests := []struct { From bedbaf644104c007f386debf636fc3718d657bf5 Mon Sep 17 00:00:00 2001 From: oscarDovao <31310209+oscarDovao@users.noreply.github.com> Date: Thu, 28 Nov 2019 12:02:30 +0000 Subject: [PATCH 02/37] Waf configuration resource (#6) * waf version (configuration) API implemented --- fastly/errors.go | 14 +- fastly/fastly_test.go | 117 +++++ fastly/fixtures/waf_versions/clone.yaml | 54 +++ .../waf_versions/condition/create.yaml | 59 +++ .../condition/delete.yaml} | 12 +- fastly/fixtures/waf_versions/deploy.yaml | 46 ++ fastly/fixtures/waf_versions/get.yaml | 51 +++ fastly/fixtures/waf_versions/list.yaml | 51 +++ fastly/fixtures/waf_versions/list_all.yaml | 54 +++ fastly/fixtures/waf_versions/lock.yaml | 49 +++ .../logging/create.yaml | 26 +- .../logging/delete.yaml} | 12 +- .../waf_versions/response_object/create.yaml | 61 +++ .../response_object/delete.yaml} | 12 +- .../service/create.yaml} | 12 +- .../service/delete.yaml} | 12 +- .../waf_versions/service/version.yaml | 50 +++ fastly/fixtures/waf_versions/update.yaml | 49 +++ fastly/fixtures/waf_versions/waf/create.yaml | 46 ++ fastly/fixtures/waf_versions/waf/delete.yaml | 42 ++ fastly/fixtures/wafs/cleanup.yaml | 10 +- fastly/fixtures/wafs/condition/create.yaml | 18 +- fastly/fixtures/wafs/condition/delete.yaml | 45 ++ fastly/fixtures/wafs/create.yaml | 10 +- fastly/fixtures/wafs/delete.yaml | 10 +- fastly/fixtures/wafs/get.yaml | 10 +- fastly/fixtures/wafs/list.yaml | 10 +- .../wafs/response_object/cleanup_another.yaml | 17 +- .../fixtures/wafs/response_object/create.yaml | 18 +- .../wafs/response_object/create_another.yaml | 18 +- .../fixtures/wafs/response_object/delete.yaml | 45 ++ fastly/fixtures/wafs/service/create.yaml | 51 +++ fastly/fixtures/wafs/service/delete.yaml | 45 ++ fastly/fixtures/wafs/service/version.yaml | 49 +++ fastly/fixtures/wafs/update.yaml | 14 +- fastly/fixtures/wafs/version.yaml | 58 --- fastly/waf.go | 29 +- fastly/waf_test.go | 94 +--- fastly/waf_version.go | 376 ++++++++++++++++ fastly/waf_version_test.go | 416 ++++++++++++++++++ 40 files changed, 1883 insertions(+), 289 deletions(-) create mode 100644 fastly/fixtures/waf_versions/clone.yaml create mode 100644 fastly/fixtures/waf_versions/condition/create.yaml rename fastly/fixtures/{wafs/condition/cleanup.yaml => waf_versions/condition/delete.yaml} (76%) create mode 100644 fastly/fixtures/waf_versions/deploy.yaml create mode 100644 fastly/fixtures/waf_versions/get.yaml create mode 100644 fastly/fixtures/waf_versions/list.yaml create mode 100644 fastly/fixtures/waf_versions/list_all.yaml create mode 100644 fastly/fixtures/waf_versions/lock.yaml rename fastly/fixtures/{wafs => waf_versions}/logging/create.yaml (59%) rename fastly/fixtures/{wafs/logging/cleanup.yaml => waf_versions/logging/delete.yaml} (76%) create mode 100644 fastly/fixtures/waf_versions/response_object/create.yaml rename fastly/fixtures/{wafs/response_object/cleanup.yaml => waf_versions/response_object/delete.yaml} (76%) rename fastly/fixtures/{wafs/create_service.yaml => waf_versions/service/create.yaml} (60%) rename fastly/fixtures/{wafs/delete_service.yaml => waf_versions/service/delete.yaml} (75%) create mode 100644 fastly/fixtures/waf_versions/service/version.yaml create mode 100644 fastly/fixtures/waf_versions/update.yaml create mode 100644 fastly/fixtures/waf_versions/waf/create.yaml create mode 100644 fastly/fixtures/waf_versions/waf/delete.yaml create mode 100644 fastly/fixtures/wafs/condition/delete.yaml create mode 100644 fastly/fixtures/wafs/response_object/delete.yaml create mode 100644 fastly/fixtures/wafs/service/create.yaml create mode 100644 fastly/fixtures/wafs/service/delete.yaml create mode 100644 fastly/fixtures/wafs/service/version.yaml delete mode 100644 fastly/fixtures/wafs/version.yaml create mode 100644 fastly/waf_version.go create mode 100644 fastly/waf_version_test.go diff --git a/fastly/errors.go b/fastly/errors.go index e16a83251..df133dd6b 100644 --- a/fastly/errors.go +++ b/fastly/errors.go @@ -101,9 +101,17 @@ var ErrMissingCustomerID = errors.New("missing required field 'CustomerID'") // requires a "EventID" key, but one was not set var ErrMissingEventID = errors.New("missing required field 'EventID'") -// ErrMissingWafID is an error that is returned was an input struct -// requires a "WafID" key, but one was not set -var ErrMissingWAFID = errors.New("missing required field 'WAFID'") +// ErrMissingWAFID is an error that is returned when an input struct +// requires a "WAFID" key, but one was not set. +var ErrMissingWAFID = errors.New("Missing required field 'WAFID'") + +// ErrMissingWAFVersionNumber is an error that is returned when an input struct +// requires a "WAFVersionNumber" key, but one was not set. +var ErrMissingWAFVersionNumber = errors.New("Missing required field 'WAFVersionNumber'") + +// ErrMissingWAFVersionID is an error that is returned when an input struct +// requires a "WAFVersionID" key, but one was not set. +var ErrMissingWAFVersionID = errors.New("Missing required field 'WAFVersionID'") // ErrMissingOWASPID is an error that is returned was an input struct // requires a "OWASPID" key, but one was not set diff --git a/fastly/fastly_test.go b/fastly/fastly_test.go index 49f9d72a5..ce1850e3e 100644 --- a/fastly/fastly_test.go +++ b/fastly/fastly_test.go @@ -277,6 +277,32 @@ func createTestPool(t *testing.T, createFixture string, serviceId string, versio return pool } +func createTestLogging(t *testing.T, fixture, serviceID string, serviceNumber int) *Syslog { + + var err error + var log *Syslog + + record(t, fixture, func(c *Client) { + log, err = c.CreateSyslog(&CreateSyslogInput{ + Service: serviceID, + Version: serviceNumber, + Name: "test-syslog", + Address: "example.com", + Hostname: "example.com", + Port: 1234, + Token: "abcd1234", + Format: "format", + FormatVersion: 2, + MessageType: "classic", + }) + }) + if err != nil { + t.Fatal(err) + } + + return log +} + func deleteTestPool(t *testing.T, pool *Pool, deleteFixture string) { var err error @@ -293,6 +319,97 @@ func deleteTestPool(t *testing.T, pool *Pool, deleteFixture string) { } } +func deleteTestLogging(t *testing.T, fixture, serviceID string, serviceNumber int) { + + var err error + + record(t, fixture, func(c *Client) { + err = c.DeleteSyslog(&DeleteSyslogInput{ + Service: serviceID, + Version: serviceNumber, + Name: "test-syslog", + }) + }) + if err != nil { + t.Fatal(err) + } +} + +func createTestWAFCondition(t *testing.T, fixture, serviceID, name string, serviceNumber int) *Condition { + + var err error + var condition *Condition + + record(t, fixture, func(c *Client) { + condition, err = c.CreateCondition(&CreateConditionInput{ + Service: serviceID, + Version: serviceNumber, + Name: name, + Statement: "req.url~+\"index.html\"", + Type: "PREFETCH", // This must be a prefetch condition + Priority: 1, + }) + }) + if err != nil { + t.Fatal(err) + } + return condition +} + +func deleteTestWAFCondition(t *testing.T, fixture, serviceID, name string, serviceNumber int) { + + var err error + + record(t, fixture, func(c *Client) { + err = c.DeleteCondition(&DeleteConditionInput{ + Service: serviceID, + Version: serviceNumber, + Name: name, + }) + }) + if err != nil { + t.Fatal(err) + } +} + +func createTestResponseObject(t *testing.T, fixture, serviceID, name string, serviceNumber int) *ResponseObject { + + var err error + var ro *ResponseObject + + record(t, fixture, func(c *Client) { + ro, err = c.CreateResponseObject(&CreateResponseObjectInput{ + Service: serviceID, + Version: serviceNumber, + Name: name, + Status: 200, + Response: "Ok", + Content: "abcd", + ContentType: "text/plain", + }) + }) + if err != nil { + t.Fatal(err) + } + return ro +} + +func deleteTestResponseObject(t *testing.T, fixture, serviceID, name string, serviceNumber int) { + + var err error + + record(t, fixture, func(c *Client) { + err = c.DeleteResponseObject(&DeleteResponseObjectInput{ + Service: serviceID, + Version: serviceNumber, + Name: name, + }) + }) + if err != nil { + t.Fatal(err) + } +} + func deleteTestService(t *testing.T, cleanupFixture string, serviceId string) { var err error diff --git a/fastly/fixtures/waf_versions/clone.yaml b/fastly/fixtures/waf_versions/clone.yaml new file mode 100644 index 000000000..2d5008851 --- /dev/null +++ b/fastly/fixtures/waf_versions/clone.yaml @@ -0,0 +1,54 @@ +--- +version: 1 +interactions: +- request: + body: | + {"data":{"type":""}} + form: {} + headers: + Accept: + - application/vnd.api+json + Content-Type: + - application/vnd.api+json + User-Agent: + - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) + url: https://api.fastly.com/waf/firewalls/3bhISXhyFhsufhCFnTst1j/versions/1/clone + method: PUT + response: + body: '{"data":{"id":"4x66aw12P6aLHGwK4KzGni","type":"waf_firewall_version","attributes":{"number":2,"comment":null,"active":null,"locked":false,"error":null,"deployed_at":null,"critical_anomaly_score":5,"error_anomaly_score":4,"warning_anomaly_score":3,"notice_anomaly_score":2,"http_violation_score_threshold":999,"inbound_anomaly_score_threshold":999,"lfi_score_threshold":999,"php_injection_score_threshold":999,"rce_score_threshold":999,"rfi_score_threshold":999,"session_fixation_score_threshold":999,"sql_injection_score_threshold":999,"xss_score_threshold":999,"paranoia_level":1,"arg_name_length":100,"arg_length":400,"total_arg_length":6400,"max_file_size":10000000,"combined_file_sizes":10000000,"max_num_args":255,"high_risk_country_codes":"","allowed_methods":"GET + HEAD POST OPTIONS PUT PATCH DELETE","restricted_headers":"/proxy/ /lock-token/ + /content-range/ /translate/ /if/","restricted_extensions":".asa/ .asax/ .ascx/ + .axd/ .backup/ .bak/ .bat/ .cdx/ .cer/ .cfg/ .cmd/ .com/ .config/ .conf/ .cs/ + .csproj/ .csr/ .dat/ .db/ .dbf/ .dll/ .dos/ .htr/ .htw/ .ida/ .idc/ .idq/ .inc/ + .ini/ .key/ .licx/ .lnk/ .log/ .mdb/ .old/ .pass/ .pdb/ .pol/ .printer/ .pwd/ + .resources/ .resx/ .sql/ .sys/ .vb/ .vbs/ .vbproj/ .vsdisco/ .webinfo/ .xsd/ + .xsx/","allowed_request_content_type":"application/x-www-form-urlencoded|multipart/form-data|text/xml|application/xml|application/soap+xml|application/x-amf|application/json|application/octet-stream|application/csp-report|application/xss-auditor-report|text/plain","allowed_request_content_type_charset":"utf-8|iso-8859-1|iso-8859-15|windows-1252","allowed_http_versions":"HTTP/1.0 + HTTP/1.1 HTTP/2","crs_validate_utf8_encoding":false,"created_at":"2019-11-25T14:43:32Z","updated_at":"2019-11-25T14:43:32Z","active_rules_trustwave_log_count":0,"active_rules_trustwave_block_count":0,"active_rules_fastly_log_count":0,"active_rules_fastly_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_score_count":0},"relationships":{"waf_firewall":{"data":{"id":"3bhISXhyFhsufhCFnTst1j","type":"waf_firewall"}}}}}' + headers: + Accept-Ranges: + - bytes + Content-Length: + - "2095" + Content-Type: + - application/vnd.api+json + Date: + - Mon, 25 Nov 2019 14:43:32 GMT + Status: + - 200 OK + Strict-Transport-Security: + - max-age=31536000 + Via: + - 1.1 varnish + X-Cache: + - MISS, MISS + X-Cache-Hits: + - 0, 0 + X-Content-Type-Options: + - nosniff + X-Served-By: + - cache-control-slwdc9036-CONTROL-SLWDC, cache-lcy19271-LCY + X-Timer: + - S1574693013.761070,VS0,VE155 + status: 200 OK + code: 200 + duration: "" diff --git a/fastly/fixtures/waf_versions/condition/create.yaml b/fastly/fixtures/waf_versions/condition/create.yaml new file mode 100644 index 000000000..87d57c108 --- /dev/null +++ b/fastly/fixtures/waf_versions/condition/create.yaml @@ -0,0 +1,59 @@ +--- +version: 1 +interactions: +- request: + body: Service=300YFPn1PVF82Na4SUkiqy&Version=2&name=WAF_Prefetch&priority=1&statement=req.url~%2B%22index.html%22&type=PREFETCH + form: + Service: + - 300YFPn1PVF82Na4SUkiqy + Version: + - "2" + name: + - WAF_Prefetch + priority: + - "1" + statement: + - req.url~+"index.html" + type: + - PREFETCH + headers: + Content-Type: + - application/x-www-form-urlencoded + User-Agent: + - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) + url: https://api.fastly.com/service/300YFPn1PVF82Na4SUkiqy/version/2/condition + method: POST + response: + body: '{"name":"WAF_Prefetch","priority":"1","statement":"req.url~+\"index.html\"","type":"PREFETCH","service_id":"300YFPn1PVF82Na4SUkiqy","version":"2","created_at":"2019-11-25T14:43:30Z","deleted_at":null,"comment":"","updated_at":"2019-11-25T14:43:30Z"}' + headers: + Accept-Ranges: + - bytes + Cache-Control: + - no-cache + Content-Type: + - application/json + Date: + - Mon, 25 Nov 2019 14:43:30 GMT + Fastly-Ratelimit-Remaining: + - "996" + Fastly-Ratelimit-Reset: + - "1574694000" + Status: + - 200 OK + Strict-Transport-Security: + - max-age=31536000 + Vary: + - Accept-Encoding + Via: + - 1.1 varnish + X-Cache: + - MISS, MISS + X-Cache-Hits: + - 0, 0 + X-Served-By: + - cache-control-slwdc9036-CONTROL-SLWDC, cache-lcy19271-LCY + X-Timer: + - S1574693011.709810,VS0,VE175 + status: 200 OK + code: 200 + duration: "" diff --git a/fastly/fixtures/wafs/condition/cleanup.yaml b/fastly/fixtures/waf_versions/condition/delete.yaml similarity index 76% rename from fastly/fixtures/wafs/condition/cleanup.yaml rename to fastly/fixtures/waf_versions/condition/delete.yaml index a4e0e644b..6a9e1ad21 100644 --- a/fastly/fixtures/wafs/condition/cleanup.yaml +++ b/fastly/fixtures/waf_versions/condition/delete.yaml @@ -7,7 +7,7 @@ interactions: headers: User-Agent: - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) - url: https://api.fastly.com/service/6gkEdARZ3mPzhQvdi2YH3j/version/2/condition/WAF_Prefetch + url: https://api.fastly.com/service/300YFPn1PVF82Na4SUkiqy/version/2/condition/WAF_Prefetch method: DELETE response: body: '{"status":"ok"}' @@ -20,11 +20,11 @@ interactions: Content-Type: - application/json Date: - - Tue, 12 Nov 2019 16:10:26 GMT + - Mon, 25 Nov 2019 14:43:35 GMT Fastly-Ratelimit-Remaining: - - "969" + - "993" Fastly-Ratelimit-Reset: - - "1573578000" + - "1574694000" Status: - 200 OK Strict-Transport-Security: @@ -38,9 +38,9 @@ interactions: X-Cache-Hits: - 0, 0 X-Served-By: - - cache-control-slwdc9035-CONTROL-SLWDC, cache-lcy19279-LCY + - cache-control-slwdc9035-CONTROL-SLWDC, cache-lcy19271-LCY X-Timer: - - S1573575026.978734,VS0,VE248 + - S1574693015.316753,VS0,VE246 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/waf_versions/deploy.yaml b/fastly/fixtures/waf_versions/deploy.yaml new file mode 100644 index 000000000..38acec62a --- /dev/null +++ b/fastly/fixtures/waf_versions/deploy.yaml @@ -0,0 +1,46 @@ +--- +version: 1 +interactions: +- request: + body: | + {"data":{"type":""}} + form: {} + headers: + Accept: + - application/vnd.api+json + Content-Type: + - application/vnd.api+json + User-Agent: + - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) + url: https://api.fastly.com/waf/firewalls/3bhISXhyFhsufhCFnTst1j/versions/1 + method: POST + response: + body: '{"errors":[],"data":null}' + headers: + Accept-Ranges: + - bytes + Content-Length: + - "25" + Content-Type: + - application/vnd.api+json + Date: + - Mon, 25 Nov 2019 14:43:32 GMT + Status: + - 202 Accepted + Strict-Transport-Security: + - max-age=31536000 + Via: + - 1.1 varnish + X-Cache: + - MISS, MISS + X-Cache-Hits: + - 0, 0 + X-Content-Type-Options: + - nosniff + X-Served-By: + - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19271-LCY + X-Timer: + - S1574693013.536450,VS0,VE158 + status: 202 Accepted + code: 202 + duration: "" diff --git a/fastly/fixtures/waf_versions/get.yaml b/fastly/fixtures/waf_versions/get.yaml new file mode 100644 index 000000000..2a0a878de --- /dev/null +++ b/fastly/fixtures/waf_versions/get.yaml @@ -0,0 +1,51 @@ +--- +version: 1 +interactions: +- request: + body: "" + form: {} + headers: + User-Agent: + - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) + url: https://api.fastly.com/waf/firewalls/3bhISXhyFhsufhCFnTst1j/versions/2 + method: GET + response: + body: '{"data":{"id":"4x66aw12P6aLHGwK4KzGni","type":"waf_firewall_version","attributes":{"number":2,"comment":null,"active":null,"locked":false,"error":null,"deployed_at":null,"critical_anomaly_score":5,"error_anomaly_score":4,"warning_anomaly_score":3,"notice_anomaly_score":2,"http_violation_score_threshold":999,"inbound_anomaly_score_threshold":999,"lfi_score_threshold":999,"php_injection_score_threshold":999,"rce_score_threshold":999,"rfi_score_threshold":999,"session_fixation_score_threshold":999,"sql_injection_score_threshold":999,"xss_score_threshold":999,"paranoia_level":1,"arg_name_length":100,"arg_length":400,"total_arg_length":6400,"max_file_size":10000000,"combined_file_sizes":10000000,"max_num_args":255,"high_risk_country_codes":"","allowed_methods":"GET + HEAD POST OPTIONS PUT PATCH DELETE","restricted_headers":"/proxy/ /lock-token/ + /content-range/ /translate/ /if/","restricted_extensions":".asa/ .asax/ .ascx/ + .axd/ .backup/ .bak/ .bat/ .cdx/ .cer/ .cfg/ .cmd/ .com/ .config/ .conf/ .cs/ + .csproj/ .csr/ .dat/ .db/ .dbf/ .dll/ .dos/ .htr/ .htw/ .ida/ .idc/ .idq/ .inc/ + .ini/ .key/ .licx/ .lnk/ .log/ .mdb/ .old/ .pass/ .pdb/ .pol/ .printer/ .pwd/ + .resources/ .resx/ .sql/ .sys/ .vb/ .vbs/ .vbproj/ .vsdisco/ .webinfo/ .xsd/ + .xsx/","allowed_request_content_type":"application/x-www-form-urlencoded|multipart/form-data|text/xml|application/xml|application/soap+xml|application/x-amf|application/json|application/octet-stream|application/csp-report|application/xss-auditor-report|text/plain","allowed_request_content_type_charset":"utf-8|iso-8859-1|iso-8859-15|windows-1252","allowed_http_versions":"HTTP/1.0 + HTTP/1.1 HTTP/2","crs_validate_utf8_encoding":false,"created_at":"2019-11-25T14:43:32Z","updated_at":"2019-11-25T14:43:32Z","active_rules_trustwave_log_count":0,"active_rules_trustwave_block_count":0,"active_rules_fastly_log_count":0,"active_rules_fastly_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_score_count":0}}}' + headers: + Accept-Ranges: + - bytes + Age: + - "0" + Content-Length: + - "1999" + Content-Type: + - application/vnd.api+json + Date: + - Mon, 25 Nov 2019 14:43:33 GMT + Status: + - 200 OK + Strict-Transport-Security: + - max-age=31536000 + Via: + - 1.1 varnish + X-Cache: + - MISS, MISS + X-Cache-Hits: + - 0, 0 + X-Content-Type-Options: + - nosniff + X-Served-By: + - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19271-LCY + X-Timer: + - S1574693013.970868,VS0,VE452 + status: 200 OK + code: 200 + duration: "" diff --git a/fastly/fixtures/waf_versions/list.yaml b/fastly/fixtures/waf_versions/list.yaml new file mode 100644 index 000000000..aab15354b --- /dev/null +++ b/fastly/fixtures/waf_versions/list.yaml @@ -0,0 +1,51 @@ +--- +version: 1 +interactions: +- request: + body: "" + form: {} + headers: + User-Agent: + - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) + url: https://api.fastly.com/waf/firewalls/3bhISXhyFhsufhCFnTst1j/versions + method: GET + response: + body: '{"data":[{"id":"7i72jnPlJu3AjUC7nfewht","type":"waf_firewall_version","attributes":{"number":1,"comment":null,"active":null,"locked":null,"error":null,"deployed_at":null,"critical_anomaly_score":5,"error_anomaly_score":4,"warning_anomaly_score":3,"notice_anomaly_score":2,"http_violation_score_threshold":999,"inbound_anomaly_score_threshold":999,"lfi_score_threshold":999,"php_injection_score_threshold":999,"rce_score_threshold":999,"rfi_score_threshold":999,"session_fixation_score_threshold":999,"sql_injection_score_threshold":999,"xss_score_threshold":999,"paranoia_level":1,"arg_name_length":100,"arg_length":400,"total_arg_length":6400,"max_file_size":10000000,"combined_file_sizes":10000000,"max_num_args":255,"high_risk_country_codes":"","allowed_methods":"GET + HEAD POST OPTIONS PUT PATCH DELETE","restricted_headers":"/proxy/ /lock-token/ + /content-range/ /translate/ /if/","restricted_extensions":".asa/ .asax/ .ascx/ + .axd/ .backup/ .bak/ .bat/ .cdx/ .cer/ .cfg/ .cmd/ .com/ .config/ .conf/ .cs/ + .csproj/ .csr/ .dat/ .db/ .dbf/ .dll/ .dos/ .htr/ .htw/ .ida/ .idc/ .idq/ .inc/ + .ini/ .key/ .licx/ .lnk/ .log/ .mdb/ .old/ .pass/ .pdb/ .pol/ .printer/ .pwd/ + .resources/ .resx/ .sql/ .sys/ .vb/ .vbs/ .vbproj/ .vsdisco/ .webinfo/ .xsd/ + .xsx/","allowed_request_content_type":"application/x-www-form-urlencoded|multipart/form-data|text/xml|application/xml|application/soap+xml|application/x-amf|application/json|application/octet-stream|application/csp-report|application/xss-auditor-report|text/plain","allowed_request_content_type_charset":"utf-8|iso-8859-1|iso-8859-15|windows-1252","allowed_http_versions":"HTTP/1.0 + HTTP/1.1 HTTP/2","crs_validate_utf8_encoding":false,"created_at":"2019-11-25T14:43:32Z","updated_at":"2019-11-25T14:43:32Z","active_rules_trustwave_log_count":0,"active_rules_trustwave_block_count":0,"active_rules_fastly_log_count":0,"active_rules_fastly_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_score_count":0}}],"links":{"last":"https://api.fastly.com/waf/firewalls/3bhISXhyFhsufhCFnTst1j/versions?page[number]=1\u0026page[size]=100","first":"https://api.fastly.com/waf/firewalls/3bhISXhyFhsufhCFnTst1j/versions?page[number]=1\u0026page[size]=100"},"meta":{"current_page":1,"per_page":100,"record_count":1,"total_pages":1}}' + headers: + Accept-Ranges: + - bytes + Age: + - "0" + Content-Length: + - "2311" + Content-Type: + - application/vnd.api+json + Date: + - Mon, 25 Nov 2019 14:43:32 GMT + Status: + - 200 OK + Strict-Transport-Security: + - max-age=31536000 + Via: + - 1.1 varnish + X-Cache: + - MISS, MISS + X-Cache-Hits: + - 0, 0 + X-Content-Type-Options: + - nosniff + X-Served-By: + - cache-control-slwdc9036-CONTROL-SLWDC, cache-lcy19271-LCY + X-Timer: + - S1574693012.243526,VS0,VE276 + status: 200 OK + code: 200 + duration: "" diff --git a/fastly/fixtures/waf_versions/list_all.yaml b/fastly/fixtures/waf_versions/list_all.yaml new file mode 100644 index 000000000..82f78f3f5 --- /dev/null +++ b/fastly/fixtures/waf_versions/list_all.yaml @@ -0,0 +1,54 @@ +--- +version: 1 +interactions: +- request: + body: "" + form: {} + headers: + User-Agent: + - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) + url: https://api.fastly.com/waf/firewalls/3bhISXhyFhsufhCFnTst1j/versions?page%5Bnumber%5D=1&page%5Bsize%5D=100 + method: GET + response: + body: '{"data":[{"id":"7i72jnPlJu3AjUC7nfewht","type":"waf_firewall_version","attributes":{"number":1,"comment":null,"active":true,"locked":true,"error":null,"deployed_at":"2019-11-25T14:43:33Z","critical_anomaly_score":5,"error_anomaly_score":4,"warning_anomaly_score":3,"notice_anomaly_score":2,"http_violation_score_threshold":999,"inbound_anomaly_score_threshold":999,"lfi_score_threshold":999,"php_injection_score_threshold":999,"rce_score_threshold":999,"rfi_score_threshold":999,"session_fixation_score_threshold":999,"sql_injection_score_threshold":999,"xss_score_threshold":999,"paranoia_level":1,"arg_name_length":100,"arg_length":400,"total_arg_length":6400,"max_file_size":10000000,"combined_file_sizes":10000000,"max_num_args":255,"high_risk_country_codes":"","allowed_methods":"GET + HEAD POST OPTIONS PUT PATCH DELETE","restricted_headers":"/proxy/ /lock-token/ + /content-range/ /translate/ /if/","restricted_extensions":".asa/ .asax/ .ascx/ + .axd/ .backup/ .bak/ .bat/ .cdx/ .cer/ .cfg/ .cmd/ .com/ .config/ .conf/ .cs/ + .csproj/ .csr/ .dat/ .db/ .dbf/ .dll/ .dos/ .htr/ .htw/ .ida/ .idc/ .idq/ .inc/ + .ini/ .key/ .licx/ .lnk/ .log/ .mdb/ .old/ .pass/ .pdb/ .pol/ .printer/ .pwd/ + .resources/ .resx/ .sql/ .sys/ .vb/ .vbs/ .vbproj/ .vsdisco/ .webinfo/ .xsd/ + .xsx/","allowed_request_content_type":"application/x-www-form-urlencoded|multipart/form-data|text/xml|application/xml|application/soap+xml|application/x-amf|application/json|application/octet-stream|application/csp-report|application/xss-auditor-report|text/plain","allowed_request_content_type_charset":"utf-8|iso-8859-1|iso-8859-15|windows-1252","allowed_http_versions":"HTTP/1.0 + HTTP/1.1 HTTP/2","crs_validate_utf8_encoding":false,"created_at":"2019-11-25T14:43:32Z","updated_at":"2019-11-25T14:43:33Z","active_rules_trustwave_log_count":0,"active_rules_trustwave_block_count":0,"active_rules_fastly_log_count":0,"active_rules_fastly_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_score_count":0}},{"id":"4x66aw12P6aLHGwK4KzGni","type":"waf_firewall_version","attributes":{"number":2,"comment":null,"active":null,"locked":true,"error":null,"deployed_at":null,"critical_anomaly_score":12,"error_anomaly_score":10,"warning_anomaly_score":20,"notice_anomaly_score":8,"http_violation_score_threshold":20,"inbound_anomaly_score_threshold":20,"lfi_score_threshold":20,"php_injection_score_threshold":20,"rce_score_threshold":20,"rfi_score_threshold":20,"session_fixation_score_threshold":20,"sql_injection_score_threshold":20,"xss_score_threshold":20,"paranoia_level":2,"arg_name_length":200,"arg_length":800,"total_arg_length":12800,"max_file_size":20000000,"combined_file_sizes":20000000,"max_num_args":510,"high_risk_country_codes":"gb","allowed_methods":"GET + HEAD POST","restricted_headers":"/proxy/ /lock-token/","restricted_extensions":".asa/ + .asax/ .ascx/ .axd/ .backup/ .bak/ .bat/ .cdx/ .cer/ .cfg/ .cmd/ .com/","allowed_request_content_type":"application/x-www-form-urlencoded|multipart/form-data|text/xml|application/xml","allowed_request_content_type_charset":"utf-8|iso-8859-1","allowed_http_versions":"HTTP/1.0 + HTTP/1.1","crs_validate_utf8_encoding":true,"created_at":"2019-11-25T14:43:32Z","updated_at":"2019-11-25T14:43:34Z","active_rules_trustwave_log_count":0,"active_rules_trustwave_block_count":0,"active_rules_fastly_log_count":0,"active_rules_fastly_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_score_count":0}}],"links":{"last":"https://api.fastly.com/waf/firewalls/3bhISXhyFhsufhCFnTst1j/versions?page[number]=1\u0026page[size]=20","first":"https://api.fastly.com/waf/firewalls/3bhISXhyFhsufhCFnTst1j/versions?page[number]=1\u0026page[size]=20"},"meta":{"current_page":1,"per_page":20,"record_count":2,"total_pages":1}}' + headers: + Accept-Ranges: + - bytes + Age: + - "0" + Content-Length: + - "3814" + Content-Type: + - application/vnd.api+json + Date: + - Mon, 25 Nov 2019 14:43:34 GMT + Status: + - 200 OK + Strict-Transport-Security: + - max-age=31536000 + Via: + - 1.1 varnish + X-Cache: + - MISS, MISS + X-Cache-Hits: + - 0, 0 + X-Content-Type-Options: + - nosniff + X-Served-By: + - cache-control-slwdc9035-CONTROL-SLWDC, cache-lcy19271-LCY + X-Timer: + - S1574693014.202293,VS0,VE160 + status: 200 OK + code: 200 + duration: "" diff --git a/fastly/fixtures/waf_versions/lock.yaml b/fastly/fixtures/waf_versions/lock.yaml new file mode 100644 index 000000000..ef3b13e46 --- /dev/null +++ b/fastly/fixtures/waf_versions/lock.yaml @@ -0,0 +1,49 @@ +--- +version: 1 +interactions: +- request: + body: | + {"data":{"type":""}} + form: {} + headers: + Accept: + - application/vnd.api+json + Content-Type: + - application/vnd.api+json + User-Agent: + - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) + url: https://api.fastly.com/waf/firewalls/3bhISXhyFhsufhCFnTst1j/versions/2/lock + method: PUT + response: + body: '{"data":{"id":"4x66aw12P6aLHGwK4KzGni","type":"waf_firewall_version","attributes":{"number":2,"comment":null,"active":null,"locked":true,"error":null,"deployed_at":null,"critical_anomaly_score":12,"error_anomaly_score":10,"warning_anomaly_score":20,"notice_anomaly_score":8,"http_violation_score_threshold":20,"inbound_anomaly_score_threshold":20,"lfi_score_threshold":20,"php_injection_score_threshold":20,"rce_score_threshold":20,"rfi_score_threshold":20,"session_fixation_score_threshold":20,"sql_injection_score_threshold":20,"xss_score_threshold":20,"paranoia_level":2,"arg_name_length":200,"arg_length":800,"total_arg_length":12800,"max_file_size":20000000,"combined_file_sizes":20000000,"max_num_args":510,"high_risk_country_codes":"gb","allowed_methods":"GET + HEAD POST","restricted_headers":"/proxy/ /lock-token/","restricted_extensions":".asa/ + .asax/ .ascx/ .axd/ .backup/ .bak/ .bat/ .cdx/ .cer/ .cfg/ .cmd/ .com/","allowed_request_content_type":"application/x-www-form-urlencoded|multipart/form-data|text/xml|application/xml","allowed_request_content_type_charset":"utf-8|iso-8859-1","allowed_http_versions":"HTTP/1.0 + HTTP/1.1","crs_validate_utf8_encoding":true,"created_at":"2019-11-25T14:43:32Z","updated_at":"2019-11-25T14:43:34Z","active_rules_trustwave_log_count":0,"active_rules_trustwave_block_count":0,"active_rules_fastly_log_count":0,"active_rules_fastly_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_score_count":0},"relationships":{"waf_firewall":{"data":{"id":"3bhISXhyFhsufhCFnTst1j","type":"waf_firewall"}}}}}' + headers: + Accept-Ranges: + - bytes + Content-Length: + - "1592" + Content-Type: + - application/vnd.api+json + Date: + - Mon, 25 Nov 2019 14:43:34 GMT + Status: + - 200 OK + Strict-Transport-Security: + - max-age=31536000 + Via: + - 1.1 varnish + X-Cache: + - MISS, MISS + X-Cache-Hits: + - 0, 0 + X-Content-Type-Options: + - nosniff + X-Served-By: + - cache-control-slwdc9035-CONTROL-SLWDC, cache-lcy19271-LCY + X-Timer: + - S1574693014.998478,VS0,VE156 + status: 200 OK + code: 200 + duration: "" diff --git a/fastly/fixtures/wafs/logging/create.yaml b/fastly/fixtures/waf_versions/logging/create.yaml similarity index 59% rename from fastly/fixtures/wafs/logging/create.yaml rename to fastly/fixtures/waf_versions/logging/create.yaml index 39a22af1a..fbff5b9ac 100644 --- a/fastly/fixtures/wafs/logging/create.yaml +++ b/fastly/fixtures/waf_versions/logging/create.yaml @@ -2,20 +2,12 @@ version: 1 interactions: - request: -<<<<<<< HEAD - body: Service=7i6HN3TK9wS159v2gPAZ8A&Version=34&address=example.com&format=format&format_version=2&hostname=example.com&message_type=classic&name=test-syslog&port=1234&token=abcd1234 -======= - body: Service=6gkEdARZ3mPzhQvdi2YH3j&Version=2&address=example.com&format=format&format_version=2&hostname=example.com&message_type=classic&name=test-syslog&port=1234&token=abcd1234 ->>>>>>> Service waf component (#5) + body: Service=300YFPn1PVF82Na4SUkiqy&Version=2&address=example.com&format=format&format_version=2&hostname=example.com&message_type=classic&name=test-syslog&port=1234&token=abcd1234 form: Service: - - 6gkEdARZ3mPzhQvdi2YH3j + - 300YFPn1PVF82Na4SUkiqy Version: -<<<<<<< HEAD - - "34" -======= - "2" ->>>>>>> Service waf component (#5) address: - example.com format: @@ -37,10 +29,10 @@ interactions: - application/x-www-form-urlencoded User-Agent: - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) - url: https://api.fastly.com/service/6gkEdARZ3mPzhQvdi2YH3j/version/2/logging/syslog + url: https://api.fastly.com/service/300YFPn1PVF82Na4SUkiqy/version/2/logging/syslog method: POST response: - body: '{"address":"example.com","format":"format","format_version":"2","hostname":"example.com","message_type":"classic","name":"test-syslog","port":"1234","token":"abcd1234","service_id":"6gkEdARZ3mPzhQvdi2YH3j","version":"2","tls_hostname":null,"public_key":null,"use_tls":"0","deleted_at":null,"response_condition":"","tls_ca_cert":null,"placement":null,"updated_at":"2019-11-12T16:10:21Z","ipv4":null,"created_at":"2019-11-12T16:10:21Z","tls_client_cert":null,"tls_client_key":null}' + body: '{"address":"example.com","format":"format","format_version":"2","hostname":"example.com","message_type":"classic","name":"test-syslog","port":"1234","token":"abcd1234","service_id":"300YFPn1PVF82Na4SUkiqy","version":"2","public_key":null,"tls_client_cert":null,"use_tls":"0","ipv4":null,"created_at":"2019-11-25T14:43:30Z","tls_hostname":null,"deleted_at":null,"tls_ca_cert":null,"response_condition":"","tls_client_key":null,"placement":null,"updated_at":"2019-11-25T14:43:30Z"}' headers: Accept-Ranges: - bytes @@ -50,11 +42,11 @@ interactions: Content-Type: - application/json Date: - - Tue, 12 Nov 2019 16:10:21 GMT + - Mon, 25 Nov 2019 14:43:30 GMT Fastly-Ratelimit-Remaining: - - "975" + - "997" Fastly-Ratelimit-Reset: - - "1573578000" + - "1574694000" Status: - 200 OK Strict-Transport-Security: @@ -68,9 +60,9 @@ interactions: X-Cache-Hits: - 0, 0 X-Served-By: - - cache-control-slwdc9036-CONTROL-SLWDC, cache-lcy19279-LCY + - cache-control-slwdc9035-CONTROL-SLWDC, cache-lcy19271-LCY X-Timer: - - S1573575021.168593,VS0,VE780 + - S1574693010.990980,VS0,VE660 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/wafs/logging/cleanup.yaml b/fastly/fixtures/waf_versions/logging/delete.yaml similarity index 76% rename from fastly/fixtures/wafs/logging/cleanup.yaml rename to fastly/fixtures/waf_versions/logging/delete.yaml index 8f68141da..007236f7e 100644 --- a/fastly/fixtures/wafs/logging/cleanup.yaml +++ b/fastly/fixtures/waf_versions/logging/delete.yaml @@ -7,7 +7,7 @@ interactions: headers: User-Agent: - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) - url: https://api.fastly.com/service/6gkEdARZ3mPzhQvdi2YH3j/version/2/logging/syslog/test-syslog + url: https://api.fastly.com/service/300YFPn1PVF82Na4SUkiqy/version/2/logging/syslog/test-syslog method: DELETE response: body: '{"status":"ok"}' @@ -20,11 +20,11 @@ interactions: Content-Type: - application/json Date: - - Tue, 12 Nov 2019 16:10:26 GMT + - Mon, 25 Nov 2019 14:43:36 GMT Fastly-Ratelimit-Remaining: - - "968" + - "992" Fastly-Ratelimit-Reset: - - "1573578000" + - "1574694000" Status: - 200 OK Strict-Transport-Security: @@ -38,9 +38,9 @@ interactions: X-Cache-Hits: - 0, 0 X-Served-By: - - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19279-LCY + - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19271-LCY X-Timer: - - S1573575026.284242,VS0,VE480 + - S1574693016.629715,VS0,VE393 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/waf_versions/response_object/create.yaml b/fastly/fixtures/waf_versions/response_object/create.yaml new file mode 100644 index 000000000..1af41aa65 --- /dev/null +++ b/fastly/fixtures/waf_versions/response_object/create.yaml @@ -0,0 +1,61 @@ +--- +version: 1 +interactions: +- request: + body: Service=300YFPn1PVF82Na4SUkiqy&Version=2&content=abcd&content_type=text%2Fplain&name=WAf_Response&response=Ok&status=200 + form: + Service: + - 300YFPn1PVF82Na4SUkiqy + Version: + - "2" + content: + - abcd + content_type: + - text/plain + name: + - WAf_Response + response: + - Ok + status: + - "200" + headers: + Content-Type: + - application/x-www-form-urlencoded + User-Agent: + - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) + url: https://api.fastly.com/service/300YFPn1PVF82Na4SUkiqy/version/2/response_object + method: POST + response: + body: '{"content":"abcd","content_type":"text/plain","name":"WAf_Response","response":"Ok","status":"200","service_id":"300YFPn1PVF82Na4SUkiqy","version":"2","cache_condition":"","created_at":"2019-11-25T14:43:31Z","request_condition":"","updated_at":"2019-11-25T14:43:31Z","deleted_at":null}' + headers: + Accept-Ranges: + - bytes + Cache-Control: + - no-cache + Content-Type: + - application/json + Date: + - Mon, 25 Nov 2019 14:43:31 GMT + Fastly-Ratelimit-Remaining: + - "995" + Fastly-Ratelimit-Reset: + - "1574694000" + Status: + - 200 OK + Strict-Transport-Security: + - max-age=31536000 + Vary: + - Accept-Encoding + Via: + - 1.1 varnish + X-Cache: + - MISS, MISS + X-Cache-Hits: + - 0, 0 + X-Served-By: + - cache-control-slwdc9036-CONTROL-SLWDC, cache-lcy19271-LCY + X-Timer: + - S1574693011.918974,VS0,VE307 + status: 200 OK + code: 200 + duration: "" diff --git a/fastly/fixtures/wafs/response_object/cleanup.yaml b/fastly/fixtures/waf_versions/response_object/delete.yaml similarity index 76% rename from fastly/fixtures/wafs/response_object/cleanup.yaml rename to fastly/fixtures/waf_versions/response_object/delete.yaml index 17d361ad9..22889cdda 100644 --- a/fastly/fixtures/wafs/response_object/cleanup.yaml +++ b/fastly/fixtures/waf_versions/response_object/delete.yaml @@ -7,7 +7,7 @@ interactions: headers: User-Agent: - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) - url: https://api.fastly.com/service/6gkEdARZ3mPzhQvdi2YH3j/version/2/response_object/WAf_Response + url: https://api.fastly.com/service/300YFPn1PVF82Na4SUkiqy/version/2/response_object/WAf_Response method: DELETE response: body: '{"status":"ok"}' @@ -20,11 +20,11 @@ interactions: Content-Type: - application/json Date: - - Tue, 12 Nov 2019 16:10:25 GMT + - Mon, 25 Nov 2019 14:43:35 GMT Fastly-Ratelimit-Remaining: - - "970" + - "994" Fastly-Ratelimit-Reset: - - "1573578000" + - "1574694000" Status: - 200 OK Strict-Transport-Security: @@ -38,9 +38,9 @@ interactions: X-Cache-Hits: - 0, 0 X-Served-By: - - cache-control-slwdc9036-CONTROL-SLWDC, cache-lcy19279-LCY + - cache-control-slwdc9036-CONTROL-SLWDC, cache-lcy19271-LCY X-Timer: - - S1573575026.606832,VS0,VE339 + - S1574693015.809568,VS0,VE403 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/wafs/create_service.yaml b/fastly/fixtures/waf_versions/service/create.yaml similarity index 60% rename from fastly/fixtures/wafs/create_service.yaml rename to fastly/fixtures/waf_versions/service/create.yaml index 3dff2ba24..02e596002 100644 --- a/fastly/fixtures/wafs/create_service.yaml +++ b/fastly/fixtures/waf_versions/service/create.yaml @@ -16,7 +16,7 @@ interactions: url: https://api.fastly.com/service method: POST response: - body: '{"customer_id":"WpqWFjTA4lk2N1g0GY2HH","comment":"go-fastly client test","name":"test_service_service","publish_key":"3b94816c86b3a740fe97cbfa2c1f24d00a3317d8","deleted_at":null,"created_at":"2019-11-12T16:10:20Z","updated_at":"2019-11-12T16:10:20Z","id":"6gkEdARZ3mPzhQvdi2YH3j","type":"vcl","versions":[{"service_id":"6gkEdARZ3mPzhQvdi2YH3j","deployed":false,"staging":false,"active":false,"updated_at":"2019-11-12T16:10:20Z","created_at":"2019-11-12T16:10:20Z","locked":false,"deleted_at":null,"testing":false,"number":1,"comment":""}]}' + body: '{"customer_id":"WpqWFjTA4lk2N1g0GY2HH","comment":"go-fastly client test","name":"test_service_service","created_at":"2019-11-25T14:43:29Z","type":"vcl","publish_key":"06140d06c6706f308be66ef0d52ba15f600c007b","deleted_at":null,"id":"300YFPn1PVF82Na4SUkiqy","versions":[{"service_id":"300YFPn1PVF82Na4SUkiqy","locked":false,"created_at":"2019-11-25T14:43:29Z","comment":"","deleted_at":null,"active":false,"number":1,"deployed":false,"testing":false,"updated_at":"2019-11-25T14:43:29Z","staging":false}],"updated_at":"2019-11-25T14:43:29Z"}' headers: Accept-Ranges: - bytes @@ -25,11 +25,11 @@ interactions: Content-Type: - application/json Date: - - Tue, 12 Nov 2019 16:10:20 GMT + - Mon, 25 Nov 2019 14:43:29 GMT Fastly-Ratelimit-Remaining: - - "977" + - "999" Fastly-Ratelimit-Reset: - - "1573578000" + - "1574694000" Status: - 200 OK Strict-Transport-Security: @@ -43,9 +43,9 @@ interactions: X-Cache-Hits: - 0, 0 X-Served-By: - - cache-control-slwdc9035-CONTROL-SLWDC, cache-lcy19279-LCY + - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19271-LCY X-Timer: - - S1573575020.114176,VS0,VE526 + - S1574693009.998660,VS0,VE235 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/wafs/delete_service.yaml b/fastly/fixtures/waf_versions/service/delete.yaml similarity index 75% rename from fastly/fixtures/wafs/delete_service.yaml rename to fastly/fixtures/waf_versions/service/delete.yaml index c5a50fc5b..d0a6a54cc 100644 --- a/fastly/fixtures/wafs/delete_service.yaml +++ b/fastly/fixtures/waf_versions/service/delete.yaml @@ -7,7 +7,7 @@ interactions: headers: User-Agent: - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) - url: https://api.fastly.com/service/6gkEdARZ3mPzhQvdi2YH3j + url: https://api.fastly.com/service/300YFPn1PVF82Na4SUkiqy method: DELETE response: body: '{"status":"ok"}' @@ -19,11 +19,11 @@ interactions: Content-Type: - application/json Date: - - Tue, 12 Nov 2019 16:10:27 GMT + - Mon, 25 Nov 2019 14:43:36 GMT Fastly-Ratelimit-Remaining: - - "967" + - "991" Fastly-Ratelimit-Reset: - - "1573578000" + - "1574694000" Status: - 200 OK Strict-Transport-Security: @@ -37,9 +37,9 @@ interactions: X-Cache-Hits: - 0, 0 X-Served-By: - - cache-control-slwdc9036-CONTROL-SLWDC, cache-lcy19279-LCY + - cache-control-slwdc9035-CONTROL-SLWDC, cache-lcy19271-LCY X-Timer: - - S1573575027.804178,VS0,VE215 + - S1574693016.148525,VS0,VE222 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/waf_versions/service/version.yaml b/fastly/fixtures/waf_versions/service/version.yaml new file mode 100644 index 000000000..c4169866a --- /dev/null +++ b/fastly/fixtures/waf_versions/service/version.yaml @@ -0,0 +1,50 @@ +--- +version: 1 +interactions: +- request: + body: Service=300YFPn1PVF82Na4SUkiqy + form: + Service: + - 300YFPn1PVF82Na4SUkiqy + headers: + Content-Type: + - application/x-www-form-urlencoded + User-Agent: + - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) + url: https://api.fastly.com/service/300YFPn1PVF82Na4SUkiqy/version + method: POST + response: + body: '{"service_id":"300YFPn1PVF82Na4SUkiqy","number":2}' + headers: + Accept-Ranges: + - bytes + - bytes + Cache-Control: + - no-cache + Content-Type: + - application/json + Date: + - Mon, 25 Nov 2019 14:43:29 GMT + Fastly-Ratelimit-Remaining: + - "998" + Fastly-Ratelimit-Reset: + - "1574694000" + Status: + - 200 OK + Strict-Transport-Security: + - max-age=31536000 + Vary: + - Accept-Encoding + Via: + - 1.1 varnish + X-Cache: + - MISS, MISS + X-Cache-Hits: + - 0, 0 + X-Served-By: + - cache-control-slwdc9036-CONTROL-SLWDC, cache-lcy19271-LCY + X-Timer: + - S1574693009.278394,VS0,VE632 + status: 200 OK + code: 200 + duration: "" diff --git a/fastly/fixtures/waf_versions/update.yaml b/fastly/fixtures/waf_versions/update.yaml new file mode 100644 index 000000000..924b10db4 --- /dev/null +++ b/fastly/fixtures/waf_versions/update.yaml @@ -0,0 +1,49 @@ +--- +version: 1 +interactions: +- request: + body: | + {"data":{"type":"waf_firewall","id":"4x66aw12P6aLHGwK4KzGni","attributes":{"allowed_http_versions":"HTTP/1.0 HTTP/1.1","allowed_methods":"GET HEAD POST","allowed_request_content_type":"application/x-www-form-urlencoded|multipart/form-data|text/xml|application/xml","allowed_request_content_type_charset":"utf-8|iso-8859-1","arg_length":800,"arg_name_length":200,"combined_file_sizes":20000000,"comment":"my comment","critical_anomaly_score":12,"crs_validate_utf8_encoding":true,"error_anomaly_score":10,"high_risk_country_codes":"gb","http_violation_score_threshold":20,"inbound_anomaly_score_threshold":20,"lfi_score_threshold":20,"max_file_size":20000000,"max_num_args":510,"notice_anomaly_score":8,"paranoia_level":2,"php_injection_score_threshold":20,"rce_score_threshold":20,"restricted_extensions":".asa/ .asax/ .ascx/ .axd/ .backup/ .bak/ .bat/ .cdx/ .cer/ .cfg/ .cmd/ .com/","restricted_headers":"/proxy/ /lock-token/","rfi_score_threshold":20,"session_fixation_score_threshold":20,"sql_injection_score_threshold":20,"total_arg_length":12800,"warning_anomaly_score":20,"xss_score_threshold":20}}} + form: {} + headers: + Accept: + - application/vnd.api+json + Content-Type: + - application/vnd.api+json + User-Agent: + - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) + url: https://api.fastly.com/waf/firewalls/3bhISXhyFhsufhCFnTst1j/versions/2 + method: PATCH + response: + body: '{"data":{"id":"4x66aw12P6aLHGwK4KzGni","type":"waf_firewall_version","attributes":{"number":2,"comment":null,"active":null,"locked":false,"error":null,"deployed_at":null,"critical_anomaly_score":12,"error_anomaly_score":10,"warning_anomaly_score":20,"notice_anomaly_score":8,"http_violation_score_threshold":20,"inbound_anomaly_score_threshold":20,"lfi_score_threshold":20,"php_injection_score_threshold":20,"rce_score_threshold":20,"rfi_score_threshold":20,"session_fixation_score_threshold":20,"sql_injection_score_threshold":20,"xss_score_threshold":20,"paranoia_level":2,"arg_name_length":200,"arg_length":800,"total_arg_length":12800,"max_file_size":20000000,"combined_file_sizes":20000000,"max_num_args":510,"high_risk_country_codes":"gb","allowed_methods":"GET + HEAD POST","restricted_headers":"/proxy/ /lock-token/","restricted_extensions":".asa/ + .asax/ .ascx/ .axd/ .backup/ .bak/ .bat/ .cdx/ .cer/ .cfg/ .cmd/ .com/","allowed_request_content_type":"application/x-www-form-urlencoded|multipart/form-data|text/xml|application/xml","allowed_request_content_type_charset":"utf-8|iso-8859-1","allowed_http_versions":"HTTP/1.0 + HTTP/1.1","crs_validate_utf8_encoding":true,"created_at":"2019-11-25T14:43:32Z","updated_at":"2019-11-25T14:43:33Z","active_rules_trustwave_log_count":0,"active_rules_trustwave_block_count":0,"active_rules_fastly_log_count":0,"active_rules_fastly_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_score_count":0},"relationships":{"waf_firewall":{"data":{"id":"3bhISXhyFhsufhCFnTst1j","type":"waf_firewall"}}}}}' + headers: + Accept-Ranges: + - bytes + Content-Length: + - "1593" + Content-Type: + - application/vnd.api+json + Date: + - Mon, 25 Nov 2019 14:43:33 GMT + Status: + - 200 OK + Strict-Transport-Security: + - max-age=31536000 + Via: + - 1.1 varnish + X-Cache: + - MISS, MISS + X-Cache-Hits: + - 0, 0 + X-Content-Type-Options: + - nosniff + X-Served-By: + - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19271-LCY + X-Timer: + - S1574693013.491879,VS0,VE373 + status: 200 OK + code: 200 + duration: "" diff --git a/fastly/fixtures/waf_versions/waf/create.yaml b/fastly/fixtures/waf_versions/waf/create.yaml new file mode 100644 index 000000000..ed14483c7 --- /dev/null +++ b/fastly/fixtures/waf_versions/waf/create.yaml @@ -0,0 +1,46 @@ +--- +version: 1 +interactions: +- request: + body: | + {"data":{"type":"waf_firewall","attributes":{"prefetch_condition":"WAF_Prefetch","response":"WAf_Response","service_id":"300YFPn1PVF82Na4SUkiqy","service_version_number":"2"}}} + form: {} + headers: + Accept: + - application/vnd.api+json + Content-Type: + - application/vnd.api+json + User-Agent: + - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) + url: https://api.fastly.com/waf/firewalls + method: POST + response: + body: '{"data":{"id":"3bhISXhyFhsufhCFnTst1j","type":"waf_firewall","attributes":{"service_id":"300YFPn1PVF82Na4SUkiqy","prefetch_condition":"WAF_Prefetch","response":"WAf_Response","disabled":false,"service_version_number":2,"created_at":"2019-11-25T14:43:32Z","updated_at":"2019-11-25T14:43:32Z","active_rules_trustwave_log_count":0,"active_rules_trustwave_block_count":0,"active_rules_fastly_log_count":0,"active_rules_fastly_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_score_count":0}}}' + headers: + Accept-Ranges: + - bytes + Content-Length: + - "542" + Content-Type: + - application/vnd.api+json + Date: + - Mon, 25 Nov 2019 14:43:32 GMT + Status: + - 201 Created + Strict-Transport-Security: + - max-age=31536000 + Via: + - 1.1 varnish + X-Cache: + - MISS, MISS + X-Cache-Hits: + - 0, 0 + X-Content-Type-Options: + - nosniff + X-Served-By: + - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19271-LCY + X-Timer: + - S1574693011.323975,VS0,VE833 + status: 201 Created + code: 201 + duration: "" diff --git a/fastly/fixtures/waf_versions/waf/delete.yaml b/fastly/fixtures/waf_versions/waf/delete.yaml new file mode 100644 index 000000000..7df283012 --- /dev/null +++ b/fastly/fixtures/waf_versions/waf/delete.yaml @@ -0,0 +1,42 @@ +--- +version: 1 +interactions: +- request: + body: | + {"data":{"type":"waf_firewall","id":"3bhISXhyFhsufhCFnTst1j","attributes":{"service_version_number":"2"}}} + form: {} + headers: + Accept: + - application/vnd.api+json + Content-Type: + - application/vnd.api+json + User-Agent: + - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) + url: https://api.fastly.com/waf/firewalls/3bhISXhyFhsufhCFnTst1j + method: DELETE + response: + body: "" + headers: + Accept-Ranges: + - bytes + Date: + - Mon, 25 Nov 2019 14:43:34 GMT + Status: + - 204 No Content + Strict-Transport-Security: + - max-age=31536000 + Via: + - 1.1 varnish + X-Cache: + - MISS, MISS + X-Cache-Hits: + - 0, 0 + X-Content-Type-Options: + - nosniff + X-Served-By: + - cache-control-slwdc9035-CONTROL-SLWDC, cache-lcy19271-LCY + X-Timer: + - S1574693014.397467,VS0,VE288 + status: 204 No Content + code: 204 + duration: "" diff --git a/fastly/fixtures/wafs/cleanup.yaml b/fastly/fixtures/wafs/cleanup.yaml index d71246fa2..252139cb5 100644 --- a/fastly/fixtures/wafs/cleanup.yaml +++ b/fastly/fixtures/wafs/cleanup.yaml @@ -3,7 +3,7 @@ version: 1 interactions: - request: body: | - {"data":{"type":"waf_firewall","id":"59onHkuKX28AMcf0gOojis","attributes":{"service_version_number":"2"}}} + {"data":{"type":"waf_firewall","id":"5ui1qC2Y9TZIonO95zU3gM","attributes":{"service_version_number":"2"}}} form: {} headers: Accept: @@ -12,7 +12,7 @@ interactions: - application/vnd.api+json User-Agent: - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) - url: https://api.fastly.com/waf/firewalls/59onHkuKX28AMcf0gOojis + url: https://api.fastly.com/waf/firewalls/5ui1qC2Y9TZIonO95zU3gM method: DELETE response: body: '{"errors":[{"title":"Resource not found","detail":"We could not find a @@ -22,7 +22,7 @@ interactions: - bytes - bytes Date: - - Tue, 12 Nov 2019 16:10:25 GMT + - Wed, 20 Nov 2019 12:59:08 GMT Status: - 404 Not Found Strict-Transport-Security: @@ -34,9 +34,9 @@ interactions: X-Cache-Hits: - 0, 0 X-Served-By: - - cache-control-slwdc9036-CONTROL-SLWDC, cache-lcy19279-LCY + - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19265-LCY X-Timer: - - S1573575025.472733,VS0,VE128 + - S1574254748.068564,VS0,VE131 status: 404 Not Found code: 404 duration: "" diff --git a/fastly/fixtures/wafs/condition/create.yaml b/fastly/fixtures/wafs/condition/create.yaml index 7be6f8dac..0ea3c1c78 100644 --- a/fastly/fixtures/wafs/condition/create.yaml +++ b/fastly/fixtures/wafs/condition/create.yaml @@ -2,10 +2,10 @@ version: 1 interactions: - request: - body: Service=6gkEdARZ3mPzhQvdi2YH3j&Version=2&name=WAF_Prefetch&priority=1&statement=req.url~%2B%22index.html%22&type=PREFETCH + body: Service=3qt0xLYGlOxt19jpAQ0LJM&Version=2&name=WAF_Prefetch&priority=1&statement=req.url~%2B%22index.html%22&type=PREFETCH form: Service: - - 6gkEdARZ3mPzhQvdi2YH3j + - 3qt0xLYGlOxt19jpAQ0LJM Version: - "2" name: @@ -21,10 +21,10 @@ interactions: - application/x-www-form-urlencoded User-Agent: - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) - url: https://api.fastly.com/service/6gkEdARZ3mPzhQvdi2YH3j/version/2/condition + url: https://api.fastly.com/service/3qt0xLYGlOxt19jpAQ0LJM/version/2/condition method: POST response: - body: '{"name":"WAF_Prefetch","priority":"1","statement":"req.url~+\"index.html\"","type":"PREFETCH","service_id":"6gkEdARZ3mPzhQvdi2YH3j","version":"2","comment":"","deleted_at":null,"updated_at":"2019-11-12T16:10:22Z","created_at":"2019-11-12T16:10:22Z"}' + body: '{"name":"WAF_Prefetch","priority":"1","statement":"req.url~+\"index.html\"","type":"PREFETCH","service_id":"3qt0xLYGlOxt19jpAQ0LJM","version":"2","deleted_at":null,"updated_at":"2019-11-20T12:59:04Z","comment":"","created_at":"2019-11-20T12:59:04Z"}' headers: Accept-Ranges: - bytes @@ -34,11 +34,11 @@ interactions: Content-Type: - application/json Date: - - Tue, 12 Nov 2019 16:10:22 GMT + - Wed, 20 Nov 2019 12:59:04 GMT Fastly-Ratelimit-Remaining: - - "974" + - "970" Fastly-Ratelimit-Reset: - - "1573578000" + - "1574254800" Status: - 200 OK Strict-Transport-Security: @@ -52,9 +52,9 @@ interactions: X-Cache-Hits: - 0, 0 X-Served-By: - - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19279-LCY + - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19265-LCY X-Timer: - - S1573575022.958487,VS0,VE181 + - S1574254744.247357,VS0,VE185 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/wafs/condition/delete.yaml b/fastly/fixtures/wafs/condition/delete.yaml new file mode 100644 index 000000000..fa484a059 --- /dev/null +++ b/fastly/fixtures/wafs/condition/delete.yaml @@ -0,0 +1,45 @@ +--- +version: 1 +interactions: +- request: + body: "" + form: {} + headers: + User-Agent: + - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) + url: https://api.fastly.com/service/3qt0xLYGlOxt19jpAQ0LJM/version/2/condition/WAF_Prefetch + method: DELETE + response: + body: '{"status":"ok"}' + headers: + Accept-Ranges: + - bytes + Cache-Control: + - no-cache + Content-Type: + - application/json + Date: + - Wed, 20 Nov 2019 12:59:08 GMT + Fastly-Ratelimit-Remaining: + - "965" + Fastly-Ratelimit-Reset: + - "1574254800" + Status: + - 200 OK + Strict-Transport-Security: + - max-age=31536000 + Vary: + - Accept-Encoding + Via: + - 1.1 varnish + X-Cache: + - MISS, MISS + X-Cache-Hits: + - 0, 0 + X-Served-By: + - cache-control-slwdc9036-CONTROL-SLWDC, cache-lcy19265-LCY + X-Timer: + - S1574254749.547759,VS0,VE264 + status: 200 OK + code: 200 + duration: "" diff --git a/fastly/fixtures/wafs/create.yaml b/fastly/fixtures/wafs/create.yaml index 1571375eb..ad6d3a64a 100644 --- a/fastly/fixtures/wafs/create.yaml +++ b/fastly/fixtures/wafs/create.yaml @@ -3,7 +3,7 @@ version: 1 interactions: - request: body: | - {"data":{"type":"waf_firewall","attributes":{"prefetch_condition":"WAF_Prefetch","response":"WAf_Response","service_id":"6gkEdARZ3mPzhQvdi2YH3j","service_version_number":"2"}}} + {"data":{"type":"waf_firewall","attributes":{"prefetch_condition":"WAF_Prefetch","response":"WAf_Response","service_id":"3qt0xLYGlOxt19jpAQ0LJM","service_version_number":"2"}}} form: {} headers: Accept: @@ -15,7 +15,7 @@ interactions: url: https://api.fastly.com/waf/firewalls method: POST response: - body: '{"data":{"id":"59onHkuKX28AMcf0gOojis","type":"waf_firewall","attributes":{"service_id":"6gkEdARZ3mPzhQvdi2YH3j","prefetch_condition":"WAF_Prefetch","response":"WAf_Response","disabled":false,"service_version_number":2,"created_at":"2019-11-12T16:10:23Z","updated_at":"2019-11-12T16:10:23Z","active_rules_trustwave_log_count":0,"active_rules_trustwave_block_count":0,"active_rules_fastly_log_count":0,"active_rules_fastly_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_score_count":0}}}' + body: '{"data":{"id":"5ui1qC2Y9TZIonO95zU3gM","type":"waf_firewall","attributes":{"service_id":"3qt0xLYGlOxt19jpAQ0LJM","prefetch_condition":"WAF_Prefetch","response":"WAf_Response","disabled":false,"service_version_number":2,"created_at":"2019-11-20T12:59:05Z","updated_at":"2019-11-20T12:59:05Z","active_rules_trustwave_log_count":0,"active_rules_trustwave_block_count":0,"active_rules_fastly_log_count":0,"active_rules_fastly_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_score_count":0}}}' headers: Accept-Ranges: - bytes @@ -25,7 +25,7 @@ interactions: Content-Type: - application/vnd.api+json Date: - - Tue, 12 Nov 2019 16:10:23 GMT + - Wed, 20 Nov 2019 12:59:05 GMT Status: - 201 Created Strict-Transport-Security: @@ -39,9 +39,9 @@ interactions: X-Content-Type-Options: - nosniff X-Served-By: - - cache-control-slwdc9036-CONTROL-SLWDC, cache-lcy19279-LCY + - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19265-LCY X-Timer: - - S1573575023.603740,VS0,VE737 + - S1574254745.875699,VS0,VE922 status: 201 Created code: 201 duration: "" diff --git a/fastly/fixtures/wafs/delete.yaml b/fastly/fixtures/wafs/delete.yaml index bb1ae658b..44eda0b6d 100644 --- a/fastly/fixtures/wafs/delete.yaml +++ b/fastly/fixtures/wafs/delete.yaml @@ -3,7 +3,7 @@ version: 1 interactions: - request: body: | - {"data":{"type":"waf_firewall","id":"59onHkuKX28AMcf0gOojis","attributes":{"service_version_number":"2"}}} + {"data":{"type":"waf_firewall","id":"5ui1qC2Y9TZIonO95zU3gM","attributes":{"service_version_number":"2"}}} form: {} headers: Accept: @@ -12,7 +12,7 @@ interactions: - application/vnd.api+json User-Agent: - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) - url: https://api.fastly.com/waf/firewalls/59onHkuKX28AMcf0gOojis + url: https://api.fastly.com/waf/firewalls/5ui1qC2Y9TZIonO95zU3gM method: DELETE response: body: "" @@ -21,7 +21,7 @@ interactions: - bytes - bytes Date: - - Tue, 12 Nov 2019 16:10:24 GMT + - Wed, 20 Nov 2019 12:59:07 GMT Status: - 204 No Content Strict-Transport-Security: @@ -35,9 +35,9 @@ interactions: X-Content-Type-Options: - nosniff X-Served-By: - - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19279-LCY + - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19265-LCY X-Timer: - - S1573575025.533117,VS0,VE317 + - S1574254747.217414,VS0,VE284 status: 204 No Content code: 204 duration: "" diff --git a/fastly/fixtures/wafs/get.yaml b/fastly/fixtures/wafs/get.yaml index 6e8c7a9d5..604bacbba 100644 --- a/fastly/fixtures/wafs/get.yaml +++ b/fastly/fixtures/wafs/get.yaml @@ -7,10 +7,10 @@ interactions: headers: User-Agent: - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) - url: https://api.fastly.com/waf/firewalls/59onHkuKX28AMcf0gOojis?filter%5Bservice_version_number%5D=2 + url: https://api.fastly.com/waf/firewalls/5ui1qC2Y9TZIonO95zU3gM?filter%5Bservice_version_number%5D=2 method: GET response: - body: '{"data":{"id":"59onHkuKX28AMcf0gOojis","type":"waf_firewall","attributes":{"service_id":"6gkEdARZ3mPzhQvdi2YH3j","prefetch_condition":"WAF_Prefetch","response":"WAf_Response","disabled":false,"service_version_number":2,"created_at":"2019-11-12T16:10:23Z","updated_at":"2019-11-12T16:10:23Z","active_rules_trustwave_log_count":0,"active_rules_trustwave_block_count":0,"active_rules_fastly_log_count":0,"active_rules_fastly_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_score_count":0}}}' + body: '{"data":{"id":"5ui1qC2Y9TZIonO95zU3gM","type":"waf_firewall","attributes":{"service_id":"3qt0xLYGlOxt19jpAQ0LJM","prefetch_condition":"WAF_Prefetch","response":"WAf_Response","disabled":false,"service_version_number":2,"created_at":"2019-11-20T12:59:05Z","updated_at":"2019-11-20T12:59:05Z","active_rules_trustwave_log_count":0,"active_rules_trustwave_block_count":0,"active_rules_fastly_log_count":0,"active_rules_fastly_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_score_count":0}}}' headers: Accept-Ranges: - bytes @@ -24,7 +24,7 @@ interactions: Content-Type: - application/vnd.api+json Date: - - Tue, 12 Nov 2019 16:10:23 GMT + - Wed, 20 Nov 2019 12:59:06 GMT Status: - 200 OK Strict-Transport-Security: @@ -38,9 +38,9 @@ interactions: X-Content-Type-Options: - nosniff X-Served-By: - - cache-control-slwdc9036-CONTROL-SLWDC, cache-lcy19279-LCY + - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19265-LCY X-Timer: - - S1573575024.630073,VS0,VE173 + - S1574254746.088317,VS0,VE225 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/wafs/list.yaml b/fastly/fixtures/wafs/list.yaml index 98b35052b..c29f8a5bf 100644 --- a/fastly/fixtures/wafs/list.yaml +++ b/fastly/fixtures/wafs/list.yaml @@ -7,10 +7,10 @@ interactions: headers: User-Agent: - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) - url: https://api.fastly.com/waf/firewalls?filter%5Bservice_id%5D=6gkEdARZ3mPzhQvdi2YH3j&filter%5Bservice_version_number%5D=2 + url: https://api.fastly.com/waf/firewalls?filter%5Bservice_id%5D=3qt0xLYGlOxt19jpAQ0LJM&filter%5Bservice_version_number%5D=2 method: GET response: - body: '{"data":[{"id":"59onHkuKX28AMcf0gOojis","type":"waf_firewall","attributes":{"service_id":"6gkEdARZ3mPzhQvdi2YH3j","prefetch_condition":"WAF_Prefetch","response":"WAf_Response","disabled":false,"service_version_number":2,"created_at":"2019-11-12T16:10:23Z","updated_at":"2019-11-12T16:10:23Z","active_rules_trustwave_log_count":0,"active_rules_trustwave_block_count":0,"active_rules_fastly_log_count":0,"active_rules_fastly_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_score_count":0}}],"links":{"last":"https://api.fastly.com/waf/firewalls?filter[service_id]=6gkEdARZ3mPzhQvdi2YH3j\u0026filter[service_version_number]=2\u0026page[number]=1\u0026page[size]=100","first":"https://api.fastly.com/waf/firewalls?filter[service_id]=6gkEdARZ3mPzhQvdi2YH3j\u0026filter[service_version_number]=2\u0026page[number]=1\u0026page[size]=100"},"meta":{"current_page":1,"per_page":100,"record_count":1,"total_pages":1}}' + body: '{"data":[{"id":"5ui1qC2Y9TZIonO95zU3gM","type":"waf_firewall","attributes":{"service_id":"3qt0xLYGlOxt19jpAQ0LJM","prefetch_condition":"WAF_Prefetch","response":"WAf_Response","disabled":false,"service_version_number":2,"created_at":"2019-11-20T12:59:05Z","updated_at":"2019-11-20T12:59:05Z","active_rules_trustwave_log_count":0,"active_rules_trustwave_block_count":0,"active_rules_fastly_log_count":0,"active_rules_fastly_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_score_count":0}}],"links":{"last":"https://api.fastly.com/waf/firewalls?filter[service_id]=3qt0xLYGlOxt19jpAQ0LJM\u0026filter[service_version_number]=2\u0026page[number]=1\u0026page[size]=100","first":"https://api.fastly.com/waf/firewalls?filter[service_id]=3qt0xLYGlOxt19jpAQ0LJM\u0026filter[service_version_number]=2\u0026page[number]=1\u0026page[size]=100"},"meta":{"current_page":1,"per_page":100,"record_count":1,"total_pages":1}}' headers: Accept-Ranges: - bytes @@ -24,7 +24,7 @@ interactions: Content-Type: - application/vnd.api+json Date: - - Tue, 12 Nov 2019 16:10:23 GMT + - Wed, 20 Nov 2019 12:59:06 GMT Status: - 200 OK Strict-Transport-Security: @@ -38,9 +38,9 @@ interactions: X-Content-Type-Options: - nosniff X-Served-By: - - cache-control-slwdc9036-CONTROL-SLWDC, cache-lcy19279-LCY + - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19265-LCY X-Timer: - - S1573575023.349598,VS0,VE175 + - S1574254746.880426,VS0,VE172 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/wafs/response_object/cleanup_another.yaml b/fastly/fixtures/wafs/response_object/cleanup_another.yaml index 646820e68..a53aa66f6 100644 --- a/fastly/fixtures/wafs/response_object/cleanup_another.yaml +++ b/fastly/fixtures/wafs/response_object/cleanup_another.yaml @@ -6,13 +6,8 @@ interactions: form: {} headers: User-Agent: -<<<<<<< HEAD - - FastlyGo/1.10.0 (+github.com/fastly/go-fastly; go1.12) - url: https://api.fastly.com/service/7i6HN3TK9wS159v2gPAZ8A/version/34/response_object/test-response-object-2 -======= - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) - url: https://api.fastly.com/service/6gkEdARZ3mPzhQvdi2YH3j/version/2/response_object/test-response-object-2 ->>>>>>> Service waf component (#5) + url: https://api.fastly.com/service/3qt0xLYGlOxt19jpAQ0LJM/version/2/response_object/test-response-object-2 method: DELETE response: body: '{"status":"ok"}' @@ -25,11 +20,11 @@ interactions: Content-Type: - application/json Date: - - Tue, 12 Nov 2019 16:10:25 GMT + - Wed, 20 Nov 2019 12:59:07 GMT Fastly-Ratelimit-Remaining: - - "971" + - "967" Fastly-Ratelimit-Reset: - - "1573578000" + - "1574254800" Status: - 200 OK Strict-Transport-Security: @@ -43,9 +38,9 @@ interactions: X-Cache-Hits: - 0, 0 X-Served-By: - - cache-control-slwdc9035-CONTROL-SLWDC, cache-lcy19279-LCY + - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19265-LCY X-Timer: - - S1573575025.955392,VS0,VE478 + - S1574254748.524032,VS0,VE458 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/wafs/response_object/create.yaml b/fastly/fixtures/wafs/response_object/create.yaml index 68c3247a3..2d03d9946 100644 --- a/fastly/fixtures/wafs/response_object/create.yaml +++ b/fastly/fixtures/wafs/response_object/create.yaml @@ -2,10 +2,10 @@ version: 1 interactions: - request: - body: Service=6gkEdARZ3mPzhQvdi2YH3j&Version=2&content=abcd&content_type=text%2Fplain&name=WAf_Response&response=Ok&status=200 + body: Service=3qt0xLYGlOxt19jpAQ0LJM&Version=2&content=abcd&content_type=text%2Fplain&name=WAf_Response&response=Ok&status=200 form: Service: - - 6gkEdARZ3mPzhQvdi2YH3j + - 3qt0xLYGlOxt19jpAQ0LJM Version: - "2" content: @@ -23,10 +23,10 @@ interactions: - application/x-www-form-urlencoded User-Agent: - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) - url: https://api.fastly.com/service/6gkEdARZ3mPzhQvdi2YH3j/version/2/response_object + url: https://api.fastly.com/service/3qt0xLYGlOxt19jpAQ0LJM/version/2/response_object method: POST response: - body: '{"content":"abcd","content_type":"text/plain","name":"WAf_Response","response":"Ok","status":"200","service_id":"6gkEdARZ3mPzhQvdi2YH3j","version":"2","created_at":"2019-11-12T16:10:22Z","deleted_at":null,"updated_at":"2019-11-12T16:10:22Z","cache_condition":"","request_condition":""}' + body: '{"content":"abcd","content_type":"text/plain","name":"WAf_Response","response":"Ok","status":"200","service_id":"3qt0xLYGlOxt19jpAQ0LJM","version":"2","cache_condition":"","updated_at":"2019-11-20T12:59:04Z","request_condition":"","deleted_at":null,"created_at":"2019-11-20T12:59:04Z"}' headers: Accept-Ranges: - bytes @@ -36,11 +36,11 @@ interactions: Content-Type: - application/json Date: - - Tue, 12 Nov 2019 16:10:22 GMT + - Wed, 20 Nov 2019 12:59:04 GMT Fastly-Ratelimit-Remaining: - - "973" + - "969" Fastly-Ratelimit-Reset: - - "1573578000" + - "1574254800" Status: - 200 OK Strict-Transport-Security: @@ -54,9 +54,9 @@ interactions: X-Cache-Hits: - 0, 0 X-Served-By: - - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19279-LCY + - cache-control-slwdc9036-CONTROL-SLWDC, cache-lcy19265-LCY X-Timer: - - S1573575022.149894,VS0,VE343 + - S1574254744.451020,VS0,VE306 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/wafs/response_object/create_another.yaml b/fastly/fixtures/wafs/response_object/create_another.yaml index e423104d2..a5fd4ff3b 100644 --- a/fastly/fixtures/wafs/response_object/create_another.yaml +++ b/fastly/fixtures/wafs/response_object/create_another.yaml @@ -2,10 +2,10 @@ version: 1 interactions: - request: - body: Service=6gkEdARZ3mPzhQvdi2YH3j&Version=2&content=efgh&content_type=text%2Fplain&name=test-response-object-2&response=Ok&status=200 + body: Service=3qt0xLYGlOxt19jpAQ0LJM&Version=2&content=efgh&content_type=text%2Fplain&name=test-response-object-2&response=Ok&status=200 form: Service: - - 6gkEdARZ3mPzhQvdi2YH3j + - 3qt0xLYGlOxt19jpAQ0LJM Version: - "2" content: @@ -23,10 +23,10 @@ interactions: - application/x-www-form-urlencoded User-Agent: - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) - url: https://api.fastly.com/service/6gkEdARZ3mPzhQvdi2YH3j/version/2/response_object + url: https://api.fastly.com/service/3qt0xLYGlOxt19jpAQ0LJM/version/2/response_object method: POST response: - body: '{"content":"efgh","content_type":"text/plain","name":"test-response-object-2","response":"Ok","status":"200","service_id":"6gkEdARZ3mPzhQvdi2YH3j","version":"2","deleted_at":null,"updated_at":"2019-11-12T16:10:24Z","request_condition":"","created_at":"2019-11-12T16:10:24Z","cache_condition":""}' + body: '{"content":"efgh","content_type":"text/plain","name":"test-response-object-2","response":"Ok","status":"200","service_id":"3qt0xLYGlOxt19jpAQ0LJM","version":"2","request_condition":"","updated_at":"2019-11-20T12:59:06Z","deleted_at":null,"created_at":"2019-11-20T12:59:06Z","cache_condition":""}' headers: Accept-Ranges: - bytes @@ -36,11 +36,11 @@ interactions: Content-Type: - application/json Date: - - Tue, 12 Nov 2019 16:10:24 GMT + - Wed, 20 Nov 2019 12:59:06 GMT Fastly-Ratelimit-Remaining: - - "972" + - "968" Fastly-Ratelimit-Reset: - - "1573578000" + - "1574254800" Status: - 200 OK Strict-Transport-Security: @@ -54,9 +54,9 @@ interactions: X-Cache-Hits: - 0, 0 X-Served-By: - - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19279-LCY + - cache-control-slwdc9035-CONTROL-SLWDC, cache-lcy19265-LCY X-Timer: - - S1573575024.828564,VS0,VE366 + - S1574254746.396063,VS0,VE303 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/wafs/response_object/delete.yaml b/fastly/fixtures/wafs/response_object/delete.yaml new file mode 100644 index 000000000..9bb9be0fa --- /dev/null +++ b/fastly/fixtures/wafs/response_object/delete.yaml @@ -0,0 +1,45 @@ +--- +version: 1 +interactions: +- request: + body: "" + form: {} + headers: + User-Agent: + - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) + url: https://api.fastly.com/service/3qt0xLYGlOxt19jpAQ0LJM/version/2/response_object/WAf_Response + method: DELETE + response: + body: '{"status":"ok"}' + headers: + Accept-Ranges: + - bytes + Cache-Control: + - no-cache + Content-Type: + - application/json + Date: + - Wed, 20 Nov 2019 12:59:08 GMT + Fastly-Ratelimit-Remaining: + - "966" + Fastly-Ratelimit-Reset: + - "1574254800" + Status: + - 200 OK + Strict-Transport-Security: + - max-age=31536000 + Vary: + - Accept-Encoding + Via: + - 1.1 varnish + X-Cache: + - MISS, MISS + X-Cache-Hits: + - 0, 0 + X-Served-By: + - cache-control-slwdc9036-CONTROL-SLWDC, cache-lcy19265-LCY + X-Timer: + - S1574254748.207257,VS0,VE316 + status: 200 OK + code: 200 + duration: "" diff --git a/fastly/fixtures/wafs/service/create.yaml b/fastly/fixtures/wafs/service/create.yaml new file mode 100644 index 000000000..559f69e95 --- /dev/null +++ b/fastly/fixtures/wafs/service/create.yaml @@ -0,0 +1,51 @@ +--- +version: 1 +interactions: +- request: + body: comment=go-fastly+client+test&name=test_service_service + form: + comment: + - go-fastly client test + name: + - test_service_service + headers: + Content-Type: + - application/x-www-form-urlencoded + User-Agent: + - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) + url: https://api.fastly.com/service + method: POST + response: + body: '{"customer_id":"WpqWFjTA4lk2N1g0GY2HH","comment":"go-fastly client test","name":"test_service_service","type":"vcl","versions":[{"testing":false,"service_id":"3qt0xLYGlOxt19jpAQ0LJM","deployed":false,"locked":false,"deleted_at":null,"created_at":"2019-11-20T12:59:03Z","staging":false,"comment":"","number":1,"updated_at":"2019-11-20T12:59:03Z","active":false}],"publish_key":"84a3007cd3e38afa00fdeb2cf36b24361153c410","updated_at":"2019-11-20T12:59:03Z","id":"3qt0xLYGlOxt19jpAQ0LJM","deleted_at":null,"created_at":"2019-11-20T12:59:03Z"}' + headers: + Accept-Ranges: + - bytes + Cache-Control: + - no-cache + Content-Type: + - application/json + Date: + - Wed, 20 Nov 2019 12:59:03 GMT + Fastly-Ratelimit-Remaining: + - "972" + Fastly-Ratelimit-Reset: + - "1574254800" + Status: + - 200 OK + Strict-Transport-Security: + - max-age=31536000 + Vary: + - Accept-Encoding + Via: + - 1.1 varnish + X-Cache: + - MISS, MISS + X-Cache-Hits: + - 0, 0 + X-Served-By: + - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19265-LCY + X-Timer: + - S1574254744.559435,VS0,VE269 + status: 200 OK + code: 200 + duration: "" diff --git a/fastly/fixtures/wafs/service/delete.yaml b/fastly/fixtures/wafs/service/delete.yaml new file mode 100644 index 000000000..bf88320bc --- /dev/null +++ b/fastly/fixtures/wafs/service/delete.yaml @@ -0,0 +1,45 @@ +--- +version: 1 +interactions: +- request: + body: "" + form: {} + headers: + User-Agent: + - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) + url: https://api.fastly.com/service/3qt0xLYGlOxt19jpAQ0LJM + method: DELETE + response: + body: '{"status":"ok"}' + headers: + Accept-Ranges: + - bytes + Cache-Control: + - no-cache + Content-Type: + - application/json + Date: + - Wed, 20 Nov 2019 12:59:09 GMT + Fastly-Ratelimit-Remaining: + - "964" + Fastly-Ratelimit-Reset: + - "1574254800" + Status: + - 200 OK + Strict-Transport-Security: + - max-age=31536000 + Vary: + - Accept-Encoding + Via: + - 1.1 varnish + X-Cache: + - MISS, MISS + X-Cache-Hits: + - 0, 0 + X-Served-By: + - cache-control-slwdc9036-CONTROL-SLWDC, cache-lcy19265-LCY + X-Timer: + - S1574254749.852966,VS0,VE301 + status: 200 OK + code: 200 + duration: "" diff --git a/fastly/fixtures/wafs/service/version.yaml b/fastly/fixtures/wafs/service/version.yaml new file mode 100644 index 000000000..69b717cc7 --- /dev/null +++ b/fastly/fixtures/wafs/service/version.yaml @@ -0,0 +1,49 @@ +--- +version: 1 +interactions: +- request: + body: Service=3qt0xLYGlOxt19jpAQ0LJM + form: + Service: + - 3qt0xLYGlOxt19jpAQ0LJM + headers: + Content-Type: + - application/x-www-form-urlencoded + User-Agent: + - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) + url: https://api.fastly.com/service/3qt0xLYGlOxt19jpAQ0LJM/version + method: POST + response: + body: '{"service_id":"3qt0xLYGlOxt19jpAQ0LJM","number":2}' + headers: + Accept-Ranges: + - bytes + Cache-Control: + - no-cache + Content-Type: + - application/json + Date: + - Wed, 20 Nov 2019 12:59:04 GMT + Fastly-Ratelimit-Remaining: + - "971" + Fastly-Ratelimit-Reset: + - "1574254800" + Status: + - 200 OK + Strict-Transport-Security: + - max-age=31536000 + Vary: + - Accept-Encoding + Via: + - 1.1 varnish + X-Cache: + - MISS, MISS + X-Cache-Hits: + - 0, 0 + X-Served-By: + - cache-control-slwdc9036-CONTROL-SLWDC, cache-lcy19265-LCY + X-Timer: + - S1574254744.878101,VS0,VE349 + status: 200 OK + code: 200 + duration: "" diff --git a/fastly/fixtures/wafs/update.yaml b/fastly/fixtures/wafs/update.yaml index 5097ed347..7ff51a6e3 100644 --- a/fastly/fixtures/wafs/update.yaml +++ b/fastly/fixtures/wafs/update.yaml @@ -3,7 +3,7 @@ version: 1 interactions: - request: body: | - {"data":{"type":"waf_firewall","id":"59onHkuKX28AMcf0gOojis","attributes":{"prefetch_condition":"","response":"test-response-object-2","service_id":"6gkEdARZ3mPzhQvdi2YH3j","service_version_number":"2"}}} + {"data":{"type":"waf_firewall","id":"5ui1qC2Y9TZIonO95zU3gM","attributes":{"prefetch_condition":"","response":"test-response-object-2","service_id":"3qt0xLYGlOxt19jpAQ0LJM","service_version_number":"2"}}} form: {} headers: Accept: @@ -12,12 +12,12 @@ interactions: - application/vnd.api+json User-Agent: - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) - url: https://api.fastly.com/waf/firewalls/59onHkuKX28AMcf0gOojis + url: https://api.fastly.com/waf/firewalls/5ui1qC2Y9TZIonO95zU3gM method: PATCH response: - body: '{"data":{"id":"59onHkuKX28AMcf0gOojis","type":"waf_firewall","attributes":{"service_id":"6gkEdARZ3mPzhQvdi2YH3j","prefetch_condition":"","response":"test-response-object-2","disabled":false,"service_version_number":2,"created_at":"2019-11-12T16:10:23Z","updated_at":"2019-11-12T16:10:23Z","active_rules_trustwave_log_count":0,"active_rules_trustwave_block_count":0,"active_rules_fastly_log_count":0,"active_rules_fastly_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_score_count":0}},"meta":{"warnings":[{"title":"This + body: '{"data":{"id":"5ui1qC2Y9TZIonO95zU3gM","type":"waf_firewall","attributes":{"service_id":"3qt0xLYGlOxt19jpAQ0LJM","prefetch_condition":"","response":"test-response-object-2","disabled":false,"service_version_number":2,"created_at":"2019-11-20T12:59:05Z","updated_at":"2019-11-20T12:59:05Z","active_rules_trustwave_log_count":0,"active_rules_trustwave_block_count":0,"active_rules_fastly_log_count":0,"active_rules_fastly_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_score_count":0}},"meta":{"warnings":[{"title":"This version of this service must be active","detail":"You may only update the WAF - VCL on an active version of a service. The version 2 of service 6gkEdARZ3mPzhQvdi2YH3j + VCL on an active version of a service. The version 2 of service 3qt0xLYGlOxt19jpAQ0LJM is not active. You may activate it through https://app.fastly.com or through the API: https://docs.fastly.com/api/config#version Be sure to review the version''s changes before activating it."}]}}' @@ -30,7 +30,7 @@ interactions: Content-Type: - application/vnd.api+json Date: - - Tue, 12 Nov 2019 16:10:24 GMT + - Wed, 20 Nov 2019 12:59:07 GMT Status: - 200 OK Strict-Transport-Security: @@ -44,9 +44,9 @@ interactions: X-Content-Type-Options: - nosniff X-Served-By: - - cache-control-slwdc9035-CONTROL-SLWDC, cache-lcy19279-LCY + - cache-control-slwdc9035-CONTROL-SLWDC, cache-lcy19265-LCY X-Timer: - - S1573575024.240097,VS0,VE283 + - S1574254747.806856,VS0,VE292 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/wafs/version.yaml b/fastly/fixtures/wafs/version.yaml deleted file mode 100644 index 987ac8298..000000000 --- a/fastly/fixtures/wafs/version.yaml +++ /dev/null @@ -1,58 +0,0 @@ ---- -version: 1 -interactions: -- request: - body: Service=6gkEdARZ3mPzhQvdi2YH3j - form: - Service: - - 6gkEdARZ3mPzhQvdi2YH3j - headers: - Content-Type: - - application/x-www-form-urlencoded - User-Agent: -<<<<<<< HEAD - - FastlyGo/1.10.0 (+github.com/fastly/go-fastly; go1.12) - url: https://api.fastly.com/service/7i6HN3TK9wS159v2gPAZ8A/version - method: POST - response: - body: '{"service_id":"7i6HN3TK9wS159v2gPAZ8A","number":34}' -======= - - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) - url: https://api.fastly.com/service/6gkEdARZ3mPzhQvdi2YH3j/version - method: POST - response: - body: '{"service_id":"6gkEdARZ3mPzhQvdi2YH3j","number":2}' ->>>>>>> Service waf component (#5) - headers: - Accept-Ranges: - - bytes - - bytes - Cache-Control: - - no-cache - Content-Type: - - application/json - Date: - - Tue, 12 Nov 2019 16:10:21 GMT - Fastly-Ratelimit-Remaining: - - "976" - Fastly-Ratelimit-Reset: - - "1573578000" - Status: - - 200 OK - Strict-Transport-Security: - - max-age=31536000 - Vary: - - Accept-Encoding - Via: - - 1.1 varnish - X-Cache: - - MISS, MISS - X-Cache-Hits: - - 0, 0 - X-Served-By: - - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19279-LCY - X-Timer: - - S1573575021.764746,VS0,VE374 - status: 200 OK - code: 200 - duration: "" diff --git a/fastly/waf.go b/fastly/waf.go index a01f356f3..a0c432831 100644 --- a/fastly/waf.go +++ b/fastly/waf.go @@ -20,7 +20,7 @@ type WAFConfigurationSet struct { ID string `jsonapi:"primary,configuration_set"` } -// WAF is the information about a firewall object. +// WAF is the information about a firewall object. type WAF struct { ID string `jsonapi:"primary,waf_firewall"` ServiceID string `jsonapi:"attr,service_id"` @@ -279,32 +279,6 @@ func (c *Client) DisableWAF(id string) error { return nil } -// DeployWAFInput is the input configuration used to deploy a WAF. -type DeployWAFInput struct { - // These are the ID and version of the WAF. - ID string - Version int -} - -// DeployWAFVersion deploys (i.e. activates) a WAF by version. -func (c *Client) DeployWAFVersion(i *DeployWAFInput) error { - - if i.ID == "" { - return ErrMissingWAFID - } - - if i.Version == 0 { - return ErrMissingVersion - } - - path := fmt.Sprintf("/waf/firewalls/%s/versions/%d", i.ID, i.Version) - _, err := c.PostJSONAPI(path, i, nil) - if err != nil { - return err - } - return nil -} - // DeleteWAFInput is used as input to the DeleteWAFInput function. type DeleteWAFInput struct { // This is the WAF ID. @@ -911,6 +885,7 @@ func getResponseInfo(body io.Reader) (infoResponse, error) { return infoResponse{}, err } return info, nil + } // GetWAFRuleStatusInput specifies the parameters for the GetWAFRuleStatus call. diff --git a/fastly/waf_test.go b/fastly/waf_test.go index 65ab71eaa..40ed8579a 100644 --- a/fastly/waf_test.go +++ b/fastly/waf_test.go @@ -13,93 +13,20 @@ func TestClient_WAFs(t *testing.T) { fixtureBase := "wafs/" - testService := createTestService(t, fixtureBase+"create_service", "service") - defer deleteTestService(t, fixtureBase+"delete_service", testService.ID) + testService := createTestService(t, fixtureBase+"service/create", "service") + defer deleteTestService(t, fixtureBase+"/service/delete", testService.ID) - tv := createTestVersion(t, fixtureBase+"/version", testService.ID) + tv := createTestVersion(t, fixtureBase+"/service/version", testService.ID) - var err error - // Enable logging on the service - we cannot create wafs without logging - // enabled - record(t, fixtureBase+"/logging/create", func(c *Client) { - _, err = c.CreateSyslog(&CreateSyslogInput{ - Service: testService.ID, - Version: tv.Number, - Name: "test-syslog", - Address: "example.com", - Hostname: "example.com", - Port: 1234, - Token: "abcd1234", - Format: "format", - FormatVersion: 2, - MessageType: "classic", - }) - }) - if err != nil { - t.Fatal(err) - } - defer func() { - record(t, fixtureBase+"/logging/cleanup", func(c *Client) { - c.DeleteSyslog(&DeleteSyslogInput{ - Service: testService.ID, - Version: tv.Number, - Name: "test-syslog", - }) - }) - }() + prefetch := "WAF_Prefetch" + condition := createTestWAFCondition(t, fixtureBase+"/condition/create", testService.ID, prefetch, tv.Number) + defer deleteTestWAFCondition(t, fixtureBase+"/condition/delete", testService.ID, prefetch, tv.Number) - // Create a condition - we cannot create a waf without attaching a condition - var condition *Condition - record(t, fixtureBase+"/condition/create", func(c *Client) { - condition, err = c.CreateCondition(&CreateConditionInput{ - Service: testService.ID, - Version: tv.Number, - Name: "WAF_Prefetch", - Statement: "req.url~+\"index.html\"", - Type: "PREFETCH", // This must be a prefetch condition - Priority: 1, - }) - }) - if err != nil { - t.Fatal(err) - } - defer func() { - record(t, fixtureBase+"/condition/cleanup", func(c *Client) { - c.DeleteCondition(&DeleteConditionInput{ - Service: testService.ID, - Version: tv.Number, - Name: condition.Name, - }) - }) - }() + responseName := "WAf_Response" + ro := createTestResponseObject(t, fixtureBase+"/response_object/create", testService.ID, responseName, tv.Number) + defer deleteTestResponseObject(t, fixtureBase+"/response_object/delete", testService.ID, responseName, tv.Number) - // Create a response object - var ro *ResponseObject - record(t, fixtureBase+"/response_object/create", func(c *Client) { - ro, err = c.CreateResponseObject(&CreateResponseObjectInput{ - Service: testService.ID, - Version: tv.Number, - Name: "WAf_Response", - Status: 200, - Response: "Ok", - Content: "abcd", - ContentType: "text/plain", - }) - }) - if err != nil { - t.Fatal(err) - } - defer func() { - record(t, fixtureBase+"/response_object/cleanup", func(c *Client) { - c.DeleteResponseObject(&DeleteResponseObjectInput{ - Service: testService.ID, - Version: tv.Number, - Name: ro.Name, - }) - }) - }() - - // Create + var err error var waf *WAF record(t, fixtureBase+"/create", func(c *Client) { waf, err = c.CreateWAF(&CreateWAFInput{ @@ -254,7 +181,6 @@ func TestClient_WAFs(t *testing.T) { if err != nil { t.Fatal(err) } - } func TestClient_CreateWAF_validation(t *testing.T) { diff --git a/fastly/waf_version.go b/fastly/waf_version.go new file mode 100644 index 000000000..92358ba0b --- /dev/null +++ b/fastly/waf_version.go @@ -0,0 +1,376 @@ +package fastly + +import ( + "bytes" + "fmt" + "io" + "reflect" + "strconv" + "time" + + "github.com/google/jsonapi" +) + +// WAFVersionType is used for reflection because JSONAPI wants to know what it's +// decoding into. +var WAFVersionType = reflect.TypeOf(new(WAFVersion)) + +// WAFPaginationPageSize used as the default pagination page size by the WAF related requests. +const WAFPaginationPageSize = 100 + +// WAFVersion is the information about a WAF version object. +type WAFVersion struct { + // See documentation here https://docs.fastly.com/api/ngwaf#api-section-ngwaf_firewall_versions + ID string `jsonapi:"primary,waf_firewall_version"` + Number int `jsonapi:"attr,number"` + Active bool `jsonapi:"attr,active"` + Locked bool `jsonapi:"attr,locked"` + CRSValidateUTF8Encoding bool `jsonapi:"attr,crs_validate_utf8_encoding"` + Comment string `jsonapi:"attr,comment"` + Error string `jsonapi:"attr,error"` + DeployedAt *time.Time `jsonapi:"attr,deployed_at,iso8601"` + AllowedHTTPVersions string `jsonapi:"attr,allowed_http_versions"` + AllowedMethods string `jsonapi:"attr,allowed_methods"` + AllowedRequestContentType string `jsonapi:"attr,allowed_request_content_type"` + AllowedRequestContentTypeCharset string `jsonapi:"attr,allowed_request_content_type_charset"` + HighRiskCountryCodes string `jsonapi:"attr,high_risk_country_codes"` + RestrictedExtensions string `jsonapi:"attr,restricted_extensions"` + RestrictedHeaders string `jsonapi:"attr,restricted_headers"` + CreatedAt *time.Time `jsonapi:"attr,created_at,iso8601"` + UpdatedAt *time.Time `jsonapi:"attr,updated_at,iso8601"` + ArgLength int `jsonapi:"attr,arg_length"` + ArgNameLength int `jsonapi:"attr,arg_name_length"` + CombinedFileSizes int `jsonapi:"attr,combined_file_sizes"` + CriticalAnomalyScore int `jsonapi:"attr,critical_anomaly_score"` + ErrorAnomalyScore int `jsonapi:"attr,error_anomaly_score"` + HTTPViolationScoreThreshold int `jsonapi:"attr,http_violation_score_threshold"` + InboundAnomalyScoreThreshold int `jsonapi:"attr,inbound_anomaly_score_threshold"` + LFIScoreThreshold int `jsonapi:"attr,lfi_score_threshold"` + MaxFileSize int `jsonapi:"attr,max_file_size"` + MaxNumArgs int `jsonapi:"attr,max_num_args"` + NoticeAnomalyScore int `jsonapi:"attr,notice_anomaly_score"` + ParanoiaLevel int `jsonapi:"attr,paranoia_level"` + PHPInjectionScoreThreshold int `jsonapi:"attr,php_injection_score_threshold"` + RCEScoreThreshold int `jsonapi:"attr,rce_score_threshold"` + RFIScoreThreshold int `jsonapi:"attr,rfi_score_threshold"` + SessionFixationScoreThreshold int `jsonapi:"attr,session_fixation_score_threshold"` + SQLInjectionScoreThreshold int `jsonapi:"attr,sql_injection_score_threshold"` + TotalArgLength int `jsonapi:"attr,total_arg_length"` + WarningAnomalyScore int `jsonapi:"attr,warning_anomaly_score"` + XSSScoreThreshold int `jsonapi:"attr,xss_score_threshold"` + ActiveRulesTrustwaveLogCount int `jsonapi:"attr,active_rules_trustwave_log_count"` + ActiveRulesTrustwaveBlockCount int `jsonapi:"attr,active_rules_trustwave_block_count"` + ActiveRulesFastlyLogCount int `jsonapi:"attr,active_rules_fastly_log_count"` + ActiveRulesFastlyBlockCount int `jsonapi:"attr,active_rules_fastly_block_count"` + ActiveRulesOWASPLogCount int `jsonapi:"attr,active_rules_owasp_log_count"` + ActiveRulesOWASPBlockCount int `jsonapi:"attr,active_rules_owasp_block_count"` +} + +// WAFVersionResponse represents a list WAF versions full response. +type WAFVersionResponse struct { + Items []*WAFVersion + Info infoResponse +} + +// ListWAFVersionsInput used as input for listing WAF versions. +type ListWAFVersionsInput struct { + // The Web Application Firewall's id. + WAFID string + // Limit the number records returned. + PageSize int + // Request a specific page of WAFs. + PageNumber int + // Include relationships. Optional, comma-separated values. Permitted values: waf_firewall_versions. + Include string +} + +func (i *ListWAFVersionsInput) formatFilters() map[string]string { + + result := map[string]string{} + pairings := map[string]interface{}{ + "page[size]": i.PageSize, + "page[number]": i.PageNumber, + "include": i.Include, + } + + for key, value := range pairings { + switch t := reflect.TypeOf(value).String(); t { + case "string": + if value != "" { + result[key] = value.(string) + } + case "int": + if value != 0 { + result[key] = strconv.Itoa(value.(int)) + } + } + } + return result +} + +// ListWAFVersions returns the list of VAF versions for a given WAF id. +func (c *Client) ListWAFVersions(i *ListWAFVersionsInput) (*WAFVersionResponse, error) { + + if i.WAFID == "" { + return nil, ErrMissingWAFID + } + + path := fmt.Sprintf("/waf/firewalls/%s/versions", i.WAFID) + resp, err := c.Get(path, &RequestOptions{ + Params: i.formatFilters(), + }) + if err != nil { + return nil, err + } + + var buf bytes.Buffer + tee := io.TeeReader(resp.Body, &buf) + + info, err := getResponseInfo(tee) + if err != nil { + return nil, err + } + + data, err := jsonapi.UnmarshalManyPayload(bytes.NewReader(buf.Bytes()), WAFVersionType) + if err != nil { + return nil, err + } + + wafVersions := make([]*WAFVersion, len(data)) + for i := range data { + typed, ok := data[i].(*WAFVersion) + if !ok { + return nil, fmt.Errorf("got back a non-WAFVersion response") + } + wafVersions[i] = typed + } + return &WAFVersionResponse{ + Items: wafVersions, + Info: info, + }, nil +} + +// ListAllWAFVersionsInput used as input for listing all WAF versions. +type ListAllWAFVersionsInput struct { + // The Web Application Firewall's id. + WAFID string + // Include relationships. Optional, comma-separated values. Permitted values: waf_firewall_versions. + Include string +} + +// ListAllWAFVersions returns the complete list of WAF versions for a given WAF id. It iterates through +// all existing pages to ensure all WAF versions are returned at once. +func (c *Client) ListAllWAFVersions(i *ListAllWAFVersionsInput) (*WAFVersionResponse, error) { + + if i.WAFID == "" { + return nil, ErrMissingWAFID + } + + currentPage := 1 + result := &WAFVersionResponse{Items: []*WAFVersion{}} + for { + r, err := c.ListWAFVersions(&ListWAFVersionsInput{ + WAFID: i.WAFID, + Include: i.Include, + PageNumber: currentPage, + PageSize: WAFPaginationPageSize, + }) + if err != nil { + return r, err + } + + currentPage++ + result.Items = append(result.Items, r.Items...) + + if r.Info.Links.Next == "" || len(r.Items) == 0 { + return result, nil + } + } +} + +// GetWAFVersionInput used as input for GetWAFVersion function. +type GetWAFVersionInput struct { + // The Web Application Firewall's id. + WAFID string + // the Web Application Firewall's version number. + WAFVersionNumber int +} + +// GetWAFVersion gets details for given WAF version. +func (c *Client) GetWAFVersion(i *GetWAFVersionInput) (*WAFVersion, error) { + + if i.WAFID == "" { + return nil, ErrMissingWAFID + } + + if i.WAFVersionNumber == 0 { + return nil, ErrMissingWAFVersionNumber + } + + path := fmt.Sprintf("/waf/firewalls/%s/versions/%d", i.WAFID, i.WAFVersionNumber) + resp, err := c.Get(path, nil) + if err != nil { + return nil, err + } + + var wafVer WAFVersion + if err := jsonapi.UnmarshalPayload(resp.Body, &wafVer); err != nil { + return nil, err + } + return &wafVer, nil +} + +// UpdateWAFVersionInput is used as input to the UpdateWAFVersion function. +type UpdateWAFVersionInput struct { + // The Web Application Firewall's id. + WAFID string + // the Web Application Firewall's version id. + WAFVersionID string `jsonapi:"primary,waf_firewall"` + // the Web Application Firewall's version number. + WAFVersionNumber int + Comment string `jsonapi:"attr,comment,omitempty"` + CRSValidateUTF8Encoding bool `jsonapi:"attr,crs_validate_utf8_encoding,omitempty"` + AllowedHTTPVersions string `jsonapi:"attr,allowed_http_versions,omitempty"` + AllowedMethods string `jsonapi:"attr,allowed_methods,omitempty"` + AllowedRequestContentType string `jsonapi:"attr,allowed_request_content_type,omitempty"` + AllowedRequestContentTypeCharset string `jsonapi:"attr,allowed_request_content_type_charset,omitempty"` + HighRiskCountryCodes string `jsonapi:"attr,high_risk_country_codes,omitempty"` + RestrictedExtensions string `jsonapi:"attr,restricted_extensions,omitempty"` + RestrictedHeaders string `jsonapi:"attr,restricted_headers,omitempty"` + ArgLength int `jsonapi:"attr,arg_length,omitempty"` + ArgNameLength int `jsonapi:"attr,arg_name_length,omitempty"` + CombinedFileSizes int `jsonapi:"attr,combined_file_sizes,omitempty"` + CriticalAnomalyScore int `jsonapi:"attr,critical_anomaly_score,omitempty"` + ErrorAnomalyScore int `jsonapi:"attr,error_anomaly_score,omitempty"` + HTTPViolationScoreThreshold int `jsonapi:"attr,http_violation_score_threshold,omitempty"` + InboundAnomalyScoreThreshold int `jsonapi:"attr,inbound_anomaly_score_threshold,omitempty"` + LFIScoreThreshold int `jsonapi:"attr,lfi_score_threshold,omitempty"` + MaxFileSize int `jsonapi:"attr,max_file_size,omitempty"` + MaxNumArgs int `jsonapi:"attr,max_num_args,omitempty"` + NoticeAnomalyScore int `jsonapi:"attr,notice_anomaly_score,omitempty"` + ParanoiaLevel int `jsonapi:"attr,paranoia_level,omitempty"` + PHPInjectionScoreThreshold int `jsonapi:"attr,php_injection_score_threshold,omitempty"` + RCEScoreThreshold int `jsonapi:"attr,rce_score_threshold,omitempty"` + RFIScoreThreshold int `jsonapi:"attr,rfi_score_threshold,omitempty"` + SessionFixationScoreThreshold int `jsonapi:"attr,session_fixation_score_threshold,omitempty"` + SQLInjectionScoreThreshold int `jsonapi:"attr,sql_injection_score_threshold,omitempty"` + TotalArgLength int `jsonapi:"attr,total_arg_length,omitempty"` + WarningAnomalyScore int `jsonapi:"attr,warning_anomaly_score,omitempty"` + XSSScoreThreshold int `jsonapi:"attr,xss_score_threshold,omitempty"` +} + +// UpdateWAFVersion updates a specific WAF version. +func (c *Client) UpdateWAFVersion(i *UpdateWAFVersionInput) (*WAFVersion, error) { + if i.WAFID == "" { + return nil, ErrMissingWAFID + } + + if i.WAFVersionNumber == 0 { + return nil, ErrMissingWAFVersionNumber + } + + if i.WAFVersionID == "" { + return nil, ErrMissingWAFVersionID + } + + path := fmt.Sprintf("/waf/firewalls/%s/versions/%d", i.WAFID, i.WAFVersionNumber) + resp, err := c.PatchJSONAPI(path, i, nil) + if err != nil { + return nil, err + } + + var waf WAFVersion + if err := jsonapi.UnmarshalPayload(resp.Body, &waf); err != nil { + return nil, err + } + return &waf, nil +} + +// LockWAFVersionInput used as input for locking a WAF version. +type LockWAFVersionInput struct { + // The Web Application Firewall's id. + WAFID string + // The Web Application Firewall's version number. + WAFVersionNumber int +} + +// LockWAFVersion locks a specific WAF version. +func (c *Client) LockWAFVersion(i *LockWAFVersionInput) (*WAFVersion, error) { + if i.WAFID == "" { + return nil, ErrMissingWAFID + } + + if i.WAFVersionNumber == 0 { + return nil, ErrMissingWAFVersionNumber + } + + path := fmt.Sprintf("/waf/firewalls/%s/versions/%d/lock", i.WAFID, i.WAFVersionNumber) + resp, err := c.PutJSONAPI(path, &LockWAFVersionInput{}, nil) + if err != nil { + return nil, err + } + + var waf WAFVersion + if err := jsonapi.UnmarshalPayload(resp.Body, &waf); err != nil { + return nil, err + } + return &waf, nil +} + +// CloneWAFVersionInput used as input for cloning a WAF version. +type CloneWAFVersionInput struct { + // The Web Application Firewall's id. + WAFID string + // The Web Application Firewall's version number. + WAFVersionNumber int +} + +// CloneWAFVersion clones a specific WAF version. +func (c *Client) CloneWAFVersion(i *CloneWAFVersionInput) (*WAFVersion, error) { + if i.WAFID == "" { + return nil, ErrMissingWAFID + } + + if i.WAFVersionNumber == 0 { + return nil, ErrMissingWAFVersionNumber + } + + path := fmt.Sprintf("/waf/firewalls/%s/versions/%d/clone", i.WAFID, i.WAFVersionNumber) + resp, err := c.PutJSONAPI(path, &CloneWAFVersionInput{}, nil) + if err != nil { + return nil, err + } + + var waf WAFVersion + if err := jsonapi.UnmarshalPayload(resp.Body, &waf); err != nil { + return nil, err + } + return &waf, nil +} + +// DeployWAFVersionInput used as input for deploying a WAF version. +type DeployWAFVersionInput struct { + // The Web Application Firewall's id. + WAFID string + // The Web Application Firewall's version number. + WAFVersionNumber int +} + +// DeployWAFVersion deploys a specific WAF version. +func (c *Client) DeployWAFVersion(i *DeployWAFVersionInput) error { + + if i.WAFID == "" { + return ErrMissingWAFID + } + + if i.WAFVersionNumber == 0 { + return ErrMissingWAFVersionNumber + } + + path := fmt.Sprintf("/waf/firewalls/%s/versions/%d", i.WAFID, i.WAFVersionNumber) + _, err := c.PostJSONAPI(path, &DeployWAFVersionInput{}, nil) + if err != nil { + return err + } + return nil +} diff --git a/fastly/waf_version_test.go b/fastly/waf_version_test.go new file mode 100644 index 000000000..0b088dd6d --- /dev/null +++ b/fastly/waf_version_test.go @@ -0,0 +1,416 @@ +package fastly + +import ( + "reflect" + "strconv" + "testing" +) + +func TestClient_WAF_Versions(t *testing.T) { + t.Parallel() + + fixtureBase := "waf_versions/" + + testService := createTestService(t, fixtureBase+"service/create", "service") + defer deleteTestService(t, fixtureBase+"/service/delete", testService.ID) + + tv := createTestVersion(t, fixtureBase+"/service/version", testService.ID) + + createTestLogging(t, fixtureBase+"/logging/create", testService.ID, tv.Number) + defer deleteTestLogging(t, fixtureBase+"/logging/delete", testService.ID, tv.Number) + + prefetch := "WAF_Prefetch" + condition := createTestWAFCondition(t, fixtureBase+"/condition/create", testService.ID, prefetch, tv.Number) + defer deleteTestWAFCondition(t, fixtureBase+"/condition/delete", testService.ID, prefetch, tv.Number) + + responseName := "WAf_Response" + ro := createTestResponseObject(t, fixtureBase+"/response_object/create", testService.ID, responseName, tv.Number) + defer deleteTestResponseObject(t, fixtureBase+"/response_object/delete", testService.ID, responseName, tv.Number) + + var err error + var waf *WAF + record(t, fixtureBase+"/waf/create", func(c *Client) { + waf, err = c.CreateWAF(&CreateWAFInput{ + Service: testService.ID, + Version: strconv.Itoa(tv.Number), + PrefetchCondition: condition.Name, + Response: ro.Name, + }) + }) + if err != nil { + t.Fatal(err) + } + defer func() { + record(t, fixtureBase+"/waf/delete", func(c *Client) { + if err := c.DeleteWAF(&DeleteWAFInput{ + Version: strconv.Itoa(tv.Number), + ID: waf.ID, + }); err != nil { + t.Fatal(err) + } + }) + }() + + var wafVerResp *WAFVersionResponse + record(t, fixtureBase+"/list", func(c *Client) { + wafVerResp, err = c.ListWAFVersions(&ListWAFVersionsInput{ + WAFID: waf.ID, + }) + }) + if err != nil { + t.Fatal(err) + } + if len(wafVerResp.Items) != 1 { + t.Errorf("expected 1 waf: got %d", len(wafVerResp.Items)) + } + + record(t, fixtureBase+"/deploy", func(c *Client) { + err = c.DeployWAFVersion(&DeployWAFVersionInput{ + WAFID: waf.ID, + WAFVersionNumber: 1, + }) + }) + if err != nil { + t.Fatal(err) + } + + var wafVer *WAFVersion + record(t, fixtureBase+"/clone", func(c *Client) { + wafVer, err = c.CloneWAFVersion(&CloneWAFVersionInput{ + WAFID: waf.ID, + WAFVersionNumber: 1, + }) + }) + if err != nil { + t.Fatal(err) + } + if wafVer == nil { + t.Errorf("expected 1 waf: got %d", len(wafVerResp.Items)) + } + + record(t, fixtureBase+"/get", func(c *Client) { + wafVer, err = c.GetWAFVersion(&GetWAFVersionInput{ + WAFID: waf.ID, + WAFVersionNumber: 2, + }) + }) + if err != nil { + t.Fatal(err) + } + if wafVer == nil { + t.Error("expected waf, got nil") + } + + input := buildUpdateInput() + input.WAFID = waf.ID + input.WAFVersionNumber = 2 + input.WAFVersionID = wafVer.ID + record(t, fixtureBase+"/update", func(c *Client) { + wafVer, err = c.UpdateWAFVersion(input) + }) + if err != nil { + t.Fatal(err) + } + if wafVer == nil { + t.Error("expected waf, got nil") + } + verifyWAFVersionUpdate(t, input, wafVer) + + record(t, fixtureBase+"/lock", func(c *Client) { + wafVer, err = c.LockWAFVersion(&LockWAFVersionInput{ + WAFID: waf.ID, + WAFVersionNumber: 2, + }) + }) + if err != nil { + t.Fatal(err) + } + if wafVer == nil { + t.Error("expected waf, got nil") + } + if !wafVer.Locked { + t.Errorf("expected locked = true waf: got locked == %v", wafVer.Locked) + } + + record(t, fixtureBase+"/list_all", func(c *Client) { + wafVerResp, err = c.ListAllWAFVersions(&ListAllWAFVersionsInput{ + WAFID: waf.ID, + }) + }) + if err != nil { + t.Fatal(err) + } + if len(wafVerResp.Items) != 2 { + t.Errorf("expected 2 waf: got %d", len(wafVerResp.Items)) + } +} + +func verifyWAFVersionUpdate(t *testing.T, i *UpdateWAFVersionInput, o *WAFVersion) { + + if i.WAFVersionID != o.ID { + t.Errorf("expected %s waf: got %s", i.WAFVersionID, o.ID) + } + if i.AllowedHTTPVersions != o.AllowedHTTPVersions { + t.Errorf("expected %s waf: got %s", i.AllowedHTTPVersions, o.AllowedHTTPVersions) + } + if i.AllowedMethods != o.AllowedMethods { + t.Errorf("expected %s waf: got %s", i.AllowedMethods, o.AllowedMethods) + } + if i.AllowedRequestContentType != o.AllowedRequestContentType { + t.Errorf("expected %s waf: got %s", i.AllowedRequestContentType, o.AllowedRequestContentType) + } + if i.AllowedRequestContentTypeCharset != o.AllowedRequestContentTypeCharset { + t.Errorf("expected %s waf: got %s", i.AllowedRequestContentTypeCharset, o.AllowedRequestContentTypeCharset) + } + if i.ArgLength != o.ArgLength { + t.Errorf("expected %d waf: got %d", i.ArgLength, o.ArgLength) + } + if i.ArgNameLength != o.ArgNameLength { + t.Errorf("expected %d waf: got %d", i.ArgNameLength, o.ArgNameLength) + } + if i.CombinedFileSizes != o.CombinedFileSizes { + t.Errorf("expected %d waf: got %d", i.CombinedFileSizes, o.CombinedFileSizes) + } + if i.CriticalAnomalyScore != o.CriticalAnomalyScore { + t.Errorf("expected %d waf: got %d", i.CriticalAnomalyScore, o.CriticalAnomalyScore) + } + if i.CRSValidateUTF8Encoding != o.CRSValidateUTF8Encoding { + t.Errorf("expected %v waf: got %v", i.CRSValidateUTF8Encoding, o.CRSValidateUTF8Encoding) + } + if i.ErrorAnomalyScore != o.ErrorAnomalyScore { + t.Errorf("expected %d waf: got %d", i.ErrorAnomalyScore, o.ErrorAnomalyScore) + } + if i.HighRiskCountryCodes != o.HighRiskCountryCodes { + t.Errorf("expected %s waf: got %s", i.HighRiskCountryCodes, o.HighRiskCountryCodes) + } + if i.HTTPViolationScoreThreshold != o.HTTPViolationScoreThreshold { + t.Errorf("expected %d waf: got %d", i.HTTPViolationScoreThreshold, o.HTTPViolationScoreThreshold) + } + if i.InboundAnomalyScoreThreshold != o.InboundAnomalyScoreThreshold { + t.Errorf("expected %d waf: got %d", i.InboundAnomalyScoreThreshold, o.InboundAnomalyScoreThreshold) + } + if i.LFIScoreThreshold != o.LFIScoreThreshold { + t.Errorf("expected %d waf: got %d", i.LFIScoreThreshold, o.LFIScoreThreshold) + } + if i.MaxFileSize != o.MaxFileSize { + t.Errorf("expected %d waf: got %d", i.MaxFileSize, o.MaxFileSize) + } + if i.MaxNumArgs != o.MaxNumArgs { + t.Errorf("expected %d waf: got %d", i.MaxNumArgs, o.MaxNumArgs) + } + if i.NoticeAnomalyScore != o.NoticeAnomalyScore { + t.Errorf("expected %d waf: got %d", i.NoticeAnomalyScore, o.NoticeAnomalyScore) + } + if i.ParanoiaLevel != o.ParanoiaLevel { + t.Errorf("expected %d waf: got %d", i.ParanoiaLevel, o.ParanoiaLevel) + } + if i.PHPInjectionScoreThreshold != o.PHPInjectionScoreThreshold { + t.Errorf("expected %d waf: got %d", i.PHPInjectionScoreThreshold, o.PHPInjectionScoreThreshold) + } + if i.RCEScoreThreshold != o.RCEScoreThreshold { + t.Errorf("expected %d waf: got %d", i.RCEScoreThreshold, o.RCEScoreThreshold) + } + if i.RestrictedExtensions != o.RestrictedExtensions { + t.Errorf("expected %s waf: got %s", i.RestrictedExtensions, o.RestrictedExtensions) + } + if i.RestrictedHeaders != o.RestrictedHeaders { + t.Errorf("expected %s waf: got %s", i.RestrictedHeaders, o.RestrictedHeaders) + } + if i.RFIScoreThreshold != o.RFIScoreThreshold { + t.Errorf("expected %d waf: got %d", i.RFIScoreThreshold, o.RFIScoreThreshold) + } + if i.SessionFixationScoreThreshold != o.SessionFixationScoreThreshold { + t.Errorf("expected %d waf: got %d", i.SessionFixationScoreThreshold, o.SessionFixationScoreThreshold) + } + if i.SQLInjectionScoreThreshold != o.SQLInjectionScoreThreshold { + t.Errorf("expected %d waf: got %d", i.SQLInjectionScoreThreshold, o.SQLInjectionScoreThreshold) + } + if i.TotalArgLength != o.TotalArgLength { + t.Errorf("expected %d waf: got %d", i.TotalArgLength, o.TotalArgLength) + } + if i.WarningAnomalyScore != o.WarningAnomalyScore { + t.Errorf("expected %d waf: got %d", i.WarningAnomalyScore, o.WarningAnomalyScore) + } + if i.XSSScoreThreshold != o.XSSScoreThreshold { + t.Errorf("expected %d waf: got %d", i.XSSScoreThreshold, o.XSSScoreThreshold) + } + +} + +func buildUpdateInput() *UpdateWAFVersionInput { + return &UpdateWAFVersionInput{ + Comment: "my comment", + AllowedHTTPVersions: "HTTP/1.0 HTTP/1.1", + AllowedMethods: "GET HEAD POST", + AllowedRequestContentType: "application/x-www-form-urlencoded|multipart/form-data|text/xml|application/xml", + AllowedRequestContentTypeCharset: "utf-8|iso-8859-1", + ArgLength: 800, + ArgNameLength: 200, + CombinedFileSizes: 20000000, + CriticalAnomalyScore: 12, + CRSValidateUTF8Encoding: true, + ErrorAnomalyScore: 10, + HighRiskCountryCodes: "gb", + HTTPViolationScoreThreshold: 20, + InboundAnomalyScoreThreshold: 20, + LFIScoreThreshold: 20, + MaxFileSize: 20000000, + MaxNumArgs: 510, + NoticeAnomalyScore: 8, + ParanoiaLevel: 2, + PHPInjectionScoreThreshold: 20, + RCEScoreThreshold: 20, + RestrictedExtensions: ".asa/ .asax/ .ascx/ .axd/ .backup/ .bak/ .bat/ .cdx/ .cer/ .cfg/ .cmd/ .com/", + RestrictedHeaders: "/proxy/ /lock-token/", + RFIScoreThreshold: 20, + SessionFixationScoreThreshold: 20, + SQLInjectionScoreThreshold: 20, + TotalArgLength: 12800, + WarningAnomalyScore: 20, + XSSScoreThreshold: 20, + } +} + +func TestClient_listWAFVersions_formatFilters(t *testing.T) { + cases := []struct { + remote *ListWAFVersionsInput + local map[string]string + }{ + { + remote: &ListWAFVersionsInput{ + PageSize: 2, + PageNumber: 2, + Include: "included", + }, + local: map[string]string{ + "page[size]": "2", + "page[number]": "2", + "include": "included", + }, + }, + } + for _, c := range cases { + out := c.remote.formatFilters() + if !reflect.DeepEqual(out, c.local) { + t.Fatalf("Error matching:\nexpected: %#v\n got: %#v", c.local, out) + } + } +} + +func TestClient_ListWAFVersions_validation(t *testing.T) { + var err error + _, err = testClient.ListWAFVersions(&ListWAFVersionsInput{ + WAFID: "", + }) + if err != ErrMissingWAFID { + t.Errorf("bad error: %s", err) + } +} + +func TestClient_ListAllWAFVersions_validation(t *testing.T) { + var err error + _, err = testClient.ListAllWAFVersions(&ListAllWAFVersionsInput{ + WAFID: "", + }) + if err != ErrMissingWAFID { + t.Errorf("bad error: %s", err) + } + + resp, err := testClient.ListAllWAFVersions(&ListAllWAFVersionsInput{ + WAFID: "4QXAURauMXa4KHQ3kRn5Yr", + }) + if err != nil { + t.Errorf("bad error: %s", err) + } + + print(resp) +} + +func TestClient_GetWAFVersion_validation(t *testing.T) { + var err error + _, err = testClient.GetWAFVersion(&GetWAFVersionInput{ + WAFID: "", + }) + if err != ErrMissingWAFID { + t.Errorf("bad error: %s", err) + } +} + +func TestClient_UpdateWAFVersion_validation(t *testing.T) { + var err error + _, err = testClient.UpdateWAFVersion(&UpdateWAFVersionInput{ + WAFID: "", + }) + if err != ErrMissingWAFID { + t.Errorf("bad error: %s", err) + } + + _, err = testClient.UpdateWAFVersion(&UpdateWAFVersionInput{ + WAFID: "1", + WAFVersionNumber: 0, + }) + if err != ErrMissingWAFVersionNumber { + t.Errorf("bad error: %s", err) + } + + _, err = testClient.UpdateWAFVersion(&UpdateWAFVersionInput{ + WAFID: "1", + WAFVersionNumber: 1, + WAFVersionID: "", + }) + if err != ErrMissingWAFVersionID { + t.Errorf("bad error: %s", err) + } +} + +func TestClient_LockWAFVersion_validation(t *testing.T) { + var err error + _, err = testClient.LockWAFVersion(&LockWAFVersionInput{ + WAFID: "", + }) + if err != ErrMissingWAFID { + t.Errorf("bad error: %s", err) + } + + _, err = testClient.LockWAFVersion(&LockWAFVersionInput{ + WAFID: "1", + WAFVersionNumber: 0, + }) + if err != ErrMissingWAFVersionNumber { + t.Errorf("bad error: %s", err) + } +} + +func TestClient_CloneWAFVersion_validation(t *testing.T) { + var err error + _, err = testClient.CloneWAFVersion(&CloneWAFVersionInput{ + WAFID: "", + }) + if err != ErrMissingWAFID { + t.Errorf("bad error: %s", err) + } + + _, err = testClient.CloneWAFVersion(&CloneWAFVersionInput{ + WAFID: "1", + WAFVersionNumber: 0, + }) + if err != ErrMissingWAFVersionNumber { + t.Errorf("bad error: %s", err) + } +} + +func TestClient_DeployWAFVersion_validation(t *testing.T) { + var err error + if err = testClient.DeployWAFVersion(&DeployWAFVersionInput{ + WAFID: "", + }); err != ErrMissingWAFID { + t.Errorf("bad error: %s", err) + } + + if err = testClient.DeployWAFVersion(&DeployWAFVersionInput{ + WAFID: "1", + WAFVersionNumber: 0, + }); err != ErrMissingWAFVersionNumber { + t.Errorf("bad error: %s", err) + } +} From 64d140f6c7ac45236be666ba67e4c29ad382d4f6 Mon Sep 17 00:00:00 2001 From: oscarDovao <31310209+oscarDovao@users.noreply.github.com> Date: Thu, 12 Dec 2019 15:22:13 +0000 Subject: [PATCH 03/37] Waf active rules (#9) * WAF active rules implementation --- fastly/client.go | 37 +- fastly/errors.go | 4 + fastly/fastly_test.go | 34 ++ .../waf_active_rules/condition/create.yaml | 59 ++++ fastly/fixtures/waf_active_rules/create.yaml | 46 +++ .../fixtures/waf_active_rules/delete_all.yaml | 41 +++ .../fixtures/waf_active_rules/delete_one.yaml | 42 +++ .../waf_active_rules/list_after_delete.yaml | 41 +++ .../list_after_delete_all.yaml | 41 +++ .../fixtures/waf_active_rules/list_empty.yaml | 43 +++ .../waf_active_rules/list_not_empty.yaml | 41 +++ .../waf_active_rules/list_not_empty2.yaml | 41 +++ .../waf_active_rules/logging/create.yaml | 67 ++++ .../waf_active_rules/logging/delete.yaml | 45 +++ .../response_object/create.yaml | 61 ++++ .../waf_active_rules/service/create.yaml | 51 +++ .../waf_active_rules/service/delete.yaml | 45 +++ .../waf_active_rules/service/version.yaml | 49 +++ fastly/fixtures/waf_active_rules/update.yaml | 46 +++ .../fixtures/waf_active_rules/waf/create.yaml | 46 +++ .../fixtures/waf_active_rules/waf/delete.yaml | 42 +++ fastly/waf.go | 2 +- fastly/waf_active_rule.go | 319 ++++++++++++++++++ fastly/waf_active_rule_test.go | 317 +++++++++++++++++ fastly/waf_version.go | 28 +- fastly/waf_version_test.go | 17 +- 26 files changed, 1579 insertions(+), 26 deletions(-) create mode 100644 fastly/fixtures/waf_active_rules/condition/create.yaml create mode 100644 fastly/fixtures/waf_active_rules/create.yaml create mode 100644 fastly/fixtures/waf_active_rules/delete_all.yaml create mode 100644 fastly/fixtures/waf_active_rules/delete_one.yaml create mode 100644 fastly/fixtures/waf_active_rules/list_after_delete.yaml create mode 100644 fastly/fixtures/waf_active_rules/list_after_delete_all.yaml create mode 100644 fastly/fixtures/waf_active_rules/list_empty.yaml create mode 100644 fastly/fixtures/waf_active_rules/list_not_empty.yaml create mode 100644 fastly/fixtures/waf_active_rules/list_not_empty2.yaml create mode 100644 fastly/fixtures/waf_active_rules/logging/create.yaml create mode 100644 fastly/fixtures/waf_active_rules/logging/delete.yaml create mode 100644 fastly/fixtures/waf_active_rules/response_object/create.yaml create mode 100644 fastly/fixtures/waf_active_rules/service/create.yaml create mode 100644 fastly/fixtures/waf_active_rules/service/delete.yaml create mode 100644 fastly/fixtures/waf_active_rules/service/version.yaml create mode 100644 fastly/fixtures/waf_active_rules/update.yaml create mode 100644 fastly/fixtures/waf_active_rules/waf/create.yaml create mode 100644 fastly/fixtures/waf_active_rules/waf/delete.yaml create mode 100644 fastly/waf_active_rule.go create mode 100644 fastly/waf_active_rule_test.go diff --git a/fastly/client.go b/fastly/client.go index 9cb108763..18b5a5f3a 100644 --- a/fastly/client.go +++ b/fastly/client.go @@ -211,6 +211,11 @@ func (c *Client) PostJSONAPI(p string, i interface{}, ro *RequestOptions) (*http return c.RequestJSONAPI("POST", p, i, ro) } +// PostJSONAPIBulk issues an HTTP POST request with the given interface json-encoded and bulk requests. +func (c *Client) PostJSONAPIBulk(p string, i interface{}, ro *RequestOptions) (*http.Response, error) { + return c.RequestJSONAPIBulk("POST", p, i, ro) +} + // Put issues an HTTP PUT request. func (c *Client) Put(p string, ro *RequestOptions) (*http.Response, error) { return c.Request("PUT", p, ro) @@ -241,11 +246,16 @@ func (c *Client) Delete(p string, ro *RequestOptions) (*http.Response, error) { return c.Request("DELETE", p, ro) } -// DeleteJSON issues an HTTP DELETE request. -func (c *Client) DeleteJSON(p string, i interface{}, ro *RequestOptions) (*http.Response, error) { +// DeleteJSONAPI issues an HTTP DELETE request with the given interface json-encoded. +func (c *Client) DeleteJSONAPI(p string, i interface{}, ro *RequestOptions) (*http.Response, error) { return c.RequestJSONAPI("DELETE", p, i, ro) } +// DeleteJSONAPIBulk issues an HTTP DELETE request with the given interface json-encoded and bulk requests. +func (c *Client) DeleteJSONAPIBulk(p string, i interface{}, ro *RequestOptions) (*http.Response, error) { + return c.RequestJSONAPIBulk("DELETE", p, i, ro) +} + // Request makes an HTTP request against the HTTPClient using the given verb, // Path, and request options. func (c *Client) Request(verb, p string, ro *RequestOptions) (*http.Response, error) { @@ -364,6 +374,29 @@ func (c *Client) RequestJSONAPI(verb, p string, i interface{}, ro *RequestOption ro.Headers["Content-Type"] = jsonapi.MediaType ro.Headers["Accept"] = jsonapi.MediaType + if i != nil { + var buf bytes.Buffer + if err := jsonapi.MarshalPayload(&buf, i); err != nil { + return nil, err + } + + ro.Body = &buf + ro.BodyLength = int64(buf.Len()) + } + return c.Request(verb, p, ro) +} + +func (c *Client) RequestJSONAPIBulk(verb, p string, i interface{}, ro *RequestOptions) (*http.Response, error) { + if ro == nil { + ro = new(RequestOptions) + } + + if ro.Headers == nil { + ro.Headers = make(map[string]string) + } + ro.Headers["Content-Type"] = jsonapi.MediaType + ro.Headers["Accept"] = jsonapi.MediaType + "; ext=bulk" + var buf bytes.Buffer if err := jsonapi.MarshalPayload(&buf, i); err != nil { return nil, err diff --git a/fastly/errors.go b/fastly/errors.go index df133dd6b..7849a45fa 100644 --- a/fastly/errors.go +++ b/fastly/errors.go @@ -113,6 +113,10 @@ var ErrMissingWAFVersionNumber = errors.New("Missing required field 'WAFVersionN // requires a "WAFVersionID" key, but one was not set. var ErrMissingWAFVersionID = errors.New("Missing required field 'WAFVersionID'") +// ErrMissingWAFActiveRuleList is an error that is returned when an input struct +// requires a list of WAF active rules, but it is empty. +var ErrMissingWAFActiveRuleList = errors.New("WAF active rules slice is empty") + // ErrMissingOWASPID is an error that is returned was an input struct // requires a "OWASPID" key, but one was not set var ErrMissingOWASPID = errors.New("missing required field 'OWASPID'") diff --git a/fastly/fastly_test.go b/fastly/fastly_test.go index ce1850e3e..af09f5482 100644 --- a/fastly/fastly_test.go +++ b/fastly/fastly_test.go @@ -410,6 +410,40 @@ func deleteTestResponseObject(t *testing.T, fixture, serviceID, name string, ser } } +func createWAF(t *testing.T, fixture, serviceID, serviceNumber, condition, response string) *WAF { + + var err error + var waf *WAF + + record(t, fixture, func(c *Client) { + waf, err = c.CreateWAF(&CreateWAFInput{ + Service: serviceID, + Version: serviceNumber, + PrefetchCondition: condition, + Response: response, + }) + }) + if err != nil { + t.Fatal(err) + } + return waf +} + +func deleteWAF(t *testing.T, fixture, WAFID, WAFVersion string) { + + var err error + + record(t, fixture, func(c *Client) { + err = c.DeleteWAF(&DeleteWAFInput{ + ID: WAFID, + Version: WAFVersion, + }) + }) + if err != nil { + t.Fatal(err) + } +} + func deleteTestService(t *testing.T, cleanupFixture string, serviceId string) { var err error diff --git a/fastly/fixtures/waf_active_rules/condition/create.yaml b/fastly/fixtures/waf_active_rules/condition/create.yaml new file mode 100644 index 000000000..6b185d7e4 --- /dev/null +++ b/fastly/fixtures/waf_active_rules/condition/create.yaml @@ -0,0 +1,59 @@ +--- +version: 1 +interactions: +- request: + body: Service=1qNbCw880P3rmalHHls5Oc&Version=2&name=WAF_Prefetch&priority=1&statement=req.url~%2B%22index.html%22&type=PREFETCH + form: + Service: + - 1qNbCw880P3rmalHHls5Oc + Version: + - "2" + name: + - WAF_Prefetch + priority: + - "1" + statement: + - req.url~+"index.html" + type: + - PREFETCH + headers: + Content-Type: + - application/x-www-form-urlencoded + User-Agent: + - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) + url: https://api.fastly.com/service/1qNbCw880P3rmalHHls5Oc/version/2/condition + method: POST + response: + body: '{"name":"WAF_Prefetch","priority":"1","statement":"req.url~+\"index.html\"","type":"PREFETCH","service_id":"1qNbCw880P3rmalHHls5Oc","version":"2","created_at":"2019-11-28T12:43:22Z","comment":"","deleted_at":null,"updated_at":"2019-11-28T12:43:22Z"}' + headers: + Accept-Ranges: + - bytes + Cache-Control: + - no-cache + Content-Type: + - application/json + Date: + - Thu, 28 Nov 2019 12:43:22 GMT + Fastly-Ratelimit-Remaining: + - "982" + Fastly-Ratelimit-Reset: + - "1574946000" + Status: + - 200 OK + Strict-Transport-Security: + - max-age=31536000 + Vary: + - Accept-Encoding + Via: + - 1.1 varnish + X-Cache: + - MISS, MISS + X-Cache-Hits: + - 0, 0 + X-Served-By: + - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19243-LCY + X-Timer: + - S1574945002.999829,VS0,VE247 + status: 200 OK + code: 200 + duration: "" diff --git a/fastly/fixtures/waf_active_rules/create.yaml b/fastly/fixtures/waf_active_rules/create.yaml new file mode 100644 index 000000000..72c26a381 --- /dev/null +++ b/fastly/fixtures/waf_active_rules/create.yaml @@ -0,0 +1,46 @@ +--- +version: 1 +interactions: +- request: + body: | + {"data":[{"type":"waf_active_rule","attributes":{"modsec_rule_id":2029718,"status":"log"}},{"type":"waf_active_rule","attributes":{"modsec_rule_id":2037405,"status":"log"}},{"type":"waf_active_rule","attributes":{"modsec_rule_id":1010070,"status":"log"}}]} + form: {} + headers: + Accept: + - application/vnd.api+json; ext=bulk + Content-Type: + - application/vnd.api+json + User-Agent: + - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) + url: https://api.fastly.com/waf/firewalls/5n9TykpTt7zn0KFJ4k9bMz/versions/1/rules + method: POST + response: + body: '{"data":[{"id":"6E8M7nScn1buIUJrSKvqkt","type":"waf_active_rule","attributes":{"status":"log","modsec_rule_id":2029718,"revision":1,"created_at":"2019-11-28T12:43:23Z","updated_at":"2019-11-28T12:43:23Z"},"relationships":{"waf_firewall_version":{"data":{"id":"6Wo0vAYg6cS79HacNpZrBm","type":"waf_firewall_version"}},"waf_rule_revision":{"data":{"id":"6ZJML5tsy5uVq1nGNgmZ78","type":"waf_rule_revision"}}}},{"id":"7UZK2qQ20TMUBoZbKo9NZy","type":"waf_active_rule","attributes":{"status":"log","modsec_rule_id":2037405,"revision":1,"created_at":"2019-11-28T12:43:24Z","updated_at":"2019-11-28T12:43:24Z"},"relationships":{"waf_firewall_version":{"data":{"id":"6Wo0vAYg6cS79HacNpZrBm","type":"waf_firewall_version"}},"waf_rule_revision":{"data":{"id":"3ANlv7vVZdzk2qFXlJLIk3","type":"waf_rule_revision"}}}},{"id":"5CVFtVaW0WCns3ksB7tMv2","type":"waf_active_rule","attributes":{"status":"log","modsec_rule_id":1010070,"revision":1,"created_at":"2019-11-28T12:43:24Z","updated_at":"2019-11-28T12:43:24Z"},"relationships":{"waf_firewall_version":{"data":{"id":"6Wo0vAYg6cS79HacNpZrBm","type":"waf_firewall_version"}},"waf_rule_revision":{"data":{"id":"2qiuFDyJoxuKkKkJYjrgsC","type":"waf_rule_revision"}}}}]}' + headers: + Accept-Ranges: + - bytes + Content-Length: + - "1201" + Content-Type: + - application/vnd.api+json + Date: + - Thu, 28 Nov 2019 12:43:24 GMT + Status: + - 201 Created + Strict-Transport-Security: + - max-age=31536000 + Via: + - 1.1 varnish + X-Cache: + - MISS, MISS + X-Cache-Hits: + - 0, 0 + X-Content-Type-Options: + - nosniff + X-Served-By: + - cache-control-slwdc9036-CONTROL-SLWDC, cache-lcy19243-LCY + X-Timer: + - S1574945004.785524,VS0,VE290 + status: 201 Created + code: 201 + duration: "" diff --git a/fastly/fixtures/waf_active_rules/delete_all.yaml b/fastly/fixtures/waf_active_rules/delete_all.yaml new file mode 100644 index 000000000..cc7735eec --- /dev/null +++ b/fastly/fixtures/waf_active_rules/delete_all.yaml @@ -0,0 +1,41 @@ +--- +version: 1 +interactions: +- request: + body: "" + form: {} + headers: + Accept: + - application/vnd.api+json + Content-Type: + - application/vnd.api+json + User-Agent: + - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) + url: https://api.fastly.com/waf/firewalls/5n9TykpTt7zn0KFJ4k9bMz/versions/1/rules + method: DELETE + response: + body: "" + headers: + Accept-Ranges: + - bytes + Date: + - Thu, 28 Nov 2019 12:43:25 GMT + Status: + - 204 No Content + Strict-Transport-Security: + - max-age=31536000 + Via: + - 1.1 varnish + X-Cache: + - MISS, MISS + X-Cache-Hits: + - 0, 0 + X-Content-Type-Options: + - nosniff + X-Served-By: + - cache-control-slwdc9036-CONTROL-SLWDC, cache-lcy19243-LCY + X-Timer: + - S1574945005.172121,VS0,VE153 + status: 204 No Content + code: 204 + duration: "" diff --git a/fastly/fixtures/waf_active_rules/delete_one.yaml b/fastly/fixtures/waf_active_rules/delete_one.yaml new file mode 100644 index 000000000..e52e88132 --- /dev/null +++ b/fastly/fixtures/waf_active_rules/delete_one.yaml @@ -0,0 +1,42 @@ +--- +version: 1 +interactions: +- request: + body: | + {"data":[{"type":"waf_active_rule","attributes":{"modsec_rule_id":1010070}}]} + form: {} + headers: + Accept: + - application/vnd.api+json; ext=bulk + Content-Type: + - application/vnd.api+json + User-Agent: + - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) + url: https://api.fastly.com/waf/firewalls/5n9TykpTt7zn0KFJ4k9bMz/versions/1/rules + method: DELETE + response: + body: "" + headers: + Accept-Ranges: + - bytes + Date: + - Thu, 28 Nov 2019 12:43:24 GMT + Status: + - 204 No Content + Strict-Transport-Security: + - max-age=31536000 + Via: + - 1.1 varnish + X-Cache: + - MISS, MISS + X-Cache-Hits: + - 0, 0 + X-Content-Type-Options: + - nosniff + X-Served-By: + - cache-control-slwdc9036-CONTROL-SLWDC, cache-lcy19243-LCY + X-Timer: + - S1574945005.763911,VS0,VE151 + status: 204 No Content + code: 204 + duration: "" diff --git a/fastly/fixtures/waf_active_rules/list_after_delete.yaml b/fastly/fixtures/waf_active_rules/list_after_delete.yaml new file mode 100644 index 000000000..573ef5bd7 --- /dev/null +++ b/fastly/fixtures/waf_active_rules/list_after_delete.yaml @@ -0,0 +1,41 @@ +--- +version: 1 +interactions: +- request: + body: "" + form: {} + headers: + User-Agent: + - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) + url: https://api.fastly.com/waf/firewalls/5n9TykpTt7zn0KFJ4k9bMz/versions/1/rules + method: GET + response: + body: '{"data":[{"id":"7UZK2qQ20TMUBoZbKo9NZy","type":"waf_active_rule","attributes":{"status":"block","modsec_rule_id":2037405,"revision":1,"created_at":"2019-11-28T12:43:24Z","updated_at":"2019-11-28T12:43:24Z"}},{"id":"6E8M7nScn1buIUJrSKvqkt","type":"waf_active_rule","attributes":{"status":"block","modsec_rule_id":2029718,"revision":1,"created_at":"2019-11-28T12:43:23Z","updated_at":"2019-11-28T12:43:24Z"}}],"links":{"last":"https://api.fastly.com/waf/firewalls/5n9TykpTt7zn0KFJ4k9bMz/versions/1/rules?page[number]=1\u0026page[size]=100","first":"https://api.fastly.com/waf/firewalls/5n9TykpTt7zn0KFJ4k9bMz/versions/1/rules?page[number]=1\u0026page[size]=100"},"meta":{"current_page":1,"per_page":100,"record_count":2,"total_pages":1}}' + headers: + Accept-Ranges: + - bytes + Content-Length: + - "735" + Content-Type: + - application/vnd.api+json + Date: + - Thu, 28 Nov 2019 12:43:25 GMT + Status: + - 200 OK + Strict-Transport-Security: + - max-age=31536000 + Via: + - 1.1 varnish + X-Cache: + - MISS, MISS + X-Cache-Hits: + - 0, 0 + X-Content-Type-Options: + - nosniff + X-Served-By: + - cache-control-slwdc9035-CONTROL-SLWDC, cache-lcy19243-LCY + X-Timer: + - S1574945005.966243,VS0,VE153 + status: 200 OK + code: 200 + duration: "" diff --git a/fastly/fixtures/waf_active_rules/list_after_delete_all.yaml b/fastly/fixtures/waf_active_rules/list_after_delete_all.yaml new file mode 100644 index 000000000..cc10efb04 --- /dev/null +++ b/fastly/fixtures/waf_active_rules/list_after_delete_all.yaml @@ -0,0 +1,41 @@ +--- +version: 1 +interactions: +- request: + body: "" + form: {} + headers: + User-Agent: + - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) + url: https://api.fastly.com/waf/firewalls/5n9TykpTt7zn0KFJ4k9bMz/versions/1/rules + method: GET + response: + body: '{"data":[],"links":{"last":"https://api.fastly.com/waf/firewalls/5n9TykpTt7zn0KFJ4k9bMz/versions/1/rules?page[number]=1\u0026page[size]=100","first":"https://api.fastly.com/waf/firewalls/5n9TykpTt7zn0KFJ4k9bMz/versions/1/rules?page[number]=1\u0026page[size]=100"},"meta":{"current_page":1,"per_page":100,"record_count":0,"total_pages":1}}' + headers: + Accept-Ranges: + - bytes + Content-Length: + - "338" + Content-Type: + - application/vnd.api+json + Date: + - Thu, 28 Nov 2019 12:43:25 GMT + Status: + - 200 OK + Strict-Transport-Security: + - max-age=31536000 + Via: + - 1.1 varnish + X-Cache: + - MISS, MISS + X-Cache-Hits: + - 0, 0 + X-Content-Type-Options: + - nosniff + X-Served-By: + - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19243-LCY + X-Timer: + - S1574945005.378410,VS0,VE180 + status: 200 OK + code: 200 + duration: "" diff --git a/fastly/fixtures/waf_active_rules/list_empty.yaml b/fastly/fixtures/waf_active_rules/list_empty.yaml new file mode 100644 index 000000000..ab3fe4bbe --- /dev/null +++ b/fastly/fixtures/waf_active_rules/list_empty.yaml @@ -0,0 +1,43 @@ +--- +version: 1 +interactions: +- request: + body: "" + form: {} + headers: + User-Agent: + - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) + url: https://api.fastly.com/waf/firewalls/5n9TykpTt7zn0KFJ4k9bMz/versions/1/rules + method: GET + response: + body: '{"data":[],"links":{"last":"https://api.fastly.com/waf/firewalls/5n9TykpTt7zn0KFJ4k9bMz/versions/1/rules?page[number]=1\u0026page[size]=100","first":"https://api.fastly.com/waf/firewalls/5n9TykpTt7zn0KFJ4k9bMz/versions/1/rules?page[number]=1\u0026page[size]=100"},"meta":{"current_page":1,"per_page":100,"record_count":0,"total_pages":1}}' + headers: + Accept-Ranges: + - bytes + Age: + - "0" + Content-Length: + - "338" + Content-Type: + - application/vnd.api+json + Date: + - Thu, 28 Nov 2019 12:43:23 GMT + Status: + - 200 OK + Strict-Transport-Security: + - max-age=31536000 + Via: + - 1.1 varnish + X-Cache: + - MISS, MISS + X-Cache-Hits: + - 0, 0 + X-Content-Type-Options: + - nosniff + X-Served-By: + - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19243-LCY + X-Timer: + - S1574945004.636936,VS0,VE140 + status: 200 OK + code: 200 + duration: "" diff --git a/fastly/fixtures/waf_active_rules/list_not_empty.yaml b/fastly/fixtures/waf_active_rules/list_not_empty.yaml new file mode 100644 index 000000000..a4d7c7a92 --- /dev/null +++ b/fastly/fixtures/waf_active_rules/list_not_empty.yaml @@ -0,0 +1,41 @@ +--- +version: 1 +interactions: +- request: + body: "" + form: {} + headers: + User-Agent: + - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) + url: https://api.fastly.com/waf/firewalls/5n9TykpTt7zn0KFJ4k9bMz/versions/1/rules + method: GET + response: + body: '{"data":[{"id":"7UZK2qQ20TMUBoZbKo9NZy","type":"waf_active_rule","attributes":{"status":"log","modsec_rule_id":2037405,"revision":1,"created_at":"2019-11-28T12:43:24Z","updated_at":"2019-11-28T12:43:24Z"}},{"id":"5CVFtVaW0WCns3ksB7tMv2","type":"waf_active_rule","attributes":{"status":"log","modsec_rule_id":1010070,"revision":1,"created_at":"2019-11-28T12:43:24Z","updated_at":"2019-11-28T12:43:24Z"}},{"id":"6E8M7nScn1buIUJrSKvqkt","type":"waf_active_rule","attributes":{"status":"log","modsec_rule_id":2029718,"revision":1,"created_at":"2019-11-28T12:43:23Z","updated_at":"2019-11-28T12:43:23Z"}}],"links":{"last":"https://api.fastly.com/waf/firewalls/5n9TykpTt7zn0KFJ4k9bMz/versions/1/rules?page[number]=1\u0026page[size]=100","first":"https://api.fastly.com/waf/firewalls/5n9TykpTt7zn0KFJ4k9bMz/versions/1/rules?page[number]=1\u0026page[size]=100"},"meta":{"current_page":1,"per_page":100,"record_count":3,"total_pages":1}}' + headers: + Accept-Ranges: + - bytes + Content-Length: + - "928" + Content-Type: + - application/vnd.api+json + Date: + - Thu, 28 Nov 2019 12:43:24 GMT + Status: + - 200 OK + Strict-Transport-Security: + - max-age=31536000 + Via: + - 1.1 varnish + X-Cache: + - MISS, MISS + X-Cache-Hits: + - 0, 0 + X-Content-Type-Options: + - nosniff + X-Served-By: + - cache-control-slwdc9035-CONTROL-SLWDC, cache-lcy19243-LCY + X-Timer: + - S1574945004.147737,VS0,VE150 + status: 200 OK + code: 200 + duration: "" diff --git a/fastly/fixtures/waf_active_rules/list_not_empty2.yaml b/fastly/fixtures/waf_active_rules/list_not_empty2.yaml new file mode 100644 index 000000000..44a3d4bdb --- /dev/null +++ b/fastly/fixtures/waf_active_rules/list_not_empty2.yaml @@ -0,0 +1,41 @@ +--- +version: 1 +interactions: +- request: + body: "" + form: {} + headers: + User-Agent: + - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) + url: https://api.fastly.com/waf/firewalls/5n9TykpTt7zn0KFJ4k9bMz/versions/1/rules + method: GET + response: + body: '{"data":[{"id":"7UZK2qQ20TMUBoZbKo9NZy","type":"waf_active_rule","attributes":{"status":"block","modsec_rule_id":2037405,"revision":1,"created_at":"2019-11-28T12:43:24Z","updated_at":"2019-11-28T12:43:24Z"}},{"id":"5CVFtVaW0WCns3ksB7tMv2","type":"waf_active_rule","attributes":{"status":"block","modsec_rule_id":1010070,"revision":1,"created_at":"2019-11-28T12:43:24Z","updated_at":"2019-11-28T12:43:24Z"}},{"id":"6E8M7nScn1buIUJrSKvqkt","type":"waf_active_rule","attributes":{"status":"block","modsec_rule_id":2029718,"revision":1,"created_at":"2019-11-28T12:43:23Z","updated_at":"2019-11-28T12:43:24Z"}}],"links":{"last":"https://api.fastly.com/waf/firewalls/5n9TykpTt7zn0KFJ4k9bMz/versions/1/rules?page[number]=1\u0026page[size]=100","first":"https://api.fastly.com/waf/firewalls/5n9TykpTt7zn0KFJ4k9bMz/versions/1/rules?page[number]=1\u0026page[size]=100"},"meta":{"current_page":1,"per_page":100,"record_count":3,"total_pages":1}}' + headers: + Accept-Ranges: + - bytes + Content-Length: + - "934" + Content-Type: + - application/vnd.api+json + Date: + - Thu, 28 Nov 2019 12:43:24 GMT + Status: + - 200 OK + Strict-Transport-Security: + - max-age=31536000 + Via: + - 1.1 varnish + X-Cache: + - MISS, MISS + X-Cache-Hits: + - 0, 0 + X-Content-Type-Options: + - nosniff + X-Served-By: + - cache-control-slwdc9035-CONTROL-SLWDC, cache-lcy19243-LCY + X-Timer: + - S1574945005.573909,VS0,VE155 + status: 200 OK + code: 200 + duration: "" diff --git a/fastly/fixtures/waf_active_rules/logging/create.yaml b/fastly/fixtures/waf_active_rules/logging/create.yaml new file mode 100644 index 000000000..d64fdcf3f --- /dev/null +++ b/fastly/fixtures/waf_active_rules/logging/create.yaml @@ -0,0 +1,67 @@ +--- +version: 1 +interactions: +- request: + body: Service=1qNbCw880P3rmalHHls5Oc&Version=2&address=example.com&format=format&format_version=2&hostname=example.com&message_type=classic&name=test-syslog&port=1234&token=abcd1234 + form: + Service: + - 1qNbCw880P3rmalHHls5Oc + Version: + - "2" + address: + - example.com + format: + - format + format_version: + - "2" + hostname: + - example.com + message_type: + - classic + name: + - test-syslog + port: + - "1234" + token: + - abcd1234 + headers: + Content-Type: + - application/x-www-form-urlencoded + User-Agent: + - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) + url: https://api.fastly.com/service/1qNbCw880P3rmalHHls5Oc/version/2/logging/syslog + method: POST + response: + body: '{"address":"example.com","format":"format","format_version":"2","hostname":"example.com","message_type":"classic","name":"test-syslog","port":"1234","token":"abcd1234","service_id":"1qNbCw880P3rmalHHls5Oc","version":"2","tls_ca_cert":null,"placement":null,"updated_at":"2019-11-28T12:43:21Z","deleted_at":null,"ipv4":null,"tls_client_cert":null,"tls_client_key":null,"created_at":"2019-11-28T12:43:21Z","tls_hostname":null,"use_tls":"0","response_condition":"","public_key":null}' + headers: + Accept-Ranges: + - bytes + Cache-Control: + - no-cache + Content-Type: + - application/json + Date: + - Thu, 28 Nov 2019 12:43:21 GMT + Fastly-Ratelimit-Remaining: + - "983" + Fastly-Ratelimit-Reset: + - "1574946000" + Status: + - 200 OK + Strict-Transport-Security: + - max-age=31536000 + Vary: + - Accept-Encoding + Via: + - 1.1 varnish + X-Cache: + - MISS, MISS + X-Cache-Hits: + - 0, 0 + X-Served-By: + - cache-control-slwdc9035-CONTROL-SLWDC, cache-lcy19243-LCY + X-Timer: + - S1574945001.323314,VS0,VE575 + status: 200 OK + code: 200 + duration: "" diff --git a/fastly/fixtures/waf_active_rules/logging/delete.yaml b/fastly/fixtures/waf_active_rules/logging/delete.yaml new file mode 100644 index 000000000..f0a3da12f --- /dev/null +++ b/fastly/fixtures/waf_active_rules/logging/delete.yaml @@ -0,0 +1,45 @@ +--- +version: 1 +interactions: +- request: + body: "" + form: {} + headers: + User-Agent: + - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) + url: https://api.fastly.com/service/1qNbCw880P3rmalHHls5Oc/version/2/logging/syslog/test-syslog + method: DELETE + response: + body: '{"status":"ok"}' + headers: + Accept-Ranges: + - bytes + Cache-Control: + - no-cache + Content-Type: + - application/json + Date: + - Thu, 28 Nov 2019 12:43:26 GMT + Fastly-Ratelimit-Remaining: + - "980" + Fastly-Ratelimit-Reset: + - "1574946000" + Status: + - 200 OK + Strict-Transport-Security: + - max-age=31536000 + Vary: + - Accept-Encoding + Via: + - 1.1 varnish + X-Cache: + - MISS, MISS + X-Cache-Hits: + - 0, 0 + X-Served-By: + - cache-control-slwdc9035-CONTROL-SLWDC, cache-lcy19243-LCY + X-Timer: + - S1574945006.787589,VS0,VE437 + status: 200 OK + code: 200 + duration: "" diff --git a/fastly/fixtures/waf_active_rules/response_object/create.yaml b/fastly/fixtures/waf_active_rules/response_object/create.yaml new file mode 100644 index 000000000..c3753cd9d --- /dev/null +++ b/fastly/fixtures/waf_active_rules/response_object/create.yaml @@ -0,0 +1,61 @@ +--- +version: 1 +interactions: +- request: + body: Service=1qNbCw880P3rmalHHls5Oc&Version=2&content=abcd&content_type=text%2Fplain&name=WAf_Response&response=Ok&status=200 + form: + Service: + - 1qNbCw880P3rmalHHls5Oc + Version: + - "2" + content: + - abcd + content_type: + - text/plain + name: + - WAf_Response + response: + - Ok + status: + - "200" + headers: + Content-Type: + - application/x-www-form-urlencoded + User-Agent: + - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) + url: https://api.fastly.com/service/1qNbCw880P3rmalHHls5Oc/version/2/response_object + method: POST + response: + body: '{"content":"abcd","content_type":"text/plain","name":"WAf_Response","response":"Ok","status":"200","service_id":"1qNbCw880P3rmalHHls5Oc","version":"2","request_condition":"","updated_at":"2019-11-28T12:43:22Z","deleted_at":null,"created_at":"2019-11-28T12:43:22Z","cache_condition":""}' + headers: + Accept-Ranges: + - bytes + Cache-Control: + - no-cache + Content-Type: + - application/json + Date: + - Thu, 28 Nov 2019 12:43:22 GMT + Fastly-Ratelimit-Remaining: + - "981" + Fastly-Ratelimit-Reset: + - "1574946000" + Status: + - 200 OK + Strict-Transport-Security: + - max-age=31536000 + Vary: + - Accept-Encoding + Via: + - 1.1 varnish + X-Cache: + - MISS, MISS + X-Cache-Hits: + - 0, 0 + X-Served-By: + - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19243-LCY + X-Timer: + - S1574945002.309059,VS0,VE399 + status: 200 OK + code: 200 + duration: "" diff --git a/fastly/fixtures/waf_active_rules/service/create.yaml b/fastly/fixtures/waf_active_rules/service/create.yaml new file mode 100644 index 000000000..49a08eb78 --- /dev/null +++ b/fastly/fixtures/waf_active_rules/service/create.yaml @@ -0,0 +1,51 @@ +--- +version: 1 +interactions: +- request: + body: comment=go-fastly+client+test&name=test_service_service + form: + comment: + - go-fastly client test + name: + - test_service_service + headers: + Content-Type: + - application/x-www-form-urlencoded + User-Agent: + - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) + url: https://api.fastly.com/service + method: POST + response: + body: '{"customer_id":"WpqWFjTA4lk2N1g0GY2HH","comment":"go-fastly client test","name":"test_service_service","deleted_at":null,"id":"1qNbCw880P3rmalHHls5Oc","versions":[{"locked":false,"service_id":"1qNbCw880P3rmalHHls5Oc","staging":false,"number":1,"deleted_at":null,"active":false,"comment":"","updated_at":"2019-11-28T12:43:20Z","testing":false,"created_at":"2019-11-28T12:43:20Z","deployed":false}],"type":"vcl","created_at":"2019-11-28T12:43:20Z","publish_key":"311e1e932579e7d6e7f706b92c17bf51e649ed27","updated_at":"2019-11-28T12:43:20Z"}' + headers: + Accept-Ranges: + - bytes + Cache-Control: + - no-cache + Content-Type: + - application/json + Date: + - Thu, 28 Nov 2019 12:43:20 GMT + Fastly-Ratelimit-Remaining: + - "985" + Fastly-Ratelimit-Reset: + - "1574946000" + Status: + - 200 OK + Strict-Transport-Security: + - max-age=31536000 + Vary: + - Accept-Encoding + Via: + - 1.1 varnish + X-Cache: + - MISS, MISS + X-Cache-Hits: + - 0, 0 + X-Served-By: + - cache-control-slwdc9036-CONTROL-SLWDC, cache-lcy19243-LCY + X-Timer: + - S1574945001.520378,VS0,VE280 + status: 200 OK + code: 200 + duration: "" diff --git a/fastly/fixtures/waf_active_rules/service/delete.yaml b/fastly/fixtures/waf_active_rules/service/delete.yaml new file mode 100644 index 000000000..125ea916c --- /dev/null +++ b/fastly/fixtures/waf_active_rules/service/delete.yaml @@ -0,0 +1,45 @@ +--- +version: 1 +interactions: +- request: + body: "" + form: {} + headers: + User-Agent: + - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) + url: https://api.fastly.com/service/1qNbCw880P3rmalHHls5Oc + method: DELETE + response: + body: '{"status":"ok"}' + headers: + Accept-Ranges: + - bytes + Cache-Control: + - no-cache + Content-Type: + - application/json + Date: + - Thu, 28 Nov 2019 12:43:26 GMT + Fastly-Ratelimit-Remaining: + - "979" + Fastly-Ratelimit-Reset: + - "1574946000" + Status: + - 200 OK + Strict-Transport-Security: + - max-age=31536000 + Vary: + - Accept-Encoding + Via: + - 1.1 varnish + X-Cache: + - MISS, MISS + X-Cache-Hits: + - 0, 0 + X-Served-By: + - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19243-LCY + X-Timer: + - S1574945006.296687,VS0,VE243 + status: 200 OK + code: 200 + duration: "" diff --git a/fastly/fixtures/waf_active_rules/service/version.yaml b/fastly/fixtures/waf_active_rules/service/version.yaml new file mode 100644 index 000000000..7d51e4293 --- /dev/null +++ b/fastly/fixtures/waf_active_rules/service/version.yaml @@ -0,0 +1,49 @@ +--- +version: 1 +interactions: +- request: + body: Service=1qNbCw880P3rmalHHls5Oc + form: + Service: + - 1qNbCw880P3rmalHHls5Oc + headers: + Content-Type: + - application/x-www-form-urlencoded + User-Agent: + - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) + url: https://api.fastly.com/service/1qNbCw880P3rmalHHls5Oc/version + method: POST + response: + body: '{"service_id":"1qNbCw880P3rmalHHls5Oc","number":2}' + headers: + Accept-Ranges: + - bytes + Cache-Control: + - no-cache + Content-Type: + - application/json + Date: + - Thu, 28 Nov 2019 12:43:21 GMT + Fastly-Ratelimit-Remaining: + - "984" + Fastly-Ratelimit-Reset: + - "1574946000" + Status: + - 200 OK + Strict-Transport-Security: + - max-age=31536000 + Vary: + - Accept-Encoding + Via: + - 1.1 varnish + X-Cache: + - MISS, MISS + X-Cache-Hits: + - 0, 0 + X-Served-By: + - cache-control-slwdc9035-CONTROL-SLWDC, cache-lcy19243-LCY + X-Timer: + - S1574945001.871880,VS0,VE437 + status: 200 OK + code: 200 + duration: "" diff --git a/fastly/fixtures/waf_active_rules/update.yaml b/fastly/fixtures/waf_active_rules/update.yaml new file mode 100644 index 000000000..eb3772840 --- /dev/null +++ b/fastly/fixtures/waf_active_rules/update.yaml @@ -0,0 +1,46 @@ +--- +version: 1 +interactions: +- request: + body: | + {"data":[{"type":"waf_active_rule","attributes":{"modsec_rule_id":2029718,"status":"block"}},{"type":"waf_active_rule","attributes":{"modsec_rule_id":2037405,"status":"block"}},{"type":"waf_active_rule","attributes":{"modsec_rule_id":1010070,"status":"block"}}]} + form: {} + headers: + Accept: + - application/vnd.api+json; ext=bulk + Content-Type: + - application/vnd.api+json + User-Agent: + - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) + url: https://api.fastly.com/waf/firewalls/5n9TykpTt7zn0KFJ4k9bMz/versions/1/rules + method: POST + response: + body: '{"data":[{"id":"6E8M7nScn1buIUJrSKvqkt","type":"waf_active_rule","attributes":{"status":"block","modsec_rule_id":2029718,"revision":1,"created_at":"2019-11-28T12:43:23Z","updated_at":"2019-11-28T12:43:24Z"},"relationships":{"waf_firewall_version":{"data":{"id":"6Wo0vAYg6cS79HacNpZrBm","type":"waf_firewall_version"}},"waf_rule_revision":{"data":{"id":"6ZJML5tsy5uVq1nGNgmZ78","type":"waf_rule_revision"}}}},{"id":"7UZK2qQ20TMUBoZbKo9NZy","type":"waf_active_rule","attributes":{"status":"block","modsec_rule_id":2037405,"revision":1,"created_at":"2019-11-28T12:43:24Z","updated_at":"2019-11-28T12:43:24Z"},"relationships":{"waf_firewall_version":{"data":{"id":"6Wo0vAYg6cS79HacNpZrBm","type":"waf_firewall_version"}},"waf_rule_revision":{"data":{"id":"3ANlv7vVZdzk2qFXlJLIk3","type":"waf_rule_revision"}}}},{"id":"5CVFtVaW0WCns3ksB7tMv2","type":"waf_active_rule","attributes":{"status":"block","modsec_rule_id":1010070,"revision":1,"created_at":"2019-11-28T12:43:24Z","updated_at":"2019-11-28T12:43:24Z"},"relationships":{"waf_firewall_version":{"data":{"id":"6Wo0vAYg6cS79HacNpZrBm","type":"waf_firewall_version"}},"waf_rule_revision":{"data":{"id":"2qiuFDyJoxuKkKkJYjrgsC","type":"waf_rule_revision"}}}}]}' + headers: + Accept-Ranges: + - bytes + Content-Length: + - "1207" + Content-Type: + - application/vnd.api+json + Date: + - Thu, 28 Nov 2019 12:43:24 GMT + Status: + - 201 Created + Strict-Transport-Security: + - max-age=31536000 + Via: + - 1.1 varnish + X-Cache: + - MISS, MISS + X-Cache-Hits: + - 0, 0 + X-Content-Type-Options: + - nosniff + X-Served-By: + - cache-control-slwdc9035-CONTROL-SLWDC, cache-lcy19243-LCY + X-Timer: + - S1574945004.355642,VS0,VE211 + status: 201 Created + code: 201 + duration: "" diff --git a/fastly/fixtures/waf_active_rules/waf/create.yaml b/fastly/fixtures/waf_active_rules/waf/create.yaml new file mode 100644 index 000000000..b8df1f39f --- /dev/null +++ b/fastly/fixtures/waf_active_rules/waf/create.yaml @@ -0,0 +1,46 @@ +--- +version: 1 +interactions: +- request: + body: | + {"data":{"type":"waf_firewall","attributes":{"prefetch_condition":"WAF_Prefetch","response":"WAf_Response","service_id":"1qNbCw880P3rmalHHls5Oc","service_version_number":"2"}}} + form: {} + headers: + Accept: + - application/vnd.api+json + Content-Type: + - application/vnd.api+json + User-Agent: + - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) + url: https://api.fastly.com/waf/firewalls + method: POST + response: + body: '{"data":{"id":"5n9TykpTt7zn0KFJ4k9bMz","type":"waf_firewall","attributes":{"service_id":"1qNbCw880P3rmalHHls5Oc","prefetch_condition":"WAF_Prefetch","response":"WAf_Response","disabled":false,"service_version_number":2,"created_at":"2019-11-28T12:43:23Z","updated_at":"2019-11-28T12:43:23Z","active_rules_trustwave_log_count":0,"active_rules_trustwave_block_count":0,"active_rules_fastly_log_count":0,"active_rules_fastly_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_score_count":0}}}' + headers: + Accept-Ranges: + - bytes + Content-Length: + - "542" + Content-Type: + - application/vnd.api+json + Date: + - Thu, 28 Nov 2019 12:43:23 GMT + Status: + - 201 Created + Strict-Transport-Security: + - max-age=31536000 + Via: + - 1.1 varnish + X-Cache: + - MISS, MISS + X-Cache-Hits: + - 0, 0 + X-Content-Type-Options: + - nosniff + X-Served-By: + - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19243-LCY + X-Timer: + - S1574945003.818460,VS0,VE751 + status: 201 Created + code: 201 + duration: "" diff --git a/fastly/fixtures/waf_active_rules/waf/delete.yaml b/fastly/fixtures/waf_active_rules/waf/delete.yaml new file mode 100644 index 000000000..cdaf74067 --- /dev/null +++ b/fastly/fixtures/waf_active_rules/waf/delete.yaml @@ -0,0 +1,42 @@ +--- +version: 1 +interactions: +- request: + body: | + {"data":{"type":"waf_firewall","id":"5n9TykpTt7zn0KFJ4k9bMz","attributes":{"service_version_number":"1"}}} + form: {} + headers: + Accept: + - application/vnd.api+json + Content-Type: + - application/vnd.api+json + User-Agent: + - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) + url: https://api.fastly.com/waf/firewalls/5n9TykpTt7zn0KFJ4k9bMz + method: DELETE + response: + body: "" + headers: + Accept-Ranges: + - bytes + Date: + - Thu, 28 Nov 2019 12:43:25 GMT + Status: + - 204 No Content + Strict-Transport-Security: + - max-age=31536000 + Via: + - 1.1 varnish + X-Cache: + - MISS, MISS + X-Cache-Hits: + - 0, 0 + X-Content-Type-Options: + - nosniff + X-Served-By: + - cache-control-slwdc9035-CONTROL-SLWDC, cache-lcy19243-LCY + X-Timer: + - S1574945006.566540,VS0,VE182 + status: 204 No Content + code: 204 + duration: "" diff --git a/fastly/waf.go b/fastly/waf.go index a0c432831..a6c43e4bf 100644 --- a/fastly/waf.go +++ b/fastly/waf.go @@ -299,7 +299,7 @@ func (c *Client) DeleteWAF(i *DeleteWAFInput) error { } path := fmt.Sprintf("/waf/firewalls/%s", i.ID) - _, err := c.DeleteJSON(path, i, nil) + _, err := c.DeleteJSONAPI(path, i, nil) return err } diff --git a/fastly/waf_active_rule.go b/fastly/waf_active_rule.go new file mode 100644 index 000000000..cc1bb2a46 --- /dev/null +++ b/fastly/waf_active_rule.go @@ -0,0 +1,319 @@ +package fastly + +import ( + "bytes" + "fmt" + "io" + "reflect" + "strconv" + "time" + + "github.com/google/jsonapi" +) + +// WAFActiveRuleType is used for reflection because JSONAPI wants to know what it's +// decoding into. +var WAFActiveRuleType = reflect.TypeOf(new(WAFActiveRule)) + +// WAFActiveRule is the information about a WAF active rule object. +type WAFActiveRule struct { + ID string `jsonapi:"primary,waf_active_rule,omitempty"` + Status string `jsonapi:"attr,status,omitempty"` + ModSecID int `jsonapi:"attr,modsec_rule_id,omitempty"` + Revision int `jsonapi:"attr,revision,omitempty"` + CreatedAt *time.Time `jsonapi:"attr,created_at,iso8601,omitempty"` + UpdatedAt *time.Time `jsonapi:"attr,updated_at,iso8601,omitempty"` +} + +// WAFActiveRuleResponse represents a list of active rules - full response. +type WAFActiveRuleResponse struct { + Items []*WAFActiveRule + Info infoResponse +} + +// ListWAFActiveRulesInput used as input for listing a WAF's active rules. +type ListWAFActiveRulesInput struct { + // The Web Application Firewall's ID. + WAFID string + // The Web Application Firewall's version number. + WAFVersionNumber int + // Limit results to active rules with the specified status. + FilterStatus string + // Limit results to active rules with the specified message. + FilterMessage string + // Limit results to active rules that represent the specified ModSecurity modsec_rule_id. + FilterModSedID string + // Limit the number of returned pages. + PageSize int + // Request a specific page of active rules. + PageNumber int + // Include relationships. Optional, comma-separated values. Permitted values: waf_rule_revision and waf_firewall_version. + Include string +} + +func (i *ListWAFActiveRulesInput) formatFilters() map[string]string { + + result := map[string]string{} + pairings := map[string]interface{}{ + "filter[status]": i.FilterStatus, + "filter[waf_rule_revision][message]": i.FilterMessage, + "filter[waf_rule_revision][modsec_rule_id]": i.FilterModSedID, + "page[size]": i.PageSize, + "page[number]": i.PageNumber, + "include": i.Include, + } + + for key, value := range pairings { + switch t := reflect.TypeOf(value).String(); t { + case "string": + if value != "" { + result[key] = value.(string) + } + case "int": + if value != 0 { + result[key] = strconv.Itoa(value.(int)) + } + } + } + return result +} + +// ListWAFActiveRules returns the list of active rules for a given WAF ID. +func (c *Client) ListWAFActiveRules(i *ListWAFActiveRulesInput) (*WAFActiveRuleResponse, error) { + + if i.WAFID == "" { + return nil, ErrMissingWAFID + } + + if i.WAFVersionNumber == 0 { + return nil, ErrMissingWAFVersionNumber + } + + path := fmt.Sprintf("/waf/firewalls/%s/versions/%d/rules", i.WAFID, i.WAFVersionNumber) + resp, err := c.Get(path, &RequestOptions{ + Params: i.formatFilters(), + }) + if err != nil { + return nil, err + } + + var buf bytes.Buffer + tee := io.TeeReader(resp.Body, &buf) + + info, err := getResponseInfo(tee) + if err != nil { + return nil, err + } + + data, err := jsonapi.UnmarshalManyPayload(bytes.NewReader(buf.Bytes()), WAFActiveRuleType) + if err != nil { + return nil, err + } + + wafRules := make([]*WAFActiveRule, len(data)) + for i := range data { + typed, ok := data[i].(*WAFActiveRule) + if !ok { + return nil, fmt.Errorf("got back a non-WAFActiveRule response") + } + wafRules[i] = typed + } + return &WAFActiveRuleResponse{ + Items: wafRules, + Info: info, + }, nil +} + +// ListAllWAFActiveRulesInput used as input for listing all WAF active rules. +type ListAllWAFActiveRulesInput struct { + // The Web Application Firewall's ID. + WAFID string + // The Web Application Firewall's version number. + WAFVersionNumber int + // Limit results to active rules with the specified status. + FilterStatus string + // Limit results to active rules with the specified message. + FilterMessage string + // Limit results to active rules that represent the specified ModSecurity modsec_rule_id. + FilterModSedID string + // Include relationships. Optional, comma-separated values. Permitted values: waf_rule_revision and waf_firewall_version. + Include string +} + +// ListAllWAFActiveRules returns the complete list of WAF active rules for a given WAF ID. It iterates through +// all existing pages to ensure all WAF active rules are returned at once. +func (c *Client) ListAllWAFActiveRules(i *ListAllWAFActiveRulesInput) (*WAFActiveRuleResponse, error) { + + if i.WAFID == "" { + return nil, ErrMissingWAFID + } + + if i.WAFVersionNumber == 0 { + return nil, ErrMissingWAFVersionNumber + } + + currentPage := 1 + result := &WAFActiveRuleResponse{Items: []*WAFActiveRule{}} + for { + r, err := c.ListWAFActiveRules(&ListWAFActiveRulesInput{ + WAFID: i.WAFID, + WAFVersionNumber: i.WAFVersionNumber, + PageNumber: currentPage, + PageSize: WAFPaginationPageSize, + Include: i.Include, + FilterStatus: i.FilterStatus, + FilterModSedID: i.FilterModSedID, + FilterMessage: i.FilterMessage, + }) + if err != nil { + return r, err + } + + currentPage++ + result.Items = append(result.Items, r.Items...) + + if r.Info.Links.Next == "" || len(r.Items) == 0 { + return result, nil + } + } +} + +// CreateWAFActiveRulesInput used as input for adding rules to a WAF. +type CreateWAFActiveRulesInput struct { + // The Web Application Firewall's ID. + WAFID string + // The Web Application Firewall's version number. + WAFVersionNumber int + // The list of WAF active rules (ModSecID, Status and Revision are required). + Rules []*WAFActiveRule +} + +// CreateWAFActiveRules adds rules to a particular WAF. +func (c *Client) CreateWAFActiveRules(i *CreateWAFActiveRulesInput) ([]*WAFActiveRule, error) { + + if i.WAFID == "" { + return nil, ErrMissingWAFID + } + + if i.WAFVersionNumber == 0 { + return nil, ErrMissingWAFVersionNumber + } + + if len(i.Rules) == 0 { + return nil, ErrMissingWAFActiveRuleList + } + + path := fmt.Sprintf("/waf/firewalls/%s/versions/%d/rules", i.WAFID, i.WAFVersionNumber) + resp, err := c.PostJSONAPIBulk(path, i.Rules, nil) + if err != nil { + return nil, err + } + + data, err := jsonapi.UnmarshalManyPayload(resp.Body, WAFActiveRuleType) + if err != nil { + return nil, err + } + + wafRules := make([]*WAFActiveRule, len(data)) + for i := range data { + typed, ok := data[i].(*WAFActiveRule) + if !ok { + return nil, fmt.Errorf("got back a non-WAFActiveRule response") + } + wafRules[i] = typed + } + + return wafRules, nil +} + +// BatchModificationWAFActiveRulesInput is used for active rules batch modifications. +type BatchModificationWAFActiveRulesInput struct { + // The Web Application Firewall's ID. + WAFID string + // The Web Application Firewall's version number. + WAFVersionNumber int + // The list of WAF active rules (ModSecID, Status and Revision are required for upsert, ModSecID is required for delete). + Rules []*WAFActiveRule + // The batch operation to be performed (allowed operations are upsert and delete). + OP BatchOperation +} + +// BatchModificationWAFActiveRules is a generic function for creating or deleting WAF active rules in batches. +// Upsert and delete are the only operations allowed. +func (c *Client) BatchModificationWAFActiveRules(i *BatchModificationWAFActiveRulesInput) ([]*WAFActiveRule, error) { + + if len(i.Rules) > BatchModifyMaximumOperations { + return nil, ErrBatchUpdateMaximumOperationsExceeded + } + + switch i.OP { + case UpsertBatchOperation: + return c.CreateWAFActiveRules(&CreateWAFActiveRulesInput{ + WAFID: i.WAFID, + WAFVersionNumber: i.WAFVersionNumber, + Rules: i.Rules, + }) + case DeleteBatchOperation: + return nil, c.DeleteWAFActiveRules(&DeleteWAFActiveRulesInput{ + WAFID: i.WAFID, + WAFVersionNumber: i.WAFVersionNumber, + Rules: i.Rules, + }) + default: + return nil, fmt.Errorf("operation %s not supported", i.OP) + } +} + +// DeleteWAFActiveRulesInput used as input for removing rules from a WAF. +type DeleteWAFActiveRulesInput struct { + // The Web Application Firewall's ID. + WAFID string + // The Web Application Firewall's version number. + WAFVersionNumber int + // The list of WAF active rules (ModSecID is required). + Rules []*WAFActiveRule +} + +// DeleteWAFActiveRules removes rules from a particular WAF. +func (c *Client) DeleteWAFActiveRules(i *DeleteWAFActiveRulesInput) error { + + if i.WAFID == "" { + return ErrMissingWAFID + } + + if i.WAFVersionNumber == 0 { + return ErrMissingWAFVersionNumber + } + + if len(i.Rules) == 0 { + return ErrMissingWAFActiveRuleList + } + + path := fmt.Sprintf("/waf/firewalls/%s/versions/%d/rules", i.WAFID, i.WAFVersionNumber) + _, err := c.DeleteJSONAPIBulk(path, i.Rules, nil) + return err +} + +// DeleteAllWAFActiveRulesInput used as input for removing all rules from a WAF. +type DeleteAllWAFActiveRulesInput struct { + // The Web Application Firewall's ID. + WAFID string + // The Web Application Firewall's version number. + WAFVersionNumber int +} + +// DeleteAllWAFActiveRules removes all rules from a particular WAF. +func (c *Client) DeleteAllWAFActiveRules(i *DeleteAllWAFActiveRulesInput) error { + + if i.WAFID == "" { + return ErrMissingWAFID + } + + if i.WAFVersionNumber == 0 { + return ErrMissingWAFVersionNumber + } + + path := fmt.Sprintf("/waf/firewalls/%s/versions/%d/rules", i.WAFID, i.WAFVersionNumber) + _, err := c.DeleteJSONAPI(path, nil, nil) + return err +} diff --git a/fastly/waf_active_rule_test.go b/fastly/waf_active_rule_test.go new file mode 100644 index 000000000..a5be00851 --- /dev/null +++ b/fastly/waf_active_rule_test.go @@ -0,0 +1,317 @@ +package fastly + +import ( + "strconv" + "testing" +) + +func TestClient_WAF_Active_Rules(t *testing.T) { + t.Parallel() + + fixtureBase := "waf_active_rules/" + + testService := createTestService(t, fixtureBase+"service/create", "service") + defer deleteTestService(t, fixtureBase+"/service/delete", testService.ID) + + tv := createTestVersion(t, fixtureBase+"/service/version", testService.ID) + + createTestLogging(t, fixtureBase+"/logging/create", testService.ID, tv.Number) + defer deleteTestLogging(t, fixtureBase+"/logging/delete", testService.ID, tv.Number) + + prefetch := "WAF_Prefetch" + createTestWAFCondition(t, fixtureBase+"/condition/create", testService.ID, prefetch, tv.Number) + + responseName := "WAf_Response" + createTestResponseObject(t, fixtureBase+"/response_object/create", testService.ID, responseName, tv.Number) + + waf := createWAF(t, fixtureBase+"/waf/create", testService.ID, strconv.Itoa(tv.Number), prefetch, responseName) + defer deleteWAF(t, fixtureBase+"/waf/delete", waf.ID, "1") + + var err error + + var rulesResp *WAFActiveRuleResponse + record(t, fixtureBase+"/list_empty", func(c *Client) { + rulesResp, err = c.ListWAFActiveRules(&ListWAFActiveRulesInput{ + WAFID: waf.ID, + WAFVersionNumber: 1, + }) + }) + if err != nil { + t.Fatal(err) + } + if len(rulesResp.Items) != 0 { + t.Errorf("expected 0 waf version: got %d", len(rulesResp.Items)) + } + + rulesIn := buildWAFRules("log") + var rulesOut []*WAFActiveRule + record(t, fixtureBase+"/create", func(c *Client) { + rulesOut, err = c.BatchModificationWAFActiveRules(&BatchModificationWAFActiveRulesInput{ + WAFID: waf.ID, + WAFVersionNumber: 1, + Rules: rulesIn, + OP: UpsertBatchOperation, + }) + }) + if err != nil { + t.Fatal(err) + } + if len(rulesOut) != len(rulesIn) { + t.Errorf("expected 0 waf version: got %d", len(rulesOut)) + } + + record(t, fixtureBase+"/list_not_empty", func(c *Client) { + rulesResp, err = c.ListWAFActiveRules(&ListWAFActiveRulesInput{ + WAFID: waf.ID, + WAFVersionNumber: 1, + }) + }) + if err != nil { + t.Fatal(err) + } + if len(rulesResp.Items) != len(rulesIn) { + t.Errorf("expected equal slice sizes: got expected %d actual %d", len(rulesIn), len(rulesResp.Items)) + } + for i := range rulesIn { + if rulesIn[i].ModSecID != rulesOut[i].ModSecID { + t.Errorf("Error matching:\nexpected: %#v\ngot: %#v", rulesIn[i].ModSecID, rulesOut[i].ModSecID) + } + if rulesIn[i].Status != rulesOut[i].Status { + t.Errorf("Error matching:\nexpected: %#v\ngot: %#v", rulesIn[i].Status, rulesOut[i].Status) + } + } + + rulesIn = buildWAFRules("block") + record(t, fixtureBase+"/update", func(c *Client) { + rulesOut, err = c.BatchModificationWAFActiveRules(&BatchModificationWAFActiveRulesInput{ + WAFID: waf.ID, + WAFVersionNumber: 1, + Rules: rulesIn, + OP: UpsertBatchOperation, + }) + }) + if err != nil { + t.Fatal(err) + } + if len(rulesOut) != len(rulesIn) { + t.Errorf("expected 0 waf version: got %d", len(rulesOut)) + } + + record(t, fixtureBase+"/list_not_empty2", func(c *Client) { + rulesResp, err = c.ListWAFActiveRules(&ListWAFActiveRulesInput{ + WAFID: waf.ID, + WAFVersionNumber: 1, + }) + }) + if err != nil { + t.Fatal(err) + } + if len(rulesResp.Items) != len(rulesIn) { + t.Errorf("expected equal slice sizes: got expected %d actual %d", len(rulesIn), len(rulesResp.Items)) + } + for i := range rulesIn { + if rulesIn[i].ModSecID != rulesOut[i].ModSecID { + t.Errorf("Error matching:\nexpected: %#v\ngot: %#v", rulesIn[i].ModSecID, rulesOut[i].ModSecID) + } + if rulesIn[i].Status != rulesOut[i].Status { + t.Errorf("Error matching:\nexpected: %#v\ngot: %#v", rulesIn[i].Status, rulesOut[i].Status) + } + } + + rules := []*WAFActiveRule{{ + ModSecID: 1010070, + }} + record(t, fixtureBase+"/delete_one", func(c *Client) { + rulesOut, err = c.BatchModificationWAFActiveRules(&BatchModificationWAFActiveRulesInput{ + WAFID: waf.ID, + WAFVersionNumber: 1, + Rules: rules, + OP: DeleteBatchOperation, + }) + }) + if err != nil { + t.Fatal(err) + } + + record(t, fixtureBase+"/list_after_delete", func(c *Client) { + rulesResp, err = c.ListWAFActiveRules(&ListWAFActiveRulesInput{ + WAFID: waf.ID, + WAFVersionNumber: 1, + }) + }) + if err != nil { + t.Fatal(err) + } + if len(rulesResp.Items) != 2 { + t.Errorf("expected 2 waf rules: got %d", len(rulesResp.Items)) + } + + record(t, fixtureBase+"/delete_all", func(c *Client) { + err = c.DeleteAllWAFActiveRules(&DeleteAllWAFActiveRulesInput{ + WAFID: waf.ID, + WAFVersionNumber: 1, + }) + }) + if err != nil { + t.Fatal(err) + } + + record(t, fixtureBase+"/list_after_delete_all", func(c *Client) { + rulesResp, err = c.ListWAFActiveRules(&ListWAFActiveRulesInput{ + WAFID: waf.ID, + WAFVersionNumber: 1, + }) + }) + if err != nil { + t.Fatal(err) + } + if len(rulesResp.Items) != 0 { + t.Errorf("expected 0 waf rules: got %d", len(rulesResp.Items)) + } +} + +func TestClient_ListWAFActiveRules_validation(t *testing.T) { + var err error + _, err = testClient.ListWAFActiveRules(&ListWAFActiveRulesInput{ + WAFID: "", + }) + if err != ErrMissingWAFID { + t.Errorf("bad error: %s", err) + } + + _, err = testClient.ListWAFActiveRules(&ListWAFActiveRulesInput{ + WAFID: "1", + WAFVersionNumber: 0, + }) + if err != ErrMissingWAFVersionNumber { + t.Errorf("bad error: %s", err) + } +} + +func TestClient_ListAllWAFActiveRules_validation(t *testing.T) { + var err error + _, err = testClient.ListAllWAFActiveRules(&ListAllWAFActiveRulesInput{ + WAFID: "", + }) + if err != ErrMissingWAFID { + t.Errorf("bad error: %s", err) + } + + _, err = testClient.ListAllWAFActiveRules(&ListAllWAFActiveRulesInput{ + WAFID: "1", + WAFVersionNumber: 0, + }) + if err != ErrMissingWAFVersionNumber { + t.Errorf("bad error: %s", err) + } +} + +func TestClient_CreateWAFActiveRules_validation(t *testing.T) { + var err error + _, err = testClient.CreateWAFActiveRules(&CreateWAFActiveRulesInput{ + WAFID: "", + }) + if err != ErrMissingWAFID { + t.Errorf("bad error: %s", err) + } + + _, err = testClient.CreateWAFActiveRules(&CreateWAFActiveRulesInput{ + WAFID: "1", + WAFVersionNumber: 0, + }) + if err != ErrMissingWAFVersionNumber { + t.Errorf("bad error: %s", err) + } + + _, err = testClient.CreateWAFActiveRules(&CreateWAFActiveRulesInput{ + WAFID: "1", + WAFVersionNumber: 1, + Rules: []*WAFActiveRule{}, + }) + if err != ErrMissingWAFActiveRuleList { + t.Errorf("bad error: %s", err) + } +} + +func TestClient_BatchModificationWAFActiveRules_validation(t *testing.T) { + var err error + _, err = testClient.BatchModificationWAFActiveRules(&BatchModificationWAFActiveRulesInput{}) + if err == nil { + t.Errorf("error expected") + } + + var rules []*WAFActiveRule + for i := 0; i <= BatchModifyMaximumOperations; i++ { + rules = append(rules, &WAFActiveRule{}) + } + _, err = testClient.BatchModificationWAFActiveRules(&BatchModificationWAFActiveRulesInput{ + Rules: rules, + }) + if err != ErrBatchUpdateMaximumOperationsExceeded { + t.Errorf("bad error: %s", err) + } +} + +func TestClient_DeleteWAFActiveRules_validation(t *testing.T) { + var err error + if err = testClient.DeleteWAFActiveRules(&DeleteWAFActiveRulesInput{ + WAFID: "", + }); err != ErrMissingWAFID { + t.Errorf("bad error: %s", err) + } + + if err = testClient.DeleteWAFActiveRules(&DeleteWAFActiveRulesInput{ + WAFID: "1", + WAFVersionNumber: 0, + }); err != ErrMissingWAFVersionNumber { + t.Errorf("bad error: %s", err) + } + + if err = testClient.DeleteWAFActiveRules(&DeleteWAFActiveRulesInput{ + WAFID: "1", + WAFVersionNumber: 1, + Rules: []*WAFActiveRule{}, + }); err != ErrMissingWAFActiveRuleList { + t.Errorf("bad error: %s", err) + } + +} + +func TestClient_DeleteAllWAFActiveRules_validation(t *testing.T) { + var err error + err = testClient.DeleteAllWAFActiveRules(&DeleteAllWAFActiveRulesInput{ + WAFID: "", + }) + if err != ErrMissingWAFID { + t.Errorf("bad error: %s", err) + } + + err = testClient.DeleteAllWAFActiveRules(&DeleteAllWAFActiveRulesInput{ + WAFID: "1", + WAFVersionNumber: 0, + }) + if err != ErrMissingWAFVersionNumber { + t.Errorf("bad error: %s", err) + } +} + +func buildWAFRules(status string) []*WAFActiveRule { + + return []*WAFActiveRule{ + { + ModSecID: 2029718, + Status: status, + Revision: 1, + }, + { + ModSecID: 2037405, + Status: status, + Revision: 1, + }, + { + ModSecID: 1010070, + Status: status, + Revision: 1, + }, + } +} diff --git a/fastly/waf_version.go b/fastly/waf_version.go index 92358ba0b..2ac9e7afe 100644 --- a/fastly/waf_version.go +++ b/fastly/waf_version.go @@ -74,7 +74,7 @@ type WAFVersionResponse struct { // ListWAFVersionsInput used as input for listing WAF versions. type ListWAFVersionsInput struct { - // The Web Application Firewall's id. + // The Web Application Firewall's ID. WAFID string // Limit the number records returned. PageSize int @@ -108,7 +108,7 @@ func (i *ListWAFVersionsInput) formatFilters() map[string]string { return result } -// ListWAFVersions returns the list of VAF versions for a given WAF id. +// ListWAFVersions returns the list of VAF versions for a given WAF ID. func (c *Client) ListWAFVersions(i *ListWAFVersionsInput) (*WAFVersionResponse, error) { if i.WAFID == "" { @@ -152,13 +152,13 @@ func (c *Client) ListWAFVersions(i *ListWAFVersionsInput) (*WAFVersionResponse, // ListAllWAFVersionsInput used as input for listing all WAF versions. type ListAllWAFVersionsInput struct { - // The Web Application Firewall's id. + // The Web Application Firewall's ID. WAFID string // Include relationships. Optional, comma-separated values. Permitted values: waf_firewall_versions. Include string } -// ListAllWAFVersions returns the complete list of WAF versions for a given WAF id. It iterates through +// ListAllWAFVersions returns the complete list of WAF versions for a given WAF ID. It iterates through // all existing pages to ensure all WAF versions are returned at once. func (c *Client) ListAllWAFVersions(i *ListAllWAFVersionsInput) (*WAFVersionResponse, error) { @@ -190,9 +190,9 @@ func (c *Client) ListAllWAFVersions(i *ListAllWAFVersionsInput) (*WAFVersionResp // GetWAFVersionInput used as input for GetWAFVersion function. type GetWAFVersionInput struct { - // The Web Application Firewall's id. + // The Web Application Firewall's ID. WAFID string - // the Web Application Firewall's version number. + // The Web Application Firewall's version number. WAFVersionNumber int } @@ -222,12 +222,12 @@ func (c *Client) GetWAFVersion(i *GetWAFVersionInput) (*WAFVersion, error) { // UpdateWAFVersionInput is used as input to the UpdateWAFVersion function. type UpdateWAFVersionInput struct { - // The Web Application Firewall's id. + // The Web Application Firewall's ID. WAFID string - // the Web Application Firewall's version id. - WAFVersionID string `jsonapi:"primary,waf_firewall"` - // the Web Application Firewall's version number. - WAFVersionNumber int + // The Web Application Firewall's version number. + WAFVersionNumber int + // The Web Application Firewall's version ID. + WAFVersionID string `jsonapi:"primary,waf_firewall"` Comment string `jsonapi:"attr,comment,omitempty"` CRSValidateUTF8Encoding bool `jsonapi:"attr,crs_validate_utf8_encoding,omitempty"` AllowedHTTPVersions string `jsonapi:"attr,allowed_http_versions,omitempty"` @@ -288,7 +288,7 @@ func (c *Client) UpdateWAFVersion(i *UpdateWAFVersionInput) (*WAFVersion, error) // LockWAFVersionInput used as input for locking a WAF version. type LockWAFVersionInput struct { - // The Web Application Firewall's id. + // The Web Application Firewall's ID. WAFID string // The Web Application Firewall's version number. WAFVersionNumber int @@ -319,7 +319,7 @@ func (c *Client) LockWAFVersion(i *LockWAFVersionInput) (*WAFVersion, error) { // CloneWAFVersionInput used as input for cloning a WAF version. type CloneWAFVersionInput struct { - // The Web Application Firewall's id. + // The Web Application Firewall's ID. WAFID string // The Web Application Firewall's version number. WAFVersionNumber int @@ -350,7 +350,7 @@ func (c *Client) CloneWAFVersion(i *CloneWAFVersionInput) (*WAFVersion, error) { // DeployWAFVersionInput used as input for deploying a WAF version. type DeployWAFVersionInput struct { - // The Web Application Firewall's id. + // The Web Application Firewall's ID. WAFID string // The Web Application Firewall's version number. WAFVersionNumber int diff --git a/fastly/waf_version_test.go b/fastly/waf_version_test.go index 0b088dd6d..4ac35c7e5 100644 --- a/fastly/waf_version_test.go +++ b/fastly/waf_version_test.go @@ -315,15 +315,6 @@ func TestClient_ListAllWAFVersions_validation(t *testing.T) { if err != ErrMissingWAFID { t.Errorf("bad error: %s", err) } - - resp, err := testClient.ListAllWAFVersions(&ListAllWAFVersionsInput{ - WAFID: "4QXAURauMXa4KHQ3kRn5Yr", - }) - if err != nil { - t.Errorf("bad error: %s", err) - } - - print(resp) } func TestClient_GetWAFVersion_validation(t *testing.T) { @@ -334,6 +325,14 @@ func TestClient_GetWAFVersion_validation(t *testing.T) { if err != ErrMissingWAFID { t.Errorf("bad error: %s", err) } + + _, err = testClient.GetWAFVersion(&GetWAFVersionInput{ + WAFID: "1", + WAFVersionNumber: 0, + }) + if err != ErrMissingWAFVersionNumber { + t.Errorf("bad error: %s", err) + } } func TestClient_UpdateWAFVersion_validation(t *testing.T) { From ace5f94afc099cf169eb04223050a2530d02c5a9 Mon Sep 17 00:00:00 2001 From: oscarDovao <31310209+oscarDovao@users.noreply.github.com> Date: Thu, 12 Dec 2019 15:24:46 +0000 Subject: [PATCH 04/37] Waf rules (#10) * WAF rules related endpoints implementation --- .../fixtures/waf_rules/list_all_fastly.yaml | 43 +++++ .../waf_rules/list_all_fastly_exclusion.yaml | 43 +++++ fastly/fixtures/waf_rules/list_owasp.yaml | 43 +++++ fastly/waf_rules.go | 177 ++++++++++++++++++ fastly/waf_rules_test.go | 109 +++++++++++ 5 files changed, 415 insertions(+) create mode 100644 fastly/fixtures/waf_rules/list_all_fastly.yaml create mode 100644 fastly/fixtures/waf_rules/list_all_fastly_exclusion.yaml create mode 100644 fastly/fixtures/waf_rules/list_owasp.yaml create mode 100644 fastly/waf_rules.go create mode 100644 fastly/waf_rules_test.go diff --git a/fastly/fixtures/waf_rules/list_all_fastly.yaml b/fastly/fixtures/waf_rules/list_all_fastly.yaml new file mode 100644 index 000000000..962f89927 --- /dev/null +++ b/fastly/fixtures/waf_rules/list_all_fastly.yaml @@ -0,0 +1,43 @@ +--- +version: 1 +interactions: +- request: + body: "" + form: {} + headers: + User-Agent: + - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) + url: https://api.fastly.com/waf/rules?filter%5Bpublisher%5D%5Bin%5D=fastly&page%5Bnumber%5D=1&page%5Bsize%5D=100 + method: GET + response: + body: '{"data":[{"id":"2XaxZXGRt3si6PYFjk72VJ","type":"waf_rule","attributes":{"modsec_rule_id":4113001,"publisher":"fastly","type":"strict"}},{"id":"3gFobZTPjwOe2d4wjyMq0t","type":"waf_rule","attributes":{"modsec_rule_id":4112010,"publisher":"fastly","type":"strict"}},{"id":"7XknD1S1cIaBzaLaLM03rU","type":"waf_rule","attributes":{"modsec_rule_id":4170010,"publisher":"fastly","type":"strict"}},{"id":"4Ik26w8xeZsg6YSIgXvxk8","type":"waf_rule","attributes":{"modsec_rule_id":4112012,"publisher":"fastly","type":"strict"}},{"id":"3eMBNjXm2CDeuVGtqQ5gnm","type":"waf_rule","attributes":{"modsec_rule_id":4112019,"publisher":"fastly","type":"strict"}},{"id":"Z4a2ehtBKgSGKdzjLsFho","type":"waf_rule","attributes":{"modsec_rule_id":4120010,"publisher":"fastly","type":"strict"}},{"id":"YIvh8KyBfg2mpxd8VL701","type":"waf_rule","attributes":{"modsec_rule_id":4113060,"publisher":"fastly","type":"strict"}},{"id":"5IIah6rhz2xHPN4z0BGZQs","type":"waf_rule","attributes":{"modsec_rule_id":4112016,"publisher":"fastly","type":"strict"}},{"id":"WW0xqe1o1uGZkkZvyteXn","type":"waf_rule","attributes":{"modsec_rule_id":4113030,"publisher":"fastly","type":"strict"}},{"id":"7DupBmq6B6wFWBK1g9G56H","type":"waf_rule","attributes":{"modsec_rule_id":4170020,"publisher":"fastly","type":"strict"}},{"id":"4UrmWndGlZ6wF6YvVEo4mU","type":"waf_rule","attributes":{"modsec_rule_id":4112060,"publisher":"fastly","type":"strict"}},{"id":"38J95zkMuMHTAZa7YBV2Vj","type":"waf_rule","attributes":{"modsec_rule_id":4100030,"publisher":"fastly","type":"strict"}},{"id":"4tgA6dhHu45W2hWdGyVzmN","type":"waf_rule","attributes":{"modsec_rule_id":4112014,"publisher":"fastly","type":"strict"}},{"id":"5GdxS8oMO6Q7nVRDbbhetP","type":"waf_rule","attributes":{"modsec_rule_id":4113061,"publisher":"fastly","type":"strict"}},{"id":"1IKpuI64G89IiTwJ4OFjWd","type":"waf_rule","attributes":{"modsec_rule_id":4113050,"publisher":"fastly","type":"strict"}},{"id":"56ujtNdxwqnArlcY1ZxwuT","type":"waf_rule","attributes":{"modsec_rule_id":4112031,"publisher":"fastly","type":"strict"}},{"id":"5G9dWn5s3Po0rxqeQS2kQj","type":"waf_rule","attributes":{"modsec_rule_id":4112015,"publisher":"fastly","type":"strict"}},{"id":"17wfGf6Hha4qRO8al8C17G","type":"waf_rule","attributes":{"modsec_rule_id":4113020,"publisher":"fastly","type":"strict"}},{"id":"3M3EURR8f1V4hnsfVy8XRG","type":"waf_rule","attributes":{"modsec_rule_id":4112013,"publisher":"fastly","type":"strict"}},{"id":"4fYCmxnKNs1vPlJWhDTYOx","type":"waf_rule","attributes":{"modsec_rule_id":4100020,"publisher":"fastly","type":"strict"}},{"id":"C36P2W5xakP9F01r42Kht","type":"waf_rule","attributes":{"modsec_rule_id":4100041,"publisher":"fastly","type":"strict"}},{"id":"4TbXJfEwK7m8BcoZA24Sbe","type":"waf_rule","attributes":{"modsec_rule_id":4100010,"publisher":"fastly","type":"strict"}},{"id":"2zJHh4N0NqjpnIetsScbDd","type":"waf_rule","attributes":{"modsec_rule_id":4120011,"publisher":"fastly","type":"strict"}},{"id":"6pCSSke85supSFYGlhbQKF","type":"waf_rule","attributes":{"modsec_rule_id":4112018,"publisher":"fastly","type":"strict"}},{"id":"2SOmKa8AfgmNj0LCv9322W","type":"waf_rule","attributes":{"modsec_rule_id":4134010,"publisher":"fastly","type":"strict"}},{"id":"5jnKuokWp9ttLvzzV2fhMa","type":"waf_rule","attributes":{"modsec_rule_id":4113002,"publisher":"fastly","type":"strict"}},{"id":"38ZKGAwj8ePH7LyT4sELcW","type":"waf_rule","attributes":{"modsec_rule_id":4170001,"publisher":"fastly","type":"strict"}},{"id":"1j1agibUmJiozEVbIjnxw4","type":"waf_rule","attributes":{"modsec_rule_id":4170000,"publisher":"fastly","type":"strict"}},{"id":"7alH8ouxT4Ecl0omtUxDwi","type":"waf_rule","attributes":{"modsec_rule_id":4112011,"publisher":"fastly","type":"strict"}},{"id":"5rY5QVuuEnVp00OjBkW9d8","type":"waf_rule","attributes":{"modsec_rule_id":4113010,"publisher":"fastly","type":"strict"}},{"id":"2afLRYhGuQEW82cD5S7aAv","type":"waf_rule","attributes":{"modsec_rule_id":4100040,"publisher":"fastly","type":"strict"}}],"links":{"last":"https://api.fastly.com/waf/rules?filter[publisher][in]=fastly\u0026page[number]=1\u0026page[size]=100","first":"https://api.fastly.com/waf/rules?filter[publisher][in]=fastly\u0026page[number]=1\u0026page[size]=100"},"meta":{"current_page":1,"per_page":100,"record_count":31,"total_pages":1}}' + headers: + Accept-Ranges: + - bytes + Age: + - "0" + Content-Length: + - "4251" + Content-Type: + - application/vnd.api+json + Date: + - Thu, 05 Dec 2019 10:22:56 GMT + Status: + - 200 OK + Strict-Transport-Security: + - max-age=31536000 + Via: + - 1.1 varnish + X-Cache: + - MISS, MISS + X-Cache-Hits: + - 0, 0 + X-Content-Type-Options: + - nosniff + X-Served-By: + - cache-control-slwdc9036-CONTROL-SLWDC, cache-lcy19256-LCY + X-Timer: + - S1575541376.941919,VS0,VE335 + status: 200 OK + code: 200 + duration: "" diff --git a/fastly/fixtures/waf_rules/list_all_fastly_exclusion.yaml b/fastly/fixtures/waf_rules/list_all_fastly_exclusion.yaml new file mode 100644 index 000000000..4ceb2c155 --- /dev/null +++ b/fastly/fixtures/waf_rules/list_all_fastly_exclusion.yaml @@ -0,0 +1,43 @@ +--- +version: 1 +interactions: +- request: + body: "" + form: {} + headers: + User-Agent: + - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) + url: https://api.fastly.com/waf/rules?filter%5Bmodsec_rule_id%5D%5Bnot%5D=4170020&filter%5Bpublisher%5D%5Bin%5D=fastly&page%5Bnumber%5D=1&page%5Bsize%5D=100 + method: GET + response: + body: '{"data":[{"id":"2XaxZXGRt3si6PYFjk72VJ","type":"waf_rule","attributes":{"modsec_rule_id":4113001,"publisher":"fastly","type":"strict"}},{"id":"3gFobZTPjwOe2d4wjyMq0t","type":"waf_rule","attributes":{"modsec_rule_id":4112010,"publisher":"fastly","type":"strict"}},{"id":"7XknD1S1cIaBzaLaLM03rU","type":"waf_rule","attributes":{"modsec_rule_id":4170010,"publisher":"fastly","type":"strict"}},{"id":"4Ik26w8xeZsg6YSIgXvxk8","type":"waf_rule","attributes":{"modsec_rule_id":4112012,"publisher":"fastly","type":"strict"}},{"id":"3eMBNjXm2CDeuVGtqQ5gnm","type":"waf_rule","attributes":{"modsec_rule_id":4112019,"publisher":"fastly","type":"strict"}},{"id":"Z4a2ehtBKgSGKdzjLsFho","type":"waf_rule","attributes":{"modsec_rule_id":4120010,"publisher":"fastly","type":"strict"}},{"id":"YIvh8KyBfg2mpxd8VL701","type":"waf_rule","attributes":{"modsec_rule_id":4113060,"publisher":"fastly","type":"strict"}},{"id":"5IIah6rhz2xHPN4z0BGZQs","type":"waf_rule","attributes":{"modsec_rule_id":4112016,"publisher":"fastly","type":"strict"}},{"id":"WW0xqe1o1uGZkkZvyteXn","type":"waf_rule","attributes":{"modsec_rule_id":4113030,"publisher":"fastly","type":"strict"}},{"id":"4UrmWndGlZ6wF6YvVEo4mU","type":"waf_rule","attributes":{"modsec_rule_id":4112060,"publisher":"fastly","type":"strict"}},{"id":"38J95zkMuMHTAZa7YBV2Vj","type":"waf_rule","attributes":{"modsec_rule_id":4100030,"publisher":"fastly","type":"strict"}},{"id":"4tgA6dhHu45W2hWdGyVzmN","type":"waf_rule","attributes":{"modsec_rule_id":4112014,"publisher":"fastly","type":"strict"}},{"id":"5GdxS8oMO6Q7nVRDbbhetP","type":"waf_rule","attributes":{"modsec_rule_id":4113061,"publisher":"fastly","type":"strict"}},{"id":"1IKpuI64G89IiTwJ4OFjWd","type":"waf_rule","attributes":{"modsec_rule_id":4113050,"publisher":"fastly","type":"strict"}},{"id":"56ujtNdxwqnArlcY1ZxwuT","type":"waf_rule","attributes":{"modsec_rule_id":4112031,"publisher":"fastly","type":"strict"}},{"id":"5G9dWn5s3Po0rxqeQS2kQj","type":"waf_rule","attributes":{"modsec_rule_id":4112015,"publisher":"fastly","type":"strict"}},{"id":"17wfGf6Hha4qRO8al8C17G","type":"waf_rule","attributes":{"modsec_rule_id":4113020,"publisher":"fastly","type":"strict"}},{"id":"3M3EURR8f1V4hnsfVy8XRG","type":"waf_rule","attributes":{"modsec_rule_id":4112013,"publisher":"fastly","type":"strict"}},{"id":"4fYCmxnKNs1vPlJWhDTYOx","type":"waf_rule","attributes":{"modsec_rule_id":4100020,"publisher":"fastly","type":"strict"}},{"id":"C36P2W5xakP9F01r42Kht","type":"waf_rule","attributes":{"modsec_rule_id":4100041,"publisher":"fastly","type":"strict"}},{"id":"4TbXJfEwK7m8BcoZA24Sbe","type":"waf_rule","attributes":{"modsec_rule_id":4100010,"publisher":"fastly","type":"strict"}},{"id":"2zJHh4N0NqjpnIetsScbDd","type":"waf_rule","attributes":{"modsec_rule_id":4120011,"publisher":"fastly","type":"strict"}},{"id":"6pCSSke85supSFYGlhbQKF","type":"waf_rule","attributes":{"modsec_rule_id":4112018,"publisher":"fastly","type":"strict"}},{"id":"2SOmKa8AfgmNj0LCv9322W","type":"waf_rule","attributes":{"modsec_rule_id":4134010,"publisher":"fastly","type":"strict"}},{"id":"5jnKuokWp9ttLvzzV2fhMa","type":"waf_rule","attributes":{"modsec_rule_id":4113002,"publisher":"fastly","type":"strict"}},{"id":"38ZKGAwj8ePH7LyT4sELcW","type":"waf_rule","attributes":{"modsec_rule_id":4170001,"publisher":"fastly","type":"strict"}},{"id":"1j1agibUmJiozEVbIjnxw4","type":"waf_rule","attributes":{"modsec_rule_id":4170000,"publisher":"fastly","type":"strict"}},{"id":"7alH8ouxT4Ecl0omtUxDwi","type":"waf_rule","attributes":{"modsec_rule_id":4112011,"publisher":"fastly","type":"strict"}},{"id":"5rY5QVuuEnVp00OjBkW9d8","type":"waf_rule","attributes":{"modsec_rule_id":4113010,"publisher":"fastly","type":"strict"}},{"id":"2afLRYhGuQEW82cD5S7aAv","type":"waf_rule","attributes":{"modsec_rule_id":4100040,"publisher":"fastly","type":"strict"}}],"links":{"last":"https://api.fastly.com/waf/rules?filter[modsec_rule_id][not]=4170020\u0026filter[publisher][in]=fastly\u0026page[number]=1\u0026page[size]=100","first":"https://api.fastly.com/waf/rules?filter[modsec_rule_id][not]=4170020\u0026filter[publisher][in]=fastly\u0026page[number]=1\u0026page[size]=100"},"meta":{"current_page":1,"per_page":100,"record_count":30,"total_pages":1}}' + headers: + Accept-Ranges: + - bytes + Age: + - "0" + Content-Length: + - "4206" + Content-Type: + - application/vnd.api+json + Date: + - Thu, 05 Dec 2019 10:29:34 GMT + Status: + - 200 OK + Strict-Transport-Security: + - max-age=31536000 + Via: + - 1.1 varnish + X-Cache: + - MISS, MISS + X-Cache-Hits: + - 0, 0 + X-Content-Type-Options: + - nosniff + X-Served-By: + - cache-control-slwdc9035-CONTROL-SLWDC, cache-lcy19262-LCY + X-Timer: + - S1575541773.450107,VS0,VE580 + status: 200 OK + code: 200 + duration: "" diff --git a/fastly/fixtures/waf_rules/list_owasp.yaml b/fastly/fixtures/waf_rules/list_owasp.yaml new file mode 100644 index 000000000..fed7944c1 --- /dev/null +++ b/fastly/fixtures/waf_rules/list_owasp.yaml @@ -0,0 +1,43 @@ +--- +version: 1 +interactions: +- request: + body: "" + form: {} + headers: + User-Agent: + - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) + url: https://api.fastly.com/waf/rules?filter%5Bpublisher%5D%5Bin%5D=owasp + method: GET + response: + body: '{"data":[{"id":"3T97utLZHIHPEJsBjZs53","type":"waf_rule","attributes":{"modsec_rule_id":932170,"publisher":"owasp","type":"score"}},{"id":"6eCACmN7PEYXxMullt6EM1","type":"waf_rule","attributes":{"modsec_rule_id":942251,"publisher":"owasp","type":"score"}},{"id":"4meOF9EtJO6vNGe8w3lACj","type":"waf_rule","attributes":{"modsec_rule_id":933160,"publisher":"owasp","type":"score"}},{"id":"4V2Q1ISeiD8ls9QG7g6CaN","type":"waf_rule","attributes":{"modsec_rule_id":920170,"publisher":"owasp","type":"score"}},{"id":"ZBJDmVFau6VPKErXgI6wJ","type":"waf_rule","attributes":{"modsec_rule_id":920310,"publisher":"owasp","type":"score"}},{"id":"7E7gblergwe4HVRNtfyUW","type":"waf_rule","attributes":{"modsec_rule_id":941220,"publisher":"owasp","type":"score"}},{"id":"7NEve7gRqNCFB8sbWjKPmk","type":"waf_rule","attributes":{"modsec_rule_id":941180,"publisher":"owasp","type":"score"}},{"id":"6tLDKDkaoZvOHtZaf7c2Fi","type":"waf_rule","attributes":{"modsec_rule_id":933161,"publisher":"owasp","type":"score"}},{"id":"3uXyImW5Yya1M6ROl6iC0C","type":"waf_rule","attributes":{"modsec_rule_id":921151,"publisher":"owasp","type":"score"}},{"id":"63ClIlgxR5QvvoWR1YvXbR","type":"waf_rule","attributes":{"modsec_rule_id":930120,"publisher":"owasp","type":"score"}},{"id":"62NGF4KWy1v17yyV1vmPdb","type":"waf_rule","attributes":{"modsec_rule_id":1010070,"publisher":"owasp","type":"threshold"}},{"id":"5UQ8T26JMr0iF8d48Gpxuj","type":"waf_rule","attributes":{"modsec_rule_id":942220,"publisher":"owasp","type":"score"}},{"id":"2g407ucfEuQeNzSgMgGXek","type":"waf_rule","attributes":{"modsec_rule_id":910100,"publisher":"owasp","type":"score"}},{"id":"2NaHL7tra6XWlV6SYyt4ga","type":"waf_rule","attributes":{"modsec_rule_id":942110,"publisher":"owasp","type":"score"}},{"id":"3oalwv7se4B4tm4UCzcFb9","type":"waf_rule","attributes":{"modsec_rule_id":920320,"publisher":"owasp","type":"score"}},{"id":"6ma7K2OMX17Q4H8pFfcnbT","type":"waf_rule","attributes":{"modsec_rule_id":941210,"publisher":"owasp","type":"score"}},{"id":"6XTOTlhM57bSHhwlhO2UmP","type":"waf_rule","attributes":{"modsec_rule_id":1010020,"publisher":"owasp","type":"threshold"}},{"id":"4Cm4vjJNDNpw0JntslEKRT","type":"waf_rule","attributes":{"modsec_rule_id":941250,"publisher":"owasp","type":"score"}},{"id":"3WSdmoQeLxs8AGAXnslLha","type":"waf_rule","attributes":{"modsec_rule_id":932120,"publisher":"owasp","type":"score"}},{"id":"4PI1v9ISbTCJkul1CEq500","type":"waf_rule","attributes":{"modsec_rule_id":920450,"publisher":"owasp","type":"score"}},{"id":"3J11D3hj7iY8LgundZ69V8","type":"waf_rule","attributes":{"modsec_rule_id":920300,"publisher":"owasp","type":"score"}},{"id":"2W6ynM8FDG0w2p2Un05NXU","type":"waf_rule","attributes":{"modsec_rule_id":920230,"publisher":"owasp","type":"score"}},{"id":"437sNKowWbmCcZpfC4K1Ys","type":"waf_rule","attributes":{"modsec_rule_id":933100,"publisher":"owasp","type":"score"}},{"id":"2cxIQeMUhQ5YMn1rAlNy5s","type":"waf_rule","attributes":{"modsec_rule_id":921120,"publisher":"owasp","type":"score"}},{"id":"3uhvC8VfCipiVE7NqSQTDm","type":"waf_rule","attributes":{"modsec_rule_id":942260,"publisher":"owasp","type":"score"}},{"id":"5GKi5BbX7TRgJ9PduDHen7","type":"waf_rule","attributes":{"modsec_rule_id":942432,"publisher":"owasp","type":"score"}},{"id":"2pMaOZyqdXhWGjAo6nuSNj","type":"waf_rule","attributes":{"modsec_rule_id":911100,"publisher":"owasp","type":"score"}},{"id":"7W8PV6MPJFlIRTZ12p8jYW","type":"waf_rule","attributes":{"modsec_rule_id":942230,"publisher":"owasp","type":"score"}},{"id":"1r8ROzSG3Ese1IixarVDpL","type":"waf_rule","attributes":{"modsec_rule_id":941160,"publisher":"owasp","type":"score"}},{"id":"5lV5N7lXvmU9KkD9GmXVsP","type":"waf_rule","attributes":{"modsec_rule_id":942420,"publisher":"owasp","type":"score"}},{"id":"1ppPUAVlwI0wWungzHZow9","type":"waf_rule","attributes":{"modsec_rule_id":942421,"publisher":"owasp","type":"score"}},{"id":"2iTaUVNPHrmGlfifFj70Ob","type":"waf_rule","attributes":{"modsec_rule_id":921110,"publisher":"owasp","type":"score"}},{"id":"1I2bjaooKfJZM221bFdiez","type":"waf_rule","attributes":{"modsec_rule_id":920260,"publisher":"owasp","type":"score"}},{"id":"3u6Ltv3BSqatwpfK51IMlQ","type":"waf_rule","attributes":{"modsec_rule_id":1010090,"publisher":"owasp","type":"threshold"}},{"id":"3DzcVuVJNPgiJu6pSnPHLq","type":"waf_rule","attributes":{"modsec_rule_id":941130,"publisher":"owasp","type":"score"}},{"id":"Qy1QN21QHjQ9mLnesJtCh","type":"waf_rule","attributes":{"modsec_rule_id":941120,"publisher":"owasp","type":"score"}},{"id":"2UTSgKsnwLoSOWqZBqdEtg","type":"waf_rule","attributes":{"modsec_rule_id":941380,"publisher":"owasp","type":"score"}},{"id":"5Alz18HtbDbawfV1k3crxc","type":"waf_rule","attributes":{"modsec_rule_id":944200,"publisher":"owasp","type":"score"}},{"id":"2lTpkHjsgQ1FB9yy6jp6cF","type":"waf_rule","attributes":{"modsec_rule_id":933170,"publisher":"owasp","type":"score"}},{"id":"6ybI2uR1NMirDQYXEyxCr8","type":"waf_rule","attributes":{"modsec_rule_id":942460,"publisher":"owasp","type":"score"}},{"id":"54WZ12x9YZipGXKApNM3hq","type":"waf_rule","attributes":{"modsec_rule_id":932115,"publisher":"owasp","type":"score"}},{"id":"j8oUsJv2A8bKVTu2vWxlU","type":"waf_rule","attributes":{"modsec_rule_id":941270,"publisher":"owasp","type":"score"}},{"id":"5K7PEy8BqRZtdYSNTEnAji","type":"waf_rule","attributes":{"modsec_rule_id":942150,"publisher":"owasp","type":"score"}},{"id":"78HEJuoe2y9C07T1WIayts","type":"waf_rule","attributes":{"modsec_rule_id":920120,"publisher":"owasp","type":"score"}},{"id":"4ZdBcwv7Bn75DGHx5keY1E","type":"waf_rule","attributes":{"modsec_rule_id":942430,"publisher":"owasp","type":"score"}},{"id":"6ohxwJw00B34nj7xWEzNj6","type":"waf_rule","attributes":{"modsec_rule_id":920100,"publisher":"owasp","type":"score"}},{"id":"44rWsPJ4tVVo6Cnd1RKWqp","type":"waf_rule","attributes":{"modsec_rule_id":941370,"publisher":"owasp","type":"score"}},{"id":"1d2B4YgoOJrr0vasxtu7uG","type":"waf_rule","attributes":{"modsec_rule_id":942200,"publisher":"owasp","type":"score"}},{"id":"2UybEFm2RCnm8dGfAeLxfz","type":"waf_rule","attributes":{"modsec_rule_id":920274,"publisher":"owasp","type":"score"}},{"id":"4Sw1CvP0yI0nhTJ3X7VOUL","type":"waf_rule","attributes":{"modsec_rule_id":933150,"publisher":"owasp","type":"score"}},{"id":"7BsAdPVS7ffHyhU0id9x8q","type":"waf_rule","attributes":{"modsec_rule_id":931120,"publisher":"owasp","type":"score"}},{"id":"5jWm6lK7zNBcZlAaHvaCYo","type":"waf_rule","attributes":{"modsec_rule_id":933140,"publisher":"owasp","type":"score"}},{"id":"3OEFyXBGFQhByya3eh3yah","type":"waf_rule","attributes":{"modsec_rule_id":942250,"publisher":"owasp","type":"score"}},{"id":"74D8C9HK9aLo3OhrHgTAXg","type":"waf_rule","attributes":{"modsec_rule_id":932180,"publisher":"owasp","type":"score"}},{"id":"2bkdAVUipvtbVQ4EzOmG2m","type":"waf_rule","attributes":{"modsec_rule_id":944100,"publisher":"owasp","type":"score"}},{"id":"6H5ysoO5yF8zmv3ZE0ugtQ","type":"waf_rule","attributes":{"modsec_rule_id":933111,"publisher":"owasp","type":"score"}},{"id":"y0mfQVk16BAK4g8uAm8WX","type":"waf_rule","attributes":{"modsec_rule_id":941360,"publisher":"owasp","type":"score"}},{"id":"1M7aeBXFGCPhDTjMOE3CAX","type":"waf_rule","attributes":{"modsec_rule_id":920360,"publisher":"owasp","type":"score"}},{"id":"R93yg4qgWyUiWu4QFPUKf","type":"waf_rule","attributes":{"modsec_rule_id":933131,"publisher":"owasp","type":"score"}},{"id":"CUpzK925yVTV8PFBZUIjN","type":"waf_rule","attributes":{"modsec_rule_id":941170,"publisher":"owasp","type":"score"}},{"id":"4i6rpWlrKTqfcFP4MQ7mq0","type":"waf_rule","attributes":{"modsec_rule_id":942450,"publisher":"owasp","type":"score"}},{"id":"5L0MdZ1VUBG9GIjPtiru5i","type":"waf_rule","attributes":{"modsec_rule_id":920440,"publisher":"owasp","type":"score"}},{"id":"4jFD0qz0k9DrZ9IQ3ghU1A","type":"waf_rule","attributes":{"modsec_rule_id":933110,"publisher":"owasp","type":"score"}},{"id":"mpkSgMxYhSxvVK3OySnsO","type":"waf_rule","attributes":{"modsec_rule_id":920270,"publisher":"owasp","type":"score"}},{"id":"38CkHzoUDqy8D7OCCnurrm","type":"waf_rule","attributes":{"modsec_rule_id":920410,"publisher":"owasp","type":"score"}},{"id":"1zCtssfrH0f4yCBwGz8DeL","type":"waf_rule","attributes":{"modsec_rule_id":931110,"publisher":"owasp","type":"score"}},{"id":"7UAnNmAPJmTCHt6iim3sIw","type":"waf_rule","attributes":{"modsec_rule_id":944120,"publisher":"owasp","type":"score"}},{"id":"1FWIQiCyJ02Y2YFODFkEgE","type":"waf_rule","attributes":{"modsec_rule_id":943100,"publisher":"owasp","type":"score"}},{"id":"LqkxyC7pdmf8NpYxjBtTk","type":"waf_rule","attributes":{"modsec_rule_id":920420,"publisher":"owasp","type":"score"}},{"id":"q8zb2QVJwUxpKklK7ankA","type":"waf_rule","attributes":{"modsec_rule_id":933200,"publisher":"owasp","type":"score"}},{"id":"4gvWLVxLSZTpfTPVqx61JL","type":"waf_rule","attributes":{"modsec_rule_id":941230,"publisher":"owasp","type":"score"}},{"id":"5f7f6CqkSG2j15pk4XrPgB","type":"waf_rule","attributes":{"modsec_rule_id":932100,"publisher":"owasp","type":"score"}},{"id":"1qTpth9Z0s0D5znDL74c0M","type":"waf_rule","attributes":{"modsec_rule_id":941101,"publisher":"owasp","type":"score"}},{"id":"6UHBQFXN2FTeEum3bVx3ZU","type":"waf_rule","attributes":{"modsec_rule_id":941330,"publisher":"owasp","type":"score"}},{"id":"funFRE2G4BZ4WSgY5Xouw","type":"waf_rule","attributes":{"modsec_rule_id":942340,"publisher":"owasp","type":"score"}},{"id":"4E4v0EjqJrRgsmE1MtBbgx","type":"waf_rule","attributes":{"modsec_rule_id":942210,"publisher":"owasp","type":"score"}},{"id":"3BbHhiELIMFBkN8PVDjUNP","type":"waf_rule","attributes":{"modsec_rule_id":933210,"publisher":"owasp","type":"score"}},{"id":"6OWgIt1lHg0VxvH74oRZ6P","type":"waf_rule","attributes":{"modsec_rule_id":942490,"publisher":"owasp","type":"score"}},{"id":"18VsY1pWtXCzKryriATeyX","type":"waf_rule","attributes":{"modsec_rule_id":913110,"publisher":"owasp","type":"score"}},{"id":"F9VD65YbW1oKqdF4H9z5B","type":"waf_rule","attributes":{"modsec_rule_id":944130,"publisher":"owasp","type":"score"}},{"id":"6VyXTUwMT84H8GTHxqJblu","type":"waf_rule","attributes":{"modsec_rule_id":921160,"publisher":"owasp","type":"score"}},{"id":"3DD6dZWc9boscyBHXFHFue","type":"waf_rule","attributes":{"modsec_rule_id":942270,"publisher":"owasp","type":"score"}},{"id":"2nsxhcrILheCQ0inXwyILg","type":"waf_rule","attributes":{"modsec_rule_id":942290,"publisher":"owasp","type":"score"}},{"id":"85UvmpBGX7hDLM8FMv3wi","type":"waf_rule","attributes":{"modsec_rule_id":941110,"publisher":"owasp","type":"score"}},{"id":"3hl5DmRG9x1HLkQ78VBy1M","type":"waf_rule","attributes":{"modsec_rule_id":942370,"publisher":"owasp","type":"score"}},{"id":"UoUTdyxk6Jezxs1I6Nr3C","type":"waf_rule","attributes":{"modsec_rule_id":913101,"publisher":"owasp","type":"score"}},{"id":"TCypkfvnpJTNI4Nqn1Lih","type":"waf_rule","attributes":{"modsec_rule_id":942510,"publisher":"owasp","type":"score"}},{"id":"UPSeN85nGCPgclhzVCM86","type":"waf_rule","attributes":{"modsec_rule_id":920171,"publisher":"owasp","type":"score"}},{"id":"4MxIKWZLEY3X0EdL9BDht","type":"waf_rule","attributes":{"modsec_rule_id":943120,"publisher":"owasp","type":"score"}},{"id":"7dnkIiK5Xm7ZhlvyDKNgDW","type":"waf_rule","attributes":{"modsec_rule_id":932150,"publisher":"owasp","type":"score"}},{"id":"2eD4wyBhZFhGTQWvO7YC6n","type":"waf_rule","attributes":{"modsec_rule_id":942400,"publisher":"owasp","type":"score"}},{"id":"77QafiZSnHGxzYGCjb0kLF","type":"waf_rule","attributes":{"modsec_rule_id":1010050,"publisher":"owasp","type":"threshold"}},{"id":"1hNQd6E7jAfOXHtrBjcAK6","type":"waf_rule","attributes":{"modsec_rule_id":920220,"publisher":"owasp","type":"score"}},{"id":"34gEBuw65poZkXn1ZTiYUX","type":"waf_rule","attributes":{"modsec_rule_id":932105,"publisher":"owasp","type":"score"}},{"id":"iLZHukpIqhkUPvMxLkYG3","type":"waf_rule","attributes":{"modsec_rule_id":920470,"publisher":"owasp","type":"score"}},{"id":"2KWVfNjiLcK3rvgcbXsfou","type":"waf_rule","attributes":{"modsec_rule_id":920121,"publisher":"owasp","type":"score"}},{"id":"5h8bwr7tjpvZopJFsZURVq","type":"waf_rule","attributes":{"modsec_rule_id":920202,"publisher":"owasp","type":"score"}},{"id":"2Yue8UQu1xxzOFT0cLW36S","type":"waf_rule","attributes":{"modsec_rule_id":920250,"publisher":"owasp","type":"score"}},{"id":"34bYyLKN2lD4wtiFlJzjk5","type":"waf_rule","attributes":{"modsec_rule_id":942120,"publisher":"owasp","type":"score"}},{"id":"1GSqDL7E4nH7fFq2tbB3Vi","type":"waf_rule","attributes":{"modsec_rule_id":941340,"publisher":"owasp","type":"score"}}],"links":{"last":"https://api.fastly.com/waf/rules?filter[publisher][in]=owasp\u0026page[number]=2\u0026page[size]=100","first":"https://api.fastly.com/waf/rules?filter[publisher][in]=owasp\u0026page[number]=1\u0026page[size]=100","next":"https://api.fastly.com/waf/rules?filter[publisher][in]=owasp\u0026page[number]=2\u0026page[size]=100"},"meta":{"current_page":1,"per_page":100,"record_count":191,"total_pages":2}}' + headers: + Accept-Ranges: + - bytes + Age: + - "0" + Content-Length: + - "12828" + Content-Type: + - application/vnd.api+json + Date: + - Thu, 05 Dec 2019 10:22:55 GMT + Status: + - 200 OK + Strict-Transport-Security: + - max-age=31536000 + Via: + - 1.1 varnish + X-Cache: + - MISS, MISS + X-Cache-Hits: + - 0, 0 + X-Content-Type-Options: + - nosniff + X-Served-By: + - cache-control-slwdc9035-CONTROL-SLWDC, cache-lcy19256-LCY + X-Timer: + - S1575541375.472243,VS0,VE388 + status: 200 OK + code: 200 + duration: "" diff --git a/fastly/waf_rules.go b/fastly/waf_rules.go new file mode 100644 index 000000000..ca475b16d --- /dev/null +++ b/fastly/waf_rules.go @@ -0,0 +1,177 @@ +package fastly + +import ( + "bytes" + "fmt" + "io" + "reflect" + "strconv" + "strings" + + "github.com/google/jsonapi" +) + +// WAFRuleType is used for reflection because JSONAPI wants to know what it's +// decoding into. +var WAFRuleType = reflect.TypeOf(new(WAFRule)) + +// WAFRule is the information about a WAF rule object. +type WAFRule struct { + ID string `jsonapi:"primary,waf_rule,omitempty"` + ModSecID int `jsonapi:"attr,modsec_rule_id,omitempty"` + Publisher string `jsonapi:"attr,publisher,omitempty"` + Type string `jsonapi:"attr,type,omitempty"` + Revisions []*WAFRuleRevision `jsonapi:"relation,waf_rule_revisions,omitempty"` +} + +// WAFRuleRevision is the information about a WAF rule revision object. +type WAFRuleRevision struct { + ID string `jsonapi:"primary,waf_rule_revision,omitempty"` + Status string `jsonapi:"attr,message,omitempty"` + Severity int `jsonapi:"attr,severity,omitempty"` + Revision int `jsonapi:"attr,revision,omitempty"` + ParanoiaLevel int `jsonapi:"attr,paranoia_level,omitempty"` + ModSecID int `jsonapi:"attr,modsec_rule_id,omitempty"` + State string `jsonapi:"attr,state,omitempty"` + Source string `jsonapi:"attr,source,omitempty"` + VCL string `jsonapi:"attr,vcl,omitempty"` +} + +// WAFRuleResponse represents a list WAF rules full response. +type WAFRuleResponse struct { + Items []*WAFRule + Info infoResponse +} + +// ListWAFRulesInput used as input for listing WAF rules. +type ListWAFRulesInput struct { + // Limit the returned rules to a set linked to list of tags by name. + FilterTagNames []string + // Limit the returned rules to a set by publishers. + FilterPublishers []string + // Excludes individual rules by modsecurity rule IDs. + ExcludeMocSecIDs []int + // Limit the number of returned rules. + PageSize int + // Request a specific page of rules. + PageNumber int + // Include relationships. Optional, comma-separated values. Permitted values: waf_tags and waf_rule_revisions. + Include string +} + +func (i *ListWAFRulesInput) formatFilters() map[string]string { + + result := map[string]string{} + pairings := map[string]interface{}{ + "filter[waf_tags][name][in]": i.FilterTagNames, + "filter[publisher][in]": i.FilterPublishers, + "filter[modsec_rule_id][not]": i.ExcludeMocSecIDs, + "page[size]": i.PageSize, + "page[number]": i.PageNumber, + "include": i.Include, + } + + for key, value := range pairings { + switch t := reflect.TypeOf(value).String(); t { + case "string": + if value != "" { + result[key] = value.(string) + } + case "int": + if value != 0 { + result[key] = strconv.Itoa(value.(int)) + } + case "[]string": + if len(value.([]string)) > 0 { + result[key] = strings.Join(value.([]string), ",") + } + case "[]int": + if len(value.([]int)) > 0 { + + stringSlice := make([]string, len(value.([]int))) + for i, id := range value.([]int) { + stringSlice[i] = strconv.Itoa(id) + } + result[key] = strings.Join(stringSlice, ",") + } + } + } + return result +} + +// ListWAFRules returns the list of VAF versions for a given WAF ID. +func (c *Client) ListWAFRules(i *ListWAFRulesInput) (*WAFRuleResponse, error) { + + resp, err := c.Get("/waf/rules", &RequestOptions{ + Params: i.formatFilters(), + }) + if err != nil { + return nil, err + } + + var buf bytes.Buffer + tee := io.TeeReader(resp.Body, &buf) + + info, err := getResponseInfo(tee) + if err != nil { + return nil, err + } + + data, err := jsonapi.UnmarshalManyPayload(bytes.NewReader(buf.Bytes()), WAFRuleType) + if err != nil { + return nil, err + } + + wafRules := make([]*WAFRule, len(data)) + for i := range data { + typed, ok := data[i].(*WAFRule) + if !ok { + return nil, fmt.Errorf("got back a non-WAFRule response") + } + wafRules[i] = typed + } + return &WAFRuleResponse{ + Items: wafRules, + Info: info, + }, nil +} + +// ListAllWAFRulesInput used as input for listing all WAF rules. +type ListAllWAFRulesInput struct { + // Limit the returned rules to a set linked to a tag by name. + FilterTagNames []string + // Limit the returned rules to a set by publishers. + FilterPublishers []string + // Excludes individual rules by modsecurity rule IDs. + ExcludeMocSecIDs []int + // Include relationships. Optional, comma-separated values. Permitted values: waf_tags and waf_rule_revisions. + Include string +} + +// ListAllWAFRules returns the complete list of WAF rules for the given filters. It iterates through +// all existing pages to ensure all WAF rules are returned at once. +func (c *Client) ListAllWAFRules(i *ListAllWAFRulesInput) (*WAFRuleResponse, error) { + + currentPage := 1 + result := &WAFRuleResponse{Items: []*WAFRule{}} + for { + r, err := c.ListWAFRules(&ListWAFRulesInput{ + FilterTagNames: i.FilterTagNames, + FilterPublishers: i.FilterPublishers, + ExcludeMocSecIDs: i.ExcludeMocSecIDs, + Include: i.Include, + PageNumber: currentPage, + PageSize: WAFPaginationPageSize, + }) + if err != nil { + return r, err + } + + currentPage++ + result.Items = append(result.Items, r.Items...) + + if r.Info.Links.Next == "" || len(r.Items) == 0 { + return result, nil + } + } +} diff --git a/fastly/waf_rules_test.go b/fastly/waf_rules_test.go new file mode 100644 index 000000000..607b80ce7 --- /dev/null +++ b/fastly/waf_rules_test.go @@ -0,0 +1,109 @@ +package fastly + +import ( + "reflect" + "testing" +) + +func TestClient_WAF_Rules(t *testing.T) { + t.Parallel() + + fixtureBase := "waf_rules/" + + var err error + var rulesResp *WAFRuleResponse + publisher := "owasp" + record(t, fixtureBase+"/list_owasp", func(c *Client) { + rulesResp, err = c.ListWAFRules(&ListWAFRulesInput{ + FilterPublishers: []string{publisher}, + }) + }) + if err != nil { + t.Fatal(err) + } + if len(rulesResp.Items) < 1 { + t.Errorf("expected many rules: got %d", len(rulesResp.Items)) + } + + for _, r := range rulesResp.Items { + if r.Publisher != publisher { + t.Errorf("expected rule publisher %s: got %s", publisher, r.Publisher) + } + } + + publisher = "fastly" + var fastlyRulesNumber int + record(t, fixtureBase+"/list_all_fastly", func(c *Client) { + rulesResp, err = c.ListAllWAFRules(&ListAllWAFRulesInput{ + FilterPublishers: []string{publisher}, + }) + }) + if err != nil { + t.Fatal(err) + } + if len(rulesResp.Items) < 1 { + t.Errorf("expected many rules: got %d", len(rulesResp.Items)) + } + + for _, r := range rulesResp.Items { + if r.Publisher != publisher { + t.Errorf("expected rule publisher %s: got %s", publisher, r.Publisher) + } + } + fastlyRulesNumber = len(rulesResp.Items) + + record(t, fixtureBase+"/list_all_fastly_exclusion", func(c *Client) { + rulesResp, err = c.ListAllWAFRules(&ListAllWAFRulesInput{ + FilterPublishers: []string{publisher}, + ExcludeMocSecIDs: []int{4170020}, + }) + }) + if err != nil { + t.Fatal(err) + } + if len(rulesResp.Items) < 1 { + t.Errorf("expected many rules: got %d", len(rulesResp.Items)) + } + + for _, r := range rulesResp.Items { + if r.Publisher != publisher { + t.Errorf("expected rule publisher %s: got %s", publisher, r.Publisher) + } + } + + if fastlyRulesNumber-1 != len(rulesResp.Items) { + t.Errorf("expected %d rules: got %d", fastlyRulesNumber-1, len(rulesResp.Items)) + } +} + +func TestClient_listWAFRules_formatFilters(t *testing.T) { + cases := []struct { + remote *ListWAFRulesInput + local map[string]string + }{ + { + remote: &ListWAFRulesInput{ + FilterTagNames: []string{"tag1", "tag2"}, + FilterPublishers: []string{"owasp", "trustwave"}, + ExcludeMocSecIDs: []int{123456, 1234567}, + PageSize: 2, + PageNumber: 2, + Include: "included", + }, + local: map[string]string{ + "filter[waf_tags][name][in]": "tag1,tag2", + "filter[publisher][in]": "owasp,trustwave", + "filter[modsec_rule_id][not]": "123456,1234567", + "page[size]": "2", + "page[number]": "2", + "include": "included", + }, + }, + } + for _, c := range cases { + out := c.remote.formatFilters() + if !reflect.DeepEqual(out, c.local) { + t.Fatalf("Error matching:\nexpected: %#v\n got: %#v", c.local, out) + } + } +} From f99eb9418ce20fb04e182ef696e6655d4bc8e225 Mon Sep 17 00:00:00 2001 From: oscarDovao <31310209+oscarDovao@users.noreply.github.com> Date: Wed, 8 Jan 2020 09:18:12 +0000 Subject: [PATCH 05/37] Waf config resource deletion (#12) * create empty waf version endpoint implemented --- .../fixtures/waf_versions/create_empty.yaml | 53 ++++++++++++++++ fastly/waf_version.go | 28 +++++++++ fastly/waf_version_test.go | 60 +++++++++++++++++++ 3 files changed, 141 insertions(+) create mode 100644 fastly/fixtures/waf_versions/create_empty.yaml diff --git a/fastly/fixtures/waf_versions/create_empty.yaml b/fastly/fixtures/waf_versions/create_empty.yaml new file mode 100644 index 000000000..451a7cb6d --- /dev/null +++ b/fastly/fixtures/waf_versions/create_empty.yaml @@ -0,0 +1,53 @@ +--- +version: 1 +interactions: +- request: + body: "" + form: {} + headers: + Accept: + - application/vnd.api+json + Content-Type: + - application/vnd.api+json + User-Agent: + - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) + url: https://api.fastly.com/waf/firewalls/3bhISXhyFhsufhCFnTst1j/versions + method: POST + response: + body: '{"data":{"id":"74nEJg1p4KRGeeV371dcKM","type":"waf_firewall_version","attributes":{"number":3,"comment":null,"active":null,"locked":null,"error":null,"deployed_at":null,"critical_anomaly_score":5,"error_anomaly_score":4,"warning_anomaly_score":3,"notice_anomaly_score":2,"http_violation_score_threshold":999,"inbound_anomaly_score_threshold":999,"lfi_score_threshold":999,"php_injection_score_threshold":999,"rce_score_threshold":999,"rfi_score_threshold":999,"session_fixation_score_threshold":999,"sql_injection_score_threshold":999,"xss_score_threshold":999,"paranoia_level":1,"arg_name_length":100,"arg_length":400,"total_arg_length":6400,"max_file_size":10000000,"combined_file_sizes":10000000,"max_num_args":255,"high_risk_country_codes":"","allowed_methods":"GET + HEAD POST OPTIONS PUT PATCH DELETE","restricted_headers":"/proxy/ /lock-token/ + /content-range/ /translate/ /if/","restricted_extensions":".asa/ .asax/ .ascx/ + .axd/ .backup/ .bak/ .bat/ .cdx/ .cer/ .cfg/ .cmd/ .com/ .config/ .conf/ .cs/ + .csproj/ .csr/ .dat/ .db/ .dbf/ .dll/ .dos/ .htr/ .htw/ .ida/ .idc/ .idq/ .inc/ + .ini/ .key/ .licx/ .lnk/ .log/ .mdb/ .old/ .pass/ .pdb/ .pol/ .printer/ .pwd/ + .resources/ .resx/ .sql/ .sys/ .vb/ .vbs/ .vbproj/ .vsdisco/ .webinfo/ .xsd/ + .xsx/","allowed_request_content_type":"application/x-www-form-urlencoded|multipart/form-data|text/xml|application/xml|application/soap+xml|application/x-amf|application/json|application/octet-stream|application/csp-report|application/xss-auditor-report|text/plain","allowed_request_content_type_charset":"utf-8|iso-8859-1|iso-8859-15|windows-1252","allowed_http_versions":"HTTP/1.0 + HTTP/1.1 HTTP/2","crs_validate_utf8_encoding":false,"created_at":"2019-12-10T13:16:45Z","updated_at":"2019-12-10T13:16:45Z","active_rules_trustwave_log_count":0,"active_rules_trustwave_block_count":0,"active_rules_fastly_log_count":0,"active_rules_fastly_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_score_count":0},"relationships":{"waf_firewall":{"data":{"id":"7lMzP6tPtmcRNLiiDRrvuE","type":"waf_firewall"}}}}}' + headers: + Accept-Ranges: + - bytes + Content-Length: + - "2094" + Content-Type: + - application/vnd.api+json + Date: + - Tue, 10 Dec 2019 13:16:45 GMT + Status: + - 201 Created + Strict-Transport-Security: + - max-age=31536000 + Via: + - 1.1 varnish + X-Cache: + - MISS, MISS + X-Cache-Hits: + - 0, 0 + X-Content-Type-Options: + - nosniff + X-Served-By: + - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19243-LCY + X-Timer: + - S1575983806.821971,VS0,VE154 + status: 201 Created + code: 201 + duration: "" diff --git a/fastly/waf_version.go b/fastly/waf_version.go index 2ac9e7afe..07973b52a 100644 --- a/fastly/waf_version.go +++ b/fastly/waf_version.go @@ -64,6 +64,7 @@ type WAFVersion struct { ActiveRulesFastlyBlockCount int `jsonapi:"attr,active_rules_fastly_block_count"` ActiveRulesOWASPLogCount int `jsonapi:"attr,active_rules_owasp_log_count"` ActiveRulesOWASPBlockCount int `jsonapi:"attr,active_rules_owasp_block_count"` + ActiveRulesOWASPScoreCount int `jsonapi:"attr,active_rules_owasp_score_count"` } // WAFVersionResponse represents a list WAF versions full response. @@ -374,3 +375,30 @@ func (c *Client) DeployWAFVersion(i *DeployWAFVersionInput) error { } return nil } + +// CreateEmptyWAFVersionInput used as input for creating an empty WAF version. +type CreateEmptyWAFVersionInput struct { + // The Web Application Firewall's ID. + WAFID string +} + +// CreateEmptyWAFVersion creates an empty WAF version, +// which means a version without rules and all config options set to their default values. +func (c *Client) CreateEmptyWAFVersion(i *CreateEmptyWAFVersionInput) (*WAFVersion, error) { + + if i.WAFID == "" { + return nil, ErrMissingWAFID + } + + path := fmt.Sprintf("/waf/firewalls/%s/versions", i.WAFID) + resp, err := c.PostJSONAPI(path, nil, nil) + if err != nil { + return nil, err + } + + var waf WAFVersion + if err := jsonapi.UnmarshalPayload(resp.Body, &waf); err != nil { + return nil, err + } + return &waf, nil +} diff --git a/fastly/waf_version_test.go b/fastly/waf_version_test.go index 4ac35c7e5..5df170f7c 100644 --- a/fastly/waf_version_test.go +++ b/fastly/waf_version_test.go @@ -143,6 +143,19 @@ func TestClient_WAF_Versions(t *testing.T) { if len(wafVerResp.Items) != 2 { t.Errorf("expected 2 waf: got %d", len(wafVerResp.Items)) } + + record(t, fixtureBase+"/create_empty", func(c *Client) { + wafVer, err = c.CreateEmptyWAFVersion(&CreateEmptyWAFVersionInput{ + WAFID: waf.ID, + }) + }) + if err != nil { + t.Fatal(err) + } + if wafVer == nil { + t.Error("expected waf, got nil") + } + verifyEmptyWAFVersion(t, wafVer) } func verifyWAFVersionUpdate(t *testing.T, i *UpdateWAFVersionInput, o *WAFVersion) { @@ -234,7 +247,45 @@ func verifyWAFVersionUpdate(t *testing.T, i *UpdateWAFVersionInput, o *WAFVersio if i.XSSScoreThreshold != o.XSSScoreThreshold { t.Errorf("expected %d waf: got %d", i.XSSScoreThreshold, o.XSSScoreThreshold) } +} + +func verifyEmptyWAFVersion(t *testing.T, o *WAFVersion) { + threshold := 999 + if threshold != o.HTTPViolationScoreThreshold { + t.Errorf("expected %d HTTPViolationScoreThreshold: got %d", threshold, o.HTTPViolationScoreThreshold) + } + if threshold != o.InboundAnomalyScoreThreshold { + t.Errorf("expected %d InboundAnomalyScoreThreshold: got %d", threshold, o.InboundAnomalyScoreThreshold) + } + if threshold != o.InboundAnomalyScoreThreshold { + t.Errorf("expected %d InboundAnomalyScoreThreshold: got %d", threshold, o.InboundAnomalyScoreThreshold) + } + if threshold != o.PHPInjectionScoreThreshold { + t.Errorf("expected %d PHPInjectionScoreThreshold: got %d", threshold, o.PHPInjectionScoreThreshold) + } + if threshold != o.RCEScoreThreshold { + t.Errorf("expected %d RCEScoreThreshold: got %d", threshold, o.RCEScoreThreshold) + } + if threshold != o.RFIScoreThreshold { + t.Errorf("expected %d waf: RFIScoreThreshold %d", threshold, o.RFIScoreThreshold) + } + if threshold != o.SessionFixationScoreThreshold { + t.Errorf("expected %d SessionFixationScoreThreshold: got %d", threshold, o.SessionFixationScoreThreshold) + } + if threshold != o.SQLInjectionScoreThreshold { + t.Errorf("expected %d SQLInjectionScoreThreshold: got %d", threshold, o.SQLInjectionScoreThreshold) + } + if threshold != o.XSSScoreThreshold { + t.Errorf("expected %d XSSScoreThreshold: got %d", threshold, o.XSSScoreThreshold) + } + + totalRules := o.ActiveRulesFastlyBlockCount + o.ActiveRulesFastlyLogCount + o.ActiveRulesOWASPBlockCount + + o.ActiveRulesOWASPLogCount + o.ActiveRulesOWASPScoreCount + o.ActiveRulesTrustwaveBlockCount + o.ActiveRulesTrustwaveLogCount + + if totalRules != 0 { + t.Errorf("expected no active rules rules: got %d", totalRules) + } } func buildUpdateInput() *UpdateWAFVersionInput { @@ -413,3 +464,12 @@ func TestClient_DeployWAFVersion_validation(t *testing.T) { t.Errorf("bad error: %s", err) } } + +func TestClient_CreateEmptyWAFVersion_validation(t *testing.T) { + var err error + if _, err = testClient.CreateEmptyWAFVersion(&CreateEmptyWAFVersionInput{ + WAFID: "", + }); err != ErrMissingWAFID { + t.Errorf("bad error: %s", err) + } +} From 0837bf7a1f0ec0e2575cd342a7e6c98cfd2d9747 Mon Sep 17 00:00:00 2001 From: oscarDovao <31310209+oscarDovao@users.noreply.github.com> Date: Wed, 8 Jan 2020 09:19:28 +0000 Subject: [PATCH 06/37] Waf disable enable (#14) * making WAF enable and disable functions consistent with rest --- fastly/fastly_test.go | 19 ++- fastly/fixtures/wafs/deploy.yaml | 46 +++++++ fastly/fixtures/wafs/disable.yaml | 45 +++++++ fastly/fixtures/wafs/enable.yaml | 45 +++++++ .../wafs/response_object/cleanup_another.yaml | 2 +- .../wafs/response_object/create_another.yaml | 6 +- .../fixtures/wafs/response_object/delete.yaml | 2 +- fastly/fixtures/wafs/update.yaml | 4 +- fastly/waf.go | 50 ++++--- fastly/waf_active_rule_test.go | 2 +- fastly/waf_test.go | 125 ++++++++---------- fastly/waf_version_test.go | 4 +- 12 files changed, 242 insertions(+), 108 deletions(-) create mode 100644 fastly/fixtures/wafs/deploy.yaml create mode 100644 fastly/fixtures/wafs/disable.yaml create mode 100644 fastly/fixtures/wafs/enable.yaml diff --git a/fastly/fastly_test.go b/fastly/fastly_test.go index af09f5482..a094f8392 100644 --- a/fastly/fastly_test.go +++ b/fastly/fastly_test.go @@ -356,7 +356,7 @@ func createTestWAFCondition(t *testing.T, fixture, serviceID, name string, servi return condition } -func deleteTestWAFCondition(t *testing.T, fixture, serviceID, name string, serviceNumber int) { +func deleteTestCondition(t *testing.T, fixture, serviceID, name string, serviceNumber int) { var err error @@ -372,20 +372,17 @@ func deleteTestWAFCondition(t *testing.T, fixture, serviceID, name string, servi } } -func createTestResponseObject(t *testing.T, fixture, serviceID, name string, serviceNumber int) *ResponseObject { +func createTestWAFResponseObject(t *testing.T, fixture, serviceID, name string, serviceNumber int) *ResponseObject { var err error var ro *ResponseObject record(t, fixture, func(c *Client) { ro, err = c.CreateResponseObject(&CreateResponseObjectInput{ - Service: serviceID, - Version: serviceNumber, - Name: name, - Status: 200, - Response: "Ok", - Content: "abcd", - ContentType: "text/plain", + Service: serviceID, + Version: serviceNumber, + Name: name, + Status: 403, }) }) if err != nil { @@ -444,13 +441,13 @@ func deleteWAF(t *testing.T, fixture, WAFID, WAFVersion string) { } } -func deleteTestService(t *testing.T, cleanupFixture string, serviceId string) { +func deleteTestService(t *testing.T, cleanupFixture, serviceID string) { var err error record(t, cleanupFixture, func(client *Client) { err = client.DeleteService(&DeleteServiceInput{ - ID: serviceId, + ID: serviceID, }) }) if err != nil { diff --git a/fastly/fixtures/wafs/deploy.yaml b/fastly/fixtures/wafs/deploy.yaml new file mode 100644 index 000000000..8dc694ae9 --- /dev/null +++ b/fastly/fixtures/wafs/deploy.yaml @@ -0,0 +1,46 @@ +--- +version: 1 +interactions: +- request: + body: | + {"data":{"type":""}} + form: {} + headers: + Accept: + - application/vnd.api+json + Content-Type: + - application/vnd.api+json + User-Agent: + - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) + url: https://api.fastly.com/waf/firewalls/5ui1qC2Y9TZIonO95zU3gM/versions/1 + method: POST + response: + body: '{"errors":[],"data":null}' + headers: + Accept-Ranges: + - bytes + Content-Length: + - "25" + Content-Type: + - application/vnd.api+json + Date: + - Fri, 13 Dec 2019 08:52:53 GMT + Status: + - 202 Accepted + Strict-Transport-Security: + - max-age=31536000 + Via: + - 1.1 varnish + X-Cache: + - MISS, MISS + X-Cache-Hits: + - 0, 0 + X-Content-Type-Options: + - nosniff + X-Served-By: + - cache-control-slwdc9036-CONTROL-SLWDC, cache-lcy19229-LCY + X-Timer: + - S1576227173.880248,VS0,VE137 + status: 202 Accepted + code: 202 + duration: "" diff --git a/fastly/fixtures/wafs/disable.yaml b/fastly/fixtures/wafs/disable.yaml new file mode 100644 index 000000000..22a5c209e --- /dev/null +++ b/fastly/fixtures/wafs/disable.yaml @@ -0,0 +1,45 @@ +--- +version: 1 +interactions: +- request: + body: "" + form: {} + headers: + Accept: + - application/vnd.api+json + Content-Type: + - application/vnd.api+json + User-Agent: + - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) + url: https://api.fastly.com/waf/firewalls/5ui1qC2Y9TZIonO95zU3gM/disable + method: PATCH + response: + body: '{"data":{"id":"5ui1qC2Y9TZIonO95zU3gM","type":"waf_firewall","attributes":{"service_id":"1l9vtYGCa1be9QkG5opE5F","prefetch_condition":null,"response":null,"disabled":true,"service_version_number":null,"created_at":"2019-12-13T08:52:52Z","updated_at":"2019-12-13T08:52:54Z","active_rules_trustwave_log_count":0,"active_rules_trustwave_block_count":0,"active_rules_fastly_log_count":0,"active_rules_fastly_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_score_count":0}}}' + headers: + Accept-Ranges: + - bytes + Content-Length: + - "524" + Content-Type: + - application/vnd.api+json + Date: + - Fri, 13 Dec 2019 08:52:54 GMT + Status: + - 200 OK + Strict-Transport-Security: + - max-age=31536000 + Via: + - 1.1 varnish + X-Cache: + - MISS, MISS + X-Cache-Hits: + - 0, 0 + X-Content-Type-Options: + - nosniff + X-Served-By: + - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19229-LCY + X-Timer: + - S1576227174.900944,VS0,VE671 + status: 200 OK + code: 200 + duration: "" diff --git a/fastly/fixtures/wafs/enable.yaml b/fastly/fixtures/wafs/enable.yaml new file mode 100644 index 000000000..c5d88c2fe --- /dev/null +++ b/fastly/fixtures/wafs/enable.yaml @@ -0,0 +1,45 @@ +--- +version: 1 +interactions: +- request: + body: "" + form: {} + headers: + Accept: + - application/vnd.api+json + Content-Type: + - application/vnd.api+json + User-Agent: + - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) + url: https://api.fastly.com/waf/firewalls/5ui1qC2Y9TZIonO95zU3gM/enable + method: PATCH + response: + body: '{"data":{"id":"5ui1qC2Y9TZIonO95zU3gM","type":"waf_firewall","attributes":{"service_id":"1l9vtYGCa1be9QkG5opE5F","prefetch_condition":null,"response":null,"disabled":false,"service_version_number":null,"created_at":"2019-12-13T08:52:52Z","updated_at":"2019-12-13T08:52:55Z","active_rules_trustwave_log_count":0,"active_rules_trustwave_block_count":0,"active_rules_fastly_log_count":0,"active_rules_fastly_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_score_count":0}}}' + headers: + Accept-Ranges: + - bytes + Content-Length: + - "525" + Content-Type: + - application/vnd.api+json + Date: + - Fri, 13 Dec 2019 08:52:55 GMT + Status: + - 200 OK + Strict-Transport-Security: + - max-age=31536000 + Via: + - 1.1 varnish + X-Cache: + - MISS, MISS + X-Cache-Hits: + - 0, 0 + X-Content-Type-Options: + - nosniff + X-Served-By: + - cache-control-slwdc9036-CONTROL-SLWDC, cache-lcy19229-LCY + X-Timer: + - S1576227175.617161,VS0,VE667 + status: 200 OK + code: 200 + duration: "" diff --git a/fastly/fixtures/wafs/response_object/cleanup_another.yaml b/fastly/fixtures/wafs/response_object/cleanup_another.yaml index a53aa66f6..7e9ff16dc 100644 --- a/fastly/fixtures/wafs/response_object/cleanup_another.yaml +++ b/fastly/fixtures/wafs/response_object/cleanup_another.yaml @@ -7,7 +7,7 @@ interactions: headers: User-Agent: - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) - url: https://api.fastly.com/service/3qt0xLYGlOxt19jpAQ0LJM/version/2/response_object/test-response-object-2 + url: https://api.fastly.com/service/3qt0xLYGlOxt19jpAQ0LJM/version/2/response_object/WAF_Response2 method: DELETE response: body: '{"status":"ok"}' diff --git a/fastly/fixtures/wafs/response_object/create_another.yaml b/fastly/fixtures/wafs/response_object/create_another.yaml index a5fd4ff3b..47d87a3fe 100644 --- a/fastly/fixtures/wafs/response_object/create_another.yaml +++ b/fastly/fixtures/wafs/response_object/create_another.yaml @@ -2,7 +2,7 @@ version: 1 interactions: - request: - body: Service=3qt0xLYGlOxt19jpAQ0LJM&Version=2&content=efgh&content_type=text%2Fplain&name=test-response-object-2&response=Ok&status=200 + body: Service=3qt0xLYGlOxt19jpAQ0LJM&Version=2&content=efgh&content_type=text%2Fplain&name=WAF_Response2&response=Ok&status=200 form: Service: - 3qt0xLYGlOxt19jpAQ0LJM @@ -13,7 +13,7 @@ interactions: content_type: - text/plain name: - - test-response-object-2 + - WAF_Response2 response: - Ok status: @@ -26,7 +26,7 @@ interactions: url: https://api.fastly.com/service/3qt0xLYGlOxt19jpAQ0LJM/version/2/response_object method: POST response: - body: '{"content":"efgh","content_type":"text/plain","name":"test-response-object-2","response":"Ok","status":"200","service_id":"3qt0xLYGlOxt19jpAQ0LJM","version":"2","request_condition":"","updated_at":"2019-11-20T12:59:06Z","deleted_at":null,"created_at":"2019-11-20T12:59:06Z","cache_condition":""}' + body: '{"content":"efgh","content_type":"text/plain","name":"WAF_Response2","response":"Ok","status":"200","service_id":"3qt0xLYGlOxt19jpAQ0LJM","version":"2","request_condition":"","updated_at":"2019-11-20T12:59:06Z","deleted_at":null,"created_at":"2019-11-20T12:59:06Z","cache_condition":""}' headers: Accept-Ranges: - bytes diff --git a/fastly/fixtures/wafs/response_object/delete.yaml b/fastly/fixtures/wafs/response_object/delete.yaml index 9bb9be0fa..560e28be9 100644 --- a/fastly/fixtures/wafs/response_object/delete.yaml +++ b/fastly/fixtures/wafs/response_object/delete.yaml @@ -7,7 +7,7 @@ interactions: headers: User-Agent: - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) - url: https://api.fastly.com/service/3qt0xLYGlOxt19jpAQ0LJM/version/2/response_object/WAf_Response + url: https://api.fastly.com/service/3qt0xLYGlOxt19jpAQ0LJM/version/2/response_object/WAF_Response method: DELETE response: body: '{"status":"ok"}' diff --git a/fastly/fixtures/wafs/update.yaml b/fastly/fixtures/wafs/update.yaml index 7ff51a6e3..0d2e0e503 100644 --- a/fastly/fixtures/wafs/update.yaml +++ b/fastly/fixtures/wafs/update.yaml @@ -3,7 +3,7 @@ version: 1 interactions: - request: body: | - {"data":{"type":"waf_firewall","id":"5ui1qC2Y9TZIonO95zU3gM","attributes":{"prefetch_condition":"","response":"test-response-object-2","service_id":"3qt0xLYGlOxt19jpAQ0LJM","service_version_number":"2"}}} + {"data":{"type":"waf_firewall","id":"5ui1qC2Y9TZIonO95zU3gM","attributes":{"prefetch_condition":"","response":"WAF_Response2","service_id":"3qt0xLYGlOxt19jpAQ0LJM","service_version_number":"2"}}} form: {} headers: Accept: @@ -15,7 +15,7 @@ interactions: url: https://api.fastly.com/waf/firewalls/5ui1qC2Y9TZIonO95zU3gM method: PATCH response: - body: '{"data":{"id":"5ui1qC2Y9TZIonO95zU3gM","type":"waf_firewall","attributes":{"service_id":"3qt0xLYGlOxt19jpAQ0LJM","prefetch_condition":"","response":"test-response-object-2","disabled":false,"service_version_number":2,"created_at":"2019-11-20T12:59:05Z","updated_at":"2019-11-20T12:59:05Z","active_rules_trustwave_log_count":0,"active_rules_trustwave_block_count":0,"active_rules_fastly_log_count":0,"active_rules_fastly_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_score_count":0}},"meta":{"warnings":[{"title":"This + body: '{"data":{"id":"5ui1qC2Y9TZIonO95zU3gM","type":"waf_firewall","attributes":{"service_id":"3qt0xLYGlOxt19jpAQ0LJM","prefetch_condition":"","response":"WAF_Response2","disabled":false,"service_version_number":2,"created_at":"2019-11-20T12:59:05Z","updated_at":"2019-11-20T12:59:05Z","active_rules_trustwave_log_count":0,"active_rules_trustwave_block_count":0,"active_rules_fastly_log_count":0,"active_rules_fastly_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_score_count":0}},"meta":{"warnings":[{"title":"This version of this service must be active","detail":"You may only update the WAF VCL on an active version of a service. The version 2 of service 3qt0xLYGlOxt19jpAQ0LJM is not active. You may activate it through https://app.fastly.com or through diff --git a/fastly/waf.go b/fastly/waf.go index a6c43e4bf..7bfe25968 100644 --- a/fastly/waf.go +++ b/fastly/waf.go @@ -166,7 +166,7 @@ type GetWAFInput struct { // version. Both fields are required. Service string Version string - // ID is the id of the WAF to get. + // ID is the WAF's ID. ID string } @@ -239,44 +239,56 @@ func (c *Client) UpdateWAF(i *UpdateWAFInput) (*WAF, error) { return &waf, nil } -// EnableWAF updates a specific WAF. -func (c *Client) EnableWAF(id string) error { +// EnableWAFInput is used as input to the EnableWAF function. +type EnableWAFInput struct { + // ID is the WAF's ID. + ID string +} - if id == "" { - return ErrMissingWAFID +// EnableWAF enables a specific WAF. +func (c *Client) EnableWAF(i *EnableWAFInput) (*WAF, error) { + + if i.ID == "" { + return nil, ErrMissingWAFID } - path := fmt.Sprintf("/waf/firewalls/%s/enable", id) - resp, err := c.PatchJSONAPI(path, &UpdateWAFInput{}, nil) + path := fmt.Sprintf("/waf/firewalls/%s/enable", i.ID) + resp, err := c.PatchJSONAPI(path, nil, nil) if err != nil { - return err + return nil, err } var waf WAF if err := jsonapi.UnmarshalPayload(resp.Body, &waf); err != nil { - return err + return nil, err } - return nil + return &waf, nil } -// DisableWAF disables a WAF. -func (c *Client) DisableWAF(id string) error { +// DisableWAFInput is used as input to the DisableWAF function. +type DisableWAFInput struct { + // ID is the WAF's ID. + ID string +} - if id == "" { - return ErrMissingWAFID +// DisableWAF disables a specific WAF. +func (c *Client) DisableWAF(i *DisableWAFInput) (*WAF, error) { + + if i.ID == "" { + return nil, ErrMissingWAFID } - path := fmt.Sprintf("/waf/firewalls/%s/disable", id) - resp, err := c.PatchJSONAPI(path, &UpdateWAFInput{}, nil) + path := fmt.Sprintf("/waf/firewalls/%s/disable", i.ID) + resp, err := c.PatchJSONAPI(path, nil, nil) if err != nil { - return err + return nil, err } var waf WAF if err := jsonapi.UnmarshalPayload(resp.Body, &waf); err != nil { - return err + return nil, err } - return nil + return &waf, nil } // DeleteWAFInput is used as input to the DeleteWAFInput function. diff --git a/fastly/waf_active_rule_test.go b/fastly/waf_active_rule_test.go index a5be00851..35cf0be01 100644 --- a/fastly/waf_active_rule_test.go +++ b/fastly/waf_active_rule_test.go @@ -22,7 +22,7 @@ func TestClient_WAF_Active_Rules(t *testing.T) { createTestWAFCondition(t, fixtureBase+"/condition/create", testService.ID, prefetch, tv.Number) responseName := "WAf_Response" - createTestResponseObject(t, fixtureBase+"/response_object/create", testService.ID, responseName, tv.Number) + createTestWAFResponseObject(t, fixtureBase+"/response_object/create", testService.ID, responseName, tv.Number) waf := createWAF(t, fixtureBase+"/waf/create", testService.ID, strconv.Itoa(tv.Number), prefetch, responseName) defer deleteWAF(t, fixtureBase+"/waf/delete", waf.ID, "1") diff --git a/fastly/waf_test.go b/fastly/waf_test.go index 40ed8579a..40580cfe2 100644 --- a/fastly/waf_test.go +++ b/fastly/waf_test.go @@ -20,12 +20,16 @@ func TestClient_WAFs(t *testing.T) { prefetch := "WAF_Prefetch" condition := createTestWAFCondition(t, fixtureBase+"/condition/create", testService.ID, prefetch, tv.Number) - defer deleteTestWAFCondition(t, fixtureBase+"/condition/delete", testService.ID, prefetch, tv.Number) + defer deleteTestCondition(t, fixtureBase+"/condition/delete", testService.ID, prefetch, tv.Number) - responseName := "WAf_Response" - ro := createTestResponseObject(t, fixtureBase+"/response_object/create", testService.ID, responseName, tv.Number) + responseName := "WAF_Response" + ro := createTestWAFResponseObject(t, fixtureBase+"/response_object/create", testService.ID, responseName, tv.Number) defer deleteTestResponseObject(t, fixtureBase+"/response_object/delete", testService.ID, responseName, tv.Number) + responseName2 := "WAF_Response2" + nro := createTestWAFResponseObject(t, fixtureBase+"/response_object/create_another", testService.ID, responseName2, tv.Number) + defer deleteTestResponseObject(t, fixtureBase+"/response_object/cleanup_another", testService.ID, responseName2, tv.Number) + var err error var waf *WAF record(t, fixtureBase+"/create", func(c *Client) { @@ -65,6 +69,16 @@ func TestClient_WAFs(t *testing.T) { }) }() + record(t, fixtureBase+"/deploy", func(c *Client) { + err = c.DeployWAFVersion(&DeployWAFVersionInput{ + WAFID: waf.ID, + WAFVersionNumber: 1, + }) + }) + if err != nil { + t.Fatal(err) + } + // Get var nwaf *WAF record(t, fixtureBase+"/get", func(c *Client) { @@ -80,57 +94,10 @@ func TestClient_WAFs(t *testing.T) { if nwaf.ID != waf.ID { t.Errorf("expected %q to be %q", nwaf.ID, waf.ID) } - - // Get the WAF ruleset - var ruleset *Ruleset - record(t, "wafs/ruleset/get", func(c *Client) { - ruleset, err = c.GetWAFRuleRuleSets(&GetWAFRuleRuleSetsInput{ - Service: testServiceID, - ID: waf.ID, - }) - }) - if err != nil { - t.Fatal(err) - } - if ruleset.ID != waf.ID { - t.Errorf("expected %q to be %q", ruleset.ID, waf.ID) - } - if ruleset.VCL == "" { - t.Error("bad vcl") - } - if ruleset.LastPush != waf.LastPush { - t.Errorf("expected %q to be %q", ruleset.LastPush, waf.LastPush) - } - if ruleset.Link != "" { - t.Error("bad link") + if nwaf.Disabled { + t.Errorf("expected disabled false, got : %v", nwaf.Disabled) } - // Update - // Create a new response object to attach - var nro *ResponseObject - record(t, fixtureBase+"/response_object/create_another", func(c *Client) { - nro, err = c.CreateResponseObject(&CreateResponseObjectInput{ - Service: testService.ID, - Version: tv.Number, - Name: "test-response-object-2", - Status: 200, - Response: "Ok", - Content: "efgh", - ContentType: "text/plain", - }) - }) - if err != nil { - t.Fatal(err) - } - defer func() { - record(t, fixtureBase+"/response_object/cleanup_another", func(c *Client) { - c.DeleteResponseObject(&DeleteResponseObjectInput{ - Service: testService.ID, - Version: tv.Number, - Name: nro.Name, - }) - }) - }() var uwaf *WAF record(t, fixtureBase+"/update", func(c *Client) { uwaf, err = c.UpdateWAF(&UpdateWAFInput{ @@ -143,32 +110,34 @@ func TestClient_WAFs(t *testing.T) { if err != nil { t.Fatal(err) } - if uwaf.Response != "test-response-object-2" { + if uwaf.Response != responseName2 { t.Errorf("bad name: %q", uwaf.Response) } - // Update the WAF ruleset - var uRuleset *Ruleset - record(t, "wafs/ruleset/patch", func(c *Client) { - uRuleset, err = c.UpdateWAFRuleSets(&UpdateWAFRuleRuleSetsInput{ - Service: testServiceID, - ID: uwaf.ID, + var dwaf *WAF + record(t, fixtureBase+"/disable", func(c *Client) { + dwaf, err = c.DisableWAF(&DisableWAFInput{ + ID: waf.ID, }) }) if err != nil { t.Fatal(err) } - if uRuleset.ID != uwaf.ID { - t.Errorf("expected %q to be %q", uRuleset.ID, uwaf.ID) + if !dwaf.Disabled { + t.Errorf("expected disabled true, got : %v", dwaf.Disabled) } - if uRuleset.VCL != "" { - t.Error("bad vcl") - } - if uRuleset.LastPush != nil { - t.Error("bad last_push") + + var ewaf *WAF + record(t, fixtureBase+"/enable", func(c *Client) { + ewaf, err = c.EnableWAF(&EnableWAFInput{ + ID: waf.ID, + }) + }) + if err != nil { + t.Fatal(err) } - if uRuleset.Link == "" { - t.Error("bad link") + if ewaf.Disabled { + t.Errorf("expected disabled false, got : %v", ewaf.Disabled) } // Delete @@ -272,6 +241,26 @@ func TestClient_DeleteWAF_validation(t *testing.T) { } } +func TestClient_EnableWAF_validation(t *testing.T) { + var err error + _, err = testClient.EnableWAF(&EnableWAFInput{ + ID: "", + }) + if err != ErrMissingWAFID { + t.Errorf("bad error: %s", err) + } +} + +func TestClient_DisableWAF_validation(t *testing.T) { + var err error + _, err = testClient.DisableWAF(&DisableWAFInput{ + ID: "", + }) + if err != ErrMissingWAFID { + t.Errorf("bad error: %s", err) + } +} + func TestClient_listWAFs_formatFilters(t *testing.T) { cases := []struct { remote *ListWAFsInput diff --git a/fastly/waf_version_test.go b/fastly/waf_version_test.go index 5df170f7c..9a9796131 100644 --- a/fastly/waf_version_test.go +++ b/fastly/waf_version_test.go @@ -21,10 +21,10 @@ func TestClient_WAF_Versions(t *testing.T) { prefetch := "WAF_Prefetch" condition := createTestWAFCondition(t, fixtureBase+"/condition/create", testService.ID, prefetch, tv.Number) - defer deleteTestWAFCondition(t, fixtureBase+"/condition/delete", testService.ID, prefetch, tv.Number) + defer deleteTestCondition(t, fixtureBase+"/condition/delete", testService.ID, prefetch, tv.Number) responseName := "WAf_Response" - ro := createTestResponseObject(t, fixtureBase+"/response_object/create", testService.ID, responseName, tv.Number) + ro := createTestWAFResponseObject(t, fixtureBase+"/response_object/create", testService.ID, responseName, tv.Number) defer deleteTestResponseObject(t, fixtureBase+"/response_object/delete", testService.ID, responseName, tv.Number) var err error From d770ecb3fcc1fea945bad70d8ea9720cc4fa5714 Mon Sep 17 00:00:00 2001 From: Oscar Date: Fri, 20 Dec 2019 16:59:10 +0000 Subject: [PATCH 07/37] introducing a maximum batch size exclusive for WAF requests --- fastly/waf_version.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/fastly/waf_version.go b/fastly/waf_version.go index 07973b52a..cdee63f97 100644 --- a/fastly/waf_version.go +++ b/fastly/waf_version.go @@ -15,8 +15,13 @@ import ( // decoding into. var WAFVersionType = reflect.TypeOf(new(WAFVersion)) -// WAFPaginationPageSize used as the default pagination page size by the WAF related requests. -const WAFPaginationPageSize = 100 +const ( + // WAFPaginationPageSize is used as the default pagination page size by the WAF related requests. + WAFPaginationPageSize = 100 + + // WAFBatchModifyMaximumOperations is used as the default batch maximum operations. + WAFBatchModifyMaximumOperations = 500 +) // WAFVersion is the information about a WAF version object. type WAFVersion struct { From e0fd4bae57dad8cbad5b9c1c71ed5f4f47710f83 Mon Sep 17 00:00:00 2001 From: oscarDovao <31310209+oscarDovao@users.noreply.github.com> Date: Wed, 22 Jan 2020 17:04:39 +0000 Subject: [PATCH 08/37] Waf resource import (#17) * Introducing waf version struct method to check for custom emptiness * Using pointers on the WAf version update endpoint --- fastly/waf_version.go | 86 ++++++++------ fastly/waf_version_test.go | 238 ++++++++++++++++++++++--------------- 2 files changed, 191 insertions(+), 133 deletions(-) diff --git a/fastly/waf_version.go b/fastly/waf_version.go index cdee63f97..3fca53b35 100644 --- a/fastly/waf_version.go +++ b/fastly/waf_version.go @@ -226,60 +226,72 @@ func (c *Client) GetWAFVersion(i *GetWAFVersionInput) (*WAFVersion, error) { return &wafVer, nil } -// UpdateWAFVersionInput is used as input to the UpdateWAFVersion function. +// UpdateWAFVersionInput is used as input to the UpdateWAFVersion function. This struct uses pointers due to the problem +// detailed on this issue https://github.com/opencredo/go-fastly/pull/17. type UpdateWAFVersionInput struct { // The Web Application Firewall's ID. - WAFID string + WAFID *string // The Web Application Firewall's version number. - WAFVersionNumber int + WAFVersionNumber *int // The Web Application Firewall's version ID. - WAFVersionID string `jsonapi:"primary,waf_firewall"` - Comment string `jsonapi:"attr,comment,omitempty"` - CRSValidateUTF8Encoding bool `jsonapi:"attr,crs_validate_utf8_encoding,omitempty"` - AllowedHTTPVersions string `jsonapi:"attr,allowed_http_versions,omitempty"` - AllowedMethods string `jsonapi:"attr,allowed_methods,omitempty"` - AllowedRequestContentType string `jsonapi:"attr,allowed_request_content_type,omitempty"` - AllowedRequestContentTypeCharset string `jsonapi:"attr,allowed_request_content_type_charset,omitempty"` - HighRiskCountryCodes string `jsonapi:"attr,high_risk_country_codes,omitempty"` - RestrictedExtensions string `jsonapi:"attr,restricted_extensions,omitempty"` - RestrictedHeaders string `jsonapi:"attr,restricted_headers,omitempty"` - ArgLength int `jsonapi:"attr,arg_length,omitempty"` - ArgNameLength int `jsonapi:"attr,arg_name_length,omitempty"` - CombinedFileSizes int `jsonapi:"attr,combined_file_sizes,omitempty"` - CriticalAnomalyScore int `jsonapi:"attr,critical_anomaly_score,omitempty"` - ErrorAnomalyScore int `jsonapi:"attr,error_anomaly_score,omitempty"` - HTTPViolationScoreThreshold int `jsonapi:"attr,http_violation_score_threshold,omitempty"` - InboundAnomalyScoreThreshold int `jsonapi:"attr,inbound_anomaly_score_threshold,omitempty"` - LFIScoreThreshold int `jsonapi:"attr,lfi_score_threshold,omitempty"` - MaxFileSize int `jsonapi:"attr,max_file_size,omitempty"` - MaxNumArgs int `jsonapi:"attr,max_num_args,omitempty"` - NoticeAnomalyScore int `jsonapi:"attr,notice_anomaly_score,omitempty"` - ParanoiaLevel int `jsonapi:"attr,paranoia_level,omitempty"` - PHPInjectionScoreThreshold int `jsonapi:"attr,php_injection_score_threshold,omitempty"` - RCEScoreThreshold int `jsonapi:"attr,rce_score_threshold,omitempty"` - RFIScoreThreshold int `jsonapi:"attr,rfi_score_threshold,omitempty"` - SessionFixationScoreThreshold int `jsonapi:"attr,session_fixation_score_threshold,omitempty"` - SQLInjectionScoreThreshold int `jsonapi:"attr,sql_injection_score_threshold,omitempty"` - TotalArgLength int `jsonapi:"attr,total_arg_length,omitempty"` - WarningAnomalyScore int `jsonapi:"attr,warning_anomaly_score,omitempty"` - XSSScoreThreshold int `jsonapi:"attr,xss_score_threshold,omitempty"` + WAFVersionID *string `jsonapi:"primary,waf_firewall_version"` + Comment *string `jsonapi:"attr,comment,omitempty"` + CRSValidateUTF8Encoding *bool `jsonapi:"attr,crs_validate_utf8_encoding,omitempty"` + AllowedHTTPVersions *string `jsonapi:"attr,allowed_http_versions,omitempty"` + AllowedMethods *string `jsonapi:"attr,allowed_methods,omitempty"` + AllowedRequestContentType *string `jsonapi:"attr,allowed_request_content_type,omitempty"` + AllowedRequestContentTypeCharset *string `jsonapi:"attr,allowed_request_content_type_charset,omitempty"` + HighRiskCountryCodes *string `jsonapi:"attr,high_risk_country_codes,omitempty"` + RestrictedExtensions *string `jsonapi:"attr,restricted_extensions,omitempty"` + RestrictedHeaders *string `jsonapi:"attr,restricted_headers,omitempty"` + ArgLength *int `jsonapi:"attr,arg_length,omitempty"` + ArgNameLength *int `jsonapi:"attr,arg_name_length,omitempty"` + CombinedFileSizes *int `jsonapi:"attr,combined_file_sizes,omitempty"` + CriticalAnomalyScore *int `jsonapi:"attr,critical_anomaly_score,omitempty"` + ErrorAnomalyScore *int `jsonapi:"attr,error_anomaly_score,omitempty"` + HTTPViolationScoreThreshold *int `jsonapi:"attr,http_violation_score_threshold,omitempty"` + InboundAnomalyScoreThreshold *int `jsonapi:"attr,inbound_anomaly_score_threshold,omitempty"` + LFIScoreThreshold *int `jsonapi:"attr,lfi_score_threshold,omitempty"` + MaxFileSize *int `jsonapi:"attr,max_file_size,omitempty"` + MaxNumArgs *int `jsonapi:"attr,max_num_args,omitempty"` + NoticeAnomalyScore *int `jsonapi:"attr,notice_anomaly_score,omitempty"` + ParanoiaLevel *int `jsonapi:"attr,paranoia_level,omitempty"` + PHPInjectionScoreThreshold *int `jsonapi:"attr,php_injection_score_threshold,omitempty"` + RCEScoreThreshold *int `jsonapi:"attr,rce_score_threshold,omitempty"` + RFIScoreThreshold *int `jsonapi:"attr,rfi_score_threshold,omitempty"` + SessionFixationScoreThreshold *int `jsonapi:"attr,session_fixation_score_threshold,omitempty"` + SQLInjectionScoreThreshold *int `jsonapi:"attr,sql_injection_score_threshold,omitempty"` + TotalArgLength *int `jsonapi:"attr,total_arg_length,omitempty"` + WarningAnomalyScore *int `jsonapi:"attr,warning_anomaly_score,omitempty"` + XSSScoreThreshold *int `jsonapi:"attr,xss_score_threshold,omitempty"` +} + +// HasChanges checks that UpdateWAFVersionInput has changed in terms of configuration, which means - if it has configuration fields populated. +// if UpdateWAFVersionInput is updated to have a slice this method will not longer work as it is. +// if a slice is introduced the "!=" must be replaced with !DeepEquals +func (i UpdateWAFVersionInput) HasChanges() bool { + return i != UpdateWAFVersionInput{ + WAFID: i.WAFID, + WAFVersionNumber: i.WAFVersionNumber, + WAFVersionID: i.WAFVersionID, + } } // UpdateWAFVersion updates a specific WAF version. func (c *Client) UpdateWAFVersion(i *UpdateWAFVersionInput) (*WAFVersion, error) { - if i.WAFID == "" { + if i.WAFID == nil || *i.WAFID == "" { return nil, ErrMissingWAFID } - if i.WAFVersionNumber == 0 { + if i.WAFVersionNumber == nil || *i.WAFVersionNumber == 0 { return nil, ErrMissingWAFVersionNumber } - if i.WAFVersionID == "" { + if i.WAFVersionID == nil || *i.WAFVersionID == "" { return nil, ErrMissingWAFVersionID } - path := fmt.Sprintf("/waf/firewalls/%s/versions/%d", i.WAFID, i.WAFVersionNumber) + path := fmt.Sprintf("/waf/firewalls/%s/versions/%d", *i.WAFID, *i.WAFVersionNumber) resp, err := c.PatchJSONAPI(path, i, nil) if err != nil { return nil, err diff --git a/fastly/waf_version_test.go b/fastly/waf_version_test.go index 9a9796131..2591ff919 100644 --- a/fastly/waf_version_test.go +++ b/fastly/waf_version_test.go @@ -102,9 +102,9 @@ func TestClient_WAF_Versions(t *testing.T) { } input := buildUpdateInput() - input.WAFID = waf.ID - input.WAFVersionNumber = 2 - input.WAFVersionID = wafVer.ID + input.WAFID = &waf.ID + input.WAFVersionNumber = intToPtr(2) + input.WAFVersionID = &wafVer.ID record(t, fixtureBase+"/update", func(c *Client) { wafVer, err = c.UpdateWAFVersion(input) }) @@ -160,92 +160,92 @@ func TestClient_WAF_Versions(t *testing.T) { func verifyWAFVersionUpdate(t *testing.T, i *UpdateWAFVersionInput, o *WAFVersion) { - if i.WAFVersionID != o.ID { - t.Errorf("expected %s waf: got %s", i.WAFVersionID, o.ID) + if *i.WAFVersionID != o.ID { + t.Errorf("expected %s waf: got %s", *i.WAFVersionID, o.ID) } - if i.AllowedHTTPVersions != o.AllowedHTTPVersions { - t.Errorf("expected %s waf: got %s", i.AllowedHTTPVersions, o.AllowedHTTPVersions) + if *i.AllowedHTTPVersions != o.AllowedHTTPVersions { + t.Errorf("expected %s waf: got %s", *i.AllowedHTTPVersions, o.AllowedHTTPVersions) } - if i.AllowedMethods != o.AllowedMethods { - t.Errorf("expected %s waf: got %s", i.AllowedMethods, o.AllowedMethods) + if *i.AllowedMethods != o.AllowedMethods { + t.Errorf("expected %s waf: got %s", *i.AllowedMethods, o.AllowedMethods) } - if i.AllowedRequestContentType != o.AllowedRequestContentType { - t.Errorf("expected %s waf: got %s", i.AllowedRequestContentType, o.AllowedRequestContentType) + if *i.AllowedRequestContentType != o.AllowedRequestContentType { + t.Errorf("expected %s waf: got %s", *i.AllowedRequestContentType, o.AllowedRequestContentType) } - if i.AllowedRequestContentTypeCharset != o.AllowedRequestContentTypeCharset { - t.Errorf("expected %s waf: got %s", i.AllowedRequestContentTypeCharset, o.AllowedRequestContentTypeCharset) + if *i.AllowedRequestContentTypeCharset != o.AllowedRequestContentTypeCharset { + t.Errorf("expected %s waf: got %s", *i.AllowedRequestContentTypeCharset, o.AllowedRequestContentTypeCharset) } - if i.ArgLength != o.ArgLength { - t.Errorf("expected %d waf: got %d", i.ArgLength, o.ArgLength) + if *i.ArgLength != o.ArgLength { + t.Errorf("expected %d waf: got %d", *i.ArgLength, o.ArgLength) } - if i.ArgNameLength != o.ArgNameLength { - t.Errorf("expected %d waf: got %d", i.ArgNameLength, o.ArgNameLength) + if *i.ArgNameLength != o.ArgNameLength { + t.Errorf("expected %d waf: got %d", *i.ArgNameLength, o.ArgNameLength) } - if i.CombinedFileSizes != o.CombinedFileSizes { - t.Errorf("expected %d waf: got %d", i.CombinedFileSizes, o.CombinedFileSizes) + if *i.CombinedFileSizes != o.CombinedFileSizes { + t.Errorf("expected %d waf: got %d", *i.CombinedFileSizes, o.CombinedFileSizes) } - if i.CriticalAnomalyScore != o.CriticalAnomalyScore { - t.Errorf("expected %d waf: got %d", i.CriticalAnomalyScore, o.CriticalAnomalyScore) + if *i.CriticalAnomalyScore != o.CriticalAnomalyScore { + t.Errorf("expected %d waf: got %d", *i.CriticalAnomalyScore, o.CriticalAnomalyScore) } - if i.CRSValidateUTF8Encoding != o.CRSValidateUTF8Encoding { - t.Errorf("expected %v waf: got %v", i.CRSValidateUTF8Encoding, o.CRSValidateUTF8Encoding) + if *i.CRSValidateUTF8Encoding != o.CRSValidateUTF8Encoding { + t.Errorf("expected %v waf: got %v", *i.CRSValidateUTF8Encoding, o.CRSValidateUTF8Encoding) } - if i.ErrorAnomalyScore != o.ErrorAnomalyScore { - t.Errorf("expected %d waf: got %d", i.ErrorAnomalyScore, o.ErrorAnomalyScore) + if *i.ErrorAnomalyScore != o.ErrorAnomalyScore { + t.Errorf("expected %d waf: got %d", *i.ErrorAnomalyScore, o.ErrorAnomalyScore) } - if i.HighRiskCountryCodes != o.HighRiskCountryCodes { - t.Errorf("expected %s waf: got %s", i.HighRiskCountryCodes, o.HighRiskCountryCodes) + if *i.HighRiskCountryCodes != o.HighRiskCountryCodes { + t.Errorf("expected %s waf: got %s", *i.HighRiskCountryCodes, o.HighRiskCountryCodes) } - if i.HTTPViolationScoreThreshold != o.HTTPViolationScoreThreshold { - t.Errorf("expected %d waf: got %d", i.HTTPViolationScoreThreshold, o.HTTPViolationScoreThreshold) + if *i.HTTPViolationScoreThreshold != o.HTTPViolationScoreThreshold { + t.Errorf("expected %d waf: got %d", *i.HTTPViolationScoreThreshold, o.HTTPViolationScoreThreshold) } - if i.InboundAnomalyScoreThreshold != o.InboundAnomalyScoreThreshold { - t.Errorf("expected %d waf: got %d", i.InboundAnomalyScoreThreshold, o.InboundAnomalyScoreThreshold) + if *i.InboundAnomalyScoreThreshold != o.InboundAnomalyScoreThreshold { + t.Errorf("expected %d waf: got %d", *i.InboundAnomalyScoreThreshold, o.InboundAnomalyScoreThreshold) } - if i.LFIScoreThreshold != o.LFIScoreThreshold { - t.Errorf("expected %d waf: got %d", i.LFIScoreThreshold, o.LFIScoreThreshold) + if *i.LFIScoreThreshold != o.LFIScoreThreshold { + t.Errorf("expected %d waf: got %d", *i.LFIScoreThreshold, o.LFIScoreThreshold) } - if i.MaxFileSize != o.MaxFileSize { - t.Errorf("expected %d waf: got %d", i.MaxFileSize, o.MaxFileSize) + if *i.MaxFileSize != o.MaxFileSize { + t.Errorf("expected %d waf: got %d", *i.MaxFileSize, o.MaxFileSize) } - if i.MaxNumArgs != o.MaxNumArgs { - t.Errorf("expected %d waf: got %d", i.MaxNumArgs, o.MaxNumArgs) + if *i.MaxNumArgs != o.MaxNumArgs { + t.Errorf("expected %d waf: got %d", *i.MaxNumArgs, o.MaxNumArgs) } - if i.NoticeAnomalyScore != o.NoticeAnomalyScore { - t.Errorf("expected %d waf: got %d", i.NoticeAnomalyScore, o.NoticeAnomalyScore) + if *i.NoticeAnomalyScore != o.NoticeAnomalyScore { + t.Errorf("expected %d waf: got %d", *i.NoticeAnomalyScore, o.NoticeAnomalyScore) } - if i.ParanoiaLevel != o.ParanoiaLevel { - t.Errorf("expected %d waf: got %d", i.ParanoiaLevel, o.ParanoiaLevel) + if *i.ParanoiaLevel != o.ParanoiaLevel { + t.Errorf("expected %d waf: got %d", *i.ParanoiaLevel, o.ParanoiaLevel) } - if i.PHPInjectionScoreThreshold != o.PHPInjectionScoreThreshold { - t.Errorf("expected %d waf: got %d", i.PHPInjectionScoreThreshold, o.PHPInjectionScoreThreshold) + if *i.PHPInjectionScoreThreshold != o.PHPInjectionScoreThreshold { + t.Errorf("expected %d waf: got %d", *i.PHPInjectionScoreThreshold, o.PHPInjectionScoreThreshold) } - if i.RCEScoreThreshold != o.RCEScoreThreshold { - t.Errorf("expected %d waf: got %d", i.RCEScoreThreshold, o.RCEScoreThreshold) + if *i.RCEScoreThreshold != o.RCEScoreThreshold { + t.Errorf("expected %d waf: got %d", *i.RCEScoreThreshold, o.RCEScoreThreshold) } - if i.RestrictedExtensions != o.RestrictedExtensions { - t.Errorf("expected %s waf: got %s", i.RestrictedExtensions, o.RestrictedExtensions) + if *i.RestrictedExtensions != o.RestrictedExtensions { + t.Errorf("expected %s waf: got %s", *i.RestrictedExtensions, o.RestrictedExtensions) } - if i.RestrictedHeaders != o.RestrictedHeaders { - t.Errorf("expected %s waf: got %s", i.RestrictedHeaders, o.RestrictedHeaders) + if *i.RestrictedHeaders != o.RestrictedHeaders { + t.Errorf("expected %s waf: got %s", *i.RestrictedHeaders, o.RestrictedHeaders) } - if i.RFIScoreThreshold != o.RFIScoreThreshold { - t.Errorf("expected %d waf: got %d", i.RFIScoreThreshold, o.RFIScoreThreshold) + if *i.RFIScoreThreshold != o.RFIScoreThreshold { + t.Errorf("expected %d waf: got %d", *i.RFIScoreThreshold, o.RFIScoreThreshold) } - if i.SessionFixationScoreThreshold != o.SessionFixationScoreThreshold { - t.Errorf("expected %d waf: got %d", i.SessionFixationScoreThreshold, o.SessionFixationScoreThreshold) + if *i.SessionFixationScoreThreshold != o.SessionFixationScoreThreshold { + t.Errorf("expected %d waf: got %d", *i.SessionFixationScoreThreshold, o.SessionFixationScoreThreshold) } - if i.SQLInjectionScoreThreshold != o.SQLInjectionScoreThreshold { - t.Errorf("expected %d waf: got %d", i.SQLInjectionScoreThreshold, o.SQLInjectionScoreThreshold) + if *i.SQLInjectionScoreThreshold != o.SQLInjectionScoreThreshold { + t.Errorf("expected %d waf: got %d", *i.SQLInjectionScoreThreshold, o.SQLInjectionScoreThreshold) } - if i.TotalArgLength != o.TotalArgLength { - t.Errorf("expected %d waf: got %d", i.TotalArgLength, o.TotalArgLength) + if *i.TotalArgLength != o.TotalArgLength { + t.Errorf("expected %d waf: got %d", *i.TotalArgLength, o.TotalArgLength) } - if i.WarningAnomalyScore != o.WarningAnomalyScore { - t.Errorf("expected %d waf: got %d", i.WarningAnomalyScore, o.WarningAnomalyScore) + if *i.WarningAnomalyScore != o.WarningAnomalyScore { + t.Errorf("expected %d waf: got %d", *i.WarningAnomalyScore, o.WarningAnomalyScore) } - if i.XSSScoreThreshold != o.XSSScoreThreshold { - t.Errorf("expected %d waf: got %d", i.XSSScoreThreshold, o.XSSScoreThreshold) + if *i.XSSScoreThreshold != o.XSSScoreThreshold { + t.Errorf("expected %d waf: got %d", *i.XSSScoreThreshold, o.XSSScoreThreshold) } } @@ -290,35 +290,35 @@ func verifyEmptyWAFVersion(t *testing.T, o *WAFVersion) { func buildUpdateInput() *UpdateWAFVersionInput { return &UpdateWAFVersionInput{ - Comment: "my comment", - AllowedHTTPVersions: "HTTP/1.0 HTTP/1.1", - AllowedMethods: "GET HEAD POST", - AllowedRequestContentType: "application/x-www-form-urlencoded|multipart/form-data|text/xml|application/xml", - AllowedRequestContentTypeCharset: "utf-8|iso-8859-1", - ArgLength: 800, - ArgNameLength: 200, - CombinedFileSizes: 20000000, - CriticalAnomalyScore: 12, - CRSValidateUTF8Encoding: true, - ErrorAnomalyScore: 10, - HighRiskCountryCodes: "gb", - HTTPViolationScoreThreshold: 20, - InboundAnomalyScoreThreshold: 20, - LFIScoreThreshold: 20, - MaxFileSize: 20000000, - MaxNumArgs: 510, - NoticeAnomalyScore: 8, - ParanoiaLevel: 2, - PHPInjectionScoreThreshold: 20, - RCEScoreThreshold: 20, - RestrictedExtensions: ".asa/ .asax/ .ascx/ .axd/ .backup/ .bak/ .bat/ .cdx/ .cer/ .cfg/ .cmd/ .com/", - RestrictedHeaders: "/proxy/ /lock-token/", - RFIScoreThreshold: 20, - SessionFixationScoreThreshold: 20, - SQLInjectionScoreThreshold: 20, - TotalArgLength: 12800, - WarningAnomalyScore: 20, - XSSScoreThreshold: 20, + Comment: strToPtr("my comment"), + AllowedHTTPVersions: strToPtr("HTTP/1.0 HTTP/1.1"), + AllowedMethods: strToPtr("GET HEAD POST"), + AllowedRequestContentType: strToPtr("application/x-www-form-urlencoded|multipart/form-data|text/xml|application/xml"), + AllowedRequestContentTypeCharset: strToPtr("utf-8|iso-8859-1"), + ArgLength: intToPtr(800), + ArgNameLength: intToPtr(200), + CombinedFileSizes: intToPtr(20000000), + CriticalAnomalyScore: intToPtr(12), + CRSValidateUTF8Encoding: boolToPtr(true), + ErrorAnomalyScore: intToPtr(10), + HighRiskCountryCodes: strToPtr("gb"), + HTTPViolationScoreThreshold: intToPtr(20), + InboundAnomalyScoreThreshold: intToPtr(20), + LFIScoreThreshold: intToPtr(20), + MaxFileSize: intToPtr(20000000), + MaxNumArgs: intToPtr(510), + NoticeAnomalyScore: intToPtr(8), + ParanoiaLevel: intToPtr(2), + PHPInjectionScoreThreshold: intToPtr(20), + RCEScoreThreshold: intToPtr(20), + RestrictedExtensions: strToPtr(".asa/ .asax/ .ascx/ .axd/ .backup/ .bak/ .bat/ .cdx/ .cer/ .cfg/ .cmd/ .com/"), + RestrictedHeaders: strToPtr("/proxy/ /lock-token/"), + RFIScoreThreshold: intToPtr(20), + SessionFixationScoreThreshold: intToPtr(20), + SQLInjectionScoreThreshold: intToPtr(20), + TotalArgLength: intToPtr(12800), + WarningAnomalyScore: intToPtr(20), + XSSScoreThreshold: intToPtr(20), } } @@ -389,24 +389,24 @@ func TestClient_GetWAFVersion_validation(t *testing.T) { func TestClient_UpdateWAFVersion_validation(t *testing.T) { var err error _, err = testClient.UpdateWAFVersion(&UpdateWAFVersionInput{ - WAFID: "", + WAFID: strToPtr(""), }) if err != ErrMissingWAFID { t.Errorf("bad error: %s", err) } _, err = testClient.UpdateWAFVersion(&UpdateWAFVersionInput{ - WAFID: "1", - WAFVersionNumber: 0, + WAFID: strToPtr("1"), + WAFVersionNumber: intToPtr(0), }) if err != ErrMissingWAFVersionNumber { t.Errorf("bad error: %s", err) } _, err = testClient.UpdateWAFVersion(&UpdateWAFVersionInput{ - WAFID: "1", - WAFVersionNumber: 1, - WAFVersionID: "", + WAFID: strToPtr("1"), + WAFVersionNumber: intToPtr(1), + WAFVersionID: strToPtr(""), }) if err != ErrMissingWAFVersionID { t.Errorf("bad error: %s", err) @@ -465,6 +465,38 @@ func TestClient_DeployWAFVersion_validation(t *testing.T) { } } +func TestClient_UpdateWAFVersionInput_HasChanges(t *testing.T) { + + cases := []struct { + in UpdateWAFVersionInput + out bool + }{ + { + in: UpdateWAFVersionInput{ + WAFID: strToPtr("ID"), + WAFVersionNumber: intToPtr(1), + WAFVersionID: strToPtr("versionID"), + }, + out: false, + }, + { + in: UpdateWAFVersionInput{ + WAFID: strToPtr("ID"), + WAFVersionNumber: intToPtr(1), + WAFVersionID: strToPtr("versionID"), + AllowedMethods: strToPtr("any"), + }, + out: true, + }, + } + for _, c := range cases { + empty := c.in.HasChanges() + if empty != c.out { + t.Fatalf("Error matching:\nexpected: %#v\n got: %#v", c.out, empty) + } + } +} + func TestClient_CreateEmptyWAFVersion_validation(t *testing.T) { var err error if _, err = testClient.CreateEmptyWAFVersion(&CreateEmptyWAFVersionInput{ @@ -473,3 +505,17 @@ func TestClient_CreateEmptyWAFVersion_validation(t *testing.T) { t.Errorf("bad error: %s", err) } } + +func strToPtr(s string) *string { + return &s +} + +func intToPtr(i int) *int { + return &i +} + +func boolToPtr(i bool) *bool { + return &i +} + + From 4f7a5476ba08501c492485b2258f278f937a7200 Mon Sep 17 00:00:00 2001 From: oscarDovao <31310209+oscarDovao@users.noreply.github.com> Date: Tue, 28 Jan 2020 15:11:47 +0000 Subject: [PATCH 09/37] Cleaning up the old API remaining code (#18) --- fastly/waf.go | 815 --------------------------------------------- fastly/waf_test.go | 199 ----------- 2 files changed, 1014 deletions(-) diff --git a/fastly/waf.go b/fastly/waf.go index 7bfe25968..b9bd95135 100644 --- a/fastly/waf.go +++ b/fastly/waf.go @@ -6,10 +6,8 @@ import ( "fmt" "io" "io/ioutil" - "net/http" "reflect" "strconv" - "strings" "time" "github.com/google/jsonapi" @@ -315,531 +313,6 @@ func (c *Client) DeleteWAF(i *DeleteWAFInput) error { return err } -// OWASP is the information about an OWASP object. -type OWASP struct { - ID string `jsonapi:"primary,owasp"` - AllowedHTTPVersions string `jsonapi:"attr,allowed_http_versions"` - AllowedMethods string `jsonapi:"attr,allowed_methods"` - AllowedRequestContentType string `jsonapi:"attr,allowed_request_content_type"` - AllowedRequestContentTypeCharset string `jsonapi:"attr,allowed_request_content_type_charset"` - ArgLength int `jsonapi:"attr,arg_length"` - ArgNameLength int `jsonapi:"attr,arg_name_length"` - CombinedFileSizes int `jsonapi:"attr,combined_file_sizes"` - CreatedAt *time.Time `jsonapi:"attr,created_at,iso8601"` - CriticalAnomalyScore int `jsonapi:"attr,critical_anomaly_score"` - CRSValidateUTF8Encoding bool `jsonapi:"attr,crs_validate_utf8_encoding"` - ErrorAnomalyScore int `jsonapi:"attr,error_anomaly_score"` - HighRiskCountryCodes string `jsonapi:"attr,high_risk_country_codes"` - HTTPViolationScoreThreshold int `jsonapi:"attr,http_violation_score_threshold"` - InboundAnomalyScoreThreshold int `jsonapi:"attr,inbound_anomaly_score_threshold"` - LFIScoreThreshold int `jsonapi:"attr,lfi_score_threshold"` - MaxFileSize int `jsonapi:"attr,max_file_size"` - MaxNumArgs int `jsonapi:"attr,max_num_args"` - NoticeAnomalyScore int `jsonapi:"attr,notice_anomaly_score"` - ParanoiaLevel int `jsonapi:"attr,paranoia_level"` - PHPInjectionScoreThreshold int `jsonapi:"attr,php_injection_score_threshold"` - RCEScoreThreshold int `jsonapi:"attr,rce_score_threshold"` - RestrictedExtensions string `jsonapi:"attr,restricted_extensions"` - RestrictedHeaders string `jsonapi:"attr,restricted_headers"` - RFIScoreThreshold int `jsonapi:"attr,rfi_score_threshold"` - SessionFixationScoreThreshold int `jsonapi:"attr,session_fixation_score_threshold"` - SQLInjectionScoreThreshold int `jsonapi:"attr,sql_injection_score_threshold"` - TotalArgLength int `jsonapi:"attr,total_arg_length"` - UpdatedAt *time.Time `jsonapi:"attr,updated_at,iso8601"` - WarningAnomalyScore int `jsonapi:"attr,warning_anomaly_score"` - XSSScoreThreshold int `jsonapi:"attr,xss_score_threshold"` -} - -// GetOWASPInput is used as input to the GetOWASP function. -type GetOWASPInput struct { - // Service is the ID of the service. ID is the ID of the firewall. - // Both fields are required. - Service string - ID string -} - -// GetOWASP gets OWASP settings for a service firewall object. -func (c *Client) GetOWASP(i *GetOWASPInput) (*OWASP, error) { - if i.Service == "" { - return nil, ErrMissingService - } - - if i.ID == "" { - return nil, ErrMissingWAFID - } - - path := fmt.Sprintf("/service/%s/wafs/%s/owasp", i.Service, i.ID) - - resp, err := c.Get(path, nil) - if err != nil { - return nil, err - } - - var owasp OWASP - if err := jsonapi.UnmarshalPayload(resp.Body, &owasp); err != nil { - return nil, err - } - return &owasp, nil -} - -// CreateOWASPInput is used as input to the CreateOWASP function. -type CreateOWASPInput struct { - // Service is the ID of the service. ID is the ID of the firewall. - // Both fields are required. - Service string - ID string `jsonapi:"primary,owasp"` - Type string `jsonapi:"attr,type"` -} - -// CreateOWASP creates an OWASP settings object for a service firewall object. -func (c *Client) CreateOWASP(i *CreateOWASPInput) (*OWASP, error) { - if i.Service == "" { - return nil, ErrMissingService - } - - if i.ID == "" { - return nil, ErrMissingWAFID - } - - path := fmt.Sprintf("/service/%s/wafs/%s/owasp", i.Service, i.ID) - resp, err := c.PostJSONAPI(path, i, nil) - if err != nil { - return nil, err - } - - var owasp OWASP - if err := jsonapi.UnmarshalPayload(resp.Body, &owasp); err != nil { - return nil, err - } - return &owasp, nil -} - -// UpdateOWASPInput is used as input to the CreateOWASP function. -type UpdateOWASPInput struct { - // Service is the ID of the service. ID is the ID of the firewall. - // Both fields are required. - Service string - ID string - OWASPID string `jsonapi:"primary,owasp,omitempty"` - - Type string `jsonapi:"attr,type"` - AllowedHTTPVersions string `jsonapi:"attr,allowed_http_versions,omitempty"` - AllowedMethods string `jsonapi:"attr,allowed_methods,omitempty"` - AllowedRequestContentType string `jsonapi:"attr,allowed_request_content_type,omitempty"` - AllowedRequestContentTypeCharset string `jsonapi:"attr,allowed_request_content_type_charset,omitempty"` - ArgLength int `jsonapi:"attr,arg_length,omitempty"` - ArgNameLength int `jsonapi:"attr,arg_name_length,omitempty"` - CombinedFileSizes int `jsonapi:"attr,combined_file_sizes,omitempty"` - CreatedAt *time.Time `jsonapi:"attr,created_at,omitempty,iso8601"` - CriticalAnomalyScore int `jsonapi:"attr,critical_anomaly_score,omitempty"` - CRSValidateUTF8Encoding bool `jsonapi:"attr,crs_validate_utf8_encoding,omitempty"` - ErrorAnomalyScore int `jsonapi:"attr,error_anomaly_score,omitempty"` - HighRiskCountryCodes string `jsonapi:"attr,high_risk_country_codes,omitempty"` - HTTPViolationScoreThreshold int `jsonapi:"attr,http_violation_score_threshold,omitempty"` - InboundAnomalyScoreThreshold int `jsonapi:"attr,inbound_anomaly_score_threshold,omitempty"` - LFIScoreThreshold int `jsonapi:"attr,lfi_score_threshold,omitempty"` - MaxFileSize int `jsonapi:"attr,max_file_size,omitempty"` - MaxNumArgs int `jsonapi:"attr,max_num_args,omitempty"` - NoticeAnomalyScore int `jsonapi:"attr,notice_anomaly_score,omitempty"` - ParanoiaLevel int `jsonapi:"attr,paranoia_level,omitempty"` - PHPInjectionScoreThreshold int `jsonapi:"attr,php_injection_score_threshold,omitempty"` - RCEScoreThreshold int `jsonapi:"attr,rce_score_threshold,omitempty"` - RestrictedExtensions string `jsonapi:"attr,restricted_extensions,omitempty"` - RestrictedHeaders string `jsonapi:"attr,restricted_headers,omitempty"` - RFIScoreThreshold int `jsonapi:"attr,rfi_score_threshold,omitempty"` - SessionFixationScoreThreshold int `jsonapi:"attr,session_fixation_score_threshold,omitempty"` - SQLInjectionScoreThreshold int `jsonapi:"attr,sql_injection_score_threshold,omitempty"` - TotalArgLength int `jsonapi:"attr,total_arg_length,omitempty"` - UpdatedAt *time.Time `jsonapi:"attr,updated_at,omitempty,iso8601"` - WarningAnomalyScore int `jsonapi:"attr,warning_anomaly_score,omitempty"` - XSSScoreThreshold int `jsonapi:"attr,xss_score_threshold,omitempty"` -} - -// CreateOWASP creates an OWASP settings object for a service firewall object. -func (c *Client) UpdateOWASP(i *UpdateOWASPInput) (*OWASP, error) { - if i.Service == "" { - return nil, ErrMissingService - } - - if i.ID == "" { - return nil, ErrMissingWAFID - } - - if i.OWASPID == "" { - return nil, ErrMissingOWASPID - } - - path := fmt.Sprintf("/service/%s/wafs/%s/owasp", i.Service, i.ID) - resp, err := c.PatchJSONAPI(path, i, nil) - if err != nil { - return nil, err - } - - var owasp OWASP - if err := jsonapi.UnmarshalPayload(resp.Body, &owasp); err != nil { - return nil, err - } - return &owasp, nil -} - -// Rule is the information about a WAF rule. -type Rule struct { - ID string `jsonapi:"primary,rule"` - RuleID string `jsonapi:"attr,rule_id,omitempty"` - Severity int `jsonapi:"attr,severity,omitempty"` - Message string `jsonapi:"attr,message,omitempty"` -} - -// rulesType is used for reflection because JSONAPI wants to know what it's -// decoding into. -var rulesType = reflect.TypeOf(new(Rule)) - -// GetRules returns the list of wafs for the configuration version. -func (c *Client) GetRules() ([]*Rule, error) { - var path = "/wafs/rules" - resp, err := c.Get(path, nil) - if err != nil { - return nil, err - } - - data, err := jsonapi.UnmarshalManyPayload(resp.Body, rulesType) - if err != nil { - return nil, err - } - - rules := make([]*Rule, len(data)) - for i := range data { - typed, ok := data[i].(*Rule) - if !ok { - return nil, fmt.Errorf("got back a non-Rules response") - } - rules[i] = typed - } - - return rules, nil -} - -// GetRuleVCLInput is used as input to the GetRuleVCL function. -type GetRuleInput struct { - // RuleID is the ID of the rule and is required. - RuleID string -} - -// GetRule gets a Rule using the Rule ID. -func (c *Client) GetRule(i *GetRuleInput) (*Rule, error) { - if i.RuleID == "" { - return nil, ErrMissingRuleID - } - - path := fmt.Sprintf("/wafs/rules/%s", i.RuleID) - resp, err := c.Get(path, nil) - if err != nil { - return nil, err - } - - var rule Rule - if err := jsonapi.UnmarshalPayload(resp.Body, &rule); err != nil { - return nil, err - } - return &rule, nil -} - -// RuleVCL is the information about a Rule's VCL. -type RuleVCL struct { - ID string `jsonapi:"primary,rule_vcl"` - VCL string `jsonapi:"attr,vcl,omitempty"` -} - -// GetRuleVCL gets the VCL for a Rule. -func (c *Client) GetRuleVCL(i *GetRuleInput) (*RuleVCL, error) { - if i.RuleID == "" { - return nil, ErrMissingRuleID - } - - path := fmt.Sprintf("/wafs/rules/%s/vcl", i.RuleID) - resp, err := c.Get(path, nil) - if err != nil { - return nil, err - } - - var vcl RuleVCL - if err := jsonapi.UnmarshalPayload(resp.Body, &vcl); err != nil { - return nil, err - } - return &vcl, nil -} - -// GetWAFRuleVCLInput is used as input to the GetWAFRuleVCL function. -type GetWAFRuleVCLInput struct { - // ID is the ID of the firewall. RuleID is the ID of the rule. - // Both are required. - ID string - RuleID string -} - -// GetWAFRuleVCL gets the VCL for a role associated with a firewall WAF. -func (c *Client) GetWAFRuleVCL(i *GetWAFRuleVCLInput) (*RuleVCL, error) { - if i.ID == "" { - return nil, ErrMissingWAFID - } - - if i.RuleID == "" { - return nil, ErrMissingRuleID - } - - path := fmt.Sprintf("/wafs/%s/rules/%s/vcl", i.ID, i.RuleID) - resp, err := c.Get(path, nil) - if err != nil { - return nil, err - } - - var vcl RuleVCL - if err := jsonapi.UnmarshalPayload(resp.Body, &vcl); err != nil { - return nil, err - } - return &vcl, nil -} - -// Ruleset is the information about a firewall object's ruleset. -type Ruleset struct { - ID string `jsonapi:"primary,ruleset"` - VCL string `jsonapi:"attr,vcl,omitempty"` - LastPush *time.Time `jsonapi:"attr,last_push,omitempty,iso8601"` - Link string -} - -// GetWAFRuleRuleSetsInput is used as input to the GetWAFRuleRuleSets function. -type GetWAFRuleRuleSetsInput struct { - // Service is the ID of the service. ID is the ID of the firewall. - // Both fields are required. - Service string - ID string -} - -// GetWAFRuleRuleSets gets the VCL for rulesets associated with a firewall WAF. -func (c *Client) GetWAFRuleRuleSets(i *GetWAFRuleRuleSetsInput) (*Ruleset, error) { - if i.Service == "" { - return nil, ErrMissingService - } - - if i.ID == "" { - return nil, ErrMissingWAFID - } - - path := fmt.Sprintf("/service/%s/wafs/%s/ruleset", i.Service, i.ID) - resp, err := c.Get(path, nil) - if err != nil { - return nil, err - } - - var ruleset Ruleset - if err := jsonapi.UnmarshalPayload(resp.Body, &ruleset); err != nil { - return nil, err - } - return &ruleset, nil -} - -// UpdateWAFRuleRuleSetsInput is used as input to the UpdateWAFRuleSets function. -type UpdateWAFRuleRuleSetsInput struct { - // Service is the ID of the service. ID is the ID of the firewall. - // Both fields are required. - Service string - ID string `jsonapi:"primary,ruleset"` -} - -// UpdateWAFRuleSets updates the rulesets for a role associated with a firewall WAF. -func (c *Client) UpdateWAFRuleSets(i *UpdateWAFRuleRuleSetsInput) (*Ruleset, error) { - if i.Service == "" { - return nil, ErrMissingService - } - - if i.ID == "" { - return nil, ErrMissingWAFID - } - - path := fmt.Sprintf("/service/%s/wafs/%s/ruleset", i.Service, i.ID) - resp, err := c.PatchJSONAPI(path, i, nil) - if err != nil { - return nil, err - } - - interimRuleset := struct { - Data struct { - ID string `json:"id"` - Type string `json:"type"` - } `json:"data"` - Links struct { - Related struct { - Href string `json:"href"` - } `json:"related"` - } `json:"links"` - }{} - if err = json.NewDecoder(resp.Body).Decode(&interimRuleset); err != nil { - return nil, err - } - - var ruleset Ruleset - if interimRuleset.Data.ID != "" { - ruleset.ID = interimRuleset.Data.ID - } - if interimRuleset.Links.Related.Href != "" { - ruleset.Link = interimRuleset.Links.Related.Href - } - - return &ruleset, nil -} - -// GetWAFRuleStatusesInput specifies the parameters for the GetWAFRuleStatuses call -type GetWAFRuleStatusesInput struct { - Service string - WAF string - Filters GetWAFRuleStatusesFilters -} - -// WAFRuleStatus stores the information about a rule received from Fastly -type WAFRuleStatus struct { - ID string `jsonapi:"primary,rule_status"` // This is the ID of the status, not the ID of the rule. Currently, it is of the format ${WAF_ID}-${rule_ID}, if you want to infer those based on this field. - Status string `jsonapi:"attr,status"` - - Tag string `jsonapi:"attr,name,omitempty"` // This will only be set in a response for modifying rules based on tag. - - // HACK: These two fields are supposed to be sent in response - // to requests for rule status data, but the entire "Relationships" - // field is currently missing from Fastly responses, so they are - // instead inferred from the status ID (see inferIDs method). - // WAF newTypeThatDoesntExistNow `jsonapi:"relation,waf"` - // Rule newTypeThatDoesntExistNow `jsonapi:"relation,rule"` -} - -// GetWAFRuleStatusesFilters provides a set of parameters for filtering the -// results of the call to get the rules associated with a WAF. -type GetWAFRuleStatusesFilters struct { - Status string - Accuracy int - Maturity int - Message string - Revision int - RuleID string - TagID int // Filter by a single tag ID. - TagName string // Filter by single tag name. - Version string - Tags []int // Return all rules with any of the specified tag IDs. - MaxResults int // Max number of returned results per request. - Page int // Which page of results to return. -} - -// formatFilters converts user input into query parameters for filtering -// Fastly results for rules in a WAF. -func (i *GetWAFRuleStatusesInput) formatFilters() map[string]string { - input := i.Filters - result := map[string]string{} - pairings := map[string]interface{}{ - "filter[status]": input.Status, - "filter[rule][accuracy]": input.Accuracy, - "filter[rule][maturity]": input.Maturity, - "filter[rule][message]": input.Message, - "filter[rule][revision]": input.Revision, - "filter[rule][rule_id]": input.RuleID, - "filter[rule][tags]": input.TagID, - "filter[rule][tags][name]": input.TagName, - "filter[rule][version]": input.Version, - "include": input.Tags, - "page[size]": input.MaxResults, - "page[number]": input.Page, // starts at 1, not 0 - } - // NOTE: This setup means we will not be able to send the zero value - // of any of these filters. It doesn't appear we would need to at present. - for key, value := range pairings { - switch t := reflect.TypeOf(value).String(); t { - case "string": - if value != "" { - result[key] = value.(string) - } - case "int": - if value != 0 { - result[key] = strconv.Itoa(value.(int)) - } - case "[]int": - // convert ints to strings - toStrings := []string{} - values := value.([]int) - for _, i := range values { - toStrings = append(toStrings, strconv.Itoa(i)) - } - // concat strings - if len(values) > 0 { - result[key] = strings.Join(toStrings, ",") - } - } - } - return result -} - -// GetWAFRuleStatuses fetches the status of a subset of rules associated with a WAF. -func (c *Client) GetWAFRuleStatuses(i *GetWAFRuleStatusesInput) (GetWAFRuleStatusesResponse, error) { - statusResponse := GetWAFRuleStatusesResponse{Rules: []*WAFRuleStatus{}} - if i.Service == "" { - return statusResponse, ErrMissingService - } - if i.WAF == "" { - return statusResponse, ErrMissingWAFID - } - - path := fmt.Sprintf("/service/%s/wafs/%s/rule_statuses", i.Service, i.WAF) - filters := &RequestOptions{Params: i.formatFilters()} - - resp, err := c.Get(path, filters) - if err != nil { - return statusResponse, err - } - err = c.interpretWAFRuleStatusesPage(&statusResponse, resp) - // NOTE: It's possible for statusResponse to be partially completed before an error - // was encountered, so the presence of a statusResponse doesn't preclude the presence of - // an error. - return statusResponse, err -} - -// interpretWAFRuleStatusesPage accepts a Fastly response for a set of WAF rule statuses -// and unmarshals the results. If there are more pages of results, it fetches the next -// page, adds that response to the array of results, and repeats until all results have -// been fetched. -func (c *Client) interpretWAFRuleStatusesPage(answer *GetWAFRuleStatusesResponse, received *http.Response) error { - // before we pull the status info out of the response body, fetch - // pagination info from it: - pages, body, err := getPages(received.Body) - if err != nil { - return err - } - data, err := jsonapi.UnmarshalManyPayload(body, reflect.TypeOf(new(WAFRuleStatus))) - if err != nil { - return err - } - - for i := range data { - typed, ok := data[i].(*WAFRuleStatus) - if !ok { - return fmt.Errorf("got back response of unexpected type") - } - answer.Rules = append(answer.Rules, typed) - } - if pages.Next != "" { - // NOTE: pages.Next URL includes filters already - resp, err := c.SimpleGet(pages.Next) - if err != nil { - return err - } - c.interpretWAFRuleStatusesPage(answer, resp) - } - return nil -} - -// linksResponse is used to pull the "Links" pagination fields from -// a call to Fastly; these are excluded from the results of the jsonapi -// call to `UnmarshalManyPayload()`, so we have to fetch them separately. -type linksResponse struct { - Links paginationInfo `json:"links"` -} - // infoResponse is used to pull the links and meta from the result. type infoResponse struct { Links paginationInfo `json:"links"` @@ -854,11 +327,6 @@ type paginationInfo struct { Next string `json:"next,omitempty"` } -// GetWAFRuleStatusesResponse is the data returned to the user from a GetWAFRuleStatus call -type GetWAFRuleStatusesResponse struct { - Rules []*WAFRuleStatus -} - // metaInfo stores information about the result returned by the server. type metaInfo struct { CurrentPage int `json:"current_page,omitempty"` @@ -867,23 +335,6 @@ type metaInfo struct { TotalPages int `json:"total_pages,omitempty"` } -// getPages parses a response to get the pagination data without destroying -// the reader we receive as "resp.Body"; this essentially copies resp.Body -// and returns it so we can use it again. -func getPages(body io.Reader) (paginationInfo, io.Reader, error) { - var buf bytes.Buffer - tee := io.TeeReader(body, &buf) - - bodyBytes, err := ioutil.ReadAll(tee) - if err != nil { - return paginationInfo{}, nil, err - } - - var pages linksResponse - json.Unmarshal(bodyBytes, &pages) - return pages.Links, bytes.NewReader(buf.Bytes()), nil -} - // getResponseInfo parses a response to get the pagination and metadata info. func getResponseInfo(body io.Reader) (infoResponse, error) { @@ -897,270 +348,4 @@ func getResponseInfo(body io.Reader) (infoResponse, error) { return infoResponse{}, err } return info, nil - -} - -// GetWAFRuleStatusInput specifies the parameters for the GetWAFRuleStatus call. -type GetWAFRuleStatusInput struct { - ID int - Service string - WAF string -} - -// GetWAFRuleStatus fetches the status of a single rule associated with a WAF. -func (c *Client) GetWAFRuleStatus(i *GetWAFRuleStatusInput) (WAFRuleStatus, error) { - if i.ID == 0 { - return WAFRuleStatus{}, ErrMissingRuleID - } - if i.Service == "" { - return WAFRuleStatus{}, ErrMissingService - } - if i.WAF == "" { - return WAFRuleStatus{}, ErrMissingWAFID - } - - path := fmt.Sprintf("/service/%s/wafs/%s/rules/%d/rule_status", i.Service, i.WAF, i.ID) - resp, err := c.Get(path, nil) - if err != nil { - return WAFRuleStatus{}, err - } - - var status WAFRuleStatus - err = jsonapi.UnmarshalPayload(resp.Body, &status) - return status, err -} - -// UpdateWAFRuleStatusInput specifies the parameters for the UpdateWAFRuleStatus call. -type UpdateWAFRuleStatusInput struct { - ID string `jsonapi:"primary,rule_status"` // The ID of the rule status. Currently in the format ${WAF_ID}-${rule_ID}. - RuleID int - Service string - WAF string - Status string `jsonapi:"attr,status"` -} - -// validate makes sure the UpdateWAFRuleStatusInput instance has all -// fields we need to request a change. -func (i UpdateWAFRuleStatusInput) validate() error { - if i.ID == "" { - return ErrMissingID - } - if i.RuleID == 0 { - return ErrMissingRuleID - } - if i.Service == "" { - return ErrMissingService - } - if i.WAF == "" { - return ErrMissingWAFID - } - if i.Status == "" { - return ErrMissingStatus - } - return nil -} - -// UpdateWAFRuleStatus changes the status of a single rule associated with a WAF. -func (c *Client) UpdateWAFRuleStatus(i *UpdateWAFRuleStatusInput) (WAFRuleStatus, error) { - if err := i.validate(); err != nil { - return WAFRuleStatus{}, err - } - - path := fmt.Sprintf("/service/%s/wafs/%s/rules/%d/rule_status", i.Service, i.WAF, i.RuleID) - - var buf bytes.Buffer - err := jsonapi.MarshalPayload(&buf, i) - if err != nil { - return WAFRuleStatus{}, err - } - - options := &RequestOptions{ - Body: &buf, - Headers: map[string]string{ - "Content-Type": jsonapi.MediaType, - "Accept": jsonapi.MediaType, - }, - } - - resp, err := c.Patch(path, options) - if err != nil { - return WAFRuleStatus{}, err - } - - var status WAFRuleStatus - err = jsonapi.UnmarshalPayload(resp.Body, &status) - return status, err -} - -// UpdateWAFRuleTagStatusInput specifies the parameters for the UpdateWAFRuleStatus call. -type UpdateWAFRuleTagStatusInput struct { - Service string - WAF string - Status string `json:"status"` // `jsonapi:"attr,status"` - Tag string `json:"name"` // `jsonapi:"attr,name"` - Force bool `json:"force"` // `jsonapi:"attr,force"` - // HACK: This won't work with the jsonapi struct tags, because the POST body expected by - // Fastly doesn't conform to the jsonapi spec -- there's no ID field at the top level, - // and there's no way for us to indicate the "type" of the entity without a primary key. - // ID field is required: http://jsonapi.org/format/#document-resource-objects -} - -// updateWAFRuleTagStatusBody is the top-level object sent to Fastly based on -// UpdateWAFRuleTagStatusInput from the user. -type updateWAFRuleTagStatusBody struct { - Data updateWAFRuleTagStatusData `json:"data"` -} - -type updateWAFRuleTagStatusData struct { - Type string `json:"type"` // hard-coded because we can't use jsonapi - Attributes *UpdateWAFRuleTagStatusInput `json:"attributes"` // supplied by user as input -} - -// validate makes sure the UpdateWAFRuleStatusInput instance has all -// fields we need to request a change. Almost, but not quite, identical to -// UpdateWAFRuleStatusInput.validate() -func (i UpdateWAFRuleTagStatusInput) validate() error { - if i.Tag == "" { - return ErrMissingTag - } - if i.Service == "" { - return ErrMissingService - } - if i.WAF == "" { - return ErrMissingWAFID - } - if i.Status == "" { - return ErrMissingStatus - } - return nil -} - -// UpdateWAFRuleTagStatus changes the status of a single rule associated with a WAF. -// NOTE: This call currently appears to return *all* rules attached to the WAF, rather -// than just the ones that were modified by the call. -func (c *Client) UpdateWAFRuleTagStatus(input *UpdateWAFRuleTagStatusInput) (GetWAFRuleStatusesResponse, error) { - if err := input.validate(); err != nil { - return GetWAFRuleStatusesResponse{}, err - } - - path := fmt.Sprintf("/service/%s/wafs/%s/rule_statuses", input.Service, input.WAF) - - body := updateWAFRuleTagStatusBody{ - Data: updateWAFRuleTagStatusData{ - Type: "rule_status", - Attributes: input, - }, - } - encoded, err := json.Marshal(body) - if err != nil { - return GetWAFRuleStatusesResponse{}, err - } - - options := &RequestOptions{ - Body: bytes.NewReader(encoded), - Headers: map[string]string{ - "Content-Type": jsonapi.MediaType, - "Accept": jsonapi.MediaType, - }, - } - - resp, err := c.Post(path, options) - if err != nil { - return GetWAFRuleStatusesResponse{}, err - } - - statusResponse := GetWAFRuleStatusesResponse{Rules: []*WAFRuleStatus{}} - err = c.interpretWAFRuleStatusesPage(&statusResponse, resp) - - return statusResponse, err -} - -// UpdateWAFConfigSetInput is used as input to the UpdateWAFConfigSet function. -type UpdateWAFConfigSetInput struct { - WAFList []ConfigSetWAFs - ConfigSetID string -} - -// ConfigSetWAFs used to store the ID of a WAF needed to update config set relationships -type ConfigSetWAFs struct { - ID string `jsonapi:"primary,waf"` -} - -// UpdateWAFConfigSetResponse stores the list of WAFs returned from the call to update its config set -type UpdateWAFConfigSetResponse struct { - IDs []ConfigSetWAFs `jsonapi:"primary,waf"` -} - -// UpdateWAFConfigSet updates a list of WAFs with the given configset -func (c *Client) UpdateWAFConfigSet(i *UpdateWAFConfigSetInput) (UpdateWAFConfigSetResponse, error) { - if err := i.validate(); err != nil { - return UpdateWAFConfigSetResponse{}, err - } - var wafs []interface{} - for _, w := range i.WAFList { - wafs = append(wafs, &w) - } - - path := fmt.Sprintf("/wafs/configuration_sets/%s/relationships/wafs", i.ConfigSetID) - resp, err := c.PatchJSONAPI(path, wafs, nil) - if err != nil { - return UpdateWAFConfigSetResponse{}, err - } - - wafConfigSetResponse := UpdateWAFConfigSetResponse{} - - err = c.interpretWAFCongfigSetResponse(&wafConfigSetResponse, resp) - if err != nil { - return UpdateWAFConfigSetResponse{}, err - } - - return wafConfigSetResponse, nil -} - -// validate makes sure the UpdateWAFConfigSetInput instance has all -// fields we need to assign the config set to the WAF(s) -func (i UpdateWAFConfigSetInput) validate() error { - if i.ConfigSetID == "" { - return ErrMissingConfigSetID - } - - if len(i.WAFList) == 0 { - return ErrMissingWAFList - } - - return nil -} - -// interpretWAFCongfigSetResponse accepts a Fastly response containing a set of WAF ID's that -// where given to associate with the config set and unmarshals the results. -// If there are more pages of results, it fetches the next -// page, adds that response to the array of results, and repeats until all results have -// been fetched. -func (c *Client) interpretWAFCongfigSetResponse(answer *UpdateWAFConfigSetResponse, received *http.Response) error { - pages, body, err := getPages(received.Body) - if err != nil { - return err - } - data, err := jsonapi.UnmarshalManyPayload(body, reflect.TypeOf([]ConfigSetWAFs{})) - if err != nil { - return err - } - - for i := range data { - typed, ok := data[i].(*ConfigSetWAFs) - if !ok { - return fmt.Errorf("got back response of unexpected type") - } - answer.IDs = append(answer.IDs, *typed) - } - - if pages.Next != "" { - resp, err := c.SimpleGet(pages.Next) - if err != nil { - return err - } - c.interpretWAFCongfigSetResponse(answer, resp) - } - - return nil } diff --git a/fastly/waf_test.go b/fastly/waf_test.go index 40580cfe2..82fe2319c 100644 --- a/fastly/waf_test.go +++ b/fastly/waf_test.go @@ -1,8 +1,6 @@ package fastly import ( - "bytes" - "io/ioutil" "reflect" "strconv" "testing" @@ -300,200 +298,3 @@ func TestClient_listWAFs_formatFilters(t *testing.T) { } } } - -func TestUpdateWAFRuleStatusesInput_validate(t *testing.T) { - tests := []struct { - description string - input UpdateWAFRuleStatusInput - expected error - }{ - { - description: "Accepts valid input", - input: UpdateWAFRuleStatusInput{ - ID: "as098k-8104", - RuleID: 8104, - Service: "108asj1", - WAF: "as098k", - Status: "block", - }, - expected: nil, - }, - { - description: "Rejects input with missing int field", - input: UpdateWAFRuleStatusInput{ - ID: "as098k-8104", - Service: "108asj1", - WAF: "as098k", - Status: "block", - }, - expected: ErrMissingRuleID, - }, - { - description: "Rejects input with missing string field", - input: UpdateWAFRuleStatusInput{ - ID: "as098k-8104", - RuleID: 8104, - WAF: "as098k", - Status: "block", - }, - expected: ErrMissingService, - }, - } - for _, testcase := range tests { - err := testcase.input.validate() - if err != testcase.expected { - t.Errorf("In test %s: Expected %v,got %v", testcase.description, testcase.expected, err) - } - } -} - -func TestUpdateWAFRuleTagStatusInput_validate(t *testing.T) { - tests := []struct { - description string - input UpdateWAFRuleTagStatusInput - expected error - }{ - { - description: "Accepts valid input", - input: UpdateWAFRuleTagStatusInput{ - Tag: "lala tag la", - Service: "108asj1", - WAF: "as098k", - Status: "block", - }, - expected: nil, - }, - { - description: "Rejects input with missing string field", - input: UpdateWAFRuleTagStatusInput{ - Service: "108asj1", - WAF: "as098k", - Status: "block", - }, - expected: ErrMissingTag, - }, - } - for _, testcase := range tests { - err := testcase.input.validate() - if err != testcase.expected { - t.Errorf("In test %s: Expected %v,got %v", testcase.description, testcase.expected, err) - } - } -} - -func TestGetWAFRuleStatusesInput_formatFilters(t *testing.T) { - tests := []struct { - description string - filters GetWAFRuleStatusesFilters - expected map[string]string - }{ - { - description: "converts both strings and ints to strings", - filters: GetWAFRuleStatusesFilters{ - Status: "log", - Accuracy: 10, - Version: "180ad", - }, - expected: map[string]string{ - "filter[status]": "log", - "filter[rule][accuracy]": "10", - "filter[rule][version]": "180ad", - }, - }, - { - description: "converts arrays to strings", - filters: GetWAFRuleStatusesFilters{ - Status: "log", - Version: "181ad", - Tags: []int{18, 1, 1093, 86308}, - }, - expected: map[string]string{ - "filter[status]": "log", - "filter[rule][version]": "181ad", - "include": "18,1,1093,86308", - }, - }, - } - for _, testcase := range tests { - input := GetWAFRuleStatusesInput{ - Filters: testcase.filters, - } - answer := input.formatFilters() - if len(answer) != len(testcase.expected) { - t.Errorf("In test %s: Expected map with %d entries,got one with %d", testcase.description, len(testcase.expected), len(answer)) - } - for key, value := range testcase.expected { - if answer[key] != value { - t.Errorf("In test %s: Expected %s key to have value %s, got %s", testcase.description, key, value, answer[key]) - } - } - } -} - -func TestGetPages(t *testing.T) { - tests := []struct { - description string - input string - expectedPages paginationInfo - expectedErr error - }{ - { - description: "returns the next page", - input: `{"links": {"next": "https://google.com/2"}, "data": []}`, - expectedPages: paginationInfo{ - Next: "https://google.com/2", - }, - }, - { - description: "returns multiple pages", - input: `{"links": {"next": "https://google.com/2", "first": "https://google.com/1"}, "data": []}`, - expectedPages: paginationInfo{ - First: "https://google.com/1", - Next: "https://google.com/2", - }, - }, - { - description: "returns no pages", - input: `{"data": []}`, - expectedPages: paginationInfo{}, - }, - } - for _, testcase := range tests { - pages, reader, err := getPages(bytes.NewReader([]byte(testcase.input))) - if pages != testcase.expectedPages { - t.Errorf("Test %s: Expected pages %+v, got %+v", testcase.description, testcase.expectedPages, pages) - } - - // we expect to be able to get the original input out again - resultBytes, _ := ioutil.ReadAll(reader) - if string(resultBytes) != testcase.input { - t.Errorf("Test %s: Expected body %s, got %s", testcase.description, testcase.input, string(resultBytes)) - } - if err != testcase.expectedErr { - t.Errorf("Test %s: Expected error %v, got %v", testcase.description, testcase.expectedErr, err) - } - } -} - -func TestUpdateWAFConfigSetInput_validate(t *testing.T) { - tests := []struct { - description string - input UpdateWAFConfigSetInput - expected error - }{ - { - description: "Accepts valid input", - input: UpdateWAFConfigSetInput{ - WAFList: []ConfigSetWAFs{{ID: "derpID"}}, - ConfigSetID: "derpConfigSet", - }, - expected: nil, - }, - } - for _, testcase := range tests { - err := testcase.input.validate() - if err != testcase.expected { - t.Errorf("In test %s: Expected %v,got %v", testcase.description, testcase.expected, err) - } - } -} From 21ebff608903e644d4a6b11d2f2064debde2f8aa Mon Sep 17 00:00:00 2001 From: Stuart Wallace Date: Mon, 29 Jun 2020 21:44:21 +0100 Subject: [PATCH 10/37] Update enable/disable WAF API --- fastly/fixtures/wafs/disable.yaml | 5 +++-- fastly/fixtures/wafs/enable.yaml | 5 +++-- fastly/waf.go | 16 ++++++++++------ 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/fastly/fixtures/wafs/disable.yaml b/fastly/fixtures/wafs/disable.yaml index 22a5c209e..49f5c499b 100644 --- a/fastly/fixtures/wafs/disable.yaml +++ b/fastly/fixtures/wafs/disable.yaml @@ -2,7 +2,8 @@ version: 1 interactions: - request: - body: "" + body: | + {"data":{"type":"waf_firewall","id":"5ui1qC2Y9TZIonO95zU3gM","attributes":{"disable":true}}} form: {} headers: Accept: @@ -11,7 +12,7 @@ interactions: - application/vnd.api+json User-Agent: - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) - url: https://api.fastly.com/waf/firewalls/5ui1qC2Y9TZIonO95zU3gM/disable + url: https://api.fastly.com/waf/firewalls/5ui1qC2Y9TZIonO95zU3gM method: PATCH response: body: '{"data":{"id":"5ui1qC2Y9TZIonO95zU3gM","type":"waf_firewall","attributes":{"service_id":"1l9vtYGCa1be9QkG5opE5F","prefetch_condition":null,"response":null,"disabled":true,"service_version_number":null,"created_at":"2019-12-13T08:52:52Z","updated_at":"2019-12-13T08:52:54Z","active_rules_trustwave_log_count":0,"active_rules_trustwave_block_count":0,"active_rules_fastly_log_count":0,"active_rules_fastly_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_score_count":0}}}' diff --git a/fastly/fixtures/wafs/enable.yaml b/fastly/fixtures/wafs/enable.yaml index c5d88c2fe..c6597241f 100644 --- a/fastly/fixtures/wafs/enable.yaml +++ b/fastly/fixtures/wafs/enable.yaml @@ -2,7 +2,8 @@ version: 1 interactions: - request: - body: "" + body: | + {"data":{"type":"waf_firewall","id":"5ui1qC2Y9TZIonO95zU3gM","attributes":{"disable":false}}} form: {} headers: Accept: @@ -11,7 +12,7 @@ interactions: - application/vnd.api+json User-Agent: - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) - url: https://api.fastly.com/waf/firewalls/5ui1qC2Y9TZIonO95zU3gM/enable + url: https://api.fastly.com/waf/firewalls/5ui1qC2Y9TZIonO95zU3gM method: PATCH response: body: '{"data":{"id":"5ui1qC2Y9TZIonO95zU3gM","type":"waf_firewall","attributes":{"service_id":"1l9vtYGCa1be9QkG5opE5F","prefetch_condition":null,"response":null,"disabled":false,"service_version_number":null,"created_at":"2019-12-13T08:52:52Z","updated_at":"2019-12-13T08:52:55Z","active_rules_trustwave_log_count":0,"active_rules_trustwave_block_count":0,"active_rules_fastly_log_count":0,"active_rules_fastly_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_score_count":0}}}' diff --git a/fastly/waf.go b/fastly/waf.go index b9bd95135..638de7b80 100644 --- a/fastly/waf.go +++ b/fastly/waf.go @@ -240,7 +240,8 @@ func (c *Client) UpdateWAF(i *UpdateWAFInput) (*WAF, error) { // EnableWAFInput is used as input to the EnableWAF function. type EnableWAFInput struct { // ID is the WAF's ID. - ID string + ID string `jsonapi:"primary,waf_firewall"` + Disabled bool `jsonapi:"attr,disabled"` } // EnableWAF enables a specific WAF. @@ -249,9 +250,10 @@ func (c *Client) EnableWAF(i *EnableWAFInput) (*WAF, error) { if i.ID == "" { return nil, ErrMissingWAFID } + i.Disabled = false - path := fmt.Sprintf("/waf/firewalls/%s/enable", i.ID) - resp, err := c.PatchJSONAPI(path, nil, nil) + path := fmt.Sprintf("/waf/firewalls/%s", i.ID) + resp, err := c.PatchJSONAPI(path, i, nil) if err != nil { return nil, err } @@ -266,7 +268,8 @@ func (c *Client) EnableWAF(i *EnableWAFInput) (*WAF, error) { // DisableWAFInput is used as input to the DisableWAF function. type DisableWAFInput struct { // ID is the WAF's ID. - ID string + ID string + Disabled bool `jsonapi:"attr,disabled"` } // DisableWAF disables a specific WAF. @@ -275,9 +278,10 @@ func (c *Client) DisableWAF(i *DisableWAFInput) (*WAF, error) { if i.ID == "" { return nil, ErrMissingWAFID } + i.Disabled = true - path := fmt.Sprintf("/waf/firewalls/%s/disable", i.ID) - resp, err := c.PatchJSONAPI(path, nil, nil) + path := fmt.Sprintf("/waf/firewalls/%s", i.ID) + resp, err := c.PatchJSONAPI(path, i, nil) if err != nil { return nil, err } From e1611fa6429ffd47be279be4e38a8353f111b644 Mon Sep 17 00:00:00 2001 From: Stuart Wallace Date: Tue, 30 Jun 2020 13:43:56 +0100 Subject: [PATCH 11/37] Update WAF active rules and WAF fixtures --- fastly/client.go | 2 +- .../waf_active_rules/condition/create.yaml | 22 ++++---- fastly/fixtures/waf_active_rules/create.yaml | 20 ++++---- .../fixtures/waf_active_rules/delete_all.yaml | 41 --------------- .../fixtures/waf_active_rules/delete_one.yaml | 14 +++--- .../waf_active_rules/list_after_delete.yaml | 16 +++--- .../list_after_delete_all.yaml | 41 --------------- .../fixtures/waf_active_rules/list_empty.yaml | 18 ++++--- .../waf_active_rules/list_not_empty.yaml | 16 +++--- .../waf_active_rules/list_not_empty2.yaml | 16 +++--- .../waf_active_rules/logging/create.yaml | 22 ++++---- .../waf_active_rules/logging/delete.yaml | 16 +++--- .../response_object/create.yaml | 30 +++++------ .../waf_active_rules/service/create.yaml | 20 +++++--- .../waf_active_rules/service/delete.yaml | 16 +++--- .../waf_active_rules/service/version.yaml | 22 ++++---- fastly/fixtures/waf_active_rules/update.yaml | 20 ++++---- .../fixtures/waf_active_rules/waf/create.yaml | 16 +++--- .../fixtures/waf_active_rules/waf/delete.yaml | 14 +++--- .../fixtures/waf_rules/list_all_fastly.yaml | 12 +++-- .../waf_rules/list_all_fastly_exclusion.yaml | 12 +++-- fastly/fixtures/waf_rules/list_owasp.yaml | 12 +++-- fastly/fixtures/waf_versions/clone.yaml | 31 ++++++------ .../waf_versions/condition/create.yaml | 22 ++++---- .../waf_versions/condition/delete.yaml | 15 +++--- .../fixtures/waf_versions/create_empty.yaml | 31 ++++++------ fastly/fixtures/waf_versions/deploy.yaml | 16 +++--- fastly/fixtures/waf_versions/get.yaml | 33 ++++++------ fastly/fixtures/waf_versions/list.yaml | 33 ++++++------ fastly/fixtures/waf_versions/list_all.yaml | 40 ++++++++------- fastly/fixtures/waf_versions/lock.yaml | 23 +++++---- .../fixtures/waf_versions/logging/create.yaml | 21 ++++---- .../fixtures/waf_versions/logging/delete.yaml | 15 +++--- .../waf_versions/response_object/create.yaml | 30 +++++------ .../waf_versions/response_object/delete.yaml | 15 +++--- .../fixtures/waf_versions/service/create.yaml | 22 ++++---- .../fixtures/waf_versions/service/delete.yaml | 16 +++--- .../waf_versions/service/version.yaml | 21 ++++---- fastly/fixtures/waf_versions/update.yaml | 25 ++++++---- fastly/fixtures/waf_versions/waf/create.yaml | 16 +++--- fastly/fixtures/waf_versions/waf/delete.yaml | 14 +++--- fastly/fixtures/wafs/cleanup.yaml | 15 +++--- fastly/fixtures/wafs/condition/create.yaml | 21 ++++---- fastly/fixtures/wafs/condition/delete.yaml | 16 +++--- fastly/fixtures/wafs/create.yaml | 15 +++--- fastly/fixtures/wafs/delete.yaml | 13 ++--- fastly/fixtures/wafs/deploy.yaml | 16 +++--- fastly/fixtures/wafs/disable.yaml | 20 ++++---- fastly/fixtures/wafs/enable.yaml | 18 ++++--- fastly/fixtures/wafs/get.yaml | 15 +++--- fastly/fixtures/wafs/list.yaml | 15 +++--- .../wafs/response_object/cleanup_another.yaml | 15 +++--- .../fixtures/wafs/response_object/create.yaml | 31 +++++------- .../wafs/response_object/create_another.yaml | 29 +++++------ .../fixtures/wafs/response_object/delete.yaml | 16 +++--- fastly/fixtures/wafs/ruleset/get.yaml | 48 ------------------ fastly/fixtures/wafs/ruleset/patch.yaml | 48 ------------------ fastly/fixtures/wafs/service/create.yaml | 22 ++++---- fastly/fixtures/wafs/service/delete.yaml | 16 +++--- fastly/fixtures/wafs/service/version.yaml | 22 ++++---- fastly/fixtures/wafs/update.yaml | 19 +++---- fastly/waf_active_rule.go | 50 ++++++------------- fastly/waf_active_rule_test.go | 41 --------------- fastly/waf_test.go | 2 +- fastly/waf_version_test.go | 4 +- 65 files changed, 617 insertions(+), 767 deletions(-) delete mode 100644 fastly/fixtures/waf_active_rules/delete_all.yaml delete mode 100644 fastly/fixtures/waf_active_rules/list_after_delete_all.yaml delete mode 100644 fastly/fixtures/wafs/ruleset/get.yaml delete mode 100644 fastly/fixtures/wafs/ruleset/patch.yaml diff --git a/fastly/client.go b/fastly/client.go index 18b5a5f3a..1b446b6f8 100644 --- a/fastly/client.go +++ b/fastly/client.go @@ -394,7 +394,7 @@ func (c *Client) RequestJSONAPIBulk(verb, p string, i interface{}, ro *RequestOp if ro.Headers == nil { ro.Headers = make(map[string]string) } - ro.Headers["Content-Type"] = jsonapi.MediaType + ro.Headers["Content-Type"] = jsonapi.MediaType + "; ext=bulk" ro.Headers["Accept"] = jsonapi.MediaType + "; ext=bulk" var buf bytes.Buffer diff --git a/fastly/fixtures/waf_active_rules/condition/create.yaml b/fastly/fixtures/waf_active_rules/condition/create.yaml index 6b185d7e4..6d3c3d30a 100644 --- a/fastly/fixtures/waf_active_rules/condition/create.yaml +++ b/fastly/fixtures/waf_active_rules/condition/create.yaml @@ -2,10 +2,10 @@ version: 1 interactions: - request: - body: Service=1qNbCw880P3rmalHHls5Oc&Version=2&name=WAF_Prefetch&priority=1&statement=req.url~%2B%22index.html%22&type=PREFETCH + body: Service=0tMlTqfWhijgsh07mPyFJq&Version=2&name=WAF_Prefetch&priority=1&statement=req.url~%2B%22index.html%22&type=PREFETCH form: Service: - - 1qNbCw880P3rmalHHls5Oc + - 0tMlTqfWhijgsh07mPyFJq Version: - "2" name: @@ -20,24 +20,25 @@ interactions: Content-Type: - application/x-www-form-urlencoded User-Agent: - - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) - url: https://api.fastly.com/service/1qNbCw880P3rmalHHls5Oc/version/2/condition + - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) + url: https://api.fastly.com/service/0tMlTqfWhijgsh07mPyFJq/version/2/condition method: POST response: - body: '{"name":"WAF_Prefetch","priority":"1","statement":"req.url~+\"index.html\"","type":"PREFETCH","service_id":"1qNbCw880P3rmalHHls5Oc","version":"2","created_at":"2019-11-28T12:43:22Z","comment":"","deleted_at":null,"updated_at":"2019-11-28T12:43:22Z"}' + body: '{"name":"WAF_Prefetch","priority":"1","statement":"req.url~+\"index.html\"","type":"PREFETCH","service_id":"0tMlTqfWhijgsh07mPyFJq","version":"2","updated_at":"2020-06-30T10:56:25Z","created_at":"2020-06-30T10:56:25Z","comment":"","deleted_at":null}' headers: Accept-Ranges: - bytes + - bytes Cache-Control: - no-cache Content-Type: - application/json Date: - - Thu, 28 Nov 2019 12:43:22 GMT + - Tue, 30 Jun 2020 10:56:25 GMT Fastly-Ratelimit-Remaining: - - "982" + - "686" Fastly-Ratelimit-Reset: - - "1574946000" + - "1593514800" Status: - 200 OK Strict-Transport-Security: @@ -46,14 +47,15 @@ interactions: - Accept-Encoding Via: - 1.1 varnish + - 1.1 varnish X-Cache: - MISS, MISS X-Cache-Hits: - 0, 0 X-Served-By: - - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19243-LCY + - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19235-LCY X-Timer: - - S1574945002.999829,VS0,VE247 + - S1593514585.239619,VS0,VE183 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/waf_active_rules/create.yaml b/fastly/fixtures/waf_active_rules/create.yaml index 72c26a381..2f5f48c02 100644 --- a/fastly/fixtures/waf_active_rules/create.yaml +++ b/fastly/fixtures/waf_active_rules/create.yaml @@ -3,34 +3,36 @@ version: 1 interactions: - request: body: | - {"data":[{"type":"waf_active_rule","attributes":{"modsec_rule_id":2029718,"status":"log"}},{"type":"waf_active_rule","attributes":{"modsec_rule_id":2037405,"status":"log"}},{"type":"waf_active_rule","attributes":{"modsec_rule_id":1010070,"status":"log"}}]} + {"data":[{"type":"waf_active_rule","attributes":{"modsec_rule_id":2029718,"revision":1,"status":"log"}},{"type":"waf_active_rule","attributes":{"modsec_rule_id":2037405,"revision":1,"status":"log"}},{"type":"waf_active_rule","attributes":{"modsec_rule_id":1010070,"revision":1,"status":"log"}}]} form: {} headers: Accept: - application/vnd.api+json; ext=bulk Content-Type: - - application/vnd.api+json + - application/vnd.api+json; ext=bulk User-Agent: - - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) - url: https://api.fastly.com/waf/firewalls/5n9TykpTt7zn0KFJ4k9bMz/versions/1/rules + - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) + url: https://api.fastly.com/waf/firewalls/2pmz6XhLxsbLCkK68TrL46/versions/1/active-rules method: POST response: - body: '{"data":[{"id":"6E8M7nScn1buIUJrSKvqkt","type":"waf_active_rule","attributes":{"status":"log","modsec_rule_id":2029718,"revision":1,"created_at":"2019-11-28T12:43:23Z","updated_at":"2019-11-28T12:43:23Z"},"relationships":{"waf_firewall_version":{"data":{"id":"6Wo0vAYg6cS79HacNpZrBm","type":"waf_firewall_version"}},"waf_rule_revision":{"data":{"id":"6ZJML5tsy5uVq1nGNgmZ78","type":"waf_rule_revision"}}}},{"id":"7UZK2qQ20TMUBoZbKo9NZy","type":"waf_active_rule","attributes":{"status":"log","modsec_rule_id":2037405,"revision":1,"created_at":"2019-11-28T12:43:24Z","updated_at":"2019-11-28T12:43:24Z"},"relationships":{"waf_firewall_version":{"data":{"id":"6Wo0vAYg6cS79HacNpZrBm","type":"waf_firewall_version"}},"waf_rule_revision":{"data":{"id":"3ANlv7vVZdzk2qFXlJLIk3","type":"waf_rule_revision"}}}},{"id":"5CVFtVaW0WCns3ksB7tMv2","type":"waf_active_rule","attributes":{"status":"log","modsec_rule_id":1010070,"revision":1,"created_at":"2019-11-28T12:43:24Z","updated_at":"2019-11-28T12:43:24Z"},"relationships":{"waf_firewall_version":{"data":{"id":"6Wo0vAYg6cS79HacNpZrBm","type":"waf_firewall_version"}},"waf_rule_revision":{"data":{"id":"2qiuFDyJoxuKkKkJYjrgsC","type":"waf_rule_revision"}}}}]}' + body: '{"data":[{"id":"2dUkKDhlx5hVWljfob6ggO","type":"waf_active_rule","attributes":{"created_at":"2020-06-30T10:56:27Z","latest_revision":1,"modsec_rule_id":2029718,"outdated":false,"revision":1,"status":"log","updated_at":"2020-06-30T10:56:27Z"},"relationships":{"waf_firewall_version":{"data":{"id":"4cpxRmmOXFmDMFQQyGqZDX","type":"waf_firewall_version"}},"waf_rule_revision":{"data":{"id":"6ZJML5tsy5uVq1nGNgmZ78","type":"waf_rule_revision"}}}},{"id":"3F5R6J4vJf9nSF6J1r5nd","type":"waf_active_rule","attributes":{"created_at":"2020-06-30T10:56:27Z","latest_revision":1,"modsec_rule_id":2037405,"outdated":false,"revision":1,"status":"log","updated_at":"2020-06-30T10:56:27Z"},"relationships":{"waf_firewall_version":{"data":{"id":"4cpxRmmOXFmDMFQQyGqZDX","type":"waf_firewall_version"}},"waf_rule_revision":{"data":{"id":"3ANlv7vVZdzk2qFXlJLIk3","type":"waf_rule_revision"}}}},{"id":"59Tw8iZn3e22bjLDlOP4a8","type":"waf_active_rule","attributes":{"created_at":"2020-06-30T10:56:27Z","latest_revision":1,"modsec_rule_id":1010070,"outdated":false,"revision":1,"status":"log","updated_at":"2020-06-30T10:56:27Z"},"relationships":{"waf_firewall_version":{"data":{"id":"4cpxRmmOXFmDMFQQyGqZDX","type":"waf_firewall_version"}},"waf_rule_revision":{"data":{"id":"2qiuFDyJoxuKkKkJYjrgsC","type":"waf_rule_revision"}}}}]}' headers: Accept-Ranges: - bytes + - bytes Content-Length: - - "1201" + - "1311" Content-Type: - application/vnd.api+json Date: - - Thu, 28 Nov 2019 12:43:24 GMT + - Tue, 30 Jun 2020 10:56:27 GMT Status: - 201 Created Strict-Transport-Security: - max-age=31536000 Via: - 1.1 varnish + - 1.1 varnish X-Cache: - MISS, MISS X-Cache-Hits: @@ -38,9 +40,9 @@ interactions: X-Content-Type-Options: - nosniff X-Served-By: - - cache-control-slwdc9036-CONTROL-SLWDC, cache-lcy19243-LCY + - cache-control-slwdc9035-CONTROL-SLWDC, cache-lcy19235-LCY X-Timer: - - S1574945004.785524,VS0,VE290 + - S1593514587.382494,VS0,VE161 status: 201 Created code: 201 duration: "" diff --git a/fastly/fixtures/waf_active_rules/delete_all.yaml b/fastly/fixtures/waf_active_rules/delete_all.yaml deleted file mode 100644 index cc7735eec..000000000 --- a/fastly/fixtures/waf_active_rules/delete_all.yaml +++ /dev/null @@ -1,41 +0,0 @@ ---- -version: 1 -interactions: -- request: - body: "" - form: {} - headers: - Accept: - - application/vnd.api+json - Content-Type: - - application/vnd.api+json - User-Agent: - - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) - url: https://api.fastly.com/waf/firewalls/5n9TykpTt7zn0KFJ4k9bMz/versions/1/rules - method: DELETE - response: - body: "" - headers: - Accept-Ranges: - - bytes - Date: - - Thu, 28 Nov 2019 12:43:25 GMT - Status: - - 204 No Content - Strict-Transport-Security: - - max-age=31536000 - Via: - - 1.1 varnish - X-Cache: - - MISS, MISS - X-Cache-Hits: - - 0, 0 - X-Content-Type-Options: - - nosniff - X-Served-By: - - cache-control-slwdc9036-CONTROL-SLWDC, cache-lcy19243-LCY - X-Timer: - - S1574945005.172121,VS0,VE153 - status: 204 No Content - code: 204 - duration: "" diff --git a/fastly/fixtures/waf_active_rules/delete_one.yaml b/fastly/fixtures/waf_active_rules/delete_one.yaml index e52e88132..4ef341387 100644 --- a/fastly/fixtures/waf_active_rules/delete_one.yaml +++ b/fastly/fixtures/waf_active_rules/delete_one.yaml @@ -9,24 +9,26 @@ interactions: Accept: - application/vnd.api+json; ext=bulk Content-Type: - - application/vnd.api+json + - application/vnd.api+json; ext=bulk User-Agent: - - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) - url: https://api.fastly.com/waf/firewalls/5n9TykpTt7zn0KFJ4k9bMz/versions/1/rules + - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) + url: https://api.fastly.com/waf/firewalls/2pmz6XhLxsbLCkK68TrL46/versions/1/active-rules method: DELETE response: body: "" headers: Accept-Ranges: - bytes + - bytes Date: - - Thu, 28 Nov 2019 12:43:24 GMT + - Tue, 30 Jun 2020 10:56:28 GMT Status: - 204 No Content Strict-Transport-Security: - max-age=31536000 Via: - 1.1 varnish + - 1.1 varnish X-Cache: - MISS, MISS X-Cache-Hits: @@ -34,9 +36,9 @@ interactions: X-Content-Type-Options: - nosniff X-Served-By: - - cache-control-slwdc9036-CONTROL-SLWDC, cache-lcy19243-LCY + - cache-control-slwdc9035-CONTROL-SLWDC, cache-lcy19235-LCY X-Timer: - - S1574945005.763911,VS0,VE151 + - S1593514589.581939,VS0,VE165 status: 204 No Content code: 204 duration: "" diff --git a/fastly/fixtures/waf_active_rules/list_after_delete.yaml b/fastly/fixtures/waf_active_rules/list_after_delete.yaml index 573ef5bd7..c180e798a 100644 --- a/fastly/fixtures/waf_active_rules/list_after_delete.yaml +++ b/fastly/fixtures/waf_active_rules/list_after_delete.yaml @@ -6,26 +6,28 @@ interactions: form: {} headers: User-Agent: - - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) - url: https://api.fastly.com/waf/firewalls/5n9TykpTt7zn0KFJ4k9bMz/versions/1/rules + - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) + url: https://api.fastly.com/waf/firewalls/2pmz6XhLxsbLCkK68TrL46/versions/1/active-rules method: GET response: - body: '{"data":[{"id":"7UZK2qQ20TMUBoZbKo9NZy","type":"waf_active_rule","attributes":{"status":"block","modsec_rule_id":2037405,"revision":1,"created_at":"2019-11-28T12:43:24Z","updated_at":"2019-11-28T12:43:24Z"}},{"id":"6E8M7nScn1buIUJrSKvqkt","type":"waf_active_rule","attributes":{"status":"block","modsec_rule_id":2029718,"revision":1,"created_at":"2019-11-28T12:43:23Z","updated_at":"2019-11-28T12:43:24Z"}}],"links":{"last":"https://api.fastly.com/waf/firewalls/5n9TykpTt7zn0KFJ4k9bMz/versions/1/rules?page[number]=1\u0026page[size]=100","first":"https://api.fastly.com/waf/firewalls/5n9TykpTt7zn0KFJ4k9bMz/versions/1/rules?page[number]=1\u0026page[size]=100"},"meta":{"current_page":1,"per_page":100,"record_count":2,"total_pages":1}}' + body: '{"data":[{"id":"3F5R6J4vJf9nSF6J1r5nd","type":"waf_active_rule","attributes":{"created_at":"2020-06-30T10:56:27Z","latest_revision":1,"modsec_rule_id":2037405,"outdated":false,"revision":1,"status":"block","updated_at":"2020-06-30T10:56:28Z"}},{"id":"2dUkKDhlx5hVWljfob6ggO","type":"waf_active_rule","attributes":{"created_at":"2020-06-30T10:56:27Z","latest_revision":1,"modsec_rule_id":2029718,"outdated":false,"revision":1,"status":"block","updated_at":"2020-06-30T10:56:28Z"}}],"links":{"last":"https://api.fastly.com/waf/firewalls/2pmz6XhLxsbLCkK68TrL46/versions/1/active-rules?page[number]=1\u0026page[size]=100","first":"https://api.fastly.com/waf/firewalls/2pmz6XhLxsbLCkK68TrL46/versions/1/active-rules?page[number]=1\u0026page[size]=100"},"meta":{"current_page":1,"per_page":100,"record_count":2,"total_pages":1}}' headers: Accept-Ranges: - bytes + - bytes Content-Length: - - "735" + - "822" Content-Type: - application/vnd.api+json Date: - - Thu, 28 Nov 2019 12:43:25 GMT + - Tue, 30 Jun 2020 10:56:29 GMT Status: - 200 OK Strict-Transport-Security: - max-age=31536000 Via: - 1.1 varnish + - 1.1 varnish X-Cache: - MISS, MISS X-Cache-Hits: @@ -33,9 +35,9 @@ interactions: X-Content-Type-Options: - nosniff X-Served-By: - - cache-control-slwdc9035-CONTROL-SLWDC, cache-lcy19243-LCY + - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19235-LCY X-Timer: - - S1574945005.966243,VS0,VE153 + - S1593514589.914695,VS0,VE143 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/waf_active_rules/list_after_delete_all.yaml b/fastly/fixtures/waf_active_rules/list_after_delete_all.yaml deleted file mode 100644 index cc10efb04..000000000 --- a/fastly/fixtures/waf_active_rules/list_after_delete_all.yaml +++ /dev/null @@ -1,41 +0,0 @@ ---- -version: 1 -interactions: -- request: - body: "" - form: {} - headers: - User-Agent: - - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) - url: https://api.fastly.com/waf/firewalls/5n9TykpTt7zn0KFJ4k9bMz/versions/1/rules - method: GET - response: - body: '{"data":[],"links":{"last":"https://api.fastly.com/waf/firewalls/5n9TykpTt7zn0KFJ4k9bMz/versions/1/rules?page[number]=1\u0026page[size]=100","first":"https://api.fastly.com/waf/firewalls/5n9TykpTt7zn0KFJ4k9bMz/versions/1/rules?page[number]=1\u0026page[size]=100"},"meta":{"current_page":1,"per_page":100,"record_count":0,"total_pages":1}}' - headers: - Accept-Ranges: - - bytes - Content-Length: - - "338" - Content-Type: - - application/vnd.api+json - Date: - - Thu, 28 Nov 2019 12:43:25 GMT - Status: - - 200 OK - Strict-Transport-Security: - - max-age=31536000 - Via: - - 1.1 varnish - X-Cache: - - MISS, MISS - X-Cache-Hits: - - 0, 0 - X-Content-Type-Options: - - nosniff - X-Served-By: - - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19243-LCY - X-Timer: - - S1574945005.378410,VS0,VE180 - status: 200 OK - code: 200 - duration: "" diff --git a/fastly/fixtures/waf_active_rules/list_empty.yaml b/fastly/fixtures/waf_active_rules/list_empty.yaml index ab3fe4bbe..03d46efdf 100644 --- a/fastly/fixtures/waf_active_rules/list_empty.yaml +++ b/fastly/fixtures/waf_active_rules/list_empty.yaml @@ -6,28 +6,32 @@ interactions: form: {} headers: User-Agent: - - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) - url: https://api.fastly.com/waf/firewalls/5n9TykpTt7zn0KFJ4k9bMz/versions/1/rules + - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) + url: https://api.fastly.com/waf/firewalls/2pmz6XhLxsbLCkK68TrL46/versions/1/active-rules method: GET response: - body: '{"data":[],"links":{"last":"https://api.fastly.com/waf/firewalls/5n9TykpTt7zn0KFJ4k9bMz/versions/1/rules?page[number]=1\u0026page[size]=100","first":"https://api.fastly.com/waf/firewalls/5n9TykpTt7zn0KFJ4k9bMz/versions/1/rules?page[number]=1\u0026page[size]=100"},"meta":{"current_page":1,"per_page":100,"record_count":0,"total_pages":1}}' + body: '{"data":[],"links":{"last":"https://api.fastly.com/waf/firewalls/2pmz6XhLxsbLCkK68TrL46/versions/1/active-rules?page[number]=1\u0026page[size]=100","first":"https://api.fastly.com/waf/firewalls/2pmz6XhLxsbLCkK68TrL46/versions/1/active-rules?page[number]=1\u0026page[size]=100"},"meta":{"current_page":1,"per_page":100,"record_count":0,"total_pages":1}}' headers: Accept-Ranges: - bytes + - bytes + - bytes Age: - "0" + - "0" Content-Length: - - "338" + - "352" Content-Type: - application/vnd.api+json Date: - - Thu, 28 Nov 2019 12:43:23 GMT + - Tue, 30 Jun 2020 10:56:27 GMT Status: - 200 OK Strict-Transport-Security: - max-age=31536000 Via: - 1.1 varnish + - 1.1 varnish X-Cache: - MISS, MISS X-Cache-Hits: @@ -35,9 +39,9 @@ interactions: X-Content-Type-Options: - nosniff X-Served-By: - - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19243-LCY + - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19235-LCY X-Timer: - - S1574945004.636936,VS0,VE140 + - S1593514587.141564,VS0,VE147 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/waf_active_rules/list_not_empty.yaml b/fastly/fixtures/waf_active_rules/list_not_empty.yaml index a4d7c7a92..e92b51a3d 100644 --- a/fastly/fixtures/waf_active_rules/list_not_empty.yaml +++ b/fastly/fixtures/waf_active_rules/list_not_empty.yaml @@ -6,26 +6,28 @@ interactions: form: {} headers: User-Agent: - - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) - url: https://api.fastly.com/waf/firewalls/5n9TykpTt7zn0KFJ4k9bMz/versions/1/rules + - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) + url: https://api.fastly.com/waf/firewalls/2pmz6XhLxsbLCkK68TrL46/versions/1/active-rules method: GET response: - body: '{"data":[{"id":"7UZK2qQ20TMUBoZbKo9NZy","type":"waf_active_rule","attributes":{"status":"log","modsec_rule_id":2037405,"revision":1,"created_at":"2019-11-28T12:43:24Z","updated_at":"2019-11-28T12:43:24Z"}},{"id":"5CVFtVaW0WCns3ksB7tMv2","type":"waf_active_rule","attributes":{"status":"log","modsec_rule_id":1010070,"revision":1,"created_at":"2019-11-28T12:43:24Z","updated_at":"2019-11-28T12:43:24Z"}},{"id":"6E8M7nScn1buIUJrSKvqkt","type":"waf_active_rule","attributes":{"status":"log","modsec_rule_id":2029718,"revision":1,"created_at":"2019-11-28T12:43:23Z","updated_at":"2019-11-28T12:43:23Z"}}],"links":{"last":"https://api.fastly.com/waf/firewalls/5n9TykpTt7zn0KFJ4k9bMz/versions/1/rules?page[number]=1\u0026page[size]=100","first":"https://api.fastly.com/waf/firewalls/5n9TykpTt7zn0KFJ4k9bMz/versions/1/rules?page[number]=1\u0026page[size]=100"},"meta":{"current_page":1,"per_page":100,"record_count":3,"total_pages":1}}' + body: '{"data":[{"id":"59Tw8iZn3e22bjLDlOP4a8","type":"waf_active_rule","attributes":{"created_at":"2020-06-30T10:56:27Z","latest_revision":1,"modsec_rule_id":1010070,"outdated":false,"revision":1,"status":"log","updated_at":"2020-06-30T10:56:27Z"}},{"id":"3F5R6J4vJf9nSF6J1r5nd","type":"waf_active_rule","attributes":{"created_at":"2020-06-30T10:56:27Z","latest_revision":1,"modsec_rule_id":2037405,"outdated":false,"revision":1,"status":"log","updated_at":"2020-06-30T10:56:27Z"}},{"id":"2dUkKDhlx5hVWljfob6ggO","type":"waf_active_rule","attributes":{"created_at":"2020-06-30T10:56:27Z","latest_revision":1,"modsec_rule_id":2029718,"outdated":false,"revision":1,"status":"log","updated_at":"2020-06-30T10:56:27Z"}}],"links":{"last":"https://api.fastly.com/waf/firewalls/2pmz6XhLxsbLCkK68TrL46/versions/1/active-rules?page[number]=1\u0026page[size]=100","first":"https://api.fastly.com/waf/firewalls/2pmz6XhLxsbLCkK68TrL46/versions/1/active-rules?page[number]=1\u0026page[size]=100"},"meta":{"current_page":1,"per_page":100,"record_count":3,"total_pages":1}}' headers: Accept-Ranges: - bytes + - bytes Content-Length: - - "928" + - "1052" Content-Type: - application/vnd.api+json Date: - - Thu, 28 Nov 2019 12:43:24 GMT + - Tue, 30 Jun 2020 10:56:27 GMT Status: - 200 OK Strict-Transport-Security: - max-age=31536000 Via: - 1.1 varnish + - 1.1 varnish X-Cache: - MISS, MISS X-Cache-Hits: @@ -33,9 +35,9 @@ interactions: X-Content-Type-Options: - nosniff X-Served-By: - - cache-control-slwdc9035-CONTROL-SLWDC, cache-lcy19243-LCY + - cache-control-slwdc9036-CONTROL-SLWDC, cache-lcy19235-LCY X-Timer: - - S1574945004.147737,VS0,VE150 + - S1593514588.741812,VS0,VE168 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/waf_active_rules/list_not_empty2.yaml b/fastly/fixtures/waf_active_rules/list_not_empty2.yaml index 44a3d4bdb..17943b2eb 100644 --- a/fastly/fixtures/waf_active_rules/list_not_empty2.yaml +++ b/fastly/fixtures/waf_active_rules/list_not_empty2.yaml @@ -6,26 +6,28 @@ interactions: form: {} headers: User-Agent: - - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) - url: https://api.fastly.com/waf/firewalls/5n9TykpTt7zn0KFJ4k9bMz/versions/1/rules + - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) + url: https://api.fastly.com/waf/firewalls/2pmz6XhLxsbLCkK68TrL46/versions/1/active-rules method: GET response: - body: '{"data":[{"id":"7UZK2qQ20TMUBoZbKo9NZy","type":"waf_active_rule","attributes":{"status":"block","modsec_rule_id":2037405,"revision":1,"created_at":"2019-11-28T12:43:24Z","updated_at":"2019-11-28T12:43:24Z"}},{"id":"5CVFtVaW0WCns3ksB7tMv2","type":"waf_active_rule","attributes":{"status":"block","modsec_rule_id":1010070,"revision":1,"created_at":"2019-11-28T12:43:24Z","updated_at":"2019-11-28T12:43:24Z"}},{"id":"6E8M7nScn1buIUJrSKvqkt","type":"waf_active_rule","attributes":{"status":"block","modsec_rule_id":2029718,"revision":1,"created_at":"2019-11-28T12:43:23Z","updated_at":"2019-11-28T12:43:24Z"}}],"links":{"last":"https://api.fastly.com/waf/firewalls/5n9TykpTt7zn0KFJ4k9bMz/versions/1/rules?page[number]=1\u0026page[size]=100","first":"https://api.fastly.com/waf/firewalls/5n9TykpTt7zn0KFJ4k9bMz/versions/1/rules?page[number]=1\u0026page[size]=100"},"meta":{"current_page":1,"per_page":100,"record_count":3,"total_pages":1}}' + body: '{"data":[{"id":"59Tw8iZn3e22bjLDlOP4a8","type":"waf_active_rule","attributes":{"created_at":"2020-06-30T10:56:27Z","latest_revision":1,"modsec_rule_id":1010070,"outdated":false,"revision":1,"status":"block","updated_at":"2020-06-30T10:56:28Z"}},{"id":"3F5R6J4vJf9nSF6J1r5nd","type":"waf_active_rule","attributes":{"created_at":"2020-06-30T10:56:27Z","latest_revision":1,"modsec_rule_id":2037405,"outdated":false,"revision":1,"status":"block","updated_at":"2020-06-30T10:56:28Z"}},{"id":"2dUkKDhlx5hVWljfob6ggO","type":"waf_active_rule","attributes":{"created_at":"2020-06-30T10:56:27Z","latest_revision":1,"modsec_rule_id":2029718,"outdated":false,"revision":1,"status":"block","updated_at":"2020-06-30T10:56:28Z"}}],"links":{"last":"https://api.fastly.com/waf/firewalls/2pmz6XhLxsbLCkK68TrL46/versions/1/active-rules?page[number]=1\u0026page[size]=100","first":"https://api.fastly.com/waf/firewalls/2pmz6XhLxsbLCkK68TrL46/versions/1/active-rules?page[number]=1\u0026page[size]=100"},"meta":{"current_page":1,"per_page":100,"record_count":3,"total_pages":1}}' headers: Accept-Ranges: - bytes + - bytes Content-Length: - - "934" + - "1058" Content-Type: - application/vnd.api+json Date: - - Thu, 28 Nov 2019 12:43:24 GMT + - Tue, 30 Jun 2020 10:56:28 GMT Status: - 200 OK Strict-Transport-Security: - max-age=31536000 Via: - 1.1 varnish + - 1.1 varnish X-Cache: - MISS, MISS X-Cache-Hits: @@ -33,9 +35,9 @@ interactions: X-Content-Type-Options: - nosniff X-Served-By: - - cache-control-slwdc9035-CONTROL-SLWDC, cache-lcy19243-LCY + - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19235-LCY X-Timer: - - S1574945005.573909,VS0,VE155 + - S1593514588.307651,VS0,VE146 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/waf_active_rules/logging/create.yaml b/fastly/fixtures/waf_active_rules/logging/create.yaml index d64fdcf3f..465184136 100644 --- a/fastly/fixtures/waf_active_rules/logging/create.yaml +++ b/fastly/fixtures/waf_active_rules/logging/create.yaml @@ -2,10 +2,10 @@ version: 1 interactions: - request: - body: Service=1qNbCw880P3rmalHHls5Oc&Version=2&address=example.com&format=format&format_version=2&hostname=example.com&message_type=classic&name=test-syslog&port=1234&token=abcd1234 + body: Service=0tMlTqfWhijgsh07mPyFJq&Version=2&address=example.com&format=format&format_version=2&hostname=example.com&message_type=classic&name=test-syslog&port=1234&token=abcd1234 form: Service: - - 1qNbCw880P3rmalHHls5Oc + - 0tMlTqfWhijgsh07mPyFJq Version: - "2" address: @@ -28,24 +28,25 @@ interactions: Content-Type: - application/x-www-form-urlencoded User-Agent: - - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) - url: https://api.fastly.com/service/1qNbCw880P3rmalHHls5Oc/version/2/logging/syslog + - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) + url: https://api.fastly.com/service/0tMlTqfWhijgsh07mPyFJq/version/2/logging/syslog method: POST response: - body: '{"address":"example.com","format":"format","format_version":"2","hostname":"example.com","message_type":"classic","name":"test-syslog","port":"1234","token":"abcd1234","service_id":"1qNbCw880P3rmalHHls5Oc","version":"2","tls_ca_cert":null,"placement":null,"updated_at":"2019-11-28T12:43:21Z","deleted_at":null,"ipv4":null,"tls_client_cert":null,"tls_client_key":null,"created_at":"2019-11-28T12:43:21Z","tls_hostname":null,"use_tls":"0","response_condition":"","public_key":null}' + body: '{"address":"example.com","format":"format","format_version":"2","hostname":"example.com","message_type":"classic","name":"test-syslog","port":"1234","token":"abcd1234","service_id":"0tMlTqfWhijgsh07mPyFJq","version":"2","tls_client_cert":null,"response_condition":"","use_tls":"0","deleted_at":null,"ipv4":null,"placement":null,"public_key":null,"tls_client_key":null,"tls_hostname":null,"tls_ca_cert":null,"updated_at":"2020-06-30T10:56:24Z","created_at":"2020-06-30T10:56:24Z"}' headers: Accept-Ranges: - bytes + - bytes Cache-Control: - no-cache Content-Type: - application/json Date: - - Thu, 28 Nov 2019 12:43:21 GMT + - Tue, 30 Jun 2020 10:56:25 GMT Fastly-Ratelimit-Remaining: - - "983" + - "689" Fastly-Ratelimit-Reset: - - "1574946000" + - "1593514800" Status: - 200 OK Strict-Transport-Security: @@ -54,14 +55,15 @@ interactions: - Accept-Encoding Via: - 1.1 varnish + - 1.1 varnish X-Cache: - MISS, MISS X-Cache-Hits: - 0, 0 X-Served-By: - - cache-control-slwdc9035-CONTROL-SLWDC, cache-lcy19243-LCY + - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19235-LCY X-Timer: - - S1574945001.323314,VS0,VE575 + - S1593514585.652093,VS0,VE468 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/waf_active_rules/logging/delete.yaml b/fastly/fixtures/waf_active_rules/logging/delete.yaml index f0a3da12f..1bd5eb171 100644 --- a/fastly/fixtures/waf_active_rules/logging/delete.yaml +++ b/fastly/fixtures/waf_active_rules/logging/delete.yaml @@ -6,24 +6,25 @@ interactions: form: {} headers: User-Agent: - - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) - url: https://api.fastly.com/service/1qNbCw880P3rmalHHls5Oc/version/2/logging/syslog/test-syslog + - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) + url: https://api.fastly.com/service/0tMlTqfWhijgsh07mPyFJq/version/2/logging/syslog/test-syslog method: DELETE response: body: '{"status":"ok"}' headers: Accept-Ranges: - bytes + - bytes Cache-Control: - no-cache Content-Type: - application/json Date: - - Thu, 28 Nov 2019 12:43:26 GMT + - Tue, 30 Jun 2020 10:56:29 GMT Fastly-Ratelimit-Remaining: - - "980" + - "678" Fastly-Ratelimit-Reset: - - "1574946000" + - "1593514800" Status: - 200 OK Strict-Transport-Security: @@ -32,14 +33,15 @@ interactions: - Accept-Encoding Via: - 1.1 varnish + - 1.1 varnish X-Cache: - MISS, MISS X-Cache-Hits: - 0, 0 X-Served-By: - - cache-control-slwdc9035-CONTROL-SLWDC, cache-lcy19243-LCY + - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19235-LCY X-Timer: - - S1574945006.787589,VS0,VE437 + - S1593514590.515011,VS0,VE251 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/waf_active_rules/response_object/create.yaml b/fastly/fixtures/waf_active_rules/response_object/create.yaml index c3753cd9d..8353cc316 100644 --- a/fastly/fixtures/waf_active_rules/response_object/create.yaml +++ b/fastly/fixtures/waf_active_rules/response_object/create.yaml @@ -2,44 +2,39 @@ version: 1 interactions: - request: - body: Service=1qNbCw880P3rmalHHls5Oc&Version=2&content=abcd&content_type=text%2Fplain&name=WAf_Response&response=Ok&status=200 + body: Service=0tMlTqfWhijgsh07mPyFJq&Version=2&name=WAf_Response&status=403 form: Service: - - 1qNbCw880P3rmalHHls5Oc + - 0tMlTqfWhijgsh07mPyFJq Version: - "2" - content: - - abcd - content_type: - - text/plain name: - WAf_Response - response: - - Ok status: - - "200" + - "403" headers: Content-Type: - application/x-www-form-urlencoded User-Agent: - - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) - url: https://api.fastly.com/service/1qNbCw880P3rmalHHls5Oc/version/2/response_object + - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) + url: https://api.fastly.com/service/0tMlTqfWhijgsh07mPyFJq/version/2/response_object method: POST response: - body: '{"content":"abcd","content_type":"text/plain","name":"WAf_Response","response":"Ok","status":"200","service_id":"1qNbCw880P3rmalHHls5Oc","version":"2","request_condition":"","updated_at":"2019-11-28T12:43:22Z","deleted_at":null,"created_at":"2019-11-28T12:43:22Z","cache_condition":""}' + body: '{"name":"WAf_Response","status":"403","service_id":"0tMlTqfWhijgsh07mPyFJq","version":"2","request_condition":"","response":"ok","content":null,"content_type":null,"updated_at":"2020-06-30T10:56:25Z","cache_condition":"","created_at":"2020-06-30T10:56:25Z","deleted_at":null}' headers: Accept-Ranges: - bytes + - bytes Cache-Control: - no-cache Content-Type: - application/json Date: - - Thu, 28 Nov 2019 12:43:22 GMT + - Tue, 30 Jun 2020 10:56:26 GMT Fastly-Ratelimit-Remaining: - - "981" + - "682" Fastly-Ratelimit-Reset: - - "1574946000" + - "1593514800" Status: - 200 OK Strict-Transport-Security: @@ -48,14 +43,15 @@ interactions: - Accept-Encoding Via: - 1.1 varnish + - 1.1 varnish X-Cache: - MISS, MISS X-Cache-Hits: - 0, 0 X-Served-By: - - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19243-LCY + - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19235-LCY X-Timer: - - S1574945002.309059,VS0,VE399 + - S1593514586.539848,VS0,VE678 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/waf_active_rules/service/create.yaml b/fastly/fixtures/waf_active_rules/service/create.yaml index 49a08eb78..bb3c56bc1 100644 --- a/fastly/fixtures/waf_active_rules/service/create.yaml +++ b/fastly/fixtures/waf_active_rules/service/create.yaml @@ -2,34 +2,37 @@ version: 1 interactions: - request: - body: comment=go-fastly+client+test&name=test_service_service + body: comment=go-fastly+client+test&name=test_service_service&type=vcl form: comment: - go-fastly client test name: - test_service_service + type: + - vcl headers: Content-Type: - application/x-www-form-urlencoded User-Agent: - - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) + - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) url: https://api.fastly.com/service method: POST response: - body: '{"customer_id":"WpqWFjTA4lk2N1g0GY2HH","comment":"go-fastly client test","name":"test_service_service","deleted_at":null,"id":"1qNbCw880P3rmalHHls5Oc","versions":[{"locked":false,"service_id":"1qNbCw880P3rmalHHls5Oc","staging":false,"number":1,"deleted_at":null,"active":false,"comment":"","updated_at":"2019-11-28T12:43:20Z","testing":false,"created_at":"2019-11-28T12:43:20Z","deployed":false}],"type":"vcl","created_at":"2019-11-28T12:43:20Z","publish_key":"311e1e932579e7d6e7f706b92c17bf51e649ed27","updated_at":"2019-11-28T12:43:20Z"}' + body: '{"customer_id":"WpqWFjTA4lk2N1g0GY2HH","comment":"go-fastly client test","name":"test_service_service","type":"vcl","id":"0tMlTqfWhijgsh07mPyFJq","publish_key":"","versions":[{"comment":"","number":1,"testing":false,"locked":false,"updated_at":"2020-06-30T10:56:24Z","deleted_at":null,"created_at":"2020-06-30T10:56:24Z","service_id":"0tMlTqfWhijgsh07mPyFJq","deployed":false,"active":false,"staging":false}],"deleted_at":null,"created_at":"2020-06-30T10:56:24Z","updated_at":"2020-06-30T10:56:24Z"}' headers: Accept-Ranges: - bytes + - bytes Cache-Control: - no-cache Content-Type: - application/json Date: - - Thu, 28 Nov 2019 12:43:20 GMT + - Tue, 30 Jun 2020 10:56:24 GMT Fastly-Ratelimit-Remaining: - - "985" + - "693" Fastly-Ratelimit-Reset: - - "1574946000" + - "1593514800" Status: - 200 OK Strict-Transport-Security: @@ -38,14 +41,15 @@ interactions: - Accept-Encoding Via: - 1.1 varnish + - 1.1 varnish X-Cache: - MISS, MISS X-Cache-Hits: - 0, 0 X-Served-By: - - cache-control-slwdc9036-CONTROL-SLWDC, cache-lcy19243-LCY + - cache-control-slwdc9035-CONTROL-SLWDC, cache-lcy19235-LCY X-Timer: - - S1574945001.520378,VS0,VE280 + - S1593514584.987398,VS0,VE218 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/waf_active_rules/service/delete.yaml b/fastly/fixtures/waf_active_rules/service/delete.yaml index 125ea916c..b2d64dbc5 100644 --- a/fastly/fixtures/waf_active_rules/service/delete.yaml +++ b/fastly/fixtures/waf_active_rules/service/delete.yaml @@ -6,24 +6,25 @@ interactions: form: {} headers: User-Agent: - - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) - url: https://api.fastly.com/service/1qNbCw880P3rmalHHls5Oc + - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) + url: https://api.fastly.com/service/0tMlTqfWhijgsh07mPyFJq method: DELETE response: body: '{"status":"ok"}' headers: Accept-Ranges: - bytes + - bytes Cache-Control: - no-cache Content-Type: - application/json Date: - - Thu, 28 Nov 2019 12:43:26 GMT + - Tue, 30 Jun 2020 10:56:30 GMT Fastly-Ratelimit-Remaining: - - "979" + - "677" Fastly-Ratelimit-Reset: - - "1574946000" + - "1593514800" Status: - 200 OK Strict-Transport-Security: @@ -32,14 +33,15 @@ interactions: - Accept-Encoding Via: - 1.1 varnish + - 1.1 varnish X-Cache: - MISS, MISS X-Cache-Hits: - 0, 0 X-Served-By: - - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19243-LCY + - cache-control-slwdc9036-CONTROL-SLWDC, cache-lcy19235-LCY X-Timer: - - S1574945006.296687,VS0,VE243 + - S1593514590.950083,VS0,VE219 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/waf_active_rules/service/version.yaml b/fastly/fixtures/waf_active_rules/service/version.yaml index 7d51e4293..18216282f 100644 --- a/fastly/fixtures/waf_active_rules/service/version.yaml +++ b/fastly/fixtures/waf_active_rules/service/version.yaml @@ -2,32 +2,33 @@ version: 1 interactions: - request: - body: Service=1qNbCw880P3rmalHHls5Oc + body: Service=0tMlTqfWhijgsh07mPyFJq form: Service: - - 1qNbCw880P3rmalHHls5Oc + - 0tMlTqfWhijgsh07mPyFJq headers: Content-Type: - application/x-www-form-urlencoded User-Agent: - - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) - url: https://api.fastly.com/service/1qNbCw880P3rmalHHls5Oc/version + - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) + url: https://api.fastly.com/service/0tMlTqfWhijgsh07mPyFJq/version method: POST response: - body: '{"service_id":"1qNbCw880P3rmalHHls5Oc","number":2}' + body: '{"service_id":"0tMlTqfWhijgsh07mPyFJq","number":2}' headers: Accept-Ranges: - bytes + - bytes Cache-Control: - no-cache Content-Type: - application/json Date: - - Thu, 28 Nov 2019 12:43:21 GMT + - Tue, 30 Jun 2020 10:56:24 GMT Fastly-Ratelimit-Remaining: - - "984" + - "690" Fastly-Ratelimit-Reset: - - "1574946000" + - "1593514800" Status: - 200 OK Strict-Transport-Security: @@ -36,14 +37,15 @@ interactions: - Accept-Encoding Via: - 1.1 varnish + - 1.1 varnish X-Cache: - MISS, MISS X-Cache-Hits: - 0, 0 X-Served-By: - - cache-control-slwdc9035-CONTROL-SLWDC, cache-lcy19243-LCY + - cache-control-slwdc9036-CONTROL-SLWDC, cache-lcy19235-LCY X-Timer: - - S1574945001.871880,VS0,VE437 + - S1593514584.296820,VS0,VE225 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/waf_active_rules/update.yaml b/fastly/fixtures/waf_active_rules/update.yaml index eb3772840..da1c5fa97 100644 --- a/fastly/fixtures/waf_active_rules/update.yaml +++ b/fastly/fixtures/waf_active_rules/update.yaml @@ -3,34 +3,36 @@ version: 1 interactions: - request: body: | - {"data":[{"type":"waf_active_rule","attributes":{"modsec_rule_id":2029718,"status":"block"}},{"type":"waf_active_rule","attributes":{"modsec_rule_id":2037405,"status":"block"}},{"type":"waf_active_rule","attributes":{"modsec_rule_id":1010070,"status":"block"}}]} + {"data":[{"type":"waf_active_rule","attributes":{"modsec_rule_id":2029718,"revision":1,"status":"block"}},{"type":"waf_active_rule","attributes":{"modsec_rule_id":2037405,"revision":1,"status":"block"}},{"type":"waf_active_rule","attributes":{"modsec_rule_id":1010070,"revision":1,"status":"block"}}]} form: {} headers: Accept: - application/vnd.api+json; ext=bulk Content-Type: - - application/vnd.api+json + - application/vnd.api+json; ext=bulk User-Agent: - - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) - url: https://api.fastly.com/waf/firewalls/5n9TykpTt7zn0KFJ4k9bMz/versions/1/rules + - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) + url: https://api.fastly.com/waf/firewalls/2pmz6XhLxsbLCkK68TrL46/versions/1/active-rules method: POST response: - body: '{"data":[{"id":"6E8M7nScn1buIUJrSKvqkt","type":"waf_active_rule","attributes":{"status":"block","modsec_rule_id":2029718,"revision":1,"created_at":"2019-11-28T12:43:23Z","updated_at":"2019-11-28T12:43:24Z"},"relationships":{"waf_firewall_version":{"data":{"id":"6Wo0vAYg6cS79HacNpZrBm","type":"waf_firewall_version"}},"waf_rule_revision":{"data":{"id":"6ZJML5tsy5uVq1nGNgmZ78","type":"waf_rule_revision"}}}},{"id":"7UZK2qQ20TMUBoZbKo9NZy","type":"waf_active_rule","attributes":{"status":"block","modsec_rule_id":2037405,"revision":1,"created_at":"2019-11-28T12:43:24Z","updated_at":"2019-11-28T12:43:24Z"},"relationships":{"waf_firewall_version":{"data":{"id":"6Wo0vAYg6cS79HacNpZrBm","type":"waf_firewall_version"}},"waf_rule_revision":{"data":{"id":"3ANlv7vVZdzk2qFXlJLIk3","type":"waf_rule_revision"}}}},{"id":"5CVFtVaW0WCns3ksB7tMv2","type":"waf_active_rule","attributes":{"status":"block","modsec_rule_id":1010070,"revision":1,"created_at":"2019-11-28T12:43:24Z","updated_at":"2019-11-28T12:43:24Z"},"relationships":{"waf_firewall_version":{"data":{"id":"6Wo0vAYg6cS79HacNpZrBm","type":"waf_firewall_version"}},"waf_rule_revision":{"data":{"id":"2qiuFDyJoxuKkKkJYjrgsC","type":"waf_rule_revision"}}}}]}' + body: '{"data":[{"id":"2dUkKDhlx5hVWljfob6ggO","type":"waf_active_rule","attributes":{"created_at":"2020-06-30T10:56:27Z","latest_revision":1,"modsec_rule_id":2029718,"outdated":false,"revision":1,"status":"block","updated_at":"2020-06-30T10:56:28Z"},"relationships":{"waf_firewall_version":{"data":{"id":"4cpxRmmOXFmDMFQQyGqZDX","type":"waf_firewall_version"}},"waf_rule_revision":{"data":{"id":"6ZJML5tsy5uVq1nGNgmZ78","type":"waf_rule_revision"}}}},{"id":"3F5R6J4vJf9nSF6J1r5nd","type":"waf_active_rule","attributes":{"created_at":"2020-06-30T10:56:27Z","latest_revision":1,"modsec_rule_id":2037405,"outdated":false,"revision":1,"status":"block","updated_at":"2020-06-30T10:56:28Z"},"relationships":{"waf_firewall_version":{"data":{"id":"4cpxRmmOXFmDMFQQyGqZDX","type":"waf_firewall_version"}},"waf_rule_revision":{"data":{"id":"3ANlv7vVZdzk2qFXlJLIk3","type":"waf_rule_revision"}}}},{"id":"59Tw8iZn3e22bjLDlOP4a8","type":"waf_active_rule","attributes":{"created_at":"2020-06-30T10:56:27Z","latest_revision":1,"modsec_rule_id":1010070,"outdated":false,"revision":1,"status":"block","updated_at":"2020-06-30T10:56:28Z"},"relationships":{"waf_firewall_version":{"data":{"id":"4cpxRmmOXFmDMFQQyGqZDX","type":"waf_firewall_version"}},"waf_rule_revision":{"data":{"id":"2qiuFDyJoxuKkKkJYjrgsC","type":"waf_rule_revision"}}}}]}' headers: Accept-Ranges: - bytes + - bytes Content-Length: - - "1207" + - "1317" Content-Type: - application/vnd.api+json Date: - - Thu, 28 Nov 2019 12:43:24 GMT + - Tue, 30 Jun 2020 10:56:28 GMT Status: - 201 Created Strict-Transport-Security: - max-age=31536000 Via: - 1.1 varnish + - 1.1 varnish X-Cache: - MISS, MISS X-Cache-Hits: @@ -38,9 +40,9 @@ interactions: X-Content-Type-Options: - nosniff X-Served-By: - - cache-control-slwdc9035-CONTROL-SLWDC, cache-lcy19243-LCY + - cache-control-slwdc9035-CONTROL-SLWDC, cache-lcy19235-LCY X-Timer: - - S1574945004.355642,VS0,VE211 + - S1593514588.984474,VS0,VE156 status: 201 Created code: 201 duration: "" diff --git a/fastly/fixtures/waf_active_rules/waf/create.yaml b/fastly/fixtures/waf_active_rules/waf/create.yaml index b8df1f39f..007028558 100644 --- a/fastly/fixtures/waf_active_rules/waf/create.yaml +++ b/fastly/fixtures/waf_active_rules/waf/create.yaml @@ -3,7 +3,7 @@ version: 1 interactions: - request: body: | - {"data":{"type":"waf_firewall","attributes":{"prefetch_condition":"WAF_Prefetch","response":"WAf_Response","service_id":"1qNbCw880P3rmalHHls5Oc","service_version_number":"2"}}} + {"data":{"type":"waf_firewall","attributes":{"prefetch_condition":"WAF_Prefetch","response":"WAf_Response","service_id":"0tMlTqfWhijgsh07mPyFJq","service_version_number":"2"}}} form: {} headers: Accept: @@ -11,26 +11,28 @@ interactions: Content-Type: - application/vnd.api+json User-Agent: - - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) + - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) url: https://api.fastly.com/waf/firewalls method: POST response: - body: '{"data":{"id":"5n9TykpTt7zn0KFJ4k9bMz","type":"waf_firewall","attributes":{"service_id":"1qNbCw880P3rmalHHls5Oc","prefetch_condition":"WAF_Prefetch","response":"WAf_Response","disabled":false,"service_version_number":2,"created_at":"2019-11-28T12:43:23Z","updated_at":"2019-11-28T12:43:23Z","active_rules_trustwave_log_count":0,"active_rules_trustwave_block_count":0,"active_rules_fastly_log_count":0,"active_rules_fastly_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_score_count":0}}}' + body: '{"data":{"id":"2pmz6XhLxsbLCkK68TrL46","type":"waf_firewall","attributes":{"active_rules_fastly_block_count":0,"active_rules_fastly_log_count":0,"active_rules_fastly_score_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_score_count":0,"active_rules_trustwave_block_count":0,"active_rules_trustwave_log_count":0,"created_at":"2020-06-30T10:56:26Z","disabled":false,"prefetch_condition":"WAF_Prefetch","response":"WAf_Response","service_id":"0tMlTqfWhijgsh07mPyFJq","service_version_number":2,"updated_at":"2020-06-30T10:56:26Z"}}}' headers: Accept-Ranges: - bytes + - bytes Content-Length: - - "542" + - "578" Content-Type: - application/vnd.api+json Date: - - Thu, 28 Nov 2019 12:43:23 GMT + - Tue, 30 Jun 2020 10:56:26 GMT Status: - 201 Created Strict-Transport-Security: - max-age=31536000 Via: - 1.1 varnish + - 1.1 varnish X-Cache: - MISS, MISS X-Cache-Hits: @@ -38,9 +40,9 @@ interactions: X-Content-Type-Options: - nosniff X-Served-By: - - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19243-LCY + - cache-control-slwdc9036-CONTROL-SLWDC, cache-lcy19235-LCY X-Timer: - - S1574945003.818460,VS0,VE751 + - S1593514586.335946,VS0,VE611 status: 201 Created code: 201 duration: "" diff --git a/fastly/fixtures/waf_active_rules/waf/delete.yaml b/fastly/fixtures/waf_active_rules/waf/delete.yaml index cdaf74067..67a857ea0 100644 --- a/fastly/fixtures/waf_active_rules/waf/delete.yaml +++ b/fastly/fixtures/waf_active_rules/waf/delete.yaml @@ -3,7 +3,7 @@ version: 1 interactions: - request: body: | - {"data":{"type":"waf_firewall","id":"5n9TykpTt7zn0KFJ4k9bMz","attributes":{"service_version_number":"1"}}} + {"data":{"type":"waf_firewall","id":"2pmz6XhLxsbLCkK68TrL46","attributes":{"service_version_number":"1"}}} form: {} headers: Accept: @@ -11,22 +11,24 @@ interactions: Content-Type: - application/vnd.api+json User-Agent: - - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) - url: https://api.fastly.com/waf/firewalls/5n9TykpTt7zn0KFJ4k9bMz + - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) + url: https://api.fastly.com/waf/firewalls/2pmz6XhLxsbLCkK68TrL46 method: DELETE response: body: "" headers: Accept-Ranges: - bytes + - bytes Date: - - Thu, 28 Nov 2019 12:43:25 GMT + - Tue, 30 Jun 2020 10:56:29 GMT Status: - 204 No Content Strict-Transport-Security: - max-age=31536000 Via: - 1.1 varnish + - 1.1 varnish X-Cache: - MISS, MISS X-Cache-Hits: @@ -34,9 +36,9 @@ interactions: X-Content-Type-Options: - nosniff X-Served-By: - - cache-control-slwdc9035-CONTROL-SLWDC, cache-lcy19243-LCY + - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19235-LCY X-Timer: - - S1574945006.566540,VS0,VE182 + - S1593514589.178816,VS0,VE148 status: 204 No Content code: 204 duration: "" diff --git a/fastly/fixtures/waf_rules/list_all_fastly.yaml b/fastly/fixtures/waf_rules/list_all_fastly.yaml index 962f89927..0848e7442 100644 --- a/fastly/fixtures/waf_rules/list_all_fastly.yaml +++ b/fastly/fixtures/waf_rules/list_all_fastly.yaml @@ -6,7 +6,7 @@ interactions: form: {} headers: User-Agent: - - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) + - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) url: https://api.fastly.com/waf/rules?filter%5Bpublisher%5D%5Bin%5D=fastly&page%5Bnumber%5D=1&page%5Bsize%5D=100 method: GET response: @@ -14,20 +14,24 @@ interactions: headers: Accept-Ranges: - bytes + - bytes + - bytes Age: - "0" + - "0" Content-Length: - "4251" Content-Type: - application/vnd.api+json Date: - - Thu, 05 Dec 2019 10:22:56 GMT + - Tue, 30 Jun 2020 10:56:25 GMT Status: - 200 OK Strict-Transport-Security: - max-age=31536000 Via: - 1.1 varnish + - 1.1 varnish X-Cache: - MISS, MISS X-Cache-Hits: @@ -35,9 +39,9 @@ interactions: X-Content-Type-Options: - nosniff X-Served-By: - - cache-control-slwdc9036-CONTROL-SLWDC, cache-lcy19256-LCY + - cache-control-slwdc9036-CONTROL-SLWDC, cache-lcy19235-LCY X-Timer: - - S1575541376.941919,VS0,VE335 + - S1593514585.652064,VS0,VE367 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/waf_rules/list_all_fastly_exclusion.yaml b/fastly/fixtures/waf_rules/list_all_fastly_exclusion.yaml index 4ceb2c155..d96c58fc7 100644 --- a/fastly/fixtures/waf_rules/list_all_fastly_exclusion.yaml +++ b/fastly/fixtures/waf_rules/list_all_fastly_exclusion.yaml @@ -6,7 +6,7 @@ interactions: form: {} headers: User-Agent: - - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) + - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) url: https://api.fastly.com/waf/rules?filter%5Bmodsec_rule_id%5D%5Bnot%5D=4170020&filter%5Bpublisher%5D%5Bin%5D=fastly&page%5Bnumber%5D=1&page%5Bsize%5D=100 method: GET response: @@ -14,20 +14,24 @@ interactions: headers: Accept-Ranges: - bytes + - bytes + - bytes Age: - "0" + - "0" Content-Length: - "4206" Content-Type: - application/vnd.api+json Date: - - Thu, 05 Dec 2019 10:29:34 GMT + - Tue, 30 Jun 2020 10:56:25 GMT Status: - 200 OK Strict-Transport-Security: - max-age=31536000 Via: - 1.1 varnish + - 1.1 varnish X-Cache: - MISS, MISS X-Cache-Hits: @@ -35,9 +39,9 @@ interactions: X-Content-Type-Options: - nosniff X-Served-By: - - cache-control-slwdc9035-CONTROL-SLWDC, cache-lcy19262-LCY + - cache-control-slwdc9036-CONTROL-SLWDC, cache-lcy19235-LCY X-Timer: - - S1575541773.450107,VS0,VE580 + - S1593514585.185515,VS0,VE225 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/waf_rules/list_owasp.yaml b/fastly/fixtures/waf_rules/list_owasp.yaml index fed7944c1..93880c617 100644 --- a/fastly/fixtures/waf_rules/list_owasp.yaml +++ b/fastly/fixtures/waf_rules/list_owasp.yaml @@ -6,7 +6,7 @@ interactions: form: {} headers: User-Agent: - - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) + - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) url: https://api.fastly.com/waf/rules?filter%5Bpublisher%5D%5Bin%5D=owasp method: GET response: @@ -14,20 +14,24 @@ interactions: headers: Accept-Ranges: - bytes + - bytes + - bytes Age: - "0" + - "0" Content-Length: - "12828" Content-Type: - application/vnd.api+json Date: - - Thu, 05 Dec 2019 10:22:55 GMT + - Tue, 30 Jun 2020 10:56:24 GMT Status: - 200 OK Strict-Transport-Security: - max-age=31536000 Via: - 1.1 varnish + - 1.1 varnish X-Cache: - MISS, MISS X-Cache-Hits: @@ -35,9 +39,9 @@ interactions: X-Content-Type-Options: - nosniff X-Served-By: - - cache-control-slwdc9035-CONTROL-SLWDC, cache-lcy19256-LCY + - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19235-LCY X-Timer: - - S1575541375.472243,VS0,VE388 + - S1593514584.064753,VS0,VE381 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/waf_versions/clone.yaml b/fastly/fixtures/waf_versions/clone.yaml index 2d5008851..d154e7b17 100644 --- a/fastly/fixtures/waf_versions/clone.yaml +++ b/fastly/fixtures/waf_versions/clone.yaml @@ -11,34 +11,35 @@ interactions: Content-Type: - application/vnd.api+json User-Agent: - - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) - url: https://api.fastly.com/waf/firewalls/3bhISXhyFhsufhCFnTst1j/versions/1/clone + - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) + url: https://api.fastly.com/waf/firewalls/6gj91AAsD3ndcoKaplqiq8/versions/1/clone method: PUT response: - body: '{"data":{"id":"4x66aw12P6aLHGwK4KzGni","type":"waf_firewall_version","attributes":{"number":2,"comment":null,"active":null,"locked":false,"error":null,"deployed_at":null,"critical_anomaly_score":5,"error_anomaly_score":4,"warning_anomaly_score":3,"notice_anomaly_score":2,"http_violation_score_threshold":999,"inbound_anomaly_score_threshold":999,"lfi_score_threshold":999,"php_injection_score_threshold":999,"rce_score_threshold":999,"rfi_score_threshold":999,"session_fixation_score_threshold":999,"sql_injection_score_threshold":999,"xss_score_threshold":999,"paranoia_level":1,"arg_name_length":100,"arg_length":400,"total_arg_length":6400,"max_file_size":10000000,"combined_file_sizes":10000000,"max_num_args":255,"high_risk_country_codes":"","allowed_methods":"GET - HEAD POST OPTIONS PUT PATCH DELETE","restricted_headers":"/proxy/ /lock-token/ - /content-range/ /translate/ /if/","restricted_extensions":".asa/ .asax/ .ascx/ - .axd/ .backup/ .bak/ .bat/ .cdx/ .cer/ .cfg/ .cmd/ .com/ .config/ .conf/ .cs/ - .csproj/ .csr/ .dat/ .db/ .dbf/ .dll/ .dos/ .htr/ .htw/ .ida/ .idc/ .idq/ .inc/ - .ini/ .key/ .licx/ .lnk/ .log/ .mdb/ .old/ .pass/ .pdb/ .pol/ .printer/ .pwd/ - .resources/ .resx/ .sql/ .sys/ .vb/ .vbs/ .vbproj/ .vsdisco/ .webinfo/ .xsd/ - .xsx/","allowed_request_content_type":"application/x-www-form-urlencoded|multipart/form-data|text/xml|application/xml|application/soap+xml|application/x-amf|application/json|application/octet-stream|application/csp-report|application/xss-auditor-report|text/plain","allowed_request_content_type_charset":"utf-8|iso-8859-1|iso-8859-15|windows-1252","allowed_http_versions":"HTTP/1.0 - HTTP/1.1 HTTP/2","crs_validate_utf8_encoding":false,"created_at":"2019-11-25T14:43:32Z","updated_at":"2019-11-25T14:43:32Z","active_rules_trustwave_log_count":0,"active_rules_trustwave_block_count":0,"active_rules_fastly_log_count":0,"active_rules_fastly_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_score_count":0},"relationships":{"waf_firewall":{"data":{"id":"3bhISXhyFhsufhCFnTst1j","type":"waf_firewall"}}}}}' + body: '{"data":{"id":"3LP12sn59pB0iz0Kh75cHb","type":"waf_firewall_version","attributes":{"active":false,"active_rules_fastly_block_count":0,"active_rules_fastly_log_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_score_count":0,"active_rules_trustwave_block_count":0,"active_rules_trustwave_log_count":0,"allowed_http_versions":"HTTP/1.0 + HTTP/1.1 HTTP/2","allowed_methods":"GET HEAD POST OPTIONS PUT PATCH DELETE","allowed_request_content_type":"application/x-www-form-urlencoded|multipart/form-data|text/xml|application/xml|application/soap+xml|application/x-amf|application/json|application/octet-stream|application/csp-report|application/xss-auditor-report|text/plain","allowed_request_content_type_charset":"utf-8|iso-8859-1|iso-8859-15|windows-1252","arg_name_length":100,"arg_length":400,"combined_file_sizes":10000000,"comment":null,"created_at":"2020-06-30T10:56:28Z","critical_anomaly_score":5,"crs_validate_utf8_encoding":false,"deployed_at":null,"error":null,"error_anomaly_score":4,"high_risk_country_codes":"","http_violation_score_threshold":999,"inbound_anomaly_score_threshold":999,"last_deployment_status":null,"lfi_score_threshold":999,"locked":false,"max_file_size":10000000,"max_num_args":255,"notice_anomaly_score":2,"number":2,"paranoia_level":1,"php_injection_score_threshold":999,"rce_score_threshold":999,"restricted_extensions":".asa/ + .asax/ .ascx/ .axd/ .backup/ .bak/ .bat/ .cdx/ .cer/ .cfg/ .cmd/ .com/ .config/ + .conf/ .cs/ .csproj/ .csr/ .dat/ .db/ .dbf/ .dll/ .dos/ .htr/ .htw/ .ida/ .idc/ + .idq/ .inc/ .ini/ .key/ .licx/ .lnk/ .log/ .mdb/ .old/ .pass/ .pdb/ .pol/ .printer/ + .pwd/ .resources/ .resx/ .sql/ .sys/ .vb/ .vbs/ .vbproj/ .vsdisco/ .webinfo/ + .xsd/ .xsx/","restricted_headers":"/proxy/ /lock-token/ /content-range/ /translate/ + /if/","rfi_score_threshold":999,"session_fixation_score_threshold":999,"sql_injection_score_threshold":999,"total_arg_length":6400,"updated_at":"2020-06-30T10:56:28Z","warning_anomaly_score":3,"xss_score_threshold":999},"relationships":{"waf_firewall":{"data":{"id":"6gj91AAsD3ndcoKaplqiq8","type":"waf_firewall"}}}}}' headers: Accept-Ranges: - bytes + - bytes Content-Length: - - "2095" + - "2126" Content-Type: - application/vnd.api+json Date: - - Mon, 25 Nov 2019 14:43:32 GMT + - Tue, 30 Jun 2020 10:56:28 GMT Status: - 200 OK Strict-Transport-Security: - max-age=31536000 Via: - 1.1 varnish + - 1.1 varnish X-Cache: - MISS, MISS X-Cache-Hits: @@ -46,9 +47,9 @@ interactions: X-Content-Type-Options: - nosniff X-Served-By: - - cache-control-slwdc9036-CONTROL-SLWDC, cache-lcy19271-LCY + - cache-control-slwdc9035-CONTROL-SLWDC, cache-lcy19235-LCY X-Timer: - - S1574693013.761070,VS0,VE155 + - S1593514588.456050,VS0,VE159 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/waf_versions/condition/create.yaml b/fastly/fixtures/waf_versions/condition/create.yaml index 87d57c108..016e2446b 100644 --- a/fastly/fixtures/waf_versions/condition/create.yaml +++ b/fastly/fixtures/waf_versions/condition/create.yaml @@ -2,10 +2,10 @@ version: 1 interactions: - request: - body: Service=300YFPn1PVF82Na4SUkiqy&Version=2&name=WAF_Prefetch&priority=1&statement=req.url~%2B%22index.html%22&type=PREFETCH + body: Service=3BOOVoayIlrdMuRU8LrKSA&Version=2&name=WAF_Prefetch&priority=1&statement=req.url~%2B%22index.html%22&type=PREFETCH form: Service: - - 300YFPn1PVF82Na4SUkiqy + - 3BOOVoayIlrdMuRU8LrKSA Version: - "2" name: @@ -20,24 +20,25 @@ interactions: Content-Type: - application/x-www-form-urlencoded User-Agent: - - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) - url: https://api.fastly.com/service/300YFPn1PVF82Na4SUkiqy/version/2/condition + - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) + url: https://api.fastly.com/service/3BOOVoayIlrdMuRU8LrKSA/version/2/condition method: POST response: - body: '{"name":"WAF_Prefetch","priority":"1","statement":"req.url~+\"index.html\"","type":"PREFETCH","service_id":"300YFPn1PVF82Na4SUkiqy","version":"2","created_at":"2019-11-25T14:43:30Z","deleted_at":null,"comment":"","updated_at":"2019-11-25T14:43:30Z"}' + body: '{"name":"WAF_Prefetch","priority":"1","statement":"req.url~+\"index.html\"","type":"PREFETCH","service_id":"3BOOVoayIlrdMuRU8LrKSA","version":"2","updated_at":"2020-06-30T10:56:26Z","comment":"","created_at":"2020-06-30T10:56:26Z","deleted_at":null}' headers: Accept-Ranges: - bytes + - bytes Cache-Control: - no-cache Content-Type: - application/json Date: - - Mon, 25 Nov 2019 14:43:30 GMT + - Tue, 30 Jun 2020 10:56:26 GMT Fastly-Ratelimit-Remaining: - - "996" + - "680" Fastly-Ratelimit-Reset: - - "1574694000" + - "1593514800" Status: - 200 OK Strict-Transport-Security: @@ -46,14 +47,15 @@ interactions: - Accept-Encoding Via: - 1.1 varnish + - 1.1 varnish X-Cache: - MISS, MISS X-Cache-Hits: - 0, 0 X-Served-By: - - cache-control-slwdc9036-CONTROL-SLWDC, cache-lcy19271-LCY + - cache-control-slwdc9035-CONTROL-SLWDC, cache-lcy19235-LCY X-Timer: - - S1574693011.709810,VS0,VE175 + - S1593514586.994859,VS0,VE446 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/waf_versions/condition/delete.yaml b/fastly/fixtures/waf_versions/condition/delete.yaml index 6a9e1ad21..a40502cf2 100644 --- a/fastly/fixtures/waf_versions/condition/delete.yaml +++ b/fastly/fixtures/waf_versions/condition/delete.yaml @@ -6,8 +6,8 @@ interactions: form: {} headers: User-Agent: - - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) - url: https://api.fastly.com/service/300YFPn1PVF82Na4SUkiqy/version/2/condition/WAF_Prefetch + - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) + url: https://api.fastly.com/service/3BOOVoayIlrdMuRU8LrKSA/version/2/condition/WAF_Prefetch method: DELETE response: body: '{"status":"ok"}' @@ -20,11 +20,11 @@ interactions: Content-Type: - application/json Date: - - Mon, 25 Nov 2019 14:43:35 GMT + - Tue, 30 Jun 2020 10:56:31 GMT Fastly-Ratelimit-Remaining: - - "993" + - "674" Fastly-Ratelimit-Reset: - - "1574694000" + - "1593514800" Status: - 200 OK Strict-Transport-Security: @@ -33,14 +33,15 @@ interactions: - Accept-Encoding Via: - 1.1 varnish + - 1.1 varnish X-Cache: - MISS, MISS X-Cache-Hits: - 0, 0 X-Served-By: - - cache-control-slwdc9035-CONTROL-SLWDC, cache-lcy19271-LCY + - cache-control-slwdc9035-CONTROL-SLWDC, cache-lcy19235-LCY X-Timer: - - S1574693015.316753,VS0,VE246 + - S1593514591.237210,VS0,VE232 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/waf_versions/create_empty.yaml b/fastly/fixtures/waf_versions/create_empty.yaml index 451a7cb6d..79e98f315 100644 --- a/fastly/fixtures/waf_versions/create_empty.yaml +++ b/fastly/fixtures/waf_versions/create_empty.yaml @@ -10,34 +10,35 @@ interactions: Content-Type: - application/vnd.api+json User-Agent: - - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) - url: https://api.fastly.com/waf/firewalls/3bhISXhyFhsufhCFnTst1j/versions + - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) + url: https://api.fastly.com/waf/firewalls/6gj91AAsD3ndcoKaplqiq8/versions method: POST response: - body: '{"data":{"id":"74nEJg1p4KRGeeV371dcKM","type":"waf_firewall_version","attributes":{"number":3,"comment":null,"active":null,"locked":null,"error":null,"deployed_at":null,"critical_anomaly_score":5,"error_anomaly_score":4,"warning_anomaly_score":3,"notice_anomaly_score":2,"http_violation_score_threshold":999,"inbound_anomaly_score_threshold":999,"lfi_score_threshold":999,"php_injection_score_threshold":999,"rce_score_threshold":999,"rfi_score_threshold":999,"session_fixation_score_threshold":999,"sql_injection_score_threshold":999,"xss_score_threshold":999,"paranoia_level":1,"arg_name_length":100,"arg_length":400,"total_arg_length":6400,"max_file_size":10000000,"combined_file_sizes":10000000,"max_num_args":255,"high_risk_country_codes":"","allowed_methods":"GET - HEAD POST OPTIONS PUT PATCH DELETE","restricted_headers":"/proxy/ /lock-token/ - /content-range/ /translate/ /if/","restricted_extensions":".asa/ .asax/ .ascx/ - .axd/ .backup/ .bak/ .bat/ .cdx/ .cer/ .cfg/ .cmd/ .com/ .config/ .conf/ .cs/ - .csproj/ .csr/ .dat/ .db/ .dbf/ .dll/ .dos/ .htr/ .htw/ .ida/ .idc/ .idq/ .inc/ - .ini/ .key/ .licx/ .lnk/ .log/ .mdb/ .old/ .pass/ .pdb/ .pol/ .printer/ .pwd/ - .resources/ .resx/ .sql/ .sys/ .vb/ .vbs/ .vbproj/ .vsdisco/ .webinfo/ .xsd/ - .xsx/","allowed_request_content_type":"application/x-www-form-urlencoded|multipart/form-data|text/xml|application/xml|application/soap+xml|application/x-amf|application/json|application/octet-stream|application/csp-report|application/xss-auditor-report|text/plain","allowed_request_content_type_charset":"utf-8|iso-8859-1|iso-8859-15|windows-1252","allowed_http_versions":"HTTP/1.0 - HTTP/1.1 HTTP/2","crs_validate_utf8_encoding":false,"created_at":"2019-12-10T13:16:45Z","updated_at":"2019-12-10T13:16:45Z","active_rules_trustwave_log_count":0,"active_rules_trustwave_block_count":0,"active_rules_fastly_log_count":0,"active_rules_fastly_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_score_count":0},"relationships":{"waf_firewall":{"data":{"id":"7lMzP6tPtmcRNLiiDRrvuE","type":"waf_firewall"}}}}}' + body: '{"data":{"id":"7DhddGiMYD6YoPOrpMZfHc","type":"waf_firewall_version","attributes":{"active":false,"active_rules_fastly_block_count":0,"active_rules_fastly_log_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_score_count":0,"active_rules_trustwave_block_count":0,"active_rules_trustwave_log_count":0,"allowed_http_versions":"HTTP/1.0 + HTTP/1.1 HTTP/2","allowed_methods":"GET HEAD POST OPTIONS PUT PATCH DELETE","allowed_request_content_type":"application/x-www-form-urlencoded|multipart/form-data|text/xml|application/xml|application/soap+xml|application/x-amf|application/json|application/octet-stream|application/csp-report|application/xss-auditor-report|text/plain","allowed_request_content_type_charset":"utf-8|iso-8859-1|iso-8859-15|windows-1252","arg_name_length":100,"arg_length":400,"combined_file_sizes":10000000,"comment":null,"created_at":"2020-06-30T10:56:30Z","critical_anomaly_score":5,"crs_validate_utf8_encoding":false,"deployed_at":null,"error":null,"error_anomaly_score":4,"high_risk_country_codes":"","http_violation_score_threshold":999,"inbound_anomaly_score_threshold":999,"last_deployment_status":null,"lfi_score_threshold":999,"locked":false,"max_file_size":10000000,"max_num_args":255,"notice_anomaly_score":2,"number":3,"paranoia_level":1,"php_injection_score_threshold":999,"rce_score_threshold":999,"restricted_extensions":".asa/ + .asax/ .ascx/ .axd/ .backup/ .bak/ .bat/ .cdx/ .cer/ .cfg/ .cmd/ .com/ .config/ + .conf/ .cs/ .csproj/ .csr/ .dat/ .db/ .dbf/ .dll/ .dos/ .htr/ .htw/ .ida/ .idc/ + .idq/ .inc/ .ini/ .key/ .licx/ .lnk/ .log/ .mdb/ .old/ .pass/ .pdb/ .pol/ .printer/ + .pwd/ .resources/ .resx/ .sql/ .sys/ .vb/ .vbs/ .vbproj/ .vsdisco/ .webinfo/ + .xsd/ .xsx/","restricted_headers":"/proxy/ /lock-token/ /content-range/ /translate/ + /if/","rfi_score_threshold":999,"session_fixation_score_threshold":999,"sql_injection_score_threshold":999,"total_arg_length":6400,"updated_at":"2020-06-30T10:56:30Z","warning_anomaly_score":3,"xss_score_threshold":999},"relationships":{"waf_firewall":{"data":{"id":"6gj91AAsD3ndcoKaplqiq8","type":"waf_firewall"}}}}}' headers: Accept-Ranges: - bytes + - bytes Content-Length: - - "2094" + - "2126" Content-Type: - application/vnd.api+json Date: - - Tue, 10 Dec 2019 13:16:45 GMT + - Tue, 30 Jun 2020 10:56:30 GMT Status: - 201 Created Strict-Transport-Security: - max-age=31536000 Via: - 1.1 varnish + - 1.1 varnish X-Cache: - MISS, MISS X-Cache-Hits: @@ -45,9 +46,9 @@ interactions: X-Content-Type-Options: - nosniff X-Served-By: - - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19243-LCY + - cache-control-slwdc9036-CONTROL-SLWDC, cache-lcy19235-LCY X-Timer: - - S1575983806.821971,VS0,VE154 + - S1593514590.943096,VS0,VE156 status: 201 Created code: 201 duration: "" diff --git a/fastly/fixtures/waf_versions/deploy.yaml b/fastly/fixtures/waf_versions/deploy.yaml index 38acec62a..d28610b9a 100644 --- a/fastly/fixtures/waf_versions/deploy.yaml +++ b/fastly/fixtures/waf_versions/deploy.yaml @@ -11,26 +11,28 @@ interactions: Content-Type: - application/vnd.api+json User-Agent: - - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) - url: https://api.fastly.com/waf/firewalls/3bhISXhyFhsufhCFnTst1j/versions/1 + - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) + url: https://api.fastly.com/waf/firewalls/6gj91AAsD3ndcoKaplqiq8/versions/1 method: POST response: - body: '{"errors":[],"data":null}' + body: '{}' headers: Accept-Ranges: - bytes + - bytes Content-Length: - - "25" + - "2" Content-Type: - application/vnd.api+json Date: - - Mon, 25 Nov 2019 14:43:32 GMT + - Tue, 30 Jun 2020 10:56:28 GMT Status: - 202 Accepted Strict-Transport-Security: - max-age=31536000 Via: - 1.1 varnish + - 1.1 varnish X-Cache: - MISS, MISS X-Cache-Hits: @@ -38,9 +40,9 @@ interactions: X-Content-Type-Options: - nosniff X-Served-By: - - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19271-LCY + - cache-control-slwdc9035-CONTROL-SLWDC, cache-lcy19235-LCY X-Timer: - - S1574693013.536450,VS0,VE158 + - S1593514588.222313,VS0,VE148 status: 202 Accepted code: 202 duration: "" diff --git a/fastly/fixtures/waf_versions/get.yaml b/fastly/fixtures/waf_versions/get.yaml index 2a0a878de..ce020382d 100644 --- a/fastly/fixtures/waf_versions/get.yaml +++ b/fastly/fixtures/waf_versions/get.yaml @@ -6,36 +6,39 @@ interactions: form: {} headers: User-Agent: - - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) - url: https://api.fastly.com/waf/firewalls/3bhISXhyFhsufhCFnTst1j/versions/2 + - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) + url: https://api.fastly.com/waf/firewalls/6gj91AAsD3ndcoKaplqiq8/versions/2 method: GET response: - body: '{"data":{"id":"4x66aw12P6aLHGwK4KzGni","type":"waf_firewall_version","attributes":{"number":2,"comment":null,"active":null,"locked":false,"error":null,"deployed_at":null,"critical_anomaly_score":5,"error_anomaly_score":4,"warning_anomaly_score":3,"notice_anomaly_score":2,"http_violation_score_threshold":999,"inbound_anomaly_score_threshold":999,"lfi_score_threshold":999,"php_injection_score_threshold":999,"rce_score_threshold":999,"rfi_score_threshold":999,"session_fixation_score_threshold":999,"sql_injection_score_threshold":999,"xss_score_threshold":999,"paranoia_level":1,"arg_name_length":100,"arg_length":400,"total_arg_length":6400,"max_file_size":10000000,"combined_file_sizes":10000000,"max_num_args":255,"high_risk_country_codes":"","allowed_methods":"GET - HEAD POST OPTIONS PUT PATCH DELETE","restricted_headers":"/proxy/ /lock-token/ - /content-range/ /translate/ /if/","restricted_extensions":".asa/ .asax/ .ascx/ - .axd/ .backup/ .bak/ .bat/ .cdx/ .cer/ .cfg/ .cmd/ .com/ .config/ .conf/ .cs/ - .csproj/ .csr/ .dat/ .db/ .dbf/ .dll/ .dos/ .htr/ .htw/ .ida/ .idc/ .idq/ .inc/ - .ini/ .key/ .licx/ .lnk/ .log/ .mdb/ .old/ .pass/ .pdb/ .pol/ .printer/ .pwd/ - .resources/ .resx/ .sql/ .sys/ .vb/ .vbs/ .vbproj/ .vsdisco/ .webinfo/ .xsd/ - .xsx/","allowed_request_content_type":"application/x-www-form-urlencoded|multipart/form-data|text/xml|application/xml|application/soap+xml|application/x-amf|application/json|application/octet-stream|application/csp-report|application/xss-auditor-report|text/plain","allowed_request_content_type_charset":"utf-8|iso-8859-1|iso-8859-15|windows-1252","allowed_http_versions":"HTTP/1.0 - HTTP/1.1 HTTP/2","crs_validate_utf8_encoding":false,"created_at":"2019-11-25T14:43:32Z","updated_at":"2019-11-25T14:43:32Z","active_rules_trustwave_log_count":0,"active_rules_trustwave_block_count":0,"active_rules_fastly_log_count":0,"active_rules_fastly_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_score_count":0}}}' + body: '{"data":{"id":"3LP12sn59pB0iz0Kh75cHb","type":"waf_firewall_version","attributes":{"active":false,"active_rules_fastly_block_count":0,"active_rules_fastly_log_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_score_count":0,"active_rules_trustwave_block_count":0,"active_rules_trustwave_log_count":0,"allowed_http_versions":"HTTP/1.0 + HTTP/1.1 HTTP/2","allowed_methods":"GET HEAD POST OPTIONS PUT PATCH DELETE","allowed_request_content_type":"application/x-www-form-urlencoded|multipart/form-data|text/xml|application/xml|application/soap+xml|application/x-amf|application/json|application/octet-stream|application/csp-report|application/xss-auditor-report|text/plain","allowed_request_content_type_charset":"utf-8|iso-8859-1|iso-8859-15|windows-1252","arg_name_length":100,"arg_length":400,"combined_file_sizes":10000000,"comment":null,"created_at":"2020-06-30T10:56:28Z","critical_anomaly_score":5,"crs_validate_utf8_encoding":false,"deployed_at":null,"error":null,"error_anomaly_score":4,"high_risk_country_codes":"","http_violation_score_threshold":999,"inbound_anomaly_score_threshold":999,"last_deployment_status":null,"lfi_score_threshold":999,"locked":false,"max_file_size":10000000,"max_num_args":255,"notice_anomaly_score":2,"number":2,"paranoia_level":1,"php_injection_score_threshold":999,"rce_score_threshold":999,"restricted_extensions":".asa/ + .asax/ .ascx/ .axd/ .backup/ .bak/ .bat/ .cdx/ .cer/ .cfg/ .cmd/ .com/ .config/ + .conf/ .cs/ .csproj/ .csr/ .dat/ .db/ .dbf/ .dll/ .dos/ .htr/ .htw/ .ida/ .idc/ + .idq/ .inc/ .ini/ .key/ .licx/ .lnk/ .log/ .mdb/ .old/ .pass/ .pdb/ .pol/ .printer/ + .pwd/ .resources/ .resx/ .sql/ .sys/ .vb/ .vbs/ .vbproj/ .vsdisco/ .webinfo/ + .xsd/ .xsx/","restricted_headers":"/proxy/ /lock-token/ /content-range/ /translate/ + /if/","rfi_score_threshold":999,"session_fixation_score_threshold":999,"sql_injection_score_threshold":999,"total_arg_length":6400,"updated_at":"2020-06-30T10:56:28Z","warning_anomaly_score":3,"xss_score_threshold":999}}}' headers: Accept-Ranges: - bytes + - bytes + - bytes Age: - "0" + - "0" Content-Length: - - "1999" + - "2030" Content-Type: - application/vnd.api+json Date: - - Mon, 25 Nov 2019 14:43:33 GMT + - Tue, 30 Jun 2020 10:56:28 GMT Status: - 200 OK Strict-Transport-Security: - max-age=31536000 Via: - 1.1 varnish + - 1.1 varnish X-Cache: - MISS, MISS X-Cache-Hits: @@ -43,9 +46,9 @@ interactions: X-Content-Type-Options: - nosniff X-Served-By: - - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19271-LCY + - cache-control-slwdc9036-CONTROL-SLWDC, cache-lcy19235-LCY X-Timer: - - S1574693013.970868,VS0,VE452 + - S1593514589.802406,VS0,VE149 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/waf_versions/list.yaml b/fastly/fixtures/waf_versions/list.yaml index aab15354b..915001c87 100644 --- a/fastly/fixtures/waf_versions/list.yaml +++ b/fastly/fixtures/waf_versions/list.yaml @@ -6,36 +6,39 @@ interactions: form: {} headers: User-Agent: - - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) - url: https://api.fastly.com/waf/firewalls/3bhISXhyFhsufhCFnTst1j/versions + - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) + url: https://api.fastly.com/waf/firewalls/6gj91AAsD3ndcoKaplqiq8/versions method: GET response: - body: '{"data":[{"id":"7i72jnPlJu3AjUC7nfewht","type":"waf_firewall_version","attributes":{"number":1,"comment":null,"active":null,"locked":null,"error":null,"deployed_at":null,"critical_anomaly_score":5,"error_anomaly_score":4,"warning_anomaly_score":3,"notice_anomaly_score":2,"http_violation_score_threshold":999,"inbound_anomaly_score_threshold":999,"lfi_score_threshold":999,"php_injection_score_threshold":999,"rce_score_threshold":999,"rfi_score_threshold":999,"session_fixation_score_threshold":999,"sql_injection_score_threshold":999,"xss_score_threshold":999,"paranoia_level":1,"arg_name_length":100,"arg_length":400,"total_arg_length":6400,"max_file_size":10000000,"combined_file_sizes":10000000,"max_num_args":255,"high_risk_country_codes":"","allowed_methods":"GET - HEAD POST OPTIONS PUT PATCH DELETE","restricted_headers":"/proxy/ /lock-token/ - /content-range/ /translate/ /if/","restricted_extensions":".asa/ .asax/ .ascx/ - .axd/ .backup/ .bak/ .bat/ .cdx/ .cer/ .cfg/ .cmd/ .com/ .config/ .conf/ .cs/ - .csproj/ .csr/ .dat/ .db/ .dbf/ .dll/ .dos/ .htr/ .htw/ .ida/ .idc/ .idq/ .inc/ - .ini/ .key/ .licx/ .lnk/ .log/ .mdb/ .old/ .pass/ .pdb/ .pol/ .printer/ .pwd/ - .resources/ .resx/ .sql/ .sys/ .vb/ .vbs/ .vbproj/ .vsdisco/ .webinfo/ .xsd/ - .xsx/","allowed_request_content_type":"application/x-www-form-urlencoded|multipart/form-data|text/xml|application/xml|application/soap+xml|application/x-amf|application/json|application/octet-stream|application/csp-report|application/xss-auditor-report|text/plain","allowed_request_content_type_charset":"utf-8|iso-8859-1|iso-8859-15|windows-1252","allowed_http_versions":"HTTP/1.0 - HTTP/1.1 HTTP/2","crs_validate_utf8_encoding":false,"created_at":"2019-11-25T14:43:32Z","updated_at":"2019-11-25T14:43:32Z","active_rules_trustwave_log_count":0,"active_rules_trustwave_block_count":0,"active_rules_fastly_log_count":0,"active_rules_fastly_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_score_count":0}}],"links":{"last":"https://api.fastly.com/waf/firewalls/3bhISXhyFhsufhCFnTst1j/versions?page[number]=1\u0026page[size]=100","first":"https://api.fastly.com/waf/firewalls/3bhISXhyFhsufhCFnTst1j/versions?page[number]=1\u0026page[size]=100"},"meta":{"current_page":1,"per_page":100,"record_count":1,"total_pages":1}}' + body: '{"data":[{"id":"5QIeb4KiWL4GRSXcbrJwlU","type":"waf_firewall_version","attributes":{"active":false,"active_rules_fastly_block_count":0,"active_rules_fastly_log_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_score_count":0,"active_rules_trustwave_block_count":0,"active_rules_trustwave_log_count":0,"allowed_http_versions":"HTTP/1.0 + HTTP/1.1 HTTP/2","allowed_methods":"GET HEAD POST OPTIONS PUT PATCH DELETE","allowed_request_content_type":"application/x-www-form-urlencoded|multipart/form-data|text/xml|application/xml|application/soap+xml|application/x-amf|application/json|application/octet-stream|application/csp-report|application/xss-auditor-report|text/plain","allowed_request_content_type_charset":"utf-8|iso-8859-1|iso-8859-15|windows-1252","arg_name_length":100,"arg_length":400,"combined_file_sizes":10000000,"comment":null,"created_at":"2020-06-30T10:56:27Z","critical_anomaly_score":5,"crs_validate_utf8_encoding":false,"deployed_at":null,"error":null,"error_anomaly_score":4,"high_risk_country_codes":"","http_violation_score_threshold":999,"inbound_anomaly_score_threshold":999,"last_deployment_status":null,"lfi_score_threshold":999,"locked":false,"max_file_size":10000000,"max_num_args":255,"notice_anomaly_score":2,"number":1,"paranoia_level":1,"php_injection_score_threshold":999,"rce_score_threshold":999,"restricted_extensions":".asa/ + .asax/ .ascx/ .axd/ .backup/ .bak/ .bat/ .cdx/ .cer/ .cfg/ .cmd/ .com/ .config/ + .conf/ .cs/ .csproj/ .csr/ .dat/ .db/ .dbf/ .dll/ .dos/ .htr/ .htw/ .ida/ .idc/ + .idq/ .inc/ .ini/ .key/ .licx/ .lnk/ .log/ .mdb/ .old/ .pass/ .pdb/ .pol/ .printer/ + .pwd/ .resources/ .resx/ .sql/ .sys/ .vb/ .vbs/ .vbproj/ .vsdisco/ .webinfo/ + .xsd/ .xsx/","restricted_headers":"/proxy/ /lock-token/ /content-range/ /translate/ + /if/","rfi_score_threshold":999,"session_fixation_score_threshold":999,"sql_injection_score_threshold":999,"total_arg_length":6400,"updated_at":"2020-06-30T10:56:27Z","warning_anomaly_score":3,"xss_score_threshold":999}}],"links":{"last":"https://api.fastly.com/waf/firewalls/6gj91AAsD3ndcoKaplqiq8/versions?page[number]=1\u0026page[size]=100","first":"https://api.fastly.com/waf/firewalls/6gj91AAsD3ndcoKaplqiq8/versions?page[number]=1\u0026page[size]=100"},"meta":{"current_page":1,"per_page":100,"record_count":1,"total_pages":1}}' headers: Accept-Ranges: - bytes + - bytes + - bytes Age: - "0" + - "0" Content-Length: - - "2311" + - "2343" Content-Type: - application/vnd.api+json Date: - - Mon, 25 Nov 2019 14:43:32 GMT + - Tue, 30 Jun 2020 10:56:28 GMT Status: - 200 OK Strict-Transport-Security: - max-age=31536000 Via: - 1.1 varnish + - 1.1 varnish X-Cache: - MISS, MISS X-Cache-Hits: @@ -43,9 +46,9 @@ interactions: X-Content-Type-Options: - nosniff X-Served-By: - - cache-control-slwdc9036-CONTROL-SLWDC, cache-lcy19271-LCY + - cache-control-slwdc9036-CONTROL-SLWDC, cache-lcy19235-LCY X-Timer: - - S1574693012.243526,VS0,VE276 + - S1593514588.005669,VS0,VE155 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/waf_versions/list_all.yaml b/fastly/fixtures/waf_versions/list_all.yaml index 82f78f3f5..bff3ca98c 100644 --- a/fastly/fixtures/waf_versions/list_all.yaml +++ b/fastly/fixtures/waf_versions/list_all.yaml @@ -6,39 +6,43 @@ interactions: form: {} headers: User-Agent: - - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) - url: https://api.fastly.com/waf/firewalls/3bhISXhyFhsufhCFnTst1j/versions?page%5Bnumber%5D=1&page%5Bsize%5D=100 + - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) + url: https://api.fastly.com/waf/firewalls/6gj91AAsD3ndcoKaplqiq8/versions?page%5Bnumber%5D=1&page%5Bsize%5D=100 method: GET response: - body: '{"data":[{"id":"7i72jnPlJu3AjUC7nfewht","type":"waf_firewall_version","attributes":{"number":1,"comment":null,"active":true,"locked":true,"error":null,"deployed_at":"2019-11-25T14:43:33Z","critical_anomaly_score":5,"error_anomaly_score":4,"warning_anomaly_score":3,"notice_anomaly_score":2,"http_violation_score_threshold":999,"inbound_anomaly_score_threshold":999,"lfi_score_threshold":999,"php_injection_score_threshold":999,"rce_score_threshold":999,"rfi_score_threshold":999,"session_fixation_score_threshold":999,"sql_injection_score_threshold":999,"xss_score_threshold":999,"paranoia_level":1,"arg_name_length":100,"arg_length":400,"total_arg_length":6400,"max_file_size":10000000,"combined_file_sizes":10000000,"max_num_args":255,"high_risk_country_codes":"","allowed_methods":"GET - HEAD POST OPTIONS PUT PATCH DELETE","restricted_headers":"/proxy/ /lock-token/ - /content-range/ /translate/ /if/","restricted_extensions":".asa/ .asax/ .ascx/ - .axd/ .backup/ .bak/ .bat/ .cdx/ .cer/ .cfg/ .cmd/ .com/ .config/ .conf/ .cs/ - .csproj/ .csr/ .dat/ .db/ .dbf/ .dll/ .dos/ .htr/ .htw/ .ida/ .idc/ .idq/ .inc/ - .ini/ .key/ .licx/ .lnk/ .log/ .mdb/ .old/ .pass/ .pdb/ .pol/ .printer/ .pwd/ - .resources/ .resx/ .sql/ .sys/ .vb/ .vbs/ .vbproj/ .vsdisco/ .webinfo/ .xsd/ - .xsx/","allowed_request_content_type":"application/x-www-form-urlencoded|multipart/form-data|text/xml|application/xml|application/soap+xml|application/x-amf|application/json|application/octet-stream|application/csp-report|application/xss-auditor-report|text/plain","allowed_request_content_type_charset":"utf-8|iso-8859-1|iso-8859-15|windows-1252","allowed_http_versions":"HTTP/1.0 - HTTP/1.1 HTTP/2","crs_validate_utf8_encoding":false,"created_at":"2019-11-25T14:43:32Z","updated_at":"2019-11-25T14:43:33Z","active_rules_trustwave_log_count":0,"active_rules_trustwave_block_count":0,"active_rules_fastly_log_count":0,"active_rules_fastly_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_score_count":0}},{"id":"4x66aw12P6aLHGwK4KzGni","type":"waf_firewall_version","attributes":{"number":2,"comment":null,"active":null,"locked":true,"error":null,"deployed_at":null,"critical_anomaly_score":12,"error_anomaly_score":10,"warning_anomaly_score":20,"notice_anomaly_score":8,"http_violation_score_threshold":20,"inbound_anomaly_score_threshold":20,"lfi_score_threshold":20,"php_injection_score_threshold":20,"rce_score_threshold":20,"rfi_score_threshold":20,"session_fixation_score_threshold":20,"sql_injection_score_threshold":20,"xss_score_threshold":20,"paranoia_level":2,"arg_name_length":200,"arg_length":800,"total_arg_length":12800,"max_file_size":20000000,"combined_file_sizes":20000000,"max_num_args":510,"high_risk_country_codes":"gb","allowed_methods":"GET - HEAD POST","restricted_headers":"/proxy/ /lock-token/","restricted_extensions":".asa/ - .asax/ .ascx/ .axd/ .backup/ .bak/ .bat/ .cdx/ .cer/ .cfg/ .cmd/ .com/","allowed_request_content_type":"application/x-www-form-urlencoded|multipart/form-data|text/xml|application/xml","allowed_request_content_type_charset":"utf-8|iso-8859-1","allowed_http_versions":"HTTP/1.0 - HTTP/1.1","crs_validate_utf8_encoding":true,"created_at":"2019-11-25T14:43:32Z","updated_at":"2019-11-25T14:43:34Z","active_rules_trustwave_log_count":0,"active_rules_trustwave_block_count":0,"active_rules_fastly_log_count":0,"active_rules_fastly_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_score_count":0}}],"links":{"last":"https://api.fastly.com/waf/firewalls/3bhISXhyFhsufhCFnTst1j/versions?page[number]=1\u0026page[size]=20","first":"https://api.fastly.com/waf/firewalls/3bhISXhyFhsufhCFnTst1j/versions?page[number]=1\u0026page[size]=20"},"meta":{"current_page":1,"per_page":20,"record_count":2,"total_pages":1}}' + body: '{"data":[{"id":"3LP12sn59pB0iz0Kh75cHb","type":"waf_firewall_version","attributes":{"active":false,"active_rules_fastly_block_count":0,"active_rules_fastly_log_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_score_count":0,"active_rules_trustwave_block_count":0,"active_rules_trustwave_log_count":0,"allowed_http_versions":"HTTP/1.0 + HTTP/1.1","allowed_methods":"GET HEAD POST","allowed_request_content_type":"application/x-www-form-urlencoded|multipart/form-data|text/xml|application/xml","allowed_request_content_type_charset":"utf-8|iso-8859-1","arg_name_length":200,"arg_length":800,"combined_file_sizes":20000000,"comment":"my + comment","created_at":"2020-06-30T10:56:28Z","critical_anomaly_score":12,"crs_validate_utf8_encoding":true,"deployed_at":null,"error":null,"error_anomaly_score":10,"high_risk_country_codes":"gb","http_violation_score_threshold":20,"inbound_anomaly_score_threshold":20,"last_deployment_status":null,"lfi_score_threshold":20,"locked":true,"max_file_size":20000000,"max_num_args":510,"notice_anomaly_score":8,"number":2,"paranoia_level":2,"php_injection_score_threshold":20,"rce_score_threshold":20,"restricted_extensions":".asa/ + .asax/ .ascx/ .axd/ .backup/ .bak/ .bat/ .cdx/ .cer/ .cfg/ .cmd/ .com/","restricted_headers":"/proxy/ + /lock-token/","rfi_score_threshold":20,"session_fixation_score_threshold":20,"sql_injection_score_threshold":20,"total_arg_length":12800,"updated_at":"2020-06-30T10:56:29Z","warning_anomaly_score":20,"xss_score_threshold":20}},{"id":"5QIeb4KiWL4GRSXcbrJwlU","type":"waf_firewall_version","attributes":{"active":true,"active_rules_fastly_block_count":0,"active_rules_fastly_log_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_score_count":0,"active_rules_trustwave_block_count":0,"active_rules_trustwave_log_count":0,"allowed_http_versions":"HTTP/1.0 + HTTP/1.1 HTTP/2","allowed_methods":"GET HEAD POST OPTIONS PUT PATCH DELETE","allowed_request_content_type":"application/x-www-form-urlencoded|multipart/form-data|text/xml|application/xml|application/soap+xml|application/x-amf|application/json|application/octet-stream|application/csp-report|application/xss-auditor-report|text/plain","allowed_request_content_type_charset":"utf-8|iso-8859-1|iso-8859-15|windows-1252","arg_name_length":100,"arg_length":400,"combined_file_sizes":10000000,"comment":null,"created_at":"2020-06-30T10:56:27Z","critical_anomaly_score":5,"crs_validate_utf8_encoding":false,"deployed_at":"2020-06-30T10:56:28Z","error":null,"error_anomaly_score":4,"high_risk_country_codes":"","http_violation_score_threshold":999,"inbound_anomaly_score_threshold":999,"last_deployment_status":"completed","lfi_score_threshold":999,"locked":true,"max_file_size":10000000,"max_num_args":255,"notice_anomaly_score":2,"number":1,"paranoia_level":1,"php_injection_score_threshold":999,"rce_score_threshold":999,"restricted_extensions":".asa/ + .asax/ .ascx/ .axd/ .backup/ .bak/ .bat/ .cdx/ .cer/ .cfg/ .cmd/ .com/ .config/ + .conf/ .cs/ .csproj/ .csr/ .dat/ .db/ .dbf/ .dll/ .dos/ .htr/ .htw/ .ida/ .idc/ + .idq/ .inc/ .ini/ .key/ .licx/ .lnk/ .log/ .mdb/ .old/ .pass/ .pdb/ .pol/ .printer/ + .pwd/ .resources/ .resx/ .sql/ .sys/ .vb/ .vbs/ .vbproj/ .vsdisco/ .webinfo/ + .xsd/ .xsx/","restricted_headers":"/proxy/ /lock-token/ /content-range/ /translate/ + /if/","rfi_score_threshold":999,"session_fixation_score_threshold":999,"sql_injection_score_threshold":999,"total_arg_length":6400,"updated_at":"2020-06-30T10:56:28Z","warning_anomaly_score":3,"xss_score_threshold":999}}],"links":{"last":"https://api.fastly.com/waf/firewalls/6gj91AAsD3ndcoKaplqiq8/versions?page[number]=1\u0026page[size]=100","first":"https://api.fastly.com/waf/firewalls/6gj91AAsD3ndcoKaplqiq8/versions?page[number]=1\u0026page[size]=100"},"meta":{"current_page":1,"per_page":100,"record_count":2,"total_pages":1}}' headers: Accept-Ranges: - bytes + - bytes + - bytes Age: - "0" + - "0" Content-Length: - - "3814" + - "3893" Content-Type: - application/vnd.api+json Date: - - Mon, 25 Nov 2019 14:43:34 GMT + - Tue, 30 Jun 2020 10:56:29 GMT Status: - 200 OK Strict-Transport-Security: - max-age=31536000 Via: - 1.1 varnish + - 1.1 varnish X-Cache: - MISS, MISS X-Cache-Hits: @@ -46,9 +50,9 @@ interactions: X-Content-Type-Options: - nosniff X-Served-By: - - cache-control-slwdc9035-CONTROL-SLWDC, cache-lcy19271-LCY + - cache-control-slwdc9036-CONTROL-SLWDC, cache-lcy19235-LCY X-Timer: - - S1574693014.202293,VS0,VE160 + - S1593514590.633771,VS0,VE172 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/waf_versions/lock.yaml b/fastly/fixtures/waf_versions/lock.yaml index ef3b13e46..47e3aaddb 100644 --- a/fastly/fixtures/waf_versions/lock.yaml +++ b/fastly/fixtures/waf_versions/lock.yaml @@ -11,29 +11,32 @@ interactions: Content-Type: - application/vnd.api+json User-Agent: - - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) - url: https://api.fastly.com/waf/firewalls/3bhISXhyFhsufhCFnTst1j/versions/2/lock + - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) + url: https://api.fastly.com/waf/firewalls/6gj91AAsD3ndcoKaplqiq8/versions/2/lock method: PUT response: - body: '{"data":{"id":"4x66aw12P6aLHGwK4KzGni","type":"waf_firewall_version","attributes":{"number":2,"comment":null,"active":null,"locked":true,"error":null,"deployed_at":null,"critical_anomaly_score":12,"error_anomaly_score":10,"warning_anomaly_score":20,"notice_anomaly_score":8,"http_violation_score_threshold":20,"inbound_anomaly_score_threshold":20,"lfi_score_threshold":20,"php_injection_score_threshold":20,"rce_score_threshold":20,"rfi_score_threshold":20,"session_fixation_score_threshold":20,"sql_injection_score_threshold":20,"xss_score_threshold":20,"paranoia_level":2,"arg_name_length":200,"arg_length":800,"total_arg_length":12800,"max_file_size":20000000,"combined_file_sizes":20000000,"max_num_args":510,"high_risk_country_codes":"gb","allowed_methods":"GET - HEAD POST","restricted_headers":"/proxy/ /lock-token/","restricted_extensions":".asa/ - .asax/ .ascx/ .axd/ .backup/ .bak/ .bat/ .cdx/ .cer/ .cfg/ .cmd/ .com/","allowed_request_content_type":"application/x-www-form-urlencoded|multipart/form-data|text/xml|application/xml","allowed_request_content_type_charset":"utf-8|iso-8859-1","allowed_http_versions":"HTTP/1.0 - HTTP/1.1","crs_validate_utf8_encoding":true,"created_at":"2019-11-25T14:43:32Z","updated_at":"2019-11-25T14:43:34Z","active_rules_trustwave_log_count":0,"active_rules_trustwave_block_count":0,"active_rules_fastly_log_count":0,"active_rules_fastly_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_score_count":0},"relationships":{"waf_firewall":{"data":{"id":"3bhISXhyFhsufhCFnTst1j","type":"waf_firewall"}}}}}' + body: '{"data":{"id":"3LP12sn59pB0iz0Kh75cHb","type":"waf_firewall_version","attributes":{"active":false,"active_rules_fastly_block_count":0,"active_rules_fastly_log_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_score_count":0,"active_rules_trustwave_block_count":0,"active_rules_trustwave_log_count":0,"allowed_http_versions":"HTTP/1.0 + HTTP/1.1","allowed_methods":"GET HEAD POST","allowed_request_content_type":"application/x-www-form-urlencoded|multipart/form-data|text/xml|application/xml","allowed_request_content_type_charset":"utf-8|iso-8859-1","arg_name_length":200,"arg_length":800,"combined_file_sizes":20000000,"comment":"my + comment","created_at":"2020-06-30T10:56:28Z","critical_anomaly_score":12,"crs_validate_utf8_encoding":true,"deployed_at":null,"error":null,"error_anomaly_score":10,"high_risk_country_codes":"gb","http_violation_score_threshold":20,"inbound_anomaly_score_threshold":20,"last_deployment_status":null,"lfi_score_threshold":20,"locked":true,"max_file_size":20000000,"max_num_args":510,"notice_anomaly_score":8,"number":2,"paranoia_level":2,"php_injection_score_threshold":20,"rce_score_threshold":20,"restricted_extensions":".asa/ + .asax/ .ascx/ .axd/ .backup/ .bak/ .bat/ .cdx/ .cer/ .cfg/ .cmd/ .com/","restricted_headers":"/proxy/ + /lock-token/","rfi_score_threshold":20,"session_fixation_score_threshold":20,"sql_injection_score_threshold":20,"total_arg_length":12800,"updated_at":"2020-06-30T10:56:29Z","warning_anomaly_score":20,"xss_score_threshold":20},"relationships":{"waf_firewall":{"data":{"id":"6gj91AAsD3ndcoKaplqiq8","type":"waf_firewall"}}}}}' headers: Accept-Ranges: - bytes + - bytes Content-Length: - - "1592" + - "1631" Content-Type: - application/vnd.api+json Date: - - Mon, 25 Nov 2019 14:43:34 GMT + - Tue, 30 Jun 2020 10:56:29 GMT Status: - 200 OK Strict-Transport-Security: - max-age=31536000 Via: - 1.1 varnish + - 1.1 varnish X-Cache: - MISS, MISS X-Cache-Hits: @@ -41,9 +44,9 @@ interactions: X-Content-Type-Options: - nosniff X-Served-By: - - cache-control-slwdc9035-CONTROL-SLWDC, cache-lcy19271-LCY + - cache-control-slwdc9036-CONTROL-SLWDC, cache-lcy19235-LCY X-Timer: - - S1574693014.998478,VS0,VE156 + - S1593514589.295264,VS0,VE174 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/waf_versions/logging/create.yaml b/fastly/fixtures/waf_versions/logging/create.yaml index fbff5b9ac..986432fda 100644 --- a/fastly/fixtures/waf_versions/logging/create.yaml +++ b/fastly/fixtures/waf_versions/logging/create.yaml @@ -2,10 +2,10 @@ version: 1 interactions: - request: - body: Service=300YFPn1PVF82Na4SUkiqy&Version=2&address=example.com&format=format&format_version=2&hostname=example.com&message_type=classic&name=test-syslog&port=1234&token=abcd1234 + body: Service=3BOOVoayIlrdMuRU8LrKSA&Version=2&address=example.com&format=format&format_version=2&hostname=example.com&message_type=classic&name=test-syslog&port=1234&token=abcd1234 form: Service: - - 300YFPn1PVF82Na4SUkiqy + - 3BOOVoayIlrdMuRU8LrKSA Version: - "2" address: @@ -28,11 +28,11 @@ interactions: Content-Type: - application/x-www-form-urlencoded User-Agent: - - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) - url: https://api.fastly.com/service/300YFPn1PVF82Na4SUkiqy/version/2/logging/syslog + - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) + url: https://api.fastly.com/service/3BOOVoayIlrdMuRU8LrKSA/version/2/logging/syslog method: POST response: - body: '{"address":"example.com","format":"format","format_version":"2","hostname":"example.com","message_type":"classic","name":"test-syslog","port":"1234","token":"abcd1234","service_id":"300YFPn1PVF82Na4SUkiqy","version":"2","public_key":null,"tls_client_cert":null,"use_tls":"0","ipv4":null,"created_at":"2019-11-25T14:43:30Z","tls_hostname":null,"deleted_at":null,"tls_ca_cert":null,"response_condition":"","tls_client_key":null,"placement":null,"updated_at":"2019-11-25T14:43:30Z"}' + body: '{"address":"example.com","format":"format","format_version":"2","hostname":"example.com","message_type":"classic","name":"test-syslog","port":"1234","token":"abcd1234","service_id":"3BOOVoayIlrdMuRU8LrKSA","version":"2","tls_ca_cert":null,"tls_client_key":null,"updated_at":"2020-06-30T10:56:25Z","created_at":"2020-06-30T10:56:25Z","tls_hostname":null,"placement":null,"response_condition":"","use_tls":"0","tls_client_cert":null,"ipv4":null,"deleted_at":null,"public_key":null}' headers: Accept-Ranges: - bytes @@ -42,11 +42,11 @@ interactions: Content-Type: - application/json Date: - - Mon, 25 Nov 2019 14:43:30 GMT + - Tue, 30 Jun 2020 10:56:25 GMT Fastly-Ratelimit-Remaining: - - "997" + - "684" Fastly-Ratelimit-Reset: - - "1574694000" + - "1593514800" Status: - 200 OK Strict-Transport-Security: @@ -55,14 +55,15 @@ interactions: - Accept-Encoding Via: - 1.1 varnish + - 1.1 varnish X-Cache: - MISS, MISS X-Cache-Hits: - 0, 0 X-Served-By: - - cache-control-slwdc9035-CONTROL-SLWDC, cache-lcy19271-LCY + - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19235-LCY X-Timer: - - S1574693010.990980,VS0,VE660 + - S1593514585.355101,VS0,VE520 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/waf_versions/logging/delete.yaml b/fastly/fixtures/waf_versions/logging/delete.yaml index 007236f7e..0bfb5a772 100644 --- a/fastly/fixtures/waf_versions/logging/delete.yaml +++ b/fastly/fixtures/waf_versions/logging/delete.yaml @@ -6,8 +6,8 @@ interactions: form: {} headers: User-Agent: - - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) - url: https://api.fastly.com/service/300YFPn1PVF82Na4SUkiqy/version/2/logging/syslog/test-syslog + - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) + url: https://api.fastly.com/service/3BOOVoayIlrdMuRU8LrKSA/version/2/logging/syslog/test-syslog method: DELETE response: body: '{"status":"ok"}' @@ -20,11 +20,11 @@ interactions: Content-Type: - application/json Date: - - Mon, 25 Nov 2019 14:43:36 GMT + - Tue, 30 Jun 2020 10:56:31 GMT Fastly-Ratelimit-Remaining: - - "992" + - "672" Fastly-Ratelimit-Reset: - - "1574694000" + - "1593514800" Status: - 200 OK Strict-Transport-Security: @@ -33,14 +33,15 @@ interactions: - Accept-Encoding Via: - 1.1 varnish + - 1.1 varnish X-Cache: - MISS, MISS X-Cache-Hits: - 0, 0 X-Served-By: - - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19271-LCY + - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19235-LCY X-Timer: - - S1574693016.629715,VS0,VE393 + - S1593514592.662938,VS0,VE244 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/waf_versions/response_object/create.yaml b/fastly/fixtures/waf_versions/response_object/create.yaml index 1af41aa65..47f41cc4f 100644 --- a/fastly/fixtures/waf_versions/response_object/create.yaml +++ b/fastly/fixtures/waf_versions/response_object/create.yaml @@ -2,44 +2,39 @@ version: 1 interactions: - request: - body: Service=300YFPn1PVF82Na4SUkiqy&Version=2&content=abcd&content_type=text%2Fplain&name=WAf_Response&response=Ok&status=200 + body: Service=3BOOVoayIlrdMuRU8LrKSA&Version=2&name=WAf_Response&status=403 form: Service: - - 300YFPn1PVF82Na4SUkiqy + - 3BOOVoayIlrdMuRU8LrKSA Version: - "2" - content: - - abcd - content_type: - - text/plain name: - WAf_Response - response: - - Ok status: - - "200" + - "403" headers: Content-Type: - application/x-www-form-urlencoded User-Agent: - - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) - url: https://api.fastly.com/service/300YFPn1PVF82Na4SUkiqy/version/2/response_object + - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) + url: https://api.fastly.com/service/3BOOVoayIlrdMuRU8LrKSA/version/2/response_object method: POST response: - body: '{"content":"abcd","content_type":"text/plain","name":"WAf_Response","response":"Ok","status":"200","service_id":"300YFPn1PVF82Na4SUkiqy","version":"2","cache_condition":"","created_at":"2019-11-25T14:43:31Z","request_condition":"","updated_at":"2019-11-25T14:43:31Z","deleted_at":null}' + body: '{"name":"WAf_Response","status":"403","service_id":"3BOOVoayIlrdMuRU8LrKSA","version":"2","content":null,"cache_condition":"","request_condition":"","updated_at":"2020-06-30T10:56:26Z","content_type":null,"created_at":"2020-06-30T10:56:26Z","deleted_at":null,"response":"ok"}' headers: Accept-Ranges: - bytes + - bytes Cache-Control: - no-cache Content-Type: - application/json Date: - - Mon, 25 Nov 2019 14:43:31 GMT + - Tue, 30 Jun 2020 10:56:27 GMT Fastly-Ratelimit-Remaining: - - "995" + - "679" Fastly-Ratelimit-Reset: - - "1574694000" + - "1593514800" Status: - 200 OK Strict-Transport-Security: @@ -48,14 +43,15 @@ interactions: - Accept-Encoding Via: - 1.1 varnish + - 1.1 varnish X-Cache: - MISS, MISS X-Cache-Hits: - 0, 0 X-Served-By: - - cache-control-slwdc9036-CONTROL-SLWDC, cache-lcy19271-LCY + - cache-control-slwdc9036-CONTROL-SLWDC, cache-lcy19235-LCY X-Timer: - - S1574693011.918974,VS0,VE307 + - S1593514587.562114,VS0,VE489 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/waf_versions/response_object/delete.yaml b/fastly/fixtures/waf_versions/response_object/delete.yaml index 22889cdda..f5f55bf35 100644 --- a/fastly/fixtures/waf_versions/response_object/delete.yaml +++ b/fastly/fixtures/waf_versions/response_object/delete.yaml @@ -6,8 +6,8 @@ interactions: form: {} headers: User-Agent: - - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) - url: https://api.fastly.com/service/300YFPn1PVF82Na4SUkiqy/version/2/response_object/WAf_Response + - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) + url: https://api.fastly.com/service/3BOOVoayIlrdMuRU8LrKSA/version/2/response_object/WAf_Response method: DELETE response: body: '{"status":"ok"}' @@ -20,11 +20,11 @@ interactions: Content-Type: - application/json Date: - - Mon, 25 Nov 2019 14:43:35 GMT + - Tue, 30 Jun 2020 10:56:31 GMT Fastly-Ratelimit-Remaining: - - "994" + - "676" Fastly-Ratelimit-Reset: - - "1574694000" + - "1593514800" Status: - 200 OK Strict-Transport-Security: @@ -33,14 +33,15 @@ interactions: - Accept-Encoding Via: - 1.1 varnish + - 1.1 varnish X-Cache: - MISS, MISS X-Cache-Hits: - 0, 0 X-Served-By: - - cache-control-slwdc9036-CONTROL-SLWDC, cache-lcy19271-LCY + - cache-control-slwdc9035-CONTROL-SLWDC, cache-lcy19235-LCY X-Timer: - - S1574693015.809568,VS0,VE403 + - S1593514591.815615,VS0,VE249 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/waf_versions/service/create.yaml b/fastly/fixtures/waf_versions/service/create.yaml index 02e596002..a4003cc9c 100644 --- a/fastly/fixtures/waf_versions/service/create.yaml +++ b/fastly/fixtures/waf_versions/service/create.yaml @@ -2,34 +2,37 @@ version: 1 interactions: - request: - body: comment=go-fastly+client+test&name=test_service_service + body: comment=go-fastly+client+test&name=test_service_service3&type=vcl form: comment: - go-fastly client test name: - - test_service_service + - test_service_service3 + type: + - vcl headers: Content-Type: - application/x-www-form-urlencoded User-Agent: - - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) + - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) url: https://api.fastly.com/service method: POST response: - body: '{"customer_id":"WpqWFjTA4lk2N1g0GY2HH","comment":"go-fastly client test","name":"test_service_service","created_at":"2019-11-25T14:43:29Z","type":"vcl","publish_key":"06140d06c6706f308be66ef0d52ba15f600c007b","deleted_at":null,"id":"300YFPn1PVF82Na4SUkiqy","versions":[{"service_id":"300YFPn1PVF82Na4SUkiqy","locked":false,"created_at":"2019-11-25T14:43:29Z","comment":"","deleted_at":null,"active":false,"number":1,"deployed":false,"testing":false,"updated_at":"2019-11-25T14:43:29Z","staging":false}],"updated_at":"2019-11-25T14:43:29Z"}' + body: '{"customer_id":"WpqWFjTA4lk2N1g0GY2HH","comment":"go-fastly client test","name":"test_service_service3","type":"vcl","versions":[{"updated_at":"2020-06-30T10:56:24Z","created_at":"2020-06-30T10:56:24Z","service_id":"3BOOVoayIlrdMuRU8LrKSA","locked":false,"staging":false,"deployed":false,"number":1,"deleted_at":null,"testing":false,"active":false,"comment":""}],"updated_at":"2020-06-30T10:56:24Z","id":"3BOOVoayIlrdMuRU8LrKSA","created_at":"2020-06-30T10:56:24Z","deleted_at":null,"publish_key":""}' headers: Accept-Ranges: - bytes + - bytes Cache-Control: - no-cache Content-Type: - application/json Date: - - Mon, 25 Nov 2019 14:43:29 GMT + - Tue, 30 Jun 2020 10:56:24 GMT Fastly-Ratelimit-Remaining: - - "999" + - "691" Fastly-Ratelimit-Reset: - - "1574694000" + - "1593514800" Status: - 200 OK Strict-Transport-Security: @@ -38,14 +41,15 @@ interactions: - Accept-Encoding Via: - 1.1 varnish + - 1.1 varnish X-Cache: - MISS, MISS X-Cache-Hits: - 0, 0 X-Served-By: - - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19271-LCY + - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19235-LCY X-Timer: - - S1574693009.998660,VS0,VE235 + - S1593514584.987441,VS0,VE469 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/waf_versions/service/delete.yaml b/fastly/fixtures/waf_versions/service/delete.yaml index d0a6a54cc..a5a97f836 100644 --- a/fastly/fixtures/waf_versions/service/delete.yaml +++ b/fastly/fixtures/waf_versions/service/delete.yaml @@ -6,24 +6,25 @@ interactions: form: {} headers: User-Agent: - - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) - url: https://api.fastly.com/service/300YFPn1PVF82Na4SUkiqy + - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) + url: https://api.fastly.com/service/3BOOVoayIlrdMuRU8LrKSA method: DELETE response: body: '{"status":"ok"}' headers: Accept-Ranges: - bytes + - bytes Cache-Control: - no-cache Content-Type: - application/json Date: - - Mon, 25 Nov 2019 14:43:36 GMT + - Tue, 30 Jun 2020 10:56:32 GMT Fastly-Ratelimit-Remaining: - - "991" + - "670" Fastly-Ratelimit-Reset: - - "1574694000" + - "1593514800" Status: - 200 OK Strict-Transport-Security: @@ -32,14 +33,15 @@ interactions: - Accept-Encoding Via: - 1.1 varnish + - 1.1 varnish X-Cache: - MISS, MISS X-Cache-Hits: - 0, 0 X-Served-By: - - cache-control-slwdc9035-CONTROL-SLWDC, cache-lcy19271-LCY + - cache-control-slwdc9035-CONTROL-SLWDC, cache-lcy19235-LCY X-Timer: - - S1574693016.148525,VS0,VE222 + - S1593514592.090749,VS0,VE215 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/waf_versions/service/version.yaml b/fastly/fixtures/waf_versions/service/version.yaml index c4169866a..d0a8e0d26 100644 --- a/fastly/fixtures/waf_versions/service/version.yaml +++ b/fastly/fixtures/waf_versions/service/version.yaml @@ -2,19 +2,19 @@ version: 1 interactions: - request: - body: Service=300YFPn1PVF82Na4SUkiqy + body: Service=3BOOVoayIlrdMuRU8LrKSA form: Service: - - 300YFPn1PVF82Na4SUkiqy + - 3BOOVoayIlrdMuRU8LrKSA headers: Content-Type: - application/x-www-form-urlencoded User-Agent: - - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) - url: https://api.fastly.com/service/300YFPn1PVF82Na4SUkiqy/version + - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) + url: https://api.fastly.com/service/3BOOVoayIlrdMuRU8LrKSA/version method: POST response: - body: '{"service_id":"300YFPn1PVF82Na4SUkiqy","number":2}' + body: '{"service_id":"3BOOVoayIlrdMuRU8LrKSA","number":2}' headers: Accept-Ranges: - bytes @@ -24,11 +24,11 @@ interactions: Content-Type: - application/json Date: - - Mon, 25 Nov 2019 14:43:29 GMT + - Tue, 30 Jun 2020 10:56:25 GMT Fastly-Ratelimit-Remaining: - - "998" + - "687" Fastly-Ratelimit-Reset: - - "1574694000" + - "1593514800" Status: - 200 OK Strict-Transport-Security: @@ -37,14 +37,15 @@ interactions: - Accept-Encoding Via: - 1.1 varnish + - 1.1 varnish X-Cache: - MISS, MISS X-Cache-Hits: - 0, 0 X-Served-By: - - cache-control-slwdc9036-CONTROL-SLWDC, cache-lcy19271-LCY + - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19235-LCY X-Timer: - - S1574693009.278394,VS0,VE632 + - S1593514585.002324,VS0,VE232 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/waf_versions/update.yaml b/fastly/fixtures/waf_versions/update.yaml index 924b10db4..1b5968fb7 100644 --- a/fastly/fixtures/waf_versions/update.yaml +++ b/fastly/fixtures/waf_versions/update.yaml @@ -3,7 +3,7 @@ version: 1 interactions: - request: body: | - {"data":{"type":"waf_firewall","id":"4x66aw12P6aLHGwK4KzGni","attributes":{"allowed_http_versions":"HTTP/1.0 HTTP/1.1","allowed_methods":"GET HEAD POST","allowed_request_content_type":"application/x-www-form-urlencoded|multipart/form-data|text/xml|application/xml","allowed_request_content_type_charset":"utf-8|iso-8859-1","arg_length":800,"arg_name_length":200,"combined_file_sizes":20000000,"comment":"my comment","critical_anomaly_score":12,"crs_validate_utf8_encoding":true,"error_anomaly_score":10,"high_risk_country_codes":"gb","http_violation_score_threshold":20,"inbound_anomaly_score_threshold":20,"lfi_score_threshold":20,"max_file_size":20000000,"max_num_args":510,"notice_anomaly_score":8,"paranoia_level":2,"php_injection_score_threshold":20,"rce_score_threshold":20,"restricted_extensions":".asa/ .asax/ .ascx/ .axd/ .backup/ .bak/ .bat/ .cdx/ .cer/ .cfg/ .cmd/ .com/","restricted_headers":"/proxy/ /lock-token/","rfi_score_threshold":20,"session_fixation_score_threshold":20,"sql_injection_score_threshold":20,"total_arg_length":12800,"warning_anomaly_score":20,"xss_score_threshold":20}}} + {"data":{"type":"waf_firewall_version","id":"3LP12sn59pB0iz0Kh75cHb","attributes":{"allowed_http_versions":"HTTP/1.0 HTTP/1.1","allowed_methods":"GET HEAD POST","allowed_request_content_type":"application/x-www-form-urlencoded|multipart/form-data|text/xml|application/xml","allowed_request_content_type_charset":"utf-8|iso-8859-1","arg_length":800,"arg_name_length":200,"combined_file_sizes":20000000,"comment":"my comment","critical_anomaly_score":12,"crs_validate_utf8_encoding":true,"error_anomaly_score":10,"high_risk_country_codes":"gb","http_violation_score_threshold":20,"inbound_anomaly_score_threshold":20,"lfi_score_threshold":20,"max_file_size":20000000,"max_num_args":510,"notice_anomaly_score":8,"paranoia_level":2,"php_injection_score_threshold":20,"rce_score_threshold":20,"restricted_extensions":".asa/ .asax/ .ascx/ .axd/ .backup/ .bak/ .bat/ .cdx/ .cer/ .cfg/ .cmd/ .com/","restricted_headers":"/proxy/ /lock-token/","rfi_score_threshold":20,"session_fixation_score_threshold":20,"sql_injection_score_threshold":20,"total_arg_length":12800,"warning_anomaly_score":20,"xss_score_threshold":20}}} form: {} headers: Accept: @@ -11,29 +11,32 @@ interactions: Content-Type: - application/vnd.api+json User-Agent: - - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) - url: https://api.fastly.com/waf/firewalls/3bhISXhyFhsufhCFnTst1j/versions/2 + - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) + url: https://api.fastly.com/waf/firewalls/6gj91AAsD3ndcoKaplqiq8/versions/2 method: PATCH response: - body: '{"data":{"id":"4x66aw12P6aLHGwK4KzGni","type":"waf_firewall_version","attributes":{"number":2,"comment":null,"active":null,"locked":false,"error":null,"deployed_at":null,"critical_anomaly_score":12,"error_anomaly_score":10,"warning_anomaly_score":20,"notice_anomaly_score":8,"http_violation_score_threshold":20,"inbound_anomaly_score_threshold":20,"lfi_score_threshold":20,"php_injection_score_threshold":20,"rce_score_threshold":20,"rfi_score_threshold":20,"session_fixation_score_threshold":20,"sql_injection_score_threshold":20,"xss_score_threshold":20,"paranoia_level":2,"arg_name_length":200,"arg_length":800,"total_arg_length":12800,"max_file_size":20000000,"combined_file_sizes":20000000,"max_num_args":510,"high_risk_country_codes":"gb","allowed_methods":"GET - HEAD POST","restricted_headers":"/proxy/ /lock-token/","restricted_extensions":".asa/ - .asax/ .ascx/ .axd/ .backup/ .bak/ .bat/ .cdx/ .cer/ .cfg/ .cmd/ .com/","allowed_request_content_type":"application/x-www-form-urlencoded|multipart/form-data|text/xml|application/xml","allowed_request_content_type_charset":"utf-8|iso-8859-1","allowed_http_versions":"HTTP/1.0 - HTTP/1.1","crs_validate_utf8_encoding":true,"created_at":"2019-11-25T14:43:32Z","updated_at":"2019-11-25T14:43:33Z","active_rules_trustwave_log_count":0,"active_rules_trustwave_block_count":0,"active_rules_fastly_log_count":0,"active_rules_fastly_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_score_count":0},"relationships":{"waf_firewall":{"data":{"id":"3bhISXhyFhsufhCFnTst1j","type":"waf_firewall"}}}}}' + body: '{"data":{"id":"3LP12sn59pB0iz0Kh75cHb","type":"waf_firewall_version","attributes":{"active":false,"active_rules_fastly_block_count":0,"active_rules_fastly_log_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_score_count":0,"active_rules_trustwave_block_count":0,"active_rules_trustwave_log_count":0,"allowed_http_versions":"HTTP/1.0 + HTTP/1.1","allowed_methods":"GET HEAD POST","allowed_request_content_type":"application/x-www-form-urlencoded|multipart/form-data|text/xml|application/xml","allowed_request_content_type_charset":"utf-8|iso-8859-1","arg_name_length":200,"arg_length":800,"combined_file_sizes":20000000,"comment":"my + comment","created_at":"2020-06-30T10:56:28Z","critical_anomaly_score":12,"crs_validate_utf8_encoding":true,"deployed_at":null,"error":null,"error_anomaly_score":10,"high_risk_country_codes":"gb","http_violation_score_threshold":20,"inbound_anomaly_score_threshold":20,"last_deployment_status":null,"lfi_score_threshold":20,"locked":false,"max_file_size":20000000,"max_num_args":510,"notice_anomaly_score":8,"number":2,"paranoia_level":2,"php_injection_score_threshold":20,"rce_score_threshold":20,"restricted_extensions":".asa/ + .asax/ .ascx/ .axd/ .backup/ .bak/ .bat/ .cdx/ .cer/ .cfg/ .cmd/ .com/","restricted_headers":"/proxy/ + /lock-token/","rfi_score_threshold":20,"session_fixation_score_threshold":20,"sql_injection_score_threshold":20,"total_arg_length":12800,"updated_at":"2020-06-30T10:56:29Z","warning_anomaly_score":20,"xss_score_threshold":20},"relationships":{"waf_firewall":{"data":{"id":"6gj91AAsD3ndcoKaplqiq8","type":"waf_firewall"}}}}}' headers: Accept-Ranges: - bytes + - bytes Content-Length: - - "1593" + - "1632" Content-Type: - application/vnd.api+json Date: - - Mon, 25 Nov 2019 14:43:33 GMT + - Tue, 30 Jun 2020 10:56:29 GMT Status: - 200 OK Strict-Transport-Security: - max-age=31536000 Via: - 1.1 varnish + - 1.1 varnish X-Cache: - MISS, MISS X-Cache-Hits: @@ -41,9 +44,9 @@ interactions: X-Content-Type-Options: - nosniff X-Served-By: - - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19271-LCY + - cache-control-slwdc9036-CONTROL-SLWDC, cache-lcy19235-LCY X-Timer: - - S1574693013.491879,VS0,VE373 + - S1593514589.036404,VS0,VE142 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/waf_versions/waf/create.yaml b/fastly/fixtures/waf_versions/waf/create.yaml index ed14483c7..fe6d2f35d 100644 --- a/fastly/fixtures/waf_versions/waf/create.yaml +++ b/fastly/fixtures/waf_versions/waf/create.yaml @@ -3,7 +3,7 @@ version: 1 interactions: - request: body: | - {"data":{"type":"waf_firewall","attributes":{"prefetch_condition":"WAF_Prefetch","response":"WAf_Response","service_id":"300YFPn1PVF82Na4SUkiqy","service_version_number":"2"}}} + {"data":{"type":"waf_firewall","attributes":{"prefetch_condition":"WAF_Prefetch","response":"WAf_Response","service_id":"3BOOVoayIlrdMuRU8LrKSA","service_version_number":"2"}}} form: {} headers: Accept: @@ -11,26 +11,28 @@ interactions: Content-Type: - application/vnd.api+json User-Agent: - - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) + - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) url: https://api.fastly.com/waf/firewalls method: POST response: - body: '{"data":{"id":"3bhISXhyFhsufhCFnTst1j","type":"waf_firewall","attributes":{"service_id":"300YFPn1PVF82Na4SUkiqy","prefetch_condition":"WAF_Prefetch","response":"WAf_Response","disabled":false,"service_version_number":2,"created_at":"2019-11-25T14:43:32Z","updated_at":"2019-11-25T14:43:32Z","active_rules_trustwave_log_count":0,"active_rules_trustwave_block_count":0,"active_rules_fastly_log_count":0,"active_rules_fastly_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_score_count":0}}}' + body: '{"data":{"id":"6gj91AAsD3ndcoKaplqiq8","type":"waf_firewall","attributes":{"active_rules_fastly_block_count":0,"active_rules_fastly_log_count":0,"active_rules_fastly_score_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_score_count":0,"active_rules_trustwave_block_count":0,"active_rules_trustwave_log_count":0,"created_at":"2020-06-30T10:56:27Z","disabled":false,"prefetch_condition":"WAF_Prefetch","response":"WAf_Response","service_id":"3BOOVoayIlrdMuRU8LrKSA","service_version_number":2,"updated_at":"2020-06-30T10:56:27Z"}}}' headers: Accept-Ranges: - bytes + - bytes Content-Length: - - "542" + - "578" Content-Type: - application/vnd.api+json Date: - - Mon, 25 Nov 2019 14:43:32 GMT + - Tue, 30 Jun 2020 10:56:27 GMT Status: - 201 Created Strict-Transport-Security: - max-age=31536000 Via: - 1.1 varnish + - 1.1 varnish X-Cache: - MISS, MISS X-Cache-Hits: @@ -38,9 +40,9 @@ interactions: X-Content-Type-Options: - nosniff X-Served-By: - - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19271-LCY + - cache-control-slwdc9035-CONTROL-SLWDC, cache-lcy19235-LCY X-Timer: - - S1574693011.323975,VS0,VE833 + - S1593514587.128070,VS0,VE708 status: 201 Created code: 201 duration: "" diff --git a/fastly/fixtures/waf_versions/waf/delete.yaml b/fastly/fixtures/waf_versions/waf/delete.yaml index 7df283012..85f481454 100644 --- a/fastly/fixtures/waf_versions/waf/delete.yaml +++ b/fastly/fixtures/waf_versions/waf/delete.yaml @@ -3,7 +3,7 @@ version: 1 interactions: - request: body: | - {"data":{"type":"waf_firewall","id":"3bhISXhyFhsufhCFnTst1j","attributes":{"service_version_number":"2"}}} + {"data":{"type":"waf_firewall","id":"6gj91AAsD3ndcoKaplqiq8","attributes":{"service_version_number":"2"}}} form: {} headers: Accept: @@ -11,22 +11,24 @@ interactions: Content-Type: - application/vnd.api+json User-Agent: - - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) - url: https://api.fastly.com/waf/firewalls/3bhISXhyFhsufhCFnTst1j + - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) + url: https://api.fastly.com/waf/firewalls/6gj91AAsD3ndcoKaplqiq8 method: DELETE response: body: "" headers: Accept-Ranges: - bytes + - bytes Date: - - Mon, 25 Nov 2019 14:43:34 GMT + - Tue, 30 Jun 2020 10:56:30 GMT Status: - 204 No Content Strict-Transport-Security: - max-age=31536000 Via: - 1.1 varnish + - 1.1 varnish X-Cache: - MISS, MISS X-Cache-Hits: @@ -34,9 +36,9 @@ interactions: X-Content-Type-Options: - nosniff X-Served-By: - - cache-control-slwdc9035-CONTROL-SLWDC, cache-lcy19271-LCY + - cache-control-slwdc9035-CONTROL-SLWDC, cache-lcy19235-LCY X-Timer: - - S1574693014.397467,VS0,VE288 + - S1593514590.231324,VS0,VE434 status: 204 No Content code: 204 duration: "" diff --git a/fastly/fixtures/wafs/cleanup.yaml b/fastly/fixtures/wafs/cleanup.yaml index 252139cb5..a9b62be70 100644 --- a/fastly/fixtures/wafs/cleanup.yaml +++ b/fastly/fixtures/wafs/cleanup.yaml @@ -3,7 +3,7 @@ version: 1 interactions: - request: body: | - {"data":{"type":"waf_firewall","id":"5ui1qC2Y9TZIonO95zU3gM","attributes":{"service_version_number":"2"}}} + {"data":{"type":"waf_firewall","id":"2m5TQ56k5nWIFJusRN0Vap","attributes":{"service_version_number":"2"}}} form: {} headers: Accept: @@ -11,8 +11,8 @@ interactions: Content-Type: - application/vnd.api+json User-Agent: - - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) - url: https://api.fastly.com/waf/firewalls/5ui1qC2Y9TZIonO95zU3gM + - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) + url: https://api.fastly.com/waf/firewalls/2m5TQ56k5nWIFJusRN0Vap method: DELETE response: body: '{"errors":[{"title":"Resource not found","detail":"We could not find a @@ -21,22 +21,25 @@ interactions: Accept-Ranges: - bytes - bytes + Content-Type: + - application/vnd.api+json Date: - - Wed, 20 Nov 2019 12:59:08 GMT + - Tue, 30 Jun 2020 10:56:30 GMT Status: - 404 Not Found Strict-Transport-Security: - max-age=31536000 Via: - 1.1 varnish + - 1.1 varnish X-Cache: - MISS, MISS X-Cache-Hits: - 0, 0 X-Served-By: - - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19265-LCY + - cache-control-slwdc9036-CONTROL-SLWDC, cache-lcy19235-LCY X-Timer: - - S1574254748.068564,VS0,VE131 + - S1593514591.815640,VS0,VE156 status: 404 Not Found code: 404 duration: "" diff --git a/fastly/fixtures/wafs/condition/create.yaml b/fastly/fixtures/wafs/condition/create.yaml index 0ea3c1c78..0fef972a8 100644 --- a/fastly/fixtures/wafs/condition/create.yaml +++ b/fastly/fixtures/wafs/condition/create.yaml @@ -2,10 +2,10 @@ version: 1 interactions: - request: - body: Service=3qt0xLYGlOxt19jpAQ0LJM&Version=2&name=WAF_Prefetch&priority=1&statement=req.url~%2B%22index.html%22&type=PREFETCH + body: Service=6PehUY86Aj8yGpccQ0a8oT&Version=2&name=WAF_Prefetch&priority=1&statement=req.url~%2B%22index.html%22&type=PREFETCH form: Service: - - 3qt0xLYGlOxt19jpAQ0LJM + - 6PehUY86Aj8yGpccQ0a8oT Version: - "2" name: @@ -20,11 +20,11 @@ interactions: Content-Type: - application/x-www-form-urlencoded User-Agent: - - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) - url: https://api.fastly.com/service/3qt0xLYGlOxt19jpAQ0LJM/version/2/condition + - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) + url: https://api.fastly.com/service/6PehUY86Aj8yGpccQ0a8oT/version/2/condition method: POST response: - body: '{"name":"WAF_Prefetch","priority":"1","statement":"req.url~+\"index.html\"","type":"PREFETCH","service_id":"3qt0xLYGlOxt19jpAQ0LJM","version":"2","deleted_at":null,"updated_at":"2019-11-20T12:59:04Z","comment":"","created_at":"2019-11-20T12:59:04Z"}' + body: '{"name":"WAF_Prefetch","priority":"1","statement":"req.url~+\"index.html\"","type":"PREFETCH","service_id":"6PehUY86Aj8yGpccQ0a8oT","version":"2","comment":"","updated_at":"2020-06-30T10:56:25Z","created_at":"2020-06-30T10:56:25Z","deleted_at":null}' headers: Accept-Ranges: - bytes @@ -34,11 +34,11 @@ interactions: Content-Type: - application/json Date: - - Wed, 20 Nov 2019 12:59:04 GMT + - Tue, 30 Jun 2020 10:56:25 GMT Fastly-Ratelimit-Remaining: - - "970" + - "685" Fastly-Ratelimit-Reset: - - "1574254800" + - "1593514800" Status: - 200 OK Strict-Transport-Security: @@ -47,14 +47,15 @@ interactions: - Accept-Encoding Via: - 1.1 varnish + - 1.1 varnish X-Cache: - MISS, MISS X-Cache-Hits: - 0, 0 X-Served-By: - - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19265-LCY + - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19235-LCY X-Timer: - - S1574254744.247357,VS0,VE185 + - S1593514585.002337,VS0,VE451 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/wafs/condition/delete.yaml b/fastly/fixtures/wafs/condition/delete.yaml index fa484a059..b421922e0 100644 --- a/fastly/fixtures/wafs/condition/delete.yaml +++ b/fastly/fixtures/wafs/condition/delete.yaml @@ -6,24 +6,25 @@ interactions: form: {} headers: User-Agent: - - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) - url: https://api.fastly.com/service/3qt0xLYGlOxt19jpAQ0LJM/version/2/condition/WAF_Prefetch + - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) + url: https://api.fastly.com/service/6PehUY86Aj8yGpccQ0a8oT/version/2/condition/WAF_Prefetch method: DELETE response: body: '{"status":"ok"}' headers: Accept-Ranges: - bytes + - bytes Cache-Control: - no-cache Content-Type: - application/json Date: - - Wed, 20 Nov 2019 12:59:08 GMT + - Tue, 30 Jun 2020 10:56:32 GMT Fastly-Ratelimit-Remaining: - - "965" + - "671" Fastly-Ratelimit-Reset: - - "1574254800" + - "1593514800" Status: - 200 OK Strict-Transport-Security: @@ -32,14 +33,15 @@ interactions: - Accept-Encoding Via: - 1.1 varnish + - 1.1 varnish X-Cache: - MISS, MISS X-Cache-Hits: - 0, 0 X-Served-By: - - cache-control-slwdc9036-CONTROL-SLWDC, cache-lcy19265-LCY + - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19235-LCY X-Timer: - - S1574254749.547759,VS0,VE264 + - S1593514592.036626,VS0,VE184 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/wafs/create.yaml b/fastly/fixtures/wafs/create.yaml index ad6d3a64a..b029f9ee6 100644 --- a/fastly/fixtures/wafs/create.yaml +++ b/fastly/fixtures/wafs/create.yaml @@ -3,7 +3,7 @@ version: 1 interactions: - request: body: | - {"data":{"type":"waf_firewall","attributes":{"prefetch_condition":"WAF_Prefetch","response":"WAf_Response","service_id":"3qt0xLYGlOxt19jpAQ0LJM","service_version_number":"2"}}} + {"data":{"type":"waf_firewall","attributes":{"prefetch_condition":"WAF_Prefetch","response":"WAF_Response","service_id":"6PehUY86Aj8yGpccQ0a8oT","service_version_number":"2"}}} form: {} headers: Accept: @@ -11,27 +11,28 @@ interactions: Content-Type: - application/vnd.api+json User-Agent: - - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) + - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) url: https://api.fastly.com/waf/firewalls method: POST response: - body: '{"data":{"id":"5ui1qC2Y9TZIonO95zU3gM","type":"waf_firewall","attributes":{"service_id":"3qt0xLYGlOxt19jpAQ0LJM","prefetch_condition":"WAF_Prefetch","response":"WAf_Response","disabled":false,"service_version_number":2,"created_at":"2019-11-20T12:59:05Z","updated_at":"2019-11-20T12:59:05Z","active_rules_trustwave_log_count":0,"active_rules_trustwave_block_count":0,"active_rules_fastly_log_count":0,"active_rules_fastly_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_score_count":0}}}' + body: '{"data":{"id":"2m5TQ56k5nWIFJusRN0Vap","type":"waf_firewall","attributes":{"active_rules_fastly_block_count":0,"active_rules_fastly_log_count":0,"active_rules_fastly_score_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_score_count":0,"active_rules_trustwave_block_count":0,"active_rules_trustwave_log_count":0,"created_at":"2020-06-30T10:56:27Z","disabled":false,"prefetch_condition":"WAF_Prefetch","response":"WAF_Response","service_id":"6PehUY86Aj8yGpccQ0a8oT","service_version_number":2,"updated_at":"2020-06-30T10:56:27Z"}}}' headers: Accept-Ranges: - bytes - bytes Content-Length: - - "542" + - "578" Content-Type: - application/vnd.api+json Date: - - Wed, 20 Nov 2019 12:59:05 GMT + - Tue, 30 Jun 2020 10:56:27 GMT Status: - 201 Created Strict-Transport-Security: - max-age=31536000 Via: - 1.1 varnish + - 1.1 varnish X-Cache: - MISS, MISS X-Cache-Hits: @@ -39,9 +40,9 @@ interactions: X-Content-Type-Options: - nosniff X-Served-By: - - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19265-LCY + - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19235-LCY X-Timer: - - S1574254745.875699,VS0,VE922 + - S1593514586.335980,VS0,VE783 status: 201 Created code: 201 duration: "" diff --git a/fastly/fixtures/wafs/delete.yaml b/fastly/fixtures/wafs/delete.yaml index 44eda0b6d..2851b6826 100644 --- a/fastly/fixtures/wafs/delete.yaml +++ b/fastly/fixtures/wafs/delete.yaml @@ -3,7 +3,7 @@ version: 1 interactions: - request: body: | - {"data":{"type":"waf_firewall","id":"5ui1qC2Y9TZIonO95zU3gM","attributes":{"service_version_number":"2"}}} + {"data":{"type":"waf_firewall","id":"2m5TQ56k5nWIFJusRN0Vap","attributes":{"service_version_number":"2"}}} form: {} headers: Accept: @@ -11,8 +11,8 @@ interactions: Content-Type: - application/vnd.api+json User-Agent: - - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) - url: https://api.fastly.com/waf/firewalls/5ui1qC2Y9TZIonO95zU3gM + - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) + url: https://api.fastly.com/waf/firewalls/2m5TQ56k5nWIFJusRN0Vap method: DELETE response: body: "" @@ -21,13 +21,14 @@ interactions: - bytes - bytes Date: - - Wed, 20 Nov 2019 12:59:07 GMT + - Tue, 30 Jun 2020 10:56:30 GMT Status: - 204 No Content Strict-Transport-Security: - max-age=31536000 Via: - 1.1 varnish + - 1.1 varnish X-Cache: - MISS, MISS X-Cache-Hits: @@ -35,9 +36,9 @@ interactions: X-Content-Type-Options: - nosniff X-Served-By: - - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19265-LCY + - cache-control-slwdc9035-CONTROL-SLWDC, cache-lcy19235-LCY X-Timer: - - S1574254747.217414,VS0,VE284 + - S1593514590.075210,VS0,VE595 status: 204 No Content code: 204 duration: "" diff --git a/fastly/fixtures/wafs/deploy.yaml b/fastly/fixtures/wafs/deploy.yaml index 8dc694ae9..29bbcd1bc 100644 --- a/fastly/fixtures/wafs/deploy.yaml +++ b/fastly/fixtures/wafs/deploy.yaml @@ -11,26 +11,28 @@ interactions: Content-Type: - application/vnd.api+json User-Agent: - - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) - url: https://api.fastly.com/waf/firewalls/5ui1qC2Y9TZIonO95zU3gM/versions/1 + - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) + url: https://api.fastly.com/waf/firewalls/2m5TQ56k5nWIFJusRN0Vap/versions/1 method: POST response: - body: '{"errors":[],"data":null}' + body: '{}' headers: Accept-Ranges: - bytes + - bytes Content-Length: - - "25" + - "2" Content-Type: - application/vnd.api+json Date: - - Fri, 13 Dec 2019 08:52:53 GMT + - Tue, 30 Jun 2020 10:56:27 GMT Status: - 202 Accepted Strict-Transport-Security: - max-age=31536000 Via: - 1.1 varnish + - 1.1 varnish X-Cache: - MISS, MISS X-Cache-Hits: @@ -38,9 +40,9 @@ interactions: X-Content-Type-Options: - nosniff X-Served-By: - - cache-control-slwdc9036-CONTROL-SLWDC, cache-lcy19229-LCY + - cache-control-slwdc9036-CONTROL-SLWDC, cache-lcy19235-LCY X-Timer: - - S1576227173.880248,VS0,VE137 + - S1593514588.553163,VS0,VE139 status: 202 Accepted code: 202 duration: "" diff --git a/fastly/fixtures/wafs/disable.yaml b/fastly/fixtures/wafs/disable.yaml index 49f5c499b..296a72f98 100644 --- a/fastly/fixtures/wafs/disable.yaml +++ b/fastly/fixtures/wafs/disable.yaml @@ -2,8 +2,8 @@ version: 1 interactions: - request: - body: | - {"data":{"type":"waf_firewall","id":"5ui1qC2Y9TZIonO95zU3gM","attributes":{"disable":true}}} + body: | + {"data":{"type":"","attributes":{"disabled":true}}} form: {} headers: Accept: @@ -11,26 +11,28 @@ interactions: Content-Type: - application/vnd.api+json User-Agent: - - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) - url: https://api.fastly.com/waf/firewalls/5ui1qC2Y9TZIonO95zU3gM + - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) + url: https://api.fastly.com/waf/firewalls/2m5TQ56k5nWIFJusRN0Vap method: PATCH response: - body: '{"data":{"id":"5ui1qC2Y9TZIonO95zU3gM","type":"waf_firewall","attributes":{"service_id":"1l9vtYGCa1be9QkG5opE5F","prefetch_condition":null,"response":null,"disabled":true,"service_version_number":null,"created_at":"2019-12-13T08:52:52Z","updated_at":"2019-12-13T08:52:54Z","active_rules_trustwave_log_count":0,"active_rules_trustwave_block_count":0,"active_rules_fastly_log_count":0,"active_rules_fastly_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_score_count":0}}}' + body: '{"data":{"id":"2m5TQ56k5nWIFJusRN0Vap","type":"waf_firewall","attributes":{"active_rules_fastly_block_count":0,"active_rules_fastly_log_count":0,"active_rules_fastly_score_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_score_count":0,"active_rules_trustwave_block_count":0,"active_rules_trustwave_log_count":0,"created_at":"2020-06-30T10:56:27Z","disabled":true,"prefetch_condition":null,"response":null,"service_id":"6PehUY86Aj8yGpccQ0a8oT","service_version_number":null,"updated_at":"2020-06-30T10:56:29Z"}}}' headers: Accept-Ranges: - bytes + - bytes Content-Length: - - "524" + - "560" Content-Type: - application/vnd.api+json Date: - - Fri, 13 Dec 2019 08:52:54 GMT + - Tue, 30 Jun 2020 10:56:29 GMT Status: - 200 OK Strict-Transport-Security: - max-age=31536000 Via: - 1.1 varnish + - 1.1 varnish X-Cache: - MISS, MISS X-Cache-Hits: @@ -38,9 +40,9 @@ interactions: X-Content-Type-Options: - nosniff X-Served-By: - - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19229-LCY + - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19235-LCY X-Timer: - - S1576227174.900944,VS0,VE671 + - S1593514589.581966,VS0,VE658 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/wafs/enable.yaml b/fastly/fixtures/wafs/enable.yaml index c6597241f..d1c46a9c8 100644 --- a/fastly/fixtures/wafs/enable.yaml +++ b/fastly/fixtures/wafs/enable.yaml @@ -3,7 +3,7 @@ version: 1 interactions: - request: body: | - {"data":{"type":"waf_firewall","id":"5ui1qC2Y9TZIonO95zU3gM","attributes":{"disable":false}}} + {"data":{"type":"waf_firewall","id":"2m5TQ56k5nWIFJusRN0Vap","attributes":{"disabled":false}}} form: {} headers: Accept: @@ -11,26 +11,28 @@ interactions: Content-Type: - application/vnd.api+json User-Agent: - - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) - url: https://api.fastly.com/waf/firewalls/5ui1qC2Y9TZIonO95zU3gM + - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) + url: https://api.fastly.com/waf/firewalls/2m5TQ56k5nWIFJusRN0Vap method: PATCH response: - body: '{"data":{"id":"5ui1qC2Y9TZIonO95zU3gM","type":"waf_firewall","attributes":{"service_id":"1l9vtYGCa1be9QkG5opE5F","prefetch_condition":null,"response":null,"disabled":false,"service_version_number":null,"created_at":"2019-12-13T08:52:52Z","updated_at":"2019-12-13T08:52:55Z","active_rules_trustwave_log_count":0,"active_rules_trustwave_block_count":0,"active_rules_fastly_log_count":0,"active_rules_fastly_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_score_count":0}}}' + body: '{"data":{"id":"2m5TQ56k5nWIFJusRN0Vap","type":"waf_firewall","attributes":{"active_rules_fastly_block_count":0,"active_rules_fastly_log_count":0,"active_rules_fastly_score_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_score_count":0,"active_rules_trustwave_block_count":0,"active_rules_trustwave_log_count":0,"created_at":"2020-06-30T10:56:27Z","disabled":false,"prefetch_condition":null,"response":null,"service_id":"6PehUY86Aj8yGpccQ0a8oT","service_version_number":null,"updated_at":"2020-06-30T10:56:29Z"}}}' headers: Accept-Ranges: - bytes + - bytes Content-Length: - - "525" + - "561" Content-Type: - application/vnd.api+json Date: - - Fri, 13 Dec 2019 08:52:55 GMT + - Tue, 30 Jun 2020 10:56:29 GMT Status: - 200 OK Strict-Transport-Security: - max-age=31536000 Via: - 1.1 varnish + - 1.1 varnish X-Cache: - MISS, MISS X-Cache-Hits: @@ -38,9 +40,9 @@ interactions: X-Content-Type-Options: - nosniff X-Served-By: - - cache-control-slwdc9036-CONTROL-SLWDC, cache-lcy19229-LCY + - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19235-LCY X-Timer: - - S1576227175.617161,VS0,VE667 + - S1593514589.338495,VS0,VE622 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/wafs/get.yaml b/fastly/fixtures/wafs/get.yaml index 604bacbba..e32e5b77b 100644 --- a/fastly/fixtures/wafs/get.yaml +++ b/fastly/fixtures/wafs/get.yaml @@ -6,11 +6,11 @@ interactions: form: {} headers: User-Agent: - - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) - url: https://api.fastly.com/waf/firewalls/5ui1qC2Y9TZIonO95zU3gM?filter%5Bservice_version_number%5D=2 + - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) + url: https://api.fastly.com/waf/firewalls/2m5TQ56k5nWIFJusRN0Vap?filter%5Bservice_version_number%5D=2 method: GET response: - body: '{"data":{"id":"5ui1qC2Y9TZIonO95zU3gM","type":"waf_firewall","attributes":{"service_id":"3qt0xLYGlOxt19jpAQ0LJM","prefetch_condition":"WAF_Prefetch","response":"WAf_Response","disabled":false,"service_version_number":2,"created_at":"2019-11-20T12:59:05Z","updated_at":"2019-11-20T12:59:05Z","active_rules_trustwave_log_count":0,"active_rules_trustwave_block_count":0,"active_rules_fastly_log_count":0,"active_rules_fastly_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_score_count":0}}}' + body: '{"data":{"id":"2m5TQ56k5nWIFJusRN0Vap","type":"waf_firewall","attributes":{"active_rules_fastly_block_count":0,"active_rules_fastly_log_count":0,"active_rules_fastly_score_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_score_count":0,"active_rules_trustwave_block_count":0,"active_rules_trustwave_log_count":0,"created_at":"2020-06-30T10:56:27Z","disabled":false,"prefetch_condition":"WAF_Prefetch","response":"WAF_Response","service_id":"6PehUY86Aj8yGpccQ0a8oT","service_version_number":2,"updated_at":"2020-06-30T10:56:27Z"}}}' headers: Accept-Ranges: - bytes @@ -20,17 +20,18 @@ interactions: - "0" - "0" Content-Length: - - "542" + - "578" Content-Type: - application/vnd.api+json Date: - - Wed, 20 Nov 2019 12:59:06 GMT + - Tue, 30 Jun 2020 10:56:28 GMT Status: - 200 OK Strict-Transport-Security: - max-age=31536000 Via: - 1.1 varnish + - 1.1 varnish X-Cache: - MISS, MISS X-Cache-Hits: @@ -38,9 +39,9 @@ interactions: X-Content-Type-Options: - nosniff X-Served-By: - - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19265-LCY + - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19235-LCY X-Timer: - - S1574254746.088317,VS0,VE225 + - S1593514588.863572,VS0,VE179 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/wafs/list.yaml b/fastly/fixtures/wafs/list.yaml index c29f8a5bf..a0115ac6a 100644 --- a/fastly/fixtures/wafs/list.yaml +++ b/fastly/fixtures/wafs/list.yaml @@ -6,11 +6,11 @@ interactions: form: {} headers: User-Agent: - - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) - url: https://api.fastly.com/waf/firewalls?filter%5Bservice_id%5D=3qt0xLYGlOxt19jpAQ0LJM&filter%5Bservice_version_number%5D=2 + - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) + url: https://api.fastly.com/waf/firewalls?filter%5Bservice_id%5D=6PehUY86Aj8yGpccQ0a8oT&filter%5Bservice_version_number%5D=2 method: GET response: - body: '{"data":[{"id":"5ui1qC2Y9TZIonO95zU3gM","type":"waf_firewall","attributes":{"service_id":"3qt0xLYGlOxt19jpAQ0LJM","prefetch_condition":"WAF_Prefetch","response":"WAf_Response","disabled":false,"service_version_number":2,"created_at":"2019-11-20T12:59:05Z","updated_at":"2019-11-20T12:59:05Z","active_rules_trustwave_log_count":0,"active_rules_trustwave_block_count":0,"active_rules_fastly_log_count":0,"active_rules_fastly_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_score_count":0}}],"links":{"last":"https://api.fastly.com/waf/firewalls?filter[service_id]=3qt0xLYGlOxt19jpAQ0LJM\u0026filter[service_version_number]=2\u0026page[number]=1\u0026page[size]=100","first":"https://api.fastly.com/waf/firewalls?filter[service_id]=3qt0xLYGlOxt19jpAQ0LJM\u0026filter[service_version_number]=2\u0026page[number]=1\u0026page[size]=100"},"meta":{"current_page":1,"per_page":100,"record_count":1,"total_pages":1}}' + body: '{"data":[{"id":"2m5TQ56k5nWIFJusRN0Vap","type":"waf_firewall","attributes":{"active_rules_fastly_block_count":0,"active_rules_fastly_log_count":0,"active_rules_fastly_score_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_score_count":0,"active_rules_trustwave_block_count":0,"active_rules_trustwave_log_count":0,"created_at":"2020-06-30T10:56:27Z","disabled":false,"prefetch_condition":"WAF_Prefetch","response":"WAF_Response","service_id":"6PehUY86Aj8yGpccQ0a8oT","service_version_number":2,"updated_at":"2020-06-30T10:56:27Z"}}],"links":{"last":"https://api.fastly.com/waf/firewalls?filter[service_id]=6PehUY86Aj8yGpccQ0a8oT\u0026filter[service_version_number]=2\u0026page[number]=1\u0026page[size]=100","first":"https://api.fastly.com/waf/firewalls?filter[service_id]=6PehUY86Aj8yGpccQ0a8oT\u0026filter[service_version_number]=2\u0026page[number]=1\u0026page[size]=100"},"meta":{"current_page":1,"per_page":100,"record_count":1,"total_pages":1}}' headers: Accept-Ranges: - bytes @@ -20,17 +20,18 @@ interactions: - "0" - "0" Content-Length: - - "961" + - "997" Content-Type: - application/vnd.api+json Date: - - Wed, 20 Nov 2019 12:59:06 GMT + - Tue, 30 Jun 2020 10:56:27 GMT Status: - 200 OK Strict-Transport-Security: - max-age=31536000 Via: - 1.1 varnish + - 1.1 varnish X-Cache: - MISS, MISS X-Cache-Hits: @@ -38,9 +39,9 @@ interactions: X-Content-Type-Options: - nosniff X-Served-By: - - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19265-LCY + - cache-control-slwdc9035-CONTROL-SLWDC, cache-lcy19235-LCY X-Timer: - - S1574254746.880426,VS0,VE172 + - S1593514587.296392,VS0,VE179 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/wafs/response_object/cleanup_another.yaml b/fastly/fixtures/wafs/response_object/cleanup_another.yaml index 7e9ff16dc..cbe989e4c 100644 --- a/fastly/fixtures/wafs/response_object/cleanup_another.yaml +++ b/fastly/fixtures/wafs/response_object/cleanup_another.yaml @@ -6,8 +6,8 @@ interactions: form: {} headers: User-Agent: - - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) - url: https://api.fastly.com/service/3qt0xLYGlOxt19jpAQ0LJM/version/2/response_object/WAF_Response2 + - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) + url: https://api.fastly.com/service/6PehUY86Aj8yGpccQ0a8oT/version/2/response_object/WAF_Response2 method: DELETE response: body: '{"status":"ok"}' @@ -20,11 +20,11 @@ interactions: Content-Type: - application/json Date: - - Wed, 20 Nov 2019 12:59:07 GMT + - Tue, 30 Jun 2020 10:56:31 GMT Fastly-Ratelimit-Remaining: - - "967" + - "675" Fastly-Ratelimit-Reset: - - "1574254800" + - "1593514800" Status: - 200 OK Strict-Transport-Security: @@ -33,14 +33,15 @@ interactions: - Accept-Encoding Via: - 1.1 varnish + - 1.1 varnish X-Cache: - MISS, MISS X-Cache-Hits: - 0, 0 X-Served-By: - - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19265-LCY + - cache-control-slwdc9035-CONTROL-SLWDC, cache-lcy19235-LCY X-Timer: - - S1574254748.524032,VS0,VE458 + - S1593514591.168293,VS0,VE283 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/wafs/response_object/create.yaml b/fastly/fixtures/wafs/response_object/create.yaml index 2d03d9946..431d89191 100644 --- a/fastly/fixtures/wafs/response_object/create.yaml +++ b/fastly/fixtures/wafs/response_object/create.yaml @@ -2,31 +2,25 @@ version: 1 interactions: - request: - body: Service=3qt0xLYGlOxt19jpAQ0LJM&Version=2&content=abcd&content_type=text%2Fplain&name=WAf_Response&response=Ok&status=200 + body: Service=6PehUY86Aj8yGpccQ0a8oT&Version=2&name=WAF_Response&status=403 form: Service: - - 3qt0xLYGlOxt19jpAQ0LJM + - 6PehUY86Aj8yGpccQ0a8oT Version: - "2" - content: - - abcd - content_type: - - text/plain name: - - WAf_Response - response: - - Ok + - WAF_Response status: - - "200" + - "403" headers: Content-Type: - application/x-www-form-urlencoded User-Agent: - - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) - url: https://api.fastly.com/service/3qt0xLYGlOxt19jpAQ0LJM/version/2/response_object + - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) + url: https://api.fastly.com/service/6PehUY86Aj8yGpccQ0a8oT/version/2/response_object method: POST response: - body: '{"content":"abcd","content_type":"text/plain","name":"WAf_Response","response":"Ok","status":"200","service_id":"3qt0xLYGlOxt19jpAQ0LJM","version":"2","cache_condition":"","updated_at":"2019-11-20T12:59:04Z","request_condition":"","deleted_at":null,"created_at":"2019-11-20T12:59:04Z"}' + body: '{"name":"WAF_Response","status":"403","service_id":"6PehUY86Aj8yGpccQ0a8oT","version":"2","response":"ok","updated_at":"2020-06-30T10:56:25Z","created_at":"2020-06-30T10:56:25Z","content_type":null,"request_condition":"","content":null,"deleted_at":null,"cache_condition":""}' headers: Accept-Ranges: - bytes @@ -36,11 +30,11 @@ interactions: Content-Type: - application/json Date: - - Wed, 20 Nov 2019 12:59:04 GMT + - Tue, 30 Jun 2020 10:56:25 GMT Fastly-Ratelimit-Remaining: - - "969" + - "683" Fastly-Ratelimit-Reset: - - "1574254800" + - "1593514800" Status: - 200 OK Strict-Transport-Security: @@ -49,14 +43,15 @@ interactions: - Accept-Encoding Via: - 1.1 varnish + - 1.1 varnish X-Cache: - MISS, MISS X-Cache-Hits: - 0, 0 X-Served-By: - - cache-control-slwdc9036-CONTROL-SLWDC, cache-lcy19265-LCY + - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19235-LCY X-Timer: - - S1574254744.451020,VS0,VE306 + - S1593514586.539867,VS0,VE271 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/wafs/response_object/create_another.yaml b/fastly/fixtures/wafs/response_object/create_another.yaml index 47d87a3fe..43c22a761 100644 --- a/fastly/fixtures/wafs/response_object/create_another.yaml +++ b/fastly/fixtures/wafs/response_object/create_another.yaml @@ -2,31 +2,25 @@ version: 1 interactions: - request: - body: Service=3qt0xLYGlOxt19jpAQ0LJM&Version=2&content=efgh&content_type=text%2Fplain&name=WAF_Response2&response=Ok&status=200 + body: Service=6PehUY86Aj8yGpccQ0a8oT&Version=2&name=WAF_Response2&status=403 form: Service: - - 3qt0xLYGlOxt19jpAQ0LJM + - 6PehUY86Aj8yGpccQ0a8oT Version: - "2" - content: - - efgh - content_type: - - text/plain name: - WAF_Response2 - response: - - Ok status: - - "200" + - "403" headers: Content-Type: - application/x-www-form-urlencoded User-Agent: - - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) - url: https://api.fastly.com/service/3qt0xLYGlOxt19jpAQ0LJM/version/2/response_object + - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) + url: https://api.fastly.com/service/6PehUY86Aj8yGpccQ0a8oT/version/2/response_object method: POST response: - body: '{"content":"efgh","content_type":"text/plain","name":"WAF_Response2","response":"Ok","status":"200","service_id":"3qt0xLYGlOxt19jpAQ0LJM","version":"2","request_condition":"","updated_at":"2019-11-20T12:59:06Z","deleted_at":null,"created_at":"2019-11-20T12:59:06Z","cache_condition":""}' + body: '{"name":"WAF_Response2","status":"403","service_id":"6PehUY86Aj8yGpccQ0a8oT","version":"2","response":"ok","content":null,"updated_at":"2020-06-30T10:56:26Z","cache_condition":"","deleted_at":null,"request_condition":"","content_type":null,"created_at":"2020-06-30T10:56:26Z"}' headers: Accept-Ranges: - bytes @@ -36,11 +30,11 @@ interactions: Content-Type: - application/json Date: - - Wed, 20 Nov 2019 12:59:06 GMT + - Tue, 30 Jun 2020 10:56:26 GMT Fastly-Ratelimit-Remaining: - - "968" + - "681" Fastly-Ratelimit-Reset: - - "1574254800" + - "1593514800" Status: - 200 OK Strict-Transport-Security: @@ -49,14 +43,15 @@ interactions: - Accept-Encoding Via: - 1.1 varnish + - 1.1 varnish X-Cache: - MISS, MISS X-Cache-Hits: - 0, 0 X-Served-By: - - cache-control-slwdc9035-CONTROL-SLWDC, cache-lcy19265-LCY + - cache-control-slwdc9035-CONTROL-SLWDC, cache-lcy19235-LCY X-Timer: - - S1574254746.396063,VS0,VE303 + - S1593514586.885042,VS0,VE316 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/wafs/response_object/delete.yaml b/fastly/fixtures/wafs/response_object/delete.yaml index 560e28be9..9e3ee8b42 100644 --- a/fastly/fixtures/wafs/response_object/delete.yaml +++ b/fastly/fixtures/wafs/response_object/delete.yaml @@ -6,24 +6,25 @@ interactions: form: {} headers: User-Agent: - - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) - url: https://api.fastly.com/service/3qt0xLYGlOxt19jpAQ0LJM/version/2/response_object/WAF_Response + - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) + url: https://api.fastly.com/service/6PehUY86Aj8yGpccQ0a8oT/version/2/response_object/WAF_Response method: DELETE response: body: '{"status":"ok"}' headers: Accept-Ranges: - bytes + - bytes Cache-Control: - no-cache Content-Type: - application/json Date: - - Wed, 20 Nov 2019 12:59:08 GMT + - Tue, 30 Jun 2020 10:56:31 GMT Fastly-Ratelimit-Remaining: - - "966" + - "673" Fastly-Ratelimit-Reset: - - "1574254800" + - "1593514800" Status: - 200 OK Strict-Transport-Security: @@ -32,14 +33,15 @@ interactions: - Accept-Encoding Via: - 1.1 varnish + - 1.1 varnish X-Cache: - MISS, MISS X-Cache-Hits: - 0, 0 X-Served-By: - - cache-control-slwdc9036-CONTROL-SLWDC, cache-lcy19265-LCY + - cache-control-slwdc9036-CONTROL-SLWDC, cache-lcy19235-LCY X-Timer: - - S1574254748.207257,VS0,VE316 + - S1593514592.653737,VS0,VE214 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/wafs/ruleset/get.yaml b/fastly/fixtures/wafs/ruleset/get.yaml deleted file mode 100644 index b7c2b927e..000000000 --- a/fastly/fixtures/wafs/ruleset/get.yaml +++ /dev/null @@ -1,48 +0,0 @@ ---- -version: 1 -interactions: -- request: - body: "" - form: {} - headers: - User-Agent: - - FastlyGo/1.10.0 (+github.com/fastly/go-fastly; go1.12) - url: https://api.fastly.com/service/7i6HN3TK9wS159v2gPAZ8A/wafs/1NGmubiAYnKMtCvXWAeszf/ruleset - method: GET - response: - body: '{"data":{"id":"1NGmubiAYnKMtCvXWAeszf","type":"ruleset","attributes":{"vcl":"sub - waf_ruleset {\n /* This WAF is not configured */\n}","last_push":null}}}' - headers: - Accept-Ranges: - - bytes - - bytes - - bytes - Age: - - "0" - - "0" - Content-Length: - - "154" - Content-Type: - - application/vnd.api+json - Date: - - Fri, 15 May 2020 15:35:17 GMT - Status: - - 200 OK - Strict-Transport-Security: - - max-age=31536000 - Via: - - 1.1 varnish - - 1.1 varnish - X-Cache: - - MISS, MISS - X-Cache-Hits: - - 0, 0 - X-Content-Type-Options: - - nosniff - X-Served-By: - - cache-control-slwdc9037-CONTROL-SLWDC, cache-sea4480-SEA - X-Timer: - - S1589556917.308235,VS0,VE134 - status: 200 OK - code: 200 - duration: "" diff --git a/fastly/fixtures/wafs/ruleset/patch.yaml b/fastly/fixtures/wafs/ruleset/patch.yaml deleted file mode 100644 index af38c6a3c..000000000 --- a/fastly/fixtures/wafs/ruleset/patch.yaml +++ /dev/null @@ -1,48 +0,0 @@ ---- -version: 1 -interactions: -- request: - body: | - {"data":{"type":"ruleset","id":"1NGmubiAYnKMtCvXWAeszf"}} - form: {} - headers: - Accept: - - application/vnd.api+json - Content-Type: - - application/vnd.api+json - User-Agent: - - FastlyGo/1.10.0 (+github.com/fastly/go-fastly; go1.12) - url: https://api.fastly.com/service/7i6HN3TK9wS159v2gPAZ8A/wafs/1NGmubiAYnKMtCvXWAeszf/ruleset - method: PATCH - response: - body: '{"data":{"id":"1NGmubiAYnKMtCvXWAeszf","type":"ruleset"},"links":{"related":{"href":"https://api.fastly.com/service/7i6HN3TK9wS159v2gPAZ8A/wafs/1NGmubiAYnKMtCvXWAeszf/update_statuses/37i4YLJHlPWsHB4ndwHkpt"}}}' - headers: - Accept-Ranges: - - bytes - - bytes - Content-Length: - - "209" - Content-Type: - - application/vnd.api+json - Date: - - Fri, 15 May 2020 15:35:18 GMT - Status: - - 202 Accepted - Strict-Transport-Security: - - max-age=31536000 - Via: - - 1.1 varnish - - 1.1 varnish - X-Cache: - - MISS, MISS - X-Cache-Hits: - - 0, 0 - X-Content-Type-Options: - - nosniff - X-Served-By: - - cache-control-slwdc9035-CONTROL-SLWDC, cache-sea4480-SEA - X-Timer: - - S1589556918.085171,VS0,VE109 - status: 202 Accepted - code: 202 - duration: "" diff --git a/fastly/fixtures/wafs/service/create.yaml b/fastly/fixtures/wafs/service/create.yaml index 559f69e95..205e1277b 100644 --- a/fastly/fixtures/wafs/service/create.yaml +++ b/fastly/fixtures/wafs/service/create.yaml @@ -2,34 +2,37 @@ version: 1 interactions: - request: - body: comment=go-fastly+client+test&name=test_service_service + body: comment=go-fastly+client+test&name=test_service_service2&type=vcl form: comment: - go-fastly client test name: - - test_service_service + - test_service_service2 + type: + - vcl headers: Content-Type: - application/x-www-form-urlencoded User-Agent: - - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) + - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) url: https://api.fastly.com/service method: POST response: - body: '{"customer_id":"WpqWFjTA4lk2N1g0GY2HH","comment":"go-fastly client test","name":"test_service_service","type":"vcl","versions":[{"testing":false,"service_id":"3qt0xLYGlOxt19jpAQ0LJM","deployed":false,"locked":false,"deleted_at":null,"created_at":"2019-11-20T12:59:03Z","staging":false,"comment":"","number":1,"updated_at":"2019-11-20T12:59:03Z","active":false}],"publish_key":"84a3007cd3e38afa00fdeb2cf36b24361153c410","updated_at":"2019-11-20T12:59:03Z","id":"3qt0xLYGlOxt19jpAQ0LJM","deleted_at":null,"created_at":"2019-11-20T12:59:03Z"}' + body: '{"customer_id":"WpqWFjTA4lk2N1g0GY2HH","comment":"go-fastly client test","name":"test_service_service2","type":"vcl","versions":[{"service_id":"6PehUY86Aj8yGpccQ0a8oT","locked":false,"updated_at":"2020-06-30T10:56:24Z","created_at":"2020-06-30T10:56:24Z","testing":false,"deleted_at":null,"number":1,"active":false,"comment":"","staging":false,"deployed":false}],"created_at":"2020-06-30T10:56:24Z","id":"6PehUY86Aj8yGpccQ0a8oT","updated_at":"2020-06-30T10:56:24Z","deleted_at":null,"publish_key":""}' headers: Accept-Ranges: - bytes + - bytes Cache-Control: - no-cache Content-Type: - application/json Date: - - Wed, 20 Nov 2019 12:59:03 GMT + - Tue, 30 Jun 2020 10:56:24 GMT Fastly-Ratelimit-Remaining: - - "972" + - "692" Fastly-Ratelimit-Reset: - - "1574254800" + - "1593514800" Status: - 200 OK Strict-Transport-Security: @@ -38,14 +41,15 @@ interactions: - Accept-Encoding Via: - 1.1 varnish + - 1.1 varnish X-Cache: - MISS, MISS X-Cache-Hits: - 0, 0 X-Served-By: - - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19265-LCY + - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19235-LCY X-Timer: - - S1574254744.559435,VS0,VE269 + - S1593514584.987381,VS0,VE225 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/wafs/service/delete.yaml b/fastly/fixtures/wafs/service/delete.yaml index bf88320bc..d3bae3853 100644 --- a/fastly/fixtures/wafs/service/delete.yaml +++ b/fastly/fixtures/wafs/service/delete.yaml @@ -6,24 +6,25 @@ interactions: form: {} headers: User-Agent: - - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) - url: https://api.fastly.com/service/3qt0xLYGlOxt19jpAQ0LJM + - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) + url: https://api.fastly.com/service/6PehUY86Aj8yGpccQ0a8oT method: DELETE response: body: '{"status":"ok"}' headers: Accept-Ranges: - bytes + - bytes Cache-Control: - no-cache Content-Type: - application/json Date: - - Wed, 20 Nov 2019 12:59:09 GMT + - Tue, 30 Jun 2020 10:56:32 GMT Fastly-Ratelimit-Remaining: - - "964" + - "669" Fastly-Ratelimit-Reset: - - "1574254800" + - "1593514800" Status: - 200 OK Strict-Transport-Security: @@ -32,14 +33,15 @@ interactions: - Accept-Encoding Via: - 1.1 varnish + - 1.1 varnish X-Cache: - MISS, MISS X-Cache-Hits: - 0, 0 X-Served-By: - - cache-control-slwdc9036-CONTROL-SLWDC, cache-lcy19265-LCY + - cache-control-slwdc9035-CONTROL-SLWDC, cache-lcy19235-LCY X-Timer: - - S1574254749.852966,VS0,VE301 + - S1593514592.408581,VS0,VE212 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/wafs/service/version.yaml b/fastly/fixtures/wafs/service/version.yaml index 69b717cc7..476ea32a6 100644 --- a/fastly/fixtures/wafs/service/version.yaml +++ b/fastly/fixtures/wafs/service/version.yaml @@ -2,32 +2,33 @@ version: 1 interactions: - request: - body: Service=3qt0xLYGlOxt19jpAQ0LJM + body: Service=6PehUY86Aj8yGpccQ0a8oT form: Service: - - 3qt0xLYGlOxt19jpAQ0LJM + - 6PehUY86Aj8yGpccQ0a8oT headers: Content-Type: - application/x-www-form-urlencoded User-Agent: - - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) - url: https://api.fastly.com/service/3qt0xLYGlOxt19jpAQ0LJM/version + - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) + url: https://api.fastly.com/service/6PehUY86Aj8yGpccQ0a8oT/version method: POST response: - body: '{"service_id":"3qt0xLYGlOxt19jpAQ0LJM","number":2}' + body: '{"service_id":"6PehUY86Aj8yGpccQ0a8oT","number":2}' headers: Accept-Ranges: - bytes + - bytes Cache-Control: - no-cache Content-Type: - application/json Date: - - Wed, 20 Nov 2019 12:59:04 GMT + - Tue, 30 Jun 2020 10:56:24 GMT Fastly-Ratelimit-Remaining: - - "971" + - "688" Fastly-Ratelimit-Reset: - - "1574254800" + - "1593514800" Status: - 200 OK Strict-Transport-Security: @@ -36,14 +37,15 @@ interactions: - Accept-Encoding Via: - 1.1 varnish + - 1.1 varnish X-Cache: - MISS, MISS X-Cache-Hits: - 0, 0 X-Served-By: - - cache-control-slwdc9036-CONTROL-SLWDC, cache-lcy19265-LCY + - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19235-LCY X-Timer: - - S1574254744.878101,VS0,VE349 + - S1593514585.652123,VS0,VE224 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/wafs/update.yaml b/fastly/fixtures/wafs/update.yaml index 0d2e0e503..8f7f27b01 100644 --- a/fastly/fixtures/wafs/update.yaml +++ b/fastly/fixtures/wafs/update.yaml @@ -3,7 +3,7 @@ version: 1 interactions: - request: body: | - {"data":{"type":"waf_firewall","id":"5ui1qC2Y9TZIonO95zU3gM","attributes":{"prefetch_condition":"","response":"WAF_Response2","service_id":"3qt0xLYGlOxt19jpAQ0LJM","service_version_number":"2"}}} + {"data":{"type":"waf_firewall","id":"2m5TQ56k5nWIFJusRN0Vap","attributes":{"prefetch_condition":"","response":"WAF_Response2","service_id":"6PehUY86Aj8yGpccQ0a8oT","service_version_number":"2"}}} form: {} headers: Accept: @@ -11,13 +11,13 @@ interactions: Content-Type: - application/vnd.api+json User-Agent: - - FastlyGo/1.3.0 (+github.com/fastly/go-fastly; go1.13.4) - url: https://api.fastly.com/waf/firewalls/5ui1qC2Y9TZIonO95zU3gM + - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) + url: https://api.fastly.com/waf/firewalls/2m5TQ56k5nWIFJusRN0Vap method: PATCH response: - body: '{"data":{"id":"5ui1qC2Y9TZIonO95zU3gM","type":"waf_firewall","attributes":{"service_id":"3qt0xLYGlOxt19jpAQ0LJM","prefetch_condition":"","response":"WAF_Response2","disabled":false,"service_version_number":2,"created_at":"2019-11-20T12:59:05Z","updated_at":"2019-11-20T12:59:05Z","active_rules_trustwave_log_count":0,"active_rules_trustwave_block_count":0,"active_rules_fastly_log_count":0,"active_rules_fastly_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_score_count":0}},"meta":{"warnings":[{"title":"This + body: '{"data":{"id":"2m5TQ56k5nWIFJusRN0Vap","type":"waf_firewall","attributes":{"active_rules_fastly_block_count":0,"active_rules_fastly_log_count":0,"active_rules_fastly_score_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_score_count":0,"active_rules_trustwave_block_count":0,"active_rules_trustwave_log_count":0,"created_at":"2020-06-30T10:56:27Z","disabled":false,"prefetch_condition":"","response":"WAF_Response2","service_id":"6PehUY86Aj8yGpccQ0a8oT","service_version_number":2,"updated_at":"2020-06-30T10:56:27Z"}},"meta":{"warnings":[{"title":"This version of this service must be active","detail":"You may only update the WAF - VCL on an active version of a service. The version 2 of service 3qt0xLYGlOxt19jpAQ0LJM + VCL on an active version of a service. The version 2 of service 6PehUY86Aj8yGpccQ0a8oT is not active. You may activate it through https://app.fastly.com or through the API: https://docs.fastly.com/api/config#version Be sure to review the version''s changes before activating it."}]}}' @@ -26,17 +26,18 @@ interactions: - bytes - bytes Content-Length: - - "938" + - "965" Content-Type: - application/vnd.api+json Date: - - Wed, 20 Nov 2019 12:59:07 GMT + - Tue, 30 Jun 2020 10:56:28 GMT Status: - 200 OK Strict-Transport-Security: - max-age=31536000 Via: - 1.1 varnish + - 1.1 varnish X-Cache: - MISS, MISS X-Cache-Hits: @@ -44,9 +45,9 @@ interactions: X-Content-Type-Options: - nosniff X-Served-By: - - cache-control-slwdc9035-CONTROL-SLWDC, cache-lcy19265-LCY + - cache-control-slwdc9035-CONTROL-SLWDC, cache-lcy19235-LCY X-Timer: - - S1574254747.806856,VS0,VE292 + - S1593514588.150990,VS0,VE311 status: 200 OK code: 200 duration: "" diff --git a/fastly/waf_active_rule.go b/fastly/waf_active_rule.go index cc1bb2a46..8a2e5ca00 100644 --- a/fastly/waf_active_rule.go +++ b/fastly/waf_active_rule.go @@ -17,12 +17,14 @@ var WAFActiveRuleType = reflect.TypeOf(new(WAFActiveRule)) // WAFActiveRule is the information about a WAF active rule object. type WAFActiveRule struct { - ID string `jsonapi:"primary,waf_active_rule,omitempty"` - Status string `jsonapi:"attr,status,omitempty"` - ModSecID int `jsonapi:"attr,modsec_rule_id,omitempty"` - Revision int `jsonapi:"attr,revision,omitempty"` - CreatedAt *time.Time `jsonapi:"attr,created_at,iso8601,omitempty"` - UpdatedAt *time.Time `jsonapi:"attr,updated_at,iso8601,omitempty"` + ID string `jsonapi:"primary,waf_active_rule,omitempty"` + Status string `jsonapi:"attr,status,omitempty"` + ModSecID int `jsonapi:"attr,modsec_rule_id,omitempty"` + Revision int `jsonapi:"attr,revision,omitempty"` + CreatedAt *time.Time `jsonapi:"attr,created_at,iso8601,omitempty"` + UpdatedAt *time.Time `jsonapi:"attr,updated_at,iso8601,omitempty"` + Outdated bool `jsonapi:"attr,outdated,omitempty"` + LatestRevision int `jsonapi:"attr,latest_revision,omitempty"` } // WAFActiveRuleResponse represents a list of active rules - full response. @@ -64,12 +66,12 @@ func (i *ListWAFActiveRulesInput) formatFilters() map[string]string { } for key, value := range pairings { - switch t := reflect.TypeOf(value).String(); t { - case "string": + switch value.(type) { + case string: if value != "" { result[key] = value.(string) } - case "int": + case int: if value != 0 { result[key] = strconv.Itoa(value.(int)) } @@ -89,7 +91,7 @@ func (c *Client) ListWAFActiveRules(i *ListWAFActiveRulesInput) (*WAFActiveRuleR return nil, ErrMissingWAFVersionNumber } - path := fmt.Sprintf("/waf/firewalls/%s/versions/%d/rules", i.WAFID, i.WAFVersionNumber) + path := fmt.Sprintf("/waf/firewalls/%s/versions/%d/active-rules", i.WAFID, i.WAFVersionNumber) resp, err := c.Get(path, &RequestOptions{ Params: i.formatFilters(), }) @@ -203,7 +205,7 @@ func (c *Client) CreateWAFActiveRules(i *CreateWAFActiveRulesInput) ([]*WAFActiv return nil, ErrMissingWAFActiveRuleList } - path := fmt.Sprintf("/waf/firewalls/%s/versions/%d/rules", i.WAFID, i.WAFVersionNumber) + path := fmt.Sprintf("/waf/firewalls/%s/versions/%d/active-rules", i.WAFID, i.WAFVersionNumber) resp, err := c.PostJSONAPIBulk(path, i.Rules, nil) if err != nil { return nil, err @@ -289,31 +291,7 @@ func (c *Client) DeleteWAFActiveRules(i *DeleteWAFActiveRulesInput) error { return ErrMissingWAFActiveRuleList } - path := fmt.Sprintf("/waf/firewalls/%s/versions/%d/rules", i.WAFID, i.WAFVersionNumber) + path := fmt.Sprintf("/waf/firewalls/%s/versions/%d/active-rules", i.WAFID, i.WAFVersionNumber) _, err := c.DeleteJSONAPIBulk(path, i.Rules, nil) return err } - -// DeleteAllWAFActiveRulesInput used as input for removing all rules from a WAF. -type DeleteAllWAFActiveRulesInput struct { - // The Web Application Firewall's ID. - WAFID string - // The Web Application Firewall's version number. - WAFVersionNumber int -} - -// DeleteAllWAFActiveRules removes all rules from a particular WAF. -func (c *Client) DeleteAllWAFActiveRules(i *DeleteAllWAFActiveRulesInput) error { - - if i.WAFID == "" { - return ErrMissingWAFID - } - - if i.WAFVersionNumber == 0 { - return ErrMissingWAFVersionNumber - } - - path := fmt.Sprintf("/waf/firewalls/%s/versions/%d/rules", i.WAFID, i.WAFVersionNumber) - _, err := c.DeleteJSONAPI(path, nil, nil) - return err -} diff --git a/fastly/waf_active_rule_test.go b/fastly/waf_active_rule_test.go index 35cf0be01..d4d61890a 100644 --- a/fastly/waf_active_rule_test.go +++ b/fastly/waf_active_rule_test.go @@ -145,29 +145,6 @@ func TestClient_WAF_Active_Rules(t *testing.T) { if len(rulesResp.Items) != 2 { t.Errorf("expected 2 waf rules: got %d", len(rulesResp.Items)) } - - record(t, fixtureBase+"/delete_all", func(c *Client) { - err = c.DeleteAllWAFActiveRules(&DeleteAllWAFActiveRulesInput{ - WAFID: waf.ID, - WAFVersionNumber: 1, - }) - }) - if err != nil { - t.Fatal(err) - } - - record(t, fixtureBase+"/list_after_delete_all", func(c *Client) { - rulesResp, err = c.ListWAFActiveRules(&ListWAFActiveRulesInput{ - WAFID: waf.ID, - WAFVersionNumber: 1, - }) - }) - if err != nil { - t.Fatal(err) - } - if len(rulesResp.Items) != 0 { - t.Errorf("expected 0 waf rules: got %d", len(rulesResp.Items)) - } } func TestClient_ListWAFActiveRules_validation(t *testing.T) { @@ -277,24 +254,6 @@ func TestClient_DeleteWAFActiveRules_validation(t *testing.T) { } -func TestClient_DeleteAllWAFActiveRules_validation(t *testing.T) { - var err error - err = testClient.DeleteAllWAFActiveRules(&DeleteAllWAFActiveRulesInput{ - WAFID: "", - }) - if err != ErrMissingWAFID { - t.Errorf("bad error: %s", err) - } - - err = testClient.DeleteAllWAFActiveRules(&DeleteAllWAFActiveRulesInput{ - WAFID: "1", - WAFVersionNumber: 0, - }) - if err != ErrMissingWAFVersionNumber { - t.Errorf("bad error: %s", err) - } -} - func buildWAFRules(status string) []*WAFActiveRule { return []*WAFActiveRule{ diff --git a/fastly/waf_test.go b/fastly/waf_test.go index 82fe2319c..36105632c 100644 --- a/fastly/waf_test.go +++ b/fastly/waf_test.go @@ -11,7 +11,7 @@ func TestClient_WAFs(t *testing.T) { fixtureBase := "wafs/" - testService := createTestService(t, fixtureBase+"service/create", "service") + testService := createTestService(t, fixtureBase+"service/create", "service2") defer deleteTestService(t, fixtureBase+"/service/delete", testService.ID) tv := createTestVersion(t, fixtureBase+"/service/version", testService.ID) diff --git a/fastly/waf_version_test.go b/fastly/waf_version_test.go index 2591ff919..98a598ee0 100644 --- a/fastly/waf_version_test.go +++ b/fastly/waf_version_test.go @@ -11,7 +11,7 @@ func TestClient_WAF_Versions(t *testing.T) { fixtureBase := "waf_versions/" - testService := createTestService(t, fixtureBase+"service/create", "service") + testService := createTestService(t, fixtureBase+"service/create", "service3") defer deleteTestService(t, fixtureBase+"/service/delete", testService.ID) tv := createTestVersion(t, fixtureBase+"/service/version", testService.ID) @@ -517,5 +517,3 @@ func intToPtr(i int) *int { func boolToPtr(i bool) *bool { return &i } - - From 6dd7afe7710df8cea52c7ccc6bc2abe6e2d665e0 Mon Sep 17 00:00:00 2001 From: Stuart Wallace Date: Wed, 1 Jul 2020 10:44:05 +0100 Subject: [PATCH 12/37] Remove enable/disable WAF API --- fastly/fixtures/wafs/cleanup.yaml | 10 +-- fastly/fixtures/wafs/condition/create.yaml | 18 ++-- fastly/fixtures/wafs/condition/delete.yaml | 12 +-- fastly/fixtures/wafs/create.yaml | 10 +-- fastly/fixtures/wafs/delete.yaml | 10 +-- fastly/fixtures/wafs/deploy.yaml | 8 +- fastly/fixtures/wafs/disable.yaml | 12 +-- fastly/fixtures/wafs/enable.yaml | 12 +-- fastly/fixtures/wafs/get.yaml | 10 +-- fastly/fixtures/wafs/list.yaml | 10 +-- .../wafs/response_object/cleanup_another.yaml | 12 +-- .../fixtures/wafs/response_object/create.yaml | 18 ++-- .../wafs/response_object/create_another.yaml | 18 ++-- .../fixtures/wafs/response_object/delete.yaml | 12 +-- fastly/fixtures/wafs/service/create.yaml | 12 +-- fastly/fixtures/wafs/service/delete.yaml | 12 +-- fastly/fixtures/wafs/service/version.yaml | 18 ++-- fastly/fixtures/wafs/update.yaml | 16 ++-- fastly/waf.go | 83 ++++--------------- fastly/waf_test.go | 43 ++++++---- 20 files changed, 158 insertions(+), 198 deletions(-) diff --git a/fastly/fixtures/wafs/cleanup.yaml b/fastly/fixtures/wafs/cleanup.yaml index a9b62be70..872905f6a 100644 --- a/fastly/fixtures/wafs/cleanup.yaml +++ b/fastly/fixtures/wafs/cleanup.yaml @@ -3,7 +3,7 @@ version: 1 interactions: - request: body: | - {"data":{"type":"waf_firewall","id":"2m5TQ56k5nWIFJusRN0Vap","attributes":{"service_version_number":"2"}}} + {"data":{"type":"waf_firewall","id":"206Rvtz4NQuFifzUpnhUqL","attributes":{"service_version_number":"2"}}} form: {} headers: Accept: @@ -12,7 +12,7 @@ interactions: - application/vnd.api+json User-Agent: - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) - url: https://api.fastly.com/waf/firewalls/2m5TQ56k5nWIFJusRN0Vap + url: https://api.fastly.com/waf/firewalls/206Rvtz4NQuFifzUpnhUqL method: DELETE response: body: '{"errors":[{"title":"Resource not found","detail":"We could not find a @@ -24,7 +24,7 @@ interactions: Content-Type: - application/vnd.api+json Date: - - Tue, 30 Jun 2020 10:56:30 GMT + - Wed, 01 Jul 2020 09:40:43 GMT Status: - 404 Not Found Strict-Transport-Security: @@ -37,9 +37,9 @@ interactions: X-Cache-Hits: - 0, 0 X-Served-By: - - cache-control-slwdc9036-CONTROL-SLWDC, cache-lcy19235-LCY + - cache-control-slwdc9035-CONTROL-SLWDC, cache-lcy19273-LCY X-Timer: - - S1593514591.815640,VS0,VE156 + - S1593596443.956301,VS0,VE134 status: 404 Not Found code: 404 duration: "" diff --git a/fastly/fixtures/wafs/condition/create.yaml b/fastly/fixtures/wafs/condition/create.yaml index 0fef972a8..12bfd2bb6 100644 --- a/fastly/fixtures/wafs/condition/create.yaml +++ b/fastly/fixtures/wafs/condition/create.yaml @@ -2,10 +2,10 @@ version: 1 interactions: - request: - body: Service=6PehUY86Aj8yGpccQ0a8oT&Version=2&name=WAF_Prefetch&priority=1&statement=req.url~%2B%22index.html%22&type=PREFETCH + body: Service=5MlnHT66t9pZgO8XrBEDQl&Version=2&name=WAF_Prefetch&priority=1&statement=req.url~%2B%22index.html%22&type=PREFETCH form: Service: - - 6PehUY86Aj8yGpccQ0a8oT + - 5MlnHT66t9pZgO8XrBEDQl Version: - "2" name: @@ -21,10 +21,10 @@ interactions: - application/x-www-form-urlencoded User-Agent: - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) - url: https://api.fastly.com/service/6PehUY86Aj8yGpccQ0a8oT/version/2/condition + url: https://api.fastly.com/service/5MlnHT66t9pZgO8XrBEDQl/version/2/condition method: POST response: - body: '{"name":"WAF_Prefetch","priority":"1","statement":"req.url~+\"index.html\"","type":"PREFETCH","service_id":"6PehUY86Aj8yGpccQ0a8oT","version":"2","comment":"","updated_at":"2020-06-30T10:56:25Z","created_at":"2020-06-30T10:56:25Z","deleted_at":null}' + body: '{"name":"WAF_Prefetch","priority":"1","statement":"req.url~+\"index.html\"","type":"PREFETCH","service_id":"5MlnHT66t9pZgO8XrBEDQl","version":"2","created_at":"2020-07-01T09:40:37Z","comment":"","updated_at":"2020-07-01T09:40:37Z","deleted_at":null}' headers: Accept-Ranges: - bytes @@ -34,11 +34,11 @@ interactions: Content-Type: - application/json Date: - - Tue, 30 Jun 2020 10:56:25 GMT + - Wed, 01 Jul 2020 09:40:37 GMT Fastly-Ratelimit-Remaining: - - "685" + - "979" Fastly-Ratelimit-Reset: - - "1593514800" + - "1593597600" Status: - 200 OK Strict-Transport-Security: @@ -53,9 +53,9 @@ interactions: X-Cache-Hits: - 0, 0 X-Served-By: - - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19235-LCY + - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19273-LCY X-Timer: - - S1593514585.002337,VS0,VE451 + - S1593596437.298159,VS0,VE195 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/wafs/condition/delete.yaml b/fastly/fixtures/wafs/condition/delete.yaml index b421922e0..9ebdd909f 100644 --- a/fastly/fixtures/wafs/condition/delete.yaml +++ b/fastly/fixtures/wafs/condition/delete.yaml @@ -7,7 +7,7 @@ interactions: headers: User-Agent: - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) - url: https://api.fastly.com/service/6PehUY86Aj8yGpccQ0a8oT/version/2/condition/WAF_Prefetch + url: https://api.fastly.com/service/5MlnHT66t9pZgO8XrBEDQl/version/2/condition/WAF_Prefetch method: DELETE response: body: '{"status":"ok"}' @@ -20,11 +20,11 @@ interactions: Content-Type: - application/json Date: - - Tue, 30 Jun 2020 10:56:32 GMT + - Wed, 01 Jul 2020 09:40:44 GMT Fastly-Ratelimit-Remaining: - - "671" + - "974" Fastly-Ratelimit-Reset: - - "1593514800" + - "1593597600" Status: - 200 OK Strict-Transport-Security: @@ -39,9 +39,9 @@ interactions: X-Cache-Hits: - 0, 0 X-Served-By: - - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19235-LCY + - cache-control-slwdc9035-CONTROL-SLWDC, cache-lcy19273-LCY X-Timer: - - S1593514592.036626,VS0,VE184 + - S1593596444.150375,VS0,VE223 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/wafs/create.yaml b/fastly/fixtures/wafs/create.yaml index b029f9ee6..1eb88dd77 100644 --- a/fastly/fixtures/wafs/create.yaml +++ b/fastly/fixtures/wafs/create.yaml @@ -3,7 +3,7 @@ version: 1 interactions: - request: body: | - {"data":{"type":"waf_firewall","attributes":{"prefetch_condition":"WAF_Prefetch","response":"WAF_Response","service_id":"6PehUY86Aj8yGpccQ0a8oT","service_version_number":"2"}}} + {"data":{"type":"waf_firewall","attributes":{"prefetch_condition":"WAF_Prefetch","response":"WAF_Response","service_id":"5MlnHT66t9pZgO8XrBEDQl","service_version_number":"2"}}} form: {} headers: Accept: @@ -15,7 +15,7 @@ interactions: url: https://api.fastly.com/waf/firewalls method: POST response: - body: '{"data":{"id":"2m5TQ56k5nWIFJusRN0Vap","type":"waf_firewall","attributes":{"active_rules_fastly_block_count":0,"active_rules_fastly_log_count":0,"active_rules_fastly_score_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_score_count":0,"active_rules_trustwave_block_count":0,"active_rules_trustwave_log_count":0,"created_at":"2020-06-30T10:56:27Z","disabled":false,"prefetch_condition":"WAF_Prefetch","response":"WAF_Response","service_id":"6PehUY86Aj8yGpccQ0a8oT","service_version_number":2,"updated_at":"2020-06-30T10:56:27Z"}}}' + body: '{"data":{"id":"206Rvtz4NQuFifzUpnhUqL","type":"waf_firewall","attributes":{"active_rules_fastly_block_count":0,"active_rules_fastly_log_count":0,"active_rules_fastly_score_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_score_count":0,"active_rules_trustwave_block_count":0,"active_rules_trustwave_log_count":0,"created_at":"2020-07-01T09:40:39Z","disabled":false,"prefetch_condition":"WAF_Prefetch","response":"WAF_Response","service_id":"5MlnHT66t9pZgO8XrBEDQl","service_version_number":2,"updated_at":"2020-07-01T09:40:39Z"}}}' headers: Accept-Ranges: - bytes @@ -25,7 +25,7 @@ interactions: Content-Type: - application/vnd.api+json Date: - - Tue, 30 Jun 2020 10:56:27 GMT + - Wed, 01 Jul 2020 09:40:39 GMT Status: - 201 Created Strict-Transport-Security: @@ -40,9 +40,9 @@ interactions: X-Content-Type-Options: - nosniff X-Served-By: - - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19235-LCY + - cache-control-slwdc9036-CONTROL-SLWDC, cache-lcy19273-LCY X-Timer: - - S1593514586.335980,VS0,VE783 + - S1593596438.341101,VS0,VE830 status: 201 Created code: 201 duration: "" diff --git a/fastly/fixtures/wafs/delete.yaml b/fastly/fixtures/wafs/delete.yaml index 2851b6826..fc2966823 100644 --- a/fastly/fixtures/wafs/delete.yaml +++ b/fastly/fixtures/wafs/delete.yaml @@ -3,7 +3,7 @@ version: 1 interactions: - request: body: | - {"data":{"type":"waf_firewall","id":"2m5TQ56k5nWIFJusRN0Vap","attributes":{"service_version_number":"2"}}} + {"data":{"type":"waf_firewall","id":"206Rvtz4NQuFifzUpnhUqL","attributes":{"service_version_number":"2"}}} form: {} headers: Accept: @@ -12,7 +12,7 @@ interactions: - application/vnd.api+json User-Agent: - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) - url: https://api.fastly.com/waf/firewalls/2m5TQ56k5nWIFJusRN0Vap + url: https://api.fastly.com/waf/firewalls/206Rvtz4NQuFifzUpnhUqL method: DELETE response: body: "" @@ -21,7 +21,7 @@ interactions: - bytes - bytes Date: - - Tue, 30 Jun 2020 10:56:30 GMT + - Wed, 01 Jul 2020 09:40:42 GMT Status: - 204 No Content Strict-Transport-Security: @@ -36,9 +36,9 @@ interactions: X-Content-Type-Options: - nosniff X-Served-By: - - cache-control-slwdc9035-CONTROL-SLWDC, cache-lcy19235-LCY + - cache-control-slwdc9036-CONTROL-SLWDC, cache-lcy19273-LCY X-Timer: - - S1593514590.075210,VS0,VE595 + - S1593596443.569625,VS0,VE255 status: 204 No Content code: 204 duration: "" diff --git a/fastly/fixtures/wafs/deploy.yaml b/fastly/fixtures/wafs/deploy.yaml index 29bbcd1bc..f7273b8f9 100644 --- a/fastly/fixtures/wafs/deploy.yaml +++ b/fastly/fixtures/wafs/deploy.yaml @@ -12,7 +12,7 @@ interactions: - application/vnd.api+json User-Agent: - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) - url: https://api.fastly.com/waf/firewalls/2m5TQ56k5nWIFJusRN0Vap/versions/1 + url: https://api.fastly.com/waf/firewalls/206Rvtz4NQuFifzUpnhUqL/versions/1 method: POST response: body: '{}' @@ -25,7 +25,7 @@ interactions: Content-Type: - application/vnd.api+json Date: - - Tue, 30 Jun 2020 10:56:27 GMT + - Wed, 01 Jul 2020 09:40:39 GMT Status: - 202 Accepted Strict-Transport-Security: @@ -40,9 +40,9 @@ interactions: X-Content-Type-Options: - nosniff X-Served-By: - - cache-control-slwdc9036-CONTROL-SLWDC, cache-lcy19235-LCY + - cache-control-slwdc9035-CONTROL-SLWDC, cache-lcy19273-LCY X-Timer: - - S1593514588.553163,VS0,VE139 + - S1593596440.647605,VS0,VE142 status: 202 Accepted code: 202 duration: "" diff --git a/fastly/fixtures/wafs/disable.yaml b/fastly/fixtures/wafs/disable.yaml index 296a72f98..860b68317 100644 --- a/fastly/fixtures/wafs/disable.yaml +++ b/fastly/fixtures/wafs/disable.yaml @@ -3,7 +3,7 @@ version: 1 interactions: - request: body: | - {"data":{"type":"","attributes":{"disabled":true}}} + {"data":{"type":"waf_firewall","id":"206Rvtz4NQuFifzUpnhUqL","attributes":{"disabled":true}}} form: {} headers: Accept: @@ -12,10 +12,10 @@ interactions: - application/vnd.api+json User-Agent: - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) - url: https://api.fastly.com/waf/firewalls/2m5TQ56k5nWIFJusRN0Vap + url: https://api.fastly.com/waf/firewalls/206Rvtz4NQuFifzUpnhUqL method: PATCH response: - body: '{"data":{"id":"2m5TQ56k5nWIFJusRN0Vap","type":"waf_firewall","attributes":{"active_rules_fastly_block_count":0,"active_rules_fastly_log_count":0,"active_rules_fastly_score_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_score_count":0,"active_rules_trustwave_block_count":0,"active_rules_trustwave_log_count":0,"created_at":"2020-06-30T10:56:27Z","disabled":true,"prefetch_condition":null,"response":null,"service_id":"6PehUY86Aj8yGpccQ0a8oT","service_version_number":null,"updated_at":"2020-06-30T10:56:29Z"}}}' + body: '{"data":{"id":"206Rvtz4NQuFifzUpnhUqL","type":"waf_firewall","attributes":{"active_rules_fastly_block_count":0,"active_rules_fastly_log_count":0,"active_rules_fastly_score_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_score_count":0,"active_rules_trustwave_block_count":0,"active_rules_trustwave_log_count":0,"created_at":"2020-07-01T09:40:39Z","disabled":true,"prefetch_condition":null,"response":null,"service_id":"5MlnHT66t9pZgO8XrBEDQl","service_version_number":null,"updated_at":"2020-07-01T09:40:41Z"}}}' headers: Accept-Ranges: - bytes @@ -25,7 +25,7 @@ interactions: Content-Type: - application/vnd.api+json Date: - - Tue, 30 Jun 2020 10:56:29 GMT + - Wed, 01 Jul 2020 09:40:41 GMT Status: - 200 OK Strict-Transport-Security: @@ -40,9 +40,9 @@ interactions: X-Content-Type-Options: - nosniff X-Served-By: - - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19235-LCY + - cache-control-slwdc9036-CONTROL-SLWDC, cache-lcy19273-LCY X-Timer: - - S1593514589.581966,VS0,VE658 + - S1593596441.933188,VS0,VE667 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/wafs/enable.yaml b/fastly/fixtures/wafs/enable.yaml index d1c46a9c8..b9e1849e7 100644 --- a/fastly/fixtures/wafs/enable.yaml +++ b/fastly/fixtures/wafs/enable.yaml @@ -3,7 +3,7 @@ version: 1 interactions: - request: body: | - {"data":{"type":"waf_firewall","id":"2m5TQ56k5nWIFJusRN0Vap","attributes":{"disabled":false}}} + {"data":{"type":"waf_firewall","id":"206Rvtz4NQuFifzUpnhUqL","attributes":{"disabled":false}}} form: {} headers: Accept: @@ -12,10 +12,10 @@ interactions: - application/vnd.api+json User-Agent: - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) - url: https://api.fastly.com/waf/firewalls/2m5TQ56k5nWIFJusRN0Vap + url: https://api.fastly.com/waf/firewalls/206Rvtz4NQuFifzUpnhUqL method: PATCH response: - body: '{"data":{"id":"2m5TQ56k5nWIFJusRN0Vap","type":"waf_firewall","attributes":{"active_rules_fastly_block_count":0,"active_rules_fastly_log_count":0,"active_rules_fastly_score_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_score_count":0,"active_rules_trustwave_block_count":0,"active_rules_trustwave_log_count":0,"created_at":"2020-06-30T10:56:27Z","disabled":false,"prefetch_condition":null,"response":null,"service_id":"6PehUY86Aj8yGpccQ0a8oT","service_version_number":null,"updated_at":"2020-06-30T10:56:29Z"}}}' + body: '{"data":{"id":"206Rvtz4NQuFifzUpnhUqL","type":"waf_firewall","attributes":{"active_rules_fastly_block_count":0,"active_rules_fastly_log_count":0,"active_rules_fastly_score_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_score_count":0,"active_rules_trustwave_block_count":0,"active_rules_trustwave_log_count":0,"created_at":"2020-07-01T09:40:39Z","disabled":false,"prefetch_condition":null,"response":null,"service_id":"5MlnHT66t9pZgO8XrBEDQl","service_version_number":null,"updated_at":"2020-07-01T09:40:42Z"}}}' headers: Accept-Ranges: - bytes @@ -25,7 +25,7 @@ interactions: Content-Type: - application/vnd.api+json Date: - - Tue, 30 Jun 2020 10:56:29 GMT + - Wed, 01 Jul 2020 09:40:42 GMT Status: - 200 OK Strict-Transport-Security: @@ -40,9 +40,9 @@ interactions: X-Content-Type-Options: - nosniff X-Served-By: - - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19235-LCY + - cache-control-slwdc9036-CONTROL-SLWDC, cache-lcy19273-LCY X-Timer: - - S1593514589.338495,VS0,VE622 + - S1593596442.742125,VS0,VE705 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/wafs/get.yaml b/fastly/fixtures/wafs/get.yaml index e32e5b77b..4201adc2c 100644 --- a/fastly/fixtures/wafs/get.yaml +++ b/fastly/fixtures/wafs/get.yaml @@ -7,10 +7,10 @@ interactions: headers: User-Agent: - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) - url: https://api.fastly.com/waf/firewalls/2m5TQ56k5nWIFJusRN0Vap?filter%5Bservice_version_number%5D=2 + url: https://api.fastly.com/waf/firewalls/206Rvtz4NQuFifzUpnhUqL?filter%5Bservice_version_number%5D=2 method: GET response: - body: '{"data":{"id":"2m5TQ56k5nWIFJusRN0Vap","type":"waf_firewall","attributes":{"active_rules_fastly_block_count":0,"active_rules_fastly_log_count":0,"active_rules_fastly_score_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_score_count":0,"active_rules_trustwave_block_count":0,"active_rules_trustwave_log_count":0,"created_at":"2020-06-30T10:56:27Z","disabled":false,"prefetch_condition":"WAF_Prefetch","response":"WAF_Response","service_id":"6PehUY86Aj8yGpccQ0a8oT","service_version_number":2,"updated_at":"2020-06-30T10:56:27Z"}}}' + body: '{"data":{"id":"206Rvtz4NQuFifzUpnhUqL","type":"waf_firewall","attributes":{"active_rules_fastly_block_count":0,"active_rules_fastly_log_count":0,"active_rules_fastly_score_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_score_count":0,"active_rules_trustwave_block_count":0,"active_rules_trustwave_log_count":0,"created_at":"2020-07-01T09:40:39Z","disabled":false,"prefetch_condition":"WAF_Prefetch","response":"WAF_Response","service_id":"5MlnHT66t9pZgO8XrBEDQl","service_version_number":2,"updated_at":"2020-07-01T09:40:39Z"}}}' headers: Accept-Ranges: - bytes @@ -24,7 +24,7 @@ interactions: Content-Type: - application/vnd.api+json Date: - - Tue, 30 Jun 2020 10:56:28 GMT + - Wed, 01 Jul 2020 09:40:40 GMT Status: - 200 OK Strict-Transport-Security: @@ -39,9 +39,9 @@ interactions: X-Content-Type-Options: - nosniff X-Served-By: - - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19235-LCY + - cache-control-slwdc9036-CONTROL-SLWDC, cache-lcy19273-LCY X-Timer: - - S1593514588.863572,VS0,VE179 + - S1593596440.975316,VS0,VE425 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/wafs/list.yaml b/fastly/fixtures/wafs/list.yaml index a0115ac6a..cfa783e8f 100644 --- a/fastly/fixtures/wafs/list.yaml +++ b/fastly/fixtures/wafs/list.yaml @@ -7,10 +7,10 @@ interactions: headers: User-Agent: - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) - url: https://api.fastly.com/waf/firewalls?filter%5Bservice_id%5D=6PehUY86Aj8yGpccQ0a8oT&filter%5Bservice_version_number%5D=2 + url: https://api.fastly.com/waf/firewalls?filter%5Bservice_id%5D=5MlnHT66t9pZgO8XrBEDQl&filter%5Bservice_version_number%5D=2 method: GET response: - body: '{"data":[{"id":"2m5TQ56k5nWIFJusRN0Vap","type":"waf_firewall","attributes":{"active_rules_fastly_block_count":0,"active_rules_fastly_log_count":0,"active_rules_fastly_score_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_score_count":0,"active_rules_trustwave_block_count":0,"active_rules_trustwave_log_count":0,"created_at":"2020-06-30T10:56:27Z","disabled":false,"prefetch_condition":"WAF_Prefetch","response":"WAF_Response","service_id":"6PehUY86Aj8yGpccQ0a8oT","service_version_number":2,"updated_at":"2020-06-30T10:56:27Z"}}],"links":{"last":"https://api.fastly.com/waf/firewalls?filter[service_id]=6PehUY86Aj8yGpccQ0a8oT\u0026filter[service_version_number]=2\u0026page[number]=1\u0026page[size]=100","first":"https://api.fastly.com/waf/firewalls?filter[service_id]=6PehUY86Aj8yGpccQ0a8oT\u0026filter[service_version_number]=2\u0026page[number]=1\u0026page[size]=100"},"meta":{"current_page":1,"per_page":100,"record_count":1,"total_pages":1}}' + body: '{"data":[{"id":"206Rvtz4NQuFifzUpnhUqL","type":"waf_firewall","attributes":{"active_rules_fastly_block_count":0,"active_rules_fastly_log_count":0,"active_rules_fastly_score_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_score_count":0,"active_rules_trustwave_block_count":0,"active_rules_trustwave_log_count":0,"created_at":"2020-07-01T09:40:39Z","disabled":false,"prefetch_condition":"WAF_Prefetch","response":"WAF_Response","service_id":"5MlnHT66t9pZgO8XrBEDQl","service_version_number":2,"updated_at":"2020-07-01T09:40:39Z"}}],"links":{"last":"https://api.fastly.com/waf/firewalls?filter[service_id]=5MlnHT66t9pZgO8XrBEDQl\u0026filter[service_version_number]=2\u0026page[number]=1\u0026page[size]=100","first":"https://api.fastly.com/waf/firewalls?filter[service_id]=5MlnHT66t9pZgO8XrBEDQl\u0026filter[service_version_number]=2\u0026page[number]=1\u0026page[size]=100"},"meta":{"current_page":1,"per_page":100,"record_count":1,"total_pages":1}}' headers: Accept-Ranges: - bytes @@ -24,7 +24,7 @@ interactions: Content-Type: - application/vnd.api+json Date: - - Tue, 30 Jun 2020 10:56:27 GMT + - Wed, 01 Jul 2020 09:40:39 GMT Status: - 200 OK Strict-Transport-Security: @@ -39,9 +39,9 @@ interactions: X-Content-Type-Options: - nosniff X-Served-By: - - cache-control-slwdc9035-CONTROL-SLWDC, cache-lcy19235-LCY + - cache-control-slwdc9036-CONTROL-SLWDC, cache-lcy19273-LCY X-Timer: - - S1593514587.296392,VS0,VE179 + - S1593596439.359453,VS0,VE194 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/wafs/response_object/cleanup_another.yaml b/fastly/fixtures/wafs/response_object/cleanup_another.yaml index cbe989e4c..ad29433a6 100644 --- a/fastly/fixtures/wafs/response_object/cleanup_another.yaml +++ b/fastly/fixtures/wafs/response_object/cleanup_another.yaml @@ -7,7 +7,7 @@ interactions: headers: User-Agent: - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) - url: https://api.fastly.com/service/6PehUY86Aj8yGpccQ0a8oT/version/2/response_object/WAF_Response2 + url: https://api.fastly.com/service/5MlnHT66t9pZgO8XrBEDQl/version/2/response_object/WAF_Response2 method: DELETE response: body: '{"status":"ok"}' @@ -20,11 +20,11 @@ interactions: Content-Type: - application/json Date: - - Tue, 30 Jun 2020 10:56:31 GMT + - Wed, 01 Jul 2020 09:40:43 GMT Fastly-Ratelimit-Remaining: - - "675" + - "976" Fastly-Ratelimit-Reset: - - "1593514800" + - "1593597600" Status: - 200 OK Strict-Transport-Security: @@ -39,9 +39,9 @@ interactions: X-Cache-Hits: - 0, 0 X-Served-By: - - cache-control-slwdc9035-CONTROL-SLWDC, cache-lcy19235-LCY + - cache-control-slwdc9035-CONTROL-SLWDC, cache-lcy19273-LCY X-Timer: - - S1593514591.168293,VS0,VE283 + - S1593596443.282633,VS0,VE252 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/wafs/response_object/create.yaml b/fastly/fixtures/wafs/response_object/create.yaml index 431d89191..4e990576f 100644 --- a/fastly/fixtures/wafs/response_object/create.yaml +++ b/fastly/fixtures/wafs/response_object/create.yaml @@ -2,10 +2,10 @@ version: 1 interactions: - request: - body: Service=6PehUY86Aj8yGpccQ0a8oT&Version=2&name=WAF_Response&status=403 + body: Service=5MlnHT66t9pZgO8XrBEDQl&Version=2&name=WAF_Response&status=403 form: Service: - - 6PehUY86Aj8yGpccQ0a8oT + - 5MlnHT66t9pZgO8XrBEDQl Version: - "2" name: @@ -17,10 +17,10 @@ interactions: - application/x-www-form-urlencoded User-Agent: - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) - url: https://api.fastly.com/service/6PehUY86Aj8yGpccQ0a8oT/version/2/response_object + url: https://api.fastly.com/service/5MlnHT66t9pZgO8XrBEDQl/version/2/response_object method: POST response: - body: '{"name":"WAF_Response","status":"403","service_id":"6PehUY86Aj8yGpccQ0a8oT","version":"2","response":"ok","updated_at":"2020-06-30T10:56:25Z","created_at":"2020-06-30T10:56:25Z","content_type":null,"request_condition":"","content":null,"deleted_at":null,"cache_condition":""}' + body: '{"name":"WAF_Response","status":"403","service_id":"5MlnHT66t9pZgO8XrBEDQl","version":"2","content":null,"deleted_at":null,"response":"ok","cache_condition":"","created_at":"2020-07-01T09:40:37Z","content_type":null,"request_condition":"","updated_at":"2020-07-01T09:40:37Z"}' headers: Accept-Ranges: - bytes @@ -30,11 +30,11 @@ interactions: Content-Type: - application/json Date: - - Tue, 30 Jun 2020 10:56:25 GMT + - Wed, 01 Jul 2020 09:40:37 GMT Fastly-Ratelimit-Remaining: - - "683" + - "978" Fastly-Ratelimit-Reset: - - "1593514800" + - "1593597600" Status: - 200 OK Strict-Transport-Security: @@ -49,9 +49,9 @@ interactions: X-Cache-Hits: - 0, 0 X-Served-By: - - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19235-LCY + - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19273-LCY X-Timer: - - S1593514586.539867,VS0,VE271 + - S1593596438.626325,VS0,VE243 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/wafs/response_object/create_another.yaml b/fastly/fixtures/wafs/response_object/create_another.yaml index 43c22a761..a1b3ee4fd 100644 --- a/fastly/fixtures/wafs/response_object/create_another.yaml +++ b/fastly/fixtures/wafs/response_object/create_another.yaml @@ -2,10 +2,10 @@ version: 1 interactions: - request: - body: Service=6PehUY86Aj8yGpccQ0a8oT&Version=2&name=WAF_Response2&status=403 + body: Service=5MlnHT66t9pZgO8XrBEDQl&Version=2&name=WAF_Response2&status=403 form: Service: - - 6PehUY86Aj8yGpccQ0a8oT + - 5MlnHT66t9pZgO8XrBEDQl Version: - "2" name: @@ -17,10 +17,10 @@ interactions: - application/x-www-form-urlencoded User-Agent: - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) - url: https://api.fastly.com/service/6PehUY86Aj8yGpccQ0a8oT/version/2/response_object + url: https://api.fastly.com/service/5MlnHT66t9pZgO8XrBEDQl/version/2/response_object method: POST response: - body: '{"name":"WAF_Response2","status":"403","service_id":"6PehUY86Aj8yGpccQ0a8oT","version":"2","response":"ok","content":null,"updated_at":"2020-06-30T10:56:26Z","cache_condition":"","deleted_at":null,"request_condition":"","content_type":null,"created_at":"2020-06-30T10:56:26Z"}' + body: '{"name":"WAF_Response2","status":"403","service_id":"5MlnHT66t9pZgO8XrBEDQl","version":"2","content_type":null,"deleted_at":null,"updated_at":"2020-07-01T09:40:38Z","request_condition":"","content":null,"created_at":"2020-07-01T09:40:38Z","cache_condition":"","response":"ok"}' headers: Accept-Ranges: - bytes @@ -30,11 +30,11 @@ interactions: Content-Type: - application/json Date: - - Tue, 30 Jun 2020 10:56:26 GMT + - Wed, 01 Jul 2020 09:40:38 GMT Fastly-Ratelimit-Remaining: - - "681" + - "977" Fastly-Ratelimit-Reset: - - "1593514800" + - "1593597600" Status: - 200 OK Strict-Transport-Security: @@ -49,9 +49,9 @@ interactions: X-Cache-Hits: - 0, 0 X-Served-By: - - cache-control-slwdc9035-CONTROL-SLWDC, cache-lcy19235-LCY + - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19273-LCY X-Timer: - - S1593514586.885042,VS0,VE316 + - S1593596438.994076,VS0,VE219 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/wafs/response_object/delete.yaml b/fastly/fixtures/wafs/response_object/delete.yaml index 9e3ee8b42..5fd50e3b2 100644 --- a/fastly/fixtures/wafs/response_object/delete.yaml +++ b/fastly/fixtures/wafs/response_object/delete.yaml @@ -7,7 +7,7 @@ interactions: headers: User-Agent: - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) - url: https://api.fastly.com/service/6PehUY86Aj8yGpccQ0a8oT/version/2/response_object/WAF_Response + url: https://api.fastly.com/service/5MlnHT66t9pZgO8XrBEDQl/version/2/response_object/WAF_Response method: DELETE response: body: '{"status":"ok"}' @@ -20,11 +20,11 @@ interactions: Content-Type: - application/json Date: - - Tue, 30 Jun 2020 10:56:31 GMT + - Wed, 01 Jul 2020 09:40:43 GMT Fastly-Ratelimit-Remaining: - - "673" + - "975" Fastly-Ratelimit-Reset: - - "1593514800" + - "1593597600" Status: - 200 OK Strict-Transport-Security: @@ -39,9 +39,9 @@ interactions: X-Cache-Hits: - 0, 0 X-Served-By: - - cache-control-slwdc9036-CONTROL-SLWDC, cache-lcy19235-LCY + - cache-control-slwdc9035-CONTROL-SLWDC, cache-lcy19273-LCY X-Timer: - - S1593514592.653737,VS0,VE214 + - S1593596444.711876,VS0,VE248 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/wafs/service/create.yaml b/fastly/fixtures/wafs/service/create.yaml index 205e1277b..503f0c020 100644 --- a/fastly/fixtures/wafs/service/create.yaml +++ b/fastly/fixtures/wafs/service/create.yaml @@ -18,7 +18,7 @@ interactions: url: https://api.fastly.com/service method: POST response: - body: '{"customer_id":"WpqWFjTA4lk2N1g0GY2HH","comment":"go-fastly client test","name":"test_service_service2","type":"vcl","versions":[{"service_id":"6PehUY86Aj8yGpccQ0a8oT","locked":false,"updated_at":"2020-06-30T10:56:24Z","created_at":"2020-06-30T10:56:24Z","testing":false,"deleted_at":null,"number":1,"active":false,"comment":"","staging":false,"deployed":false}],"created_at":"2020-06-30T10:56:24Z","id":"6PehUY86Aj8yGpccQ0a8oT","updated_at":"2020-06-30T10:56:24Z","deleted_at":null,"publish_key":""}' + body: '{"customer_id":"WpqWFjTA4lk2N1g0GY2HH","comment":"go-fastly client test","name":"test_service_service2","type":"vcl","updated_at":"2020-07-01T09:40:36Z","id":"5MlnHT66t9pZgO8XrBEDQl","publish_key":"","versions":[{"active":false,"updated_at":"2020-07-01T09:40:36Z","staging":false,"service_id":"5MlnHT66t9pZgO8XrBEDQl","deleted_at":null,"comment":"","created_at":"2020-07-01T09:40:36Z","number":1,"testing":false,"locked":false,"deployed":false}],"deleted_at":null,"created_at":"2020-07-01T09:40:36Z"}' headers: Accept-Ranges: - bytes @@ -28,11 +28,11 @@ interactions: Content-Type: - application/json Date: - - Tue, 30 Jun 2020 10:56:24 GMT + - Wed, 01 Jul 2020 09:40:36 GMT Fastly-Ratelimit-Remaining: - - "692" + - "981" Fastly-Ratelimit-Reset: - - "1593514800" + - "1593597600" Status: - 200 OK Strict-Transport-Security: @@ -47,9 +47,9 @@ interactions: X-Cache-Hits: - 0, 0 X-Served-By: - - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19235-LCY + - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19273-LCY X-Timer: - - S1593514584.987381,VS0,VE225 + - S1593596436.357176,VS0,VE226 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/wafs/service/delete.yaml b/fastly/fixtures/wafs/service/delete.yaml index d3bae3853..9201166e6 100644 --- a/fastly/fixtures/wafs/service/delete.yaml +++ b/fastly/fixtures/wafs/service/delete.yaml @@ -7,7 +7,7 @@ interactions: headers: User-Agent: - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) - url: https://api.fastly.com/service/6PehUY86Aj8yGpccQ0a8oT + url: https://api.fastly.com/service/5MlnHT66t9pZgO8XrBEDQl method: DELETE response: body: '{"status":"ok"}' @@ -20,11 +20,11 @@ interactions: Content-Type: - application/json Date: - - Tue, 30 Jun 2020 10:56:32 GMT + - Wed, 01 Jul 2020 09:40:44 GMT Fastly-Ratelimit-Remaining: - - "669" + - "973" Fastly-Ratelimit-Reset: - - "1593514800" + - "1593597600" Status: - 200 OK Strict-Transport-Security: @@ -39,9 +39,9 @@ interactions: X-Cache-Hits: - 0, 0 X-Served-By: - - cache-control-slwdc9035-CONTROL-SLWDC, cache-lcy19235-LCY + - cache-control-slwdc9035-CONTROL-SLWDC, cache-lcy19273-LCY X-Timer: - - S1593514592.408581,VS0,VE212 + - S1593596445.566062,VS0,VE235 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/wafs/service/version.yaml b/fastly/fixtures/wafs/service/version.yaml index 476ea32a6..364e0f446 100644 --- a/fastly/fixtures/wafs/service/version.yaml +++ b/fastly/fixtures/wafs/service/version.yaml @@ -2,19 +2,19 @@ version: 1 interactions: - request: - body: Service=6PehUY86Aj8yGpccQ0a8oT + body: Service=5MlnHT66t9pZgO8XrBEDQl form: Service: - - 6PehUY86Aj8yGpccQ0a8oT + - 5MlnHT66t9pZgO8XrBEDQl headers: Content-Type: - application/x-www-form-urlencoded User-Agent: - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) - url: https://api.fastly.com/service/6PehUY86Aj8yGpccQ0a8oT/version + url: https://api.fastly.com/service/5MlnHT66t9pZgO8XrBEDQl/version method: POST response: - body: '{"service_id":"6PehUY86Aj8yGpccQ0a8oT","number":2}' + body: '{"service_id":"5MlnHT66t9pZgO8XrBEDQl","number":2}' headers: Accept-Ranges: - bytes @@ -24,11 +24,11 @@ interactions: Content-Type: - application/json Date: - - Tue, 30 Jun 2020 10:56:24 GMT + - Wed, 01 Jul 2020 09:40:37 GMT Fastly-Ratelimit-Remaining: - - "688" + - "980" Fastly-Ratelimit-Reset: - - "1593514800" + - "1593597600" Status: - 200 OK Strict-Transport-Security: @@ -43,9 +43,9 @@ interactions: X-Cache-Hits: - 0, 0 X-Served-By: - - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19235-LCY + - cache-control-slwdc9035-CONTROL-SLWDC, cache-lcy19273-LCY X-Timer: - - S1593514585.652123,VS0,VE224 + - S1593596437.730308,VS0,VE444 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/wafs/update.yaml b/fastly/fixtures/wafs/update.yaml index 8f7f27b01..7281b8183 100644 --- a/fastly/fixtures/wafs/update.yaml +++ b/fastly/fixtures/wafs/update.yaml @@ -3,7 +3,7 @@ version: 1 interactions: - request: body: | - {"data":{"type":"waf_firewall","id":"2m5TQ56k5nWIFJusRN0Vap","attributes":{"prefetch_condition":"","response":"WAF_Response2","service_id":"6PehUY86Aj8yGpccQ0a8oT","service_version_number":"2"}}} + {"data":{"type":"waf_firewall","id":"206Rvtz4NQuFifzUpnhUqL","attributes":{"response":"WAF_Response2","service_id":"5MlnHT66t9pZgO8XrBEDQl","service_version_number":"2"}}} form: {} headers: Accept: @@ -12,12 +12,12 @@ interactions: - application/vnd.api+json User-Agent: - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) - url: https://api.fastly.com/waf/firewalls/2m5TQ56k5nWIFJusRN0Vap + url: https://api.fastly.com/waf/firewalls/206Rvtz4NQuFifzUpnhUqL method: PATCH response: - body: '{"data":{"id":"2m5TQ56k5nWIFJusRN0Vap","type":"waf_firewall","attributes":{"active_rules_fastly_block_count":0,"active_rules_fastly_log_count":0,"active_rules_fastly_score_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_score_count":0,"active_rules_trustwave_block_count":0,"active_rules_trustwave_log_count":0,"created_at":"2020-06-30T10:56:27Z","disabled":false,"prefetch_condition":"","response":"WAF_Response2","service_id":"6PehUY86Aj8yGpccQ0a8oT","service_version_number":2,"updated_at":"2020-06-30T10:56:27Z"}},"meta":{"warnings":[{"title":"This + body: '{"data":{"id":"206Rvtz4NQuFifzUpnhUqL","type":"waf_firewall","attributes":{"active_rules_fastly_block_count":0,"active_rules_fastly_log_count":0,"active_rules_fastly_score_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_score_count":0,"active_rules_trustwave_block_count":0,"active_rules_trustwave_log_count":0,"created_at":"2020-07-01T09:40:39Z","disabled":false,"prefetch_condition":"WAF_Prefetch","response":"WAF_Response2","service_id":"5MlnHT66t9pZgO8XrBEDQl","service_version_number":2,"updated_at":"2020-07-01T09:40:39Z"}},"meta":{"warnings":[{"title":"This version of this service must be active","detail":"You may only update the WAF - VCL on an active version of a service. The version 2 of service 6PehUY86Aj8yGpccQ0a8oT + VCL on an active version of a service. The version 2 of service 5MlnHT66t9pZgO8XrBEDQl is not active. You may activate it through https://app.fastly.com or through the API: https://docs.fastly.com/api/config#version Be sure to review the version''s changes before activating it."}]}}' @@ -26,11 +26,11 @@ interactions: - bytes - bytes Content-Length: - - "965" + - "977" Content-Type: - application/vnd.api+json Date: - - Tue, 30 Jun 2020 10:56:28 GMT + - Wed, 01 Jul 2020 09:40:40 GMT Status: - 200 OK Strict-Transport-Security: @@ -45,9 +45,9 @@ interactions: X-Content-Type-Options: - nosniff X-Served-By: - - cache-control-slwdc9035-CONTROL-SLWDC, cache-lcy19235-LCY + - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19273-LCY X-Timer: - - S1593514588.150990,VS0,VE311 + - S1593596440.488349,VS0,VE310 status: 200 OK code: 200 duration: "" diff --git a/fastly/waf.go b/fastly/waf.go index 638de7b80..4539684b9 100644 --- a/fastly/waf.go +++ b/fastly/waf.go @@ -204,81 +204,34 @@ type UpdateWAFInput struct { // Service is the ID of the service. Version is the specific configuration // version. Both fields are required. ID string `jsonapi:"primary,waf_firewall"` - Service string `jsonapi:"attr,service_id"` - Version string `jsonapi:"attr,service_version_number"` - PrefetchCondition string `jsonapi:"attr,prefetch_condition"` - Response string `jsonapi:"attr,response"` + Service string `jsonapi:"attr,service_id,omitempty"` + Version string `jsonapi:"attr,service_version_number,omitempty"` + PrefetchCondition string `jsonapi:"attr,prefetch_condition,omitempty"` + Response string `jsonapi:"attr,response,omitempty"` + Disabled *bool `jsonapi:"attr,disabled,omitempty"` } // UpdateWAF updates a specific WAF. func (c *Client) UpdateWAF(i *UpdateWAFInput) (*WAF, error) { - if i.Service == "" { - return nil, ErrMissingService - } - - if i.Version == "" { - return nil, ErrMissingVersion - } - if i.ID == "" { return nil, ErrMissingWAFID } - path := fmt.Sprintf("/waf/firewalls/%s", i.ID) - resp, err := c.PatchJSONAPI(path, i, nil) - if err != nil { - return nil, err - } - - var waf WAF - if err := jsonapi.UnmarshalPayload(resp.Body, &waf); err != nil { - return nil, err - } - return &waf, nil -} - -// EnableWAFInput is used as input to the EnableWAF function. -type EnableWAFInput struct { - // ID is the WAF's ID. - ID string `jsonapi:"primary,waf_firewall"` - Disabled bool `jsonapi:"attr,disabled"` -} - -// EnableWAF enables a specific WAF. -func (c *Client) EnableWAF(i *EnableWAFInput) (*WAF, error) { - - if i.ID == "" { - return nil, ErrMissingWAFID - } - i.Disabled = false - - path := fmt.Sprintf("/waf/firewalls/%s", i.ID) - resp, err := c.PatchJSONAPI(path, i, nil) - if err != nil { - return nil, err - } - - var waf WAF - if err := jsonapi.UnmarshalPayload(resp.Body, &waf); err != nil { - return nil, err - } - return &waf, nil -} - -// DisableWAFInput is used as input to the DisableWAF function. -type DisableWAFInput struct { - // ID is the WAF's ID. - ID string - Disabled bool `jsonapi:"attr,disabled"` -} - -// DisableWAF disables a specific WAF. -func (c *Client) DisableWAF(i *DisableWAFInput) (*WAF, error) { + // 'Service' and 'Version' are mandatory + // if 'Disabled' is not specified. + // + // 'Service' and 'Version' are mandatory + // if 'PrefetchCondition' or 'Response' are + // not empty + if i.Disabled == nil || i.PrefetchCondition != "" || i.Response != "" { + if i.Service == "" { + return nil, ErrMissingService + } - if i.ID == "" { - return nil, ErrMissingWAFID + if i.Version == "" { + return nil, ErrMissingVersion + } } - i.Disabled = true path := fmt.Sprintf("/waf/firewalls/%s", i.ID) resp, err := c.PatchJSONAPI(path, i, nil) diff --git a/fastly/waf_test.go b/fastly/waf_test.go index 36105632c..f4291708e 100644 --- a/fastly/waf_test.go +++ b/fastly/waf_test.go @@ -114,8 +114,9 @@ func TestClient_WAFs(t *testing.T) { var dwaf *WAF record(t, fixtureBase+"/disable", func(c *Client) { - dwaf, err = c.DisableWAF(&DisableWAFInput{ - ID: waf.ID, + dwaf, err = c.UpdateWAF(&UpdateWAFInput{ + ID: waf.ID, + Disabled: Bool(true), }) }) if err != nil { @@ -127,8 +128,9 @@ func TestClient_WAFs(t *testing.T) { var ewaf *WAF record(t, fixtureBase+"/enable", func(c *Client) { - ewaf, err = c.EnableWAF(&EnableWAFInput{ - ID: waf.ID, + ewaf, err = c.UpdateWAF(&UpdateWAFInput{ + ID: waf.ID, + Disabled: Bool(false), }) }) if err != nil { @@ -196,27 +198,30 @@ func TestClient_GetWAF_validation(t *testing.T) { func TestClient_UpdateWAF_validation(t *testing.T) { var err error + _, err = testClient.UpdateWAF(&UpdateWAFInput{ - Service: "", + Service: "foo", + Version: "1", + ID: "", }) - if err != ErrMissingService { + if err != ErrMissingWAFID { t.Errorf("bad error: %s", err) } _, err = testClient.UpdateWAF(&UpdateWAFInput{ - Service: "foo", - Version: "", + ID: "123", + Service: "", }) - if err != ErrMissingVersion { + if err != ErrMissingService { t.Errorf("bad error: %s", err) } _, err = testClient.UpdateWAF(&UpdateWAFInput{ + ID: "123", Service: "foo", - Version: "1", - ID: "", + Version: "", }) - if err != ErrMissingWAFID { + if err != ErrMissingVersion { t.Errorf("bad error: %s", err) } } @@ -239,20 +244,22 @@ func TestClient_DeleteWAF_validation(t *testing.T) { } } -func TestClient_EnableWAF_validation(t *testing.T) { +func TestClient_UpdateWAF_Enable_validation(t *testing.T) { var err error - _, err = testClient.EnableWAF(&EnableWAFInput{ - ID: "", + _, err = testClient.UpdateWAF(&UpdateWAFInput{ + ID: "", + Disabled: Bool(false), }) if err != ErrMissingWAFID { t.Errorf("bad error: %s", err) } } -func TestClient_DisableWAF_validation(t *testing.T) { +func TestClient_UpdateWAF_Disable_validation(t *testing.T) { var err error - _, err = testClient.DisableWAF(&DisableWAFInput{ - ID: "", + _, err = testClient.UpdateWAF(&UpdateWAFInput{ + ID: "", + Disabled: Bool(true), }) if err != ErrMissingWAFID { t.Errorf("bad error: %s", err) From 4c90c53f2d3757b5b78cb349dd2aeafbf26545cf Mon Sep 17 00:00:00 2001 From: Stuart Wallace Date: Mon, 13 Jul 2020 13:51:22 +0100 Subject: [PATCH 13/37] Fix type assertion for linter --- fastly/waf_active_rule.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fastly/waf_active_rule.go b/fastly/waf_active_rule.go index 8a2e5ca00..21e23ca48 100644 --- a/fastly/waf_active_rule.go +++ b/fastly/waf_active_rule.go @@ -66,14 +66,14 @@ func (i *ListWAFActiveRulesInput) formatFilters() map[string]string { } for key, value := range pairings { - switch value.(type) { + switch value := value.(type) { case string: if value != "" { - result[key] = value.(string) + result[key] = value } case int: if value != 0 { - result[key] = strconv.Itoa(value.(int)) + result[key] = strconv.Itoa(value) } } } From 15f7b2210c47b114a7419770fa658557abbde77a Mon Sep 17 00:00:00 2001 From: Stuart Wallace Date: Mon, 13 Jul 2020 13:55:41 +0100 Subject: [PATCH 14/37] Fix error message capitalisation for linter --- fastly/errors.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fastly/errors.go b/fastly/errors.go index 7849a45fa..1be95f8aa 100644 --- a/fastly/errors.go +++ b/fastly/errors.go @@ -103,15 +103,15 @@ var ErrMissingEventID = errors.New("missing required field 'EventID'") // ErrMissingWAFID is an error that is returned when an input struct // requires a "WAFID" key, but one was not set. -var ErrMissingWAFID = errors.New("Missing required field 'WAFID'") +var ErrMissingWAFID = errors.New("missing required field 'WAFID'") // ErrMissingWAFVersionNumber is an error that is returned when an input struct // requires a "WAFVersionNumber" key, but one was not set. -var ErrMissingWAFVersionNumber = errors.New("Missing required field 'WAFVersionNumber'") +var ErrMissingWAFVersionNumber = errors.New("missing required field 'WAFVersionNumber'") // ErrMissingWAFVersionID is an error that is returned when an input struct // requires a "WAFVersionID" key, but one was not set. -var ErrMissingWAFVersionID = errors.New("Missing required field 'WAFVersionID'") +var ErrMissingWAFVersionID = errors.New("missing required field 'WAFVersionID'") // ErrMissingWAFActiveRuleList is an error that is returned when an input struct // requires a list of WAF active rules, but it is empty. From 29aff373551a981ab5b88330b15b6fa814f88cd9 Mon Sep 17 00:00:00 2001 From: Stuart Wallace Date: Thu, 2 Jul 2020 21:06:34 +0100 Subject: [PATCH 15/37] Update waf_versions lock API --- fastly/fixtures/waf_versions/clone.yaml | 14 +++++++------- .../waf_versions/condition/create.yaml | 18 +++++++++--------- .../waf_versions/condition/delete.yaml | 12 ++++++------ fastly/fixtures/waf_versions/create_empty.yaml | 14 +++++++------- fastly/fixtures/waf_versions/deploy.yaml | 8 ++++---- fastly/fixtures/waf_versions/get.yaml | 14 +++++++------- fastly/fixtures/waf_versions/list.yaml | 14 +++++++------- fastly/fixtures/waf_versions/list_all.yaml | 18 +++++++++--------- fastly/fixtures/waf_versions/lock.yaml | 18 +++++++++--------- .../fixtures/waf_versions/logging/create.yaml | 18 +++++++++--------- .../fixtures/waf_versions/logging/delete.yaml | 12 ++++++------ .../waf_versions/response_object/create.yaml | 18 +++++++++--------- .../waf_versions/response_object/delete.yaml | 12 ++++++------ .../fixtures/waf_versions/service/create.yaml | 12 ++++++------ .../fixtures/waf_versions/service/delete.yaml | 12 ++++++------ .../fixtures/waf_versions/service/version.yaml | 18 +++++++++--------- fastly/fixtures/waf_versions/update.yaml | 16 ++++++++-------- fastly/fixtures/waf_versions/waf/create.yaml | 10 +++++----- fastly/fixtures/waf_versions/waf/delete.yaml | 10 +++++----- fastly/waf_version.go | 6 ++++-- 20 files changed, 138 insertions(+), 136 deletions(-) diff --git a/fastly/fixtures/waf_versions/clone.yaml b/fastly/fixtures/waf_versions/clone.yaml index d154e7b17..cb1771e41 100644 --- a/fastly/fixtures/waf_versions/clone.yaml +++ b/fastly/fixtures/waf_versions/clone.yaml @@ -12,17 +12,17 @@ interactions: - application/vnd.api+json User-Agent: - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) - url: https://api.fastly.com/waf/firewalls/6gj91AAsD3ndcoKaplqiq8/versions/1/clone + url: https://api.fastly.com/waf/firewalls/3x9V8lGE6mhxxVIr15QeRo/versions/1/clone method: PUT response: - body: '{"data":{"id":"3LP12sn59pB0iz0Kh75cHb","type":"waf_firewall_version","attributes":{"active":false,"active_rules_fastly_block_count":0,"active_rules_fastly_log_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_score_count":0,"active_rules_trustwave_block_count":0,"active_rules_trustwave_log_count":0,"allowed_http_versions":"HTTP/1.0 - HTTP/1.1 HTTP/2","allowed_methods":"GET HEAD POST OPTIONS PUT PATCH DELETE","allowed_request_content_type":"application/x-www-form-urlencoded|multipart/form-data|text/xml|application/xml|application/soap+xml|application/x-amf|application/json|application/octet-stream|application/csp-report|application/xss-auditor-report|text/plain","allowed_request_content_type_charset":"utf-8|iso-8859-1|iso-8859-15|windows-1252","arg_name_length":100,"arg_length":400,"combined_file_sizes":10000000,"comment":null,"created_at":"2020-06-30T10:56:28Z","critical_anomaly_score":5,"crs_validate_utf8_encoding":false,"deployed_at":null,"error":null,"error_anomaly_score":4,"high_risk_country_codes":"","http_violation_score_threshold":999,"inbound_anomaly_score_threshold":999,"last_deployment_status":null,"lfi_score_threshold":999,"locked":false,"max_file_size":10000000,"max_num_args":255,"notice_anomaly_score":2,"number":2,"paranoia_level":1,"php_injection_score_threshold":999,"rce_score_threshold":999,"restricted_extensions":".asa/ + body: '{"data":{"id":"6Kz7TD05ACSKRCkV3KGIC9","type":"waf_firewall_version","attributes":{"active":false,"active_rules_fastly_block_count":0,"active_rules_fastly_log_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_score_count":0,"active_rules_trustwave_block_count":0,"active_rules_trustwave_log_count":0,"allowed_http_versions":"HTTP/1.0 + HTTP/1.1 HTTP/2","allowed_methods":"GET HEAD POST OPTIONS PUT PATCH DELETE","allowed_request_content_type":"application/x-www-form-urlencoded|multipart/form-data|text/xml|application/xml|application/soap+xml|application/x-amf|application/json|application/octet-stream|application/csp-report|application/xss-auditor-report|text/plain","allowed_request_content_type_charset":"utf-8|iso-8859-1|iso-8859-15|windows-1252","arg_name_length":100,"arg_length":400,"combined_file_sizes":10000000,"comment":null,"created_at":"2020-07-02T20:05:35Z","critical_anomaly_score":5,"crs_validate_utf8_encoding":false,"deployed_at":null,"error":null,"error_anomaly_score":4,"high_risk_country_codes":"","http_violation_score_threshold":999,"inbound_anomaly_score_threshold":999,"last_deployment_status":null,"lfi_score_threshold":999,"locked":false,"max_file_size":10000000,"max_num_args":255,"notice_anomaly_score":2,"number":2,"paranoia_level":1,"php_injection_score_threshold":999,"rce_score_threshold":999,"restricted_extensions":".asa/ .asax/ .ascx/ .axd/ .backup/ .bak/ .bat/ .cdx/ .cer/ .cfg/ .cmd/ .com/ .config/ .conf/ .cs/ .csproj/ .csr/ .dat/ .db/ .dbf/ .dll/ .dos/ .htr/ .htw/ .ida/ .idc/ .idq/ .inc/ .ini/ .key/ .licx/ .lnk/ .log/ .mdb/ .old/ .pass/ .pdb/ .pol/ .printer/ .pwd/ .resources/ .resx/ .sql/ .sys/ .vb/ .vbs/ .vbproj/ .vsdisco/ .webinfo/ .xsd/ .xsx/","restricted_headers":"/proxy/ /lock-token/ /content-range/ /translate/ - /if/","rfi_score_threshold":999,"session_fixation_score_threshold":999,"sql_injection_score_threshold":999,"total_arg_length":6400,"updated_at":"2020-06-30T10:56:28Z","warning_anomaly_score":3,"xss_score_threshold":999},"relationships":{"waf_firewall":{"data":{"id":"6gj91AAsD3ndcoKaplqiq8","type":"waf_firewall"}}}}}' + /if/","rfi_score_threshold":999,"session_fixation_score_threshold":999,"sql_injection_score_threshold":999,"total_arg_length":6400,"updated_at":"2020-07-02T20:05:35Z","warning_anomaly_score":3,"xss_score_threshold":999},"relationships":{"waf_firewall":{"data":{"id":"3x9V8lGE6mhxxVIr15QeRo","type":"waf_firewall"}}}}}' headers: Accept-Ranges: - bytes @@ -32,7 +32,7 @@ interactions: Content-Type: - application/vnd.api+json Date: - - Tue, 30 Jun 2020 10:56:28 GMT + - Thu, 02 Jul 2020 20:05:36 GMT Status: - 200 OK Strict-Transport-Security: @@ -47,9 +47,9 @@ interactions: X-Content-Type-Options: - nosniff X-Served-By: - - cache-control-slwdc9035-CONTROL-SLWDC, cache-lcy19235-LCY + - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19251-LCY X-Timer: - - S1593514588.456050,VS0,VE159 + - S1593720336.867840,VS0,VE200 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/waf_versions/condition/create.yaml b/fastly/fixtures/waf_versions/condition/create.yaml index 016e2446b..247447cff 100644 --- a/fastly/fixtures/waf_versions/condition/create.yaml +++ b/fastly/fixtures/waf_versions/condition/create.yaml @@ -2,10 +2,10 @@ version: 1 interactions: - request: - body: Service=3BOOVoayIlrdMuRU8LrKSA&Version=2&name=WAF_Prefetch&priority=1&statement=req.url~%2B%22index.html%22&type=PREFETCH + body: Service=5mAR0wHKpNJjOqc65YeDqI&Version=2&name=WAF_Prefetch&priority=1&statement=req.url~%2B%22index.html%22&type=PREFETCH form: Service: - - 3BOOVoayIlrdMuRU8LrKSA + - 5mAR0wHKpNJjOqc65YeDqI Version: - "2" name: @@ -21,10 +21,10 @@ interactions: - application/x-www-form-urlencoded User-Agent: - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) - url: https://api.fastly.com/service/3BOOVoayIlrdMuRU8LrKSA/version/2/condition + url: https://api.fastly.com/service/5mAR0wHKpNJjOqc65YeDqI/version/2/condition method: POST response: - body: '{"name":"WAF_Prefetch","priority":"1","statement":"req.url~+\"index.html\"","type":"PREFETCH","service_id":"3BOOVoayIlrdMuRU8LrKSA","version":"2","updated_at":"2020-06-30T10:56:26Z","comment":"","created_at":"2020-06-30T10:56:26Z","deleted_at":null}' + body: '{"name":"WAF_Prefetch","priority":"1","statement":"req.url~+\"index.html\"","type":"PREFETCH","service_id":"5mAR0wHKpNJjOqc65YeDqI","version":"2","updated_at":"2020-07-02T20:05:33Z","comment":"","created_at":"2020-07-02T20:05:33Z","deleted_at":null}' headers: Accept-Ranges: - bytes @@ -34,11 +34,11 @@ interactions: Content-Type: - application/json Date: - - Tue, 30 Jun 2020 10:56:26 GMT + - Thu, 02 Jul 2020 20:05:33 GMT Fastly-Ratelimit-Remaining: - - "680" + - "978" Fastly-Ratelimit-Reset: - - "1593514800" + - "1593723600" Status: - 200 OK Strict-Transport-Security: @@ -53,9 +53,9 @@ interactions: X-Cache-Hits: - 0, 0 X-Served-By: - - cache-control-slwdc9035-CONTROL-SLWDC, cache-lcy19235-LCY + - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19251-LCY X-Timer: - - S1593514586.994859,VS0,VE446 + - S1593720333.268758,VS0,VE199 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/waf_versions/condition/delete.yaml b/fastly/fixtures/waf_versions/condition/delete.yaml index a40502cf2..966a90d1c 100644 --- a/fastly/fixtures/waf_versions/condition/delete.yaml +++ b/fastly/fixtures/waf_versions/condition/delete.yaml @@ -7,7 +7,7 @@ interactions: headers: User-Agent: - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) - url: https://api.fastly.com/service/3BOOVoayIlrdMuRU8LrKSA/version/2/condition/WAF_Prefetch + url: https://api.fastly.com/service/5mAR0wHKpNJjOqc65YeDqI/version/2/condition/WAF_Prefetch method: DELETE response: body: '{"status":"ok"}' @@ -20,11 +20,11 @@ interactions: Content-Type: - application/json Date: - - Tue, 30 Jun 2020 10:56:31 GMT + - Thu, 02 Jul 2020 20:05:39 GMT Fastly-Ratelimit-Remaining: - - "674" + - "975" Fastly-Ratelimit-Reset: - - "1593514800" + - "1593723600" Status: - 200 OK Strict-Transport-Security: @@ -39,9 +39,9 @@ interactions: X-Cache-Hits: - 0, 0 X-Served-By: - - cache-control-slwdc9035-CONTROL-SLWDC, cache-lcy19235-LCY + - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19251-LCY X-Timer: - - S1593514591.237210,VS0,VE232 + - S1593720339.176681,VS0,VE200 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/waf_versions/create_empty.yaml b/fastly/fixtures/waf_versions/create_empty.yaml index 79e98f315..6f70f58c4 100644 --- a/fastly/fixtures/waf_versions/create_empty.yaml +++ b/fastly/fixtures/waf_versions/create_empty.yaml @@ -11,17 +11,17 @@ interactions: - application/vnd.api+json User-Agent: - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) - url: https://api.fastly.com/waf/firewalls/6gj91AAsD3ndcoKaplqiq8/versions + url: https://api.fastly.com/waf/firewalls/3x9V8lGE6mhxxVIr15QeRo/versions method: POST response: - body: '{"data":{"id":"7DhddGiMYD6YoPOrpMZfHc","type":"waf_firewall_version","attributes":{"active":false,"active_rules_fastly_block_count":0,"active_rules_fastly_log_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_score_count":0,"active_rules_trustwave_block_count":0,"active_rules_trustwave_log_count":0,"allowed_http_versions":"HTTP/1.0 - HTTP/1.1 HTTP/2","allowed_methods":"GET HEAD POST OPTIONS PUT PATCH DELETE","allowed_request_content_type":"application/x-www-form-urlencoded|multipart/form-data|text/xml|application/xml|application/soap+xml|application/x-amf|application/json|application/octet-stream|application/csp-report|application/xss-auditor-report|text/plain","allowed_request_content_type_charset":"utf-8|iso-8859-1|iso-8859-15|windows-1252","arg_name_length":100,"arg_length":400,"combined_file_sizes":10000000,"comment":null,"created_at":"2020-06-30T10:56:30Z","critical_anomaly_score":5,"crs_validate_utf8_encoding":false,"deployed_at":null,"error":null,"error_anomaly_score":4,"high_risk_country_codes":"","http_violation_score_threshold":999,"inbound_anomaly_score_threshold":999,"last_deployment_status":null,"lfi_score_threshold":999,"locked":false,"max_file_size":10000000,"max_num_args":255,"notice_anomaly_score":2,"number":3,"paranoia_level":1,"php_injection_score_threshold":999,"rce_score_threshold":999,"restricted_extensions":".asa/ + body: '{"data":{"id":"3q8hwfM0DdhLZRIFKZFPI4","type":"waf_firewall_version","attributes":{"active":false,"active_rules_fastly_block_count":0,"active_rules_fastly_log_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_score_count":0,"active_rules_trustwave_block_count":0,"active_rules_trustwave_log_count":0,"allowed_http_versions":"HTTP/1.0 + HTTP/1.1 HTTP/2","allowed_methods":"GET HEAD POST OPTIONS PUT PATCH DELETE","allowed_request_content_type":"application/x-www-form-urlencoded|multipart/form-data|text/xml|application/xml|application/soap+xml|application/x-amf|application/json|application/octet-stream|application/csp-report|application/xss-auditor-report|text/plain","allowed_request_content_type_charset":"utf-8|iso-8859-1|iso-8859-15|windows-1252","arg_name_length":100,"arg_length":400,"combined_file_sizes":10000000,"comment":null,"created_at":"2020-07-02T20:05:38Z","critical_anomaly_score":5,"crs_validate_utf8_encoding":false,"deployed_at":null,"error":null,"error_anomaly_score":4,"high_risk_country_codes":"","http_violation_score_threshold":999,"inbound_anomaly_score_threshold":999,"last_deployment_status":null,"lfi_score_threshold":999,"locked":false,"max_file_size":10000000,"max_num_args":255,"notice_anomaly_score":2,"number":3,"paranoia_level":1,"php_injection_score_threshold":999,"rce_score_threshold":999,"restricted_extensions":".asa/ .asax/ .ascx/ .axd/ .backup/ .bak/ .bat/ .cdx/ .cer/ .cfg/ .cmd/ .com/ .config/ .conf/ .cs/ .csproj/ .csr/ .dat/ .db/ .dbf/ .dll/ .dos/ .htr/ .htw/ .ida/ .idc/ .idq/ .inc/ .ini/ .key/ .licx/ .lnk/ .log/ .mdb/ .old/ .pass/ .pdb/ .pol/ .printer/ .pwd/ .resources/ .resx/ .sql/ .sys/ .vb/ .vbs/ .vbproj/ .vsdisco/ .webinfo/ .xsd/ .xsx/","restricted_headers":"/proxy/ /lock-token/ /content-range/ /translate/ - /if/","rfi_score_threshold":999,"session_fixation_score_threshold":999,"sql_injection_score_threshold":999,"total_arg_length":6400,"updated_at":"2020-06-30T10:56:30Z","warning_anomaly_score":3,"xss_score_threshold":999},"relationships":{"waf_firewall":{"data":{"id":"6gj91AAsD3ndcoKaplqiq8","type":"waf_firewall"}}}}}' + /if/","rfi_score_threshold":999,"session_fixation_score_threshold":999,"sql_injection_score_threshold":999,"total_arg_length":6400,"updated_at":"2020-07-02T20:05:38Z","warning_anomaly_score":3,"xss_score_threshold":999},"relationships":{"waf_firewall":{"data":{"id":"3x9V8lGE6mhxxVIr15QeRo","type":"waf_firewall"}}}}}' headers: Accept-Ranges: - bytes @@ -31,7 +31,7 @@ interactions: Content-Type: - application/vnd.api+json Date: - - Tue, 30 Jun 2020 10:56:30 GMT + - Thu, 02 Jul 2020 20:05:38 GMT Status: - 201 Created Strict-Transport-Security: @@ -46,9 +46,9 @@ interactions: X-Content-Type-Options: - nosniff X-Served-By: - - cache-control-slwdc9036-CONTROL-SLWDC, cache-lcy19235-LCY + - cache-control-slwdc9035-CONTROL-SLWDC, cache-lcy19251-LCY X-Timer: - - S1593514590.943096,VS0,VE156 + - S1593720338.937872,VS0,VE175 status: 201 Created code: 201 duration: "" diff --git a/fastly/fixtures/waf_versions/deploy.yaml b/fastly/fixtures/waf_versions/deploy.yaml index d28610b9a..388362086 100644 --- a/fastly/fixtures/waf_versions/deploy.yaml +++ b/fastly/fixtures/waf_versions/deploy.yaml @@ -12,7 +12,7 @@ interactions: - application/vnd.api+json User-Agent: - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) - url: https://api.fastly.com/waf/firewalls/6gj91AAsD3ndcoKaplqiq8/versions/1 + url: https://api.fastly.com/waf/firewalls/3x9V8lGE6mhxxVIr15QeRo/versions/1 method: POST response: body: '{}' @@ -25,7 +25,7 @@ interactions: Content-Type: - application/vnd.api+json Date: - - Tue, 30 Jun 2020 10:56:28 GMT + - Thu, 02 Jul 2020 20:05:35 GMT Status: - 202 Accepted Strict-Transport-Security: @@ -40,9 +40,9 @@ interactions: X-Content-Type-Options: - nosniff X-Served-By: - - cache-control-slwdc9035-CONTROL-SLWDC, cache-lcy19235-LCY + - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19251-LCY X-Timer: - - S1593514588.222313,VS0,VE148 + - S1593720336.584735,VS0,VE141 status: 202 Accepted code: 202 duration: "" diff --git a/fastly/fixtures/waf_versions/get.yaml b/fastly/fixtures/waf_versions/get.yaml index ce020382d..d117643d4 100644 --- a/fastly/fixtures/waf_versions/get.yaml +++ b/fastly/fixtures/waf_versions/get.yaml @@ -7,17 +7,17 @@ interactions: headers: User-Agent: - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) - url: https://api.fastly.com/waf/firewalls/6gj91AAsD3ndcoKaplqiq8/versions/2 + url: https://api.fastly.com/waf/firewalls/3x9V8lGE6mhxxVIr15QeRo/versions/2 method: GET response: - body: '{"data":{"id":"3LP12sn59pB0iz0Kh75cHb","type":"waf_firewall_version","attributes":{"active":false,"active_rules_fastly_block_count":0,"active_rules_fastly_log_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_score_count":0,"active_rules_trustwave_block_count":0,"active_rules_trustwave_log_count":0,"allowed_http_versions":"HTTP/1.0 - HTTP/1.1 HTTP/2","allowed_methods":"GET HEAD POST OPTIONS PUT PATCH DELETE","allowed_request_content_type":"application/x-www-form-urlencoded|multipart/form-data|text/xml|application/xml|application/soap+xml|application/x-amf|application/json|application/octet-stream|application/csp-report|application/xss-auditor-report|text/plain","allowed_request_content_type_charset":"utf-8|iso-8859-1|iso-8859-15|windows-1252","arg_name_length":100,"arg_length":400,"combined_file_sizes":10000000,"comment":null,"created_at":"2020-06-30T10:56:28Z","critical_anomaly_score":5,"crs_validate_utf8_encoding":false,"deployed_at":null,"error":null,"error_anomaly_score":4,"high_risk_country_codes":"","http_violation_score_threshold":999,"inbound_anomaly_score_threshold":999,"last_deployment_status":null,"lfi_score_threshold":999,"locked":false,"max_file_size":10000000,"max_num_args":255,"notice_anomaly_score":2,"number":2,"paranoia_level":1,"php_injection_score_threshold":999,"rce_score_threshold":999,"restricted_extensions":".asa/ + body: '{"data":{"id":"6Kz7TD05ACSKRCkV3KGIC9","type":"waf_firewall_version","attributes":{"active":false,"active_rules_fastly_block_count":0,"active_rules_fastly_log_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_score_count":0,"active_rules_trustwave_block_count":0,"active_rules_trustwave_log_count":0,"allowed_http_versions":"HTTP/1.0 + HTTP/1.1 HTTP/2","allowed_methods":"GET HEAD POST OPTIONS PUT PATCH DELETE","allowed_request_content_type":"application/x-www-form-urlencoded|multipart/form-data|text/xml|application/xml|application/soap+xml|application/x-amf|application/json|application/octet-stream|application/csp-report|application/xss-auditor-report|text/plain","allowed_request_content_type_charset":"utf-8|iso-8859-1|iso-8859-15|windows-1252","arg_name_length":100,"arg_length":400,"combined_file_sizes":10000000,"comment":null,"created_at":"2020-07-02T20:05:35Z","critical_anomaly_score":5,"crs_validate_utf8_encoding":false,"deployed_at":null,"error":null,"error_anomaly_score":4,"high_risk_country_codes":"","http_violation_score_threshold":999,"inbound_anomaly_score_threshold":999,"last_deployment_status":null,"lfi_score_threshold":999,"locked":false,"max_file_size":10000000,"max_num_args":255,"notice_anomaly_score":2,"number":2,"paranoia_level":1,"php_injection_score_threshold":999,"rce_score_threshold":999,"restricted_extensions":".asa/ .asax/ .ascx/ .axd/ .backup/ .bak/ .bat/ .cdx/ .cer/ .cfg/ .cmd/ .com/ .config/ .conf/ .cs/ .csproj/ .csr/ .dat/ .db/ .dbf/ .dll/ .dos/ .htr/ .htw/ .ida/ .idc/ .idq/ .inc/ .ini/ .key/ .licx/ .lnk/ .log/ .mdb/ .old/ .pass/ .pdb/ .pol/ .printer/ .pwd/ .resources/ .resx/ .sql/ .sys/ .vb/ .vbs/ .vbproj/ .vsdisco/ .webinfo/ .xsd/ .xsx/","restricted_headers":"/proxy/ /lock-token/ /content-range/ /translate/ - /if/","rfi_score_threshold":999,"session_fixation_score_threshold":999,"sql_injection_score_threshold":999,"total_arg_length":6400,"updated_at":"2020-06-30T10:56:28Z","warning_anomaly_score":3,"xss_score_threshold":999}}}' + /if/","rfi_score_threshold":999,"session_fixation_score_threshold":999,"sql_injection_score_threshold":999,"total_arg_length":6400,"updated_at":"2020-07-02T20:05:35Z","warning_anomaly_score":3,"xss_score_threshold":999}}}' headers: Accept-Ranges: - bytes @@ -31,7 +31,7 @@ interactions: Content-Type: - application/vnd.api+json Date: - - Tue, 30 Jun 2020 10:56:28 GMT + - Thu, 02 Jul 2020 20:05:36 GMT Status: - 200 OK Strict-Transport-Security: @@ -46,9 +46,9 @@ interactions: X-Content-Type-Options: - nosniff X-Served-By: - - cache-control-slwdc9036-CONTROL-SLWDC, cache-lcy19235-LCY + - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19251-LCY X-Timer: - - S1593514589.802406,VS0,VE149 + - S1593720336.270762,VS0,VE376 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/waf_versions/list.yaml b/fastly/fixtures/waf_versions/list.yaml index 915001c87..459410b8c 100644 --- a/fastly/fixtures/waf_versions/list.yaml +++ b/fastly/fixtures/waf_versions/list.yaml @@ -7,17 +7,17 @@ interactions: headers: User-Agent: - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) - url: https://api.fastly.com/waf/firewalls/6gj91AAsD3ndcoKaplqiq8/versions + url: https://api.fastly.com/waf/firewalls/3x9V8lGE6mhxxVIr15QeRo/versions method: GET response: - body: '{"data":[{"id":"5QIeb4KiWL4GRSXcbrJwlU","type":"waf_firewall_version","attributes":{"active":false,"active_rules_fastly_block_count":0,"active_rules_fastly_log_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_score_count":0,"active_rules_trustwave_block_count":0,"active_rules_trustwave_log_count":0,"allowed_http_versions":"HTTP/1.0 - HTTP/1.1 HTTP/2","allowed_methods":"GET HEAD POST OPTIONS PUT PATCH DELETE","allowed_request_content_type":"application/x-www-form-urlencoded|multipart/form-data|text/xml|application/xml|application/soap+xml|application/x-amf|application/json|application/octet-stream|application/csp-report|application/xss-auditor-report|text/plain","allowed_request_content_type_charset":"utf-8|iso-8859-1|iso-8859-15|windows-1252","arg_name_length":100,"arg_length":400,"combined_file_sizes":10000000,"comment":null,"created_at":"2020-06-30T10:56:27Z","critical_anomaly_score":5,"crs_validate_utf8_encoding":false,"deployed_at":null,"error":null,"error_anomaly_score":4,"high_risk_country_codes":"","http_violation_score_threshold":999,"inbound_anomaly_score_threshold":999,"last_deployment_status":null,"lfi_score_threshold":999,"locked":false,"max_file_size":10000000,"max_num_args":255,"notice_anomaly_score":2,"number":1,"paranoia_level":1,"php_injection_score_threshold":999,"rce_score_threshold":999,"restricted_extensions":".asa/ + body: '{"data":[{"id":"7WfLA42gWjnACmwwTJYylj","type":"waf_firewall_version","attributes":{"active":false,"active_rules_fastly_block_count":0,"active_rules_fastly_log_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_score_count":0,"active_rules_trustwave_block_count":0,"active_rules_trustwave_log_count":0,"allowed_http_versions":"HTTP/1.0 + HTTP/1.1 HTTP/2","allowed_methods":"GET HEAD POST OPTIONS PUT PATCH DELETE","allowed_request_content_type":"application/x-www-form-urlencoded|multipart/form-data|text/xml|application/xml|application/soap+xml|application/x-amf|application/json|application/octet-stream|application/csp-report|application/xss-auditor-report|text/plain","allowed_request_content_type_charset":"utf-8|iso-8859-1|iso-8859-15|windows-1252","arg_name_length":100,"arg_length":400,"combined_file_sizes":10000000,"comment":null,"created_at":"2020-07-02T20:05:34Z","critical_anomaly_score":5,"crs_validate_utf8_encoding":false,"deployed_at":null,"error":null,"error_anomaly_score":4,"high_risk_country_codes":"","http_violation_score_threshold":999,"inbound_anomaly_score_threshold":999,"last_deployment_status":null,"lfi_score_threshold":999,"locked":false,"max_file_size":10000000,"max_num_args":255,"notice_anomaly_score":2,"number":1,"paranoia_level":1,"php_injection_score_threshold":999,"rce_score_threshold":999,"restricted_extensions":".asa/ .asax/ .ascx/ .axd/ .backup/ .bak/ .bat/ .cdx/ .cer/ .cfg/ .cmd/ .com/ .config/ .conf/ .cs/ .csproj/ .csr/ .dat/ .db/ .dbf/ .dll/ .dos/ .htr/ .htw/ .ida/ .idc/ .idq/ .inc/ .ini/ .key/ .licx/ .lnk/ .log/ .mdb/ .old/ .pass/ .pdb/ .pol/ .printer/ .pwd/ .resources/ .resx/ .sql/ .sys/ .vb/ .vbs/ .vbproj/ .vsdisco/ .webinfo/ .xsd/ .xsx/","restricted_headers":"/proxy/ /lock-token/ /content-range/ /translate/ - /if/","rfi_score_threshold":999,"session_fixation_score_threshold":999,"sql_injection_score_threshold":999,"total_arg_length":6400,"updated_at":"2020-06-30T10:56:27Z","warning_anomaly_score":3,"xss_score_threshold":999}}],"links":{"last":"https://api.fastly.com/waf/firewalls/6gj91AAsD3ndcoKaplqiq8/versions?page[number]=1\u0026page[size]=100","first":"https://api.fastly.com/waf/firewalls/6gj91AAsD3ndcoKaplqiq8/versions?page[number]=1\u0026page[size]=100"},"meta":{"current_page":1,"per_page":100,"record_count":1,"total_pages":1}}' + /if/","rfi_score_threshold":999,"session_fixation_score_threshold":999,"sql_injection_score_threshold":999,"total_arg_length":6400,"updated_at":"2020-07-02T20:05:34Z","warning_anomaly_score":3,"xss_score_threshold":999}}],"links":{"last":"https://api.fastly.com/waf/firewalls/3x9V8lGE6mhxxVIr15QeRo/versions?page[number]=1\u0026page[size]=100","first":"https://api.fastly.com/waf/firewalls/3x9V8lGE6mhxxVIr15QeRo/versions?page[number]=1\u0026page[size]=100"},"meta":{"current_page":1,"per_page":100,"record_count":1,"total_pages":1}}' headers: Accept-Ranges: - bytes @@ -31,7 +31,7 @@ interactions: Content-Type: - application/vnd.api+json Date: - - Tue, 30 Jun 2020 10:56:28 GMT + - Thu, 02 Jul 2020 20:05:35 GMT Status: - 200 OK Strict-Transport-Security: @@ -46,9 +46,9 @@ interactions: X-Content-Type-Options: - nosniff X-Served-By: - - cache-control-slwdc9036-CONTROL-SLWDC, cache-lcy19235-LCY + - cache-control-slwdc9036-CONTROL-SLWDC, cache-lcy19251-LCY X-Timer: - - S1593514588.005669,VS0,VE155 + - S1593720335.083414,VS0,VE401 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/waf_versions/list_all.yaml b/fastly/fixtures/waf_versions/list_all.yaml index bff3ca98c..1141c2ee2 100644 --- a/fastly/fixtures/waf_versions/list_all.yaml +++ b/fastly/fixtures/waf_versions/list_all.yaml @@ -7,21 +7,21 @@ interactions: headers: User-Agent: - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) - url: https://api.fastly.com/waf/firewalls/6gj91AAsD3ndcoKaplqiq8/versions?page%5Bnumber%5D=1&page%5Bsize%5D=100 + url: https://api.fastly.com/waf/firewalls/3x9V8lGE6mhxxVIr15QeRo/versions?page%5Bnumber%5D=1&page%5Bsize%5D=100 method: GET response: - body: '{"data":[{"id":"3LP12sn59pB0iz0Kh75cHb","type":"waf_firewall_version","attributes":{"active":false,"active_rules_fastly_block_count":0,"active_rules_fastly_log_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_score_count":0,"active_rules_trustwave_block_count":0,"active_rules_trustwave_log_count":0,"allowed_http_versions":"HTTP/1.0 + body: '{"data":[{"id":"6Kz7TD05ACSKRCkV3KGIC9","type":"waf_firewall_version","attributes":{"active":false,"active_rules_fastly_block_count":0,"active_rules_fastly_log_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_score_count":0,"active_rules_trustwave_block_count":0,"active_rules_trustwave_log_count":0,"allowed_http_versions":"HTTP/1.0 HTTP/1.1","allowed_methods":"GET HEAD POST","allowed_request_content_type":"application/x-www-form-urlencoded|multipart/form-data|text/xml|application/xml","allowed_request_content_type_charset":"utf-8|iso-8859-1","arg_name_length":200,"arg_length":800,"combined_file_sizes":20000000,"comment":"my - comment","created_at":"2020-06-30T10:56:28Z","critical_anomaly_score":12,"crs_validate_utf8_encoding":true,"deployed_at":null,"error":null,"error_anomaly_score":10,"high_risk_country_codes":"gb","http_violation_score_threshold":20,"inbound_anomaly_score_threshold":20,"last_deployment_status":null,"lfi_score_threshold":20,"locked":true,"max_file_size":20000000,"max_num_args":510,"notice_anomaly_score":8,"number":2,"paranoia_level":2,"php_injection_score_threshold":20,"rce_score_threshold":20,"restricted_extensions":".asa/ + comment","created_at":"2020-07-02T20:05:35Z","critical_anomaly_score":12,"crs_validate_utf8_encoding":true,"deployed_at":null,"error":null,"error_anomaly_score":10,"high_risk_country_codes":"gb","http_violation_score_threshold":20,"inbound_anomaly_score_threshold":20,"last_deployment_status":null,"lfi_score_threshold":20,"locked":true,"max_file_size":20000000,"max_num_args":510,"notice_anomaly_score":8,"number":2,"paranoia_level":2,"php_injection_score_threshold":20,"rce_score_threshold":20,"restricted_extensions":".asa/ .asax/ .ascx/ .axd/ .backup/ .bak/ .bat/ .cdx/ .cer/ .cfg/ .cmd/ .com/","restricted_headers":"/proxy/ - /lock-token/","rfi_score_threshold":20,"session_fixation_score_threshold":20,"sql_injection_score_threshold":20,"total_arg_length":12800,"updated_at":"2020-06-30T10:56:29Z","warning_anomaly_score":20,"xss_score_threshold":20}},{"id":"5QIeb4KiWL4GRSXcbrJwlU","type":"waf_firewall_version","attributes":{"active":true,"active_rules_fastly_block_count":0,"active_rules_fastly_log_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_score_count":0,"active_rules_trustwave_block_count":0,"active_rules_trustwave_log_count":0,"allowed_http_versions":"HTTP/1.0 - HTTP/1.1 HTTP/2","allowed_methods":"GET HEAD POST OPTIONS PUT PATCH DELETE","allowed_request_content_type":"application/x-www-form-urlencoded|multipart/form-data|text/xml|application/xml|application/soap+xml|application/x-amf|application/json|application/octet-stream|application/csp-report|application/xss-auditor-report|text/plain","allowed_request_content_type_charset":"utf-8|iso-8859-1|iso-8859-15|windows-1252","arg_name_length":100,"arg_length":400,"combined_file_sizes":10000000,"comment":null,"created_at":"2020-06-30T10:56:27Z","critical_anomaly_score":5,"crs_validate_utf8_encoding":false,"deployed_at":"2020-06-30T10:56:28Z","error":null,"error_anomaly_score":4,"high_risk_country_codes":"","http_violation_score_threshold":999,"inbound_anomaly_score_threshold":999,"last_deployment_status":"completed","lfi_score_threshold":999,"locked":true,"max_file_size":10000000,"max_num_args":255,"notice_anomaly_score":2,"number":1,"paranoia_level":1,"php_injection_score_threshold":999,"rce_score_threshold":999,"restricted_extensions":".asa/ + /lock-token/","rfi_score_threshold":20,"session_fixation_score_threshold":20,"sql_injection_score_threshold":20,"total_arg_length":12800,"updated_at":"2020-07-02T20:05:37Z","warning_anomaly_score":20,"xss_score_threshold":20}},{"id":"7WfLA42gWjnACmwwTJYylj","type":"waf_firewall_version","attributes":{"active":true,"active_rules_fastly_block_count":0,"active_rules_fastly_log_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_score_count":0,"active_rules_trustwave_block_count":0,"active_rules_trustwave_log_count":0,"allowed_http_versions":"HTTP/1.0 + HTTP/1.1 HTTP/2","allowed_methods":"GET HEAD POST OPTIONS PUT PATCH DELETE","allowed_request_content_type":"application/x-www-form-urlencoded|multipart/form-data|text/xml|application/xml|application/soap+xml|application/x-amf|application/json|application/octet-stream|application/csp-report|application/xss-auditor-report|text/plain","allowed_request_content_type_charset":"utf-8|iso-8859-1|iso-8859-15|windows-1252","arg_name_length":100,"arg_length":400,"combined_file_sizes":10000000,"comment":null,"created_at":"2020-07-02T20:05:34Z","critical_anomaly_score":5,"crs_validate_utf8_encoding":false,"deployed_at":"2020-07-02T20:05:36Z","error":null,"error_anomaly_score":4,"high_risk_country_codes":"","http_violation_score_threshold":999,"inbound_anomaly_score_threshold":999,"last_deployment_status":"completed","lfi_score_threshold":999,"locked":true,"max_file_size":10000000,"max_num_args":255,"notice_anomaly_score":2,"number":1,"paranoia_level":1,"php_injection_score_threshold":999,"rce_score_threshold":999,"restricted_extensions":".asa/ .asax/ .ascx/ .axd/ .backup/ .bak/ .bat/ .cdx/ .cer/ .cfg/ .cmd/ .com/ .config/ .conf/ .cs/ .csproj/ .csr/ .dat/ .db/ .dbf/ .dll/ .dos/ .htr/ .htw/ .ida/ .idc/ .idq/ .inc/ .ini/ .key/ .licx/ .lnk/ .log/ .mdb/ .old/ .pass/ .pdb/ .pol/ .printer/ .pwd/ .resources/ .resx/ .sql/ .sys/ .vb/ .vbs/ .vbproj/ .vsdisco/ .webinfo/ .xsd/ .xsx/","restricted_headers":"/proxy/ /lock-token/ /content-range/ /translate/ - /if/","rfi_score_threshold":999,"session_fixation_score_threshold":999,"sql_injection_score_threshold":999,"total_arg_length":6400,"updated_at":"2020-06-30T10:56:28Z","warning_anomaly_score":3,"xss_score_threshold":999}}],"links":{"last":"https://api.fastly.com/waf/firewalls/6gj91AAsD3ndcoKaplqiq8/versions?page[number]=1\u0026page[size]=100","first":"https://api.fastly.com/waf/firewalls/6gj91AAsD3ndcoKaplqiq8/versions?page[number]=1\u0026page[size]=100"},"meta":{"current_page":1,"per_page":100,"record_count":2,"total_pages":1}}' + /if/","rfi_score_threshold":999,"session_fixation_score_threshold":999,"sql_injection_score_threshold":999,"total_arg_length":6400,"updated_at":"2020-07-02T20:05:36Z","warning_anomaly_score":3,"xss_score_threshold":999}}],"links":{"last":"https://api.fastly.com/waf/firewalls/3x9V8lGE6mhxxVIr15QeRo/versions?page[number]=1\u0026page[size]=100","first":"https://api.fastly.com/waf/firewalls/3x9V8lGE6mhxxVIr15QeRo/versions?page[number]=1\u0026page[size]=100"},"meta":{"current_page":1,"per_page":100,"record_count":2,"total_pages":1}}' headers: Accept-Ranges: - bytes @@ -35,7 +35,7 @@ interactions: Content-Type: - application/vnd.api+json Date: - - Tue, 30 Jun 2020 10:56:29 GMT + - Thu, 02 Jul 2020 20:05:37 GMT Status: - 200 OK Strict-Transport-Security: @@ -50,9 +50,9 @@ interactions: X-Content-Type-Options: - nosniff X-Served-By: - - cache-control-slwdc9036-CONTROL-SLWDC, cache-lcy19235-LCY + - cache-control-slwdc9035-CONTROL-SLWDC, cache-lcy19251-LCY X-Timer: - - S1593514590.633771,VS0,VE172 + - S1593720337.368966,VS0,VE388 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/waf_versions/lock.yaml b/fastly/fixtures/waf_versions/lock.yaml index 47e3aaddb..3cdfb600a 100644 --- a/fastly/fixtures/waf_versions/lock.yaml +++ b/fastly/fixtures/waf_versions/lock.yaml @@ -3,7 +3,7 @@ version: 1 interactions: - request: body: | - {"data":{"type":""}} + {"data":{"type":"","attributes":{"locked":true}}} form: {} headers: Accept: @@ -12,14 +12,14 @@ interactions: - application/vnd.api+json User-Agent: - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) - url: https://api.fastly.com/waf/firewalls/6gj91AAsD3ndcoKaplqiq8/versions/2/lock - method: PUT + url: https://api.fastly.com/waf/firewalls/3x9V8lGE6mhxxVIr15QeRo/versions/2 + method: PATCH response: - body: '{"data":{"id":"3LP12sn59pB0iz0Kh75cHb","type":"waf_firewall_version","attributes":{"active":false,"active_rules_fastly_block_count":0,"active_rules_fastly_log_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_score_count":0,"active_rules_trustwave_block_count":0,"active_rules_trustwave_log_count":0,"allowed_http_versions":"HTTP/1.0 + body: '{"data":{"id":"6Kz7TD05ACSKRCkV3KGIC9","type":"waf_firewall_version","attributes":{"active":false,"active_rules_fastly_block_count":0,"active_rules_fastly_log_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_score_count":0,"active_rules_trustwave_block_count":0,"active_rules_trustwave_log_count":0,"allowed_http_versions":"HTTP/1.0 HTTP/1.1","allowed_methods":"GET HEAD POST","allowed_request_content_type":"application/x-www-form-urlencoded|multipart/form-data|text/xml|application/xml","allowed_request_content_type_charset":"utf-8|iso-8859-1","arg_name_length":200,"arg_length":800,"combined_file_sizes":20000000,"comment":"my - comment","created_at":"2020-06-30T10:56:28Z","critical_anomaly_score":12,"crs_validate_utf8_encoding":true,"deployed_at":null,"error":null,"error_anomaly_score":10,"high_risk_country_codes":"gb","http_violation_score_threshold":20,"inbound_anomaly_score_threshold":20,"last_deployment_status":null,"lfi_score_threshold":20,"locked":true,"max_file_size":20000000,"max_num_args":510,"notice_anomaly_score":8,"number":2,"paranoia_level":2,"php_injection_score_threshold":20,"rce_score_threshold":20,"restricted_extensions":".asa/ + comment","created_at":"2020-07-02T20:05:35Z","critical_anomaly_score":12,"crs_validate_utf8_encoding":true,"deployed_at":null,"error":null,"error_anomaly_score":10,"high_risk_country_codes":"gb","http_violation_score_threshold":20,"inbound_anomaly_score_threshold":20,"last_deployment_status":null,"lfi_score_threshold":20,"locked":true,"max_file_size":20000000,"max_num_args":510,"notice_anomaly_score":8,"number":2,"paranoia_level":2,"php_injection_score_threshold":20,"rce_score_threshold":20,"restricted_extensions":".asa/ .asax/ .ascx/ .axd/ .backup/ .bak/ .bat/ .cdx/ .cer/ .cfg/ .cmd/ .com/","restricted_headers":"/proxy/ - /lock-token/","rfi_score_threshold":20,"session_fixation_score_threshold":20,"sql_injection_score_threshold":20,"total_arg_length":12800,"updated_at":"2020-06-30T10:56:29Z","warning_anomaly_score":20,"xss_score_threshold":20},"relationships":{"waf_firewall":{"data":{"id":"6gj91AAsD3ndcoKaplqiq8","type":"waf_firewall"}}}}}' + /lock-token/","rfi_score_threshold":20,"session_fixation_score_threshold":20,"sql_injection_score_threshold":20,"total_arg_length":12800,"updated_at":"2020-07-02T20:05:37Z","warning_anomaly_score":20,"xss_score_threshold":20},"relationships":{"waf_firewall":{"data":{"id":"3x9V8lGE6mhxxVIr15QeRo","type":"waf_firewall"}}}}}' headers: Accept-Ranges: - bytes @@ -29,7 +29,7 @@ interactions: Content-Type: - application/vnd.api+json Date: - - Tue, 30 Jun 2020 10:56:29 GMT + - Thu, 02 Jul 2020 20:05:37 GMT Status: - 200 OK Strict-Transport-Security: @@ -44,9 +44,9 @@ interactions: X-Content-Type-Options: - nosniff X-Served-By: - - cache-control-slwdc9036-CONTROL-SLWDC, cache-lcy19235-LCY + - cache-control-slwdc9036-CONTROL-SLWDC, cache-lcy19251-LCY X-Timer: - - S1593514589.295264,VS0,VE174 + - S1593720337.989253,VS0,VE181 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/waf_versions/logging/create.yaml b/fastly/fixtures/waf_versions/logging/create.yaml index 986432fda..298698e03 100644 --- a/fastly/fixtures/waf_versions/logging/create.yaml +++ b/fastly/fixtures/waf_versions/logging/create.yaml @@ -2,10 +2,10 @@ version: 1 interactions: - request: - body: Service=3BOOVoayIlrdMuRU8LrKSA&Version=2&address=example.com&format=format&format_version=2&hostname=example.com&message_type=classic&name=test-syslog&port=1234&token=abcd1234 + body: Service=5mAR0wHKpNJjOqc65YeDqI&Version=2&address=example.com&format=format&format_version=2&hostname=example.com&message_type=classic&name=test-syslog&port=1234&token=abcd1234 form: Service: - - 3BOOVoayIlrdMuRU8LrKSA + - 5mAR0wHKpNJjOqc65YeDqI Version: - "2" address: @@ -29,10 +29,10 @@ interactions: - application/x-www-form-urlencoded User-Agent: - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) - url: https://api.fastly.com/service/3BOOVoayIlrdMuRU8LrKSA/version/2/logging/syslog + url: https://api.fastly.com/service/5mAR0wHKpNJjOqc65YeDqI/version/2/logging/syslog method: POST response: - body: '{"address":"example.com","format":"format","format_version":"2","hostname":"example.com","message_type":"classic","name":"test-syslog","port":"1234","token":"abcd1234","service_id":"3BOOVoayIlrdMuRU8LrKSA","version":"2","tls_ca_cert":null,"tls_client_key":null,"updated_at":"2020-06-30T10:56:25Z","created_at":"2020-06-30T10:56:25Z","tls_hostname":null,"placement":null,"response_condition":"","use_tls":"0","tls_client_cert":null,"ipv4":null,"deleted_at":null,"public_key":null}' + body: '{"address":"example.com","format":"format","format_version":"2","hostname":"example.com","message_type":"classic","name":"test-syslog","port":"1234","token":"abcd1234","service_id":"5mAR0wHKpNJjOqc65YeDqI","version":"2","updated_at":"2020-07-02T20:05:32Z","deleted_at":null,"created_at":"2020-07-02T20:05:32Z","tls_client_cert":null,"placement":null,"tls_ca_cert":null,"tls_hostname":null,"tls_client_key":null,"ipv4":null,"response_condition":"","use_tls":"0","public_key":null}' headers: Accept-Ranges: - bytes @@ -42,11 +42,11 @@ interactions: Content-Type: - application/json Date: - - Tue, 30 Jun 2020 10:56:25 GMT + - Thu, 02 Jul 2020 20:05:33 GMT Fastly-Ratelimit-Remaining: - - "684" + - "979" Fastly-Ratelimit-Reset: - - "1593514800" + - "1593723600" Status: - 200 OK Strict-Transport-Security: @@ -61,9 +61,9 @@ interactions: X-Cache-Hits: - 0, 0 X-Served-By: - - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19235-LCY + - cache-control-slwdc9036-CONTROL-SLWDC, cache-lcy19251-LCY X-Timer: - - S1593514585.355101,VS0,VE520 + - S1593720333.715815,VS0,VE413 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/waf_versions/logging/delete.yaml b/fastly/fixtures/waf_versions/logging/delete.yaml index 0bfb5a772..3173dcebd 100644 --- a/fastly/fixtures/waf_versions/logging/delete.yaml +++ b/fastly/fixtures/waf_versions/logging/delete.yaml @@ -7,7 +7,7 @@ interactions: headers: User-Agent: - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) - url: https://api.fastly.com/service/3BOOVoayIlrdMuRU8LrKSA/version/2/logging/syslog/test-syslog + url: https://api.fastly.com/service/5mAR0wHKpNJjOqc65YeDqI/version/2/logging/syslog/test-syslog method: DELETE response: body: '{"status":"ok"}' @@ -20,11 +20,11 @@ interactions: Content-Type: - application/json Date: - - Tue, 30 Jun 2020 10:56:31 GMT + - Thu, 02 Jul 2020 20:05:39 GMT Fastly-Ratelimit-Remaining: - - "672" + - "974" Fastly-Ratelimit-Reset: - - "1593514800" + - "1593723600" Status: - 200 OK Strict-Transport-Security: @@ -39,9 +39,9 @@ interactions: X-Cache-Hits: - 0, 0 X-Served-By: - - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19235-LCY + - cache-control-slwdc9036-CONTROL-SLWDC, cache-lcy19251-LCY X-Timer: - - S1593514592.662938,VS0,VE244 + - S1593720340.556496,VS0,VE257 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/waf_versions/response_object/create.yaml b/fastly/fixtures/waf_versions/response_object/create.yaml index 47f41cc4f..65e98893f 100644 --- a/fastly/fixtures/waf_versions/response_object/create.yaml +++ b/fastly/fixtures/waf_versions/response_object/create.yaml @@ -2,10 +2,10 @@ version: 1 interactions: - request: - body: Service=3BOOVoayIlrdMuRU8LrKSA&Version=2&name=WAf_Response&status=403 + body: Service=5mAR0wHKpNJjOqc65YeDqI&Version=2&name=WAf_Response&status=403 form: Service: - - 3BOOVoayIlrdMuRU8LrKSA + - 5mAR0wHKpNJjOqc65YeDqI Version: - "2" name: @@ -17,10 +17,10 @@ interactions: - application/x-www-form-urlencoded User-Agent: - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) - url: https://api.fastly.com/service/3BOOVoayIlrdMuRU8LrKSA/version/2/response_object + url: https://api.fastly.com/service/5mAR0wHKpNJjOqc65YeDqI/version/2/response_object method: POST response: - body: '{"name":"WAf_Response","status":"403","service_id":"3BOOVoayIlrdMuRU8LrKSA","version":"2","content":null,"cache_condition":"","request_condition":"","updated_at":"2020-06-30T10:56:26Z","content_type":null,"created_at":"2020-06-30T10:56:26Z","deleted_at":null,"response":"ok"}' + body: '{"name":"WAf_Response","status":"403","service_id":"5mAR0wHKpNJjOqc65YeDqI","version":"2","response":"ok","updated_at":"2020-07-02T20:05:33Z","created_at":"2020-07-02T20:05:33Z","cache_condition":"","request_condition":"","deleted_at":null,"content_type":null,"content":null}' headers: Accept-Ranges: - bytes @@ -30,11 +30,11 @@ interactions: Content-Type: - application/json Date: - - Tue, 30 Jun 2020 10:56:27 GMT + - Thu, 02 Jul 2020 20:05:33 GMT Fastly-Ratelimit-Remaining: - - "679" + - "977" Fastly-Ratelimit-Reset: - - "1593514800" + - "1593723600" Status: - 200 OK Strict-Transport-Security: @@ -49,9 +49,9 @@ interactions: X-Cache-Hits: - 0, 0 X-Served-By: - - cache-control-slwdc9036-CONTROL-SLWDC, cache-lcy19235-LCY + - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19251-LCY X-Timer: - - S1593514587.562114,VS0,VE489 + - S1593720334.609439,VS0,VE228 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/waf_versions/response_object/delete.yaml b/fastly/fixtures/waf_versions/response_object/delete.yaml index f5f55bf35..955f00519 100644 --- a/fastly/fixtures/waf_versions/response_object/delete.yaml +++ b/fastly/fixtures/waf_versions/response_object/delete.yaml @@ -7,7 +7,7 @@ interactions: headers: User-Agent: - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) - url: https://api.fastly.com/service/3BOOVoayIlrdMuRU8LrKSA/version/2/response_object/WAf_Response + url: https://api.fastly.com/service/5mAR0wHKpNJjOqc65YeDqI/version/2/response_object/WAf_Response method: DELETE response: body: '{"status":"ok"}' @@ -20,11 +20,11 @@ interactions: Content-Type: - application/json Date: - - Tue, 30 Jun 2020 10:56:31 GMT + - Thu, 02 Jul 2020 20:05:38 GMT Fastly-Ratelimit-Remaining: - - "676" + - "976" Fastly-Ratelimit-Reset: - - "1593514800" + - "1593723600" Status: - 200 OK Strict-Transport-Security: @@ -39,9 +39,9 @@ interactions: X-Cache-Hits: - 0, 0 X-Served-By: - - cache-control-slwdc9035-CONTROL-SLWDC, cache-lcy19235-LCY + - cache-control-slwdc9035-CONTROL-SLWDC, cache-lcy19251-LCY X-Timer: - - S1593514591.815615,VS0,VE249 + - S1593720339.719207,VS0,VE248 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/waf_versions/service/create.yaml b/fastly/fixtures/waf_versions/service/create.yaml index a4003cc9c..b8ab2a9ff 100644 --- a/fastly/fixtures/waf_versions/service/create.yaml +++ b/fastly/fixtures/waf_versions/service/create.yaml @@ -18,7 +18,7 @@ interactions: url: https://api.fastly.com/service method: POST response: - body: '{"customer_id":"WpqWFjTA4lk2N1g0GY2HH","comment":"go-fastly client test","name":"test_service_service3","type":"vcl","versions":[{"updated_at":"2020-06-30T10:56:24Z","created_at":"2020-06-30T10:56:24Z","service_id":"3BOOVoayIlrdMuRU8LrKSA","locked":false,"staging":false,"deployed":false,"number":1,"deleted_at":null,"testing":false,"active":false,"comment":""}],"updated_at":"2020-06-30T10:56:24Z","id":"3BOOVoayIlrdMuRU8LrKSA","created_at":"2020-06-30T10:56:24Z","deleted_at":null,"publish_key":""}' + body: '{"customer_id":"WpqWFjTA4lk2N1g0GY2HH","comment":"go-fastly client test","name":"test_service_service3","type":"vcl","versions":[{"testing":false,"deleted_at":null,"service_id":"5mAR0wHKpNJjOqc65YeDqI","comment":"","created_at":"2020-07-02T20:05:32Z","updated_at":"2020-07-02T20:05:32Z","active":false,"locked":false,"number":1,"deployed":false,"staging":false}],"publish_key":"","created_at":"2020-07-02T20:05:32Z","deleted_at":null,"id":"5mAR0wHKpNJjOqc65YeDqI","updated_at":"2020-07-02T20:05:32Z"}' headers: Accept-Ranges: - bytes @@ -28,11 +28,11 @@ interactions: Content-Type: - application/json Date: - - Tue, 30 Jun 2020 10:56:24 GMT + - Thu, 02 Jul 2020 20:05:32 GMT Fastly-Ratelimit-Remaining: - - "691" + - "981" Fastly-Ratelimit-Reset: - - "1593514800" + - "1593723600" Status: - 200 OK Strict-Transport-Security: @@ -47,9 +47,9 @@ interactions: X-Cache-Hits: - 0, 0 X-Served-By: - - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19235-LCY + - cache-control-slwdc9035-CONTROL-SLWDC, cache-lcy19251-LCY X-Timer: - - S1593514584.987441,VS0,VE469 + - S1593720332.921745,VS0,VE229 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/waf_versions/service/delete.yaml b/fastly/fixtures/waf_versions/service/delete.yaml index a5a97f836..8026e78ae 100644 --- a/fastly/fixtures/waf_versions/service/delete.yaml +++ b/fastly/fixtures/waf_versions/service/delete.yaml @@ -7,7 +7,7 @@ interactions: headers: User-Agent: - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) - url: https://api.fastly.com/service/3BOOVoayIlrdMuRU8LrKSA + url: https://api.fastly.com/service/5mAR0wHKpNJjOqc65YeDqI method: DELETE response: body: '{"status":"ok"}' @@ -20,11 +20,11 @@ interactions: Content-Type: - application/json Date: - - Tue, 30 Jun 2020 10:56:32 GMT + - Thu, 02 Jul 2020 20:05:40 GMT Fastly-Ratelimit-Remaining: - - "670" + - "973" Fastly-Ratelimit-Reset: - - "1593514800" + - "1593723600" Status: - 200 OK Strict-Transport-Security: @@ -39,9 +39,9 @@ interactions: X-Cache-Hits: - 0, 0 X-Served-By: - - cache-control-slwdc9035-CONTROL-SLWDC, cache-lcy19235-LCY + - cache-control-slwdc9035-CONTROL-SLWDC, cache-lcy19251-LCY X-Timer: - - S1593514592.090749,VS0,VE215 + - S1593720340.000730,VS0,VE243 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/waf_versions/service/version.yaml b/fastly/fixtures/waf_versions/service/version.yaml index d0a8e0d26..192b7310c 100644 --- a/fastly/fixtures/waf_versions/service/version.yaml +++ b/fastly/fixtures/waf_versions/service/version.yaml @@ -2,19 +2,19 @@ version: 1 interactions: - request: - body: Service=3BOOVoayIlrdMuRU8LrKSA + body: Service=5mAR0wHKpNJjOqc65YeDqI form: Service: - - 3BOOVoayIlrdMuRU8LrKSA + - 5mAR0wHKpNJjOqc65YeDqI headers: Content-Type: - application/x-www-form-urlencoded User-Agent: - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) - url: https://api.fastly.com/service/3BOOVoayIlrdMuRU8LrKSA/version + url: https://api.fastly.com/service/5mAR0wHKpNJjOqc65YeDqI/version method: POST response: - body: '{"service_id":"3BOOVoayIlrdMuRU8LrKSA","number":2}' + body: '{"service_id":"5mAR0wHKpNJjOqc65YeDqI","number":2}' headers: Accept-Ranges: - bytes @@ -24,11 +24,11 @@ interactions: Content-Type: - application/json Date: - - Tue, 30 Jun 2020 10:56:25 GMT + - Thu, 02 Jul 2020 20:05:32 GMT Fastly-Ratelimit-Remaining: - - "687" + - "980" Fastly-Ratelimit-Reset: - - "1593514800" + - "1593723600" Status: - 200 OK Strict-Transport-Security: @@ -43,9 +43,9 @@ interactions: X-Cache-Hits: - 0, 0 X-Served-By: - - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19235-LCY + - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19251-LCY X-Timer: - - S1593514585.002324,VS0,VE232 + - S1593720332.316214,VS0,VE255 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/waf_versions/update.yaml b/fastly/fixtures/waf_versions/update.yaml index 1b5968fb7..e6a96a58e 100644 --- a/fastly/fixtures/waf_versions/update.yaml +++ b/fastly/fixtures/waf_versions/update.yaml @@ -3,7 +3,7 @@ version: 1 interactions: - request: body: | - {"data":{"type":"waf_firewall_version","id":"3LP12sn59pB0iz0Kh75cHb","attributes":{"allowed_http_versions":"HTTP/1.0 HTTP/1.1","allowed_methods":"GET HEAD POST","allowed_request_content_type":"application/x-www-form-urlencoded|multipart/form-data|text/xml|application/xml","allowed_request_content_type_charset":"utf-8|iso-8859-1","arg_length":800,"arg_name_length":200,"combined_file_sizes":20000000,"comment":"my comment","critical_anomaly_score":12,"crs_validate_utf8_encoding":true,"error_anomaly_score":10,"high_risk_country_codes":"gb","http_violation_score_threshold":20,"inbound_anomaly_score_threshold":20,"lfi_score_threshold":20,"max_file_size":20000000,"max_num_args":510,"notice_anomaly_score":8,"paranoia_level":2,"php_injection_score_threshold":20,"rce_score_threshold":20,"restricted_extensions":".asa/ .asax/ .ascx/ .axd/ .backup/ .bak/ .bat/ .cdx/ .cer/ .cfg/ .cmd/ .com/","restricted_headers":"/proxy/ /lock-token/","rfi_score_threshold":20,"session_fixation_score_threshold":20,"sql_injection_score_threshold":20,"total_arg_length":12800,"warning_anomaly_score":20,"xss_score_threshold":20}}} + {"data":{"type":"waf_firewall_version","id":"6Kz7TD05ACSKRCkV3KGIC9","attributes":{"allowed_http_versions":"HTTP/1.0 HTTP/1.1","allowed_methods":"GET HEAD POST","allowed_request_content_type":"application/x-www-form-urlencoded|multipart/form-data|text/xml|application/xml","allowed_request_content_type_charset":"utf-8|iso-8859-1","arg_length":800,"arg_name_length":200,"combined_file_sizes":20000000,"comment":"my comment","critical_anomaly_score":12,"crs_validate_utf8_encoding":true,"error_anomaly_score":10,"high_risk_country_codes":"gb","http_violation_score_threshold":20,"inbound_anomaly_score_threshold":20,"lfi_score_threshold":20,"max_file_size":20000000,"max_num_args":510,"notice_anomaly_score":8,"paranoia_level":2,"php_injection_score_threshold":20,"rce_score_threshold":20,"restricted_extensions":".asa/ .asax/ .ascx/ .axd/ .backup/ .bak/ .bat/ .cdx/ .cer/ .cfg/ .cmd/ .com/","restricted_headers":"/proxy/ /lock-token/","rfi_score_threshold":20,"session_fixation_score_threshold":20,"sql_injection_score_threshold":20,"total_arg_length":12800,"warning_anomaly_score":20,"xss_score_threshold":20}}} form: {} headers: Accept: @@ -12,14 +12,14 @@ interactions: - application/vnd.api+json User-Agent: - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) - url: https://api.fastly.com/waf/firewalls/6gj91AAsD3ndcoKaplqiq8/versions/2 + url: https://api.fastly.com/waf/firewalls/3x9V8lGE6mhxxVIr15QeRo/versions/2 method: PATCH response: - body: '{"data":{"id":"3LP12sn59pB0iz0Kh75cHb","type":"waf_firewall_version","attributes":{"active":false,"active_rules_fastly_block_count":0,"active_rules_fastly_log_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_score_count":0,"active_rules_trustwave_block_count":0,"active_rules_trustwave_log_count":0,"allowed_http_versions":"HTTP/1.0 + body: '{"data":{"id":"6Kz7TD05ACSKRCkV3KGIC9","type":"waf_firewall_version","attributes":{"active":false,"active_rules_fastly_block_count":0,"active_rules_fastly_log_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_score_count":0,"active_rules_trustwave_block_count":0,"active_rules_trustwave_log_count":0,"allowed_http_versions":"HTTP/1.0 HTTP/1.1","allowed_methods":"GET HEAD POST","allowed_request_content_type":"application/x-www-form-urlencoded|multipart/form-data|text/xml|application/xml","allowed_request_content_type_charset":"utf-8|iso-8859-1","arg_name_length":200,"arg_length":800,"combined_file_sizes":20000000,"comment":"my - comment","created_at":"2020-06-30T10:56:28Z","critical_anomaly_score":12,"crs_validate_utf8_encoding":true,"deployed_at":null,"error":null,"error_anomaly_score":10,"high_risk_country_codes":"gb","http_violation_score_threshold":20,"inbound_anomaly_score_threshold":20,"last_deployment_status":null,"lfi_score_threshold":20,"locked":false,"max_file_size":20000000,"max_num_args":510,"notice_anomaly_score":8,"number":2,"paranoia_level":2,"php_injection_score_threshold":20,"rce_score_threshold":20,"restricted_extensions":".asa/ + comment","created_at":"2020-07-02T20:05:35Z","critical_anomaly_score":12,"crs_validate_utf8_encoding":true,"deployed_at":null,"error":null,"error_anomaly_score":10,"high_risk_country_codes":"gb","http_violation_score_threshold":20,"inbound_anomaly_score_threshold":20,"last_deployment_status":null,"lfi_score_threshold":20,"locked":false,"max_file_size":20000000,"max_num_args":510,"notice_anomaly_score":8,"number":2,"paranoia_level":2,"php_injection_score_threshold":20,"rce_score_threshold":20,"restricted_extensions":".asa/ .asax/ .ascx/ .axd/ .backup/ .bak/ .bat/ .cdx/ .cer/ .cfg/ .cmd/ .com/","restricted_headers":"/proxy/ - /lock-token/","rfi_score_threshold":20,"session_fixation_score_threshold":20,"sql_injection_score_threshold":20,"total_arg_length":12800,"updated_at":"2020-06-30T10:56:29Z","warning_anomaly_score":20,"xss_score_threshold":20},"relationships":{"waf_firewall":{"data":{"id":"6gj91AAsD3ndcoKaplqiq8","type":"waf_firewall"}}}}}' + /lock-token/","rfi_score_threshold":20,"session_fixation_score_threshold":20,"sql_injection_score_threshold":20,"total_arg_length":12800,"updated_at":"2020-07-02T20:05:36Z","warning_anomaly_score":20,"xss_score_threshold":20},"relationships":{"waf_firewall":{"data":{"id":"3x9V8lGE6mhxxVIr15QeRo","type":"waf_firewall"}}}}}' headers: Accept-Ranges: - bytes @@ -29,7 +29,7 @@ interactions: Content-Type: - application/vnd.api+json Date: - - Tue, 30 Jun 2020 10:56:29 GMT + - Thu, 02 Jul 2020 20:05:36 GMT Status: - 200 OK Strict-Transport-Security: @@ -44,9 +44,9 @@ interactions: X-Content-Type-Options: - nosniff X-Served-By: - - cache-control-slwdc9036-CONTROL-SLWDC, cache-lcy19235-LCY + - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19251-LCY X-Timer: - - S1593514589.036404,VS0,VE142 + - S1593720337.744107,VS0,VE118 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/waf_versions/waf/create.yaml b/fastly/fixtures/waf_versions/waf/create.yaml index fe6d2f35d..b49442f45 100644 --- a/fastly/fixtures/waf_versions/waf/create.yaml +++ b/fastly/fixtures/waf_versions/waf/create.yaml @@ -3,7 +3,7 @@ version: 1 interactions: - request: body: | - {"data":{"type":"waf_firewall","attributes":{"prefetch_condition":"WAF_Prefetch","response":"WAf_Response","service_id":"3BOOVoayIlrdMuRU8LrKSA","service_version_number":"2"}}} + {"data":{"type":"waf_firewall","attributes":{"prefetch_condition":"WAF_Prefetch","response":"WAf_Response","service_id":"5mAR0wHKpNJjOqc65YeDqI","service_version_number":"2"}}} form: {} headers: Accept: @@ -15,7 +15,7 @@ interactions: url: https://api.fastly.com/waf/firewalls method: POST response: - body: '{"data":{"id":"6gj91AAsD3ndcoKaplqiq8","type":"waf_firewall","attributes":{"active_rules_fastly_block_count":0,"active_rules_fastly_log_count":0,"active_rules_fastly_score_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_score_count":0,"active_rules_trustwave_block_count":0,"active_rules_trustwave_log_count":0,"created_at":"2020-06-30T10:56:27Z","disabled":false,"prefetch_condition":"WAF_Prefetch","response":"WAf_Response","service_id":"3BOOVoayIlrdMuRU8LrKSA","service_version_number":2,"updated_at":"2020-06-30T10:56:27Z"}}}' + body: '{"data":{"id":"3x9V8lGE6mhxxVIr15QeRo","type":"waf_firewall","attributes":{"active_rules_fastly_block_count":0,"active_rules_fastly_log_count":0,"active_rules_fastly_score_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_score_count":0,"active_rules_trustwave_block_count":0,"active_rules_trustwave_log_count":0,"created_at":"2020-07-02T20:05:34Z","disabled":false,"prefetch_condition":"WAF_Prefetch","response":"WAf_Response","service_id":"5mAR0wHKpNJjOqc65YeDqI","service_version_number":2,"updated_at":"2020-07-02T20:05:34Z"}}}' headers: Accept-Ranges: - bytes @@ -25,7 +25,7 @@ interactions: Content-Type: - application/vnd.api+json Date: - - Tue, 30 Jun 2020 10:56:27 GMT + - Thu, 02 Jul 2020 20:05:34 GMT Status: - 201 Created Strict-Transport-Security: @@ -40,9 +40,9 @@ interactions: X-Content-Type-Options: - nosniff X-Served-By: - - cache-control-slwdc9035-CONTROL-SLWDC, cache-lcy19235-LCY + - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19251-LCY X-Timer: - - S1593514587.128070,VS0,VE708 + - S1593720334.961963,VS0,VE936 status: 201 Created code: 201 duration: "" diff --git a/fastly/fixtures/waf_versions/waf/delete.yaml b/fastly/fixtures/waf_versions/waf/delete.yaml index 85f481454..eb56d9718 100644 --- a/fastly/fixtures/waf_versions/waf/delete.yaml +++ b/fastly/fixtures/waf_versions/waf/delete.yaml @@ -3,7 +3,7 @@ version: 1 interactions: - request: body: | - {"data":{"type":"waf_firewall","id":"6gj91AAsD3ndcoKaplqiq8","attributes":{"service_version_number":"2"}}} + {"data":{"type":"waf_firewall","id":"3x9V8lGE6mhxxVIr15QeRo","attributes":{"service_version_number":"2"}}} form: {} headers: Accept: @@ -12,7 +12,7 @@ interactions: - application/vnd.api+json User-Agent: - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) - url: https://api.fastly.com/waf/firewalls/6gj91AAsD3ndcoKaplqiq8 + url: https://api.fastly.com/waf/firewalls/3x9V8lGE6mhxxVIr15QeRo method: DELETE response: body: "" @@ -21,7 +21,7 @@ interactions: - bytes - bytes Date: - - Tue, 30 Jun 2020 10:56:30 GMT + - Thu, 02 Jul 2020 20:05:38 GMT Status: - 204 No Content Strict-Transport-Security: @@ -36,9 +36,9 @@ interactions: X-Content-Type-Options: - nosniff X-Served-By: - - cache-control-slwdc9035-CONTROL-SLWDC, cache-lcy19235-LCY + - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19251-LCY X-Timer: - - S1593514590.231324,VS0,VE434 + - S1593720338.214280,VS0,VE316 status: 204 No Content code: 204 duration: "" diff --git a/fastly/waf_version.go b/fastly/waf_version.go index 3fca53b35..4cedc9064 100644 --- a/fastly/waf_version.go +++ b/fastly/waf_version.go @@ -322,8 +322,10 @@ func (c *Client) LockWAFVersion(i *LockWAFVersionInput) (*WAFVersion, error) { return nil, ErrMissingWAFVersionNumber } - path := fmt.Sprintf("/waf/firewalls/%s/versions/%d/lock", i.WAFID, i.WAFVersionNumber) - resp, err := c.PutJSONAPI(path, &LockWAFVersionInput{}, nil) + path := fmt.Sprintf("/waf/firewalls/%s/versions/%d", i.WAFID, i.WAFVersionNumber) + resp, err := c.PatchJSONAPI(path, &struct { + Locked bool `jsonapi:"attr,locked"` + }{true}, nil) if err != nil { return nil, err } From f3742d30058d21eefde8888b1e73627db9a1e73b Mon Sep 17 00:00:00 2001 From: Stuart Wallace Date: Thu, 2 Jul 2020 21:21:35 +0100 Subject: [PATCH 16/37] Update waf_versions activate API --- fastly/fixtures/waf_versions/clone.yaml | 14 +++++++------- .../waf_versions/condition/create.yaml | 16 ++++++++-------- .../waf_versions/condition/delete.yaml | 10 +++++----- fastly/fixtures/waf_versions/create_empty.yaml | 14 +++++++------- fastly/fixtures/waf_versions/deploy.yaml | 10 +++++----- fastly/fixtures/waf_versions/get.yaml | 14 +++++++------- fastly/fixtures/waf_versions/list.yaml | 14 +++++++------- fastly/fixtures/waf_versions/list_all.yaml | 18 +++++++++--------- fastly/fixtures/waf_versions/lock.yaml | 14 +++++++------- .../fixtures/waf_versions/logging/create.yaml | 16 ++++++++-------- .../fixtures/waf_versions/logging/delete.yaml | 10 +++++----- .../waf_versions/response_object/create.yaml | 16 ++++++++-------- .../waf_versions/response_object/delete.yaml | 10 +++++----- .../fixtures/waf_versions/service/create.yaml | 10 +++++----- .../fixtures/waf_versions/service/delete.yaml | 10 +++++----- .../fixtures/waf_versions/service/version.yaml | 16 ++++++++-------- fastly/fixtures/waf_versions/update.yaml | 16 ++++++++-------- fastly/fixtures/waf_versions/waf/create.yaml | 10 +++++----- fastly/fixtures/waf_versions/waf/delete.yaml | 10 +++++----- fastly/fixtures/wafs/cleanup.yaml | 10 +++++----- fastly/fixtures/wafs/condition/create.yaml | 18 +++++++++--------- fastly/fixtures/wafs/condition/delete.yaml | 12 ++++++------ fastly/fixtures/wafs/create.yaml | 10 +++++----- fastly/fixtures/wafs/delete.yaml | 10 +++++----- fastly/fixtures/wafs/deploy.yaml | 10 +++++----- fastly/fixtures/wafs/disable.yaml | 12 ++++++------ fastly/fixtures/wafs/enable.yaml | 12 ++++++------ fastly/fixtures/wafs/get.yaml | 10 +++++----- fastly/fixtures/wafs/list.yaml | 10 +++++----- .../wafs/response_object/cleanup_another.yaml | 12 ++++++------ .../fixtures/wafs/response_object/create.yaml | 18 +++++++++--------- .../wafs/response_object/create_another.yaml | 18 +++++++++--------- .../fixtures/wafs/response_object/delete.yaml | 12 ++++++------ fastly/fixtures/wafs/service/create.yaml | 12 ++++++------ fastly/fixtures/wafs/service/delete.yaml | 12 ++++++------ fastly/fixtures/wafs/service/version.yaml | 18 +++++++++--------- fastly/fixtures/wafs/update.yaml | 14 +++++++------- fastly/waf_version.go | 4 ++-- 38 files changed, 241 insertions(+), 241 deletions(-) diff --git a/fastly/fixtures/waf_versions/clone.yaml b/fastly/fixtures/waf_versions/clone.yaml index cb1771e41..fd7732662 100644 --- a/fastly/fixtures/waf_versions/clone.yaml +++ b/fastly/fixtures/waf_versions/clone.yaml @@ -12,17 +12,17 @@ interactions: - application/vnd.api+json User-Agent: - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) - url: https://api.fastly.com/waf/firewalls/3x9V8lGE6mhxxVIr15QeRo/versions/1/clone + url: https://api.fastly.com/waf/firewalls/5oX1X8cVEBpEXg6PsNSTXA/versions/1/clone method: PUT response: - body: '{"data":{"id":"6Kz7TD05ACSKRCkV3KGIC9","type":"waf_firewall_version","attributes":{"active":false,"active_rules_fastly_block_count":0,"active_rules_fastly_log_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_score_count":0,"active_rules_trustwave_block_count":0,"active_rules_trustwave_log_count":0,"allowed_http_versions":"HTTP/1.0 - HTTP/1.1 HTTP/2","allowed_methods":"GET HEAD POST OPTIONS PUT PATCH DELETE","allowed_request_content_type":"application/x-www-form-urlencoded|multipart/form-data|text/xml|application/xml|application/soap+xml|application/x-amf|application/json|application/octet-stream|application/csp-report|application/xss-auditor-report|text/plain","allowed_request_content_type_charset":"utf-8|iso-8859-1|iso-8859-15|windows-1252","arg_name_length":100,"arg_length":400,"combined_file_sizes":10000000,"comment":null,"created_at":"2020-07-02T20:05:35Z","critical_anomaly_score":5,"crs_validate_utf8_encoding":false,"deployed_at":null,"error":null,"error_anomaly_score":4,"high_risk_country_codes":"","http_violation_score_threshold":999,"inbound_anomaly_score_threshold":999,"last_deployment_status":null,"lfi_score_threshold":999,"locked":false,"max_file_size":10000000,"max_num_args":255,"notice_anomaly_score":2,"number":2,"paranoia_level":1,"php_injection_score_threshold":999,"rce_score_threshold":999,"restricted_extensions":".asa/ + body: '{"data":{"id":"6q3TBLBKV00lMIsp0DC3wq","type":"waf_firewall_version","attributes":{"active":false,"active_rules_fastly_block_count":0,"active_rules_fastly_log_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_score_count":0,"active_rules_trustwave_block_count":0,"active_rules_trustwave_log_count":0,"allowed_http_versions":"HTTP/1.0 + HTTP/1.1 HTTP/2","allowed_methods":"GET HEAD POST OPTIONS PUT PATCH DELETE","allowed_request_content_type":"application/x-www-form-urlencoded|multipart/form-data|text/xml|application/xml|application/soap+xml|application/x-amf|application/json|application/octet-stream|application/csp-report|application/xss-auditor-report|text/plain","allowed_request_content_type_charset":"utf-8|iso-8859-1|iso-8859-15|windows-1252","arg_name_length":100,"arg_length":400,"combined_file_sizes":10000000,"comment":null,"created_at":"2020-07-02T20:20:58Z","critical_anomaly_score":5,"crs_validate_utf8_encoding":false,"deployed_at":null,"error":null,"error_anomaly_score":4,"high_risk_country_codes":"","http_violation_score_threshold":999,"inbound_anomaly_score_threshold":999,"last_deployment_status":null,"lfi_score_threshold":999,"locked":false,"max_file_size":10000000,"max_num_args":255,"notice_anomaly_score":2,"number":2,"paranoia_level":1,"php_injection_score_threshold":999,"rce_score_threshold":999,"restricted_extensions":".asa/ .asax/ .ascx/ .axd/ .backup/ .bak/ .bat/ .cdx/ .cer/ .cfg/ .cmd/ .com/ .config/ .conf/ .cs/ .csproj/ .csr/ .dat/ .db/ .dbf/ .dll/ .dos/ .htr/ .htw/ .ida/ .idc/ .idq/ .inc/ .ini/ .key/ .licx/ .lnk/ .log/ .mdb/ .old/ .pass/ .pdb/ .pol/ .printer/ .pwd/ .resources/ .resx/ .sql/ .sys/ .vb/ .vbs/ .vbproj/ .vsdisco/ .webinfo/ .xsd/ .xsx/","restricted_headers":"/proxy/ /lock-token/ /content-range/ /translate/ - /if/","rfi_score_threshold":999,"session_fixation_score_threshold":999,"sql_injection_score_threshold":999,"total_arg_length":6400,"updated_at":"2020-07-02T20:05:35Z","warning_anomaly_score":3,"xss_score_threshold":999},"relationships":{"waf_firewall":{"data":{"id":"3x9V8lGE6mhxxVIr15QeRo","type":"waf_firewall"}}}}}' + /if/","rfi_score_threshold":999,"session_fixation_score_threshold":999,"sql_injection_score_threshold":999,"total_arg_length":6400,"updated_at":"2020-07-02T20:20:58Z","warning_anomaly_score":3,"xss_score_threshold":999},"relationships":{"waf_firewall":{"data":{"id":"5oX1X8cVEBpEXg6PsNSTXA","type":"waf_firewall"}}}}}' headers: Accept-Ranges: - bytes @@ -32,7 +32,7 @@ interactions: Content-Type: - application/vnd.api+json Date: - - Thu, 02 Jul 2020 20:05:36 GMT + - Thu, 02 Jul 2020 20:20:58 GMT Status: - 200 OK Strict-Transport-Security: @@ -47,9 +47,9 @@ interactions: X-Content-Type-Options: - nosniff X-Served-By: - - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19251-LCY + - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19265-LCY X-Timer: - - S1593720336.867840,VS0,VE200 + - S1593721258.437172,VS0,VE181 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/waf_versions/condition/create.yaml b/fastly/fixtures/waf_versions/condition/create.yaml index 247447cff..891c1f5d4 100644 --- a/fastly/fixtures/waf_versions/condition/create.yaml +++ b/fastly/fixtures/waf_versions/condition/create.yaml @@ -2,10 +2,10 @@ version: 1 interactions: - request: - body: Service=5mAR0wHKpNJjOqc65YeDqI&Version=2&name=WAF_Prefetch&priority=1&statement=req.url~%2B%22index.html%22&type=PREFETCH + body: Service=52szbbqIWi1L5bUd4EBKkX&Version=2&name=WAF_Prefetch&priority=1&statement=req.url~%2B%22index.html%22&type=PREFETCH form: Service: - - 5mAR0wHKpNJjOqc65YeDqI + - 52szbbqIWi1L5bUd4EBKkX Version: - "2" name: @@ -21,10 +21,10 @@ interactions: - application/x-www-form-urlencoded User-Agent: - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) - url: https://api.fastly.com/service/5mAR0wHKpNJjOqc65YeDqI/version/2/condition + url: https://api.fastly.com/service/52szbbqIWi1L5bUd4EBKkX/version/2/condition method: POST response: - body: '{"name":"WAF_Prefetch","priority":"1","statement":"req.url~+\"index.html\"","type":"PREFETCH","service_id":"5mAR0wHKpNJjOqc65YeDqI","version":"2","updated_at":"2020-07-02T20:05:33Z","comment":"","created_at":"2020-07-02T20:05:33Z","deleted_at":null}' + body: '{"name":"WAF_Prefetch","priority":"1","statement":"req.url~+\"index.html\"","type":"PREFETCH","service_id":"52szbbqIWi1L5bUd4EBKkX","version":"2","created_at":"2020-07-02T20:20:56Z","updated_at":"2020-07-02T20:20:56Z","deleted_at":null,"comment":""}' headers: Accept-Ranges: - bytes @@ -34,9 +34,9 @@ interactions: Content-Type: - application/json Date: - - Thu, 02 Jul 2020 20:05:33 GMT + - Thu, 02 Jul 2020 20:20:56 GMT Fastly-Ratelimit-Remaining: - - "978" + - "951" Fastly-Ratelimit-Reset: - "1593723600" Status: @@ -53,9 +53,9 @@ interactions: X-Cache-Hits: - 0, 0 X-Served-By: - - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19251-LCY + - cache-control-slwdc9036-CONTROL-SLWDC, cache-lcy19265-LCY X-Timer: - - S1593720333.268758,VS0,VE199 + - S1593721256.006684,VS0,VE198 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/waf_versions/condition/delete.yaml b/fastly/fixtures/waf_versions/condition/delete.yaml index 966a90d1c..ebf9ccccf 100644 --- a/fastly/fixtures/waf_versions/condition/delete.yaml +++ b/fastly/fixtures/waf_versions/condition/delete.yaml @@ -7,7 +7,7 @@ interactions: headers: User-Agent: - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) - url: https://api.fastly.com/service/5mAR0wHKpNJjOqc65YeDqI/version/2/condition/WAF_Prefetch + url: https://api.fastly.com/service/52szbbqIWi1L5bUd4EBKkX/version/2/condition/WAF_Prefetch method: DELETE response: body: '{"status":"ok"}' @@ -20,9 +20,9 @@ interactions: Content-Type: - application/json Date: - - Thu, 02 Jul 2020 20:05:39 GMT + - Thu, 02 Jul 2020 20:21:01 GMT Fastly-Ratelimit-Remaining: - - "975" + - "948" Fastly-Ratelimit-Reset: - "1593723600" Status: @@ -39,9 +39,9 @@ interactions: X-Cache-Hits: - 0, 0 X-Served-By: - - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19251-LCY + - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19265-LCY X-Timer: - - S1593720339.176681,VS0,VE200 + - S1593721262.721294,VS0,VE222 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/waf_versions/create_empty.yaml b/fastly/fixtures/waf_versions/create_empty.yaml index 6f70f58c4..f1c663c26 100644 --- a/fastly/fixtures/waf_versions/create_empty.yaml +++ b/fastly/fixtures/waf_versions/create_empty.yaml @@ -11,17 +11,17 @@ interactions: - application/vnd.api+json User-Agent: - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) - url: https://api.fastly.com/waf/firewalls/3x9V8lGE6mhxxVIr15QeRo/versions + url: https://api.fastly.com/waf/firewalls/5oX1X8cVEBpEXg6PsNSTXA/versions method: POST response: - body: '{"data":{"id":"3q8hwfM0DdhLZRIFKZFPI4","type":"waf_firewall_version","attributes":{"active":false,"active_rules_fastly_block_count":0,"active_rules_fastly_log_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_score_count":0,"active_rules_trustwave_block_count":0,"active_rules_trustwave_log_count":0,"allowed_http_versions":"HTTP/1.0 - HTTP/1.1 HTTP/2","allowed_methods":"GET HEAD POST OPTIONS PUT PATCH DELETE","allowed_request_content_type":"application/x-www-form-urlencoded|multipart/form-data|text/xml|application/xml|application/soap+xml|application/x-amf|application/json|application/octet-stream|application/csp-report|application/xss-auditor-report|text/plain","allowed_request_content_type_charset":"utf-8|iso-8859-1|iso-8859-15|windows-1252","arg_name_length":100,"arg_length":400,"combined_file_sizes":10000000,"comment":null,"created_at":"2020-07-02T20:05:38Z","critical_anomaly_score":5,"crs_validate_utf8_encoding":false,"deployed_at":null,"error":null,"error_anomaly_score":4,"high_risk_country_codes":"","http_violation_score_threshold":999,"inbound_anomaly_score_threshold":999,"last_deployment_status":null,"lfi_score_threshold":999,"locked":false,"max_file_size":10000000,"max_num_args":255,"notice_anomaly_score":2,"number":3,"paranoia_level":1,"php_injection_score_threshold":999,"rce_score_threshold":999,"restricted_extensions":".asa/ + body: '{"data":{"id":"7ZbqqxjPYZsBzq6nePHDRT","type":"waf_firewall_version","attributes":{"active":false,"active_rules_fastly_block_count":0,"active_rules_fastly_log_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_score_count":0,"active_rules_trustwave_block_count":0,"active_rules_trustwave_log_count":0,"allowed_http_versions":"HTTP/1.0 + HTTP/1.1 HTTP/2","allowed_methods":"GET HEAD POST OPTIONS PUT PATCH DELETE","allowed_request_content_type":"application/x-www-form-urlencoded|multipart/form-data|text/xml|application/xml|application/soap+xml|application/x-amf|application/json|application/octet-stream|application/csp-report|application/xss-auditor-report|text/plain","allowed_request_content_type_charset":"utf-8|iso-8859-1|iso-8859-15|windows-1252","arg_name_length":100,"arg_length":400,"combined_file_sizes":10000000,"comment":null,"created_at":"2020-07-02T20:21:00Z","critical_anomaly_score":5,"crs_validate_utf8_encoding":false,"deployed_at":null,"error":null,"error_anomaly_score":4,"high_risk_country_codes":"","http_violation_score_threshold":999,"inbound_anomaly_score_threshold":999,"last_deployment_status":null,"lfi_score_threshold":999,"locked":false,"max_file_size":10000000,"max_num_args":255,"notice_anomaly_score":2,"number":3,"paranoia_level":1,"php_injection_score_threshold":999,"rce_score_threshold":999,"restricted_extensions":".asa/ .asax/ .ascx/ .axd/ .backup/ .bak/ .bat/ .cdx/ .cer/ .cfg/ .cmd/ .com/ .config/ .conf/ .cs/ .csproj/ .csr/ .dat/ .db/ .dbf/ .dll/ .dos/ .htr/ .htw/ .ida/ .idc/ .idq/ .inc/ .ini/ .key/ .licx/ .lnk/ .log/ .mdb/ .old/ .pass/ .pdb/ .pol/ .printer/ .pwd/ .resources/ .resx/ .sql/ .sys/ .vb/ .vbs/ .vbproj/ .vsdisco/ .webinfo/ .xsd/ .xsx/","restricted_headers":"/proxy/ /lock-token/ /content-range/ /translate/ - /if/","rfi_score_threshold":999,"session_fixation_score_threshold":999,"sql_injection_score_threshold":999,"total_arg_length":6400,"updated_at":"2020-07-02T20:05:38Z","warning_anomaly_score":3,"xss_score_threshold":999},"relationships":{"waf_firewall":{"data":{"id":"3x9V8lGE6mhxxVIr15QeRo","type":"waf_firewall"}}}}}' + /if/","rfi_score_threshold":999,"session_fixation_score_threshold":999,"sql_injection_score_threshold":999,"total_arg_length":6400,"updated_at":"2020-07-02T20:21:00Z","warning_anomaly_score":3,"xss_score_threshold":999},"relationships":{"waf_firewall":{"data":{"id":"5oX1X8cVEBpEXg6PsNSTXA","type":"waf_firewall"}}}}}' headers: Accept-Ranges: - bytes @@ -31,7 +31,7 @@ interactions: Content-Type: - application/vnd.api+json Date: - - Thu, 02 Jul 2020 20:05:38 GMT + - Thu, 02 Jul 2020 20:21:00 GMT Status: - 201 Created Strict-Transport-Security: @@ -46,9 +46,9 @@ interactions: X-Content-Type-Options: - nosniff X-Served-By: - - cache-control-slwdc9035-CONTROL-SLWDC, cache-lcy19251-LCY + - cache-control-slwdc9035-CONTROL-SLWDC, cache-lcy19265-LCY X-Timer: - - S1593720338.937872,VS0,VE175 + - S1593721261.504568,VS0,VE189 status: 201 Created code: 201 duration: "" diff --git a/fastly/fixtures/waf_versions/deploy.yaml b/fastly/fixtures/waf_versions/deploy.yaml index 388362086..a859cddb7 100644 --- a/fastly/fixtures/waf_versions/deploy.yaml +++ b/fastly/fixtures/waf_versions/deploy.yaml @@ -12,8 +12,8 @@ interactions: - application/vnd.api+json User-Agent: - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) - url: https://api.fastly.com/waf/firewalls/3x9V8lGE6mhxxVIr15QeRo/versions/1 - method: POST + url: https://api.fastly.com/waf/firewalls/5oX1X8cVEBpEXg6PsNSTXA/versions/1/activate + method: PUT response: body: '{}' headers: @@ -25,7 +25,7 @@ interactions: Content-Type: - application/vnd.api+json Date: - - Thu, 02 Jul 2020 20:05:35 GMT + - Thu, 02 Jul 2020 20:20:58 GMT Status: - 202 Accepted Strict-Transport-Security: @@ -40,9 +40,9 @@ interactions: X-Content-Type-Options: - nosniff X-Served-By: - - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19251-LCY + - cache-control-slwdc9035-CONTROL-SLWDC, cache-lcy19265-LCY X-Timer: - - S1593720336.584735,VS0,VE141 + - S1593721258.140969,VS0,VE151 status: 202 Accepted code: 202 duration: "" diff --git a/fastly/fixtures/waf_versions/get.yaml b/fastly/fixtures/waf_versions/get.yaml index d117643d4..7f49beecb 100644 --- a/fastly/fixtures/waf_versions/get.yaml +++ b/fastly/fixtures/waf_versions/get.yaml @@ -7,17 +7,17 @@ interactions: headers: User-Agent: - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) - url: https://api.fastly.com/waf/firewalls/3x9V8lGE6mhxxVIr15QeRo/versions/2 + url: https://api.fastly.com/waf/firewalls/5oX1X8cVEBpEXg6PsNSTXA/versions/2 method: GET response: - body: '{"data":{"id":"6Kz7TD05ACSKRCkV3KGIC9","type":"waf_firewall_version","attributes":{"active":false,"active_rules_fastly_block_count":0,"active_rules_fastly_log_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_score_count":0,"active_rules_trustwave_block_count":0,"active_rules_trustwave_log_count":0,"allowed_http_versions":"HTTP/1.0 - HTTP/1.1 HTTP/2","allowed_methods":"GET HEAD POST OPTIONS PUT PATCH DELETE","allowed_request_content_type":"application/x-www-form-urlencoded|multipart/form-data|text/xml|application/xml|application/soap+xml|application/x-amf|application/json|application/octet-stream|application/csp-report|application/xss-auditor-report|text/plain","allowed_request_content_type_charset":"utf-8|iso-8859-1|iso-8859-15|windows-1252","arg_name_length":100,"arg_length":400,"combined_file_sizes":10000000,"comment":null,"created_at":"2020-07-02T20:05:35Z","critical_anomaly_score":5,"crs_validate_utf8_encoding":false,"deployed_at":null,"error":null,"error_anomaly_score":4,"high_risk_country_codes":"","http_violation_score_threshold":999,"inbound_anomaly_score_threshold":999,"last_deployment_status":null,"lfi_score_threshold":999,"locked":false,"max_file_size":10000000,"max_num_args":255,"notice_anomaly_score":2,"number":2,"paranoia_level":1,"php_injection_score_threshold":999,"rce_score_threshold":999,"restricted_extensions":".asa/ + body: '{"data":{"id":"6q3TBLBKV00lMIsp0DC3wq","type":"waf_firewall_version","attributes":{"active":false,"active_rules_fastly_block_count":0,"active_rules_fastly_log_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_score_count":0,"active_rules_trustwave_block_count":0,"active_rules_trustwave_log_count":0,"allowed_http_versions":"HTTP/1.0 + HTTP/1.1 HTTP/2","allowed_methods":"GET HEAD POST OPTIONS PUT PATCH DELETE","allowed_request_content_type":"application/x-www-form-urlencoded|multipart/form-data|text/xml|application/xml|application/soap+xml|application/x-amf|application/json|application/octet-stream|application/csp-report|application/xss-auditor-report|text/plain","allowed_request_content_type_charset":"utf-8|iso-8859-1|iso-8859-15|windows-1252","arg_name_length":100,"arg_length":400,"combined_file_sizes":10000000,"comment":null,"created_at":"2020-07-02T20:20:58Z","critical_anomaly_score":5,"crs_validate_utf8_encoding":false,"deployed_at":null,"error":null,"error_anomaly_score":4,"high_risk_country_codes":"","http_violation_score_threshold":999,"inbound_anomaly_score_threshold":999,"last_deployment_status":null,"lfi_score_threshold":999,"locked":false,"max_file_size":10000000,"max_num_args":255,"notice_anomaly_score":2,"number":2,"paranoia_level":1,"php_injection_score_threshold":999,"rce_score_threshold":999,"restricted_extensions":".asa/ .asax/ .ascx/ .axd/ .backup/ .bak/ .bat/ .cdx/ .cer/ .cfg/ .cmd/ .com/ .config/ .conf/ .cs/ .csproj/ .csr/ .dat/ .db/ .dbf/ .dll/ .dos/ .htr/ .htw/ .ida/ .idc/ .idq/ .inc/ .ini/ .key/ .licx/ .lnk/ .log/ .mdb/ .old/ .pass/ .pdb/ .pol/ .printer/ .pwd/ .resources/ .resx/ .sql/ .sys/ .vb/ .vbs/ .vbproj/ .vsdisco/ .webinfo/ .xsd/ .xsx/","restricted_headers":"/proxy/ /lock-token/ /content-range/ /translate/ - /if/","rfi_score_threshold":999,"session_fixation_score_threshold":999,"sql_injection_score_threshold":999,"total_arg_length":6400,"updated_at":"2020-07-02T20:05:35Z","warning_anomaly_score":3,"xss_score_threshold":999}}}' + /if/","rfi_score_threshold":999,"session_fixation_score_threshold":999,"sql_injection_score_threshold":999,"total_arg_length":6400,"updated_at":"2020-07-02T20:20:58Z","warning_anomaly_score":3,"xss_score_threshold":999}}}' headers: Accept-Ranges: - bytes @@ -31,7 +31,7 @@ interactions: Content-Type: - application/vnd.api+json Date: - - Thu, 02 Jul 2020 20:05:36 GMT + - Thu, 02 Jul 2020 20:20:59 GMT Status: - 200 OK Strict-Transport-Security: @@ -46,9 +46,9 @@ interactions: X-Content-Type-Options: - nosniff X-Served-By: - - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19251-LCY + - cache-control-slwdc9035-CONTROL-SLWDC, cache-lcy19265-LCY X-Timer: - - S1593720336.270762,VS0,VE376 + - S1593721259.794691,VS0,VE419 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/waf_versions/list.yaml b/fastly/fixtures/waf_versions/list.yaml index 459410b8c..d4ce67d90 100644 --- a/fastly/fixtures/waf_versions/list.yaml +++ b/fastly/fixtures/waf_versions/list.yaml @@ -7,17 +7,17 @@ interactions: headers: User-Agent: - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) - url: https://api.fastly.com/waf/firewalls/3x9V8lGE6mhxxVIr15QeRo/versions + url: https://api.fastly.com/waf/firewalls/5oX1X8cVEBpEXg6PsNSTXA/versions method: GET response: - body: '{"data":[{"id":"7WfLA42gWjnACmwwTJYylj","type":"waf_firewall_version","attributes":{"active":false,"active_rules_fastly_block_count":0,"active_rules_fastly_log_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_score_count":0,"active_rules_trustwave_block_count":0,"active_rules_trustwave_log_count":0,"allowed_http_versions":"HTTP/1.0 - HTTP/1.1 HTTP/2","allowed_methods":"GET HEAD POST OPTIONS PUT PATCH DELETE","allowed_request_content_type":"application/x-www-form-urlencoded|multipart/form-data|text/xml|application/xml|application/soap+xml|application/x-amf|application/json|application/octet-stream|application/csp-report|application/xss-auditor-report|text/plain","allowed_request_content_type_charset":"utf-8|iso-8859-1|iso-8859-15|windows-1252","arg_name_length":100,"arg_length":400,"combined_file_sizes":10000000,"comment":null,"created_at":"2020-07-02T20:05:34Z","critical_anomaly_score":5,"crs_validate_utf8_encoding":false,"deployed_at":null,"error":null,"error_anomaly_score":4,"high_risk_country_codes":"","http_violation_score_threshold":999,"inbound_anomaly_score_threshold":999,"last_deployment_status":null,"lfi_score_threshold":999,"locked":false,"max_file_size":10000000,"max_num_args":255,"notice_anomaly_score":2,"number":1,"paranoia_level":1,"php_injection_score_threshold":999,"rce_score_threshold":999,"restricted_extensions":".asa/ + body: '{"data":[{"id":"6oTvCXk15i1OiTbir1LNYn","type":"waf_firewall_version","attributes":{"active":false,"active_rules_fastly_block_count":0,"active_rules_fastly_log_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_score_count":0,"active_rules_trustwave_block_count":0,"active_rules_trustwave_log_count":0,"allowed_http_versions":"HTTP/1.0 + HTTP/1.1 HTTP/2","allowed_methods":"GET HEAD POST OPTIONS PUT PATCH DELETE","allowed_request_content_type":"application/x-www-form-urlencoded|multipart/form-data|text/xml|application/xml|application/soap+xml|application/x-amf|application/json|application/octet-stream|application/csp-report|application/xss-auditor-report|text/plain","allowed_request_content_type_charset":"utf-8|iso-8859-1|iso-8859-15|windows-1252","arg_name_length":100,"arg_length":400,"combined_file_sizes":10000000,"comment":null,"created_at":"2020-07-02T20:20:57Z","critical_anomaly_score":5,"crs_validate_utf8_encoding":false,"deployed_at":null,"error":null,"error_anomaly_score":4,"high_risk_country_codes":"","http_violation_score_threshold":999,"inbound_anomaly_score_threshold":999,"last_deployment_status":null,"lfi_score_threshold":999,"locked":false,"max_file_size":10000000,"max_num_args":255,"notice_anomaly_score":2,"number":1,"paranoia_level":1,"php_injection_score_threshold":999,"rce_score_threshold":999,"restricted_extensions":".asa/ .asax/ .ascx/ .axd/ .backup/ .bak/ .bat/ .cdx/ .cer/ .cfg/ .cmd/ .com/ .config/ .conf/ .cs/ .csproj/ .csr/ .dat/ .db/ .dbf/ .dll/ .dos/ .htr/ .htw/ .ida/ .idc/ .idq/ .inc/ .ini/ .key/ .licx/ .lnk/ .log/ .mdb/ .old/ .pass/ .pdb/ .pol/ .printer/ .pwd/ .resources/ .resx/ .sql/ .sys/ .vb/ .vbs/ .vbproj/ .vsdisco/ .webinfo/ .xsd/ .xsx/","restricted_headers":"/proxy/ /lock-token/ /content-range/ /translate/ - /if/","rfi_score_threshold":999,"session_fixation_score_threshold":999,"sql_injection_score_threshold":999,"total_arg_length":6400,"updated_at":"2020-07-02T20:05:34Z","warning_anomaly_score":3,"xss_score_threshold":999}}],"links":{"last":"https://api.fastly.com/waf/firewalls/3x9V8lGE6mhxxVIr15QeRo/versions?page[number]=1\u0026page[size]=100","first":"https://api.fastly.com/waf/firewalls/3x9V8lGE6mhxxVIr15QeRo/versions?page[number]=1\u0026page[size]=100"},"meta":{"current_page":1,"per_page":100,"record_count":1,"total_pages":1}}' + /if/","rfi_score_threshold":999,"session_fixation_score_threshold":999,"sql_injection_score_threshold":999,"total_arg_length":6400,"updated_at":"2020-07-02T20:20:57Z","warning_anomaly_score":3,"xss_score_threshold":999}}],"links":{"last":"https://api.fastly.com/waf/firewalls/5oX1X8cVEBpEXg6PsNSTXA/versions?page[number]=1\u0026page[size]=100","first":"https://api.fastly.com/waf/firewalls/5oX1X8cVEBpEXg6PsNSTXA/versions?page[number]=1\u0026page[size]=100"},"meta":{"current_page":1,"per_page":100,"record_count":1,"total_pages":1}}' headers: Accept-Ranges: - bytes @@ -31,7 +31,7 @@ interactions: Content-Type: - application/vnd.api+json Date: - - Thu, 02 Jul 2020 20:05:35 GMT + - Thu, 02 Jul 2020 20:20:58 GMT Status: - 200 OK Strict-Transport-Security: @@ -46,9 +46,9 @@ interactions: X-Content-Type-Options: - nosniff X-Served-By: - - cache-control-slwdc9036-CONTROL-SLWDC, cache-lcy19251-LCY + - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19265-LCY X-Timer: - - S1593720335.083414,VS0,VE401 + - S1593721258.886149,VS0,VE163 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/waf_versions/list_all.yaml b/fastly/fixtures/waf_versions/list_all.yaml index 1141c2ee2..e7b4928a1 100644 --- a/fastly/fixtures/waf_versions/list_all.yaml +++ b/fastly/fixtures/waf_versions/list_all.yaml @@ -7,21 +7,21 @@ interactions: headers: User-Agent: - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) - url: https://api.fastly.com/waf/firewalls/3x9V8lGE6mhxxVIr15QeRo/versions?page%5Bnumber%5D=1&page%5Bsize%5D=100 + url: https://api.fastly.com/waf/firewalls/5oX1X8cVEBpEXg6PsNSTXA/versions?page%5Bnumber%5D=1&page%5Bsize%5D=100 method: GET response: - body: '{"data":[{"id":"6Kz7TD05ACSKRCkV3KGIC9","type":"waf_firewall_version","attributes":{"active":false,"active_rules_fastly_block_count":0,"active_rules_fastly_log_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_score_count":0,"active_rules_trustwave_block_count":0,"active_rules_trustwave_log_count":0,"allowed_http_versions":"HTTP/1.0 + body: '{"data":[{"id":"6q3TBLBKV00lMIsp0DC3wq","type":"waf_firewall_version","attributes":{"active":false,"active_rules_fastly_block_count":0,"active_rules_fastly_log_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_score_count":0,"active_rules_trustwave_block_count":0,"active_rules_trustwave_log_count":0,"allowed_http_versions":"HTTP/1.0 HTTP/1.1","allowed_methods":"GET HEAD POST","allowed_request_content_type":"application/x-www-form-urlencoded|multipart/form-data|text/xml|application/xml","allowed_request_content_type_charset":"utf-8|iso-8859-1","arg_name_length":200,"arg_length":800,"combined_file_sizes":20000000,"comment":"my - comment","created_at":"2020-07-02T20:05:35Z","critical_anomaly_score":12,"crs_validate_utf8_encoding":true,"deployed_at":null,"error":null,"error_anomaly_score":10,"high_risk_country_codes":"gb","http_violation_score_threshold":20,"inbound_anomaly_score_threshold":20,"last_deployment_status":null,"lfi_score_threshold":20,"locked":true,"max_file_size":20000000,"max_num_args":510,"notice_anomaly_score":8,"number":2,"paranoia_level":2,"php_injection_score_threshold":20,"rce_score_threshold":20,"restricted_extensions":".asa/ + comment","created_at":"2020-07-02T20:20:58Z","critical_anomaly_score":12,"crs_validate_utf8_encoding":true,"deployed_at":null,"error":null,"error_anomaly_score":10,"high_risk_country_codes":"gb","http_violation_score_threshold":20,"inbound_anomaly_score_threshold":20,"last_deployment_status":null,"lfi_score_threshold":20,"locked":true,"max_file_size":20000000,"max_num_args":510,"notice_anomaly_score":8,"number":2,"paranoia_level":2,"php_injection_score_threshold":20,"rce_score_threshold":20,"restricted_extensions":".asa/ .asax/ .ascx/ .axd/ .backup/ .bak/ .bat/ .cdx/ .cer/ .cfg/ .cmd/ .com/","restricted_headers":"/proxy/ - /lock-token/","rfi_score_threshold":20,"session_fixation_score_threshold":20,"sql_injection_score_threshold":20,"total_arg_length":12800,"updated_at":"2020-07-02T20:05:37Z","warning_anomaly_score":20,"xss_score_threshold":20}},{"id":"7WfLA42gWjnACmwwTJYylj","type":"waf_firewall_version","attributes":{"active":true,"active_rules_fastly_block_count":0,"active_rules_fastly_log_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_score_count":0,"active_rules_trustwave_block_count":0,"active_rules_trustwave_log_count":0,"allowed_http_versions":"HTTP/1.0 - HTTP/1.1 HTTP/2","allowed_methods":"GET HEAD POST OPTIONS PUT PATCH DELETE","allowed_request_content_type":"application/x-www-form-urlencoded|multipart/form-data|text/xml|application/xml|application/soap+xml|application/x-amf|application/json|application/octet-stream|application/csp-report|application/xss-auditor-report|text/plain","allowed_request_content_type_charset":"utf-8|iso-8859-1|iso-8859-15|windows-1252","arg_name_length":100,"arg_length":400,"combined_file_sizes":10000000,"comment":null,"created_at":"2020-07-02T20:05:34Z","critical_anomaly_score":5,"crs_validate_utf8_encoding":false,"deployed_at":"2020-07-02T20:05:36Z","error":null,"error_anomaly_score":4,"high_risk_country_codes":"","http_violation_score_threshold":999,"inbound_anomaly_score_threshold":999,"last_deployment_status":"completed","lfi_score_threshold":999,"locked":true,"max_file_size":10000000,"max_num_args":255,"notice_anomaly_score":2,"number":1,"paranoia_level":1,"php_injection_score_threshold":999,"rce_score_threshold":999,"restricted_extensions":".asa/ + /lock-token/","rfi_score_threshold":20,"session_fixation_score_threshold":20,"sql_injection_score_threshold":20,"total_arg_length":12800,"updated_at":"2020-07-02T20:20:59Z","warning_anomaly_score":20,"xss_score_threshold":20}},{"id":"6oTvCXk15i1OiTbir1LNYn","type":"waf_firewall_version","attributes":{"active":true,"active_rules_fastly_block_count":0,"active_rules_fastly_log_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_score_count":0,"active_rules_trustwave_block_count":0,"active_rules_trustwave_log_count":0,"allowed_http_versions":"HTTP/1.0 + HTTP/1.1 HTTP/2","allowed_methods":"GET HEAD POST OPTIONS PUT PATCH DELETE","allowed_request_content_type":"application/x-www-form-urlencoded|multipart/form-data|text/xml|application/xml|application/soap+xml|application/x-amf|application/json|application/octet-stream|application/csp-report|application/xss-auditor-report|text/plain","allowed_request_content_type_charset":"utf-8|iso-8859-1|iso-8859-15|windows-1252","arg_name_length":100,"arg_length":400,"combined_file_sizes":10000000,"comment":null,"created_at":"2020-07-02T20:20:57Z","critical_anomaly_score":5,"crs_validate_utf8_encoding":false,"deployed_at":"2020-07-02T20:20:58Z","error":null,"error_anomaly_score":4,"high_risk_country_codes":"","http_violation_score_threshold":999,"inbound_anomaly_score_threshold":999,"last_deployment_status":"completed","lfi_score_threshold":999,"locked":true,"max_file_size":10000000,"max_num_args":255,"notice_anomaly_score":2,"number":1,"paranoia_level":1,"php_injection_score_threshold":999,"rce_score_threshold":999,"restricted_extensions":".asa/ .asax/ .ascx/ .axd/ .backup/ .bak/ .bat/ .cdx/ .cer/ .cfg/ .cmd/ .com/ .config/ .conf/ .cs/ .csproj/ .csr/ .dat/ .db/ .dbf/ .dll/ .dos/ .htr/ .htw/ .ida/ .idc/ .idq/ .inc/ .ini/ .key/ .licx/ .lnk/ .log/ .mdb/ .old/ .pass/ .pdb/ .pol/ .printer/ .pwd/ .resources/ .resx/ .sql/ .sys/ .vb/ .vbs/ .vbproj/ .vsdisco/ .webinfo/ .xsd/ .xsx/","restricted_headers":"/proxy/ /lock-token/ /content-range/ /translate/ - /if/","rfi_score_threshold":999,"session_fixation_score_threshold":999,"sql_injection_score_threshold":999,"total_arg_length":6400,"updated_at":"2020-07-02T20:05:36Z","warning_anomaly_score":3,"xss_score_threshold":999}}],"links":{"last":"https://api.fastly.com/waf/firewalls/3x9V8lGE6mhxxVIr15QeRo/versions?page[number]=1\u0026page[size]=100","first":"https://api.fastly.com/waf/firewalls/3x9V8lGE6mhxxVIr15QeRo/versions?page[number]=1\u0026page[size]=100"},"meta":{"current_page":1,"per_page":100,"record_count":2,"total_pages":1}}' + /if/","rfi_score_threshold":999,"session_fixation_score_threshold":999,"sql_injection_score_threshold":999,"total_arg_length":6400,"updated_at":"2020-07-02T20:20:58Z","warning_anomaly_score":3,"xss_score_threshold":999}}],"links":{"last":"https://api.fastly.com/waf/firewalls/5oX1X8cVEBpEXg6PsNSTXA/versions?page[number]=1\u0026page[size]=100","first":"https://api.fastly.com/waf/firewalls/5oX1X8cVEBpEXg6PsNSTXA/versions?page[number]=1\u0026page[size]=100"},"meta":{"current_page":1,"per_page":100,"record_count":2,"total_pages":1}}' headers: Accept-Ranges: - bytes @@ -35,7 +35,7 @@ interactions: Content-Type: - application/vnd.api+json Date: - - Thu, 02 Jul 2020 20:05:37 GMT + - Thu, 02 Jul 2020 20:21:00 GMT Status: - 200 OK Strict-Transport-Security: @@ -50,9 +50,9 @@ interactions: X-Content-Type-Options: - nosniff X-Served-By: - - cache-control-slwdc9035-CONTROL-SLWDC, cache-lcy19251-LCY + - cache-control-slwdc9036-CONTROL-SLWDC, cache-lcy19265-LCY X-Timer: - - S1593720337.368966,VS0,VE388 + - S1593721260.916258,VS0,VE392 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/waf_versions/lock.yaml b/fastly/fixtures/waf_versions/lock.yaml index 3cdfb600a..f1cba3dc0 100644 --- a/fastly/fixtures/waf_versions/lock.yaml +++ b/fastly/fixtures/waf_versions/lock.yaml @@ -12,14 +12,14 @@ interactions: - application/vnd.api+json User-Agent: - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) - url: https://api.fastly.com/waf/firewalls/3x9V8lGE6mhxxVIr15QeRo/versions/2 + url: https://api.fastly.com/waf/firewalls/5oX1X8cVEBpEXg6PsNSTXA/versions/2 method: PATCH response: - body: '{"data":{"id":"6Kz7TD05ACSKRCkV3KGIC9","type":"waf_firewall_version","attributes":{"active":false,"active_rules_fastly_block_count":0,"active_rules_fastly_log_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_score_count":0,"active_rules_trustwave_block_count":0,"active_rules_trustwave_log_count":0,"allowed_http_versions":"HTTP/1.0 + body: '{"data":{"id":"6q3TBLBKV00lMIsp0DC3wq","type":"waf_firewall_version","attributes":{"active":false,"active_rules_fastly_block_count":0,"active_rules_fastly_log_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_score_count":0,"active_rules_trustwave_block_count":0,"active_rules_trustwave_log_count":0,"allowed_http_versions":"HTTP/1.0 HTTP/1.1","allowed_methods":"GET HEAD POST","allowed_request_content_type":"application/x-www-form-urlencoded|multipart/form-data|text/xml|application/xml","allowed_request_content_type_charset":"utf-8|iso-8859-1","arg_name_length":200,"arg_length":800,"combined_file_sizes":20000000,"comment":"my - comment","created_at":"2020-07-02T20:05:35Z","critical_anomaly_score":12,"crs_validate_utf8_encoding":true,"deployed_at":null,"error":null,"error_anomaly_score":10,"high_risk_country_codes":"gb","http_violation_score_threshold":20,"inbound_anomaly_score_threshold":20,"last_deployment_status":null,"lfi_score_threshold":20,"locked":true,"max_file_size":20000000,"max_num_args":510,"notice_anomaly_score":8,"number":2,"paranoia_level":2,"php_injection_score_threshold":20,"rce_score_threshold":20,"restricted_extensions":".asa/ + comment","created_at":"2020-07-02T20:20:58Z","critical_anomaly_score":12,"crs_validate_utf8_encoding":true,"deployed_at":null,"error":null,"error_anomaly_score":10,"high_risk_country_codes":"gb","http_violation_score_threshold":20,"inbound_anomaly_score_threshold":20,"last_deployment_status":null,"lfi_score_threshold":20,"locked":true,"max_file_size":20000000,"max_num_args":510,"notice_anomaly_score":8,"number":2,"paranoia_level":2,"php_injection_score_threshold":20,"rce_score_threshold":20,"restricted_extensions":".asa/ .asax/ .ascx/ .axd/ .backup/ .bak/ .bat/ .cdx/ .cer/ .cfg/ .cmd/ .com/","restricted_headers":"/proxy/ - /lock-token/","rfi_score_threshold":20,"session_fixation_score_threshold":20,"sql_injection_score_threshold":20,"total_arg_length":12800,"updated_at":"2020-07-02T20:05:37Z","warning_anomaly_score":20,"xss_score_threshold":20},"relationships":{"waf_firewall":{"data":{"id":"3x9V8lGE6mhxxVIr15QeRo","type":"waf_firewall"}}}}}' + /lock-token/","rfi_score_threshold":20,"session_fixation_score_threshold":20,"sql_injection_score_threshold":20,"total_arg_length":12800,"updated_at":"2020-07-02T20:20:59Z","warning_anomaly_score":20,"xss_score_threshold":20},"relationships":{"waf_firewall":{"data":{"id":"5oX1X8cVEBpEXg6PsNSTXA","type":"waf_firewall"}}}}}' headers: Accept-Ranges: - bytes @@ -29,7 +29,7 @@ interactions: Content-Type: - application/vnd.api+json Date: - - Thu, 02 Jul 2020 20:05:37 GMT + - Thu, 02 Jul 2020 20:20:59 GMT Status: - 200 OK Strict-Transport-Security: @@ -44,9 +44,9 @@ interactions: X-Content-Type-Options: - nosniff X-Served-By: - - cache-control-slwdc9036-CONTROL-SLWDC, cache-lcy19251-LCY + - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19265-LCY X-Timer: - - S1593720337.989253,VS0,VE181 + - S1593721260.560847,VS0,VE167 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/waf_versions/logging/create.yaml b/fastly/fixtures/waf_versions/logging/create.yaml index 298698e03..57cef883b 100644 --- a/fastly/fixtures/waf_versions/logging/create.yaml +++ b/fastly/fixtures/waf_versions/logging/create.yaml @@ -2,10 +2,10 @@ version: 1 interactions: - request: - body: Service=5mAR0wHKpNJjOqc65YeDqI&Version=2&address=example.com&format=format&format_version=2&hostname=example.com&message_type=classic&name=test-syslog&port=1234&token=abcd1234 + body: Service=52szbbqIWi1L5bUd4EBKkX&Version=2&address=example.com&format=format&format_version=2&hostname=example.com&message_type=classic&name=test-syslog&port=1234&token=abcd1234 form: Service: - - 5mAR0wHKpNJjOqc65YeDqI + - 52szbbqIWi1L5bUd4EBKkX Version: - "2" address: @@ -29,10 +29,10 @@ interactions: - application/x-www-form-urlencoded User-Agent: - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) - url: https://api.fastly.com/service/5mAR0wHKpNJjOqc65YeDqI/version/2/logging/syslog + url: https://api.fastly.com/service/52szbbqIWi1L5bUd4EBKkX/version/2/logging/syslog method: POST response: - body: '{"address":"example.com","format":"format","format_version":"2","hostname":"example.com","message_type":"classic","name":"test-syslog","port":"1234","token":"abcd1234","service_id":"5mAR0wHKpNJjOqc65YeDqI","version":"2","updated_at":"2020-07-02T20:05:32Z","deleted_at":null,"created_at":"2020-07-02T20:05:32Z","tls_client_cert":null,"placement":null,"tls_ca_cert":null,"tls_hostname":null,"tls_client_key":null,"ipv4":null,"response_condition":"","use_tls":"0","public_key":null}' + body: '{"address":"example.com","format":"format","format_version":"2","hostname":"example.com","message_type":"classic","name":"test-syslog","port":"1234","token":"abcd1234","service_id":"52szbbqIWi1L5bUd4EBKkX","version":"2","tls_hostname":null,"tls_ca_cert":null,"use_tls":"0","tls_client_key":null,"public_key":null,"deleted_at":null,"placement":null,"tls_client_cert":null,"ipv4":null,"created_at":"2020-07-02T20:20:55Z","response_condition":"","updated_at":"2020-07-02T20:20:55Z"}' headers: Accept-Ranges: - bytes @@ -42,9 +42,9 @@ interactions: Content-Type: - application/json Date: - - Thu, 02 Jul 2020 20:05:33 GMT + - Thu, 02 Jul 2020 20:20:55 GMT Fastly-Ratelimit-Remaining: - - "979" + - "952" Fastly-Ratelimit-Reset: - "1593723600" Status: @@ -61,9 +61,9 @@ interactions: X-Cache-Hits: - 0, 0 X-Served-By: - - cache-control-slwdc9036-CONTROL-SLWDC, cache-lcy19251-LCY + - cache-control-slwdc9035-CONTROL-SLWDC, cache-lcy19265-LCY X-Timer: - - S1593720333.715815,VS0,VE413 + - S1593721255.159701,VS0,VE719 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/waf_versions/logging/delete.yaml b/fastly/fixtures/waf_versions/logging/delete.yaml index 3173dcebd..cc9646daa 100644 --- a/fastly/fixtures/waf_versions/logging/delete.yaml +++ b/fastly/fixtures/waf_versions/logging/delete.yaml @@ -7,7 +7,7 @@ interactions: headers: User-Agent: - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) - url: https://api.fastly.com/service/5mAR0wHKpNJjOqc65YeDqI/version/2/logging/syslog/test-syslog + url: https://api.fastly.com/service/52szbbqIWi1L5bUd4EBKkX/version/2/logging/syslog/test-syslog method: DELETE response: body: '{"status":"ok"}' @@ -20,9 +20,9 @@ interactions: Content-Type: - application/json Date: - - Thu, 02 Jul 2020 20:05:39 GMT + - Thu, 02 Jul 2020 20:21:02 GMT Fastly-Ratelimit-Remaining: - - "974" + - "947" Fastly-Ratelimit-Reset: - "1593723600" Status: @@ -39,9 +39,9 @@ interactions: X-Cache-Hits: - 0, 0 X-Served-By: - - cache-control-slwdc9036-CONTROL-SLWDC, cache-lcy19251-LCY + - cache-control-slwdc9035-CONTROL-SLWDC, cache-lcy19265-LCY X-Timer: - - S1593720340.556496,VS0,VE257 + - S1593721262.118224,VS0,VE245 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/waf_versions/response_object/create.yaml b/fastly/fixtures/waf_versions/response_object/create.yaml index 65e98893f..de5614f6f 100644 --- a/fastly/fixtures/waf_versions/response_object/create.yaml +++ b/fastly/fixtures/waf_versions/response_object/create.yaml @@ -2,10 +2,10 @@ version: 1 interactions: - request: - body: Service=5mAR0wHKpNJjOqc65YeDqI&Version=2&name=WAf_Response&status=403 + body: Service=52szbbqIWi1L5bUd4EBKkX&Version=2&name=WAf_Response&status=403 form: Service: - - 5mAR0wHKpNJjOqc65YeDqI + - 52szbbqIWi1L5bUd4EBKkX Version: - "2" name: @@ -17,10 +17,10 @@ interactions: - application/x-www-form-urlencoded User-Agent: - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) - url: https://api.fastly.com/service/5mAR0wHKpNJjOqc65YeDqI/version/2/response_object + url: https://api.fastly.com/service/52szbbqIWi1L5bUd4EBKkX/version/2/response_object method: POST response: - body: '{"name":"WAf_Response","status":"403","service_id":"5mAR0wHKpNJjOqc65YeDqI","version":"2","response":"ok","updated_at":"2020-07-02T20:05:33Z","created_at":"2020-07-02T20:05:33Z","cache_condition":"","request_condition":"","deleted_at":null,"content_type":null,"content":null}' + body: '{"name":"WAf_Response","status":"403","service_id":"52szbbqIWi1L5bUd4EBKkX","version":"2","content":null,"response":"ok","updated_at":"2020-07-02T20:20:56Z","cache_condition":"","created_at":"2020-07-02T20:20:56Z","request_condition":"","deleted_at":null,"content_type":null}' headers: Accept-Ranges: - bytes @@ -30,9 +30,9 @@ interactions: Content-Type: - application/json Date: - - Thu, 02 Jul 2020 20:05:33 GMT + - Thu, 02 Jul 2020 20:20:56 GMT Fastly-Ratelimit-Remaining: - - "977" + - "950" Fastly-Ratelimit-Reset: - "1593723600" Status: @@ -49,9 +49,9 @@ interactions: X-Cache-Hits: - 0, 0 X-Served-By: - - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19251-LCY + - cache-control-slwdc9035-CONTROL-SLWDC, cache-lcy19265-LCY X-Timer: - - S1593720334.609439,VS0,VE228 + - S1593721256.343174,VS0,VE213 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/waf_versions/response_object/delete.yaml b/fastly/fixtures/waf_versions/response_object/delete.yaml index 955f00519..a2d8a9249 100644 --- a/fastly/fixtures/waf_versions/response_object/delete.yaml +++ b/fastly/fixtures/waf_versions/response_object/delete.yaml @@ -7,7 +7,7 @@ interactions: headers: User-Agent: - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) - url: https://api.fastly.com/service/5mAR0wHKpNJjOqc65YeDqI/version/2/response_object/WAf_Response + url: https://api.fastly.com/service/52szbbqIWi1L5bUd4EBKkX/version/2/response_object/WAf_Response method: DELETE response: body: '{"status":"ok"}' @@ -20,9 +20,9 @@ interactions: Content-Type: - application/json Date: - - Thu, 02 Jul 2020 20:05:38 GMT + - Thu, 02 Jul 2020 20:21:01 GMT Fastly-Ratelimit-Remaining: - - "976" + - "949" Fastly-Ratelimit-Reset: - "1593723600" Status: @@ -39,9 +39,9 @@ interactions: X-Cache-Hits: - 0, 0 X-Served-By: - - cache-control-slwdc9035-CONTROL-SLWDC, cache-lcy19251-LCY + - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19265-LCY X-Timer: - - S1593720339.719207,VS0,VE248 + - S1593721261.253414,VS0,VE268 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/waf_versions/service/create.yaml b/fastly/fixtures/waf_versions/service/create.yaml index b8ab2a9ff..f966ab99a 100644 --- a/fastly/fixtures/waf_versions/service/create.yaml +++ b/fastly/fixtures/waf_versions/service/create.yaml @@ -18,7 +18,7 @@ interactions: url: https://api.fastly.com/service method: POST response: - body: '{"customer_id":"WpqWFjTA4lk2N1g0GY2HH","comment":"go-fastly client test","name":"test_service_service3","type":"vcl","versions":[{"testing":false,"deleted_at":null,"service_id":"5mAR0wHKpNJjOqc65YeDqI","comment":"","created_at":"2020-07-02T20:05:32Z","updated_at":"2020-07-02T20:05:32Z","active":false,"locked":false,"number":1,"deployed":false,"staging":false}],"publish_key":"","created_at":"2020-07-02T20:05:32Z","deleted_at":null,"id":"5mAR0wHKpNJjOqc65YeDqI","updated_at":"2020-07-02T20:05:32Z"}' + body: '{"customer_id":"WpqWFjTA4lk2N1g0GY2HH","comment":"go-fastly client test","name":"test_service_service3","type":"vcl","created_at":"2020-07-02T20:20:54Z","id":"52szbbqIWi1L5bUd4EBKkX","versions":[{"comment":"","deployed":false,"staging":false,"service_id":"52szbbqIWi1L5bUd4EBKkX","locked":false,"deleted_at":null,"updated_at":"2020-07-02T20:20:54Z","created_at":"2020-07-02T20:20:54Z","number":1,"active":false,"testing":false}],"publish_key":"","deleted_at":null,"updated_at":"2020-07-02T20:20:54Z"}' headers: Accept-Ranges: - bytes @@ -28,9 +28,9 @@ interactions: Content-Type: - application/json Date: - - Thu, 02 Jul 2020 20:05:32 GMT + - Thu, 02 Jul 2020 20:20:54 GMT Fastly-Ratelimit-Remaining: - - "981" + - "954" Fastly-Ratelimit-Reset: - "1593723600" Status: @@ -47,9 +47,9 @@ interactions: X-Cache-Hits: - 0, 0 X-Served-By: - - cache-control-slwdc9035-CONTROL-SLWDC, cache-lcy19251-LCY + - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19265-LCY X-Timer: - - S1593720332.921745,VS0,VE229 + - S1593721254.141906,VS0,VE474 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/waf_versions/service/delete.yaml b/fastly/fixtures/waf_versions/service/delete.yaml index 8026e78ae..1fb1aa4e3 100644 --- a/fastly/fixtures/waf_versions/service/delete.yaml +++ b/fastly/fixtures/waf_versions/service/delete.yaml @@ -7,7 +7,7 @@ interactions: headers: User-Agent: - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) - url: https://api.fastly.com/service/5mAR0wHKpNJjOqc65YeDqI + url: https://api.fastly.com/service/52szbbqIWi1L5bUd4EBKkX method: DELETE response: body: '{"status":"ok"}' @@ -20,9 +20,9 @@ interactions: Content-Type: - application/json Date: - - Thu, 02 Jul 2020 20:05:40 GMT + - Thu, 02 Jul 2020 20:21:02 GMT Fastly-Ratelimit-Remaining: - - "973" + - "946" Fastly-Ratelimit-Reset: - "1593723600" Status: @@ -39,9 +39,9 @@ interactions: X-Cache-Hits: - 0, 0 X-Served-By: - - cache-control-slwdc9035-CONTROL-SLWDC, cache-lcy19251-LCY + - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19265-LCY X-Timer: - - S1593720340.000730,VS0,VE243 + - S1593721263.555733,VS0,VE231 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/waf_versions/service/version.yaml b/fastly/fixtures/waf_versions/service/version.yaml index 192b7310c..40ac06603 100644 --- a/fastly/fixtures/waf_versions/service/version.yaml +++ b/fastly/fixtures/waf_versions/service/version.yaml @@ -2,19 +2,19 @@ version: 1 interactions: - request: - body: Service=5mAR0wHKpNJjOqc65YeDqI + body: Service=52szbbqIWi1L5bUd4EBKkX form: Service: - - 5mAR0wHKpNJjOqc65YeDqI + - 52szbbqIWi1L5bUd4EBKkX headers: Content-Type: - application/x-www-form-urlencoded User-Agent: - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) - url: https://api.fastly.com/service/5mAR0wHKpNJjOqc65YeDqI/version + url: https://api.fastly.com/service/52szbbqIWi1L5bUd4EBKkX/version method: POST response: - body: '{"service_id":"5mAR0wHKpNJjOqc65YeDqI","number":2}' + body: '{"service_id":"52szbbqIWi1L5bUd4EBKkX","number":2}' headers: Accept-Ranges: - bytes @@ -24,9 +24,9 @@ interactions: Content-Type: - application/json Date: - - Thu, 02 Jul 2020 20:05:32 GMT + - Thu, 02 Jul 2020 20:20:55 GMT Fastly-Ratelimit-Remaining: - - "980" + - "953" Fastly-Ratelimit-Reset: - "1593723600" Status: @@ -43,9 +43,9 @@ interactions: X-Cache-Hits: - 0, 0 X-Served-By: - - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19251-LCY + - cache-control-slwdc9036-CONTROL-SLWDC, cache-lcy19265-LCY X-Timer: - - S1593720332.316214,VS0,VE255 + - S1593721255.771073,VS0,VE244 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/waf_versions/update.yaml b/fastly/fixtures/waf_versions/update.yaml index e6a96a58e..69127ca74 100644 --- a/fastly/fixtures/waf_versions/update.yaml +++ b/fastly/fixtures/waf_versions/update.yaml @@ -3,7 +3,7 @@ version: 1 interactions: - request: body: | - {"data":{"type":"waf_firewall_version","id":"6Kz7TD05ACSKRCkV3KGIC9","attributes":{"allowed_http_versions":"HTTP/1.0 HTTP/1.1","allowed_methods":"GET HEAD POST","allowed_request_content_type":"application/x-www-form-urlencoded|multipart/form-data|text/xml|application/xml","allowed_request_content_type_charset":"utf-8|iso-8859-1","arg_length":800,"arg_name_length":200,"combined_file_sizes":20000000,"comment":"my comment","critical_anomaly_score":12,"crs_validate_utf8_encoding":true,"error_anomaly_score":10,"high_risk_country_codes":"gb","http_violation_score_threshold":20,"inbound_anomaly_score_threshold":20,"lfi_score_threshold":20,"max_file_size":20000000,"max_num_args":510,"notice_anomaly_score":8,"paranoia_level":2,"php_injection_score_threshold":20,"rce_score_threshold":20,"restricted_extensions":".asa/ .asax/ .ascx/ .axd/ .backup/ .bak/ .bat/ .cdx/ .cer/ .cfg/ .cmd/ .com/","restricted_headers":"/proxy/ /lock-token/","rfi_score_threshold":20,"session_fixation_score_threshold":20,"sql_injection_score_threshold":20,"total_arg_length":12800,"warning_anomaly_score":20,"xss_score_threshold":20}}} + {"data":{"type":"waf_firewall_version","id":"6q3TBLBKV00lMIsp0DC3wq","attributes":{"allowed_http_versions":"HTTP/1.0 HTTP/1.1","allowed_methods":"GET HEAD POST","allowed_request_content_type":"application/x-www-form-urlencoded|multipart/form-data|text/xml|application/xml","allowed_request_content_type_charset":"utf-8|iso-8859-1","arg_length":800,"arg_name_length":200,"combined_file_sizes":20000000,"comment":"my comment","critical_anomaly_score":12,"crs_validate_utf8_encoding":true,"error_anomaly_score":10,"high_risk_country_codes":"gb","http_violation_score_threshold":20,"inbound_anomaly_score_threshold":20,"lfi_score_threshold":20,"max_file_size":20000000,"max_num_args":510,"notice_anomaly_score":8,"paranoia_level":2,"php_injection_score_threshold":20,"rce_score_threshold":20,"restricted_extensions":".asa/ .asax/ .ascx/ .axd/ .backup/ .bak/ .bat/ .cdx/ .cer/ .cfg/ .cmd/ .com/","restricted_headers":"/proxy/ /lock-token/","rfi_score_threshold":20,"session_fixation_score_threshold":20,"sql_injection_score_threshold":20,"total_arg_length":12800,"warning_anomaly_score":20,"xss_score_threshold":20}}} form: {} headers: Accept: @@ -12,14 +12,14 @@ interactions: - application/vnd.api+json User-Agent: - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) - url: https://api.fastly.com/waf/firewalls/3x9V8lGE6mhxxVIr15QeRo/versions/2 + url: https://api.fastly.com/waf/firewalls/5oX1X8cVEBpEXg6PsNSTXA/versions/2 method: PATCH response: - body: '{"data":{"id":"6Kz7TD05ACSKRCkV3KGIC9","type":"waf_firewall_version","attributes":{"active":false,"active_rules_fastly_block_count":0,"active_rules_fastly_log_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_score_count":0,"active_rules_trustwave_block_count":0,"active_rules_trustwave_log_count":0,"allowed_http_versions":"HTTP/1.0 + body: '{"data":{"id":"6q3TBLBKV00lMIsp0DC3wq","type":"waf_firewall_version","attributes":{"active":false,"active_rules_fastly_block_count":0,"active_rules_fastly_log_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_score_count":0,"active_rules_trustwave_block_count":0,"active_rules_trustwave_log_count":0,"allowed_http_versions":"HTTP/1.0 HTTP/1.1","allowed_methods":"GET HEAD POST","allowed_request_content_type":"application/x-www-form-urlencoded|multipart/form-data|text/xml|application/xml","allowed_request_content_type_charset":"utf-8|iso-8859-1","arg_name_length":200,"arg_length":800,"combined_file_sizes":20000000,"comment":"my - comment","created_at":"2020-07-02T20:05:35Z","critical_anomaly_score":12,"crs_validate_utf8_encoding":true,"deployed_at":null,"error":null,"error_anomaly_score":10,"high_risk_country_codes":"gb","http_violation_score_threshold":20,"inbound_anomaly_score_threshold":20,"last_deployment_status":null,"lfi_score_threshold":20,"locked":false,"max_file_size":20000000,"max_num_args":510,"notice_anomaly_score":8,"number":2,"paranoia_level":2,"php_injection_score_threshold":20,"rce_score_threshold":20,"restricted_extensions":".asa/ + comment","created_at":"2020-07-02T20:20:58Z","critical_anomaly_score":12,"crs_validate_utf8_encoding":true,"deployed_at":null,"error":null,"error_anomaly_score":10,"high_risk_country_codes":"gb","http_violation_score_threshold":20,"inbound_anomaly_score_threshold":20,"last_deployment_status":null,"lfi_score_threshold":20,"locked":false,"max_file_size":20000000,"max_num_args":510,"notice_anomaly_score":8,"number":2,"paranoia_level":2,"php_injection_score_threshold":20,"rce_score_threshold":20,"restricted_extensions":".asa/ .asax/ .ascx/ .axd/ .backup/ .bak/ .bat/ .cdx/ .cer/ .cfg/ .cmd/ .com/","restricted_headers":"/proxy/ - /lock-token/","rfi_score_threshold":20,"session_fixation_score_threshold":20,"sql_injection_score_threshold":20,"total_arg_length":12800,"updated_at":"2020-07-02T20:05:36Z","warning_anomaly_score":20,"xss_score_threshold":20},"relationships":{"waf_firewall":{"data":{"id":"3x9V8lGE6mhxxVIr15QeRo","type":"waf_firewall"}}}}}' + /lock-token/","rfi_score_threshold":20,"session_fixation_score_threshold":20,"sql_injection_score_threshold":20,"total_arg_length":12800,"updated_at":"2020-07-02T20:20:59Z","warning_anomaly_score":20,"xss_score_threshold":20},"relationships":{"waf_firewall":{"data":{"id":"5oX1X8cVEBpEXg6PsNSTXA","type":"waf_firewall"}}}}}' headers: Accept-Ranges: - bytes @@ -29,7 +29,7 @@ interactions: Content-Type: - application/vnd.api+json Date: - - Thu, 02 Jul 2020 20:05:36 GMT + - Thu, 02 Jul 2020 20:20:59 GMT Status: - 200 OK Strict-Transport-Security: @@ -44,9 +44,9 @@ interactions: X-Content-Type-Options: - nosniff X-Served-By: - - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19251-LCY + - cache-control-slwdc9035-CONTROL-SLWDC, cache-lcy19265-LCY X-Timer: - - S1593720337.744107,VS0,VE118 + - S1593721259.289697,VS0,VE140 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/waf_versions/waf/create.yaml b/fastly/fixtures/waf_versions/waf/create.yaml index b49442f45..6b39e8565 100644 --- a/fastly/fixtures/waf_versions/waf/create.yaml +++ b/fastly/fixtures/waf_versions/waf/create.yaml @@ -3,7 +3,7 @@ version: 1 interactions: - request: body: | - {"data":{"type":"waf_firewall","attributes":{"prefetch_condition":"WAF_Prefetch","response":"WAf_Response","service_id":"5mAR0wHKpNJjOqc65YeDqI","service_version_number":"2"}}} + {"data":{"type":"waf_firewall","attributes":{"prefetch_condition":"WAF_Prefetch","response":"WAf_Response","service_id":"52szbbqIWi1L5bUd4EBKkX","service_version_number":"2"}}} form: {} headers: Accept: @@ -15,7 +15,7 @@ interactions: url: https://api.fastly.com/waf/firewalls method: POST response: - body: '{"data":{"id":"3x9V8lGE6mhxxVIr15QeRo","type":"waf_firewall","attributes":{"active_rules_fastly_block_count":0,"active_rules_fastly_log_count":0,"active_rules_fastly_score_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_score_count":0,"active_rules_trustwave_block_count":0,"active_rules_trustwave_log_count":0,"created_at":"2020-07-02T20:05:34Z","disabled":false,"prefetch_condition":"WAF_Prefetch","response":"WAf_Response","service_id":"5mAR0wHKpNJjOqc65YeDqI","service_version_number":2,"updated_at":"2020-07-02T20:05:34Z"}}}' + body: '{"data":{"id":"5oX1X8cVEBpEXg6PsNSTXA","type":"waf_firewall","attributes":{"active_rules_fastly_block_count":0,"active_rules_fastly_log_count":0,"active_rules_fastly_score_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_score_count":0,"active_rules_trustwave_block_count":0,"active_rules_trustwave_log_count":0,"created_at":"2020-07-02T20:20:57Z","disabled":false,"prefetch_condition":"WAF_Prefetch","response":"WAf_Response","service_id":"52szbbqIWi1L5bUd4EBKkX","service_version_number":2,"updated_at":"2020-07-02T20:20:57Z"}}}' headers: Accept-Ranges: - bytes @@ -25,7 +25,7 @@ interactions: Content-Type: - application/vnd.api+json Date: - - Thu, 02 Jul 2020 20:05:34 GMT + - Thu, 02 Jul 2020 20:20:57 GMT Status: - 201 Created Strict-Transport-Security: @@ -40,9 +40,9 @@ interactions: X-Content-Type-Options: - nosniff X-Served-By: - - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19251-LCY + - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19265-LCY X-Timer: - - S1593720334.961963,VS0,VE936 + - S1593721257.721769,VS0,VE968 status: 201 Created code: 201 duration: "" diff --git a/fastly/fixtures/waf_versions/waf/delete.yaml b/fastly/fixtures/waf_versions/waf/delete.yaml index eb56d9718..6824ca11b 100644 --- a/fastly/fixtures/waf_versions/waf/delete.yaml +++ b/fastly/fixtures/waf_versions/waf/delete.yaml @@ -3,7 +3,7 @@ version: 1 interactions: - request: body: | - {"data":{"type":"waf_firewall","id":"3x9V8lGE6mhxxVIr15QeRo","attributes":{"service_version_number":"2"}}} + {"data":{"type":"waf_firewall","id":"5oX1X8cVEBpEXg6PsNSTXA","attributes":{"service_version_number":"2"}}} form: {} headers: Accept: @@ -12,7 +12,7 @@ interactions: - application/vnd.api+json User-Agent: - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) - url: https://api.fastly.com/waf/firewalls/3x9V8lGE6mhxxVIr15QeRo + url: https://api.fastly.com/waf/firewalls/5oX1X8cVEBpEXg6PsNSTXA method: DELETE response: body: "" @@ -21,7 +21,7 @@ interactions: - bytes - bytes Date: - - Thu, 02 Jul 2020 20:05:38 GMT + - Thu, 02 Jul 2020 20:21:01 GMT Status: - 204 No Content Strict-Transport-Security: @@ -36,9 +36,9 @@ interactions: X-Content-Type-Options: - nosniff X-Served-By: - - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19251-LCY + - cache-control-slwdc9035-CONTROL-SLWDC, cache-lcy19265-LCY X-Timer: - - S1593720338.214280,VS0,VE316 + - S1593721261.790412,VS0,VE281 status: 204 No Content code: 204 duration: "" diff --git a/fastly/fixtures/wafs/cleanup.yaml b/fastly/fixtures/wafs/cleanup.yaml index 872905f6a..7f838f4c3 100644 --- a/fastly/fixtures/wafs/cleanup.yaml +++ b/fastly/fixtures/wafs/cleanup.yaml @@ -3,7 +3,7 @@ version: 1 interactions: - request: body: | - {"data":{"type":"waf_firewall","id":"206Rvtz4NQuFifzUpnhUqL","attributes":{"service_version_number":"2"}}} + {"data":{"type":"waf_firewall","id":"1bibBdxQkJYmZsQtR3EmmH","attributes":{"service_version_number":"2"}}} form: {} headers: Accept: @@ -12,7 +12,7 @@ interactions: - application/vnd.api+json User-Agent: - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) - url: https://api.fastly.com/waf/firewalls/206Rvtz4NQuFifzUpnhUqL + url: https://api.fastly.com/waf/firewalls/1bibBdxQkJYmZsQtR3EmmH method: DELETE response: body: '{"errors":[{"title":"Resource not found","detail":"We could not find a @@ -24,7 +24,7 @@ interactions: Content-Type: - application/vnd.api+json Date: - - Wed, 01 Jul 2020 09:40:43 GMT + - Thu, 02 Jul 2020 20:19:42 GMT Status: - 404 Not Found Strict-Transport-Security: @@ -37,9 +37,9 @@ interactions: X-Cache-Hits: - 0, 0 X-Served-By: - - cache-control-slwdc9035-CONTROL-SLWDC, cache-lcy19273-LCY + - cache-control-slwdc9035-CONTROL-SLWDC, cache-lcy19250-LCY X-Timer: - - S1593596443.956301,VS0,VE134 + - S1593721183.681419,VS0,VE135 status: 404 Not Found code: 404 duration: "" diff --git a/fastly/fixtures/wafs/condition/create.yaml b/fastly/fixtures/wafs/condition/create.yaml index 12bfd2bb6..f59dbd61d 100644 --- a/fastly/fixtures/wafs/condition/create.yaml +++ b/fastly/fixtures/wafs/condition/create.yaml @@ -2,10 +2,10 @@ version: 1 interactions: - request: - body: Service=5MlnHT66t9pZgO8XrBEDQl&Version=2&name=WAF_Prefetch&priority=1&statement=req.url~%2B%22index.html%22&type=PREFETCH + body: Service=5n1Tvc6QVHtvZlG109EsyV&Version=2&name=WAF_Prefetch&priority=1&statement=req.url~%2B%22index.html%22&type=PREFETCH form: Service: - - 5MlnHT66t9pZgO8XrBEDQl + - 5n1Tvc6QVHtvZlG109EsyV Version: - "2" name: @@ -21,10 +21,10 @@ interactions: - application/x-www-form-urlencoded User-Agent: - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) - url: https://api.fastly.com/service/5MlnHT66t9pZgO8XrBEDQl/version/2/condition + url: https://api.fastly.com/service/5n1Tvc6QVHtvZlG109EsyV/version/2/condition method: POST response: - body: '{"name":"WAF_Prefetch","priority":"1","statement":"req.url~+\"index.html\"","type":"PREFETCH","service_id":"5MlnHT66t9pZgO8XrBEDQl","version":"2","created_at":"2020-07-01T09:40:37Z","comment":"","updated_at":"2020-07-01T09:40:37Z","deleted_at":null}' + body: '{"name":"WAF_Prefetch","priority":"1","statement":"req.url~+\"index.html\"","type":"PREFETCH","service_id":"5n1Tvc6QVHtvZlG109EsyV","version":"2","comment":"","created_at":"2020-07-02T20:19:36Z","updated_at":"2020-07-02T20:19:36Z","deleted_at":null}' headers: Accept-Ranges: - bytes @@ -34,11 +34,11 @@ interactions: Content-Type: - application/json Date: - - Wed, 01 Jul 2020 09:40:37 GMT + - Thu, 02 Jul 2020 20:19:36 GMT Fastly-Ratelimit-Remaining: - - "979" + - "961" Fastly-Ratelimit-Reset: - - "1593597600" + - "1593723600" Status: - 200 OK Strict-Transport-Security: @@ -53,9 +53,9 @@ interactions: X-Cache-Hits: - 0, 0 X-Served-By: - - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19273-LCY + - cache-control-slwdc9036-CONTROL-SLWDC, cache-lcy19250-LCY X-Timer: - - S1593596437.298159,VS0,VE195 + - S1593721177.726120,VS0,VE188 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/wafs/condition/delete.yaml b/fastly/fixtures/wafs/condition/delete.yaml index 9ebdd909f..cd6b3db18 100644 --- a/fastly/fixtures/wafs/condition/delete.yaml +++ b/fastly/fixtures/wafs/condition/delete.yaml @@ -7,7 +7,7 @@ interactions: headers: User-Agent: - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) - url: https://api.fastly.com/service/5MlnHT66t9pZgO8XrBEDQl/version/2/condition/WAF_Prefetch + url: https://api.fastly.com/service/5n1Tvc6QVHtvZlG109EsyV/version/2/condition/WAF_Prefetch method: DELETE response: body: '{"status":"ok"}' @@ -20,11 +20,11 @@ interactions: Content-Type: - application/json Date: - - Wed, 01 Jul 2020 09:40:44 GMT + - Thu, 02 Jul 2020 20:19:44 GMT Fastly-Ratelimit-Remaining: - - "974" + - "956" Fastly-Ratelimit-Reset: - - "1593597600" + - "1593723600" Status: - 200 OK Strict-Transport-Security: @@ -39,9 +39,9 @@ interactions: X-Cache-Hits: - 0, 0 X-Served-By: - - cache-control-slwdc9035-CONTROL-SLWDC, cache-lcy19273-LCY + - cache-control-slwdc9035-CONTROL-SLWDC, cache-lcy19250-LCY X-Timer: - - S1593596444.150375,VS0,VE223 + - S1593721184.932272,VS0,VE211 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/wafs/create.yaml b/fastly/fixtures/wafs/create.yaml index 1eb88dd77..dfb123173 100644 --- a/fastly/fixtures/wafs/create.yaml +++ b/fastly/fixtures/wafs/create.yaml @@ -3,7 +3,7 @@ version: 1 interactions: - request: body: | - {"data":{"type":"waf_firewall","attributes":{"prefetch_condition":"WAF_Prefetch","response":"WAF_Response","service_id":"5MlnHT66t9pZgO8XrBEDQl","service_version_number":"2"}}} + {"data":{"type":"waf_firewall","attributes":{"prefetch_condition":"WAF_Prefetch","response":"WAF_Response","service_id":"5n1Tvc6QVHtvZlG109EsyV","service_version_number":"2"}}} form: {} headers: Accept: @@ -15,7 +15,7 @@ interactions: url: https://api.fastly.com/waf/firewalls method: POST response: - body: '{"data":{"id":"206Rvtz4NQuFifzUpnhUqL","type":"waf_firewall","attributes":{"active_rules_fastly_block_count":0,"active_rules_fastly_log_count":0,"active_rules_fastly_score_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_score_count":0,"active_rules_trustwave_block_count":0,"active_rules_trustwave_log_count":0,"created_at":"2020-07-01T09:40:39Z","disabled":false,"prefetch_condition":"WAF_Prefetch","response":"WAF_Response","service_id":"5MlnHT66t9pZgO8XrBEDQl","service_version_number":2,"updated_at":"2020-07-01T09:40:39Z"}}}' + body: '{"data":{"id":"1bibBdxQkJYmZsQtR3EmmH","type":"waf_firewall","attributes":{"active_rules_fastly_block_count":0,"active_rules_fastly_log_count":0,"active_rules_fastly_score_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_score_count":0,"active_rules_trustwave_block_count":0,"active_rules_trustwave_log_count":0,"created_at":"2020-07-02T20:19:38Z","disabled":false,"prefetch_condition":"WAF_Prefetch","response":"WAF_Response","service_id":"5n1Tvc6QVHtvZlG109EsyV","service_version_number":2,"updated_at":"2020-07-02T20:19:38Z"}}}' headers: Accept-Ranges: - bytes @@ -25,7 +25,7 @@ interactions: Content-Type: - application/vnd.api+json Date: - - Wed, 01 Jul 2020 09:40:39 GMT + - Thu, 02 Jul 2020 20:19:38 GMT Status: - 201 Created Strict-Transport-Security: @@ -40,9 +40,9 @@ interactions: X-Content-Type-Options: - nosniff X-Served-By: - - cache-control-slwdc9036-CONTROL-SLWDC, cache-lcy19273-LCY + - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19250-LCY X-Timer: - - S1593596438.341101,VS0,VE830 + - S1593721178.801891,VS0,VE944 status: 201 Created code: 201 duration: "" diff --git a/fastly/fixtures/wafs/delete.yaml b/fastly/fixtures/wafs/delete.yaml index fc2966823..bee9ee2a2 100644 --- a/fastly/fixtures/wafs/delete.yaml +++ b/fastly/fixtures/wafs/delete.yaml @@ -3,7 +3,7 @@ version: 1 interactions: - request: body: | - {"data":{"type":"waf_firewall","id":"206Rvtz4NQuFifzUpnhUqL","attributes":{"service_version_number":"2"}}} + {"data":{"type":"waf_firewall","id":"1bibBdxQkJYmZsQtR3EmmH","attributes":{"service_version_number":"2"}}} form: {} headers: Accept: @@ -12,7 +12,7 @@ interactions: - application/vnd.api+json User-Agent: - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) - url: https://api.fastly.com/waf/firewalls/206Rvtz4NQuFifzUpnhUqL + url: https://api.fastly.com/waf/firewalls/1bibBdxQkJYmZsQtR3EmmH method: DELETE response: body: "" @@ -21,7 +21,7 @@ interactions: - bytes - bytes Date: - - Wed, 01 Jul 2020 09:40:42 GMT + - Thu, 02 Jul 2020 20:19:42 GMT Status: - 204 No Content Strict-Transport-Security: @@ -36,9 +36,9 @@ interactions: X-Content-Type-Options: - nosniff X-Served-By: - - cache-control-slwdc9036-CONTROL-SLWDC, cache-lcy19273-LCY + - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19250-LCY X-Timer: - - S1593596443.569625,VS0,VE255 + - S1593721182.281203,VS0,VE280 status: 204 No Content code: 204 duration: "" diff --git a/fastly/fixtures/wafs/deploy.yaml b/fastly/fixtures/wafs/deploy.yaml index f7273b8f9..2cc8f9c4e 100644 --- a/fastly/fixtures/wafs/deploy.yaml +++ b/fastly/fixtures/wafs/deploy.yaml @@ -12,8 +12,8 @@ interactions: - application/vnd.api+json User-Agent: - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) - url: https://api.fastly.com/waf/firewalls/206Rvtz4NQuFifzUpnhUqL/versions/1 - method: POST + url: https://api.fastly.com/waf/firewalls/1bibBdxQkJYmZsQtR3EmmH/versions/1/activate + method: PUT response: body: '{}' headers: @@ -25,7 +25,7 @@ interactions: Content-Type: - application/vnd.api+json Date: - - Wed, 01 Jul 2020 09:40:39 GMT + - Thu, 02 Jul 2020 20:19:39 GMT Status: - 202 Accepted Strict-Transport-Security: @@ -40,9 +40,9 @@ interactions: X-Content-Type-Options: - nosniff X-Served-By: - - cache-control-slwdc9035-CONTROL-SLWDC, cache-lcy19273-LCY + - cache-control-slwdc9036-CONTROL-SLWDC, cache-lcy19250-LCY X-Timer: - - S1593596440.647605,VS0,VE142 + - S1593721179.458398,VS0,VE144 status: 202 Accepted code: 202 duration: "" diff --git a/fastly/fixtures/wafs/disable.yaml b/fastly/fixtures/wafs/disable.yaml index 860b68317..8703926c0 100644 --- a/fastly/fixtures/wafs/disable.yaml +++ b/fastly/fixtures/wafs/disable.yaml @@ -3,7 +3,7 @@ version: 1 interactions: - request: body: | - {"data":{"type":"waf_firewall","id":"206Rvtz4NQuFifzUpnhUqL","attributes":{"disabled":true}}} + {"data":{"type":"waf_firewall","id":"1bibBdxQkJYmZsQtR3EmmH","attributes":{"disabled":true}}} form: {} headers: Accept: @@ -12,10 +12,10 @@ interactions: - application/vnd.api+json User-Agent: - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) - url: https://api.fastly.com/waf/firewalls/206Rvtz4NQuFifzUpnhUqL + url: https://api.fastly.com/waf/firewalls/1bibBdxQkJYmZsQtR3EmmH method: PATCH response: - body: '{"data":{"id":"206Rvtz4NQuFifzUpnhUqL","type":"waf_firewall","attributes":{"active_rules_fastly_block_count":0,"active_rules_fastly_log_count":0,"active_rules_fastly_score_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_score_count":0,"active_rules_trustwave_block_count":0,"active_rules_trustwave_log_count":0,"created_at":"2020-07-01T09:40:39Z","disabled":true,"prefetch_condition":null,"response":null,"service_id":"5MlnHT66t9pZgO8XrBEDQl","service_version_number":null,"updated_at":"2020-07-01T09:40:41Z"}}}' + body: '{"data":{"id":"1bibBdxQkJYmZsQtR3EmmH","type":"waf_firewall","attributes":{"active_rules_fastly_block_count":0,"active_rules_fastly_log_count":0,"active_rules_fastly_score_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_score_count":0,"active_rules_trustwave_block_count":0,"active_rules_trustwave_log_count":0,"created_at":"2020-07-02T20:19:38Z","disabled":true,"prefetch_condition":null,"response":null,"service_id":"5n1Tvc6QVHtvZlG109EsyV","service_version_number":null,"updated_at":"2020-07-02T20:19:41Z"}}}' headers: Accept-Ranges: - bytes @@ -25,7 +25,7 @@ interactions: Content-Type: - application/vnd.api+json Date: - - Wed, 01 Jul 2020 09:40:41 GMT + - Thu, 02 Jul 2020 20:19:41 GMT Status: - 200 OK Strict-Transport-Security: @@ -40,9 +40,9 @@ interactions: X-Content-Type-Options: - nosniff X-Served-By: - - cache-control-slwdc9036-CONTROL-SLWDC, cache-lcy19273-LCY + - cache-control-slwdc9036-CONTROL-SLWDC, cache-lcy19250-LCY X-Timer: - - S1593596441.933188,VS0,VE667 + - S1593721181.528967,VS0,VE721 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/wafs/enable.yaml b/fastly/fixtures/wafs/enable.yaml index b9e1849e7..787409dcd 100644 --- a/fastly/fixtures/wafs/enable.yaml +++ b/fastly/fixtures/wafs/enable.yaml @@ -3,7 +3,7 @@ version: 1 interactions: - request: body: | - {"data":{"type":"waf_firewall","id":"206Rvtz4NQuFifzUpnhUqL","attributes":{"disabled":false}}} + {"data":{"type":"waf_firewall","id":"1bibBdxQkJYmZsQtR3EmmH","attributes":{"disabled":false}}} form: {} headers: Accept: @@ -12,10 +12,10 @@ interactions: - application/vnd.api+json User-Agent: - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) - url: https://api.fastly.com/waf/firewalls/206Rvtz4NQuFifzUpnhUqL + url: https://api.fastly.com/waf/firewalls/1bibBdxQkJYmZsQtR3EmmH method: PATCH response: - body: '{"data":{"id":"206Rvtz4NQuFifzUpnhUqL","type":"waf_firewall","attributes":{"active_rules_fastly_block_count":0,"active_rules_fastly_log_count":0,"active_rules_fastly_score_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_score_count":0,"active_rules_trustwave_block_count":0,"active_rules_trustwave_log_count":0,"created_at":"2020-07-01T09:40:39Z","disabled":false,"prefetch_condition":null,"response":null,"service_id":"5MlnHT66t9pZgO8XrBEDQl","service_version_number":null,"updated_at":"2020-07-01T09:40:42Z"}}}' + body: '{"data":{"id":"1bibBdxQkJYmZsQtR3EmmH","type":"waf_firewall","attributes":{"active_rules_fastly_block_count":0,"active_rules_fastly_log_count":0,"active_rules_fastly_score_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_score_count":0,"active_rules_trustwave_block_count":0,"active_rules_trustwave_log_count":0,"created_at":"2020-07-02T20:19:38Z","disabled":false,"prefetch_condition":null,"response":null,"service_id":"5n1Tvc6QVHtvZlG109EsyV","service_version_number":null,"updated_at":"2020-07-02T20:19:42Z"}}}' headers: Accept-Ranges: - bytes @@ -25,7 +25,7 @@ interactions: Content-Type: - application/vnd.api+json Date: - - Wed, 01 Jul 2020 09:40:42 GMT + - Thu, 02 Jul 2020 20:19:42 GMT Status: - 200 OK Strict-Transport-Security: @@ -40,9 +40,9 @@ interactions: X-Content-Type-Options: - nosniff X-Served-By: - - cache-control-slwdc9036-CONTROL-SLWDC, cache-lcy19273-LCY + - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19250-LCY X-Timer: - - S1593596442.742125,VS0,VE705 + - S1593721181.385175,VS0,VE767 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/wafs/get.yaml b/fastly/fixtures/wafs/get.yaml index 4201adc2c..e36bbdfe8 100644 --- a/fastly/fixtures/wafs/get.yaml +++ b/fastly/fixtures/wafs/get.yaml @@ -7,10 +7,10 @@ interactions: headers: User-Agent: - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) - url: https://api.fastly.com/waf/firewalls/206Rvtz4NQuFifzUpnhUqL?filter%5Bservice_version_number%5D=2 + url: https://api.fastly.com/waf/firewalls/1bibBdxQkJYmZsQtR3EmmH?filter%5Bservice_version_number%5D=2 method: GET response: - body: '{"data":{"id":"206Rvtz4NQuFifzUpnhUqL","type":"waf_firewall","attributes":{"active_rules_fastly_block_count":0,"active_rules_fastly_log_count":0,"active_rules_fastly_score_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_score_count":0,"active_rules_trustwave_block_count":0,"active_rules_trustwave_log_count":0,"created_at":"2020-07-01T09:40:39Z","disabled":false,"prefetch_condition":"WAF_Prefetch","response":"WAF_Response","service_id":"5MlnHT66t9pZgO8XrBEDQl","service_version_number":2,"updated_at":"2020-07-01T09:40:39Z"}}}' + body: '{"data":{"id":"1bibBdxQkJYmZsQtR3EmmH","type":"waf_firewall","attributes":{"active_rules_fastly_block_count":0,"active_rules_fastly_log_count":0,"active_rules_fastly_score_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_score_count":0,"active_rules_trustwave_block_count":0,"active_rules_trustwave_log_count":0,"created_at":"2020-07-02T20:19:38Z","disabled":false,"prefetch_condition":"WAF_Prefetch","response":"WAF_Response","service_id":"5n1Tvc6QVHtvZlG109EsyV","service_version_number":2,"updated_at":"2020-07-02T20:19:38Z"}}}' headers: Accept-Ranges: - bytes @@ -24,7 +24,7 @@ interactions: Content-Type: - application/vnd.api+json Date: - - Wed, 01 Jul 2020 09:40:40 GMT + - Thu, 02 Jul 2020 20:19:39 GMT Status: - 200 OK Strict-Transport-Security: @@ -39,9 +39,9 @@ interactions: X-Content-Type-Options: - nosniff X-Served-By: - - cache-control-slwdc9036-CONTROL-SLWDC, cache-lcy19273-LCY + - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19250-LCY X-Timer: - - S1593596440.975316,VS0,VE425 + - S1593721180.771141,VS0,VE191 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/wafs/list.yaml b/fastly/fixtures/wafs/list.yaml index cfa783e8f..9dae8689a 100644 --- a/fastly/fixtures/wafs/list.yaml +++ b/fastly/fixtures/wafs/list.yaml @@ -7,10 +7,10 @@ interactions: headers: User-Agent: - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) - url: https://api.fastly.com/waf/firewalls?filter%5Bservice_id%5D=5MlnHT66t9pZgO8XrBEDQl&filter%5Bservice_version_number%5D=2 + url: https://api.fastly.com/waf/firewalls?filter%5Bservice_id%5D=5n1Tvc6QVHtvZlG109EsyV&filter%5Bservice_version_number%5D=2 method: GET response: - body: '{"data":[{"id":"206Rvtz4NQuFifzUpnhUqL","type":"waf_firewall","attributes":{"active_rules_fastly_block_count":0,"active_rules_fastly_log_count":0,"active_rules_fastly_score_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_score_count":0,"active_rules_trustwave_block_count":0,"active_rules_trustwave_log_count":0,"created_at":"2020-07-01T09:40:39Z","disabled":false,"prefetch_condition":"WAF_Prefetch","response":"WAF_Response","service_id":"5MlnHT66t9pZgO8XrBEDQl","service_version_number":2,"updated_at":"2020-07-01T09:40:39Z"}}],"links":{"last":"https://api.fastly.com/waf/firewalls?filter[service_id]=5MlnHT66t9pZgO8XrBEDQl\u0026filter[service_version_number]=2\u0026page[number]=1\u0026page[size]=100","first":"https://api.fastly.com/waf/firewalls?filter[service_id]=5MlnHT66t9pZgO8XrBEDQl\u0026filter[service_version_number]=2\u0026page[number]=1\u0026page[size]=100"},"meta":{"current_page":1,"per_page":100,"record_count":1,"total_pages":1}}' + body: '{"data":[{"id":"1bibBdxQkJYmZsQtR3EmmH","type":"waf_firewall","attributes":{"active_rules_fastly_block_count":0,"active_rules_fastly_log_count":0,"active_rules_fastly_score_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_score_count":0,"active_rules_trustwave_block_count":0,"active_rules_trustwave_log_count":0,"created_at":"2020-07-02T20:19:38Z","disabled":false,"prefetch_condition":"WAF_Prefetch","response":"WAF_Response","service_id":"5n1Tvc6QVHtvZlG109EsyV","service_version_number":2,"updated_at":"2020-07-02T20:19:38Z"}}],"links":{"last":"https://api.fastly.com/waf/firewalls?filter[service_id]=5n1Tvc6QVHtvZlG109EsyV\u0026filter[service_version_number]=2\u0026page[number]=1\u0026page[size]=100","first":"https://api.fastly.com/waf/firewalls?filter[service_id]=5n1Tvc6QVHtvZlG109EsyV\u0026filter[service_version_number]=2\u0026page[number]=1\u0026page[size]=100"},"meta":{"current_page":1,"per_page":100,"record_count":1,"total_pages":1}}' headers: Accept-Ranges: - bytes @@ -24,7 +24,7 @@ interactions: Content-Type: - application/vnd.api+json Date: - - Wed, 01 Jul 2020 09:40:39 GMT + - Thu, 02 Jul 2020 20:19:39 GMT Status: - 200 OK Strict-Transport-Security: @@ -39,9 +39,9 @@ interactions: X-Content-Type-Options: - nosniff X-Served-By: - - cache-control-slwdc9036-CONTROL-SLWDC, cache-lcy19273-LCY + - cache-control-slwdc9036-CONTROL-SLWDC, cache-lcy19250-LCY X-Timer: - - S1593596439.359453,VS0,VE194 + - S1593721179.929427,VS0,VE437 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/wafs/response_object/cleanup_another.yaml b/fastly/fixtures/wafs/response_object/cleanup_another.yaml index ad29433a6..61c7e0b49 100644 --- a/fastly/fixtures/wafs/response_object/cleanup_another.yaml +++ b/fastly/fixtures/wafs/response_object/cleanup_another.yaml @@ -7,7 +7,7 @@ interactions: headers: User-Agent: - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) - url: https://api.fastly.com/service/5MlnHT66t9pZgO8XrBEDQl/version/2/response_object/WAF_Response2 + url: https://api.fastly.com/service/5n1Tvc6QVHtvZlG109EsyV/version/2/response_object/WAF_Response2 method: DELETE response: body: '{"status":"ok"}' @@ -20,11 +20,11 @@ interactions: Content-Type: - application/json Date: - - Wed, 01 Jul 2020 09:40:43 GMT + - Thu, 02 Jul 2020 20:19:43 GMT Fastly-Ratelimit-Remaining: - - "976" + - "958" Fastly-Ratelimit-Reset: - - "1593597600" + - "1593723600" Status: - 200 OK Strict-Transport-Security: @@ -39,9 +39,9 @@ interactions: X-Cache-Hits: - 0, 0 X-Served-By: - - cache-control-slwdc9035-CONTROL-SLWDC, cache-lcy19273-LCY + - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19250-LCY X-Timer: - - S1593596443.282633,VS0,VE252 + - S1593721183.010001,VS0,VE281 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/wafs/response_object/create.yaml b/fastly/fixtures/wafs/response_object/create.yaml index 4e990576f..2835549de 100644 --- a/fastly/fixtures/wafs/response_object/create.yaml +++ b/fastly/fixtures/wafs/response_object/create.yaml @@ -2,10 +2,10 @@ version: 1 interactions: - request: - body: Service=5MlnHT66t9pZgO8XrBEDQl&Version=2&name=WAF_Response&status=403 + body: Service=5n1Tvc6QVHtvZlG109EsyV&Version=2&name=WAF_Response&status=403 form: Service: - - 5MlnHT66t9pZgO8XrBEDQl + - 5n1Tvc6QVHtvZlG109EsyV Version: - "2" name: @@ -17,10 +17,10 @@ interactions: - application/x-www-form-urlencoded User-Agent: - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) - url: https://api.fastly.com/service/5MlnHT66t9pZgO8XrBEDQl/version/2/response_object + url: https://api.fastly.com/service/5n1Tvc6QVHtvZlG109EsyV/version/2/response_object method: POST response: - body: '{"name":"WAF_Response","status":"403","service_id":"5MlnHT66t9pZgO8XrBEDQl","version":"2","content":null,"deleted_at":null,"response":"ok","cache_condition":"","created_at":"2020-07-01T09:40:37Z","content_type":null,"request_condition":"","updated_at":"2020-07-01T09:40:37Z"}' + body: '{"name":"WAF_Response","status":"403","service_id":"5n1Tvc6QVHtvZlG109EsyV","version":"2","deleted_at":null,"content":null,"request_condition":"","created_at":"2020-07-02T20:19:37Z","cache_condition":"","content_type":null,"response":"ok","updated_at":"2020-07-02T20:19:37Z"}' headers: Accept-Ranges: - bytes @@ -30,11 +30,11 @@ interactions: Content-Type: - application/json Date: - - Wed, 01 Jul 2020 09:40:37 GMT + - Thu, 02 Jul 2020 20:19:37 GMT Fastly-Ratelimit-Remaining: - - "978" + - "960" Fastly-Ratelimit-Reset: - - "1593597600" + - "1593723600" Status: - 200 OK Strict-Transport-Security: @@ -49,9 +49,9 @@ interactions: X-Cache-Hits: - 0, 0 X-Served-By: - - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19273-LCY + - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19250-LCY X-Timer: - - S1593596438.626325,VS0,VE243 + - S1593721177.049409,VS0,VE242 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/wafs/response_object/create_another.yaml b/fastly/fixtures/wafs/response_object/create_another.yaml index a1b3ee4fd..6a3aacb71 100644 --- a/fastly/fixtures/wafs/response_object/create_another.yaml +++ b/fastly/fixtures/wafs/response_object/create_another.yaml @@ -2,10 +2,10 @@ version: 1 interactions: - request: - body: Service=5MlnHT66t9pZgO8XrBEDQl&Version=2&name=WAF_Response2&status=403 + body: Service=5n1Tvc6QVHtvZlG109EsyV&Version=2&name=WAF_Response2&status=403 form: Service: - - 5MlnHT66t9pZgO8XrBEDQl + - 5n1Tvc6QVHtvZlG109EsyV Version: - "2" name: @@ -17,10 +17,10 @@ interactions: - application/x-www-form-urlencoded User-Agent: - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) - url: https://api.fastly.com/service/5MlnHT66t9pZgO8XrBEDQl/version/2/response_object + url: https://api.fastly.com/service/5n1Tvc6QVHtvZlG109EsyV/version/2/response_object method: POST response: - body: '{"name":"WAF_Response2","status":"403","service_id":"5MlnHT66t9pZgO8XrBEDQl","version":"2","content_type":null,"deleted_at":null,"updated_at":"2020-07-01T09:40:38Z","request_condition":"","content":null,"created_at":"2020-07-01T09:40:38Z","cache_condition":"","response":"ok"}' + body: '{"name":"WAF_Response2","status":"403","service_id":"5n1Tvc6QVHtvZlG109EsyV","version":"2","content":null,"updated_at":"2020-07-02T20:19:37Z","response":"ok","cache_condition":"","created_at":"2020-07-02T20:19:37Z","content_type":null,"request_condition":"","deleted_at":null}' headers: Accept-Ranges: - bytes @@ -30,11 +30,11 @@ interactions: Content-Type: - application/json Date: - - Wed, 01 Jul 2020 09:40:38 GMT + - Thu, 02 Jul 2020 20:19:37 GMT Fastly-Ratelimit-Remaining: - - "977" + - "959" Fastly-Ratelimit-Reset: - - "1593597600" + - "1593723600" Status: - 200 OK Strict-Transport-Security: @@ -49,9 +49,9 @@ interactions: X-Cache-Hits: - 0, 0 X-Served-By: - - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19273-LCY + - cache-control-slwdc9036-CONTROL-SLWDC, cache-lcy19250-LCY X-Timer: - - S1593596438.994076,VS0,VE219 + - S1593721177.422242,VS0,VE235 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/wafs/response_object/delete.yaml b/fastly/fixtures/wafs/response_object/delete.yaml index 5fd50e3b2..eea8bc218 100644 --- a/fastly/fixtures/wafs/response_object/delete.yaml +++ b/fastly/fixtures/wafs/response_object/delete.yaml @@ -7,7 +7,7 @@ interactions: headers: User-Agent: - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) - url: https://api.fastly.com/service/5MlnHT66t9pZgO8XrBEDQl/version/2/response_object/WAF_Response + url: https://api.fastly.com/service/5n1Tvc6QVHtvZlG109EsyV/version/2/response_object/WAF_Response method: DELETE response: body: '{"status":"ok"}' @@ -20,11 +20,11 @@ interactions: Content-Type: - application/json Date: - - Wed, 01 Jul 2020 09:40:43 GMT + - Thu, 02 Jul 2020 20:19:43 GMT Fastly-Ratelimit-Remaining: - - "975" + - "957" Fastly-Ratelimit-Reset: - - "1593597600" + - "1593723600" Status: - 200 OK Strict-Transport-Security: @@ -39,9 +39,9 @@ interactions: X-Cache-Hits: - 0, 0 X-Served-By: - - cache-control-slwdc9035-CONTROL-SLWDC, cache-lcy19273-LCY + - cache-control-slwdc9036-CONTROL-SLWDC, cache-lcy19250-LCY X-Timer: - - S1593596444.711876,VS0,VE248 + - S1593721183.471935,VS0,VE285 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/wafs/service/create.yaml b/fastly/fixtures/wafs/service/create.yaml index 503f0c020..5727271e7 100644 --- a/fastly/fixtures/wafs/service/create.yaml +++ b/fastly/fixtures/wafs/service/create.yaml @@ -18,7 +18,7 @@ interactions: url: https://api.fastly.com/service method: POST response: - body: '{"customer_id":"WpqWFjTA4lk2N1g0GY2HH","comment":"go-fastly client test","name":"test_service_service2","type":"vcl","updated_at":"2020-07-01T09:40:36Z","id":"5MlnHT66t9pZgO8XrBEDQl","publish_key":"","versions":[{"active":false,"updated_at":"2020-07-01T09:40:36Z","staging":false,"service_id":"5MlnHT66t9pZgO8XrBEDQl","deleted_at":null,"comment":"","created_at":"2020-07-01T09:40:36Z","number":1,"testing":false,"locked":false,"deployed":false}],"deleted_at":null,"created_at":"2020-07-01T09:40:36Z"}' + body: '{"customer_id":"WpqWFjTA4lk2N1g0GY2HH","comment":"go-fastly client test","name":"test_service_service2","type":"vcl","versions":[{"testing":false,"locked":false,"deployed":false,"updated_at":"2020-07-02T20:19:36Z","deleted_at":null,"service_id":"5n1Tvc6QVHtvZlG109EsyV","active":false,"staging":false,"comment":"","created_at":"2020-07-02T20:19:36Z","number":1}],"created_at":"2020-07-02T20:19:36Z","publish_key":"","deleted_at":null,"id":"5n1Tvc6QVHtvZlG109EsyV","updated_at":"2020-07-02T20:19:36Z"}' headers: Accept-Ranges: - bytes @@ -28,11 +28,11 @@ interactions: Content-Type: - application/json Date: - - Wed, 01 Jul 2020 09:40:36 GMT + - Thu, 02 Jul 2020 20:19:36 GMT Fastly-Ratelimit-Remaining: - - "981" + - "963" Fastly-Ratelimit-Reset: - - "1593597600" + - "1593723600" Status: - 200 OK Strict-Transport-Security: @@ -47,9 +47,9 @@ interactions: X-Cache-Hits: - 0, 0 X-Served-By: - - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19273-LCY + - cache-control-slwdc9035-CONTROL-SLWDC, cache-lcy19250-LCY X-Timer: - - S1593596436.357176,VS0,VE226 + - S1593721176.037648,VS0,VE232 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/wafs/service/delete.yaml b/fastly/fixtures/wafs/service/delete.yaml index 9201166e6..5947cfc71 100644 --- a/fastly/fixtures/wafs/service/delete.yaml +++ b/fastly/fixtures/wafs/service/delete.yaml @@ -7,7 +7,7 @@ interactions: headers: User-Agent: - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) - url: https://api.fastly.com/service/5MlnHT66t9pZgO8XrBEDQl + url: https://api.fastly.com/service/5n1Tvc6QVHtvZlG109EsyV method: DELETE response: body: '{"status":"ok"}' @@ -20,11 +20,11 @@ interactions: Content-Type: - application/json Date: - - Wed, 01 Jul 2020 09:40:44 GMT + - Thu, 02 Jul 2020 20:19:44 GMT Fastly-Ratelimit-Remaining: - - "973" + - "955" Fastly-Ratelimit-Reset: - - "1593597600" + - "1593723600" Status: - 200 OK Strict-Transport-Security: @@ -39,9 +39,9 @@ interactions: X-Cache-Hits: - 0, 0 X-Served-By: - - cache-control-slwdc9035-CONTROL-SLWDC, cache-lcy19273-LCY + - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19250-LCY X-Timer: - - S1593596445.566062,VS0,VE235 + - S1593721184.372119,VS0,VE228 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/wafs/service/version.yaml b/fastly/fixtures/wafs/service/version.yaml index 364e0f446..c5d383659 100644 --- a/fastly/fixtures/wafs/service/version.yaml +++ b/fastly/fixtures/wafs/service/version.yaml @@ -2,19 +2,19 @@ version: 1 interactions: - request: - body: Service=5MlnHT66t9pZgO8XrBEDQl + body: Service=5n1Tvc6QVHtvZlG109EsyV form: Service: - - 5MlnHT66t9pZgO8XrBEDQl + - 5n1Tvc6QVHtvZlG109EsyV headers: Content-Type: - application/x-www-form-urlencoded User-Agent: - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) - url: https://api.fastly.com/service/5MlnHT66t9pZgO8XrBEDQl/version + url: https://api.fastly.com/service/5n1Tvc6QVHtvZlG109EsyV/version method: POST response: - body: '{"service_id":"5MlnHT66t9pZgO8XrBEDQl","number":2}' + body: '{"service_id":"5n1Tvc6QVHtvZlG109EsyV","number":2}' headers: Accept-Ranges: - bytes @@ -24,11 +24,11 @@ interactions: Content-Type: - application/json Date: - - Wed, 01 Jul 2020 09:40:37 GMT + - Thu, 02 Jul 2020 20:19:36 GMT Fastly-Ratelimit-Remaining: - - "980" + - "962" Fastly-Ratelimit-Reset: - - "1593597600" + - "1593723600" Status: - 200 OK Strict-Transport-Security: @@ -43,9 +43,9 @@ interactions: X-Cache-Hits: - 0, 0 X-Served-By: - - cache-control-slwdc9035-CONTROL-SLWDC, cache-lcy19273-LCY + - cache-control-slwdc9035-CONTROL-SLWDC, cache-lcy19250-LCY X-Timer: - - S1593596437.730308,VS0,VE444 + - S1593721176.361205,VS0,VE234 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/wafs/update.yaml b/fastly/fixtures/wafs/update.yaml index 7281b8183..8529984c9 100644 --- a/fastly/fixtures/wafs/update.yaml +++ b/fastly/fixtures/wafs/update.yaml @@ -3,7 +3,7 @@ version: 1 interactions: - request: body: | - {"data":{"type":"waf_firewall","id":"206Rvtz4NQuFifzUpnhUqL","attributes":{"response":"WAF_Response2","service_id":"5MlnHT66t9pZgO8XrBEDQl","service_version_number":"2"}}} + {"data":{"type":"waf_firewall","id":"1bibBdxQkJYmZsQtR3EmmH","attributes":{"response":"WAF_Response2","service_id":"5n1Tvc6QVHtvZlG109EsyV","service_version_number":"2"}}} form: {} headers: Accept: @@ -12,12 +12,12 @@ interactions: - application/vnd.api+json User-Agent: - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) - url: https://api.fastly.com/waf/firewalls/206Rvtz4NQuFifzUpnhUqL + url: https://api.fastly.com/waf/firewalls/1bibBdxQkJYmZsQtR3EmmH method: PATCH response: - body: '{"data":{"id":"206Rvtz4NQuFifzUpnhUqL","type":"waf_firewall","attributes":{"active_rules_fastly_block_count":0,"active_rules_fastly_log_count":0,"active_rules_fastly_score_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_score_count":0,"active_rules_trustwave_block_count":0,"active_rules_trustwave_log_count":0,"created_at":"2020-07-01T09:40:39Z","disabled":false,"prefetch_condition":"WAF_Prefetch","response":"WAF_Response2","service_id":"5MlnHT66t9pZgO8XrBEDQl","service_version_number":2,"updated_at":"2020-07-01T09:40:39Z"}},"meta":{"warnings":[{"title":"This + body: '{"data":{"id":"1bibBdxQkJYmZsQtR3EmmH","type":"waf_firewall","attributes":{"active_rules_fastly_block_count":0,"active_rules_fastly_log_count":0,"active_rules_fastly_score_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_score_count":0,"active_rules_trustwave_block_count":0,"active_rules_trustwave_log_count":0,"created_at":"2020-07-02T20:19:38Z","disabled":false,"prefetch_condition":"WAF_Prefetch","response":"WAF_Response2","service_id":"5n1Tvc6QVHtvZlG109EsyV","service_version_number":2,"updated_at":"2020-07-02T20:19:38Z"}},"meta":{"warnings":[{"title":"This version of this service must be active","detail":"You may only update the WAF - VCL on an active version of a service. The version 2 of service 5MlnHT66t9pZgO8XrBEDQl + VCL on an active version of a service. The version 2 of service 5n1Tvc6QVHtvZlG109EsyV is not active. You may activate it through https://app.fastly.com or through the API: https://docs.fastly.com/api/config#version Be sure to review the version''s changes before activating it."}]}}' @@ -30,7 +30,7 @@ interactions: Content-Type: - application/vnd.api+json Date: - - Wed, 01 Jul 2020 09:40:40 GMT + - Thu, 02 Jul 2020 20:19:40 GMT Status: - 200 OK Strict-Transport-Security: @@ -45,9 +45,9 @@ interactions: X-Content-Type-Options: - nosniff X-Served-By: - - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19273-LCY + - cache-control-slwdc9035-CONTROL-SLWDC, cache-lcy19250-LCY X-Timer: - - S1593596440.488349,VS0,VE310 + - S1593721180.056656,VS0,VE340 status: 200 OK code: 200 duration: "" diff --git a/fastly/waf_version.go b/fastly/waf_version.go index 4cedc9064..7ba80d8a8 100644 --- a/fastly/waf_version.go +++ b/fastly/waf_version.go @@ -387,8 +387,8 @@ func (c *Client) DeployWAFVersion(i *DeployWAFVersionInput) error { return ErrMissingWAFVersionNumber } - path := fmt.Sprintf("/waf/firewalls/%s/versions/%d", i.WAFID, i.WAFVersionNumber) - _, err := c.PostJSONAPI(path, &DeployWAFVersionInput{}, nil) + path := fmt.Sprintf("/waf/firewalls/%s/versions/%d/activate", i.WAFID, i.WAFVersionNumber) + _, err := c.PutJSONAPI(path, &DeployWAFVersionInput{}, nil) if err != nil { return err } From b4c81c42175e05a9dfef75f2fe252f86299143dd Mon Sep 17 00:00:00 2001 From: Stuart Wallace Date: Fri, 3 Jul 2020 16:43:58 +0100 Subject: [PATCH 17/37] Add LastDeploymentStatus so clients can deal with async deploys --- fastly/waf_version.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/fastly/waf_version.go b/fastly/waf_version.go index 7ba80d8a8..8dd79407b 100644 --- a/fastly/waf_version.go +++ b/fastly/waf_version.go @@ -21,6 +21,18 @@ const ( // WAFBatchModifyMaximumOperations is used as the default batch maximum operations. WAFBatchModifyMaximumOperations = 500 + + // WAFVersionDeploymentStatusPending is the string value representing pending state for last_deployment_status for a WAF version + WAFVersionDeploymentStatusPending = "pending" + + // WAFVersionDeploymentStatusInProgress is the string value representing in-progress state for last_deployment_status for a WAF version + WAFVersionDeploymentStatusInProgress = "in-progress" + + // WAFVersionDeploymentStatusCompleted is the string value representing completed state for last_deployment_status for a WAF versions + WAFVersionDeploymentStatusCompleted = "completed" + + // WAFVersionDeploymentStatusFailed is the string value representing failed state for last_deployment_status for a WAF versions + WAFVersionDeploymentStatusFailed = "failed" ) // WAFVersion is the information about a WAF version object. @@ -33,6 +45,7 @@ type WAFVersion struct { CRSValidateUTF8Encoding bool `jsonapi:"attr,crs_validate_utf8_encoding"` Comment string `jsonapi:"attr,comment"` Error string `jsonapi:"attr,error"` + LastDeploymentStatus string `jsonapi:"attr,last_deployment_status"` DeployedAt *time.Time `jsonapi:"attr,deployed_at,iso8601"` AllowedHTTPVersions string `jsonapi:"attr,allowed_http_versions"` AllowedMethods string `jsonapi:"attr,allowed_methods"` From 182e219ed98a65ce6cd824c2948b4599ccc4eb28 Mon Sep 17 00:00:00 2001 From: Stuart Wallace Date: Mon, 6 Jul 2020 12:12:12 +0100 Subject: [PATCH 18/37] Add testing for LastDeploymentStatus --- fastly/fixtures/waf_versions/clone.yaml | 14 ++--- .../waf_versions/condition/create.yaml | 18 +++--- .../waf_versions/condition/delete.yaml | 12 ++-- .../fixtures/waf_versions/create_empty.yaml | 16 +++--- fastly/fixtures/waf_versions/deploy.yaml | 8 +-- fastly/fixtures/waf_versions/get.yaml | 14 ++--- .../waf_versions/getPostDeploy_0.yaml | 55 +++++++++++++++++++ .../waf_versions/getPostDeploy_1.yaml | 50 +++++++++++++++++ fastly/fixtures/waf_versions/list.yaml | 14 ++--- fastly/fixtures/waf_versions/list_all.yaml | 18 +++--- fastly/fixtures/waf_versions/lock.yaml | 14 ++--- .../fixtures/waf_versions/logging/create.yaml | 18 +++--- .../fixtures/waf_versions/logging/delete.yaml | 12 ++-- .../waf_versions/response_object/create.yaml | 18 +++--- .../waf_versions/response_object/delete.yaml | 12 ++-- .../fixtures/waf_versions/service/create.yaml | 12 ++-- .../fixtures/waf_versions/service/delete.yaml | 12 ++-- .../waf_versions/service/version.yaml | 18 +++--- fastly/fixtures/waf_versions/update.yaml | 16 +++--- fastly/fixtures/waf_versions/waf/create.yaml | 10 ++-- fastly/fixtures/waf_versions/waf/delete.yaml | 10 ++-- fastly/waf_version.go | 2 +- fastly/waf_version_test.go | 37 +++++++++++++ 23 files changed, 276 insertions(+), 134 deletions(-) create mode 100644 fastly/fixtures/waf_versions/getPostDeploy_0.yaml create mode 100644 fastly/fixtures/waf_versions/getPostDeploy_1.yaml diff --git a/fastly/fixtures/waf_versions/clone.yaml b/fastly/fixtures/waf_versions/clone.yaml index fd7732662..2f3ba3de1 100644 --- a/fastly/fixtures/waf_versions/clone.yaml +++ b/fastly/fixtures/waf_versions/clone.yaml @@ -12,17 +12,17 @@ interactions: - application/vnd.api+json User-Agent: - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) - url: https://api.fastly.com/waf/firewalls/5oX1X8cVEBpEXg6PsNSTXA/versions/1/clone + url: https://api.fastly.com/waf/firewalls/7kRiB97L3ppEaKv5J3hJmV/versions/1/clone method: PUT response: - body: '{"data":{"id":"6q3TBLBKV00lMIsp0DC3wq","type":"waf_firewall_version","attributes":{"active":false,"active_rules_fastly_block_count":0,"active_rules_fastly_log_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_score_count":0,"active_rules_trustwave_block_count":0,"active_rules_trustwave_log_count":0,"allowed_http_versions":"HTTP/1.0 - HTTP/1.1 HTTP/2","allowed_methods":"GET HEAD POST OPTIONS PUT PATCH DELETE","allowed_request_content_type":"application/x-www-form-urlencoded|multipart/form-data|text/xml|application/xml|application/soap+xml|application/x-amf|application/json|application/octet-stream|application/csp-report|application/xss-auditor-report|text/plain","allowed_request_content_type_charset":"utf-8|iso-8859-1|iso-8859-15|windows-1252","arg_name_length":100,"arg_length":400,"combined_file_sizes":10000000,"comment":null,"created_at":"2020-07-02T20:20:58Z","critical_anomaly_score":5,"crs_validate_utf8_encoding":false,"deployed_at":null,"error":null,"error_anomaly_score":4,"high_risk_country_codes":"","http_violation_score_threshold":999,"inbound_anomaly_score_threshold":999,"last_deployment_status":null,"lfi_score_threshold":999,"locked":false,"max_file_size":10000000,"max_num_args":255,"notice_anomaly_score":2,"number":2,"paranoia_level":1,"php_injection_score_threshold":999,"rce_score_threshold":999,"restricted_extensions":".asa/ + body: '{"data":{"id":"6BowSDK5ezUJMnkXOUWVuD","type":"waf_firewall_version","attributes":{"active":false,"active_rules_fastly_block_count":0,"active_rules_fastly_log_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_score_count":0,"active_rules_trustwave_block_count":0,"active_rules_trustwave_log_count":0,"allowed_http_versions":"HTTP/1.0 + HTTP/1.1 HTTP/2","allowed_methods":"GET HEAD POST OPTIONS PUT PATCH DELETE","allowed_request_content_type":"application/x-www-form-urlencoded|multipart/form-data|text/xml|application/xml|application/soap+xml|application/x-amf|application/json|application/octet-stream|application/csp-report|application/xss-auditor-report|text/plain","allowed_request_content_type_charset":"utf-8|iso-8859-1|iso-8859-15|windows-1252","arg_name_length":100,"arg_length":400,"combined_file_sizes":10000000,"comment":null,"created_at":"2020-07-06T11:09:09Z","critical_anomaly_score":5,"crs_validate_utf8_encoding":false,"deployed_at":null,"error":null,"error_anomaly_score":4,"high_risk_country_codes":"","http_violation_score_threshold":999,"inbound_anomaly_score_threshold":999,"last_deployment_status":null,"lfi_score_threshold":999,"locked":false,"max_file_size":10000000,"max_num_args":255,"notice_anomaly_score":2,"number":2,"paranoia_level":1,"php_injection_score_threshold":999,"rce_score_threshold":999,"restricted_extensions":".asa/ .asax/ .ascx/ .axd/ .backup/ .bak/ .bat/ .cdx/ .cer/ .cfg/ .cmd/ .com/ .config/ .conf/ .cs/ .csproj/ .csr/ .dat/ .db/ .dbf/ .dll/ .dos/ .htr/ .htw/ .ida/ .idc/ .idq/ .inc/ .ini/ .key/ .licx/ .lnk/ .log/ .mdb/ .old/ .pass/ .pdb/ .pol/ .printer/ .pwd/ .resources/ .resx/ .sql/ .sys/ .vb/ .vbs/ .vbproj/ .vsdisco/ .webinfo/ .xsd/ .xsx/","restricted_headers":"/proxy/ /lock-token/ /content-range/ /translate/ - /if/","rfi_score_threshold":999,"session_fixation_score_threshold":999,"sql_injection_score_threshold":999,"total_arg_length":6400,"updated_at":"2020-07-02T20:20:58Z","warning_anomaly_score":3,"xss_score_threshold":999},"relationships":{"waf_firewall":{"data":{"id":"5oX1X8cVEBpEXg6PsNSTXA","type":"waf_firewall"}}}}}' + /if/","rfi_score_threshold":999,"session_fixation_score_threshold":999,"sql_injection_score_threshold":999,"total_arg_length":6400,"updated_at":"2020-07-06T11:09:09Z","warning_anomaly_score":3,"xss_score_threshold":999},"relationships":{"waf_firewall":{"data":{"id":"7kRiB97L3ppEaKv5J3hJmV","type":"waf_firewall"}}}}}' headers: Accept-Ranges: - bytes @@ -32,7 +32,7 @@ interactions: Content-Type: - application/vnd.api+json Date: - - Thu, 02 Jul 2020 20:20:58 GMT + - Mon, 06 Jul 2020 11:09:09 GMT Status: - 200 OK Strict-Transport-Security: @@ -47,9 +47,9 @@ interactions: X-Content-Type-Options: - nosniff X-Served-By: - - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19265-LCY + - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19257-LCY X-Timer: - - S1593721258.437172,VS0,VE181 + - S1594033750.645844,VS0,VE182 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/waf_versions/condition/create.yaml b/fastly/fixtures/waf_versions/condition/create.yaml index 891c1f5d4..9414670e7 100644 --- a/fastly/fixtures/waf_versions/condition/create.yaml +++ b/fastly/fixtures/waf_versions/condition/create.yaml @@ -2,10 +2,10 @@ version: 1 interactions: - request: - body: Service=52szbbqIWi1L5bUd4EBKkX&Version=2&name=WAF_Prefetch&priority=1&statement=req.url~%2B%22index.html%22&type=PREFETCH + body: Service=5GZsX83POn5zij6allCOKe&Version=2&name=WAF_Prefetch&priority=1&statement=req.url~%2B%22index.html%22&type=PREFETCH form: Service: - - 52szbbqIWi1L5bUd4EBKkX + - 5GZsX83POn5zij6allCOKe Version: - "2" name: @@ -21,10 +21,10 @@ interactions: - application/x-www-form-urlencoded User-Agent: - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) - url: https://api.fastly.com/service/52szbbqIWi1L5bUd4EBKkX/version/2/condition + url: https://api.fastly.com/service/5GZsX83POn5zij6allCOKe/version/2/condition method: POST response: - body: '{"name":"WAF_Prefetch","priority":"1","statement":"req.url~+\"index.html\"","type":"PREFETCH","service_id":"52szbbqIWi1L5bUd4EBKkX","version":"2","created_at":"2020-07-02T20:20:56Z","updated_at":"2020-07-02T20:20:56Z","deleted_at":null,"comment":""}' + body: '{"name":"WAF_Prefetch","priority":"1","statement":"req.url~+\"index.html\"","type":"PREFETCH","service_id":"5GZsX83POn5zij6allCOKe","version":"2","updated_at":"2020-07-06T11:09:06Z","comment":"","deleted_at":null,"created_at":"2020-07-06T11:09:06Z"}' headers: Accept-Ranges: - bytes @@ -34,11 +34,11 @@ interactions: Content-Type: - application/json Date: - - Thu, 02 Jul 2020 20:20:56 GMT + - Mon, 06 Jul 2020 11:09:06 GMT Fastly-Ratelimit-Remaining: - - "951" + - "978" Fastly-Ratelimit-Reset: - - "1593723600" + - "1594036800" Status: - 200 OK Strict-Transport-Security: @@ -53,9 +53,9 @@ interactions: X-Cache-Hits: - 0, 0 X-Served-By: - - cache-control-slwdc9036-CONTROL-SLWDC, cache-lcy19265-LCY + - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19257-LCY X-Timer: - - S1593721256.006684,VS0,VE198 + - S1594033746.983994,VS0,VE199 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/waf_versions/condition/delete.yaml b/fastly/fixtures/waf_versions/condition/delete.yaml index ebf9ccccf..34ddbb821 100644 --- a/fastly/fixtures/waf_versions/condition/delete.yaml +++ b/fastly/fixtures/waf_versions/condition/delete.yaml @@ -7,7 +7,7 @@ interactions: headers: User-Agent: - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) - url: https://api.fastly.com/service/52szbbqIWi1L5bUd4EBKkX/version/2/condition/WAF_Prefetch + url: https://api.fastly.com/service/5GZsX83POn5zij6allCOKe/version/2/condition/WAF_Prefetch method: DELETE response: body: '{"status":"ok"}' @@ -20,11 +20,11 @@ interactions: Content-Type: - application/json Date: - - Thu, 02 Jul 2020 20:21:01 GMT + - Mon, 06 Jul 2020 11:09:12 GMT Fastly-Ratelimit-Remaining: - - "948" + - "975" Fastly-Ratelimit-Reset: - - "1593723600" + - "1594036800" Status: - 200 OK Strict-Transport-Security: @@ -39,9 +39,9 @@ interactions: X-Cache-Hits: - 0, 0 X-Served-By: - - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19265-LCY + - cache-control-slwdc9036-CONTROL-SLWDC, cache-lcy19257-LCY X-Timer: - - S1593721262.721294,VS0,VE222 + - S1594033753.708720,VS0,VE226 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/waf_versions/create_empty.yaml b/fastly/fixtures/waf_versions/create_empty.yaml index f1c663c26..662707783 100644 --- a/fastly/fixtures/waf_versions/create_empty.yaml +++ b/fastly/fixtures/waf_versions/create_empty.yaml @@ -11,27 +11,27 @@ interactions: - application/vnd.api+json User-Agent: - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) - url: https://api.fastly.com/waf/firewalls/5oX1X8cVEBpEXg6PsNSTXA/versions + url: https://api.fastly.com/waf/firewalls/7kRiB97L3ppEaKv5J3hJmV/versions method: POST response: - body: '{"data":{"id":"7ZbqqxjPYZsBzq6nePHDRT","type":"waf_firewall_version","attributes":{"active":false,"active_rules_fastly_block_count":0,"active_rules_fastly_log_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_score_count":0,"active_rules_trustwave_block_count":0,"active_rules_trustwave_log_count":0,"allowed_http_versions":"HTTP/1.0 - HTTP/1.1 HTTP/2","allowed_methods":"GET HEAD POST OPTIONS PUT PATCH DELETE","allowed_request_content_type":"application/x-www-form-urlencoded|multipart/form-data|text/xml|application/xml|application/soap+xml|application/x-amf|application/json|application/octet-stream|application/csp-report|application/xss-auditor-report|text/plain","allowed_request_content_type_charset":"utf-8|iso-8859-1|iso-8859-15|windows-1252","arg_name_length":100,"arg_length":400,"combined_file_sizes":10000000,"comment":null,"created_at":"2020-07-02T20:21:00Z","critical_anomaly_score":5,"crs_validate_utf8_encoding":false,"deployed_at":null,"error":null,"error_anomaly_score":4,"high_risk_country_codes":"","http_violation_score_threshold":999,"inbound_anomaly_score_threshold":999,"last_deployment_status":null,"lfi_score_threshold":999,"locked":false,"max_file_size":10000000,"max_num_args":255,"notice_anomaly_score":2,"number":3,"paranoia_level":1,"php_injection_score_threshold":999,"rce_score_threshold":999,"restricted_extensions":".asa/ + body: '{"data":{"id":"3fLfb20XK4ep2ACbeI35T","type":"waf_firewall_version","attributes":{"active":false,"active_rules_fastly_block_count":0,"active_rules_fastly_log_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_score_count":0,"active_rules_trustwave_block_count":0,"active_rules_trustwave_log_count":0,"allowed_http_versions":"HTTP/1.0 + HTTP/1.1 HTTP/2","allowed_methods":"GET HEAD POST OPTIONS PUT PATCH DELETE","allowed_request_content_type":"application/x-www-form-urlencoded|multipart/form-data|text/xml|application/xml|application/soap+xml|application/x-amf|application/json|application/octet-stream|application/csp-report|application/xss-auditor-report|text/plain","allowed_request_content_type_charset":"utf-8|iso-8859-1|iso-8859-15|windows-1252","arg_name_length":100,"arg_length":400,"combined_file_sizes":10000000,"comment":null,"created_at":"2020-07-06T11:09:11Z","critical_anomaly_score":5,"crs_validate_utf8_encoding":false,"deployed_at":null,"error":null,"error_anomaly_score":4,"high_risk_country_codes":"","http_violation_score_threshold":999,"inbound_anomaly_score_threshold":999,"last_deployment_status":null,"lfi_score_threshold":999,"locked":false,"max_file_size":10000000,"max_num_args":255,"notice_anomaly_score":2,"number":3,"paranoia_level":1,"php_injection_score_threshold":999,"rce_score_threshold":999,"restricted_extensions":".asa/ .asax/ .ascx/ .axd/ .backup/ .bak/ .bat/ .cdx/ .cer/ .cfg/ .cmd/ .com/ .config/ .conf/ .cs/ .csproj/ .csr/ .dat/ .db/ .dbf/ .dll/ .dos/ .htr/ .htw/ .ida/ .idc/ .idq/ .inc/ .ini/ .key/ .licx/ .lnk/ .log/ .mdb/ .old/ .pass/ .pdb/ .pol/ .printer/ .pwd/ .resources/ .resx/ .sql/ .sys/ .vb/ .vbs/ .vbproj/ .vsdisco/ .webinfo/ .xsd/ .xsx/","restricted_headers":"/proxy/ /lock-token/ /content-range/ /translate/ - /if/","rfi_score_threshold":999,"session_fixation_score_threshold":999,"sql_injection_score_threshold":999,"total_arg_length":6400,"updated_at":"2020-07-02T20:21:00Z","warning_anomaly_score":3,"xss_score_threshold":999},"relationships":{"waf_firewall":{"data":{"id":"5oX1X8cVEBpEXg6PsNSTXA","type":"waf_firewall"}}}}}' + /if/","rfi_score_threshold":999,"session_fixation_score_threshold":999,"sql_injection_score_threshold":999,"total_arg_length":6400,"updated_at":"2020-07-06T11:09:11Z","warning_anomaly_score":3,"xss_score_threshold":999},"relationships":{"waf_firewall":{"data":{"id":"7kRiB97L3ppEaKv5J3hJmV","type":"waf_firewall"}}}}}' headers: Accept-Ranges: - bytes - bytes Content-Length: - - "2126" + - "2125" Content-Type: - application/vnd.api+json Date: - - Thu, 02 Jul 2020 20:21:00 GMT + - Mon, 06 Jul 2020 11:09:11 GMT Status: - 201 Created Strict-Transport-Security: @@ -46,9 +46,9 @@ interactions: X-Content-Type-Options: - nosniff X-Served-By: - - cache-control-slwdc9035-CONTROL-SLWDC, cache-lcy19265-LCY + - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19257-LCY X-Timer: - - S1593721261.504568,VS0,VE189 + - S1594033752.522295,VS0,VE172 status: 201 Created code: 201 duration: "" diff --git a/fastly/fixtures/waf_versions/deploy.yaml b/fastly/fixtures/waf_versions/deploy.yaml index a859cddb7..42cc2c330 100644 --- a/fastly/fixtures/waf_versions/deploy.yaml +++ b/fastly/fixtures/waf_versions/deploy.yaml @@ -12,7 +12,7 @@ interactions: - application/vnd.api+json User-Agent: - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) - url: https://api.fastly.com/waf/firewalls/5oX1X8cVEBpEXg6PsNSTXA/versions/1/activate + url: https://api.fastly.com/waf/firewalls/7kRiB97L3ppEaKv5J3hJmV/versions/1/activate method: PUT response: body: '{}' @@ -25,7 +25,7 @@ interactions: Content-Type: - application/vnd.api+json Date: - - Thu, 02 Jul 2020 20:20:58 GMT + - Mon, 06 Jul 2020 11:09:08 GMT Status: - 202 Accepted Strict-Transport-Security: @@ -40,9 +40,9 @@ interactions: X-Content-Type-Options: - nosniff X-Served-By: - - cache-control-slwdc9035-CONTROL-SLWDC, cache-lcy19265-LCY + - cache-control-slwdc9036-CONTROL-SLWDC, cache-lcy19257-LCY X-Timer: - - S1593721258.140969,VS0,VE151 + - S1594033748.268765,VS0,VE150 status: 202 Accepted code: 202 duration: "" diff --git a/fastly/fixtures/waf_versions/get.yaml b/fastly/fixtures/waf_versions/get.yaml index 7f49beecb..1e6e6556c 100644 --- a/fastly/fixtures/waf_versions/get.yaml +++ b/fastly/fixtures/waf_versions/get.yaml @@ -7,17 +7,17 @@ interactions: headers: User-Agent: - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) - url: https://api.fastly.com/waf/firewalls/5oX1X8cVEBpEXg6PsNSTXA/versions/2 + url: https://api.fastly.com/waf/firewalls/7kRiB97L3ppEaKv5J3hJmV/versions/2 method: GET response: - body: '{"data":{"id":"6q3TBLBKV00lMIsp0DC3wq","type":"waf_firewall_version","attributes":{"active":false,"active_rules_fastly_block_count":0,"active_rules_fastly_log_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_score_count":0,"active_rules_trustwave_block_count":0,"active_rules_trustwave_log_count":0,"allowed_http_versions":"HTTP/1.0 - HTTP/1.1 HTTP/2","allowed_methods":"GET HEAD POST OPTIONS PUT PATCH DELETE","allowed_request_content_type":"application/x-www-form-urlencoded|multipart/form-data|text/xml|application/xml|application/soap+xml|application/x-amf|application/json|application/octet-stream|application/csp-report|application/xss-auditor-report|text/plain","allowed_request_content_type_charset":"utf-8|iso-8859-1|iso-8859-15|windows-1252","arg_name_length":100,"arg_length":400,"combined_file_sizes":10000000,"comment":null,"created_at":"2020-07-02T20:20:58Z","critical_anomaly_score":5,"crs_validate_utf8_encoding":false,"deployed_at":null,"error":null,"error_anomaly_score":4,"high_risk_country_codes":"","http_violation_score_threshold":999,"inbound_anomaly_score_threshold":999,"last_deployment_status":null,"lfi_score_threshold":999,"locked":false,"max_file_size":10000000,"max_num_args":255,"notice_anomaly_score":2,"number":2,"paranoia_level":1,"php_injection_score_threshold":999,"rce_score_threshold":999,"restricted_extensions":".asa/ + body: '{"data":{"id":"6BowSDK5ezUJMnkXOUWVuD","type":"waf_firewall_version","attributes":{"active":false,"active_rules_fastly_block_count":0,"active_rules_fastly_log_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_score_count":0,"active_rules_trustwave_block_count":0,"active_rules_trustwave_log_count":0,"allowed_http_versions":"HTTP/1.0 + HTTP/1.1 HTTP/2","allowed_methods":"GET HEAD POST OPTIONS PUT PATCH DELETE","allowed_request_content_type":"application/x-www-form-urlencoded|multipart/form-data|text/xml|application/xml|application/soap+xml|application/x-amf|application/json|application/octet-stream|application/csp-report|application/xss-auditor-report|text/plain","allowed_request_content_type_charset":"utf-8|iso-8859-1|iso-8859-15|windows-1252","arg_name_length":100,"arg_length":400,"combined_file_sizes":10000000,"comment":null,"created_at":"2020-07-06T11:09:09Z","critical_anomaly_score":5,"crs_validate_utf8_encoding":false,"deployed_at":null,"error":null,"error_anomaly_score":4,"high_risk_country_codes":"","http_violation_score_threshold":999,"inbound_anomaly_score_threshold":999,"last_deployment_status":null,"lfi_score_threshold":999,"locked":false,"max_file_size":10000000,"max_num_args":255,"notice_anomaly_score":2,"number":2,"paranoia_level":1,"php_injection_score_threshold":999,"rce_score_threshold":999,"restricted_extensions":".asa/ .asax/ .ascx/ .axd/ .backup/ .bak/ .bat/ .cdx/ .cer/ .cfg/ .cmd/ .com/ .config/ .conf/ .cs/ .csproj/ .csr/ .dat/ .db/ .dbf/ .dll/ .dos/ .htr/ .htw/ .ida/ .idc/ .idq/ .inc/ .ini/ .key/ .licx/ .lnk/ .log/ .mdb/ .old/ .pass/ .pdb/ .pol/ .printer/ .pwd/ .resources/ .resx/ .sql/ .sys/ .vb/ .vbs/ .vbproj/ .vsdisco/ .webinfo/ .xsd/ .xsx/","restricted_headers":"/proxy/ /lock-token/ /content-range/ /translate/ - /if/","rfi_score_threshold":999,"session_fixation_score_threshold":999,"sql_injection_score_threshold":999,"total_arg_length":6400,"updated_at":"2020-07-02T20:20:58Z","warning_anomaly_score":3,"xss_score_threshold":999}}}' + /if/","rfi_score_threshold":999,"session_fixation_score_threshold":999,"sql_injection_score_threshold":999,"total_arg_length":6400,"updated_at":"2020-07-06T11:09:09Z","warning_anomaly_score":3,"xss_score_threshold":999}}}' headers: Accept-Ranges: - bytes @@ -31,7 +31,7 @@ interactions: Content-Type: - application/vnd.api+json Date: - - Thu, 02 Jul 2020 20:20:59 GMT + - Mon, 06 Jul 2020 11:09:10 GMT Status: - 200 OK Strict-Transport-Security: @@ -46,9 +46,9 @@ interactions: X-Content-Type-Options: - nosniff X-Served-By: - - cache-control-slwdc9035-CONTROL-SLWDC, cache-lcy19265-LCY + - cache-control-slwdc9036-CONTROL-SLWDC, cache-lcy19257-LCY X-Timer: - - S1593721259.794691,VS0,VE419 + - S1594033750.030340,VS0,VE160 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/waf_versions/getPostDeploy_0.yaml b/fastly/fixtures/waf_versions/getPostDeploy_0.yaml new file mode 100644 index 000000000..ab47db9ea --- /dev/null +++ b/fastly/fixtures/waf_versions/getPostDeploy_0.yaml @@ -0,0 +1,55 @@ +--- +version: 1 +interactions: +- request: + body: "" + form: {} + headers: + User-Agent: + - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) + url: https://api.fastly.com/waf/firewalls/7kRiB97L3ppEaKv5J3hJmV/versions/1 + method: GET + response: + body: '{"data":{"id":"6adJ5yqgOU9olga76asAr6","type":"waf_firewall_version","attributes":{"active":false,"active_rules_fastly_block_count":0,"active_rules_fastly_log_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_score_count":0,"active_rules_trustwave_block_count":0,"active_rules_trustwave_log_count":0,"allowed_http_versions":"HTTP/1.0 + HTTP/1.1 HTTP/2","allowed_methods":"GET HEAD POST OPTIONS PUT PATCH DELETE","allowed_request_content_type":"application/x-www-form-urlencoded|multipart/form-data|text/xml|application/xml|application/soap+xml|application/x-amf|application/json|application/octet-stream|application/csp-report|application/xss-auditor-report|text/plain","allowed_request_content_type_charset":"utf-8|iso-8859-1|iso-8859-15|windows-1252","arg_name_length":100,"arg_length":400,"combined_file_sizes":10000000,"comment":null,"created_at":"2020-07-06T11:09:07Z","critical_anomaly_score":5,"crs_validate_utf8_encoding":false,"deployed_at":null,"error":null,"error_anomaly_score":4,"high_risk_country_codes":"","http_violation_score_threshold":999,"inbound_anomaly_score_threshold":999,"last_deployment_status":"in + progress","lfi_score_threshold":999,"locked":false,"max_file_size":10000000,"max_num_args":255,"notice_anomaly_score":2,"number":1,"paranoia_level":1,"php_injection_score_threshold":999,"rce_score_threshold":999,"restricted_extensions":".asa/ + .asax/ .ascx/ .axd/ .backup/ .bak/ .bat/ .cdx/ .cer/ .cfg/ .cmd/ .com/ .config/ + .conf/ .cs/ .csproj/ .csr/ .dat/ .db/ .dbf/ .dll/ .dos/ .htr/ .htw/ .ida/ .idc/ + .idq/ .inc/ .ini/ .key/ .licx/ .lnk/ .log/ .mdb/ .old/ .pass/ .pdb/ .pol/ .printer/ + .pwd/ .resources/ .resx/ .sql/ .sys/ .vb/ .vbs/ .vbproj/ .vsdisco/ .webinfo/ + .xsd/ .xsx/","restricted_headers":"/proxy/ /lock-token/ /content-range/ /translate/ + /if/","rfi_score_threshold":999,"session_fixation_score_threshold":999,"sql_injection_score_threshold":999,"total_arg_length":6400,"updated_at":"2020-07-06T11:09:08Z","warning_anomaly_score":3,"xss_score_threshold":999}}}' + headers: + Accept-Ranges: + - bytes + - bytes + - bytes + Age: + - "0" + - "0" + Content-Length: + - "2039" + Content-Type: + - application/vnd.api+json + Date: + - Mon, 06 Jul 2020 11:09:08 GMT + Status: + - 200 OK + Strict-Transport-Security: + - max-age=31536000 + Via: + - 1.1 varnish + - 1.1 varnish + X-Cache: + - MISS, MISS + X-Cache-Hits: + - 0, 0 + X-Content-Type-Options: + - nosniff + X-Served-By: + - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19257-LCY + X-Timer: + - S1594033749.600415,VS0,VE156 + status: 200 OK + code: 200 + duration: "" diff --git a/fastly/fixtures/waf_versions/getPostDeploy_1.yaml b/fastly/fixtures/waf_versions/getPostDeploy_1.yaml new file mode 100644 index 000000000..ee26ce004 --- /dev/null +++ b/fastly/fixtures/waf_versions/getPostDeploy_1.yaml @@ -0,0 +1,50 @@ +--- +version: 1 +interactions: +- request: + body: "" + form: {} + headers: + User-Agent: + - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) + url: https://api.fastly.com/waf/firewalls/7kRiB97L3ppEaKv5J3hJmV/versions/1 + method: GET + response: + body: '{"data":{"id":"6adJ5yqgOU9olga76asAr6","type":"waf_firewall_version","attributes":{"active":true,"active_rules_fastly_block_count":0,"active_rules_fastly_log_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_score_count":0,"active_rules_trustwave_block_count":0,"active_rules_trustwave_log_count":0,"allowed_http_versions":"HTTP/1.0 + HTTP/1.1 HTTP/2","allowed_methods":"GET HEAD POST OPTIONS PUT PATCH DELETE","allowed_request_content_type":"application/x-www-form-urlencoded|multipart/form-data|text/xml|application/xml|application/soap+xml|application/x-amf|application/json|application/octet-stream|application/csp-report|application/xss-auditor-report|text/plain","allowed_request_content_type_charset":"utf-8|iso-8859-1|iso-8859-15|windows-1252","arg_name_length":100,"arg_length":400,"combined_file_sizes":10000000,"comment":null,"created_at":"2020-07-06T11:09:07Z","critical_anomaly_score":5,"crs_validate_utf8_encoding":false,"deployed_at":"2020-07-06T11:09:08Z","error":null,"error_anomaly_score":4,"high_risk_country_codes":"","http_violation_score_threshold":999,"inbound_anomaly_score_threshold":999,"last_deployment_status":"completed","lfi_score_threshold":999,"locked":true,"max_file_size":10000000,"max_num_args":255,"notice_anomaly_score":2,"number":1,"paranoia_level":1,"php_injection_score_threshold":999,"rce_score_threshold":999,"restricted_extensions":".asa/ + .asax/ .ascx/ .axd/ .backup/ .bak/ .bat/ .cdx/ .cer/ .cfg/ .cmd/ .com/ .config/ + .conf/ .cs/ .csproj/ .csr/ .dat/ .db/ .dbf/ .dll/ .dos/ .htr/ .htw/ .ida/ .idc/ + .idq/ .inc/ .ini/ .key/ .licx/ .lnk/ .log/ .mdb/ .old/ .pass/ .pdb/ .pol/ .printer/ + .pwd/ .resources/ .resx/ .sql/ .sys/ .vb/ .vbs/ .vbproj/ .vsdisco/ .webinfo/ + .xsd/ .xsx/","restricted_headers":"/proxy/ /lock-token/ /content-range/ /translate/ + /if/","rfi_score_threshold":999,"session_fixation_score_threshold":999,"sql_injection_score_threshold":999,"total_arg_length":6400,"updated_at":"2020-07-06T11:09:08Z","warning_anomaly_score":3,"xss_score_threshold":999}}}' + headers: + Accept-Ranges: + - bytes + - bytes + Content-Length: + - "2053" + Content-Type: + - application/vnd.api+json + Date: + - Mon, 06 Jul 2020 11:09:09 GMT + Status: + - 200 OK + Strict-Transport-Security: + - max-age=31536000 + Via: + - 1.1 varnish + - 1.1 varnish + X-Cache: + - MISS, MISS + X-Cache-Hits: + - 0, 0 + X-Content-Type-Options: + - nosniff + X-Served-By: + - cache-control-slwdc9036-CONTROL-SLWDC, cache-lcy19257-LCY + X-Timer: + - S1594033749.441229,VS0,VE161 + status: 200 OK + code: 200 + duration: "" diff --git a/fastly/fixtures/waf_versions/list.yaml b/fastly/fixtures/waf_versions/list.yaml index d4ce67d90..a026bcf10 100644 --- a/fastly/fixtures/waf_versions/list.yaml +++ b/fastly/fixtures/waf_versions/list.yaml @@ -7,17 +7,17 @@ interactions: headers: User-Agent: - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) - url: https://api.fastly.com/waf/firewalls/5oX1X8cVEBpEXg6PsNSTXA/versions + url: https://api.fastly.com/waf/firewalls/7kRiB97L3ppEaKv5J3hJmV/versions method: GET response: - body: '{"data":[{"id":"6oTvCXk15i1OiTbir1LNYn","type":"waf_firewall_version","attributes":{"active":false,"active_rules_fastly_block_count":0,"active_rules_fastly_log_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_score_count":0,"active_rules_trustwave_block_count":0,"active_rules_trustwave_log_count":0,"allowed_http_versions":"HTTP/1.0 - HTTP/1.1 HTTP/2","allowed_methods":"GET HEAD POST OPTIONS PUT PATCH DELETE","allowed_request_content_type":"application/x-www-form-urlencoded|multipart/form-data|text/xml|application/xml|application/soap+xml|application/x-amf|application/json|application/octet-stream|application/csp-report|application/xss-auditor-report|text/plain","allowed_request_content_type_charset":"utf-8|iso-8859-1|iso-8859-15|windows-1252","arg_name_length":100,"arg_length":400,"combined_file_sizes":10000000,"comment":null,"created_at":"2020-07-02T20:20:57Z","critical_anomaly_score":5,"crs_validate_utf8_encoding":false,"deployed_at":null,"error":null,"error_anomaly_score":4,"high_risk_country_codes":"","http_violation_score_threshold":999,"inbound_anomaly_score_threshold":999,"last_deployment_status":null,"lfi_score_threshold":999,"locked":false,"max_file_size":10000000,"max_num_args":255,"notice_anomaly_score":2,"number":1,"paranoia_level":1,"php_injection_score_threshold":999,"rce_score_threshold":999,"restricted_extensions":".asa/ + body: '{"data":[{"id":"6adJ5yqgOU9olga76asAr6","type":"waf_firewall_version","attributes":{"active":false,"active_rules_fastly_block_count":0,"active_rules_fastly_log_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_score_count":0,"active_rules_trustwave_block_count":0,"active_rules_trustwave_log_count":0,"allowed_http_versions":"HTTP/1.0 + HTTP/1.1 HTTP/2","allowed_methods":"GET HEAD POST OPTIONS PUT PATCH DELETE","allowed_request_content_type":"application/x-www-form-urlencoded|multipart/form-data|text/xml|application/xml|application/soap+xml|application/x-amf|application/json|application/octet-stream|application/csp-report|application/xss-auditor-report|text/plain","allowed_request_content_type_charset":"utf-8|iso-8859-1|iso-8859-15|windows-1252","arg_name_length":100,"arg_length":400,"combined_file_sizes":10000000,"comment":null,"created_at":"2020-07-06T11:09:07Z","critical_anomaly_score":5,"crs_validate_utf8_encoding":false,"deployed_at":null,"error":null,"error_anomaly_score":4,"high_risk_country_codes":"","http_violation_score_threshold":999,"inbound_anomaly_score_threshold":999,"last_deployment_status":null,"lfi_score_threshold":999,"locked":false,"max_file_size":10000000,"max_num_args":255,"notice_anomaly_score":2,"number":1,"paranoia_level":1,"php_injection_score_threshold":999,"rce_score_threshold":999,"restricted_extensions":".asa/ .asax/ .ascx/ .axd/ .backup/ .bak/ .bat/ .cdx/ .cer/ .cfg/ .cmd/ .com/ .config/ .conf/ .cs/ .csproj/ .csr/ .dat/ .db/ .dbf/ .dll/ .dos/ .htr/ .htw/ .ida/ .idc/ .idq/ .inc/ .ini/ .key/ .licx/ .lnk/ .log/ .mdb/ .old/ .pass/ .pdb/ .pol/ .printer/ .pwd/ .resources/ .resx/ .sql/ .sys/ .vb/ .vbs/ .vbproj/ .vsdisco/ .webinfo/ .xsd/ .xsx/","restricted_headers":"/proxy/ /lock-token/ /content-range/ /translate/ - /if/","rfi_score_threshold":999,"session_fixation_score_threshold":999,"sql_injection_score_threshold":999,"total_arg_length":6400,"updated_at":"2020-07-02T20:20:57Z","warning_anomaly_score":3,"xss_score_threshold":999}}],"links":{"last":"https://api.fastly.com/waf/firewalls/5oX1X8cVEBpEXg6PsNSTXA/versions?page[number]=1\u0026page[size]=100","first":"https://api.fastly.com/waf/firewalls/5oX1X8cVEBpEXg6PsNSTXA/versions?page[number]=1\u0026page[size]=100"},"meta":{"current_page":1,"per_page":100,"record_count":1,"total_pages":1}}' + /if/","rfi_score_threshold":999,"session_fixation_score_threshold":999,"sql_injection_score_threshold":999,"total_arg_length":6400,"updated_at":"2020-07-06T11:09:07Z","warning_anomaly_score":3,"xss_score_threshold":999}}],"links":{"last":"https://api.fastly.com/waf/firewalls/7kRiB97L3ppEaKv5J3hJmV/versions?page[number]=1\u0026page[size]=100","first":"https://api.fastly.com/waf/firewalls/7kRiB97L3ppEaKv5J3hJmV/versions?page[number]=1\u0026page[size]=100"},"meta":{"current_page":1,"per_page":100,"record_count":1,"total_pages":1}}' headers: Accept-Ranges: - bytes @@ -31,7 +31,7 @@ interactions: Content-Type: - application/vnd.api+json Date: - - Thu, 02 Jul 2020 20:20:58 GMT + - Mon, 06 Jul 2020 11:09:08 GMT Status: - 200 OK Strict-Transport-Security: @@ -46,9 +46,9 @@ interactions: X-Content-Type-Options: - nosniff X-Served-By: - - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19265-LCY + - cache-control-slwdc9036-CONTROL-SLWDC, cache-lcy19257-LCY X-Timer: - - S1593721258.886149,VS0,VE163 + - S1594033748.743478,VS0,VE397 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/waf_versions/list_all.yaml b/fastly/fixtures/waf_versions/list_all.yaml index e7b4928a1..f195412f5 100644 --- a/fastly/fixtures/waf_versions/list_all.yaml +++ b/fastly/fixtures/waf_versions/list_all.yaml @@ -7,21 +7,21 @@ interactions: headers: User-Agent: - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) - url: https://api.fastly.com/waf/firewalls/5oX1X8cVEBpEXg6PsNSTXA/versions?page%5Bnumber%5D=1&page%5Bsize%5D=100 + url: https://api.fastly.com/waf/firewalls/7kRiB97L3ppEaKv5J3hJmV/versions?page%5Bnumber%5D=1&page%5Bsize%5D=100 method: GET response: - body: '{"data":[{"id":"6q3TBLBKV00lMIsp0DC3wq","type":"waf_firewall_version","attributes":{"active":false,"active_rules_fastly_block_count":0,"active_rules_fastly_log_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_score_count":0,"active_rules_trustwave_block_count":0,"active_rules_trustwave_log_count":0,"allowed_http_versions":"HTTP/1.0 + body: '{"data":[{"id":"6BowSDK5ezUJMnkXOUWVuD","type":"waf_firewall_version","attributes":{"active":false,"active_rules_fastly_block_count":0,"active_rules_fastly_log_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_score_count":0,"active_rules_trustwave_block_count":0,"active_rules_trustwave_log_count":0,"allowed_http_versions":"HTTP/1.0 HTTP/1.1","allowed_methods":"GET HEAD POST","allowed_request_content_type":"application/x-www-form-urlencoded|multipart/form-data|text/xml|application/xml","allowed_request_content_type_charset":"utf-8|iso-8859-1","arg_name_length":200,"arg_length":800,"combined_file_sizes":20000000,"comment":"my - comment","created_at":"2020-07-02T20:20:58Z","critical_anomaly_score":12,"crs_validate_utf8_encoding":true,"deployed_at":null,"error":null,"error_anomaly_score":10,"high_risk_country_codes":"gb","http_violation_score_threshold":20,"inbound_anomaly_score_threshold":20,"last_deployment_status":null,"lfi_score_threshold":20,"locked":true,"max_file_size":20000000,"max_num_args":510,"notice_anomaly_score":8,"number":2,"paranoia_level":2,"php_injection_score_threshold":20,"rce_score_threshold":20,"restricted_extensions":".asa/ + comment","created_at":"2020-07-06T11:09:09Z","critical_anomaly_score":12,"crs_validate_utf8_encoding":true,"deployed_at":null,"error":null,"error_anomaly_score":10,"high_risk_country_codes":"gb","http_violation_score_threshold":20,"inbound_anomaly_score_threshold":20,"last_deployment_status":null,"lfi_score_threshold":20,"locked":true,"max_file_size":20000000,"max_num_args":510,"notice_anomaly_score":8,"number":2,"paranoia_level":2,"php_injection_score_threshold":20,"rce_score_threshold":20,"restricted_extensions":".asa/ .asax/ .ascx/ .axd/ .backup/ .bak/ .bat/ .cdx/ .cer/ .cfg/ .cmd/ .com/","restricted_headers":"/proxy/ - /lock-token/","rfi_score_threshold":20,"session_fixation_score_threshold":20,"sql_injection_score_threshold":20,"total_arg_length":12800,"updated_at":"2020-07-02T20:20:59Z","warning_anomaly_score":20,"xss_score_threshold":20}},{"id":"6oTvCXk15i1OiTbir1LNYn","type":"waf_firewall_version","attributes":{"active":true,"active_rules_fastly_block_count":0,"active_rules_fastly_log_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_score_count":0,"active_rules_trustwave_block_count":0,"active_rules_trustwave_log_count":0,"allowed_http_versions":"HTTP/1.0 - HTTP/1.1 HTTP/2","allowed_methods":"GET HEAD POST OPTIONS PUT PATCH DELETE","allowed_request_content_type":"application/x-www-form-urlencoded|multipart/form-data|text/xml|application/xml|application/soap+xml|application/x-amf|application/json|application/octet-stream|application/csp-report|application/xss-auditor-report|text/plain","allowed_request_content_type_charset":"utf-8|iso-8859-1|iso-8859-15|windows-1252","arg_name_length":100,"arg_length":400,"combined_file_sizes":10000000,"comment":null,"created_at":"2020-07-02T20:20:57Z","critical_anomaly_score":5,"crs_validate_utf8_encoding":false,"deployed_at":"2020-07-02T20:20:58Z","error":null,"error_anomaly_score":4,"high_risk_country_codes":"","http_violation_score_threshold":999,"inbound_anomaly_score_threshold":999,"last_deployment_status":"completed","lfi_score_threshold":999,"locked":true,"max_file_size":10000000,"max_num_args":255,"notice_anomaly_score":2,"number":1,"paranoia_level":1,"php_injection_score_threshold":999,"rce_score_threshold":999,"restricted_extensions":".asa/ + /lock-token/","rfi_score_threshold":20,"session_fixation_score_threshold":20,"sql_injection_score_threshold":20,"total_arg_length":12800,"updated_at":"2020-07-06T11:09:10Z","warning_anomaly_score":20,"xss_score_threshold":20}},{"id":"6adJ5yqgOU9olga76asAr6","type":"waf_firewall_version","attributes":{"active":true,"active_rules_fastly_block_count":0,"active_rules_fastly_log_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_score_count":0,"active_rules_trustwave_block_count":0,"active_rules_trustwave_log_count":0,"allowed_http_versions":"HTTP/1.0 + HTTP/1.1 HTTP/2","allowed_methods":"GET HEAD POST OPTIONS PUT PATCH DELETE","allowed_request_content_type":"application/x-www-form-urlencoded|multipart/form-data|text/xml|application/xml|application/soap+xml|application/x-amf|application/json|application/octet-stream|application/csp-report|application/xss-auditor-report|text/plain","allowed_request_content_type_charset":"utf-8|iso-8859-1|iso-8859-15|windows-1252","arg_name_length":100,"arg_length":400,"combined_file_sizes":10000000,"comment":null,"created_at":"2020-07-06T11:09:07Z","critical_anomaly_score":5,"crs_validate_utf8_encoding":false,"deployed_at":"2020-07-06T11:09:08Z","error":null,"error_anomaly_score":4,"high_risk_country_codes":"","http_violation_score_threshold":999,"inbound_anomaly_score_threshold":999,"last_deployment_status":"completed","lfi_score_threshold":999,"locked":true,"max_file_size":10000000,"max_num_args":255,"notice_anomaly_score":2,"number":1,"paranoia_level":1,"php_injection_score_threshold":999,"rce_score_threshold":999,"restricted_extensions":".asa/ .asax/ .ascx/ .axd/ .backup/ .bak/ .bat/ .cdx/ .cer/ .cfg/ .cmd/ .com/ .config/ .conf/ .cs/ .csproj/ .csr/ .dat/ .db/ .dbf/ .dll/ .dos/ .htr/ .htw/ .ida/ .idc/ .idq/ .inc/ .ini/ .key/ .licx/ .lnk/ .log/ .mdb/ .old/ .pass/ .pdb/ .pol/ .printer/ .pwd/ .resources/ .resx/ .sql/ .sys/ .vb/ .vbs/ .vbproj/ .vsdisco/ .webinfo/ .xsd/ .xsx/","restricted_headers":"/proxy/ /lock-token/ /content-range/ /translate/ - /if/","rfi_score_threshold":999,"session_fixation_score_threshold":999,"sql_injection_score_threshold":999,"total_arg_length":6400,"updated_at":"2020-07-02T20:20:58Z","warning_anomaly_score":3,"xss_score_threshold":999}}],"links":{"last":"https://api.fastly.com/waf/firewalls/5oX1X8cVEBpEXg6PsNSTXA/versions?page[number]=1\u0026page[size]=100","first":"https://api.fastly.com/waf/firewalls/5oX1X8cVEBpEXg6PsNSTXA/versions?page[number]=1\u0026page[size]=100"},"meta":{"current_page":1,"per_page":100,"record_count":2,"total_pages":1}}' + /if/","rfi_score_threshold":999,"session_fixation_score_threshold":999,"sql_injection_score_threshold":999,"total_arg_length":6400,"updated_at":"2020-07-06T11:09:08Z","warning_anomaly_score":3,"xss_score_threshold":999}}],"links":{"last":"https://api.fastly.com/waf/firewalls/7kRiB97L3ppEaKv5J3hJmV/versions?page[number]=1\u0026page[size]=100","first":"https://api.fastly.com/waf/firewalls/7kRiB97L3ppEaKv5J3hJmV/versions?page[number]=1\u0026page[size]=100"},"meta":{"current_page":1,"per_page":100,"record_count":2,"total_pages":1}}' headers: Accept-Ranges: - bytes @@ -35,7 +35,7 @@ interactions: Content-Type: - application/vnd.api+json Date: - - Thu, 02 Jul 2020 20:21:00 GMT + - Mon, 06 Jul 2020 11:09:11 GMT Status: - 200 OK Strict-Transport-Security: @@ -50,9 +50,9 @@ interactions: X-Content-Type-Options: - nosniff X-Served-By: - - cache-control-slwdc9036-CONTROL-SLWDC, cache-lcy19265-LCY + - cache-control-slwdc9035-CONTROL-SLWDC, cache-lcy19257-LCY X-Timer: - - S1593721260.916258,VS0,VE392 + - S1594033751.890658,VS0,VE459 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/waf_versions/lock.yaml b/fastly/fixtures/waf_versions/lock.yaml index f1cba3dc0..d6855e909 100644 --- a/fastly/fixtures/waf_versions/lock.yaml +++ b/fastly/fixtures/waf_versions/lock.yaml @@ -12,14 +12,14 @@ interactions: - application/vnd.api+json User-Agent: - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) - url: https://api.fastly.com/waf/firewalls/5oX1X8cVEBpEXg6PsNSTXA/versions/2 + url: https://api.fastly.com/waf/firewalls/7kRiB97L3ppEaKv5J3hJmV/versions/2 method: PATCH response: - body: '{"data":{"id":"6q3TBLBKV00lMIsp0DC3wq","type":"waf_firewall_version","attributes":{"active":false,"active_rules_fastly_block_count":0,"active_rules_fastly_log_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_score_count":0,"active_rules_trustwave_block_count":0,"active_rules_trustwave_log_count":0,"allowed_http_versions":"HTTP/1.0 + body: '{"data":{"id":"6BowSDK5ezUJMnkXOUWVuD","type":"waf_firewall_version","attributes":{"active":false,"active_rules_fastly_block_count":0,"active_rules_fastly_log_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_score_count":0,"active_rules_trustwave_block_count":0,"active_rules_trustwave_log_count":0,"allowed_http_versions":"HTTP/1.0 HTTP/1.1","allowed_methods":"GET HEAD POST","allowed_request_content_type":"application/x-www-form-urlencoded|multipart/form-data|text/xml|application/xml","allowed_request_content_type_charset":"utf-8|iso-8859-1","arg_name_length":200,"arg_length":800,"combined_file_sizes":20000000,"comment":"my - comment","created_at":"2020-07-02T20:20:58Z","critical_anomaly_score":12,"crs_validate_utf8_encoding":true,"deployed_at":null,"error":null,"error_anomaly_score":10,"high_risk_country_codes":"gb","http_violation_score_threshold":20,"inbound_anomaly_score_threshold":20,"last_deployment_status":null,"lfi_score_threshold":20,"locked":true,"max_file_size":20000000,"max_num_args":510,"notice_anomaly_score":8,"number":2,"paranoia_level":2,"php_injection_score_threshold":20,"rce_score_threshold":20,"restricted_extensions":".asa/ + comment","created_at":"2020-07-06T11:09:09Z","critical_anomaly_score":12,"crs_validate_utf8_encoding":true,"deployed_at":null,"error":null,"error_anomaly_score":10,"high_risk_country_codes":"gb","http_violation_score_threshold":20,"inbound_anomaly_score_threshold":20,"last_deployment_status":null,"lfi_score_threshold":20,"locked":true,"max_file_size":20000000,"max_num_args":510,"notice_anomaly_score":8,"number":2,"paranoia_level":2,"php_injection_score_threshold":20,"rce_score_threshold":20,"restricted_extensions":".asa/ .asax/ .ascx/ .axd/ .backup/ .bak/ .bat/ .cdx/ .cer/ .cfg/ .cmd/ .com/","restricted_headers":"/proxy/ - /lock-token/","rfi_score_threshold":20,"session_fixation_score_threshold":20,"sql_injection_score_threshold":20,"total_arg_length":12800,"updated_at":"2020-07-02T20:20:59Z","warning_anomaly_score":20,"xss_score_threshold":20},"relationships":{"waf_firewall":{"data":{"id":"5oX1X8cVEBpEXg6PsNSTXA","type":"waf_firewall"}}}}}' + /lock-token/","rfi_score_threshold":20,"session_fixation_score_threshold":20,"sql_injection_score_threshold":20,"total_arg_length":12800,"updated_at":"2020-07-06T11:09:10Z","warning_anomaly_score":20,"xss_score_threshold":20},"relationships":{"waf_firewall":{"data":{"id":"7kRiB97L3ppEaKv5J3hJmV","type":"waf_firewall"}}}}}' headers: Accept-Ranges: - bytes @@ -29,7 +29,7 @@ interactions: Content-Type: - application/vnd.api+json Date: - - Thu, 02 Jul 2020 20:20:59 GMT + - Mon, 06 Jul 2020 11:09:10 GMT Status: - 200 OK Strict-Transport-Security: @@ -44,9 +44,9 @@ interactions: X-Content-Type-Options: - nosniff X-Served-By: - - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19265-LCY + - cache-control-slwdc9036-CONTROL-SLWDC, cache-lcy19257-LCY X-Timer: - - S1593721260.560847,VS0,VE167 + - S1594033751.529078,VS0,VE157 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/waf_versions/logging/create.yaml b/fastly/fixtures/waf_versions/logging/create.yaml index 57cef883b..08afb3deb 100644 --- a/fastly/fixtures/waf_versions/logging/create.yaml +++ b/fastly/fixtures/waf_versions/logging/create.yaml @@ -2,10 +2,10 @@ version: 1 interactions: - request: - body: Service=52szbbqIWi1L5bUd4EBKkX&Version=2&address=example.com&format=format&format_version=2&hostname=example.com&message_type=classic&name=test-syslog&port=1234&token=abcd1234 + body: Service=5GZsX83POn5zij6allCOKe&Version=2&address=example.com&format=format&format_version=2&hostname=example.com&message_type=classic&name=test-syslog&port=1234&token=abcd1234 form: Service: - - 52szbbqIWi1L5bUd4EBKkX + - 5GZsX83POn5zij6allCOKe Version: - "2" address: @@ -29,10 +29,10 @@ interactions: - application/x-www-form-urlencoded User-Agent: - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) - url: https://api.fastly.com/service/52szbbqIWi1L5bUd4EBKkX/version/2/logging/syslog + url: https://api.fastly.com/service/5GZsX83POn5zij6allCOKe/version/2/logging/syslog method: POST response: - body: '{"address":"example.com","format":"format","format_version":"2","hostname":"example.com","message_type":"classic","name":"test-syslog","port":"1234","token":"abcd1234","service_id":"52szbbqIWi1L5bUd4EBKkX","version":"2","tls_hostname":null,"tls_ca_cert":null,"use_tls":"0","tls_client_key":null,"public_key":null,"deleted_at":null,"placement":null,"tls_client_cert":null,"ipv4":null,"created_at":"2020-07-02T20:20:55Z","response_condition":"","updated_at":"2020-07-02T20:20:55Z"}' + body: '{"address":"example.com","format":"format","format_version":"2","hostname":"example.com","message_type":"classic","name":"test-syslog","port":"1234","token":"abcd1234","service_id":"5GZsX83POn5zij6allCOKe","version":"2","tls_client_cert":null,"deleted_at":null,"created_at":"2020-07-06T11:09:05Z","updated_at":"2020-07-06T11:09:05Z","tls_hostname":null,"tls_ca_cert":null,"placement":null,"ipv4":null,"tls_client_key":null,"public_key":null,"use_tls":"0","response_condition":""}' headers: Accept-Ranges: - bytes @@ -42,11 +42,11 @@ interactions: Content-Type: - application/json Date: - - Thu, 02 Jul 2020 20:20:55 GMT + - Mon, 06 Jul 2020 11:09:05 GMT Fastly-Ratelimit-Remaining: - - "952" + - "979" Fastly-Ratelimit-Reset: - - "1593723600" + - "1594036800" Status: - 200 OK Strict-Transport-Security: @@ -61,9 +61,9 @@ interactions: X-Cache-Hits: - 0, 0 X-Served-By: - - cache-control-slwdc9035-CONTROL-SLWDC, cache-lcy19265-LCY + - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19257-LCY X-Timer: - - S1593721255.159701,VS0,VE719 + - S1594033745.359766,VS0,VE496 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/waf_versions/logging/delete.yaml b/fastly/fixtures/waf_versions/logging/delete.yaml index cc9646daa..5accec35b 100644 --- a/fastly/fixtures/waf_versions/logging/delete.yaml +++ b/fastly/fixtures/waf_versions/logging/delete.yaml @@ -7,7 +7,7 @@ interactions: headers: User-Agent: - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) - url: https://api.fastly.com/service/52szbbqIWi1L5bUd4EBKkX/version/2/logging/syslog/test-syslog + url: https://api.fastly.com/service/5GZsX83POn5zij6allCOKe/version/2/logging/syslog/test-syslog method: DELETE response: body: '{"status":"ok"}' @@ -20,11 +20,11 @@ interactions: Content-Type: - application/json Date: - - Thu, 02 Jul 2020 20:21:02 GMT + - Mon, 06 Jul 2020 11:09:13 GMT Fastly-Ratelimit-Remaining: - - "947" + - "974" Fastly-Ratelimit-Reset: - - "1593723600" + - "1594036800" Status: - 200 OK Strict-Transport-Security: @@ -39,9 +39,9 @@ interactions: X-Cache-Hits: - 0, 0 X-Served-By: - - cache-control-slwdc9035-CONTROL-SLWDC, cache-lcy19265-LCY + - cache-control-slwdc9035-CONTROL-SLWDC, cache-lcy19257-LCY X-Timer: - - S1593721262.118224,VS0,VE245 + - S1594033753.121374,VS0,VE260 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/waf_versions/response_object/create.yaml b/fastly/fixtures/waf_versions/response_object/create.yaml index de5614f6f..f058fc868 100644 --- a/fastly/fixtures/waf_versions/response_object/create.yaml +++ b/fastly/fixtures/waf_versions/response_object/create.yaml @@ -2,10 +2,10 @@ version: 1 interactions: - request: - body: Service=52szbbqIWi1L5bUd4EBKkX&Version=2&name=WAf_Response&status=403 + body: Service=5GZsX83POn5zij6allCOKe&Version=2&name=WAf_Response&status=403 form: Service: - - 52szbbqIWi1L5bUd4EBKkX + - 5GZsX83POn5zij6allCOKe Version: - "2" name: @@ -17,10 +17,10 @@ interactions: - application/x-www-form-urlencoded User-Agent: - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) - url: https://api.fastly.com/service/52szbbqIWi1L5bUd4EBKkX/version/2/response_object + url: https://api.fastly.com/service/5GZsX83POn5zij6allCOKe/version/2/response_object method: POST response: - body: '{"name":"WAf_Response","status":"403","service_id":"52szbbqIWi1L5bUd4EBKkX","version":"2","content":null,"response":"ok","updated_at":"2020-07-02T20:20:56Z","cache_condition":"","created_at":"2020-07-02T20:20:56Z","request_condition":"","deleted_at":null,"content_type":null}' + body: '{"name":"WAf_Response","status":"403","service_id":"5GZsX83POn5zij6allCOKe","version":"2","request_condition":"","content_type":null,"created_at":"2020-07-06T11:09:06Z","deleted_at":null,"response":"ok","content":null,"cache_condition":"","updated_at":"2020-07-06T11:09:06Z"}' headers: Accept-Ranges: - bytes @@ -30,11 +30,11 @@ interactions: Content-Type: - application/json Date: - - Thu, 02 Jul 2020 20:20:56 GMT + - Mon, 06 Jul 2020 11:09:06 GMT Fastly-Ratelimit-Remaining: - - "950" + - "977" Fastly-Ratelimit-Reset: - - "1593723600" + - "1594036800" Status: - 200 OK Strict-Transport-Security: @@ -49,9 +49,9 @@ interactions: X-Cache-Hits: - 0, 0 X-Served-By: - - cache-control-slwdc9035-CONTROL-SLWDC, cache-lcy19265-LCY + - cache-control-slwdc9036-CONTROL-SLWDC, cache-lcy19257-LCY X-Timer: - - S1593721256.343174,VS0,VE213 + - S1594033746.319287,VS0,VE242 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/waf_versions/response_object/delete.yaml b/fastly/fixtures/waf_versions/response_object/delete.yaml index a2d8a9249..4561cda2a 100644 --- a/fastly/fixtures/waf_versions/response_object/delete.yaml +++ b/fastly/fixtures/waf_versions/response_object/delete.yaml @@ -7,7 +7,7 @@ interactions: headers: User-Agent: - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) - url: https://api.fastly.com/service/52szbbqIWi1L5bUd4EBKkX/version/2/response_object/WAf_Response + url: https://api.fastly.com/service/5GZsX83POn5zij6allCOKe/version/2/response_object/WAf_Response method: DELETE response: body: '{"status":"ok"}' @@ -20,11 +20,11 @@ interactions: Content-Type: - application/json Date: - - Thu, 02 Jul 2020 20:21:01 GMT + - Mon, 06 Jul 2020 11:09:12 GMT Fastly-Ratelimit-Remaining: - - "949" + - "976" Fastly-Ratelimit-Reset: - - "1593723600" + - "1594036800" Status: - 200 OK Strict-Transport-Security: @@ -39,9 +39,9 @@ interactions: X-Cache-Hits: - 0, 0 X-Served-By: - - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19265-LCY + - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19257-LCY X-Timer: - - S1593721261.253414,VS0,VE268 + - S1594033752.264087,VS0,VE236 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/waf_versions/service/create.yaml b/fastly/fixtures/waf_versions/service/create.yaml index f966ab99a..015a90447 100644 --- a/fastly/fixtures/waf_versions/service/create.yaml +++ b/fastly/fixtures/waf_versions/service/create.yaml @@ -18,7 +18,7 @@ interactions: url: https://api.fastly.com/service method: POST response: - body: '{"customer_id":"WpqWFjTA4lk2N1g0GY2HH","comment":"go-fastly client test","name":"test_service_service3","type":"vcl","created_at":"2020-07-02T20:20:54Z","id":"52szbbqIWi1L5bUd4EBKkX","versions":[{"comment":"","deployed":false,"staging":false,"service_id":"52szbbqIWi1L5bUd4EBKkX","locked":false,"deleted_at":null,"updated_at":"2020-07-02T20:20:54Z","created_at":"2020-07-02T20:20:54Z","number":1,"active":false,"testing":false}],"publish_key":"","deleted_at":null,"updated_at":"2020-07-02T20:20:54Z"}' + body: '{"customer_id":"WpqWFjTA4lk2N1g0GY2HH","comment":"go-fastly client test","name":"test_service_service3","type":"vcl","id":"5GZsX83POn5zij6allCOKe","versions":[{"testing":false,"active":false,"service_id":"5GZsX83POn5zij6allCOKe","number":1,"created_at":"2020-07-06T11:09:04Z","updated_at":"2020-07-06T11:09:04Z","deleted_at":null,"locked":false,"deployed":false,"comment":"","staging":false}],"created_at":"2020-07-06T11:09:04Z","publish_key":"","updated_at":"2020-07-06T11:09:04Z","deleted_at":null}' headers: Accept-Ranges: - bytes @@ -28,11 +28,11 @@ interactions: Content-Type: - application/json Date: - - Thu, 02 Jul 2020 20:20:54 GMT + - Mon, 06 Jul 2020 11:09:04 GMT Fastly-Ratelimit-Remaining: - - "954" + - "981" Fastly-Ratelimit-Reset: - - "1593723600" + - "1594036800" Status: - 200 OK Strict-Transport-Security: @@ -47,9 +47,9 @@ interactions: X-Cache-Hits: - 0, 0 X-Served-By: - - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19265-LCY + - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19257-LCY X-Timer: - - S1593721254.141906,VS0,VE474 + - S1594033744.045220,VS0,VE487 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/waf_versions/service/delete.yaml b/fastly/fixtures/waf_versions/service/delete.yaml index 1fb1aa4e3..da204d6a4 100644 --- a/fastly/fixtures/waf_versions/service/delete.yaml +++ b/fastly/fixtures/waf_versions/service/delete.yaml @@ -7,7 +7,7 @@ interactions: headers: User-Agent: - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) - url: https://api.fastly.com/service/52szbbqIWi1L5bUd4EBKkX + url: https://api.fastly.com/service/5GZsX83POn5zij6allCOKe method: DELETE response: body: '{"status":"ok"}' @@ -20,11 +20,11 @@ interactions: Content-Type: - application/json Date: - - Thu, 02 Jul 2020 20:21:02 GMT + - Mon, 06 Jul 2020 11:09:14 GMT Fastly-Ratelimit-Remaining: - - "946" + - "973" Fastly-Ratelimit-Reset: - - "1593723600" + - "1594036800" Status: - 200 OK Strict-Transport-Security: @@ -39,9 +39,9 @@ interactions: X-Cache-Hits: - 0, 0 X-Served-By: - - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19265-LCY + - cache-control-slwdc9035-CONTROL-SLWDC, cache-lcy19257-LCY X-Timer: - - S1593721263.555733,VS0,VE231 + - S1594033754.569065,VS0,VE615 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/waf_versions/service/version.yaml b/fastly/fixtures/waf_versions/service/version.yaml index 40ac06603..bfb29161a 100644 --- a/fastly/fixtures/waf_versions/service/version.yaml +++ b/fastly/fixtures/waf_versions/service/version.yaml @@ -2,19 +2,19 @@ version: 1 interactions: - request: - body: Service=52szbbqIWi1L5bUd4EBKkX + body: Service=5GZsX83POn5zij6allCOKe form: Service: - - 52szbbqIWi1L5bUd4EBKkX + - 5GZsX83POn5zij6allCOKe headers: Content-Type: - application/x-www-form-urlencoded User-Agent: - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) - url: https://api.fastly.com/service/52szbbqIWi1L5bUd4EBKkX/version + url: https://api.fastly.com/service/5GZsX83POn5zij6allCOKe/version method: POST response: - body: '{"service_id":"52szbbqIWi1L5bUd4EBKkX","number":2}' + body: '{"service_id":"5GZsX83POn5zij6allCOKe","number":2}' headers: Accept-Ranges: - bytes @@ -24,11 +24,11 @@ interactions: Content-Type: - application/json Date: - - Thu, 02 Jul 2020 20:20:55 GMT + - Mon, 06 Jul 2020 11:09:05 GMT Fastly-Ratelimit-Remaining: - - "953" + - "980" Fastly-Ratelimit-Reset: - - "1593723600" + - "1594036800" Status: - 200 OK Strict-Transport-Security: @@ -43,9 +43,9 @@ interactions: X-Cache-Hits: - 0, 0 X-Served-By: - - cache-control-slwdc9036-CONTROL-SLWDC, cache-lcy19265-LCY + - cache-control-slwdc9035-CONTROL-SLWDC, cache-lcy19257-LCY X-Timer: - - S1593721255.771073,VS0,VE244 + - S1594033745.664307,VS0,VE540 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/waf_versions/update.yaml b/fastly/fixtures/waf_versions/update.yaml index 69127ca74..007492f2e 100644 --- a/fastly/fixtures/waf_versions/update.yaml +++ b/fastly/fixtures/waf_versions/update.yaml @@ -3,7 +3,7 @@ version: 1 interactions: - request: body: | - {"data":{"type":"waf_firewall_version","id":"6q3TBLBKV00lMIsp0DC3wq","attributes":{"allowed_http_versions":"HTTP/1.0 HTTP/1.1","allowed_methods":"GET HEAD POST","allowed_request_content_type":"application/x-www-form-urlencoded|multipart/form-data|text/xml|application/xml","allowed_request_content_type_charset":"utf-8|iso-8859-1","arg_length":800,"arg_name_length":200,"combined_file_sizes":20000000,"comment":"my comment","critical_anomaly_score":12,"crs_validate_utf8_encoding":true,"error_anomaly_score":10,"high_risk_country_codes":"gb","http_violation_score_threshold":20,"inbound_anomaly_score_threshold":20,"lfi_score_threshold":20,"max_file_size":20000000,"max_num_args":510,"notice_anomaly_score":8,"paranoia_level":2,"php_injection_score_threshold":20,"rce_score_threshold":20,"restricted_extensions":".asa/ .asax/ .ascx/ .axd/ .backup/ .bak/ .bat/ .cdx/ .cer/ .cfg/ .cmd/ .com/","restricted_headers":"/proxy/ /lock-token/","rfi_score_threshold":20,"session_fixation_score_threshold":20,"sql_injection_score_threshold":20,"total_arg_length":12800,"warning_anomaly_score":20,"xss_score_threshold":20}}} + {"data":{"type":"waf_firewall_version","id":"6BowSDK5ezUJMnkXOUWVuD","attributes":{"allowed_http_versions":"HTTP/1.0 HTTP/1.1","allowed_methods":"GET HEAD POST","allowed_request_content_type":"application/x-www-form-urlencoded|multipart/form-data|text/xml|application/xml","allowed_request_content_type_charset":"utf-8|iso-8859-1","arg_length":800,"arg_name_length":200,"combined_file_sizes":20000000,"comment":"my comment","critical_anomaly_score":12,"crs_validate_utf8_encoding":true,"error_anomaly_score":10,"high_risk_country_codes":"gb","http_violation_score_threshold":20,"inbound_anomaly_score_threshold":20,"lfi_score_threshold":20,"max_file_size":20000000,"max_num_args":510,"notice_anomaly_score":8,"paranoia_level":2,"php_injection_score_threshold":20,"rce_score_threshold":20,"restricted_extensions":".asa/ .asax/ .ascx/ .axd/ .backup/ .bak/ .bat/ .cdx/ .cer/ .cfg/ .cmd/ .com/","restricted_headers":"/proxy/ /lock-token/","rfi_score_threshold":20,"session_fixation_score_threshold":20,"sql_injection_score_threshold":20,"total_arg_length":12800,"warning_anomaly_score":20,"xss_score_threshold":20}}} form: {} headers: Accept: @@ -12,14 +12,14 @@ interactions: - application/vnd.api+json User-Agent: - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) - url: https://api.fastly.com/waf/firewalls/5oX1X8cVEBpEXg6PsNSTXA/versions/2 + url: https://api.fastly.com/waf/firewalls/7kRiB97L3ppEaKv5J3hJmV/versions/2 method: PATCH response: - body: '{"data":{"id":"6q3TBLBKV00lMIsp0DC3wq","type":"waf_firewall_version","attributes":{"active":false,"active_rules_fastly_block_count":0,"active_rules_fastly_log_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_score_count":0,"active_rules_trustwave_block_count":0,"active_rules_trustwave_log_count":0,"allowed_http_versions":"HTTP/1.0 + body: '{"data":{"id":"6BowSDK5ezUJMnkXOUWVuD","type":"waf_firewall_version","attributes":{"active":false,"active_rules_fastly_block_count":0,"active_rules_fastly_log_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_score_count":0,"active_rules_trustwave_block_count":0,"active_rules_trustwave_log_count":0,"allowed_http_versions":"HTTP/1.0 HTTP/1.1","allowed_methods":"GET HEAD POST","allowed_request_content_type":"application/x-www-form-urlencoded|multipart/form-data|text/xml|application/xml","allowed_request_content_type_charset":"utf-8|iso-8859-1","arg_name_length":200,"arg_length":800,"combined_file_sizes":20000000,"comment":"my - comment","created_at":"2020-07-02T20:20:58Z","critical_anomaly_score":12,"crs_validate_utf8_encoding":true,"deployed_at":null,"error":null,"error_anomaly_score":10,"high_risk_country_codes":"gb","http_violation_score_threshold":20,"inbound_anomaly_score_threshold":20,"last_deployment_status":null,"lfi_score_threshold":20,"locked":false,"max_file_size":20000000,"max_num_args":510,"notice_anomaly_score":8,"number":2,"paranoia_level":2,"php_injection_score_threshold":20,"rce_score_threshold":20,"restricted_extensions":".asa/ + comment","created_at":"2020-07-06T11:09:09Z","critical_anomaly_score":12,"crs_validate_utf8_encoding":true,"deployed_at":null,"error":null,"error_anomaly_score":10,"high_risk_country_codes":"gb","http_violation_score_threshold":20,"inbound_anomaly_score_threshold":20,"last_deployment_status":null,"lfi_score_threshold":20,"locked":false,"max_file_size":20000000,"max_num_args":510,"notice_anomaly_score":8,"number":2,"paranoia_level":2,"php_injection_score_threshold":20,"rce_score_threshold":20,"restricted_extensions":".asa/ .asax/ .ascx/ .axd/ .backup/ .bak/ .bat/ .cdx/ .cer/ .cfg/ .cmd/ .com/","restricted_headers":"/proxy/ - /lock-token/","rfi_score_threshold":20,"session_fixation_score_threshold":20,"sql_injection_score_threshold":20,"total_arg_length":12800,"updated_at":"2020-07-02T20:20:59Z","warning_anomaly_score":20,"xss_score_threshold":20},"relationships":{"waf_firewall":{"data":{"id":"5oX1X8cVEBpEXg6PsNSTXA","type":"waf_firewall"}}}}}' + /lock-token/","rfi_score_threshold":20,"session_fixation_score_threshold":20,"sql_injection_score_threshold":20,"total_arg_length":12800,"updated_at":"2020-07-06T11:09:10Z","warning_anomaly_score":20,"xss_score_threshold":20},"relationships":{"waf_firewall":{"data":{"id":"7kRiB97L3ppEaKv5J3hJmV","type":"waf_firewall"}}}}}' headers: Accept-Ranges: - bytes @@ -29,7 +29,7 @@ interactions: Content-Type: - application/vnd.api+json Date: - - Thu, 02 Jul 2020 20:20:59 GMT + - Mon, 06 Jul 2020 11:09:10 GMT Status: - 200 OK Strict-Transport-Security: @@ -44,9 +44,9 @@ interactions: X-Content-Type-Options: - nosniff X-Served-By: - - cache-control-slwdc9035-CONTROL-SLWDC, cache-lcy19265-LCY + - cache-control-slwdc9036-CONTROL-SLWDC, cache-lcy19257-LCY X-Timer: - - S1593721259.289697,VS0,VE140 + - S1594033750.290024,VS0,VE118 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/waf_versions/waf/create.yaml b/fastly/fixtures/waf_versions/waf/create.yaml index 6b39e8565..cc5d3b9d4 100644 --- a/fastly/fixtures/waf_versions/waf/create.yaml +++ b/fastly/fixtures/waf_versions/waf/create.yaml @@ -3,7 +3,7 @@ version: 1 interactions: - request: body: | - {"data":{"type":"waf_firewall","attributes":{"prefetch_condition":"WAF_Prefetch","response":"WAf_Response","service_id":"52szbbqIWi1L5bUd4EBKkX","service_version_number":"2"}}} + {"data":{"type":"waf_firewall","attributes":{"prefetch_condition":"WAF_Prefetch","response":"WAf_Response","service_id":"5GZsX83POn5zij6allCOKe","service_version_number":"2"}}} form: {} headers: Accept: @@ -15,7 +15,7 @@ interactions: url: https://api.fastly.com/waf/firewalls method: POST response: - body: '{"data":{"id":"5oX1X8cVEBpEXg6PsNSTXA","type":"waf_firewall","attributes":{"active_rules_fastly_block_count":0,"active_rules_fastly_log_count":0,"active_rules_fastly_score_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_score_count":0,"active_rules_trustwave_block_count":0,"active_rules_trustwave_log_count":0,"created_at":"2020-07-02T20:20:57Z","disabled":false,"prefetch_condition":"WAF_Prefetch","response":"WAf_Response","service_id":"52szbbqIWi1L5bUd4EBKkX","service_version_number":2,"updated_at":"2020-07-02T20:20:57Z"}}}' + body: '{"data":{"id":"7kRiB97L3ppEaKv5J3hJmV","type":"waf_firewall","attributes":{"active_rules_fastly_block_count":0,"active_rules_fastly_log_count":0,"active_rules_fastly_score_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_score_count":0,"active_rules_trustwave_block_count":0,"active_rules_trustwave_log_count":0,"created_at":"2020-07-06T11:09:07Z","disabled":false,"prefetch_condition":"WAF_Prefetch","response":"WAf_Response","service_id":"5GZsX83POn5zij6allCOKe","service_version_number":2,"updated_at":"2020-07-06T11:09:07Z"}}}' headers: Accept-Ranges: - bytes @@ -25,7 +25,7 @@ interactions: Content-Type: - application/vnd.api+json Date: - - Thu, 02 Jul 2020 20:20:57 GMT + - Mon, 06 Jul 2020 11:09:07 GMT Status: - 201 Created Strict-Transport-Security: @@ -40,9 +40,9 @@ interactions: X-Content-Type-Options: - nosniff X-Served-By: - - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19265-LCY + - cache-control-slwdc9035-CONTROL-SLWDC, cache-lcy19257-LCY X-Timer: - - S1593721257.721769,VS0,VE968 + - S1594033747.712036,VS0,VE839 status: 201 Created code: 201 duration: "" diff --git a/fastly/fixtures/waf_versions/waf/delete.yaml b/fastly/fixtures/waf_versions/waf/delete.yaml index 6824ca11b..b1a07b427 100644 --- a/fastly/fixtures/waf_versions/waf/delete.yaml +++ b/fastly/fixtures/waf_versions/waf/delete.yaml @@ -3,7 +3,7 @@ version: 1 interactions: - request: body: | - {"data":{"type":"waf_firewall","id":"5oX1X8cVEBpEXg6PsNSTXA","attributes":{"service_version_number":"2"}}} + {"data":{"type":"waf_firewall","id":"7kRiB97L3ppEaKv5J3hJmV","attributes":{"service_version_number":"2"}}} form: {} headers: Accept: @@ -12,7 +12,7 @@ interactions: - application/vnd.api+json User-Agent: - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) - url: https://api.fastly.com/waf/firewalls/5oX1X8cVEBpEXg6PsNSTXA + url: https://api.fastly.com/waf/firewalls/7kRiB97L3ppEaKv5J3hJmV method: DELETE response: body: "" @@ -21,7 +21,7 @@ interactions: - bytes - bytes Date: - - Thu, 02 Jul 2020 20:21:01 GMT + - Mon, 06 Jul 2020 11:09:12 GMT Status: - 204 No Content Strict-Transport-Security: @@ -36,9 +36,9 @@ interactions: X-Content-Type-Options: - nosniff X-Served-By: - - cache-control-slwdc9035-CONTROL-SLWDC, cache-lcy19265-LCY + - cache-control-slwdc9037-CONTROL-SLWDC, cache-lcy19257-LCY X-Timer: - - S1593721261.790412,VS0,VE281 + - S1594033752.780170,VS0,VE305 status: 204 No Content code: 204 duration: "" diff --git a/fastly/waf_version.go b/fastly/waf_version.go index 8dd79407b..ba7fd88da 100644 --- a/fastly/waf_version.go +++ b/fastly/waf_version.go @@ -26,7 +26,7 @@ const ( WAFVersionDeploymentStatusPending = "pending" // WAFVersionDeploymentStatusInProgress is the string value representing in-progress state for last_deployment_status for a WAF version - WAFVersionDeploymentStatusInProgress = "in-progress" + WAFVersionDeploymentStatusInProgress = "in progress" // WAFVersionDeploymentStatusCompleted is the string value representing completed state for last_deployment_status for a WAF versions WAFVersionDeploymentStatusCompleted = "completed" diff --git a/fastly/waf_version_test.go b/fastly/waf_version_test.go index 98a598ee0..b323537c2 100644 --- a/fastly/waf_version_test.go +++ b/fastly/waf_version_test.go @@ -1,9 +1,11 @@ package fastly import ( + "fmt" "reflect" "strconv" "testing" + "time" ) func TestClient_WAF_Versions(t *testing.T) { @@ -63,6 +65,9 @@ func TestClient_WAF_Versions(t *testing.T) { if len(wafVerResp.Items) != 1 { t.Errorf("expected 1 waf: got %d", len(wafVerResp.Items)) } + if wafVerResp.Items[0].LastDeploymentStatus != "" { + t.Errorf("unexpected waf deployment status: \"%s\"", wafVerResp.Items[0].LastDeploymentStatus) + } record(t, fixtureBase+"/deploy", func(c *Client) { err = c.DeployWAFVersion(&DeployWAFVersionInput{ @@ -74,6 +79,38 @@ func TestClient_WAF_Versions(t *testing.T) { t.Fatal(err) } + var wafVerPD *WAFVersion + for i := 0; i < 120 && (wafVerPD == nil || wafVerPD.LastDeploymentStatus != WAFVersionDeploymentStatusCompleted); i++ { + record(t, fmt.Sprintf("%s/getPostDeploy_%d", fixtureBase, i), func(c *Client) { + wafVerPD, err = c.GetWAFVersion(&GetWAFVersionInput{ + WAFID: waf.ID, + WAFVersionNumber: 1, + }) + }) + if err != nil { + t.Fatal(err) + break + } + if wafVerPD == nil { + t.Error("expected waf, got nil") + break + } + if wafVerPD.LastDeploymentStatus != WAFVersionDeploymentStatusPending && + wafVerPD.LastDeploymentStatus != WAFVersionDeploymentStatusInProgress && + wafVerPD.LastDeploymentStatus != WAFVersionDeploymentStatusFailed && + wafVerPD.LastDeploymentStatus != WAFVersionDeploymentStatusCompleted { + t.Errorf("unexpected waf deployment status: \"%s\"", wafVerPD.LastDeploymentStatus) + break + } + + if wafVerPD.LastDeploymentStatus != WAFVersionDeploymentStatusCompleted { + time.Sleep(500 * time.Millisecond) + } + } + if wafVerPD.LastDeploymentStatus != WAFVersionDeploymentStatusCompleted { + t.Error("waf deployment did not reach completed status") + } + var wafVer *WAFVersion record(t, fixtureBase+"/clone", func(c *Client) { wafVer, err = c.CloneWAFVersion(&CloneWAFVersionInput{ From 03573deb5e3e5ce5ddad07464df0454c520ce21c Mon Sep 17 00:00:00 2001 From: Patrick Hamann Date: Wed, 22 Jul 2020 12:39:08 +0100 Subject: [PATCH 19/37] Apply suggestions from code review --- fastly/waf_active_rule.go | 4 ++-- fastly/waf_version.go | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/fastly/waf_active_rule.go b/fastly/waf_active_rule.go index 21e23ca48..315b60b75 100644 --- a/fastly/waf_active_rule.go +++ b/fastly/waf_active_rule.go @@ -21,10 +21,10 @@ type WAFActiveRule struct { Status string `jsonapi:"attr,status,omitempty"` ModSecID int `jsonapi:"attr,modsec_rule_id,omitempty"` Revision int `jsonapi:"attr,revision,omitempty"` - CreatedAt *time.Time `jsonapi:"attr,created_at,iso8601,omitempty"` - UpdatedAt *time.Time `jsonapi:"attr,updated_at,iso8601,omitempty"` Outdated bool `jsonapi:"attr,outdated,omitempty"` LatestRevision int `jsonapi:"attr,latest_revision,omitempty"` + CreatedAt *time.Time `jsonapi:"attr,created_at,iso8601,omitempty"` + UpdatedAt *time.Time `jsonapi:"attr,updated_at,iso8601,omitempty"` } // WAFActiveRuleResponse represents a list of active rules - full response. diff --git a/fastly/waf_version.go b/fastly/waf_version.go index ba7fd88da..d22743a4b 100644 --- a/fastly/waf_version.go +++ b/fastly/waf_version.go @@ -22,22 +22,22 @@ const ( // WAFBatchModifyMaximumOperations is used as the default batch maximum operations. WAFBatchModifyMaximumOperations = 500 - // WAFVersionDeploymentStatusPending is the string value representing pending state for last_deployment_status for a WAF version + // WAFVersionDeploymentStatusPending is the string value representing pending state for last_deployment_status for a WAF version. WAFVersionDeploymentStatusPending = "pending" - // WAFVersionDeploymentStatusInProgress is the string value representing in-progress state for last_deployment_status for a WAF version + // WAFVersionDeploymentStatusInProgress is the string value representing in-progress state for last_deployment_status for a WAF version. WAFVersionDeploymentStatusInProgress = "in progress" - // WAFVersionDeploymentStatusCompleted is the string value representing completed state for last_deployment_status for a WAF versions + // WAFVersionDeploymentStatusCompleted is the string value representing completed state for last_deployment_status for a WAF versions. WAFVersionDeploymentStatusCompleted = "completed" - // WAFVersionDeploymentStatusFailed is the string value representing failed state for last_deployment_status for a WAF versions + // WAFVersionDeploymentStatusFailed is the string value representing failed state for last_deployment_status for a WAF versions. WAFVersionDeploymentStatusFailed = "failed" ) // WAFVersion is the information about a WAF version object. type WAFVersion struct { - // See documentation here https://docs.fastly.com/api/ngwaf#api-section-ngwaf_firewall_versions + // See documentation here https://developer.fastly.com/reference/api/waf/ngwaf/#api-section-ngwaf_firewall_versions ID string `jsonapi:"primary,waf_firewall_version"` Number int `jsonapi:"attr,number"` Active bool `jsonapi:"attr,active"` @@ -46,7 +46,6 @@ type WAFVersion struct { Comment string `jsonapi:"attr,comment"` Error string `jsonapi:"attr,error"` LastDeploymentStatus string `jsonapi:"attr,last_deployment_status"` - DeployedAt *time.Time `jsonapi:"attr,deployed_at,iso8601"` AllowedHTTPVersions string `jsonapi:"attr,allowed_http_versions"` AllowedMethods string `jsonapi:"attr,allowed_methods"` AllowedRequestContentType string `jsonapi:"attr,allowed_request_content_type"` @@ -54,8 +53,6 @@ type WAFVersion struct { HighRiskCountryCodes string `jsonapi:"attr,high_risk_country_codes"` RestrictedExtensions string `jsonapi:"attr,restricted_extensions"` RestrictedHeaders string `jsonapi:"attr,restricted_headers"` - CreatedAt *time.Time `jsonapi:"attr,created_at,iso8601"` - UpdatedAt *time.Time `jsonapi:"attr,updated_at,iso8601"` ArgLength int `jsonapi:"attr,arg_length"` ArgNameLength int `jsonapi:"attr,arg_name_length"` CombinedFileSizes int `jsonapi:"attr,combined_file_sizes"` @@ -83,6 +80,9 @@ type WAFVersion struct { ActiveRulesOWASPLogCount int `jsonapi:"attr,active_rules_owasp_log_count"` ActiveRulesOWASPBlockCount int `jsonapi:"attr,active_rules_owasp_block_count"` ActiveRulesOWASPScoreCount int `jsonapi:"attr,active_rules_owasp_score_count"` + DeployedAt *time.Time `jsonapi:"attr,deployed_at,iso8601"` + CreatedAt *time.Time `jsonapi:"attr,created_at,iso8601"` + UpdatedAt *time.Time `jsonapi:"attr,updated_at,iso8601"` } // WAFVersionResponse represents a list WAF versions full response. From 1c58cc167caaa625529e465a938ca4988563ad01 Mon Sep 17 00:00:00 2001 From: phamann Date: Wed, 22 Jul 2020 13:58:57 +0100 Subject: [PATCH 20/37] Fix fixtures for WAF tests --- fastly/fixtures/waf_active_rules/condition/create.yaml | 8 ++++---- fastly/fixtures/waf_active_rules/create.yaml | 2 +- fastly/fixtures/waf_active_rules/delete_one.yaml | 2 +- fastly/fixtures/waf_active_rules/list_after_delete.yaml | 4 ++-- fastly/fixtures/waf_active_rules/list_empty.yaml | 4 ++-- fastly/fixtures/waf_active_rules/list_not_empty.yaml | 4 ++-- fastly/fixtures/waf_active_rules/list_not_empty2.yaml | 4 ++-- fastly/fixtures/waf_active_rules/logging/create.yaml | 8 ++++---- fastly/fixtures/waf_active_rules/logging/delete.yaml | 2 +- .../fixtures/waf_active_rules/response_object/create.yaml | 8 ++++---- fastly/fixtures/waf_active_rules/service/create.yaml | 2 +- fastly/fixtures/waf_active_rules/service/delete.yaml | 2 +- fastly/fixtures/waf_active_rules/service/version.yaml | 8 ++++---- fastly/fixtures/waf_active_rules/update.yaml | 2 +- fastly/fixtures/waf_active_rules/waf/create.yaml | 4 ++-- fastly/fixtures/waf_active_rules/waf/delete.yaml | 4 ++-- fastly/fixtures/waf_versions/condition/create.yaml | 8 ++++---- fastly/fixtures/waf_versions/condition/delete.yaml | 2 +- fastly/fixtures/waf_versions/logging/create.yaml | 8 ++++---- fastly/fixtures/waf_versions/logging/delete.yaml | 2 +- fastly/fixtures/waf_versions/response_object/create.yaml | 8 ++++---- fastly/fixtures/waf_versions/response_object/delete.yaml | 2 +- fastly/fixtures/waf_versions/service/create.yaml | 2 +- fastly/fixtures/waf_versions/service/delete.yaml | 2 +- fastly/fixtures/waf_versions/service/version.yaml | 8 ++++---- fastly/fixtures/waf_versions/waf/create.yaml | 4 ++-- fastly/fixtures/wafs/condition/create.yaml | 8 ++++---- fastly/fixtures/wafs/condition/delete.yaml | 2 +- fastly/fixtures/wafs/create.yaml | 4 ++-- fastly/fixtures/wafs/disable.yaml | 2 +- fastly/fixtures/wafs/enable.yaml | 2 +- fastly/fixtures/wafs/get.yaml | 2 +- fastly/fixtures/wafs/list.yaml | 4 ++-- fastly/fixtures/wafs/response_object/cleanup_another.yaml | 2 +- fastly/fixtures/wafs/response_object/create.yaml | 8 ++++---- fastly/fixtures/wafs/response_object/create_another.yaml | 8 ++++---- fastly/fixtures/wafs/response_object/delete.yaml | 2 +- fastly/fixtures/wafs/service/create.yaml | 2 +- fastly/fixtures/wafs/service/delete.yaml | 2 +- fastly/fixtures/wafs/service/version.yaml | 8 ++++---- fastly/fixtures/wafs/update.yaml | 6 +++--- 41 files changed, 88 insertions(+), 88 deletions(-) diff --git a/fastly/fixtures/waf_active_rules/condition/create.yaml b/fastly/fixtures/waf_active_rules/condition/create.yaml index 6d3c3d30a..86ec4a36a 100644 --- a/fastly/fixtures/waf_active_rules/condition/create.yaml +++ b/fastly/fixtures/waf_active_rules/condition/create.yaml @@ -2,10 +2,10 @@ version: 1 interactions: - request: - body: Service=0tMlTqfWhijgsh07mPyFJq&Version=2&name=WAF_Prefetch&priority=1&statement=req.url~%2B%22index.html%22&type=PREFETCH + body: Service=7i6HN3TK9wS159v2gPAZ8A&Version=2&name=WAF_Prefetch&priority=1&statement=req.url~%2B%22index.html%22&type=PREFETCH form: Service: - - 0tMlTqfWhijgsh07mPyFJq + - 7i6HN3TK9wS159v2gPAZ8A Version: - "2" name: @@ -21,10 +21,10 @@ interactions: - application/x-www-form-urlencoded User-Agent: - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) - url: https://api.fastly.com/service/0tMlTqfWhijgsh07mPyFJq/version/2/condition + url: https://api.fastly.com/service/7i6HN3TK9wS159v2gPAZ8A/version/2/condition method: POST response: - body: '{"name":"WAF_Prefetch","priority":"1","statement":"req.url~+\"index.html\"","type":"PREFETCH","service_id":"0tMlTqfWhijgsh07mPyFJq","version":"2","updated_at":"2020-06-30T10:56:25Z","created_at":"2020-06-30T10:56:25Z","comment":"","deleted_at":null}' + body: '{"name":"WAF_Prefetch","priority":"1","statement":"req.url~+\"index.html\"","type":"PREFETCH","service_id":"7i6HN3TK9wS159v2gPAZ8A","version":"2","updated_at":"2020-06-30T10:56:25Z","created_at":"2020-06-30T10:56:25Z","comment":"","deleted_at":null}' headers: Accept-Ranges: - bytes diff --git a/fastly/fixtures/waf_active_rules/create.yaml b/fastly/fixtures/waf_active_rules/create.yaml index 2f5f48c02..3bfbb8244 100644 --- a/fastly/fixtures/waf_active_rules/create.yaml +++ b/fastly/fixtures/waf_active_rules/create.yaml @@ -12,7 +12,7 @@ interactions: - application/vnd.api+json; ext=bulk User-Agent: - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) - url: https://api.fastly.com/waf/firewalls/2pmz6XhLxsbLCkK68TrL46/versions/1/active-rules + url: https://api.fastly.com/waf/firewalls/7i6HN3TK9wS159v2gPAZ8A/versions/1/active-rules method: POST response: body: '{"data":[{"id":"2dUkKDhlx5hVWljfob6ggO","type":"waf_active_rule","attributes":{"created_at":"2020-06-30T10:56:27Z","latest_revision":1,"modsec_rule_id":2029718,"outdated":false,"revision":1,"status":"log","updated_at":"2020-06-30T10:56:27Z"},"relationships":{"waf_firewall_version":{"data":{"id":"4cpxRmmOXFmDMFQQyGqZDX","type":"waf_firewall_version"}},"waf_rule_revision":{"data":{"id":"6ZJML5tsy5uVq1nGNgmZ78","type":"waf_rule_revision"}}}},{"id":"3F5R6J4vJf9nSF6J1r5nd","type":"waf_active_rule","attributes":{"created_at":"2020-06-30T10:56:27Z","latest_revision":1,"modsec_rule_id":2037405,"outdated":false,"revision":1,"status":"log","updated_at":"2020-06-30T10:56:27Z"},"relationships":{"waf_firewall_version":{"data":{"id":"4cpxRmmOXFmDMFQQyGqZDX","type":"waf_firewall_version"}},"waf_rule_revision":{"data":{"id":"3ANlv7vVZdzk2qFXlJLIk3","type":"waf_rule_revision"}}}},{"id":"59Tw8iZn3e22bjLDlOP4a8","type":"waf_active_rule","attributes":{"created_at":"2020-06-30T10:56:27Z","latest_revision":1,"modsec_rule_id":1010070,"outdated":false,"revision":1,"status":"log","updated_at":"2020-06-30T10:56:27Z"},"relationships":{"waf_firewall_version":{"data":{"id":"4cpxRmmOXFmDMFQQyGqZDX","type":"waf_firewall_version"}},"waf_rule_revision":{"data":{"id":"2qiuFDyJoxuKkKkJYjrgsC","type":"waf_rule_revision"}}}}]}' diff --git a/fastly/fixtures/waf_active_rules/delete_one.yaml b/fastly/fixtures/waf_active_rules/delete_one.yaml index 4ef341387..955f96db1 100644 --- a/fastly/fixtures/waf_active_rules/delete_one.yaml +++ b/fastly/fixtures/waf_active_rules/delete_one.yaml @@ -12,7 +12,7 @@ interactions: - application/vnd.api+json; ext=bulk User-Agent: - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) - url: https://api.fastly.com/waf/firewalls/2pmz6XhLxsbLCkK68TrL46/versions/1/active-rules + url: https://api.fastly.com/waf/firewalls/7i6HN3TK9wS159v2gPAZ8A/versions/1/active-rules method: DELETE response: body: "" diff --git a/fastly/fixtures/waf_active_rules/list_after_delete.yaml b/fastly/fixtures/waf_active_rules/list_after_delete.yaml index c180e798a..a82dd215e 100644 --- a/fastly/fixtures/waf_active_rules/list_after_delete.yaml +++ b/fastly/fixtures/waf_active_rules/list_after_delete.yaml @@ -7,10 +7,10 @@ interactions: headers: User-Agent: - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) - url: https://api.fastly.com/waf/firewalls/2pmz6XhLxsbLCkK68TrL46/versions/1/active-rules + url: https://api.fastly.com/waf/firewalls/7i6HN3TK9wS159v2gPAZ8A/versions/1/active-rules method: GET response: - body: '{"data":[{"id":"3F5R6J4vJf9nSF6J1r5nd","type":"waf_active_rule","attributes":{"created_at":"2020-06-30T10:56:27Z","latest_revision":1,"modsec_rule_id":2037405,"outdated":false,"revision":1,"status":"block","updated_at":"2020-06-30T10:56:28Z"}},{"id":"2dUkKDhlx5hVWljfob6ggO","type":"waf_active_rule","attributes":{"created_at":"2020-06-30T10:56:27Z","latest_revision":1,"modsec_rule_id":2029718,"outdated":false,"revision":1,"status":"block","updated_at":"2020-06-30T10:56:28Z"}}],"links":{"last":"https://api.fastly.com/waf/firewalls/2pmz6XhLxsbLCkK68TrL46/versions/1/active-rules?page[number]=1\u0026page[size]=100","first":"https://api.fastly.com/waf/firewalls/2pmz6XhLxsbLCkK68TrL46/versions/1/active-rules?page[number]=1\u0026page[size]=100"},"meta":{"current_page":1,"per_page":100,"record_count":2,"total_pages":1}}' + body: '{"data":[{"id":"3F5R6J4vJf9nSF6J1r5nd","type":"waf_active_rule","attributes":{"created_at":"2020-06-30T10:56:27Z","latest_revision":1,"modsec_rule_id":2037405,"outdated":false,"revision":1,"status":"block","updated_at":"2020-06-30T10:56:28Z"}},{"id":"2dUkKDhlx5hVWljfob6ggO","type":"waf_active_rule","attributes":{"created_at":"2020-06-30T10:56:27Z","latest_revision":1,"modsec_rule_id":2029718,"outdated":false,"revision":1,"status":"block","updated_at":"2020-06-30T10:56:28Z"}}],"links":{"last":"https://api.fastly.com/waf/firewalls/7i6HN3TK9wS159v2gPAZ8A/versions/1/active-rules?page[number]=1\u0026page[size]=100","first":"https://api.fastly.com/waf/firewalls/7i6HN3TK9wS159v2gPAZ8A/versions/1/active-rules?page[number]=1\u0026page[size]=100"},"meta":{"current_page":1,"per_page":100,"record_count":2,"total_pages":1}}' headers: Accept-Ranges: - bytes diff --git a/fastly/fixtures/waf_active_rules/list_empty.yaml b/fastly/fixtures/waf_active_rules/list_empty.yaml index 03d46efdf..c6c87702e 100644 --- a/fastly/fixtures/waf_active_rules/list_empty.yaml +++ b/fastly/fixtures/waf_active_rules/list_empty.yaml @@ -7,10 +7,10 @@ interactions: headers: User-Agent: - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) - url: https://api.fastly.com/waf/firewalls/2pmz6XhLxsbLCkK68TrL46/versions/1/active-rules + url: https://api.fastly.com/waf/firewalls/7i6HN3TK9wS159v2gPAZ8A/versions/1/active-rules method: GET response: - body: '{"data":[],"links":{"last":"https://api.fastly.com/waf/firewalls/2pmz6XhLxsbLCkK68TrL46/versions/1/active-rules?page[number]=1\u0026page[size]=100","first":"https://api.fastly.com/waf/firewalls/2pmz6XhLxsbLCkK68TrL46/versions/1/active-rules?page[number]=1\u0026page[size]=100"},"meta":{"current_page":1,"per_page":100,"record_count":0,"total_pages":1}}' + body: '{"data":[],"links":{"last":"https://api.fastly.com/waf/firewalls/7i6HN3TK9wS159v2gPAZ8A/versions/1/active-rules?page[number]=1\u0026page[size]=100","first":"https://api.fastly.com/waf/firewalls/7i6HN3TK9wS159v2gPAZ8A/versions/1/active-rules?page[number]=1\u0026page[size]=100"},"meta":{"current_page":1,"per_page":100,"record_count":0,"total_pages":1}}' headers: Accept-Ranges: - bytes diff --git a/fastly/fixtures/waf_active_rules/list_not_empty.yaml b/fastly/fixtures/waf_active_rules/list_not_empty.yaml index e92b51a3d..bc6a13399 100644 --- a/fastly/fixtures/waf_active_rules/list_not_empty.yaml +++ b/fastly/fixtures/waf_active_rules/list_not_empty.yaml @@ -7,10 +7,10 @@ interactions: headers: User-Agent: - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) - url: https://api.fastly.com/waf/firewalls/2pmz6XhLxsbLCkK68TrL46/versions/1/active-rules + url: https://api.fastly.com/waf/firewalls/7i6HN3TK9wS159v2gPAZ8A/versions/1/active-rules method: GET response: - body: '{"data":[{"id":"59Tw8iZn3e22bjLDlOP4a8","type":"waf_active_rule","attributes":{"created_at":"2020-06-30T10:56:27Z","latest_revision":1,"modsec_rule_id":1010070,"outdated":false,"revision":1,"status":"log","updated_at":"2020-06-30T10:56:27Z"}},{"id":"3F5R6J4vJf9nSF6J1r5nd","type":"waf_active_rule","attributes":{"created_at":"2020-06-30T10:56:27Z","latest_revision":1,"modsec_rule_id":2037405,"outdated":false,"revision":1,"status":"log","updated_at":"2020-06-30T10:56:27Z"}},{"id":"2dUkKDhlx5hVWljfob6ggO","type":"waf_active_rule","attributes":{"created_at":"2020-06-30T10:56:27Z","latest_revision":1,"modsec_rule_id":2029718,"outdated":false,"revision":1,"status":"log","updated_at":"2020-06-30T10:56:27Z"}}],"links":{"last":"https://api.fastly.com/waf/firewalls/2pmz6XhLxsbLCkK68TrL46/versions/1/active-rules?page[number]=1\u0026page[size]=100","first":"https://api.fastly.com/waf/firewalls/2pmz6XhLxsbLCkK68TrL46/versions/1/active-rules?page[number]=1\u0026page[size]=100"},"meta":{"current_page":1,"per_page":100,"record_count":3,"total_pages":1}}' + body: '{"data":[{"id":"59Tw8iZn3e22bjLDlOP4a8","type":"waf_active_rule","attributes":{"created_at":"2020-06-30T10:56:27Z","latest_revision":1,"modsec_rule_id":1010070,"outdated":false,"revision":1,"status":"log","updated_at":"2020-06-30T10:56:27Z"}},{"id":"3F5R6J4vJf9nSF6J1r5nd","type":"waf_active_rule","attributes":{"created_at":"2020-06-30T10:56:27Z","latest_revision":1,"modsec_rule_id":2037405,"outdated":false,"revision":1,"status":"log","updated_at":"2020-06-30T10:56:27Z"}},{"id":"2dUkKDhlx5hVWljfob6ggO","type":"waf_active_rule","attributes":{"created_at":"2020-06-30T10:56:27Z","latest_revision":1,"modsec_rule_id":2029718,"outdated":false,"revision":1,"status":"log","updated_at":"2020-06-30T10:56:27Z"}}],"links":{"last":"https://api.fastly.com/waf/firewalls/7i6HN3TK9wS159v2gPAZ8A/versions/1/active-rules?page[number]=1\u0026page[size]=100","first":"https://api.fastly.com/waf/firewalls/7i6HN3TK9wS159v2gPAZ8A/versions/1/active-rules?page[number]=1\u0026page[size]=100"},"meta":{"current_page":1,"per_page":100,"record_count":3,"total_pages":1}}' headers: Accept-Ranges: - bytes diff --git a/fastly/fixtures/waf_active_rules/list_not_empty2.yaml b/fastly/fixtures/waf_active_rules/list_not_empty2.yaml index 17943b2eb..84fadc518 100644 --- a/fastly/fixtures/waf_active_rules/list_not_empty2.yaml +++ b/fastly/fixtures/waf_active_rules/list_not_empty2.yaml @@ -7,10 +7,10 @@ interactions: headers: User-Agent: - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) - url: https://api.fastly.com/waf/firewalls/2pmz6XhLxsbLCkK68TrL46/versions/1/active-rules + url: https://api.fastly.com/waf/firewalls/7i6HN3TK9wS159v2gPAZ8A/versions/1/active-rules method: GET response: - body: '{"data":[{"id":"59Tw8iZn3e22bjLDlOP4a8","type":"waf_active_rule","attributes":{"created_at":"2020-06-30T10:56:27Z","latest_revision":1,"modsec_rule_id":1010070,"outdated":false,"revision":1,"status":"block","updated_at":"2020-06-30T10:56:28Z"}},{"id":"3F5R6J4vJf9nSF6J1r5nd","type":"waf_active_rule","attributes":{"created_at":"2020-06-30T10:56:27Z","latest_revision":1,"modsec_rule_id":2037405,"outdated":false,"revision":1,"status":"block","updated_at":"2020-06-30T10:56:28Z"}},{"id":"2dUkKDhlx5hVWljfob6ggO","type":"waf_active_rule","attributes":{"created_at":"2020-06-30T10:56:27Z","latest_revision":1,"modsec_rule_id":2029718,"outdated":false,"revision":1,"status":"block","updated_at":"2020-06-30T10:56:28Z"}}],"links":{"last":"https://api.fastly.com/waf/firewalls/2pmz6XhLxsbLCkK68TrL46/versions/1/active-rules?page[number]=1\u0026page[size]=100","first":"https://api.fastly.com/waf/firewalls/2pmz6XhLxsbLCkK68TrL46/versions/1/active-rules?page[number]=1\u0026page[size]=100"},"meta":{"current_page":1,"per_page":100,"record_count":3,"total_pages":1}}' + body: '{"data":[{"id":"59Tw8iZn3e22bjLDlOP4a8","type":"waf_active_rule","attributes":{"created_at":"2020-06-30T10:56:27Z","latest_revision":1,"modsec_rule_id":1010070,"outdated":false,"revision":1,"status":"block","updated_at":"2020-06-30T10:56:28Z"}},{"id":"3F5R6J4vJf9nSF6J1r5nd","type":"waf_active_rule","attributes":{"created_at":"2020-06-30T10:56:27Z","latest_revision":1,"modsec_rule_id":2037405,"outdated":false,"revision":1,"status":"block","updated_at":"2020-06-30T10:56:28Z"}},{"id":"2dUkKDhlx5hVWljfob6ggO","type":"waf_active_rule","attributes":{"created_at":"2020-06-30T10:56:27Z","latest_revision":1,"modsec_rule_id":2029718,"outdated":false,"revision":1,"status":"block","updated_at":"2020-06-30T10:56:28Z"}}],"links":{"last":"https://api.fastly.com/waf/firewalls/7i6HN3TK9wS159v2gPAZ8A/versions/1/active-rules?page[number]=1\u0026page[size]=100","first":"https://api.fastly.com/waf/firewalls/7i6HN3TK9wS159v2gPAZ8A/versions/1/active-rules?page[number]=1\u0026page[size]=100"},"meta":{"current_page":1,"per_page":100,"record_count":3,"total_pages":1}}' headers: Accept-Ranges: - bytes diff --git a/fastly/fixtures/waf_active_rules/logging/create.yaml b/fastly/fixtures/waf_active_rules/logging/create.yaml index 465184136..021daa62e 100644 --- a/fastly/fixtures/waf_active_rules/logging/create.yaml +++ b/fastly/fixtures/waf_active_rules/logging/create.yaml @@ -2,10 +2,10 @@ version: 1 interactions: - request: - body: Service=0tMlTqfWhijgsh07mPyFJq&Version=2&address=example.com&format=format&format_version=2&hostname=example.com&message_type=classic&name=test-syslog&port=1234&token=abcd1234 + body: Service=7i6HN3TK9wS159v2gPAZ8A&Version=2&address=example.com&format=format&format_version=2&hostname=example.com&message_type=classic&name=test-syslog&port=1234&token=abcd1234 form: Service: - - 0tMlTqfWhijgsh07mPyFJq + - 7i6HN3TK9wS159v2gPAZ8A Version: - "2" address: @@ -29,10 +29,10 @@ interactions: - application/x-www-form-urlencoded User-Agent: - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) - url: https://api.fastly.com/service/0tMlTqfWhijgsh07mPyFJq/version/2/logging/syslog + url: https://api.fastly.com/service/7i6HN3TK9wS159v2gPAZ8A/version/2/logging/syslog method: POST response: - body: '{"address":"example.com","format":"format","format_version":"2","hostname":"example.com","message_type":"classic","name":"test-syslog","port":"1234","token":"abcd1234","service_id":"0tMlTqfWhijgsh07mPyFJq","version":"2","tls_client_cert":null,"response_condition":"","use_tls":"0","deleted_at":null,"ipv4":null,"placement":null,"public_key":null,"tls_client_key":null,"tls_hostname":null,"tls_ca_cert":null,"updated_at":"2020-06-30T10:56:24Z","created_at":"2020-06-30T10:56:24Z"}' + body: '{"address":"example.com","format":"format","format_version":"2","hostname":"example.com","message_type":"classic","name":"test-syslog","port":"1234","token":"abcd1234","service_id":"7i6HN3TK9wS159v2gPAZ8A","version":"2","tls_client_cert":null,"response_condition":"","use_tls":"0","deleted_at":null,"ipv4":null,"placement":null,"public_key":null,"tls_client_key":null,"tls_hostname":null,"tls_ca_cert":null,"updated_at":"2020-06-30T10:56:24Z","created_at":"2020-06-30T10:56:24Z"}' headers: Accept-Ranges: - bytes diff --git a/fastly/fixtures/waf_active_rules/logging/delete.yaml b/fastly/fixtures/waf_active_rules/logging/delete.yaml index 1bd5eb171..6ec3a6e9c 100644 --- a/fastly/fixtures/waf_active_rules/logging/delete.yaml +++ b/fastly/fixtures/waf_active_rules/logging/delete.yaml @@ -7,7 +7,7 @@ interactions: headers: User-Agent: - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) - url: https://api.fastly.com/service/0tMlTqfWhijgsh07mPyFJq/version/2/logging/syslog/test-syslog + url: https://api.fastly.com/service/7i6HN3TK9wS159v2gPAZ8A/version/2/logging/syslog/test-syslog method: DELETE response: body: '{"status":"ok"}' diff --git a/fastly/fixtures/waf_active_rules/response_object/create.yaml b/fastly/fixtures/waf_active_rules/response_object/create.yaml index 8353cc316..0ed9cdb09 100644 --- a/fastly/fixtures/waf_active_rules/response_object/create.yaml +++ b/fastly/fixtures/waf_active_rules/response_object/create.yaml @@ -2,10 +2,10 @@ version: 1 interactions: - request: - body: Service=0tMlTqfWhijgsh07mPyFJq&Version=2&name=WAf_Response&status=403 + body: Service=7i6HN3TK9wS159v2gPAZ8A&Version=2&name=WAf_Response&status=403 form: Service: - - 0tMlTqfWhijgsh07mPyFJq + - 7i6HN3TK9wS159v2gPAZ8A Version: - "2" name: @@ -17,10 +17,10 @@ interactions: - application/x-www-form-urlencoded User-Agent: - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) - url: https://api.fastly.com/service/0tMlTqfWhijgsh07mPyFJq/version/2/response_object + url: https://api.fastly.com/service/7i6HN3TK9wS159v2gPAZ8A/version/2/response_object method: POST response: - body: '{"name":"WAf_Response","status":"403","service_id":"0tMlTqfWhijgsh07mPyFJq","version":"2","request_condition":"","response":"ok","content":null,"content_type":null,"updated_at":"2020-06-30T10:56:25Z","cache_condition":"","created_at":"2020-06-30T10:56:25Z","deleted_at":null}' + body: '{"name":"WAf_Response","status":"403","service_id":"7i6HN3TK9wS159v2gPAZ8A","version":"2","request_condition":"","response":"ok","content":null,"content_type":null,"updated_at":"2020-06-30T10:56:25Z","cache_condition":"","created_at":"2020-06-30T10:56:25Z","deleted_at":null}' headers: Accept-Ranges: - bytes diff --git a/fastly/fixtures/waf_active_rules/service/create.yaml b/fastly/fixtures/waf_active_rules/service/create.yaml index bb3c56bc1..4ce9f0086 100644 --- a/fastly/fixtures/waf_active_rules/service/create.yaml +++ b/fastly/fixtures/waf_active_rules/service/create.yaml @@ -18,7 +18,7 @@ interactions: url: https://api.fastly.com/service method: POST response: - body: '{"customer_id":"WpqWFjTA4lk2N1g0GY2HH","comment":"go-fastly client test","name":"test_service_service","type":"vcl","id":"0tMlTqfWhijgsh07mPyFJq","publish_key":"","versions":[{"comment":"","number":1,"testing":false,"locked":false,"updated_at":"2020-06-30T10:56:24Z","deleted_at":null,"created_at":"2020-06-30T10:56:24Z","service_id":"0tMlTqfWhijgsh07mPyFJq","deployed":false,"active":false,"staging":false}],"deleted_at":null,"created_at":"2020-06-30T10:56:24Z","updated_at":"2020-06-30T10:56:24Z"}' + body: '{"customer_id":"WpqWFjTA4lk2N1g0GY2HH","comment":"go-fastly client test","name":"test_service_service","type":"vcl","id":"7i6HN3TK9wS159v2gPAZ8A","publish_key":"","versions":[{"comment":"","number":1,"testing":false,"locked":false,"updated_at":"2020-06-30T10:56:24Z","deleted_at":null,"created_at":"2020-06-30T10:56:24Z","service_id":"7i6HN3TK9wS159v2gPAZ8A","deployed":false,"active":false,"staging":false}],"deleted_at":null,"created_at":"2020-06-30T10:56:24Z","updated_at":"2020-06-30T10:56:24Z"}' headers: Accept-Ranges: - bytes diff --git a/fastly/fixtures/waf_active_rules/service/delete.yaml b/fastly/fixtures/waf_active_rules/service/delete.yaml index b2d64dbc5..9b5b96dcf 100644 --- a/fastly/fixtures/waf_active_rules/service/delete.yaml +++ b/fastly/fixtures/waf_active_rules/service/delete.yaml @@ -7,7 +7,7 @@ interactions: headers: User-Agent: - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) - url: https://api.fastly.com/service/0tMlTqfWhijgsh07mPyFJq + url: https://api.fastly.com/service/7i6HN3TK9wS159v2gPAZ8A method: DELETE response: body: '{"status":"ok"}' diff --git a/fastly/fixtures/waf_active_rules/service/version.yaml b/fastly/fixtures/waf_active_rules/service/version.yaml index 18216282f..af67df650 100644 --- a/fastly/fixtures/waf_active_rules/service/version.yaml +++ b/fastly/fixtures/waf_active_rules/service/version.yaml @@ -2,19 +2,19 @@ version: 1 interactions: - request: - body: Service=0tMlTqfWhijgsh07mPyFJq + body: Service=7i6HN3TK9wS159v2gPAZ8A form: Service: - - 0tMlTqfWhijgsh07mPyFJq + - 7i6HN3TK9wS159v2gPAZ8A headers: Content-Type: - application/x-www-form-urlencoded User-Agent: - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) - url: https://api.fastly.com/service/0tMlTqfWhijgsh07mPyFJq/version + url: https://api.fastly.com/service/7i6HN3TK9wS159v2gPAZ8A/version method: POST response: - body: '{"service_id":"0tMlTqfWhijgsh07mPyFJq","number":2}' + body: '{"service_id":"7i6HN3TK9wS159v2gPAZ8A","number":2}' headers: Accept-Ranges: - bytes diff --git a/fastly/fixtures/waf_active_rules/update.yaml b/fastly/fixtures/waf_active_rules/update.yaml index da1c5fa97..4d28606e0 100644 --- a/fastly/fixtures/waf_active_rules/update.yaml +++ b/fastly/fixtures/waf_active_rules/update.yaml @@ -12,7 +12,7 @@ interactions: - application/vnd.api+json; ext=bulk User-Agent: - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) - url: https://api.fastly.com/waf/firewalls/2pmz6XhLxsbLCkK68TrL46/versions/1/active-rules + url: https://api.fastly.com/waf/firewalls/7i6HN3TK9wS159v2gPAZ8A/versions/1/active-rules method: POST response: body: '{"data":[{"id":"2dUkKDhlx5hVWljfob6ggO","type":"waf_active_rule","attributes":{"created_at":"2020-06-30T10:56:27Z","latest_revision":1,"modsec_rule_id":2029718,"outdated":false,"revision":1,"status":"block","updated_at":"2020-06-30T10:56:28Z"},"relationships":{"waf_firewall_version":{"data":{"id":"4cpxRmmOXFmDMFQQyGqZDX","type":"waf_firewall_version"}},"waf_rule_revision":{"data":{"id":"6ZJML5tsy5uVq1nGNgmZ78","type":"waf_rule_revision"}}}},{"id":"3F5R6J4vJf9nSF6J1r5nd","type":"waf_active_rule","attributes":{"created_at":"2020-06-30T10:56:27Z","latest_revision":1,"modsec_rule_id":2037405,"outdated":false,"revision":1,"status":"block","updated_at":"2020-06-30T10:56:28Z"},"relationships":{"waf_firewall_version":{"data":{"id":"4cpxRmmOXFmDMFQQyGqZDX","type":"waf_firewall_version"}},"waf_rule_revision":{"data":{"id":"3ANlv7vVZdzk2qFXlJLIk3","type":"waf_rule_revision"}}}},{"id":"59Tw8iZn3e22bjLDlOP4a8","type":"waf_active_rule","attributes":{"created_at":"2020-06-30T10:56:27Z","latest_revision":1,"modsec_rule_id":1010070,"outdated":false,"revision":1,"status":"block","updated_at":"2020-06-30T10:56:28Z"},"relationships":{"waf_firewall_version":{"data":{"id":"4cpxRmmOXFmDMFQQyGqZDX","type":"waf_firewall_version"}},"waf_rule_revision":{"data":{"id":"2qiuFDyJoxuKkKkJYjrgsC","type":"waf_rule_revision"}}}}]}' diff --git a/fastly/fixtures/waf_active_rules/waf/create.yaml b/fastly/fixtures/waf_active_rules/waf/create.yaml index 007028558..5fd0d63f2 100644 --- a/fastly/fixtures/waf_active_rules/waf/create.yaml +++ b/fastly/fixtures/waf_active_rules/waf/create.yaml @@ -3,7 +3,7 @@ version: 1 interactions: - request: body: | - {"data":{"type":"waf_firewall","attributes":{"prefetch_condition":"WAF_Prefetch","response":"WAf_Response","service_id":"0tMlTqfWhijgsh07mPyFJq","service_version_number":"2"}}} + {"data":{"type":"waf_firewall","attributes":{"prefetch_condition":"WAF_Prefetch","response":"WAf_Response","service_id":"7i6HN3TK9wS159v2gPAZ8A","service_version_number":"2"}}} form: {} headers: Accept: @@ -15,7 +15,7 @@ interactions: url: https://api.fastly.com/waf/firewalls method: POST response: - body: '{"data":{"id":"2pmz6XhLxsbLCkK68TrL46","type":"waf_firewall","attributes":{"active_rules_fastly_block_count":0,"active_rules_fastly_log_count":0,"active_rules_fastly_score_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_score_count":0,"active_rules_trustwave_block_count":0,"active_rules_trustwave_log_count":0,"created_at":"2020-06-30T10:56:26Z","disabled":false,"prefetch_condition":"WAF_Prefetch","response":"WAf_Response","service_id":"0tMlTqfWhijgsh07mPyFJq","service_version_number":2,"updated_at":"2020-06-30T10:56:26Z"}}}' + body: '{"data":{"id":"7i6HN3TK9wS159v2gPAZ8A","type":"waf_firewall","attributes":{"active_rules_fastly_block_count":0,"active_rules_fastly_log_count":0,"active_rules_fastly_score_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_score_count":0,"active_rules_trustwave_block_count":0,"active_rules_trustwave_log_count":0,"created_at":"2020-06-30T10:56:26Z","disabled":false,"prefetch_condition":"WAF_Prefetch","response":"WAf_Response","service_id":"7i6HN3TK9wS159v2gPAZ8A","service_version_number":2,"updated_at":"2020-06-30T10:56:26Z"}}}' headers: Accept-Ranges: - bytes diff --git a/fastly/fixtures/waf_active_rules/waf/delete.yaml b/fastly/fixtures/waf_active_rules/waf/delete.yaml index 67a857ea0..4594c3097 100644 --- a/fastly/fixtures/waf_active_rules/waf/delete.yaml +++ b/fastly/fixtures/waf_active_rules/waf/delete.yaml @@ -3,7 +3,7 @@ version: 1 interactions: - request: body: | - {"data":{"type":"waf_firewall","id":"2pmz6XhLxsbLCkK68TrL46","attributes":{"service_version_number":"1"}}} + {"data":{"type":"waf_firewall","id":"7i6HN3TK9wS159v2gPAZ8A","attributes":{"service_version_number":"1"}}} form: {} headers: Accept: @@ -12,7 +12,7 @@ interactions: - application/vnd.api+json User-Agent: - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) - url: https://api.fastly.com/waf/firewalls/2pmz6XhLxsbLCkK68TrL46 + url: https://api.fastly.com/waf/firewalls/7i6HN3TK9wS159v2gPAZ8A method: DELETE response: body: "" diff --git a/fastly/fixtures/waf_versions/condition/create.yaml b/fastly/fixtures/waf_versions/condition/create.yaml index 9414670e7..42c462a56 100644 --- a/fastly/fixtures/waf_versions/condition/create.yaml +++ b/fastly/fixtures/waf_versions/condition/create.yaml @@ -2,10 +2,10 @@ version: 1 interactions: - request: - body: Service=5GZsX83POn5zij6allCOKe&Version=2&name=WAF_Prefetch&priority=1&statement=req.url~%2B%22index.html%22&type=PREFETCH + body: Service=7i6HN3TK9wS159v2gPAZ8A&Version=2&name=WAF_Prefetch&priority=1&statement=req.url~%2B%22index.html%22&type=PREFETCH form: Service: - - 5GZsX83POn5zij6allCOKe + - 7i6HN3TK9wS159v2gPAZ8A Version: - "2" name: @@ -21,10 +21,10 @@ interactions: - application/x-www-form-urlencoded User-Agent: - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) - url: https://api.fastly.com/service/5GZsX83POn5zij6allCOKe/version/2/condition + url: https://api.fastly.com/service/7i6HN3TK9wS159v2gPAZ8A/version/2/condition method: POST response: - body: '{"name":"WAF_Prefetch","priority":"1","statement":"req.url~+\"index.html\"","type":"PREFETCH","service_id":"5GZsX83POn5zij6allCOKe","version":"2","updated_at":"2020-07-06T11:09:06Z","comment":"","deleted_at":null,"created_at":"2020-07-06T11:09:06Z"}' + body: '{"name":"WAF_Prefetch","priority":"1","statement":"req.url~+\"index.html\"","type":"PREFETCH","service_id":"7i6HN3TK9wS159v2gPAZ8A","version":"2","updated_at":"2020-07-06T11:09:06Z","comment":"","deleted_at":null,"created_at":"2020-07-06T11:09:06Z"}' headers: Accept-Ranges: - bytes diff --git a/fastly/fixtures/waf_versions/condition/delete.yaml b/fastly/fixtures/waf_versions/condition/delete.yaml index 34ddbb821..223bb1e63 100644 --- a/fastly/fixtures/waf_versions/condition/delete.yaml +++ b/fastly/fixtures/waf_versions/condition/delete.yaml @@ -7,7 +7,7 @@ interactions: headers: User-Agent: - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) - url: https://api.fastly.com/service/5GZsX83POn5zij6allCOKe/version/2/condition/WAF_Prefetch + url: https://api.fastly.com/service/7i6HN3TK9wS159v2gPAZ8A/version/2/condition/WAF_Prefetch method: DELETE response: body: '{"status":"ok"}' diff --git a/fastly/fixtures/waf_versions/logging/create.yaml b/fastly/fixtures/waf_versions/logging/create.yaml index 08afb3deb..43fb9d7ea 100644 --- a/fastly/fixtures/waf_versions/logging/create.yaml +++ b/fastly/fixtures/waf_versions/logging/create.yaml @@ -2,10 +2,10 @@ version: 1 interactions: - request: - body: Service=5GZsX83POn5zij6allCOKe&Version=2&address=example.com&format=format&format_version=2&hostname=example.com&message_type=classic&name=test-syslog&port=1234&token=abcd1234 + body: Service=7i6HN3TK9wS159v2gPAZ8A&Version=2&address=example.com&format=format&format_version=2&hostname=example.com&message_type=classic&name=test-syslog&port=1234&token=abcd1234 form: Service: - - 5GZsX83POn5zij6allCOKe + - 7i6HN3TK9wS159v2gPAZ8A Version: - "2" address: @@ -29,10 +29,10 @@ interactions: - application/x-www-form-urlencoded User-Agent: - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) - url: https://api.fastly.com/service/5GZsX83POn5zij6allCOKe/version/2/logging/syslog + url: https://api.fastly.com/service/7i6HN3TK9wS159v2gPAZ8A/version/2/logging/syslog method: POST response: - body: '{"address":"example.com","format":"format","format_version":"2","hostname":"example.com","message_type":"classic","name":"test-syslog","port":"1234","token":"abcd1234","service_id":"5GZsX83POn5zij6allCOKe","version":"2","tls_client_cert":null,"deleted_at":null,"created_at":"2020-07-06T11:09:05Z","updated_at":"2020-07-06T11:09:05Z","tls_hostname":null,"tls_ca_cert":null,"placement":null,"ipv4":null,"tls_client_key":null,"public_key":null,"use_tls":"0","response_condition":""}' + body: '{"address":"example.com","format":"format","format_version":"2","hostname":"example.com","message_type":"classic","name":"test-syslog","port":"1234","token":"abcd1234","service_id":"7i6HN3TK9wS159v2gPAZ8A","version":"2","tls_client_cert":null,"deleted_at":null,"created_at":"2020-07-06T11:09:05Z","updated_at":"2020-07-06T11:09:05Z","tls_hostname":null,"tls_ca_cert":null,"placement":null,"ipv4":null,"tls_client_key":null,"public_key":null,"use_tls":"0","response_condition":""}' headers: Accept-Ranges: - bytes diff --git a/fastly/fixtures/waf_versions/logging/delete.yaml b/fastly/fixtures/waf_versions/logging/delete.yaml index 5accec35b..6f9497c9f 100644 --- a/fastly/fixtures/waf_versions/logging/delete.yaml +++ b/fastly/fixtures/waf_versions/logging/delete.yaml @@ -7,7 +7,7 @@ interactions: headers: User-Agent: - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) - url: https://api.fastly.com/service/5GZsX83POn5zij6allCOKe/version/2/logging/syslog/test-syslog + url: https://api.fastly.com/service/7i6HN3TK9wS159v2gPAZ8A/version/2/logging/syslog/test-syslog method: DELETE response: body: '{"status":"ok"}' diff --git a/fastly/fixtures/waf_versions/response_object/create.yaml b/fastly/fixtures/waf_versions/response_object/create.yaml index f058fc868..c896c11ac 100644 --- a/fastly/fixtures/waf_versions/response_object/create.yaml +++ b/fastly/fixtures/waf_versions/response_object/create.yaml @@ -2,10 +2,10 @@ version: 1 interactions: - request: - body: Service=5GZsX83POn5zij6allCOKe&Version=2&name=WAf_Response&status=403 + body: Service=7i6HN3TK9wS159v2gPAZ8A&Version=2&name=WAf_Response&status=403 form: Service: - - 5GZsX83POn5zij6allCOKe + - 7i6HN3TK9wS159v2gPAZ8A Version: - "2" name: @@ -17,10 +17,10 @@ interactions: - application/x-www-form-urlencoded User-Agent: - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) - url: https://api.fastly.com/service/5GZsX83POn5zij6allCOKe/version/2/response_object + url: https://api.fastly.com/service/7i6HN3TK9wS159v2gPAZ8A/version/2/response_object method: POST response: - body: '{"name":"WAf_Response","status":"403","service_id":"5GZsX83POn5zij6allCOKe","version":"2","request_condition":"","content_type":null,"created_at":"2020-07-06T11:09:06Z","deleted_at":null,"response":"ok","content":null,"cache_condition":"","updated_at":"2020-07-06T11:09:06Z"}' + body: '{"name":"WAf_Response","status":"403","service_id":"7i6HN3TK9wS159v2gPAZ8A","version":"2","request_condition":"","content_type":null,"created_at":"2020-07-06T11:09:06Z","deleted_at":null,"response":"ok","content":null,"cache_condition":"","updated_at":"2020-07-06T11:09:06Z"}' headers: Accept-Ranges: - bytes diff --git a/fastly/fixtures/waf_versions/response_object/delete.yaml b/fastly/fixtures/waf_versions/response_object/delete.yaml index 4561cda2a..b7b39f270 100644 --- a/fastly/fixtures/waf_versions/response_object/delete.yaml +++ b/fastly/fixtures/waf_versions/response_object/delete.yaml @@ -7,7 +7,7 @@ interactions: headers: User-Agent: - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) - url: https://api.fastly.com/service/5GZsX83POn5zij6allCOKe/version/2/response_object/WAf_Response + url: https://api.fastly.com/service/7i6HN3TK9wS159v2gPAZ8A/version/2/response_object/WAf_Response method: DELETE response: body: '{"status":"ok"}' diff --git a/fastly/fixtures/waf_versions/service/create.yaml b/fastly/fixtures/waf_versions/service/create.yaml index 015a90447..891e8318a 100644 --- a/fastly/fixtures/waf_versions/service/create.yaml +++ b/fastly/fixtures/waf_versions/service/create.yaml @@ -18,7 +18,7 @@ interactions: url: https://api.fastly.com/service method: POST response: - body: '{"customer_id":"WpqWFjTA4lk2N1g0GY2HH","comment":"go-fastly client test","name":"test_service_service3","type":"vcl","id":"5GZsX83POn5zij6allCOKe","versions":[{"testing":false,"active":false,"service_id":"5GZsX83POn5zij6allCOKe","number":1,"created_at":"2020-07-06T11:09:04Z","updated_at":"2020-07-06T11:09:04Z","deleted_at":null,"locked":false,"deployed":false,"comment":"","staging":false}],"created_at":"2020-07-06T11:09:04Z","publish_key":"","updated_at":"2020-07-06T11:09:04Z","deleted_at":null}' + body: '{"customer_id":"WpqWFjTA4lk2N1g0GY2HH","comment":"go-fastly client test","name":"test_service_service3","type":"vcl","id":"7i6HN3TK9wS159v2gPAZ8A","versions":[{"testing":false,"active":false,"service_id":"7i6HN3TK9wS159v2gPAZ8A","number":1,"created_at":"2020-07-06T11:09:04Z","updated_at":"2020-07-06T11:09:04Z","deleted_at":null,"locked":false,"deployed":false,"comment":"","staging":false}],"created_at":"2020-07-06T11:09:04Z","publish_key":"","updated_at":"2020-07-06T11:09:04Z","deleted_at":null}' headers: Accept-Ranges: - bytes diff --git a/fastly/fixtures/waf_versions/service/delete.yaml b/fastly/fixtures/waf_versions/service/delete.yaml index da204d6a4..9f2553742 100644 --- a/fastly/fixtures/waf_versions/service/delete.yaml +++ b/fastly/fixtures/waf_versions/service/delete.yaml @@ -7,7 +7,7 @@ interactions: headers: User-Agent: - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) - url: https://api.fastly.com/service/5GZsX83POn5zij6allCOKe + url: https://api.fastly.com/service/7i6HN3TK9wS159v2gPAZ8A method: DELETE response: body: '{"status":"ok"}' diff --git a/fastly/fixtures/waf_versions/service/version.yaml b/fastly/fixtures/waf_versions/service/version.yaml index bfb29161a..1364ad862 100644 --- a/fastly/fixtures/waf_versions/service/version.yaml +++ b/fastly/fixtures/waf_versions/service/version.yaml @@ -2,19 +2,19 @@ version: 1 interactions: - request: - body: Service=5GZsX83POn5zij6allCOKe + body: Service=7i6HN3TK9wS159v2gPAZ8A form: Service: - - 5GZsX83POn5zij6allCOKe + - 7i6HN3TK9wS159v2gPAZ8A headers: Content-Type: - application/x-www-form-urlencoded User-Agent: - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) - url: https://api.fastly.com/service/5GZsX83POn5zij6allCOKe/version + url: https://api.fastly.com/service/7i6HN3TK9wS159v2gPAZ8A/version method: POST response: - body: '{"service_id":"5GZsX83POn5zij6allCOKe","number":2}' + body: '{"service_id":"7i6HN3TK9wS159v2gPAZ8A","number":2}' headers: Accept-Ranges: - bytes diff --git a/fastly/fixtures/waf_versions/waf/create.yaml b/fastly/fixtures/waf_versions/waf/create.yaml index cc5d3b9d4..1f127782f 100644 --- a/fastly/fixtures/waf_versions/waf/create.yaml +++ b/fastly/fixtures/waf_versions/waf/create.yaml @@ -3,7 +3,7 @@ version: 1 interactions: - request: body: | - {"data":{"type":"waf_firewall","attributes":{"prefetch_condition":"WAF_Prefetch","response":"WAf_Response","service_id":"5GZsX83POn5zij6allCOKe","service_version_number":"2"}}} + {"data":{"type":"waf_firewall","attributes":{"prefetch_condition":"WAF_Prefetch","response":"WAf_Response","service_id":"7i6HN3TK9wS159v2gPAZ8A","service_version_number":"2"}}} form: {} headers: Accept: @@ -15,7 +15,7 @@ interactions: url: https://api.fastly.com/waf/firewalls method: POST response: - body: '{"data":{"id":"7kRiB97L3ppEaKv5J3hJmV","type":"waf_firewall","attributes":{"active_rules_fastly_block_count":0,"active_rules_fastly_log_count":0,"active_rules_fastly_score_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_score_count":0,"active_rules_trustwave_block_count":0,"active_rules_trustwave_log_count":0,"created_at":"2020-07-06T11:09:07Z","disabled":false,"prefetch_condition":"WAF_Prefetch","response":"WAf_Response","service_id":"5GZsX83POn5zij6allCOKe","service_version_number":2,"updated_at":"2020-07-06T11:09:07Z"}}}' + body: '{"data":{"id":"7kRiB97L3ppEaKv5J3hJmV","type":"waf_firewall","attributes":{"active_rules_fastly_block_count":0,"active_rules_fastly_log_count":0,"active_rules_fastly_score_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_score_count":0,"active_rules_trustwave_block_count":0,"active_rules_trustwave_log_count":0,"created_at":"2020-07-06T11:09:07Z","disabled":false,"prefetch_condition":"WAF_Prefetch","response":"WAf_Response","service_id":"7i6HN3TK9wS159v2gPAZ8A","service_version_number":2,"updated_at":"2020-07-06T11:09:07Z"}}}' headers: Accept-Ranges: - bytes diff --git a/fastly/fixtures/wafs/condition/create.yaml b/fastly/fixtures/wafs/condition/create.yaml index f59dbd61d..35b561b6f 100644 --- a/fastly/fixtures/wafs/condition/create.yaml +++ b/fastly/fixtures/wafs/condition/create.yaml @@ -2,10 +2,10 @@ version: 1 interactions: - request: - body: Service=5n1Tvc6QVHtvZlG109EsyV&Version=2&name=WAF_Prefetch&priority=1&statement=req.url~%2B%22index.html%22&type=PREFETCH + body: Service=7i6HN3TK9wS159v2gPAZ8A&Version=2&name=WAF_Prefetch&priority=1&statement=req.url~%2B%22index.html%22&type=PREFETCH form: Service: - - 5n1Tvc6QVHtvZlG109EsyV + - 7i6HN3TK9wS159v2gPAZ8A Version: - "2" name: @@ -21,10 +21,10 @@ interactions: - application/x-www-form-urlencoded User-Agent: - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) - url: https://api.fastly.com/service/5n1Tvc6QVHtvZlG109EsyV/version/2/condition + url: https://api.fastly.com/service/7i6HN3TK9wS159v2gPAZ8A/version/2/condition method: POST response: - body: '{"name":"WAF_Prefetch","priority":"1","statement":"req.url~+\"index.html\"","type":"PREFETCH","service_id":"5n1Tvc6QVHtvZlG109EsyV","version":"2","comment":"","created_at":"2020-07-02T20:19:36Z","updated_at":"2020-07-02T20:19:36Z","deleted_at":null}' + body: '{"name":"WAF_Prefetch","priority":"1","statement":"req.url~+\"index.html\"","type":"PREFETCH","service_id":"7i6HN3TK9wS159v2gPAZ8A","version":"2","comment":"","created_at":"2020-07-02T20:19:36Z","updated_at":"2020-07-02T20:19:36Z","deleted_at":null}' headers: Accept-Ranges: - bytes diff --git a/fastly/fixtures/wafs/condition/delete.yaml b/fastly/fixtures/wafs/condition/delete.yaml index cd6b3db18..362b4127c 100644 --- a/fastly/fixtures/wafs/condition/delete.yaml +++ b/fastly/fixtures/wafs/condition/delete.yaml @@ -7,7 +7,7 @@ interactions: headers: User-Agent: - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) - url: https://api.fastly.com/service/5n1Tvc6QVHtvZlG109EsyV/version/2/condition/WAF_Prefetch + url: https://api.fastly.com/service/7i6HN3TK9wS159v2gPAZ8A/version/2/condition/WAF_Prefetch method: DELETE response: body: '{"status":"ok"}' diff --git a/fastly/fixtures/wafs/create.yaml b/fastly/fixtures/wafs/create.yaml index dfb123173..40c6b2d78 100644 --- a/fastly/fixtures/wafs/create.yaml +++ b/fastly/fixtures/wafs/create.yaml @@ -3,7 +3,7 @@ version: 1 interactions: - request: body: | - {"data":{"type":"waf_firewall","attributes":{"prefetch_condition":"WAF_Prefetch","response":"WAF_Response","service_id":"5n1Tvc6QVHtvZlG109EsyV","service_version_number":"2"}}} + {"data":{"type":"waf_firewall","attributes":{"prefetch_condition":"WAF_Prefetch","response":"WAF_Response","service_id":"7i6HN3TK9wS159v2gPAZ8A","service_version_number":"2"}}} form: {} headers: Accept: @@ -15,7 +15,7 @@ interactions: url: https://api.fastly.com/waf/firewalls method: POST response: - body: '{"data":{"id":"1bibBdxQkJYmZsQtR3EmmH","type":"waf_firewall","attributes":{"active_rules_fastly_block_count":0,"active_rules_fastly_log_count":0,"active_rules_fastly_score_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_score_count":0,"active_rules_trustwave_block_count":0,"active_rules_trustwave_log_count":0,"created_at":"2020-07-02T20:19:38Z","disabled":false,"prefetch_condition":"WAF_Prefetch","response":"WAF_Response","service_id":"5n1Tvc6QVHtvZlG109EsyV","service_version_number":2,"updated_at":"2020-07-02T20:19:38Z"}}}' + body: '{"data":{"id":"1bibBdxQkJYmZsQtR3EmmH","type":"waf_firewall","attributes":{"active_rules_fastly_block_count":0,"active_rules_fastly_log_count":0,"active_rules_fastly_score_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_score_count":0,"active_rules_trustwave_block_count":0,"active_rules_trustwave_log_count":0,"created_at":"2020-07-02T20:19:38Z","disabled":false,"prefetch_condition":"WAF_Prefetch","response":"WAF_Response","service_id":"7i6HN3TK9wS159v2gPAZ8A","service_version_number":2,"updated_at":"2020-07-02T20:19:38Z"}}}' headers: Accept-Ranges: - bytes diff --git a/fastly/fixtures/wafs/disable.yaml b/fastly/fixtures/wafs/disable.yaml index 8703926c0..a1431aa3a 100644 --- a/fastly/fixtures/wafs/disable.yaml +++ b/fastly/fixtures/wafs/disable.yaml @@ -15,7 +15,7 @@ interactions: url: https://api.fastly.com/waf/firewalls/1bibBdxQkJYmZsQtR3EmmH method: PATCH response: - body: '{"data":{"id":"1bibBdxQkJYmZsQtR3EmmH","type":"waf_firewall","attributes":{"active_rules_fastly_block_count":0,"active_rules_fastly_log_count":0,"active_rules_fastly_score_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_score_count":0,"active_rules_trustwave_block_count":0,"active_rules_trustwave_log_count":0,"created_at":"2020-07-02T20:19:38Z","disabled":true,"prefetch_condition":null,"response":null,"service_id":"5n1Tvc6QVHtvZlG109EsyV","service_version_number":null,"updated_at":"2020-07-02T20:19:41Z"}}}' + body: '{"data":{"id":"1bibBdxQkJYmZsQtR3EmmH","type":"waf_firewall","attributes":{"active_rules_fastly_block_count":0,"active_rules_fastly_log_count":0,"active_rules_fastly_score_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_score_count":0,"active_rules_trustwave_block_count":0,"active_rules_trustwave_log_count":0,"created_at":"2020-07-02T20:19:38Z","disabled":true,"prefetch_condition":null,"response":null,"service_id":"7i6HN3TK9wS159v2gPAZ8A","service_version_number":null,"updated_at":"2020-07-02T20:19:41Z"}}}' headers: Accept-Ranges: - bytes diff --git a/fastly/fixtures/wafs/enable.yaml b/fastly/fixtures/wafs/enable.yaml index 787409dcd..e9d292153 100644 --- a/fastly/fixtures/wafs/enable.yaml +++ b/fastly/fixtures/wafs/enable.yaml @@ -15,7 +15,7 @@ interactions: url: https://api.fastly.com/waf/firewalls/1bibBdxQkJYmZsQtR3EmmH method: PATCH response: - body: '{"data":{"id":"1bibBdxQkJYmZsQtR3EmmH","type":"waf_firewall","attributes":{"active_rules_fastly_block_count":0,"active_rules_fastly_log_count":0,"active_rules_fastly_score_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_score_count":0,"active_rules_trustwave_block_count":0,"active_rules_trustwave_log_count":0,"created_at":"2020-07-02T20:19:38Z","disabled":false,"prefetch_condition":null,"response":null,"service_id":"5n1Tvc6QVHtvZlG109EsyV","service_version_number":null,"updated_at":"2020-07-02T20:19:42Z"}}}' + body: '{"data":{"id":"1bibBdxQkJYmZsQtR3EmmH","type":"waf_firewall","attributes":{"active_rules_fastly_block_count":0,"active_rules_fastly_log_count":0,"active_rules_fastly_score_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_score_count":0,"active_rules_trustwave_block_count":0,"active_rules_trustwave_log_count":0,"created_at":"2020-07-02T20:19:38Z","disabled":false,"prefetch_condition":null,"response":null,"service_id":"7i6HN3TK9wS159v2gPAZ8A","service_version_number":null,"updated_at":"2020-07-02T20:19:42Z"}}}' headers: Accept-Ranges: - bytes diff --git a/fastly/fixtures/wafs/get.yaml b/fastly/fixtures/wafs/get.yaml index e36bbdfe8..4b918b0d2 100644 --- a/fastly/fixtures/wafs/get.yaml +++ b/fastly/fixtures/wafs/get.yaml @@ -10,7 +10,7 @@ interactions: url: https://api.fastly.com/waf/firewalls/1bibBdxQkJYmZsQtR3EmmH?filter%5Bservice_version_number%5D=2 method: GET response: - body: '{"data":{"id":"1bibBdxQkJYmZsQtR3EmmH","type":"waf_firewall","attributes":{"active_rules_fastly_block_count":0,"active_rules_fastly_log_count":0,"active_rules_fastly_score_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_score_count":0,"active_rules_trustwave_block_count":0,"active_rules_trustwave_log_count":0,"created_at":"2020-07-02T20:19:38Z","disabled":false,"prefetch_condition":"WAF_Prefetch","response":"WAF_Response","service_id":"5n1Tvc6QVHtvZlG109EsyV","service_version_number":2,"updated_at":"2020-07-02T20:19:38Z"}}}' + body: '{"data":{"id":"1bibBdxQkJYmZsQtR3EmmH","type":"waf_firewall","attributes":{"active_rules_fastly_block_count":0,"active_rules_fastly_log_count":0,"active_rules_fastly_score_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_score_count":0,"active_rules_trustwave_block_count":0,"active_rules_trustwave_log_count":0,"created_at":"2020-07-02T20:19:38Z","disabled":false,"prefetch_condition":"WAF_Prefetch","response":"WAF_Response","service_id":"7i6HN3TK9wS159v2gPAZ8A","service_version_number":2,"updated_at":"2020-07-02T20:19:38Z"}}}' headers: Accept-Ranges: - bytes diff --git a/fastly/fixtures/wafs/list.yaml b/fastly/fixtures/wafs/list.yaml index 9dae8689a..350be524a 100644 --- a/fastly/fixtures/wafs/list.yaml +++ b/fastly/fixtures/wafs/list.yaml @@ -7,10 +7,10 @@ interactions: headers: User-Agent: - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) - url: https://api.fastly.com/waf/firewalls?filter%5Bservice_id%5D=5n1Tvc6QVHtvZlG109EsyV&filter%5Bservice_version_number%5D=2 + url: https://api.fastly.com/waf/firewalls?filter%5Bservice_id%5D=7i6HN3TK9wS159v2gPAZ8A&filter%5Bservice_version_number%5D=2 method: GET response: - body: '{"data":[{"id":"1bibBdxQkJYmZsQtR3EmmH","type":"waf_firewall","attributes":{"active_rules_fastly_block_count":0,"active_rules_fastly_log_count":0,"active_rules_fastly_score_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_score_count":0,"active_rules_trustwave_block_count":0,"active_rules_trustwave_log_count":0,"created_at":"2020-07-02T20:19:38Z","disabled":false,"prefetch_condition":"WAF_Prefetch","response":"WAF_Response","service_id":"5n1Tvc6QVHtvZlG109EsyV","service_version_number":2,"updated_at":"2020-07-02T20:19:38Z"}}],"links":{"last":"https://api.fastly.com/waf/firewalls?filter[service_id]=5n1Tvc6QVHtvZlG109EsyV\u0026filter[service_version_number]=2\u0026page[number]=1\u0026page[size]=100","first":"https://api.fastly.com/waf/firewalls?filter[service_id]=5n1Tvc6QVHtvZlG109EsyV\u0026filter[service_version_number]=2\u0026page[number]=1\u0026page[size]=100"},"meta":{"current_page":1,"per_page":100,"record_count":1,"total_pages":1}}' + body: '{"data":[{"id":"1bibBdxQkJYmZsQtR3EmmH","type":"waf_firewall","attributes":{"active_rules_fastly_block_count":0,"active_rules_fastly_log_count":0,"active_rules_fastly_score_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_score_count":0,"active_rules_trustwave_block_count":0,"active_rules_trustwave_log_count":0,"created_at":"2020-07-02T20:19:38Z","disabled":false,"prefetch_condition":"WAF_Prefetch","response":"WAF_Response","service_id":"7i6HN3TK9wS159v2gPAZ8A","service_version_number":2,"updated_at":"2020-07-02T20:19:38Z"}}],"links":{"last":"https://api.fastly.com/waf/firewalls?filter[service_id]=7i6HN3TK9wS159v2gPAZ8A\u0026filter[service_version_number]=2\u0026page[number]=1\u0026page[size]=100","first":"https://api.fastly.com/waf/firewalls?filter[service_id]=7i6HN3TK9wS159v2gPAZ8A\u0026filter[service_version_number]=2\u0026page[number]=1\u0026page[size]=100"},"meta":{"current_page":1,"per_page":100,"record_count":1,"total_pages":1}}' headers: Accept-Ranges: - bytes diff --git a/fastly/fixtures/wafs/response_object/cleanup_another.yaml b/fastly/fixtures/wafs/response_object/cleanup_another.yaml index 61c7e0b49..e75f99ced 100644 --- a/fastly/fixtures/wafs/response_object/cleanup_another.yaml +++ b/fastly/fixtures/wafs/response_object/cleanup_another.yaml @@ -7,7 +7,7 @@ interactions: headers: User-Agent: - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) - url: https://api.fastly.com/service/5n1Tvc6QVHtvZlG109EsyV/version/2/response_object/WAF_Response2 + url: https://api.fastly.com/service/7i6HN3TK9wS159v2gPAZ8A/version/2/response_object/WAF_Response2 method: DELETE response: body: '{"status":"ok"}' diff --git a/fastly/fixtures/wafs/response_object/create.yaml b/fastly/fixtures/wafs/response_object/create.yaml index 2835549de..3417e4557 100644 --- a/fastly/fixtures/wafs/response_object/create.yaml +++ b/fastly/fixtures/wafs/response_object/create.yaml @@ -2,10 +2,10 @@ version: 1 interactions: - request: - body: Service=5n1Tvc6QVHtvZlG109EsyV&Version=2&name=WAF_Response&status=403 + body: Service=7i6HN3TK9wS159v2gPAZ8A&Version=2&name=WAF_Response&status=403 form: Service: - - 5n1Tvc6QVHtvZlG109EsyV + - 7i6HN3TK9wS159v2gPAZ8A Version: - "2" name: @@ -17,10 +17,10 @@ interactions: - application/x-www-form-urlencoded User-Agent: - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) - url: https://api.fastly.com/service/5n1Tvc6QVHtvZlG109EsyV/version/2/response_object + url: https://api.fastly.com/service/7i6HN3TK9wS159v2gPAZ8A/version/2/response_object method: POST response: - body: '{"name":"WAF_Response","status":"403","service_id":"5n1Tvc6QVHtvZlG109EsyV","version":"2","deleted_at":null,"content":null,"request_condition":"","created_at":"2020-07-02T20:19:37Z","cache_condition":"","content_type":null,"response":"ok","updated_at":"2020-07-02T20:19:37Z"}' + body: '{"name":"WAF_Response","status":"403","service_id":"7i6HN3TK9wS159v2gPAZ8A","version":"2","deleted_at":null,"content":null,"request_condition":"","created_at":"2020-07-02T20:19:37Z","cache_condition":"","content_type":null,"response":"ok","updated_at":"2020-07-02T20:19:37Z"}' headers: Accept-Ranges: - bytes diff --git a/fastly/fixtures/wafs/response_object/create_another.yaml b/fastly/fixtures/wafs/response_object/create_another.yaml index 6a3aacb71..c3c1713e9 100644 --- a/fastly/fixtures/wafs/response_object/create_another.yaml +++ b/fastly/fixtures/wafs/response_object/create_another.yaml @@ -2,10 +2,10 @@ version: 1 interactions: - request: - body: Service=5n1Tvc6QVHtvZlG109EsyV&Version=2&name=WAF_Response2&status=403 + body: Service=7i6HN3TK9wS159v2gPAZ8A&Version=2&name=WAF_Response2&status=403 form: Service: - - 5n1Tvc6QVHtvZlG109EsyV + - 7i6HN3TK9wS159v2gPAZ8A Version: - "2" name: @@ -17,10 +17,10 @@ interactions: - application/x-www-form-urlencoded User-Agent: - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) - url: https://api.fastly.com/service/5n1Tvc6QVHtvZlG109EsyV/version/2/response_object + url: https://api.fastly.com/service/7i6HN3TK9wS159v2gPAZ8A/version/2/response_object method: POST response: - body: '{"name":"WAF_Response2","status":"403","service_id":"5n1Tvc6QVHtvZlG109EsyV","version":"2","content":null,"updated_at":"2020-07-02T20:19:37Z","response":"ok","cache_condition":"","created_at":"2020-07-02T20:19:37Z","content_type":null,"request_condition":"","deleted_at":null}' + body: '{"name":"WAF_Response2","status":"403","service_id":"7i6HN3TK9wS159v2gPAZ8A","version":"2","content":null,"updated_at":"2020-07-02T20:19:37Z","response":"ok","cache_condition":"","created_at":"2020-07-02T20:19:37Z","content_type":null,"request_condition":"","deleted_at":null}' headers: Accept-Ranges: - bytes diff --git a/fastly/fixtures/wafs/response_object/delete.yaml b/fastly/fixtures/wafs/response_object/delete.yaml index eea8bc218..0811790f7 100644 --- a/fastly/fixtures/wafs/response_object/delete.yaml +++ b/fastly/fixtures/wafs/response_object/delete.yaml @@ -7,7 +7,7 @@ interactions: headers: User-Agent: - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) - url: https://api.fastly.com/service/5n1Tvc6QVHtvZlG109EsyV/version/2/response_object/WAF_Response + url: https://api.fastly.com/service/7i6HN3TK9wS159v2gPAZ8A/version/2/response_object/WAF_Response method: DELETE response: body: '{"status":"ok"}' diff --git a/fastly/fixtures/wafs/service/create.yaml b/fastly/fixtures/wafs/service/create.yaml index 5727271e7..19406a199 100644 --- a/fastly/fixtures/wafs/service/create.yaml +++ b/fastly/fixtures/wafs/service/create.yaml @@ -18,7 +18,7 @@ interactions: url: https://api.fastly.com/service method: POST response: - body: '{"customer_id":"WpqWFjTA4lk2N1g0GY2HH","comment":"go-fastly client test","name":"test_service_service2","type":"vcl","versions":[{"testing":false,"locked":false,"deployed":false,"updated_at":"2020-07-02T20:19:36Z","deleted_at":null,"service_id":"5n1Tvc6QVHtvZlG109EsyV","active":false,"staging":false,"comment":"","created_at":"2020-07-02T20:19:36Z","number":1}],"created_at":"2020-07-02T20:19:36Z","publish_key":"","deleted_at":null,"id":"5n1Tvc6QVHtvZlG109EsyV","updated_at":"2020-07-02T20:19:36Z"}' + body: '{"customer_id":"WpqWFjTA4lk2N1g0GY2HH","comment":"go-fastly client test","name":"test_service_service2","type":"vcl","versions":[{"testing":false,"locked":false,"deployed":false,"updated_at":"2020-07-02T20:19:36Z","deleted_at":null,"service_id":"7i6HN3TK9wS159v2gPAZ8A","active":false,"staging":false,"comment":"","created_at":"2020-07-02T20:19:36Z","number":1}],"created_at":"2020-07-02T20:19:36Z","publish_key":"","deleted_at":null,"id":"7i6HN3TK9wS159v2gPAZ8A","updated_at":"2020-07-02T20:19:36Z"}' headers: Accept-Ranges: - bytes diff --git a/fastly/fixtures/wafs/service/delete.yaml b/fastly/fixtures/wafs/service/delete.yaml index 5947cfc71..81b8b3625 100644 --- a/fastly/fixtures/wafs/service/delete.yaml +++ b/fastly/fixtures/wafs/service/delete.yaml @@ -7,7 +7,7 @@ interactions: headers: User-Agent: - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) - url: https://api.fastly.com/service/5n1Tvc6QVHtvZlG109EsyV + url: https://api.fastly.com/service/7i6HN3TK9wS159v2gPAZ8A method: DELETE response: body: '{"status":"ok"}' diff --git a/fastly/fixtures/wafs/service/version.yaml b/fastly/fixtures/wafs/service/version.yaml index c5d383659..0d920060c 100644 --- a/fastly/fixtures/wafs/service/version.yaml +++ b/fastly/fixtures/wafs/service/version.yaml @@ -2,19 +2,19 @@ version: 1 interactions: - request: - body: Service=5n1Tvc6QVHtvZlG109EsyV + body: Service=7i6HN3TK9wS159v2gPAZ8A form: Service: - - 5n1Tvc6QVHtvZlG109EsyV + - 7i6HN3TK9wS159v2gPAZ8A headers: Content-Type: - application/x-www-form-urlencoded User-Agent: - FastlyGo/1.16.0 (+github.com/fastly/go-fastly; go1.14.2) - url: https://api.fastly.com/service/5n1Tvc6QVHtvZlG109EsyV/version + url: https://api.fastly.com/service/7i6HN3TK9wS159v2gPAZ8A/version method: POST response: - body: '{"service_id":"5n1Tvc6QVHtvZlG109EsyV","number":2}' + body: '{"service_id":"7i6HN3TK9wS159v2gPAZ8A","number":2}' headers: Accept-Ranges: - bytes diff --git a/fastly/fixtures/wafs/update.yaml b/fastly/fixtures/wafs/update.yaml index 8529984c9..d308291ff 100644 --- a/fastly/fixtures/wafs/update.yaml +++ b/fastly/fixtures/wafs/update.yaml @@ -3,7 +3,7 @@ version: 1 interactions: - request: body: | - {"data":{"type":"waf_firewall","id":"1bibBdxQkJYmZsQtR3EmmH","attributes":{"response":"WAF_Response2","service_id":"5n1Tvc6QVHtvZlG109EsyV","service_version_number":"2"}}} + {"data":{"type":"waf_firewall","id":"1bibBdxQkJYmZsQtR3EmmH","attributes":{"response":"WAF_Response2","service_id":"7i6HN3TK9wS159v2gPAZ8A","service_version_number":"2"}}} form: {} headers: Accept: @@ -15,9 +15,9 @@ interactions: url: https://api.fastly.com/waf/firewalls/1bibBdxQkJYmZsQtR3EmmH method: PATCH response: - body: '{"data":{"id":"1bibBdxQkJYmZsQtR3EmmH","type":"waf_firewall","attributes":{"active_rules_fastly_block_count":0,"active_rules_fastly_log_count":0,"active_rules_fastly_score_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_score_count":0,"active_rules_trustwave_block_count":0,"active_rules_trustwave_log_count":0,"created_at":"2020-07-02T20:19:38Z","disabled":false,"prefetch_condition":"WAF_Prefetch","response":"WAF_Response2","service_id":"5n1Tvc6QVHtvZlG109EsyV","service_version_number":2,"updated_at":"2020-07-02T20:19:38Z"}},"meta":{"warnings":[{"title":"This + body: '{"data":{"id":"1bibBdxQkJYmZsQtR3EmmH","type":"waf_firewall","attributes":{"active_rules_fastly_block_count":0,"active_rules_fastly_log_count":0,"active_rules_fastly_score_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_score_count":0,"active_rules_trustwave_block_count":0,"active_rules_trustwave_log_count":0,"created_at":"2020-07-02T20:19:38Z","disabled":false,"prefetch_condition":"WAF_Prefetch","response":"WAF_Response2","service_id":"7i6HN3TK9wS159v2gPAZ8A","service_version_number":2,"updated_at":"2020-07-02T20:19:38Z"}},"meta":{"warnings":[{"title":"This version of this service must be active","detail":"You may only update the WAF - VCL on an active version of a service. The version 2 of service 5n1Tvc6QVHtvZlG109EsyV + VCL on an active version of a service. The version 2 of service 7i6HN3TK9wS159v2gPAZ8A is not active. You may activate it through https://app.fastly.com or through the API: https://docs.fastly.com/api/config#version Be sure to review the version''s changes before activating it."}]}}' From 66fe95234c8e3761daa6bf9b0efebce7f3c649ac Mon Sep 17 00:00:00 2001 From: Mateus Pimenta <1920261+matpimenta@users.noreply.github.com> Date: Mon, 5 Oct 2020 13:43:00 +0100 Subject: [PATCH 21/37] Setting go.mod package to v2 --- go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.mod b/go.mod index c072714dc..300de411e 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/fastly/go-fastly +module github.com/fastly/go-fastly/v2 require ( github.com/ajg/form v0.0.0-20160802194845-cc2954064ec9 From 255a5d7df2712c1bb9bd24900dc1baca140bf7af Mon Sep 17 00:00:00 2001 From: Mateus Pimenta <1920261+matpimenta@users.noreply.github.com> Date: Tue, 6 Oct 2020 18:50:56 +0100 Subject: [PATCH 22/37] Adding WAF Exclusion endpoints to go-fastly client Co-authored-by: Zsolt Balvanyos <5632209+ZsoltBalvanyos@users.noreply.github.com> --- fastly/errors.go | 8 + .../create/active_rules/create.yaml | 48 ++ .../create/response_object/create.yaml | 57 ++ .../waf_exclusion/create/service/create.yaml | 55 ++ .../waf_exclusion/create/service/delete.yaml | 47 ++ .../waf_exclusion/create/service/version.yaml | 51 ++ .../waf_exclusion/create/waf/create.yaml | 48 ++ .../waf_exclusion/create/waf/delete.yaml | 44 ++ .../create/waf_exclusions/create.yaml | 49 ++ .../create/waf_exclusions/list.yaml | 48 ++ .../delete/active_rules/create.yaml | 48 ++ .../delete/response_object/create.yaml | 57 ++ .../waf_exclusion/delete/service/create.yaml | 55 ++ .../waf_exclusion/delete/service/delete.yaml | 47 ++ .../waf_exclusion/delete/service/version.yaml | 51 ++ .../waf_exclusion/delete/waf/create.yaml | 48 ++ .../waf_exclusion/delete/waf/delete.yaml | 44 ++ .../delete/waf_exclusions/create.yaml | 49 ++ .../delete/waf_exclusions/list.yaml | 47 ++ .../delete/waf_exclusions/update.yaml | 39 ++ .../list/active_rules/create.yaml | 48 ++ .../list/response_object/create.yaml | 57 ++ .../waf_exclusion/list/service/create.yaml | 55 ++ .../waf_exclusion/list/service/delete.yaml | 47 ++ .../waf_exclusion/list/service/version.yaml | 51 ++ .../waf_exclusion/list/waf/create.yaml | 48 ++ .../waf_exclusion/list/waf/delete.yaml | 44 ++ .../list/waf_exclusions/create-1.yaml | 49 ++ .../list/waf_exclusions/create-2.yaml | 49 ++ .../list/waf_exclusions/list.yaml | 49 ++ .../list_filters/active_rules/create.yaml | 48 ++ .../list_filters/response_object/create.yaml | 57 ++ .../list_filters/service/create.yaml | 55 ++ .../list_filters/service/delete.yaml | 47 ++ .../list_filters/service/version.yaml | 51 ++ .../list_filters/waf/create.yaml | 48 ++ .../list_filters/waf/delete.yaml | 44 ++ .../list_filters/waf_exclusions/create-1.yaml | 49 ++ .../list_filters/waf_exclusions/create-2.yaml | 49 ++ .../list_filters/waf_exclusions/create-3.yaml | 49 ++ .../list_filters/waf_exclusions/list.yaml | 48 ++ .../update/active_rules/create.yaml | 48 ++ .../update/response_object/create.yaml | 57 ++ .../waf_exclusion/update/service/create.yaml | 55 ++ .../waf_exclusion/update/service/delete.yaml | 47 ++ .../waf_exclusion/update/service/version.yaml | 51 ++ .../waf_exclusion/update/waf/create.yaml | 48 ++ .../waf_exclusion/update/waf/delete.yaml | 44 ++ .../update/waf_exclusions/create.yaml | 49 ++ .../update/waf_exclusions/list.yaml | 48 ++ .../update/waf_exclusions/update.yaml | 49 ++ fastly/waf_exclusion.go | 297 +++++++++++ fastly/waf_exclusion_test.go | 499 ++++++++++++++++++ 53 files changed, 3274 insertions(+) create mode 100644 fastly/fixtures/waf_exclusion/create/active_rules/create.yaml create mode 100644 fastly/fixtures/waf_exclusion/create/response_object/create.yaml create mode 100644 fastly/fixtures/waf_exclusion/create/service/create.yaml create mode 100644 fastly/fixtures/waf_exclusion/create/service/delete.yaml create mode 100644 fastly/fixtures/waf_exclusion/create/service/version.yaml create mode 100644 fastly/fixtures/waf_exclusion/create/waf/create.yaml create mode 100644 fastly/fixtures/waf_exclusion/create/waf/delete.yaml create mode 100644 fastly/fixtures/waf_exclusion/create/waf_exclusions/create.yaml create mode 100644 fastly/fixtures/waf_exclusion/create/waf_exclusions/list.yaml create mode 100644 fastly/fixtures/waf_exclusion/delete/active_rules/create.yaml create mode 100644 fastly/fixtures/waf_exclusion/delete/response_object/create.yaml create mode 100644 fastly/fixtures/waf_exclusion/delete/service/create.yaml create mode 100644 fastly/fixtures/waf_exclusion/delete/service/delete.yaml create mode 100644 fastly/fixtures/waf_exclusion/delete/service/version.yaml create mode 100644 fastly/fixtures/waf_exclusion/delete/waf/create.yaml create mode 100644 fastly/fixtures/waf_exclusion/delete/waf/delete.yaml create mode 100644 fastly/fixtures/waf_exclusion/delete/waf_exclusions/create.yaml create mode 100644 fastly/fixtures/waf_exclusion/delete/waf_exclusions/list.yaml create mode 100644 fastly/fixtures/waf_exclusion/delete/waf_exclusions/update.yaml create mode 100644 fastly/fixtures/waf_exclusion/list/active_rules/create.yaml create mode 100644 fastly/fixtures/waf_exclusion/list/response_object/create.yaml create mode 100644 fastly/fixtures/waf_exclusion/list/service/create.yaml create mode 100644 fastly/fixtures/waf_exclusion/list/service/delete.yaml create mode 100644 fastly/fixtures/waf_exclusion/list/service/version.yaml create mode 100644 fastly/fixtures/waf_exclusion/list/waf/create.yaml create mode 100644 fastly/fixtures/waf_exclusion/list/waf/delete.yaml create mode 100644 fastly/fixtures/waf_exclusion/list/waf_exclusions/create-1.yaml create mode 100644 fastly/fixtures/waf_exclusion/list/waf_exclusions/create-2.yaml create mode 100644 fastly/fixtures/waf_exclusion/list/waf_exclusions/list.yaml create mode 100644 fastly/fixtures/waf_exclusion/list_filters/active_rules/create.yaml create mode 100644 fastly/fixtures/waf_exclusion/list_filters/response_object/create.yaml create mode 100644 fastly/fixtures/waf_exclusion/list_filters/service/create.yaml create mode 100644 fastly/fixtures/waf_exclusion/list_filters/service/delete.yaml create mode 100644 fastly/fixtures/waf_exclusion/list_filters/service/version.yaml create mode 100644 fastly/fixtures/waf_exclusion/list_filters/waf/create.yaml create mode 100644 fastly/fixtures/waf_exclusion/list_filters/waf/delete.yaml create mode 100644 fastly/fixtures/waf_exclusion/list_filters/waf_exclusions/create-1.yaml create mode 100644 fastly/fixtures/waf_exclusion/list_filters/waf_exclusions/create-2.yaml create mode 100644 fastly/fixtures/waf_exclusion/list_filters/waf_exclusions/create-3.yaml create mode 100644 fastly/fixtures/waf_exclusion/list_filters/waf_exclusions/list.yaml create mode 100644 fastly/fixtures/waf_exclusion/update/active_rules/create.yaml create mode 100644 fastly/fixtures/waf_exclusion/update/response_object/create.yaml create mode 100644 fastly/fixtures/waf_exclusion/update/service/create.yaml create mode 100644 fastly/fixtures/waf_exclusion/update/service/delete.yaml create mode 100644 fastly/fixtures/waf_exclusion/update/service/version.yaml create mode 100644 fastly/fixtures/waf_exclusion/update/waf/create.yaml create mode 100644 fastly/fixtures/waf_exclusion/update/waf/delete.yaml create mode 100644 fastly/fixtures/waf_exclusion/update/waf_exclusions/create.yaml create mode 100644 fastly/fixtures/waf_exclusion/update/waf_exclusions/list.yaml create mode 100644 fastly/fixtures/waf_exclusion/update/waf_exclusions/update.yaml create mode 100644 fastly/waf_exclusion.go create mode 100644 fastly/waf_exclusion_test.go diff --git a/fastly/errors.go b/fastly/errors.go index 1be95f8aa..30c4871ed 100644 --- a/fastly/errors.go +++ b/fastly/errors.go @@ -117,6 +117,14 @@ var ErrMissingWAFVersionID = errors.New("missing required field 'WAFVersionID'") // requires a list of WAF active rules, but it is empty. var ErrMissingWAFActiveRuleList = errors.New("WAF active rules slice is empty") +// ErrMissingWAFExclusionNumber is an error that is returned when an input struct +// requires a "WAFExclusionNumber" key, but one was not set. +var ErrMissingWAFExclusionNumber = errors.New("missing required field 'WAFExclusionNumber'") + +// ErrMissingWAFExclusion is an error that is returned when an input struct +// requires a "WAFExclusion" key, but one was not set. +var ErrMissingWAFExclusion = errors.New("missing required field 'WAFExclusion'") + // ErrMissingOWASPID is an error that is returned was an input struct // requires a "OWASPID" key, but one was not set var ErrMissingOWASPID = errors.New("missing required field 'OWASPID'") diff --git a/fastly/fixtures/waf_exclusion/create/active_rules/create.yaml b/fastly/fixtures/waf_exclusion/create/active_rules/create.yaml new file mode 100644 index 000000000..ae892544f --- /dev/null +++ b/fastly/fixtures/waf_exclusion/create/active_rules/create.yaml @@ -0,0 +1,48 @@ +--- +version: 1 +interactions: +- request: + body: | + {"data":[{"type":"waf_active_rule","attributes":{"modsec_rule_id":2029718,"revision":1,"status":"log"}},{"type":"waf_active_rule","attributes":{"modsec_rule_id":2037405,"revision":1,"status":"log"}},{"type":"waf_active_rule","attributes":{"modsec_rule_id":1010070,"revision":1,"status":"log"}}]} + form: {} + headers: + Accept: + - application/vnd.api+json; ext=bulk + Content-Type: + - application/vnd.api+json; ext=bulk + User-Agent: + - FastlyGo/1.17.0 (+github.com/fastly/go-fastly; go1.14.5) + url: https://api.fastly.com/waf/firewalls/0PJDTfXzU9F4KsTErnB41h/versions/1/active-rules + method: POST + response: + body: '{"data":[{"id":"2kcqGgKYiXSQQci6TxlHJf","type":"waf_active_rule","attributes":{"created_at":"2020-10-07T13:09:09Z","latest_revision":1,"modsec_rule_id":2029718,"outdated":false,"revision":1,"status":"log","updated_at":"2020-10-07T13:09:09Z"},"relationships":{"waf_firewall_version":{"data":{"id":"5DiT3wrGN8OFEL8GnKM4Dr","type":"waf_firewall_version"}},"waf_rule_revision":{"data":{"id":"6ZJML5tsy5uVq1nGNgmZ78","type":"waf_rule_revision"}}}},{"id":"2HkKe5PmWYa1wjgJetq980","type":"waf_active_rule","attributes":{"created_at":"2020-10-07T13:09:09Z","latest_revision":1,"modsec_rule_id":2037405,"outdated":false,"revision":1,"status":"log","updated_at":"2020-10-07T13:09:09Z"},"relationships":{"waf_firewall_version":{"data":{"id":"5DiT3wrGN8OFEL8GnKM4Dr","type":"waf_firewall_version"}},"waf_rule_revision":{"data":{"id":"3ANlv7vVZdzk2qFXlJLIk3","type":"waf_rule_revision"}}}},{"id":"4oebnye6APVjo1fn7RSYhV","type":"waf_active_rule","attributes":{"created_at":"2020-10-07T13:09:09Z","latest_revision":1,"modsec_rule_id":1010070,"outdated":false,"revision":1,"status":"log","updated_at":"2020-10-07T13:09:09Z"},"relationships":{"waf_firewall_version":{"data":{"id":"5DiT3wrGN8OFEL8GnKM4Dr","type":"waf_firewall_version"}},"waf_rule_revision":{"data":{"id":"2qiuFDyJoxuKkKkJYjrgsC","type":"waf_rule_revision"}}}}]}' + headers: + Accept-Ranges: + - bytes + - bytes + Content-Length: + - "1312" + Content-Type: + - application/vnd.api+json + Date: + - Wed, 07 Oct 2020 13:09:09 GMT + Status: + - 201 Created + Strict-Transport-Security: + - max-age=31536000 + Via: + - 1.1 varnish + - 1.1 varnish + X-Cache: + - MISS, MISS + X-Cache-Hits: + - 0, 0 + X-Content-Type-Options: + - nosniff + X-Served-By: + - cache-control-slwdc9037-CONTROL-SLWDC, cache-lhr7363-LHR + X-Timer: + - S1602076149.046940,VS0,VE320 + status: 201 Created + code: 201 + duration: "" diff --git a/fastly/fixtures/waf_exclusion/create/response_object/create.yaml b/fastly/fixtures/waf_exclusion/create/response_object/create.yaml new file mode 100644 index 000000000..80e21cc53 --- /dev/null +++ b/fastly/fixtures/waf_exclusion/create/response_object/create.yaml @@ -0,0 +1,57 @@ +--- +version: 1 +interactions: +- request: + body: Service=5ZTGLKH5LoWkfPUSAv1w6X&Version=2&name=WAf_Response&status=403 + form: + Service: + - 5ZTGLKH5LoWkfPUSAv1w6X + Version: + - "2" + name: + - WAf_Response + status: + - "403" + headers: + Content-Type: + - application/x-www-form-urlencoded + User-Agent: + - FastlyGo/1.17.0 (+github.com/fastly/go-fastly; go1.14.5) + url: https://api.fastly.com/service/5ZTGLKH5LoWkfPUSAv1w6X/version/2/response_object + method: POST + response: + body: '{"name":"WAf_Response","status":"403","service_id":"5ZTGLKH5LoWkfPUSAv1w6X","version":"2","created_at":"2020-10-07T13:09:07Z","response":"ok","cache_condition":"","deleted_at":null,"content":null,"request_condition":"","content_type":null,"updated_at":"2020-10-07T13:09:07Z"}' + headers: + Accept-Ranges: + - bytes + - bytes + Cache-Control: + - no-cache + Content-Type: + - application/json + Date: + - Wed, 07 Oct 2020 13:09:07 GMT + Fastly-Ratelimit-Remaining: + - "4944" + Fastly-Ratelimit-Reset: + - "1602079200" + Status: + - 200 OK + Strict-Transport-Security: + - max-age=31536000 + Vary: + - Accept-Encoding + Via: + - 1.1 varnish + - 1.1 varnish + X-Cache: + - MISS, MISS + X-Cache-Hits: + - 0, 0 + X-Served-By: + - cache-control-slwdc9035-CONTROL-SLWDC, cache-lhr7363-LHR + X-Timer: + - S1602076148.510773,VS0,VE209 + status: 200 OK + code: 200 + duration: "" diff --git a/fastly/fixtures/waf_exclusion/create/service/create.yaml b/fastly/fixtures/waf_exclusion/create/service/create.yaml new file mode 100644 index 000000000..446a73a73 --- /dev/null +++ b/fastly/fixtures/waf_exclusion/create/service/create.yaml @@ -0,0 +1,55 @@ +--- +version: 1 +interactions: +- request: + body: comment=go-fastly+client+test&name=test_service_service-5577006791947779410&type=vcl + form: + comment: + - go-fastly client test + name: + - test_service_service-5577006791947779410 + type: + - vcl + headers: + Content-Type: + - application/x-www-form-urlencoded + User-Agent: + - FastlyGo/1.17.0 (+github.com/fastly/go-fastly; go1.14.5) + url: https://api.fastly.com/service + method: POST + response: + body: '{"customer_id":"WpqWFjTA4lk2N1g0GY2HH","comment":"go-fastly client test","name":"test_service_service-5577006791947779410","type":"vcl","created_at":"2020-10-07T13:09:06Z","updated_at":"2020-10-07T13:09:06Z","deleted_at":null,"versions":[{"deleted_at":null,"comment":"","testing":false,"locked":false,"active":false,"deployed":false,"service_id":"5ZTGLKH5LoWkfPUSAv1w6X","staging":false,"updated_at":"2020-10-07T13:09:06Z","number":1,"created_at":"2020-10-07T13:09:06Z"}],"publish_key":"","id":"5ZTGLKH5LoWkfPUSAv1w6X"}' + headers: + Accept-Ranges: + - bytes + - bytes + Cache-Control: + - no-cache + Content-Type: + - application/json + Date: + - Wed, 07 Oct 2020 13:09:06 GMT + Fastly-Ratelimit-Remaining: + - "4950" + Fastly-Ratelimit-Reset: + - "1602079200" + Status: + - 200 OK + Strict-Transport-Security: + - max-age=31536000 + Vary: + - Accept-Encoding + Via: + - 1.1 varnish + - 1.1 varnish + X-Cache: + - MISS, MISS + X-Cache-Hits: + - 0, 0 + X-Served-By: + - cache-control-slwdc9037-CONTROL-SLWDC, cache-lhr7363-LHR + X-Timer: + - S1602076146.397380,VS0,VE463 + status: 200 OK + code: 200 + duration: "" diff --git a/fastly/fixtures/waf_exclusion/create/service/delete.yaml b/fastly/fixtures/waf_exclusion/create/service/delete.yaml new file mode 100644 index 000000000..738469c61 --- /dev/null +++ b/fastly/fixtures/waf_exclusion/create/service/delete.yaml @@ -0,0 +1,47 @@ +--- +version: 1 +interactions: +- request: + body: "" + form: {} + headers: + User-Agent: + - FastlyGo/1.17.0 (+github.com/fastly/go-fastly; go1.14.5) + url: https://api.fastly.com/service/5ZTGLKH5LoWkfPUSAv1w6X + method: DELETE + response: + body: '{"status":"ok"}' + headers: + Accept-Ranges: + - bytes + - bytes + Cache-Control: + - no-cache + Content-Type: + - application/json + Date: + - Wed, 07 Oct 2020 13:09:10 GMT + Fastly-Ratelimit-Remaining: + - "4937" + Fastly-Ratelimit-Reset: + - "1602079200" + Status: + - 200 OK + Strict-Transport-Security: + - max-age=31536000 + Vary: + - Accept-Encoding + Via: + - 1.1 varnish + - 1.1 varnish + X-Cache: + - MISS, MISS + X-Cache-Hits: + - 0, 0 + X-Served-By: + - cache-control-slwdc9035-CONTROL-SLWDC, cache-lhr7363-LHR + X-Timer: + - S1602076150.061571,VS0,VE239 + status: 200 OK + code: 200 + duration: "" diff --git a/fastly/fixtures/waf_exclusion/create/service/version.yaml b/fastly/fixtures/waf_exclusion/create/service/version.yaml new file mode 100644 index 000000000..ee9ccd081 --- /dev/null +++ b/fastly/fixtures/waf_exclusion/create/service/version.yaml @@ -0,0 +1,51 @@ +--- +version: 1 +interactions: +- request: + body: Service=5ZTGLKH5LoWkfPUSAv1w6X + form: + Service: + - 5ZTGLKH5LoWkfPUSAv1w6X + headers: + Content-Type: + - application/x-www-form-urlencoded + User-Agent: + - FastlyGo/1.17.0 (+github.com/fastly/go-fastly; go1.14.5) + url: https://api.fastly.com/service/5ZTGLKH5LoWkfPUSAv1w6X/version + method: POST + response: + body: '{"service_id":"5ZTGLKH5LoWkfPUSAv1w6X","number":2}' + headers: + Accept-Ranges: + - bytes + - bytes + Cache-Control: + - no-cache + Content-Type: + - application/json + Date: + - Wed, 07 Oct 2020 13:09:07 GMT + Fastly-Ratelimit-Remaining: + - "4946" + Fastly-Ratelimit-Reset: + - "1602079200" + Status: + - 200 OK + Strict-Transport-Security: + - max-age=31536000 + Vary: + - Accept-Encoding + Via: + - 1.1 varnish + - 1.1 varnish + X-Cache: + - MISS, MISS + X-Cache-Hits: + - 0, 0 + X-Served-By: + - cache-control-slwdc9036-CONTROL-SLWDC, cache-lhr7363-LHR + X-Timer: + - S1602076147.213445,VS0,VE229 + status: 200 OK + code: 200 + duration: "" diff --git a/fastly/fixtures/waf_exclusion/create/waf/create.yaml b/fastly/fixtures/waf_exclusion/create/waf/create.yaml new file mode 100644 index 000000000..a55f5af14 --- /dev/null +++ b/fastly/fixtures/waf_exclusion/create/waf/create.yaml @@ -0,0 +1,48 @@ +--- +version: 1 +interactions: +- request: + body: | + {"data":{"type":"waf_firewall","attributes":{"prefetch_condition":"","response":"WAf_Response","service_id":"5ZTGLKH5LoWkfPUSAv1w6X","service_version_number":"2"}}} + form: {} + headers: + Accept: + - application/vnd.api+json + Content-Type: + - application/vnd.api+json + User-Agent: + - FastlyGo/1.17.0 (+github.com/fastly/go-fastly; go1.14.5) + url: https://api.fastly.com/waf/firewalls + method: POST + response: + body: '{"data":{"id":"0PJDTfXzU9F4KsTErnB41h","type":"waf_firewall","attributes":{"active_rules_fastly_block_count":0,"active_rules_fastly_log_count":0,"active_rules_fastly_score_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_score_count":0,"active_rules_trustwave_block_count":0,"active_rules_trustwave_log_count":0,"created_at":"2020-10-07T13:09:08Z","disabled":false,"prefetch_condition":"","response":"WAf_Response","service_id":"5ZTGLKH5LoWkfPUSAv1w6X","service_version_number":2,"updated_at":"2020-10-07T13:09:08Z"}}}' + headers: + Accept-Ranges: + - bytes + - bytes + Content-Length: + - "566" + Content-Type: + - application/vnd.api+json + Date: + - Wed, 07 Oct 2020 13:09:08 GMT + Status: + - 201 Created + Strict-Transport-Security: + - max-age=31536000 + Via: + - 1.1 varnish + - 1.1 varnish + X-Cache: + - MISS, MISS + X-Cache-Hits: + - 0, 0 + X-Content-Type-Options: + - nosniff + X-Served-By: + - cache-control-slwdc9035-CONTROL-SLWDC, cache-lhr7363-LHR + X-Timer: + - S1602076148.811138,VS0,VE1146 + status: 201 Created + code: 201 + duration: "" diff --git a/fastly/fixtures/waf_exclusion/create/waf/delete.yaml b/fastly/fixtures/waf_exclusion/create/waf/delete.yaml new file mode 100644 index 000000000..b5102a3fc --- /dev/null +++ b/fastly/fixtures/waf_exclusion/create/waf/delete.yaml @@ -0,0 +1,44 @@ +--- +version: 1 +interactions: +- request: + body: | + {"data":{"type":"waf_firewall","id":"0PJDTfXzU9F4KsTErnB41h","attributes":{"service_version_number":"1"}}} + form: {} + headers: + Accept: + - application/vnd.api+json + Content-Type: + - application/vnd.api+json + User-Agent: + - FastlyGo/1.17.0 (+github.com/fastly/go-fastly; go1.14.5) + url: https://api.fastly.com/waf/firewalls/0PJDTfXzU9F4KsTErnB41h + method: DELETE + response: + body: "" + headers: + Accept-Ranges: + - bytes + - bytes + Date: + - Wed, 07 Oct 2020 13:09:10 GMT + Status: + - 204 No Content + Strict-Transport-Security: + - max-age=31536000 + Via: + - 1.1 varnish + - 1.1 varnish + X-Cache: + - MISS, MISS + X-Cache-Hits: + - 0, 0 + X-Content-Type-Options: + - nosniff + X-Served-By: + - cache-control-slwdc9036-CONTROL-SLWDC, cache-lhr7363-LHR + X-Timer: + - S1602076150.870875,VS0,VE154 + status: 204 No Content + code: 204 + duration: "" diff --git a/fastly/fixtures/waf_exclusion/create/waf_exclusions/create.yaml b/fastly/fixtures/waf_exclusion/create/waf_exclusions/create.yaml new file mode 100644 index 000000000..4308556bf --- /dev/null +++ b/fastly/fixtures/waf_exclusion/create/waf_exclusions/create.yaml @@ -0,0 +1,49 @@ +--- +version: 1 +interactions: +- request: + body: | + {"data":{"type":"waf_exclusion","attributes":{"condition":"req.url.basename == \"index.html\"","exclusion_type":"rule","name":"index page","number":null},"relationships":{"waf_rules":{"data":[{"type":"waf_rule","id":"2029718"},{"type":"waf_rule","id":"2037405"}]}}},"included":[{"type":"waf_rule","id":"2029718","attributes":{"modsec_rule_id":2029718}},{"type":"waf_rule","id":"2037405","attributes":{"modsec_rule_id":2037405}}]} + form: {} + headers: + Accept: + - application/vnd.api+json + Content-Type: + - application/vnd.api+json + User-Agent: + - FastlyGo/1.17.0 (+github.com/fastly/go-fastly; go1.14.5) + url: https://api.fastly.com/waf/firewalls/0PJDTfXzU9F4KsTErnB41h/versions/1/exclusions + method: POST + response: + body: '{"data":{"id":"1pyqLOEXniQ7MDp6CU7nc2","type":"waf_exclusion","attributes":{"created_at":"2020-10-07T13:09:09Z","exclusion_type":"rule","condition":"req.url.basename + == \"index.html\"","name":"index page","number":1,"updated_at":"2020-10-07T13:09:09Z"},"relationships":{"waf_rules":{"data":[{"id":"1YveWU8qwEYidE8WAiZqCN","type":"waf_rule"},{"id":"VovV0PIWJCm33k1piDpnX","type":"waf_rule"}]}}}}' + headers: + Accept-Ranges: + - bytes + - bytes + Content-Length: + - "394" + Content-Type: + - application/vnd.api+json + Date: + - Wed, 07 Oct 2020 13:09:09 GMT + Status: + - 201 Created + Strict-Transport-Security: + - max-age=31536000 + Via: + - 1.1 varnish + - 1.1 varnish + X-Cache: + - MISS, MISS + X-Cache-Hits: + - 0, 0 + X-Content-Type-Options: + - nosniff + X-Served-By: + - cache-control-slwdc9037-CONTROL-SLWDC, cache-lhr7363-LHR + X-Timer: + - S1602076149.426656,VS0,VE148 + status: 201 Created + code: 201 + duration: "" diff --git a/fastly/fixtures/waf_exclusion/create/waf_exclusions/list.yaml b/fastly/fixtures/waf_exclusion/create/waf_exclusions/list.yaml new file mode 100644 index 000000000..31afb40e3 --- /dev/null +++ b/fastly/fixtures/waf_exclusion/create/waf_exclusions/list.yaml @@ -0,0 +1,48 @@ +--- +version: 1 +interactions: +- request: + body: "" + form: {} + headers: + User-Agent: + - FastlyGo/1.17.0 (+github.com/fastly/go-fastly; go1.14.5) + url: https://api.fastly.com/waf/firewalls/0PJDTfXzU9F4KsTErnB41h/versions/1/exclusions?include=waf_rules&page%5Bnumber%5D=1&page%5Bsize%5D=100 + method: GET + response: + body: '{"data":[{"id":"1pyqLOEXniQ7MDp6CU7nc2","type":"waf_exclusion","attributes":{"created_at":"2020-10-07T13:09:09Z","exclusion_type":"rule","condition":"req.url.basename + == \"index.html\"","name":"index page","number":1,"updated_at":"2020-10-07T13:09:09Z"},"relationships":{"waf_rules":{"data":[{"id":"1YveWU8qwEYidE8WAiZqCN","type":"waf_rule"},{"id":"VovV0PIWJCm33k1piDpnX","type":"waf_rule"}]}}}],"included":[{"id":"1YveWU8qwEYidE8WAiZqCN","type":"waf_rule","attributes":{"modsec_rule_id":2029718,"publisher":"trustwave","type":"strict"}},{"id":"VovV0PIWJCm33k1piDpnX","type":"waf_rule","attributes":{"modsec_rule_id":2037405,"publisher":"trustwave","type":"strict"}}],"links":{"last":"https://api.fastly.com/waf/firewalls/0PJDTfXzU9F4KsTErnB41h/versions/1/exclusions?include=waf_rules\u0026page[number]=1\u0026page[size]=100","first":"https://api.fastly.com/waf/firewalls/0PJDTfXzU9F4KsTErnB41h/versions/1/exclusions?include=waf_rules\u0026page[number]=1\u0026page[size]=100"},"meta":{"current_page":1,"per_page":100,"record_count":1,"total_pages":1}}' + headers: + Accept-Ranges: + - bytes + - bytes + - bytes + Age: + - "0" + - "0" + Content-Length: + - "1051" + Content-Type: + - application/vnd.api+json + Date: + - Wed, 07 Oct 2020 13:09:09 GMT + Status: + - 200 OK + Strict-Transport-Security: + - max-age=31536000 + Via: + - 1.1 varnish + - 1.1 varnish + X-Cache: + - MISS, MISS + X-Cache-Hits: + - 0, 0 + X-Content-Type-Options: + - nosniff + X-Served-By: + - cache-control-slwdc9036-CONTROL-SLWDC, cache-lhr7363-LHR + X-Timer: + - S1602076150.659102,VS0,VE148 + status: 200 OK + code: 200 + duration: "" diff --git a/fastly/fixtures/waf_exclusion/delete/active_rules/create.yaml b/fastly/fixtures/waf_exclusion/delete/active_rules/create.yaml new file mode 100644 index 000000000..cae1cc261 --- /dev/null +++ b/fastly/fixtures/waf_exclusion/delete/active_rules/create.yaml @@ -0,0 +1,48 @@ +--- +version: 1 +interactions: +- request: + body: | + {"data":[{"type":"waf_active_rule","attributes":{"modsec_rule_id":2029718,"revision":1,"status":"log"}},{"type":"waf_active_rule","attributes":{"modsec_rule_id":2037405,"revision":1,"status":"log"}},{"type":"waf_active_rule","attributes":{"modsec_rule_id":1010070,"revision":1,"status":"log"}}]} + form: {} + headers: + Accept: + - application/vnd.api+json; ext=bulk + Content-Type: + - application/vnd.api+json; ext=bulk + User-Agent: + - FastlyGo/1.17.0 (+github.com/fastly/go-fastly; go1.14.5) + url: https://api.fastly.com/waf/firewalls/3wsTANvXfIbxSOd5GUpqQf/versions/1/active-rules + method: POST + response: + body: '{"data":[{"id":"3BVvSyopzcQ9Vfi0ia51PF","type":"waf_active_rule","attributes":{"created_at":"2020-10-07T13:09:09Z","latest_revision":1,"modsec_rule_id":2029718,"outdated":false,"revision":1,"status":"log","updated_at":"2020-10-07T13:09:09Z"},"relationships":{"waf_firewall_version":{"data":{"id":"HmBQAyog2H22IHva5xNzB","type":"waf_firewall_version"}},"waf_rule_revision":{"data":{"id":"6ZJML5tsy5uVq1nGNgmZ78","type":"waf_rule_revision"}}}},{"id":"5SabvExTpr2dlLgVP2lgJm","type":"waf_active_rule","attributes":{"created_at":"2020-10-07T13:09:09Z","latest_revision":1,"modsec_rule_id":2037405,"outdated":false,"revision":1,"status":"log","updated_at":"2020-10-07T13:09:09Z"},"relationships":{"waf_firewall_version":{"data":{"id":"HmBQAyog2H22IHva5xNzB","type":"waf_firewall_version"}},"waf_rule_revision":{"data":{"id":"3ANlv7vVZdzk2qFXlJLIk3","type":"waf_rule_revision"}}}},{"id":"2XGTelStkzWMYJSqtoc8Bs","type":"waf_active_rule","attributes":{"created_at":"2020-10-07T13:09:09Z","latest_revision":1,"modsec_rule_id":1010070,"outdated":false,"revision":1,"status":"log","updated_at":"2020-10-07T13:09:09Z"},"relationships":{"waf_firewall_version":{"data":{"id":"HmBQAyog2H22IHva5xNzB","type":"waf_firewall_version"}},"waf_rule_revision":{"data":{"id":"2qiuFDyJoxuKkKkJYjrgsC","type":"waf_rule_revision"}}}}]}' + headers: + Accept-Ranges: + - bytes + - bytes + Content-Length: + - "1309" + Content-Type: + - application/vnd.api+json + Date: + - Wed, 07 Oct 2020 13:09:09 GMT + Status: + - 201 Created + Strict-Transport-Security: + - max-age=31536000 + Via: + - 1.1 varnish + - 1.1 varnish + X-Cache: + - MISS, MISS + X-Cache-Hits: + - 0, 0 + X-Content-Type-Options: + - nosniff + X-Served-By: + - cache-control-slwdc9035-CONTROL-SLWDC, cache-lhr7363-LHR + X-Timer: + - S1602076149.887066,VS0,VE479 + status: 201 Created + code: 201 + duration: "" diff --git a/fastly/fixtures/waf_exclusion/delete/response_object/create.yaml b/fastly/fixtures/waf_exclusion/delete/response_object/create.yaml new file mode 100644 index 000000000..696f5ae79 --- /dev/null +++ b/fastly/fixtures/waf_exclusion/delete/response_object/create.yaml @@ -0,0 +1,57 @@ +--- +version: 1 +interactions: +- request: + body: Service=4j5iMcheZDNpEMiwjnYh8K&Version=2&name=WAf_Response&status=403 + form: + Service: + - 4j5iMcheZDNpEMiwjnYh8K + Version: + - "2" + name: + - WAf_Response + status: + - "403" + headers: + Content-Type: + - application/x-www-form-urlencoded + User-Agent: + - FastlyGo/1.17.0 (+github.com/fastly/go-fastly; go1.14.5) + url: https://api.fastly.com/service/4j5iMcheZDNpEMiwjnYh8K/version/2/response_object + method: POST + response: + body: '{"name":"WAf_Response","status":"403","service_id":"4j5iMcheZDNpEMiwjnYh8K","version":"2","cache_condition":"","updated_at":"2020-10-07T13:09:07Z","deleted_at":null,"content_type":null,"request_condition":"","content":null,"response":"ok","created_at":"2020-10-07T13:09:07Z"}' + headers: + Accept-Ranges: + - bytes + - bytes + Cache-Control: + - no-cache + Content-Type: + - application/json + Date: + - Wed, 07 Oct 2020 13:09:07 GMT + Fastly-Ratelimit-Remaining: + - "4945" + Fastly-Ratelimit-Reset: + - "1602079200" + Status: + - 200 OK + Strict-Transport-Security: + - max-age=31536000 + Vary: + - Accept-Encoding + Via: + - 1.1 varnish + - 1.1 varnish + X-Cache: + - MISS, MISS + X-Cache-Hits: + - 0, 0 + X-Served-By: + - cache-control-slwdc9035-CONTROL-SLWDC, cache-lhr7363-LHR + X-Timer: + - S1602076147.215250,VS0,VE233 + status: 200 OK + code: 200 + duration: "" diff --git a/fastly/fixtures/waf_exclusion/delete/service/create.yaml b/fastly/fixtures/waf_exclusion/delete/service/create.yaml new file mode 100644 index 000000000..81d647184 --- /dev/null +++ b/fastly/fixtures/waf_exclusion/delete/service/create.yaml @@ -0,0 +1,55 @@ +--- +version: 1 +interactions: +- request: + body: comment=go-fastly+client+test&name=test_service_service-3916589616287113937&type=vcl + form: + comment: + - go-fastly client test + name: + - test_service_service-3916589616287113937 + type: + - vcl + headers: + Content-Type: + - application/x-www-form-urlencoded + User-Agent: + - FastlyGo/1.17.0 (+github.com/fastly/go-fastly; go1.14.5) + url: https://api.fastly.com/service + method: POST + response: + body: '{"customer_id":"WpqWFjTA4lk2N1g0GY2HH","comment":"go-fastly client test","name":"test_service_service-3916589616287113937","type":"vcl","updated_at":"2020-10-07T13:09:06Z","publish_key":"","versions":[{"locked":false,"deployed":false,"testing":false,"deleted_at":null,"created_at":"2020-10-07T13:09:06Z","service_id":"4j5iMcheZDNpEMiwjnYh8K","staging":false,"updated_at":"2020-10-07T13:09:06Z","comment":"","active":false,"number":1}],"id":"4j5iMcheZDNpEMiwjnYh8K","created_at":"2020-10-07T13:09:06Z","deleted_at":null}' + headers: + Accept-Ranges: + - bytes + - bytes + Cache-Control: + - no-cache + Content-Type: + - application/json + Date: + - Wed, 07 Oct 2020 13:09:06 GMT + Fastly-Ratelimit-Remaining: + - "4952" + Fastly-Ratelimit-Reset: + - "1602079200" + Status: + - 200 OK + Strict-Transport-Security: + - max-age=31536000 + Vary: + - Accept-Encoding + Via: + - 1.1 varnish + - 1.1 varnish + X-Cache: + - MISS, MISS + X-Cache-Hits: + - 0, 0 + X-Served-By: + - cache-control-slwdc9036-CONTROL-SLWDC, cache-lhr7363-LHR + X-Timer: + - S1602076146.397397,VS0,VE221 + status: 200 OK + code: 200 + duration: "" diff --git a/fastly/fixtures/waf_exclusion/delete/service/delete.yaml b/fastly/fixtures/waf_exclusion/delete/service/delete.yaml new file mode 100644 index 000000000..587e7d399 --- /dev/null +++ b/fastly/fixtures/waf_exclusion/delete/service/delete.yaml @@ -0,0 +1,47 @@ +--- +version: 1 +interactions: +- request: + body: "" + form: {} + headers: + User-Agent: + - FastlyGo/1.17.0 (+github.com/fastly/go-fastly; go1.14.5) + url: https://api.fastly.com/service/4j5iMcheZDNpEMiwjnYh8K + method: DELETE + response: + body: '{"status":"ok"}' + headers: + Accept-Ranges: + - bytes + - bytes + Cache-Control: + - no-cache + Content-Type: + - application/json + Date: + - Wed, 07 Oct 2020 13:09:11 GMT + Fastly-Ratelimit-Remaining: + - "4935" + Fastly-Ratelimit-Reset: + - "1602079200" + Status: + - 200 OK + Strict-Transport-Security: + - max-age=31536000 + Vary: + - Accept-Encoding + Via: + - 1.1 varnish + - 1.1 varnish + X-Cache: + - MISS, MISS + X-Cache-Hits: + - 0, 0 + X-Served-By: + - cache-control-slwdc9037-CONTROL-SLWDC, cache-lhr7363-LHR + X-Timer: + - S1602076151.749556,VS0,VE271 + status: 200 OK + code: 200 + duration: "" diff --git a/fastly/fixtures/waf_exclusion/delete/service/version.yaml b/fastly/fixtures/waf_exclusion/delete/service/version.yaml new file mode 100644 index 000000000..cfd35bd4e --- /dev/null +++ b/fastly/fixtures/waf_exclusion/delete/service/version.yaml @@ -0,0 +1,51 @@ +--- +version: 1 +interactions: +- request: + body: Service=4j5iMcheZDNpEMiwjnYh8K + form: + Service: + - 4j5iMcheZDNpEMiwjnYh8K + headers: + Content-Type: + - application/x-www-form-urlencoded + User-Agent: + - FastlyGo/1.17.0 (+github.com/fastly/go-fastly; go1.14.5) + url: https://api.fastly.com/service/4j5iMcheZDNpEMiwjnYh8K/version + method: POST + response: + body: '{"service_id":"4j5iMcheZDNpEMiwjnYh8K","number":2}' + headers: + Accept-Ranges: + - bytes + - bytes + Cache-Control: + - no-cache + Content-Type: + - application/json + Date: + - Wed, 07 Oct 2020 13:09:07 GMT + Fastly-Ratelimit-Remaining: + - "4947" + Fastly-Ratelimit-Reset: + - "1602079200" + Status: + - 200 OK + Strict-Transport-Security: + - max-age=31536000 + Vary: + - Accept-Encoding + Via: + - 1.1 varnish + - 1.1 varnish + X-Cache: + - MISS, MISS + X-Cache-Hits: + - 0, 0 + X-Served-By: + - cache-control-slwdc9035-CONTROL-SLWDC, cache-lhr7363-LHR + X-Timer: + - S1602076147.661563,VS0,VE511 + status: 200 OK + code: 200 + duration: "" diff --git a/fastly/fixtures/waf_exclusion/delete/waf/create.yaml b/fastly/fixtures/waf_exclusion/delete/waf/create.yaml new file mode 100644 index 000000000..f6f1999d2 --- /dev/null +++ b/fastly/fixtures/waf_exclusion/delete/waf/create.yaml @@ -0,0 +1,48 @@ +--- +version: 1 +interactions: +- request: + body: | + {"data":{"type":"waf_firewall","attributes":{"prefetch_condition":"","response":"WAf_Response","service_id":"4j5iMcheZDNpEMiwjnYh8K","service_version_number":"2"}}} + form: {} + headers: + Accept: + - application/vnd.api+json + Content-Type: + - application/vnd.api+json + User-Agent: + - FastlyGo/1.17.0 (+github.com/fastly/go-fastly; go1.14.5) + url: https://api.fastly.com/waf/firewalls + method: POST + response: + body: '{"data":{"id":"3wsTANvXfIbxSOd5GUpqQf","type":"waf_firewall","attributes":{"active_rules_fastly_block_count":0,"active_rules_fastly_log_count":0,"active_rules_fastly_score_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_score_count":0,"active_rules_trustwave_block_count":0,"active_rules_trustwave_log_count":0,"created_at":"2020-10-07T13:09:08Z","disabled":false,"prefetch_condition":"","response":"WAf_Response","service_id":"4j5iMcheZDNpEMiwjnYh8K","service_version_number":2,"updated_at":"2020-10-07T13:09:08Z"}}}' + headers: + Accept-Ranges: + - bytes + - bytes + Content-Length: + - "566" + Content-Type: + - application/vnd.api+json + Date: + - Wed, 07 Oct 2020 13:09:08 GMT + Status: + - 201 Created + Strict-Transport-Security: + - max-age=31536000 + Via: + - 1.1 varnish + - 1.1 varnish + X-Cache: + - MISS, MISS + X-Cache-Hits: + - 0, 0 + X-Content-Type-Options: + - nosniff + X-Served-By: + - cache-control-slwdc9037-CONTROL-SLWDC, cache-lhr7363-LHR + X-Timer: + - S1602076148.510756,VS0,VE1275 + status: 201 Created + code: 201 + duration: "" diff --git a/fastly/fixtures/waf_exclusion/delete/waf/delete.yaml b/fastly/fixtures/waf_exclusion/delete/waf/delete.yaml new file mode 100644 index 000000000..5968a7f48 --- /dev/null +++ b/fastly/fixtures/waf_exclusion/delete/waf/delete.yaml @@ -0,0 +1,44 @@ +--- +version: 1 +interactions: +- request: + body: | + {"data":{"type":"waf_firewall","id":"3wsTANvXfIbxSOd5GUpqQf","attributes":{"service_version_number":"1"}}} + form: {} + headers: + Accept: + - application/vnd.api+json + Content-Type: + - application/vnd.api+json + User-Agent: + - FastlyGo/1.17.0 (+github.com/fastly/go-fastly; go1.14.5) + url: https://api.fastly.com/waf/firewalls/3wsTANvXfIbxSOd5GUpqQf + method: DELETE + response: + body: "" + headers: + Accept-Ranges: + - bytes + - bytes + Date: + - Wed, 07 Oct 2020 13:09:10 GMT + Status: + - 204 No Content + Strict-Transport-Security: + - max-age=31536000 + Via: + - 1.1 varnish + - 1.1 varnish + X-Cache: + - MISS, MISS + X-Cache-Hits: + - 0, 0 + X-Content-Type-Options: + - nosniff + X-Served-By: + - cache-control-slwdc9036-CONTROL-SLWDC, cache-lhr7363-LHR + X-Timer: + - S1602076150.302674,VS0,VE385 + status: 204 No Content + code: 204 + duration: "" diff --git a/fastly/fixtures/waf_exclusion/delete/waf_exclusions/create.yaml b/fastly/fixtures/waf_exclusion/delete/waf_exclusions/create.yaml new file mode 100644 index 000000000..f4c7e6056 --- /dev/null +++ b/fastly/fixtures/waf_exclusion/delete/waf_exclusions/create.yaml @@ -0,0 +1,49 @@ +--- +version: 1 +interactions: +- request: + body: | + {"data":{"type":"waf_exclusion","attributes":{"condition":"req.url.basename == \"index.html\"","exclusion_type":"rule","name":"index page","number":null},"relationships":{"waf_rules":{"data":[{"type":"waf_rule","id":"2029718"},{"type":"waf_rule","id":"2037405"}]}}},"included":[{"type":"waf_rule","id":"2029718","attributes":{"modsec_rule_id":2029718}},{"type":"waf_rule","id":"2037405","attributes":{"modsec_rule_id":2037405}}]} + form: {} + headers: + Accept: + - application/vnd.api+json + Content-Type: + - application/vnd.api+json + User-Agent: + - FastlyGo/1.17.0 (+github.com/fastly/go-fastly; go1.14.5) + url: https://api.fastly.com/waf/firewalls/3wsTANvXfIbxSOd5GUpqQf/versions/1/exclusions + method: POST + response: + body: '{"data":{"id":"4QHUnacVJDGp13EJmos89K","type":"waf_exclusion","attributes":{"created_at":"2020-10-07T13:09:09Z","exclusion_type":"rule","condition":"req.url.basename + == \"index.html\"","name":"index page","number":1,"updated_at":"2020-10-07T13:09:09Z"},"relationships":{"waf_rules":{"data":[{"id":"1YveWU8qwEYidE8WAiZqCN","type":"waf_rule"},{"id":"VovV0PIWJCm33k1piDpnX","type":"waf_rule"}]}}}}' + headers: + Accept-Ranges: + - bytes + - bytes + Content-Length: + - "394" + Content-Type: + - application/vnd.api+json + Date: + - Wed, 07 Oct 2020 13:09:09 GMT + Status: + - 201 Created + Strict-Transport-Security: + - max-age=31536000 + Via: + - 1.1 varnish + - 1.1 varnish + X-Cache: + - MISS, MISS + X-Cache-Hits: + - 0, 0 + X-Content-Type-Options: + - nosniff + X-Served-By: + - cache-control-slwdc9036-CONTROL-SLWDC, cache-lhr7363-LHR + X-Timer: + - S1602076149.426628,VS0,VE136 + status: 201 Created + code: 201 + duration: "" diff --git a/fastly/fixtures/waf_exclusion/delete/waf_exclusions/list.yaml b/fastly/fixtures/waf_exclusion/delete/waf_exclusions/list.yaml new file mode 100644 index 000000000..969a15880 --- /dev/null +++ b/fastly/fixtures/waf_exclusion/delete/waf_exclusions/list.yaml @@ -0,0 +1,47 @@ +--- +version: 1 +interactions: +- request: + body: "" + form: {} + headers: + User-Agent: + - FastlyGo/1.17.0 (+github.com/fastly/go-fastly; go1.14.5) + url: https://api.fastly.com/waf/firewalls/3wsTANvXfIbxSOd5GUpqQf/versions/1/exclusions?include=waf_rules&page%5Bnumber%5D=1&page%5Bsize%5D=100 + method: GET + response: + body: '{"data":[],"links":{"last":"https://api.fastly.com/waf/firewalls/3wsTANvXfIbxSOd5GUpqQf/versions/1/exclusions?include=waf_rules\u0026page[number]=1\u0026page[size]=100","first":"https://api.fastly.com/waf/firewalls/3wsTANvXfIbxSOd5GUpqQf/versions/1/exclusions?include=waf_rules\u0026page[number]=1\u0026page[size]=100"},"meta":{"current_page":1,"per_page":100,"record_count":0,"total_pages":1}}' + headers: + Accept-Ranges: + - bytes + - bytes + - bytes + Age: + - "0" + - "0" + Content-Length: + - "394" + Content-Type: + - application/vnd.api+json + Date: + - Wed, 07 Oct 2020 13:09:10 GMT + Status: + - 200 OK + Strict-Transport-Security: + - max-age=31536000 + Via: + - 1.1 varnish + - 1.1 varnish + X-Cache: + - MISS, MISS + X-Cache-Hits: + - 0, 0 + X-Content-Type-Options: + - nosniff + X-Served-By: + - cache-control-slwdc9037-CONTROL-SLWDC, cache-lhr7363-LHR + X-Timer: + - S1602076150.870889,VS0,VE382 + status: 200 OK + code: 200 + duration: "" diff --git a/fastly/fixtures/waf_exclusion/delete/waf_exclusions/update.yaml b/fastly/fixtures/waf_exclusion/delete/waf_exclusions/update.yaml new file mode 100644 index 000000000..0e5cac778 --- /dev/null +++ b/fastly/fixtures/waf_exclusion/delete/waf_exclusions/update.yaml @@ -0,0 +1,39 @@ +--- +version: 1 +interactions: +- request: + body: "" + form: {} + headers: + User-Agent: + - FastlyGo/1.17.0 (+github.com/fastly/go-fastly; go1.14.5) + url: https://api.fastly.com/waf/firewalls/3wsTANvXfIbxSOd5GUpqQf/versions/1/exclusions/1 + method: DELETE + response: + body: "" + headers: + Accept-Ranges: + - bytes + - bytes + Date: + - Wed, 07 Oct 2020 13:09:09 GMT + Status: + - 204 No Content + Strict-Transport-Security: + - max-age=31536000 + Via: + - 1.1 varnish + - 1.1 varnish + X-Cache: + - MISS, MISS + X-Cache-Hits: + - 0, 0 + X-Content-Type-Options: + - nosniff + X-Served-By: + - cache-control-slwdc9036-CONTROL-SLWDC, cache-lhr7363-LHR + X-Timer: + - S1602076150.611413,VS0,VE171 + status: 204 No Content + code: 204 + duration: "" diff --git a/fastly/fixtures/waf_exclusion/list/active_rules/create.yaml b/fastly/fixtures/waf_exclusion/list/active_rules/create.yaml new file mode 100644 index 000000000..e7fe83bad --- /dev/null +++ b/fastly/fixtures/waf_exclusion/list/active_rules/create.yaml @@ -0,0 +1,48 @@ +--- +version: 1 +interactions: +- request: + body: | + {"data":[{"type":"waf_active_rule","attributes":{"modsec_rule_id":2029718,"revision":1,"status":"log"}},{"type":"waf_active_rule","attributes":{"modsec_rule_id":2037405,"revision":1,"status":"log"}},{"type":"waf_active_rule","attributes":{"modsec_rule_id":1010070,"revision":1,"status":"log"}}]} + form: {} + headers: + Accept: + - application/vnd.api+json; ext=bulk + Content-Type: + - application/vnd.api+json; ext=bulk + User-Agent: + - FastlyGo/1.17.0 (+github.com/fastly/go-fastly; go1.14.5) + url: https://api.fastly.com/waf/firewalls/5HtuuALz7WUiKn4AZnU1VM/versions/1/active-rules + method: POST + response: + body: '{"data":[{"id":"2meQ2kooxO1TVMgfrmoZXE","type":"waf_active_rule","attributes":{"created_at":"2020-10-07T13:09:09Z","latest_revision":1,"modsec_rule_id":2029718,"outdated":false,"revision":1,"status":"log","updated_at":"2020-10-07T13:09:09Z"},"relationships":{"waf_firewall_version":{"data":{"id":"2YlFM58yYJBu2oZqAPxJ5n","type":"waf_firewall_version"}},"waf_rule_revision":{"data":{"id":"6ZJML5tsy5uVq1nGNgmZ78","type":"waf_rule_revision"}}}},{"id":"6CggG3aoA4lfhBtOJuGK8G","type":"waf_active_rule","attributes":{"created_at":"2020-10-07T13:09:09Z","latest_revision":1,"modsec_rule_id":2037405,"outdated":false,"revision":1,"status":"log","updated_at":"2020-10-07T13:09:09Z"},"relationships":{"waf_firewall_version":{"data":{"id":"2YlFM58yYJBu2oZqAPxJ5n","type":"waf_firewall_version"}},"waf_rule_revision":{"data":{"id":"3ANlv7vVZdzk2qFXlJLIk3","type":"waf_rule_revision"}}}},{"id":"7KQSfZg4DSO1EZCjSCtKSf","type":"waf_active_rule","attributes":{"created_at":"2020-10-07T13:09:09Z","latest_revision":1,"modsec_rule_id":1010070,"outdated":false,"revision":1,"status":"log","updated_at":"2020-10-07T13:09:09Z"},"relationships":{"waf_firewall_version":{"data":{"id":"2YlFM58yYJBu2oZqAPxJ5n","type":"waf_firewall_version"}},"waf_rule_revision":{"data":{"id":"2qiuFDyJoxuKkKkJYjrgsC","type":"waf_rule_revision"}}}}]}' + headers: + Accept-Ranges: + - bytes + - bytes + Content-Length: + - "1312" + Content-Type: + - application/vnd.api+json + Date: + - Wed, 07 Oct 2020 13:09:09 GMT + Status: + - 201 Created + Strict-Transport-Security: + - max-age=31536000 + Via: + - 1.1 varnish + - 1.1 varnish + X-Cache: + - MISS, MISS + X-Cache-Hits: + - 0, 0 + X-Content-Type-Options: + - nosniff + X-Served-By: + - cache-control-slwdc9036-CONTROL-SLWDC, cache-lhr7363-LHR + X-Timer: + - S1602076149.250968,VS0,VE131 + status: 201 Created + code: 201 + duration: "" diff --git a/fastly/fixtures/waf_exclusion/list/response_object/create.yaml b/fastly/fixtures/waf_exclusion/list/response_object/create.yaml new file mode 100644 index 000000000..eb1c6eec4 --- /dev/null +++ b/fastly/fixtures/waf_exclusion/list/response_object/create.yaml @@ -0,0 +1,57 @@ +--- +version: 1 +interactions: +- request: + body: Service=2tqox6DHGJMOXYH4nYZqgN&Version=2&name=WAf_Response&status=403 + form: + Service: + - 2tqox6DHGJMOXYH4nYZqgN + Version: + - "2" + name: + - WAf_Response + status: + - "403" + headers: + Content-Type: + - application/x-www-form-urlencoded + User-Agent: + - FastlyGo/1.17.0 (+github.com/fastly/go-fastly; go1.14.5) + url: https://api.fastly.com/service/2tqox6DHGJMOXYH4nYZqgN/version/2/response_object + method: POST + response: + body: '{"name":"WAf_Response","status":"403","service_id":"2tqox6DHGJMOXYH4nYZqgN","version":"2","cache_condition":"","updated_at":"2020-10-07T13:09:08Z","response":"ok","created_at":"2020-10-07T13:09:08Z","request_condition":"","content_type":null,"content":null,"deleted_at":null}' + headers: + Accept-Ranges: + - bytes + - bytes + Cache-Control: + - no-cache + Content-Type: + - application/json + Date: + - Wed, 07 Oct 2020 13:09:08 GMT + Fastly-Ratelimit-Remaining: + - "4940" + Fastly-Ratelimit-Reset: + - "1602079200" + Status: + - 200 OK + Strict-Transport-Security: + - max-age=31536000 + Vary: + - Accept-Encoding + Via: + - 1.1 varnish + - 1.1 varnish + X-Cache: + - MISS, MISS + X-Cache-Hits: + - 0, 0 + X-Served-By: + - cache-control-slwdc9036-CONTROL-SLWDC, cache-lhr7363-LHR + X-Timer: + - S1602076148.085221,VS0,VE208 + status: 200 OK + code: 200 + duration: "" diff --git a/fastly/fixtures/waf_exclusion/list/service/create.yaml b/fastly/fixtures/waf_exclusion/list/service/create.yaml new file mode 100644 index 000000000..c1d686bf1 --- /dev/null +++ b/fastly/fixtures/waf_exclusion/list/service/create.yaml @@ -0,0 +1,55 @@ +--- +version: 1 +interactions: +- request: + body: comment=go-fastly+client+test&name=test_service_service-6129484611666145821&type=vcl + form: + comment: + - go-fastly client test + name: + - test_service_service-6129484611666145821 + type: + - vcl + headers: + Content-Type: + - application/x-www-form-urlencoded + User-Agent: + - FastlyGo/1.17.0 (+github.com/fastly/go-fastly; go1.14.5) + url: https://api.fastly.com/service + method: POST + response: + body: '{"customer_id":"WpqWFjTA4lk2N1g0GY2HH","comment":"go-fastly client test","name":"test_service_service-6129484611666145821","type":"vcl","versions":[{"testing":false,"comment":"","staging":false,"deleted_at":null,"active":false,"created_at":"2020-10-07T13:09:06Z","updated_at":"2020-10-07T13:09:06Z","service_id":"2tqox6DHGJMOXYH4nYZqgN","locked":false,"number":1,"deployed":false}],"id":"2tqox6DHGJMOXYH4nYZqgN","updated_at":"2020-10-07T13:09:06Z","created_at":"2020-10-07T13:09:06Z","deleted_at":null,"publish_key":""}' + headers: + Accept-Ranges: + - bytes + - bytes + Cache-Control: + - no-cache + Content-Type: + - application/json + Date: + - Wed, 07 Oct 2020 13:09:06 GMT + Fastly-Ratelimit-Remaining: + - "4949" + Fastly-Ratelimit-Reset: + - "1602079200" + Status: + - 200 OK + Strict-Transport-Security: + - max-age=31536000 + Vary: + - Accept-Encoding + Via: + - 1.1 varnish + - 1.1 varnish + X-Cache: + - MISS, MISS + X-Cache-Hits: + - 0, 0 + X-Served-By: + - cache-control-slwdc9035-CONTROL-SLWDC, cache-lhr7363-LHR + X-Timer: + - S1602076146.399215,VS0,VE487 + status: 200 OK + code: 200 + duration: "" diff --git a/fastly/fixtures/waf_exclusion/list/service/delete.yaml b/fastly/fixtures/waf_exclusion/list/service/delete.yaml new file mode 100644 index 000000000..8b28684e6 --- /dev/null +++ b/fastly/fixtures/waf_exclusion/list/service/delete.yaml @@ -0,0 +1,47 @@ +--- +version: 1 +interactions: +- request: + body: "" + form: {} + headers: + User-Agent: + - FastlyGo/1.17.0 (+github.com/fastly/go-fastly; go1.14.5) + url: https://api.fastly.com/service/2tqox6DHGJMOXYH4nYZqgN + method: DELETE + response: + body: '{"status":"ok"}' + headers: + Accept-Ranges: + - bytes + - bytes + Cache-Control: + - no-cache + Content-Type: + - application/json + Date: + - Wed, 07 Oct 2020 13:09:10 GMT + Fastly-Ratelimit-Remaining: + - "4936" + Fastly-Ratelimit-Reset: + - "1602079200" + Status: + - 200 OK + Strict-Transport-Security: + - max-age=31536000 + Vary: + - Accept-Encoding + Via: + - 1.1 varnish + - 1.1 varnish + X-Cache: + - MISS, MISS + X-Cache-Hits: + - 0, 0 + X-Served-By: + - cache-control-slwdc9037-CONTROL-SLWDC, cache-lhr7363-LHR + X-Timer: + - S1602076151.681556,VS0,VE254 + status: 200 OK + code: 200 + duration: "" diff --git a/fastly/fixtures/waf_exclusion/list/service/version.yaml b/fastly/fixtures/waf_exclusion/list/service/version.yaml new file mode 100644 index 000000000..c04c1e598 --- /dev/null +++ b/fastly/fixtures/waf_exclusion/list/service/version.yaml @@ -0,0 +1,51 @@ +--- +version: 1 +interactions: +- request: + body: Service=2tqox6DHGJMOXYH4nYZqgN + form: + Service: + - 2tqox6DHGJMOXYH4nYZqgN + headers: + Content-Type: + - application/x-www-form-urlencoded + User-Agent: + - FastlyGo/1.17.0 (+github.com/fastly/go-fastly; go1.14.5) + url: https://api.fastly.com/service/2tqox6DHGJMOXYH4nYZqgN/version + method: POST + response: + body: '{"service_id":"2tqox6DHGJMOXYH4nYZqgN","number":2}' + headers: + Accept-Ranges: + - bytes + - bytes + Cache-Control: + - no-cache + Content-Type: + - application/json + Date: + - Wed, 07 Oct 2020 13:09:08 GMT + Fastly-Ratelimit-Remaining: + - "4941" + Fastly-Ratelimit-Reset: + - "1602079200" + Status: + - 200 OK + Strict-Transport-Security: + - max-age=31536000 + Vary: + - Accept-Encoding + Via: + - 1.1 varnish + - 1.1 varnish + X-Cache: + - MISS, MISS + X-Cache-Hits: + - 0, 0 + X-Served-By: + - cache-control-slwdc9037-CONTROL-SLWDC, cache-lhr7363-LHR + X-Timer: + - S1602076148.811108,VS0,VE218 + status: 200 OK + code: 200 + duration: "" diff --git a/fastly/fixtures/waf_exclusion/list/waf/create.yaml b/fastly/fixtures/waf_exclusion/list/waf/create.yaml new file mode 100644 index 000000000..d8e656cde --- /dev/null +++ b/fastly/fixtures/waf_exclusion/list/waf/create.yaml @@ -0,0 +1,48 @@ +--- +version: 1 +interactions: +- request: + body: | + {"data":{"type":"waf_firewall","attributes":{"prefetch_condition":"","response":"WAf_Response","service_id":"2tqox6DHGJMOXYH4nYZqgN","service_version_number":"2"}}} + form: {} + headers: + Accept: + - application/vnd.api+json + Content-Type: + - application/vnd.api+json + User-Agent: + - FastlyGo/1.17.0 (+github.com/fastly/go-fastly; go1.14.5) + url: https://api.fastly.com/waf/firewalls + method: POST + response: + body: '{"data":{"id":"5HtuuALz7WUiKn4AZnU1VM","type":"waf_firewall","attributes":{"active_rules_fastly_block_count":0,"active_rules_fastly_log_count":0,"active_rules_fastly_score_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_score_count":0,"active_rules_trustwave_block_count":0,"active_rules_trustwave_log_count":0,"created_at":"2020-10-07T13:09:09Z","disabled":false,"prefetch_condition":"","response":"WAf_Response","service_id":"2tqox6DHGJMOXYH4nYZqgN","service_version_number":2,"updated_at":"2020-10-07T13:09:09Z"}}}' + headers: + Accept-Ranges: + - bytes + - bytes + Content-Length: + - "566" + Content-Type: + - application/vnd.api+json + Date: + - Wed, 07 Oct 2020 13:09:09 GMT + Status: + - 201 Created + Strict-Transport-Security: + - max-age=31536000 + Via: + - 1.1 varnish + - 1.1 varnish + X-Cache: + - MISS, MISS + X-Cache-Hits: + - 0, 0 + X-Content-Type-Options: + - nosniff + X-Served-By: + - cache-control-slwdc9036-CONTROL-SLWDC, cache-lhr7363-LHR + X-Timer: + - S1602076148.390914,VS0,VE785 + status: 201 Created + code: 201 + duration: "" diff --git a/fastly/fixtures/waf_exclusion/list/waf/delete.yaml b/fastly/fixtures/waf_exclusion/list/waf/delete.yaml new file mode 100644 index 000000000..b219f7809 --- /dev/null +++ b/fastly/fixtures/waf_exclusion/list/waf/delete.yaml @@ -0,0 +1,44 @@ +--- +version: 1 +interactions: +- request: + body: | + {"data":{"type":"waf_firewall","id":"5HtuuALz7WUiKn4AZnU1VM","attributes":{"service_version_number":"1"}}} + form: {} + headers: + Accept: + - application/vnd.api+json + Content-Type: + - application/vnd.api+json + User-Agent: + - FastlyGo/1.17.0 (+github.com/fastly/go-fastly; go1.14.5) + url: https://api.fastly.com/waf/firewalls/5HtuuALz7WUiKn4AZnU1VM + method: DELETE + response: + body: "" + headers: + Accept-Ranges: + - bytes + - bytes + Date: + - Wed, 07 Oct 2020 13:09:10 GMT + Status: + - 204 No Content + Strict-Transport-Security: + - max-age=31536000 + Via: + - 1.1 varnish + - 1.1 varnish + X-Cache: + - MISS, MISS + X-Cache-Hits: + - 0, 0 + X-Content-Type-Options: + - nosniff + X-Served-By: + - cache-control-slwdc9035-CONTROL-SLWDC, cache-lhr7363-LHR + X-Timer: + - S1602076150.387327,VS0,VE239 + status: 204 No Content + code: 204 + duration: "" diff --git a/fastly/fixtures/waf_exclusion/list/waf_exclusions/create-1.yaml b/fastly/fixtures/waf_exclusion/list/waf_exclusions/create-1.yaml new file mode 100644 index 000000000..d7463c6de --- /dev/null +++ b/fastly/fixtures/waf_exclusion/list/waf_exclusions/create-1.yaml @@ -0,0 +1,49 @@ +--- +version: 1 +interactions: +- request: + body: | + {"data":{"type":"waf_exclusion","attributes":{"condition":"req.url.basename == \"index.html\"","exclusion_type":"rule","name":"index page","number":null},"relationships":{"waf_rules":{"data":[{"type":"waf_rule","id":"2029718"},{"type":"waf_rule","id":"2037405"}]}}},"included":[{"type":"waf_rule","id":"2029718","attributes":{"modsec_rule_id":2029718}},{"type":"waf_rule","id":"2037405","attributes":{"modsec_rule_id":2037405}}]} + form: {} + headers: + Accept: + - application/vnd.api+json + Content-Type: + - application/vnd.api+json + User-Agent: + - FastlyGo/1.17.0 (+github.com/fastly/go-fastly; go1.14.5) + url: https://api.fastly.com/waf/firewalls/5HtuuALz7WUiKn4AZnU1VM/versions/1/exclusions + method: POST + response: + body: '{"data":{"id":"34s9Ff1kxfri0Re34WzNk5","type":"waf_exclusion","attributes":{"created_at":"2020-10-07T13:09:09Z","exclusion_type":"rule","condition":"req.url.basename + == \"index.html\"","name":"index page","number":1,"updated_at":"2020-10-07T13:09:09Z"},"relationships":{"waf_rules":{"data":[{"id":"1YveWU8qwEYidE8WAiZqCN","type":"waf_rule"},{"id":"VovV0PIWJCm33k1piDpnX","type":"waf_rule"}]}}}}' + headers: + Accept-Ranges: + - bytes + - bytes + Content-Length: + - "394" + Content-Type: + - application/vnd.api+json + Date: + - Wed, 07 Oct 2020 13:09:09 GMT + Status: + - 201 Created + Strict-Transport-Security: + - max-age=31536000 + Via: + - 1.1 varnish + - 1.1 varnish + X-Cache: + - MISS, MISS + X-Cache-Hits: + - 0, 0 + X-Content-Type-Options: + - nosniff + X-Served-By: + - cache-control-slwdc9037-CONTROL-SLWDC, cache-lhr7363-LHR + X-Timer: + - S1602076149.428149,VS0,VE158 + status: 201 Created + code: 201 + duration: "" diff --git a/fastly/fixtures/waf_exclusion/list/waf_exclusions/create-2.yaml b/fastly/fixtures/waf_exclusion/list/waf_exclusions/create-2.yaml new file mode 100644 index 000000000..323a5c998 --- /dev/null +++ b/fastly/fixtures/waf_exclusion/list/waf_exclusions/create-2.yaml @@ -0,0 +1,49 @@ +--- +version: 1 +interactions: +- request: + body: | + {"data":{"type":"waf_exclusion","attributes":{"condition":"req.url.basename == \"index.php\"","exclusion_type":"rule","name":"index php","number":null},"relationships":{"waf_rules":{"data":[{"type":"waf_rule","id":"1010070"}]}}},"included":[{"type":"waf_rule","id":"1010070","attributes":{"modsec_rule_id":1010070}}]} + form: {} + headers: + Accept: + - application/vnd.api+json + Content-Type: + - application/vnd.api+json + User-Agent: + - FastlyGo/1.17.0 (+github.com/fastly/go-fastly; go1.14.5) + url: https://api.fastly.com/waf/firewalls/5HtuuALz7WUiKn4AZnU1VM/versions/1/exclusions + method: POST + response: + body: '{"data":{"id":"3ZQKFpHrO9heq1gv2o1pEo","type":"waf_exclusion","attributes":{"created_at":"2020-10-07T13:09:09Z","exclusion_type":"rule","condition":"req.url.basename + == \"index.php\"","name":"index php","number":2,"updated_at":"2020-10-07T13:09:09Z"},"relationships":{"waf_rules":{"data":[{"id":"62NGF4KWy1v17yyV1vmPdb","type":"waf_rule"}]}}}}' + headers: + Accept-Ranges: + - bytes + - bytes + Content-Length: + - "343" + Content-Type: + - application/vnd.api+json + Date: + - Wed, 07 Oct 2020 13:09:10 GMT + Status: + - 201 Created + Strict-Transport-Security: + - max-age=31536000 + Via: + - 1.1 varnish + - 1.1 varnish + X-Cache: + - MISS, MISS + X-Cache-Hits: + - 0, 0 + X-Content-Type-Options: + - nosniff + X-Served-By: + - cache-control-slwdc9036-CONTROL-SLWDC, cache-lhr7363-LHR + X-Timer: + - S1602076150.659086,VS0,VE377 + status: 201 Created + code: 201 + duration: "" diff --git a/fastly/fixtures/waf_exclusion/list/waf_exclusions/list.yaml b/fastly/fixtures/waf_exclusion/list/waf_exclusions/list.yaml new file mode 100644 index 000000000..d972e7fb3 --- /dev/null +++ b/fastly/fixtures/waf_exclusion/list/waf_exclusions/list.yaml @@ -0,0 +1,49 @@ +--- +version: 1 +interactions: +- request: + body: "" + form: {} + headers: + User-Agent: + - FastlyGo/1.17.0 (+github.com/fastly/go-fastly; go1.14.5) + url: https://api.fastly.com/waf/firewalls/5HtuuALz7WUiKn4AZnU1VM/versions/1/exclusions?include=waf_rules&page%5Bnumber%5D=1&page%5Bsize%5D=100 + method: GET + response: + body: '{"data":[{"id":"34s9Ff1kxfri0Re34WzNk5","type":"waf_exclusion","attributes":{"created_at":"2020-10-07T13:09:09Z","exclusion_type":"rule","condition":"req.url.basename + == \"index.html\"","name":"index page","number":1,"updated_at":"2020-10-07T13:09:09Z"},"relationships":{"waf_rules":{"data":[{"id":"1YveWU8qwEYidE8WAiZqCN","type":"waf_rule"},{"id":"VovV0PIWJCm33k1piDpnX","type":"waf_rule"}]}}},{"id":"3ZQKFpHrO9heq1gv2o1pEo","type":"waf_exclusion","attributes":{"created_at":"2020-10-07T13:09:09Z","exclusion_type":"rule","condition":"req.url.basename + == \"index.php\"","name":"index php","number":2,"updated_at":"2020-10-07T13:09:09Z"},"relationships":{"waf_rules":{"data":[{"id":"62NGF4KWy1v17yyV1vmPdb","type":"waf_rule"}]}}}],"included":[{"id":"1YveWU8qwEYidE8WAiZqCN","type":"waf_rule","attributes":{"modsec_rule_id":2029718,"publisher":"trustwave","type":"strict"}},{"id":"62NGF4KWy1v17yyV1vmPdb","type":"waf_rule","attributes":{"modsec_rule_id":1010070,"publisher":"owasp","type":"threshold"}},{"id":"VovV0PIWJCm33k1piDpnX","type":"waf_rule","attributes":{"modsec_rule_id":2037405,"publisher":"trustwave","type":"strict"}}],"links":{"last":"https://api.fastly.com/waf/firewalls/5HtuuALz7WUiKn4AZnU1VM/versions/1/exclusions?include=waf_rules\u0026page[number]=1\u0026page[size]=100","first":"https://api.fastly.com/waf/firewalls/5HtuuALz7WUiKn4AZnU1VM/versions/1/exclusions?include=waf_rules\u0026page[number]=1\u0026page[size]=100"},"meta":{"current_page":1,"per_page":100,"record_count":2,"total_pages":1}}' + headers: + Accept-Ranges: + - bytes + - bytes + - bytes + Age: + - "0" + - "0" + Content-Length: + - "1515" + Content-Type: + - application/vnd.api+json + Date: + - Wed, 07 Oct 2020 13:09:10 GMT + Status: + - 200 OK + Strict-Transport-Security: + - max-age=31536000 + Via: + - 1.1 varnish + - 1.1 varnish + X-Cache: + - MISS, MISS + X-Cache-Hits: + - 0, 0 + X-Content-Type-Options: + - nosniff + X-Served-By: + - cache-control-slwdc9035-CONTROL-SLWDC, cache-lhr7363-LHR + X-Timer: + - S1602076150.106723,VS0,VE152 + status: 200 OK + code: 200 + duration: "" diff --git a/fastly/fixtures/waf_exclusion/list_filters/active_rules/create.yaml b/fastly/fixtures/waf_exclusion/list_filters/active_rules/create.yaml new file mode 100644 index 000000000..a38d1fd01 --- /dev/null +++ b/fastly/fixtures/waf_exclusion/list_filters/active_rules/create.yaml @@ -0,0 +1,48 @@ +--- +version: 1 +interactions: +- request: + body: | + {"data":[{"type":"waf_active_rule","attributes":{"modsec_rule_id":2029718,"revision":1,"status":"log"}},{"type":"waf_active_rule","attributes":{"modsec_rule_id":2037405,"revision":1,"status":"log"}},{"type":"waf_active_rule","attributes":{"modsec_rule_id":1010070,"revision":1,"status":"log"}}]} + form: {} + headers: + Accept: + - application/vnd.api+json; ext=bulk + Content-Type: + - application/vnd.api+json; ext=bulk + User-Agent: + - FastlyGo/1.17.0 (+github.com/fastly/go-fastly; go1.14.5) + url: https://api.fastly.com/waf/firewalls/5mOnW9PxK7wPrCwcItgmY8/versions/1/active-rules + method: POST + response: + body: '{"data":[{"id":"3hhQOzGeZp1tIUKLTyZcZE","type":"waf_active_rule","attributes":{"created_at":"2020-10-07T13:09:10Z","latest_revision":1,"modsec_rule_id":2029718,"outdated":false,"revision":1,"status":"log","updated_at":"2020-10-07T13:09:10Z"},"relationships":{"waf_firewall_version":{"data":{"id":"tfMVN3sK40XQHrWAd512K","type":"waf_firewall_version"}},"waf_rule_revision":{"data":{"id":"6ZJML5tsy5uVq1nGNgmZ78","type":"waf_rule_revision"}}}},{"id":"5ofAVqut8G3hMAW3oZZY2d","type":"waf_active_rule","attributes":{"created_at":"2020-10-07T13:09:10Z","latest_revision":1,"modsec_rule_id":2037405,"outdated":false,"revision":1,"status":"log","updated_at":"2020-10-07T13:09:10Z"},"relationships":{"waf_firewall_version":{"data":{"id":"tfMVN3sK40XQHrWAd512K","type":"waf_firewall_version"}},"waf_rule_revision":{"data":{"id":"3ANlv7vVZdzk2qFXlJLIk3","type":"waf_rule_revision"}}}},{"id":"134uu0BVVV1LvdZsgZclZd","type":"waf_active_rule","attributes":{"created_at":"2020-10-07T13:09:10Z","latest_revision":1,"modsec_rule_id":1010070,"outdated":false,"revision":1,"status":"log","updated_at":"2020-10-07T13:09:10Z"},"relationships":{"waf_firewall_version":{"data":{"id":"tfMVN3sK40XQHrWAd512K","type":"waf_firewall_version"}},"waf_rule_revision":{"data":{"id":"2qiuFDyJoxuKkKkJYjrgsC","type":"waf_rule_revision"}}}}]}' + headers: + Accept-Ranges: + - bytes + - bytes + Content-Length: + - "1309" + Content-Type: + - application/vnd.api+json + Date: + - Wed, 07 Oct 2020 13:09:10 GMT + Status: + - 201 Created + Strict-Transport-Security: + - max-age=31536000 + Via: + - 1.1 varnish + - 1.1 varnish + X-Cache: + - MISS, MISS + X-Cache-Hits: + - 0, 0 + X-Content-Type-Options: + - nosniff + X-Served-By: + - cache-control-slwdc9035-CONTROL-SLWDC, cache-lhr7363-LHR + X-Timer: + - S1602076150.029718,VS0,VE162 + status: 201 Created + code: 201 + duration: "" diff --git a/fastly/fixtures/waf_exclusion/list_filters/response_object/create.yaml b/fastly/fixtures/waf_exclusion/list_filters/response_object/create.yaml new file mode 100644 index 000000000..2e00f197d --- /dev/null +++ b/fastly/fixtures/waf_exclusion/list_filters/response_object/create.yaml @@ -0,0 +1,57 @@ +--- +version: 1 +interactions: +- request: + body: Service=1JeR1AIjuRcEXA5doHqxPr&Version=2&name=WAf_Response&status=403 + form: + Service: + - 1JeR1AIjuRcEXA5doHqxPr + Version: + - "2" + name: + - WAf_Response + status: + - "403" + headers: + Content-Type: + - application/x-www-form-urlencoded + User-Agent: + - FastlyGo/1.17.0 (+github.com/fastly/go-fastly; go1.14.5) + url: https://api.fastly.com/service/1JeR1AIjuRcEXA5doHqxPr/version/2/response_object + method: POST + response: + body: '{"name":"WAf_Response","status":"403","service_id":"1JeR1AIjuRcEXA5doHqxPr","version":"2","content":null,"cache_condition":"","content_type":null,"updated_at":"2020-10-07T13:09:08Z","request_condition":"","deleted_at":null,"created_at":"2020-10-07T13:09:08Z","response":"ok"}' + headers: + Accept-Ranges: + - bytes + - bytes + Cache-Control: + - no-cache + Content-Type: + - application/json + Date: + - Wed, 07 Oct 2020 13:09:09 GMT + Fastly-Ratelimit-Remaining: + - "4938" + Fastly-Ratelimit-Reset: + - "1602079200" + Status: + - 200 OK + Strict-Transport-Security: + - max-age=31536000 + Vary: + - Accept-Encoding + Via: + - 1.1 varnish + - 1.1 varnish + X-Cache: + - MISS, MISS + X-Cache-Hits: + - 0, 0 + X-Served-By: + - cache-control-slwdc9036-CONTROL-SLWDC, cache-lhr7363-LHR + X-Timer: + - S1602076149.651672,VS0,VE399 + status: 200 OK + code: 200 + duration: "" diff --git a/fastly/fixtures/waf_exclusion/list_filters/service/create.yaml b/fastly/fixtures/waf_exclusion/list_filters/service/create.yaml new file mode 100644 index 000000000..bcd52b7ab --- /dev/null +++ b/fastly/fixtures/waf_exclusion/list_filters/service/create.yaml @@ -0,0 +1,55 @@ +--- +version: 1 +interactions: +- request: + body: comment=go-fastly+client+test&name=test_service_service-8674665223082153551&type=vcl + form: + comment: + - go-fastly client test + name: + - test_service_service-8674665223082153551 + type: + - vcl + headers: + Content-Type: + - application/x-www-form-urlencoded + User-Agent: + - FastlyGo/1.17.0 (+github.com/fastly/go-fastly; go1.14.5) + url: https://api.fastly.com/service + method: POST + response: + body: '{"customer_id":"WpqWFjTA4lk2N1g0GY2HH","comment":"go-fastly client test","name":"test_service_service-8674665223082153551","type":"vcl","created_at":"2020-10-07T13:09:06Z","updated_at":"2020-10-07T13:09:06Z","publish_key":"","deleted_at":null,"versions":[{"deployed":false,"locked":false,"service_id":"1JeR1AIjuRcEXA5doHqxPr","number":1,"updated_at":"2020-10-07T13:09:06Z","created_at":"2020-10-07T13:09:06Z","active":false,"deleted_at":null,"staging":false,"comment":"","testing":false}],"id":"1JeR1AIjuRcEXA5doHqxPr"}' + headers: + Accept-Ranges: + - bytes + - bytes + Cache-Control: + - no-cache + Content-Type: + - application/json + Date: + - Wed, 07 Oct 2020 13:09:06 GMT + Fastly-Ratelimit-Remaining: + - "4948" + Fastly-Ratelimit-Reset: + - "1602079200" + Status: + - 200 OK + Strict-Transport-Security: + - max-age=31536000 + Vary: + - Accept-Encoding + Via: + - 1.1 varnish + - 1.1 varnish + X-Cache: + - MISS, MISS + X-Cache-Hits: + - 0, 0 + X-Served-By: + - cache-control-slwdc9036-CONTROL-SLWDC, cache-lhr7363-LHR + X-Timer: + - S1602076146.399232,VS0,VE493 + status: 200 OK + code: 200 + duration: "" diff --git a/fastly/fixtures/waf_exclusion/list_filters/service/delete.yaml b/fastly/fixtures/waf_exclusion/list_filters/service/delete.yaml new file mode 100644 index 000000000..992881431 --- /dev/null +++ b/fastly/fixtures/waf_exclusion/list_filters/service/delete.yaml @@ -0,0 +1,47 @@ +--- +version: 1 +interactions: +- request: + body: "" + form: {} + headers: + User-Agent: + - FastlyGo/1.17.0 (+github.com/fastly/go-fastly; go1.14.5) + url: https://api.fastly.com/service/1JeR1AIjuRcEXA5doHqxPr + method: DELETE + response: + body: '{"status":"ok"}' + headers: + Accept-Ranges: + - bytes + - bytes + Cache-Control: + - no-cache + Content-Type: + - application/json + Date: + - Wed, 07 Oct 2020 13:09:12 GMT + Fastly-Ratelimit-Remaining: + - "4933" + Fastly-Ratelimit-Reset: + - "1602079200" + Status: + - 200 OK + Strict-Transport-Security: + - max-age=31536000 + Vary: + - Accept-Encoding + Via: + - 1.1 varnish + - 1.1 varnish + X-Cache: + - MISS, MISS + X-Cache-Hits: + - 0, 0 + X-Served-By: + - cache-control-slwdc9037-CONTROL-SLWDC, cache-lhr7363-LHR + X-Timer: + - S1602076152.021407,VS0,VE246 + status: 200 OK + code: 200 + duration: "" diff --git a/fastly/fixtures/waf_exclusion/list_filters/service/version.yaml b/fastly/fixtures/waf_exclusion/list_filters/service/version.yaml new file mode 100644 index 000000000..09ef93c5c --- /dev/null +++ b/fastly/fixtures/waf_exclusion/list_filters/service/version.yaml @@ -0,0 +1,51 @@ +--- +version: 1 +interactions: +- request: + body: Service=1JeR1AIjuRcEXA5doHqxPr + form: + Service: + - 1JeR1AIjuRcEXA5doHqxPr + headers: + Content-Type: + - application/x-www-form-urlencoded + User-Agent: + - FastlyGo/1.17.0 (+github.com/fastly/go-fastly; go1.14.5) + url: https://api.fastly.com/service/1JeR1AIjuRcEXA5doHqxPr/version + method: POST + response: + body: '{"service_id":"1JeR1AIjuRcEXA5doHqxPr","number":2}' + headers: + Accept-Ranges: + - bytes + - bytes + Cache-Control: + - no-cache + Content-Type: + - application/json + Date: + - Wed, 07 Oct 2020 13:09:08 GMT + Fastly-Ratelimit-Remaining: + - "4939" + Fastly-Ratelimit-Reset: + - "1602079200" + Status: + - 200 OK + Strict-Transport-Security: + - max-age=31536000 + Vary: + - Accept-Encoding + Via: + - 1.1 varnish + - 1.1 varnish + X-Cache: + - MISS, MISS + X-Cache-Hits: + - 0, 0 + X-Served-By: + - cache-control-slwdc9037-CONTROL-SLWDC, cache-lhr7363-LHR + X-Timer: + - S1602076148.085255,VS0,VE514 + status: 200 OK + code: 200 + duration: "" diff --git a/fastly/fixtures/waf_exclusion/list_filters/waf/create.yaml b/fastly/fixtures/waf_exclusion/list_filters/waf/create.yaml new file mode 100644 index 000000000..94a27ecf2 --- /dev/null +++ b/fastly/fixtures/waf_exclusion/list_filters/waf/create.yaml @@ -0,0 +1,48 @@ +--- +version: 1 +interactions: +- request: + body: | + {"data":{"type":"waf_firewall","attributes":{"prefetch_condition":"","response":"WAf_Response","service_id":"1JeR1AIjuRcEXA5doHqxPr","service_version_number":"2"}}} + form: {} + headers: + Accept: + - application/vnd.api+json + Content-Type: + - application/vnd.api+json + User-Agent: + - FastlyGo/1.17.0 (+github.com/fastly/go-fastly; go1.14.5) + url: https://api.fastly.com/waf/firewalls + method: POST + response: + body: '{"data":{"id":"5mOnW9PxK7wPrCwcItgmY8","type":"waf_firewall","attributes":{"active_rules_fastly_block_count":0,"active_rules_fastly_log_count":0,"active_rules_fastly_score_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_score_count":0,"active_rules_trustwave_block_count":0,"active_rules_trustwave_log_count":0,"created_at":"2020-10-07T13:09:09Z","disabled":false,"prefetch_condition":"","response":"WAf_Response","service_id":"1JeR1AIjuRcEXA5doHqxPr","service_version_number":2,"updated_at":"2020-10-07T13:09:09Z"}}}' + headers: + Accept-Ranges: + - bytes + - bytes + Content-Length: + - "566" + Content-Type: + - application/vnd.api+json + Date: + - Wed, 07 Oct 2020 13:09:09 GMT + Status: + - 201 Created + Strict-Transport-Security: + - max-age=31536000 + Via: + - 1.1 varnish + - 1.1 varnish + X-Cache: + - MISS, MISS + X-Cache-Hits: + - 0, 0 + X-Content-Type-Options: + - nosniff + X-Served-By: + - cache-control-slwdc9036-CONTROL-SLWDC, cache-lhr7363-LHR + X-Timer: + - S1602076149.147104,VS0,VE831 + status: 201 Created + code: 201 + duration: "" diff --git a/fastly/fixtures/waf_exclusion/list_filters/waf/delete.yaml b/fastly/fixtures/waf_exclusion/list_filters/waf/delete.yaml new file mode 100644 index 000000000..658789a1a --- /dev/null +++ b/fastly/fixtures/waf_exclusion/list_filters/waf/delete.yaml @@ -0,0 +1,44 @@ +--- +version: 1 +interactions: +- request: + body: | + {"data":{"type":"waf_firewall","id":"5mOnW9PxK7wPrCwcItgmY8","attributes":{"service_version_number":"1"}}} + form: {} + headers: + Accept: + - application/vnd.api+json + Content-Type: + - application/vnd.api+json + User-Agent: + - FastlyGo/1.17.0 (+github.com/fastly/go-fastly; go1.14.5) + url: https://api.fastly.com/waf/firewalls/5mOnW9PxK7wPrCwcItgmY8 + method: DELETE + response: + body: "" + headers: + Accept-Ranges: + - bytes + - bytes + Date: + - Wed, 07 Oct 2020 13:09:11 GMT + Status: + - 204 No Content + Strict-Transport-Security: + - max-age=31536000 + Via: + - 1.1 varnish + - 1.1 varnish + X-Cache: + - MISS, MISS + X-Cache-Hits: + - 0, 0 + X-Content-Type-Options: + - nosniff + X-Served-By: + - cache-control-slwdc9035-CONTROL-SLWDC, cache-lhr7363-LHR + X-Timer: + - S1602076152.821405,VS0,VE153 + status: 204 No Content + code: 204 + duration: "" diff --git a/fastly/fixtures/waf_exclusion/list_filters/waf_exclusions/create-1.yaml b/fastly/fixtures/waf_exclusion/list_filters/waf_exclusions/create-1.yaml new file mode 100644 index 000000000..0538b5f76 --- /dev/null +++ b/fastly/fixtures/waf_exclusion/list_filters/waf_exclusions/create-1.yaml @@ -0,0 +1,49 @@ +--- +version: 1 +interactions: +- request: + body: | + {"data":{"type":"waf_exclusion","attributes":{"condition":"req.url.basename == \"index.html\"","exclusion_type":"rule","name":"index page","number":null},"relationships":{"waf_rules":{"data":[{"type":"waf_rule","id":"2029718"},{"type":"waf_rule","id":"2037405"}]}}},"included":[{"type":"waf_rule","id":"2029718","attributes":{"modsec_rule_id":2029718}},{"type":"waf_rule","id":"2037405","attributes":{"modsec_rule_id":2037405}}]} + form: {} + headers: + Accept: + - application/vnd.api+json + Content-Type: + - application/vnd.api+json + User-Agent: + - FastlyGo/1.17.0 (+github.com/fastly/go-fastly; go1.14.5) + url: https://api.fastly.com/waf/firewalls/5mOnW9PxK7wPrCwcItgmY8/versions/1/exclusions + method: POST + response: + body: '{"data":{"id":"4pKiyBglAh5CSpCKwuru7y","type":"waf_exclusion","attributes":{"created_at":"2020-10-07T13:09:10Z","exclusion_type":"rule","condition":"req.url.basename + == \"index.html\"","name":"index page","number":1,"updated_at":"2020-10-07T13:09:10Z"},"relationships":{"waf_rules":{"data":[{"id":"1YveWU8qwEYidE8WAiZqCN","type":"waf_rule"},{"id":"VovV0PIWJCm33k1piDpnX","type":"waf_rule"}]}}}}' + headers: + Accept-Ranges: + - bytes + - bytes + Content-Length: + - "394" + Content-Type: + - application/vnd.api+json + Date: + - Wed, 07 Oct 2020 13:09:10 GMT + Status: + - 201 Created + Strict-Transport-Security: + - max-age=31536000 + Via: + - 1.1 varnish + - 1.1 varnish + X-Cache: + - MISS, MISS + X-Cache-Hits: + - 0, 0 + X-Content-Type-Options: + - nosniff + X-Served-By: + - cache-control-slwdc9037-CONTROL-SLWDC, cache-lhr7363-LHR + X-Timer: + - S1602076150.257585,VS0,VE436 + status: 201 Created + code: 201 + duration: "" diff --git a/fastly/fixtures/waf_exclusion/list_filters/waf_exclusions/create-2.yaml b/fastly/fixtures/waf_exclusion/list_filters/waf_exclusions/create-2.yaml new file mode 100644 index 000000000..ae448f90d --- /dev/null +++ b/fastly/fixtures/waf_exclusion/list_filters/waf_exclusions/create-2.yaml @@ -0,0 +1,49 @@ +--- +version: 1 +interactions: +- request: + body: | + {"data":{"type":"waf_exclusion","attributes":{"condition":"req.url.basename == \"index.php\"","exclusion_type":"rule","name":"index php","number":null},"relationships":{"waf_rules":{"data":[{"type":"waf_rule","id":"1010070"}]}}},"included":[{"type":"waf_rule","id":"1010070","attributes":{"modsec_rule_id":1010070}}]} + form: {} + headers: + Accept: + - application/vnd.api+json + Content-Type: + - application/vnd.api+json + User-Agent: + - FastlyGo/1.17.0 (+github.com/fastly/go-fastly; go1.14.5) + url: https://api.fastly.com/waf/firewalls/5mOnW9PxK7wPrCwcItgmY8/versions/1/exclusions + method: POST + response: + body: '{"data":{"id":"64CI57J6goELQDlxSOBJSB","type":"waf_exclusion","attributes":{"created_at":"2020-10-07T13:09:10Z","exclusion_type":"rule","condition":"req.url.basename + == \"index.php\"","name":"index php","number":2,"updated_at":"2020-10-07T13:09:10Z"},"relationships":{"waf_rules":{"data":[{"id":"62NGF4KWy1v17yyV1vmPdb","type":"waf_rule"}]}}}}' + headers: + Accept-Ranges: + - bytes + - bytes + Content-Length: + - "343" + Content-Type: + - application/vnd.api+json + Date: + - Wed, 07 Oct 2020 13:09:10 GMT + Status: + - 201 Created + Strict-Transport-Security: + - max-age=31536000 + Via: + - 1.1 varnish + - 1.1 varnish + X-Cache: + - MISS, MISS + X-Cache-Hits: + - 0, 0 + X-Content-Type-Options: + - nosniff + X-Served-By: + - cache-control-slwdc9037-CONTROL-SLWDC, cache-lhr7363-LHR + X-Timer: + - S1602076151.749547,VS0,VE176 + status: 201 Created + code: 201 + duration: "" diff --git a/fastly/fixtures/waf_exclusion/list_filters/waf_exclusions/create-3.yaml b/fastly/fixtures/waf_exclusion/list_filters/waf_exclusions/create-3.yaml new file mode 100644 index 000000000..140899f56 --- /dev/null +++ b/fastly/fixtures/waf_exclusion/list_filters/waf_exclusions/create-3.yaml @@ -0,0 +1,49 @@ +--- +version: 1 +interactions: +- request: + body: | + {"data":{"type":"waf_exclusion","attributes":{"condition":"req.url.basename == \"index.asp\"","exclusion_type":"waf","name":"index asp","number":null}}} + form: {} + headers: + Accept: + - application/vnd.api+json + Content-Type: + - application/vnd.api+json + User-Agent: + - FastlyGo/1.17.0 (+github.com/fastly/go-fastly; go1.14.5) + url: https://api.fastly.com/waf/firewalls/5mOnW9PxK7wPrCwcItgmY8/versions/1/exclusions + method: POST + response: + body: '{"data":{"id":"2aSCXcRmYd1A3Yh52n1isb","type":"waf_exclusion","attributes":{"created_at":"2020-10-07T13:09:11Z","exclusion_type":"waf","condition":"req.url.basename + == \"index.asp\"","name":"index asp","number":3,"updated_at":"2020-10-07T13:09:11Z"}}}' + headers: + Accept-Ranges: + - bytes + - bytes + Content-Length: + - "251" + Content-Type: + - application/vnd.api+json + Date: + - Wed, 07 Oct 2020 13:09:11 GMT + Status: + - 201 Created + Strict-Transport-Security: + - max-age=31536000 + Via: + - 1.1 varnish + - 1.1 varnish + X-Cache: + - MISS, MISS + X-Cache-Hits: + - 0, 0 + X-Content-Type-Options: + - nosniff + X-Served-By: + - cache-control-slwdc9037-CONTROL-SLWDC, cache-lhr7363-LHR + X-Timer: + - S1602076151.969444,VS0,VE604 + status: 201 Created + code: 201 + duration: "" diff --git a/fastly/fixtures/waf_exclusion/list_filters/waf_exclusions/list.yaml b/fastly/fixtures/waf_exclusion/list_filters/waf_exclusions/list.yaml new file mode 100644 index 000000000..eb7cbccb6 --- /dev/null +++ b/fastly/fixtures/waf_exclusion/list_filters/waf_exclusions/list.yaml @@ -0,0 +1,48 @@ +--- +version: 1 +interactions: +- request: + body: "" + form: {} + headers: + User-Agent: + - FastlyGo/1.17.0 (+github.com/fastly/go-fastly; go1.14.5) + url: https://api.fastly.com/waf/firewalls/5mOnW9PxK7wPrCwcItgmY8/versions/1/exclusions?filter%5Bexclusion_type%5D=rule&filter%5Bwaf_rules.modsec_rule_id%5D=1010070&include=waf_rules&page%5Bnumber%5D=1&page%5Bsize%5D=100 + method: GET + response: + body: '{"data":[{"id":"64CI57J6goELQDlxSOBJSB","type":"waf_exclusion","attributes":{"created_at":"2020-10-07T13:09:10Z","exclusion_type":"rule","condition":"req.url.basename + == \"index.php\"","name":"index php","number":2,"updated_at":"2020-10-07T13:09:10Z"},"relationships":{"waf_rules":{"data":[{"id":"62NGF4KWy1v17yyV1vmPdb","type":"waf_rule"}]}}}],"included":[{"id":"62NGF4KWy1v17yyV1vmPdb","type":"waf_rule","attributes":{"modsec_rule_id":1010070,"publisher":"owasp","type":"threshold"}}],"links":{"last":"https://api.fastly.com/waf/firewalls/5mOnW9PxK7wPrCwcItgmY8/versions/1/exclusions?filter[exclusion_type]=rule\u0026filter[waf_rules.modsec_rule_id]=1010070\u0026include=waf_rules\u0026page[number]=1\u0026page[size]=100","first":"https://api.fastly.com/waf/firewalls/5mOnW9PxK7wPrCwcItgmY8/versions/1/exclusions?filter[exclusion_type]=rule\u0026filter[waf_rules.modsec_rule_id]=1010070\u0026include=waf_rules\u0026page[number]=1\u0026page[size]=100"},"meta":{"current_page":1,"per_page":100,"record_count":1,"total_pages":1}}' + headers: + Accept-Ranges: + - bytes + - bytes + - bytes + Age: + - "0" + - "0" + Content-Length: + - "1028" + Content-Type: + - application/vnd.api+json + Date: + - Wed, 07 Oct 2020 13:09:11 GMT + Status: + - 200 OK + Strict-Transport-Security: + - max-age=31536000 + Via: + - 1.1 varnish + - 1.1 varnish + X-Cache: + - MISS, MISS + X-Cache-Hits: + - 0, 0 + X-Content-Type-Options: + - nosniff + X-Served-By: + - cache-control-slwdc9036-CONTROL-SLWDC, cache-lhr7363-LHR + X-Timer: + - S1602076152.609213,VS0,VE145 + status: 200 OK + code: 200 + duration: "" diff --git a/fastly/fixtures/waf_exclusion/update/active_rules/create.yaml b/fastly/fixtures/waf_exclusion/update/active_rules/create.yaml new file mode 100644 index 000000000..49c918a7b --- /dev/null +++ b/fastly/fixtures/waf_exclusion/update/active_rules/create.yaml @@ -0,0 +1,48 @@ +--- +version: 1 +interactions: +- request: + body: | + {"data":[{"type":"waf_active_rule","attributes":{"modsec_rule_id":2029718,"revision":1,"status":"log"}},{"type":"waf_active_rule","attributes":{"modsec_rule_id":2037405,"revision":1,"status":"log"}},{"type":"waf_active_rule","attributes":{"modsec_rule_id":1010070,"revision":1,"status":"log"}}]} + form: {} + headers: + Accept: + - application/vnd.api+json; ext=bulk + Content-Type: + - application/vnd.api+json; ext=bulk + User-Agent: + - FastlyGo/1.17.0 (+github.com/fastly/go-fastly; go1.14.5) + url: https://api.fastly.com/waf/firewalls/6YqagDC62Z4bIFpsNBzxVm/versions/1/active-rules + method: POST + response: + body: '{"data":[{"id":"2hSd4y1hudZJPE1qbZvDQz","type":"waf_active_rule","attributes":{"created_at":"2020-10-07T13:09:09Z","latest_revision":1,"modsec_rule_id":2029718,"outdated":false,"revision":1,"status":"log","updated_at":"2020-10-07T13:09:09Z"},"relationships":{"waf_firewall_version":{"data":{"id":"138SmQjgMETTvw0Fdagfvv","type":"waf_firewall_version"}},"waf_rule_revision":{"data":{"id":"6ZJML5tsy5uVq1nGNgmZ78","type":"waf_rule_revision"}}}},{"id":"7ZMBRI5js2ilh5BtgXiNNO","type":"waf_active_rule","attributes":{"created_at":"2020-10-07T13:09:09Z","latest_revision":1,"modsec_rule_id":2037405,"outdated":false,"revision":1,"status":"log","updated_at":"2020-10-07T13:09:09Z"},"relationships":{"waf_firewall_version":{"data":{"id":"138SmQjgMETTvw0Fdagfvv","type":"waf_firewall_version"}},"waf_rule_revision":{"data":{"id":"3ANlv7vVZdzk2qFXlJLIk3","type":"waf_rule_revision"}}}},{"id":"4BoYJt6J1fMXWjtGG3LyRb","type":"waf_active_rule","attributes":{"created_at":"2020-10-07T13:09:09Z","latest_revision":1,"modsec_rule_id":1010070,"outdated":false,"revision":1,"status":"log","updated_at":"2020-10-07T13:09:09Z"},"relationships":{"waf_firewall_version":{"data":{"id":"138SmQjgMETTvw0Fdagfvv","type":"waf_firewall_version"}},"waf_rule_revision":{"data":{"id":"2qiuFDyJoxuKkKkJYjrgsC","type":"waf_rule_revision"}}}}]}' + headers: + Accept-Ranges: + - bytes + - bytes + Content-Length: + - "1312" + Content-Type: + - application/vnd.api+json + Date: + - Wed, 07 Oct 2020 13:09:09 GMT + Status: + - 201 Created + Strict-Transport-Security: + - max-age=31536000 + Via: + - 1.1 varnish + - 1.1 varnish + X-Cache: + - MISS, MISS + X-Cache-Hits: + - 0, 0 + X-Content-Type-Options: + - nosniff + X-Served-By: + - cache-control-slwdc9036-CONTROL-SLWDC, cache-lhr7363-LHR + X-Timer: + - S1602076149.368523,VS0,VE413 + status: 201 Created + code: 201 + duration: "" diff --git a/fastly/fixtures/waf_exclusion/update/response_object/create.yaml b/fastly/fixtures/waf_exclusion/update/response_object/create.yaml new file mode 100644 index 000000000..b39df9bc9 --- /dev/null +++ b/fastly/fixtures/waf_exclusion/update/response_object/create.yaml @@ -0,0 +1,57 @@ +--- +version: 1 +interactions: +- request: + body: Service=2Xx48e6pQNCa26prCiwiTG&Version=2&name=WAf_Response&status=403 + form: + Service: + - 2Xx48e6pQNCa26prCiwiTG + Version: + - "2" + name: + - WAf_Response + status: + - "403" + headers: + Content-Type: + - application/x-www-form-urlencoded + User-Agent: + - FastlyGo/1.17.0 (+github.com/fastly/go-fastly; go1.14.5) + url: https://api.fastly.com/service/2Xx48e6pQNCa26prCiwiTG/version/2/response_object + method: POST + response: + body: '{"name":"WAf_Response","status":"403","service_id":"2Xx48e6pQNCa26prCiwiTG","version":"2","updated_at":"2020-10-07T13:09:07Z","content_type":null,"request_condition":"","content":null,"deleted_at":null,"cache_condition":"","response":"ok","created_at":"2020-10-07T13:09:07Z"}' + headers: + Accept-Ranges: + - bytes + - bytes + Cache-Control: + - no-cache + Content-Type: + - application/json + Date: + - Wed, 07 Oct 2020 13:09:08 GMT + Fastly-Ratelimit-Remaining: + - "4942" + Fastly-Ratelimit-Reset: + - "1602079200" + Status: + - 200 OK + Strict-Transport-Security: + - max-age=31536000 + Vary: + - Accept-Encoding + Via: + - 1.1 varnish + - 1.1 varnish + X-Cache: + - MISS, MISS + X-Cache-Hits: + - 0, 0 + X-Served-By: + - cache-control-slwdc9036-CONTROL-SLWDC, cache-lhr7363-LHR + X-Timer: + - S1602076148.811099,VS0,VE218 + status: 200 OK + code: 200 + duration: "" diff --git a/fastly/fixtures/waf_exclusion/update/service/create.yaml b/fastly/fixtures/waf_exclusion/update/service/create.yaml new file mode 100644 index 000000000..0c4c4db0f --- /dev/null +++ b/fastly/fixtures/waf_exclusion/update/service/create.yaml @@ -0,0 +1,55 @@ +--- +version: 1 +interactions: +- request: + body: comment=go-fastly+client+test&name=test_service_service-4037200794235010051&type=vcl + form: + comment: + - go-fastly client test + name: + - test_service_service-4037200794235010051 + type: + - vcl + headers: + Content-Type: + - application/x-www-form-urlencoded + User-Agent: + - FastlyGo/1.17.0 (+github.com/fastly/go-fastly; go1.14.5) + url: https://api.fastly.com/service + method: POST + response: + body: '{"customer_id":"WpqWFjTA4lk2N1g0GY2HH","comment":"go-fastly client test","name":"test_service_service-4037200794235010051","type":"vcl","versions":[{"created_at":"2020-10-07T13:09:06Z","deleted_at":null,"deployed":false,"locked":false,"service_id":"2Xx48e6pQNCa26prCiwiTG","staging":false,"active":false,"number":1,"testing":false,"updated_at":"2020-10-07T13:09:06Z","comment":""}],"id":"2Xx48e6pQNCa26prCiwiTG","created_at":"2020-10-07T13:09:06Z","deleted_at":null,"publish_key":"","updated_at":"2020-10-07T13:09:06Z"}' + headers: + Accept-Ranges: + - bytes + - bytes + Cache-Control: + - no-cache + Content-Type: + - application/json + Date: + - Wed, 07 Oct 2020 13:09:06 GMT + Fastly-Ratelimit-Remaining: + - "4951" + Fastly-Ratelimit-Reset: + - "1602079200" + Status: + - 200 OK + Strict-Transport-Security: + - max-age=31536000 + Vary: + - Accept-Encoding + Via: + - 1.1 varnish + - 1.1 varnish + X-Cache: + - MISS, MISS + X-Cache-Hits: + - 0, 0 + X-Served-By: + - cache-control-slwdc9037-CONTROL-SLWDC, cache-lhr7363-LHR + X-Timer: + - S1602076146.399238,VS0,VE466 + status: 200 OK + code: 200 + duration: "" diff --git a/fastly/fixtures/waf_exclusion/update/service/delete.yaml b/fastly/fixtures/waf_exclusion/update/service/delete.yaml new file mode 100644 index 000000000..56ac67fd1 --- /dev/null +++ b/fastly/fixtures/waf_exclusion/update/service/delete.yaml @@ -0,0 +1,47 @@ +--- +version: 1 +interactions: +- request: + body: "" + form: {} + headers: + User-Agent: + - FastlyGo/1.17.0 (+github.com/fastly/go-fastly; go1.14.5) + url: https://api.fastly.com/service/2Xx48e6pQNCa26prCiwiTG + method: DELETE + response: + body: '{"status":"ok"}' + headers: + Accept-Ranges: + - bytes + - bytes + Cache-Control: + - no-cache + Content-Type: + - application/json + Date: + - Wed, 07 Oct 2020 13:09:12 GMT + Fastly-Ratelimit-Remaining: + - "4934" + Fastly-Ratelimit-Reset: + - "1602079200" + Status: + - 200 OK + Strict-Transport-Security: + - max-age=31536000 + Vary: + - Accept-Encoding + Via: + - 1.1 varnish + - 1.1 varnish + X-Cache: + - MISS, MISS + X-Cache-Hits: + - 0, 0 + X-Served-By: + - cache-control-slwdc9035-CONTROL-SLWDC, cache-lhr7363-LHR + X-Timer: + - S1602076152.861456,VS0,VE228 + status: 200 OK + code: 200 + duration: "" diff --git a/fastly/fixtures/waf_exclusion/update/service/version.yaml b/fastly/fixtures/waf_exclusion/update/service/version.yaml new file mode 100644 index 000000000..081f8ca2d --- /dev/null +++ b/fastly/fixtures/waf_exclusion/update/service/version.yaml @@ -0,0 +1,51 @@ +--- +version: 1 +interactions: +- request: + body: Service=2Xx48e6pQNCa26prCiwiTG + form: + Service: + - 2Xx48e6pQNCa26prCiwiTG + headers: + Content-Type: + - application/x-www-form-urlencoded + User-Agent: + - FastlyGo/1.17.0 (+github.com/fastly/go-fastly; go1.14.5) + url: https://api.fastly.com/service/2Xx48e6pQNCa26prCiwiTG/version + method: POST + response: + body: '{"service_id":"2Xx48e6pQNCa26prCiwiTG","number":2}' + headers: + Accept-Ranges: + - bytes + - bytes + Cache-Control: + - no-cache + Content-Type: + - application/json + Date: + - Wed, 07 Oct 2020 13:09:07 GMT + Fastly-Ratelimit-Remaining: + - "4943" + Fastly-Ratelimit-Reset: + - "1602079200" + Status: + - 200 OK + Strict-Transport-Security: + - max-age=31536000 + Vary: + - Accept-Encoding + Via: + - 1.1 varnish + - 1.1 varnish + X-Cache: + - MISS, MISS + X-Cache-Hits: + - 0, 0 + X-Served-By: + - cache-control-slwdc9035-CONTROL-SLWDC, cache-lhr7363-LHR + X-Timer: + - S1602076148.510787,VS0,VE232 + status: 200 OK + code: 200 + duration: "" diff --git a/fastly/fixtures/waf_exclusion/update/waf/create.yaml b/fastly/fixtures/waf_exclusion/update/waf/create.yaml new file mode 100644 index 000000000..9693f1227 --- /dev/null +++ b/fastly/fixtures/waf_exclusion/update/waf/create.yaml @@ -0,0 +1,48 @@ +--- +version: 1 +interactions: +- request: + body: | + {"data":{"type":"waf_firewall","attributes":{"prefetch_condition":"","response":"WAf_Response","service_id":"2Xx48e6pQNCa26prCiwiTG","service_version_number":"2"}}} + form: {} + headers: + Accept: + - application/vnd.api+json + Content-Type: + - application/vnd.api+json + User-Agent: + - FastlyGo/1.17.0 (+github.com/fastly/go-fastly; go1.14.5) + url: https://api.fastly.com/waf/firewalls + method: POST + response: + body: '{"data":{"id":"6YqagDC62Z4bIFpsNBzxVm","type":"waf_firewall","attributes":{"active_rules_fastly_block_count":0,"active_rules_fastly_log_count":0,"active_rules_fastly_score_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_score_count":0,"active_rules_trustwave_block_count":0,"active_rules_trustwave_log_count":0,"created_at":"2020-10-07T13:09:09Z","disabled":false,"prefetch_condition":"","response":"WAf_Response","service_id":"2Xx48e6pQNCa26prCiwiTG","service_version_number":2,"updated_at":"2020-10-07T13:09:09Z"}}}' + headers: + Accept-Ranges: + - bytes + - bytes + Content-Length: + - "566" + Content-Type: + - application/vnd.api+json + Date: + - Wed, 07 Oct 2020 13:09:09 GMT + Status: + - 201 Created + Strict-Transport-Security: + - max-age=31536000 + Via: + - 1.1 varnish + - 1.1 varnish + X-Cache: + - MISS, MISS + X-Cache-Hits: + - 0, 0 + X-Content-Type-Options: + - nosniff + X-Served-By: + - cache-control-slwdc9037-CONTROL-SLWDC, cache-lhr7363-LHR + X-Timer: + - S1602076148.085211,VS0,VE1201 + status: 201 Created + code: 201 + duration: "" diff --git a/fastly/fixtures/waf_exclusion/update/waf/delete.yaml b/fastly/fixtures/waf_exclusion/update/waf/delete.yaml new file mode 100644 index 000000000..adb3692eb --- /dev/null +++ b/fastly/fixtures/waf_exclusion/update/waf/delete.yaml @@ -0,0 +1,44 @@ +--- +version: 1 +interactions: +- request: + body: | + {"data":{"type":"waf_firewall","id":"6YqagDC62Z4bIFpsNBzxVm","attributes":{"service_version_number":"1"}}} + form: {} + headers: + Accept: + - application/vnd.api+json + Content-Type: + - application/vnd.api+json + User-Agent: + - FastlyGo/1.17.0 (+github.com/fastly/go-fastly; go1.14.5) + url: https://api.fastly.com/waf/firewalls/6YqagDC62Z4bIFpsNBzxVm + method: DELETE + response: + body: "" + headers: + Accept-Ranges: + - bytes + - bytes + Date: + - Wed, 07 Oct 2020 13:09:11 GMT + Status: + - 204 No Content + Strict-Transport-Security: + - max-age=31536000 + Via: + - 1.1 varnish + - 1.1 varnish + X-Cache: + - MISS, MISS + X-Cache-Hits: + - 0, 0 + X-Content-Type-Options: + - nosniff + X-Served-By: + - cache-control-slwdc9035-CONTROL-SLWDC, cache-lhr7363-LHR + X-Timer: + - S1602076152.650787,VS0,VE153 + status: 204 No Content + code: 204 + duration: "" diff --git a/fastly/fixtures/waf_exclusion/update/waf_exclusions/create.yaml b/fastly/fixtures/waf_exclusion/update/waf_exclusions/create.yaml new file mode 100644 index 000000000..c120a4cb6 --- /dev/null +++ b/fastly/fixtures/waf_exclusion/update/waf_exclusions/create.yaml @@ -0,0 +1,49 @@ +--- +version: 1 +interactions: +- request: + body: | + {"data":{"type":"waf_exclusion","attributes":{"condition":"req.url.basename == \"index.html\"","exclusion_type":"rule","name":"index page","number":null},"relationships":{"waf_rules":{"data":[{"type":"waf_rule","id":"2029718"},{"type":"waf_rule","id":"2037405"}]}}},"included":[{"type":"waf_rule","id":"2029718","attributes":{"modsec_rule_id":2029718}},{"type":"waf_rule","id":"2037405","attributes":{"modsec_rule_id":2037405}}]} + form: {} + headers: + Accept: + - application/vnd.api+json + Content-Type: + - application/vnd.api+json + User-Agent: + - FastlyGo/1.17.0 (+github.com/fastly/go-fastly; go1.14.5) + url: https://api.fastly.com/waf/firewalls/6YqagDC62Z4bIFpsNBzxVm/versions/1/exclusions + method: POST + response: + body: '{"data":{"id":"4eV7U9toc5h0Yqi9Vm1hcN","type":"waf_exclusion","attributes":{"created_at":"2020-10-07T13:09:09Z","exclusion_type":"rule","condition":"req.url.basename + == \"index.html\"","name":"index page","number":1,"updated_at":"2020-10-07T13:09:09Z"},"relationships":{"waf_rules":{"data":[{"id":"1YveWU8qwEYidE8WAiZqCN","type":"waf_rule"},{"id":"VovV0PIWJCm33k1piDpnX","type":"waf_rule"}]}}}}' + headers: + Accept-Ranges: + - bytes + - bytes + Content-Length: + - "394" + Content-Type: + - application/vnd.api+json + Date: + - Wed, 07 Oct 2020 13:09:10 GMT + Status: + - 201 Created + Strict-Transport-Security: + - max-age=31536000 + Via: + - 1.1 varnish + - 1.1 varnish + X-Cache: + - MISS, MISS + X-Cache-Hits: + - 0, 0 + X-Content-Type-Options: + - nosniff + X-Served-By: + - cache-control-slwdc9035-CONTROL-SLWDC, cache-lhr7363-LHR + X-Timer: + - S1602076150.870902,VS0,VE153 + status: 201 Created + code: 201 + duration: "" diff --git a/fastly/fixtures/waf_exclusion/update/waf_exclusions/list.yaml b/fastly/fixtures/waf_exclusion/update/waf_exclusions/list.yaml new file mode 100644 index 000000000..135c43f75 --- /dev/null +++ b/fastly/fixtures/waf_exclusion/update/waf_exclusions/list.yaml @@ -0,0 +1,48 @@ +--- +version: 1 +interactions: +- request: + body: "" + form: {} + headers: + User-Agent: + - FastlyGo/1.17.0 (+github.com/fastly/go-fastly; go1.14.5) + url: https://api.fastly.com/waf/firewalls/6YqagDC62Z4bIFpsNBzxVm/versions/1/exclusions?include=waf_rules&page%5Bnumber%5D=1&page%5Bsize%5D=100 + method: GET + response: + body: '{"data":[{"id":"4eV7U9toc5h0Yqi9Vm1hcN","type":"waf_exclusion","attributes":{"created_at":"2020-10-07T13:09:09Z","exclusion_type":"rule","condition":"req.url.basename + == \"index.html\"","name":"index page","number":1,"updated_at":"2020-10-07T13:09:09Z"},"relationships":{"waf_rules":{"data":[{"id":"1YveWU8qwEYidE8WAiZqCN","type":"waf_rule"},{"id":"62NGF4KWy1v17yyV1vmPdb","type":"waf_rule"}]}}}],"included":[{"id":"1YveWU8qwEYidE8WAiZqCN","type":"waf_rule","attributes":{"modsec_rule_id":2029718,"publisher":"trustwave","type":"strict"}},{"id":"62NGF4KWy1v17yyV1vmPdb","type":"waf_rule","attributes":{"modsec_rule_id":1010070,"publisher":"owasp","type":"threshold"}}],"links":{"last":"https://api.fastly.com/waf/firewalls/6YqagDC62Z4bIFpsNBzxVm/versions/1/exclusions?include=waf_rules\u0026page[number]=1\u0026page[size]=100","first":"https://api.fastly.com/waf/firewalls/6YqagDC62Z4bIFpsNBzxVm/versions/1/exclusions?include=waf_rules\u0026page[number]=1\u0026page[size]=100"},"meta":{"current_page":1,"per_page":100,"record_count":1,"total_pages":1}}' + headers: + Accept-Ranges: + - bytes + - bytes + - bytes + Age: + - "0" + - "0" + Content-Length: + - "1052" + Content-Type: + - application/vnd.api+json + Date: + - Wed, 07 Oct 2020 13:09:11 GMT + Status: + - 200 OK + Strict-Transport-Security: + - max-age=31536000 + Via: + - 1.1 varnish + - 1.1 varnish + X-Cache: + - MISS, MISS + X-Cache-Hits: + - 0, 0 + X-Content-Type-Options: + - nosniff + X-Served-By: + - cache-control-slwdc9035-CONTROL-SLWDC, cache-lhr7363-LHR + X-Timer: + - S1602076151.749519,VS0,VE834 + status: 200 OK + code: 200 + duration: "" diff --git a/fastly/fixtures/waf_exclusion/update/waf_exclusions/update.yaml b/fastly/fixtures/waf_exclusion/update/waf_exclusions/update.yaml new file mode 100644 index 000000000..bfba3a2ed --- /dev/null +++ b/fastly/fixtures/waf_exclusion/update/waf_exclusions/update.yaml @@ -0,0 +1,49 @@ +--- +version: 1 +interactions: +- request: + body: | + {"data":{"type":"waf_exclusion","attributes":{"condition":"req.url.basename == \"index.html\"","exclusion_type":"rule","name":"index page","number":null},"relationships":{"waf_rules":{"data":[{"type":"waf_rule","id":"2029718"},{"type":"waf_rule","id":"1010070"}]}}},"included":[{"type":"waf_rule","id":"1010070","attributes":{"modsec_rule_id":1010070}},{"type":"waf_rule","id":"2029718","attributes":{"modsec_rule_id":2029718}}]} + form: {} + headers: + Accept: + - application/vnd.api+json + Content-Type: + - application/vnd.api+json + User-Agent: + - FastlyGo/1.17.0 (+github.com/fastly/go-fastly; go1.14.5) + url: https://api.fastly.com/waf/firewalls/6YqagDC62Z4bIFpsNBzxVm/versions/1/exclusions/1 + method: PATCH + response: + body: '{"data":{"id":"4eV7U9toc5h0Yqi9Vm1hcN","type":"waf_exclusion","attributes":{"created_at":"2020-10-07T13:09:09Z","exclusion_type":"rule","condition":"req.url.basename + == \"index.html\"","name":"index page","number":1,"updated_at":"2020-10-07T13:09:09Z"},"relationships":{"waf_rules":{"data":[{"id":"1YveWU8qwEYidE8WAiZqCN","type":"waf_rule"},{"id":"62NGF4KWy1v17yyV1vmPdb","type":"waf_rule"}]}}}}' + headers: + Accept-Ranges: + - bytes + - bytes + Content-Length: + - "395" + Content-Type: + - application/vnd.api+json + Date: + - Wed, 07 Oct 2020 13:09:10 GMT + Status: + - 200 OK + Strict-Transport-Security: + - max-age=31536000 + Via: + - 1.1 varnish + - 1.1 varnish + X-Cache: + - MISS, MISS + X-Cache-Hits: + - 0, 0 + X-Content-Type-Options: + - nosniff + X-Served-By: + - cache-control-slwdc9035-CONTROL-SLWDC, cache-lhr7363-LHR + X-Timer: + - S1602076150.106747,VS0,VE598 + status: 200 OK + code: 200 + duration: "" diff --git a/fastly/waf_exclusion.go b/fastly/waf_exclusion.go new file mode 100644 index 000000000..8731d0020 --- /dev/null +++ b/fastly/waf_exclusion.go @@ -0,0 +1,297 @@ +package fastly + +import ( + "bytes" + "fmt" + "io" + "reflect" + "strconv" + "time" + + "github.com/google/jsonapi" +) + +// WAFExclusionType is used for reflection because JSONAPI wants to know what it's +// decoding into. +var WAFExclusionType = reflect.TypeOf(new(WAFExclusion)) + +const ( + // WAFExclusionTypeRule is the type of WAF exclusions that excludes rules from the WAF based on certain conditions + WAFExclusionTypeRule = "rule" + // WAFExclusionTypeWAF is the type of WAF exclusions that excludes WAF based on certain conditions + WAFExclusionTypeWAF = "waf" +) + +// WAFExclusion is the information about a WAF exclusion object. +type WAFExclusion struct { + ID string `jsonapi:"primary,waf_exclusion"` + Name *string `jsonapi:"attr,name"` + ExclusionType *string `jsonapi:"attr,exclusion_type"` + Condition *string `jsonapi:"attr,condition"` + Number *int `jsonapi:"attr,number"` + Rules []*WAFRule `jsonapi:"relation,waf_rules,omitempty"` + CreatedAt *time.Time `jsonapi:"attr,created_at,iso8601,omitempty"` + UpdatedAt *time.Time `jsonapi:"attr,updated_at,iso8601,omitempty"` +} + +// WAFExclusionResponse represents a list of exclusions - full response. +type WAFExclusionResponse struct { + Items []*WAFExclusion + Info infoResponse +} + +// ListWAFExclusionsInput used as input for listing a WAF's exclusions. +type ListWAFExclusionsInput struct { + // The Web Application Firewall's ID. + WAFID string + // The Web Application Firewall's version number. + WAFVersionNumber int + // Limit results to exclusions with the specified exclusions type. + FilterExclusionType *string + // Limit results to exclusions with the specified exclusion name. + FilterName *string + // Limit results to exclusions that represent the specified ModSecurity modsec_rule_id. + FilterModSedID *string + // Limit the number of returned pages. + PageSize *int + // Request a specific page of exclusions. + PageNumber *int + // Include relationships. Optional, comma-separated values. Permitted values: waf_rule_revision and waf_firewall_version. + Include *string +} + +// ListAllWAFExclusionsInput used as input for listing all WAF exclusions. +type ListAllWAFExclusionsInput struct { + // The Web Application Firewall's ID. + WAFID string + // The Web Application Firewall's version number. + WAFVersionNumber int + // Limit results to exclusions with the specified exclusions type. + FilterExclusionType *string + // Limit results to exclusions with the specified exclusion name. + FilterName *string + // Limit results to exclusions that represent the specified ModSecurity modsec_rule_id. + FilterModSedID *string + // Include relationships. Optional, comma-separated values. Permitted values: waf_rule_revision and waf_firewall_version. + Include *string +} + +// CreateWAFExclusionInput used as input to create a WAF exclusion. +type CreateWAFExclusionInput struct { + // The Web Application Firewall's ID. + WAFID string + // The Web Application Firewall's version number. + WAFVersionNumber int + // The Web Application Firewall's exclusion + WAFExclusion *WAFExclusion +} + +// UpdateWAFExclusionInput is used for exclusions updates. +type UpdateWAFExclusionInput struct { + // The Web Application Firewall's ID. + WAFID string + // The Web Application Firewall's version number. + WAFVersionNumber int + // The exclusion number. + Number int + // The WAF exclusion + WAFExclusion *WAFExclusion +} + +// DeleteWAFExclusionInput used as input for removing WAF exclusions. +type DeleteWAFExclusionInput struct { + // The Web Application Firewall's ID. + WAFID string + // The Web Application Firewall's version number. + WAFVersionNumber int + // The exclusion number. + Number int +} + +func (i *ListWAFExclusionsInput) formatFilters() map[string]string { + + result := map[string]string{} + pairings := map[string]interface{}{ + "filter[exclusion_type]": i.FilterExclusionType, + "filter[name]": i.FilterName, + "filter[waf_rules.modsec_rule_id]": i.FilterModSedID, + "page[size]": i.PageSize, + "page[number]": i.PageNumber, + "include": i.Include, + } + + for key, value := range pairings { + switch value := value.(type) { + case *string: + if value != nil { + result[key] = *value + } + case *int: + if value != nil { + result[key] = strconv.Itoa(*value) + } + } + } + return result +} + +// ListWAFExclusions returns the list of exclusions for a given WAF ID. +func (c *Client) ListWAFExclusions(i *ListWAFExclusionsInput) (*WAFExclusionResponse, error) { + + if i.WAFID == "" { + return nil, ErrMissingWAFID + } + + if i.WAFVersionNumber == 0 { + return nil, ErrMissingWAFVersionNumber + } + + path := fmt.Sprintf("/waf/firewalls/%s/versions/%d/exclusions", i.WAFID, i.WAFVersionNumber) + resp, err := c.Get(path, &RequestOptions{ + Params: i.formatFilters(), + }) + if err != nil { + return nil, err + } + + var buf bytes.Buffer + tee := io.TeeReader(resp.Body, &buf) + + info, err := getResponseInfo(tee) + if err != nil { + return nil, err + } + + data, err := jsonapi.UnmarshalManyPayload(bytes.NewReader(buf.Bytes()), WAFExclusionType) + if err != nil { + return nil, err + } + + wafExclusions := make([]*WAFExclusion, len(data)) + for i := range data { + typed, ok := data[i].(*WAFExclusion) + if !ok { + return nil, fmt.Errorf("got back a non-WAFExclusion response") + } + wafExclusions[i] = typed + } + return &WAFExclusionResponse{ + Items: wafExclusions, + Info: info, + }, nil +} + +// ListAllWAFExclusions returns the complete list of WAF exclusions for a given WAF ID. It iterates through +// all existing pages to ensure all WAF exclusions are returned at once. +func (c *Client) ListAllWAFExclusions(i *ListAllWAFExclusionsInput) (*WAFExclusionResponse, error) { + + if i.WAFID == "" { + return nil, ErrMissingWAFID + } + + if i.WAFVersionNumber == 0 { + return nil, ErrMissingWAFVersionNumber + } + + currentPage := 1 + pageSize := WAFPaginationPageSize + result := &WAFExclusionResponse{Items: []*WAFExclusion{}} + for { + r, err := c.ListWAFExclusions(&ListWAFExclusionsInput{ + WAFID: i.WAFID, + WAFVersionNumber: i.WAFVersionNumber, + PageNumber: ¤tPage, + PageSize: &pageSize, + Include: i.Include, + FilterName: i.FilterName, + FilterModSedID: i.FilterModSedID, + FilterExclusionType: i.FilterExclusionType, + }) + if err != nil { + return r, err + } + + currentPage++ + result.Items = append(result.Items, r.Items...) + + if r.Info.Links.Next == "" || len(r.Items) == 0 { + return result, nil + } + } +} + +// CreateWAFExclusion used to create a particular WAF exclusion. +func (c *Client) CreateWAFExclusion(i *CreateWAFExclusionInput) (*WAFExclusion, error) { + + if i.WAFID == "" { + return nil, ErrMissingWAFID + } + + if i.WAFVersionNumber == 0 { + return nil, ErrMissingWAFVersionNumber + } + + if i.WAFExclusion == nil { + return nil, ErrMissingWAFExclusion + } + + path := fmt.Sprintf("/waf/firewalls/%s/versions/%d/exclusions", i.WAFID, i.WAFVersionNumber) + resp, err := c.PostJSONAPI(path, i.WAFExclusion, nil) + if err != nil { + return nil, err + } + + var wafExclusion WAFExclusion + if err := jsonapi.UnmarshalPayload(resp.Body, &wafExclusion); err != nil { + return nil, err + } + return &wafExclusion, nil +} + +// UpdateWAFExclusion used to update a particular WAF exclusion. +func (c *Client) UpdateWAFExclusion(i *UpdateWAFExclusionInput) (*WAFExclusion, error) { + if i.WAFID == "" { + return nil, ErrMissingWAFID + } + + if i.WAFVersionNumber == 0 { + return nil, ErrMissingWAFVersionNumber + } + + if i.Number == 0 { + return nil, ErrMissingWAFExclusionNumber + } + + if i.WAFExclusion == nil { + return nil, ErrMissingWAFExclusion + } + + path := fmt.Sprintf("/waf/firewalls/%s/versions/%d/exclusions/%d", i.WAFID, i.WAFVersionNumber, i.Number) + resp, err := c.PatchJSONAPI(path, i.WAFExclusion, nil) + if err != nil { + return nil, err + } + + var exc *WAFExclusion + if err := decodeBodyMap(resp.Body, &exc); err != nil { + return nil, err + } + return exc, nil +} + +// DeleteWAFExclusions removes rules from a particular WAF. +func (c *Client) DeleteWAFExclusion(i *DeleteWAFExclusionInput) error { + if i.WAFID == "" { + return ErrMissingWAFID + } + if i.WAFVersionNumber == 0 { + return ErrMissingWAFVersionNumber + } + if i.Number == 0 { + return ErrMissingWAFExclusionNumber + } + + path := fmt.Sprintf("/waf/firewalls/%s/versions/%d/exclusions/%d", i.WAFID, i.WAFVersionNumber, i.Number) + _, err := c.Delete(path, nil) + return err +} diff --git a/fastly/waf_exclusion_test.go b/fastly/waf_exclusion_test.go new file mode 100644 index 000000000..8769641f2 --- /dev/null +++ b/fastly/waf_exclusion_test.go @@ -0,0 +1,499 @@ +package fastly + +import ( + "math/rand" + "reflect" + "strconv" + "testing" +) + +func TestClient_WAF_Exclusion_list(t *testing.T) { + t.Parallel() + + fixtureBase := "waf_exclusion/list/" + + testService, serviceVersion, responseName := createServiceForWAF(t, fixtureBase) + waf := createWAFWithRules(t, fixtureBase, testService, serviceVersion, responseName) + + defer deleteTestService(t, fixtureBase+"service/delete", testService.ID) + defer deleteWAF(t, fixtureBase+"waf/delete", waf.ID, "1") + + excl1In := buildWAFExclusion1(waf.ID, 1) + excl2In := buildWAFExclusion2(waf.ID, 1) + createWAFExclusion(t, fixtureBase+"waf_exclusions/create-1", excl1In) + createWAFExclusion(t, fixtureBase+"waf_exclusions/create-2", excl2In) + + exclResp := listWAFExclusions(t, fixtureBase+"waf_exclusions/list", waf, "waf_rules") + if len(exclResp.Items) != 2 { + t.Errorf("expected 2 waf exclusions: got %d", len(exclResp.Items)) + } + + assertWAFExclusionEquals(t, exclResp.Items[0], excl1In.WAFExclusion) + assertWAFExclusionEquals(t, exclResp.Items[1], excl2In.WAFExclusion) +} + +func TestClient_WAF_Exclusion_list_filters(t *testing.T) { + t.Parallel() + + fixtureBase := "waf_exclusion/list_filters/" + + testService, serviceVersion, responseName := createServiceForWAF(t, fixtureBase) + waf := createWAFWithRules(t, fixtureBase, testService, serviceVersion, responseName) + + defer deleteTestService(t, fixtureBase+"service/delete", testService.ID) + defer deleteWAF(t, fixtureBase+"waf/delete", waf.ID, "1") + + excl1In := buildWAFExclusion1(waf.ID, 1) + excl2In := buildWAFExclusion2(waf.ID, 1) + excl3In := buildWAFExclusionWAF(waf.ID, 1) + createWAFExclusion(t, fixtureBase+"waf_exclusions/create-1", excl1In) + createWAFExclusion(t, fixtureBase+"waf_exclusions/create-2", excl2In) + createWAFExclusion(t, fixtureBase+"waf_exclusions/create-3", excl3In) + + exclResp := listWAFExclusionsWithFilters(t, fixtureBase+"waf_exclusions/list", &ListAllWAFExclusionsInput{ + WAFID: waf.ID, + WAFVersionNumber: 1, + FilterExclusionType: strToPtr(WAFExclusionTypeRule), + FilterModSedID: strToPtr("1010070"), + Include: strToPtr("waf_rules"), + }) + if len(exclResp.Items) != 1 { + t.Errorf("expected 2 waf exclusions: got %d", len(exclResp.Items)) + } + + assertWAFExclusionEquals(t, exclResp.Items[0], excl2In.WAFExclusion) +} + +func TestClient_WAF_Exclusion_create(t *testing.T) { + t.Parallel() + + fixtureBase := "waf_exclusion/create/" + + testService, serviceVersion, responseName := createServiceForWAF(t, fixtureBase) + waf := createWAFWithRules(t, fixtureBase, testService, serviceVersion, responseName) + + defer deleteTestService(t, fixtureBase+"service/delete", testService.ID) + defer deleteWAF(t, fixtureBase+"waf/delete", waf.ID, "1") + + exclIn := buildWAFExclusion1(waf.ID, 1) + createWAFExclusion(t, fixtureBase+"waf_exclusions/create", exclIn) + + exclResp := listWAFExclusions(t, fixtureBase+"waf_exclusions/list", waf, "waf_rules") + if len(exclResp.Items) != 1 { + t.Errorf("expected 2 waf exclusions: got %d", len(exclResp.Items)) + } + assertWAFExclusionEquals(t, exclResp.Items[0], exclIn.WAFExclusion) +} + +func TestClient_WAF_Exclusion_update(t *testing.T) { + t.Parallel() + + fixtureBase := "waf_exclusion/update/" + + testService, serviceVersion, responseName := createServiceForWAF(t, fixtureBase) + waf := createWAFWithRules(t, fixtureBase, testService, serviceVersion, responseName) + + defer deleteTestService(t, fixtureBase+"service/delete", testService.ID) + defer deleteWAF(t, fixtureBase+"waf/delete", waf.ID, "1") + + exclIn := buildWAFExclusion1(waf.ID, 1) + exclOut := createWAFExclusion(t, fixtureBase+"waf_exclusions/create", exclIn) + + exclUpdateIn := buildWAFExclusion1ForUpdate(waf.ID, 1, *exclOut.Number) + updateWAFExclusion(t, fixtureBase+"waf_exclusions/update", exclUpdateIn) + + exclResp := listWAFExclusions(t, fixtureBase+"waf_exclusions/list", waf, "waf_rules") + if len(exclResp.Items) != 1 { + t.Errorf("expected 1 waf version: got %d", len(exclResp.Items)) + } + assertWAFExclusionEquals(t, exclResp.Items[0], exclIn.WAFExclusion) +} + +func TestClient_WAF_Exclusion_delete(t *testing.T) { + t.Parallel() + + fixtureBase := "waf_exclusion/delete/" + + testService, serviceVersion, responseName := createServiceForWAF(t, fixtureBase) + waf := createWAFWithRules(t, fixtureBase, testService, serviceVersion, responseName) + + defer deleteTestService(t, fixtureBase+"service/delete", testService.ID) + defer deleteWAF(t, fixtureBase+"waf/delete", waf.ID, "1") + + exclIn := buildWAFExclusion1(waf.ID, 1) + exclOut := createWAFExclusion(t, fixtureBase+"waf_exclusions/create", exclIn) + + exclUpdateIn := buildWAFExclusion1ForDeletion(waf.ID, 1, *exclOut.Number) + deleteWAFExclusion(t, fixtureBase+"waf_exclusions/update", exclUpdateIn) + + exclResp := listWAFExclusions(t, fixtureBase+"waf_exclusions/list", waf, "waf_rules") + if len(exclResp.Items) != 0 { + t.Errorf("expected 0 waf version: got %d", len(exclResp.Items)) + } +} + +func TestClient_ListWAFExclusion_validation(t *testing.T) { + t.Parallel() + + cases := []struct { + input *ListWAFExclusionsInput + expectedError error + }{ + { + input: &ListWAFExclusionsInput{ + WAFID: "", + }, + expectedError: ErrMissingWAFID, + }, + { + input: &ListWAFExclusionsInput{ + WAFID: "1", + WAFVersionNumber: 0, + }, + expectedError: ErrMissingWAFVersionNumber, + }, + } + for _, c := range cases { + if _, err := testClient.ListWAFExclusions(c.input); err != c.expectedError { + t.Errorf("bad error: %s", err) + } + } +} + +func TestClient_ListAllWAFExclusion_validation(t *testing.T) { + t.Parallel() + + cases := []struct { + input *ListAllWAFExclusionsInput + expectedError error + }{ + { + input: &ListAllWAFExclusionsInput{ + WAFID: "", + }, + expectedError: ErrMissingWAFID, + }, + { + input: &ListAllWAFExclusionsInput{ + WAFID: "1", + WAFVersionNumber: 0, + }, + expectedError: ErrMissingWAFVersionNumber, + }, + } + for _, c := range cases { + if _, err := testClient.ListAllWAFExclusions(c.input); err != c.expectedError { + t.Errorf("bad error: %s", err) + } + } +} + +func TestClient_CreateWAFExclusion_validation(t *testing.T) { + t.Parallel() + + cases := []struct { + input *CreateWAFExclusionInput + expectedError error + }{ + { + input: &CreateWAFExclusionInput{ + WAFID: "", + }, + expectedError: ErrMissingWAFID, + }, + { + input: &CreateWAFExclusionInput{ + WAFID: "1", + WAFVersionNumber: 0, + }, + expectedError: ErrMissingWAFVersionNumber, + }, + { + input: &CreateWAFExclusionInput{ + WAFID: "1", + WAFVersionNumber: 1, + }, + expectedError: ErrMissingWAFExclusion, + }, + } + for _, c := range cases { + if _, err := testClient.CreateWAFExclusion(c.input); err != c.expectedError { + t.Errorf("bad error: %s", err) + } + } +} + +func TestClient_UpdateWAFExclusion_validation(t *testing.T) { + t.Parallel() + + cases := []struct { + input *UpdateWAFExclusionInput + expectedError error + }{ + { + input: &UpdateWAFExclusionInput{ + WAFID: "", + }, + expectedError: ErrMissingWAFID, + }, + { + input: &UpdateWAFExclusionInput{ + WAFID: "1", + WAFVersionNumber: 0, + }, + expectedError: ErrMissingWAFVersionNumber, + }, + { + input: &UpdateWAFExclusionInput{ + WAFID: "1", + WAFVersionNumber: 1, + }, + expectedError: ErrMissingWAFExclusionNumber, + }, + { + input: &UpdateWAFExclusionInput{ + WAFID: "1", + WAFVersionNumber: 1, + Number: 1, + }, + expectedError: ErrMissingWAFExclusion, + }, + } + for _, c := range cases { + if _, err := testClient.UpdateWAFExclusion(c.input); err != c.expectedError { + t.Errorf("bad error: %s", err) + } + } +} + +func TestClient_DeleteWAFExclusion_validation(t *testing.T) { + t.Parallel() + + cases := []struct { + input *DeleteWAFExclusionInput + expectedError error + }{ + { + input: &DeleteWAFExclusionInput{ + WAFID: "", + }, + expectedError: ErrMissingWAFID, + }, + { + input: &DeleteWAFExclusionInput{ + WAFID: "1", + WAFVersionNumber: 0, + }, + expectedError: ErrMissingWAFVersionNumber, + }, + { + input: &DeleteWAFExclusionInput{ + WAFID: "1", + WAFVersionNumber: 1, + }, + expectedError: ErrMissingWAFExclusionNumber, + }, + } + for _, c := range cases { + if err := testClient.DeleteWAFExclusion(c.input); err != c.expectedError { + t.Errorf("bad error: %s", err) + } + } +} + +func assertWAFExclusionEquals(t *testing.T, actual *WAFExclusion, expected *WAFExclusion) { + if *actual.ExclusionType != *expected.ExclusionType { + t.Errorf("expected ExclusionType to be %s got %s", *expected.ExclusionType, *actual.ExclusionType) + } + if *actual.Condition != *expected.Condition { + t.Errorf("expected Condition to be %s got %s", *expected.Condition, *actual.Condition) + } + if *actual.Name != *expected.Name { + t.Errorf("expected Name to be %s got %s", *expected.Name, *actual.Name) + } + if len(actual.Rules) != len(expected.Rules) { + t.Errorf("expected Rules to be of size %d got %d", len(actual.Rules), len(expected.Rules)) + } + + reflect.DeepEqual(extractModSecId(actual.Rules), extractModSecId(expected.Rules)) +} + +func extractModSecId(wafRule []*WAFRule) []int { + var modSecIDs []int + for _, rule := range wafRule { + modSecIDs = append(modSecIDs, rule.ModSecID) + } + return modSecIDs +} + +func createWAFWithRules(t *testing.T, fixtureBase string, testService *Service, version *Version, responseName string) *WAF { + waf := createWAF(t, fixtureBase+"waf/create", testService.ID, strconv.Itoa(version.Number), "", responseName) + + var err error + rulesIn := buildWAFRules("log") + record(t, fixtureBase+"active_rules/create", func(c *Client) { + _, err = c.BatchModificationWAFActiveRules(&BatchModificationWAFActiveRulesInput{ + WAFID: waf.ID, + WAFVersionNumber: 1, + Rules: rulesIn, + OP: UpsertBatchOperation, + }) + }) + if err != nil { + t.Fatal(err) + } + return waf +} + +func createServiceForWAF(t *testing.T, fixtureBase string) (*Service, *Version, string) { + service := createTestService(t, fixtureBase+"service/create", "service-"+strconv.Itoa(rand.Int())) + version := createTestVersion(t, fixtureBase+"service/version", service.ID) + responseName := "WAf_Response" + createTestWAFResponseObject(t, fixtureBase+"response_object/create", service.ID, responseName, version.Number) + return service, version, responseName +} + +func createWAFExclusion(t *testing.T, fixture string, excl1In *CreateWAFExclusionInput) *WAFExclusion { + var excl1Out *WAFExclusion + var err error + record(t, fixture, func(c *Client) { + excl1Out, err = c.CreateWAFExclusion(excl1In) + }) + if err != nil { + t.Fatal(err) + } + return excl1Out +} + +func updateWAFExclusion(t *testing.T, fixture string, updateExcl *UpdateWAFExclusionInput) *WAFExclusion { + var err error + var out *WAFExclusion + record(t, fixture, func(c *Client) { + out, err = c.UpdateWAFExclusion(updateExcl) + }) + if err != nil { + t.Fatal(err) + } + return out +} + +func deleteWAFExclusion(t *testing.T, fixture string, updateExcl *DeleteWAFExclusionInput) { + var err error + record(t, fixture, func(c *Client) { + err = c.DeleteWAFExclusion(updateExcl) + }) + if err != nil { + t.Fatal(err) + } +} + +func listWAFExclusions(t *testing.T, fixture string, waf *WAF, include string) *WAFExclusionResponse { + var err error + var exclResp *WAFExclusionResponse + record(t, fixture, func(c *Client) { + exclResp, err = c.ListAllWAFExclusions(&ListAllWAFExclusionsInput{ + WAFID: waf.ID, + WAFVersionNumber: 1, + Include: &include, + }) + }) + if err != nil { + t.Fatal(err) + } + return exclResp +} + +func listWAFExclusionsWithFilters(t *testing.T, fixture string, request *ListAllWAFExclusionsInput) *WAFExclusionResponse { + var err error + var exclResp *WAFExclusionResponse + record(t, fixture, func(c *Client) { + exclResp, err = c.ListAllWAFExclusions(request) + }) + if err != nil { + t.Fatal(err) + } + return exclResp +} + +func buildWAFExclusion1(wafID string, version int) *CreateWAFExclusionInput { + return &CreateWAFExclusionInput{ + WAFID: wafID, + WAFVersionNumber: version, + WAFExclusion: &WAFExclusion{ + Name: strToPtr("index page"), + ExclusionType: strToPtr(WAFExclusionTypeRule), + Condition: strToPtr("req.url.basename == \"index.html\""), + Rules: []*WAFRule{ + { + ID: "2029718", + ModSecID: 2029718, + }, + { + ID: "2037405", + ModSecID: 2037405, + }, + }, + }, + } +} + +func buildWAFExclusion2(wafID string, version int) *CreateWAFExclusionInput { + return &CreateWAFExclusionInput{ + WAFID: wafID, + WAFVersionNumber: version, + WAFExclusion: &WAFExclusion{ + Name: strToPtr("index php"), + ExclusionType: strToPtr(WAFExclusionTypeRule), + Condition: strToPtr("req.url.basename == \"index.php\""), + Rules: []*WAFRule{ + { + ID: "1010070", + ModSecID: 1010070, + }, + }, + }, + } +} + +func buildWAFExclusionWAF(wafID string, version int) *CreateWAFExclusionInput { + return &CreateWAFExclusionInput{ + WAFID: wafID, + WAFVersionNumber: version, + WAFExclusion: &WAFExclusion{ + Name: strToPtr("index asp"), + ExclusionType: strToPtr(WAFExclusionTypeWAF), + Condition: strToPtr("req.url.basename == \"index.asp\""), + }, + } +} + +func buildWAFExclusion1ForUpdate(wafID string, version, number int) *UpdateWAFExclusionInput { + return &UpdateWAFExclusionInput{ + WAFID: wafID, + WAFVersionNumber: version, + Number: number, + WAFExclusion: &WAFExclusion{ + Name: strToPtr("index page"), + ExclusionType: strToPtr(WAFExclusionTypeRule), + Condition: strToPtr("req.url.basename == \"index.html\""), + Rules: []*WAFRule{ + { + ID: "2029718", + ModSecID: 2029718, + }, + { + ID: "1010070", + ModSecID: 1010070, + }, + }, + }, + } +} + +func buildWAFExclusion1ForDeletion(wafID string, version, number int) *DeleteWAFExclusionInput { + return &DeleteWAFExclusionInput{ + WAFID: wafID, + WAFVersionNumber: version, + Number: number, + } +} From 121e2b534cdf96a7625d17117b1cfc2cdd4c194c Mon Sep 17 00:00:00 2001 From: Mateus Pimenta <1920261+matpimenta@users.noreply.github.com> Date: Fri, 9 Oct 2020 11:26:34 +0100 Subject: [PATCH 23/37] Changing WAF Exclusion terminology to WAF Rule Exclusion --- fastly/errors.go | 10 +- .../delete/active_rules/create.yaml | 48 ---- .../list/active_rules/create.yaml | 48 ---- .../list/waf_exclusions/list.yaml | 49 ---- .../list_filters/active_rules/create.yaml | 48 ---- .../list_filters/waf_exclusions/list.yaml | 48 ---- .../update/active_rules/create.yaml | 48 ---- .../update/response_object/create.yaml | 57 ---- .../waf_exclusion/update/service/delete.yaml | 47 ---- .../waf_exclusion/update/service/version.yaml | 51 ---- .../waf_exclusion/update/waf/create.yaml | 48 ---- .../waf_exclusion/update/waf/delete.yaml | 44 --- .../update/waf_exclusions/list.yaml | 48 ---- .../create/active_rules/create.yaml | 14 +- .../create}/response_object/create.yaml | 18 +- .../create}/service/create.yaml | 12 +- .../create}/service/delete.yaml | 12 +- .../create/service/version.yaml | 18 +- .../create}/waf/create.yaml | 10 +- .../create}/waf/delete.yaml | 10 +- .../create/waf_rule_exclusions}/create.yaml | 14 +- .../create/waf_rule_exclusions}/list.yaml | 12 +- .../delete/active_rules/create.yaml | 48 ++++ .../delete}/response_object/create.yaml | 18 +- .../delete}/service/create.yaml | 12 +- .../delete/service/delete.yaml | 12 +- .../delete}/service/version.yaml | 18 +- .../delete}/waf/create.yaml | 10 +- .../delete}/waf/delete.yaml | 10 +- .../delete/waf_rule_exclusions}/create.yaml | 12 +- .../delete/waf_rule_exclusions}/list.yaml | 10 +- .../delete/waf_rule_exclusions}/update.yaml | 8 +- .../list/active_rules/create.yaml | 48 ++++ .../list/response_object/create.yaml | 18 +- .../list}/service/create.yaml | 12 +- .../list}/service/delete.yaml | 12 +- .../list}/service/version.yaml | 18 +- .../list/waf/create.yaml | 10 +- .../list}/waf/delete.yaml | 10 +- .../list/waf_rule_exclusions}/create-1.yaml | 14 +- .../list/waf_rule_exclusions}/create-2.yaml | 14 +- .../list/waf_rule_exclusions/list.yaml | 49 ++++ .../list_filters/active_rules/create.yaml | 48 ++++ .../list_filters}/response_object/create.yaml | 18 +- .../list_filters}/service/create.yaml | 12 +- .../list_filters}/service/delete.yaml | 12 +- .../list_filters/service/version.yaml | 18 +- .../list_filters/waf/create.yaml | 10 +- .../list_filters}/waf/delete.yaml | 10 +- .../waf_rule_exclusions}/create-1.yaml | 12 +- .../waf_rule_exclusions}/create-2.yaml | 16 +- .../waf_rule_exclusions}/create-3.yaml | 12 +- .../waf_rule_exclusions/list.yaml | 48 ++++ .../update/active_rules/create.yaml | 48 ++++ .../update/response_object/create.yaml | 57 ++++ .../update}/service/create.yaml | 12 +- .../update/service/delete.yaml | 47 ++++ .../update/service/version.yaml | 51 ++++ .../waf_rule_exclusion/update/waf/create.yaml | 48 ++++ .../waf_rule_exclusion/update/waf/delete.yaml | 44 +++ .../update/waf_rule_exclusions}/create.yaml | 12 +- .../update/waf_rule_exclusions/list.yaml | 48 ++++ .../update/waf_rule_exclusions}/update.yaml | 14 +- ...waf_exclusion.go => waf_rule_exclusion.go} | 106 +++---- ...ion_test.go => waf_rule_exclusion_test.go} | 259 ++++++++++-------- 65 files changed, 1030 insertions(+), 1009 deletions(-) delete mode 100644 fastly/fixtures/waf_exclusion/delete/active_rules/create.yaml delete mode 100644 fastly/fixtures/waf_exclusion/list/active_rules/create.yaml delete mode 100644 fastly/fixtures/waf_exclusion/list/waf_exclusions/list.yaml delete mode 100644 fastly/fixtures/waf_exclusion/list_filters/active_rules/create.yaml delete mode 100644 fastly/fixtures/waf_exclusion/list_filters/waf_exclusions/list.yaml delete mode 100644 fastly/fixtures/waf_exclusion/update/active_rules/create.yaml delete mode 100644 fastly/fixtures/waf_exclusion/update/response_object/create.yaml delete mode 100644 fastly/fixtures/waf_exclusion/update/service/delete.yaml delete mode 100644 fastly/fixtures/waf_exclusion/update/service/version.yaml delete mode 100644 fastly/fixtures/waf_exclusion/update/waf/create.yaml delete mode 100644 fastly/fixtures/waf_exclusion/update/waf/delete.yaml delete mode 100644 fastly/fixtures/waf_exclusion/update/waf_exclusions/list.yaml rename fastly/fixtures/{waf_exclusion => waf_rule_exclusion}/create/active_rules/create.yaml (51%) rename fastly/fixtures/{waf_exclusion/list_filters => waf_rule_exclusion/create}/response_object/create.yaml (59%) rename fastly/fixtures/{waf_exclusion/update => waf_rule_exclusion/create}/service/create.yaml (67%) rename fastly/fixtures/{waf_exclusion/list => waf_rule_exclusion/create}/service/delete.yaml (76%) rename fastly/fixtures/{waf_exclusion => waf_rule_exclusion}/create/service/version.yaml (68%) rename fastly/fixtures/{waf_exclusion/delete => waf_rule_exclusion/create}/waf/create.yaml (71%) rename fastly/fixtures/{waf_exclusion/delete => waf_rule_exclusion/create}/waf/delete.yaml (69%) rename fastly/fixtures/{waf_exclusion/delete/waf_exclusions => waf_rule_exclusion/create/waf_rule_exclusions}/create.yaml (67%) rename fastly/fixtures/{waf_exclusion/create/waf_exclusions => waf_rule_exclusion/create/waf_rule_exclusions}/list.yaml (68%) create mode 100644 fastly/fixtures/waf_rule_exclusion/delete/active_rules/create.yaml rename fastly/fixtures/{waf_exclusion/create => waf_rule_exclusion/delete}/response_object/create.yaml (64%) rename fastly/fixtures/{waf_exclusion/list_filters => waf_rule_exclusion/delete}/service/create.yaml (67%) rename fastly/fixtures/{waf_exclusion => waf_rule_exclusion}/delete/service/delete.yaml (76%) rename fastly/fixtures/{waf_exclusion/list => waf_rule_exclusion/delete}/service/version.yaml (68%) rename fastly/fixtures/{waf_exclusion/create => waf_rule_exclusion/delete}/waf/create.yaml (71%) rename fastly/fixtures/{waf_exclusion/create => waf_rule_exclusion/delete}/waf/delete.yaml (69%) rename fastly/fixtures/{waf_exclusion/update/waf_exclusions => waf_rule_exclusion/delete/waf_rule_exclusions}/create.yaml (77%) rename fastly/fixtures/{waf_exclusion/delete/waf_exclusions => waf_rule_exclusion/delete/waf_rule_exclusions}/list.yaml (72%) rename fastly/fixtures/{waf_exclusion/delete/waf_exclusions => waf_rule_exclusion/delete/waf_rule_exclusions}/update.yaml (73%) create mode 100644 fastly/fixtures/waf_rule_exclusion/list/active_rules/create.yaml rename fastly/fixtures/{waf_exclusion => waf_rule_exclusion}/list/response_object/create.yaml (64%) rename fastly/fixtures/{waf_exclusion/create => waf_rule_exclusion/list}/service/create.yaml (67%) rename fastly/fixtures/{waf_exclusion/list_filters => waf_rule_exclusion/list}/service/delete.yaml (76%) rename fastly/fixtures/{waf_exclusion/delete => waf_rule_exclusion/list}/service/version.yaml (68%) rename fastly/fixtures/{waf_exclusion => waf_rule_exclusion}/list/waf/create.yaml (71%) rename fastly/fixtures/{waf_exclusion/list_filters => waf_rule_exclusion/list}/waf/delete.yaml (69%) rename fastly/fixtures/{waf_exclusion/list_filters/waf_exclusions => waf_rule_exclusion/list/waf_rule_exclusions}/create-1.yaml (67%) rename fastly/fixtures/{waf_exclusion/list_filters/waf_exclusions => waf_rule_exclusion/list/waf_rule_exclusions}/create-2.yaml (64%) create mode 100644 fastly/fixtures/waf_rule_exclusion/list/waf_rule_exclusions/list.yaml create mode 100644 fastly/fixtures/waf_rule_exclusion/list_filters/active_rules/create.yaml rename fastly/fixtures/{waf_exclusion/delete => waf_rule_exclusion/list_filters}/response_object/create.yaml (59%) rename fastly/fixtures/{waf_exclusion/delete => waf_rule_exclusion/list_filters}/service/create.yaml (67%) rename fastly/fixtures/{waf_exclusion/create => waf_rule_exclusion/list_filters}/service/delete.yaml (76%) rename fastly/fixtures/{waf_exclusion => waf_rule_exclusion}/list_filters/service/version.yaml (68%) rename fastly/fixtures/{waf_exclusion => waf_rule_exclusion}/list_filters/waf/create.yaml (71%) rename fastly/fixtures/{waf_exclusion/list => waf_rule_exclusion/list_filters}/waf/delete.yaml (69%) rename fastly/fixtures/{waf_exclusion/list/waf_exclusions => waf_rule_exclusion/list_filters/waf_rule_exclusions}/create-1.yaml (77%) rename fastly/fixtures/{waf_exclusion/list/waf_exclusions => waf_rule_exclusion/list_filters/waf_rule_exclusions}/create-2.yaml (60%) rename fastly/fixtures/{waf_exclusion/list_filters/waf_exclusions => waf_rule_exclusion/list_filters/waf_rule_exclusions}/create-3.yaml (73%) create mode 100644 fastly/fixtures/waf_rule_exclusion/list_filters/waf_rule_exclusions/list.yaml create mode 100644 fastly/fixtures/waf_rule_exclusion/update/active_rules/create.yaml create mode 100644 fastly/fixtures/waf_rule_exclusion/update/response_object/create.yaml rename fastly/fixtures/{waf_exclusion/list => waf_rule_exclusion/update}/service/create.yaml (67%) create mode 100644 fastly/fixtures/waf_rule_exclusion/update/service/delete.yaml create mode 100644 fastly/fixtures/waf_rule_exclusion/update/service/version.yaml create mode 100644 fastly/fixtures/waf_rule_exclusion/update/waf/create.yaml create mode 100644 fastly/fixtures/waf_rule_exclusion/update/waf/delete.yaml rename fastly/fixtures/{waf_exclusion/create/waf_exclusions => waf_rule_exclusion/update/waf_rule_exclusions}/create.yaml (77%) create mode 100644 fastly/fixtures/waf_rule_exclusion/update/waf_rule_exclusions/list.yaml rename fastly/fixtures/{waf_exclusion/update/waf_exclusions => waf_rule_exclusion/update/waf_rule_exclusions}/update.yaml (61%) rename fastly/{waf_exclusion.go => waf_rule_exclusion.go} (63%) rename fastly/{waf_exclusion_test.go => waf_rule_exclusion_test.go} (50%) diff --git a/fastly/errors.go b/fastly/errors.go index 30c4871ed..1bad4e731 100644 --- a/fastly/errors.go +++ b/fastly/errors.go @@ -117,13 +117,13 @@ var ErrMissingWAFVersionID = errors.New("missing required field 'WAFVersionID'") // requires a list of WAF active rules, but it is empty. var ErrMissingWAFActiveRuleList = errors.New("WAF active rules slice is empty") -// ErrMissingWAFExclusionNumber is an error that is returned when an input struct +// ErrMissingWAFRuleExclusionNumber is an error that is returned when an input struct // requires a "WAFExclusionNumber" key, but one was not set. -var ErrMissingWAFExclusionNumber = errors.New("missing required field 'WAFExclusionNumber'") +var ErrMissingWAFRuleExclusionNumber = errors.New("missing required field 'WAFExclusionNumber'") -// ErrMissingWAFExclusion is an error that is returned when an input struct -// requires a "WAFExclusion" key, but one was not set. -var ErrMissingWAFExclusion = errors.New("missing required field 'WAFExclusion'") +// ErrMissingWAFRuleExclusion is an error that is returned when an input struct +// requires a "WAFRuleExclusion" key, but one was not set. +var ErrMissingWAFRuleExclusion = errors.New("missing required field 'WAFRuleExclusion'") // ErrMissingOWASPID is an error that is returned was an input struct // requires a "OWASPID" key, but one was not set diff --git a/fastly/fixtures/waf_exclusion/delete/active_rules/create.yaml b/fastly/fixtures/waf_exclusion/delete/active_rules/create.yaml deleted file mode 100644 index cae1cc261..000000000 --- a/fastly/fixtures/waf_exclusion/delete/active_rules/create.yaml +++ /dev/null @@ -1,48 +0,0 @@ ---- -version: 1 -interactions: -- request: - body: | - {"data":[{"type":"waf_active_rule","attributes":{"modsec_rule_id":2029718,"revision":1,"status":"log"}},{"type":"waf_active_rule","attributes":{"modsec_rule_id":2037405,"revision":1,"status":"log"}},{"type":"waf_active_rule","attributes":{"modsec_rule_id":1010070,"revision":1,"status":"log"}}]} - form: {} - headers: - Accept: - - application/vnd.api+json; ext=bulk - Content-Type: - - application/vnd.api+json; ext=bulk - User-Agent: - - FastlyGo/1.17.0 (+github.com/fastly/go-fastly; go1.14.5) - url: https://api.fastly.com/waf/firewalls/3wsTANvXfIbxSOd5GUpqQf/versions/1/active-rules - method: POST - response: - body: '{"data":[{"id":"3BVvSyopzcQ9Vfi0ia51PF","type":"waf_active_rule","attributes":{"created_at":"2020-10-07T13:09:09Z","latest_revision":1,"modsec_rule_id":2029718,"outdated":false,"revision":1,"status":"log","updated_at":"2020-10-07T13:09:09Z"},"relationships":{"waf_firewall_version":{"data":{"id":"HmBQAyog2H22IHva5xNzB","type":"waf_firewall_version"}},"waf_rule_revision":{"data":{"id":"6ZJML5tsy5uVq1nGNgmZ78","type":"waf_rule_revision"}}}},{"id":"5SabvExTpr2dlLgVP2lgJm","type":"waf_active_rule","attributes":{"created_at":"2020-10-07T13:09:09Z","latest_revision":1,"modsec_rule_id":2037405,"outdated":false,"revision":1,"status":"log","updated_at":"2020-10-07T13:09:09Z"},"relationships":{"waf_firewall_version":{"data":{"id":"HmBQAyog2H22IHva5xNzB","type":"waf_firewall_version"}},"waf_rule_revision":{"data":{"id":"3ANlv7vVZdzk2qFXlJLIk3","type":"waf_rule_revision"}}}},{"id":"2XGTelStkzWMYJSqtoc8Bs","type":"waf_active_rule","attributes":{"created_at":"2020-10-07T13:09:09Z","latest_revision":1,"modsec_rule_id":1010070,"outdated":false,"revision":1,"status":"log","updated_at":"2020-10-07T13:09:09Z"},"relationships":{"waf_firewall_version":{"data":{"id":"HmBQAyog2H22IHva5xNzB","type":"waf_firewall_version"}},"waf_rule_revision":{"data":{"id":"2qiuFDyJoxuKkKkJYjrgsC","type":"waf_rule_revision"}}}}]}' - headers: - Accept-Ranges: - - bytes - - bytes - Content-Length: - - "1309" - Content-Type: - - application/vnd.api+json - Date: - - Wed, 07 Oct 2020 13:09:09 GMT - Status: - - 201 Created - Strict-Transport-Security: - - max-age=31536000 - Via: - - 1.1 varnish - - 1.1 varnish - X-Cache: - - MISS, MISS - X-Cache-Hits: - - 0, 0 - X-Content-Type-Options: - - nosniff - X-Served-By: - - cache-control-slwdc9035-CONTROL-SLWDC, cache-lhr7363-LHR - X-Timer: - - S1602076149.887066,VS0,VE479 - status: 201 Created - code: 201 - duration: "" diff --git a/fastly/fixtures/waf_exclusion/list/active_rules/create.yaml b/fastly/fixtures/waf_exclusion/list/active_rules/create.yaml deleted file mode 100644 index e7fe83bad..000000000 --- a/fastly/fixtures/waf_exclusion/list/active_rules/create.yaml +++ /dev/null @@ -1,48 +0,0 @@ ---- -version: 1 -interactions: -- request: - body: | - {"data":[{"type":"waf_active_rule","attributes":{"modsec_rule_id":2029718,"revision":1,"status":"log"}},{"type":"waf_active_rule","attributes":{"modsec_rule_id":2037405,"revision":1,"status":"log"}},{"type":"waf_active_rule","attributes":{"modsec_rule_id":1010070,"revision":1,"status":"log"}}]} - form: {} - headers: - Accept: - - application/vnd.api+json; ext=bulk - Content-Type: - - application/vnd.api+json; ext=bulk - User-Agent: - - FastlyGo/1.17.0 (+github.com/fastly/go-fastly; go1.14.5) - url: https://api.fastly.com/waf/firewalls/5HtuuALz7WUiKn4AZnU1VM/versions/1/active-rules - method: POST - response: - body: '{"data":[{"id":"2meQ2kooxO1TVMgfrmoZXE","type":"waf_active_rule","attributes":{"created_at":"2020-10-07T13:09:09Z","latest_revision":1,"modsec_rule_id":2029718,"outdated":false,"revision":1,"status":"log","updated_at":"2020-10-07T13:09:09Z"},"relationships":{"waf_firewall_version":{"data":{"id":"2YlFM58yYJBu2oZqAPxJ5n","type":"waf_firewall_version"}},"waf_rule_revision":{"data":{"id":"6ZJML5tsy5uVq1nGNgmZ78","type":"waf_rule_revision"}}}},{"id":"6CggG3aoA4lfhBtOJuGK8G","type":"waf_active_rule","attributes":{"created_at":"2020-10-07T13:09:09Z","latest_revision":1,"modsec_rule_id":2037405,"outdated":false,"revision":1,"status":"log","updated_at":"2020-10-07T13:09:09Z"},"relationships":{"waf_firewall_version":{"data":{"id":"2YlFM58yYJBu2oZqAPxJ5n","type":"waf_firewall_version"}},"waf_rule_revision":{"data":{"id":"3ANlv7vVZdzk2qFXlJLIk3","type":"waf_rule_revision"}}}},{"id":"7KQSfZg4DSO1EZCjSCtKSf","type":"waf_active_rule","attributes":{"created_at":"2020-10-07T13:09:09Z","latest_revision":1,"modsec_rule_id":1010070,"outdated":false,"revision":1,"status":"log","updated_at":"2020-10-07T13:09:09Z"},"relationships":{"waf_firewall_version":{"data":{"id":"2YlFM58yYJBu2oZqAPxJ5n","type":"waf_firewall_version"}},"waf_rule_revision":{"data":{"id":"2qiuFDyJoxuKkKkJYjrgsC","type":"waf_rule_revision"}}}}]}' - headers: - Accept-Ranges: - - bytes - - bytes - Content-Length: - - "1312" - Content-Type: - - application/vnd.api+json - Date: - - Wed, 07 Oct 2020 13:09:09 GMT - Status: - - 201 Created - Strict-Transport-Security: - - max-age=31536000 - Via: - - 1.1 varnish - - 1.1 varnish - X-Cache: - - MISS, MISS - X-Cache-Hits: - - 0, 0 - X-Content-Type-Options: - - nosniff - X-Served-By: - - cache-control-slwdc9036-CONTROL-SLWDC, cache-lhr7363-LHR - X-Timer: - - S1602076149.250968,VS0,VE131 - status: 201 Created - code: 201 - duration: "" diff --git a/fastly/fixtures/waf_exclusion/list/waf_exclusions/list.yaml b/fastly/fixtures/waf_exclusion/list/waf_exclusions/list.yaml deleted file mode 100644 index d972e7fb3..000000000 --- a/fastly/fixtures/waf_exclusion/list/waf_exclusions/list.yaml +++ /dev/null @@ -1,49 +0,0 @@ ---- -version: 1 -interactions: -- request: - body: "" - form: {} - headers: - User-Agent: - - FastlyGo/1.17.0 (+github.com/fastly/go-fastly; go1.14.5) - url: https://api.fastly.com/waf/firewalls/5HtuuALz7WUiKn4AZnU1VM/versions/1/exclusions?include=waf_rules&page%5Bnumber%5D=1&page%5Bsize%5D=100 - method: GET - response: - body: '{"data":[{"id":"34s9Ff1kxfri0Re34WzNk5","type":"waf_exclusion","attributes":{"created_at":"2020-10-07T13:09:09Z","exclusion_type":"rule","condition":"req.url.basename - == \"index.html\"","name":"index page","number":1,"updated_at":"2020-10-07T13:09:09Z"},"relationships":{"waf_rules":{"data":[{"id":"1YveWU8qwEYidE8WAiZqCN","type":"waf_rule"},{"id":"VovV0PIWJCm33k1piDpnX","type":"waf_rule"}]}}},{"id":"3ZQKFpHrO9heq1gv2o1pEo","type":"waf_exclusion","attributes":{"created_at":"2020-10-07T13:09:09Z","exclusion_type":"rule","condition":"req.url.basename - == \"index.php\"","name":"index php","number":2,"updated_at":"2020-10-07T13:09:09Z"},"relationships":{"waf_rules":{"data":[{"id":"62NGF4KWy1v17yyV1vmPdb","type":"waf_rule"}]}}}],"included":[{"id":"1YveWU8qwEYidE8WAiZqCN","type":"waf_rule","attributes":{"modsec_rule_id":2029718,"publisher":"trustwave","type":"strict"}},{"id":"62NGF4KWy1v17yyV1vmPdb","type":"waf_rule","attributes":{"modsec_rule_id":1010070,"publisher":"owasp","type":"threshold"}},{"id":"VovV0PIWJCm33k1piDpnX","type":"waf_rule","attributes":{"modsec_rule_id":2037405,"publisher":"trustwave","type":"strict"}}],"links":{"last":"https://api.fastly.com/waf/firewalls/5HtuuALz7WUiKn4AZnU1VM/versions/1/exclusions?include=waf_rules\u0026page[number]=1\u0026page[size]=100","first":"https://api.fastly.com/waf/firewalls/5HtuuALz7WUiKn4AZnU1VM/versions/1/exclusions?include=waf_rules\u0026page[number]=1\u0026page[size]=100"},"meta":{"current_page":1,"per_page":100,"record_count":2,"total_pages":1}}' - headers: - Accept-Ranges: - - bytes - - bytes - - bytes - Age: - - "0" - - "0" - Content-Length: - - "1515" - Content-Type: - - application/vnd.api+json - Date: - - Wed, 07 Oct 2020 13:09:10 GMT - Status: - - 200 OK - Strict-Transport-Security: - - max-age=31536000 - Via: - - 1.1 varnish - - 1.1 varnish - X-Cache: - - MISS, MISS - X-Cache-Hits: - - 0, 0 - X-Content-Type-Options: - - nosniff - X-Served-By: - - cache-control-slwdc9035-CONTROL-SLWDC, cache-lhr7363-LHR - X-Timer: - - S1602076150.106723,VS0,VE152 - status: 200 OK - code: 200 - duration: "" diff --git a/fastly/fixtures/waf_exclusion/list_filters/active_rules/create.yaml b/fastly/fixtures/waf_exclusion/list_filters/active_rules/create.yaml deleted file mode 100644 index a38d1fd01..000000000 --- a/fastly/fixtures/waf_exclusion/list_filters/active_rules/create.yaml +++ /dev/null @@ -1,48 +0,0 @@ ---- -version: 1 -interactions: -- request: - body: | - {"data":[{"type":"waf_active_rule","attributes":{"modsec_rule_id":2029718,"revision":1,"status":"log"}},{"type":"waf_active_rule","attributes":{"modsec_rule_id":2037405,"revision":1,"status":"log"}},{"type":"waf_active_rule","attributes":{"modsec_rule_id":1010070,"revision":1,"status":"log"}}]} - form: {} - headers: - Accept: - - application/vnd.api+json; ext=bulk - Content-Type: - - application/vnd.api+json; ext=bulk - User-Agent: - - FastlyGo/1.17.0 (+github.com/fastly/go-fastly; go1.14.5) - url: https://api.fastly.com/waf/firewalls/5mOnW9PxK7wPrCwcItgmY8/versions/1/active-rules - method: POST - response: - body: '{"data":[{"id":"3hhQOzGeZp1tIUKLTyZcZE","type":"waf_active_rule","attributes":{"created_at":"2020-10-07T13:09:10Z","latest_revision":1,"modsec_rule_id":2029718,"outdated":false,"revision":1,"status":"log","updated_at":"2020-10-07T13:09:10Z"},"relationships":{"waf_firewall_version":{"data":{"id":"tfMVN3sK40XQHrWAd512K","type":"waf_firewall_version"}},"waf_rule_revision":{"data":{"id":"6ZJML5tsy5uVq1nGNgmZ78","type":"waf_rule_revision"}}}},{"id":"5ofAVqut8G3hMAW3oZZY2d","type":"waf_active_rule","attributes":{"created_at":"2020-10-07T13:09:10Z","latest_revision":1,"modsec_rule_id":2037405,"outdated":false,"revision":1,"status":"log","updated_at":"2020-10-07T13:09:10Z"},"relationships":{"waf_firewall_version":{"data":{"id":"tfMVN3sK40XQHrWAd512K","type":"waf_firewall_version"}},"waf_rule_revision":{"data":{"id":"3ANlv7vVZdzk2qFXlJLIk3","type":"waf_rule_revision"}}}},{"id":"134uu0BVVV1LvdZsgZclZd","type":"waf_active_rule","attributes":{"created_at":"2020-10-07T13:09:10Z","latest_revision":1,"modsec_rule_id":1010070,"outdated":false,"revision":1,"status":"log","updated_at":"2020-10-07T13:09:10Z"},"relationships":{"waf_firewall_version":{"data":{"id":"tfMVN3sK40XQHrWAd512K","type":"waf_firewall_version"}},"waf_rule_revision":{"data":{"id":"2qiuFDyJoxuKkKkJYjrgsC","type":"waf_rule_revision"}}}}]}' - headers: - Accept-Ranges: - - bytes - - bytes - Content-Length: - - "1309" - Content-Type: - - application/vnd.api+json - Date: - - Wed, 07 Oct 2020 13:09:10 GMT - Status: - - 201 Created - Strict-Transport-Security: - - max-age=31536000 - Via: - - 1.1 varnish - - 1.1 varnish - X-Cache: - - MISS, MISS - X-Cache-Hits: - - 0, 0 - X-Content-Type-Options: - - nosniff - X-Served-By: - - cache-control-slwdc9035-CONTROL-SLWDC, cache-lhr7363-LHR - X-Timer: - - S1602076150.029718,VS0,VE162 - status: 201 Created - code: 201 - duration: "" diff --git a/fastly/fixtures/waf_exclusion/list_filters/waf_exclusions/list.yaml b/fastly/fixtures/waf_exclusion/list_filters/waf_exclusions/list.yaml deleted file mode 100644 index eb7cbccb6..000000000 --- a/fastly/fixtures/waf_exclusion/list_filters/waf_exclusions/list.yaml +++ /dev/null @@ -1,48 +0,0 @@ ---- -version: 1 -interactions: -- request: - body: "" - form: {} - headers: - User-Agent: - - FastlyGo/1.17.0 (+github.com/fastly/go-fastly; go1.14.5) - url: https://api.fastly.com/waf/firewalls/5mOnW9PxK7wPrCwcItgmY8/versions/1/exclusions?filter%5Bexclusion_type%5D=rule&filter%5Bwaf_rules.modsec_rule_id%5D=1010070&include=waf_rules&page%5Bnumber%5D=1&page%5Bsize%5D=100 - method: GET - response: - body: '{"data":[{"id":"64CI57J6goELQDlxSOBJSB","type":"waf_exclusion","attributes":{"created_at":"2020-10-07T13:09:10Z","exclusion_type":"rule","condition":"req.url.basename - == \"index.php\"","name":"index php","number":2,"updated_at":"2020-10-07T13:09:10Z"},"relationships":{"waf_rules":{"data":[{"id":"62NGF4KWy1v17yyV1vmPdb","type":"waf_rule"}]}}}],"included":[{"id":"62NGF4KWy1v17yyV1vmPdb","type":"waf_rule","attributes":{"modsec_rule_id":1010070,"publisher":"owasp","type":"threshold"}}],"links":{"last":"https://api.fastly.com/waf/firewalls/5mOnW9PxK7wPrCwcItgmY8/versions/1/exclusions?filter[exclusion_type]=rule\u0026filter[waf_rules.modsec_rule_id]=1010070\u0026include=waf_rules\u0026page[number]=1\u0026page[size]=100","first":"https://api.fastly.com/waf/firewalls/5mOnW9PxK7wPrCwcItgmY8/versions/1/exclusions?filter[exclusion_type]=rule\u0026filter[waf_rules.modsec_rule_id]=1010070\u0026include=waf_rules\u0026page[number]=1\u0026page[size]=100"},"meta":{"current_page":1,"per_page":100,"record_count":1,"total_pages":1}}' - headers: - Accept-Ranges: - - bytes - - bytes - - bytes - Age: - - "0" - - "0" - Content-Length: - - "1028" - Content-Type: - - application/vnd.api+json - Date: - - Wed, 07 Oct 2020 13:09:11 GMT - Status: - - 200 OK - Strict-Transport-Security: - - max-age=31536000 - Via: - - 1.1 varnish - - 1.1 varnish - X-Cache: - - MISS, MISS - X-Cache-Hits: - - 0, 0 - X-Content-Type-Options: - - nosniff - X-Served-By: - - cache-control-slwdc9036-CONTROL-SLWDC, cache-lhr7363-LHR - X-Timer: - - S1602076152.609213,VS0,VE145 - status: 200 OK - code: 200 - duration: "" diff --git a/fastly/fixtures/waf_exclusion/update/active_rules/create.yaml b/fastly/fixtures/waf_exclusion/update/active_rules/create.yaml deleted file mode 100644 index 49c918a7b..000000000 --- a/fastly/fixtures/waf_exclusion/update/active_rules/create.yaml +++ /dev/null @@ -1,48 +0,0 @@ ---- -version: 1 -interactions: -- request: - body: | - {"data":[{"type":"waf_active_rule","attributes":{"modsec_rule_id":2029718,"revision":1,"status":"log"}},{"type":"waf_active_rule","attributes":{"modsec_rule_id":2037405,"revision":1,"status":"log"}},{"type":"waf_active_rule","attributes":{"modsec_rule_id":1010070,"revision":1,"status":"log"}}]} - form: {} - headers: - Accept: - - application/vnd.api+json; ext=bulk - Content-Type: - - application/vnd.api+json; ext=bulk - User-Agent: - - FastlyGo/1.17.0 (+github.com/fastly/go-fastly; go1.14.5) - url: https://api.fastly.com/waf/firewalls/6YqagDC62Z4bIFpsNBzxVm/versions/1/active-rules - method: POST - response: - body: '{"data":[{"id":"2hSd4y1hudZJPE1qbZvDQz","type":"waf_active_rule","attributes":{"created_at":"2020-10-07T13:09:09Z","latest_revision":1,"modsec_rule_id":2029718,"outdated":false,"revision":1,"status":"log","updated_at":"2020-10-07T13:09:09Z"},"relationships":{"waf_firewall_version":{"data":{"id":"138SmQjgMETTvw0Fdagfvv","type":"waf_firewall_version"}},"waf_rule_revision":{"data":{"id":"6ZJML5tsy5uVq1nGNgmZ78","type":"waf_rule_revision"}}}},{"id":"7ZMBRI5js2ilh5BtgXiNNO","type":"waf_active_rule","attributes":{"created_at":"2020-10-07T13:09:09Z","latest_revision":1,"modsec_rule_id":2037405,"outdated":false,"revision":1,"status":"log","updated_at":"2020-10-07T13:09:09Z"},"relationships":{"waf_firewall_version":{"data":{"id":"138SmQjgMETTvw0Fdagfvv","type":"waf_firewall_version"}},"waf_rule_revision":{"data":{"id":"3ANlv7vVZdzk2qFXlJLIk3","type":"waf_rule_revision"}}}},{"id":"4BoYJt6J1fMXWjtGG3LyRb","type":"waf_active_rule","attributes":{"created_at":"2020-10-07T13:09:09Z","latest_revision":1,"modsec_rule_id":1010070,"outdated":false,"revision":1,"status":"log","updated_at":"2020-10-07T13:09:09Z"},"relationships":{"waf_firewall_version":{"data":{"id":"138SmQjgMETTvw0Fdagfvv","type":"waf_firewall_version"}},"waf_rule_revision":{"data":{"id":"2qiuFDyJoxuKkKkJYjrgsC","type":"waf_rule_revision"}}}}]}' - headers: - Accept-Ranges: - - bytes - - bytes - Content-Length: - - "1312" - Content-Type: - - application/vnd.api+json - Date: - - Wed, 07 Oct 2020 13:09:09 GMT - Status: - - 201 Created - Strict-Transport-Security: - - max-age=31536000 - Via: - - 1.1 varnish - - 1.1 varnish - X-Cache: - - MISS, MISS - X-Cache-Hits: - - 0, 0 - X-Content-Type-Options: - - nosniff - X-Served-By: - - cache-control-slwdc9036-CONTROL-SLWDC, cache-lhr7363-LHR - X-Timer: - - S1602076149.368523,VS0,VE413 - status: 201 Created - code: 201 - duration: "" diff --git a/fastly/fixtures/waf_exclusion/update/response_object/create.yaml b/fastly/fixtures/waf_exclusion/update/response_object/create.yaml deleted file mode 100644 index b39df9bc9..000000000 --- a/fastly/fixtures/waf_exclusion/update/response_object/create.yaml +++ /dev/null @@ -1,57 +0,0 @@ ---- -version: 1 -interactions: -- request: - body: Service=2Xx48e6pQNCa26prCiwiTG&Version=2&name=WAf_Response&status=403 - form: - Service: - - 2Xx48e6pQNCa26prCiwiTG - Version: - - "2" - name: - - WAf_Response - status: - - "403" - headers: - Content-Type: - - application/x-www-form-urlencoded - User-Agent: - - FastlyGo/1.17.0 (+github.com/fastly/go-fastly; go1.14.5) - url: https://api.fastly.com/service/2Xx48e6pQNCa26prCiwiTG/version/2/response_object - method: POST - response: - body: '{"name":"WAf_Response","status":"403","service_id":"2Xx48e6pQNCa26prCiwiTG","version":"2","updated_at":"2020-10-07T13:09:07Z","content_type":null,"request_condition":"","content":null,"deleted_at":null,"cache_condition":"","response":"ok","created_at":"2020-10-07T13:09:07Z"}' - headers: - Accept-Ranges: - - bytes - - bytes - Cache-Control: - - no-cache - Content-Type: - - application/json - Date: - - Wed, 07 Oct 2020 13:09:08 GMT - Fastly-Ratelimit-Remaining: - - "4942" - Fastly-Ratelimit-Reset: - - "1602079200" - Status: - - 200 OK - Strict-Transport-Security: - - max-age=31536000 - Vary: - - Accept-Encoding - Via: - - 1.1 varnish - - 1.1 varnish - X-Cache: - - MISS, MISS - X-Cache-Hits: - - 0, 0 - X-Served-By: - - cache-control-slwdc9036-CONTROL-SLWDC, cache-lhr7363-LHR - X-Timer: - - S1602076148.811099,VS0,VE218 - status: 200 OK - code: 200 - duration: "" diff --git a/fastly/fixtures/waf_exclusion/update/service/delete.yaml b/fastly/fixtures/waf_exclusion/update/service/delete.yaml deleted file mode 100644 index 56ac67fd1..000000000 --- a/fastly/fixtures/waf_exclusion/update/service/delete.yaml +++ /dev/null @@ -1,47 +0,0 @@ ---- -version: 1 -interactions: -- request: - body: "" - form: {} - headers: - User-Agent: - - FastlyGo/1.17.0 (+github.com/fastly/go-fastly; go1.14.5) - url: https://api.fastly.com/service/2Xx48e6pQNCa26prCiwiTG - method: DELETE - response: - body: '{"status":"ok"}' - headers: - Accept-Ranges: - - bytes - - bytes - Cache-Control: - - no-cache - Content-Type: - - application/json - Date: - - Wed, 07 Oct 2020 13:09:12 GMT - Fastly-Ratelimit-Remaining: - - "4934" - Fastly-Ratelimit-Reset: - - "1602079200" - Status: - - 200 OK - Strict-Transport-Security: - - max-age=31536000 - Vary: - - Accept-Encoding - Via: - - 1.1 varnish - - 1.1 varnish - X-Cache: - - MISS, MISS - X-Cache-Hits: - - 0, 0 - X-Served-By: - - cache-control-slwdc9035-CONTROL-SLWDC, cache-lhr7363-LHR - X-Timer: - - S1602076152.861456,VS0,VE228 - status: 200 OK - code: 200 - duration: "" diff --git a/fastly/fixtures/waf_exclusion/update/service/version.yaml b/fastly/fixtures/waf_exclusion/update/service/version.yaml deleted file mode 100644 index 081f8ca2d..000000000 --- a/fastly/fixtures/waf_exclusion/update/service/version.yaml +++ /dev/null @@ -1,51 +0,0 @@ ---- -version: 1 -interactions: -- request: - body: Service=2Xx48e6pQNCa26prCiwiTG - form: - Service: - - 2Xx48e6pQNCa26prCiwiTG - headers: - Content-Type: - - application/x-www-form-urlencoded - User-Agent: - - FastlyGo/1.17.0 (+github.com/fastly/go-fastly; go1.14.5) - url: https://api.fastly.com/service/2Xx48e6pQNCa26prCiwiTG/version - method: POST - response: - body: '{"service_id":"2Xx48e6pQNCa26prCiwiTG","number":2}' - headers: - Accept-Ranges: - - bytes - - bytes - Cache-Control: - - no-cache - Content-Type: - - application/json - Date: - - Wed, 07 Oct 2020 13:09:07 GMT - Fastly-Ratelimit-Remaining: - - "4943" - Fastly-Ratelimit-Reset: - - "1602079200" - Status: - - 200 OK - Strict-Transport-Security: - - max-age=31536000 - Vary: - - Accept-Encoding - Via: - - 1.1 varnish - - 1.1 varnish - X-Cache: - - MISS, MISS - X-Cache-Hits: - - 0, 0 - X-Served-By: - - cache-control-slwdc9035-CONTROL-SLWDC, cache-lhr7363-LHR - X-Timer: - - S1602076148.510787,VS0,VE232 - status: 200 OK - code: 200 - duration: "" diff --git a/fastly/fixtures/waf_exclusion/update/waf/create.yaml b/fastly/fixtures/waf_exclusion/update/waf/create.yaml deleted file mode 100644 index 9693f1227..000000000 --- a/fastly/fixtures/waf_exclusion/update/waf/create.yaml +++ /dev/null @@ -1,48 +0,0 @@ ---- -version: 1 -interactions: -- request: - body: | - {"data":{"type":"waf_firewall","attributes":{"prefetch_condition":"","response":"WAf_Response","service_id":"2Xx48e6pQNCa26prCiwiTG","service_version_number":"2"}}} - form: {} - headers: - Accept: - - application/vnd.api+json - Content-Type: - - application/vnd.api+json - User-Agent: - - FastlyGo/1.17.0 (+github.com/fastly/go-fastly; go1.14.5) - url: https://api.fastly.com/waf/firewalls - method: POST - response: - body: '{"data":{"id":"6YqagDC62Z4bIFpsNBzxVm","type":"waf_firewall","attributes":{"active_rules_fastly_block_count":0,"active_rules_fastly_log_count":0,"active_rules_fastly_score_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_score_count":0,"active_rules_trustwave_block_count":0,"active_rules_trustwave_log_count":0,"created_at":"2020-10-07T13:09:09Z","disabled":false,"prefetch_condition":"","response":"WAf_Response","service_id":"2Xx48e6pQNCa26prCiwiTG","service_version_number":2,"updated_at":"2020-10-07T13:09:09Z"}}}' - headers: - Accept-Ranges: - - bytes - - bytes - Content-Length: - - "566" - Content-Type: - - application/vnd.api+json - Date: - - Wed, 07 Oct 2020 13:09:09 GMT - Status: - - 201 Created - Strict-Transport-Security: - - max-age=31536000 - Via: - - 1.1 varnish - - 1.1 varnish - X-Cache: - - MISS, MISS - X-Cache-Hits: - - 0, 0 - X-Content-Type-Options: - - nosniff - X-Served-By: - - cache-control-slwdc9037-CONTROL-SLWDC, cache-lhr7363-LHR - X-Timer: - - S1602076148.085211,VS0,VE1201 - status: 201 Created - code: 201 - duration: "" diff --git a/fastly/fixtures/waf_exclusion/update/waf/delete.yaml b/fastly/fixtures/waf_exclusion/update/waf/delete.yaml deleted file mode 100644 index adb3692eb..000000000 --- a/fastly/fixtures/waf_exclusion/update/waf/delete.yaml +++ /dev/null @@ -1,44 +0,0 @@ ---- -version: 1 -interactions: -- request: - body: | - {"data":{"type":"waf_firewall","id":"6YqagDC62Z4bIFpsNBzxVm","attributes":{"service_version_number":"1"}}} - form: {} - headers: - Accept: - - application/vnd.api+json - Content-Type: - - application/vnd.api+json - User-Agent: - - FastlyGo/1.17.0 (+github.com/fastly/go-fastly; go1.14.5) - url: https://api.fastly.com/waf/firewalls/6YqagDC62Z4bIFpsNBzxVm - method: DELETE - response: - body: "" - headers: - Accept-Ranges: - - bytes - - bytes - Date: - - Wed, 07 Oct 2020 13:09:11 GMT - Status: - - 204 No Content - Strict-Transport-Security: - - max-age=31536000 - Via: - - 1.1 varnish - - 1.1 varnish - X-Cache: - - MISS, MISS - X-Cache-Hits: - - 0, 0 - X-Content-Type-Options: - - nosniff - X-Served-By: - - cache-control-slwdc9035-CONTROL-SLWDC, cache-lhr7363-LHR - X-Timer: - - S1602076152.650787,VS0,VE153 - status: 204 No Content - code: 204 - duration: "" diff --git a/fastly/fixtures/waf_exclusion/update/waf_exclusions/list.yaml b/fastly/fixtures/waf_exclusion/update/waf_exclusions/list.yaml deleted file mode 100644 index 135c43f75..000000000 --- a/fastly/fixtures/waf_exclusion/update/waf_exclusions/list.yaml +++ /dev/null @@ -1,48 +0,0 @@ ---- -version: 1 -interactions: -- request: - body: "" - form: {} - headers: - User-Agent: - - FastlyGo/1.17.0 (+github.com/fastly/go-fastly; go1.14.5) - url: https://api.fastly.com/waf/firewalls/6YqagDC62Z4bIFpsNBzxVm/versions/1/exclusions?include=waf_rules&page%5Bnumber%5D=1&page%5Bsize%5D=100 - method: GET - response: - body: '{"data":[{"id":"4eV7U9toc5h0Yqi9Vm1hcN","type":"waf_exclusion","attributes":{"created_at":"2020-10-07T13:09:09Z","exclusion_type":"rule","condition":"req.url.basename - == \"index.html\"","name":"index page","number":1,"updated_at":"2020-10-07T13:09:09Z"},"relationships":{"waf_rules":{"data":[{"id":"1YveWU8qwEYidE8WAiZqCN","type":"waf_rule"},{"id":"62NGF4KWy1v17yyV1vmPdb","type":"waf_rule"}]}}}],"included":[{"id":"1YveWU8qwEYidE8WAiZqCN","type":"waf_rule","attributes":{"modsec_rule_id":2029718,"publisher":"trustwave","type":"strict"}},{"id":"62NGF4KWy1v17yyV1vmPdb","type":"waf_rule","attributes":{"modsec_rule_id":1010070,"publisher":"owasp","type":"threshold"}}],"links":{"last":"https://api.fastly.com/waf/firewalls/6YqagDC62Z4bIFpsNBzxVm/versions/1/exclusions?include=waf_rules\u0026page[number]=1\u0026page[size]=100","first":"https://api.fastly.com/waf/firewalls/6YqagDC62Z4bIFpsNBzxVm/versions/1/exclusions?include=waf_rules\u0026page[number]=1\u0026page[size]=100"},"meta":{"current_page":1,"per_page":100,"record_count":1,"total_pages":1}}' - headers: - Accept-Ranges: - - bytes - - bytes - - bytes - Age: - - "0" - - "0" - Content-Length: - - "1052" - Content-Type: - - application/vnd.api+json - Date: - - Wed, 07 Oct 2020 13:09:11 GMT - Status: - - 200 OK - Strict-Transport-Security: - - max-age=31536000 - Via: - - 1.1 varnish - - 1.1 varnish - X-Cache: - - MISS, MISS - X-Cache-Hits: - - 0, 0 - X-Content-Type-Options: - - nosniff - X-Served-By: - - cache-control-slwdc9035-CONTROL-SLWDC, cache-lhr7363-LHR - X-Timer: - - S1602076151.749519,VS0,VE834 - status: 200 OK - code: 200 - duration: "" diff --git a/fastly/fixtures/waf_exclusion/create/active_rules/create.yaml b/fastly/fixtures/waf_rule_exclusion/create/active_rules/create.yaml similarity index 51% rename from fastly/fixtures/waf_exclusion/create/active_rules/create.yaml rename to fastly/fixtures/waf_rule_exclusion/create/active_rules/create.yaml index ae892544f..a644a8101 100644 --- a/fastly/fixtures/waf_exclusion/create/active_rules/create.yaml +++ b/fastly/fixtures/waf_rule_exclusion/create/active_rules/create.yaml @@ -3,7 +3,7 @@ version: 1 interactions: - request: body: | - {"data":[{"type":"waf_active_rule","attributes":{"modsec_rule_id":2029718,"revision":1,"status":"log"}},{"type":"waf_active_rule","attributes":{"modsec_rule_id":2037405,"revision":1,"status":"log"}},{"type":"waf_active_rule","attributes":{"modsec_rule_id":1010070,"revision":1,"status":"log"}}]} + {"data":[{"type":"waf_active_rule","attributes":{"modsec_rule_id":2029718,"revision":1,"status":"log"}},{"type":"waf_active_rule","attributes":{"modsec_rule_id":2037405,"revision":1,"status":"log"}},{"type":"waf_active_rule","attributes":{"modsec_rule_id":21032607,"revision":1,"status":"log"}}]} form: {} headers: Accept: @@ -12,20 +12,20 @@ interactions: - application/vnd.api+json; ext=bulk User-Agent: - FastlyGo/1.17.0 (+github.com/fastly/go-fastly; go1.14.5) - url: https://api.fastly.com/waf/firewalls/0PJDTfXzU9F4KsTErnB41h/versions/1/active-rules + url: https://api.fastly.com/waf/firewalls/4AGLf45qntIRxH9l9fkdBe/versions/1/active-rules method: POST response: - body: '{"data":[{"id":"2kcqGgKYiXSQQci6TxlHJf","type":"waf_active_rule","attributes":{"created_at":"2020-10-07T13:09:09Z","latest_revision":1,"modsec_rule_id":2029718,"outdated":false,"revision":1,"status":"log","updated_at":"2020-10-07T13:09:09Z"},"relationships":{"waf_firewall_version":{"data":{"id":"5DiT3wrGN8OFEL8GnKM4Dr","type":"waf_firewall_version"}},"waf_rule_revision":{"data":{"id":"6ZJML5tsy5uVq1nGNgmZ78","type":"waf_rule_revision"}}}},{"id":"2HkKe5PmWYa1wjgJetq980","type":"waf_active_rule","attributes":{"created_at":"2020-10-07T13:09:09Z","latest_revision":1,"modsec_rule_id":2037405,"outdated":false,"revision":1,"status":"log","updated_at":"2020-10-07T13:09:09Z"},"relationships":{"waf_firewall_version":{"data":{"id":"5DiT3wrGN8OFEL8GnKM4Dr","type":"waf_firewall_version"}},"waf_rule_revision":{"data":{"id":"3ANlv7vVZdzk2qFXlJLIk3","type":"waf_rule_revision"}}}},{"id":"4oebnye6APVjo1fn7RSYhV","type":"waf_active_rule","attributes":{"created_at":"2020-10-07T13:09:09Z","latest_revision":1,"modsec_rule_id":1010070,"outdated":false,"revision":1,"status":"log","updated_at":"2020-10-07T13:09:09Z"},"relationships":{"waf_firewall_version":{"data":{"id":"5DiT3wrGN8OFEL8GnKM4Dr","type":"waf_firewall_version"}},"waf_rule_revision":{"data":{"id":"2qiuFDyJoxuKkKkJYjrgsC","type":"waf_rule_revision"}}}}]}' + body: '{"data":[{"id":"5sVGswVGA0YacH6Jz5o7tq","type":"waf_active_rule","attributes":{"created_at":"2020-10-09T09:28:44Z","latest_revision":1,"modsec_rule_id":2029718,"outdated":false,"revision":1,"status":"log","updated_at":"2020-10-09T09:28:44Z"},"relationships":{"waf_firewall_version":{"data":{"id":"1aS3EW9fdCptX2lLm4CuRV","type":"waf_firewall_version"}},"waf_rule_revision":{"data":{"id":"6ZJML5tsy5uVq1nGNgmZ78","type":"waf_rule_revision"}}}},{"id":"7YwTWHJZk23BrK0Uz1nVwa","type":"waf_active_rule","attributes":{"created_at":"2020-10-09T09:28:44Z","latest_revision":1,"modsec_rule_id":2037405,"outdated":false,"revision":1,"status":"log","updated_at":"2020-10-09T09:28:44Z"},"relationships":{"waf_firewall_version":{"data":{"id":"1aS3EW9fdCptX2lLm4CuRV","type":"waf_firewall_version"}},"waf_rule_revision":{"data":{"id":"3ANlv7vVZdzk2qFXlJLIk3","type":"waf_rule_revision"}}}},{"id":"4E6F2jr3bCGmP7ShSi6jTv","type":"waf_active_rule","attributes":{"created_at":"2020-10-09T09:28:44Z","latest_revision":1,"modsec_rule_id":21032607,"outdated":false,"revision":1,"status":"log","updated_at":"2020-10-09T09:28:44Z"},"relationships":{"waf_firewall_version":{"data":{"id":"1aS3EW9fdCptX2lLm4CuRV","type":"waf_firewall_version"}},"waf_rule_revision":{"data":{"id":"168gOasZaIZ1Sr712NJLLn","type":"waf_rule_revision"}}}}]}' headers: Accept-Ranges: - bytes - bytes Content-Length: - - "1312" + - "1313" Content-Type: - application/vnd.api+json Date: - - Wed, 07 Oct 2020 13:09:09 GMT + - Fri, 09 Oct 2020 09:28:44 GMT Status: - 201 Created Strict-Transport-Security: @@ -40,9 +40,9 @@ interactions: X-Content-Type-Options: - nosniff X-Served-By: - - cache-control-slwdc9037-CONTROL-SLWDC, cache-lhr7363-LHR + - cache-control-slwdc9035-CONTROL-SLWDC, cache-lon4257-LON X-Timer: - - S1602076149.046940,VS0,VE320 + - S1602235724.073715,VS0,VE638 status: 201 Created code: 201 duration: "" diff --git a/fastly/fixtures/waf_exclusion/list_filters/response_object/create.yaml b/fastly/fixtures/waf_rule_exclusion/create/response_object/create.yaml similarity index 59% rename from fastly/fixtures/waf_exclusion/list_filters/response_object/create.yaml rename to fastly/fixtures/waf_rule_exclusion/create/response_object/create.yaml index 2e00f197d..9b778fe7e 100644 --- a/fastly/fixtures/waf_exclusion/list_filters/response_object/create.yaml +++ b/fastly/fixtures/waf_rule_exclusion/create/response_object/create.yaml @@ -2,10 +2,10 @@ version: 1 interactions: - request: - body: Service=1JeR1AIjuRcEXA5doHqxPr&Version=2&name=WAf_Response&status=403 + body: Service=0Ez5eLazQudDmMaeJ6sk4A&Version=2&name=WAf_Response&status=403 form: Service: - - 1JeR1AIjuRcEXA5doHqxPr + - 0Ez5eLazQudDmMaeJ6sk4A Version: - "2" name: @@ -17,10 +17,10 @@ interactions: - application/x-www-form-urlencoded User-Agent: - FastlyGo/1.17.0 (+github.com/fastly/go-fastly; go1.14.5) - url: https://api.fastly.com/service/1JeR1AIjuRcEXA5doHqxPr/version/2/response_object + url: https://api.fastly.com/service/0Ez5eLazQudDmMaeJ6sk4A/version/2/response_object method: POST response: - body: '{"name":"WAf_Response","status":"403","service_id":"1JeR1AIjuRcEXA5doHqxPr","version":"2","content":null,"cache_condition":"","content_type":null,"updated_at":"2020-10-07T13:09:08Z","request_condition":"","deleted_at":null,"created_at":"2020-10-07T13:09:08Z","response":"ok"}' + body: '{"name":"WAf_Response","status":"403","service_id":"0Ez5eLazQudDmMaeJ6sk4A","version":"2","created_at":"2020-10-09T09:28:42Z","deleted_at":null,"updated_at":"2020-10-09T09:28:42Z","response":"ok","content":null,"cache_condition":"","request_condition":"","content_type":null}' headers: Accept-Ranges: - bytes @@ -30,11 +30,11 @@ interactions: Content-Type: - application/json Date: - - Wed, 07 Oct 2020 13:09:09 GMT + - Fri, 09 Oct 2020 09:28:42 GMT Fastly-Ratelimit-Remaining: - - "4938" + - "4925" Fastly-Ratelimit-Reset: - - "1602079200" + - "1602237600" Status: - 200 OK Strict-Transport-Security: @@ -49,9 +49,9 @@ interactions: X-Cache-Hits: - 0, 0 X-Served-By: - - cache-control-slwdc9036-CONTROL-SLWDC, cache-lhr7363-LHR + - cache-control-slwdc9035-CONTROL-SLWDC, cache-lon4257-LON X-Timer: - - S1602076149.651672,VS0,VE399 + - S1602235723.651685,VS0,VE232 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/waf_exclusion/update/service/create.yaml b/fastly/fixtures/waf_rule_exclusion/create/service/create.yaml similarity index 67% rename from fastly/fixtures/waf_exclusion/update/service/create.yaml rename to fastly/fixtures/waf_rule_exclusion/create/service/create.yaml index 0c4c4db0f..edf4e8c18 100644 --- a/fastly/fixtures/waf_exclusion/update/service/create.yaml +++ b/fastly/fixtures/waf_rule_exclusion/create/service/create.yaml @@ -18,7 +18,7 @@ interactions: url: https://api.fastly.com/service method: POST response: - body: '{"customer_id":"WpqWFjTA4lk2N1g0GY2HH","comment":"go-fastly client test","name":"test_service_service-4037200794235010051","type":"vcl","versions":[{"created_at":"2020-10-07T13:09:06Z","deleted_at":null,"deployed":false,"locked":false,"service_id":"2Xx48e6pQNCa26prCiwiTG","staging":false,"active":false,"number":1,"testing":false,"updated_at":"2020-10-07T13:09:06Z","comment":""}],"id":"2Xx48e6pQNCa26prCiwiTG","created_at":"2020-10-07T13:09:06Z","deleted_at":null,"publish_key":"","updated_at":"2020-10-07T13:09:06Z"}' + body: '{"customer_id":"WpqWFjTA4lk2N1g0GY2HH","comment":"go-fastly client test","name":"test_service_service-4037200794235010051","type":"vcl","updated_at":"2020-10-09T09:28:40Z","id":"0Ez5eLazQudDmMaeJ6sk4A","versions":[{"service_id":"0Ez5eLazQudDmMaeJ6sk4A","deleted_at":null,"active":false,"number":1,"deployed":false,"locked":false,"created_at":"2020-10-09T09:28:40Z","comment":"","staging":false,"testing":false,"updated_at":"2020-10-09T09:28:40Z"}],"created_at":"2020-10-09T09:28:40Z","publish_key":"","deleted_at":null}' headers: Accept-Ranges: - bytes @@ -28,11 +28,11 @@ interactions: Content-Type: - application/json Date: - - Wed, 07 Oct 2020 13:09:06 GMT + - Fri, 09 Oct 2020 09:28:40 GMT Fastly-Ratelimit-Remaining: - - "4951" + - "4934" Fastly-Ratelimit-Reset: - - "1602079200" + - "1602237600" Status: - 200 OK Strict-Transport-Security: @@ -47,9 +47,9 @@ interactions: X-Cache-Hits: - 0, 0 X-Served-By: - - cache-control-slwdc9037-CONTROL-SLWDC, cache-lhr7363-LHR + - cache-control-slwdc9035-CONTROL-SLWDC, cache-lon4257-LON X-Timer: - - S1602076146.399238,VS0,VE466 + - S1602235720.463730,VS0,VE489 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/waf_exclusion/list/service/delete.yaml b/fastly/fixtures/waf_rule_exclusion/create/service/delete.yaml similarity index 76% rename from fastly/fixtures/waf_exclusion/list/service/delete.yaml rename to fastly/fixtures/waf_rule_exclusion/create/service/delete.yaml index 8b28684e6..58691a9d9 100644 --- a/fastly/fixtures/waf_exclusion/list/service/delete.yaml +++ b/fastly/fixtures/waf_rule_exclusion/create/service/delete.yaml @@ -7,7 +7,7 @@ interactions: headers: User-Agent: - FastlyGo/1.17.0 (+github.com/fastly/go-fastly; go1.14.5) - url: https://api.fastly.com/service/2tqox6DHGJMOXYH4nYZqgN + url: https://api.fastly.com/service/0Ez5eLazQudDmMaeJ6sk4A method: DELETE response: body: '{"status":"ok"}' @@ -20,11 +20,11 @@ interactions: Content-Type: - application/json Date: - - Wed, 07 Oct 2020 13:09:10 GMT + - Fri, 09 Oct 2020 09:28:46 GMT Fastly-Ratelimit-Remaining: - - "4936" + - "4920" Fastly-Ratelimit-Reset: - - "1602079200" + - "1602237600" Status: - 200 OK Strict-Transport-Security: @@ -39,9 +39,9 @@ interactions: X-Cache-Hits: - 0, 0 X-Served-By: - - cache-control-slwdc9037-CONTROL-SLWDC, cache-lhr7363-LHR + - cache-control-slwdc9037-CONTROL-SLWDC, cache-lon4257-LON X-Timer: - - S1602076151.681556,VS0,VE254 + - S1602235726.804323,VS0,VE212 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/waf_exclusion/create/service/version.yaml b/fastly/fixtures/waf_rule_exclusion/create/service/version.yaml similarity index 68% rename from fastly/fixtures/waf_exclusion/create/service/version.yaml rename to fastly/fixtures/waf_rule_exclusion/create/service/version.yaml index ee9ccd081..4ab3d6530 100644 --- a/fastly/fixtures/waf_exclusion/create/service/version.yaml +++ b/fastly/fixtures/waf_rule_exclusion/create/service/version.yaml @@ -2,19 +2,19 @@ version: 1 interactions: - request: - body: Service=5ZTGLKH5LoWkfPUSAv1w6X + body: Service=0Ez5eLazQudDmMaeJ6sk4A form: Service: - - 5ZTGLKH5LoWkfPUSAv1w6X + - 0Ez5eLazQudDmMaeJ6sk4A headers: Content-Type: - application/x-www-form-urlencoded User-Agent: - FastlyGo/1.17.0 (+github.com/fastly/go-fastly; go1.14.5) - url: https://api.fastly.com/service/5ZTGLKH5LoWkfPUSAv1w6X/version + url: https://api.fastly.com/service/0Ez5eLazQudDmMaeJ6sk4A/version method: POST response: - body: '{"service_id":"5ZTGLKH5LoWkfPUSAv1w6X","number":2}' + body: '{"service_id":"0Ez5eLazQudDmMaeJ6sk4A","number":2}' headers: Accept-Ranges: - bytes @@ -24,11 +24,11 @@ interactions: Content-Type: - application/json Date: - - Wed, 07 Oct 2020 13:09:07 GMT + - Fri, 09 Oct 2020 09:28:42 GMT Fastly-Ratelimit-Remaining: - - "4946" + - "4926" Fastly-Ratelimit-Reset: - - "1602079200" + - "1602237600" Status: - 200 OK Strict-Transport-Security: @@ -43,9 +43,9 @@ interactions: X-Cache-Hits: - 0, 0 X-Served-By: - - cache-control-slwdc9036-CONTROL-SLWDC, cache-lhr7363-LHR + - cache-control-slwdc9037-CONTROL-SLWDC, cache-lon4257-LON X-Timer: - - S1602076147.213445,VS0,VE229 + - S1602235722.039906,VS0,VE516 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/waf_exclusion/delete/waf/create.yaml b/fastly/fixtures/waf_rule_exclusion/create/waf/create.yaml similarity index 71% rename from fastly/fixtures/waf_exclusion/delete/waf/create.yaml rename to fastly/fixtures/waf_rule_exclusion/create/waf/create.yaml index f6f1999d2..a44829ff8 100644 --- a/fastly/fixtures/waf_exclusion/delete/waf/create.yaml +++ b/fastly/fixtures/waf_rule_exclusion/create/waf/create.yaml @@ -3,7 +3,7 @@ version: 1 interactions: - request: body: | - {"data":{"type":"waf_firewall","attributes":{"prefetch_condition":"","response":"WAf_Response","service_id":"4j5iMcheZDNpEMiwjnYh8K","service_version_number":"2"}}} + {"data":{"type":"waf_firewall","attributes":{"prefetch_condition":"","response":"WAf_Response","service_id":"0Ez5eLazQudDmMaeJ6sk4A","service_version_number":"2"}}} form: {} headers: Accept: @@ -15,7 +15,7 @@ interactions: url: https://api.fastly.com/waf/firewalls method: POST response: - body: '{"data":{"id":"3wsTANvXfIbxSOd5GUpqQf","type":"waf_firewall","attributes":{"active_rules_fastly_block_count":0,"active_rules_fastly_log_count":0,"active_rules_fastly_score_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_score_count":0,"active_rules_trustwave_block_count":0,"active_rules_trustwave_log_count":0,"created_at":"2020-10-07T13:09:08Z","disabled":false,"prefetch_condition":"","response":"WAf_Response","service_id":"4j5iMcheZDNpEMiwjnYh8K","service_version_number":2,"updated_at":"2020-10-07T13:09:08Z"}}}' + body: '{"data":{"id":"4AGLf45qntIRxH9l9fkdBe","type":"waf_firewall","attributes":{"active_rules_fastly_block_count":0,"active_rules_fastly_log_count":0,"active_rules_fastly_score_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_score_count":0,"active_rules_trustwave_block_count":0,"active_rules_trustwave_log_count":0,"created_at":"2020-10-09T09:28:43Z","disabled":false,"prefetch_condition":"","response":"WAf_Response","service_id":"0Ez5eLazQudDmMaeJ6sk4A","service_version_number":2,"updated_at":"2020-10-09T09:28:43Z"}}}' headers: Accept-Ranges: - bytes @@ -25,7 +25,7 @@ interactions: Content-Type: - application/vnd.api+json Date: - - Wed, 07 Oct 2020 13:09:08 GMT + - Fri, 09 Oct 2020 09:28:44 GMT Status: - 201 Created Strict-Transport-Security: @@ -40,9 +40,9 @@ interactions: X-Content-Type-Options: - nosniff X-Served-By: - - cache-control-slwdc9037-CONTROL-SLWDC, cache-lhr7363-LHR + - cache-control-slwdc9037-CONTROL-SLWDC, cache-lon4257-LON X-Timer: - - S1602076148.510756,VS0,VE1275 + - S1602235723.967657,VS0,VE1049 status: 201 Created code: 201 duration: "" diff --git a/fastly/fixtures/waf_exclusion/delete/waf/delete.yaml b/fastly/fixtures/waf_rule_exclusion/create/waf/delete.yaml similarity index 69% rename from fastly/fixtures/waf_exclusion/delete/waf/delete.yaml rename to fastly/fixtures/waf_rule_exclusion/create/waf/delete.yaml index 5968a7f48..ae124b708 100644 --- a/fastly/fixtures/waf_exclusion/delete/waf/delete.yaml +++ b/fastly/fixtures/waf_rule_exclusion/create/waf/delete.yaml @@ -3,7 +3,7 @@ version: 1 interactions: - request: body: | - {"data":{"type":"waf_firewall","id":"3wsTANvXfIbxSOd5GUpqQf","attributes":{"service_version_number":"1"}}} + {"data":{"type":"waf_firewall","id":"4AGLf45qntIRxH9l9fkdBe","attributes":{"service_version_number":"1"}}} form: {} headers: Accept: @@ -12,7 +12,7 @@ interactions: - application/vnd.api+json User-Agent: - FastlyGo/1.17.0 (+github.com/fastly/go-fastly; go1.14.5) - url: https://api.fastly.com/waf/firewalls/3wsTANvXfIbxSOd5GUpqQf + url: https://api.fastly.com/waf/firewalls/4AGLf45qntIRxH9l9fkdBe method: DELETE response: body: "" @@ -21,7 +21,7 @@ interactions: - bytes - bytes Date: - - Wed, 07 Oct 2020 13:09:10 GMT + - Fri, 09 Oct 2020 09:28:45 GMT Status: - 204 No Content Strict-Transport-Security: @@ -36,9 +36,9 @@ interactions: X-Content-Type-Options: - nosniff X-Served-By: - - cache-control-slwdc9036-CONTROL-SLWDC, cache-lhr7363-LHR + - cache-control-slwdc9035-CONTROL-SLWDC, cache-lon4257-LON X-Timer: - - S1602076150.302674,VS0,VE385 + - S1602235725.226941,VS0,VE513 status: 204 No Content code: 204 duration: "" diff --git a/fastly/fixtures/waf_exclusion/delete/waf_exclusions/create.yaml b/fastly/fixtures/waf_rule_exclusion/create/waf_rule_exclusions/create.yaml similarity index 67% rename from fastly/fixtures/waf_exclusion/delete/waf_exclusions/create.yaml rename to fastly/fixtures/waf_rule_exclusion/create/waf_rule_exclusions/create.yaml index f4c7e6056..5c36cfe7c 100644 --- a/fastly/fixtures/waf_exclusion/delete/waf_exclusions/create.yaml +++ b/fastly/fixtures/waf_rule_exclusion/create/waf_rule_exclusions/create.yaml @@ -3,7 +3,7 @@ version: 1 interactions: - request: body: | - {"data":{"type":"waf_exclusion","attributes":{"condition":"req.url.basename == \"index.html\"","exclusion_type":"rule","name":"index page","number":null},"relationships":{"waf_rules":{"data":[{"type":"waf_rule","id":"2029718"},{"type":"waf_rule","id":"2037405"}]}}},"included":[{"type":"waf_rule","id":"2029718","attributes":{"modsec_rule_id":2029718}},{"type":"waf_rule","id":"2037405","attributes":{"modsec_rule_id":2037405}}]} + {"data":{"type":"waf_exclusion","attributes":{"condition":"req.url.basename == \"index.html\"","exclusion_type":"rule","name":"index page","number":null},"relationships":{"waf_rules":{"data":[{"type":"waf_rule","id":"2029718"},{"type":"waf_rule","id":"2037405"}]}}},"included":[{"type":"waf_rule","id":"2037405","attributes":{"modsec_rule_id":2037405}},{"type":"waf_rule","id":"2029718","attributes":{"modsec_rule_id":2029718}}]} form: {} headers: Accept: @@ -12,11 +12,11 @@ interactions: - application/vnd.api+json User-Agent: - FastlyGo/1.17.0 (+github.com/fastly/go-fastly; go1.14.5) - url: https://api.fastly.com/waf/firewalls/3wsTANvXfIbxSOd5GUpqQf/versions/1/exclusions + url: https://api.fastly.com/waf/firewalls/4AGLf45qntIRxH9l9fkdBe/versions/1/exclusions method: POST response: - body: '{"data":{"id":"4QHUnacVJDGp13EJmos89K","type":"waf_exclusion","attributes":{"created_at":"2020-10-07T13:09:09Z","exclusion_type":"rule","condition":"req.url.basename - == \"index.html\"","name":"index page","number":1,"updated_at":"2020-10-07T13:09:09Z"},"relationships":{"waf_rules":{"data":[{"id":"1YveWU8qwEYidE8WAiZqCN","type":"waf_rule"},{"id":"VovV0PIWJCm33k1piDpnX","type":"waf_rule"}]}}}}' + body: '{"data":{"id":"1NkzJ4Y136Ns4zk1fjWAlU","type":"waf_exclusion","attributes":{"created_at":"2020-10-09T09:28:44Z","exclusion_type":"rule","condition":"req.url.basename + == \"index.html\"","name":"index page","number":1,"updated_at":"2020-10-09T09:28:44Z"},"relationships":{"waf_rules":{"data":[{"id":"1YveWU8qwEYidE8WAiZqCN","type":"waf_rule"},{"id":"VovV0PIWJCm33k1piDpnX","type":"waf_rule"}]}}}}' headers: Accept-Ranges: - bytes @@ -26,7 +26,7 @@ interactions: Content-Type: - application/vnd.api+json Date: - - Wed, 07 Oct 2020 13:09:09 GMT + - Fri, 09 Oct 2020 09:28:44 GMT Status: - 201 Created Strict-Transport-Security: @@ -41,9 +41,9 @@ interactions: X-Content-Type-Options: - nosniff X-Served-By: - - cache-control-slwdc9036-CONTROL-SLWDC, cache-lhr7363-LHR + - cache-control-slwdc9037-CONTROL-SLWDC, cache-lon4257-LON X-Timer: - - S1602076149.426628,VS0,VE136 + - S1602235725.768216,VS0,VE152 status: 201 Created code: 201 duration: "" diff --git a/fastly/fixtures/waf_exclusion/create/waf_exclusions/list.yaml b/fastly/fixtures/waf_rule_exclusion/create/waf_rule_exclusions/list.yaml similarity index 68% rename from fastly/fixtures/waf_exclusion/create/waf_exclusions/list.yaml rename to fastly/fixtures/waf_rule_exclusion/create/waf_rule_exclusions/list.yaml index 31afb40e3..06dcc0b10 100644 --- a/fastly/fixtures/waf_exclusion/create/waf_exclusions/list.yaml +++ b/fastly/fixtures/waf_rule_exclusion/create/waf_rule_exclusions/list.yaml @@ -7,11 +7,11 @@ interactions: headers: User-Agent: - FastlyGo/1.17.0 (+github.com/fastly/go-fastly; go1.14.5) - url: https://api.fastly.com/waf/firewalls/0PJDTfXzU9F4KsTErnB41h/versions/1/exclusions?include=waf_rules&page%5Bnumber%5D=1&page%5Bsize%5D=100 + url: https://api.fastly.com/waf/firewalls/4AGLf45qntIRxH9l9fkdBe/versions/1/exclusions?include=waf_rules&page%5Bnumber%5D=1&page%5Bsize%5D=100 method: GET response: - body: '{"data":[{"id":"1pyqLOEXniQ7MDp6CU7nc2","type":"waf_exclusion","attributes":{"created_at":"2020-10-07T13:09:09Z","exclusion_type":"rule","condition":"req.url.basename - == \"index.html\"","name":"index page","number":1,"updated_at":"2020-10-07T13:09:09Z"},"relationships":{"waf_rules":{"data":[{"id":"1YveWU8qwEYidE8WAiZqCN","type":"waf_rule"},{"id":"VovV0PIWJCm33k1piDpnX","type":"waf_rule"}]}}}],"included":[{"id":"1YveWU8qwEYidE8WAiZqCN","type":"waf_rule","attributes":{"modsec_rule_id":2029718,"publisher":"trustwave","type":"strict"}},{"id":"VovV0PIWJCm33k1piDpnX","type":"waf_rule","attributes":{"modsec_rule_id":2037405,"publisher":"trustwave","type":"strict"}}],"links":{"last":"https://api.fastly.com/waf/firewalls/0PJDTfXzU9F4KsTErnB41h/versions/1/exclusions?include=waf_rules\u0026page[number]=1\u0026page[size]=100","first":"https://api.fastly.com/waf/firewalls/0PJDTfXzU9F4KsTErnB41h/versions/1/exclusions?include=waf_rules\u0026page[number]=1\u0026page[size]=100"},"meta":{"current_page":1,"per_page":100,"record_count":1,"total_pages":1}}' + body: '{"data":[{"id":"1NkzJ4Y136Ns4zk1fjWAlU","type":"waf_exclusion","attributes":{"created_at":"2020-10-09T09:28:44Z","exclusion_type":"rule","condition":"req.url.basename + == \"index.html\"","name":"index page","number":1,"updated_at":"2020-10-09T09:28:44Z"},"relationships":{"waf_rules":{"data":[{"id":"1YveWU8qwEYidE8WAiZqCN","type":"waf_rule"},{"id":"VovV0PIWJCm33k1piDpnX","type":"waf_rule"}]}}}],"included":[{"id":"1YveWU8qwEYidE8WAiZqCN","type":"waf_rule","attributes":{"modsec_rule_id":2029718,"publisher":"trustwave","type":"strict"}},{"id":"VovV0PIWJCm33k1piDpnX","type":"waf_rule","attributes":{"modsec_rule_id":2037405,"publisher":"trustwave","type":"strict"}}],"links":{"last":"https://api.fastly.com/waf/firewalls/4AGLf45qntIRxH9l9fkdBe/versions/1/exclusions?include=waf_rules\u0026page[number]=1\u0026page[size]=100","first":"https://api.fastly.com/waf/firewalls/4AGLf45qntIRxH9l9fkdBe/versions/1/exclusions?include=waf_rules\u0026page[number]=1\u0026page[size]=100"},"meta":{"current_page":1,"per_page":100,"record_count":1,"total_pages":1}}' headers: Accept-Ranges: - bytes @@ -25,7 +25,7 @@ interactions: Content-Type: - application/vnd.api+json Date: - - Wed, 07 Oct 2020 13:09:09 GMT + - Fri, 09 Oct 2020 09:28:45 GMT Status: - 200 OK Strict-Transport-Security: @@ -40,9 +40,9 @@ interactions: X-Content-Type-Options: - nosniff X-Served-By: - - cache-control-slwdc9036-CONTROL-SLWDC, cache-lhr7363-LHR + - cache-control-slwdc9035-CONTROL-SLWDC, cache-lon4257-LON X-Timer: - - S1602076150.659102,VS0,VE148 + - S1602235725.976448,VS0,VE202 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/waf_rule_exclusion/delete/active_rules/create.yaml b/fastly/fixtures/waf_rule_exclusion/delete/active_rules/create.yaml new file mode 100644 index 000000000..1870d40bf --- /dev/null +++ b/fastly/fixtures/waf_rule_exclusion/delete/active_rules/create.yaml @@ -0,0 +1,48 @@ +--- +version: 1 +interactions: +- request: + body: | + {"data":[{"type":"waf_active_rule","attributes":{"modsec_rule_id":2029718,"revision":1,"status":"log"}},{"type":"waf_active_rule","attributes":{"modsec_rule_id":2037405,"revision":1,"status":"log"}},{"type":"waf_active_rule","attributes":{"modsec_rule_id":21032607,"revision":1,"status":"log"}}]} + form: {} + headers: + Accept: + - application/vnd.api+json; ext=bulk + Content-Type: + - application/vnd.api+json; ext=bulk + User-Agent: + - FastlyGo/1.17.0 (+github.com/fastly/go-fastly; go1.14.5) + url: https://api.fastly.com/waf/firewalls/5GwUC4LSY4l2M7dHJEFHzz/versions/1/active-rules + method: POST + response: + body: '{"data":[{"id":"1zWiNi4XCtdsSdlXzJ6aBz","type":"waf_active_rule","attributes":{"created_at":"2020-10-09T09:28:43Z","latest_revision":1,"modsec_rule_id":2029718,"outdated":false,"revision":1,"status":"log","updated_at":"2020-10-09T09:28:43Z"},"relationships":{"waf_firewall_version":{"data":{"id":"60xJCZdE0yoNXVhbxi7tOS","type":"waf_firewall_version"}},"waf_rule_revision":{"data":{"id":"6ZJML5tsy5uVq1nGNgmZ78","type":"waf_rule_revision"}}}},{"id":"mZC3pB1Q03ngWgitRFzHo","type":"waf_active_rule","attributes":{"created_at":"2020-10-09T09:28:43Z","latest_revision":1,"modsec_rule_id":2037405,"outdated":false,"revision":1,"status":"log","updated_at":"2020-10-09T09:28:43Z"},"relationships":{"waf_firewall_version":{"data":{"id":"60xJCZdE0yoNXVhbxi7tOS","type":"waf_firewall_version"}},"waf_rule_revision":{"data":{"id":"3ANlv7vVZdzk2qFXlJLIk3","type":"waf_rule_revision"}}}},{"id":"70Gnu0DoTCFvx48szOEhCd","type":"waf_active_rule","attributes":{"created_at":"2020-10-09T09:28:43Z","latest_revision":1,"modsec_rule_id":21032607,"outdated":false,"revision":1,"status":"log","updated_at":"2020-10-09T09:28:43Z"},"relationships":{"waf_firewall_version":{"data":{"id":"60xJCZdE0yoNXVhbxi7tOS","type":"waf_firewall_version"}},"waf_rule_revision":{"data":{"id":"168gOasZaIZ1Sr712NJLLn","type":"waf_rule_revision"}}}}]}' + headers: + Accept-Ranges: + - bytes + - bytes + Content-Length: + - "1312" + Content-Type: + - application/vnd.api+json + Date: + - Fri, 09 Oct 2020 09:28:43 GMT + Status: + - 201 Created + Strict-Transport-Security: + - max-age=31536000 + Via: + - 1.1 varnish + - 1.1 varnish + X-Cache: + - MISS, MISS + X-Cache-Hits: + - 0, 0 + X-Content-Type-Options: + - nosniff + X-Served-By: + - cache-control-slwdc9035-CONTROL-SLWDC, cache-lon4257-LON + X-Timer: + - S1602235724.535717,VS0,VE133 + status: 201 Created + code: 201 + duration: "" diff --git a/fastly/fixtures/waf_exclusion/create/response_object/create.yaml b/fastly/fixtures/waf_rule_exclusion/delete/response_object/create.yaml similarity index 64% rename from fastly/fixtures/waf_exclusion/create/response_object/create.yaml rename to fastly/fixtures/waf_rule_exclusion/delete/response_object/create.yaml index 80e21cc53..10ad9475c 100644 --- a/fastly/fixtures/waf_exclusion/create/response_object/create.yaml +++ b/fastly/fixtures/waf_rule_exclusion/delete/response_object/create.yaml @@ -2,10 +2,10 @@ version: 1 interactions: - request: - body: Service=5ZTGLKH5LoWkfPUSAv1w6X&Version=2&name=WAf_Response&status=403 + body: Service=5Ixrj1XHCwMMbvaoKf8Kou&Version=2&name=WAf_Response&status=403 form: Service: - - 5ZTGLKH5LoWkfPUSAv1w6X + - 5Ixrj1XHCwMMbvaoKf8Kou Version: - "2" name: @@ -17,10 +17,10 @@ interactions: - application/x-www-form-urlencoded User-Agent: - FastlyGo/1.17.0 (+github.com/fastly/go-fastly; go1.14.5) - url: https://api.fastly.com/service/5ZTGLKH5LoWkfPUSAv1w6X/version/2/response_object + url: https://api.fastly.com/service/5Ixrj1XHCwMMbvaoKf8Kou/version/2/response_object method: POST response: - body: '{"name":"WAf_Response","status":"403","service_id":"5ZTGLKH5LoWkfPUSAv1w6X","version":"2","created_at":"2020-10-07T13:09:07Z","response":"ok","cache_condition":"","deleted_at":null,"content":null,"request_condition":"","content_type":null,"updated_at":"2020-10-07T13:09:07Z"}' + body: '{"name":"WAf_Response","status":"403","service_id":"5Ixrj1XHCwMMbvaoKf8Kou","version":"2","request_condition":"","response":"ok","created_at":"2020-10-09T09:28:41Z","cache_condition":"","content":null,"deleted_at":null,"updated_at":"2020-10-09T09:28:41Z","content_type":null}' headers: Accept-Ranges: - bytes @@ -30,11 +30,11 @@ interactions: Content-Type: - application/json Date: - - Wed, 07 Oct 2020 13:09:07 GMT + - Fri, 09 Oct 2020 09:28:42 GMT Fastly-Ratelimit-Remaining: - - "4944" + - "4928" Fastly-Ratelimit-Reset: - - "1602079200" + - "1602237600" Status: - 200 OK Strict-Transport-Security: @@ -49,9 +49,9 @@ interactions: X-Cache-Hits: - 0, 0 X-Served-By: - - cache-control-slwdc9035-CONTROL-SLWDC, cache-lhr7363-LHR + - cache-control-slwdc9037-CONTROL-SLWDC, cache-lon4257-LON X-Timer: - - S1602076148.510773,VS0,VE209 + - S1602235722.579885,VS0,VE459 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/waf_exclusion/list_filters/service/create.yaml b/fastly/fixtures/waf_rule_exclusion/delete/service/create.yaml similarity index 67% rename from fastly/fixtures/waf_exclusion/list_filters/service/create.yaml rename to fastly/fixtures/waf_rule_exclusion/delete/service/create.yaml index bcd52b7ab..6d17199a7 100644 --- a/fastly/fixtures/waf_exclusion/list_filters/service/create.yaml +++ b/fastly/fixtures/waf_rule_exclusion/delete/service/create.yaml @@ -18,7 +18,7 @@ interactions: url: https://api.fastly.com/service method: POST response: - body: '{"customer_id":"WpqWFjTA4lk2N1g0GY2HH","comment":"go-fastly client test","name":"test_service_service-8674665223082153551","type":"vcl","created_at":"2020-10-07T13:09:06Z","updated_at":"2020-10-07T13:09:06Z","publish_key":"","deleted_at":null,"versions":[{"deployed":false,"locked":false,"service_id":"1JeR1AIjuRcEXA5doHqxPr","number":1,"updated_at":"2020-10-07T13:09:06Z","created_at":"2020-10-07T13:09:06Z","active":false,"deleted_at":null,"staging":false,"comment":"","testing":false}],"id":"1JeR1AIjuRcEXA5doHqxPr"}' + body: '{"customer_id":"WpqWFjTA4lk2N1g0GY2HH","comment":"go-fastly client test","name":"test_service_service-8674665223082153551","type":"vcl","id":"5Ixrj1XHCwMMbvaoKf8Kou","deleted_at":null,"created_at":"2020-10-09T09:28:40Z","versions":[{"active":false,"deployed":false,"updated_at":"2020-10-09T09:28:40Z","created_at":"2020-10-09T09:28:40Z","service_id":"5Ixrj1XHCwMMbvaoKf8Kou","testing":false,"comment":"","staging":false,"deleted_at":null,"number":1,"locked":false}],"updated_at":"2020-10-09T09:28:40Z","publish_key":""}' headers: Accept-Ranges: - bytes @@ -28,11 +28,11 @@ interactions: Content-Type: - application/json Date: - - Wed, 07 Oct 2020 13:09:06 GMT + - Fri, 09 Oct 2020 09:28:40 GMT Fastly-Ratelimit-Remaining: - - "4948" + - "4937" Fastly-Ratelimit-Reset: - - "1602079200" + - "1602237600" Status: - 200 OK Strict-Transport-Security: @@ -47,9 +47,9 @@ interactions: X-Cache-Hits: - 0, 0 X-Served-By: - - cache-control-slwdc9036-CONTROL-SLWDC, cache-lhr7363-LHR + - cache-control-slwdc9037-CONTROL-SLWDC, cache-lon4257-LON X-Timer: - - S1602076146.399232,VS0,VE493 + - S1602235720.463671,VS0,VE252 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/waf_exclusion/delete/service/delete.yaml b/fastly/fixtures/waf_rule_exclusion/delete/service/delete.yaml similarity index 76% rename from fastly/fixtures/waf_exclusion/delete/service/delete.yaml rename to fastly/fixtures/waf_rule_exclusion/delete/service/delete.yaml index 587e7d399..7762f9166 100644 --- a/fastly/fixtures/waf_exclusion/delete/service/delete.yaml +++ b/fastly/fixtures/waf_rule_exclusion/delete/service/delete.yaml @@ -7,7 +7,7 @@ interactions: headers: User-Agent: - FastlyGo/1.17.0 (+github.com/fastly/go-fastly; go1.14.5) - url: https://api.fastly.com/service/4j5iMcheZDNpEMiwjnYh8K + url: https://api.fastly.com/service/5Ixrj1XHCwMMbvaoKf8Kou method: DELETE response: body: '{"status":"ok"}' @@ -20,11 +20,11 @@ interactions: Content-Type: - application/json Date: - - Wed, 07 Oct 2020 13:09:11 GMT + - Fri, 09 Oct 2020 09:28:45 GMT Fastly-Ratelimit-Remaining: - - "4935" + - "4922" Fastly-Ratelimit-Reset: - - "1602079200" + - "1602237600" Status: - 200 OK Strict-Transport-Security: @@ -39,9 +39,9 @@ interactions: X-Cache-Hits: - 0, 0 X-Served-By: - - cache-control-slwdc9037-CONTROL-SLWDC, cache-lhr7363-LHR + - cache-control-slwdc9037-CONTROL-SLWDC, cache-lon4257-LON X-Timer: - - S1602076151.749556,VS0,VE271 + - S1602235725.724310,VS0,VE296 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/waf_exclusion/list/service/version.yaml b/fastly/fixtures/waf_rule_exclusion/delete/service/version.yaml similarity index 68% rename from fastly/fixtures/waf_exclusion/list/service/version.yaml rename to fastly/fixtures/waf_rule_exclusion/delete/service/version.yaml index c04c1e598..f9e1fd380 100644 --- a/fastly/fixtures/waf_exclusion/list/service/version.yaml +++ b/fastly/fixtures/waf_rule_exclusion/delete/service/version.yaml @@ -2,19 +2,19 @@ version: 1 interactions: - request: - body: Service=2tqox6DHGJMOXYH4nYZqgN + body: Service=5Ixrj1XHCwMMbvaoKf8Kou form: Service: - - 2tqox6DHGJMOXYH4nYZqgN + - 5Ixrj1XHCwMMbvaoKf8Kou headers: Content-Type: - application/x-www-form-urlencoded User-Agent: - FastlyGo/1.17.0 (+github.com/fastly/go-fastly; go1.14.5) - url: https://api.fastly.com/service/2tqox6DHGJMOXYH4nYZqgN/version + url: https://api.fastly.com/service/5Ixrj1XHCwMMbvaoKf8Kou/version method: POST response: - body: '{"service_id":"2tqox6DHGJMOXYH4nYZqgN","number":2}' + body: '{"service_id":"5Ixrj1XHCwMMbvaoKf8Kou","number":2}' headers: Accept-Ranges: - bytes @@ -24,11 +24,11 @@ interactions: Content-Type: - application/json Date: - - Wed, 07 Oct 2020 13:09:08 GMT + - Fri, 09 Oct 2020 09:28:41 GMT Fastly-Ratelimit-Remaining: - - "4941" + - "4931" Fastly-Ratelimit-Reset: - - "1602079200" + - "1602237600" Status: - 200 OK Strict-Transport-Security: @@ -43,9 +43,9 @@ interactions: X-Cache-Hits: - 0, 0 X-Served-By: - - cache-control-slwdc9037-CONTROL-SLWDC, cache-lhr7363-LHR + - cache-control-slwdc9036-CONTROL-SLWDC, cache-lon4257-LON X-Timer: - - S1602076148.811108,VS0,VE218 + - S1602235721.267362,VS0,VE225 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/waf_exclusion/create/waf/create.yaml b/fastly/fixtures/waf_rule_exclusion/delete/waf/create.yaml similarity index 71% rename from fastly/fixtures/waf_exclusion/create/waf/create.yaml rename to fastly/fixtures/waf_rule_exclusion/delete/waf/create.yaml index a55f5af14..276127c25 100644 --- a/fastly/fixtures/waf_exclusion/create/waf/create.yaml +++ b/fastly/fixtures/waf_rule_exclusion/delete/waf/create.yaml @@ -3,7 +3,7 @@ version: 1 interactions: - request: body: | - {"data":{"type":"waf_firewall","attributes":{"prefetch_condition":"","response":"WAf_Response","service_id":"5ZTGLKH5LoWkfPUSAv1w6X","service_version_number":"2"}}} + {"data":{"type":"waf_firewall","attributes":{"prefetch_condition":"","response":"WAf_Response","service_id":"5Ixrj1XHCwMMbvaoKf8Kou","service_version_number":"2"}}} form: {} headers: Accept: @@ -15,7 +15,7 @@ interactions: url: https://api.fastly.com/waf/firewalls method: POST response: - body: '{"data":{"id":"0PJDTfXzU9F4KsTErnB41h","type":"waf_firewall","attributes":{"active_rules_fastly_block_count":0,"active_rules_fastly_log_count":0,"active_rules_fastly_score_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_score_count":0,"active_rules_trustwave_block_count":0,"active_rules_trustwave_log_count":0,"created_at":"2020-10-07T13:09:08Z","disabled":false,"prefetch_condition":"","response":"WAf_Response","service_id":"5ZTGLKH5LoWkfPUSAv1w6X","service_version_number":2,"updated_at":"2020-10-07T13:09:08Z"}}}' + body: '{"data":{"id":"5GwUC4LSY4l2M7dHJEFHzz","type":"waf_firewall","attributes":{"active_rules_fastly_block_count":0,"active_rules_fastly_log_count":0,"active_rules_fastly_score_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_score_count":0,"active_rules_trustwave_block_count":0,"active_rules_trustwave_log_count":0,"created_at":"2020-10-09T09:28:43Z","disabled":false,"prefetch_condition":"","response":"WAf_Response","service_id":"5Ixrj1XHCwMMbvaoKf8Kou","service_version_number":2,"updated_at":"2020-10-09T09:28:43Z"}}}' headers: Accept-Ranges: - bytes @@ -25,7 +25,7 @@ interactions: Content-Type: - application/vnd.api+json Date: - - Wed, 07 Oct 2020 13:09:08 GMT + - Fri, 09 Oct 2020 09:28:43 GMT Status: - 201 Created Strict-Transport-Security: @@ -40,9 +40,9 @@ interactions: X-Content-Type-Options: - nosniff X-Served-By: - - cache-control-slwdc9035-CONTROL-SLWDC, cache-lhr7363-LHR + - cache-control-slwdc9037-CONTROL-SLWDC, cache-lon4257-LON X-Timer: - - S1602076148.811138,VS0,VE1146 + - S1602235722.104538,VS0,VE1324 status: 201 Created code: 201 duration: "" diff --git a/fastly/fixtures/waf_exclusion/create/waf/delete.yaml b/fastly/fixtures/waf_rule_exclusion/delete/waf/delete.yaml similarity index 69% rename from fastly/fixtures/waf_exclusion/create/waf/delete.yaml rename to fastly/fixtures/waf_rule_exclusion/delete/waf/delete.yaml index b5102a3fc..687f333c2 100644 --- a/fastly/fixtures/waf_exclusion/create/waf/delete.yaml +++ b/fastly/fixtures/waf_rule_exclusion/delete/waf/delete.yaml @@ -3,7 +3,7 @@ version: 1 interactions: - request: body: | - {"data":{"type":"waf_firewall","id":"0PJDTfXzU9F4KsTErnB41h","attributes":{"service_version_number":"1"}}} + {"data":{"type":"waf_firewall","id":"5GwUC4LSY4l2M7dHJEFHzz","attributes":{"service_version_number":"1"}}} form: {} headers: Accept: @@ -12,7 +12,7 @@ interactions: - application/vnd.api+json User-Agent: - FastlyGo/1.17.0 (+github.com/fastly/go-fastly; go1.14.5) - url: https://api.fastly.com/waf/firewalls/0PJDTfXzU9F4KsTErnB41h + url: https://api.fastly.com/waf/firewalls/5GwUC4LSY4l2M7dHJEFHzz method: DELETE response: body: "" @@ -21,7 +21,7 @@ interactions: - bytes - bytes Date: - - Wed, 07 Oct 2020 13:09:10 GMT + - Fri, 09 Oct 2020 09:28:44 GMT Status: - 204 No Content Strict-Transport-Security: @@ -36,9 +36,9 @@ interactions: X-Content-Type-Options: - nosniff X-Served-By: - - cache-control-slwdc9036-CONTROL-SLWDC, cache-lhr7363-LHR + - cache-control-slwdc9035-CONTROL-SLWDC, cache-lon4257-LON X-Timer: - - S1602076150.870875,VS0,VE154 + - S1602235724.364357,VS0,VE315 status: 204 No Content code: 204 duration: "" diff --git a/fastly/fixtures/waf_exclusion/update/waf_exclusions/create.yaml b/fastly/fixtures/waf_rule_exclusion/delete/waf_rule_exclusions/create.yaml similarity index 77% rename from fastly/fixtures/waf_exclusion/update/waf_exclusions/create.yaml rename to fastly/fixtures/waf_rule_exclusion/delete/waf_rule_exclusions/create.yaml index c120a4cb6..1170b50c1 100644 --- a/fastly/fixtures/waf_exclusion/update/waf_exclusions/create.yaml +++ b/fastly/fixtures/waf_rule_exclusion/delete/waf_rule_exclusions/create.yaml @@ -12,11 +12,11 @@ interactions: - application/vnd.api+json User-Agent: - FastlyGo/1.17.0 (+github.com/fastly/go-fastly; go1.14.5) - url: https://api.fastly.com/waf/firewalls/6YqagDC62Z4bIFpsNBzxVm/versions/1/exclusions + url: https://api.fastly.com/waf/firewalls/5GwUC4LSY4l2M7dHJEFHzz/versions/1/exclusions method: POST response: - body: '{"data":{"id":"4eV7U9toc5h0Yqi9Vm1hcN","type":"waf_exclusion","attributes":{"created_at":"2020-10-07T13:09:09Z","exclusion_type":"rule","condition":"req.url.basename - == \"index.html\"","name":"index page","number":1,"updated_at":"2020-10-07T13:09:09Z"},"relationships":{"waf_rules":{"data":[{"id":"1YveWU8qwEYidE8WAiZqCN","type":"waf_rule"},{"id":"VovV0PIWJCm33k1piDpnX","type":"waf_rule"}]}}}}' + body: '{"data":{"id":"6DDse6tF39VQFMlN9PaDTx","type":"waf_exclusion","attributes":{"created_at":"2020-10-09T09:28:43Z","exclusion_type":"rule","condition":"req.url.basename + == \"index.html\"","name":"index page","number":1,"updated_at":"2020-10-09T09:28:43Z"},"relationships":{"waf_rules":{"data":[{"id":"1YveWU8qwEYidE8WAiZqCN","type":"waf_rule"},{"id":"VovV0PIWJCm33k1piDpnX","type":"waf_rule"}]}}}}' headers: Accept-Ranges: - bytes @@ -26,7 +26,7 @@ interactions: Content-Type: - application/vnd.api+json Date: - - Wed, 07 Oct 2020 13:09:10 GMT + - Fri, 09 Oct 2020 09:28:43 GMT Status: - 201 Created Strict-Transport-Security: @@ -41,9 +41,9 @@ interactions: X-Content-Type-Options: - nosniff X-Served-By: - - cache-control-slwdc9035-CONTROL-SLWDC, cache-lhr7363-LHR + - cache-control-slwdc9036-CONTROL-SLWDC, cache-lon4257-LON X-Timer: - - S1602076150.870902,VS0,VE153 + - S1602235724.710494,VS0,VE132 status: 201 Created code: 201 duration: "" diff --git a/fastly/fixtures/waf_exclusion/delete/waf_exclusions/list.yaml b/fastly/fixtures/waf_rule_exclusion/delete/waf_rule_exclusions/list.yaml similarity index 72% rename from fastly/fixtures/waf_exclusion/delete/waf_exclusions/list.yaml rename to fastly/fixtures/waf_rule_exclusion/delete/waf_rule_exclusions/list.yaml index 969a15880..7089fcaff 100644 --- a/fastly/fixtures/waf_exclusion/delete/waf_exclusions/list.yaml +++ b/fastly/fixtures/waf_rule_exclusion/delete/waf_rule_exclusions/list.yaml @@ -7,10 +7,10 @@ interactions: headers: User-Agent: - FastlyGo/1.17.0 (+github.com/fastly/go-fastly; go1.14.5) - url: https://api.fastly.com/waf/firewalls/3wsTANvXfIbxSOd5GUpqQf/versions/1/exclusions?include=waf_rules&page%5Bnumber%5D=1&page%5Bsize%5D=100 + url: https://api.fastly.com/waf/firewalls/5GwUC4LSY4l2M7dHJEFHzz/versions/1/exclusions?include=waf_rules&page%5Bnumber%5D=1&page%5Bsize%5D=100 method: GET response: - body: '{"data":[],"links":{"last":"https://api.fastly.com/waf/firewalls/3wsTANvXfIbxSOd5GUpqQf/versions/1/exclusions?include=waf_rules\u0026page[number]=1\u0026page[size]=100","first":"https://api.fastly.com/waf/firewalls/3wsTANvXfIbxSOd5GUpqQf/versions/1/exclusions?include=waf_rules\u0026page[number]=1\u0026page[size]=100"},"meta":{"current_page":1,"per_page":100,"record_count":0,"total_pages":1}}' + body: '{"data":[],"links":{"last":"https://api.fastly.com/waf/firewalls/5GwUC4LSY4l2M7dHJEFHzz/versions/1/exclusions?include=waf_rules\u0026page[number]=1\u0026page[size]=100","first":"https://api.fastly.com/waf/firewalls/5GwUC4LSY4l2M7dHJEFHzz/versions/1/exclusions?include=waf_rules\u0026page[number]=1\u0026page[size]=100"},"meta":{"current_page":1,"per_page":100,"record_count":0,"total_pages":1}}' headers: Accept-Ranges: - bytes @@ -24,7 +24,7 @@ interactions: Content-Type: - application/vnd.api+json Date: - - Wed, 07 Oct 2020 13:09:10 GMT + - Fri, 09 Oct 2020 09:28:44 GMT Status: - 200 OK Strict-Transport-Security: @@ -39,9 +39,9 @@ interactions: X-Content-Type-Options: - nosniff X-Served-By: - - cache-control-slwdc9037-CONTROL-SLWDC, cache-lhr7363-LHR + - cache-control-slwdc9036-CONTROL-SLWDC, cache-lon4257-LON X-Timer: - - S1602076150.870889,VS0,VE382 + - S1602235724.164346,VS0,VE152 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/waf_exclusion/delete/waf_exclusions/update.yaml b/fastly/fixtures/waf_rule_exclusion/delete/waf_rule_exclusions/update.yaml similarity index 73% rename from fastly/fixtures/waf_exclusion/delete/waf_exclusions/update.yaml rename to fastly/fixtures/waf_rule_exclusion/delete/waf_rule_exclusions/update.yaml index 0e5cac778..e6ea35301 100644 --- a/fastly/fixtures/waf_exclusion/delete/waf_exclusions/update.yaml +++ b/fastly/fixtures/waf_rule_exclusion/delete/waf_rule_exclusions/update.yaml @@ -7,7 +7,7 @@ interactions: headers: User-Agent: - FastlyGo/1.17.0 (+github.com/fastly/go-fastly; go1.14.5) - url: https://api.fastly.com/waf/firewalls/3wsTANvXfIbxSOd5GUpqQf/versions/1/exclusions/1 + url: https://api.fastly.com/waf/firewalls/5GwUC4LSY4l2M7dHJEFHzz/versions/1/exclusions/1 method: DELETE response: body: "" @@ -16,7 +16,7 @@ interactions: - bytes - bytes Date: - - Wed, 07 Oct 2020 13:09:09 GMT + - Fri, 09 Oct 2020 09:28:44 GMT Status: - 204 No Content Strict-Transport-Security: @@ -31,9 +31,9 @@ interactions: X-Content-Type-Options: - nosniff X-Served-By: - - cache-control-slwdc9036-CONTROL-SLWDC, cache-lhr7363-LHR + - cache-control-slwdc9035-CONTROL-SLWDC, cache-lon4257-LON X-Timer: - - S1602076150.611413,VS0,VE171 + - S1602235724.904053,VS0,VE185 status: 204 No Content code: 204 duration: "" diff --git a/fastly/fixtures/waf_rule_exclusion/list/active_rules/create.yaml b/fastly/fixtures/waf_rule_exclusion/list/active_rules/create.yaml new file mode 100644 index 000000000..b5eda8ea0 --- /dev/null +++ b/fastly/fixtures/waf_rule_exclusion/list/active_rules/create.yaml @@ -0,0 +1,48 @@ +--- +version: 1 +interactions: +- request: + body: | + {"data":[{"type":"waf_active_rule","attributes":{"modsec_rule_id":2029718,"revision":1,"status":"log"}},{"type":"waf_active_rule","attributes":{"modsec_rule_id":2037405,"revision":1,"status":"log"}},{"type":"waf_active_rule","attributes":{"modsec_rule_id":21032607,"revision":1,"status":"log"}}]} + form: {} + headers: + Accept: + - application/vnd.api+json; ext=bulk + Content-Type: + - application/vnd.api+json; ext=bulk + User-Agent: + - FastlyGo/1.17.0 (+github.com/fastly/go-fastly; go1.14.5) + url: https://api.fastly.com/waf/firewalls/1YwZnVgr910HP3I8WRlhwE/versions/1/active-rules + method: POST + response: + body: '{"data":[{"id":"2zubObqhJnuNLiIY8VQGds","type":"waf_active_rule","attributes":{"created_at":"2020-10-09T09:28:42Z","latest_revision":1,"modsec_rule_id":2029718,"outdated":false,"revision":1,"status":"log","updated_at":"2020-10-09T09:28:42Z"},"relationships":{"waf_firewall_version":{"data":{"id":"1HWIlriCuj3Kd9ootUm1gf","type":"waf_firewall_version"}},"waf_rule_revision":{"data":{"id":"6ZJML5tsy5uVq1nGNgmZ78","type":"waf_rule_revision"}}}},{"id":"1qQERpkuiTZj7B5iN75Mqs","type":"waf_active_rule","attributes":{"created_at":"2020-10-09T09:28:42Z","latest_revision":1,"modsec_rule_id":2037405,"outdated":false,"revision":1,"status":"log","updated_at":"2020-10-09T09:28:42Z"},"relationships":{"waf_firewall_version":{"data":{"id":"1HWIlriCuj3Kd9ootUm1gf","type":"waf_firewall_version"}},"waf_rule_revision":{"data":{"id":"3ANlv7vVZdzk2qFXlJLIk3","type":"waf_rule_revision"}}}},{"id":"6hym9uAaoVfcipPSCEZZu4","type":"waf_active_rule","attributes":{"created_at":"2020-10-09T09:28:42Z","latest_revision":1,"modsec_rule_id":21032607,"outdated":false,"revision":1,"status":"log","updated_at":"2020-10-09T09:28:42Z"},"relationships":{"waf_firewall_version":{"data":{"id":"1HWIlriCuj3Kd9ootUm1gf","type":"waf_firewall_version"}},"waf_rule_revision":{"data":{"id":"168gOasZaIZ1Sr712NJLLn","type":"waf_rule_revision"}}}}]}' + headers: + Accept-Ranges: + - bytes + - bytes + Content-Length: + - "1313" + Content-Type: + - application/vnd.api+json + Date: + - Fri, 09 Oct 2020 09:28:42 GMT + Status: + - 201 Created + Strict-Transport-Security: + - max-age=31536000 + Via: + - 1.1 varnish + - 1.1 varnish + X-Cache: + - MISS, MISS + X-Cache-Hits: + - 0, 0 + X-Content-Type-Options: + - nosniff + X-Served-By: + - cache-control-slwdc9037-CONTROL-SLWDC, cache-lon4257-LON + X-Timer: + - S1602235722.419621,VS0,VE391 + status: 201 Created + code: 201 + duration: "" diff --git a/fastly/fixtures/waf_exclusion/list/response_object/create.yaml b/fastly/fixtures/waf_rule_exclusion/list/response_object/create.yaml similarity index 64% rename from fastly/fixtures/waf_exclusion/list/response_object/create.yaml rename to fastly/fixtures/waf_rule_exclusion/list/response_object/create.yaml index eb1c6eec4..2078f24f0 100644 --- a/fastly/fixtures/waf_exclusion/list/response_object/create.yaml +++ b/fastly/fixtures/waf_rule_exclusion/list/response_object/create.yaml @@ -2,10 +2,10 @@ version: 1 interactions: - request: - body: Service=2tqox6DHGJMOXYH4nYZqgN&Version=2&name=WAf_Response&status=403 + body: Service=2FcUklM62QkjiO0ErtK9D3&Version=2&name=WAf_Response&status=403 form: Service: - - 2tqox6DHGJMOXYH4nYZqgN + - 2FcUklM62QkjiO0ErtK9D3 Version: - "2" name: @@ -17,10 +17,10 @@ interactions: - application/x-www-form-urlencoded User-Agent: - FastlyGo/1.17.0 (+github.com/fastly/go-fastly; go1.14.5) - url: https://api.fastly.com/service/2tqox6DHGJMOXYH4nYZqgN/version/2/response_object + url: https://api.fastly.com/service/2FcUklM62QkjiO0ErtK9D3/version/2/response_object method: POST response: - body: '{"name":"WAf_Response","status":"403","service_id":"2tqox6DHGJMOXYH4nYZqgN","version":"2","cache_condition":"","updated_at":"2020-10-07T13:09:08Z","response":"ok","created_at":"2020-10-07T13:09:08Z","request_condition":"","content_type":null,"content":null,"deleted_at":null}' + body: '{"name":"WAf_Response","status":"403","service_id":"2FcUklM62QkjiO0ErtK9D3","version":"2","deleted_at":null,"cache_condition":"","request_condition":"","response":"ok","content_type":null,"updated_at":"2020-10-09T09:28:41Z","content":null,"created_at":"2020-10-09T09:28:41Z"}' headers: Accept-Ranges: - bytes @@ -30,11 +30,11 @@ interactions: Content-Type: - application/json Date: - - Wed, 07 Oct 2020 13:09:08 GMT + - Fri, 09 Oct 2020 09:28:41 GMT Fastly-Ratelimit-Remaining: - - "4940" + - "4930" Fastly-Ratelimit-Reset: - - "1602079200" + - "1602237600" Status: - 200 OK Strict-Transport-Security: @@ -49,9 +49,9 @@ interactions: X-Cache-Hits: - 0, 0 X-Served-By: - - cache-control-slwdc9036-CONTROL-SLWDC, cache-lhr7363-LHR + - cache-control-slwdc9035-CONTROL-SLWDC, cache-lon4257-LON X-Timer: - - S1602076148.085221,VS0,VE208 + - S1602235721.267342,VS0,VE228 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/waf_exclusion/create/service/create.yaml b/fastly/fixtures/waf_rule_exclusion/list/service/create.yaml similarity index 67% rename from fastly/fixtures/waf_exclusion/create/service/create.yaml rename to fastly/fixtures/waf_rule_exclusion/list/service/create.yaml index 446a73a73..a35b94d72 100644 --- a/fastly/fixtures/waf_exclusion/create/service/create.yaml +++ b/fastly/fixtures/waf_rule_exclusion/list/service/create.yaml @@ -18,7 +18,7 @@ interactions: url: https://api.fastly.com/service method: POST response: - body: '{"customer_id":"WpqWFjTA4lk2N1g0GY2HH","comment":"go-fastly client test","name":"test_service_service-5577006791947779410","type":"vcl","created_at":"2020-10-07T13:09:06Z","updated_at":"2020-10-07T13:09:06Z","deleted_at":null,"versions":[{"deleted_at":null,"comment":"","testing":false,"locked":false,"active":false,"deployed":false,"service_id":"5ZTGLKH5LoWkfPUSAv1w6X","staging":false,"updated_at":"2020-10-07T13:09:06Z","number":1,"created_at":"2020-10-07T13:09:06Z"}],"publish_key":"","id":"5ZTGLKH5LoWkfPUSAv1w6X"}' + body: '{"customer_id":"WpqWFjTA4lk2N1g0GY2HH","comment":"go-fastly client test","name":"test_service_service-5577006791947779410","type":"vcl","id":"2FcUklM62QkjiO0ErtK9D3","publish_key":"","updated_at":"2020-10-09T09:28:40Z","versions":[{"service_id":"2FcUklM62QkjiO0ErtK9D3","created_at":"2020-10-09T09:28:40Z","number":1,"deleted_at":null,"staging":false,"deployed":false,"updated_at":"2020-10-09T09:28:40Z","locked":false,"testing":false,"active":false,"comment":""}],"deleted_at":null,"created_at":"2020-10-09T09:28:40Z"}' headers: Accept-Ranges: - bytes @@ -28,11 +28,11 @@ interactions: Content-Type: - application/json Date: - - Wed, 07 Oct 2020 13:09:06 GMT + - Fri, 09 Oct 2020 09:28:40 GMT Fastly-Ratelimit-Remaining: - - "4950" + - "4939" Fastly-Ratelimit-Reset: - - "1602079200" + - "1602237600" Status: - 200 OK Strict-Transport-Security: @@ -47,9 +47,9 @@ interactions: X-Cache-Hits: - 0, 0 X-Served-By: - - cache-control-slwdc9037-CONTROL-SLWDC, cache-lhr7363-LHR + - cache-control-slwdc9036-CONTROL-SLWDC, cache-lon4257-LON X-Timer: - - S1602076146.397380,VS0,VE463 + - S1602235720.463677,VS0,VE245 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/waf_exclusion/list_filters/service/delete.yaml b/fastly/fixtures/waf_rule_exclusion/list/service/delete.yaml similarity index 76% rename from fastly/fixtures/waf_exclusion/list_filters/service/delete.yaml rename to fastly/fixtures/waf_rule_exclusion/list/service/delete.yaml index 992881431..9abc6b138 100644 --- a/fastly/fixtures/waf_exclusion/list_filters/service/delete.yaml +++ b/fastly/fixtures/waf_rule_exclusion/list/service/delete.yaml @@ -7,7 +7,7 @@ interactions: headers: User-Agent: - FastlyGo/1.17.0 (+github.com/fastly/go-fastly; go1.14.5) - url: https://api.fastly.com/service/1JeR1AIjuRcEXA5doHqxPr + url: https://api.fastly.com/service/2FcUklM62QkjiO0ErtK9D3 method: DELETE response: body: '{"status":"ok"}' @@ -20,11 +20,11 @@ interactions: Content-Type: - application/json Date: - - Wed, 07 Oct 2020 13:09:12 GMT + - Fri, 09 Oct 2020 09:28:44 GMT Fastly-Ratelimit-Remaining: - - "4933" + - "4924" Fastly-Ratelimit-Reset: - - "1602079200" + - "1602237600" Status: - 200 OK Strict-Transport-Security: @@ -39,9 +39,9 @@ interactions: X-Cache-Hits: - 0, 0 X-Served-By: - - cache-control-slwdc9037-CONTROL-SLWDC, cache-lhr7363-LHR + - cache-control-slwdc9035-CONTROL-SLWDC, cache-lon4257-LON X-Timer: - - S1602076152.021407,VS0,VE246 + - S1602235724.073708,VS0,VE246 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/waf_exclusion/delete/service/version.yaml b/fastly/fixtures/waf_rule_exclusion/list/service/version.yaml similarity index 68% rename from fastly/fixtures/waf_exclusion/delete/service/version.yaml rename to fastly/fixtures/waf_rule_exclusion/list/service/version.yaml index cfd35bd4e..c0c979680 100644 --- a/fastly/fixtures/waf_exclusion/delete/service/version.yaml +++ b/fastly/fixtures/waf_rule_exclusion/list/service/version.yaml @@ -2,19 +2,19 @@ version: 1 interactions: - request: - body: Service=4j5iMcheZDNpEMiwjnYh8K + body: Service=2FcUklM62QkjiO0ErtK9D3 form: Service: - - 4j5iMcheZDNpEMiwjnYh8K + - 2FcUklM62QkjiO0ErtK9D3 headers: Content-Type: - application/x-www-form-urlencoded User-Agent: - FastlyGo/1.17.0 (+github.com/fastly/go-fastly; go1.14.5) - url: https://api.fastly.com/service/4j5iMcheZDNpEMiwjnYh8K/version + url: https://api.fastly.com/service/2FcUklM62QkjiO0ErtK9D3/version method: POST response: - body: '{"service_id":"4j5iMcheZDNpEMiwjnYh8K","number":2}' + body: '{"service_id":"2FcUklM62QkjiO0ErtK9D3","number":2}' headers: Accept-Ranges: - bytes @@ -24,11 +24,11 @@ interactions: Content-Type: - application/json Date: - - Wed, 07 Oct 2020 13:09:07 GMT + - Fri, 09 Oct 2020 09:28:41 GMT Fastly-Ratelimit-Remaining: - - "4947" + - "4933" Fastly-Ratelimit-Reset: - - "1602079200" + - "1602237600" Status: - 200 OK Strict-Transport-Security: @@ -43,9 +43,9 @@ interactions: X-Cache-Hits: - 0, 0 X-Served-By: - - cache-control-slwdc9035-CONTROL-SLWDC, cache-lhr7363-LHR + - cache-control-slwdc9035-CONTROL-SLWDC, cache-lon4257-LON X-Timer: - - S1602076147.661563,VS0,VE511 + - S1602235721.978364,VS0,VE231 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/waf_exclusion/list/waf/create.yaml b/fastly/fixtures/waf_rule_exclusion/list/waf/create.yaml similarity index 71% rename from fastly/fixtures/waf_exclusion/list/waf/create.yaml rename to fastly/fixtures/waf_rule_exclusion/list/waf/create.yaml index d8e656cde..85d6da70e 100644 --- a/fastly/fixtures/waf_exclusion/list/waf/create.yaml +++ b/fastly/fixtures/waf_rule_exclusion/list/waf/create.yaml @@ -3,7 +3,7 @@ version: 1 interactions: - request: body: | - {"data":{"type":"waf_firewall","attributes":{"prefetch_condition":"","response":"WAf_Response","service_id":"2tqox6DHGJMOXYH4nYZqgN","service_version_number":"2"}}} + {"data":{"type":"waf_firewall","attributes":{"prefetch_condition":"","response":"WAf_Response","service_id":"2FcUklM62QkjiO0ErtK9D3","service_version_number":"2"}}} form: {} headers: Accept: @@ -15,7 +15,7 @@ interactions: url: https://api.fastly.com/waf/firewalls method: POST response: - body: '{"data":{"id":"5HtuuALz7WUiKn4AZnU1VM","type":"waf_firewall","attributes":{"active_rules_fastly_block_count":0,"active_rules_fastly_log_count":0,"active_rules_fastly_score_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_score_count":0,"active_rules_trustwave_block_count":0,"active_rules_trustwave_log_count":0,"created_at":"2020-10-07T13:09:09Z","disabled":false,"prefetch_condition":"","response":"WAf_Response","service_id":"2tqox6DHGJMOXYH4nYZqgN","service_version_number":2,"updated_at":"2020-10-07T13:09:09Z"}}}' + body: '{"data":{"id":"1YwZnVgr910HP3I8WRlhwE","type":"waf_firewall","attributes":{"active_rules_fastly_block_count":0,"active_rules_fastly_log_count":0,"active_rules_fastly_score_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_score_count":0,"active_rules_trustwave_block_count":0,"active_rules_trustwave_log_count":0,"created_at":"2020-10-09T09:28:42Z","disabled":false,"prefetch_condition":"","response":"WAf_Response","service_id":"2FcUklM62QkjiO0ErtK9D3","service_version_number":2,"updated_at":"2020-10-09T09:28:42Z"}}}' headers: Accept-Ranges: - bytes @@ -25,7 +25,7 @@ interactions: Content-Type: - application/vnd.api+json Date: - - Wed, 07 Oct 2020 13:09:09 GMT + - Fri, 09 Oct 2020 09:28:42 GMT Status: - 201 Created Strict-Transport-Security: @@ -40,9 +40,9 @@ interactions: X-Content-Type-Options: - nosniff X-Served-By: - - cache-control-slwdc9036-CONTROL-SLWDC, cache-lhr7363-LHR + - cache-control-slwdc9035-CONTROL-SLWDC, cache-lon4257-LON X-Timer: - - S1602076148.390914,VS0,VE785 + - S1602235722.579865,VS0,VE762 status: 201 Created code: 201 duration: "" diff --git a/fastly/fixtures/waf_exclusion/list_filters/waf/delete.yaml b/fastly/fixtures/waf_rule_exclusion/list/waf/delete.yaml similarity index 69% rename from fastly/fixtures/waf_exclusion/list_filters/waf/delete.yaml rename to fastly/fixtures/waf_rule_exclusion/list/waf/delete.yaml index 658789a1a..cb2ff1cf2 100644 --- a/fastly/fixtures/waf_exclusion/list_filters/waf/delete.yaml +++ b/fastly/fixtures/waf_rule_exclusion/list/waf/delete.yaml @@ -3,7 +3,7 @@ version: 1 interactions: - request: body: | - {"data":{"type":"waf_firewall","id":"5mOnW9PxK7wPrCwcItgmY8","attributes":{"service_version_number":"1"}}} + {"data":{"type":"waf_firewall","id":"1YwZnVgr910HP3I8WRlhwE","attributes":{"service_version_number":"1"}}} form: {} headers: Accept: @@ -12,7 +12,7 @@ interactions: - application/vnd.api+json User-Agent: - FastlyGo/1.17.0 (+github.com/fastly/go-fastly; go1.14.5) - url: https://api.fastly.com/waf/firewalls/5mOnW9PxK7wPrCwcItgmY8 + url: https://api.fastly.com/waf/firewalls/1YwZnVgr910HP3I8WRlhwE method: DELETE response: body: "" @@ -21,7 +21,7 @@ interactions: - bytes - bytes Date: - - Wed, 07 Oct 2020 13:09:11 GMT + - Fri, 09 Oct 2020 09:28:44 GMT Status: - 204 No Content Strict-Transport-Security: @@ -36,9 +36,9 @@ interactions: X-Content-Type-Options: - nosniff X-Served-By: - - cache-control-slwdc9035-CONTROL-SLWDC, cache-lhr7363-LHR + - cache-control-slwdc9037-CONTROL-SLWDC, cache-lon4257-LON X-Timer: - - S1602076152.821405,VS0,VE153 + - S1602235724.868725,VS0,VE154 status: 204 No Content code: 204 duration: "" diff --git a/fastly/fixtures/waf_exclusion/list_filters/waf_exclusions/create-1.yaml b/fastly/fixtures/waf_rule_exclusion/list/waf_rule_exclusions/create-1.yaml similarity index 67% rename from fastly/fixtures/waf_exclusion/list_filters/waf_exclusions/create-1.yaml rename to fastly/fixtures/waf_rule_exclusion/list/waf_rule_exclusions/create-1.yaml index 0538b5f76..202820500 100644 --- a/fastly/fixtures/waf_exclusion/list_filters/waf_exclusions/create-1.yaml +++ b/fastly/fixtures/waf_rule_exclusion/list/waf_rule_exclusions/create-1.yaml @@ -3,7 +3,7 @@ version: 1 interactions: - request: body: | - {"data":{"type":"waf_exclusion","attributes":{"condition":"req.url.basename == \"index.html\"","exclusion_type":"rule","name":"index page","number":null},"relationships":{"waf_rules":{"data":[{"type":"waf_rule","id":"2029718"},{"type":"waf_rule","id":"2037405"}]}}},"included":[{"type":"waf_rule","id":"2029718","attributes":{"modsec_rule_id":2029718}},{"type":"waf_rule","id":"2037405","attributes":{"modsec_rule_id":2037405}}]} + {"data":{"type":"waf_exclusion","attributes":{"condition":"req.url.basename == \"index.html\"","exclusion_type":"rule","name":"index page","number":null},"relationships":{"waf_rules":{"data":[{"type":"waf_rule","id":"2029718"},{"type":"waf_rule","id":"2037405"}]}}},"included":[{"type":"waf_rule","id":"2037405","attributes":{"modsec_rule_id":2037405}},{"type":"waf_rule","id":"2029718","attributes":{"modsec_rule_id":2029718}}]} form: {} headers: Accept: @@ -12,11 +12,11 @@ interactions: - application/vnd.api+json User-Agent: - FastlyGo/1.17.0 (+github.com/fastly/go-fastly; go1.14.5) - url: https://api.fastly.com/waf/firewalls/5mOnW9PxK7wPrCwcItgmY8/versions/1/exclusions + url: https://api.fastly.com/waf/firewalls/1YwZnVgr910HP3I8WRlhwE/versions/1/exclusions method: POST response: - body: '{"data":{"id":"4pKiyBglAh5CSpCKwuru7y","type":"waf_exclusion","attributes":{"created_at":"2020-10-07T13:09:10Z","exclusion_type":"rule","condition":"req.url.basename - == \"index.html\"","name":"index page","number":1,"updated_at":"2020-10-07T13:09:10Z"},"relationships":{"waf_rules":{"data":[{"id":"1YveWU8qwEYidE8WAiZqCN","type":"waf_rule"},{"id":"VovV0PIWJCm33k1piDpnX","type":"waf_rule"}]}}}}' + body: '{"data":{"id":"7HJ2K8v8lNSjN1am2rMUF6","type":"waf_exclusion","attributes":{"created_at":"2020-10-09T09:28:43Z","exclusion_type":"rule","condition":"req.url.basename + == \"index.html\"","name":"index page","number":1,"updated_at":"2020-10-09T09:28:43Z"},"relationships":{"waf_rules":{"data":[{"id":"1YveWU8qwEYidE8WAiZqCN","type":"waf_rule"},{"id":"VovV0PIWJCm33k1piDpnX","type":"waf_rule"}]}}}}' headers: Accept-Ranges: - bytes @@ -26,7 +26,7 @@ interactions: Content-Type: - application/vnd.api+json Date: - - Wed, 07 Oct 2020 13:09:10 GMT + - Fri, 09 Oct 2020 09:28:43 GMT Status: - 201 Created Strict-Transport-Security: @@ -41,9 +41,9 @@ interactions: X-Content-Type-Options: - nosniff X-Served-By: - - cache-control-slwdc9037-CONTROL-SLWDC, cache-lhr7363-LHR + - cache-control-slwdc9035-CONTROL-SLWDC, cache-lon4257-LON X-Timer: - - S1602076150.257585,VS0,VE436 + - S1602235723.891627,VS0,VE479 status: 201 Created code: 201 duration: "" diff --git a/fastly/fixtures/waf_exclusion/list_filters/waf_exclusions/create-2.yaml b/fastly/fixtures/waf_rule_exclusion/list/waf_rule_exclusions/create-2.yaml similarity index 64% rename from fastly/fixtures/waf_exclusion/list_filters/waf_exclusions/create-2.yaml rename to fastly/fixtures/waf_rule_exclusion/list/waf_rule_exclusions/create-2.yaml index ae448f90d..3291bd1af 100644 --- a/fastly/fixtures/waf_exclusion/list_filters/waf_exclusions/create-2.yaml +++ b/fastly/fixtures/waf_rule_exclusion/list/waf_rule_exclusions/create-2.yaml @@ -3,7 +3,7 @@ version: 1 interactions: - request: body: | - {"data":{"type":"waf_exclusion","attributes":{"condition":"req.url.basename == \"index.php\"","exclusion_type":"rule","name":"index php","number":null},"relationships":{"waf_rules":{"data":[{"type":"waf_rule","id":"1010070"}]}}},"included":[{"type":"waf_rule","id":"1010070","attributes":{"modsec_rule_id":1010070}}]} + {"data":{"type":"waf_exclusion","attributes":{"condition":"req.url.basename == \"index.php\"","exclusion_type":"rule","name":"index php","number":null},"relationships":{"waf_rules":{"data":[{"type":"waf_rule","id":"21032607"}]}}},"included":[{"type":"waf_rule","id":"21032607","attributes":{"modsec_rule_id":21032607}}]} form: {} headers: Accept: @@ -12,11 +12,11 @@ interactions: - application/vnd.api+json User-Agent: - FastlyGo/1.17.0 (+github.com/fastly/go-fastly; go1.14.5) - url: https://api.fastly.com/waf/firewalls/5mOnW9PxK7wPrCwcItgmY8/versions/1/exclusions + url: https://api.fastly.com/waf/firewalls/1YwZnVgr910HP3I8WRlhwE/versions/1/exclusions method: POST response: - body: '{"data":{"id":"64CI57J6goELQDlxSOBJSB","type":"waf_exclusion","attributes":{"created_at":"2020-10-07T13:09:10Z","exclusion_type":"rule","condition":"req.url.basename - == \"index.php\"","name":"index php","number":2,"updated_at":"2020-10-07T13:09:10Z"},"relationships":{"waf_rules":{"data":[{"id":"62NGF4KWy1v17yyV1vmPdb","type":"waf_rule"}]}}}}' + body: '{"data":{"id":"7hTcQkaAY1Ix0oB1i7U9FO","type":"waf_exclusion","attributes":{"created_at":"2020-10-09T09:28:43Z","exclusion_type":"rule","condition":"req.url.basename + == \"index.php\"","name":"index php","number":2,"updated_at":"2020-10-09T09:28:43Z"},"relationships":{"waf_rules":{"data":[{"id":"16kRBJ5RrNGYcnQ9EEiawe","type":"waf_rule"}]}}}}' headers: Accept-Ranges: - bytes @@ -26,7 +26,7 @@ interactions: Content-Type: - application/vnd.api+json Date: - - Wed, 07 Oct 2020 13:09:10 GMT + - Fri, 09 Oct 2020 09:28:43 GMT Status: - 201 Created Strict-Transport-Security: @@ -41,9 +41,9 @@ interactions: X-Content-Type-Options: - nosniff X-Served-By: - - cache-control-slwdc9037-CONTROL-SLWDC, cache-lhr7363-LHR + - cache-control-slwdc9037-CONTROL-SLWDC, cache-lon4257-LON X-Timer: - - S1602076151.749547,VS0,VE176 + - S1602235723.456888,VS0,VE151 status: 201 Created code: 201 duration: "" diff --git a/fastly/fixtures/waf_rule_exclusion/list/waf_rule_exclusions/list.yaml b/fastly/fixtures/waf_rule_exclusion/list/waf_rule_exclusions/list.yaml new file mode 100644 index 000000000..d2e7ccd83 --- /dev/null +++ b/fastly/fixtures/waf_rule_exclusion/list/waf_rule_exclusions/list.yaml @@ -0,0 +1,49 @@ +--- +version: 1 +interactions: +- request: + body: "" + form: {} + headers: + User-Agent: + - FastlyGo/1.17.0 (+github.com/fastly/go-fastly; go1.14.5) + url: https://api.fastly.com/waf/firewalls/1YwZnVgr910HP3I8WRlhwE/versions/1/exclusions?include=waf_rules&page%5Bnumber%5D=1&page%5Bsize%5D=100 + method: GET + response: + body: '{"data":[{"id":"7HJ2K8v8lNSjN1am2rMUF6","type":"waf_exclusion","attributes":{"created_at":"2020-10-09T09:28:43Z","exclusion_type":"rule","condition":"req.url.basename + == \"index.html\"","name":"index page","number":1,"updated_at":"2020-10-09T09:28:43Z"},"relationships":{"waf_rules":{"data":[{"id":"1YveWU8qwEYidE8WAiZqCN","type":"waf_rule"},{"id":"VovV0PIWJCm33k1piDpnX","type":"waf_rule"}]}}},{"id":"7hTcQkaAY1Ix0oB1i7U9FO","type":"waf_exclusion","attributes":{"created_at":"2020-10-09T09:28:43Z","exclusion_type":"rule","condition":"req.url.basename + == \"index.php\"","name":"index php","number":2,"updated_at":"2020-10-09T09:28:43Z"},"relationships":{"waf_rules":{"data":[{"id":"16kRBJ5RrNGYcnQ9EEiawe","type":"waf_rule"}]}}}],"included":[{"id":"16kRBJ5RrNGYcnQ9EEiawe","type":"waf_rule","attributes":{"modsec_rule_id":21032607,"publisher":"trustwave","type":"strict"}},{"id":"1YveWU8qwEYidE8WAiZqCN","type":"waf_rule","attributes":{"modsec_rule_id":2029718,"publisher":"trustwave","type":"strict"}},{"id":"VovV0PIWJCm33k1piDpnX","type":"waf_rule","attributes":{"modsec_rule_id":2037405,"publisher":"trustwave","type":"strict"}}],"links":{"last":"https://api.fastly.com/waf/firewalls/1YwZnVgr910HP3I8WRlhwE/versions/1/exclusions?include=waf_rules\u0026page[number]=1\u0026page[size]=100","first":"https://api.fastly.com/waf/firewalls/1YwZnVgr910HP3I8WRlhwE/versions/1/exclusions?include=waf_rules\u0026page[number]=1\u0026page[size]=100"},"meta":{"current_page":1,"per_page":100,"record_count":2,"total_pages":1}}' + headers: + Accept-Ranges: + - bytes + - bytes + - bytes + Age: + - "0" + - "0" + Content-Length: + - "1517" + Content-Type: + - application/vnd.api+json + Date: + - Fri, 09 Oct 2020 09:28:43 GMT + Status: + - 200 OK + Strict-Transport-Security: + - max-age=31536000 + Via: + - 1.1 varnish + - 1.1 varnish + X-Cache: + - MISS, MISS + X-Cache-Hits: + - 0, 0 + X-Content-Type-Options: + - nosniff + X-Served-By: + - cache-control-slwdc9037-CONTROL-SLWDC, cache-lon4257-LON + X-Timer: + - S1602235724.640366,VS0,VE160 + status: 200 OK + code: 200 + duration: "" diff --git a/fastly/fixtures/waf_rule_exclusion/list_filters/active_rules/create.yaml b/fastly/fixtures/waf_rule_exclusion/list_filters/active_rules/create.yaml new file mode 100644 index 000000000..7eecbd36a --- /dev/null +++ b/fastly/fixtures/waf_rule_exclusion/list_filters/active_rules/create.yaml @@ -0,0 +1,48 @@ +--- +version: 1 +interactions: +- request: + body: | + {"data":[{"type":"waf_active_rule","attributes":{"modsec_rule_id":2029718,"revision":1,"status":"log"}},{"type":"waf_active_rule","attributes":{"modsec_rule_id":2037405,"revision":1,"status":"log"}},{"type":"waf_active_rule","attributes":{"modsec_rule_id":21032607,"revision":1,"status":"log"}}]} + form: {} + headers: + Accept: + - application/vnd.api+json; ext=bulk + Content-Type: + - application/vnd.api+json; ext=bulk + User-Agent: + - FastlyGo/1.17.0 (+github.com/fastly/go-fastly; go1.14.5) + url: https://api.fastly.com/waf/firewalls/62l7nuYjgnuQSlFstrZnnH/versions/1/active-rules + method: POST + response: + body: '{"data":[{"id":"139CHbyYmTkQORPx2Xpfrt","type":"waf_active_rule","attributes":{"created_at":"2020-10-09T09:28:42Z","latest_revision":1,"modsec_rule_id":2029718,"outdated":false,"revision":1,"status":"log","updated_at":"2020-10-09T09:28:42Z"},"relationships":{"waf_firewall_version":{"data":{"id":"5FtJDkXOsXClSZ9Zf5Qij5","type":"waf_firewall_version"}},"waf_rule_revision":{"data":{"id":"6ZJML5tsy5uVq1nGNgmZ78","type":"waf_rule_revision"}}}},{"id":"4BlHJVTFejA3VRLuOeVlBf","type":"waf_active_rule","attributes":{"created_at":"2020-10-09T09:28:42Z","latest_revision":1,"modsec_rule_id":2037405,"outdated":false,"revision":1,"status":"log","updated_at":"2020-10-09T09:28:42Z"},"relationships":{"waf_firewall_version":{"data":{"id":"5FtJDkXOsXClSZ9Zf5Qij5","type":"waf_firewall_version"}},"waf_rule_revision":{"data":{"id":"3ANlv7vVZdzk2qFXlJLIk3","type":"waf_rule_revision"}}}},{"id":"6nA3mM9LmCAb7np5gJ2tXv","type":"waf_active_rule","attributes":{"created_at":"2020-10-09T09:28:42Z","latest_revision":1,"modsec_rule_id":21032607,"outdated":false,"revision":1,"status":"log","updated_at":"2020-10-09T09:28:42Z"},"relationships":{"waf_firewall_version":{"data":{"id":"5FtJDkXOsXClSZ9Zf5Qij5","type":"waf_firewall_version"}},"waf_rule_revision":{"data":{"id":"168gOasZaIZ1Sr712NJLLn","type":"waf_rule_revision"}}}}]}' + headers: + Accept-Ranges: + - bytes + - bytes + Content-Length: + - "1313" + Content-Type: + - application/vnd.api+json + Date: + - Fri, 09 Oct 2020 09:28:42 GMT + Status: + - 201 Created + Strict-Transport-Security: + - max-age=31536000 + Via: + - 1.1 varnish + - 1.1 varnish + X-Cache: + - MISS, MISS + X-Cache-Hits: + - 0, 0 + X-Content-Type-Options: + - nosniff + X-Served-By: + - cache-control-slwdc9035-CONTROL-SLWDC, cache-lon4257-LON + X-Timer: + - S1602235722.419650,VS0,VE384 + status: 201 Created + code: 201 + duration: "" diff --git a/fastly/fixtures/waf_exclusion/delete/response_object/create.yaml b/fastly/fixtures/waf_rule_exclusion/list_filters/response_object/create.yaml similarity index 59% rename from fastly/fixtures/waf_exclusion/delete/response_object/create.yaml rename to fastly/fixtures/waf_rule_exclusion/list_filters/response_object/create.yaml index 696f5ae79..424021ee1 100644 --- a/fastly/fixtures/waf_exclusion/delete/response_object/create.yaml +++ b/fastly/fixtures/waf_rule_exclusion/list_filters/response_object/create.yaml @@ -2,10 +2,10 @@ version: 1 interactions: - request: - body: Service=4j5iMcheZDNpEMiwjnYh8K&Version=2&name=WAf_Response&status=403 + body: Service=3lYLhAbTXOxJ79lUeCK97B&Version=2&name=WAf_Response&status=403 form: Service: - - 4j5iMcheZDNpEMiwjnYh8K + - 3lYLhAbTXOxJ79lUeCK97B Version: - "2" name: @@ -17,10 +17,10 @@ interactions: - application/x-www-form-urlencoded User-Agent: - FastlyGo/1.17.0 (+github.com/fastly/go-fastly; go1.14.5) - url: https://api.fastly.com/service/4j5iMcheZDNpEMiwjnYh8K/version/2/response_object + url: https://api.fastly.com/service/3lYLhAbTXOxJ79lUeCK97B/version/2/response_object method: POST response: - body: '{"name":"WAf_Response","status":"403","service_id":"4j5iMcheZDNpEMiwjnYh8K","version":"2","cache_condition":"","updated_at":"2020-10-07T13:09:07Z","deleted_at":null,"content_type":null,"request_condition":"","content":null,"response":"ok","created_at":"2020-10-07T13:09:07Z"}' + body: '{"name":"WAf_Response","status":"403","service_id":"3lYLhAbTXOxJ79lUeCK97B","version":"2","content":null,"updated_at":"2020-10-09T09:28:41Z","content_type":null,"deleted_at":null,"cache_condition":"","created_at":"2020-10-09T09:28:41Z","request_condition":"","response":"ok"}' headers: Accept-Ranges: - bytes @@ -30,11 +30,11 @@ interactions: Content-Type: - application/json Date: - - Wed, 07 Oct 2020 13:09:07 GMT + - Fri, 09 Oct 2020 09:28:41 GMT Fastly-Ratelimit-Remaining: - - "4945" + - "4932" Fastly-Ratelimit-Reset: - - "1602079200" + - "1602237600" Status: - 200 OK Strict-Transport-Security: @@ -49,9 +49,9 @@ interactions: X-Cache-Hits: - 0, 0 X-Served-By: - - cache-control-slwdc9035-CONTROL-SLWDC, cache-lhr7363-LHR + - cache-control-slwdc9036-CONTROL-SLWDC, cache-lon4257-LON X-Timer: - - S1602076147.215250,VS0,VE233 + - S1602235721.031734,VS0,VE234 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/waf_exclusion/delete/service/create.yaml b/fastly/fixtures/waf_rule_exclusion/list_filters/service/create.yaml similarity index 67% rename from fastly/fixtures/waf_exclusion/delete/service/create.yaml rename to fastly/fixtures/waf_rule_exclusion/list_filters/service/create.yaml index 81d647184..126306bc6 100644 --- a/fastly/fixtures/waf_exclusion/delete/service/create.yaml +++ b/fastly/fixtures/waf_rule_exclusion/list_filters/service/create.yaml @@ -18,7 +18,7 @@ interactions: url: https://api.fastly.com/service method: POST response: - body: '{"customer_id":"WpqWFjTA4lk2N1g0GY2HH","comment":"go-fastly client test","name":"test_service_service-3916589616287113937","type":"vcl","updated_at":"2020-10-07T13:09:06Z","publish_key":"","versions":[{"locked":false,"deployed":false,"testing":false,"deleted_at":null,"created_at":"2020-10-07T13:09:06Z","service_id":"4j5iMcheZDNpEMiwjnYh8K","staging":false,"updated_at":"2020-10-07T13:09:06Z","comment":"","active":false,"number":1}],"id":"4j5iMcheZDNpEMiwjnYh8K","created_at":"2020-10-07T13:09:06Z","deleted_at":null}' + body: '{"customer_id":"WpqWFjTA4lk2N1g0GY2HH","comment":"go-fastly client test","name":"test_service_service-3916589616287113937","type":"vcl","id":"3lYLhAbTXOxJ79lUeCK97B","deleted_at":null,"publish_key":"","updated_at":"2020-10-09T09:28:40Z","versions":[{"number":1,"created_at":"2020-10-09T09:28:40Z","deployed":false,"comment":"","service_id":"3lYLhAbTXOxJ79lUeCK97B","active":false,"locked":false,"updated_at":"2020-10-09T09:28:40Z","testing":false,"deleted_at":null,"staging":false}],"created_at":"2020-10-09T09:28:40Z"}' headers: Accept-Ranges: - bytes @@ -28,11 +28,11 @@ interactions: Content-Type: - application/json Date: - - Wed, 07 Oct 2020 13:09:06 GMT + - Fri, 09 Oct 2020 09:28:40 GMT Fastly-Ratelimit-Remaining: - - "4952" + - "4938" Fastly-Ratelimit-Reset: - - "1602079200" + - "1602237600" Status: - 200 OK Strict-Transport-Security: @@ -47,9 +47,9 @@ interactions: X-Cache-Hits: - 0, 0 X-Served-By: - - cache-control-slwdc9036-CONTROL-SLWDC, cache-lhr7363-LHR + - cache-control-slwdc9035-CONTROL-SLWDC, cache-lon4257-LON X-Timer: - - S1602076146.397397,VS0,VE221 + - S1602235720.463721,VS0,VE236 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/waf_exclusion/create/service/delete.yaml b/fastly/fixtures/waf_rule_exclusion/list_filters/service/delete.yaml similarity index 76% rename from fastly/fixtures/waf_exclusion/create/service/delete.yaml rename to fastly/fixtures/waf_rule_exclusion/list_filters/service/delete.yaml index 738469c61..e146d7cbb 100644 --- a/fastly/fixtures/waf_exclusion/create/service/delete.yaml +++ b/fastly/fixtures/waf_rule_exclusion/list_filters/service/delete.yaml @@ -7,7 +7,7 @@ interactions: headers: User-Agent: - FastlyGo/1.17.0 (+github.com/fastly/go-fastly; go1.14.5) - url: https://api.fastly.com/service/5ZTGLKH5LoWkfPUSAv1w6X + url: https://api.fastly.com/service/3lYLhAbTXOxJ79lUeCK97B method: DELETE response: body: '{"status":"ok"}' @@ -20,11 +20,11 @@ interactions: Content-Type: - application/json Date: - - Wed, 07 Oct 2020 13:09:10 GMT + - Fri, 09 Oct 2020 09:28:44 GMT Fastly-Ratelimit-Remaining: - - "4937" + - "4923" Fastly-Ratelimit-Reset: - - "1602079200" + - "1602237600" Status: - 200 OK Strict-Transport-Security: @@ -39,9 +39,9 @@ interactions: X-Cache-Hits: - 0, 0 X-Served-By: - - cache-control-slwdc9035-CONTROL-SLWDC, cache-lhr7363-LHR + - cache-control-slwdc9037-CONTROL-SLWDC, cache-lon4257-LON X-Timer: - - S1602076150.061571,VS0,VE239 + - S1602235724.256095,VS0,VE204 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/waf_exclusion/list_filters/service/version.yaml b/fastly/fixtures/waf_rule_exclusion/list_filters/service/version.yaml similarity index 68% rename from fastly/fixtures/waf_exclusion/list_filters/service/version.yaml rename to fastly/fixtures/waf_rule_exclusion/list_filters/service/version.yaml index 09ef93c5c..f643b9925 100644 --- a/fastly/fixtures/waf_exclusion/list_filters/service/version.yaml +++ b/fastly/fixtures/waf_rule_exclusion/list_filters/service/version.yaml @@ -2,19 +2,19 @@ version: 1 interactions: - request: - body: Service=1JeR1AIjuRcEXA5doHqxPr + body: Service=3lYLhAbTXOxJ79lUeCK97B form: Service: - - 1JeR1AIjuRcEXA5doHqxPr + - 3lYLhAbTXOxJ79lUeCK97B headers: Content-Type: - application/x-www-form-urlencoded User-Agent: - FastlyGo/1.17.0 (+github.com/fastly/go-fastly; go1.14.5) - url: https://api.fastly.com/service/1JeR1AIjuRcEXA5doHqxPr/version + url: https://api.fastly.com/service/3lYLhAbTXOxJ79lUeCK97B/version method: POST response: - body: '{"service_id":"1JeR1AIjuRcEXA5doHqxPr","number":2}' + body: '{"service_id":"3lYLhAbTXOxJ79lUeCK97B","number":2}' headers: Accept-Ranges: - bytes @@ -24,11 +24,11 @@ interactions: Content-Type: - application/json Date: - - Wed, 07 Oct 2020 13:09:08 GMT + - Fri, 09 Oct 2020 09:28:40 GMT Fastly-Ratelimit-Remaining: - - "4939" + - "4935" Fastly-Ratelimit-Reset: - - "1602079200" + - "1602237600" Status: - 200 OK Strict-Transport-Security: @@ -43,9 +43,9 @@ interactions: X-Cache-Hits: - 0, 0 X-Served-By: - - cache-control-slwdc9037-CONTROL-SLWDC, cache-lhr7363-LHR + - cache-control-slwdc9036-CONTROL-SLWDC, cache-lon4257-LON X-Timer: - - S1602076148.085255,VS0,VE514 + - S1602235721.728296,VS0,VE224 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/waf_exclusion/list_filters/waf/create.yaml b/fastly/fixtures/waf_rule_exclusion/list_filters/waf/create.yaml similarity index 71% rename from fastly/fixtures/waf_exclusion/list_filters/waf/create.yaml rename to fastly/fixtures/waf_rule_exclusion/list_filters/waf/create.yaml index 94a27ecf2..9cb7ff483 100644 --- a/fastly/fixtures/waf_exclusion/list_filters/waf/create.yaml +++ b/fastly/fixtures/waf_rule_exclusion/list_filters/waf/create.yaml @@ -3,7 +3,7 @@ version: 1 interactions: - request: body: | - {"data":{"type":"waf_firewall","attributes":{"prefetch_condition":"","response":"WAf_Response","service_id":"1JeR1AIjuRcEXA5doHqxPr","service_version_number":"2"}}} + {"data":{"type":"waf_firewall","attributes":{"prefetch_condition":"","response":"WAf_Response","service_id":"3lYLhAbTXOxJ79lUeCK97B","service_version_number":"2"}}} form: {} headers: Accept: @@ -15,7 +15,7 @@ interactions: url: https://api.fastly.com/waf/firewalls method: POST response: - body: '{"data":{"id":"5mOnW9PxK7wPrCwcItgmY8","type":"waf_firewall","attributes":{"active_rules_fastly_block_count":0,"active_rules_fastly_log_count":0,"active_rules_fastly_score_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_score_count":0,"active_rules_trustwave_block_count":0,"active_rules_trustwave_log_count":0,"created_at":"2020-10-07T13:09:09Z","disabled":false,"prefetch_condition":"","response":"WAf_Response","service_id":"1JeR1AIjuRcEXA5doHqxPr","service_version_number":2,"updated_at":"2020-10-07T13:09:09Z"}}}' + body: '{"data":{"id":"62l7nuYjgnuQSlFstrZnnH","type":"waf_firewall","attributes":{"active_rules_fastly_block_count":0,"active_rules_fastly_log_count":0,"active_rules_fastly_score_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_score_count":0,"active_rules_trustwave_block_count":0,"active_rules_trustwave_log_count":0,"created_at":"2020-10-09T09:28:42Z","disabled":false,"prefetch_condition":"","response":"WAf_Response","service_id":"3lYLhAbTXOxJ79lUeCK97B","service_version_number":2,"updated_at":"2020-10-09T09:28:42Z"}}}' headers: Accept-Ranges: - bytes @@ -25,7 +25,7 @@ interactions: Content-Type: - application/vnd.api+json Date: - - Wed, 07 Oct 2020 13:09:09 GMT + - Fri, 09 Oct 2020 09:28:42 GMT Status: - 201 Created Strict-Transport-Security: @@ -40,9 +40,9 @@ interactions: X-Content-Type-Options: - nosniff X-Served-By: - - cache-control-slwdc9036-CONTROL-SLWDC, cache-lhr7363-LHR + - cache-control-slwdc9037-CONTROL-SLWDC, cache-lon4257-LON X-Timer: - - S1602076149.147104,VS0,VE831 + - S1602235721.335683,VS0,VE996 status: 201 Created code: 201 duration: "" diff --git a/fastly/fixtures/waf_exclusion/list/waf/delete.yaml b/fastly/fixtures/waf_rule_exclusion/list_filters/waf/delete.yaml similarity index 69% rename from fastly/fixtures/waf_exclusion/list/waf/delete.yaml rename to fastly/fixtures/waf_rule_exclusion/list_filters/waf/delete.yaml index b219f7809..313aa9557 100644 --- a/fastly/fixtures/waf_exclusion/list/waf/delete.yaml +++ b/fastly/fixtures/waf_rule_exclusion/list_filters/waf/delete.yaml @@ -3,7 +3,7 @@ version: 1 interactions: - request: body: | - {"data":{"type":"waf_firewall","id":"5HtuuALz7WUiKn4AZnU1VM","attributes":{"service_version_number":"1"}}} + {"data":{"type":"waf_firewall","id":"62l7nuYjgnuQSlFstrZnnH","attributes":{"service_version_number":"1"}}} form: {} headers: Accept: @@ -12,7 +12,7 @@ interactions: - application/vnd.api+json User-Agent: - FastlyGo/1.17.0 (+github.com/fastly/go-fastly; go1.14.5) - url: https://api.fastly.com/waf/firewalls/5HtuuALz7WUiKn4AZnU1VM + url: https://api.fastly.com/waf/firewalls/62l7nuYjgnuQSlFstrZnnH method: DELETE response: body: "" @@ -21,7 +21,7 @@ interactions: - bytes - bytes Date: - - Wed, 07 Oct 2020 13:09:10 GMT + - Fri, 09 Oct 2020 09:28:44 GMT Status: - 204 No Content Strict-Transport-Security: @@ -36,9 +36,9 @@ interactions: X-Content-Type-Options: - nosniff X-Served-By: - - cache-control-slwdc9035-CONTROL-SLWDC, cache-lhr7363-LHR + - cache-control-slwdc9036-CONTROL-SLWDC, cache-lon4257-LON X-Timer: - - S1602076150.387327,VS0,VE239 + - S1602235724.072526,VS0,VE155 status: 204 No Content code: 204 duration: "" diff --git a/fastly/fixtures/waf_exclusion/list/waf_exclusions/create-1.yaml b/fastly/fixtures/waf_rule_exclusion/list_filters/waf_rule_exclusions/create-1.yaml similarity index 77% rename from fastly/fixtures/waf_exclusion/list/waf_exclusions/create-1.yaml rename to fastly/fixtures/waf_rule_exclusion/list_filters/waf_rule_exclusions/create-1.yaml index d7463c6de..8a7a69f39 100644 --- a/fastly/fixtures/waf_exclusion/list/waf_exclusions/create-1.yaml +++ b/fastly/fixtures/waf_rule_exclusion/list_filters/waf_rule_exclusions/create-1.yaml @@ -12,11 +12,11 @@ interactions: - application/vnd.api+json User-Agent: - FastlyGo/1.17.0 (+github.com/fastly/go-fastly; go1.14.5) - url: https://api.fastly.com/waf/firewalls/5HtuuALz7WUiKn4AZnU1VM/versions/1/exclusions + url: https://api.fastly.com/waf/firewalls/62l7nuYjgnuQSlFstrZnnH/versions/1/exclusions method: POST response: - body: '{"data":{"id":"34s9Ff1kxfri0Re34WzNk5","type":"waf_exclusion","attributes":{"created_at":"2020-10-07T13:09:09Z","exclusion_type":"rule","condition":"req.url.basename - == \"index.html\"","name":"index page","number":1,"updated_at":"2020-10-07T13:09:09Z"},"relationships":{"waf_rules":{"data":[{"id":"1YveWU8qwEYidE8WAiZqCN","type":"waf_rule"},{"id":"VovV0PIWJCm33k1piDpnX","type":"waf_rule"}]}}}}' + body: '{"data":{"id":"4Z3uV69ppxwsfvlXRKqWbQ","type":"waf_exclusion","attributes":{"created_at":"2020-10-09T09:28:43Z","exclusion_type":"rule","condition":"req.url.basename + == \"index.html\"","name":"index page","number":1,"updated_at":"2020-10-09T09:28:43Z"},"relationships":{"waf_rules":{"data":[{"id":"1YveWU8qwEYidE8WAiZqCN","type":"waf_rule"},{"id":"VovV0PIWJCm33k1piDpnX","type":"waf_rule"}]}}}}' headers: Accept-Ranges: - bytes @@ -26,7 +26,7 @@ interactions: Content-Type: - application/vnd.api+json Date: - - Wed, 07 Oct 2020 13:09:09 GMT + - Fri, 09 Oct 2020 09:28:43 GMT Status: - 201 Created Strict-Transport-Security: @@ -41,9 +41,9 @@ interactions: X-Content-Type-Options: - nosniff X-Served-By: - - cache-control-slwdc9037-CONTROL-SLWDC, cache-lhr7363-LHR + - cache-control-slwdc9037-CONTROL-SLWDC, cache-lon4257-LON X-Timer: - - S1602076149.428149,VS0,VE158 + - S1602235723.890357,VS0,VE506 status: 201 Created code: 201 duration: "" diff --git a/fastly/fixtures/waf_exclusion/list/waf_exclusions/create-2.yaml b/fastly/fixtures/waf_rule_exclusion/list_filters/waf_rule_exclusions/create-2.yaml similarity index 60% rename from fastly/fixtures/waf_exclusion/list/waf_exclusions/create-2.yaml rename to fastly/fixtures/waf_rule_exclusion/list_filters/waf_rule_exclusions/create-2.yaml index 323a5c998..8e2eda994 100644 --- a/fastly/fixtures/waf_exclusion/list/waf_exclusions/create-2.yaml +++ b/fastly/fixtures/waf_rule_exclusion/list_filters/waf_rule_exclusions/create-2.yaml @@ -3,7 +3,7 @@ version: 1 interactions: - request: body: | - {"data":{"type":"waf_exclusion","attributes":{"condition":"req.url.basename == \"index.php\"","exclusion_type":"rule","name":"index php","number":null},"relationships":{"waf_rules":{"data":[{"type":"waf_rule","id":"1010070"}]}}},"included":[{"type":"waf_rule","id":"1010070","attributes":{"modsec_rule_id":1010070}}]} + {"data":{"type":"waf_exclusion","attributes":{"condition":"req.url.basename == \"index.php\"","exclusion_type":"rule","name":"index php","number":null},"relationships":{"waf_rules":{"data":[{"type":"waf_rule","id":"21032607"}]}}},"included":[{"type":"waf_rule","id":"21032607","attributes":{"modsec_rule_id":21032607}}]} form: {} headers: Accept: @@ -12,21 +12,21 @@ interactions: - application/vnd.api+json User-Agent: - FastlyGo/1.17.0 (+github.com/fastly/go-fastly; go1.14.5) - url: https://api.fastly.com/waf/firewalls/5HtuuALz7WUiKn4AZnU1VM/versions/1/exclusions + url: https://api.fastly.com/waf/firewalls/62l7nuYjgnuQSlFstrZnnH/versions/1/exclusions method: POST response: - body: '{"data":{"id":"3ZQKFpHrO9heq1gv2o1pEo","type":"waf_exclusion","attributes":{"created_at":"2020-10-07T13:09:09Z","exclusion_type":"rule","condition":"req.url.basename - == \"index.php\"","name":"index php","number":2,"updated_at":"2020-10-07T13:09:09Z"},"relationships":{"waf_rules":{"data":[{"id":"62NGF4KWy1v17yyV1vmPdb","type":"waf_rule"}]}}}}' + body: '{"data":{"id":"e00Ot5MjYzxOxpLFnR8Cq","type":"waf_exclusion","attributes":{"created_at":"2020-10-09T09:28:43Z","exclusion_type":"rule","condition":"req.url.basename + == \"index.php\"","name":"index php","number":2,"updated_at":"2020-10-09T09:28:43Z"},"relationships":{"waf_rules":{"data":[{"id":"16kRBJ5RrNGYcnQ9EEiawe","type":"waf_rule"}]}}}}' headers: Accept-Ranges: - bytes - bytes Content-Length: - - "343" + - "342" Content-Type: - application/vnd.api+json Date: - - Wed, 07 Oct 2020 13:09:10 GMT + - Fri, 09 Oct 2020 09:28:43 GMT Status: - 201 Created Strict-Transport-Security: @@ -41,9 +41,9 @@ interactions: X-Content-Type-Options: - nosniff X-Served-By: - - cache-control-slwdc9036-CONTROL-SLWDC, cache-lhr7363-LHR + - cache-control-slwdc9035-CONTROL-SLWDC, cache-lon4257-LON X-Timer: - - S1602076150.659086,VS0,VE377 + - S1602235723.456880,VS0,VE134 status: 201 Created code: 201 duration: "" diff --git a/fastly/fixtures/waf_exclusion/list_filters/waf_exclusions/create-3.yaml b/fastly/fixtures/waf_rule_exclusion/list_filters/waf_rule_exclusions/create-3.yaml similarity index 73% rename from fastly/fixtures/waf_exclusion/list_filters/waf_exclusions/create-3.yaml rename to fastly/fixtures/waf_rule_exclusion/list_filters/waf_rule_exclusions/create-3.yaml index 140899f56..cb3d2dec0 100644 --- a/fastly/fixtures/waf_exclusion/list_filters/waf_exclusions/create-3.yaml +++ b/fastly/fixtures/waf_rule_exclusion/list_filters/waf_rule_exclusions/create-3.yaml @@ -12,11 +12,11 @@ interactions: - application/vnd.api+json User-Agent: - FastlyGo/1.17.0 (+github.com/fastly/go-fastly; go1.14.5) - url: https://api.fastly.com/waf/firewalls/5mOnW9PxK7wPrCwcItgmY8/versions/1/exclusions + url: https://api.fastly.com/waf/firewalls/62l7nuYjgnuQSlFstrZnnH/versions/1/exclusions method: POST response: - body: '{"data":{"id":"2aSCXcRmYd1A3Yh52n1isb","type":"waf_exclusion","attributes":{"created_at":"2020-10-07T13:09:11Z","exclusion_type":"waf","condition":"req.url.basename - == \"index.asp\"","name":"index asp","number":3,"updated_at":"2020-10-07T13:09:11Z"}}}' + body: '{"data":{"id":"4cYxLvo8x6ckU4GzVor1tL","type":"waf_exclusion","attributes":{"created_at":"2020-10-09T09:28:43Z","exclusion_type":"waf","condition":"req.url.basename + == \"index.asp\"","name":"index asp","number":3,"updated_at":"2020-10-09T09:28:43Z"}}}' headers: Accept-Ranges: - bytes @@ -26,7 +26,7 @@ interactions: Content-Type: - application/vnd.api+json Date: - - Wed, 07 Oct 2020 13:09:11 GMT + - Fri, 09 Oct 2020 09:28:43 GMT Status: - 201 Created Strict-Transport-Security: @@ -41,9 +41,9 @@ interactions: X-Content-Type-Options: - nosniff X-Served-By: - - cache-control-slwdc9037-CONTROL-SLWDC, cache-lhr7363-LHR + - cache-control-slwdc9036-CONTROL-SLWDC, cache-lon4257-LON X-Timer: - - S1602076151.969444,VS0,VE604 + - S1602235724.640384,VS0,VE135 status: 201 Created code: 201 duration: "" diff --git a/fastly/fixtures/waf_rule_exclusion/list_filters/waf_rule_exclusions/list.yaml b/fastly/fixtures/waf_rule_exclusion/list_filters/waf_rule_exclusions/list.yaml new file mode 100644 index 000000000..9a1627721 --- /dev/null +++ b/fastly/fixtures/waf_rule_exclusion/list_filters/waf_rule_exclusions/list.yaml @@ -0,0 +1,48 @@ +--- +version: 1 +interactions: +- request: + body: "" + form: {} + headers: + User-Agent: + - FastlyGo/1.17.0 (+github.com/fastly/go-fastly; go1.14.5) + url: https://api.fastly.com/waf/firewalls/62l7nuYjgnuQSlFstrZnnH/versions/1/exclusions?filter%5Bexclusion_type%5D=rule&filter%5Bwaf_rules.modsec_rule_id%5D=21032607&include=waf_rules&page%5Bnumber%5D=1&page%5Bsize%5D=100 + method: GET + response: + body: '{"data":[{"id":"e00Ot5MjYzxOxpLFnR8Cq","type":"waf_exclusion","attributes":{"created_at":"2020-10-09T09:28:43Z","exclusion_type":"rule","condition":"req.url.basename + == \"index.php\"","name":"index php","number":2,"updated_at":"2020-10-09T09:28:43Z"},"relationships":{"waf_rules":{"data":[{"id":"16kRBJ5RrNGYcnQ9EEiawe","type":"waf_rule"}]}}}],"included":[{"id":"16kRBJ5RrNGYcnQ9EEiawe","type":"waf_rule","attributes":{"modsec_rule_id":21032607,"publisher":"trustwave","type":"strict"}}],"links":{"last":"https://api.fastly.com/waf/firewalls/62l7nuYjgnuQSlFstrZnnH/versions/1/exclusions?filter[exclusion_type]=rule\u0026filter[waf_rules.modsec_rule_id]=21032607\u0026include=waf_rules\u0026page[number]=1\u0026page[size]=100","first":"https://api.fastly.com/waf/firewalls/62l7nuYjgnuQSlFstrZnnH/versions/1/exclusions?filter[exclusion_type]=rule\u0026filter[waf_rules.modsec_rule_id]=21032607\u0026include=waf_rules\u0026page[number]=1\u0026page[size]=100"},"meta":{"current_page":1,"per_page":100,"record_count":1,"total_pages":1}}' + headers: + Accept-Ranges: + - bytes + - bytes + - bytes + Age: + - "0" + - "0" + Content-Length: + - "1031" + Content-Type: + - application/vnd.api+json + Date: + - Fri, 09 Oct 2020 09:28:43 GMT + Status: + - 200 OK + Strict-Transport-Security: + - max-age=31536000 + Via: + - 1.1 varnish + - 1.1 varnish + X-Cache: + - MISS, MISS + X-Cache-Hits: + - 0, 0 + X-Content-Type-Options: + - nosniff + X-Served-By: + - cache-control-slwdc9037-CONTROL-SLWDC, cache-lon4257-LON + X-Timer: + - S1602235724.826469,VS0,VE155 + status: 200 OK + code: 200 + duration: "" diff --git a/fastly/fixtures/waf_rule_exclusion/update/active_rules/create.yaml b/fastly/fixtures/waf_rule_exclusion/update/active_rules/create.yaml new file mode 100644 index 000000000..b8cb3885c --- /dev/null +++ b/fastly/fixtures/waf_rule_exclusion/update/active_rules/create.yaml @@ -0,0 +1,48 @@ +--- +version: 1 +interactions: +- request: + body: | + {"data":[{"type":"waf_active_rule","attributes":{"modsec_rule_id":2029718,"revision":1,"status":"log"}},{"type":"waf_active_rule","attributes":{"modsec_rule_id":2037405,"revision":1,"status":"log"}},{"type":"waf_active_rule","attributes":{"modsec_rule_id":21032607,"revision":1,"status":"log"}}]} + form: {} + headers: + Accept: + - application/vnd.api+json; ext=bulk + Content-Type: + - application/vnd.api+json; ext=bulk + User-Agent: + - FastlyGo/1.17.0 (+github.com/fastly/go-fastly; go1.14.5) + url: https://api.fastly.com/waf/firewalls/6DaBRX0dIm1SjxiB1KQCII/versions/1/active-rules + method: POST + response: + body: '{"data":[{"id":"4Cfz3YyWpEJHybhkcui3KW","type":"waf_active_rule","attributes":{"created_at":"2020-10-09T09:28:43Z","latest_revision":1,"modsec_rule_id":2029718,"outdated":false,"revision":1,"status":"log","updated_at":"2020-10-09T09:28:43Z"},"relationships":{"waf_firewall_version":{"data":{"id":"2ZKa6D4Ibe8SL2lnmqAxNm","type":"waf_firewall_version"}},"waf_rule_revision":{"data":{"id":"6ZJML5tsy5uVq1nGNgmZ78","type":"waf_rule_revision"}}}},{"id":"4MFH6fCBrk81yMZsWzyeEk","type":"waf_active_rule","attributes":{"created_at":"2020-10-09T09:28:43Z","latest_revision":1,"modsec_rule_id":2037405,"outdated":false,"revision":1,"status":"log","updated_at":"2020-10-09T09:28:43Z"},"relationships":{"waf_firewall_version":{"data":{"id":"2ZKa6D4Ibe8SL2lnmqAxNm","type":"waf_firewall_version"}},"waf_rule_revision":{"data":{"id":"3ANlv7vVZdzk2qFXlJLIk3","type":"waf_rule_revision"}}}},{"id":"6Mj4fVJ3JHcjs9hsJPmLsV","type":"waf_active_rule","attributes":{"created_at":"2020-10-09T09:28:43Z","latest_revision":1,"modsec_rule_id":21032607,"outdated":false,"revision":1,"status":"log","updated_at":"2020-10-09T09:28:43Z"},"relationships":{"waf_firewall_version":{"data":{"id":"2ZKa6D4Ibe8SL2lnmqAxNm","type":"waf_firewall_version"}},"waf_rule_revision":{"data":{"id":"168gOasZaIZ1Sr712NJLLn","type":"waf_rule_revision"}}}}]}' + headers: + Accept-Ranges: + - bytes + - bytes + Content-Length: + - "1313" + Content-Type: + - application/vnd.api+json + Date: + - Fri, 09 Oct 2020 09:28:43 GMT + Status: + - 201 Created + Strict-Transport-Security: + - max-age=31536000 + Via: + - 1.1 varnish + - 1.1 varnish + X-Cache: + - MISS, MISS + X-Cache-Hits: + - 0, 0 + X-Content-Type-Options: + - nosniff + X-Served-By: + - cache-control-slwdc9037-CONTROL-SLWDC, cache-lon4257-LON + X-Timer: + - S1602235723.456905,VS0,VE189 + status: 201 Created + code: 201 + duration: "" diff --git a/fastly/fixtures/waf_rule_exclusion/update/response_object/create.yaml b/fastly/fixtures/waf_rule_exclusion/update/response_object/create.yaml new file mode 100644 index 000000000..4fae9c7af --- /dev/null +++ b/fastly/fixtures/waf_rule_exclusion/update/response_object/create.yaml @@ -0,0 +1,57 @@ +--- +version: 1 +interactions: +- request: + body: Service=5wBis6DpoO67acK0K7n5GU&Version=2&name=WAf_Response&status=403 + form: + Service: + - 5wBis6DpoO67acK0K7n5GU + Version: + - "2" + name: + - WAf_Response + status: + - "403" + headers: + Content-Type: + - application/x-www-form-urlencoded + User-Agent: + - FastlyGo/1.17.0 (+github.com/fastly/go-fastly; go1.14.5) + url: https://api.fastly.com/service/5wBis6DpoO67acK0K7n5GU/version/2/response_object + method: POST + response: + body: '{"name":"WAf_Response","status":"403","service_id":"5wBis6DpoO67acK0K7n5GU","version":"2","cache_condition":"","deleted_at":null,"request_condition":"","response":"ok","content_type":null,"updated_at":"2020-10-09T09:28:42Z","content":null,"created_at":"2020-10-09T09:28:42Z"}' + headers: + Accept-Ranges: + - bytes + - bytes + Cache-Control: + - no-cache + Content-Type: + - application/json + Date: + - Fri, 09 Oct 2020 09:28:42 GMT + Fastly-Ratelimit-Remaining: + - "4927" + Fastly-Ratelimit-Reset: + - "1602237600" + Status: + - 200 OK + Strict-Transport-Security: + - max-age=31536000 + Vary: + - Accept-Encoding + Via: + - 1.1 varnish + - 1.1 varnish + X-Cache: + - MISS, MISS + X-Cache-Hits: + - 0, 0 + X-Served-By: + - cache-control-slwdc9037-CONTROL-SLWDC, cache-lon4257-LON + X-Timer: + - S1602235722.039901,VS0,VE232 + status: 200 OK + code: 200 + duration: "" diff --git a/fastly/fixtures/waf_exclusion/list/service/create.yaml b/fastly/fixtures/waf_rule_exclusion/update/service/create.yaml similarity index 67% rename from fastly/fixtures/waf_exclusion/list/service/create.yaml rename to fastly/fixtures/waf_rule_exclusion/update/service/create.yaml index c1d686bf1..e7bd19bba 100644 --- a/fastly/fixtures/waf_exclusion/list/service/create.yaml +++ b/fastly/fixtures/waf_rule_exclusion/update/service/create.yaml @@ -18,7 +18,7 @@ interactions: url: https://api.fastly.com/service method: POST response: - body: '{"customer_id":"WpqWFjTA4lk2N1g0GY2HH","comment":"go-fastly client test","name":"test_service_service-6129484611666145821","type":"vcl","versions":[{"testing":false,"comment":"","staging":false,"deleted_at":null,"active":false,"created_at":"2020-10-07T13:09:06Z","updated_at":"2020-10-07T13:09:06Z","service_id":"2tqox6DHGJMOXYH4nYZqgN","locked":false,"number":1,"deployed":false}],"id":"2tqox6DHGJMOXYH4nYZqgN","updated_at":"2020-10-07T13:09:06Z","created_at":"2020-10-07T13:09:06Z","deleted_at":null,"publish_key":""}' + body: '{"customer_id":"WpqWFjTA4lk2N1g0GY2HH","comment":"go-fastly client test","name":"test_service_service-6129484611666145821","type":"vcl","updated_at":"2020-10-09T09:28:40Z","publish_key":"","id":"5wBis6DpoO67acK0K7n5GU","deleted_at":null,"created_at":"2020-10-09T09:28:40Z","versions":[{"deployed":false,"comment":"","created_at":"2020-10-09T09:28:40Z","number":1,"active":false,"service_id":"5wBis6DpoO67acK0K7n5GU","testing":false,"updated_at":"2020-10-09T09:28:40Z","locked":false,"staging":false,"deleted_at":null}]}' headers: Accept-Ranges: - bytes @@ -28,11 +28,11 @@ interactions: Content-Type: - application/json Date: - - Wed, 07 Oct 2020 13:09:06 GMT + - Fri, 09 Oct 2020 09:28:40 GMT Fastly-Ratelimit-Remaining: - - "4949" + - "4936" Fastly-Ratelimit-Reset: - - "1602079200" + - "1602237600" Status: - 200 OK Strict-Transport-Security: @@ -47,9 +47,9 @@ interactions: X-Cache-Hits: - 0, 0 X-Served-By: - - cache-control-slwdc9035-CONTROL-SLWDC, cache-lhr7363-LHR + - cache-control-slwdc9036-CONTROL-SLWDC, cache-lon4257-LON X-Timer: - - S1602076146.399215,VS0,VE487 + - S1602235720.463716,VS0,VE474 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/waf_rule_exclusion/update/service/delete.yaml b/fastly/fixtures/waf_rule_exclusion/update/service/delete.yaml new file mode 100644 index 000000000..2ca17b1c3 --- /dev/null +++ b/fastly/fixtures/waf_rule_exclusion/update/service/delete.yaml @@ -0,0 +1,47 @@ +--- +version: 1 +interactions: +- request: + body: "" + form: {} + headers: + User-Agent: + - FastlyGo/1.17.0 (+github.com/fastly/go-fastly; go1.14.5) + url: https://api.fastly.com/service/5wBis6DpoO67acK0K7n5GU + method: DELETE + response: + body: '{"status":"ok"}' + headers: + Accept-Ranges: + - bytes + - bytes + Cache-Control: + - no-cache + Content-Type: + - application/json + Date: + - Fri, 09 Oct 2020 09:28:45 GMT + Fastly-Ratelimit-Remaining: + - "4921" + Fastly-Ratelimit-Reset: + - "1602237600" + Status: + - 200 OK + Strict-Transport-Security: + - max-age=31536000 + Vary: + - Accept-Encoding + Via: + - 1.1 varnish + - 1.1 varnish + X-Cache: + - MISS, MISS + X-Cache-Hits: + - 0, 0 + X-Served-By: + - cache-control-slwdc9035-CONTROL-SLWDC, cache-lon4257-LON + X-Timer: + - S1602235725.224248,VS0,VE222 + status: 200 OK + code: 200 + duration: "" diff --git a/fastly/fixtures/waf_rule_exclusion/update/service/version.yaml b/fastly/fixtures/waf_rule_exclusion/update/service/version.yaml new file mode 100644 index 000000000..dd5600587 --- /dev/null +++ b/fastly/fixtures/waf_rule_exclusion/update/service/version.yaml @@ -0,0 +1,51 @@ +--- +version: 1 +interactions: +- request: + body: Service=5wBis6DpoO67acK0K7n5GU + form: + Service: + - 5wBis6DpoO67acK0K7n5GU + headers: + Content-Type: + - application/x-www-form-urlencoded + User-Agent: + - FastlyGo/1.17.0 (+github.com/fastly/go-fastly; go1.14.5) + url: https://api.fastly.com/service/5wBis6DpoO67acK0K7n5GU/version + method: POST + response: + body: '{"service_id":"5wBis6DpoO67acK0K7n5GU","number":2}' + headers: + Accept-Ranges: + - bytes + - bytes + Cache-Control: + - no-cache + Content-Type: + - application/json + Date: + - Fri, 09 Oct 2020 09:28:41 GMT + Fastly-Ratelimit-Remaining: + - "4929" + Fastly-Ratelimit-Reset: + - "1602237600" + Status: + - 200 OK + Strict-Transport-Security: + - max-age=31536000 + Vary: + - Accept-Encoding + Via: + - 1.1 varnish + - 1.1 varnish + X-Cache: + - MISS, MISS + X-Cache-Hits: + - 0, 0 + X-Served-By: + - cache-control-slwdc9035-CONTROL-SLWDC, cache-lon4257-LON + X-Timer: + - S1602235722.579889,VS0,VE243 + status: 200 OK + code: 200 + duration: "" diff --git a/fastly/fixtures/waf_rule_exclusion/update/waf/create.yaml b/fastly/fixtures/waf_rule_exclusion/update/waf/create.yaml new file mode 100644 index 000000000..f28ea34f0 --- /dev/null +++ b/fastly/fixtures/waf_rule_exclusion/update/waf/create.yaml @@ -0,0 +1,48 @@ +--- +version: 1 +interactions: +- request: + body: | + {"data":{"type":"waf_firewall","attributes":{"prefetch_condition":"","response":"WAf_Response","service_id":"5wBis6DpoO67acK0K7n5GU","service_version_number":"2"}}} + form: {} + headers: + Accept: + - application/vnd.api+json + Content-Type: + - application/vnd.api+json + User-Agent: + - FastlyGo/1.17.0 (+github.com/fastly/go-fastly; go1.14.5) + url: https://api.fastly.com/waf/firewalls + method: POST + response: + body: '{"data":{"id":"6DaBRX0dIm1SjxiB1KQCII","type":"waf_firewall","attributes":{"active_rules_fastly_block_count":0,"active_rules_fastly_log_count":0,"active_rules_fastly_score_count":0,"active_rules_owasp_block_count":0,"active_rules_owasp_log_count":0,"active_rules_owasp_score_count":0,"active_rules_trustwave_block_count":0,"active_rules_trustwave_log_count":0,"created_at":"2020-10-09T09:28:43Z","disabled":false,"prefetch_condition":"","response":"WAf_Response","service_id":"5wBis6DpoO67acK0K7n5GU","service_version_number":2,"updated_at":"2020-10-09T09:28:43Z"}}}' + headers: + Accept-Ranges: + - bytes + - bytes + Content-Length: + - "566" + Content-Type: + - application/vnd.api+json + Date: + - Fri, 09 Oct 2020 09:28:43 GMT + Status: + - 201 Created + Strict-Transport-Security: + - max-age=31536000 + Via: + - 1.1 varnish + - 1.1 varnish + X-Cache: + - MISS, MISS + X-Cache-Hits: + - 0, 0 + X-Content-Type-Options: + - nosniff + X-Served-By: + - cache-control-slwdc9037-CONTROL-SLWDC, cache-lon4257-LON + X-Timer: + - S1602235722.327297,VS0,VE1030 + status: 201 Created + code: 201 + duration: "" diff --git a/fastly/fixtures/waf_rule_exclusion/update/waf/delete.yaml b/fastly/fixtures/waf_rule_exclusion/update/waf/delete.yaml new file mode 100644 index 000000000..0fb5b2919 --- /dev/null +++ b/fastly/fixtures/waf_rule_exclusion/update/waf/delete.yaml @@ -0,0 +1,44 @@ +--- +version: 1 +interactions: +- request: + body: | + {"data":{"type":"waf_firewall","id":"6DaBRX0dIm1SjxiB1KQCII","attributes":{"service_version_number":"1"}}} + form: {} + headers: + Accept: + - application/vnd.api+json + Content-Type: + - application/vnd.api+json + User-Agent: + - FastlyGo/1.17.0 (+github.com/fastly/go-fastly; go1.14.5) + url: https://api.fastly.com/waf/firewalls/6DaBRX0dIm1SjxiB1KQCII + method: DELETE + response: + body: "" + headers: + Accept-Ranges: + - bytes + - bytes + Date: + - Fri, 09 Oct 2020 09:28:45 GMT + Status: + - 204 No Content + Strict-Transport-Security: + - max-age=31536000 + Via: + - 1.1 varnish + - 1.1 varnish + X-Cache: + - MISS, MISS + X-Cache-Hits: + - 0, 0 + X-Content-Type-Options: + - nosniff + X-Served-By: + - cache-control-slwdc9036-CONTROL-SLWDC, cache-lon4257-LON + X-Timer: + - S1602235725.768237,VS0,VE424 + status: 204 No Content + code: 204 + duration: "" diff --git a/fastly/fixtures/waf_exclusion/create/waf_exclusions/create.yaml b/fastly/fixtures/waf_rule_exclusion/update/waf_rule_exclusions/create.yaml similarity index 77% rename from fastly/fixtures/waf_exclusion/create/waf_exclusions/create.yaml rename to fastly/fixtures/waf_rule_exclusion/update/waf_rule_exclusions/create.yaml index 4308556bf..cd163633e 100644 --- a/fastly/fixtures/waf_exclusion/create/waf_exclusions/create.yaml +++ b/fastly/fixtures/waf_rule_exclusion/update/waf_rule_exclusions/create.yaml @@ -12,11 +12,11 @@ interactions: - application/vnd.api+json User-Agent: - FastlyGo/1.17.0 (+github.com/fastly/go-fastly; go1.14.5) - url: https://api.fastly.com/waf/firewalls/0PJDTfXzU9F4KsTErnB41h/versions/1/exclusions + url: https://api.fastly.com/waf/firewalls/6DaBRX0dIm1SjxiB1KQCII/versions/1/exclusions method: POST response: - body: '{"data":{"id":"1pyqLOEXniQ7MDp6CU7nc2","type":"waf_exclusion","attributes":{"created_at":"2020-10-07T13:09:09Z","exclusion_type":"rule","condition":"req.url.basename - == \"index.html\"","name":"index page","number":1,"updated_at":"2020-10-07T13:09:09Z"},"relationships":{"waf_rules":{"data":[{"id":"1YveWU8qwEYidE8WAiZqCN","type":"waf_rule"},{"id":"VovV0PIWJCm33k1piDpnX","type":"waf_rule"}]}}}}' + body: '{"data":{"id":"7LAsmbcxHBgJNsapohlCZK","type":"waf_exclusion","attributes":{"created_at":"2020-10-09T09:28:43Z","exclusion_type":"rule","condition":"req.url.basename + == \"index.html\"","name":"index page","number":1,"updated_at":"2020-10-09T09:28:43Z"},"relationships":{"waf_rules":{"data":[{"id":"1YveWU8qwEYidE8WAiZqCN","type":"waf_rule"},{"id":"VovV0PIWJCm33k1piDpnX","type":"waf_rule"}]}}}}' headers: Accept-Ranges: - bytes @@ -26,7 +26,7 @@ interactions: Content-Type: - application/vnd.api+json Date: - - Wed, 07 Oct 2020 13:09:09 GMT + - Fri, 09 Oct 2020 09:28:43 GMT Status: - 201 Created Strict-Transport-Security: @@ -41,9 +41,9 @@ interactions: X-Content-Type-Options: - nosniff X-Served-By: - - cache-control-slwdc9037-CONTROL-SLWDC, cache-lhr7363-LHR + - cache-control-slwdc9035-CONTROL-SLWDC, cache-lon4257-LON X-Timer: - - S1602076149.426656,VS0,VE148 + - S1602235724.696269,VS0,VE171 status: 201 Created code: 201 duration: "" diff --git a/fastly/fixtures/waf_rule_exclusion/update/waf_rule_exclusions/list.yaml b/fastly/fixtures/waf_rule_exclusion/update/waf_rule_exclusions/list.yaml new file mode 100644 index 000000000..056be9f62 --- /dev/null +++ b/fastly/fixtures/waf_rule_exclusion/update/waf_rule_exclusions/list.yaml @@ -0,0 +1,48 @@ +--- +version: 1 +interactions: +- request: + body: "" + form: {} + headers: + User-Agent: + - FastlyGo/1.17.0 (+github.com/fastly/go-fastly; go1.14.5) + url: https://api.fastly.com/waf/firewalls/6DaBRX0dIm1SjxiB1KQCII/versions/1/exclusions?include=waf_rules&page%5Bnumber%5D=1&page%5Bsize%5D=100 + method: GET + response: + body: '{"data":[{"id":"7LAsmbcxHBgJNsapohlCZK","type":"waf_exclusion","attributes":{"created_at":"2020-10-09T09:28:43Z","exclusion_type":"rule","condition":"req.url.basename + == \"index.html\"","name":"index page","number":1,"updated_at":"2020-10-09T09:28:43Z"},"relationships":{"waf_rules":{"data":[{"id":"16kRBJ5RrNGYcnQ9EEiawe","type":"waf_rule"},{"id":"1YveWU8qwEYidE8WAiZqCN","type":"waf_rule"}]}}}],"included":[{"id":"16kRBJ5RrNGYcnQ9EEiawe","type":"waf_rule","attributes":{"modsec_rule_id":21032607,"publisher":"trustwave","type":"strict"}},{"id":"1YveWU8qwEYidE8WAiZqCN","type":"waf_rule","attributes":{"modsec_rule_id":2029718,"publisher":"trustwave","type":"strict"}}],"links":{"last":"https://api.fastly.com/waf/firewalls/6DaBRX0dIm1SjxiB1KQCII/versions/1/exclusions?include=waf_rules\u0026page[number]=1\u0026page[size]=100","first":"https://api.fastly.com/waf/firewalls/6DaBRX0dIm1SjxiB1KQCII/versions/1/exclusions?include=waf_rules\u0026page[number]=1\u0026page[size]=100"},"meta":{"current_page":1,"per_page":100,"record_count":1,"total_pages":1}}' + headers: + Accept-Ranges: + - bytes + - bytes + - bytes + Age: + - "0" + - "0" + Content-Length: + - "1054" + Content-Type: + - application/vnd.api+json + Date: + - Fri, 09 Oct 2020 09:28:44 GMT + Status: + - 200 OK + Strict-Transport-Security: + - max-age=31536000 + Via: + - 1.1 varnish + - 1.1 varnish + X-Cache: + - MISS, MISS + X-Cache-Hits: + - 0, 0 + X-Content-Type-Options: + - nosniff + X-Served-By: + - cache-control-slwdc9037-CONTROL-SLWDC, cache-lon4257-LON + X-Timer: + - S1602235724.211804,VS0,VE467 + status: 200 OK + code: 200 + duration: "" diff --git a/fastly/fixtures/waf_exclusion/update/waf_exclusions/update.yaml b/fastly/fixtures/waf_rule_exclusion/update/waf_rule_exclusions/update.yaml similarity index 61% rename from fastly/fixtures/waf_exclusion/update/waf_exclusions/update.yaml rename to fastly/fixtures/waf_rule_exclusion/update/waf_rule_exclusions/update.yaml index bfba3a2ed..fdcea4124 100644 --- a/fastly/fixtures/waf_exclusion/update/waf_exclusions/update.yaml +++ b/fastly/fixtures/waf_rule_exclusion/update/waf_rule_exclusions/update.yaml @@ -3,7 +3,7 @@ version: 1 interactions: - request: body: | - {"data":{"type":"waf_exclusion","attributes":{"condition":"req.url.basename == \"index.html\"","exclusion_type":"rule","name":"index page","number":null},"relationships":{"waf_rules":{"data":[{"type":"waf_rule","id":"2029718"},{"type":"waf_rule","id":"1010070"}]}}},"included":[{"type":"waf_rule","id":"1010070","attributes":{"modsec_rule_id":1010070}},{"type":"waf_rule","id":"2029718","attributes":{"modsec_rule_id":2029718}}]} + {"data":{"type":"waf_exclusion","attributes":{"condition":"req.url.basename == \"index.html\"","exclusion_type":"rule","name":"index page","number":null},"relationships":{"waf_rules":{"data":[{"type":"waf_rule","id":"2029718"},{"type":"waf_rule","id":"21032607"}]}}},"included":[{"type":"waf_rule","id":"2029718","attributes":{"modsec_rule_id":2029718}},{"type":"waf_rule","id":"21032607","attributes":{"modsec_rule_id":21032607}}]} form: {} headers: Accept: @@ -12,11 +12,11 @@ interactions: - application/vnd.api+json User-Agent: - FastlyGo/1.17.0 (+github.com/fastly/go-fastly; go1.14.5) - url: https://api.fastly.com/waf/firewalls/6YqagDC62Z4bIFpsNBzxVm/versions/1/exclusions/1 + url: https://api.fastly.com/waf/firewalls/6DaBRX0dIm1SjxiB1KQCII/versions/1/exclusions/1 method: PATCH response: - body: '{"data":{"id":"4eV7U9toc5h0Yqi9Vm1hcN","type":"waf_exclusion","attributes":{"created_at":"2020-10-07T13:09:09Z","exclusion_type":"rule","condition":"req.url.basename - == \"index.html\"","name":"index page","number":1,"updated_at":"2020-10-07T13:09:09Z"},"relationships":{"waf_rules":{"data":[{"id":"1YveWU8qwEYidE8WAiZqCN","type":"waf_rule"},{"id":"62NGF4KWy1v17yyV1vmPdb","type":"waf_rule"}]}}}}' + body: '{"data":{"id":"7LAsmbcxHBgJNsapohlCZK","type":"waf_exclusion","attributes":{"created_at":"2020-10-09T09:28:43Z","exclusion_type":"rule","condition":"req.url.basename + == \"index.html\"","name":"index page","number":1,"updated_at":"2020-10-09T09:28:43Z"},"relationships":{"waf_rules":{"data":[{"id":"16kRBJ5RrNGYcnQ9EEiawe","type":"waf_rule"},{"id":"1YveWU8qwEYidE8WAiZqCN","type":"waf_rule"}]}}}}' headers: Accept-Ranges: - bytes @@ -26,7 +26,7 @@ interactions: Content-Type: - application/vnd.api+json Date: - - Wed, 07 Oct 2020 13:09:10 GMT + - Fri, 09 Oct 2020 09:28:44 GMT Status: - 200 OK Strict-Transport-Security: @@ -41,9 +41,9 @@ interactions: X-Content-Type-Options: - nosniff X-Served-By: - - cache-control-slwdc9035-CONTROL-SLWDC, cache-lhr7363-LHR + - cache-control-slwdc9037-CONTROL-SLWDC, cache-lon4257-LON X-Timer: - - S1602076150.106747,VS0,VE598 + - S1602235724.948516,VS0,VE160 status: 200 OK code: 200 duration: "" diff --git a/fastly/waf_exclusion.go b/fastly/waf_rule_exclusion.go similarity index 63% rename from fastly/waf_exclusion.go rename to fastly/waf_rule_exclusion.go index 8731d0020..4b74b4eb5 100644 --- a/fastly/waf_exclusion.go +++ b/fastly/waf_rule_exclusion.go @@ -11,19 +11,19 @@ import ( "github.com/google/jsonapi" ) -// WAFExclusionType is used for reflection because JSONAPI wants to know what it's +// WAFRuleExclusionType is used for reflection because JSONAPI wants to know what it's // decoding into. -var WAFExclusionType = reflect.TypeOf(new(WAFExclusion)) +var WAFRuleExclusionType = reflect.TypeOf(new(WAFRuleExclusion)) const ( - // WAFExclusionTypeRule is the type of WAF exclusions that excludes rules from the WAF based on certain conditions - WAFExclusionTypeRule = "rule" - // WAFExclusionTypeWAF is the type of WAF exclusions that excludes WAF based on certain conditions - WAFExclusionTypeWAF = "waf" + // WAFRuleExclusionTypeRule is the type of WAF rule exclusions that excludes rules from the WAF based on certain conditions. + WAFRuleExclusionTypeRule = "rule" + // WAFRuleExclusionTypeWAF is the type of WAF rule exclusions that excludes WAF based on certain conditions. + WAFRuleExclusionTypeWAF = "waf" ) -// WAFExclusion is the information about a WAF exclusion object. -type WAFExclusion struct { +// WAFRuleExclusion is the information about a WAF rule exclusion object. +type WAFRuleExclusion struct { ID string `jsonapi:"primary,waf_exclusion"` Name *string `jsonapi:"attr,name"` ExclusionType *string `jsonapi:"attr,exclusion_type"` @@ -34,14 +34,14 @@ type WAFExclusion struct { UpdatedAt *time.Time `jsonapi:"attr,updated_at,iso8601,omitempty"` } -// WAFExclusionResponse represents a list of exclusions - full response. -type WAFExclusionResponse struct { - Items []*WAFExclusion +// WAFRuleExclusionResponse represents a list of rule exclusions - full response. +type WAFRuleExclusionResponse struct { + Items []*WAFRuleExclusion Info infoResponse } -// ListWAFExclusionsInput used as input for listing a WAF's exclusions. -type ListWAFExclusionsInput struct { +// ListWAFRuleExclusionsInput used as input for listing a WAF's rule exclusions. +type ListWAFRuleExclusionsInput struct { // The Web Application Firewall's ID. WAFID string // The Web Application Firewall's version number. @@ -60,8 +60,8 @@ type ListWAFExclusionsInput struct { Include *string } -// ListAllWAFExclusionsInput used as input for listing all WAF exclusions. -type ListAllWAFExclusionsInput struct { +// ListAllWAFRuleExclusionsInput used as input for listing all WAF rule exclusions. +type ListAllWAFRuleExclusionsInput struct { // The Web Application Firewall's ID. WAFID string // The Web Application Firewall's version number. @@ -76,39 +76,39 @@ type ListAllWAFExclusionsInput struct { Include *string } -// CreateWAFExclusionInput used as input to create a WAF exclusion. -type CreateWAFExclusionInput struct { +// CreateWAFRuleExclusionInput used as input to create a WAF rule exclusion. +type CreateWAFRuleExclusionInput struct { // The Web Application Firewall's ID. WAFID string // The Web Application Firewall's version number. WAFVersionNumber int // The Web Application Firewall's exclusion - WAFExclusion *WAFExclusion + WAFRuleExclusion *WAFRuleExclusion } -// UpdateWAFExclusionInput is used for exclusions updates. -type UpdateWAFExclusionInput struct { +// UpdateWAFRuleExclusionInput is used for exclusions updates. +type UpdateWAFRuleExclusionInput struct { // The Web Application Firewall's ID. WAFID string // The Web Application Firewall's version number. WAFVersionNumber int // The exclusion number. Number int - // The WAF exclusion - WAFExclusion *WAFExclusion + // The WAF rule exclusion + WAFRuleExclusion *WAFRuleExclusion } -// DeleteWAFExclusionInput used as input for removing WAF exclusions. -type DeleteWAFExclusionInput struct { +// DeleteWAFRuleExclusionInput used as input for removing WAF rule exclusions. +type DeleteWAFRuleExclusionInput struct { // The Web Application Firewall's ID. WAFID string // The Web Application Firewall's version number. WAFVersionNumber int - // The exclusion number. + // The rule exclusion number. Number int } -func (i *ListWAFExclusionsInput) formatFilters() map[string]string { +func (i *ListWAFRuleExclusionsInput) formatFilters() map[string]string { result := map[string]string{} pairings := map[string]interface{}{ @@ -135,8 +135,8 @@ func (i *ListWAFExclusionsInput) formatFilters() map[string]string { return result } -// ListWAFExclusions returns the list of exclusions for a given WAF ID. -func (c *Client) ListWAFExclusions(i *ListWAFExclusionsInput) (*WAFExclusionResponse, error) { +// ListWAFRuleExclusions returns the list of exclusions for a given WAF ID. +func (c *Client) ListWAFRuleExclusions(i *ListWAFRuleExclusionsInput) (*WAFRuleExclusionResponse, error) { if i.WAFID == "" { return nil, ErrMissingWAFID @@ -162,28 +162,28 @@ func (c *Client) ListWAFExclusions(i *ListWAFExclusionsInput) (*WAFExclusionResp return nil, err } - data, err := jsonapi.UnmarshalManyPayload(bytes.NewReader(buf.Bytes()), WAFExclusionType) + data, err := jsonapi.UnmarshalManyPayload(bytes.NewReader(buf.Bytes()), WAFRuleExclusionType) if err != nil { return nil, err } - wafExclusions := make([]*WAFExclusion, len(data)) + wafExclusions := make([]*WAFRuleExclusion, len(data)) for i := range data { - typed, ok := data[i].(*WAFExclusion) + typed, ok := data[i].(*WAFRuleExclusion) if !ok { - return nil, fmt.Errorf("got back a non-WAFExclusion response") + return nil, fmt.Errorf("got back a non-WAFRuleExclusion response") } wafExclusions[i] = typed } - return &WAFExclusionResponse{ + return &WAFRuleExclusionResponse{ Items: wafExclusions, Info: info, }, nil } -// ListAllWAFExclusions returns the complete list of WAF exclusions for a given WAF ID. It iterates through -// all existing pages to ensure all WAF exclusions are returned at once. -func (c *Client) ListAllWAFExclusions(i *ListAllWAFExclusionsInput) (*WAFExclusionResponse, error) { +// ListAllWAFRuleExclusions returns the complete list of WAF rule exclusions for a given WAF ID. It iterates through +// all existing pages to ensure all WAF rule exclusions are returned at once. +func (c *Client) ListAllWAFRuleExclusions(i *ListAllWAFRuleExclusionsInput) (*WAFRuleExclusionResponse, error) { if i.WAFID == "" { return nil, ErrMissingWAFID @@ -195,9 +195,9 @@ func (c *Client) ListAllWAFExclusions(i *ListAllWAFExclusionsInput) (*WAFExclusi currentPage := 1 pageSize := WAFPaginationPageSize - result := &WAFExclusionResponse{Items: []*WAFExclusion{}} + result := &WAFRuleExclusionResponse{Items: []*WAFRuleExclusion{}} for { - r, err := c.ListWAFExclusions(&ListWAFExclusionsInput{ + r, err := c.ListWAFRuleExclusions(&ListWAFRuleExclusionsInput{ WAFID: i.WAFID, WAFVersionNumber: i.WAFVersionNumber, PageNumber: ¤tPage, @@ -220,8 +220,8 @@ func (c *Client) ListAllWAFExclusions(i *ListAllWAFExclusionsInput) (*WAFExclusi } } -// CreateWAFExclusion used to create a particular WAF exclusion. -func (c *Client) CreateWAFExclusion(i *CreateWAFExclusionInput) (*WAFExclusion, error) { +// CreateWAFRuleExclusion used to create a particular WAF rule exclusion. +func (c *Client) CreateWAFRuleExclusion(i *CreateWAFRuleExclusionInput) (*WAFRuleExclusion, error) { if i.WAFID == "" { return nil, ErrMissingWAFID @@ -231,25 +231,25 @@ func (c *Client) CreateWAFExclusion(i *CreateWAFExclusionInput) (*WAFExclusion, return nil, ErrMissingWAFVersionNumber } - if i.WAFExclusion == nil { - return nil, ErrMissingWAFExclusion + if i.WAFRuleExclusion == nil { + return nil, ErrMissingWAFRuleExclusion } path := fmt.Sprintf("/waf/firewalls/%s/versions/%d/exclusions", i.WAFID, i.WAFVersionNumber) - resp, err := c.PostJSONAPI(path, i.WAFExclusion, nil) + resp, err := c.PostJSONAPI(path, i.WAFRuleExclusion, nil) if err != nil { return nil, err } - var wafExclusion WAFExclusion + var wafExclusion WAFRuleExclusion if err := jsonapi.UnmarshalPayload(resp.Body, &wafExclusion); err != nil { return nil, err } return &wafExclusion, nil } -// UpdateWAFExclusion used to update a particular WAF exclusion. -func (c *Client) UpdateWAFExclusion(i *UpdateWAFExclusionInput) (*WAFExclusion, error) { +// UpdateWAFRuleExclusion used to update a particular WAF rule exclusion. +func (c *Client) UpdateWAFRuleExclusion(i *UpdateWAFRuleExclusionInput) (*WAFRuleExclusion, error) { if i.WAFID == "" { return nil, ErrMissingWAFID } @@ -259,20 +259,20 @@ func (c *Client) UpdateWAFExclusion(i *UpdateWAFExclusionInput) (*WAFExclusion, } if i.Number == 0 { - return nil, ErrMissingWAFExclusionNumber + return nil, ErrMissingWAFRuleExclusionNumber } - if i.WAFExclusion == nil { - return nil, ErrMissingWAFExclusion + if i.WAFRuleExclusion == nil { + return nil, ErrMissingWAFRuleExclusion } path := fmt.Sprintf("/waf/firewalls/%s/versions/%d/exclusions/%d", i.WAFID, i.WAFVersionNumber, i.Number) - resp, err := c.PatchJSONAPI(path, i.WAFExclusion, nil) + resp, err := c.PatchJSONAPI(path, i.WAFRuleExclusion, nil) if err != nil { return nil, err } - var exc *WAFExclusion + var exc *WAFRuleExclusion if err := decodeBodyMap(resp.Body, &exc); err != nil { return nil, err } @@ -280,7 +280,7 @@ func (c *Client) UpdateWAFExclusion(i *UpdateWAFExclusionInput) (*WAFExclusion, } // DeleteWAFExclusions removes rules from a particular WAF. -func (c *Client) DeleteWAFExclusion(i *DeleteWAFExclusionInput) error { +func (c *Client) DeleteWAFRuleExclusion(i *DeleteWAFRuleExclusionInput) error { if i.WAFID == "" { return ErrMissingWAFID } @@ -288,7 +288,7 @@ func (c *Client) DeleteWAFExclusion(i *DeleteWAFExclusionInput) error { return ErrMissingWAFVersionNumber } if i.Number == 0 { - return ErrMissingWAFExclusionNumber + return ErrMissingWAFRuleExclusionNumber } path := fmt.Sprintf("/waf/firewalls/%s/versions/%d/exclusions/%d", i.WAFID, i.WAFVersionNumber, i.Number) diff --git a/fastly/waf_exclusion_test.go b/fastly/waf_rule_exclusion_test.go similarity index 50% rename from fastly/waf_exclusion_test.go rename to fastly/waf_rule_exclusion_test.go index 8769641f2..15d248e33 100644 --- a/fastly/waf_exclusion_test.go +++ b/fastly/waf_rule_exclusion_test.go @@ -7,146 +7,146 @@ import ( "testing" ) -func TestClient_WAF_Exclusion_list(t *testing.T) { +func TestClient_WAF_Rule_Exclusion_list(t *testing.T) { t.Parallel() - fixtureBase := "waf_exclusion/list/" + fixtureBase := "waf_rule_exclusion/list/" testService, serviceVersion, responseName := createServiceForWAF(t, fixtureBase) - waf := createWAFWithRules(t, fixtureBase, testService, serviceVersion, responseName) + waf := createWAFWithRulesForExclusion(t, fixtureBase, testService, serviceVersion, responseName) defer deleteTestService(t, fixtureBase+"service/delete", testService.ID) defer deleteWAF(t, fixtureBase+"waf/delete", waf.ID, "1") - excl1In := buildWAFExclusion1(waf.ID, 1) - excl2In := buildWAFExclusion2(waf.ID, 1) - createWAFExclusion(t, fixtureBase+"waf_exclusions/create-1", excl1In) - createWAFExclusion(t, fixtureBase+"waf_exclusions/create-2", excl2In) + excl1In := buildWAFRuleExclusion1(waf.ID, 1) + excl2In := buildWAFRuleExclusion2(waf.ID, 1) + createWAFRuleExclusion(t, fixtureBase+"waf_rule_exclusions/create-1", excl1In) + createWAFRuleExclusion(t, fixtureBase+"waf_rule_exclusions/create-2", excl2In) - exclResp := listWAFExclusions(t, fixtureBase+"waf_exclusions/list", waf, "waf_rules") + exclResp := listWAFRuleExclusions(t, fixtureBase+"waf_rule_exclusions/list", waf, "waf_rules") if len(exclResp.Items) != 2 { - t.Errorf("expected 2 waf exclusions: got %d", len(exclResp.Items)) + t.Errorf("expected 2 waf rule exclusions: got %d", len(exclResp.Items)) } - assertWAFExclusionEquals(t, exclResp.Items[0], excl1In.WAFExclusion) - assertWAFExclusionEquals(t, exclResp.Items[1], excl2In.WAFExclusion) + assertWAFRuleExclusionEquals(t, exclResp.Items[0], excl1In.WAFRuleExclusion) + assertWAFRuleExclusionEquals(t, exclResp.Items[1], excl2In.WAFRuleExclusion) } -func TestClient_WAF_Exclusion_list_filters(t *testing.T) { +func TestClient_WAF_Rule_Exclusion_list_filters(t *testing.T) { t.Parallel() - fixtureBase := "waf_exclusion/list_filters/" + fixtureBase := "waf_rule_exclusion/list_filters/" testService, serviceVersion, responseName := createServiceForWAF(t, fixtureBase) - waf := createWAFWithRules(t, fixtureBase, testService, serviceVersion, responseName) + waf := createWAFWithRulesForExclusion(t, fixtureBase, testService, serviceVersion, responseName) defer deleteTestService(t, fixtureBase+"service/delete", testService.ID) defer deleteWAF(t, fixtureBase+"waf/delete", waf.ID, "1") - excl1In := buildWAFExclusion1(waf.ID, 1) - excl2In := buildWAFExclusion2(waf.ID, 1) + excl1In := buildWAFRuleExclusion1(waf.ID, 1) + excl2In := buildWAFRuleExclusion2(waf.ID, 1) excl3In := buildWAFExclusionWAF(waf.ID, 1) - createWAFExclusion(t, fixtureBase+"waf_exclusions/create-1", excl1In) - createWAFExclusion(t, fixtureBase+"waf_exclusions/create-2", excl2In) - createWAFExclusion(t, fixtureBase+"waf_exclusions/create-3", excl3In) + createWAFRuleExclusion(t, fixtureBase+"waf_rule_exclusions/create-1", excl1In) + createWAFRuleExclusion(t, fixtureBase+"waf_rule_exclusions/create-2", excl2In) + createWAFRuleExclusion(t, fixtureBase+"waf_rule_exclusions/create-3", excl3In) - exclResp := listWAFExclusionsWithFilters(t, fixtureBase+"waf_exclusions/list", &ListAllWAFExclusionsInput{ + exclResp := listWAFExclusionsWithFilters(t, fixtureBase+"waf_rule_exclusions/list", &ListAllWAFRuleExclusionsInput{ WAFID: waf.ID, WAFVersionNumber: 1, - FilterExclusionType: strToPtr(WAFExclusionTypeRule), - FilterModSedID: strToPtr("1010070"), + FilterExclusionType: strToPtr(WAFRuleExclusionTypeRule), + FilterModSedID: strToPtr("21032607"), Include: strToPtr("waf_rules"), }) if len(exclResp.Items) != 1 { - t.Errorf("expected 2 waf exclusions: got %d", len(exclResp.Items)) + t.Errorf("expected 2 waf rule exclusions: got %d", len(exclResp.Items)) } - assertWAFExclusionEquals(t, exclResp.Items[0], excl2In.WAFExclusion) + assertWAFRuleExclusionEquals(t, exclResp.Items[0], excl2In.WAFRuleExclusion) } -func TestClient_WAF_Exclusion_create(t *testing.T) { +func TestClient_WAF_Rule_Exclusion_create(t *testing.T) { t.Parallel() - fixtureBase := "waf_exclusion/create/" + fixtureBase := "waf_rule_exclusion/create/" testService, serviceVersion, responseName := createServiceForWAF(t, fixtureBase) - waf := createWAFWithRules(t, fixtureBase, testService, serviceVersion, responseName) + waf := createWAFWithRulesForExclusion(t, fixtureBase, testService, serviceVersion, responseName) defer deleteTestService(t, fixtureBase+"service/delete", testService.ID) defer deleteWAF(t, fixtureBase+"waf/delete", waf.ID, "1") - exclIn := buildWAFExclusion1(waf.ID, 1) - createWAFExclusion(t, fixtureBase+"waf_exclusions/create", exclIn) + exclIn := buildWAFRuleExclusion1(waf.ID, 1) + createWAFRuleExclusion(t, fixtureBase+"waf_rule_exclusions/create", exclIn) - exclResp := listWAFExclusions(t, fixtureBase+"waf_exclusions/list", waf, "waf_rules") + exclResp := listWAFRuleExclusions(t, fixtureBase+"waf_rule_exclusions/list", waf, "waf_rules") if len(exclResp.Items) != 1 { - t.Errorf("expected 2 waf exclusions: got %d", len(exclResp.Items)) + t.Errorf("expected 2 waf rule exclusions: got %d", len(exclResp.Items)) } - assertWAFExclusionEquals(t, exclResp.Items[0], exclIn.WAFExclusion) + assertWAFRuleExclusionEquals(t, exclResp.Items[0], exclIn.WAFRuleExclusion) } -func TestClient_WAF_Exclusion_update(t *testing.T) { +func TestClient_WAF_Rule_Exclusion_update(t *testing.T) { t.Parallel() - fixtureBase := "waf_exclusion/update/" + fixtureBase := "waf_rule_exclusion/update/" testService, serviceVersion, responseName := createServiceForWAF(t, fixtureBase) - waf := createWAFWithRules(t, fixtureBase, testService, serviceVersion, responseName) + waf := createWAFWithRulesForExclusion(t, fixtureBase, testService, serviceVersion, responseName) defer deleteTestService(t, fixtureBase+"service/delete", testService.ID) defer deleteWAF(t, fixtureBase+"waf/delete", waf.ID, "1") - exclIn := buildWAFExclusion1(waf.ID, 1) - exclOut := createWAFExclusion(t, fixtureBase+"waf_exclusions/create", exclIn) + exclIn := buildWAFRuleExclusion1(waf.ID, 1) + exclOut := createWAFRuleExclusion(t, fixtureBase+"waf_rule_exclusions/create", exclIn) exclUpdateIn := buildWAFExclusion1ForUpdate(waf.ID, 1, *exclOut.Number) - updateWAFExclusion(t, fixtureBase+"waf_exclusions/update", exclUpdateIn) + updateWAFExclusion(t, fixtureBase+"waf_rule_exclusions/update", exclUpdateIn) - exclResp := listWAFExclusions(t, fixtureBase+"waf_exclusions/list", waf, "waf_rules") + exclResp := listWAFRuleExclusions(t, fixtureBase+"waf_rule_exclusions/list", waf, "waf_rules") if len(exclResp.Items) != 1 { t.Errorf("expected 1 waf version: got %d", len(exclResp.Items)) } - assertWAFExclusionEquals(t, exclResp.Items[0], exclIn.WAFExclusion) + assertWAFRuleExclusionEquals(t, exclResp.Items[0], exclIn.WAFRuleExclusion) } -func TestClient_WAF_Exclusion_delete(t *testing.T) { +func TestClient_WAF_Rule_Exclusion_delete(t *testing.T) { t.Parallel() - fixtureBase := "waf_exclusion/delete/" + fixtureBase := "waf_rule_exclusion/delete/" testService, serviceVersion, responseName := createServiceForWAF(t, fixtureBase) - waf := createWAFWithRules(t, fixtureBase, testService, serviceVersion, responseName) + waf := createWAFWithRulesForExclusion(t, fixtureBase, testService, serviceVersion, responseName) defer deleteTestService(t, fixtureBase+"service/delete", testService.ID) defer deleteWAF(t, fixtureBase+"waf/delete", waf.ID, "1") - exclIn := buildWAFExclusion1(waf.ID, 1) - exclOut := createWAFExclusion(t, fixtureBase+"waf_exclusions/create", exclIn) + exclIn := buildWAFRuleExclusion1(waf.ID, 1) + exclOut := createWAFRuleExclusion(t, fixtureBase+"waf_rule_exclusions/create", exclIn) exclUpdateIn := buildWAFExclusion1ForDeletion(waf.ID, 1, *exclOut.Number) - deleteWAFExclusion(t, fixtureBase+"waf_exclusions/update", exclUpdateIn) + deleteWAFExclusion(t, fixtureBase+"waf_rule_exclusions/update", exclUpdateIn) - exclResp := listWAFExclusions(t, fixtureBase+"waf_exclusions/list", waf, "waf_rules") + exclResp := listWAFRuleExclusions(t, fixtureBase+"waf_rule_exclusions/list", waf, "waf_rules") if len(exclResp.Items) != 0 { t.Errorf("expected 0 waf version: got %d", len(exclResp.Items)) } } -func TestClient_ListWAFExclusion_validation(t *testing.T) { +func TestClient_WAF_Rule_Exclusion_list_validation(t *testing.T) { t.Parallel() cases := []struct { - input *ListWAFExclusionsInput + input *ListWAFRuleExclusionsInput expectedError error }{ { - input: &ListWAFExclusionsInput{ + input: &ListWAFRuleExclusionsInput{ WAFID: "", }, expectedError: ErrMissingWAFID, }, { - input: &ListWAFExclusionsInput{ + input: &ListWAFRuleExclusionsInput{ WAFID: "1", WAFVersionNumber: 0, }, @@ -154,27 +154,27 @@ func TestClient_ListWAFExclusion_validation(t *testing.T) { }, } for _, c := range cases { - if _, err := testClient.ListWAFExclusions(c.input); err != c.expectedError { + if _, err := testClient.ListWAFRuleExclusions(c.input); err != c.expectedError { t.Errorf("bad error: %s", err) } } } -func TestClient_ListAllWAFExclusion_validation(t *testing.T) { +func TestClient_WAF_Rule_Exclusion_list_all_validation(t *testing.T) { t.Parallel() cases := []struct { - input *ListAllWAFExclusionsInput + input *ListAllWAFRuleExclusionsInput expectedError error }{ { - input: &ListAllWAFExclusionsInput{ + input: &ListAllWAFRuleExclusionsInput{ WAFID: "", }, expectedError: ErrMissingWAFID, }, { - input: &ListAllWAFExclusionsInput{ + input: &ListAllWAFRuleExclusionsInput{ WAFID: "1", WAFVersionNumber: 0, }, @@ -182,126 +182,126 @@ func TestClient_ListAllWAFExclusion_validation(t *testing.T) { }, } for _, c := range cases { - if _, err := testClient.ListAllWAFExclusions(c.input); err != c.expectedError { + if _, err := testClient.ListAllWAFRuleExclusions(c.input); err != c.expectedError { t.Errorf("bad error: %s", err) } } } -func TestClient_CreateWAFExclusion_validation(t *testing.T) { +func TestClient_WAF_Rule_Exclusion_create_validation(t *testing.T) { t.Parallel() cases := []struct { - input *CreateWAFExclusionInput + input *CreateWAFRuleExclusionInput expectedError error }{ { - input: &CreateWAFExclusionInput{ + input: &CreateWAFRuleExclusionInput{ WAFID: "", }, expectedError: ErrMissingWAFID, }, { - input: &CreateWAFExclusionInput{ + input: &CreateWAFRuleExclusionInput{ WAFID: "1", WAFVersionNumber: 0, }, expectedError: ErrMissingWAFVersionNumber, }, { - input: &CreateWAFExclusionInput{ + input: &CreateWAFRuleExclusionInput{ WAFID: "1", WAFVersionNumber: 1, }, - expectedError: ErrMissingWAFExclusion, + expectedError: ErrMissingWAFRuleExclusion, }, } for _, c := range cases { - if _, err := testClient.CreateWAFExclusion(c.input); err != c.expectedError { + if _, err := testClient.CreateWAFRuleExclusion(c.input); err != c.expectedError { t.Errorf("bad error: %s", err) } } } -func TestClient_UpdateWAFExclusion_validation(t *testing.T) { +func TestClient_WAF_Rule_Exclusion_update_validation(t *testing.T) { t.Parallel() cases := []struct { - input *UpdateWAFExclusionInput + input *UpdateWAFRuleExclusionInput expectedError error }{ { - input: &UpdateWAFExclusionInput{ + input: &UpdateWAFRuleExclusionInput{ WAFID: "", }, expectedError: ErrMissingWAFID, }, { - input: &UpdateWAFExclusionInput{ + input: &UpdateWAFRuleExclusionInput{ WAFID: "1", WAFVersionNumber: 0, }, expectedError: ErrMissingWAFVersionNumber, }, { - input: &UpdateWAFExclusionInput{ + input: &UpdateWAFRuleExclusionInput{ WAFID: "1", WAFVersionNumber: 1, }, - expectedError: ErrMissingWAFExclusionNumber, + expectedError: ErrMissingWAFRuleExclusionNumber, }, { - input: &UpdateWAFExclusionInput{ + input: &UpdateWAFRuleExclusionInput{ WAFID: "1", WAFVersionNumber: 1, Number: 1, }, - expectedError: ErrMissingWAFExclusion, + expectedError: ErrMissingWAFRuleExclusion, }, } for _, c := range cases { - if _, err := testClient.UpdateWAFExclusion(c.input); err != c.expectedError { + if _, err := testClient.UpdateWAFRuleExclusion(c.input); err != c.expectedError { t.Errorf("bad error: %s", err) } } } -func TestClient_DeleteWAFExclusion_validation(t *testing.T) { +func TestClient_WAF_Rule_Exclusion_delete_validation(t *testing.T) { t.Parallel() cases := []struct { - input *DeleteWAFExclusionInput + input *DeleteWAFRuleExclusionInput expectedError error }{ { - input: &DeleteWAFExclusionInput{ + input: &DeleteWAFRuleExclusionInput{ WAFID: "", }, expectedError: ErrMissingWAFID, }, { - input: &DeleteWAFExclusionInput{ + input: &DeleteWAFRuleExclusionInput{ WAFID: "1", WAFVersionNumber: 0, }, expectedError: ErrMissingWAFVersionNumber, }, { - input: &DeleteWAFExclusionInput{ + input: &DeleteWAFRuleExclusionInput{ WAFID: "1", WAFVersionNumber: 1, }, - expectedError: ErrMissingWAFExclusionNumber, + expectedError: ErrMissingWAFRuleExclusionNumber, }, } for _, c := range cases { - if err := testClient.DeleteWAFExclusion(c.input); err != c.expectedError { + if err := testClient.DeleteWAFRuleExclusion(c.input); err != c.expectedError { t.Errorf("bad error: %s", err) } } } -func assertWAFExclusionEquals(t *testing.T, actual *WAFExclusion, expected *WAFExclusion) { +func assertWAFRuleExclusionEquals(t *testing.T, actual *WAFRuleExclusion, expected *WAFRuleExclusion) { if *actual.ExclusionType != *expected.ExclusionType { t.Errorf("expected ExclusionType to be %s got %s", *expected.ExclusionType, *actual.ExclusionType) } @@ -326,11 +326,11 @@ func extractModSecId(wafRule []*WAFRule) []int { return modSecIDs } -func createWAFWithRules(t *testing.T, fixtureBase string, testService *Service, version *Version, responseName string) *WAF { +func createWAFWithRulesForExclusion(t *testing.T, fixtureBase string, testService *Service, version *Version, responseName string) *WAF { waf := createWAF(t, fixtureBase+"waf/create", testService.ID, strconv.Itoa(version.Number), "", responseName) var err error - rulesIn := buildWAFRules("log") + rulesIn := buildWAFRulesForExclusion("log") record(t, fixtureBase+"active_rules/create", func(c *Client) { _, err = c.BatchModificationWAFActiveRules(&BatchModificationWAFActiveRulesInput{ WAFID: waf.ID, @@ -345,6 +345,27 @@ func createWAFWithRules(t *testing.T, fixtureBase string, testService *Service, return waf } +func buildWAFRulesForExclusion(status string) []*WAFActiveRule { + + return []*WAFActiveRule{ + { + ModSecID: 2029718, + Status: status, + Revision: 1, + }, + { + ModSecID: 2037405, + Status: status, + Revision: 1, + }, + { + ModSecID: 21032607, + Status: status, + Revision: 1, + }, + } +} + func createServiceForWAF(t *testing.T, fixtureBase string) (*Service, *Version, string) { service := createTestService(t, fixtureBase+"service/create", "service-"+strconv.Itoa(rand.Int())) version := createTestVersion(t, fixtureBase+"service/version", service.ID) @@ -353,11 +374,11 @@ func createServiceForWAF(t *testing.T, fixtureBase string) (*Service, *Version, return service, version, responseName } -func createWAFExclusion(t *testing.T, fixture string, excl1In *CreateWAFExclusionInput) *WAFExclusion { - var excl1Out *WAFExclusion +func createWAFRuleExclusion(t *testing.T, fixture string, excl1In *CreateWAFRuleExclusionInput) *WAFRuleExclusion { + var excl1Out *WAFRuleExclusion var err error record(t, fixture, func(c *Client) { - excl1Out, err = c.CreateWAFExclusion(excl1In) + excl1Out, err = c.CreateWAFRuleExclusion(excl1In) }) if err != nil { t.Fatal(err) @@ -365,11 +386,11 @@ func createWAFExclusion(t *testing.T, fixture string, excl1In *CreateWAFExclusio return excl1Out } -func updateWAFExclusion(t *testing.T, fixture string, updateExcl *UpdateWAFExclusionInput) *WAFExclusion { +func updateWAFExclusion(t *testing.T, fixture string, updateExcl *UpdateWAFRuleExclusionInput) *WAFRuleExclusion { var err error - var out *WAFExclusion + var out *WAFRuleExclusion record(t, fixture, func(c *Client) { - out, err = c.UpdateWAFExclusion(updateExcl) + out, err = c.UpdateWAFRuleExclusion(updateExcl) }) if err != nil { t.Fatal(err) @@ -377,21 +398,21 @@ func updateWAFExclusion(t *testing.T, fixture string, updateExcl *UpdateWAFExclu return out } -func deleteWAFExclusion(t *testing.T, fixture string, updateExcl *DeleteWAFExclusionInput) { +func deleteWAFExclusion(t *testing.T, fixture string, updateExcl *DeleteWAFRuleExclusionInput) { var err error record(t, fixture, func(c *Client) { - err = c.DeleteWAFExclusion(updateExcl) + err = c.DeleteWAFRuleExclusion(updateExcl) }) if err != nil { t.Fatal(err) } } -func listWAFExclusions(t *testing.T, fixture string, waf *WAF, include string) *WAFExclusionResponse { +func listWAFRuleExclusions(t *testing.T, fixture string, waf *WAF, include string) *WAFRuleExclusionResponse { var err error - var exclResp *WAFExclusionResponse + var exclResp *WAFRuleExclusionResponse record(t, fixture, func(c *Client) { - exclResp, err = c.ListAllWAFExclusions(&ListAllWAFExclusionsInput{ + exclResp, err = c.ListAllWAFRuleExclusions(&ListAllWAFRuleExclusionsInput{ WAFID: waf.ID, WAFVersionNumber: 1, Include: &include, @@ -403,11 +424,11 @@ func listWAFExclusions(t *testing.T, fixture string, waf *WAF, include string) * return exclResp } -func listWAFExclusionsWithFilters(t *testing.T, fixture string, request *ListAllWAFExclusionsInput) *WAFExclusionResponse { +func listWAFExclusionsWithFilters(t *testing.T, fixture string, request *ListAllWAFRuleExclusionsInput) *WAFRuleExclusionResponse { var err error - var exclResp *WAFExclusionResponse + var exclResp *WAFRuleExclusionResponse record(t, fixture, func(c *Client) { - exclResp, err = c.ListAllWAFExclusions(request) + exclResp, err = c.ListAllWAFRuleExclusions(request) }) if err != nil { t.Fatal(err) @@ -415,13 +436,13 @@ func listWAFExclusionsWithFilters(t *testing.T, fixture string, request *ListAll return exclResp } -func buildWAFExclusion1(wafID string, version int) *CreateWAFExclusionInput { - return &CreateWAFExclusionInput{ +func buildWAFRuleExclusion1(wafID string, version int) *CreateWAFRuleExclusionInput { + return &CreateWAFRuleExclusionInput{ WAFID: wafID, WAFVersionNumber: version, - WAFExclusion: &WAFExclusion{ + WAFRuleExclusion: &WAFRuleExclusion{ Name: strToPtr("index page"), - ExclusionType: strToPtr(WAFExclusionTypeRule), + ExclusionType: strToPtr(WAFRuleExclusionTypeRule), Condition: strToPtr("req.url.basename == \"index.html\""), Rules: []*WAFRule{ { @@ -437,44 +458,44 @@ func buildWAFExclusion1(wafID string, version int) *CreateWAFExclusionInput { } } -func buildWAFExclusion2(wafID string, version int) *CreateWAFExclusionInput { - return &CreateWAFExclusionInput{ +func buildWAFRuleExclusion2(wafID string, version int) *CreateWAFRuleExclusionInput { + return &CreateWAFRuleExclusionInput{ WAFID: wafID, WAFVersionNumber: version, - WAFExclusion: &WAFExclusion{ + WAFRuleExclusion: &WAFRuleExclusion{ Name: strToPtr("index php"), - ExclusionType: strToPtr(WAFExclusionTypeRule), + ExclusionType: strToPtr(WAFRuleExclusionTypeRule), Condition: strToPtr("req.url.basename == \"index.php\""), Rules: []*WAFRule{ { - ID: "1010070", - ModSecID: 1010070, + ID: "21032607", + ModSecID: 21032607, }, }, }, } } -func buildWAFExclusionWAF(wafID string, version int) *CreateWAFExclusionInput { - return &CreateWAFExclusionInput{ +func buildWAFExclusionWAF(wafID string, version int) *CreateWAFRuleExclusionInput { + return &CreateWAFRuleExclusionInput{ WAFID: wafID, WAFVersionNumber: version, - WAFExclusion: &WAFExclusion{ + WAFRuleExclusion: &WAFRuleExclusion{ Name: strToPtr("index asp"), - ExclusionType: strToPtr(WAFExclusionTypeWAF), + ExclusionType: strToPtr(WAFRuleExclusionTypeWAF), Condition: strToPtr("req.url.basename == \"index.asp\""), }, } } -func buildWAFExclusion1ForUpdate(wafID string, version, number int) *UpdateWAFExclusionInput { - return &UpdateWAFExclusionInput{ +func buildWAFExclusion1ForUpdate(wafID string, version, number int) *UpdateWAFRuleExclusionInput { + return &UpdateWAFRuleExclusionInput{ WAFID: wafID, WAFVersionNumber: version, Number: number, - WAFExclusion: &WAFExclusion{ + WAFRuleExclusion: &WAFRuleExclusion{ Name: strToPtr("index page"), - ExclusionType: strToPtr(WAFExclusionTypeRule), + ExclusionType: strToPtr(WAFRuleExclusionTypeRule), Condition: strToPtr("req.url.basename == \"index.html\""), Rules: []*WAFRule{ { @@ -482,16 +503,16 @@ func buildWAFExclusion1ForUpdate(wafID string, version, number int) *UpdateWAFEx ModSecID: 2029718, }, { - ID: "1010070", - ModSecID: 1010070, + ID: "21032607", + ModSecID: 21032607, }, }, }, } } -func buildWAFExclusion1ForDeletion(wafID string, version, number int) *DeleteWAFExclusionInput { - return &DeleteWAFExclusionInput{ +func buildWAFExclusion1ForDeletion(wafID string, version, number int) *DeleteWAFRuleExclusionInput { + return &DeleteWAFRuleExclusionInput{ WAFID: wafID, WAFVersionNumber: version, Number: number, From 8addeca8870259286973ba93fb98877afecae3e1 Mon Sep 17 00:00:00 2001 From: Mateus Pimenta <1920261+matpimenta@users.noreply.github.com> Date: Mon, 12 Oct 2020 12:09:15 +0100 Subject: [PATCH 24/37] Changing Include field to be a Slice instead of a comma-separated string --- fastly/waf_rule_exclusion.go | 17 ++++++++++++----- fastly/waf_rule_exclusion_test.go | 4 ++-- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/fastly/waf_rule_exclusion.go b/fastly/waf_rule_exclusion.go index 4b74b4eb5..0484cca91 100644 --- a/fastly/waf_rule_exclusion.go +++ b/fastly/waf_rule_exclusion.go @@ -6,6 +6,7 @@ import ( "io" "reflect" "strconv" + "strings" "time" "github.com/google/jsonapi" @@ -56,8 +57,8 @@ type ListWAFRuleExclusionsInput struct { PageSize *int // Request a specific page of exclusions. PageNumber *int - // Include relationships. Optional, comma-separated values. Permitted values: waf_rule_revision and waf_firewall_version. - Include *string + // Include relationships. Optional. Permitted values: waf_rules. + Include []string } // ListAllWAFRuleExclusionsInput used as input for listing all WAF rule exclusions. @@ -72,8 +73,8 @@ type ListAllWAFRuleExclusionsInput struct { FilterName *string // Limit results to exclusions that represent the specified ModSecurity modsec_rule_id. FilterModSedID *string - // Include relationships. Optional, comma-separated values. Permitted values: waf_rule_revision and waf_firewall_version. - Include *string + // Include relationships. Optional. Permitted values: waf_rules. + Include []string } // CreateWAFRuleExclusionInput used as input to create a WAF rule exclusion. @@ -110,6 +111,8 @@ type DeleteWAFRuleExclusionInput struct { func (i *ListWAFRuleExclusionsInput) formatFilters() map[string]string { + include := strings.Join(i.Include, ",") + result := map[string]string{} pairings := map[string]interface{}{ "filter[exclusion_type]": i.FilterExclusionType, @@ -117,11 +120,15 @@ func (i *ListWAFRuleExclusionsInput) formatFilters() map[string]string { "filter[waf_rules.modsec_rule_id]": i.FilterModSedID, "page[size]": i.PageSize, "page[number]": i.PageNumber, - "include": i.Include, + "include": include, } for key, value := range pairings { switch value := value.(type) { + case string: + if value != "" { + result[key] = value + } case *string: if value != nil { result[key] = *value diff --git a/fastly/waf_rule_exclusion_test.go b/fastly/waf_rule_exclusion_test.go index 15d248e33..3648fc0d9 100644 --- a/fastly/waf_rule_exclusion_test.go +++ b/fastly/waf_rule_exclusion_test.go @@ -55,7 +55,7 @@ func TestClient_WAF_Rule_Exclusion_list_filters(t *testing.T) { WAFVersionNumber: 1, FilterExclusionType: strToPtr(WAFRuleExclusionTypeRule), FilterModSedID: strToPtr("21032607"), - Include: strToPtr("waf_rules"), + Include: []string{"waf_rules"}, }) if len(exclResp.Items) != 1 { t.Errorf("expected 2 waf rule exclusions: got %d", len(exclResp.Items)) @@ -415,7 +415,7 @@ func listWAFRuleExclusions(t *testing.T, fixture string, waf *WAF, include strin exclResp, err = c.ListAllWAFRuleExclusions(&ListAllWAFRuleExclusionsInput{ WAFID: waf.ID, WAFVersionNumber: 1, - Include: &include, + Include: []string{include}, }) }) if err != nil { From 375448a478a6c0f7eb15702f52cd08c487d7b3dd Mon Sep 17 00:00:00 2001 From: integralist Date: Thu, 5 Nov 2020 15:28:37 +0000 Subject: [PATCH 25/37] field consistency: ServiceID, ServiceVersion, DictionaryID, PoolID --- fastly/acl.go | 94 ++++++++-------- fastly/acl_entry.go | 12 +- fastly/acl_entry_test.go | 12 +- fastly/acl_test.go | 118 +++++++++---------- fastly/backend.go | 94 ++++++++-------- fastly/backend_test.go | 110 +++++++++--------- fastly/bigquery.go | 94 ++++++++-------- fastly/bigquery_test.go | 128 ++++++++++----------- fastly/blobstorage.go | 94 ++++++++-------- fastly/blobstorage_test.go | 108 +++++++++--------- fastly/cache_setting.go | 94 ++++++++-------- fastly/cache_setting_test.go | 116 +++++++++---------- fastly/cloudfiles.go | 94 ++++++++-------- fastly/cloudfiles_test.go | 116 +++++++++---------- fastly/condition.go | 94 ++++++++-------- fastly/condition_test.go | 110 +++++++++--------- fastly/datadog.go | 94 ++++++++-------- fastly/datadog_test.go | 122 ++++++++++---------- fastly/dictionary.go | 94 ++++++++-------- fastly/dictionary_info.go | 12 +- fastly/dictionary_info_test.go | 24 ++-- fastly/dictionary_item.go | 99 ++++++++-------- fastly/dictionary_item_batch_test.go | 44 ++++---- fastly/dictionary_item_test.go | 110 +++++++++--------- fastly/dictionary_test.go | 110 +++++++++--------- fastly/diff.go | 10 +- fastly/diff_test.go | 40 +++---- fastly/digitalocean.go | 94 ++++++++-------- fastly/digitalocean_test.go | 110 +++++++++--------- fastly/director.go | 94 ++++++++-------- fastly/director_backend.go | 57 +++++----- fastly/director_backend_test.go | 90 +++++++-------- fastly/director_test.go | 118 +++++++++---------- fastly/domain.go | 95 ++++++++-------- fastly/domain_test.go | 112 +++++++++--------- fastly/elasticsearch.go | 94 ++++++++-------- fastly/elasticsearch_test.go | 110 +++++++++--------- fastly/errors.go | 12 +- fastly/fastly_test.go | 110 +++++++++--------- fastly/ftp.go | 94 ++++++++-------- fastly/ftp_test.go | 110 +++++++++--------- fastly/gcs.go | 94 ++++++++-------- fastly/gcs_test.go | 110 +++++++++--------- fastly/gzip.go | 94 ++++++++-------- fastly/gzip_test.go | 126 ++++++++++----------- fastly/header.go | 94 ++++++++-------- fastly/header_test.go | 126 ++++++++++----------- fastly/health_check.go | 94 ++++++++-------- fastly/health_check_test.go | 108 +++++++++--------- fastly/heroku.go | 94 ++++++++-------- fastly/heroku_test.go | 122 ++++++++++---------- fastly/honeycomb.go | 94 ++++++++-------- fastly/honeycomb_test.go | 124 ++++++++++---------- fastly/https.go | 94 ++++++++-------- fastly/https_test.go | 104 ++++++++--------- fastly/kafka.go | 94 ++++++++-------- fastly/kafka_test.go | 110 +++++++++--------- fastly/logentries.go | 94 ++++++++-------- fastly/logentries_test.go | 122 ++++++++++---------- fastly/loggly.go | 94 ++++++++-------- fastly/loggly_test.go | 118 +++++++++---------- fastly/logshuttle.go | 94 ++++++++-------- fastly/logshuttle_test.go | 124 ++++++++++---------- fastly/newrelic.go | 94 ++++++++-------- fastly/newrelic_test.go | 118 +++++++++---------- fastly/openstack.go | 94 ++++++++-------- fastly/openstack_test.go | 112 +++++++++--------- fastly/package.go | 28 ++--- fastly/package_test.go | 36 +++--- fastly/papertrail.go | 94 ++++++++-------- fastly/papertrail_test.go | 120 ++++++++++---------- fastly/pool.go | 103 +++++++++-------- fastly/pool_test.go | 116 +++++++++---------- fastly/pubsub.go | 94 ++++++++-------- fastly/pubsub_test.go | 126 ++++++++++----------- fastly/purge.go | 20 ++-- fastly/purge_test.go | 4 +- fastly/realtime_stats.go | 2 +- fastly/realtime_stats_test.go | 2 +- fastly/request_setting.go | 94 ++++++++-------- fastly/request_setting_test.go | 108 +++++++++--------- fastly/response_object.go | 94 ++++++++-------- fastly/response_object_test.go | 118 +++++++++---------- fastly/s3.go | 94 ++++++++-------- fastly/s3_test.go | 118 +++++++++---------- fastly/scalyr.go | 94 ++++++++-------- fastly/scalyr_test.go | 124 ++++++++++---------- fastly/server.go | 93 ++++++++------- fastly/server_test.go | 108 +++++++++--------- fastly/settings.go | 38 ++++--- fastly/settings_test.go | 32 +++--- fastly/sftp.go | 94 ++++++++-------- fastly/sftp_test.go | 112 +++++++++--------- fastly/splunk.go | 94 ++++++++-------- fastly/splunk_test.go | 124 ++++++++++---------- fastly/sumologic.go | 94 ++++++++-------- fastly/sumologic_test.go | 120 ++++++++++---------- fastly/syslog.go | 94 ++++++++-------- fastly/syslog_test.go | 138 +++++++++++------------ fastly/vcl.go | 132 +++++++++++----------- fastly/vcl_snippets.go | 111 +++++++++--------- fastly/vcl_snippets_test.go | 94 ++++++++-------- fastly/vcl_test.go | 134 +++++++++++----------- fastly/version.go | 162 ++++++++++++++------------- fastly/version_test.go | 102 ++++++++--------- fastly/waf.go | 62 +++++----- fastly/waf_active_rule_test.go | 5 +- fastly/waf_rule_exclusion_test.go | 12 +- fastly/waf_test.go | 79 +++++++------ fastly/waf_version_test.go | 9 +- 110 files changed, 5057 insertions(+), 4868 deletions(-) diff --git a/fastly/acl.go b/fastly/acl.go index 8bd5ea031..1cc18428b 100644 --- a/fastly/acl.go +++ b/fastly/acl.go @@ -30,24 +30,24 @@ func (s ACLsByName) Less(i, j int) bool { // ListACLsInput is used as input to the ListACLs function. type ListACLsInput struct { - // Service is the ID of the service (required). - Service string + // ServiceID is the ID of the service (required). + ServiceID string - // Version is the specific configuration version (required). - Version int + // ServiceVersion is the specific configuration version (required). + ServiceVersion int } // ListACLs returns the list of ACLs for the configuration version. func (c *Client) ListACLs(i *ListACLsInput) ([]*ACL, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/acl", i.Service, i.Version) + path := fmt.Sprintf("/service/%s/version/%d/acl", i.ServiceID, i.ServiceVersion) resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -63,25 +63,26 @@ func (c *Client) ListACLs(i *ListACLsInput) ([]*ACL, error) { // CreateACLInput is used as input to the CreateACL function. type CreateACLInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int // Name is the name of the ACL to create (required) Name string `form:"name"` } func (c *Client) CreateACL(i *CreateACLInput) (*ACL, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/acl", i.Service, i.Version) + path := fmt.Sprintf("/service/%s/version/%d/acl", i.ServiceID, i.ServiceVersion) resp, err := c.PostForm(path, i, nil) if err != nil { return nil, err @@ -96,10 +97,11 @@ func (c *Client) CreateACL(i *CreateACLInput) (*ACL, error) { // DeleteACLInput is the input parameter to DeleteACL function. type DeleteACLInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int // Name is the name of the ACL to delete (required). Name string @@ -107,19 +109,19 @@ type DeleteACLInput struct { // DeleteACL deletes the given ACL version. func (c *Client) DeleteACL(i *DeleteACLInput) error { - if i.Service == "" { - return ErrMissingService + if i.ServiceID == "" { + return ErrMissingServiceID } - if i.Version == 0 { - return ErrMissingVersion + if i.ServiceVersion == 0 { + return ErrMissingServiceVersion } if i.Name == "" { return ErrMissingName } - path := fmt.Sprintf("/service/%s/version/%d/acl/%s", i.Service, i.Version, url.PathEscape(i.Name)) + path := fmt.Sprintf("/service/%s/version/%d/acl/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) resp, err := c.Delete(path, nil) if err != nil { return err @@ -137,10 +139,11 @@ func (c *Client) DeleteACL(i *DeleteACLInput) error { // GetACLInput is the input parameter to GetACL function. type GetACLInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int // Name is the name of the ACL to get (required). Name string @@ -148,19 +151,19 @@ type GetACLInput struct { // GetACL gets the ACL configuration with the given parameters. func (c *Client) GetACL(i *GetACLInput) (*ACL, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } if i.Name == "" { return nil, ErrMissingName } - path := fmt.Sprintf("/service/%s/version/%d/acl/%s", i.Service, i.Version, url.PathEscape(i.Name)) + path := fmt.Sprintf("/service/%s/version/%d/acl/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -175,10 +178,11 @@ func (c *Client) GetACL(i *GetACLInput) (*ACL, error) { // UpdateACLInput is the input parameter to UpdateACL function. type UpdateACLInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int // Name is the name of the ACL to update (required). Name string @@ -189,12 +193,12 @@ type UpdateACLInput struct { // UpdateACL updates the name of the ACL with the given parameters. func (c *Client) UpdateACL(i *UpdateACLInput) (*ACL, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } if i.Name == "" { @@ -205,7 +209,7 @@ func (c *Client) UpdateACL(i *UpdateACLInput) (*ACL, error) { return nil, ErrMissingNewName } - path := fmt.Sprintf("/service/%s/version/%d/acl/%s", i.Service, i.Version, url.PathEscape(i.Name)) + path := fmt.Sprintf("/service/%s/version/%d/acl/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) resp, err := c.PutForm(path, i, nil) if err != nil { diff --git a/fastly/acl_entry.go b/fastly/acl_entry.go index 2407eeca8..c8e21c73a 100644 --- a/fastly/acl_entry.go +++ b/fastly/acl_entry.go @@ -39,7 +39,7 @@ type ListACLEntriesInput struct { // ListACLEntries return a list of entries for an ACL func (c *Client) ListACLEntries(i *ListACLEntriesInput) ([]*ACLEntry, error) { if i.Service == "" { - return nil, ErrMissingService + return nil, ErrMissingServiceID } if i.ACL == "" { @@ -73,7 +73,7 @@ type GetACLEntryInput struct { // GetACLEntry returns a single ACL entry based on its ID. func (c *Client) GetACLEntry(i *GetACLEntryInput) (*ACLEntry, error) { if i.Service == "" { - return nil, ErrMissingService + return nil, ErrMissingServiceID } if i.ACL == "" { @@ -115,7 +115,7 @@ type CreateACLEntryInput struct { // CreateACLEntry creates and returns a new ACL entry. func (c *Client) CreateACLEntry(i *CreateACLEntryInput) (*ACLEntry, error) { if i.Service == "" { - return nil, ErrMissingService + return nil, ErrMissingServiceID } if i.ACL == "" { @@ -151,7 +151,7 @@ type DeleteACLEntryInput struct { // DeleteACLEntry deletes an entry from an ACL based on its ID func (c *Client) DeleteACLEntry(i *DeleteACLEntryInput) error { if i.Service == "" { - return ErrMissingService + return ErrMissingServiceID } if i.ACL == "" { @@ -199,7 +199,7 @@ type UpdateACLEntryInput struct { // UpdateACLEntry updates an ACL entry func (c *Client) UpdateACLEntry(i *UpdateACLEntryInput) (*ACLEntry, error) { if i.Service == "" { - return nil, ErrMissingService + return nil, ErrMissingServiceID } if i.ACL == "" { @@ -244,7 +244,7 @@ type BatchACLEntry struct { func (c *Client) BatchModifyACLEntries(i *BatchModifyACLEntriesInput) error { if i.Service == "" { - return ErrMissingService + return ErrMissingServiceID } if i.ACL == "" { diff --git a/fastly/acl_entry_test.go b/fastly/acl_entry_test.go index 642186e1d..0dcdfe2dc 100644 --- a/fastly/acl_entry_test.go +++ b/fastly/acl_entry_test.go @@ -139,7 +139,7 @@ func TestClient_ListACLEntries_validation(t *testing.T) { _, err = testClient.ListACLEntries(&ListACLEntriesInput{ Service: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } @@ -157,7 +157,7 @@ func TestClient_CreateACLEntry_validation(t *testing.T) { _, err = testClient.CreateACLEntry(&CreateACLEntryInput{ Service: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } @@ -175,7 +175,7 @@ func TestClient_GetACLEntry_validation(t *testing.T) { _, err = testClient.GetACLEntry(&GetACLEntryInput{ Service: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } @@ -202,7 +202,7 @@ func TestClient_UpdateACLEntry_validation(t *testing.T) { _, err = testClient.UpdateACLEntry(&UpdateACLEntryInput{ Service: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } @@ -229,7 +229,7 @@ func TestClient_DeleteACLEntry_validation(t *testing.T) { err = testClient.DeleteACLEntry(&DeleteACLEntryInput{ Service: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } @@ -256,7 +256,7 @@ func TestClient_BatchModifyACLEntries_validation(t *testing.T) { err = testClient.BatchModifyACLEntries(&BatchModifyACLEntriesInput{ Service: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } err = testClient.BatchModifyACLEntries(&BatchModifyACLEntriesInput{ diff --git a/fastly/acl_test.go b/fastly/acl_test.go index eeec5099e..1cf084dbe 100644 --- a/fastly/acl_test.go +++ b/fastly/acl_test.go @@ -14,9 +14,9 @@ func TestClient_ACLs(t *testing.T) { var a *ACL record(t, fixtureBase+"create", func(c *Client) { a, err = c.CreateACL(&CreateACLInput{ - Service: testServiceID, - Version: testVersion.Number, - Name: "test_acl", + ServiceID: testServiceID, + ServiceVersion: testVersion.Number, + Name: "test_acl", }) }) if err != nil { @@ -27,15 +27,15 @@ func TestClient_ACLs(t *testing.T) { defer func() { record(t, fixtureBase+"cleanup", func(c *Client) { c.DeleteACL(&DeleteACLInput{ - Service: testServiceID, - Version: testVersion.Number, - Name: "test_acl", + ServiceID: testServiceID, + ServiceVersion: testVersion.Number, + Name: "test_acl", }) c.DeleteACL(&DeleteACLInput{ - Service: testServiceID, - Version: testVersion.Number, - Name: "new_test_acl", + ServiceID: testServiceID, + ServiceVersion: testVersion.Number, + Name: "new_test_acl", }) }) }() @@ -48,8 +48,8 @@ func TestClient_ACLs(t *testing.T) { var as []*ACL record(t, fixtureBase+"list", func(c *Client) { as, err = c.ListACLs(&ListACLsInput{ - Service: testServiceID, - Version: testVersion.Number, + ServiceID: testServiceID, + ServiceVersion: testVersion.Number, }) }) if err != nil { @@ -63,9 +63,9 @@ func TestClient_ACLs(t *testing.T) { var na *ACL record(t, fixtureBase+"get", func(c *Client) { na, err = c.GetACL(&GetACLInput{ - Service: testServiceID, - Version: testVersion.Number, - Name: "test_acl", + ServiceID: testServiceID, + ServiceVersion: testVersion.Number, + Name: "test_acl", }) }) if err != nil { @@ -79,10 +79,10 @@ func TestClient_ACLs(t *testing.T) { var ua *ACL record(t, fixtureBase+"update", func(c *Client) { ua, err = c.UpdateACL(&UpdateACLInput{ - Service: testServiceID, - Version: testVersion.Number, - Name: "test_acl", - NewName: "new_test_acl", + ServiceID: testServiceID, + ServiceVersion: testVersion.Number, + Name: "test_acl", + NewName: "new_test_acl", }) }) if err != nil { @@ -99,9 +99,9 @@ func TestClient_ACLs(t *testing.T) { // Delete record(t, fixtureBase+"delete", func(c *Client) { err = c.DeleteACL(&DeleteACLInput{ - Service: testServiceID, - Version: testVersion.Number, - Name: "new_test_acl", + ServiceID: testServiceID, + ServiceVersion: testVersion.Number, + Name: "new_test_acl", }) }) if err != nil { @@ -113,17 +113,17 @@ func TestClient_ACLs(t *testing.T) { func TestClient_ListACLs_validation(t *testing.T) { var err error _, err = testClient.ListACLs(&ListACLsInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.ListACLs(&ListACLsInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } } @@ -131,17 +131,17 @@ func TestClient_ListACLs_validation(t *testing.T) { func TestClient_CreateACL_validation(t *testing.T) { var err error _, err = testClient.CreateACL(&CreateACLInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.CreateACL(&CreateACLInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } } @@ -149,24 +149,24 @@ func TestClient_CreateACL_validation(t *testing.T) { func TestClient_GetACL_validation(t *testing.T) { var err error _, err = testClient.GetACL(&GetACLInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.GetACL(&GetACLInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } _, err = testClient.GetACL(&GetACLInput{ - Service: "foo", - Version: 1, - Name: "", + ServiceID: "foo", + ServiceVersion: 1, + Name: "", }) if err != ErrMissingName { t.Errorf("bad error: %s", err) @@ -176,33 +176,33 @@ func TestClient_GetACL_validation(t *testing.T) { func TestClient_UpdateACL_validation(t *testing.T) { var err error _, err = testClient.UpdateACL(&UpdateACLInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.UpdateACL(&UpdateACLInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } _, err = testClient.UpdateACL(&UpdateACLInput{ - Service: "foo", - Version: 1, - Name: "", + ServiceID: "foo", + ServiceVersion: 1, + Name: "", }) if err != ErrMissingName { t.Errorf("bad error: %s", err) } _, err = testClient.UpdateACL(&UpdateACLInput{ - Service: "foo", - Version: 1, - Name: "acl", - NewName: "", + ServiceID: "foo", + ServiceVersion: 1, + Name: "acl", + NewName: "", }) if err != ErrMissingNewName { t.Errorf("bad error: %s", err) @@ -212,24 +212,24 @@ func TestClient_UpdateACL_validation(t *testing.T) { func TestClient_DeleteACL_validation(t *testing.T) { var err error err = testClient.DeleteACL(&DeleteACLInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } err = testClient.DeleteACL(&DeleteACLInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } err = testClient.DeleteACL(&DeleteACLInput{ - Service: "foo", - Version: 1, - Name: "", + ServiceID: "foo", + ServiceVersion: 1, + Name: "", }) if err != ErrMissingName { t.Errorf("bad error: %s", err) diff --git a/fastly/backend.go b/fastly/backend.go index c4e52d5d1..0febabcff 100644 --- a/fastly/backend.go +++ b/fastly/backend.go @@ -56,24 +56,24 @@ func (s backendsByName) Less(i, j int) bool { // ListBackendsInput is used as input to the ListBackends function. type ListBackendsInput struct { - // Service is the ID of the service (required). - Service string + // ServiceID is the ID of the service (required). + ServiceID string - // Version is the specific configuration version (required). - Version int + // ServiceVersion is the specific configuration version (required). + ServiceVersion int } // ListBackends returns the list of backends for the configuration version. func (c *Client) ListBackends(i *ListBackendsInput) ([]*Backend, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/backend", i.Service, i.Version) + path := fmt.Sprintf("/service/%s/version/%d/backend", i.ServiceID, i.ServiceVersion) resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -89,10 +89,11 @@ func (c *Client) ListBackends(i *ListBackendsInput) ([]*Backend, error) { // CreateBackendInput is used as input to the CreateBackend function. type CreateBackendInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int Name string `form:"name,omitempty"` Comment string `form:"comment,omitempty"` @@ -124,15 +125,15 @@ type CreateBackendInput struct { // CreateBackend creates a new Fastly backend. func (c *Client) CreateBackend(i *CreateBackendInput) (*Backend, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/backend", i.Service, i.Version) + path := fmt.Sprintf("/service/%s/version/%d/backend", i.ServiceID, i.ServiceVersion) resp, err := c.PostForm(path, i, nil) if err != nil { return nil, err @@ -147,10 +148,11 @@ func (c *Client) CreateBackend(i *CreateBackendInput) (*Backend, error) { // GetBackendInput is used as input to the GetBackend function. type GetBackendInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int // Name is the name of the backend to fetch. Name string @@ -158,19 +160,19 @@ type GetBackendInput struct { // GetBackend gets the backend configuration with the given parameters. func (c *Client) GetBackend(i *GetBackendInput) (*Backend, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } if i.Name == "" { return nil, ErrMissingName } - path := fmt.Sprintf("/service/%s/version/%d/backend/%s", i.Service, i.Version, url.PathEscape(i.Name)) + path := fmt.Sprintf("/service/%s/version/%d/backend/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -185,10 +187,11 @@ func (c *Client) GetBackend(i *GetBackendInput) (*Backend, error) { // UpdateBackendInput is used as input to the UpdateBackend function. type UpdateBackendInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int // Name is the name of the backend to update. Name string @@ -223,19 +226,19 @@ type UpdateBackendInput struct { // UpdateBackend updates a specific backend. func (c *Client) UpdateBackend(i *UpdateBackendInput) (*Backend, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } if i.Name == "" { return nil, ErrMissingName } - path := fmt.Sprintf("/service/%s/version/%d/backend/%s", i.Service, i.Version, url.PathEscape(i.Name)) + path := fmt.Sprintf("/service/%s/version/%d/backend/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) resp, err := c.PutForm(path, i, nil) if err != nil { return nil, err @@ -250,10 +253,11 @@ func (c *Client) UpdateBackend(i *UpdateBackendInput) (*Backend, error) { // DeleteBackendInput is the input parameter to DeleteBackend. type DeleteBackendInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int // Name is the name of the backend to delete (required). Name string @@ -261,19 +265,19 @@ type DeleteBackendInput struct { // DeleteBackend deletes the given backend version. func (c *Client) DeleteBackend(i *DeleteBackendInput) error { - if i.Service == "" { - return ErrMissingService + if i.ServiceID == "" { + return ErrMissingServiceID } - if i.Version == 0 { - return ErrMissingVersion + if i.ServiceVersion == 0 { + return ErrMissingServiceVersion } if i.Name == "" { return ErrMissingName } - path := fmt.Sprintf("/service/%s/version/%d/backend/%s", i.Service, i.Version, url.PathEscape(i.Name)) + path := fmt.Sprintf("/service/%s/version/%d/backend/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) resp, err := c.Delete(path, nil) if err != nil { return err diff --git a/fastly/backend_test.go b/fastly/backend_test.go index d7214b885..48f44b9b9 100644 --- a/fastly/backend_test.go +++ b/fastly/backend_test.go @@ -15,8 +15,8 @@ func TestClient_Backends(t *testing.T) { var b *Backend record(t, "backends/create", func(c *Client) { b, err = c.CreateBackend(&CreateBackendInput{ - Service: testServiceID, - Version: tv.Number, + ServiceID: testServiceID, + ServiceVersion: tv.Number, Name: "test-backend", Address: "integ-test.go-fastly.com", Port: 1234, @@ -32,15 +32,15 @@ func TestClient_Backends(t *testing.T) { defer func() { record(t, "backends/cleanup", func(c *Client) { c.DeleteBackend(&DeleteBackendInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-backend", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "test-backend", }) c.DeleteBackend(&DeleteBackendInput{ - Service: testServiceID, - Version: tv.Number, - Name: "new-test-backend", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "new-test-backend", }) }) }() @@ -65,8 +65,8 @@ func TestClient_Backends(t *testing.T) { var bs []*Backend record(t, "backends/list", func(c *Client) { bs, err = c.ListBackends(&ListBackendsInput{ - Service: testServiceID, - Version: tv.Number, + ServiceID: testServiceID, + ServiceVersion: tv.Number, }) }) if err != nil { @@ -80,9 +80,9 @@ func TestClient_Backends(t *testing.T) { var nb *Backend record(t, "backends/get", func(c *Client) { nb, err = c.GetBackend(&GetBackendInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-backend", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "test-backend", }) }) if err != nil { @@ -108,11 +108,11 @@ func TestClient_Backends(t *testing.T) { var ub *Backend record(t, "backends/update", func(c *Client) { ub, err = c.UpdateBackend(&UpdateBackendInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-backend", - NewName: "new-test-backend", - OverrideHost: "www.example.com", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "test-backend", + NewName: "new-test-backend", + OverrideHost: "www.example.com", }) }) if err != nil { @@ -128,9 +128,9 @@ func TestClient_Backends(t *testing.T) { // Delete record(t, "backends/delete", func(c *Client) { err = c.DeleteBackend(&DeleteBackendInput{ - Service: testServiceID, - Version: tv.Number, - Name: "new-test-backend", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "new-test-backend", }) }) if err != nil { @@ -141,17 +141,17 @@ func TestClient_Backends(t *testing.T) { func TestClient_ListBackends_validation(t *testing.T) { var err error _, err = testClient.ListBackends(&ListBackendsInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.ListBackends(&ListBackendsInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } } @@ -159,17 +159,17 @@ func TestClient_ListBackends_validation(t *testing.T) { func TestClient_CreateBackend_validation(t *testing.T) { var err error _, err = testClient.CreateBackend(&CreateBackendInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.CreateBackend(&CreateBackendInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } } @@ -177,24 +177,24 @@ func TestClient_CreateBackend_validation(t *testing.T) { func TestClient_GetBackend_validation(t *testing.T) { var err error _, err = testClient.GetBackend(&GetBackendInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.GetBackend(&GetBackendInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } _, err = testClient.GetBackend(&GetBackendInput{ - Service: "foo", - Version: 1, - Name: "", + ServiceID: "foo", + ServiceVersion: 1, + Name: "", }) if err != ErrMissingName { t.Errorf("bad error: %s", err) @@ -204,24 +204,24 @@ func TestClient_GetBackend_validation(t *testing.T) { func TestClient_UpdateBackend_validation(t *testing.T) { var err error _, err = testClient.UpdateBackend(&UpdateBackendInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.UpdateBackend(&UpdateBackendInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } _, err = testClient.UpdateBackend(&UpdateBackendInput{ - Service: "foo", - Version: 1, - Name: "", + ServiceID: "foo", + ServiceVersion: 1, + Name: "", }) if err != ErrMissingName { t.Errorf("bad error: %s", err) @@ -231,24 +231,24 @@ func TestClient_UpdateBackend_validation(t *testing.T) { func TestClient_DeleteBackend_validation(t *testing.T) { var err error err = testClient.DeleteBackend(&DeleteBackendInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } err = testClient.DeleteBackend(&DeleteBackendInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } err = testClient.DeleteBackend(&DeleteBackendInput{ - Service: "foo", - Version: 1, - Name: "", + ServiceID: "foo", + ServiceVersion: 1, + Name: "", }) if err != ErrMissingName { t.Errorf("bad error: %s", err) diff --git a/fastly/bigquery.go b/fastly/bigquery.go index 513c77940..1ca94c2ff 100644 --- a/fastly/bigquery.go +++ b/fastly/bigquery.go @@ -40,24 +40,24 @@ func (s bigQueriesByName) Less(i, j int) bool { // ListBigQueriesInput is used as input to the ListBigQueries function. type ListBigQueriesInput struct { - // Service is the ID of the service (required). - Service string + // ServiceID is the ID of the service (required). + ServiceID string - // Version is the specific configuration version (required). - Version int + // ServiceVersion is the specific configuration version (required). + ServiceVersion int } // ListBigQueries returns the list of BigQueries for the configuration version. func (c *Client) ListBigQueries(i *ListBigQueriesInput) ([]*BigQuery, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/bigquery", i.Service, i.Version) + path := fmt.Sprintf("/service/%s/version/%d/logging/bigquery", i.ServiceID, i.ServiceVersion) resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -73,10 +73,11 @@ func (c *Client) ListBigQueries(i *ListBigQueriesInput) ([]*BigQuery, error) { // CreateBigQueryInput is used as input to the CreateBigQuery function. type CreateBigQueryInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int Name string `form:"name,omitempty"` ProjectID string `form:"project_id,omitempty"` @@ -93,15 +94,15 @@ type CreateBigQueryInput struct { // CreateBigQuery creates a new Fastly BigQuery. func (c *Client) CreateBigQuery(i *CreateBigQueryInput) (*BigQuery, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/bigquery", i.Service, i.Version) + path := fmt.Sprintf("/service/%s/version/%d/logging/bigquery", i.ServiceID, i.ServiceVersion) resp, err := c.PostForm(path, i, nil) if err != nil { return nil, err @@ -116,10 +117,11 @@ func (c *Client) CreateBigQuery(i *CreateBigQueryInput) (*BigQuery, error) { // GetBigQueryInput is used as input to the GetBigQuery function. type GetBigQueryInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int // Name is the name of the BigQuery to fetch. Name string @@ -127,19 +129,19 @@ type GetBigQueryInput struct { // GetBigQuery gets the BigQuery configuration with the given parameters. func (c *Client) GetBigQuery(i *GetBigQueryInput) (*BigQuery, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } if i.Name == "" { return nil, ErrMissingName } - path := fmt.Sprintf("/service/%s/version/%d/logging/bigquery/%s", i.Service, i.Version, url.PathEscape(i.Name)) + path := fmt.Sprintf("/service/%s/version/%d/logging/bigquery/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -154,10 +156,11 @@ func (c *Client) GetBigQuery(i *GetBigQueryInput) (*BigQuery, error) { // UpdateBigQueryInput is used as input to the UpdateBigQuery function. type UpdateBigQueryInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int // Name is the name of the BigQuery to update. Name string @@ -177,19 +180,19 @@ type UpdateBigQueryInput struct { // UpdateBigQuery updates a specific BigQuery. func (c *Client) UpdateBigQuery(i *UpdateBigQueryInput) (*BigQuery, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } if i.Name == "" { return nil, ErrMissingName } - path := fmt.Sprintf("/service/%s/version/%d/logging/bigquery/%s", i.Service, i.Version, url.PathEscape(i.Name)) + path := fmt.Sprintf("/service/%s/version/%d/logging/bigquery/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) resp, err := c.PutForm(path, i, nil) if err != nil { return nil, err @@ -204,10 +207,11 @@ func (c *Client) UpdateBigQuery(i *UpdateBigQueryInput) (*BigQuery, error) { // DeleteBigQueryInput is the input parameter to DeleteBigQuery. type DeleteBigQueryInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int // Name is the name of the BigQuery to delete (required). Name string @@ -215,19 +219,19 @@ type DeleteBigQueryInput struct { // DeleteBigQuery deletes the given BigQuery version. func (c *Client) DeleteBigQuery(i *DeleteBigQueryInput) error { - if i.Service == "" { - return ErrMissingService + if i.ServiceID == "" { + return ErrMissingServiceID } - if i.Version == 0 { - return ErrMissingVersion + if i.ServiceVersion == 0 { + return ErrMissingServiceVersion } if i.Name == "" { return ErrMissingName } - path := fmt.Sprintf("/service/%s/version/%d/logging/bigquery/%s", i.Service, i.Version, url.PathEscape(i.Name)) + path := fmt.Sprintf("/service/%s/version/%d/logging/bigquery/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) resp, err := c.Delete(path, nil) if err != nil { return err diff --git a/fastly/bigquery_test.go b/fastly/bigquery_test.go index 7a8213a86..0d2c9012e 100644 --- a/fastly/bigquery_test.go +++ b/fastly/bigquery_test.go @@ -19,18 +19,18 @@ func TestClient_Bigqueries(t *testing.T) { var bq *BigQuery record(t, "bigqueries/create", func(c *Client) { bq, err = c.CreateBigQuery(&CreateBigQueryInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-bigquery", - ProjectID: "example-fastly-log", - Dataset: "fastly_log_test", - Table: "fastly_logs", - Template: "", - User: "fastly-bigquery-log@example-fastly-log.iam.gserviceaccount.com", - SecretKey: secretKey, - Format: "{\n \"timestamp\":\"%{begin:%Y-%m-%dT%H:%M:%S}t\",\n \"time_elapsed\":%{time.elapsed.usec}V,\n \"is_tls\":%{if(req.is_ssl, \"true\", \"false\")}V,\n \"client_ip\":\"%{req.http.Fastly-Client-IP}V\",\n \"geo_city\":\"%{client.geo.city}V\",\n \"geo_country_code\":\"%{client.geo.country_code}V\",\n \"request\":\"%{req.request}V\",\n \"host\":\"%{req.http.Fastly-Orig-Host}V\",\n \"url\":\"%{json.escape(req.url)}V\",\n \"request_referer\":\"%{json.escape(req.http.Referer)}V\",\n \"request_user_agent\":\"%{json.escape(req.http.User-Agent)}V\",\n \"request_accept_language\":\"%{json.escape(req.http.Accept-Language)}V\",\n \"request_accept_charset\":\"%{json.escape(req.http.Accept-Charset)}V\",\n \"cache_status\":\"%{regsub(fastly_info.state, \"^(HIT-(SYNTH)|(HITPASS|HIT|MISS|PASS|ERROR|PIPE)).*\", \"\\\\2\\\\3\") }V\"\n}", - Placement: "waf_debug", - FormatVersion: 2, + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "test-bigquery", + ProjectID: "example-fastly-log", + Dataset: "fastly_log_test", + Table: "fastly_logs", + Template: "", + User: "fastly-bigquery-log@example-fastly-log.iam.gserviceaccount.com", + SecretKey: secretKey, + Format: "{\n \"timestamp\":\"%{begin:%Y-%m-%dT%H:%M:%S}t\",\n \"time_elapsed\":%{time.elapsed.usec}V,\n \"is_tls\":%{if(req.is_ssl, \"true\", \"false\")}V,\n \"client_ip\":\"%{req.http.Fastly-Client-IP}V\",\n \"geo_city\":\"%{client.geo.city}V\",\n \"geo_country_code\":\"%{client.geo.country_code}V\",\n \"request\":\"%{req.request}V\",\n \"host\":\"%{req.http.Fastly-Orig-Host}V\",\n \"url\":\"%{json.escape(req.url)}V\",\n \"request_referer\":\"%{json.escape(req.http.Referer)}V\",\n \"request_user_agent\":\"%{json.escape(req.http.User-Agent)}V\",\n \"request_accept_language\":\"%{json.escape(req.http.Accept-Language)}V\",\n \"request_accept_charset\":\"%{json.escape(req.http.Accept-Charset)}V\",\n \"cache_status\":\"%{regsub(fastly_info.state, \"^(HIT-(SYNTH)|(HITPASS|HIT|MISS|PASS|ERROR|PIPE)).*\", \"\\\\2\\\\3\") }V\"\n}", + Placement: "waf_debug", + FormatVersion: 2, }) }) if err != nil { @@ -41,15 +41,15 @@ func TestClient_Bigqueries(t *testing.T) { defer func() { record(t, "bigqueries/cleanup", func(c *Client) { c.DeleteBigQuery(&DeleteBigQueryInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-bigquery", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "test-bigquery", }) c.DeleteBigQuery(&DeleteBigQueryInput{ - Service: testServiceID, - Version: tv.Number, - Name: "new-test-bigquery", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "new-test-bigquery", }) }) }() @@ -92,8 +92,8 @@ func TestClient_Bigqueries(t *testing.T) { var bqs []*BigQuery record(t, "bigqueries/list", func(c *Client) { bqs, err = c.ListBigQueries(&ListBigQueriesInput{ - Service: testServiceID, - Version: tv.Number, + ServiceID: testServiceID, + ServiceVersion: tv.Number, }) }) if err != nil { @@ -107,9 +107,9 @@ func TestClient_Bigqueries(t *testing.T) { var nbq *BigQuery record(t, "bigqueries/get", func(c *Client) { nbq, err = c.GetBigQuery(&GetBigQueryInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-bigquery", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "test-bigquery", }) }) if err != nil { @@ -153,10 +153,10 @@ func TestClient_Bigqueries(t *testing.T) { var ubq *BigQuery record(t, "bigqueries/update", func(c *Client) { ubq, err = c.UpdateBigQuery(&UpdateBigQueryInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-bigquery", - NewName: "new-test-bigquery", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "test-bigquery", + NewName: "new-test-bigquery", }) }) if err != nil { @@ -169,9 +169,9 @@ func TestClient_Bigqueries(t *testing.T) { // Delete record(t, "bigqueries/delete", func(c *Client) { err = c.DeleteBigQuery(&DeleteBigQueryInput{ - Service: testServiceID, - Version: tv.Number, - Name: "new-test-bigquery", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "new-test-bigquery", }) }) if err != nil { @@ -182,17 +182,17 @@ func TestClient_Bigqueries(t *testing.T) { func TestClient_ListBigQueries_validation(t *testing.T) { var err error _, err = testClient.ListBigQueries(&ListBigQueriesInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.ListBigQueries(&ListBigQueriesInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } } @@ -200,17 +200,17 @@ func TestClient_ListBigQueries_validation(t *testing.T) { func TestClient_CreateBigQuery_validation(t *testing.T) { var err error _, err = testClient.CreateBigQuery(&CreateBigQueryInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.CreateBigQuery(&CreateBigQueryInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } } @@ -218,24 +218,24 @@ func TestClient_CreateBigQuery_validation(t *testing.T) { func TestClient_GetBigQuery_validation(t *testing.T) { var err error _, err = testClient.GetBigQuery(&GetBigQueryInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.GetBigQuery(&GetBigQueryInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } _, err = testClient.GetBigQuery(&GetBigQueryInput{ - Service: "foo", - Version: 1, - Name: "", + ServiceID: "foo", + ServiceVersion: 1, + Name: "", }) if err != ErrMissingName { t.Errorf("bad error: %s", err) @@ -245,24 +245,24 @@ func TestClient_GetBigQuery_validation(t *testing.T) { func TestClient_UpdateBigQuery_validation(t *testing.T) { var err error _, err = testClient.UpdateBigQuery(&UpdateBigQueryInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.UpdateBigQuery(&UpdateBigQueryInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } _, err = testClient.UpdateBigQuery(&UpdateBigQueryInput{ - Service: "foo", - Version: 1, - Name: "", + ServiceID: "foo", + ServiceVersion: 1, + Name: "", }) if err != ErrMissingName { t.Errorf("bad error: %s", err) @@ -272,24 +272,24 @@ func TestClient_UpdateBigQuery_validation(t *testing.T) { func TestClient_DeleteBigQuery_validation(t *testing.T) { var err error err = testClient.DeleteBigQuery(&DeleteBigQueryInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } err = testClient.DeleteBigQuery(&DeleteBigQueryInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } err = testClient.DeleteBigQuery(&DeleteBigQueryInput{ - Service: "foo", - Version: 1, - Name: "", + ServiceID: "foo", + ServiceVersion: 1, + Name: "", }) if err != ErrMissingName { t.Errorf("bad error: %s", err) diff --git a/fastly/blobstorage.go b/fastly/blobstorage.go index ee90b8755..78124b890 100644 --- a/fastly/blobstorage.go +++ b/fastly/blobstorage.go @@ -43,24 +43,24 @@ func (s blobStorageByName) Less(i, j int) bool { // ListBlobStoragesInput is used as input to the ListBlobStorages function. type ListBlobStoragesInput struct { - // Service is the ID of the service (required). - Service string + // ServiceID is the ID of the service (required). + ServiceID string - // Version is the specific configuration version (required). - Version int + // ServiceVersion is the specific configuration version (required). + ServiceVersion int } // ListBlobStorages returns the list of blob storages for the configuration version. func (c *Client) ListBlobStorages(i *ListBlobStoragesInput) ([]*BlobStorage, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/azureblob", i.Service, i.Version) + path := fmt.Sprintf("/service/%s/version/%d/logging/azureblob", i.ServiceID, i.ServiceVersion) resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -76,10 +76,11 @@ func (c *Client) ListBlobStorages(i *ListBlobStoragesInput) ([]*BlobStorage, err // CreateBlobStorageInput is used as input to the CreateBlobStorage function. type CreateBlobStorageInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int Name string `form:"name,omitempty"` Path string `form:"path,omitempty"` @@ -99,15 +100,15 @@ type CreateBlobStorageInput struct { // CreateBlobStorage creates a new Fastly blob storage. func (c *Client) CreateBlobStorage(i *CreateBlobStorageInput) (*BlobStorage, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/azureblob", i.Service, i.Version) + path := fmt.Sprintf("/service/%s/version/%d/logging/azureblob", i.ServiceID, i.ServiceVersion) resp, err := c.PostForm(path, i, nil) if err != nil { return nil, err @@ -122,10 +123,11 @@ func (c *Client) CreateBlobStorage(i *CreateBlobStorageInput) (*BlobStorage, err // GetBlobStorageInput is used as input to the GetBlobStorage function. type GetBlobStorageInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int // Name is the name of the blob storage to fetch. Name string @@ -133,19 +135,19 @@ type GetBlobStorageInput struct { // GetBlobStorage gets the blob storage configuration with the given parameters. func (c *Client) GetBlobStorage(i *GetBlobStorageInput) (*BlobStorage, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } if i.Name == "" { return nil, ErrMissingName } - path := fmt.Sprintf("/service/%s/version/%d/logging/azureblob/%s", i.Service, i.Version, url.PathEscape(i.Name)) + path := fmt.Sprintf("/service/%s/version/%d/logging/azureblob/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -160,10 +162,11 @@ func (c *Client) GetBlobStorage(i *GetBlobStorageInput) (*BlobStorage, error) { // UpdateBlobStorageInput is used as input to the UpdateBlobStorage function. type UpdateBlobStorageInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int // Name is the name of the blob storage to update. Name string @@ -186,19 +189,19 @@ type UpdateBlobStorageInput struct { // UpdateBlobStorage updates a specific blob storage. func (c *Client) UpdateBlobStorage(i *UpdateBlobStorageInput) (*BlobStorage, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } if i.Name == "" { return nil, ErrMissingName } - path := fmt.Sprintf("/service/%s/version/%d/logging/azureblob/%s", i.Service, i.Version, url.PathEscape(i.Name)) + path := fmt.Sprintf("/service/%s/version/%d/logging/azureblob/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) resp, err := c.PutForm(path, i, nil) if err != nil { return nil, err @@ -213,10 +216,11 @@ func (c *Client) UpdateBlobStorage(i *UpdateBlobStorageInput) (*BlobStorage, err // DeleteBlobStorageInput is the input parameter to DeleteBlobStorage. type DeleteBlobStorageInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int // Name is the name of the blob storage to delete (required). Name string @@ -224,19 +228,19 @@ type DeleteBlobStorageInput struct { // DeleteBlobStorage deletes the given blob storage version. func (c *Client) DeleteBlobStorage(i *DeleteBlobStorageInput) error { - if i.Service == "" { - return ErrMissingService + if i.ServiceID == "" { + return ErrMissingServiceID } - if i.Version == 0 { - return ErrMissingVersion + if i.ServiceVersion == 0 { + return ErrMissingServiceVersion } if i.Name == "" { return ErrMissingName } - path := fmt.Sprintf("/service/%s/version/%d/logging/azureblob/%s", i.Service, i.Version, url.PathEscape(i.Name)) + path := fmt.Sprintf("/service/%s/version/%d/logging/azureblob/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) resp, err := c.Delete(path, nil) if err != nil { return err diff --git a/fastly/blobstorage_test.go b/fastly/blobstorage_test.go index 24f0b54c7..9e8ed6e46 100644 --- a/fastly/blobstorage_test.go +++ b/fastly/blobstorage_test.go @@ -15,8 +15,8 @@ func TestClient_BlobStorages(t *testing.T) { var bs *BlobStorage record(t, "blobstorages/create", func(c *Client) { bs, err = c.CreateBlobStorage(&CreateBlobStorageInput{ - Service: testServiceID, - Version: tv.Number, + ServiceID: testServiceID, + ServiceVersion: tv.Number, Name: "test-blobstorage", Path: "/logs", AccountName: "test", @@ -40,15 +40,15 @@ func TestClient_BlobStorages(t *testing.T) { defer func() { record(t, "blobstorages/cleanup", func(c *Client) { c.DeleteBlobStorage(&DeleteBlobStorageInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-blobstorage", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "test-blobstorage", }) c.DeleteBlobStorage(&DeleteBlobStorageInput{ - Service: testServiceID, - Version: tv.Number, - Name: "new-test-blobstorage", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "new-test-blobstorage", }) }) }() @@ -97,8 +97,8 @@ func TestClient_BlobStorages(t *testing.T) { var bsl []*BlobStorage record(t, "blobstorages/list", func(c *Client) { bsl, err = c.ListBlobStorages(&ListBlobStoragesInput{ - Service: testServiceID, - Version: tv.Number, + ServiceID: testServiceID, + ServiceVersion: tv.Number, }) }) if err != nil { @@ -112,9 +112,9 @@ func TestClient_BlobStorages(t *testing.T) { var nbs *BlobStorage record(t, "blobstorages/get", func(c *Client) { nbs, err = c.GetBlobStorage(&GetBlobStorageInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-blobstorage", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "test-blobstorage", }) }) if err != nil { @@ -164,10 +164,10 @@ func TestClient_BlobStorages(t *testing.T) { var ubs *BlobStorage record(t, "blobstorages/update", func(c *Client) { ubs, err = c.UpdateBlobStorage(&UpdateBlobStorageInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-blobstorage", - NewName: "new-test-blobstorage", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "test-blobstorage", + NewName: "new-test-blobstorage", }) }) if err != nil { @@ -180,9 +180,9 @@ func TestClient_BlobStorages(t *testing.T) { // Delete record(t, "blobstorages/delete", func(c *Client) { err = c.DeleteBlobStorage(&DeleteBlobStorageInput{ - Service: testServiceID, - Version: tv.Number, - Name: "new-test-blobstorage", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "new-test-blobstorage", }) }) if err != nil { @@ -193,17 +193,17 @@ func TestClient_BlobStorages(t *testing.T) { func TestClient_ListBlobStorages_validation(t *testing.T) { var err error _, err = testClient.ListBlobStorages(&ListBlobStoragesInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.ListBlobStorages(&ListBlobStoragesInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } } @@ -211,17 +211,17 @@ func TestClient_ListBlobStorages_validation(t *testing.T) { func TestClient_CreateBlobStorage_validation(t *testing.T) { var err error _, err = testClient.CreateBlobStorage(&CreateBlobStorageInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.CreateBlobStorage(&CreateBlobStorageInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } } @@ -229,24 +229,24 @@ func TestClient_CreateBlobStorage_validation(t *testing.T) { func TestClient_GetBlobStorage_validation(t *testing.T) { var err error _, err = testClient.GetBlobStorage(&GetBlobStorageInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.GetBlobStorage(&GetBlobStorageInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } _, err = testClient.GetBlobStorage(&GetBlobStorageInput{ - Service: "foo", - Version: 1, - Name: "", + ServiceID: "foo", + ServiceVersion: 1, + Name: "", }) if err != ErrMissingName { t.Errorf("bad error: %s", err) @@ -256,24 +256,24 @@ func TestClient_GetBlobStorage_validation(t *testing.T) { func TestClient_UpdateBlobStorage_validation(t *testing.T) { var err error _, err = testClient.UpdateBlobStorage(&UpdateBlobStorageInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.UpdateBlobStorage(&UpdateBlobStorageInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } _, err = testClient.UpdateBlobStorage(&UpdateBlobStorageInput{ - Service: "foo", - Version: 1, - Name: "", + ServiceID: "foo", + ServiceVersion: 1, + Name: "", }) if err != ErrMissingName { t.Errorf("bad error: %s", err) @@ -283,24 +283,24 @@ func TestClient_UpdateBlobStorage_validation(t *testing.T) { func TestClient_DeleteBlobStorage_validation(t *testing.T) { var err error err = testClient.DeleteBlobStorage(&DeleteBlobStorageInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } err = testClient.DeleteBlobStorage(&DeleteBlobStorageInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } err = testClient.DeleteBlobStorage(&DeleteBlobStorageInput{ - Service: "foo", - Version: 1, - Name: "", + ServiceID: "foo", + ServiceVersion: 1, + Name: "", }) if err != ErrMissingName { t.Errorf("bad error: %s", err) diff --git a/fastly/cache_setting.go b/fastly/cache_setting.go index 163c0863c..df9a4ce71 100644 --- a/fastly/cache_setting.go +++ b/fastly/cache_setting.go @@ -48,25 +48,25 @@ func (s cacheSettingsByName) Less(i, j int) bool { // ListCacheSettingsInput is used as input to the ListCacheSettings function. type ListCacheSettingsInput struct { - // Service is the ID of the service (required). - Service string + // ServiceID is the ID of the service (required). + ServiceID string - // Version is the specific configuration version (required). - Version int + // ServiceVersion is the specific configuration version (required). + ServiceVersion int } // ListCacheSettings returns the list of cache settings for the configuration // version. func (c *Client) ListCacheSettings(i *ListCacheSettingsInput) ([]*CacheSetting, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/cache_settings", i.Service, i.Version) + path := fmt.Sprintf("/service/%s/version/%d/cache_settings", i.ServiceID, i.ServiceVersion) resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -82,10 +82,11 @@ func (c *Client) ListCacheSettings(i *ListCacheSettingsInput) ([]*CacheSetting, // CreateCacheSettingInput is used as input to the CreateCacheSetting function. type CreateCacheSettingInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int Name string `form:"name,omitempty"` Action CacheSettingAction `form:"action,omitempty"` @@ -96,15 +97,15 @@ type CreateCacheSettingInput struct { // CreateCacheSetting creates a new Fastly cache setting. func (c *Client) CreateCacheSetting(i *CreateCacheSettingInput) (*CacheSetting, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/cache_settings", i.Service, i.Version) + path := fmt.Sprintf("/service/%s/version/%d/cache_settings", i.ServiceID, i.ServiceVersion) resp, err := c.PostForm(path, i, nil) if err != nil { return nil, err @@ -119,10 +120,11 @@ func (c *Client) CreateCacheSetting(i *CreateCacheSettingInput) (*CacheSetting, // GetCacheSettingInput is used as input to the GetCacheSetting function. type GetCacheSettingInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int // Name is the name of the cache setting to fetch. Name string @@ -131,19 +133,19 @@ type GetCacheSettingInput struct { // GetCacheSetting gets the cache setting configuration with the given // parameters. func (c *Client) GetCacheSetting(i *GetCacheSettingInput) (*CacheSetting, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } if i.Name == "" { return nil, ErrMissingName } - path := fmt.Sprintf("/service/%s/version/%d/cache_settings/%s", i.Service, i.Version, url.PathEscape(i.Name)) + path := fmt.Sprintf("/service/%s/version/%d/cache_settings/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -158,10 +160,11 @@ func (c *Client) GetCacheSetting(i *GetCacheSettingInput) (*CacheSetting, error) // UpdateCacheSettingInput is used as input to the UpdateCacheSetting function. type UpdateCacheSettingInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int // Name is the name of the cache setting to update. Name string @@ -175,19 +178,19 @@ type UpdateCacheSettingInput struct { // UpdateCacheSetting updates a specific cache setting. func (c *Client) UpdateCacheSetting(i *UpdateCacheSettingInput) (*CacheSetting, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } if i.Name == "" { return nil, ErrMissingName } - path := fmt.Sprintf("/service/%s/version/%d/cache_settings/%s", i.Service, i.Version, url.PathEscape(i.Name)) + path := fmt.Sprintf("/service/%s/version/%d/cache_settings/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) resp, err := c.PutForm(path, i, nil) if err != nil { return nil, err @@ -202,10 +205,11 @@ func (c *Client) UpdateCacheSetting(i *UpdateCacheSettingInput) (*CacheSetting, // DeleteCacheSettingInput is the input parameter to DeleteCacheSetting. type DeleteCacheSettingInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int // Name is the name of the cache setting to delete (required). Name string @@ -213,19 +217,19 @@ type DeleteCacheSettingInput struct { // DeleteCacheSetting deletes the given cache setting version. func (c *Client) DeleteCacheSetting(i *DeleteCacheSettingInput) error { - if i.Service == "" { - return ErrMissingService + if i.ServiceID == "" { + return ErrMissingServiceID } - if i.Version == 0 { - return ErrMissingVersion + if i.ServiceVersion == 0 { + return ErrMissingServiceVersion } if i.Name == "" { return ErrMissingName } - path := fmt.Sprintf("/service/%s/version/%d/cache_settings/%s", i.Service, i.Version, url.PathEscape(i.Name)) + path := fmt.Sprintf("/service/%s/version/%d/cache_settings/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) resp, err := c.Delete(path, nil) if err != nil { return err diff --git a/fastly/cache_setting_test.go b/fastly/cache_setting_test.go index d4072ab88..b6d28a973 100644 --- a/fastly/cache_setting_test.go +++ b/fastly/cache_setting_test.go @@ -15,12 +15,12 @@ func TestClient_CacheSettings(t *testing.T) { var cacheSetting *CacheSetting record(t, "cache_settings/create", func(c *Client) { cacheSetting, err = c.CreateCacheSetting(&CreateCacheSettingInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-cache-setting", - Action: CacheSettingActionCache, - TTL: 1234, - StaleTTL: 1500, + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "test-cache-setting", + Action: CacheSettingActionCache, + TTL: 1234, + StaleTTL: 1500, }) }) if err != nil { @@ -31,15 +31,15 @@ func TestClient_CacheSettings(t *testing.T) { defer func() { record(t, "cache_settings/cleanup", func(c *Client) { c.DeleteCacheSetting(&DeleteCacheSettingInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-cache-setting", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "test-cache-setting", }) c.DeleteCacheSetting(&DeleteCacheSettingInput{ - Service: testServiceID, - Version: tv.Number, - Name: "new-test-cache-setting", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "new-test-cache-setting", }) }) }() @@ -61,8 +61,8 @@ func TestClient_CacheSettings(t *testing.T) { var cacheSettings []*CacheSetting record(t, "cache_settings/list", func(c *Client) { cacheSettings, err = c.ListCacheSettings(&ListCacheSettingsInput{ - Service: testServiceID, - Version: tv.Number, + ServiceID: testServiceID, + ServiceVersion: tv.Number, }) }) if err != nil { @@ -76,9 +76,9 @@ func TestClient_CacheSettings(t *testing.T) { var newCacheSetting *CacheSetting record(t, "cache_settings/get", func(c *Client) { newCacheSetting, err = c.GetCacheSetting(&GetCacheSettingInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-cache-setting", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "test-cache-setting", }) }) if err != nil { @@ -101,10 +101,10 @@ func TestClient_CacheSettings(t *testing.T) { var updatedCacheSetting *CacheSetting record(t, "cache_settings/update", func(c *Client) { updatedCacheSetting, err = c.UpdateCacheSetting(&UpdateCacheSettingInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-cache-setting", - NewName: "new-test-cache-setting", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "test-cache-setting", + NewName: "new-test-cache-setting", }) }) if err != nil { @@ -117,9 +117,9 @@ func TestClient_CacheSettings(t *testing.T) { // Delete record(t, "cache_settings/delete", func(c *Client) { err = c.DeleteCacheSetting(&DeleteCacheSettingInput{ - Service: testServiceID, - Version: tv.Number, - Name: "new-test-cache-setting", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "new-test-cache-setting", }) }) if err != nil { @@ -130,17 +130,17 @@ func TestClient_CacheSettings(t *testing.T) { func TestClient_ListCacheSettings_validation(t *testing.T) { var err error _, err = testClient.ListCacheSettings(&ListCacheSettingsInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.ListCacheSettings(&ListCacheSettingsInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } } @@ -148,17 +148,17 @@ func TestClient_ListCacheSettings_validation(t *testing.T) { func TestClient_CreateCacheSetting_validation(t *testing.T) { var err error _, err = testClient.CreateCacheSetting(&CreateCacheSettingInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.CreateCacheSetting(&CreateCacheSettingInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } } @@ -166,24 +166,24 @@ func TestClient_CreateCacheSetting_validation(t *testing.T) { func TestClient_GetCacheSetting_validation(t *testing.T) { var err error _, err = testClient.GetCacheSetting(&GetCacheSettingInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.GetCacheSetting(&GetCacheSettingInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } _, err = testClient.GetCacheSetting(&GetCacheSettingInput{ - Service: "foo", - Version: 1, - Name: "", + ServiceID: "foo", + ServiceVersion: 1, + Name: "", }) if err != ErrMissingName { t.Errorf("bad error: %s", err) @@ -193,24 +193,24 @@ func TestClient_GetCacheSetting_validation(t *testing.T) { func TestClient_UpdateCacheSetting_validation(t *testing.T) { var err error _, err = testClient.UpdateCacheSetting(&UpdateCacheSettingInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.UpdateCacheSetting(&UpdateCacheSettingInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } _, err = testClient.UpdateCacheSetting(&UpdateCacheSettingInput{ - Service: "foo", - Version: 1, - Name: "", + ServiceID: "foo", + ServiceVersion: 1, + Name: "", }) if err != ErrMissingName { t.Errorf("bad error: %s", err) @@ -220,24 +220,24 @@ func TestClient_UpdateCacheSetting_validation(t *testing.T) { func TestClient_DeleteCacheSetting_validation(t *testing.T) { var err error err = testClient.DeleteCacheSetting(&DeleteCacheSettingInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } err = testClient.DeleteCacheSetting(&DeleteCacheSettingInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } err = testClient.DeleteCacheSetting(&DeleteCacheSettingInput{ - Service: "foo", - Version: 1, - Name: "", + ServiceID: "foo", + ServiceVersion: 1, + Name: "", }) if err != ErrMissingName { t.Errorf("bad error: %s", err) diff --git a/fastly/cloudfiles.go b/fastly/cloudfiles.go index 628fdccd0..fa515a37f 100644 --- a/fastly/cloudfiles.go +++ b/fastly/cloudfiles.go @@ -44,24 +44,24 @@ func (c cloudfilesByName) Less(i, j int) bool { // ListCloudfilesInput is used as input to the ListCloudfiles function. type ListCloudfilesInput struct { - // Service is the ID of the service (required). - Service string + // ServiceID is the ID of the service (required). + ServiceID string - // Version is the specific configuration version (required). - Version int + // ServiceVersion is the specific configuration version (required). + ServiceVersion int } // ListCloudfiles returns the list of Cloudfiles for the configuration version. func (c *Client) ListCloudfiles(i *ListCloudfilesInput) ([]*Cloudfiles, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/cloudfiles", i.Service, i.Version) + path := fmt.Sprintf("/service/%s/version/%d/logging/cloudfiles", i.ServiceID, i.ServiceVersion) resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -77,10 +77,11 @@ func (c *Client) ListCloudfiles(i *ListCloudfilesInput) ([]*Cloudfiles, error) { // CreateCloudfilesInput is used as input to the CreateCloudfiles function. type CreateCloudfilesInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int Name *string `form:"name,omitempty"` User *string `form:"user,omitempty"` @@ -101,15 +102,15 @@ type CreateCloudfilesInput struct { // CreateCloudfiles creates a new Fastly Cloudfiles. func (c *Client) CreateCloudfiles(i *CreateCloudfilesInput) (*Cloudfiles, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/cloudfiles", i.Service, i.Version) + path := fmt.Sprintf("/service/%s/version/%d/logging/cloudfiles", i.ServiceID, i.ServiceVersion) resp, err := c.PostForm(path, i, nil) if err != nil { return nil, err @@ -124,10 +125,11 @@ func (c *Client) CreateCloudfiles(i *CreateCloudfilesInput) (*Cloudfiles, error) // GetCloudfilesInput is used as input to the GetCloudfiles function. type GetCloudfilesInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int // Name is the name of the Cloudfiles to fetch. Name string @@ -135,19 +137,19 @@ type GetCloudfilesInput struct { // GetCloudfiles gets the Cloudfiles configuration with the given parameters. func (c *Client) GetCloudfiles(i *GetCloudfilesInput) (*Cloudfiles, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } if i.Name == "" { return nil, ErrMissingName } - path := fmt.Sprintf("/service/%s/version/%d/logging/cloudfiles/%s", i.Service, i.Version, url.PathEscape(i.Name)) + path := fmt.Sprintf("/service/%s/version/%d/logging/cloudfiles/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -162,10 +164,11 @@ func (c *Client) GetCloudfiles(i *GetCloudfilesInput) (*Cloudfiles, error) { // UpdateCloudfilesInput is used as input to the UpdateCloudfiles function. type UpdateCloudfilesInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int // Name is the name of the Cloudfiles to update. Name string @@ -189,19 +192,19 @@ type UpdateCloudfilesInput struct { // UpdateCloudfiles updates a specific Cloudfiles. func (c *Client) UpdateCloudfiles(i *UpdateCloudfilesInput) (*Cloudfiles, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } if i.Name == "" { return nil, ErrMissingName } - path := fmt.Sprintf("/service/%s/version/%d/logging/cloudfiles/%s", i.Service, i.Version, url.PathEscape(i.Name)) + path := fmt.Sprintf("/service/%s/version/%d/logging/cloudfiles/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) resp, err := c.PutForm(path, i, nil) if err != nil { return nil, err @@ -216,10 +219,11 @@ func (c *Client) UpdateCloudfiles(i *UpdateCloudfilesInput) (*Cloudfiles, error) // DeleteCloudfilesInput is the input parameter to DeleteCloudfiles. type DeleteCloudfilesInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int // Name is the name of the Cloudfiles to delete (required). Name string @@ -227,19 +231,19 @@ type DeleteCloudfilesInput struct { // DeleteCloudfiles deletes the given Cloudfiles version. func (c *Client) DeleteCloudfiles(i *DeleteCloudfilesInput) error { - if i.Service == "" { - return ErrMissingService + if i.ServiceID == "" { + return ErrMissingServiceID } - if i.Version == 0 { - return ErrMissingVersion + if i.ServiceVersion == 0 { + return ErrMissingServiceVersion } if i.Name == "" { return ErrMissingName } - path := fmt.Sprintf("/service/%s/version/%d/logging/cloudfiles/%s", i.Service, i.Version, url.PathEscape(i.Name)) + path := fmt.Sprintf("/service/%s/version/%d/logging/cloudfiles/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) resp, err := c.Delete(path, nil) if err != nil { return err diff --git a/fastly/cloudfiles_test.go b/fastly/cloudfiles_test.go index 72f9d5a02..1a706bae7 100644 --- a/fastly/cloudfiles_test.go +++ b/fastly/cloudfiles_test.go @@ -15,8 +15,8 @@ func TestClient_Cloudfiles(t *testing.T) { var cloudfiles *Cloudfiles record(t, "cloudfiles/create", func(c *Client) { cloudfiles, err = c.CreateCloudfiles(&CreateCloudfilesInput{ - Service: testServiceID, - Version: tv.Number, + ServiceID: testServiceID, + ServiceVersion: tv.Number, Name: String("test-cloudfiles"), User: String("user"), AccessKey: String("secret-key"), @@ -41,15 +41,15 @@ func TestClient_Cloudfiles(t *testing.T) { defer func() { record(t, "cloudfiles/cleanup", func(c *Client) { c.DeleteCloudfiles(&DeleteCloudfilesInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-cloudfiles", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "test-cloudfiles", }) c.DeleteCloudfiles(&DeleteCloudfilesInput{ - Service: testServiceID, - Version: tv.Number, - Name: "new-test-cloudfiles", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "new-test-cloudfiles", }) }) }() @@ -101,8 +101,8 @@ func TestClient_Cloudfiles(t *testing.T) { var lc []*Cloudfiles record(t, "cloudfiles/list", func(c *Client) { lc, err = c.ListCloudfiles(&ListCloudfilesInput{ - Service: testServiceID, - Version: tv.Number, + ServiceID: testServiceID, + ServiceVersion: tv.Number, }) }) if err != nil { @@ -116,9 +116,9 @@ func TestClient_Cloudfiles(t *testing.T) { var ncloudfiles *Cloudfiles record(t, "cloudfiles/get", func(c *Client) { ncloudfiles, err = c.GetCloudfiles(&GetCloudfilesInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-cloudfiles", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "test-cloudfiles", }) }) if err != nil { @@ -171,14 +171,14 @@ func TestClient_Cloudfiles(t *testing.T) { var ucloudfiles *Cloudfiles record(t, "cloudfiles/update", func(c *Client) { ucloudfiles, err = c.UpdateCloudfiles(&UpdateCloudfilesInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-cloudfiles", - NewName: String("new-test-cloudfiles"), - User: String("new-user"), - Period: Uint(0), - GzipLevel: Uint(0), - FormatVersion: Uint(2), + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "test-cloudfiles", + NewName: String("new-test-cloudfiles"), + User: String("new-user"), + Period: Uint(0), + GzipLevel: Uint(0), + FormatVersion: Uint(2), }) }) if err != nil { @@ -203,9 +203,9 @@ func TestClient_Cloudfiles(t *testing.T) { // Delete record(t, "cloudfiles/delete", func(c *Client) { err = c.DeleteCloudfiles(&DeleteCloudfilesInput{ - Service: testServiceID, - Version: tv.Number, - Name: "new-test-cloudfiles", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "new-test-cloudfiles", }) }) if err != nil { @@ -216,17 +216,17 @@ func TestClient_Cloudfiles(t *testing.T) { func TestClient_ListCloudfiles_validation(t *testing.T) { var err error _, err = testClient.ListCloudfiles(&ListCloudfilesInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.ListCloudfiles(&ListCloudfilesInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } } @@ -234,17 +234,17 @@ func TestClient_ListCloudfiles_validation(t *testing.T) { func TestClient_CreateCloudfiles_validation(t *testing.T) { var err error _, err = testClient.CreateCloudfiles(&CreateCloudfilesInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.CreateCloudfiles(&CreateCloudfilesInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } } @@ -252,24 +252,24 @@ func TestClient_CreateCloudfiles_validation(t *testing.T) { func TestClient_GetCloudfiles_validation(t *testing.T) { var err error _, err = testClient.GetCloudfiles(&GetCloudfilesInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.GetCloudfiles(&GetCloudfilesInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } _, err = testClient.GetCloudfiles(&GetCloudfilesInput{ - Service: "foo", - Version: 1, - Name: "", + ServiceID: "foo", + ServiceVersion: 1, + Name: "", }) if err != ErrMissingName { t.Errorf("bad error: %s", err) @@ -279,24 +279,24 @@ func TestClient_GetCloudfiles_validation(t *testing.T) { func TestClient_UpdateCloudfiles_validation(t *testing.T) { var err error _, err = testClient.UpdateCloudfiles(&UpdateCloudfilesInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.UpdateCloudfiles(&UpdateCloudfilesInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } _, err = testClient.UpdateCloudfiles(&UpdateCloudfilesInput{ - Service: "foo", - Version: 1, - Name: "", + ServiceID: "foo", + ServiceVersion: 1, + Name: "", }) if err != ErrMissingName { t.Errorf("bad error: %s", err) @@ -306,24 +306,24 @@ func TestClient_UpdateCloudfiles_validation(t *testing.T) { func TestClient_DeleteCloudfiles_validation(t *testing.T) { var err error err = testClient.DeleteCloudfiles(&DeleteCloudfilesInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } err = testClient.DeleteCloudfiles(&DeleteCloudfilesInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } err = testClient.DeleteCloudfiles(&DeleteCloudfilesInput{ - Service: "foo", - Version: 1, - Name: "", + ServiceID: "foo", + ServiceVersion: 1, + Name: "", }) if err != ErrMissingName { t.Errorf("bad error: %s", err) diff --git a/fastly/condition.go b/fastly/condition.go index b22718a5d..6cf47af71 100644 --- a/fastly/condition.go +++ b/fastly/condition.go @@ -34,24 +34,24 @@ func (s conditionsByName) Less(i, j int) bool { // ListConditionsInput is used as input to the ListConditions function. type ListConditionsInput struct { - // Service is the ID of the service (required). - Service string + // ServiceID is the ID of the service (required). + ServiceID string - // Version is the specific configuration version (required). - Version int + // ServiceVersion is the specific configuration version (required). + ServiceVersion int } // ListConditions returns the list of conditions for the configuration version. func (c *Client) ListConditions(i *ListConditionsInput) ([]*Condition, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/condition", i.Service, i.Version) + path := fmt.Sprintf("/service/%s/version/%d/condition", i.ServiceID, i.ServiceVersion) resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -67,10 +67,11 @@ func (c *Client) ListConditions(i *ListConditionsInput) ([]*Condition, error) { // CreateConditionInput is used as input to the CreateCondition function. type CreateConditionInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int Name string `form:"name,omitempty"` Statement string `form:"statement,omitempty"` @@ -80,15 +81,15 @@ type CreateConditionInput struct { // CreateCondition creates a new Fastly condition. func (c *Client) CreateCondition(i *CreateConditionInput) (*Condition, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/condition", i.Service, i.Version) + path := fmt.Sprintf("/service/%s/version/%d/condition", i.ServiceID, i.ServiceVersion) resp, err := c.PostForm(path, i, nil) if err != nil { return nil, err @@ -103,10 +104,11 @@ func (c *Client) CreateCondition(i *CreateConditionInput) (*Condition, error) { // GetConditionInput is used as input to the GetCondition function. type GetConditionInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int // Name is the name of the condition to fetch. Name string @@ -114,19 +116,19 @@ type GetConditionInput struct { // GetCondition gets the condition configuration with the given parameters. func (c *Client) GetCondition(i *GetConditionInput) (*Condition, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } if i.Name == "" { return nil, ErrMissingName } - path := fmt.Sprintf("/service/%s/version/%d/condition/%s", i.Service, i.Version, url.PathEscape(i.Name)) + path := fmt.Sprintf("/service/%s/version/%d/condition/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -141,10 +143,11 @@ func (c *Client) GetCondition(i *GetConditionInput) (*Condition, error) { // UpdateConditionInput is used as input to the UpdateCondition function. type UpdateConditionInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int // Name is the name of the condition to update. Name string @@ -157,19 +160,19 @@ type UpdateConditionInput struct { // UpdateCondition updates a specific condition. func (c *Client) UpdateCondition(i *UpdateConditionInput) (*Condition, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } if i.Name == "" { return nil, ErrMissingName } - path := fmt.Sprintf("/service/%s/version/%d/condition/%s", i.Service, i.Version, url.PathEscape(i.Name)) + path := fmt.Sprintf("/service/%s/version/%d/condition/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) resp, err := c.PutForm(path, i, nil) if err != nil { return nil, err @@ -184,10 +187,11 @@ func (c *Client) UpdateCondition(i *UpdateConditionInput) (*Condition, error) { // DeleteConditionInput is the input parameter to DeleteCondition. type DeleteConditionInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int // Name is the name of the condition to delete (required). Name string @@ -195,19 +199,19 @@ type DeleteConditionInput struct { // DeleteCondition deletes the given condition version. func (c *Client) DeleteCondition(i *DeleteConditionInput) error { - if i.Service == "" { - return ErrMissingService + if i.ServiceID == "" { + return ErrMissingServiceID } - if i.Version == 0 { - return ErrMissingVersion + if i.ServiceVersion == 0 { + return ErrMissingServiceVersion } if i.Name == "" { return ErrMissingName } - path := fmt.Sprintf("/service/%s/version/%d/condition/%s", i.Service, i.Version, url.PathEscape(i.Name)) + path := fmt.Sprintf("/service/%s/version/%d/condition/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) resp, err := c.Delete(path, nil) if err != nil { return err diff --git a/fastly/condition_test.go b/fastly/condition_test.go index a4be12b57..9f759c6c3 100644 --- a/fastly/condition_test.go +++ b/fastly/condition_test.go @@ -15,12 +15,12 @@ func TestClient_Conditions(t *testing.T) { var condition *Condition record(t, "conditions/create", func(c *Client) { condition, err = c.CreateCondition(&CreateConditionInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test/condition", - Statement: "req.url~+\"index.html\"", - Type: "REQUEST", - Priority: 1, + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "test/condition", + Statement: "req.url~+\"index.html\"", + Type: "REQUEST", + Priority: 1, }) }) if err != nil { @@ -31,9 +31,9 @@ func TestClient_Conditions(t *testing.T) { defer func() { record(t, "conditions/cleanup", func(c *Client) { c.DeleteCondition(&DeleteConditionInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test/condition", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "test/condition", }) }) }() @@ -55,8 +55,8 @@ func TestClient_Conditions(t *testing.T) { var conditions []*Condition record(t, "conditions/list", func(c *Client) { conditions, err = c.ListConditions(&ListConditionsInput{ - Service: testServiceID, - Version: tv.Number, + ServiceID: testServiceID, + ServiceVersion: tv.Number, }) }) if err != nil { @@ -70,9 +70,9 @@ func TestClient_Conditions(t *testing.T) { var newCondition *Condition record(t, "conditions/get", func(c *Client) { newCondition, err = c.GetCondition(&GetConditionInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test/condition", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "test/condition", }) }) if err != nil { @@ -95,10 +95,10 @@ func TestClient_Conditions(t *testing.T) { var updatedCondition *Condition record(t, "conditions/update", func(c *Client) { updatedCondition, err = c.UpdateCondition(&UpdateConditionInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test/condition", - Statement: "req.url~+\"updated.html\"", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "test/condition", + Statement: "req.url~+\"updated.html\"", }) }) if err != nil { @@ -111,9 +111,9 @@ func TestClient_Conditions(t *testing.T) { // Delete record(t, "conditions/delete", func(c *Client) { err = c.DeleteCondition(&DeleteConditionInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test/condition", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "test/condition", }) }) if err != nil { @@ -124,17 +124,17 @@ func TestClient_Conditions(t *testing.T) { func TestClient_ListConditions_validation(t *testing.T) { var err error _, err = testClient.ListConditions(&ListConditionsInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.ListConditions(&ListConditionsInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } } @@ -142,17 +142,17 @@ func TestClient_ListConditions_validation(t *testing.T) { func TestClient_CreateCondition_validation(t *testing.T) { var err error _, err = testClient.CreateCondition(&CreateConditionInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.CreateCondition(&CreateConditionInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } } @@ -160,24 +160,24 @@ func TestClient_CreateCondition_validation(t *testing.T) { func TestClient_GetCondition_validation(t *testing.T) { var err error _, err = testClient.GetCondition(&GetConditionInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.GetCondition(&GetConditionInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } _, err = testClient.GetCondition(&GetConditionInput{ - Service: "foo", - Version: 1, - Name: "", + ServiceID: "foo", + ServiceVersion: 1, + Name: "", }) if err != ErrMissingName { t.Errorf("bad error: %s", err) @@ -187,24 +187,24 @@ func TestClient_GetCondition_validation(t *testing.T) { func TestClient_UpdateCondition_validation(t *testing.T) { var err error _, err = testClient.UpdateCondition(&UpdateConditionInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.UpdateCondition(&UpdateConditionInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } _, err = testClient.UpdateCondition(&UpdateConditionInput{ - Service: "foo", - Version: 1, - Name: "", + ServiceID: "foo", + ServiceVersion: 1, + Name: "", }) if err != ErrMissingName { t.Errorf("bad error: %s", err) @@ -214,24 +214,24 @@ func TestClient_UpdateCondition_validation(t *testing.T) { func TestClient_DeleteCondition_validation(t *testing.T) { var err error err = testClient.DeleteCondition(&DeleteConditionInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } err = testClient.DeleteCondition(&DeleteConditionInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } err = testClient.DeleteCondition(&DeleteConditionInput{ - Service: "foo", - Version: 1, - Name: "", + ServiceID: "foo", + ServiceVersion: 1, + Name: "", }) if err != ErrMissingName { t.Errorf("bad error: %s", err) diff --git a/fastly/datadog.go b/fastly/datadog.go index 489327b0b..db4609c58 100644 --- a/fastly/datadog.go +++ b/fastly/datadog.go @@ -36,24 +36,24 @@ func (s datadogByName) Less(i, j int) bool { // ListDatadogInput is used as input to the ListDatadog function. type ListDatadogInput struct { - // Service is the ID of the service (required). - Service string + // ServiceID is the ID of the service (required). + ServiceID string - // Version is the specific configuration version (required). - Version int + // ServiceVersion is the specific configuration version (required). + ServiceVersion int } // ListDatadog returns the list of Datadog for the configuration version. func (c *Client) ListDatadog(i *ListDatadogInput) ([]*Datadog, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/datadog", i.Service, i.Version) + path := fmt.Sprintf("/service/%s/version/%d/logging/datadog", i.ServiceID, i.ServiceVersion) resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -69,10 +69,11 @@ func (c *Client) ListDatadog(i *ListDatadogInput) ([]*Datadog, error) { // CreateDatadogInput is used as input to the CreateDatadog function. type CreateDatadogInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int Name *string `form:"name,omitempty"` Token *string `form:"token,omitempty"` @@ -85,15 +86,15 @@ type CreateDatadogInput struct { // CreateDatadog creates a new Datadog logging endpoint on a Fastly service version. func (c *Client) CreateDatadog(i *CreateDatadogInput) (*Datadog, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/datadog", i.Service, i.Version) + path := fmt.Sprintf("/service/%s/version/%d/logging/datadog", i.ServiceID, i.ServiceVersion) resp, err := c.PostForm(path, i, nil) if err != nil { return nil, err @@ -108,10 +109,11 @@ func (c *Client) CreateDatadog(i *CreateDatadogInput) (*Datadog, error) { // GetDatadogInput is used as input to the GetDatadog function. type GetDatadogInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int // Name is the name of the Datadog to fetch. Name string @@ -119,19 +121,19 @@ type GetDatadogInput struct { // GetDatadog gets the Datadog configuration with the given parameters. func (c *Client) GetDatadog(i *GetDatadogInput) (*Datadog, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } if i.Name == "" { return nil, ErrMissingName } - path := fmt.Sprintf("/service/%s/version/%d/logging/datadog/%s", i.Service, i.Version, url.PathEscape(i.Name)) + path := fmt.Sprintf("/service/%s/version/%d/logging/datadog/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -146,10 +148,11 @@ func (c *Client) GetDatadog(i *GetDatadogInput) (*Datadog, error) { // UpdateDatadogInput is used as input to the UpdateDatadog function. type UpdateDatadogInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int // Name is the name of the Datadog to update. Name string @@ -165,19 +168,19 @@ type UpdateDatadogInput struct { // UpdateDatadog updates a Datadog logging endpoint on a Fastly service version. func (c *Client) UpdateDatadog(i *UpdateDatadogInput) (*Datadog, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } if i.Name == "" { return nil, ErrMissingName } - path := fmt.Sprintf("/service/%s/version/%d/logging/datadog/%s", i.Service, i.Version, url.PathEscape(i.Name)) + path := fmt.Sprintf("/service/%s/version/%d/logging/datadog/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) resp, err := c.PutForm(path, i, nil) if err != nil { return nil, err @@ -192,10 +195,11 @@ func (c *Client) UpdateDatadog(i *UpdateDatadogInput) (*Datadog, error) { // DeleteDatadogInput is the input parameter to DeleteDatadog. type DeleteDatadogInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int // Name is the name of the Datadog to delete (required). Name string @@ -203,19 +207,19 @@ type DeleteDatadogInput struct { // DeleteDatadog deletes a Datadog logging endpoint on a Fastly service version. func (c *Client) DeleteDatadog(i *DeleteDatadogInput) error { - if i.Service == "" { - return ErrMissingService + if i.ServiceID == "" { + return ErrMissingServiceID } - if i.Version == 0 { - return ErrMissingVersion + if i.ServiceVersion == 0 { + return ErrMissingServiceVersion } if i.Name == "" { return ErrMissingName } - path := fmt.Sprintf("/service/%s/version/%d/logging/datadog/%s", i.Service, i.Version, url.PathEscape(i.Name)) + path := fmt.Sprintf("/service/%s/version/%d/logging/datadog/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) resp, err := c.Delete(path, nil) if err != nil { return err diff --git a/fastly/datadog_test.go b/fastly/datadog_test.go index eade5cf20..4e878ec0f 100644 --- a/fastly/datadog_test.go +++ b/fastly/datadog_test.go @@ -15,13 +15,13 @@ func TestClient_Datadog(t *testing.T) { var d *Datadog record(t, "datadog/create", func(c *Client) { d, err = c.CreateDatadog(&CreateDatadogInput{ - Service: testServiceID, - Version: tv.Number, - Name: String("test-datadog"), - Region: String("US"), - Token: String("abcd1234"), - Format: String("format"), - Placement: String("waf_debug"), + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: String("test-datadog"), + Region: String("US"), + Token: String("abcd1234"), + Format: String("format"), + Placement: String("waf_debug"), }) }) if err != nil { @@ -32,15 +32,15 @@ func TestClient_Datadog(t *testing.T) { defer func() { record(t, "datadog/delete", func(c *Client) { c.DeleteDatadog(&DeleteDatadogInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-datadog", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "test-datadog", }) c.DeleteDatadog(&DeleteDatadogInput{ - Service: testServiceID, - Version: tv.Number, - Name: "new-test-datadog", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "new-test-datadog", }) }) }() @@ -68,8 +68,8 @@ func TestClient_Datadog(t *testing.T) { var ld []*Datadog record(t, "datadog/list", func(c *Client) { ld, err = c.ListDatadog(&ListDatadogInput{ - Service: testServiceID, - Version: tv.Number, + ServiceID: testServiceID, + ServiceVersion: tv.Number, }) }) if err != nil { @@ -83,9 +83,9 @@ func TestClient_Datadog(t *testing.T) { var nd *Datadog record(t, "datadog/get", func(c *Client) { nd, err = c.GetDatadog(&GetDatadogInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-datadog", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "test-datadog", }) }) if err != nil { @@ -111,12 +111,12 @@ func TestClient_Datadog(t *testing.T) { var ud *Datadog record(t, "datadog/update", func(c *Client) { ud, err = c.UpdateDatadog(&UpdateDatadogInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-datadog", - NewName: String("new-test-datadog"), - Region: String("EU"), - FormatVersion: Uint(2), + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "test-datadog", + NewName: String("new-test-datadog"), + Region: String("EU"), + FormatVersion: Uint(2), }) }) if err != nil { @@ -135,9 +135,9 @@ func TestClient_Datadog(t *testing.T) { // Delete record(t, "datadog/delete", func(c *Client) { err = c.DeleteDatadog(&DeleteDatadogInput{ - Service: testServiceID, - Version: tv.Number, - Name: "new-test-datadog", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "new-test-datadog", }) }) if err != nil { @@ -148,17 +148,17 @@ func TestClient_Datadog(t *testing.T) { func TestClient_ListDatadog_validation(t *testing.T) { var err error _, err = testClient.ListDatadog(&ListDatadogInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.ListDatadog(&ListDatadogInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } } @@ -166,17 +166,17 @@ func TestClient_ListDatadog_validation(t *testing.T) { func TestClient_CreateDatadog_validation(t *testing.T) { var err error _, err = testClient.CreateDatadog(&CreateDatadogInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.CreateDatadog(&CreateDatadogInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } } @@ -184,24 +184,24 @@ func TestClient_CreateDatadog_validation(t *testing.T) { func TestClient_GetDatadog_validation(t *testing.T) { var err error _, err = testClient.GetDatadog(&GetDatadogInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.GetDatadog(&GetDatadogInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } _, err = testClient.GetDatadog(&GetDatadogInput{ - Service: "foo", - Version: 1, - Name: "", + ServiceID: "foo", + ServiceVersion: 1, + Name: "", }) if err != ErrMissingName { t.Errorf("bad error: %s", err) @@ -211,24 +211,24 @@ func TestClient_GetDatadog_validation(t *testing.T) { func TestClient_UpdateDatadog_validation(t *testing.T) { var err error _, err = testClient.UpdateDatadog(&UpdateDatadogInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.UpdateDatadog(&UpdateDatadogInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } _, err = testClient.UpdateDatadog(&UpdateDatadogInput{ - Service: "foo", - Version: 1, - Name: "", + ServiceID: "foo", + ServiceVersion: 1, + Name: "", }) if err != ErrMissingName { t.Errorf("bad error: %s", err) @@ -238,24 +238,24 @@ func TestClient_UpdateDatadog_validation(t *testing.T) { func TestClient_DeleteDatadog_validation(t *testing.T) { var err error err = testClient.DeleteDatadog(&DeleteDatadogInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } err = testClient.DeleteDatadog(&DeleteDatadogInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } err = testClient.DeleteDatadog(&DeleteDatadogInput{ - Service: "foo", - Version: 1, - Name: "", + ServiceID: "foo", + ServiceVersion: 1, + Name: "", }) if err != ErrMissingName { t.Errorf("bad error: %s", err) diff --git a/fastly/dictionary.go b/fastly/dictionary.go index 462966125..b2e81d3e5 100644 --- a/fastly/dictionary.go +++ b/fastly/dictionary.go @@ -32,24 +32,24 @@ func (s dictionariesByName) Less(i, j int) bool { // ListDictionariesInput is used as input to the ListDictionaries function. type ListDictionariesInput struct { - // Service is the ID of the service (required). - Service string + // ServiceID is the ID of the service (required). + ServiceID string - // Version is the specific configuration version (required). - Version int + // ServiceVersion is the specific configuration version (required). + ServiceVersion int } // ListDictionaries returns the list of dictionaries for the configuration version. func (c *Client) ListDictionaries(i *ListDictionariesInput) ([]*Dictionary, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/dictionary", i.Service, i.Version) + path := fmt.Sprintf("/service/%s/version/%d/dictionary", i.ServiceID, i.ServiceVersion) resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -65,10 +65,11 @@ func (c *Client) ListDictionaries(i *ListDictionariesInput) ([]*Dictionary, erro // CreateDictionaryInput is used as input to the CreateDictionary function. type CreateDictionaryInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int Name string `form:"name,omitempty"` WriteOnly *Compatibool `form:"write_only,omitempty"` @@ -76,15 +77,15 @@ type CreateDictionaryInput struct { // CreateDictionary creates a new Fastly dictionary. func (c *Client) CreateDictionary(i *CreateDictionaryInput) (*Dictionary, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/dictionary", i.Service, i.Version) + path := fmt.Sprintf("/service/%s/version/%d/dictionary", i.ServiceID, i.ServiceVersion) resp, err := c.PostForm(path, i, nil) if err != nil { return nil, err @@ -99,10 +100,11 @@ func (c *Client) CreateDictionary(i *CreateDictionaryInput) (*Dictionary, error) // GetDictionaryInput is used as input to the GetDictionary function. type GetDictionaryInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int // Name is the name of the dictionary to fetch. Name string @@ -110,19 +112,19 @@ type GetDictionaryInput struct { // GetDictionary gets the dictionary configuration with the given parameters. func (c *Client) GetDictionary(i *GetDictionaryInput) (*Dictionary, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } if i.Name == "" { return nil, ErrMissingName } - path := fmt.Sprintf("/service/%s/version/%d/dictionary/%s", i.Service, i.Version, url.PathEscape(i.Name)) + path := fmt.Sprintf("/service/%s/version/%d/dictionary/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -137,10 +139,11 @@ func (c *Client) GetDictionary(i *GetDictionaryInput) (*Dictionary, error) { // UpdateDictionaryInput is used as input to the UpdateDictionary function. type UpdateDictionaryInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int // Name is the name of the dictionary to update. Name string @@ -151,19 +154,19 @@ type UpdateDictionaryInput struct { // UpdateDictionary updates a specific dictionary. func (c *Client) UpdateDictionary(i *UpdateDictionaryInput) (*Dictionary, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } if i.Name == "" { return nil, ErrMissingName } - path := fmt.Sprintf("/service/%s/version/%d/dictionary/%s", i.Service, i.Version, url.PathEscape(i.Name)) + path := fmt.Sprintf("/service/%s/version/%d/dictionary/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) resp, err := c.PutForm(path, i, nil) if err != nil { return nil, err @@ -178,10 +181,11 @@ func (c *Client) UpdateDictionary(i *UpdateDictionaryInput) (*Dictionary, error) // DeleteDictionaryInput is the input parameter to DeleteDictionary. type DeleteDictionaryInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int // Name is the name of the dictionary to delete (required). Name string @@ -189,19 +193,19 @@ type DeleteDictionaryInput struct { // DeleteDictionary deletes the given dictionary version. func (c *Client) DeleteDictionary(i *DeleteDictionaryInput) error { - if i.Service == "" { - return ErrMissingService + if i.ServiceID == "" { + return ErrMissingServiceID } - if i.Version == 0 { - return ErrMissingVersion + if i.ServiceVersion == 0 { + return ErrMissingServiceVersion } if i.Name == "" { return ErrMissingName } - path := fmt.Sprintf("/service/%s/version/%d/dictionary/%s", i.Service, i.Version, url.PathEscape(i.Name)) + path := fmt.Sprintf("/service/%s/version/%d/dictionary/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) resp, err := c.Delete(path, nil) if err != nil { return err diff --git a/fastly/dictionary_info.go b/fastly/dictionary_info.go index 39423543d..ef8e195c6 100644 --- a/fastly/dictionary_info.go +++ b/fastly/dictionary_info.go @@ -22,8 +22,8 @@ type GetDictionaryInfoInput struct { // ServiceID is the ID of the service Dictionary belongs to (required). ServiceID string - // Version is the specific configuration version (required). - Version int + // ServiceVersion is the specific configuration version (required). + ServiceVersion int // ID is the alphanumeric string identifying a dictionary. ID string @@ -32,18 +32,18 @@ type GetDictionaryInfoInput struct { // GetDictionaryInfo gets the dictionary metadata with the given parameters. func (c *Client) GetDictionaryInfo(i *GetDictionaryInfoInput) (*DictionaryInfo, error) { if i.ServiceID == "" { - return nil, ErrMissingService + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } if i.ID == "" { return nil, ErrMissingID } - path := fmt.Sprintf("/service/%s/version/%d/dictionary/%s/info", i.ServiceID, i.Version, i.ID) + path := fmt.Sprintf("/service/%s/version/%d/dictionary/%s/info", i.ServiceID, i.ServiceVersion, i.ID) resp, err := c.Get(path, nil) if err != nil { return nil, err diff --git a/fastly/dictionary_info_test.go b/fastly/dictionary_info_test.go index 7448d8ff4..77b54539a 100644 --- a/fastly/dictionary_info_test.go +++ b/fastly/dictionary_info_test.go @@ -24,8 +24,8 @@ func TestClient_GetDictionaryInfo(t *testing.T) { record(t, fixtureBase+"create_dictionary_items", func(c *Client) { err = c.BatchModifyDictionaryItems(&BatchModifyDictionaryItemsInput{ - Service: testService.ID, - Dictionary: testDictionary.ID, + ServiceID: testService.ID, + DictionaryID: testDictionary.ID, Items: []*BatchDictionaryItem{ { Operation: CreateBatchOperation, @@ -46,9 +46,9 @@ func TestClient_GetDictionaryInfo(t *testing.T) { record(t, fixtureBase+"get", func(c *Client) { info, err = c.GetDictionaryInfo(&GetDictionaryInfoInput{ - ServiceID: testService.ID, - Version: testVersion.Number, - ID: testDictionary.ID, + ServiceID: testService.ID, + ServiceVersion: testVersion.Number, + ID: testDictionary.ID, }) }) if err != nil { @@ -65,22 +65,22 @@ func TestClient_GetDictionaryInfo_validation(t *testing.T) { _, err = testClient.GetDictionaryInfo(&GetDictionaryInfoInput{ ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.GetDictionaryInfo(&GetDictionaryInfoInput{ - ServiceID: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } _, err = testClient.GetDictionaryInfo(&GetDictionaryInfoInput{ - ServiceID: "foo", - Version: 1, - ID: "", + ServiceID: "foo", + ServiceVersion: 1, + ID: "", }) if err != ErrMissingID { t.Errorf("bad error: %s", err) diff --git a/fastly/dictionary_item.go b/fastly/dictionary_item.go index b94c145c4..144c6d395 100644 --- a/fastly/dictionary_item.go +++ b/fastly/dictionary_item.go @@ -31,25 +31,25 @@ func (s dictionaryItemsByKey) Less(i, j int) bool { // ListDictionaryItemsInput is used as input to the ListDictionaryItems function. type ListDictionaryItemsInput struct { - // Service is the ID of the service (required). - Service string + // ServiceID is the ID of the service (required). + ServiceID string - // Dictionary is the ID of the dictionary to retrieve items for (required). - Dictionary string + // DictionaryID is the ID of the dictionary to retrieve items for (required). + DictionaryID string } // ListDictionaryItems returns the list of dictionary items for the // configuration version. func (c *Client) ListDictionaryItems(i *ListDictionaryItemsInput) ([]*DictionaryItem, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Dictionary == "" { + if i.DictionaryID == "" { return nil, ErrMissingDictionary } - path := fmt.Sprintf("/service/%s/dictionary/%s/items", i.Service, i.Dictionary) + path := fmt.Sprintf("/service/%s/dictionary/%s/items", i.ServiceID, i.DictionaryID) resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -65,10 +65,11 @@ func (c *Client) ListDictionaryItems(i *ListDictionaryItemsInput) ([]*Dictionary // CreateDictionaryItemInput is used as input to the CreateDictionaryItem function. type CreateDictionaryItemInput struct { - // Service is the ID of the service. Dictionary is the ID of the dictionary. - // Both fields are required. - Service string - Dictionary string + // ServiceID is the ID of the service (required). + ServiceID string + + // DictionaryID is the ID of the dictionary to retrieve items for (required). + DictionaryID string ItemKey string `form:"item_key,omitempty"` ItemValue string `form:"item_value,omitempty"` @@ -76,15 +77,15 @@ type CreateDictionaryItemInput struct { // CreateDictionaryItem creates a new Fastly dictionary item. func (c *Client) CreateDictionaryItem(i *CreateDictionaryItemInput) (*DictionaryItem, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Dictionary == "" { + if i.DictionaryID == "" { return nil, ErrMissingDictionary } - path := fmt.Sprintf("/service/%s/dictionary/%s/item", i.Service, i.Dictionary) + path := fmt.Sprintf("/service/%s/dictionary/%s/item", i.ServiceID, i.DictionaryID) resp, err := c.PostForm(path, i, nil) if err != nil { return nil, err @@ -113,10 +114,11 @@ func (c *Client) CreateDictionaryItems(i []CreateDictionaryItemInput) ([]Diction // GetDictionaryItemInput is used as input to the GetDictionaryItem function. type GetDictionaryItemInput struct { - // Service is the ID of the service. Dictionary is the ID of the dictionary. - // Both fields are required. - Service string - Dictionary string + // ServiceID is the ID of the service (required). + ServiceID string + + // DictionaryID is the ID of the dictionary to retrieve items for (required). + DictionaryID string // ItemKey is the name of the dictionary item to fetch. ItemKey string @@ -124,11 +126,11 @@ type GetDictionaryItemInput struct { // GetDictionaryItem gets the dictionary item with the given parameters. func (c *Client) GetDictionaryItem(i *GetDictionaryItemInput) (*DictionaryItem, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Dictionary == "" { + if i.DictionaryID == "" { return nil, ErrMissingDictionary } @@ -136,7 +138,7 @@ func (c *Client) GetDictionaryItem(i *GetDictionaryItemInput) (*DictionaryItem, return nil, ErrMissingItemKey } - path := fmt.Sprintf("/service/%s/dictionary/%s/item/%s", i.Service, i.Dictionary, url.PathEscape(i.ItemKey)) + path := fmt.Sprintf("/service/%s/dictionary/%s/item/%s", i.ServiceID, i.DictionaryID, url.PathEscape(i.ItemKey)) resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -151,10 +153,11 @@ func (c *Client) GetDictionaryItem(i *GetDictionaryItemInput) (*DictionaryItem, // UpdateDictionaryItemInput is used as input to the UpdateDictionaryItem function. type UpdateDictionaryItemInput struct { - // Service is the ID of the service. Dictionary is the ID of the dictionary. - // Both fields are required. - Service string - Dictionary string + // ServiceID is the ID of the service (required). + ServiceID string + + // DictionaryID is the ID of the dictionary to retrieve items for (required). + DictionaryID string // ItemKey is the name of the dictionary item to fetch. ItemKey string @@ -164,11 +167,11 @@ type UpdateDictionaryItemInput struct { // UpdateDictionaryItem updates a specific dictionary item. func (c *Client) UpdateDictionaryItem(i *UpdateDictionaryItemInput) (*DictionaryItem, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Dictionary == "" { + if i.DictionaryID == "" { return nil, ErrMissingDictionary } @@ -176,7 +179,7 @@ func (c *Client) UpdateDictionaryItem(i *UpdateDictionaryItemInput) (*Dictionary return nil, ErrMissingItemKey } - path := fmt.Sprintf("/service/%s/dictionary/%s/item/%s", i.Service, i.Dictionary, url.PathEscape(i.ItemKey)) + path := fmt.Sprintf("/service/%s/dictionary/%s/item/%s", i.ServiceID, i.DictionaryID, url.PathEscape(i.ItemKey)) resp, err := c.PutForm(path, i, nil) if err != nil { return nil, err @@ -190,8 +193,11 @@ func (c *Client) UpdateDictionaryItem(i *UpdateDictionaryItemInput) (*Dictionary } type BatchModifyDictionaryItemsInput struct { - Service string `json:"-"` - Dictionary string `json:"-"` + // ServiceID is the ID of the service (required). + ServiceID string `json:"-"` + + // DictionaryID is the ID of the dictionary to modify items for (required). + DictionaryID string `json:"-"` Items []*BatchDictionaryItem `json:"items"` } @@ -204,11 +210,11 @@ type BatchDictionaryItem struct { func (c *Client) BatchModifyDictionaryItems(i *BatchModifyDictionaryItemsInput) error { - if i.Service == "" { - return ErrMissingService + if i.ServiceID == "" { + return ErrMissingServiceID } - if i.Dictionary == "" { + if i.DictionaryID == "" { return ErrMissingDictionary } @@ -216,7 +222,7 @@ func (c *Client) BatchModifyDictionaryItems(i *BatchModifyDictionaryItemsInput) return ErrBatchUpdateMaximumOperationsExceeded } - path := fmt.Sprintf("/service/%s/dictionary/%s/items", i.Service, i.Dictionary) + path := fmt.Sprintf("/service/%s/dictionary/%s/items", i.ServiceID, i.DictionaryID) resp, err := c.PatchJSON(path, i, nil) if err != nil { return err @@ -232,10 +238,11 @@ func (c *Client) BatchModifyDictionaryItems(i *BatchModifyDictionaryItemsInput) // DeleteDictionaryItemInput is the input parameter to DeleteDictionaryItem. type DeleteDictionaryItemInput struct { - // Service is the ID of the service. Dictionary is the ID of the dictionary. - // Both fields are required. - Service string - Dictionary string + // ServiceID is the ID of the service (required). + ServiceID string + + // DictionaryID is the ID of the dictionary to retrieve items for (required). + DictionaryID string // ItemKey is the name of the dictionary item to delete. ItemKey string @@ -243,11 +250,11 @@ type DeleteDictionaryItemInput struct { // DeleteDictionaryItem deletes the given dictionary item. func (c *Client) DeleteDictionaryItem(i *DeleteDictionaryItemInput) error { - if i.Service == "" { - return ErrMissingService + if i.ServiceID == "" { + return ErrMissingServiceID } - if i.Dictionary == "" { + if i.DictionaryID == "" { return ErrMissingDictionary } @@ -255,7 +262,7 @@ func (c *Client) DeleteDictionaryItem(i *DeleteDictionaryItemInput) error { return ErrMissingItemKey } - path := fmt.Sprintf("/service/%s/dictionary/%s/item/%s", i.Service, i.Dictionary, url.PathEscape(i.ItemKey)) + path := fmt.Sprintf("/service/%s/dictionary/%s/item/%s", i.ServiceID, i.DictionaryID, url.PathEscape(i.ItemKey)) resp, err := c.Delete(path, nil) if err != nil { return err diff --git a/fastly/dictionary_item_batch_test.go b/fastly/dictionary_item_batch_test.go index 407b37ffb..2b01990f8 100644 --- a/fastly/dictionary_item_batch_test.go +++ b/fastly/dictionary_item_batch_test.go @@ -19,8 +19,8 @@ func TestClient_BatchModifyDictionaryItems_Create(t *testing.T) { defer deleteTestDictionary(t, testDictionary, fixtureBase+"delete_dictionary") batchCreateOperations := &BatchModifyDictionaryItemsInput{ - Service: testService.ID, - Dictionary: testDictionary.ID, + ServiceID: testService.ID, + DictionaryID: testDictionary.ID, Items: []*BatchDictionaryItem{ { Operation: CreateBatchOperation, @@ -49,8 +49,8 @@ func TestClient_BatchModifyDictionaryItems_Create(t *testing.T) { var actualDictionaryItems []*DictionaryItem record(t, fixtureBase+"list_after_create", func(c *Client) { actualDictionaryItems, err = c.ListDictionaryItems(&ListDictionaryItemsInput{ - Service: testService.ID, - Dictionary: testDictionary.ID, + ServiceID: testService.ID, + DictionaryID: testDictionary.ID, }) }) if err != nil { @@ -96,8 +96,8 @@ func TestClient_BatchModifyDictionaryItems_Delete(t *testing.T) { defer deleteTestDictionary(t, testDictionary, fixtureBase+"delete_dictionary") batchCreateOperations := &BatchModifyDictionaryItemsInput{ - Service: testService.ID, - Dictionary: testDictionary.ID, + ServiceID: testService.ID, + DictionaryID: testDictionary.ID, Items: []*BatchDictionaryItem{ { Operation: CreateBatchOperation, @@ -123,8 +123,8 @@ func TestClient_BatchModifyDictionaryItems_Delete(t *testing.T) { // When: I execute the batch delete operations against the Fastly API, batchDeleteOperations := &BatchModifyDictionaryItemsInput{ - Service: testService.ID, - Dictionary: testDictionary.ID, + ServiceID: testService.ID, + DictionaryID: testDictionary.ID, Items: []*BatchDictionaryItem{ { Operation: DeleteBatchOperation, @@ -146,8 +146,8 @@ func TestClient_BatchModifyDictionaryItems_Delete(t *testing.T) { var actualDictionaryItems []*DictionaryItem record(t, fixtureBase+"list_after_delete", func(client *Client) { actualDictionaryItems, err = client.ListDictionaryItems(&ListDictionaryItemsInput{ - Service: testService.ID, - Dictionary: testDictionary.ID, + ServiceID: testService.ID, + DictionaryID: testDictionary.ID, }) }) if err != nil { @@ -176,8 +176,8 @@ func TestClient_BatchModifyDictionaryItems_Update(t *testing.T) { defer deleteTestDictionary(t, testDictionary, fixtureBase+"delete_dictionary") batchCreateOperations := &BatchModifyDictionaryItemsInput{ - Service: testService.ID, - Dictionary: testDictionary.ID, + ServiceID: testService.ID, + DictionaryID: testDictionary.ID, Items: []*BatchDictionaryItem{ { Operation: CreateBatchOperation, @@ -203,8 +203,8 @@ func TestClient_BatchModifyDictionaryItems_Update(t *testing.T) { // When: I execute the batch update operations against the Fastly API, batchUpdateOperations := &BatchModifyDictionaryItemsInput{ - Service: testService.ID, - Dictionary: testDictionary.ID, + ServiceID: testService.ID, + DictionaryID: testDictionary.ID, Items: []*BatchDictionaryItem{ { Operation: UpdateBatchOperation, @@ -226,8 +226,8 @@ func TestClient_BatchModifyDictionaryItems_Update(t *testing.T) { var actualDictionaryItems []*DictionaryItem record(t, fixtureBase+"list_after_update", func(c *Client) { actualDictionaryItems, err = c.ListDictionaryItems(&ListDictionaryItemsInput{ - Service: testService.ID, - Dictionary: testDictionary.ID, + ServiceID: testService.ID, + DictionaryID: testDictionary.ID, }) }) if err != nil { @@ -286,8 +286,8 @@ func TestClient_BatchModifyDictionaryItems_Upsert(t *testing.T) { defer deleteTestDictionary(t, testDictionary, fixtureBase+"delete_dictionary") batchCreateOperations := &BatchModifyDictionaryItemsInput{ - Service: testService.ID, - Dictionary: testDictionary.ID, + ServiceID: testService.ID, + DictionaryID: testDictionary.ID, Items: []*BatchDictionaryItem{ { Operation: CreateBatchOperation, @@ -308,8 +308,8 @@ func TestClient_BatchModifyDictionaryItems_Upsert(t *testing.T) { // When: I execute the batch upsert operations against the Fastly API batchUpsertOperations := &BatchModifyDictionaryItemsInput{ - Service: testService.ID, - Dictionary: testDictionary.ID, + ServiceID: testService.ID, + DictionaryID: testDictionary.ID, Items: []*BatchDictionaryItem{ { Operation: UpsertBatchOperation, @@ -336,8 +336,8 @@ func TestClient_BatchModifyDictionaryItems_Upsert(t *testing.T) { var actualDictionaryItems []*DictionaryItem record(t, fixtureBase+"list_after_upsert", func(c *Client) { actualDictionaryItems, err = c.ListDictionaryItems(&ListDictionaryItemsInput{ - Service: testService.ID, - Dictionary: testDictionary.ID, + ServiceID: testService.ID, + DictionaryID: testDictionary.ID, }) }) if err != nil { diff --git a/fastly/dictionary_item_test.go b/fastly/dictionary_item_test.go index 751dfacd6..042538533 100644 --- a/fastly/dictionary_item_test.go +++ b/fastly/dictionary_item_test.go @@ -20,10 +20,10 @@ func TestClient_DictionaryItems(t *testing.T) { var createdDictionaryItem *DictionaryItem record(t, fixtureBase+"create", func(c *Client) { createdDictionaryItem, err = c.CreateDictionaryItem(&CreateDictionaryItemInput{ - Service: testService.ID, - Dictionary: testDictionary.ID, - ItemKey: "test-dictionary-item", - ItemValue: "value", + ServiceID: testService.ID, + DictionaryID: testDictionary.ID, + ItemKey: "test-dictionary-item", + ItemValue: "value", }) }) if err != nil { @@ -34,9 +34,9 @@ func TestClient_DictionaryItems(t *testing.T) { defer func() { record(t, fixtureBase+"cleanup", func(c *Client) { c.DeleteDictionaryItem(&DeleteDictionaryItemInput{ - Service: testService.ID, - Dictionary: testDictionary.ID, - ItemKey: "test-dictionary-item", + ServiceID: testService.ID, + DictionaryID: testDictionary.ID, + ItemKey: "test-dictionary-item", }) }) }() @@ -52,8 +52,8 @@ func TestClient_DictionaryItems(t *testing.T) { var dictionaryItems []*DictionaryItem record(t, fixtureBase+"list", func(c *Client) { dictionaryItems, err = c.ListDictionaryItems(&ListDictionaryItemsInput{ - Service: testService.ID, - Dictionary: testDictionary.ID, + ServiceID: testService.ID, + DictionaryID: testDictionary.ID, }) }) if err != nil { @@ -67,9 +67,9 @@ func TestClient_DictionaryItems(t *testing.T) { var retrievedDictionaryItem *DictionaryItem record(t, fixtureBase+"get", func(c *Client) { retrievedDictionaryItem, err = c.GetDictionaryItem(&GetDictionaryItemInput{ - Service: testService.ID, - Dictionary: testDictionary.ID, - ItemKey: "test-dictionary-item", + ServiceID: testService.ID, + DictionaryID: testDictionary.ID, + ItemKey: "test-dictionary-item", }) }) if err != nil { @@ -86,10 +86,10 @@ func TestClient_DictionaryItems(t *testing.T) { var updatedDictionaryItem *DictionaryItem record(t, fixtureBase+"update", func(c *Client) { updatedDictionaryItem, err = c.UpdateDictionaryItem(&UpdateDictionaryItemInput{ - Service: testService.ID, - Dictionary: testDictionary.ID, - ItemKey: "test-dictionary-item", - ItemValue: "new-value", + ServiceID: testService.ID, + DictionaryID: testDictionary.ID, + ItemKey: "test-dictionary-item", + ItemValue: "new-value", }) }) if err != nil { @@ -102,9 +102,9 @@ func TestClient_DictionaryItems(t *testing.T) { // Delete record(t, fixtureBase+"delete", func(c *Client) { err = c.DeleteDictionaryItem(&DeleteDictionaryItemInput{ - Service: testService.ID, - Dictionary: testDictionary.ID, - ItemKey: "test-dictionary-item", + ServiceID: testService.ID, + DictionaryID: testDictionary.ID, + ItemKey: "test-dictionary-item", }) }) if err != nil { @@ -115,15 +115,15 @@ func TestClient_DictionaryItems(t *testing.T) { func TestClient_ListDictionaryItems_validation(t *testing.T) { var err error _, err = testClient.ListDictionaryItems(&ListDictionaryItemsInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.ListDictionaryItems(&ListDictionaryItemsInput{ - Service: "foo", - Dictionary: "", + ServiceID: "foo", + DictionaryID: "", }) if err != ErrMissingDictionary { t.Errorf("bad error: %s", err) @@ -133,15 +133,15 @@ func TestClient_ListDictionaryItems_validation(t *testing.T) { func TestClient_CreateDictionaryItem_validation(t *testing.T) { var err error _, err = testClient.CreateDictionaryItem(&CreateDictionaryItemInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.CreateDictionaryItem(&CreateDictionaryItemInput{ - Service: "foo", - Dictionary: "", + ServiceID: "foo", + DictionaryID: "", }) if err != ErrMissingDictionary { t.Errorf("bad error: %s", err) @@ -151,24 +151,24 @@ func TestClient_CreateDictionaryItem_validation(t *testing.T) { func TestClient_GetDictionaryItem_validation(t *testing.T) { var err error _, err = testClient.GetDictionaryItem(&GetDictionaryItemInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.GetDictionaryItem(&GetDictionaryItemInput{ - Service: "foo", - Dictionary: "", + ServiceID: "foo", + DictionaryID: "", }) if err != ErrMissingDictionary { t.Errorf("bad error: %s", err) } _, err = testClient.GetDictionaryItem(&GetDictionaryItemInput{ - Service: "foo", - Dictionary: "test", - ItemKey: "", + ServiceID: "foo", + DictionaryID: "test", + ItemKey: "", }) if err != ErrMissingItemKey { t.Errorf("bad error: %s", err) @@ -178,24 +178,24 @@ func TestClient_GetDictionaryItem_validation(t *testing.T) { func TestClient_UpdateDictionaryItem_validation(t *testing.T) { var err error _, err = testClient.UpdateDictionaryItem(&UpdateDictionaryItemInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.UpdateDictionaryItem(&UpdateDictionaryItemInput{ - Service: "foo", - Dictionary: "", + ServiceID: "foo", + DictionaryID: "", }) if err != ErrMissingDictionary { t.Errorf("bad error: %s", err) } _, err = testClient.UpdateDictionaryItem(&UpdateDictionaryItemInput{ - Service: "foo", - Dictionary: "test", - ItemKey: "", + ServiceID: "foo", + DictionaryID: "test", + ItemKey: "", }) if err != ErrMissingItemKey { t.Errorf("bad error: %s", err) @@ -205,24 +205,24 @@ func TestClient_UpdateDictionaryItem_validation(t *testing.T) { func TestClient_DeleteDictionaryItem_validation(t *testing.T) { var err error err = testClient.DeleteDictionaryItem(&DeleteDictionaryItemInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } err = testClient.DeleteDictionaryItem(&DeleteDictionaryItemInput{ - Service: "foo", - Dictionary: "", + ServiceID: "foo", + DictionaryID: "", }) if err != ErrMissingDictionary { t.Errorf("bad error: %s", err) } err = testClient.DeleteDictionaryItem(&DeleteDictionaryItemInput{ - Service: "foo", - Dictionary: "test", - ItemKey: "", + ServiceID: "foo", + DictionaryID: "test", + ItemKey: "", }) if err != ErrMissingItemKey { t.Errorf("bad error: %s", err) @@ -232,14 +232,14 @@ func TestClient_DeleteDictionaryItem_validation(t *testing.T) { func TestClient_BatchModifyDictionaryItem_validation(t *testing.T) { var err error err = testClient.BatchModifyDictionaryItems(&BatchModifyDictionaryItemsInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } err = testClient.BatchModifyDictionaryItems(&BatchModifyDictionaryItemsInput{ - Service: "foo", - Dictionary: "", + ServiceID: "foo", + DictionaryID: "", }) if err != ErrMissingDictionary { t.Errorf("bad error: %s", err) @@ -247,9 +247,9 @@ func TestClient_BatchModifyDictionaryItem_validation(t *testing.T) { oversizedDictionaryItems := make([]*BatchDictionaryItem, BatchModifyMaximumOperations+1) err = testClient.BatchModifyDictionaryItems(&BatchModifyDictionaryItemsInput{ - Service: "foo", - Dictionary: "bar", - Items: oversizedDictionaryItems, + ServiceID: "foo", + DictionaryID: "bar", + Items: oversizedDictionaryItems, }) if err != ErrBatchUpdateMaximumOperationsExceeded { t.Errorf("bad error: %s", err) diff --git a/fastly/dictionary_test.go b/fastly/dictionary_test.go index 8de0cf638..31ce7a86d 100644 --- a/fastly/dictionary_test.go +++ b/fastly/dictionary_test.go @@ -14,9 +14,9 @@ func TestClient_Dictionaries(t *testing.T) { var d *Dictionary record(t, fixtureBase+"create", func(c *Client) { d, err = c.CreateDictionary(&CreateDictionaryInput{ - Service: testServiceID, - Version: testVersion.Number, - Name: "test_dictionary", + ServiceID: testServiceID, + ServiceVersion: testVersion.Number, + Name: "test_dictionary", }) }) if err != nil { @@ -27,15 +27,15 @@ func TestClient_Dictionaries(t *testing.T) { defer func() { record(t, fixtureBase+"cleanup", func(c *Client) { c.DeleteDictionary(&DeleteDictionaryInput{ - Service: testServiceID, - Version: testVersion.Number, - Name: "test_dictionary", + ServiceID: testServiceID, + ServiceVersion: testVersion.Number, + Name: "test_dictionary", }) c.DeleteDictionary(&DeleteDictionaryInput{ - Service: testServiceID, - Version: testVersion.Number, - Name: "new_test_dictionary", + ServiceID: testServiceID, + ServiceVersion: testVersion.Number, + Name: "new_test_dictionary", }) }) }() @@ -48,8 +48,8 @@ func TestClient_Dictionaries(t *testing.T) { var ds []*Dictionary record(t, fixtureBase+"list", func(c *Client) { ds, err = c.ListDictionaries(&ListDictionariesInput{ - Service: testServiceID, - Version: testVersion.Number, + ServiceID: testServiceID, + ServiceVersion: testVersion.Number, }) }) if err != nil { @@ -63,9 +63,9 @@ func TestClient_Dictionaries(t *testing.T) { var nd *Dictionary record(t, fixtureBase+"get", func(c *Client) { nd, err = c.GetDictionary(&GetDictionaryInput{ - Service: testServiceID, - Version: testVersion.Number, - Name: "test_dictionary", + ServiceID: testServiceID, + ServiceVersion: testVersion.Number, + Name: "test_dictionary", }) }) if err != nil { @@ -79,10 +79,10 @@ func TestClient_Dictionaries(t *testing.T) { var ud *Dictionary record(t, fixtureBase+"update", func(c *Client) { ud, err = c.UpdateDictionary(&UpdateDictionaryInput{ - Service: testServiceID, - Version: testVersion.Number, - Name: "test_dictionary", - NewName: "new_test_dictionary", + ServiceID: testServiceID, + ServiceVersion: testVersion.Number, + Name: "test_dictionary", + NewName: "new_test_dictionary", }) }) if err != nil { @@ -95,9 +95,9 @@ func TestClient_Dictionaries(t *testing.T) { // Delete record(t, fixtureBase+"delete", func(c *Client) { err = c.DeleteDictionary(&DeleteDictionaryInput{ - Service: testServiceID, - Version: testVersion.Number, - Name: "new_test_dictionary", + ServiceID: testServiceID, + ServiceVersion: testVersion.Number, + Name: "new_test_dictionary", }) }) if err != nil { @@ -108,17 +108,17 @@ func TestClient_Dictionaries(t *testing.T) { func TestClient_ListDictionaries_validation(t *testing.T) { var err error _, err = testClient.ListDictionaries(&ListDictionariesInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.ListDictionaries(&ListDictionariesInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } } @@ -126,17 +126,17 @@ func TestClient_ListDictionaries_validation(t *testing.T) { func TestClient_CreateDictionary_validation(t *testing.T) { var err error _, err = testClient.CreateDictionary(&CreateDictionaryInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.CreateDictionary(&CreateDictionaryInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } } @@ -144,24 +144,24 @@ func TestClient_CreateDictionary_validation(t *testing.T) { func TestClient_GetDictionary_validation(t *testing.T) { var err error _, err = testClient.GetDictionary(&GetDictionaryInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.GetDictionary(&GetDictionaryInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } _, err = testClient.GetDictionary(&GetDictionaryInput{ - Service: "foo", - Version: 1, - Name: "", + ServiceID: "foo", + ServiceVersion: 1, + Name: "", }) if err != ErrMissingName { t.Errorf("bad error: %s", err) @@ -171,24 +171,24 @@ func TestClient_GetDictionary_validation(t *testing.T) { func TestClient_UpdateDictionary_validation(t *testing.T) { var err error _, err = testClient.UpdateDictionary(&UpdateDictionaryInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.UpdateDictionary(&UpdateDictionaryInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } _, err = testClient.UpdateDictionary(&UpdateDictionaryInput{ - Service: "foo", - Version: 1, - Name: "", + ServiceID: "foo", + ServiceVersion: 1, + Name: "", }) if err != ErrMissingName { t.Errorf("bad error: %s", err) @@ -198,24 +198,24 @@ func TestClient_UpdateDictionary_validation(t *testing.T) { func TestClient_DeleteDictionary_validation(t *testing.T) { var err error err = testClient.DeleteDictionary(&DeleteDictionaryInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } err = testClient.DeleteDictionary(&DeleteDictionaryInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } err = testClient.DeleteDictionary(&DeleteDictionaryInput{ - Service: "foo", - Version: 1, - Name: "", + ServiceID: "foo", + ServiceVersion: 1, + Name: "", }) if err != ErrMissingName { t.Errorf("bad error: %s", err) diff --git a/fastly/diff.go b/fastly/diff.go index d11610f0d..9fb6bcb61 100644 --- a/fastly/diff.go +++ b/fastly/diff.go @@ -12,8 +12,8 @@ type Diff struct { // GetDiffInput is used as input to the GetDiff function. type GetDiffInput struct { - // Service is the ID of the service (required). - Service string + // ServiceID is the ID of the service (required). + ServiceID string // From is the version to diff from. This can either be a string indicating a // positive number (e.g. "1") or a negative number from "-1" down ("-1" is the @@ -31,8 +31,8 @@ type GetDiffInput struct { // GetDiff returns the diff of the given versions. func (c *Client) GetDiff(i *GetDiffInput) (*Diff, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } if i.From == 0 { @@ -43,7 +43,7 @@ func (c *Client) GetDiff(i *GetDiffInput) (*Diff, error) { return nil, ErrMissingTo } - path := fmt.Sprintf("service/%s/diff/from/%d/to/%d", i.Service, i.From, i.To) + path := fmt.Sprintf("service/%s/diff/from/%d/to/%d", i.ServiceID, i.From, i.To) resp, err := c.Get(path, nil) if err != nil { return nil, err diff --git a/fastly/diff_test.go b/fastly/diff_test.go index 8ace5c2b5..d7d1ddc17 100644 --- a/fastly/diff_test.go +++ b/fastly/diff_test.go @@ -20,9 +20,9 @@ func TestClient_Diff(t *testing.T) { var d *Diff record(t, "diff/get", func(c *Client) { d, err = c.GetDiff(&GetDiffInput{ - Service: testServiceID, - From: tv1.Number, - To: tv2.Number, + ServiceID: testServiceID, + From: tv1.Number, + To: tv2.Number, }) }) if err != nil { @@ -32,10 +32,10 @@ func TestClient_Diff(t *testing.T) { // Create a diff record(t, "diff/create_backend", func(c *Client) { _, err = c.CreateBackend(&CreateBackendInput{ - Service: testServiceID, - Version: tv2.Number, - Name: "test-backend", - Address: "integ-test.go-fastly.com", + ServiceID: testServiceID, + ServiceVersion: tv2.Number, + Name: "test-backend", + Address: "integ-test.go-fastly.com", }) }) if err != nil { @@ -46,9 +46,9 @@ func TestClient_Diff(t *testing.T) { defer func() { record(t, "diff/cleanup", func(c *Client) { c.DeleteBackend(&DeleteBackendInput{ - Service: testServiceID, - Version: tv2.Number, - Name: "test-backend", + ServiceID: testServiceID, + ServiceVersion: tv2.Number, + Name: "test-backend", }) }) }() @@ -56,9 +56,9 @@ func TestClient_Diff(t *testing.T) { // Diff should mot be empty record(t, "diff/get_again", func(c *Client) { d, err = c.GetDiff(&GetDiffInput{ - Service: testServiceID, - From: tv1.Number, - To: tv2.Number, + ServiceID: testServiceID, + From: tv1.Number, + To: tv2.Number, }) }) if err != nil { @@ -72,24 +72,24 @@ func TestClient_Diff(t *testing.T) { func TestClient_Diff_validation(t *testing.T) { var err error _, err = testClient.GetDiff(&GetDiffInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.GetDiff(&GetDiffInput{ - Service: "foo", - From: 0, + ServiceID: "foo", + From: 0, }) if err != ErrMissingFrom { t.Errorf("bad error: %s", err) } _, err = testClient.GetDiff(&GetDiffInput{ - Service: "foo", - From: 1, - To: 0, + ServiceID: "foo", + From: 1, + To: 0, }) if err != ErrMissingTo { t.Errorf("bad error: %s", err) diff --git a/fastly/digitalocean.go b/fastly/digitalocean.go index df61e97a1..6deceac5a 100644 --- a/fastly/digitalocean.go +++ b/fastly/digitalocean.go @@ -44,24 +44,24 @@ func (d digitaloceansByName) Less(i, j int) bool { // ListDigitalOceansInput is used as input to the ListDigitalOceans function. type ListDigitalOceansInput struct { - // Service is the ID of the service (required). - Service string + // ServiceID is the ID of the service (required). + ServiceID string - // Version is the specific configuration version (required). - Version int + // ServiceVersion is the specific configuration version (required). + ServiceVersion int } // ListDigitalOceans returns the list of DigitalOceans for the configuration version. func (c *Client) ListDigitalOceans(i *ListDigitalOceansInput) ([]*DigitalOcean, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/digitalocean", i.Service, i.Version) + path := fmt.Sprintf("/service/%s/version/%d/logging/digitalocean", i.ServiceID, i.ServiceVersion) resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -77,10 +77,11 @@ func (c *Client) ListDigitalOceans(i *ListDigitalOceansInput) ([]*DigitalOcean, // CreateDigitalOceanInput is used as input to the CreateDigitalOcean function. type CreateDigitalOceanInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int Name *string `form:"name,omitempty"` BucketName *string `form:"bucket_name,omitempty"` @@ -101,15 +102,15 @@ type CreateDigitalOceanInput struct { // CreateDigitalOcean creates a new Fastly DigitalOcean. func (c *Client) CreateDigitalOcean(i *CreateDigitalOceanInput) (*DigitalOcean, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/digitalocean", i.Service, i.Version) + path := fmt.Sprintf("/service/%s/version/%d/logging/digitalocean", i.ServiceID, i.ServiceVersion) resp, err := c.PostForm(path, i, nil) if err != nil { return nil, err @@ -124,10 +125,11 @@ func (c *Client) CreateDigitalOcean(i *CreateDigitalOceanInput) (*DigitalOcean, // GetDigitalOceanInput is used as input to the GetDigitalOcean function. type GetDigitalOceanInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int // Name is the name of the DigitalOcean to fetch. Name string @@ -135,19 +137,19 @@ type GetDigitalOceanInput struct { // GetDigitalOcean gets the DigitalOcean configuration with the given parameters. func (c *Client) GetDigitalOcean(i *GetDigitalOceanInput) (*DigitalOcean, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } if i.Name == "" { return nil, ErrMissingName } - path := fmt.Sprintf("/service/%s/version/%d/logging/digitalocean/%s", i.Service, i.Version, url.PathEscape(i.Name)) + path := fmt.Sprintf("/service/%s/version/%d/logging/digitalocean/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -162,10 +164,11 @@ func (c *Client) GetDigitalOcean(i *GetDigitalOceanInput) (*DigitalOcean, error) // UpdateDigitalOceanInput is used as input to the UpdateDigitalOcean function. type UpdateDigitalOceanInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int // Name is the name of the DigitalOcean to update. Name string @@ -189,19 +192,19 @@ type UpdateDigitalOceanInput struct { // UpdateDigitalOcean updates a specific DigitalOcean. func (c *Client) UpdateDigitalOcean(i *UpdateDigitalOceanInput) (*DigitalOcean, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } if i.Name == "" { return nil, ErrMissingName } - path := fmt.Sprintf("/service/%s/version/%d/logging/digitalocean/%s", i.Service, i.Version, url.PathEscape(i.Name)) + path := fmt.Sprintf("/service/%s/version/%d/logging/digitalocean/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) resp, err := c.PutForm(path, i, nil) if err != nil { return nil, err @@ -216,10 +219,11 @@ func (c *Client) UpdateDigitalOcean(i *UpdateDigitalOceanInput) (*DigitalOcean, // DeleteDigitalOceanInput is the input parameter to DeleteDigitalOcean. type DeleteDigitalOceanInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int // Name is the name of the DigitalOcean to delete (required). Name string @@ -227,19 +231,19 @@ type DeleteDigitalOceanInput struct { // DeleteDigitalOcean deletes the given DigitalOcean version. func (c *Client) DeleteDigitalOcean(i *DeleteDigitalOceanInput) error { - if i.Service == "" { - return ErrMissingService + if i.ServiceID == "" { + return ErrMissingServiceID } - if i.Version == 0 { - return ErrMissingVersion + if i.ServiceVersion == 0 { + return ErrMissingServiceVersion } if i.Name == "" { return ErrMissingName } - path := fmt.Sprintf("/service/%s/version/%d/logging/digitalocean/%s", i.Service, i.Version, url.PathEscape(i.Name)) + path := fmt.Sprintf("/service/%s/version/%d/logging/digitalocean/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) resp, err := c.Delete(path, nil) if err != nil { return err diff --git a/fastly/digitalocean_test.go b/fastly/digitalocean_test.go index ae5855fd5..9124148c0 100644 --- a/fastly/digitalocean_test.go +++ b/fastly/digitalocean_test.go @@ -15,8 +15,8 @@ func TestClient_DigitalOceans(t *testing.T) { var digitalocean *DigitalOcean record(t, "digitaloceans/create", func(c *Client) { digitalocean, err = c.CreateDigitalOcean(&CreateDigitalOceanInput{ - Service: testServiceID, - Version: tv.Number, + ServiceID: testServiceID, + ServiceVersion: tv.Number, Name: String("test-digitalocean"), BucketName: String("bucket-name"), Domain: String("fra1.digitaloceanspaces.com"), @@ -41,15 +41,15 @@ func TestClient_DigitalOceans(t *testing.T) { defer func() { record(t, "digitaloceans/cleanup", func(c *Client) { c.DeleteDigitalOcean(&DeleteDigitalOceanInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-digitalocean", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "test-digitalocean", }) c.DeleteDigitalOcean(&DeleteDigitalOceanInput{ - Service: testServiceID, - Version: tv.Number, - Name: "new-test-digitalocean", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "new-test-digitalocean", }) }) }() @@ -101,8 +101,8 @@ func TestClient_DigitalOceans(t *testing.T) { var digitaloceans []*DigitalOcean record(t, "digitaloceans/list", func(c *Client) { digitaloceans, err = c.ListDigitalOceans(&ListDigitalOceansInput{ - Service: testServiceID, - Version: tv.Number, + ServiceID: testServiceID, + ServiceVersion: tv.Number, }) }) if err != nil { @@ -116,9 +116,9 @@ func TestClient_DigitalOceans(t *testing.T) { var ndigitalocean *DigitalOcean record(t, "digitaloceans/get", func(c *Client) { ndigitalocean, err = c.GetDigitalOcean(&GetDigitalOceanInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-digitalocean", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "test-digitalocean", }) }) if err != nil { @@ -168,11 +168,11 @@ func TestClient_DigitalOceans(t *testing.T) { var udigitalocean *DigitalOcean record(t, "digitaloceans/update", func(c *Client) { udigitalocean, err = c.UpdateDigitalOcean(&UpdateDigitalOceanInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-digitalocean", - NewName: String("new-test-digitalocean"), - Domain: String("nyc3.digitaloceanspaces.com"), + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "test-digitalocean", + NewName: String("new-test-digitalocean"), + Domain: String("nyc3.digitaloceanspaces.com"), }) }) if err != nil { @@ -188,9 +188,9 @@ func TestClient_DigitalOceans(t *testing.T) { // Delete record(t, "digitaloceans/delete", func(c *Client) { err = c.DeleteDigitalOcean(&DeleteDigitalOceanInput{ - Service: testServiceID, - Version: tv.Number, - Name: "new-test-digitalocean", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "new-test-digitalocean", }) }) if err != nil { @@ -201,17 +201,17 @@ func TestClient_DigitalOceans(t *testing.T) { func TestClient_ListDigitalOceans_validation(t *testing.T) { var err error _, err = testClient.ListDigitalOceans(&ListDigitalOceansInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.ListDigitalOceans(&ListDigitalOceansInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } } @@ -219,17 +219,17 @@ func TestClient_ListDigitalOceans_validation(t *testing.T) { func TestClient_CreateDigitalOcean_validation(t *testing.T) { var err error _, err = testClient.CreateDigitalOcean(&CreateDigitalOceanInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.CreateDigitalOcean(&CreateDigitalOceanInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } } @@ -237,24 +237,24 @@ func TestClient_CreateDigitalOcean_validation(t *testing.T) { func TestClient_GetDigitalOcean_validation(t *testing.T) { var err error _, err = testClient.GetDigitalOcean(&GetDigitalOceanInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.GetDigitalOcean(&GetDigitalOceanInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } _, err = testClient.GetDigitalOcean(&GetDigitalOceanInput{ - Service: "foo", - Version: 1, - Name: "", + ServiceID: "foo", + ServiceVersion: 1, + Name: "", }) if err != ErrMissingName { t.Errorf("bad error: %s", err) @@ -264,24 +264,24 @@ func TestClient_GetDigitalOcean_validation(t *testing.T) { func TestClient_UpdateDigitalOcean_validation(t *testing.T) { var err error _, err = testClient.UpdateDigitalOcean(&UpdateDigitalOceanInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.UpdateDigitalOcean(&UpdateDigitalOceanInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } _, err = testClient.UpdateDigitalOcean(&UpdateDigitalOceanInput{ - Service: "foo", - Version: 1, - Name: "", + ServiceID: "foo", + ServiceVersion: 1, + Name: "", }) if err != ErrMissingName { t.Errorf("bad error: %s", err) @@ -291,24 +291,24 @@ func TestClient_UpdateDigitalOcean_validation(t *testing.T) { func TestClient_DeleteDigitalOcean_validation(t *testing.T) { var err error err = testClient.DeleteDigitalOcean(&DeleteDigitalOceanInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } err = testClient.DeleteDigitalOcean(&DeleteDigitalOceanInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } err = testClient.DeleteDigitalOcean(&DeleteDigitalOceanInput{ - Service: "foo", - Version: 1, - Name: "", + ServiceID: "foo", + ServiceVersion: 1, + Name: "", }) if err != ErrMissingName { t.Errorf("bad error: %s", err) diff --git a/fastly/director.go b/fastly/director.go index 7a1d44aff..ed12d0473 100644 --- a/fastly/director.go +++ b/fastly/director.go @@ -53,24 +53,24 @@ func (s directorsByName) Less(i, j int) bool { // ListDirectorsInput is used as input to the ListDirectors function. type ListDirectorsInput struct { - // Service is the ID of the service (required). - Service string + // ServiceID is the ID of the service (required). + ServiceID string - // Version is the specific configuration version (required). - Version int + // ServiceVersion is the specific configuration version (required). + ServiceVersion int } // ListDirectors returns the list of directors for the configuration version. func (c *Client) ListDirectors(i *ListDirectorsInput) ([]*Director, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/director", i.Service, i.Version) + path := fmt.Sprintf("/service/%s/version/%d/director", i.ServiceID, i.ServiceVersion) resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -86,10 +86,11 @@ func (c *Client) ListDirectors(i *ListDirectorsInput) ([]*Director, error) { // CreateDirectorInput is used as input to the CreateDirector function. type CreateDirectorInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int Name string `form:"name,omitempty"` Comment string `form:"comment,omitempty"` @@ -102,15 +103,15 @@ type CreateDirectorInput struct { // CreateDirector creates a new Fastly director. func (c *Client) CreateDirector(i *CreateDirectorInput) (*Director, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/director", i.Service, i.Version) + path := fmt.Sprintf("/service/%s/version/%d/director", i.ServiceID, i.ServiceVersion) resp, err := c.PostForm(path, i, nil) if err != nil { return nil, err @@ -125,10 +126,11 @@ func (c *Client) CreateDirector(i *CreateDirectorInput) (*Director, error) { // GetDirectorInput is used as input to the GetDirector function. type GetDirectorInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int // Name is the name of the director to fetch. Name string @@ -136,19 +138,19 @@ type GetDirectorInput struct { // GetDirector gets the director configuration with the given parameters. func (c *Client) GetDirector(i *GetDirectorInput) (*Director, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } if i.Name == "" { return nil, ErrMissingName } - path := fmt.Sprintf("/service/%s/version/%d/director/%s", i.Service, i.Version, url.PathEscape(i.Name)) + path := fmt.Sprintf("/service/%s/version/%d/director/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -163,10 +165,11 @@ func (c *Client) GetDirector(i *GetDirectorInput) (*Director, error) { // UpdateDirectorInput is used as input to the UpdateDirector function. type UpdateDirectorInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int // Name is the name of the director to update. Name string @@ -182,19 +185,19 @@ type UpdateDirectorInput struct { // UpdateDirector updates a specific director. func (c *Client) UpdateDirector(i *UpdateDirectorInput) (*Director, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } if i.Name == "" { return nil, ErrMissingName } - path := fmt.Sprintf("/service/%s/version/%d/director/%s", i.Service, i.Version, url.PathEscape(i.Name)) + path := fmt.Sprintf("/service/%s/version/%d/director/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) resp, err := c.PutForm(path, i, nil) if err != nil { return nil, err @@ -209,10 +212,11 @@ func (c *Client) UpdateDirector(i *UpdateDirectorInput) (*Director, error) { // DeleteDirectorInput is the input parameter to DeleteDirector. type DeleteDirectorInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int // Name is the name of the director to delete (required). Name string @@ -220,19 +224,19 @@ type DeleteDirectorInput struct { // DeleteDirector deletes the given director version. func (c *Client) DeleteDirector(i *DeleteDirectorInput) error { - if i.Service == "" { - return ErrMissingService + if i.ServiceID == "" { + return ErrMissingServiceID } - if i.Version == 0 { - return ErrMissingVersion + if i.ServiceVersion == 0 { + return ErrMissingServiceVersion } if i.Name == "" { return ErrMissingName } - path := fmt.Sprintf("/service/%s/version/%d/director/%s", i.Service, i.Version, url.PathEscape(i.Name)) + path := fmt.Sprintf("/service/%s/version/%d/director/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) resp, err := c.Delete(path, nil) if err != nil { return err diff --git a/fastly/director_backend.go b/fastly/director_backend.go index 38898dedb..1bcc57a34 100644 --- a/fastly/director_backend.go +++ b/fastly/director_backend.go @@ -22,10 +22,11 @@ type DirectorBackend struct { // CreateDirectorBackendInput is used as input to the CreateDirectorBackend // function. type CreateDirectorBackendInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int // Director is the name of the director (required). Director string @@ -36,12 +37,12 @@ type CreateDirectorBackendInput struct { // CreateDirectorBackend creates a new Fastly backend. func (c *Client) CreateDirectorBackend(i *CreateDirectorBackendInput) (*DirectorBackend, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } if i.Director == "" { @@ -53,7 +54,7 @@ func (c *Client) CreateDirectorBackend(i *CreateDirectorBackendInput) (*Director } path := fmt.Sprintf("/service/%s/version/%d/director/%s/backend/%s", - i.Service, i.Version, url.PathEscape(i.Director), url.PathEscape(i.Backend)) + i.ServiceID, i.ServiceVersion, url.PathEscape(i.Director), url.PathEscape(i.Backend)) resp, err := c.PostForm(path, i, nil) if err != nil { return nil, err @@ -68,10 +69,11 @@ func (c *Client) CreateDirectorBackend(i *CreateDirectorBackendInput) (*Director // GetDirectorBackendInput is used as input to the GetDirectorBackend function. type GetDirectorBackendInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int // Director is the name of the director (required). Director string @@ -82,12 +84,12 @@ type GetDirectorBackendInput struct { // GetDirectorBackend gets the backend configuration with the given parameters. func (c *Client) GetDirectorBackend(i *GetDirectorBackendInput) (*DirectorBackend, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } if i.Director == "" { @@ -99,7 +101,7 @@ func (c *Client) GetDirectorBackend(i *GetDirectorBackendInput) (*DirectorBacken } path := fmt.Sprintf("/service/%s/version/%d/director/%s/backend/%s", - i.Service, i.Version, url.PathEscape(i.Director), url.PathEscape(i.Backend)) + i.ServiceID, i.ServiceVersion, url.PathEscape(i.Director), url.PathEscape(i.Backend)) resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -114,10 +116,11 @@ func (c *Client) GetDirectorBackend(i *GetDirectorBackendInput) (*DirectorBacken // DeleteDirectorBackendInput is the input parameter to DeleteDirectorBackend. type DeleteDirectorBackendInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int // Director is the name of the director (required). Director string @@ -128,12 +131,12 @@ type DeleteDirectorBackendInput struct { // DeleteDirectorBackend deletes the given backend version. func (c *Client) DeleteDirectorBackend(i *DeleteDirectorBackendInput) error { - if i.Service == "" { - return ErrMissingService + if i.ServiceID == "" { + return ErrMissingServiceID } - if i.Version == 0 { - return ErrMissingVersion + if i.ServiceVersion == 0 { + return ErrMissingServiceVersion } if i.Director == "" { @@ -145,7 +148,7 @@ func (c *Client) DeleteDirectorBackend(i *DeleteDirectorBackendInput) error { } path := fmt.Sprintf("/service/%s/version/%d/director/%s/backend/%s", - i.Service, i.Version, url.PathEscape(i.Director), url.PathEscape(i.Backend)) + i.ServiceID, i.ServiceVersion, url.PathEscape(i.Director), url.PathEscape(i.Backend)) resp, err := c.Delete(path, nil) if err != nil { return err diff --git a/fastly/director_backend_test.go b/fastly/director_backend_test.go index 28662220c..886cbc239 100644 --- a/fastly/director_backend_test.go +++ b/fastly/director_backend_test.go @@ -15,10 +15,10 @@ func TestClient_DirectorBackends(t *testing.T) { var b *DirectorBackend record(t, "director_backends/create", func(c *Client) { b, err = c.CreateDirectorBackend(&CreateDirectorBackendInput{ - Service: testServiceID, - Version: tv.Number, - Director: "director", - Backend: "backend", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Director: "director", + Backend: "backend", }) }) if err != nil { @@ -29,10 +29,10 @@ func TestClient_DirectorBackends(t *testing.T) { defer func() { record(t, "director_backends/cleanup", func(c *Client) { c.DeleteDirectorBackend(&DeleteDirectorBackendInput{ - Service: testServiceID, - Version: tv.Number, - Director: "director", - Backend: "backend", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Director: "director", + Backend: "backend", }) }) }() @@ -48,10 +48,10 @@ func TestClient_DirectorBackends(t *testing.T) { var nb *DirectorBackend record(t, "director_backends/get", func(c *Client) { nb, err = c.GetDirectorBackend(&GetDirectorBackendInput{ - Service: testServiceID, - Version: tv.Number, - Director: "director", - Backend: "backend", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Director: "director", + Backend: "backend", }) }) if err != nil { @@ -68,10 +68,10 @@ func TestClient_DirectorBackends(t *testing.T) { // Delete record(t, "director_backends/delete", func(c *Client) { err = c.DeleteDirectorBackend(&DeleteDirectorBackendInput{ - Service: testServiceID, - Version: tv.Number, - Director: "director", - Backend: "backend", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Director: "director", + Backend: "backend", }) }) if err != nil { @@ -82,17 +82,17 @@ func TestClient_DirectorBackends(t *testing.T) { func TestClient_CreateDirectorBackend_validation(t *testing.T) { var err error _, err = testClient.CreateDirectorBackend(&CreateDirectorBackendInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.CreateDirectorBackend(&CreateDirectorBackendInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } } @@ -100,34 +100,34 @@ func TestClient_CreateDirectorBackend_validation(t *testing.T) { func TestClient_GetDirectorBackend_validation(t *testing.T) { var err error _, err = testClient.GetDirectorBackend(&GetDirectorBackendInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.GetDirectorBackend(&GetDirectorBackendInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } _, err = testClient.GetDirectorBackend(&GetDirectorBackendInput{ - Service: "foo", - Version: 1, - Director: "", + ServiceID: "foo", + ServiceVersion: 1, + Director: "", }) if err != ErrMissingDirector { t.Errorf("bad error: %s", err) } _, err = testClient.GetDirectorBackend(&GetDirectorBackendInput{ - Service: "foo", - Version: 1, - Director: "director", - Backend: "", + ServiceID: "foo", + ServiceVersion: 1, + Director: "director", + Backend: "", }) if err != ErrMissingBackend { t.Errorf("bad error: %s", err) @@ -137,34 +137,34 @@ func TestClient_GetDirectorBackend_validation(t *testing.T) { func TestClient_DeleteDirectorBackend_validation(t *testing.T) { var err error err = testClient.DeleteDirectorBackend(&DeleteDirectorBackendInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } err = testClient.DeleteDirectorBackend(&DeleteDirectorBackendInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } err = testClient.DeleteDirectorBackend(&DeleteDirectorBackendInput{ - Service: "foo", - Version: 1, - Director: "", + ServiceID: "foo", + ServiceVersion: 1, + Director: "", }) if err != ErrMissingDirector { t.Errorf("bad error: %s", err) } err = testClient.DeleteDirectorBackend(&DeleteDirectorBackendInput{ - Service: "foo", - Version: 1, - Director: "director", - Backend: "", + ServiceID: "foo", + ServiceVersion: 1, + Director: "director", + Backend: "", }) if err != ErrMissingBackend { t.Errorf("bad error: %s", err) diff --git a/fastly/director_test.go b/fastly/director_test.go index 36e4f42b6..8238a0f15 100644 --- a/fastly/director_test.go +++ b/fastly/director_test.go @@ -15,12 +15,12 @@ func TestClient_Directors(t *testing.T) { var b *Director record(t, "directors/create", func(c *Client) { b, err = c.CreateDirector(&CreateDirectorInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-director", - Quorum: 50, - Type: DirectorTypeRandom, - Retries: 5, + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "test-director", + Quorum: 50, + Type: DirectorTypeRandom, + Retries: 5, }) }) if err != nil { @@ -31,15 +31,15 @@ func TestClient_Directors(t *testing.T) { defer func() { record(t, "directors/cleanup", func(c *Client) { c.DeleteDirector(&DeleteDirectorInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-director", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "test-director", }) c.DeleteDirector(&DeleteDirectorInput{ - Service: testServiceID, - Version: tv.Number, - Name: "new-test-director", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "new-test-director", }) }) }() @@ -61,8 +61,8 @@ func TestClient_Directors(t *testing.T) { var bs []*Director record(t, "directors/list", func(c *Client) { bs, err = c.ListDirectors(&ListDirectorsInput{ - Service: testServiceID, - Version: tv.Number, + ServiceID: testServiceID, + ServiceVersion: tv.Number, }) }) if err != nil { @@ -76,9 +76,9 @@ func TestClient_Directors(t *testing.T) { var nb *Director record(t, "directors/get", func(c *Client) { nb, err = c.GetDirector(&GetDirectorInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-director", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "test-director", }) }) if err != nil { @@ -101,11 +101,11 @@ func TestClient_Directors(t *testing.T) { var ub *Director record(t, "directors/update", func(c *Client) { ub, err = c.UpdateDirector(&UpdateDirectorInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-director", - NewName: "new-test-director", - Quorum: 100, + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "test-director", + NewName: "new-test-director", + Quorum: 100, }) }) if err != nil { @@ -118,9 +118,9 @@ func TestClient_Directors(t *testing.T) { // Delete record(t, "directors/delete", func(c *Client) { err = c.DeleteDirector(&DeleteDirectorInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-director", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "test-director", }) }) if err != nil { @@ -131,17 +131,17 @@ func TestClient_Directors(t *testing.T) { func TestClient_ListDirectors_validation(t *testing.T) { var err error _, err = testClient.ListDirectors(&ListDirectorsInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.ListDirectors(&ListDirectorsInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } } @@ -149,17 +149,17 @@ func TestClient_ListDirectors_validation(t *testing.T) { func TestClient_CreateDirector_validation(t *testing.T) { var err error _, err = testClient.CreateDirector(&CreateDirectorInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.CreateDirector(&CreateDirectorInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } } @@ -167,24 +167,24 @@ func TestClient_CreateDirector_validation(t *testing.T) { func TestClient_GetDirector_validation(t *testing.T) { var err error _, err = testClient.GetDirector(&GetDirectorInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.GetDirector(&GetDirectorInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } _, err = testClient.GetDirector(&GetDirectorInput{ - Service: "foo", - Version: 1, - Name: "", + ServiceID: "foo", + ServiceVersion: 1, + Name: "", }) if err != ErrMissingName { t.Errorf("bad error: %s", err) @@ -194,24 +194,24 @@ func TestClient_GetDirector_validation(t *testing.T) { func TestClient_UpdateDirector_validation(t *testing.T) { var err error _, err = testClient.UpdateDirector(&UpdateDirectorInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.UpdateDirector(&UpdateDirectorInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } _, err = testClient.UpdateDirector(&UpdateDirectorInput{ - Service: "foo", - Version: 1, - Name: "", + ServiceID: "foo", + ServiceVersion: 1, + Name: "", }) if err != ErrMissingName { t.Errorf("bad error: %s", err) @@ -221,24 +221,24 @@ func TestClient_UpdateDirector_validation(t *testing.T) { func TestClient_DeleteDirector_validation(t *testing.T) { var err error err = testClient.DeleteDirector(&DeleteDirectorInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } err = testClient.DeleteDirector(&DeleteDirectorInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } err = testClient.DeleteDirector(&DeleteDirectorInput{ - Service: "foo", - Version: 1, - Name: "", + ServiceID: "foo", + ServiceVersion: 1, + Name: "", }) if err != ErrMissingName { t.Errorf("bad error: %s", err) diff --git a/fastly/domain.go b/fastly/domain.go index 02aef2133..76a953da3 100644 --- a/fastly/domain.go +++ b/fastly/domain.go @@ -31,23 +31,24 @@ func (s domainsByName) Less(i, j int) bool { // ListDomainsInput is used as input to the ListDomains function. type ListDomainsInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int } // ListDomains returns the list of domains for this Service. func (c *Client) ListDomains(i *ListDomainsInput) ([]*Domain, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/domain", i.Service, i.Version) + path := fmt.Sprintf("/service/%s/version/%d/domain", i.ServiceID, i.ServiceVersion) resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -63,10 +64,11 @@ func (c *Client) ListDomains(i *ListDomainsInput) ([]*Domain, error) { // CreateDomainInput is used as input to the CreateDomain function. type CreateDomainInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int // Name is the name of the domain that the service will respond to (required). Name string `form:"name"` @@ -77,15 +79,15 @@ type CreateDomainInput struct { // CreateDomain creates a new domain with the given information. func (c *Client) CreateDomain(i *CreateDomainInput) (*Domain, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/domain", i.Service, i.Version) + path := fmt.Sprintf("/service/%s/version/%d/domain", i.ServiceID, i.ServiceVersion) resp, err := c.PostForm(path, i, nil) if err != nil { return nil, err @@ -100,10 +102,11 @@ func (c *Client) CreateDomain(i *CreateDomainInput) (*Domain, error) { // GetDomainInput is used as input to the GetDomain function. type GetDomainInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int // Name is the name of the domain to fetch. Name string `form:"name"` @@ -111,19 +114,19 @@ type GetDomainInput struct { // GetDomain retrieves information about the given domain name. func (c *Client) GetDomain(i *GetDomainInput) (*Domain, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } if i.Name == "" { return nil, ErrMissingName } - path := fmt.Sprintf("/service/%s/version/%d/domain/%s", i.Service, i.Version, url.PathEscape(i.Name)) + path := fmt.Sprintf("/service/%s/version/%d/domain/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -138,10 +141,11 @@ func (c *Client) GetDomain(i *GetDomainInput) (*Domain, error) { // UpdateDomainInput is used as input to the UpdateDomain function. type UpdateDomainInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int // Name is the name of the domain that the service will respond to (required). Name string @@ -156,19 +160,19 @@ type UpdateDomainInput struct { // UpdateDomain updates a single domain for the current service. The only allowed // parameters are `Name` and `Comment`. func (c *Client) UpdateDomain(i *UpdateDomainInput) (*Domain, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } if i.Name == "" { return nil, ErrMissingName } - path := fmt.Sprintf("/service/%s/version/%d/domain/%s", i.Service, i.Version, url.PathEscape(i.Name)) + path := fmt.Sprintf("/service/%s/version/%d/domain/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) resp, err := c.PutForm(path, i, nil) if err != nil { return nil, err @@ -183,10 +187,11 @@ func (c *Client) UpdateDomain(i *UpdateDomainInput) (*Domain, error) { // DeleteDomainInput is used as input to the DeleteDomain function. type DeleteDomainInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int // Name is the name of the domain that the service will respond to (required). Name string `form:"name"` @@ -194,19 +199,19 @@ type DeleteDomainInput struct { // DeleteDomain removes a single domain by the given name. func (c *Client) DeleteDomain(i *DeleteDomainInput) error { - if i.Service == "" { - return ErrMissingService + if i.ServiceID == "" { + return ErrMissingServiceID } - if i.Version == 0 { - return ErrMissingVersion + if i.ServiceVersion == 0 { + return ErrMissingServiceVersion } if i.Name == "" { return ErrMissingName } - path := fmt.Sprintf("/service/%s/version/%d/domain/%s", i.Service, i.Version, url.PathEscape(i.Name)) + path := fmt.Sprintf("/service/%s/version/%d/domain/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) _, err := c.Delete(path, nil) if err != nil { return err diff --git a/fastly/domain_test.go b/fastly/domain_test.go index 2c3980899..5d25a38f1 100644 --- a/fastly/domain_test.go +++ b/fastly/domain_test.go @@ -15,10 +15,10 @@ func TestClient_Domains(t *testing.T) { var d *Domain record(t, "domains/create", func(c *Client) { d, err = c.CreateDomain(&CreateDomainInput{ - Service: testServiceID, - Version: tv.Number, - Name: "integ-test.go-fastly.com", - Comment: "comment", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "integ-test.go-fastly.com", + Comment: "comment", }) }) if err != nil { @@ -29,15 +29,15 @@ func TestClient_Domains(t *testing.T) { defer func() { record(t, "domains/cleanup", func(c *Client) { c.DeleteDomain(&DeleteDomainInput{ - Service: testServiceID, - Version: tv.Number, - Name: "integ-test.go-fastly.com", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "integ-test.go-fastly.com", }) c.DeleteDomain(&DeleteDomainInput{ - Service: testServiceID, - Version: tv.Number, - Name: "new-integ-test.go-fastly.com", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "new-integ-test.go-fastly.com", }) }) }() @@ -53,8 +53,8 @@ func TestClient_Domains(t *testing.T) { var ds []*Domain record(t, "domains/list", func(c *Client) { ds, err = c.ListDomains(&ListDomainsInput{ - Service: testServiceID, - Version: tv.Number, + ServiceID: testServiceID, + ServiceVersion: tv.Number, }) }) if err != nil { @@ -68,9 +68,9 @@ func TestClient_Domains(t *testing.T) { var nd *Domain record(t, "domains/get", func(c *Client) { nd, err = c.GetDomain(&GetDomainInput{ - Service: testServiceID, - Version: tv.Number, - Name: "integ-test.go-fastly.com", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "integ-test.go-fastly.com", }) }) if err != nil { @@ -87,10 +87,10 @@ func TestClient_Domains(t *testing.T) { var ud *Domain record(t, "domains/update", func(c *Client) { ud, err = c.UpdateDomain(&UpdateDomainInput{ - Service: testServiceID, - Version: tv.Number, - Name: "integ-test.go-fastly.com", - NewName: "new-integ-test.go-fastly.com", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "integ-test.go-fastly.com", + NewName: "new-integ-test.go-fastly.com", }) }) if err != nil { @@ -103,9 +103,9 @@ func TestClient_Domains(t *testing.T) { // Delete record(t, "domains/delete", func(c *Client) { err = c.DeleteDomain(&DeleteDomainInput{ - Service: testServiceID, - Version: tv.Number, - Name: "new-integ-test.go-fastly.com", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "new-integ-test.go-fastly.com", }) }) if err != nil { @@ -116,17 +116,17 @@ func TestClient_Domains(t *testing.T) { func TestClient_ListDomains_validation(t *testing.T) { var err error _, err = testClient.ListDomains(&ListDomainsInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.ListDomains(&ListDomainsInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } } @@ -134,17 +134,17 @@ func TestClient_ListDomains_validation(t *testing.T) { func TestClient_CreateDomain_validation(t *testing.T) { var err error _, err = testClient.CreateDomain(&CreateDomainInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.CreateDomain(&CreateDomainInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } } @@ -152,24 +152,24 @@ func TestClient_CreateDomain_validation(t *testing.T) { func TestClient_GetDomain_validation(t *testing.T) { var err error _, err = testClient.GetDomain(&GetDomainInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.GetDomain(&GetDomainInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } _, err = testClient.GetDomain(&GetDomainInput{ - Service: "foo", - Version: 1, - Name: "", + ServiceID: "foo", + ServiceVersion: 1, + Name: "", }) if err != ErrMissingName { t.Errorf("bad error: %s", err) @@ -179,24 +179,24 @@ func TestClient_GetDomain_validation(t *testing.T) { func TestClient_UpdateDomain_validation(t *testing.T) { var err error _, err = testClient.UpdateDomain(&UpdateDomainInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.UpdateDomain(&UpdateDomainInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } _, err = testClient.UpdateDomain(&UpdateDomainInput{ - Service: "foo", - Version: 1, - Name: "", + ServiceID: "foo", + ServiceVersion: 1, + Name: "", }) if err != ErrMissingName { t.Errorf("bad error: %s", err) @@ -206,24 +206,24 @@ func TestClient_UpdateDomain_validation(t *testing.T) { func TestClient_DeleteDomain_validation(t *testing.T) { var err error err = testClient.DeleteDomain(&DeleteDomainInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } err = testClient.DeleteDomain(&DeleteDomainInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } err = testClient.DeleteDomain(&DeleteDomainInput{ - Service: "foo", - Version: 1, - Name: "", + ServiceID: "foo", + ServiceVersion: 1, + Name: "", }) if err != ErrMissingName { t.Errorf("bad error: %s", err) diff --git a/fastly/elasticsearch.go b/fastly/elasticsearch.go index 6654925a3..031caf156 100644 --- a/fastly/elasticsearch.go +++ b/fastly/elasticsearch.go @@ -45,24 +45,24 @@ func (s elasticsearchByName) Less(i, j int) bool { // ListElasticsearchInput is used as input to the ListElasticsearch function. type ListElasticsearchInput struct { - // Service is the ID of the service (required). - Service string + // ServiceID is the ID of the service (required). + ServiceID string - // Version is the specific configuration version (required). - Version int + // ServiceVersion is the specific configuration version (required). + ServiceVersion int } // ListElasticsearch returns the list of Elasticsearch logs for the configuration version. func (c *Client) ListElasticsearch(i *ListElasticsearchInput) ([]*Elasticsearch, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/elasticsearch", i.Service, i.Version) + path := fmt.Sprintf("/service/%s/version/%d/logging/elasticsearch", i.ServiceID, i.ServiceVersion) resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -78,10 +78,11 @@ func (c *Client) ListElasticsearch(i *ListElasticsearchInput) ([]*Elasticsearch, // CreateElasticsearchInput is used as input to the CreateElasticsearch function. type CreateElasticsearchInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int Name *string `form:"name,omitempty"` ResponseCondition *string `form:"response_condition,omitempty"` @@ -103,15 +104,15 @@ type CreateElasticsearchInput struct { // CreateElasticsearch creates a new Fastly Elasticsearch logging endpoint. func (c *Client) CreateElasticsearch(i *CreateElasticsearchInput) (*Elasticsearch, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/elasticsearch", i.Service, i.Version) + path := fmt.Sprintf("/service/%s/version/%d/logging/elasticsearch", i.ServiceID, i.ServiceVersion) resp, err := c.PostForm(path, i, nil) if err != nil { return nil, err @@ -126,29 +127,30 @@ func (c *Client) CreateElasticsearch(i *CreateElasticsearchInput) (*Elasticsearc // GetElasticsearchInput is used as input to the GetElasticsearch function. type GetElasticsearchInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int // Name is the name of the Elasticsearch endpoint to fetch. Name string } func (c *Client) GetElasticsearch(i *GetElasticsearchInput) (*Elasticsearch, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } if i.Name == "" { return nil, ErrMissingName } - path := fmt.Sprintf("/service/%s/version/%d/logging/elasticsearch/%s", i.Service, i.Version, url.PathEscape(i.Name)) + path := fmt.Sprintf("/service/%s/version/%d/logging/elasticsearch/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -163,10 +165,11 @@ func (c *Client) GetElasticsearch(i *GetElasticsearchInput) (*Elasticsearch, err } type UpdateElasticsearchInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int // Name is the name of the Elasticsearch endpoint to fetch. Name string @@ -190,19 +193,19 @@ type UpdateElasticsearchInput struct { } func (c *Client) UpdateElasticsearch(i *UpdateElasticsearchInput) (*Elasticsearch, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } if i.Name == "" { return nil, ErrMissingName } - path := fmt.Sprintf("/service/%s/version/%d/logging/elasticsearch/%s", i.Service, i.Version, url.PathEscape(i.Name)) + path := fmt.Sprintf("/service/%s/version/%d/logging/elasticsearch/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) resp, err := c.PutForm(path, i, nil) if err != nil { return nil, err @@ -216,29 +219,30 @@ func (c *Client) UpdateElasticsearch(i *UpdateElasticsearchInput) (*Elasticsearc } type DeleteElasticsearchInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int // Name is the name of the Elasticsearch endpoint to fetch. Name string } func (c *Client) DeleteElasticsearch(i *DeleteElasticsearchInput) error { - if i.Service == "" { - return ErrMissingService + if i.ServiceID == "" { + return ErrMissingServiceID } - if i.Version == 0 { - return ErrMissingVersion + if i.ServiceVersion == 0 { + return ErrMissingServiceVersion } if i.Name == "" { return ErrMissingName } - path := fmt.Sprintf("/service/%s/version/%d/logging/elasticsearch/%s", i.Service, i.Version, url.PathEscape(i.Name)) + path := fmt.Sprintf("/service/%s/version/%d/logging/elasticsearch/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) resp, err := c.Delete(path, nil) if err != nil { return err diff --git a/fastly/elasticsearch_test.go b/fastly/elasticsearch_test.go index ae2bd269e..222d7fe36 100644 --- a/fastly/elasticsearch_test.go +++ b/fastly/elasticsearch_test.go @@ -38,8 +38,8 @@ Wm7DCfrPNGVwFWUQOmsPue9rZBgO var es *Elasticsearch record(t, "elasticsearch/create", func(c *Client) { es, err = c.CreateElasticsearch(&CreateElasticsearchInput{ - Service: testServiceID, - Version: tv.Number, + ServiceID: testServiceID, + ServiceVersion: tv.Number, Name: String("test-elasticsearch"), Format: String("format"), Index: String("#{%F}"), @@ -65,16 +65,16 @@ Wm7DCfrPNGVwFWUQOmsPue9rZBgO defer func() { record(t, "elasticsearch/cleanup", func(c *Client) { c.DeleteElasticsearch(&DeleteElasticsearchInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-elasticsearch", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "test-elasticsearch", }) // ensure that renamed endpoint created in Update test is deleted c.DeleteElasticsearch(&DeleteElasticsearchInput{ - Service: testServiceID, - Version: tv.Number, - Name: "new-test-elasticsearch", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "new-test-elasticsearch", }) }) }() @@ -129,8 +129,8 @@ Wm7DCfrPNGVwFWUQOmsPue9rZBgO var ess []*Elasticsearch record(t, "elasticsearch/list", func(c *Client) { ess, err = c.ListElasticsearch(&ListElasticsearchInput{ - Service: testServiceID, - Version: tv.Number, + ServiceID: testServiceID, + ServiceVersion: tv.Number, }) }) if err != nil { @@ -144,9 +144,9 @@ Wm7DCfrPNGVwFWUQOmsPue9rZBgO var nes *Elasticsearch record(t, "elasticsearch/get", func(c *Client) { nes, err = c.GetElasticsearch(&GetElasticsearchInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-elasticsearch", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "test-elasticsearch", }) }) if err != nil { @@ -202,11 +202,11 @@ Wm7DCfrPNGVwFWUQOmsPue9rZBgO var ues *Elasticsearch record(t, "elasticsearch/update", func(c *Client) { ues, err = c.UpdateElasticsearch(&UpdateElasticsearchInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-elasticsearch", - NewName: String("new-test-elasticsearch"), - Pipeline: String("my_new_pipeline_id"), + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "test-elasticsearch", + NewName: String("new-test-elasticsearch"), + Pipeline: String("my_new_pipeline_id"), }) }) if err != nil { @@ -222,9 +222,9 @@ Wm7DCfrPNGVwFWUQOmsPue9rZBgO // Delete record(t, "elasticsearch/delete", func(c *Client) { err = c.DeleteElasticsearch(&DeleteElasticsearchInput{ - Service: testServiceID, - Version: tv.Number, - Name: "new-test-elasticsearch", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "new-test-elasticsearch", }) }) if err != nil { @@ -235,17 +235,17 @@ Wm7DCfrPNGVwFWUQOmsPue9rZBgO func TestClient_ListElasticsearch_validation(t *testing.T) { var err error _, err = testClient.ListElasticsearch(&ListElasticsearchInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.ListElasticsearch(&ListElasticsearchInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } } @@ -253,17 +253,17 @@ func TestClient_ListElasticsearch_validation(t *testing.T) { func TestClient_CreateElasticsearch_validation(t *testing.T) { var err error _, err = testClient.CreateElasticsearch(&CreateElasticsearchInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.CreateElasticsearch(&CreateElasticsearchInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } } @@ -271,24 +271,24 @@ func TestClient_CreateElasticsearch_validation(t *testing.T) { func TestClient_GetElasticsearch_validation(t *testing.T) { var err error _, err = testClient.GetElasticsearch(&GetElasticsearchInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.GetElasticsearch(&GetElasticsearchInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } _, err = testClient.GetElasticsearch(&GetElasticsearchInput{ - Service: "foo", - Version: 1, - Name: "", + ServiceID: "foo", + ServiceVersion: 1, + Name: "", }) if err != ErrMissingName { t.Errorf("bad error: %s", err) @@ -298,24 +298,24 @@ func TestClient_GetElasticsearch_validation(t *testing.T) { func TestClient_UpdateElasticsearch_validation(t *testing.T) { var err error _, err = testClient.UpdateElasticsearch(&UpdateElasticsearchInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.UpdateElasticsearch(&UpdateElasticsearchInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } _, err = testClient.UpdateElasticsearch(&UpdateElasticsearchInput{ - Service: "foo", - Version: 1, - Name: "", + ServiceID: "foo", + ServiceVersion: 1, + Name: "", }) if err != ErrMissingName { t.Errorf("bad error: %s", err) @@ -325,24 +325,24 @@ func TestClient_UpdateElasticsearch_validation(t *testing.T) { func TestClient_DeleteElasticsearch_validation(t *testing.T) { var err error err = testClient.DeleteElasticsearch(&DeleteElasticsearchInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } err = testClient.DeleteElasticsearch(&DeleteElasticsearchInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } err = testClient.DeleteElasticsearch(&DeleteElasticsearchInput{ - Service: "foo", - Version: 1, - Name: "", + ServiceID: "foo", + ServiceVersion: 1, + Name: "", }) if err != ErrMissingName { t.Errorf("bad error: %s", err) diff --git a/fastly/errors.go b/fastly/errors.go index 1bad4e731..cb9316291 100644 --- a/fastly/errors.go +++ b/fastly/errors.go @@ -9,9 +9,9 @@ import ( "github.com/google/jsonapi" ) -// ErrMissingService is an error that is returned when an input struct requires -// a "Service" key, but one was not set. -var ErrMissingService = errors.New("missing required field 'Service'") +// ErrMissingServiceID is an error that is returned when an input struct requires +// a "ServiceID" key, but one was not set. +var ErrMissingServiceID = errors.New("missing required field 'ServiceID'") // ErrMissingStatus is an error that is returned when an input struct requires // a "Status" key, but one was not set. @@ -21,9 +21,9 @@ var ErrMissingStatus = errors.New("missing required field 'Status'") // a "Tag" key, but one was not set. var ErrMissingTag = errors.New("missing required field 'Tag'") -// ErrMissingVersion is an error that is returned when an input struct requires -// a "Version" key, but one was not set. -var ErrMissingVersion = errors.New("missing required field 'Version'") +// ErrMissingServiceVersion is an error that is returned when an input struct requires +// a "ServiceVersion" key, but one was not set. +var ErrMissingServiceVersion = errors.New("missing required field 'ServiceVersion'") // ErrMissingContent is an error that is returned when an input struct requires a // "Content" key, but one was not set. diff --git a/fastly/fastly_test.go b/fastly/fastly_test.go index a094f8392..219988c08 100644 --- a/fastly/fastly_test.go +++ b/fastly/fastly_test.go @@ -163,7 +163,7 @@ func testVersion(t *testing.T, c *Client) *Version { defer testVersionLock.Unlock() v, err := c.CreateVersion(&CreateVersionInput{ - Service: testServiceID, + ServiceID: testServiceID, }) if err != nil { t.Fatal(err) @@ -181,7 +181,7 @@ func createTestVersion(t *testing.T, versionFixture string, serviceId string) *V defer testVersionLock.Unlock() version, err = client.CreateVersion(&CreateVersionInput{ - Service: serviceId, + ServiceID: serviceId, }) if err != nil { t.Fatal(err) @@ -198,9 +198,9 @@ func createTestDictionary(t *testing.T, dictionaryFixture string, serviceId stri record(t, dictionaryFixture, func(client *Client) { dictionary, err = client.CreateDictionary(&CreateDictionaryInput{ - Service: serviceId, - Version: version, - Name: fmt.Sprintf("test_dictionary_%s", dictionaryNameSuffix), + ServiceID: serviceId, + ServiceVersion: version, + Name: fmt.Sprintf("test_dictionary_%s", dictionaryNameSuffix), }) }) if err != nil { @@ -215,9 +215,9 @@ func deleteTestDictionary(t *testing.T, dictionary *Dictionary, deleteFixture st record(t, deleteFixture, func(client *Client) { err = client.DeleteDictionary(&DeleteDictionaryInput{ - Service: dictionary.ServiceID, - Version: dictionary.Version, - Name: dictionary.Name, + ServiceID: dictionary.ServiceID, + ServiceVersion: dictionary.Version, + Name: dictionary.Name, }) }) if err != nil { @@ -232,9 +232,9 @@ func createTestACL(t *testing.T, createFixture string, serviceId string, version record(t, createFixture, func(client *Client) { acl, err = client.CreateACL(&CreateACLInput{ - Service: serviceId, - Version: version, - Name: fmt.Sprintf("test_acl_%s", aclNameSuffix), + ServiceID: serviceId, + ServiceVersion: version, + Name: fmt.Sprintf("test_acl_%s", aclNameSuffix), }) }) if err != nil { @@ -249,9 +249,9 @@ func deleteTestACL(t *testing.T, acl *ACL, deleteFixture string) { record(t, deleteFixture, func(client *Client) { err = client.DeleteACL(&DeleteACLInput{ - Service: acl.ServiceID, - Version: acl.Version, - Name: acl.Name, + ServiceID: acl.ServiceID, + ServiceVersion: acl.Version, + Name: acl.Name, }) }) if err != nil { @@ -266,9 +266,9 @@ func createTestPool(t *testing.T, createFixture string, serviceId string, versio record(t, createFixture, func(client *Client) { pool, err = client.CreatePool(&CreatePoolInput{ - Service: serviceId, - Version: version, - Name: fmt.Sprintf("test_pool_%s", poolNameSuffix), + ServiceID: serviceId, + ServiceVersion: version, + Name: fmt.Sprintf("test_pool_%s", poolNameSuffix), }) }) if err != nil { @@ -284,16 +284,16 @@ func createTestLogging(t *testing.T, fixture, serviceID string, serviceNumber in record(t, fixture, func(c *Client) { log, err = c.CreateSyslog(&CreateSyslogInput{ - Service: serviceID, - Version: serviceNumber, - Name: "test-syslog", - Address: "example.com", - Hostname: "example.com", - Port: 1234, - Token: "abcd1234", - Format: "format", - FormatVersion: 2, - MessageType: "classic", + ServiceID: serviceID, + ServiceVersion: serviceNumber, + Name: "test-syslog", + Address: "example.com", + Hostname: "example.com", + Port: 1234, + Token: "abcd1234", + Format: "format", + FormatVersion: 2, + MessageType: "classic", }) }) if err != nil { @@ -309,9 +309,9 @@ func deleteTestPool(t *testing.T, pool *Pool, deleteFixture string) { record(t, deleteFixture, func(client *Client) { err = client.DeletePool(&DeletePoolInput{ - Service: pool.ServiceID, - Version: pool.Version, - Name: pool.Name, + ServiceID: pool.ServiceID, + ServiceVersion: pool.Version, + Name: pool.Name, }) }) if err != nil { @@ -325,9 +325,9 @@ func deleteTestLogging(t *testing.T, fixture, serviceID string, serviceNumber in record(t, fixture, func(c *Client) { err = c.DeleteSyslog(&DeleteSyslogInput{ - Service: serviceID, - Version: serviceNumber, - Name: "test-syslog", + ServiceID: serviceID, + ServiceVersion: serviceNumber, + Name: "test-syslog", }) }) if err != nil { @@ -342,12 +342,12 @@ func createTestWAFCondition(t *testing.T, fixture, serviceID, name string, servi record(t, fixture, func(c *Client) { condition, err = c.CreateCondition(&CreateConditionInput{ - Service: serviceID, - Version: serviceNumber, - Name: name, - Statement: "req.url~+\"index.html\"", - Type: "PREFETCH", // This must be a prefetch condition - Priority: 1, + ServiceID: serviceID, + ServiceVersion: serviceNumber, + Name: name, + Statement: "req.url~+\"index.html\"", + Type: "PREFETCH", // This must be a prefetch condition + Priority: 1, }) }) if err != nil { @@ -362,9 +362,9 @@ func deleteTestCondition(t *testing.T, fixture, serviceID, name string, serviceN record(t, fixture, func(c *Client) { err = c.DeleteCondition(&DeleteConditionInput{ - Service: serviceID, - Version: serviceNumber, - Name: name, + ServiceID: serviceID, + ServiceVersion: serviceNumber, + Name: name, }) }) if err != nil { @@ -379,10 +379,10 @@ func createTestWAFResponseObject(t *testing.T, fixture, serviceID, name string, record(t, fixture, func(c *Client) { ro, err = c.CreateResponseObject(&CreateResponseObjectInput{ - Service: serviceID, - Version: serviceNumber, - Name: name, - Status: 403, + ServiceID: serviceID, + ServiceVersion: serviceNumber, + Name: name, + Status: 403, }) }) if err != nil { @@ -397,9 +397,9 @@ func deleteTestResponseObject(t *testing.T, fixture, serviceID, name string, ser record(t, fixture, func(c *Client) { err = c.DeleteResponseObject(&DeleteResponseObjectInput{ - Service: serviceID, - Version: serviceNumber, - Name: name, + ServiceID: serviceID, + ServiceVersion: serviceNumber, + Name: name, }) }) if err != nil { @@ -407,15 +407,15 @@ func deleteTestResponseObject(t *testing.T, fixture, serviceID, name string, ser } } -func createWAF(t *testing.T, fixture, serviceID, serviceNumber, condition, response string) *WAF { +func createWAF(t *testing.T, fixture, serviceID, condition, response string, serviceNumber int) *WAF { var err error var waf *WAF record(t, fixture, func(c *Client) { waf, err = c.CreateWAF(&CreateWAFInput{ - Service: serviceID, - Version: serviceNumber, + ServiceID: serviceID, + ServiceVersion: serviceNumber, PrefetchCondition: condition, Response: response, }) @@ -426,14 +426,14 @@ func createWAF(t *testing.T, fixture, serviceID, serviceNumber, condition, respo return waf } -func deleteWAF(t *testing.T, fixture, WAFID, WAFVersion string) { +func deleteWAF(t *testing.T, fixture, WAFID string, WAFVersion int) { var err error record(t, fixture, func(c *Client) { err = c.DeleteWAF(&DeleteWAFInput{ - ID: WAFID, - Version: WAFVersion, + ID: WAFID, + ServiceVersion: WAFVersion, }) }) if err != nil { diff --git a/fastly/ftp.go b/fastly/ftp.go index c431485d6..3f1dd7e43 100644 --- a/fastly/ftp.go +++ b/fastly/ftp.go @@ -44,24 +44,24 @@ func (s ftpsByName) Less(i, j int) bool { // ListFTPsInput is used as input to the ListFTPs function. type ListFTPsInput struct { - // Service is the ID of the service (required). - Service string + // ServiceID is the ID of the service (required). + ServiceID string - // Version is the specific configuration version (required). - Version int + // ServiceVersion is the specific configuration version (required). + ServiceVersion int } // ListFTPs returns the list of ftps for the configuration version. func (c *Client) ListFTPs(i *ListFTPsInput) ([]*FTP, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/ftp", i.Service, i.Version) + path := fmt.Sprintf("/service/%s/version/%d/logging/ftp", i.ServiceID, i.ServiceVersion) resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -77,10 +77,11 @@ func (c *Client) ListFTPs(i *ListFTPsInput) ([]*FTP, error) { // CreateFTPInput is used as input to the CreateFTP function. type CreateFTPInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int Name string `form:"name,omitempty"` Address string `form:"address,omitempty"` @@ -101,15 +102,15 @@ type CreateFTPInput struct { // CreateFTP creates a new Fastly FTP. func (c *Client) CreateFTP(i *CreateFTPInput) (*FTP, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/ftp", i.Service, i.Version) + path := fmt.Sprintf("/service/%s/version/%d/logging/ftp", i.ServiceID, i.ServiceVersion) resp, err := c.PostForm(path, i, nil) if err != nil { return nil, err @@ -124,10 +125,11 @@ func (c *Client) CreateFTP(i *CreateFTPInput) (*FTP, error) { // GetFTPInput is used as input to the GetFTP function. type GetFTPInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int // Name is the name of the FTP to fetch. Name string @@ -135,19 +137,19 @@ type GetFTPInput struct { // GetFTP gets the FTP configuration with the given parameters. func (c *Client) GetFTP(i *GetFTPInput) (*FTP, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } if i.Name == "" { return nil, ErrMissingName } - path := fmt.Sprintf("/service/%s/version/%d/logging/ftp/%s", i.Service, i.Version, url.PathEscape(i.Name)) + path := fmt.Sprintf("/service/%s/version/%d/logging/ftp/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -162,10 +164,11 @@ func (c *Client) GetFTP(i *GetFTPInput) (*FTP, error) { // UpdateFTPInput is used as input to the UpdateFTP function. type UpdateFTPInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int // Name is the name of the FTP to update. Name string @@ -189,19 +192,19 @@ type UpdateFTPInput struct { // UpdateFTP updates a specific FTP. func (c *Client) UpdateFTP(i *UpdateFTPInput) (*FTP, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } if i.Name == "" { return nil, ErrMissingName } - path := fmt.Sprintf("/service/%s/version/%d/logging/ftp/%s", i.Service, i.Version, url.PathEscape(i.Name)) + path := fmt.Sprintf("/service/%s/version/%d/logging/ftp/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) resp, err := c.PutForm(path, i, nil) if err != nil { return nil, err @@ -216,10 +219,11 @@ func (c *Client) UpdateFTP(i *UpdateFTPInput) (*FTP, error) { // DeleteFTPInput is the input parameter to DeleteFTP. type DeleteFTPInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int // Name is the name of the FTP to delete (required). Name string @@ -227,19 +231,19 @@ type DeleteFTPInput struct { // DeleteFTP deletes the given FTP version. func (c *Client) DeleteFTP(i *DeleteFTPInput) error { - if i.Service == "" { - return ErrMissingService + if i.ServiceID == "" { + return ErrMissingServiceID } - if i.Version == 0 { - return ErrMissingVersion + if i.ServiceVersion == 0 { + return ErrMissingServiceVersion } if i.Name == "" { return ErrMissingName } - path := fmt.Sprintf("/service/%s/version/%d/logging/ftp/%s", i.Service, i.Version, url.PathEscape(i.Name)) + path := fmt.Sprintf("/service/%s/version/%d/logging/ftp/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) resp, err := c.Delete(path, nil) if err != nil { return err diff --git a/fastly/ftp_test.go b/fastly/ftp_test.go index a7b490877..ca0307343 100644 --- a/fastly/ftp_test.go +++ b/fastly/ftp_test.go @@ -14,8 +14,8 @@ func TestClient_FTPs(t *testing.T) { var ftp *FTP record(t, "ftps/create", func(c *Client) { ftp, err = c.CreateFTP(&CreateFTPInput{ - Service: testServiceID, - Version: tv.Number, + ServiceID: testServiceID, + ServiceVersion: tv.Number, Name: "test-ftp", Address: "example.com", Port: 1234, @@ -40,15 +40,15 @@ func TestClient_FTPs(t *testing.T) { defer func() { record(t, "ftps/cleanup", func(c *Client) { c.DeleteFTP(&DeleteFTPInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-ftp", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "test-ftp", }) c.DeleteFTP(&DeleteFTPInput{ - Service: testServiceID, - Version: tv.Number, - Name: "new-test-ftp", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "new-test-ftp", }) }) }() @@ -100,8 +100,8 @@ func TestClient_FTPs(t *testing.T) { var ftps []*FTP record(t, "ftps/list", func(c *Client) { ftps, err = c.ListFTPs(&ListFTPsInput{ - Service: testServiceID, - Version: tv.Number, + ServiceID: testServiceID, + ServiceVersion: tv.Number, }) }) if err != nil { @@ -115,9 +115,9 @@ func TestClient_FTPs(t *testing.T) { var nftp *FTP record(t, "ftps/get", func(c *Client) { nftp, err = c.GetFTP(&GetFTPInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-ftp", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "test-ftp", }) }) if err != nil { @@ -170,11 +170,11 @@ func TestClient_FTPs(t *testing.T) { var uftp *FTP record(t, "ftps/update", func(c *Client) { uftp, err = c.UpdateFTP(&UpdateFTPInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-ftp", - NewName: "new-test-ftp", - GzipLevel: 0, + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "test-ftp", + NewName: "new-test-ftp", + GzipLevel: 0, }) }) if err != nil { @@ -195,9 +195,9 @@ func TestClient_FTPs(t *testing.T) { // Delete record(t, "ftps/delete", func(c *Client) { err = c.DeleteFTP(&DeleteFTPInput{ - Service: testServiceID, - Version: tv.Number, - Name: "new-test-ftp", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "new-test-ftp", }) }) if err != nil { @@ -208,17 +208,17 @@ func TestClient_FTPs(t *testing.T) { func TestClient_ListFTPs_validation(t *testing.T) { var err error _, err = testClient.ListFTPs(&ListFTPsInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.ListFTPs(&ListFTPsInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } } @@ -226,17 +226,17 @@ func TestClient_ListFTPs_validation(t *testing.T) { func TestClient_CreateFTP_validation(t *testing.T) { var err error _, err = testClient.CreateFTP(&CreateFTPInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.CreateFTP(&CreateFTPInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } } @@ -244,24 +244,24 @@ func TestClient_CreateFTP_validation(t *testing.T) { func TestClient_GetFTP_validation(t *testing.T) { var err error _, err = testClient.GetFTP(&GetFTPInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.GetFTP(&GetFTPInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } _, err = testClient.GetFTP(&GetFTPInput{ - Service: "foo", - Version: 1, - Name: "", + ServiceID: "foo", + ServiceVersion: 1, + Name: "", }) if err != ErrMissingName { t.Errorf("bad error: %s", err) @@ -271,24 +271,24 @@ func TestClient_GetFTP_validation(t *testing.T) { func TestClient_UpdateFTP_validation(t *testing.T) { var err error _, err = testClient.UpdateFTP(&UpdateFTPInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.UpdateFTP(&UpdateFTPInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } _, err = testClient.UpdateFTP(&UpdateFTPInput{ - Service: "foo", - Version: 1, - Name: "", + ServiceID: "foo", + ServiceVersion: 1, + Name: "", }) if err != ErrMissingName { t.Errorf("bad error: %s", err) @@ -298,24 +298,24 @@ func TestClient_UpdateFTP_validation(t *testing.T) { func TestClient_DeleteFTP_validation(t *testing.T) { var err error err = testClient.DeleteFTP(&DeleteFTPInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } err = testClient.DeleteFTP(&DeleteFTPInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } err = testClient.DeleteFTP(&DeleteFTPInput{ - Service: "foo", - Version: 1, - Name: "", + ServiceID: "foo", + ServiceVersion: 1, + Name: "", }) if err != ErrMissingName { t.Errorf("bad error: %s", err) diff --git a/fastly/gcs.go b/fastly/gcs.go index 45c4fe3bb..9415bd1ad 100644 --- a/fastly/gcs.go +++ b/fastly/gcs.go @@ -42,24 +42,24 @@ func (s gcsesByName) Less(i, j int) bool { // ListGCSsInput is used as input to the ListGCSs function. type ListGCSsInput struct { - // Service is the ID of the service (required). - Service string + // ServiceID is the ID of the service (required). + ServiceID string - // Version is the specific configuration version (required). - Version int + // ServiceVersion is the specific configuration version (required). + ServiceVersion int } // ListGCSs returns the list of gcses for the configuration version. func (c *Client) ListGCSs(i *ListGCSsInput) ([]*GCS, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/gcs", i.Service, i.Version) + path := fmt.Sprintf("/service/%s/version/%d/logging/gcs", i.ServiceID, i.ServiceVersion) resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -75,10 +75,11 @@ func (c *Client) ListGCSs(i *ListGCSsInput) ([]*GCS, error) { // CreateGCSInput is used as input to the CreateGCS function. type CreateGCSInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int Name string `form:"name,omitempty"` Bucket string `form:"bucket_name,omitempty"` @@ -97,15 +98,15 @@ type CreateGCSInput struct { // CreateGCS creates a new Fastly GCS. func (c *Client) CreateGCS(i *CreateGCSInput) (*GCS, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/gcs", i.Service, i.Version) + path := fmt.Sprintf("/service/%s/version/%d/logging/gcs", i.ServiceID, i.ServiceVersion) resp, err := c.PostForm(path, i, nil) if err != nil { return nil, err @@ -120,10 +121,11 @@ func (c *Client) CreateGCS(i *CreateGCSInput) (*GCS, error) { // GetGCSInput is used as input to the GetGCS function. type GetGCSInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int // Name is the name of the GCS to fetch. Name string @@ -131,19 +133,19 @@ type GetGCSInput struct { // GetGCS gets the GCS configuration with the given parameters. func (c *Client) GetGCS(i *GetGCSInput) (*GCS, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } if i.Name == "" { return nil, ErrMissingName } - path := fmt.Sprintf("/service/%s/version/%d/logging/gcs/%s", i.Service, i.Version, url.PathEscape(i.Name)) + path := fmt.Sprintf("/service/%s/version/%d/logging/gcs/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -158,10 +160,11 @@ func (c *Client) GetGCS(i *GetGCSInput) (*GCS, error) { // UpdateGCSInput is used as input to the UpdateGCS function. type UpdateGCSInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int // Name is the name of the GCS to update. Name string @@ -183,19 +186,19 @@ type UpdateGCSInput struct { // UpdateGCS updates a specific GCS. func (c *Client) UpdateGCS(i *UpdateGCSInput) (*GCS, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } if i.Name == "" { return nil, ErrMissingName } - path := fmt.Sprintf("/service/%s/version/%d/logging/gcs/%s", i.Service, i.Version, url.PathEscape(i.Name)) + path := fmt.Sprintf("/service/%s/version/%d/logging/gcs/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) resp, err := c.PutForm(path, i, nil) if err != nil { return nil, err @@ -210,10 +213,11 @@ func (c *Client) UpdateGCS(i *UpdateGCSInput) (*GCS, error) { // DeleteGCSInput is the input parameter to DeleteGCS. type DeleteGCSInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int // Name is the name of the GCS to delete (required). Name string @@ -221,19 +225,19 @@ type DeleteGCSInput struct { // DeleteGCS deletes the given GCS version. func (c *Client) DeleteGCS(i *DeleteGCSInput) error { - if i.Service == "" { - return ErrMissingService + if i.ServiceID == "" { + return ErrMissingServiceID } - if i.Version == 0 { - return ErrMissingVersion + if i.ServiceVersion == 0 { + return ErrMissingServiceVersion } if i.Name == "" { return ErrMissingName } - path := fmt.Sprintf("/service/%s/version/%d/logging/gcs/%s", i.Service, i.Version, url.PathEscape(i.Name)) + path := fmt.Sprintf("/service/%s/version/%d/logging/gcs/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) resp, err := c.Delete(path, nil) if err != nil { return err diff --git a/fastly/gcs_test.go b/fastly/gcs_test.go index b2cec29ad..4afa7f054 100644 --- a/fastly/gcs_test.go +++ b/fastly/gcs_test.go @@ -15,8 +15,8 @@ func TestClient_GCSs(t *testing.T) { var gcs *GCS record(t, "gcses/create", func(c *Client) { gcs, err = c.CreateGCS(&CreateGCSInput{ - Service: testServiceID, - Version: tv.Number, + ServiceID: testServiceID, + ServiceVersion: tv.Number, Name: "test-gcs", Bucket: "bucket", User: "user", @@ -39,15 +39,15 @@ func TestClient_GCSs(t *testing.T) { defer func() { record(t, "gcses/cleanup", func(c *Client) { c.DeleteGCS(&DeleteGCSInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-gcs", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "test-gcs", }) c.DeleteGCS(&DeleteGCSInput{ - Service: testServiceID, - Version: tv.Number, - Name: "new-test-gcs", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "new-test-gcs", }) }) }() @@ -93,8 +93,8 @@ func TestClient_GCSs(t *testing.T) { var gcses []*GCS record(t, "gcses/list", func(c *Client) { gcses, err = c.ListGCSs(&ListGCSsInput{ - Service: testServiceID, - Version: tv.Number, + ServiceID: testServiceID, + ServiceVersion: tv.Number, }) }) if err != nil { @@ -108,9 +108,9 @@ func TestClient_GCSs(t *testing.T) { var ngcs *GCS record(t, "gcses/get", func(c *Client) { ngcs, err = c.GetGCS(&GetGCSInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-gcs", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "test-gcs", }) }) if err != nil { @@ -157,11 +157,11 @@ func TestClient_GCSs(t *testing.T) { var ugcs *GCS record(t, "gcses/update", func(c *Client) { ugcs, err = c.UpdateGCS(&UpdateGCSInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-gcs", - NewName: "new-test-gcs", - MessageType: "classic", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "test-gcs", + NewName: "new-test-gcs", + MessageType: "classic", }) }) if err != nil { @@ -177,9 +177,9 @@ func TestClient_GCSs(t *testing.T) { // Delete record(t, "gcses/delete", func(c *Client) { err = c.DeleteGCS(&DeleteGCSInput{ - Service: testServiceID, - Version: tv.Number, - Name: "new-test-gcs", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "new-test-gcs", }) }) if err != nil { @@ -190,17 +190,17 @@ func TestClient_GCSs(t *testing.T) { func TestClient_ListGCSs_validation(t *testing.T) { var err error _, err = testClient.ListGCSs(&ListGCSsInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.ListGCSs(&ListGCSsInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } } @@ -208,17 +208,17 @@ func TestClient_ListGCSs_validation(t *testing.T) { func TestClient_CreateGCS_validation(t *testing.T) { var err error _, err = testClient.CreateGCS(&CreateGCSInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.CreateGCS(&CreateGCSInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } } @@ -226,24 +226,24 @@ func TestClient_CreateGCS_validation(t *testing.T) { func TestClient_GetGCS_validation(t *testing.T) { var err error _, err = testClient.GetGCS(&GetGCSInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.GetGCS(&GetGCSInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } _, err = testClient.GetGCS(&GetGCSInput{ - Service: "foo", - Version: 1, - Name: "", + ServiceID: "foo", + ServiceVersion: 1, + Name: "", }) if err != ErrMissingName { t.Errorf("bad error: %s", err) @@ -253,24 +253,24 @@ func TestClient_GetGCS_validation(t *testing.T) { func TestClient_UpdateGCS_validation(t *testing.T) { var err error _, err = testClient.UpdateGCS(&UpdateGCSInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.UpdateGCS(&UpdateGCSInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } _, err = testClient.UpdateGCS(&UpdateGCSInput{ - Service: "foo", - Version: 1, - Name: "", + ServiceID: "foo", + ServiceVersion: 1, + Name: "", }) if err != ErrMissingName { t.Errorf("bad error: %s", err) @@ -280,24 +280,24 @@ func TestClient_UpdateGCS_validation(t *testing.T) { func TestClient_DeleteGCS_validation(t *testing.T) { var err error err = testClient.DeleteGCS(&DeleteGCSInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } err = testClient.DeleteGCS(&DeleteGCSInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } err = testClient.DeleteGCS(&DeleteGCSInput{ - Service: "foo", - Version: 1, - Name: "", + ServiceID: "foo", + ServiceVersion: 1, + Name: "", }) if err != ErrMissingName { t.Errorf("bad error: %s", err) diff --git a/fastly/gzip.go b/fastly/gzip.go index 3355cd54a..a0391d05f 100644 --- a/fastly/gzip.go +++ b/fastly/gzip.go @@ -33,24 +33,24 @@ func (s gzipsByName) Less(i, j int) bool { // ListGzipsInput is used as input to the ListGzips function. type ListGzipsInput struct { - // Service is the ID of the service (required). - Service string + // ServiceID is the ID of the service (required). + ServiceID string - // Version is the specific configuration version (required). - Version int + // ServiceVersion is the specific configuration version (required). + ServiceVersion int } // ListGzips returns the list of gzips for the configuration version. func (c *Client) ListGzips(i *ListGzipsInput) ([]*Gzip, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/gzip", i.Service, i.Version) + path := fmt.Sprintf("/service/%s/version/%d/gzip", i.ServiceID, i.ServiceVersion) resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -66,10 +66,11 @@ func (c *Client) ListGzips(i *ListGzipsInput) ([]*Gzip, error) { // CreateGzipInput is used as input to the CreateGzip function. type CreateGzipInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int Name string `form:"name,omitempty"` ContentTypes string `form:"content_types"` @@ -79,15 +80,15 @@ type CreateGzipInput struct { // CreateGzip creates a new Fastly Gzip. func (c *Client) CreateGzip(i *CreateGzipInput) (*Gzip, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/gzip", i.Service, i.Version) + path := fmt.Sprintf("/service/%s/version/%d/gzip", i.ServiceID, i.ServiceVersion) resp, err := c.PostForm(path, i, nil) if err != nil { return nil, err @@ -102,10 +103,11 @@ func (c *Client) CreateGzip(i *CreateGzipInput) (*Gzip, error) { // GetGzipInput is used as input to the GetGzip function. type GetGzipInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int // Name is the name of the Gzip to fetch. Name string @@ -113,19 +115,19 @@ type GetGzipInput struct { // GetGzip gets the Gzip configuration with the given parameters. func (c *Client) GetGzip(i *GetGzipInput) (*Gzip, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } if i.Name == "" { return nil, ErrMissingName } - path := fmt.Sprintf("/service/%s/version/%d/gzip/%s", i.Service, i.Version, url.PathEscape(i.Name)) + path := fmt.Sprintf("/service/%s/version/%d/gzip/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -140,10 +142,11 @@ func (c *Client) GetGzip(i *GetGzipInput) (*Gzip, error) { // UpdateGzipInput is used as input to the UpdateGzip function. type UpdateGzipInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int // Name is the name of the Gzip to update. Name string @@ -156,19 +159,19 @@ type UpdateGzipInput struct { // UpdateGzip updates a specific Gzip. func (c *Client) UpdateGzip(i *UpdateGzipInput) (*Gzip, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } if i.Name == "" { return nil, ErrMissingName } - path := fmt.Sprintf("/service/%s/version/%d/gzip/%s", i.Service, i.Version, url.PathEscape(i.Name)) + path := fmt.Sprintf("/service/%s/version/%d/gzip/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) resp, err := c.PutForm(path, i, nil) if err != nil { return nil, err @@ -183,10 +186,11 @@ func (c *Client) UpdateGzip(i *UpdateGzipInput) (*Gzip, error) { // DeleteGzipInput is the input parameter to DeleteGzip. type DeleteGzipInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int // Name is the name of the Gzip to delete (required). Name string @@ -194,19 +198,19 @@ type DeleteGzipInput struct { // DeleteGzip deletes the given Gzip version. func (c *Client) DeleteGzip(i *DeleteGzipInput) error { - if i.Service == "" { - return ErrMissingService + if i.ServiceID == "" { + return ErrMissingServiceID } - if i.Version == 0 { - return ErrMissingVersion + if i.ServiceVersion == 0 { + return ErrMissingServiceVersion } if i.Name == "" { return ErrMissingName } - path := fmt.Sprintf("/service/%s/version/%d/gzip/%s", i.Service, i.Version, url.PathEscape(i.Name)) + path := fmt.Sprintf("/service/%s/version/%d/gzip/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) resp, err := c.Delete(path, nil) if err != nil { return err diff --git a/fastly/gzip_test.go b/fastly/gzip_test.go index d4f341de9..198e75293 100644 --- a/fastly/gzip_test.go +++ b/fastly/gzip_test.go @@ -15,11 +15,11 @@ func TestClient_Gzips(t *testing.T) { var gzip *Gzip record(t, "gzips/create", func(c *Client) { gzip, err = c.CreateGzip(&CreateGzipInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-gzip", - ContentTypes: "text/html text/css", - Extensions: "html css", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "test-gzip", + ContentTypes: "text/html text/css", + Extensions: "html css", }) }) if err != nil { @@ -30,9 +30,9 @@ func TestClient_Gzips(t *testing.T) { var gzipomit *Gzip record(t, "gzips/create_omissions", func(c *Client) { gzipomit, err = c.CreateGzip(&CreateGzipInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-gzip-omit", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "test-gzip-omit", }) }) if err != nil { @@ -49,21 +49,21 @@ func TestClient_Gzips(t *testing.T) { defer func() { record(t, "gzips/cleanup", func(c *Client) { c.DeleteGzip(&DeleteGzipInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-gzip", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "test-gzip", }) c.DeleteGzip(&DeleteGzipInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-gzip-omit", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "test-gzip-omit", }) c.DeleteGzip(&DeleteGzipInput{ - Service: testServiceID, - Version: tv.Number, - Name: "new-test-gzip", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "new-test-gzip", }) }) }() @@ -82,8 +82,8 @@ func TestClient_Gzips(t *testing.T) { var gzips []*Gzip record(t, "gzips/list", func(c *Client) { gzips, err = c.ListGzips(&ListGzipsInput{ - Service: testServiceID, - Version: tv.Number, + ServiceID: testServiceID, + ServiceVersion: tv.Number, }) }) if err != nil { @@ -97,9 +97,9 @@ func TestClient_Gzips(t *testing.T) { var ngzip *Gzip record(t, "gzips/get", func(c *Client) { ngzip, err = c.GetGzip(&GetGzipInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-gzip", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "test-gzip", }) }) if err != nil { @@ -119,10 +119,10 @@ func TestClient_Gzips(t *testing.T) { var ugzip *Gzip record(t, "gzips/update", func(c *Client) { ugzip, err = c.UpdateGzip(&UpdateGzipInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-gzip", - NewName: "new-test-gzip", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "test-gzip", + NewName: "new-test-gzip", }) }) if err != nil { @@ -135,9 +135,9 @@ func TestClient_Gzips(t *testing.T) { // Delete record(t, "gzips/delete", func(c *Client) { err = c.DeleteGzip(&DeleteGzipInput{ - Service: testServiceID, - Version: tv.Number, - Name: "new-test-gzip", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "new-test-gzip", }) }) if err != nil { @@ -148,17 +148,17 @@ func TestClient_Gzips(t *testing.T) { func TestClient_ListGzips_validation(t *testing.T) { var err error _, err = testClient.ListGzips(&ListGzipsInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.ListGzips(&ListGzipsInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } } @@ -166,17 +166,17 @@ func TestClient_ListGzips_validation(t *testing.T) { func TestClient_CreateGzip_validation(t *testing.T) { var err error _, err = testClient.CreateGzip(&CreateGzipInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.CreateGzip(&CreateGzipInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } } @@ -184,24 +184,24 @@ func TestClient_CreateGzip_validation(t *testing.T) { func TestClient_GetGzip_validation(t *testing.T) { var err error _, err = testClient.GetGzip(&GetGzipInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.GetGzip(&GetGzipInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } _, err = testClient.GetGzip(&GetGzipInput{ - Service: "foo", - Version: 1, - Name: "", + ServiceID: "foo", + ServiceVersion: 1, + Name: "", }) if err != ErrMissingName { t.Errorf("bad error: %s", err) @@ -211,24 +211,24 @@ func TestClient_GetGzip_validation(t *testing.T) { func TestClient_UpdateGzip_validation(t *testing.T) { var err error _, err = testClient.UpdateGzip(&UpdateGzipInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.UpdateGzip(&UpdateGzipInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } _, err = testClient.UpdateGzip(&UpdateGzipInput{ - Service: "foo", - Version: 1, - Name: "", + ServiceID: "foo", + ServiceVersion: 1, + Name: "", }) if err != ErrMissingName { t.Errorf("bad error: %s", err) @@ -238,24 +238,24 @@ func TestClient_UpdateGzip_validation(t *testing.T) { func TestClient_DeleteGzip_validation(t *testing.T) { var err error err = testClient.DeleteGzip(&DeleteGzipInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } err = testClient.DeleteGzip(&DeleteGzipInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } err = testClient.DeleteGzip(&DeleteGzipInput{ - Service: "foo", - Version: 1, - Name: "", + ServiceID: "foo", + ServiceVersion: 1, + Name: "", }) if err != ErrMissingName { t.Errorf("bad error: %s", err) diff --git a/fastly/header.go b/fastly/header.go index 456954587..e259a9c13 100644 --- a/fastly/header.go +++ b/fastly/header.go @@ -84,24 +84,24 @@ func (s headersByName) Less(i, j int) bool { // ListHeadersInput is used as input to the ListHeaders function. type ListHeadersInput struct { - // Service is the ID of the service (required). - Service string + // ServiceID is the ID of the service (required). + ServiceID string - // Version is the specific configuration version (required). - Version int + // ServiceVersion is the specific configuration version (required). + ServiceVersion int } // ListHeaders returns the list of headers for the configuration version. func (c *Client) ListHeaders(i *ListHeadersInput) ([]*Header, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/header", i.Service, i.Version) + path := fmt.Sprintf("/service/%s/version/%d/header", i.ServiceID, i.ServiceVersion) resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -117,10 +117,11 @@ func (c *Client) ListHeaders(i *ListHeadersInput) ([]*Header, error) { // CreateHeaderInput is used as input to the CreateHeader function. type CreateHeaderInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int Name string `form:"name,omitempty"` Action HeaderAction `form:"action,omitempty"` @@ -138,15 +139,15 @@ type CreateHeaderInput struct { // CreateHeader creates a new Fastly header. func (c *Client) CreateHeader(i *CreateHeaderInput) (*Header, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/header", i.Service, i.Version) + path := fmt.Sprintf("/service/%s/version/%d/header", i.ServiceID, i.ServiceVersion) resp, err := c.PostForm(path, i, nil) if err != nil { return nil, err @@ -161,10 +162,11 @@ func (c *Client) CreateHeader(i *CreateHeaderInput) (*Header, error) { // GetHeaderInput is used as input to the GetHeader function. type GetHeaderInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int // Name is the name of the header to fetch. Name string @@ -172,19 +174,19 @@ type GetHeaderInput struct { // GetHeader gets the header configuration with the given parameters. func (c *Client) GetHeader(i *GetHeaderInput) (*Header, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } if i.Name == "" { return nil, ErrMissingName } - path := fmt.Sprintf("/service/%s/version/%d/header/%s", i.Service, i.Version, url.PathEscape(i.Name)) + path := fmt.Sprintf("/service/%s/version/%d/header/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -199,10 +201,11 @@ func (c *Client) GetHeader(i *GetHeaderInput) (*Header, error) { // UpdateHeaderInput is used as input to the UpdateHeader function. type UpdateHeaderInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int // Name is the name of the header to update. Name string @@ -223,19 +226,19 @@ type UpdateHeaderInput struct { // UpdateHeader updates a specific header. func (c *Client) UpdateHeader(i *UpdateHeaderInput) (*Header, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } if i.Name == "" { return nil, ErrMissingName } - path := fmt.Sprintf("/service/%s/version/%d/header/%s", i.Service, i.Version, url.PathEscape(i.Name)) + path := fmt.Sprintf("/service/%s/version/%d/header/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) resp, err := c.PutForm(path, i, nil) if err != nil { return nil, err @@ -250,10 +253,11 @@ func (c *Client) UpdateHeader(i *UpdateHeaderInput) (*Header, error) { // DeleteHeaderInput is the input parameter to DeleteHeader. type DeleteHeaderInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int // Name is the name of the header to delete (required). Name string @@ -261,19 +265,19 @@ type DeleteHeaderInput struct { // DeleteHeader deletes the given header version. func (c *Client) DeleteHeader(i *DeleteHeaderInput) error { - if i.Service == "" { - return ErrMissingService + if i.ServiceID == "" { + return ErrMissingServiceID } - if i.Version == 0 { - return ErrMissingVersion + if i.ServiceVersion == 0 { + return ErrMissingServiceVersion } if i.Name == "" { return ErrMissingName } - path := fmt.Sprintf("/service/%s/version/%d/header/%s", i.Service, i.Version, url.PathEscape(i.Name)) + path := fmt.Sprintf("/service/%s/version/%d/header/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) resp, err := c.Delete(path, nil) if err != nil { return err diff --git a/fastly/header_test.go b/fastly/header_test.go index b342d6fc2..fdb833ef5 100644 --- a/fastly/header_test.go +++ b/fastly/header_test.go @@ -15,17 +15,17 @@ func TestClient_Headers(t *testing.T) { var h *Header record(t, "headers/create", func(c *Client) { h, err = c.CreateHeader(&CreateHeaderInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-header", - Action: HeaderActionSet, - IgnoreIfSet: CBool(false), - Type: HeaderTypeRequest, - Destination: "http.foo", - Source: "client.ip", - Regex: "foobar", - Substitution: "123", - Priority: 50, + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "test-header", + Action: HeaderActionSet, + IgnoreIfSet: CBool(false), + Type: HeaderTypeRequest, + Destination: "http.foo", + Source: "client.ip", + Regex: "foobar", + Substitution: "123", + Priority: 50, }) }) if err != nil { @@ -36,15 +36,15 @@ func TestClient_Headers(t *testing.T) { defer func() { record(t, "headers/cleanup", func(c *Client) { c.DeleteHeader(&DeleteHeaderInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-header", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "test-header", }) c.DeleteHeader(&DeleteHeaderInput{ - Service: testServiceID, - Version: tv.Number, - Name: "new-test-header", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "new-test-header", }) }) }() @@ -81,8 +81,8 @@ func TestClient_Headers(t *testing.T) { var hs []*Header record(t, "headers/list", func(c *Client) { hs, err = c.ListHeaders(&ListHeadersInput{ - Service: testServiceID, - Version: tv.Number, + ServiceID: testServiceID, + ServiceVersion: tv.Number, }) }) if err != nil { @@ -96,9 +96,9 @@ func TestClient_Headers(t *testing.T) { var nh *Header record(t, "headers/get", func(c *Client) { nh, err = c.GetHeader(&GetHeaderInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-header", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "test-header", }) }) if err != nil { @@ -136,10 +136,10 @@ func TestClient_Headers(t *testing.T) { var uh *Header record(t, "headers/update", func(c *Client) { uh, err = c.UpdateHeader(&UpdateHeaderInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-header", - NewName: "new-test-header", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "test-header", + NewName: "new-test-header", }) }) if err != nil { @@ -152,9 +152,9 @@ func TestClient_Headers(t *testing.T) { // Delete record(t, "headers/delete", func(c *Client) { err = c.DeleteHeader(&DeleteHeaderInput{ - Service: testServiceID, - Version: tv.Number, - Name: "new-test-header", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "new-test-header", }) }) if err != nil { @@ -165,17 +165,17 @@ func TestClient_Headers(t *testing.T) { func TestClient_ListHeaders_validation(t *testing.T) { var err error _, err = testClient.ListHeaders(&ListHeadersInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.ListHeaders(&ListHeadersInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } } @@ -183,17 +183,17 @@ func TestClient_ListHeaders_validation(t *testing.T) { func TestClient_CreateHeader_validation(t *testing.T) { var err error _, err = testClient.CreateHeader(&CreateHeaderInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.CreateHeader(&CreateHeaderInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } } @@ -201,24 +201,24 @@ func TestClient_CreateHeader_validation(t *testing.T) { func TestClient_GetHeader_validation(t *testing.T) { var err error _, err = testClient.GetHeader(&GetHeaderInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.GetHeader(&GetHeaderInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } _, err = testClient.GetHeader(&GetHeaderInput{ - Service: "foo", - Version: 1, - Name: "", + ServiceID: "foo", + ServiceVersion: 1, + Name: "", }) if err != ErrMissingName { t.Errorf("bad error: %s", err) @@ -228,24 +228,24 @@ func TestClient_GetHeader_validation(t *testing.T) { func TestClient_UpdateHeader_validation(t *testing.T) { var err error _, err = testClient.UpdateHeader(&UpdateHeaderInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.UpdateHeader(&UpdateHeaderInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } _, err = testClient.UpdateHeader(&UpdateHeaderInput{ - Service: "foo", - Version: 1, - Name: "", + ServiceID: "foo", + ServiceVersion: 1, + Name: "", }) if err != ErrMissingName { t.Errorf("bad error: %s", err) @@ -255,24 +255,24 @@ func TestClient_UpdateHeader_validation(t *testing.T) { func TestClient_DeleteHeader_validation(t *testing.T) { var err error err = testClient.DeleteHeader(&DeleteHeaderInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } err = testClient.DeleteHeader(&DeleteHeaderInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } err = testClient.DeleteHeader(&DeleteHeaderInput{ - Service: "foo", - Version: 1, - Name: "", + ServiceID: "foo", + ServiceVersion: 1, + Name: "", }) if err != ErrMissingName { t.Errorf("bad error: %s", err) diff --git a/fastly/health_check.go b/fastly/health_check.go index 4e04c0942..307d17d52 100644 --- a/fastly/health_check.go +++ b/fastly/health_check.go @@ -41,25 +41,25 @@ func (s healthChecksByName) Less(i, j int) bool { // ListHealthChecksInput is used as input to the ListHealthChecks function. type ListHealthChecksInput struct { - // Service is the ID of the service (required). - Service string + // ServiceID is the ID of the service (required). + ServiceID string - // Version is the specific configuration version (required). - Version int + // ServiceVersion is the specific configuration version (required). + ServiceVersion int } // ListHealthChecks returns the list of health checks for the configuration // version. func (c *Client) ListHealthChecks(i *ListHealthChecksInput) ([]*HealthCheck, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/healthcheck", i.Service, i.Version) + path := fmt.Sprintf("/service/%s/version/%d/healthcheck", i.ServiceID, i.ServiceVersion) resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -75,10 +75,11 @@ func (c *Client) ListHealthChecks(i *ListHealthChecksInput) ([]*HealthCheck, err // CreateHealthCheckInput is used as input to the CreateHealthCheck function. type CreateHealthCheckInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int Name string `form:"name,omitempty"` Comment string `form:"comment,omitempty"` @@ -96,15 +97,15 @@ type CreateHealthCheckInput struct { // CreateHealthCheck creates a new Fastly health check. func (c *Client) CreateHealthCheck(i *CreateHealthCheckInput) (*HealthCheck, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/healthcheck", i.Service, i.Version) + path := fmt.Sprintf("/service/%s/version/%d/healthcheck", i.ServiceID, i.ServiceVersion) resp, err := c.PostForm(path, i, nil) if err != nil { return nil, err @@ -119,10 +120,11 @@ func (c *Client) CreateHealthCheck(i *CreateHealthCheckInput) (*HealthCheck, err // GetHealthCheckInput is used as input to the GetHealthCheck function. type GetHealthCheckInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int // Name is the name of the health check to fetch. Name string @@ -130,19 +132,19 @@ type GetHealthCheckInput struct { // GetHealthCheck gets the health check configuration with the given parameters. func (c *Client) GetHealthCheck(i *GetHealthCheckInput) (*HealthCheck, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } if i.Name == "" { return nil, ErrMissingName } - path := fmt.Sprintf("/service/%s/version/%d/healthcheck/%s", i.Service, i.Version, url.PathEscape(i.Name)) + path := fmt.Sprintf("/service/%s/version/%d/healthcheck/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -157,10 +159,11 @@ func (c *Client) GetHealthCheck(i *GetHealthCheckInput) (*HealthCheck, error) { // UpdateHealthCheckInput is used as input to the UpdateHealthCheck function. type UpdateHealthCheckInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int // Name is the name of the health check to update. Name string @@ -181,19 +184,19 @@ type UpdateHealthCheckInput struct { // UpdateHealthCheck updates a specific health check. func (c *Client) UpdateHealthCheck(i *UpdateHealthCheckInput) (*HealthCheck, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } if i.Name == "" { return nil, ErrMissingName } - path := fmt.Sprintf("/service/%s/version/%d/healthcheck/%s", i.Service, i.Version, url.PathEscape(i.Name)) + path := fmt.Sprintf("/service/%s/version/%d/healthcheck/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) resp, err := c.PutForm(path, i, nil) if err != nil { return nil, err @@ -208,10 +211,11 @@ func (c *Client) UpdateHealthCheck(i *UpdateHealthCheckInput) (*HealthCheck, err // DeleteHealthCheckInput is the input parameter to DeleteHealthCheck. type DeleteHealthCheckInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int // Name is the name of the health check to delete (required). Name string @@ -219,19 +223,19 @@ type DeleteHealthCheckInput struct { // DeleteHealthCheck deletes the given health check. func (c *Client) DeleteHealthCheck(i *DeleteHealthCheckInput) error { - if i.Service == "" { - return ErrMissingService + if i.ServiceID == "" { + return ErrMissingServiceID } - if i.Version == 0 { - return ErrMissingVersion + if i.ServiceVersion == 0 { + return ErrMissingServiceVersion } if i.Name == "" { return ErrMissingName } - path := fmt.Sprintf("/service/%s/version/%d/healthcheck/%s", i.Service, i.Version, url.PathEscape(i.Name)) + path := fmt.Sprintf("/service/%s/version/%d/healthcheck/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) resp, err := c.Delete(path, nil) if err != nil { return err diff --git a/fastly/health_check_test.go b/fastly/health_check_test.go index 7e95966e2..25a0d140d 100644 --- a/fastly/health_check_test.go +++ b/fastly/health_check_test.go @@ -15,8 +15,8 @@ func TestClient_HealthChecks(t *testing.T) { var hc *HealthCheck record(t, "health_checks/create", func(c *Client) { hc, err = c.CreateHealthCheck(&CreateHealthCheckInput{ - Service: testServiceID, - Version: tv.Number, + ServiceID: testServiceID, + ServiceVersion: tv.Number, Name: "test-healthcheck", Method: "HEAD", Host: "example.com", @@ -38,15 +38,15 @@ func TestClient_HealthChecks(t *testing.T) { defer func() { record(t, "health_checks/cleanup", func(c *Client) { c.DeleteHealthCheck(&DeleteHealthCheckInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-healthcheck", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "test-healthcheck", }) c.DeleteHealthCheck(&DeleteHealthCheckInput{ - Service: testServiceID, - Version: tv.Number, - Name: "new-test-healthcheck", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "new-test-healthcheck", }) }) }() @@ -89,8 +89,8 @@ func TestClient_HealthChecks(t *testing.T) { var hcs []*HealthCheck record(t, "health_checks/list", func(c *Client) { hcs, err = c.ListHealthChecks(&ListHealthChecksInput{ - Service: testServiceID, - Version: tv.Number, + ServiceID: testServiceID, + ServiceVersion: tv.Number, }) }) if err != nil { @@ -104,9 +104,9 @@ func TestClient_HealthChecks(t *testing.T) { var nhc *HealthCheck record(t, "health_checks/get", func(c *Client) { nhc, err = c.GetHealthCheck(&GetHealthCheckInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-healthcheck", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "test-healthcheck", }) }) if err != nil { @@ -150,10 +150,10 @@ func TestClient_HealthChecks(t *testing.T) { var uhc *HealthCheck record(t, "health_checks/update", func(c *Client) { uhc, err = c.UpdateHealthCheck(&UpdateHealthCheckInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-healthcheck", - NewName: "new-test-healthcheck", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "test-healthcheck", + NewName: "new-test-healthcheck", }) }) if err != nil { @@ -166,9 +166,9 @@ func TestClient_HealthChecks(t *testing.T) { // Delete record(t, "health_checks/delete", func(c *Client) { err = c.DeleteHealthCheck(&DeleteHealthCheckInput{ - Service: testServiceID, - Version: tv.Number, - Name: "new-test-healthcheck", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "new-test-healthcheck", }) }) if err != nil { @@ -179,17 +179,17 @@ func TestClient_HealthChecks(t *testing.T) { func TestClient_ListHealthChecks_validation(t *testing.T) { var err error _, err = testClient.ListHealthChecks(&ListHealthChecksInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.ListHealthChecks(&ListHealthChecksInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } } @@ -197,17 +197,17 @@ func TestClient_ListHealthChecks_validation(t *testing.T) { func TestClient_CreateHealthCheck_validation(t *testing.T) { var err error _, err = testClient.CreateHealthCheck(&CreateHealthCheckInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.CreateHealthCheck(&CreateHealthCheckInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } } @@ -215,24 +215,24 @@ func TestClient_CreateHealthCheck_validation(t *testing.T) { func TestClient_GetHealthCheck_validation(t *testing.T) { var err error _, err = testClient.GetHealthCheck(&GetHealthCheckInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.GetHealthCheck(&GetHealthCheckInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } _, err = testClient.GetHealthCheck(&GetHealthCheckInput{ - Service: "foo", - Version: 1, - Name: "", + ServiceID: "foo", + ServiceVersion: 1, + Name: "", }) if err != ErrMissingName { t.Errorf("bad error: %s", err) @@ -242,24 +242,24 @@ func TestClient_GetHealthCheck_validation(t *testing.T) { func TestClient_UpdateHealthCheck_validation(t *testing.T) { var err error _, err = testClient.UpdateHealthCheck(&UpdateHealthCheckInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.UpdateHealthCheck(&UpdateHealthCheckInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } _, err = testClient.UpdateHealthCheck(&UpdateHealthCheckInput{ - Service: "foo", - Version: 1, - Name: "", + ServiceID: "foo", + ServiceVersion: 1, + Name: "", }) if err != ErrMissingName { t.Errorf("bad error: %s", err) @@ -269,24 +269,24 @@ func TestClient_UpdateHealthCheck_validation(t *testing.T) { func TestClient_DeleteHealthCheck_validation(t *testing.T) { var err error err = testClient.DeleteHealthCheck(&DeleteHealthCheckInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } err = testClient.DeleteHealthCheck(&DeleteHealthCheckInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } err = testClient.DeleteHealthCheck(&DeleteHealthCheckInput{ - Service: "foo", - Version: 1, - Name: "", + ServiceID: "foo", + ServiceVersion: 1, + Name: "", }) if err != ErrMissingName { t.Errorf("bad error: %s", err) diff --git a/fastly/heroku.go b/fastly/heroku.go index cdb48e129..d78d5e7db 100644 --- a/fastly/heroku.go +++ b/fastly/heroku.go @@ -36,24 +36,24 @@ func (h herokusByName) Less(i, j int) bool { // ListHerokusInput is used as input to the ListHerokus function. type ListHerokusInput struct { - // Service is the ID of the service (required). - Service string + // ServiceID is the ID of the service (required). + ServiceID string - // Version is the specific configuration version (required). - Version int + // ServiceVersion is the specific configuration version (required). + ServiceVersion int } // ListHerokus returns the list of herokus for the configuration version. func (c *Client) ListHerokus(i *ListHerokusInput) ([]*Heroku, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/heroku", i.Service, i.Version) + path := fmt.Sprintf("/service/%s/version/%d/logging/heroku", i.ServiceID, i.ServiceVersion) resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -69,10 +69,11 @@ func (c *Client) ListHerokus(i *ListHerokusInput) ([]*Heroku, error) { // CreateHerokuInput is used as input to the CreateHeroku function. type CreateHerokuInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int Name *string `form:"name,omitempty"` Format *string `form:"format,omitempty"` @@ -85,15 +86,15 @@ type CreateHerokuInput struct { // CreateHeroku creates a new Fastly heroku. func (c *Client) CreateHeroku(i *CreateHerokuInput) (*Heroku, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/heroku", i.Service, i.Version) + path := fmt.Sprintf("/service/%s/version/%d/logging/heroku", i.ServiceID, i.ServiceVersion) resp, err := c.PostForm(path, i, nil) if err != nil { return nil, err @@ -108,10 +109,11 @@ func (c *Client) CreateHeroku(i *CreateHerokuInput) (*Heroku, error) { // GetHerokuInput is used as input to the GetHeroku function. type GetHerokuInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int // Name is the name of the heroku to fetch. Name string @@ -119,19 +121,19 @@ type GetHerokuInput struct { // GetHeroku gets the heroku configuration with the given parameters. func (c *Client) GetHeroku(i *GetHerokuInput) (*Heroku, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } if i.Name == "" { return nil, ErrMissingName } - path := fmt.Sprintf("/service/%s/version/%d/logging/heroku/%s", i.Service, i.Version, url.PathEscape(i.Name)) + path := fmt.Sprintf("/service/%s/version/%d/logging/heroku/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -146,10 +148,11 @@ func (c *Client) GetHeroku(i *GetHerokuInput) (*Heroku, error) { // UpdateHerokuInput is used as input to the UpdateHeroku function. type UpdateHerokuInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int // Name is the name of the heroku to update. Name string @@ -165,19 +168,19 @@ type UpdateHerokuInput struct { // UpdateHeroku updates a specific heroku. func (c *Client) UpdateHeroku(i *UpdateHerokuInput) (*Heroku, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } if i.Name == "" { return nil, ErrMissingName } - path := fmt.Sprintf("/service/%s/version/%d/logging/heroku/%s", i.Service, i.Version, url.PathEscape(i.Name)) + path := fmt.Sprintf("/service/%s/version/%d/logging/heroku/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) resp, err := c.PutForm(path, i, nil) if err != nil { return nil, err @@ -192,10 +195,11 @@ func (c *Client) UpdateHeroku(i *UpdateHerokuInput) (*Heroku, error) { // DeleteHerokuInput is the input parameter to DeleteHeroku. type DeleteHerokuInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int // Name is the name of the heroku to delete (required). Name string @@ -203,19 +207,19 @@ type DeleteHerokuInput struct { // DeleteHeroku deletes the given heroku version. func (c *Client) DeleteHeroku(i *DeleteHerokuInput) error { - if i.Service == "" { - return ErrMissingService + if i.ServiceID == "" { + return ErrMissingServiceID } - if i.Version == 0 { - return ErrMissingVersion + if i.ServiceVersion == 0 { + return ErrMissingServiceVersion } if i.Name == "" { return ErrMissingName } - path := fmt.Sprintf("/service/%s/version/%d/logging/heroku/%s", i.Service, i.Version, url.PathEscape(i.Name)) + path := fmt.Sprintf("/service/%s/version/%d/logging/heroku/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) resp, err := c.Delete(path, nil) if err != nil { return err diff --git a/fastly/heroku_test.go b/fastly/heroku_test.go index 929697f52..1f4a5290a 100644 --- a/fastly/heroku_test.go +++ b/fastly/heroku_test.go @@ -17,14 +17,14 @@ func TestClient_Herokus(t *testing.T) { var h *Heroku record(t, "herokus/create", func(c *Client) { h, err = c.CreateHeroku(&CreateHerokuInput{ - Service: testServiceID, - Version: tv.Number, - Name: String("test-heroku"), - Format: String("%h %l %u %t \"%r\" %>s %b"), - FormatVersion: Uint(2), - Placement: String("waf_debug"), - Token: String("super-secure-token"), - URL: String("https://1.us.logplex.io/logs"), + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: String("test-heroku"), + Format: String("%h %l %u %t \"%r\" %>s %b"), + FormatVersion: Uint(2), + Placement: String("waf_debug"), + Token: String("super-secure-token"), + URL: String("https://1.us.logplex.io/logs"), }) }) if err != nil { @@ -35,15 +35,15 @@ func TestClient_Herokus(t *testing.T) { defer func() { record(t, "herokus/cleanup", func(c *Client) { c.DeleteHeroku(&DeleteHerokuInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-heroku", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "test-heroku", }) c.DeleteHeroku(&DeleteHerokuInput{ - Service: testServiceID, - Version: tv.Number, - Name: "new-test-heroku", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "new-test-heroku", }) }) }() @@ -71,8 +71,8 @@ func TestClient_Herokus(t *testing.T) { var hs []*Heroku record(t, "herokus/list", func(c *Client) { hs, err = c.ListHerokus(&ListHerokusInput{ - Service: testServiceID, - Version: tv.Number, + ServiceID: testServiceID, + ServiceVersion: tv.Number, }) }) if err != nil { @@ -86,9 +86,9 @@ func TestClient_Herokus(t *testing.T) { var nh *Heroku record(t, "herokus/get", func(c *Client) { nh, err = c.GetHeroku(&GetHerokuInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-heroku", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "test-heroku", }) }) if err != nil { @@ -117,11 +117,11 @@ func TestClient_Herokus(t *testing.T) { var uh *Heroku record(t, "herokus/update", func(c *Client) { uh, err = c.UpdateHeroku(&UpdateHerokuInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-heroku", - NewName: String("new-test-heroku"), - Token: String("new-token"), + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "test-heroku", + NewName: String("new-test-heroku"), + Token: String("new-token"), }) }) if err != nil { @@ -137,9 +137,9 @@ func TestClient_Herokus(t *testing.T) { // Delete record(t, "herokus/delete", func(c *Client) { err = c.DeleteHeroku(&DeleteHerokuInput{ - Service: testServiceID, - Version: tv.Number, - Name: "new-test-heroku", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "new-test-heroku", }) }) if err != nil { @@ -150,17 +150,17 @@ func TestClient_Herokus(t *testing.T) { func TestClient_ListHerokus_validation(t *testing.T) { var err error _, err = testClient.ListHerokus(&ListHerokusInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.ListHerokus(&ListHerokusInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } } @@ -168,17 +168,17 @@ func TestClient_ListHerokus_validation(t *testing.T) { func TestClient_CreateHeroku_validation(t *testing.T) { var err error _, err = testClient.CreateHeroku(&CreateHerokuInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.CreateHeroku(&CreateHerokuInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } } @@ -186,24 +186,24 @@ func TestClient_CreateHeroku_validation(t *testing.T) { func TestClient_GetHeroku_validation(t *testing.T) { var err error _, err = testClient.GetHeroku(&GetHerokuInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.GetHeroku(&GetHerokuInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } _, err = testClient.GetHeroku(&GetHerokuInput{ - Service: "foo", - Version: 1, - Name: "", + ServiceID: "foo", + ServiceVersion: 1, + Name: "", }) if err != ErrMissingName { t.Errorf("bad error: %s", err) @@ -213,24 +213,24 @@ func TestClient_GetHeroku_validation(t *testing.T) { func TestClient_UpdateHeroku_validation(t *testing.T) { var err error _, err = testClient.UpdateHeroku(&UpdateHerokuInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.UpdateHeroku(&UpdateHerokuInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } _, err = testClient.UpdateHeroku(&UpdateHerokuInput{ - Service: "foo", - Version: 1, - Name: "", + ServiceID: "foo", + ServiceVersion: 1, + Name: "", }) if err != ErrMissingName { t.Errorf("bad error: %s", err) @@ -240,24 +240,24 @@ func TestClient_UpdateHeroku_validation(t *testing.T) { func TestClient_DeleteHeroku_validation(t *testing.T) { var err error err = testClient.DeleteHeroku(&DeleteHerokuInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } err = testClient.DeleteHeroku(&DeleteHerokuInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } err = testClient.DeleteHeroku(&DeleteHerokuInput{ - Service: "foo", - Version: 1, - Name: "", + ServiceID: "foo", + ServiceVersion: 1, + Name: "", }) if err != ErrMissingName { t.Errorf("bad error: %s", err) diff --git a/fastly/honeycomb.go b/fastly/honeycomb.go index 0535a37f1..16ac26c79 100644 --- a/fastly/honeycomb.go +++ b/fastly/honeycomb.go @@ -36,24 +36,24 @@ func (h honeycombsByName) Less(i, j int) bool { // ListHoneycombsInput is used as input to the ListHoneycombs function. type ListHoneycombsInput struct { - // Service is the ID of the service (required). - Service string + // ServiceID is the ID of the service (required). + ServiceID string - // Version is the specific configuration version (required). - Version int + // ServiceVersion is the specific configuration version (required). + ServiceVersion int } // ListHoneycombs returns the list of honeycombs for the configuration version. func (c *Client) ListHoneycombs(i *ListHoneycombsInput) ([]*Honeycomb, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/honeycomb", i.Service, i.Version) + path := fmt.Sprintf("/service/%s/version/%d/logging/honeycomb", i.ServiceID, i.ServiceVersion) resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -69,10 +69,11 @@ func (c *Client) ListHoneycombs(i *ListHoneycombsInput) ([]*Honeycomb, error) { // CreateHoneycombInput is used as input to the CreateHoneycomb function. type CreateHoneycombInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int Name *string `form:"name,omitempty"` Format *string `form:"format,omitempty"` @@ -85,15 +86,15 @@ type CreateHoneycombInput struct { // CreateHoneycomb creates a new Fastly honeycomb. func (c *Client) CreateHoneycomb(i *CreateHoneycombInput) (*Honeycomb, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/honeycomb", i.Service, i.Version) + path := fmt.Sprintf("/service/%s/version/%d/logging/honeycomb", i.ServiceID, i.ServiceVersion) resp, err := c.PostForm(path, i, nil) if err != nil { return nil, err @@ -108,10 +109,11 @@ func (c *Client) CreateHoneycomb(i *CreateHoneycombInput) (*Honeycomb, error) { // GetHoneycombInput is used as input to the GetHoneycomb function. type GetHoneycombInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int // Name is the name of the honeycomb to fetch. Name string @@ -119,19 +121,19 @@ type GetHoneycombInput struct { // GetHoneycomb gets the honeycomb configuration with the given parameters. func (c *Client) GetHoneycomb(i *GetHoneycombInput) (*Honeycomb, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } if i.Name == "" { return nil, ErrMissingName } - path := fmt.Sprintf("/service/%s/version/%d/logging/honeycomb/%s", i.Service, i.Version, url.PathEscape(i.Name)) + path := fmt.Sprintf("/service/%s/version/%d/logging/honeycomb/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -146,10 +148,11 @@ func (c *Client) GetHoneycomb(i *GetHoneycombInput) (*Honeycomb, error) { // UpdateHoneycombInput is used as input to the UpdateHoneycomb function. type UpdateHoneycombInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int // Name is the name of the honeycomb to update. Name string @@ -165,19 +168,19 @@ type UpdateHoneycombInput struct { // UpdateHoneycomb updates a specific honeycomb. func (c *Client) UpdateHoneycomb(i *UpdateHoneycombInput) (*Honeycomb, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } if i.Name == "" { return nil, ErrMissingName } - path := fmt.Sprintf("/service/%s/version/%d/logging/honeycomb/%s", i.Service, i.Version, url.PathEscape(i.Name)) + path := fmt.Sprintf("/service/%s/version/%d/logging/honeycomb/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) resp, err := c.PutForm(path, i, nil) if err != nil { return nil, err @@ -192,10 +195,11 @@ func (c *Client) UpdateHoneycomb(i *UpdateHoneycombInput) (*Honeycomb, error) { // DeleteHoneycombInput is the input parameter to DeleteHoneycomb. type DeleteHoneycombInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int // Name is the name of the honeycomb to delete (required). Name string @@ -203,19 +207,19 @@ type DeleteHoneycombInput struct { // DeleteHoneycomb deletes the given honeycomb version. func (c *Client) DeleteHoneycomb(i *DeleteHoneycombInput) error { - if i.Service == "" { - return ErrMissingService + if i.ServiceID == "" { + return ErrMissingServiceID } - if i.Version == 0 { - return ErrMissingVersion + if i.ServiceVersion == 0 { + return ErrMissingServiceVersion } if i.Name == "" { return ErrMissingName } - path := fmt.Sprintf("/service/%s/version/%d/logging/honeycomb/%s", i.Service, i.Version, url.PathEscape(i.Name)) + path := fmt.Sprintf("/service/%s/version/%d/logging/honeycomb/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) resp, err := c.Delete(path, nil) if err != nil { return err diff --git a/fastly/honeycomb_test.go b/fastly/honeycomb_test.go index 25432f84e..7df0f7258 100644 --- a/fastly/honeycomb_test.go +++ b/fastly/honeycomb_test.go @@ -17,14 +17,14 @@ func TestClient_Honeycombs(t *testing.T) { var h *Honeycomb record(t, "honeycombs/create", func(c *Client) { h, err = c.CreateHoneycomb(&CreateHoneycombInput{ - Service: testServiceID, - Version: tv.Number, - Name: String("test-honeycomb"), - Format: String("%h %l %u %t \"%r\" %>s %b"), - FormatVersion: Uint(2), - Placement: String("waf_debug"), - Token: String("super-secure-token"), - Dataset: String("testDataset"), + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: String("test-honeycomb"), + Format: String("%h %l %u %t \"%r\" %>s %b"), + FormatVersion: Uint(2), + Placement: String("waf_debug"), + Token: String("super-secure-token"), + Dataset: String("testDataset"), }) }) if err != nil { @@ -35,15 +35,15 @@ func TestClient_Honeycombs(t *testing.T) { defer func() { record(t, "honeycombs/cleanup", func(c *Client) { c.DeleteHoneycomb(&DeleteHoneycombInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-honeycomb", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "test-honeycomb", }) c.DeleteHoneycomb(&DeleteHoneycombInput{ - Service: testServiceID, - Version: tv.Number, - Name: "new-test-honeycomb", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "new-test-honeycomb", }) }) }() @@ -71,8 +71,8 @@ func TestClient_Honeycombs(t *testing.T) { var hs []*Honeycomb record(t, "honeycombs/list", func(c *Client) { hs, err = c.ListHoneycombs(&ListHoneycombsInput{ - Service: testServiceID, - Version: tv.Number, + ServiceID: testServiceID, + ServiceVersion: tv.Number, }) }) if err != nil { @@ -86,9 +86,9 @@ func TestClient_Honeycombs(t *testing.T) { var nh *Honeycomb record(t, "honeycombs/get", func(c *Client) { nh, err = c.GetHoneycomb(&GetHoneycombInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-honeycomb", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "test-honeycomb", }) }) if err != nil { @@ -117,12 +117,12 @@ func TestClient_Honeycombs(t *testing.T) { var us *Honeycomb record(t, "honeycombs/update", func(c *Client) { us, err = c.UpdateHoneycomb(&UpdateHoneycombInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-honeycomb", - NewName: String("new-test-honeycomb"), - Token: String("new-token"), - Dataset: String("newDataset"), + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "test-honeycomb", + NewName: String("new-test-honeycomb"), + Token: String("new-token"), + Dataset: String("newDataset"), }) }) if err != nil { @@ -141,9 +141,9 @@ func TestClient_Honeycombs(t *testing.T) { // Delete record(t, "honeycombs/delete", func(c *Client) { err = c.DeleteHoneycomb(&DeleteHoneycombInput{ - Service: testServiceID, - Version: tv.Number, - Name: "new-test-honeycomb", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "new-test-honeycomb", }) }) if err != nil { @@ -154,17 +154,17 @@ func TestClient_Honeycombs(t *testing.T) { func TestClient_ListHoneycombs_validation(t *testing.T) { var err error _, err = testClient.ListHoneycombs(&ListHoneycombsInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.ListHoneycombs(&ListHoneycombsInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } } @@ -172,17 +172,17 @@ func TestClient_ListHoneycombs_validation(t *testing.T) { func TestClient_CreateHoneycomb_validation(t *testing.T) { var err error _, err = testClient.CreateHoneycomb(&CreateHoneycombInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.CreateHoneycomb(&CreateHoneycombInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } } @@ -190,24 +190,24 @@ func TestClient_CreateHoneycomb_validation(t *testing.T) { func TestClient_GetHoneycomb_validation(t *testing.T) { var err error _, err = testClient.GetHoneycomb(&GetHoneycombInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.GetHoneycomb(&GetHoneycombInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } _, err = testClient.GetHoneycomb(&GetHoneycombInput{ - Service: "foo", - Version: 1, - Name: "", + ServiceID: "foo", + ServiceVersion: 1, + Name: "", }) if err != ErrMissingName { t.Errorf("bad error: %s", err) @@ -217,24 +217,24 @@ func TestClient_GetHoneycomb_validation(t *testing.T) { func TestClient_UpdateHoneycomb_validation(t *testing.T) { var err error _, err = testClient.UpdateHoneycomb(&UpdateHoneycombInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.UpdateHoneycomb(&UpdateHoneycombInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } _, err = testClient.UpdateHoneycomb(&UpdateHoneycombInput{ - Service: "foo", - Version: 1, - Name: "", + ServiceID: "foo", + ServiceVersion: 1, + Name: "", }) if err != ErrMissingName { t.Errorf("bad error: %s", err) @@ -244,24 +244,24 @@ func TestClient_UpdateHoneycomb_validation(t *testing.T) { func TestClient_DeleteHoneycomb_validation(t *testing.T) { var err error err = testClient.DeleteHoneycomb(&DeleteHoneycombInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } err = testClient.DeleteHoneycomb(&DeleteHoneycombInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } err = testClient.DeleteHoneycomb(&DeleteHoneycombInput{ - Service: "foo", - Version: 1, - Name: "", + ServiceID: "foo", + ServiceVersion: 1, + Name: "", }) if err != ErrMissingName { t.Errorf("bad error: %s", err) diff --git a/fastly/https.go b/fastly/https.go index 1b32d7fa9..c721f9196 100644 --- a/fastly/https.go +++ b/fastly/https.go @@ -47,24 +47,24 @@ func (s httpsByName) Less(i, j int) bool { // ListHTTPSInput is used as input to the ListHTTPS function. type ListHTTPSInput struct { - // Service is the ID of the service (required). - Service string + // ServiceID is the ID of the service (required). + ServiceID string - // Version is the specific configuration version (required). - Version int + // ServiceVersion is the specific configuration version (required). + ServiceVersion int } // ListHTTPS returns the list of HTTPS logs for the configuration version. func (c *Client) ListHTTPS(i *ListHTTPSInput) ([]*HTTPS, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/https", i.Service, i.Version) + path := fmt.Sprintf("/service/%s/version/%d/logging/https", i.ServiceID, i.ServiceVersion) resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -80,10 +80,11 @@ func (c *Client) ListHTTPS(i *ListHTTPSInput) ([]*HTTPS, error) { // CreateHTTPSInput is used as input to the CreateHTTPS function. type CreateHTTPSInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int Name string `form:"name,omitempty"` ResponseCondition string `form:"response_condition,omitempty"` @@ -107,15 +108,15 @@ type CreateHTTPSInput struct { // CreateHTTPS creates a new Fastly HTTPS logging endpoint. func (c *Client) CreateHTTPS(i *CreateHTTPSInput) (*HTTPS, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/https", i.Service, i.Version) + path := fmt.Sprintf("/service/%s/version/%d/logging/https", i.ServiceID, i.ServiceVersion) resp, err := c.PostForm(path, i, nil) if err != nil { return nil, err @@ -130,29 +131,30 @@ func (c *Client) CreateHTTPS(i *CreateHTTPSInput) (*HTTPS, error) { // GetHTTPSInput is used as input to the GetHTTPS function. type GetHTTPSInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int // Name is the name of the HTTPS endpoint to fetch. Name string } func (c *Client) GetHTTPS(i *GetHTTPSInput) (*HTTPS, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } if i.Name == "" { return nil, ErrMissingName } - path := fmt.Sprintf("/service/%s/version/%d/logging/https/%s", i.Service, i.Version, url.PathEscape(i.Name)) + path := fmt.Sprintf("/service/%s/version/%d/logging/https/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -167,10 +169,11 @@ func (c *Client) GetHTTPS(i *GetHTTPSInput) (*HTTPS, error) { } type UpdateHTTPSInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int // Name is the name of the HTTPS endpoint to fetch. Name string @@ -196,19 +199,19 @@ type UpdateHTTPSInput struct { } func (c *Client) UpdateHTTPS(i *UpdateHTTPSInput) (*HTTPS, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } if i.Name == "" { return nil, ErrMissingName } - path := fmt.Sprintf("/service/%s/version/%d/logging/https/%s", i.Service, i.Version, url.PathEscape(i.Name)) + path := fmt.Sprintf("/service/%s/version/%d/logging/https/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) resp, err := c.PutForm(path, i, nil) if err != nil { return nil, err @@ -222,29 +225,30 @@ func (c *Client) UpdateHTTPS(i *UpdateHTTPSInput) (*HTTPS, error) { } type DeleteHTTPSInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int // Name is the name of the HTTPS endpoint to fetch. Name string } func (c *Client) DeleteHTTPS(i *DeleteHTTPSInput) error { - if i.Service == "" { - return ErrMissingService + if i.ServiceID == "" { + return ErrMissingServiceID } - if i.Version == 0 { - return ErrMissingVersion + if i.ServiceVersion == 0 { + return ErrMissingServiceVersion } if i.Name == "" { return ErrMissingName } - path := fmt.Sprintf("/service/%s/version/%d/logging/https/%s", i.Service, i.Version, url.PathEscape(i.Name)) + path := fmt.Sprintf("/service/%s/version/%d/logging/https/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) resp, err := c.Delete(path, nil) if err != nil { return err diff --git a/fastly/https_test.go b/fastly/https_test.go index 05b7589aa..67e202e23 100644 --- a/fastly/https_test.go +++ b/fastly/https_test.go @@ -38,8 +38,8 @@ Wm7DCfrPNGVwFWUQOmsPue9rZBgO var h *HTTPS record(t, "https/create", func(c *Client) { h, err = c.CreateHTTPS(&CreateHTTPSInput{ - Service: testServiceID, - Version: tv.Number, + ServiceID: testServiceID, + ServiceVersion: tv.Number, Name: "test-https", Format: "format", URL: "https://example.com/", @@ -67,16 +67,16 @@ Wm7DCfrPNGVwFWUQOmsPue9rZBgO defer func() { record(t, "https/cleanup", func(c *Client) { c.DeleteHTTPS(&DeleteHTTPSInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-https", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "test-https", }) // ensure that renamed endpoint created in Update test is deleted c.DeleteHTTPS(&DeleteHTTPSInput{ - Service: testServiceID, - Version: tv.Number, - Name: "new-test-https", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "new-test-https", }) }) }() @@ -137,8 +137,8 @@ Wm7DCfrPNGVwFWUQOmsPue9rZBgO var hs []*HTTPS record(t, "https/list", func(c *Client) { hs, err = c.ListHTTPS(&ListHTTPSInput{ - Service: testServiceID, - Version: tv.Number, + ServiceID: testServiceID, + ServiceVersion: tv.Number, }) }) if err != nil { @@ -152,9 +152,9 @@ Wm7DCfrPNGVwFWUQOmsPue9rZBgO var nh *HTTPS record(t, "https/get", func(c *Client) { nh, err = c.GetHTTPS(&GetHTTPSInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-https", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "test-https", }) }) if err != nil { @@ -216,11 +216,11 @@ Wm7DCfrPNGVwFWUQOmsPue9rZBgO var uh *HTTPS record(t, "https/update", func(c *Client) { uh, err = c.UpdateHTTPS(&UpdateHTTPSInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-https", - NewName: "new-test-https", - Method: "POST", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "test-https", + NewName: "new-test-https", + Method: "POST", }) }) if err != nil { @@ -236,9 +236,9 @@ Wm7DCfrPNGVwFWUQOmsPue9rZBgO // Delete record(t, "https/delete", func(c *Client) { err = c.DeleteHTTPS(&DeleteHTTPSInput{ - Service: testServiceID, - Version: tv.Number, - Name: "new-test-https", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "new-test-https", }) }) if err != nil { @@ -249,9 +249,9 @@ Wm7DCfrPNGVwFWUQOmsPue9rZBgO func TestClient_ListHTTPS_validation(t *testing.T) { var err error _, err = testClient.ListHTTPS(&ListHTTPSInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } } @@ -259,17 +259,17 @@ func TestClient_ListHTTPS_validation(t *testing.T) { func TestClient_CreateHTTPS_validation(t *testing.T) { var err error _, err = testClient.CreateHTTPS(&CreateHTTPSInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.CreateHTTPS(&CreateHTTPSInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } } @@ -277,24 +277,24 @@ func TestClient_CreateHTTPS_validation(t *testing.T) { func TestClient_GetHTTPS_validation(t *testing.T) { var err error _, err = testClient.GetHTTPS(&GetHTTPSInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.GetHTTPS(&GetHTTPSInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } _, err = testClient.GetHTTPS(&GetHTTPSInput{ - Service: "foo", - Version: 1, - Name: "", + ServiceID: "foo", + ServiceVersion: 1, + Name: "", }) if err != ErrMissingName { t.Errorf("bad error: %s", err) @@ -304,24 +304,24 @@ func TestClient_GetHTTPS_validation(t *testing.T) { func TestClient_UpdateHTTPS_validation(t *testing.T) { var err error _, err = testClient.UpdateHTTPS(&UpdateHTTPSInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.UpdateHTTPS(&UpdateHTTPSInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } _, err = testClient.UpdateHTTPS(&UpdateHTTPSInput{ - Service: "foo", - Version: 1, - Name: "", + ServiceID: "foo", + ServiceVersion: 1, + Name: "", }) if err != ErrMissingName { t.Errorf("bad error: %s", err) @@ -331,24 +331,24 @@ func TestClient_UpdateHTTPS_validation(t *testing.T) { func TestClient_DeleteHTTPS_validation(t *testing.T) { var err error err = testClient.DeleteHTTPS(&DeleteHTTPSInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } err = testClient.DeleteHTTPS(&DeleteHTTPSInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } err = testClient.DeleteHTTPS(&DeleteHTTPSInput{ - Service: "foo", - Version: 1, - Name: "", + ServiceID: "foo", + ServiceVersion: 1, + Name: "", }) if err != ErrMissingName { t.Errorf("bad error: %s", err) diff --git a/fastly/kafka.go b/fastly/kafka.go index 87500067e..b5df581f6 100644 --- a/fastly/kafka.go +++ b/fastly/kafka.go @@ -48,24 +48,24 @@ func (s kafkasByName) Less(i, j int) bool { // ListKafkasInput is used as input to the ListKafkas function. type ListKafkasInput struct { - // Service is the ID of the service (required). - Service string + // ServiceID is the ID of the service (required). + ServiceID string - // Version is the specific configuration version (required). - Version int + // ServiceVersion is the specific configuration version (required). + ServiceVersion int } // ListKafkas returns the list of kafkas for the configuration version. func (c *Client) ListKafkas(i *ListKafkasInput) ([]*Kafka, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/kafka", i.Service, i.Version) + path := fmt.Sprintf("/service/%s/version/%d/logging/kafka", i.ServiceID, i.ServiceVersion) resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -81,10 +81,11 @@ func (c *Client) ListKafkas(i *ListKafkasInput) ([]*Kafka, error) { // CreateKafkaInput is used as input to the CreateKafka function. type CreateKafkaInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int Name *string `form:"name,omitempty"` Brokers *string `form:"brokers,omitempty"` @@ -109,15 +110,15 @@ type CreateKafkaInput struct { // CreateKafka creates a new Fastly kafka. func (c *Client) CreateKafka(i *CreateKafkaInput) (*Kafka, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/kafka", i.Service, i.Version) + path := fmt.Sprintf("/service/%s/version/%d/logging/kafka", i.ServiceID, i.ServiceVersion) resp, err := c.PostForm(path, i, nil) if err != nil { return nil, err @@ -132,10 +133,11 @@ func (c *Client) CreateKafka(i *CreateKafkaInput) (*Kafka, error) { // GetKafkaInput is used as input to the GetKafka function. type GetKafkaInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int // Name is the name of the kafka to fetch. Name string @@ -143,19 +145,19 @@ type GetKafkaInput struct { // GetKafka gets the kafka configuration with the given parameters. func (c *Client) GetKafka(i *GetKafkaInput) (*Kafka, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } if i.Name == "" { return nil, ErrMissingName } - path := fmt.Sprintf("/service/%s/version/%d/logging/kafka/%s", i.Service, i.Version, url.PathEscape(i.Name)) + path := fmt.Sprintf("/service/%s/version/%d/logging/kafka/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -170,10 +172,11 @@ func (c *Client) GetKafka(i *GetKafkaInput) (*Kafka, error) { // UpdateKafkaInput is used as input to the UpdateKafka function. type UpdateKafkaInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int // Name is the name of the kafka to update. Name string @@ -201,19 +204,19 @@ type UpdateKafkaInput struct { // UpdateKafka updates a specific kafka. func (c *Client) UpdateKafka(i *UpdateKafkaInput) (*Kafka, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } if i.Name == "" { return nil, ErrMissingName } - path := fmt.Sprintf("/service/%s/version/%d/logging/kafka/%s", i.Service, i.Version, url.PathEscape(i.Name)) + path := fmt.Sprintf("/service/%s/version/%d/logging/kafka/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) resp, err := c.PutForm(path, i, nil) if err != nil { return nil, err @@ -228,10 +231,11 @@ func (c *Client) UpdateKafka(i *UpdateKafkaInput) (*Kafka, error) { // DeleteKafkaInput is the input parameter to DeleteKafka. type DeleteKafkaInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int // Name is the name of the kafka to delete (required). Name string @@ -239,19 +243,19 @@ type DeleteKafkaInput struct { // DeleteKafka deletes the given kafka version. func (c *Client) DeleteKafka(i *DeleteKafkaInput) error { - if i.Service == "" { - return ErrMissingService + if i.ServiceID == "" { + return ErrMissingServiceID } - if i.Version == 0 { - return ErrMissingVersion + if i.ServiceVersion == 0 { + return ErrMissingServiceVersion } if i.Name == "" { return ErrMissingName } - path := fmt.Sprintf("/service/%s/version/%d/logging/kafka/%s", i.Service, i.Version, url.PathEscape(i.Name)) + path := fmt.Sprintf("/service/%s/version/%d/logging/kafka/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) resp, err := c.Delete(path, nil) if err != nil { return err diff --git a/fastly/kafka_test.go b/fastly/kafka_test.go index a911b3477..4d81d07d2 100644 --- a/fastly/kafka_test.go +++ b/fastly/kafka_test.go @@ -22,8 +22,8 @@ func TestClient_Kafkas(t *testing.T) { var k *Kafka record(t, "kafkas/create", func(c *Client) { k, err = c.CreateKafka(&CreateKafkaInput{ - Service: testServiceID, - Version: tv.Number, + ServiceID: testServiceID, + ServiceVersion: tv.Number, Name: String("test-kafka"), Brokers: String("192.168.1.1,192.168.1.2"), Topic: String("kafka-topic"), @@ -52,15 +52,15 @@ func TestClient_Kafkas(t *testing.T) { defer func() { record(t, "kafkas/cleanup", func(c *Client) { c.DeleteKafka(&DeleteKafkaInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-kafka", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "test-kafka", }) c.DeleteKafka(&DeleteKafkaInput{ - Service: testServiceID, - Version: tv.Number, - Name: "new-test-kafka", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "new-test-kafka", }) }) }() @@ -124,8 +124,8 @@ func TestClient_Kafkas(t *testing.T) { var ks []*Kafka record(t, "kafkas/list", func(c *Client) { ks, err = c.ListKafkas(&ListKafkasInput{ - Service: testServiceID, - Version: tv.Number, + ServiceID: testServiceID, + ServiceVersion: tv.Number, }) }) if err != nil { @@ -139,9 +139,9 @@ func TestClient_Kafkas(t *testing.T) { var nk *Kafka record(t, "kafkas/get", func(c *Client) { nk, err = c.GetKafka(&GetKafkaInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-kafka", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "test-kafka", }) }) if err != nil { @@ -206,11 +206,11 @@ func TestClient_Kafkas(t *testing.T) { var uk *Kafka record(t, "kafkas/update", func(c *Client) { uk, err = c.UpdateKafka(&UpdateKafkaInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-kafka", - NewName: String("new-test-kafka"), - Topic: String("new-kafka-topic"), + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "test-kafka", + NewName: String("new-test-kafka"), + Topic: String("new-kafka-topic"), }) }) if err != nil { @@ -226,9 +226,9 @@ func TestClient_Kafkas(t *testing.T) { // Delete record(t, "kafkas/delete", func(c *Client) { err = c.DeleteKafka(&DeleteKafkaInput{ - Service: testServiceID, - Version: tv.Number, - Name: "new-test-kafka", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "new-test-kafka", }) }) if err != nil { @@ -239,17 +239,17 @@ func TestClient_Kafkas(t *testing.T) { func TestClient_ListKafkas_validation(t *testing.T) { var err error _, err = testClient.ListKafkas(&ListKafkasInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.ListKafkas(&ListKafkasInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } } @@ -257,17 +257,17 @@ func TestClient_ListKafkas_validation(t *testing.T) { func TestClient_CreateKafka_validation(t *testing.T) { var err error _, err = testClient.CreateKafka(&CreateKafkaInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.CreateKafka(&CreateKafkaInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } } @@ -275,24 +275,24 @@ func TestClient_CreateKafka_validation(t *testing.T) { func TestClient_GetKafka_validation(t *testing.T) { var err error _, err = testClient.GetKafka(&GetKafkaInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.GetKafka(&GetKafkaInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } _, err = testClient.GetKafka(&GetKafkaInput{ - Service: "foo", - Version: 1, - Name: "", + ServiceID: "foo", + ServiceVersion: 1, + Name: "", }) if err != ErrMissingName { t.Errorf("bad error: %s", err) @@ -302,24 +302,24 @@ func TestClient_GetKafka_validation(t *testing.T) { func TestClient_UpdateKafka_validation(t *testing.T) { var err error _, err = testClient.UpdateKafka(&UpdateKafkaInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.UpdateKafka(&UpdateKafkaInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } _, err = testClient.UpdateKafka(&UpdateKafkaInput{ - Service: "foo", - Version: 1, - Name: "", + ServiceID: "foo", + ServiceVersion: 1, + Name: "", }) if err != ErrMissingName { t.Errorf("bad error: %s", err) @@ -329,24 +329,24 @@ func TestClient_UpdateKafka_validation(t *testing.T) { func TestClient_DeleteKafka_validation(t *testing.T) { var err error err = testClient.DeleteKafka(&DeleteKafkaInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } err = testClient.DeleteKafka(&DeleteKafkaInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } err = testClient.DeleteKafka(&DeleteKafkaInput{ - Service: "foo", - Version: 1, - Name: "", + ServiceID: "foo", + ServiceVersion: 1, + Name: "", }) if err != ErrMissingName { t.Errorf("bad error: %s", err) diff --git a/fastly/logentries.go b/fastly/logentries.go index c6761321d..b0d497424 100644 --- a/fastly/logentries.go +++ b/fastly/logentries.go @@ -37,24 +37,24 @@ func (s logentriesByName) Less(i, j int) bool { // ListLogentriesInput is used as input to the ListLogentries function. type ListLogentriesInput struct { - // Service is the ID of the service (required). - Service string + // ServiceID is the ID of the service (required). + ServiceID string - // Version is the specific configuration version (required). - Version int + // ServiceVersion is the specific configuration version (required). + ServiceVersion int } // ListLogentries returns the list of logentries for the configuration version. func (c *Client) ListLogentries(i *ListLogentriesInput) ([]*Logentries, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/logentries", i.Service, i.Version) + path := fmt.Sprintf("/service/%s/version/%d/logging/logentries", i.ServiceID, i.ServiceVersion) resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -70,10 +70,11 @@ func (c *Client) ListLogentries(i *ListLogentriesInput) ([]*Logentries, error) { // CreateLogentriesInput is used as input to the CreateLogentries function. type CreateLogentriesInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int Name string `form:"name,omitempty"` Port uint `form:"port,omitempty"` @@ -87,15 +88,15 @@ type CreateLogentriesInput struct { // CreateLogentries creates a new Fastly logentries. func (c *Client) CreateLogentries(i *CreateLogentriesInput) (*Logentries, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/logentries", i.Service, i.Version) + path := fmt.Sprintf("/service/%s/version/%d/logging/logentries", i.ServiceID, i.ServiceVersion) resp, err := c.PostForm(path, i, nil) if err != nil { return nil, err @@ -110,10 +111,11 @@ func (c *Client) CreateLogentries(i *CreateLogentriesInput) (*Logentries, error) // GetLogentriesInput is used as input to the GetLogentries function. type GetLogentriesInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int // Name is the name of the logentries to fetch. Name string @@ -121,19 +123,19 @@ type GetLogentriesInput struct { // GetLogentries gets the logentries configuration with the given parameters. func (c *Client) GetLogentries(i *GetLogentriesInput) (*Logentries, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } if i.Name == "" { return nil, ErrMissingName } - path := fmt.Sprintf("/service/%s/version/%d/logging/logentries/%s", i.Service, i.Version, url.PathEscape(i.Name)) + path := fmt.Sprintf("/service/%s/version/%d/logging/logentries/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -148,10 +150,11 @@ func (c *Client) GetLogentries(i *GetLogentriesInput) (*Logentries, error) { // UpdateLogentriesInput is used as input to the UpdateLogentries function. type UpdateLogentriesInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int // Name is the name of the logentries to update. Name string @@ -168,19 +171,19 @@ type UpdateLogentriesInput struct { // UpdateLogentries updates a specific logentries. func (c *Client) UpdateLogentries(i *UpdateLogentriesInput) (*Logentries, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } if i.Name == "" { return nil, ErrMissingName } - path := fmt.Sprintf("/service/%s/version/%d/logging/logentries/%s", i.Service, i.Version, url.PathEscape(i.Name)) + path := fmt.Sprintf("/service/%s/version/%d/logging/logentries/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) resp, err := c.PutForm(path, i, nil) if err != nil { return nil, err @@ -195,10 +198,11 @@ func (c *Client) UpdateLogentries(i *UpdateLogentriesInput) (*Logentries, error) // DeleteLogentriesInput is the input parameter to DeleteLogentries. type DeleteLogentriesInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int // Name is the name of the logentries to delete (required). Name string @@ -206,19 +210,19 @@ type DeleteLogentriesInput struct { // DeleteLogentries deletes the given logentries version. func (c *Client) DeleteLogentries(i *DeleteLogentriesInput) error { - if i.Service == "" { - return ErrMissingService + if i.ServiceID == "" { + return ErrMissingServiceID } - if i.Version == 0 { - return ErrMissingVersion + if i.ServiceVersion == 0 { + return ErrMissingServiceVersion } if i.Name == "" { return ErrMissingName } - path := fmt.Sprintf("/service/%s/version/%d/logging/logentries/%s", i.Service, i.Version, url.PathEscape(i.Name)) + path := fmt.Sprintf("/service/%s/version/%d/logging/logentries/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) resp, err := c.Delete(path, nil) if err != nil { return err diff --git a/fastly/logentries_test.go b/fastly/logentries_test.go index bb19209bf..57cb0a0c8 100644 --- a/fastly/logentries_test.go +++ b/fastly/logentries_test.go @@ -15,14 +15,14 @@ func TestClient_Logentries(t *testing.T) { var le *Logentries record(t, "logentries/create", func(c *Client) { le, err = c.CreateLogentries(&CreateLogentriesInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-logentries", - Port: 1234, - UseTLS: CBool(true), - Token: "abcd1234", - Format: "format", - Placement: "waf_debug", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "test-logentries", + Port: 1234, + UseTLS: CBool(true), + Token: "abcd1234", + Format: "format", + Placement: "waf_debug", }) }) if err != nil { @@ -33,15 +33,15 @@ func TestClient_Logentries(t *testing.T) { defer func() { record(t, "logentries/delete", func(c *Client) { c.DeleteLogentries(&DeleteLogentriesInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-logentries", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "test-logentries", }) c.DeleteLogentries(&DeleteLogentriesInput{ - Service: testServiceID, - Version: tv.Number, - Name: "new-test-logentries", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "new-test-logentries", }) }) }() @@ -72,8 +72,8 @@ func TestClient_Logentries(t *testing.T) { var les []*Logentries record(t, "logentries/list", func(c *Client) { les, err = c.ListLogentries(&ListLogentriesInput{ - Service: testServiceID, - Version: tv.Number, + ServiceID: testServiceID, + ServiceVersion: tv.Number, }) }) if err != nil { @@ -87,9 +87,9 @@ func TestClient_Logentries(t *testing.T) { var nle *Logentries record(t, "logentries/get", func(c *Client) { nle, err = c.GetLogentries(&GetLogentriesInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-logentries", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "test-logentries", }) }) if err != nil { @@ -121,11 +121,11 @@ func TestClient_Logentries(t *testing.T) { var ule *Logentries record(t, "logentries/update", func(c *Client) { ule, err = c.UpdateLogentries(&UpdateLogentriesInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-logentries", - NewName: "new-test-logentries", - FormatVersion: 2, + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "test-logentries", + NewName: "new-test-logentries", + FormatVersion: 2, }) }) if err != nil { @@ -141,9 +141,9 @@ func TestClient_Logentries(t *testing.T) { // Delete record(t, "logentries/delete", func(c *Client) { err = c.DeleteLogentries(&DeleteLogentriesInput{ - Service: testServiceID, - Version: tv.Number, - Name: "new-test-logentries", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "new-test-logentries", }) }) if err != nil { @@ -154,17 +154,17 @@ func TestClient_Logentries(t *testing.T) { func TestClient_ListLogentries_validation(t *testing.T) { var err error _, err = testClient.ListLogentries(&ListLogentriesInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.ListLogentries(&ListLogentriesInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } } @@ -172,17 +172,17 @@ func TestClient_ListLogentries_validation(t *testing.T) { func TestClient_CreateLogentries_validation(t *testing.T) { var err error _, err = testClient.CreateLogentries(&CreateLogentriesInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.CreateLogentries(&CreateLogentriesInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } } @@ -190,24 +190,24 @@ func TestClient_CreateLogentries_validation(t *testing.T) { func TestClient_GetLogentries_validation(t *testing.T) { var err error _, err = testClient.GetLogentries(&GetLogentriesInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.GetLogentries(&GetLogentriesInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } _, err = testClient.GetLogentries(&GetLogentriesInput{ - Service: "foo", - Version: 1, - Name: "", + ServiceID: "foo", + ServiceVersion: 1, + Name: "", }) if err != ErrMissingName { t.Errorf("bad error: %s", err) @@ -217,24 +217,24 @@ func TestClient_GetLogentries_validation(t *testing.T) { func TestClient_UpdateLogentries_validation(t *testing.T) { var err error _, err = testClient.UpdateLogentries(&UpdateLogentriesInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.UpdateLogentries(&UpdateLogentriesInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } _, err = testClient.UpdateLogentries(&UpdateLogentriesInput{ - Service: "foo", - Version: 1, - Name: "", + ServiceID: "foo", + ServiceVersion: 1, + Name: "", }) if err != ErrMissingName { t.Errorf("bad error: %s", err) @@ -244,24 +244,24 @@ func TestClient_UpdateLogentries_validation(t *testing.T) { func TestClient_DeleteLogentries_validation(t *testing.T) { var err error err = testClient.DeleteLogentries(&DeleteLogentriesInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } err = testClient.DeleteLogentries(&DeleteLogentriesInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } err = testClient.DeleteLogentries(&DeleteLogentriesInput{ - Service: "foo", - Version: 1, - Name: "", + ServiceID: "foo", + ServiceVersion: 1, + Name: "", }) if err != ErrMissingName { t.Errorf("bad error: %s", err) diff --git a/fastly/loggly.go b/fastly/loggly.go index 9da243cde..52d83fb2b 100644 --- a/fastly/loggly.go +++ b/fastly/loggly.go @@ -35,24 +35,24 @@ func (s logglyByName) Less(i, j int) bool { // ListLogglyInput is used as input to the ListLoggly function. type ListLogglyInput struct { - // Service is the ID of the service (required). - Service string + // ServiceID is the ID of the service (required). + ServiceID string - // Version is the specific configuration version (required). - Version int + // ServiceVersion is the specific configuration version (required). + ServiceVersion int } // ListLoggly returns the list of loggly for the configuration version. func (c *Client) ListLoggly(i *ListLogglyInput) ([]*Loggly, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/loggly", i.Service, i.Version) + path := fmt.Sprintf("/service/%s/version/%d/logging/loggly", i.ServiceID, i.ServiceVersion) resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -68,10 +68,11 @@ func (c *Client) ListLoggly(i *ListLogglyInput) ([]*Loggly, error) { // CreateLogglyInput is used as input to the CreateLoggly function. type CreateLogglyInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int Name *string `form:"name,omitempty"` Token *string `form:"token,omitempty"` @@ -83,15 +84,15 @@ type CreateLogglyInput struct { // CreateLoggly creates a new Fastly loggly. func (c *Client) CreateLoggly(i *CreateLogglyInput) (*Loggly, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/loggly", i.Service, i.Version) + path := fmt.Sprintf("/service/%s/version/%d/logging/loggly", i.ServiceID, i.ServiceVersion) resp, err := c.PostForm(path, i, nil) if err != nil { return nil, err @@ -106,10 +107,11 @@ func (c *Client) CreateLoggly(i *CreateLogglyInput) (*Loggly, error) { // GetLogglyInput is used as input to the GetLoggly function. type GetLogglyInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int // Name is the name of the loggly to fetch. Name string @@ -117,19 +119,19 @@ type GetLogglyInput struct { // GetLoggly gets the loggly configuration with the given parameters. func (c *Client) GetLoggly(i *GetLogglyInput) (*Loggly, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } if i.Name == "" { return nil, ErrMissingName } - path := fmt.Sprintf("/service/%s/version/%d/logging/loggly/%s", i.Service, i.Version, url.PathEscape(i.Name)) + path := fmt.Sprintf("/service/%s/version/%d/logging/loggly/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -144,10 +146,11 @@ func (c *Client) GetLoggly(i *GetLogglyInput) (*Loggly, error) { // UpdateLogglyInput is used as input to the UpdateLoggly function. type UpdateLogglyInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int // Name is the name of the loggly to update. Name string @@ -162,19 +165,19 @@ type UpdateLogglyInput struct { // UpdateLoggly updates a specific loggly. func (c *Client) UpdateLoggly(i *UpdateLogglyInput) (*Loggly, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } if i.Name == "" { return nil, ErrMissingName } - path := fmt.Sprintf("/service/%s/version/%d/logging/loggly/%s", i.Service, i.Version, url.PathEscape(i.Name)) + path := fmt.Sprintf("/service/%s/version/%d/logging/loggly/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) resp, err := c.PutForm(path, i, nil) if err != nil { return nil, err @@ -189,10 +192,11 @@ func (c *Client) UpdateLoggly(i *UpdateLogglyInput) (*Loggly, error) { // DeleteLogglyInput is the input parameter to DeleteLoggly. type DeleteLogglyInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int // Name is the name of the loggly to delete (required). Name string @@ -200,19 +204,19 @@ type DeleteLogglyInput struct { // DeleteLoggly deletes the given loggly version. func (c *Client) DeleteLoggly(i *DeleteLogglyInput) error { - if i.Service == "" { - return ErrMissingService + if i.ServiceID == "" { + return ErrMissingServiceID } - if i.Version == 0 { - return ErrMissingVersion + if i.ServiceVersion == 0 { + return ErrMissingServiceVersion } if i.Name == "" { return ErrMissingName } - path := fmt.Sprintf("/service/%s/version/%d/logging/loggly/%s", i.Service, i.Version, url.PathEscape(i.Name)) + path := fmt.Sprintf("/service/%s/version/%d/logging/loggly/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) resp, err := c.Delete(path, nil) if err != nil { return err diff --git a/fastly/loggly_test.go b/fastly/loggly_test.go index 36827d9f1..956c146a5 100644 --- a/fastly/loggly_test.go +++ b/fastly/loggly_test.go @@ -15,12 +15,12 @@ func TestClient_Loggly(t *testing.T) { var lg *Loggly record(t, "loggly/create", func(c *Client) { lg, err = c.CreateLoggly(&CreateLogglyInput{ - Service: testServiceID, - Version: tv.Number, - Name: String("test-loggly"), - Token: String("abcd1234"), - Format: String("format"), - Placement: String("waf_debug"), + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: String("test-loggly"), + Token: String("abcd1234"), + Format: String("format"), + Placement: String("waf_debug"), }) }) if err != nil { @@ -31,15 +31,15 @@ func TestClient_Loggly(t *testing.T) { defer func() { record(t, "loggly/delete", func(c *Client) { c.DeleteLoggly(&DeleteLogglyInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-loggly", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "test-loggly", }) c.DeleteLoggly(&DeleteLogglyInput{ - Service: testServiceID, - Version: tv.Number, - Name: "new-test-loggly", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "new-test-loggly", }) }) }() @@ -64,8 +64,8 @@ func TestClient_Loggly(t *testing.T) { var les []*Loggly record(t, "loggly/list", func(c *Client) { les, err = c.ListLoggly(&ListLogglyInput{ - Service: testServiceID, - Version: tv.Number, + ServiceID: testServiceID, + ServiceVersion: tv.Number, }) }) if err != nil { @@ -79,9 +79,9 @@ func TestClient_Loggly(t *testing.T) { var nlg *Loggly record(t, "loggly/get", func(c *Client) { nlg, err = c.GetLoggly(&GetLogglyInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-loggly", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "test-loggly", }) }) if err != nil { @@ -107,11 +107,11 @@ func TestClient_Loggly(t *testing.T) { var ulg *Loggly record(t, "loggly/update", func(c *Client) { ulg, err = c.UpdateLoggly(&UpdateLogglyInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-loggly", - NewName: String("new-test-loggly"), - FormatVersion: Uint(2), + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "test-loggly", + NewName: String("new-test-loggly"), + FormatVersion: Uint(2), }) }) if err != nil { @@ -127,9 +127,9 @@ func TestClient_Loggly(t *testing.T) { // Delete record(t, "loggly/delete", func(c *Client) { err = c.DeleteLoggly(&DeleteLogglyInput{ - Service: testServiceID, - Version: tv.Number, - Name: "new-test-loggly", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "new-test-loggly", }) }) if err != nil { @@ -140,17 +140,17 @@ func TestClient_Loggly(t *testing.T) { func TestClient_ListLoggly_validation(t *testing.T) { var err error _, err = testClient.ListLoggly(&ListLogglyInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.ListLoggly(&ListLogglyInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } } @@ -158,17 +158,17 @@ func TestClient_ListLoggly_validation(t *testing.T) { func TestClient_CreateLoggly_validation(t *testing.T) { var err error _, err = testClient.CreateLoggly(&CreateLogglyInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.CreateLoggly(&CreateLogglyInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } } @@ -176,24 +176,24 @@ func TestClient_CreateLoggly_validation(t *testing.T) { func TestClient_GetLoggly_validation(t *testing.T) { var err error _, err = testClient.GetLoggly(&GetLogglyInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.GetLoggly(&GetLogglyInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } _, err = testClient.GetLoggly(&GetLogglyInput{ - Service: "foo", - Version: 1, - Name: "", + ServiceID: "foo", + ServiceVersion: 1, + Name: "", }) if err != ErrMissingName { t.Errorf("bad error: %s", err) @@ -203,24 +203,24 @@ func TestClient_GetLoggly_validation(t *testing.T) { func TestClient_UpdateLoggly_validation(t *testing.T) { var err error _, err = testClient.UpdateLoggly(&UpdateLogglyInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.UpdateLoggly(&UpdateLogglyInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } _, err = testClient.UpdateLoggly(&UpdateLogglyInput{ - Service: "foo", - Version: 1, - Name: "", + ServiceID: "foo", + ServiceVersion: 1, + Name: "", }) if err != ErrMissingName { t.Errorf("bad error: %s", err) @@ -230,24 +230,24 @@ func TestClient_UpdateLoggly_validation(t *testing.T) { func TestClient_DeleteLoggly_validation(t *testing.T) { var err error err = testClient.DeleteLoggly(&DeleteLogglyInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } err = testClient.DeleteLoggly(&DeleteLogglyInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } err = testClient.DeleteLoggly(&DeleteLogglyInput{ - Service: "foo", - Version: 1, - Name: "", + ServiceID: "foo", + ServiceVersion: 1, + Name: "", }) if err != ErrMissingName { t.Errorf("bad error: %s", err) diff --git a/fastly/logshuttle.go b/fastly/logshuttle.go index 147981a59..2a9838a69 100644 --- a/fastly/logshuttle.go +++ b/fastly/logshuttle.go @@ -36,24 +36,24 @@ func (l logshuttlesByName) Less(i, j int) bool { // ListLogshuttlesInput is used as input to the ListLogshuttles function. type ListLogshuttlesInput struct { - // Service is the ID of the service (required). - Service string + // ServiceID is the ID of the service (required). + ServiceID string - // Version is the specific configuration version (required). - Version int + // ServiceVersion is the specific configuration version (required). + ServiceVersion int } // ListLogshuttles returns the list of logshuttles for the configuration version. func (c *Client) ListLogshuttles(i *ListLogshuttlesInput) ([]*Logshuttle, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/logshuttle", i.Service, i.Version) + path := fmt.Sprintf("/service/%s/version/%d/logging/logshuttle", i.ServiceID, i.ServiceVersion) resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -69,10 +69,11 @@ func (c *Client) ListLogshuttles(i *ListLogshuttlesInput) ([]*Logshuttle, error) // CreateLogshuttleInput is used as input to the CreateLogshuttle function. type CreateLogshuttleInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int Name *string `form:"name,omitempty"` Format *string `form:"format,omitempty"` @@ -85,15 +86,15 @@ type CreateLogshuttleInput struct { // CreateLogshuttle creates a new Fastly logshuttle. func (c *Client) CreateLogshuttle(i *CreateLogshuttleInput) (*Logshuttle, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/logshuttle", i.Service, i.Version) + path := fmt.Sprintf("/service/%s/version/%d/logging/logshuttle", i.ServiceID, i.ServiceVersion) resp, err := c.PostForm(path, i, nil) if err != nil { return nil, err @@ -108,10 +109,11 @@ func (c *Client) CreateLogshuttle(i *CreateLogshuttleInput) (*Logshuttle, error) // GetLogshuttleInput is used as input to the GetLogshuttle function. type GetLogshuttleInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int // Name is the name of the logshuttle to fetch. Name string @@ -119,19 +121,19 @@ type GetLogshuttleInput struct { // GetLogshuttle gets the logshuttle configuration with the given parameters. func (c *Client) GetLogshuttle(i *GetLogshuttleInput) (*Logshuttle, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } if i.Name == "" { return nil, ErrMissingName } - path := fmt.Sprintf("/service/%s/version/%d/logging/logshuttle/%s", i.Service, i.Version, url.PathEscape(i.Name)) + path := fmt.Sprintf("/service/%s/version/%d/logging/logshuttle/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -146,10 +148,11 @@ func (c *Client) GetLogshuttle(i *GetLogshuttleInput) (*Logshuttle, error) { // UpdateLogshuttleInput is used as input to the UpdateLogshuttle function. type UpdateLogshuttleInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int // Name is the name of the logshuttle to update. Name string @@ -165,19 +168,19 @@ type UpdateLogshuttleInput struct { // UpdateLogshuttle updates a specific logshuttle. func (c *Client) UpdateLogshuttle(i *UpdateLogshuttleInput) (*Logshuttle, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } if i.Name == "" { return nil, ErrMissingName } - path := fmt.Sprintf("/service/%s/version/%d/logging/logshuttle/%s", i.Service, i.Version, url.PathEscape(i.Name)) + path := fmt.Sprintf("/service/%s/version/%d/logging/logshuttle/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) resp, err := c.PutForm(path, i, nil) if err != nil { return nil, err @@ -192,10 +195,11 @@ func (c *Client) UpdateLogshuttle(i *UpdateLogshuttleInput) (*Logshuttle, error) // DeleteLogshuttleInput is the input parameter to DeleteLogshuttle. type DeleteLogshuttleInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int // Name is the name of the logshuttle to delete (required). Name string @@ -203,19 +207,19 @@ type DeleteLogshuttleInput struct { // DeleteLogshuttle deletes the given logshuttle version. func (c *Client) DeleteLogshuttle(i *DeleteLogshuttleInput) error { - if i.Service == "" { - return ErrMissingService + if i.ServiceID == "" { + return ErrMissingServiceID } - if i.Version == 0 { - return ErrMissingVersion + if i.ServiceVersion == 0 { + return ErrMissingServiceVersion } if i.Name == "" { return ErrMissingName } - path := fmt.Sprintf("/service/%s/version/%d/logging/logshuttle/%s", i.Service, i.Version, url.PathEscape(i.Name)) + path := fmt.Sprintf("/service/%s/version/%d/logging/logshuttle/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) resp, err := c.Delete(path, nil) if err != nil { return err diff --git a/fastly/logshuttle_test.go b/fastly/logshuttle_test.go index ccdb7e9a9..962fe82f5 100644 --- a/fastly/logshuttle_test.go +++ b/fastly/logshuttle_test.go @@ -17,14 +17,14 @@ func TestClient_Logshuttles(t *testing.T) { var l *Logshuttle record(t, "logshuttles/create", func(c *Client) { l, err = c.CreateLogshuttle(&CreateLogshuttleInput{ - Service: testServiceID, - Version: tv.Number, - Name: String("test-logshuttle"), - Format: String("%h %l %u %t \"%r\" %>s %b"), - FormatVersion: Uint(2), - Placement: String("waf_debug"), - Token: String("super-secure-token"), - URL: String("https://logs.example.com"), + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: String("test-logshuttle"), + Format: String("%h %l %u %t \"%r\" %>s %b"), + FormatVersion: Uint(2), + Placement: String("waf_debug"), + Token: String("super-secure-token"), + URL: String("https://logs.example.com"), }) }) if err != nil { @@ -35,15 +35,15 @@ func TestClient_Logshuttles(t *testing.T) { defer func() { record(t, "logshuttles/cleanup", func(c *Client) { c.DeleteLogshuttle(&DeleteLogshuttleInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-logshuttle", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "test-logshuttle", }) c.DeleteLogshuttle(&DeleteLogshuttleInput{ - Service: testServiceID, - Version: tv.Number, - Name: "new-test-logshuttle", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "new-test-logshuttle", }) }) }() @@ -71,8 +71,8 @@ func TestClient_Logshuttles(t *testing.T) { var ls []*Logshuttle record(t, "logshuttles/list", func(c *Client) { ls, err = c.ListLogshuttles(&ListLogshuttlesInput{ - Service: testServiceID, - Version: tv.Number, + ServiceID: testServiceID, + ServiceVersion: tv.Number, }) }) if err != nil { @@ -86,9 +86,9 @@ func TestClient_Logshuttles(t *testing.T) { var nl *Logshuttle record(t, "logshuttles/get", func(c *Client) { nl, err = c.GetLogshuttle(&GetLogshuttleInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-logshuttle", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "test-logshuttle", }) }) if err != nil { @@ -117,12 +117,12 @@ func TestClient_Logshuttles(t *testing.T) { var ul *Logshuttle record(t, "logshuttles/update", func(c *Client) { ul, err = c.UpdateLogshuttle(&UpdateLogshuttleInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-logshuttle", - NewName: String("new-test-logshuttle"), - Token: String("new-token"), - URL: String("https://logs2.example.com"), + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "test-logshuttle", + NewName: String("new-test-logshuttle"), + Token: String("new-token"), + URL: String("https://logs2.example.com"), }) }) if err != nil { @@ -141,9 +141,9 @@ func TestClient_Logshuttles(t *testing.T) { // Delete record(t, "logshuttles/delete", func(c *Client) { err = c.DeleteLogshuttle(&DeleteLogshuttleInput{ - Service: testServiceID, - Version: tv.Number, - Name: "new-test-logshuttle", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "new-test-logshuttle", }) }) if err != nil { @@ -154,17 +154,17 @@ func TestClient_Logshuttles(t *testing.T) { func TestClient_ListLogshuttles_validation(t *testing.T) { var err error _, err = testClient.ListLogshuttles(&ListLogshuttlesInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.ListLogshuttles(&ListLogshuttlesInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } } @@ -172,17 +172,17 @@ func TestClient_ListLogshuttles_validation(t *testing.T) { func TestClient_CreateLogshuttle_validation(t *testing.T) { var err error _, err = testClient.CreateLogshuttle(&CreateLogshuttleInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.CreateLogshuttle(&CreateLogshuttleInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } } @@ -190,24 +190,24 @@ func TestClient_CreateLogshuttle_validation(t *testing.T) { func TestClient_GetLogshuttle_validation(t *testing.T) { var err error _, err = testClient.GetLogshuttle(&GetLogshuttleInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.GetLogshuttle(&GetLogshuttleInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } _, err = testClient.GetLogshuttle(&GetLogshuttleInput{ - Service: "foo", - Version: 1, - Name: "", + ServiceID: "foo", + ServiceVersion: 1, + Name: "", }) if err != ErrMissingName { t.Errorf("bad error: %s", err) @@ -217,24 +217,24 @@ func TestClient_GetLogshuttle_validation(t *testing.T) { func TestClient_UpdateLogshuttle_validation(t *testing.T) { var err error _, err = testClient.UpdateLogshuttle(&UpdateLogshuttleInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.UpdateLogshuttle(&UpdateLogshuttleInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } _, err = testClient.UpdateLogshuttle(&UpdateLogshuttleInput{ - Service: "foo", - Version: 1, - Name: "", + ServiceID: "foo", + ServiceVersion: 1, + Name: "", }) if err != ErrMissingName { t.Errorf("bad error: %s", err) @@ -244,24 +244,24 @@ func TestClient_UpdateLogshuttle_validation(t *testing.T) { func TestClient_DeleteLogshuttle_validation(t *testing.T) { var err error err = testClient.DeleteLogshuttle(&DeleteLogshuttleInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } err = testClient.DeleteLogshuttle(&DeleteLogshuttleInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } err = testClient.DeleteLogshuttle(&DeleteLogshuttleInput{ - Service: "foo", - Version: 1, - Name: "", + ServiceID: "foo", + ServiceVersion: 1, + Name: "", }) if err != ErrMissingName { t.Errorf("bad error: %s", err) diff --git a/fastly/newrelic.go b/fastly/newrelic.go index 19c73cd69..f4bf4de62 100644 --- a/fastly/newrelic.go +++ b/fastly/newrelic.go @@ -35,24 +35,24 @@ func (s newrelicByName) Less(i, j int) bool { // ListNewRelicInput is used as input to the ListNewRelic function. type ListNewRelicInput struct { - // Service is the ID of the service (required). - Service string + // ServiceID is the ID of the service (required). + ServiceID string - // Version is the specific configuration version (required). - Version int + // ServiceVersion is the specific configuration version (required). + ServiceVersion int } // ListNewRelic returns the list of newrelic for the configuration version. func (c *Client) ListNewRelic(i *ListNewRelicInput) ([]*NewRelic, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/newrelic", i.Service, i.Version) + path := fmt.Sprintf("/service/%s/version/%d/logging/newrelic", i.ServiceID, i.ServiceVersion) resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -68,10 +68,11 @@ func (c *Client) ListNewRelic(i *ListNewRelicInput) ([]*NewRelic, error) { // CreateNewRelicInput is used as input to the CreateNewRelic function. type CreateNewRelicInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int Name *string `form:"name,omitempty"` Token *string `form:"token,omitempty"` @@ -83,15 +84,15 @@ type CreateNewRelicInput struct { // CreateNewRelic creates a new Fastly newrelic. func (c *Client) CreateNewRelic(i *CreateNewRelicInput) (*NewRelic, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/newrelic", i.Service, i.Version) + path := fmt.Sprintf("/service/%s/version/%d/logging/newrelic", i.ServiceID, i.ServiceVersion) resp, err := c.PostForm(path, i, nil) if err != nil { return nil, err @@ -106,10 +107,11 @@ func (c *Client) CreateNewRelic(i *CreateNewRelicInput) (*NewRelic, error) { // GetNewRelicInput is used as input to the GetNewRelic function. type GetNewRelicInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int // Name is the name of the newrelic to fetch. Name string @@ -117,19 +119,19 @@ type GetNewRelicInput struct { // GetNewRelic gets the newrelic configuration with the given parameters. func (c *Client) GetNewRelic(i *GetNewRelicInput) (*NewRelic, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } if i.Name == "" { return nil, ErrMissingName } - path := fmt.Sprintf("/service/%s/version/%d/logging/newrelic/%s", i.Service, i.Version, url.PathEscape(i.Name)) + path := fmt.Sprintf("/service/%s/version/%d/logging/newrelic/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -144,10 +146,11 @@ func (c *Client) GetNewRelic(i *GetNewRelicInput) (*NewRelic, error) { // UpdateNewRelicInput is used as input to the UpdateNewRelic function. type UpdateNewRelicInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int // Name is the name of the newrelic to update. Name string @@ -162,19 +165,19 @@ type UpdateNewRelicInput struct { // UpdateNewRelic updates a specific newrelic. func (c *Client) UpdateNewRelic(i *UpdateNewRelicInput) (*NewRelic, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } if i.Name == "" { return nil, ErrMissingName } - path := fmt.Sprintf("/service/%s/version/%d/logging/newrelic/%s", i.Service, i.Version, url.PathEscape(i.Name)) + path := fmt.Sprintf("/service/%s/version/%d/logging/newrelic/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) resp, err := c.PutForm(path, i, nil) if err != nil { return nil, err @@ -189,10 +192,11 @@ func (c *Client) UpdateNewRelic(i *UpdateNewRelicInput) (*NewRelic, error) { // DeleteNewRelicInput is the input parameter to DeleteNewRelic. type DeleteNewRelicInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int // Name is the name of the newrelic to delete (required). Name string @@ -200,19 +204,19 @@ type DeleteNewRelicInput struct { // DeleteNewRelic deletes the given newrelic version. func (c *Client) DeleteNewRelic(i *DeleteNewRelicInput) error { - if i.Service == "" { - return ErrMissingService + if i.ServiceID == "" { + return ErrMissingServiceID } - if i.Version == 0 { - return ErrMissingVersion + if i.ServiceVersion == 0 { + return ErrMissingServiceVersion } if i.Name == "" { return ErrMissingName } - path := fmt.Sprintf("/service/%s/version/%d/logging/newrelic/%s", i.Service, i.Version, url.PathEscape(i.Name)) + path := fmt.Sprintf("/service/%s/version/%d/logging/newrelic/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) resp, err := c.Delete(path, nil) if err != nil { return err diff --git a/fastly/newrelic_test.go b/fastly/newrelic_test.go index 71a85bc69..49dcbcbf1 100644 --- a/fastly/newrelic_test.go +++ b/fastly/newrelic_test.go @@ -15,12 +15,12 @@ func TestClient_NewRelic(t *testing.T) { var n *NewRelic record(t, "newrelic/create", func(c *Client) { n, err = c.CreateNewRelic(&CreateNewRelicInput{ - Service: testServiceID, - Version: tv.Number, - Name: String("test-newrelic"), - Token: String("abcd1234"), - Format: String("format"), - Placement: String("waf_debug"), + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: String("test-newrelic"), + Token: String("abcd1234"), + Format: String("format"), + Placement: String("waf_debug"), }) }) if err != nil { @@ -31,15 +31,15 @@ func TestClient_NewRelic(t *testing.T) { defer func() { record(t, "newrelic/delete", func(c *Client) { c.DeleteNewRelic(&DeleteNewRelicInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-newrelic", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "test-newrelic", }) c.DeleteNewRelic(&DeleteNewRelicInput{ - Service: testServiceID, - Version: tv.Number, - Name: "new-test-newrelic", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "new-test-newrelic", }) }) }() @@ -64,8 +64,8 @@ func TestClient_NewRelic(t *testing.T) { var ln []*NewRelic record(t, "newrelic/list", func(c *Client) { ln, err = c.ListNewRelic(&ListNewRelicInput{ - Service: testServiceID, - Version: tv.Number, + ServiceID: testServiceID, + ServiceVersion: tv.Number, }) }) if err != nil { @@ -79,9 +79,9 @@ func TestClient_NewRelic(t *testing.T) { var nn *NewRelic record(t, "newrelic/get", func(c *Client) { nn, err = c.GetNewRelic(&GetNewRelicInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-newrelic", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "test-newrelic", }) }) if err != nil { @@ -107,11 +107,11 @@ func TestClient_NewRelic(t *testing.T) { var un *NewRelic record(t, "newrelic/update", func(c *Client) { un, err = c.UpdateNewRelic(&UpdateNewRelicInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-newrelic", - NewName: String("new-test-newrelic"), - FormatVersion: Uint(2), + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "test-newrelic", + NewName: String("new-test-newrelic"), + FormatVersion: Uint(2), }) }) if err != nil { @@ -127,9 +127,9 @@ func TestClient_NewRelic(t *testing.T) { // Delete record(t, "newrelic/delete", func(c *Client) { err = c.DeleteNewRelic(&DeleteNewRelicInput{ - Service: testServiceID, - Version: tv.Number, - Name: "new-test-newrelic", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "new-test-newrelic", }) }) if err != nil { @@ -140,17 +140,17 @@ func TestClient_NewRelic(t *testing.T) { func TestClient_ListNewRelic_validation(t *testing.T) { var err error _, err = testClient.ListNewRelic(&ListNewRelicInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.ListNewRelic(&ListNewRelicInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } } @@ -158,17 +158,17 @@ func TestClient_ListNewRelic_validation(t *testing.T) { func TestClient_CreateNewRelic_validation(t *testing.T) { var err error _, err = testClient.CreateNewRelic(&CreateNewRelicInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.CreateNewRelic(&CreateNewRelicInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } } @@ -176,24 +176,24 @@ func TestClient_CreateNewRelic_validation(t *testing.T) { func TestClient_GetNewRelic_validation(t *testing.T) { var err error _, err = testClient.GetNewRelic(&GetNewRelicInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.GetNewRelic(&GetNewRelicInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } _, err = testClient.GetNewRelic(&GetNewRelicInput{ - Service: "foo", - Version: 1, - Name: "", + ServiceID: "foo", + ServiceVersion: 1, + Name: "", }) if err != ErrMissingName { t.Errorf("bad error: %s", err) @@ -203,24 +203,24 @@ func TestClient_GetNewRelic_validation(t *testing.T) { func TestClient_UpdateNewRelic_validation(t *testing.T) { var err error _, err = testClient.UpdateNewRelic(&UpdateNewRelicInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.UpdateNewRelic(&UpdateNewRelicInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } _, err = testClient.UpdateNewRelic(&UpdateNewRelicInput{ - Service: "foo", - Version: 1, - Name: "", + ServiceID: "foo", + ServiceVersion: 1, + Name: "", }) if err != ErrMissingName { t.Errorf("bad error: %s", err) @@ -230,24 +230,24 @@ func TestClient_UpdateNewRelic_validation(t *testing.T) { func TestClient_DeleteNewRelic_validation(t *testing.T) { var err error err = testClient.DeleteNewRelic(&DeleteNewRelicInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } err = testClient.DeleteNewRelic(&DeleteNewRelicInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } err = testClient.DeleteNewRelic(&DeleteNewRelicInput{ - Service: "foo", - Version: 1, - Name: "", + ServiceID: "foo", + ServiceVersion: 1, + Name: "", }) if err != ErrMissingName { t.Errorf("bad error: %s", err) diff --git a/fastly/openstack.go b/fastly/openstack.go index c6409fcef..898103c90 100644 --- a/fastly/openstack.go +++ b/fastly/openstack.go @@ -44,24 +44,24 @@ func (o openstacksByName) Less(i, j int) bool { // ListOpenstackInput is used as input to the ListOpenstack function. type ListOpenstackInput struct { - // Service is the ID of the service (required). - Service string + // ServiceID is the ID of the service (required). + ServiceID string - // Version is the specific configuration version (required). - Version int + // ServiceVersion is the specific configuration version (required). + ServiceVersion int } // ListOpenstack returns the list of Openstack for the configuration version. func (c *Client) ListOpenstack(i *ListOpenstackInput) ([]*Openstack, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/openstack", i.Service, i.Version) + path := fmt.Sprintf("/service/%s/version/%d/logging/openstack", i.ServiceID, i.ServiceVersion) resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -77,10 +77,11 @@ func (c *Client) ListOpenstack(i *ListOpenstackInput) ([]*Openstack, error) { // CreateOpenstackInput is used as input to the CreateOpenstack function. type CreateOpenstackInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int Name *string `form:"name,omitempty"` User *string `form:"user,omitempty"` @@ -101,15 +102,15 @@ type CreateOpenstackInput struct { // CreateOpenstack creates a new Fastly Openstack. func (c *Client) CreateOpenstack(i *CreateOpenstackInput) (*Openstack, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/openstack", i.Service, i.Version) + path := fmt.Sprintf("/service/%s/version/%d/logging/openstack", i.ServiceID, i.ServiceVersion) resp, err := c.PostForm(path, i, nil) if err != nil { return nil, err @@ -124,10 +125,11 @@ func (c *Client) CreateOpenstack(i *CreateOpenstackInput) (*Openstack, error) { // GetOpenstackInput is used as input to the GetOpenstack function. type GetOpenstackInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int // Name is the name of the Openstack to fetch. Name string @@ -135,19 +137,19 @@ type GetOpenstackInput struct { // GetOpenstack gets the Openstack configuration with the given parameters. func (c *Client) GetOpenstack(i *GetOpenstackInput) (*Openstack, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } if i.Name == "" { return nil, ErrMissingName } - path := fmt.Sprintf("/service/%s/version/%d/logging/openstack/%s", i.Service, i.Version, url.PathEscape(i.Name)) + path := fmt.Sprintf("/service/%s/version/%d/logging/openstack/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -162,10 +164,11 @@ func (c *Client) GetOpenstack(i *GetOpenstackInput) (*Openstack, error) { // UpdateOpenstackInput is used as input to the UpdateOpenstack function. type UpdateOpenstackInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int // Name is the name of the Openstack to update. Name string @@ -189,19 +192,19 @@ type UpdateOpenstackInput struct { // UpdateOpenstack updates a specific Openstack. func (c *Client) UpdateOpenstack(i *UpdateOpenstackInput) (*Openstack, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } if i.Name == "" { return nil, ErrMissingName } - path := fmt.Sprintf("/service/%s/version/%d/logging/openstack/%s", i.Service, i.Version, url.PathEscape(i.Name)) + path := fmt.Sprintf("/service/%s/version/%d/logging/openstack/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) resp, err := c.PutForm(path, i, nil) if err != nil { return nil, err @@ -216,10 +219,11 @@ func (c *Client) UpdateOpenstack(i *UpdateOpenstackInput) (*Openstack, error) { // DeleteOpenstackInput is the input parameter to DeleteOpenstack. type DeleteOpenstackInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int // Name is the name of the Openstack to delete (required). Name string @@ -227,19 +231,19 @@ type DeleteOpenstackInput struct { // DeleteOpenstack deletes the given Openstack version. func (c *Client) DeleteOpenstack(i *DeleteOpenstackInput) error { - if i.Service == "" { - return ErrMissingService + if i.ServiceID == "" { + return ErrMissingServiceID } - if i.Version == 0 { - return ErrMissingVersion + if i.ServiceVersion == 0 { + return ErrMissingServiceVersion } if i.Name == "" { return ErrMissingName } - path := fmt.Sprintf("/service/%s/version/%d/logging/openstack/%s", i.Service, i.Version, url.PathEscape(i.Name)) + path := fmt.Sprintf("/service/%s/version/%d/logging/openstack/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) resp, err := c.Delete(path, nil) if err != nil { return err diff --git a/fastly/openstack_test.go b/fastly/openstack_test.go index 0b97658df..7d954a671 100644 --- a/fastly/openstack_test.go +++ b/fastly/openstack_test.go @@ -15,8 +15,8 @@ func TestClient_Openstack(t *testing.T) { var openstack *Openstack record(t, "openstack/create", func(c *Client) { openstack, err = c.CreateOpenstack(&CreateOpenstackInput{ - Service: testServiceID, - Version: tv.Number, + ServiceID: testServiceID, + ServiceVersion: tv.Number, Name: String("test-openstack"), User: String("user"), AccessKey: String("secret-key"), @@ -41,15 +41,15 @@ func TestClient_Openstack(t *testing.T) { defer func() { record(t, "openstack/cleanup", func(c *Client) { c.DeleteOpenstack(&DeleteOpenstackInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-openstack", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "test-openstack", }) c.DeleteOpenstack(&DeleteOpenstackInput{ - Service: testServiceID, - Version: tv.Number, - Name: "new-test-openstack", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "new-test-openstack", }) }) }() @@ -101,8 +101,8 @@ func TestClient_Openstack(t *testing.T) { var lc []*Openstack record(t, "openstack/list", func(c *Client) { lc, err = c.ListOpenstack(&ListOpenstackInput{ - Service: testServiceID, - Version: tv.Number, + ServiceID: testServiceID, + ServiceVersion: tv.Number, }) }) if err != nil { @@ -116,9 +116,9 @@ func TestClient_Openstack(t *testing.T) { var nopenstack *Openstack record(t, "openstack/get", func(c *Client) { nopenstack, err = c.GetOpenstack(&GetOpenstackInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-openstack", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "test-openstack", }) }) if err != nil { @@ -171,12 +171,12 @@ func TestClient_Openstack(t *testing.T) { var uopenstack *Openstack record(t, "openstack/update", func(c *Client) { uopenstack, err = c.UpdateOpenstack(&UpdateOpenstackInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-openstack", - User: String("new-user"), - NewName: String("new-test-openstack"), - GzipLevel: Uint(0), + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "test-openstack", + User: String("new-user"), + NewName: String("new-test-openstack"), + GzipLevel: Uint(0), }) }) if err != nil { @@ -195,9 +195,9 @@ func TestClient_Openstack(t *testing.T) { // Delete record(t, "openstack/delete", func(c *Client) { err = c.DeleteOpenstack(&DeleteOpenstackInput{ - Service: testServiceID, - Version: tv.Number, - Name: "new-test-openstack", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "new-test-openstack", }) }) if err != nil { @@ -208,17 +208,17 @@ func TestClient_Openstack(t *testing.T) { func TestClient_ListOpenstack_validation(t *testing.T) { var err error _, err = testClient.ListOpenstack(&ListOpenstackInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.ListOpenstack(&ListOpenstackInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } } @@ -226,17 +226,17 @@ func TestClient_ListOpenstack_validation(t *testing.T) { func TestClient_CreateOpenstack_validation(t *testing.T) { var err error _, err = testClient.CreateOpenstack(&CreateOpenstackInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.CreateOpenstack(&CreateOpenstackInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } } @@ -244,24 +244,24 @@ func TestClient_CreateOpenstack_validation(t *testing.T) { func TestClient_GetOpenstack_validation(t *testing.T) { var err error _, err = testClient.GetOpenstack(&GetOpenstackInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.GetOpenstack(&GetOpenstackInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } _, err = testClient.GetOpenstack(&GetOpenstackInput{ - Service: "foo", - Version: 1, - Name: "", + ServiceID: "foo", + ServiceVersion: 1, + Name: "", }) if err != ErrMissingName { t.Errorf("bad error: %s", err) @@ -271,24 +271,24 @@ func TestClient_GetOpenstack_validation(t *testing.T) { func TestClient_UpdateOpenstack_validation(t *testing.T) { var err error _, err = testClient.UpdateOpenstack(&UpdateOpenstackInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.UpdateOpenstack(&UpdateOpenstackInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } _, err = testClient.UpdateOpenstack(&UpdateOpenstackInput{ - Service: "foo", - Version: 1, - Name: "", + ServiceID: "foo", + ServiceVersion: 1, + Name: "", }) if err != ErrMissingName { t.Errorf("bad error: %s", err) @@ -298,24 +298,24 @@ func TestClient_UpdateOpenstack_validation(t *testing.T) { func TestClient_DeleteOpenstack_validation(t *testing.T) { var err error err = testClient.DeleteOpenstack(&DeleteOpenstackInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } err = testClient.DeleteOpenstack(&DeleteOpenstackInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } err = testClient.DeleteOpenstack(&DeleteOpenstackInput{ - Service: "foo", - Version: 1, - Name: "", + ServiceID: "foo", + ServiceVersion: 1, + Name: "", }) if err != ErrMissingName { t.Errorf("bad error: %s", err) diff --git a/fastly/package.go b/fastly/package.go index b4d067e2d..f6ea7266d 100644 --- a/fastly/package.go +++ b/fastly/package.go @@ -31,16 +31,16 @@ type PackageMetadata struct { // GetPackageInput is used as input to the GetPackage function. type GetPackageInput struct { - // Service is the ID of the service. - // Version is the specific configuration version. - // Both fields are required. - Service string `mapstructure:"service_id"` - Version int `mapstructure:"version"` + // ServiceID is the ID of the service (required). + ServiceID string `mapstructure:"service_id"` + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int `mapstructure:"version"` } // GetPackage retrieves package information for the given service and version. func (c *Client) GetPackage(i *GetPackageInput) (*Package, error) { - path, err := MakePackagePath(i.Service, i.Version) + path, err := MakePackagePath(i.ServiceID, i.ServiceVersion) if err != nil { return nil, err } @@ -55,11 +55,11 @@ func (c *Client) GetPackage(i *GetPackageInput) (*Package, error) { // UpdatePackageInput is used as input to the UpdatePackage function. type UpdatePackageInput struct { - // Service is the ID of the service. - // Version is the specific configuration version. - // Both fields are required. - Service string `mapstructure:"service_id"` - Version int `mapstructure:"version"` + // ServiceID is the ID of the service (required). + ServiceID string `mapstructure:"service_id"` + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int `mapstructure:"version"` // PackagePath is the local filesystem path to the package to upload. PackagePath string @@ -68,7 +68,7 @@ type UpdatePackageInput struct { // UpdatePackage updates a package for a specific version. func (c *Client) UpdatePackage(i *UpdatePackageInput) (*Package, error) { - urlPath, err := MakePackagePath(i.Service, i.Version) + urlPath, err := MakePackagePath(i.ServiceID, i.ServiceVersion) if err != nil { return nil, err } @@ -84,10 +84,10 @@ func (c *Client) UpdatePackage(i *UpdatePackageInput) (*Package, error) { // MakePackagePath ensures we create the correct REST path for referencing packages in the API. func MakePackagePath(Service string, Version int) (string, error) { if Service == "" { - return "", ErrMissingService + return "", ErrMissingServiceID } if Version == 0 { - return "", ErrMissingVersion + return "", ErrMissingServiceVersion } return fmt.Sprintf("/service/%s/version/%d/package", Service, Version), nil } diff --git a/fastly/package_test.go b/fastly/package_test.go index ff7a9d858..ee731d493 100644 --- a/fastly/package_test.go +++ b/fastly/package_test.go @@ -30,9 +30,9 @@ func TestClient_Package(t *testing.T) { recordIgnoreBody(t, fixtureBase+"update", func(c *Client) { wp, err = c.UpdatePackage(&UpdatePackageInput{ - Service: testService.ID, - Version: testVersion.Number, - PackagePath: "test_assets/package/valid.tar.gz", + ServiceID: testService.ID, + ServiceVersion: testVersion.Number, + PackagePath: "test_assets/package/valid.tar.gz", }) }) if err != nil { @@ -48,8 +48,8 @@ func TestClient_Package(t *testing.T) { // Get record(t, fixtureBase+"get", func(c *Client) { wp, err = c.GetPackage(&GetPackageInput{ - Service: testService.ID, - Version: testVersion.Number, + ServiceID: testService.ID, + ServiceVersion: testVersion.Number, }) }) if err != nil { @@ -83,9 +83,9 @@ func TestClient_Package(t *testing.T) { recordIgnoreBody(t, fixtureBase+"update_invalid", func(c *Client) { wp, err = c.UpdatePackage(&UpdatePackageInput{ - Service: testService.ID, - Version: testVersion.Number, - PackagePath: "test_assets/package/invalid.tar.gz", + ServiceID: testService.ID, + ServiceVersion: testVersion.Number, + PackagePath: "test_assets/package/invalid.tar.gz", }) }) if err != nil { @@ -101,17 +101,17 @@ func TestClient_Package(t *testing.T) { func TestClient_GetPackage_validation(t *testing.T) { var err error _, err = testClient.GetPackage(&GetPackageInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.GetPackage(&GetPackageInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } } @@ -119,17 +119,17 @@ func TestClient_GetPackage_validation(t *testing.T) { func TestClient_UpdatePackage_validation(t *testing.T) { var err error _, err = testClient.UpdatePackage(&UpdatePackageInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.UpdatePackage(&UpdatePackageInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } } diff --git a/fastly/papertrail.go b/fastly/papertrail.go index 4cbe6308f..a55d4965f 100644 --- a/fastly/papertrail.go +++ b/fastly/papertrail.go @@ -36,24 +36,24 @@ func (s papertrailsByName) Less(i, j int) bool { // ListPapertrailsInput is used as input to the ListPapertrails function. type ListPapertrailsInput struct { - // Service is the ID of the service (required). - Service string + // ServiceID is the ID of the service (required). + ServiceID string - // Version is the specific configuration version (required). - Version int + // ServiceVersion is the specific configuration version (required). + ServiceVersion int } // ListPapertrails returns the list of papertrails for the configuration version. func (c *Client) ListPapertrails(i *ListPapertrailsInput) ([]*Papertrail, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/papertrail", i.Service, i.Version) + path := fmt.Sprintf("/service/%s/version/%d/logging/papertrail", i.ServiceID, i.ServiceVersion) resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -69,10 +69,11 @@ func (c *Client) ListPapertrails(i *ListPapertrailsInput) ([]*Papertrail, error) // CreatePapertrailInput is used as input to the CreatePapertrail function. type CreatePapertrailInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int Name string `form:"name,omitempty"` Address string `form:"address,omitempty"` @@ -88,15 +89,15 @@ type CreatePapertrailInput struct { // CreatePapertrail creates a new Fastly papertrail. func (c *Client) CreatePapertrail(i *CreatePapertrailInput) (*Papertrail, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/papertrail", i.Service, i.Version) + path := fmt.Sprintf("/service/%s/version/%d/logging/papertrail", i.ServiceID, i.ServiceVersion) resp, err := c.PostForm(path, i, nil) if err != nil { return nil, err @@ -111,10 +112,11 @@ func (c *Client) CreatePapertrail(i *CreatePapertrailInput) (*Papertrail, error) // GetPapertrailInput is used as input to the GetPapertrail function. type GetPapertrailInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int // Name is the name of the papertrail to fetch. Name string @@ -122,19 +124,19 @@ type GetPapertrailInput struct { // GetPapertrail gets the papertrail configuration with the given parameters. func (c *Client) GetPapertrail(i *GetPapertrailInput) (*Papertrail, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } if i.Name == "" { return nil, ErrMissingName } - path := fmt.Sprintf("/service/%s/version/%d/logging/papertrail/%s", i.Service, i.Version, url.PathEscape(i.Name)) + path := fmt.Sprintf("/service/%s/version/%d/logging/papertrail/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -149,10 +151,11 @@ func (c *Client) GetPapertrail(i *GetPapertrailInput) (*Papertrail, error) { // UpdatePapertrailInput is used as input to the UpdatePapertrail function. type UpdatePapertrailInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int // Name is the name of the papertrail to update. Name string @@ -171,19 +174,19 @@ type UpdatePapertrailInput struct { // UpdatePapertrail updates a specific papertrail. func (c *Client) UpdatePapertrail(i *UpdatePapertrailInput) (*Papertrail, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } if i.Name == "" { return nil, ErrMissingName } - path := fmt.Sprintf("/service/%s/version/%d/logging/papertrail/%s", i.Service, i.Version, url.PathEscape(i.Name)) + path := fmt.Sprintf("/service/%s/version/%d/logging/papertrail/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) resp, err := c.PutForm(path, i, nil) if err != nil { return nil, err @@ -198,10 +201,11 @@ func (c *Client) UpdatePapertrail(i *UpdatePapertrailInput) (*Papertrail, error) // DeletePapertrailInput is the input parameter to DeletePapertrail. type DeletePapertrailInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int // Name is the name of the papertrail to delete (required). Name string @@ -209,19 +213,19 @@ type DeletePapertrailInput struct { // DeletePapertrail deletes the given papertrail version. func (c *Client) DeletePapertrail(i *DeletePapertrailInput) error { - if i.Service == "" { - return ErrMissingService + if i.ServiceID == "" { + return ErrMissingServiceID } - if i.Version == 0 { - return ErrMissingVersion + if i.ServiceVersion == 0 { + return ErrMissingServiceVersion } if i.Name == "" { return ErrMissingName } - path := fmt.Sprintf("/service/%s/version/%d/logging/papertrail/%s", i.Service, i.Version, url.PathEscape(i.Name)) + path := fmt.Sprintf("/service/%s/version/%d/logging/papertrail/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) resp, err := c.Delete(path, nil) if err != nil { return err diff --git a/fastly/papertrail_test.go b/fastly/papertrail_test.go index 1c3f1d50e..7ef4036be 100644 --- a/fastly/papertrail_test.go +++ b/fastly/papertrail_test.go @@ -15,14 +15,14 @@ func TestClient_Papertrails(t *testing.T) { var p *Papertrail record(t, "papertrails/create", func(c *Client) { p, err = c.CreatePapertrail(&CreatePapertrailInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-papertrail", - Address: "integ-test.go-fastly.com", - Port: 1234, - FormatVersion: 2, - Format: "format", - Placement: "waf_debug", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "test-papertrail", + Address: "integ-test.go-fastly.com", + Port: 1234, + FormatVersion: 2, + Format: "format", + Placement: "waf_debug", }) }) if err != nil { @@ -33,15 +33,15 @@ func TestClient_Papertrails(t *testing.T) { defer func() { record(t, "papertrails/cleanup", func(c *Client) { c.DeletePapertrail(&DeletePapertrailInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-papertrail", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "test-papertrail", }) c.DeletePapertrail(&DeletePapertrailInput{ - Service: testServiceID, - Version: tv.Number, - Name: "new-test-papertrail", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "new-test-papertrail", }) }) }() @@ -69,8 +69,8 @@ func TestClient_Papertrails(t *testing.T) { var ps []*Papertrail record(t, "papertrails/list", func(c *Client) { ps, err = c.ListPapertrails(&ListPapertrailsInput{ - Service: testServiceID, - Version: tv.Number, + ServiceID: testServiceID, + ServiceVersion: tv.Number, }) }) if err != nil { @@ -84,9 +84,9 @@ func TestClient_Papertrails(t *testing.T) { var np *Papertrail record(t, "papertrails/get", func(c *Client) { np, err = c.GetPapertrail(&GetPapertrailInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-papertrail", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "test-papertrail", }) }) if err != nil { @@ -115,10 +115,10 @@ func TestClient_Papertrails(t *testing.T) { var up *Papertrail record(t, "papertrails/update", func(c *Client) { up, err = c.UpdatePapertrail(&UpdatePapertrailInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-papertrail", - NewName: "new-test-papertrail", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "test-papertrail", + NewName: "new-test-papertrail", }) }) if err != nil { @@ -131,9 +131,9 @@ func TestClient_Papertrails(t *testing.T) { // Delete record(t, "papertrails/delete", func(c *Client) { err = c.DeletePapertrail(&DeletePapertrailInput{ - Service: testServiceID, - Version: tv.Number, - Name: "new-test-papertrail", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "new-test-papertrail", }) }) if err != nil { @@ -144,17 +144,17 @@ func TestClient_Papertrails(t *testing.T) { func TestClient_ListPapertrails_validation(t *testing.T) { var err error _, err = testClient.ListPapertrails(&ListPapertrailsInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.ListPapertrails(&ListPapertrailsInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } } @@ -162,17 +162,17 @@ func TestClient_ListPapertrails_validation(t *testing.T) { func TestClient_CreatePapertrail_validation(t *testing.T) { var err error _, err = testClient.CreatePapertrail(&CreatePapertrailInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.CreatePapertrail(&CreatePapertrailInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } } @@ -180,24 +180,24 @@ func TestClient_CreatePapertrail_validation(t *testing.T) { func TestClient_GetPapertrail_validation(t *testing.T) { var err error _, err = testClient.GetPapertrail(&GetPapertrailInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.GetPapertrail(&GetPapertrailInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } _, err = testClient.GetPapertrail(&GetPapertrailInput{ - Service: "foo", - Version: 1, - Name: "", + ServiceID: "foo", + ServiceVersion: 1, + Name: "", }) if err != ErrMissingName { t.Errorf("bad error: %s", err) @@ -207,24 +207,24 @@ func TestClient_GetPapertrail_validation(t *testing.T) { func TestClient_UpdatePapertrail_validation(t *testing.T) { var err error _, err = testClient.UpdatePapertrail(&UpdatePapertrailInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.UpdatePapertrail(&UpdatePapertrailInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } _, err = testClient.UpdatePapertrail(&UpdatePapertrailInput{ - Service: "foo", - Version: 1, - Name: "", + ServiceID: "foo", + ServiceVersion: 1, + Name: "", }) if err != ErrMissingName { t.Errorf("bad error: %s", err) @@ -234,24 +234,24 @@ func TestClient_UpdatePapertrail_validation(t *testing.T) { func TestClient_DeletePapertrail_validation(t *testing.T) { var err error err = testClient.DeletePapertrail(&DeletePapertrailInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } err = testClient.DeletePapertrail(&DeletePapertrailInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } err = testClient.DeletePapertrail(&DeletePapertrailInput{ - Service: "foo", - Version: 1, - Name: "", + ServiceID: "foo", + ServiceVersion: 1, + Name: "", }) if err != ErrMissingName { t.Errorf("bad error: %s", err) diff --git a/fastly/pool.go b/fastly/pool.go index 00ca91b9f..3ca29438c 100644 --- a/fastly/pool.go +++ b/fastly/pool.go @@ -65,24 +65,24 @@ func (s poolsByName) Less(i, j int) bool { // ListPoolsInput is used as input to the ListPools function. type ListPoolsInput struct { - // Service is the ID of the service (required). - Service string + // ServiceID is the ID of the service (required). + ServiceID string - // Version is the specific configuration version (required). - Version int + // ServiceVersion is the specific configuration version (required). + ServiceVersion int } // ListPools lists all pools for a particular service and version. func (c *Client) ListPools(i *ListPoolsInput) ([]*Pool, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/pool", i.Service, i.Version) + path := fmt.Sprintf("/service/%s/version/%d/pool", i.ServiceID, i.ServiceVersion) resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -98,10 +98,11 @@ func (c *Client) ListPools(i *ListPoolsInput) ([]*Pool, error) { // CreatePoolInput is used as input to the CreatePool function. type CreatePoolInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int // Name is the name of the pool to create (required). Name string `form:"name"` @@ -131,19 +132,19 @@ type CreatePoolInput struct { // CreatePool creates a pool for a particular service and version. func (c *Client) CreatePool(i *CreatePoolInput) (*Pool, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } if i.Name == "" { return nil, ErrMissingName } - path := fmt.Sprintf("/service/%s/version/%d/pool", i.Service, i.Version) + path := fmt.Sprintf("/service/%s/version/%d/pool", i.ServiceID, i.ServiceVersion) resp, err := c.PostForm(path, i, nil) if err != nil { return nil, err @@ -158,11 +159,11 @@ func (c *Client) CreatePool(i *CreatePoolInput) (*Pool, error) { // GetPoolInput is used as input to the GetPool function. type GetPoolInput struct { - // Service is the ID of the service (required). - Service string + // ServiceID is the ID of the service (required). + ServiceID string - // Version is the specific configuration version (required). - Version int + // ServiceVersion is the specific configuration version (required). + ServiceVersion int // Name is the name of the pool of interest (required). Name string @@ -170,19 +171,19 @@ type GetPoolInput struct { // GetPool gets a single pool for a particular service and version. func (c *Client) GetPool(i *GetPoolInput) (*Pool, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } if i.Name == "" { return nil, ErrMissingName } - path := fmt.Sprintf("/service/%s/version/%d/pool/%s", i.Service, i.Version, url.PathEscape(i.Name)) + path := fmt.Sprintf("/service/%s/version/%d/pool/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -197,12 +198,14 @@ func (c *Client) GetPool(i *GetPoolInput) (*Pool, error) { // UpdatePoolInput is used as input to the UpdatePool function. type UpdatePoolInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Name is the name of the pool to update. All three fields - // are required. - Service string - Version int - Name string + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int + + // Name is the name of the pool to update (required). + Name string // Optional fields. NewName *string `form:"name,omitempty"` @@ -230,19 +233,19 @@ type UpdatePoolInput struct { // UpdatePool updates a specufic pool for a particular service and version. func (c *Client) UpdatePool(i *UpdatePoolInput) (*Pool, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } if i.Name == "" { return nil, ErrMissingName } - path := fmt.Sprintf("/service/%s/version/%d/pool/%s", i.Service, i.Version, url.PathEscape(i.Name)) + path := fmt.Sprintf("/service/%s/version/%d/pool/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) resp, err := c.PutForm(path, i, nil) if err != nil { return nil, err @@ -257,30 +260,32 @@ func (c *Client) UpdatePool(i *UpdatePoolInput) (*Pool, error) { // DeletePoolInput is used as input to the DeletePool function. type DeletePoolInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Name is the name of the pool to delete. All three fields - // are required. - Service string - Version int - Name string + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int + + // Name is the name of the pool to delete (required). + Name string } // DeletePool deletes a specific pool for a particular service and version. func (c *Client) DeletePool(i *DeletePoolInput) error { - if i.Service == "" { + if i.ServiceID == "" { - return ErrMissingService + return ErrMissingServiceID } - if i.Version == 0 { - return ErrMissingVersion + if i.ServiceVersion == 0 { + return ErrMissingServiceVersion } if i.Name == "" { return ErrMissingName } - path := fmt.Sprintf("/service/%s/version/%d/pool/%s", i.Service, i.Version, url.PathEscape(i.Name)) + path := fmt.Sprintf("/service/%s/version/%d/pool/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) resp, err := c.Delete(path, nil) if err != nil { return err diff --git a/fastly/pool_test.go b/fastly/pool_test.go index aee7ef9a6..c4d3614e6 100644 --- a/fastly/pool_test.go +++ b/fastly/pool_test.go @@ -15,8 +15,8 @@ func TestClient_Pools(t *testing.T) { var p *Pool record(t, "pools/create", func(c *Client) { p, err = c.CreatePool(&CreatePoolInput{ - Service: testServiceID, - Version: tv.Number, + ServiceID: testServiceID, + ServiceVersion: tv.Number, Name: "test_pool", Comment: String("test pool"), Quorum: Uint(50), @@ -33,15 +33,15 @@ func TestClient_Pools(t *testing.T) { defer func() { record(t, "pools/cleanup", func(c *Client) { c.DeletePool(&DeletePoolInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test_pool", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "test_pool", }) c.DeletePool(&DeletePoolInput{ - Service: testServiceID, - Version: tv.Number, - Name: "new_test_pool", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "new_test_pool", }) }) }() @@ -70,8 +70,8 @@ func TestClient_Pools(t *testing.T) { var ps []*Pool record(t, "pools/list", func(c *Client) { ps, err = c.ListPools(&ListPoolsInput{ - Service: testServiceID, - Version: tv.Number, + ServiceID: testServiceID, + ServiceVersion: tv.Number, }) }) if err != nil { @@ -85,9 +85,9 @@ func TestClient_Pools(t *testing.T) { var np *Pool record(t, "pools/get", func(c *Client) { np, err = c.GetPool(&GetPoolInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test_pool", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "test_pool", }) }) if err != nil { @@ -107,11 +107,11 @@ func TestClient_Pools(t *testing.T) { var up *Pool record(t, "pools/update", func(c *Client) { up, err = c.UpdatePool(&UpdatePoolInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test_pool", - NewName: String("new_test_pool"), - Quorum: Uint(0), + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "test_pool", + NewName: String("new_test_pool"), + Quorum: Uint(0), }) }) if err != nil { @@ -127,9 +127,9 @@ func TestClient_Pools(t *testing.T) { // Delete record(t, "pools/delete", func(c *Client) { err = c.DeletePool(&DeletePoolInput{ - Service: testServiceID, - Version: tv.Number, - Name: "new_test_pool", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "new_test_pool", }) }) if err != nil { @@ -140,17 +140,17 @@ func TestClient_Pools(t *testing.T) { func TestClient_ListPools_validation(t *testing.T) { var err error _, err = testClient.ListPools(&ListPoolsInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.ListPools(&ListPoolsInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } } @@ -158,24 +158,24 @@ func TestClient_ListPools_validation(t *testing.T) { func TestClient_CreatePool_validation(t *testing.T) { var err error _, err = testClient.CreatePool(&CreatePoolInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.CreatePool(&CreatePoolInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } _, err = testClient.CreatePool(&CreatePoolInput{ - Service: "foo", - Version: 1, - Name: "", + ServiceID: "foo", + ServiceVersion: 1, + Name: "", }) if err != ErrMissingName { t.Errorf("bad error: %s", err) @@ -185,24 +185,24 @@ func TestClient_CreatePool_validation(t *testing.T) { func TestClient_GetPool_validation(t *testing.T) { var err error _, err = testClient.GetPool(&GetPoolInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.GetPool(&GetPoolInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } _, err = testClient.GetPool(&GetPoolInput{ - Service: "foo", - Version: 1, - Name: "", + ServiceID: "foo", + ServiceVersion: 1, + Name: "", }) if err != ErrMissingName { t.Errorf("bad error: %s", err) @@ -212,24 +212,24 @@ func TestClient_GetPool_validation(t *testing.T) { func TestClient_UpdatePool_validation(t *testing.T) { var err error _, err = testClient.UpdatePool(&UpdatePoolInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.UpdatePool(&UpdatePoolInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } _, err = testClient.UpdatePool(&UpdatePoolInput{ - Service: "foo", - Version: 1, - Name: "", + ServiceID: "foo", + ServiceVersion: 1, + Name: "", }) if err != ErrMissingName { t.Errorf("bad error: %s", err) @@ -239,24 +239,24 @@ func TestClient_UpdatePool_validation(t *testing.T) { func TestClient_DeletePool_validation(t *testing.T) { var err error err = testClient.DeletePool(&DeletePoolInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } err = testClient.DeletePool(&DeletePoolInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } err = testClient.DeletePool(&DeletePoolInput{ - Service: "foo", - Version: 1, - Name: "", + ServiceID: "foo", + ServiceVersion: 1, + Name: "", }) if err != ErrMissingName { t.Errorf("bad error: %s", err) diff --git a/fastly/pubsub.go b/fastly/pubsub.go index f13fc5f57..8a3780810 100644 --- a/fastly/pubsub.go +++ b/fastly/pubsub.go @@ -38,24 +38,24 @@ func (s pubsubsByName) Less(i, j int) bool { // ListPubsubsInput is used as input to the ListPubsubs function. type ListPubsubsInput struct { - // Service is the ID of the service (required). - Service string + // ServiceID is the ID of the service (required). + ServiceID string - // Version is the specific configuration version (required). - Version int + // ServiceVersion is the specific configuration version (required). + ServiceVersion int } // ListPubsubs returns the list of pubsubs for the configuration version. func (c *Client) ListPubsubs(i *ListPubsubsInput) ([]*Pubsub, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/pubsub", i.Service, i.Version) + path := fmt.Sprintf("/service/%s/version/%d/logging/pubsub", i.ServiceID, i.ServiceVersion) resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -71,10 +71,11 @@ func (c *Client) ListPubsubs(i *ListPubsubsInput) ([]*Pubsub, error) { // CreatePubsubInput is used as input to the CreatePubsub function. type CreatePubsubInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int Name *string `form:"name,omitempty"` Topic *string `form:"topic,omitempty"` @@ -89,15 +90,15 @@ type CreatePubsubInput struct { // CreatePubsub creates a new Fastly Pubsub. func (c *Client) CreatePubsub(i *CreatePubsubInput) (*Pubsub, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/pubsub", i.Service, i.Version) + path := fmt.Sprintf("/service/%s/version/%d/logging/pubsub", i.ServiceID, i.ServiceVersion) resp, err := c.PostForm(path, i, nil) if err != nil { return nil, err @@ -112,10 +113,11 @@ func (c *Client) CreatePubsub(i *CreatePubsubInput) (*Pubsub, error) { // GetPubsubInput is used as input to the GetPubsub function. type GetPubsubInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int // Name is the name of the Pubsub to fetch. Name string @@ -123,19 +125,19 @@ type GetPubsubInput struct { // GetPubsub gets the Pubsub configuration with the given parameters. func (c *Client) GetPubsub(i *GetPubsubInput) (*Pubsub, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } if i.Name == "" { return nil, ErrMissingName } - path := fmt.Sprintf("/service/%s/version/%d/logging/pubsub/%s", i.Service, i.Version, url.PathEscape(i.Name)) + path := fmt.Sprintf("/service/%s/version/%d/logging/pubsub/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -150,10 +152,11 @@ func (c *Client) GetPubsub(i *GetPubsubInput) (*Pubsub, error) { // UpdatePubsubInput is used as input to the UpdatePubsub function. type UpdatePubsubInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int // Name is the name of the Pubsub to update. Name string @@ -171,19 +174,19 @@ type UpdatePubsubInput struct { // UpdatePubsub updates a specific Pubsub. func (c *Client) UpdatePubsub(i *UpdatePubsubInput) (*Pubsub, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } if i.Name == "" { return nil, ErrMissingName } - path := fmt.Sprintf("/service/%s/version/%d/logging/pubsub/%s", i.Service, i.Version, url.PathEscape(i.Name)) + path := fmt.Sprintf("/service/%s/version/%d/logging/pubsub/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) resp, err := c.PutForm(path, i, nil) if err != nil { return nil, err @@ -198,10 +201,11 @@ func (c *Client) UpdatePubsub(i *UpdatePubsubInput) (*Pubsub, error) { // DeletePubsubInput is the input parameter to DeletePubsub. type DeletePubsubInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int // Name is the name of the Pubsub to delete (required). Name string @@ -209,19 +213,19 @@ type DeletePubsubInput struct { // DeletePubsub deletes the given Pubsub version. func (c *Client) DeletePubsub(i *DeletePubsubInput) error { - if i.Service == "" { - return ErrMissingService + if i.ServiceID == "" { + return ErrMissingServiceID } - if i.Version == 0 { - return ErrMissingVersion + if i.ServiceVersion == 0 { + return ErrMissingServiceVersion } if i.Name == "" { return ErrMissingName } - path := fmt.Sprintf("/service/%s/version/%d/logging/pubsub/%s", i.Service, i.Version, url.PathEscape(i.Name)) + path := fmt.Sprintf("/service/%s/version/%d/logging/pubsub/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) resp, err := c.Delete(path, nil) if err != nil { return err diff --git a/fastly/pubsub_test.go b/fastly/pubsub_test.go index 643e91076..d8bdea61d 100644 --- a/fastly/pubsub_test.go +++ b/fastly/pubsub_test.go @@ -15,16 +15,16 @@ func TestClient_Pubsubs(t *testing.T) { var pubsub *Pubsub record(t, "pubsubs/create", func(c *Client) { pubsub, err = c.CreatePubsub(&CreatePubsubInput{ - Service: testServiceID, - Version: tv.Number, - Name: String("test-pubsub"), - Topic: String("topic"), - User: String("user"), - SecretKey: String("-----BEGIN PRIVATE KEY-----\nMIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQC9aQoqdHVA86oq\nTdRQ5HqwMfpiLBBMKNQcAJsO71RKNrDWwJJZiyYbvM4FOWRZFtRSdPIDgX0C0Wg1\nNnqWYvHDyA5Ug+T8kowiQDn56dU6Km2FWO4wnqZeA8q5G7rQVXlqdibuiP7FglHA\neURUzFsqyymXMUGrqDPqrHsVWC2E3NTJEb4QlywtrwI13qbhlvTx6/9oRfUjytXJ\nRuUIE5xL8yhRCagNr5ZW250aa+wBwu5DSCk5fDNr0eDuZjw84WHDll+mHxBFGV+X\nKJ5jCOmGumGqjVWZesJpNN1My3M9bsY9layNJJ0eiDeHDEi/yXhhO/mNEXhvhq/R\nfN0Jh2A3AgMBAAECggEAef+CEL5aF6/aVs0yh7fiXkKSp1ECXkud8ztgpEn63KJF\nXM1EdnBt50fA2xSQUeGmeEXi6+cngf0nRb8FToAEgLoGoOEjSJuLrzP3I8U9Fe3m\nBRG2uZI2Ti/bD0eRGEc1oSDhCpsqnkTGK1bwcD4AKpwY+c08Izh/2BOoY6McDoqh\ndQ89jzTuMtD4cNlnPiIrY9HbxoNjshK2ax1OaeXyYKZFG1TxqMFv5gA/G5+S3Cwr\nVG4fkAxYi5vdIK3b8jUXrTM/kpoTl+d3dlQ7rRZYf7KyT31/HtJ/GNzxFI6upzO7\niDNrrUOyeOPjWXdzUh9budv3j+6UfbYK7uZIoebHIQKBgQDykYX1L/akGaOC2tfS\njzCWUzPxGFYVZQ7zD1PM6UyouuS1KLURDEGk9RxqVzTPh/pYd8Ivnz3vOVski5Zt\n19ozLGxdtDhn122DcnVpfCdYzHBdAzPCzORenFohX+MhiX5fEotTlVi7wfOmzTP5\nhUCMSd/17bJrV4XMLhkdrMRBFQKBgQDH5fwV7o+Ej/ZfcdGIa3mAFazToPDzxhHU\nnwADxaxpNGKRU03XCaiYkykarLYdG6Rk+7dXUv8eLy+6Dcq1SWQtfCWKEor++IIp\n1RwWmFHfYriHGkmxSkkEkLFvL8old9xM5YWbEXc4QIXvnfR4BZxdyJHVzIDdbI2i\nFgcn17U3GwKBgDd1njMY7ENIuWHJt16k7m7wRwfwkH4DxQ89ieNn0+cgE/p3fC6R\nptCYWg7WMXThmhNwDi3lMrvnWTdZ0uL6XyEkHwKtmdfkIV3UZZPglv5uf6JEgSkg\nv3YCOXk3+y5HyWTjUIejtc334kVY1XFPThrFKTeJSSnRsP2l7IgkYBqhAoGAYGsr\nM3z1FrDF2nWw5odIfKJ30UAw2LRyB0eGH0uqhLgyzvwKcK2E98sLqYUi9llN6zOK\n1IEA8xM5hxl97AFxY4sdJEMbbi55wim7uZ5Q51nbvbbNUsmM/Lm6C/JWI8pzpVeU\nIR7EjYp50AE1WOsD6CyFQ0W35pWkn0jWvL4L938CgYEAlax4dLE5+YCG5DeLT1/N\nin6kQjl7JS4oCNlPEj6aRPLX2OJresI7oOn+uNatKvlVyfPm6rdxeHCmER1FpR7Q\nA/aNVjPeViKT/R4nK9ytsa+s/1IJVrwLFHJK3toGE660g5w3vKrCjWisMdP4yzzQ\nbv1KwcKoQbNVXwauH79JKc0=\n-----END PRIVATE KEY-----\n"), - ProjectID: String("project-id"), - FormatVersion: Uint(2), - Format: String("format"), - Placement: String("waf_debug"), + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: String("test-pubsub"), + Topic: String("topic"), + User: String("user"), + SecretKey: String("-----BEGIN PRIVATE KEY-----\nMIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQC9aQoqdHVA86oq\nTdRQ5HqwMfpiLBBMKNQcAJsO71RKNrDWwJJZiyYbvM4FOWRZFtRSdPIDgX0C0Wg1\nNnqWYvHDyA5Ug+T8kowiQDn56dU6Km2FWO4wnqZeA8q5G7rQVXlqdibuiP7FglHA\neURUzFsqyymXMUGrqDPqrHsVWC2E3NTJEb4QlywtrwI13qbhlvTx6/9oRfUjytXJ\nRuUIE5xL8yhRCagNr5ZW250aa+wBwu5DSCk5fDNr0eDuZjw84WHDll+mHxBFGV+X\nKJ5jCOmGumGqjVWZesJpNN1My3M9bsY9layNJJ0eiDeHDEi/yXhhO/mNEXhvhq/R\nfN0Jh2A3AgMBAAECggEAef+CEL5aF6/aVs0yh7fiXkKSp1ECXkud8ztgpEn63KJF\nXM1EdnBt50fA2xSQUeGmeEXi6+cngf0nRb8FToAEgLoGoOEjSJuLrzP3I8U9Fe3m\nBRG2uZI2Ti/bD0eRGEc1oSDhCpsqnkTGK1bwcD4AKpwY+c08Izh/2BOoY6McDoqh\ndQ89jzTuMtD4cNlnPiIrY9HbxoNjshK2ax1OaeXyYKZFG1TxqMFv5gA/G5+S3Cwr\nVG4fkAxYi5vdIK3b8jUXrTM/kpoTl+d3dlQ7rRZYf7KyT31/HtJ/GNzxFI6upzO7\niDNrrUOyeOPjWXdzUh9budv3j+6UfbYK7uZIoebHIQKBgQDykYX1L/akGaOC2tfS\njzCWUzPxGFYVZQ7zD1PM6UyouuS1KLURDEGk9RxqVzTPh/pYd8Ivnz3vOVski5Zt\n19ozLGxdtDhn122DcnVpfCdYzHBdAzPCzORenFohX+MhiX5fEotTlVi7wfOmzTP5\nhUCMSd/17bJrV4XMLhkdrMRBFQKBgQDH5fwV7o+Ej/ZfcdGIa3mAFazToPDzxhHU\nnwADxaxpNGKRU03XCaiYkykarLYdG6Rk+7dXUv8eLy+6Dcq1SWQtfCWKEor++IIp\n1RwWmFHfYriHGkmxSkkEkLFvL8old9xM5YWbEXc4QIXvnfR4BZxdyJHVzIDdbI2i\nFgcn17U3GwKBgDd1njMY7ENIuWHJt16k7m7wRwfwkH4DxQ89ieNn0+cgE/p3fC6R\nptCYWg7WMXThmhNwDi3lMrvnWTdZ0uL6XyEkHwKtmdfkIV3UZZPglv5uf6JEgSkg\nv3YCOXk3+y5HyWTjUIejtc334kVY1XFPThrFKTeJSSnRsP2l7IgkYBqhAoGAYGsr\nM3z1FrDF2nWw5odIfKJ30UAw2LRyB0eGH0uqhLgyzvwKcK2E98sLqYUi9llN6zOK\n1IEA8xM5hxl97AFxY4sdJEMbbi55wim7uZ5Q51nbvbbNUsmM/Lm6C/JWI8pzpVeU\nIR7EjYp50AE1WOsD6CyFQ0W35pWkn0jWvL4L938CgYEAlax4dLE5+YCG5DeLT1/N\nin6kQjl7JS4oCNlPEj6aRPLX2OJresI7oOn+uNatKvlVyfPm6rdxeHCmER1FpR7Q\nA/aNVjPeViKT/R4nK9ytsa+s/1IJVrwLFHJK3toGE660g5w3vKrCjWisMdP4yzzQ\nbv1KwcKoQbNVXwauH79JKc0=\n-----END PRIVATE KEY-----\n"), + ProjectID: String("project-id"), + FormatVersion: Uint(2), + Format: String("format"), + Placement: String("waf_debug"), }) }) if err != nil { @@ -35,15 +35,15 @@ func TestClient_Pubsubs(t *testing.T) { defer func() { record(t, "pubsubs/cleanup", func(c *Client) { c.DeletePubsub(&DeletePubsubInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-pubsub", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "test-pubsub", }) c.DeletePubsub(&DeletePubsubInput{ - Service: testServiceID, - Version: tv.Number, - Name: "new-test-pubsub", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "new-test-pubsub", }) }) }() @@ -77,8 +77,8 @@ func TestClient_Pubsubs(t *testing.T) { var pubsubs []*Pubsub record(t, "pubsubs/list", func(c *Client) { pubsubs, err = c.ListPubsubs(&ListPubsubsInput{ - Service: testServiceID, - Version: tv.Number, + ServiceID: testServiceID, + ServiceVersion: tv.Number, }) }) if err != nil { @@ -92,9 +92,9 @@ func TestClient_Pubsubs(t *testing.T) { var npubsub *Pubsub record(t, "pubsubs/get", func(c *Client) { npubsub, err = c.GetPubsub(&GetPubsubInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-pubsub", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "test-pubsub", }) }) if err != nil { @@ -129,11 +129,11 @@ func TestClient_Pubsubs(t *testing.T) { var upubsub *Pubsub record(t, "pubsubs/update", func(c *Client) { upubsub, err = c.UpdatePubsub(&UpdatePubsubInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-pubsub", - NewName: String("new-test-pubsub"), - Topic: String("new-topic"), + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "test-pubsub", + NewName: String("new-test-pubsub"), + Topic: String("new-topic"), }) }) if err != nil { @@ -149,9 +149,9 @@ func TestClient_Pubsubs(t *testing.T) { // Delete record(t, "pubsubs/delete", func(c *Client) { err = c.DeletePubsub(&DeletePubsubInput{ - Service: testServiceID, - Version: tv.Number, - Name: "new-test-pubsub", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "new-test-pubsub", }) }) if err != nil { @@ -162,17 +162,17 @@ func TestClient_Pubsubs(t *testing.T) { func TestClient_ListPubsubs_validation(t *testing.T) { var err error _, err = testClient.ListPubsubs(&ListPubsubsInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.ListPubsubs(&ListPubsubsInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } } @@ -180,17 +180,17 @@ func TestClient_ListPubsubs_validation(t *testing.T) { func TestClient_CreatePubsub_validation(t *testing.T) { var err error _, err = testClient.CreatePubsub(&CreatePubsubInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.CreatePubsub(&CreatePubsubInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } } @@ -198,24 +198,24 @@ func TestClient_CreatePubsub_validation(t *testing.T) { func TestClient_GetPubsub_validation(t *testing.T) { var err error _, err = testClient.GetPubsub(&GetPubsubInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.GetPubsub(&GetPubsubInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } _, err = testClient.GetPubsub(&GetPubsubInput{ - Service: "foo", - Version: 1, - Name: "", + ServiceID: "foo", + ServiceVersion: 1, + Name: "", }) if err != ErrMissingName { t.Errorf("bad error: %s", err) @@ -225,24 +225,24 @@ func TestClient_GetPubsub_validation(t *testing.T) { func TestClient_UpdatePubsub_validation(t *testing.T) { var err error _, err = testClient.UpdatePubsub(&UpdatePubsubInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.UpdatePubsub(&UpdatePubsubInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } _, err = testClient.UpdatePubsub(&UpdatePubsubInput{ - Service: "foo", - Version: 1, - Name: "", + ServiceID: "foo", + ServiceVersion: 1, + Name: "", }) if err != ErrMissingName { t.Errorf("bad error: %s", err) @@ -252,24 +252,24 @@ func TestClient_UpdatePubsub_validation(t *testing.T) { func TestClient_DeletePubsub_validation(t *testing.T) { var err error err = testClient.DeletePubsub(&DeletePubsubInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } err = testClient.DeletePubsub(&DeletePubsubInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } err = testClient.DeletePubsub(&DeletePubsubInput{ - Service: "foo", - Version: 1, - Name: "", + ServiceID: "foo", + ServiceVersion: 1, + Name: "", }) if err != ErrMissingName { t.Errorf("bad error: %s", err) diff --git a/fastly/purge.go b/fastly/purge.go index 58d3bc4c3..1243626a1 100644 --- a/fastly/purge.go +++ b/fastly/purge.go @@ -46,8 +46,8 @@ func (c *Client) Purge(i *PurgeInput) (*Purge, error) { // PurgeKeyInput is used as input to the Purge function. type PurgeKeyInput struct { - // Service is the ID of the service (required). - Service string + // ServiceID is the ID of the service (required). + ServiceID string // Key is the key to purge (required). Key string @@ -58,15 +58,15 @@ type PurgeKeyInput struct { // PurgeKey instantly purges a particular service of items tagged with a key. func (c *Client) PurgeKey(i *PurgeKeyInput) (*Purge, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } if i.Key == "" { return nil, ErrMissingKey } - path := fmt.Sprintf("/service/%s/purge/%s", i.Service, i.Key) + path := fmt.Sprintf("/service/%s/purge/%s", i.ServiceID, i.Key) ro := new(RequestOptions) ro.Parallel = true @@ -93,8 +93,8 @@ func (c *Client) PurgeKey(i *PurgeKeyInput) (*Purge, error) { // PurgeAllInput is used as input to the Purge function. type PurgeAllInput struct { - // Service is the ID of the service (required). - Service string + // ServiceID is the ID of the service (required). + ServiceID string // Soft performs a soft purge. Soft bool @@ -102,11 +102,11 @@ type PurgeAllInput struct { // PurgeAll instantly purges everything from a service. func (c *Client) PurgeAll(i *PurgeAllInput) (*Purge, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - path := fmt.Sprintf("/service/%s/purge_all", i.Service) + path := fmt.Sprintf("/service/%s/purge_all", i.ServiceID) req, err := c.RawRequest("POST", path, nil) if err != nil { return nil, err diff --git a/fastly/purge_test.go b/fastly/purge_test.go index a374d1374..7e9fdb75e 100644 --- a/fastly/purge_test.go +++ b/fastly/purge_test.go @@ -9,8 +9,8 @@ func TestClient_Purge(t *testing.T) { var purge *Purge record(t, "purges/purge_by_key", func(c *Client) { purge, err = c.PurgeKey(&PurgeKeyInput{ - Service: testServiceID, - Key: "foo", + ServiceID: testServiceID, + Key: "foo", }) }) if err != nil { diff --git a/fastly/realtime_stats.go b/fastly/realtime_stats.go index 0b8618e35..5da3ab2ed 100644 --- a/fastly/realtime_stats.go +++ b/fastly/realtime_stats.go @@ -48,7 +48,7 @@ func (c *RTSClient) GetRealtimeStats(i *GetRealtimeStatsInput) (*RealtimeStatsRe // GetRealtimeStatsJSON fetches stats and decodes the response directly to the JSON struct dst. func (c *RTSClient) GetRealtimeStatsJSON(i *GetRealtimeStatsInput, dst interface{}) error { if i.Service == "" { - return ErrMissingService + return ErrMissingServiceID } path := fmt.Sprintf("/v1/channel/%s/ts/%d", i.Service, i.Timestamp) diff --git a/fastly/realtime_stats_test.go b/fastly/realtime_stats_test.go index 93bd2c5c7..2ef8268c9 100644 --- a/fastly/realtime_stats_test.go +++ b/fastly/realtime_stats_test.go @@ -9,7 +9,7 @@ func TestClient_GetRealtimeStats_validation(t *testing.T) { _, err = testStatsClient.GetRealtimeStats(&GetRealtimeStatsInput{ Service: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } } diff --git a/fastly/request_setting.go b/fastly/request_setting.go index 2ebbd0155..6d17ef02b 100644 --- a/fastly/request_setting.go +++ b/fastly/request_setting.go @@ -74,25 +74,25 @@ func (s requestSettingsByName) Less(i, j int) bool { // ListRequestSettingsInput is used as input to the ListRequestSettings // function. type ListRequestSettingsInput struct { - // Service is the ID of the service (required). - Service string + // ServiceID is the ID of the service (required). + ServiceID string - // Version is the specific configuration version (required). - Version int + // ServiceVersion is the specific configuration version (required). + ServiceVersion int } // ListRequestSettings returns the list of request settings for the // configuration version. func (c *Client) ListRequestSettings(i *ListRequestSettingsInput) ([]*RequestSetting, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/request_settings", i.Service, i.Version) + path := fmt.Sprintf("/service/%s/version/%d/request_settings", i.ServiceID, i.ServiceVersion) resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -109,10 +109,11 @@ func (c *Client) ListRequestSettings(i *ListRequestSettingsInput) ([]*RequestSet // CreateRequestSettingInput is used as input to the CreateRequestSetting // function. type CreateRequestSettingInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int Name string `form:"name,omitempty"` ForceMiss *Compatibool `form:"force_miss,omitempty"` @@ -130,15 +131,15 @@ type CreateRequestSettingInput struct { // CreateRequestSetting creates a new Fastly request settings. func (c *Client) CreateRequestSetting(i *CreateRequestSettingInput) (*RequestSetting, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/request_settings", i.Service, i.Version) + path := fmt.Sprintf("/service/%s/version/%d/request_settings", i.ServiceID, i.ServiceVersion) resp, err := c.PostForm(path, i, nil) if err != nil { return nil, err @@ -153,10 +154,11 @@ func (c *Client) CreateRequestSetting(i *CreateRequestSettingInput) (*RequestSet // GetRequestSettingInput is used as input to the GetRequestSetting function. type GetRequestSettingInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int // Name is the name of the request settings to fetch. Name string @@ -165,19 +167,19 @@ type GetRequestSettingInput struct { // GetRequestSetting gets the request settings configuration with the given // parameters. func (c *Client) GetRequestSetting(i *GetRequestSettingInput) (*RequestSetting, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } if i.Name == "" { return nil, ErrMissingName } - path := fmt.Sprintf("/service/%s/version/%d/request_settings/%s", i.Service, i.Version, url.PathEscape(i.Name)) + path := fmt.Sprintf("/service/%s/version/%d/request_settings/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -193,10 +195,11 @@ func (c *Client) GetRequestSetting(i *GetRequestSettingInput) (*RequestSetting, // UpdateRequestSettingInput is used as input to the UpdateRequestSetting // function. type UpdateRequestSettingInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int // Name is the name of the request settings to update. Name string @@ -217,19 +220,19 @@ type UpdateRequestSettingInput struct { // UpdateRequestSetting updates a specific request settings. func (c *Client) UpdateRequestSetting(i *UpdateRequestSettingInput) (*RequestSetting, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } if i.Name == "" { return nil, ErrMissingName } - path := fmt.Sprintf("/service/%s/version/%d/request_settings/%s", i.Service, i.Version, url.PathEscape(i.Name)) + path := fmt.Sprintf("/service/%s/version/%d/request_settings/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) resp, err := c.PutForm(path, i, nil) if err != nil { return nil, err @@ -244,10 +247,11 @@ func (c *Client) UpdateRequestSetting(i *UpdateRequestSettingInput) (*RequestSet // DeleteRequestSettingInput is the input parameter to DeleteRequestSetting. type DeleteRequestSettingInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int // Name is the name of the request settings to delete (required). Name string @@ -255,19 +259,19 @@ type DeleteRequestSettingInput struct { // DeleteRequestSetting deletes the given request settings version. func (c *Client) DeleteRequestSetting(i *DeleteRequestSettingInput) error { - if i.Service == "" { - return ErrMissingService + if i.ServiceID == "" { + return ErrMissingServiceID } - if i.Version == 0 { - return ErrMissingVersion + if i.ServiceVersion == 0 { + return ErrMissingServiceVersion } if i.Name == "" { return ErrMissingName } - path := fmt.Sprintf("/service/%s/version/%d/request_settings/%s", i.Service, i.Version, url.PathEscape(i.Name)) + path := fmt.Sprintf("/service/%s/version/%d/request_settings/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) resp, err := c.Delete(path, nil) if err != nil { return err diff --git a/fastly/request_setting_test.go b/fastly/request_setting_test.go index 5a487290d..e4ef270aa 100644 --- a/fastly/request_setting_test.go +++ b/fastly/request_setting_test.go @@ -15,8 +15,8 @@ func TestClient_RequestSettings(t *testing.T) { var rs *RequestSetting record(t, "request_settings/create", func(c *Client) { rs, err = c.CreateRequestSetting(&CreateRequestSettingInput{ - Service: testServiceID, - Version: tv.Number, + ServiceID: testServiceID, + ServiceVersion: tv.Number, Name: "test-request-setting", ForceMiss: CBool(true), ForceSSL: CBool(true), @@ -38,15 +38,15 @@ func TestClient_RequestSettings(t *testing.T) { defer func() { record(t, "request_settings/cleanup", func(c *Client) { c.DeleteRequestSetting(&DeleteRequestSettingInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-request-setting", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "test-request-setting", }) c.DeleteRequestSetting(&DeleteRequestSettingInput{ - Service: testServiceID, - Version: tv.Number, - Name: "new-test-request-setting", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "new-test-request-setting", }) }) }() @@ -89,8 +89,8 @@ func TestClient_RequestSettings(t *testing.T) { var rss []*RequestSetting record(t, "request_settings/list", func(c *Client) { rss, err = c.ListRequestSettings(&ListRequestSettingsInput{ - Service: testServiceID, - Version: tv.Number, + ServiceID: testServiceID, + ServiceVersion: tv.Number, }) }) if err != nil { @@ -104,9 +104,9 @@ func TestClient_RequestSettings(t *testing.T) { var nrs *RequestSetting record(t, "request_settings/get", func(c *Client) { nrs, err = c.GetRequestSetting(&GetRequestSettingInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-request-setting", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "test-request-setting", }) }) if err != nil { @@ -150,10 +150,10 @@ func TestClient_RequestSettings(t *testing.T) { var urs *RequestSetting record(t, "request_settings/update", func(c *Client) { urs, err = c.UpdateRequestSetting(&UpdateRequestSettingInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-request-setting", - NewName: "new-test-request-setting", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "test-request-setting", + NewName: "new-test-request-setting", }) }) if err != nil { @@ -166,9 +166,9 @@ func TestClient_RequestSettings(t *testing.T) { // Delete record(t, "request_settings/delete", func(c *Client) { err = c.DeleteRequestSetting(&DeleteRequestSettingInput{ - Service: testServiceID, - Version: tv.Number, - Name: "new-test-request-setting", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "new-test-request-setting", }) }) if err != nil { @@ -179,17 +179,17 @@ func TestClient_RequestSettings(t *testing.T) { func TestClient_ListRequestSettings_validation(t *testing.T) { var err error _, err = testClient.ListRequestSettings(&ListRequestSettingsInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.ListRequestSettings(&ListRequestSettingsInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } } @@ -197,17 +197,17 @@ func TestClient_ListRequestSettings_validation(t *testing.T) { func TestClient_CreateRequestSetting_validation(t *testing.T) { var err error _, err = testClient.CreateRequestSetting(&CreateRequestSettingInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.CreateRequestSetting(&CreateRequestSettingInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } } @@ -215,24 +215,24 @@ func TestClient_CreateRequestSetting_validation(t *testing.T) { func TestClient_GetRequestSetting_validation(t *testing.T) { var err error _, err = testClient.GetRequestSetting(&GetRequestSettingInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.GetRequestSetting(&GetRequestSettingInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } _, err = testClient.GetRequestSetting(&GetRequestSettingInput{ - Service: "foo", - Version: 1, - Name: "", + ServiceID: "foo", + ServiceVersion: 1, + Name: "", }) if err != ErrMissingName { t.Errorf("bad error: %s", err) @@ -242,24 +242,24 @@ func TestClient_GetRequestSetting_validation(t *testing.T) { func TestClient_UpdateRequestSetting_validation(t *testing.T) { var err error _, err = testClient.UpdateRequestSetting(&UpdateRequestSettingInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.UpdateRequestSetting(&UpdateRequestSettingInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } _, err = testClient.UpdateRequestSetting(&UpdateRequestSettingInput{ - Service: "foo", - Version: 1, - Name: "", + ServiceID: "foo", + ServiceVersion: 1, + Name: "", }) if err != ErrMissingName { t.Errorf("bad error: %s", err) @@ -269,24 +269,24 @@ func TestClient_UpdateRequestSetting_validation(t *testing.T) { func TestClient_DeleteRequestSetting_validation(t *testing.T) { var err error err = testClient.DeleteRequestSetting(&DeleteRequestSettingInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } err = testClient.DeleteRequestSetting(&DeleteRequestSettingInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } err = testClient.DeleteRequestSetting(&DeleteRequestSettingInput{ - Service: "foo", - Version: 1, - Name: "", + ServiceID: "foo", + ServiceVersion: 1, + Name: "", }) if err != ErrMissingName { t.Errorf("bad error: %s", err) diff --git a/fastly/response_object.go b/fastly/response_object.go index 35a994679..92bf73898 100644 --- a/fastly/response_object.go +++ b/fastly/response_object.go @@ -37,25 +37,25 @@ func (s responseObjectsByName) Less(i, j int) bool { // ListResponseObjectsInput is used as input to the ListResponseObjects // function. type ListResponseObjectsInput struct { - // Service is the ID of the service (required). - Service string + // ServiceID is the ID of the service (required). + ServiceID string - // Version is the specific configuration version (required). - Version int + // ServiceVersion is the specific configuration version (required). + ServiceVersion int } // ListResponseObjects returns the list of response objects for the // configuration version. func (c *Client) ListResponseObjects(i *ListResponseObjectsInput) ([]*ResponseObject, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/response_object", i.Service, i.Version) + path := fmt.Sprintf("/service/%s/version/%d/response_object", i.ServiceID, i.ServiceVersion) resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -72,10 +72,11 @@ func (c *Client) ListResponseObjects(i *ListResponseObjectsInput) ([]*ResponseOb // CreateResponseObjectInput is used as input to the CreateResponseObject // function. type CreateResponseObjectInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int Name string `form:"name,omitempty"` Status uint `form:"status,omitempty"` @@ -88,15 +89,15 @@ type CreateResponseObjectInput struct { // CreateResponseObject creates a new Fastly response object. func (c *Client) CreateResponseObject(i *CreateResponseObjectInput) (*ResponseObject, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/response_object", i.Service, i.Version) + path := fmt.Sprintf("/service/%s/version/%d/response_object", i.ServiceID, i.ServiceVersion) resp, err := c.PostForm(path, i, nil) if err != nil { return nil, err @@ -111,10 +112,11 @@ func (c *Client) CreateResponseObject(i *CreateResponseObjectInput) (*ResponseOb // GetResponseObjectInput is used as input to the GetResponseObject function. type GetResponseObjectInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int // Name is the name of the response object to fetch. Name string @@ -123,19 +125,19 @@ type GetResponseObjectInput struct { // GetResponseObject gets the response object configuration with the given // parameters. func (c *Client) GetResponseObject(i *GetResponseObjectInput) (*ResponseObject, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } if i.Name == "" { return nil, ErrMissingName } - path := fmt.Sprintf("/service/%s/version/%d/response_object/%s", i.Service, i.Version, url.PathEscape(i.Name)) + path := fmt.Sprintf("/service/%s/version/%d/response_object/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -151,10 +153,11 @@ func (c *Client) GetResponseObject(i *GetResponseObjectInput) (*ResponseObject, // UpdateResponseObjectInput is used as input to the UpdateResponseObject // function. type UpdateResponseObjectInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int // Name is the name of the response object to update. Name string @@ -170,19 +173,19 @@ type UpdateResponseObjectInput struct { // UpdateResponseObject updates a specific response object. func (c *Client) UpdateResponseObject(i *UpdateResponseObjectInput) (*ResponseObject, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } if i.Name == "" { return nil, ErrMissingName } - path := fmt.Sprintf("/service/%s/version/%d/response_object/%s", i.Service, i.Version, url.PathEscape(i.Name)) + path := fmt.Sprintf("/service/%s/version/%d/response_object/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) resp, err := c.PutForm(path, i, nil) if err != nil { return nil, err @@ -197,10 +200,11 @@ func (c *Client) UpdateResponseObject(i *UpdateResponseObjectInput) (*ResponseOb // DeleteResponseObjectInput is the input parameter to DeleteResponseObject. type DeleteResponseObjectInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int // Name is the name of the response object to delete (required). Name string @@ -208,19 +212,19 @@ type DeleteResponseObjectInput struct { // DeleteResponseObject deletes the given response object version. func (c *Client) DeleteResponseObject(i *DeleteResponseObjectInput) error { - if i.Service == "" { - return ErrMissingService + if i.ServiceID == "" { + return ErrMissingServiceID } - if i.Version == 0 { - return ErrMissingVersion + if i.ServiceVersion == 0 { + return ErrMissingServiceVersion } if i.Name == "" { return ErrMissingName } - path := fmt.Sprintf("/service/%s/version/%d/response_object/%s", i.Service, i.Version, url.PathEscape(i.Name)) + path := fmt.Sprintf("/service/%s/version/%d/response_object/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) resp, err := c.Delete(path, nil) if err != nil { return err diff --git a/fastly/response_object_test.go b/fastly/response_object_test.go index 87d530f1a..cb988bcaf 100644 --- a/fastly/response_object_test.go +++ b/fastly/response_object_test.go @@ -15,13 +15,13 @@ func TestClient_ResponseObjects(t *testing.T) { var ro *ResponseObject record(t, "response_objects/create", func(c *Client) { ro, err = c.CreateResponseObject(&CreateResponseObjectInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-response-object", - Status: 200, - Response: "Ok", - Content: "abcd", - ContentType: "text/plain", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "test-response-object", + Status: 200, + Response: "Ok", + Content: "abcd", + ContentType: "text/plain", }) }) if err != nil { @@ -32,15 +32,15 @@ func TestClient_ResponseObjects(t *testing.T) { defer func() { record(t, "response_objects/cleanup", func(c *Client) { c.DeleteResponseObject(&DeleteResponseObjectInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-response-object", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "test-response-object", }) c.DeleteResponseObject(&DeleteResponseObjectInput{ - Service: testServiceID, - Version: tv.Number, - Name: "new-test-response-object", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "new-test-response-object", }) }) }() @@ -65,8 +65,8 @@ func TestClient_ResponseObjects(t *testing.T) { var ros []*ResponseObject record(t, "response_objects/list", func(c *Client) { ros, err = c.ListResponseObjects(&ListResponseObjectsInput{ - Service: testServiceID, - Version: tv.Number, + ServiceID: testServiceID, + ServiceVersion: tv.Number, }) }) if err != nil { @@ -80,9 +80,9 @@ func TestClient_ResponseObjects(t *testing.T) { var nro *ResponseObject record(t, "response_objects/get", func(c *Client) { nro, err = c.GetResponseObject(&GetResponseObjectInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-response-object", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "test-response-object", }) }) if err != nil { @@ -108,10 +108,10 @@ func TestClient_ResponseObjects(t *testing.T) { var uro *ResponseObject record(t, "response_objects/update", func(c *Client) { uro, err = c.UpdateResponseObject(&UpdateResponseObjectInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-response-object", - NewName: "new-test-response-object", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "test-response-object", + NewName: "new-test-response-object", }) }) if err != nil { @@ -124,9 +124,9 @@ func TestClient_ResponseObjects(t *testing.T) { // Delete record(t, "response_objects/delete", func(c *Client) { err = c.DeleteResponseObject(&DeleteResponseObjectInput{ - Service: testServiceID, - Version: tv.Number, - Name: "new-test-response-object", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "new-test-response-object", }) }) if err != nil { @@ -137,17 +137,17 @@ func TestClient_ResponseObjects(t *testing.T) { func TestClient_ListResponseObjects_validation(t *testing.T) { var err error _, err = testClient.ListResponseObjects(&ListResponseObjectsInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.ListResponseObjects(&ListResponseObjectsInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } } @@ -155,17 +155,17 @@ func TestClient_ListResponseObjects_validation(t *testing.T) { func TestClient_CreateResponseObject_validation(t *testing.T) { var err error _, err = testClient.CreateResponseObject(&CreateResponseObjectInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.CreateResponseObject(&CreateResponseObjectInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } } @@ -173,24 +173,24 @@ func TestClient_CreateResponseObject_validation(t *testing.T) { func TestClient_GetResponseObject_validation(t *testing.T) { var err error _, err = testClient.GetResponseObject(&GetResponseObjectInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.GetResponseObject(&GetResponseObjectInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } _, err = testClient.GetResponseObject(&GetResponseObjectInput{ - Service: "foo", - Version: 1, - Name: "", + ServiceID: "foo", + ServiceVersion: 1, + Name: "", }) if err != ErrMissingName { t.Errorf("bad error: %s", err) @@ -200,24 +200,24 @@ func TestClient_GetResponseObject_validation(t *testing.T) { func TestClient_UpdateResponseObject_validation(t *testing.T) { var err error _, err = testClient.UpdateResponseObject(&UpdateResponseObjectInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.UpdateResponseObject(&UpdateResponseObjectInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } _, err = testClient.UpdateResponseObject(&UpdateResponseObjectInput{ - Service: "foo", - Version: 1, - Name: "", + ServiceID: "foo", + ServiceVersion: 1, + Name: "", }) if err != ErrMissingName { t.Errorf("bad error: %s", err) @@ -227,24 +227,24 @@ func TestClient_UpdateResponseObject_validation(t *testing.T) { func TestClient_DeleteResponseObject_validation(t *testing.T) { var err error err = testClient.DeleteResponseObject(&DeleteResponseObjectInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } err = testClient.DeleteResponseObject(&DeleteResponseObjectInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } err = testClient.DeleteResponseObject(&DeleteResponseObjectInput{ - Service: "foo", - Version: 1, - Name: "", + ServiceID: "foo", + ServiceVersion: 1, + Name: "", }) if err != ErrMissingName { t.Errorf("bad error: %s", err) diff --git a/fastly/s3.go b/fastly/s3.go index b8b5ce5de..0c4b48c24 100644 --- a/fastly/s3.go +++ b/fastly/s3.go @@ -57,24 +57,24 @@ func (s s3sByName) Less(i, j int) bool { // ListS3sInput is used as input to the ListS3s function. type ListS3sInput struct { - // Service is the ID of the service (required). - Service string + // ServiceID is the ID of the service (required). + ServiceID string - // Version is the specific configuration version (required). - Version int + // ServiceVersion is the specific configuration version (required). + ServiceVersion int } // ListS3s returns the list of S3s for the configuration version. func (c *Client) ListS3s(i *ListS3sInput) ([]*S3, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/s3", i.Service, i.Version) + path := fmt.Sprintf("/service/%s/version/%d/logging/s3", i.ServiceID, i.ServiceVersion) resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -90,10 +90,11 @@ func (c *Client) ListS3s(i *ListS3sInput) ([]*S3, error) { // CreateS3Input is used as input to the CreateS3 function. type CreateS3Input struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int Name string `form:"name,omitempty"` BucketName string `form:"bucket_name,omitempty"` @@ -117,19 +118,19 @@ type CreateS3Input struct { // CreateS3 creates a new Fastly S3. func (c *Client) CreateS3(i *CreateS3Input) (*S3, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } if i.ServerSideEncryption == S3ServerSideEncryptionKMS && i.ServerSideEncryptionKMSKeyID == "" { return nil, ErrMissingKMSKeyID } - path := fmt.Sprintf("/service/%s/version/%d/logging/s3", i.Service, i.Version) + path := fmt.Sprintf("/service/%s/version/%d/logging/s3", i.ServiceID, i.ServiceVersion) resp, err := c.PostForm(path, i, nil) if err != nil { return nil, err @@ -144,10 +145,11 @@ func (c *Client) CreateS3(i *CreateS3Input) (*S3, error) { // GetS3Input is used as input to the GetS3 function. type GetS3Input struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int // Name is the name of the S3 to fetch. Name string @@ -155,19 +157,19 @@ type GetS3Input struct { // GetS3 gets the S3 configuration with the given parameters. func (c *Client) GetS3(i *GetS3Input) (*S3, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } if i.Name == "" { return nil, ErrMissingName } - path := fmt.Sprintf("/service/%s/version/%d/logging/s3/%s", i.Service, i.Version, url.PathEscape(i.Name)) + path := fmt.Sprintf("/service/%s/version/%d/logging/s3/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -182,10 +184,11 @@ func (c *Client) GetS3(i *GetS3Input) (*S3, error) { // UpdateS3Input is used as input to the UpdateS3 function. type UpdateS3Input struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int // Name is the name of the S3 to update. Name string @@ -212,12 +215,12 @@ type UpdateS3Input struct { // UpdateS3 updates a specific S3. func (c *Client) UpdateS3(i *UpdateS3Input) (*S3, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } if i.Name == "" { @@ -228,7 +231,7 @@ func (c *Client) UpdateS3(i *UpdateS3Input) (*S3, error) { return nil, ErrMissingKMSKeyID } - path := fmt.Sprintf("/service/%s/version/%d/logging/s3/%s", i.Service, i.Version, url.PathEscape(i.Name)) + path := fmt.Sprintf("/service/%s/version/%d/logging/s3/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) resp, err := c.PutForm(path, i, nil) if err != nil { return nil, err @@ -243,10 +246,11 @@ func (c *Client) UpdateS3(i *UpdateS3Input) (*S3, error) { // DeleteS3Input is the input parameter to DeleteS3. type DeleteS3Input struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int // Name is the name of the S3 to delete (required). Name string @@ -254,19 +258,19 @@ type DeleteS3Input struct { // DeleteS3 deletes the given S3 version. func (c *Client) DeleteS3(i *DeleteS3Input) error { - if i.Service == "" { - return ErrMissingService + if i.ServiceID == "" { + return ErrMissingServiceID } - if i.Version == 0 { - return ErrMissingVersion + if i.ServiceVersion == 0 { + return ErrMissingServiceVersion } if i.Name == "" { return ErrMissingName } - path := fmt.Sprintf("/service/%s/version/%d/logging/s3/%s", i.Service, i.Version, url.PathEscape(i.Name)) + path := fmt.Sprintf("/service/%s/version/%d/logging/s3/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) resp, err := c.Delete(path, nil) if err != nil { return err diff --git a/fastly/s3_test.go b/fastly/s3_test.go index d0f283942..56df9e547 100644 --- a/fastly/s3_test.go +++ b/fastly/s3_test.go @@ -15,8 +15,8 @@ func TestClient_S3s(t *testing.T) { var s3 *S3 record(t, "s3s/create", func(c *Client) { s3, err = c.CreateS3(&CreateS3Input{ - Service: testServiceID, - Version: tv.Number, + ServiceID: testServiceID, + ServiceVersion: tv.Number, Name: "test-s3", BucketName: "bucket-name", Domain: "s3.us-east-1.amazonaws.com", @@ -45,15 +45,15 @@ func TestClient_S3s(t *testing.T) { defer func() { record(t, "s3s/cleanup", func(c *Client) { c.DeleteS3(&DeleteS3Input{ - Service: testServiceID, - Version: tv.Number, - Name: "test-s3", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "test-s3", }) c.DeleteS3(&DeleteS3Input{ - Service: testServiceID, - Version: tv.Number, - Name: "new-test-s3", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "new-test-s3", }) }) }() @@ -118,8 +118,8 @@ func TestClient_S3s(t *testing.T) { var s3s []*S3 record(t, "s3s/list", func(c *Client) { s3s, err = c.ListS3s(&ListS3sInput{ - Service: testServiceID, - Version: tv.Number, + ServiceID: testServiceID, + ServiceVersion: tv.Number, }) }) if err != nil { @@ -133,9 +133,9 @@ func TestClient_S3s(t *testing.T) { var ns3 *S3 record(t, "s3s/get", func(c *Client) { ns3, err = c.GetS3(&GetS3Input{ - Service: testServiceID, - Version: tv.Number, - Name: "test-s3", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "test-s3", }) }) if err != nil { @@ -197,11 +197,11 @@ func TestClient_S3s(t *testing.T) { var us3 *S3 record(t, "s3s/update", func(c *Client) { us3, err = c.UpdateS3(&UpdateS3Input{ - Service: testServiceID, - Version: tv.Number, - Name: "test-s3", - NewName: "new-test-s3", - PublicKey: pgpPublicKeyUpdate(), + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "test-s3", + NewName: "new-test-s3", + PublicKey: pgpPublicKeyUpdate(), }) }) if err != nil { @@ -217,9 +217,9 @@ func TestClient_S3s(t *testing.T) { // Delete record(t, "s3s/delete", func(c *Client) { err = c.DeleteS3(&DeleteS3Input{ - Service: testServiceID, - Version: tv.Number, - Name: "new-test-s3", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "new-test-s3", }) }) if err != nil { @@ -230,17 +230,17 @@ func TestClient_S3s(t *testing.T) { func TestClient_ListS3s_validation(t *testing.T) { var err error _, err = testClient.ListS3s(&ListS3sInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.ListS3s(&ListS3sInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } } @@ -248,23 +248,23 @@ func TestClient_ListS3s_validation(t *testing.T) { func TestClient_CreateS3_validation(t *testing.T) { var err error _, err = testClient.CreateS3(&CreateS3Input{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.CreateS3(&CreateS3Input{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } _, err = testClient.CreateS3(&CreateS3Input{ - Service: "foo", - Version: 1, + ServiceID: "foo", + ServiceVersion: 1, Name: "test-service", ServerSideEncryption: S3ServerSideEncryptionKMS, ServerSideEncryptionKMSKeyID: "", @@ -277,24 +277,24 @@ func TestClient_CreateS3_validation(t *testing.T) { func TestClient_GetS3_validation(t *testing.T) { var err error _, err = testClient.GetS3(&GetS3Input{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.GetS3(&GetS3Input{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } _, err = testClient.GetS3(&GetS3Input{ - Service: "foo", - Version: 1, - Name: "", + ServiceID: "foo", + ServiceVersion: 1, + Name: "", }) if err != ErrMissingName { t.Errorf("bad error: %s", err) @@ -304,32 +304,32 @@ func TestClient_GetS3_validation(t *testing.T) { func TestClient_UpdateS3_validation(t *testing.T) { var err error _, err = testClient.UpdateS3(&UpdateS3Input{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.UpdateS3(&UpdateS3Input{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } _, err = testClient.UpdateS3(&UpdateS3Input{ - Service: "foo", - Version: 1, - Name: "", + ServiceID: "foo", + ServiceVersion: 1, + Name: "", }) if err != ErrMissingName { t.Errorf("bad error: %s", err) } _, err = testClient.UpdateS3(&UpdateS3Input{ - Service: "foo", - Version: 1, + ServiceID: "foo", + ServiceVersion: 1, Name: "test-service", ServerSideEncryption: S3ServerSideEncryptionKMS, ServerSideEncryptionKMSKeyID: "", @@ -342,24 +342,24 @@ func TestClient_UpdateS3_validation(t *testing.T) { func TestClient_DeleteS3_validation(t *testing.T) { var err error err = testClient.DeleteS3(&DeleteS3Input{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } err = testClient.DeleteS3(&DeleteS3Input{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } err = testClient.DeleteS3(&DeleteS3Input{ - Service: "foo", - Version: 1, - Name: "", + ServiceID: "foo", + ServiceVersion: 1, + Name: "", }) if err != ErrMissingName { t.Errorf("bad error: %s", err) diff --git a/fastly/scalyr.go b/fastly/scalyr.go index b7de0cd44..d09ef824d 100644 --- a/fastly/scalyr.go +++ b/fastly/scalyr.go @@ -36,24 +36,24 @@ func (s scalyrsByName) Less(i, j int) bool { // ListScalyrsInput is used as input to the ListScalyrs function. type ListScalyrsInput struct { - // Service is the ID of the service (required). - Service string + // ServiceID is the ID of the service (required). + ServiceID string - // Version is the specific configuration version (required). - Version int + // ServiceVersion is the specific configuration version (required). + ServiceVersion int } // ListScalyrs returns the list of scalyrs for the configuration version. func (c *Client) ListScalyrs(i *ListScalyrsInput) ([]*Scalyr, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/scalyr", i.Service, i.Version) + path := fmt.Sprintf("/service/%s/version/%d/logging/scalyr", i.ServiceID, i.ServiceVersion) resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -69,10 +69,11 @@ func (c *Client) ListScalyrs(i *ListScalyrsInput) ([]*Scalyr, error) { // CreateScalyrInput is used as input to the CreateScalyr function. type CreateScalyrInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int Name *string `form:"name,omitempty"` Format *string `form:"format,omitempty"` @@ -85,15 +86,15 @@ type CreateScalyrInput struct { // CreateScalyr creates a new Fastly scalyr. func (c *Client) CreateScalyr(i *CreateScalyrInput) (*Scalyr, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/scalyr", i.Service, i.Version) + path := fmt.Sprintf("/service/%s/version/%d/logging/scalyr", i.ServiceID, i.ServiceVersion) resp, err := c.PostForm(path, i, nil) if err != nil { return nil, err @@ -108,10 +109,11 @@ func (c *Client) CreateScalyr(i *CreateScalyrInput) (*Scalyr, error) { // GetScalyrInput is used as input to the GetScalyr function. type GetScalyrInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int // Name is the name of the scalyr to fetch. Name string @@ -119,19 +121,19 @@ type GetScalyrInput struct { // GetScalyr gets the scalyr configuration with the given parameters. func (c *Client) GetScalyr(i *GetScalyrInput) (*Scalyr, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } if i.Name == "" { return nil, ErrMissingName } - path := fmt.Sprintf("/service/%s/version/%d/logging/scalyr/%s", i.Service, i.Version, url.PathEscape(i.Name)) + path := fmt.Sprintf("/service/%s/version/%d/logging/scalyr/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -146,10 +148,11 @@ func (c *Client) GetScalyr(i *GetScalyrInput) (*Scalyr, error) { // UpdateScalyrInput is used as input to the UpdateScalyr function. type UpdateScalyrInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int // Name is the name of the scalyr to update. Name string @@ -165,19 +168,19 @@ type UpdateScalyrInput struct { // UpdateScalyr updates a specific scalyr. func (c *Client) UpdateScalyr(i *UpdateScalyrInput) (*Scalyr, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } if i.Name == "" { return nil, ErrMissingName } - path := fmt.Sprintf("/service/%s/version/%d/logging/scalyr/%s", i.Service, i.Version, url.PathEscape(i.Name)) + path := fmt.Sprintf("/service/%s/version/%d/logging/scalyr/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) resp, err := c.PutForm(path, i, nil) if err != nil { return nil, err @@ -192,10 +195,11 @@ func (c *Client) UpdateScalyr(i *UpdateScalyrInput) (*Scalyr, error) { // DeleteScalyrInput is the input parameter to DeleteScalyr. type DeleteScalyrInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int // Name is the name of the scalyr to delete (required). Name string @@ -203,19 +207,19 @@ type DeleteScalyrInput struct { // DeleteScalyr deletes the given scalyr version. func (c *Client) DeleteScalyr(i *DeleteScalyrInput) error { - if i.Service == "" { - return ErrMissingService + if i.ServiceID == "" { + return ErrMissingServiceID } - if i.Version == 0 { - return ErrMissingVersion + if i.ServiceVersion == 0 { + return ErrMissingServiceVersion } if i.Name == "" { return ErrMissingName } - path := fmt.Sprintf("/service/%s/version/%d/logging/scalyr/%s", i.Service, i.Version, url.PathEscape(i.Name)) + path := fmt.Sprintf("/service/%s/version/%d/logging/scalyr/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) resp, err := c.Delete(path, nil) if err != nil { return err diff --git a/fastly/scalyr_test.go b/fastly/scalyr_test.go index e1efaa7fc..e9e0c28c9 100644 --- a/fastly/scalyr_test.go +++ b/fastly/scalyr_test.go @@ -17,14 +17,14 @@ func TestClient_Scalyrs(t *testing.T) { var s *Scalyr record(t, "scalyrs/create", func(c *Client) { s, err = c.CreateScalyr(&CreateScalyrInput{ - Service: testServiceID, - Version: tv.Number, - Name: String("test-scalyr"), - Format: String("%h %l %u %t \"%r\" %>s %b"), - FormatVersion: Uint(2), - Placement: String("waf_debug"), - Region: String("US"), - Token: String("super-secure-token"), + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: String("test-scalyr"), + Format: String("%h %l %u %t \"%r\" %>s %b"), + FormatVersion: Uint(2), + Placement: String("waf_debug"), + Region: String("US"), + Token: String("super-secure-token"), }) }) if err != nil { @@ -35,15 +35,15 @@ func TestClient_Scalyrs(t *testing.T) { defer func() { record(t, "scalyrs/cleanup", func(c *Client) { c.DeleteScalyr(&DeleteScalyrInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-scalyr", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "test-scalyr", }) c.DeleteScalyr(&DeleteScalyrInput{ - Service: testServiceID, - Version: tv.Number, - Name: "new-test-scalyr", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "new-test-scalyr", }) }) }() @@ -71,8 +71,8 @@ func TestClient_Scalyrs(t *testing.T) { var ss []*Scalyr record(t, "scalyrs/list", func(c *Client) { ss, err = c.ListScalyrs(&ListScalyrsInput{ - Service: testServiceID, - Version: tv.Number, + ServiceID: testServiceID, + ServiceVersion: tv.Number, }) }) if err != nil { @@ -86,9 +86,9 @@ func TestClient_Scalyrs(t *testing.T) { var ns *Scalyr record(t, "scalyrs/get", func(c *Client) { ns, err = c.GetScalyr(&GetScalyrInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-scalyr", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "test-scalyr", }) }) if err != nil { @@ -117,12 +117,12 @@ func TestClient_Scalyrs(t *testing.T) { var us *Scalyr record(t, "scalyrs/update", func(c *Client) { us, err = c.UpdateScalyr(&UpdateScalyrInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-scalyr", - NewName: String("new-test-scalyr"), - Region: String("EU"), - Token: String("new-token"), + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "test-scalyr", + NewName: String("new-test-scalyr"), + Region: String("EU"), + Token: String("new-token"), }) }) if err != nil { @@ -141,9 +141,9 @@ func TestClient_Scalyrs(t *testing.T) { // Delete record(t, "scalyrs/delete", func(c *Client) { err = c.DeleteScalyr(&DeleteScalyrInput{ - Service: testServiceID, - Version: tv.Number, - Name: "new-test-scalyr", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "new-test-scalyr", }) }) if err != nil { @@ -154,17 +154,17 @@ func TestClient_Scalyrs(t *testing.T) { func TestClient_ListScalyrs_validation(t *testing.T) { var err error _, err = testClient.ListScalyrs(&ListScalyrsInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.ListScalyrs(&ListScalyrsInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } } @@ -172,17 +172,17 @@ func TestClient_ListScalyrs_validation(t *testing.T) { func TestClient_CreateScalyr_validation(t *testing.T) { var err error _, err = testClient.CreateScalyr(&CreateScalyrInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.CreateScalyr(&CreateScalyrInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } } @@ -190,24 +190,24 @@ func TestClient_CreateScalyr_validation(t *testing.T) { func TestClient_GetScalyr_validation(t *testing.T) { var err error _, err = testClient.GetScalyr(&GetScalyrInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.GetScalyr(&GetScalyrInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } _, err = testClient.GetScalyr(&GetScalyrInput{ - Service: "foo", - Version: 1, - Name: "", + ServiceID: "foo", + ServiceVersion: 1, + Name: "", }) if err != ErrMissingName { t.Errorf("bad error: %s", err) @@ -217,24 +217,24 @@ func TestClient_GetScalyr_validation(t *testing.T) { func TestClient_UpdateScalyr_validation(t *testing.T) { var err error _, err = testClient.UpdateScalyr(&UpdateScalyrInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.UpdateScalyr(&UpdateScalyrInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } _, err = testClient.UpdateScalyr(&UpdateScalyrInput{ - Service: "foo", - Version: 1, - Name: "", + ServiceID: "foo", + ServiceVersion: 1, + Name: "", }) if err != ErrMissingName { t.Errorf("bad error: %s", err) @@ -244,24 +244,24 @@ func TestClient_UpdateScalyr_validation(t *testing.T) { func TestClient_DeleteScalyr_validation(t *testing.T) { var err error err = testClient.DeleteScalyr(&DeleteScalyrInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } err = testClient.DeleteScalyr(&DeleteScalyrInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } err = testClient.DeleteScalyr(&DeleteScalyrInput{ - Service: "foo", - Version: 1, - Name: "", + ServiceID: "foo", + ServiceVersion: 1, + Name: "", }) if err != ErrMissingName { t.Errorf("bad error: %s", err) diff --git a/fastly/server.go b/fastly/server.go index c99d896d3..2906d6ec1 100644 --- a/fastly/server.go +++ b/fastly/server.go @@ -36,24 +36,24 @@ func (s serversByAddress) Less(i, j int) bool { // ListServersInput is used as input to the ListServers function. type ListServersInput struct { - // Service is the ID of the service (required). - Service string + // ServiceID is the ID of the service (required). + ServiceID string - // Pool is the ID of the pool (required). - Pool string + // PoolID is the ID of the pool (required). + PoolID string } // ListServers lists all servers for a particular service and pool. func (c *Client) ListServers(i *ListServersInput) ([]*Server, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Pool == "" { + if i.PoolID == "" { return nil, ErrMissingPool } - path := fmt.Sprintf("/service/%s/pool/%s/servers", i.Service, i.Pool) + path := fmt.Sprintf("/service/%s/pool/%s/servers", i.ServiceID, i.PoolID) resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -69,10 +69,11 @@ func (c *Client) ListServers(i *ListServersInput) ([]*Server, error) { // CreateServerInput is used as input to the CreateServer function. type CreateServerInput struct { - // Service is the ID of the service. Pool is the ID of the pool. Both - // fields are required. - Service string - Pool string + // ServiceID is the ID of the service (required). + ServiceID string + + // PoolID is the ID of the pool (required). + PoolID string // Address is the hostname or IP of the origin server (required). Address string `form:"address"` @@ -89,11 +90,11 @@ type CreateServerInput struct { // CreateServer creates a single server for a particular service and pool. // Servers are versionless resources that are associated with a Pool. func (c *Client) CreateServer(i *CreateServerInput) (*Server, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Pool == "" { + if i.PoolID == "" { return nil, ErrMissingPool } @@ -101,7 +102,7 @@ func (c *Client) CreateServer(i *CreateServerInput) (*Server, error) { return nil, ErrMissingAddress } - path := fmt.Sprintf("/service/%s/pool/%s/server", i.Service, i.Pool) + path := fmt.Sprintf("/service/%s/pool/%s/server", i.ServiceID, i.PoolID) resp, err := c.PostForm(path, i, nil) if err != nil { return nil, err @@ -116,20 +117,22 @@ func (c *Client) CreateServer(i *CreateServerInput) (*Server, error) { // GetServerInput is used as input to the GetServer function. type GetServerInput struct { - // Service is the ID of the service. Pool is the ID of the pool. Server is - // the ID of the server in the Pool. These are required fields. - Service string - Pool string - Server string + // ServiceID is the ID of the service (required). + ServiceID string + + // PoolID is the ID of the pool (required). + PoolID string + + Server string } // GetServer gets a single server for a particular service and pool. func (c *Client) GetServer(i *GetServerInput) (*Server, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Pool == "" { + if i.PoolID == "" { return nil, ErrMissingPool } @@ -137,7 +140,7 @@ func (c *Client) GetServer(i *GetServerInput) (*Server, error) { return nil, ErrMissingServer } - path := fmt.Sprintf("/service/%s/pool/%s/server/%s", i.Service, i.Pool, i.Server) + path := fmt.Sprintf("/service/%s/pool/%s/server/%s", i.ServiceID, i.PoolID, i.Server) resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -152,11 +155,13 @@ func (c *Client) GetServer(i *GetServerInput) (*Server, error) { // UpdateServerInput is used as input to the UpdateServer function. type UpdateServerInput struct { - // Service is the ID of the service. Pool is the ID of the pool. Server is - // the ID of the server in the Pool. These are required fields. - Service string - Pool string - Server string + // ServiceID is the ID of the service (required). + ServiceID string + + // PoolID is the ID of the pool (required). + PoolID string + + Server string // Optional fields. Address *string `form:"address,omitempty"` @@ -170,11 +175,11 @@ type UpdateServerInput struct { // UpdateServer updates a single server for a particular service and pool. func (c *Client) UpdateServer(i *UpdateServerInput) (*Server, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Pool == "" { + if i.PoolID == "" { return nil, ErrMissingPool } @@ -182,7 +187,7 @@ func (c *Client) UpdateServer(i *UpdateServerInput) (*Server, error) { return nil, ErrMissingServer } - path := fmt.Sprintf("/service/%s/pool/%s/server/%s", i.Service, i.Pool, i.Server) + path := fmt.Sprintf("/service/%s/pool/%s/server/%s", i.ServiceID, i.PoolID, i.Server) resp, err := c.PutForm(path, i, nil) if err != nil { return nil, err @@ -197,20 +202,22 @@ func (c *Client) UpdateServer(i *UpdateServerInput) (*Server, error) { // DeleteServerInput is used as input to the DeleteServer function. type DeleteServerInput struct { - // Service is the ID of the service. Pool is the ID of the pool. Server is - // the ID of the server in the Pool. These are required fields. - Service string - Pool string - Server string + // ServiceID is the ID of the service (required). + ServiceID string + + // PoolID is the ID of the pool (required). + PoolID string + + Server string } // DeleteServer deletes a single server for a particular service and pool. func (c *Client) DeleteServer(i *DeleteServerInput) error { - if i.Service == "" { - return ErrMissingService + if i.ServiceID == "" { + return ErrMissingServiceID } - if i.Pool == "" { + if i.PoolID == "" { return ErrMissingPool } @@ -218,7 +225,7 @@ func (c *Client) DeleteServer(i *DeleteServerInput) error { return ErrMissingServer } - path := fmt.Sprintf("/service/%s/pool/%s/server/%s", i.Service, i.Pool, i.Server) + path := fmt.Sprintf("/service/%s/pool/%s/server/%s", i.ServiceID, i.PoolID, i.Server) resp, err := c.Delete(path, nil) if err != nil { return err diff --git a/fastly/server_test.go b/fastly/server_test.go index c2521e298..f73a537bb 100644 --- a/fastly/server_test.go +++ b/fastly/server_test.go @@ -16,9 +16,9 @@ func TestClient_Servers(t *testing.T) { var altServer *Server record(t, "servers/create", func(c *Client) { server, err = c.CreateServer(&CreateServerInput{ - Service: testServiceID, - Pool: testPool.ID, - Address: "127.0.0.1", + ServiceID: testServiceID, + PoolID: testPool.ID, + Address: "127.0.0.1", }) if err != nil { t.Fatal(err) @@ -26,9 +26,9 @@ func TestClient_Servers(t *testing.T) { // additional pool server for DeleteServer usage altServer, err = c.CreateServer(&CreateServerInput{ - Service: testServiceID, - Pool: testPool.ID, - Address: "altserver.example.com", + ServiceID: testServiceID, + PoolID: testPool.ID, + Address: "altserver.example.com", }) if err != nil { t.Fatal(err) @@ -43,18 +43,18 @@ func TestClient_Servers(t *testing.T) { record(t, "servers/cleanup", func(c *Client) { // Expected to fail as this was explicitly deleted in the test. c.DeleteServer(&DeleteServerInput{ - Service: testServiceID, - Pool: testPool.ID, - Server: altServer.ID, + ServiceID: testServiceID, + PoolID: testPool.ID, + Server: altServer.ID, }) // Expected to fail as the API forbids deleting the last server in // the pool. The pool is deleted from this version but it still // exists as it may be associated with other versions. c.DeleteServer(&DeleteServerInput{ - Service: testServiceID, - Pool: testPool.ID, - Server: server.ID, + ServiceID: testServiceID, + PoolID: testPool.ID, + Server: server.ID, }) }) }() @@ -73,8 +73,8 @@ func TestClient_Servers(t *testing.T) { var ss []*Server record(t, "servers/list", func(c *Client) { ss, err = c.ListServers(&ListServersInput{ - Service: testServiceID, - Pool: testPool.ID, + ServiceID: testServiceID, + PoolID: testPool.ID, }) }) if err != nil { @@ -88,9 +88,9 @@ func TestClient_Servers(t *testing.T) { var ns *Server record(t, "servers/get", func(c *Client) { ns, err = c.GetServer(&GetServerInput{ - Service: testServiceID, - Pool: testPool.ID, - Server: server.ID, + ServiceID: testServiceID, + PoolID: testPool.ID, + Server: server.ID, }) }) if server.ID != ns.ID { @@ -104,11 +104,11 @@ func TestClient_Servers(t *testing.T) { var us *Server record(t, "servers/update", func(c *Client) { us, err = c.UpdateServer(&UpdateServerInput{ - Service: testServiceID, - Pool: testPool.ID, - Server: server.ID, - Address: String("0.0.0.0"), - Weight: Uint(50), + ServiceID: testServiceID, + PoolID: testPool.ID, + Server: server.ID, + Address: String("0.0.0.0"), + Weight: Uint(50), }) }) if err != nil { @@ -124,9 +124,9 @@ func TestClient_Servers(t *testing.T) { // Delete record(t, "servers/delete", func(c *Client) { err = c.DeleteServer(&DeleteServerInput{ - Service: testServiceID, - Pool: testPool.ID, - Server: altServer.ID, + ServiceID: testServiceID, + PoolID: testPool.ID, + Server: altServer.ID, }) }) if err != nil { @@ -137,15 +137,15 @@ func TestClient_Servers(t *testing.T) { func TestClient_ListServers_validation(t *testing.T) { var err error _, err = testClient.ListServers(&ListServersInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.ListServers(&ListServersInput{ - Service: "foo", - Pool: "", + ServiceID: "foo", + PoolID: "", }) if err != ErrMissingPool { t.Errorf("bad error: %q", err) @@ -155,15 +155,15 @@ func TestClient_ListServers_validation(t *testing.T) { func TestClient_CreateServer_validation(t *testing.T) { var err error _, err = testClient.CreateServer(&CreateServerInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.CreateServer(&CreateServerInput{ - Service: "foo", - Pool: "", + ServiceID: "foo", + PoolID: "", }) if err != ErrMissingPool { t.Errorf("bad error: %q", err) @@ -173,24 +173,24 @@ func TestClient_CreateServer_validation(t *testing.T) { func TestClient_GetServer_validation(t *testing.T) { var err error _, err = testClient.GetServer(&GetServerInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.GetServer(&GetServerInput{ - Service: "foo", - Pool: "", + ServiceID: "foo", + PoolID: "", }) if err != ErrMissingPool { t.Errorf("bad error: %q", err) } _, err = testClient.GetServer(&GetServerInput{ - Service: "foo", - Pool: "bar", - Server: "", + ServiceID: "foo", + PoolID: "bar", + Server: "", }) if err != ErrMissingServer { t.Errorf("bad error: %q", err) @@ -200,24 +200,24 @@ func TestClient_GetServer_validation(t *testing.T) { func TestClient_UpdateServer_validation(t *testing.T) { var err error _, err = testClient.UpdateServer(&UpdateServerInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.UpdateServer(&UpdateServerInput{ - Service: "foo", - Pool: "", + ServiceID: "foo", + PoolID: "", }) if err != ErrMissingPool { t.Errorf("bad error: %q", err) } _, err = testClient.UpdateServer(&UpdateServerInput{ - Service: "foo", - Pool: "bar", - Server: "", + ServiceID: "foo", + PoolID: "bar", + Server: "", }) if err != ErrMissingServer { t.Errorf("bad error: %q", err) @@ -227,24 +227,24 @@ func TestClient_UpdateServer_validation(t *testing.T) { func TestClient_DeleteServer_validation(t *testing.T) { var err error err = testClient.DeleteServer(&DeleteServerInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } err = testClient.DeleteServer(&DeleteServerInput{ - Service: "foo", - Pool: "", + ServiceID: "foo", + PoolID: "", }) if err != ErrMissingPool { t.Errorf("bad error: %q", err) } err = testClient.DeleteServer(&DeleteServerInput{ - Service: "foo", - Pool: "bar", - Server: "", + ServiceID: "foo", + PoolID: "bar", + Server: "", }) if err != ErrMissingServer { t.Errorf("bad error: %q", err) diff --git a/fastly/settings.go b/fastly/settings.go index 3262473eb..15eb441cf 100644 --- a/fastly/settings.go +++ b/fastly/settings.go @@ -15,23 +15,24 @@ type Settings struct { // GetSettingsInput is used as input to the GetSettings function. type GetSettingsInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int } // GetSettings gets the backend configuration with the given parameters. func (c *Client) GetSettings(i *GetSettingsInput) (*Settings, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/settings", i.Service, i.Version) + path := fmt.Sprintf("/service/%s/version/%d/settings", i.ServiceID, i.ServiceVersion) resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -46,10 +47,11 @@ func (c *Client) GetSettings(i *GetSettingsInput) (*Settings, error) { // UpdateSettingsInput is used as input to the UpdateSettings function. type UpdateSettingsInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int DefaultTTL uint `form:"general.default_ttl"` DefaultHost string `form:"general.default_host,omitempty"` @@ -59,15 +61,15 @@ type UpdateSettingsInput struct { // UpdateSettings updates a specific backend. func (c *Client) UpdateSettings(i *UpdateSettingsInput) (*Settings, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/settings", i.Service, i.Version) + path := fmt.Sprintf("/service/%s/version/%d/settings", i.ServiceID, i.ServiceVersion) resp, err := c.PutForm(path, i, nil) if err != nil { return nil, err diff --git a/fastly/settings_test.go b/fastly/settings_test.go index b74d94b0e..393b3eb57 100644 --- a/fastly/settings_test.go +++ b/fastly/settings_test.go @@ -20,8 +20,8 @@ func TestClient_Settings(t *testing.T) { var ns *Settings record(t, "settings/get", func(c *Client) { ns, err = c.GetSettings(&GetSettingsInput{ - Service: testServiceID, - Version: tv.Number, + ServiceID: testServiceID, + ServiceVersion: tv.Number, }) }) if err != nil { @@ -35,8 +35,8 @@ func TestClient_Settings(t *testing.T) { var us *Settings record(t, "settings/update", func(c *Client) { us, err = c.UpdateSettings(&UpdateSettingsInput{ - Service: testServiceID, - Version: tv.Number, + ServiceID: testServiceID, + ServiceVersion: tv.Number, DefaultTTL: 1800, StaleIfError: true, StaleIfErrorTTL: 57600, @@ -59,10 +59,10 @@ func TestClient_Settings(t *testing.T) { // Tests if we can update a default_ttl to 0 as reported in issue #20 func TestClient_UpdateSettingsInput_default_ttl(t *testing.T) { t.Parallel() - s := UpdateSettingsInput{Service: "foo", Version: 1, DefaultTTL: 0} + s := UpdateSettingsInput{ServiceID: "foo", ServiceVersion: 1, DefaultTTL: 0} buf := new(bytes.Buffer) form.NewEncoder(buf).KeepZeros(true).DelimitWith('|').Encode(s) - if buf.String() != "Service=foo&Version=1&general.default_ttl=0" { + if buf.String() != "ServiceID=foo&ServiceVersion=1&general.default_ttl=0" { t.Errorf("Update request should contain a default_ttl. Got: %s", buf.String()) } } @@ -70,17 +70,17 @@ func TestClient_UpdateSettingsInput_default_ttl(t *testing.T) { func TestClient_GetSettings_validation(t *testing.T) { var err error _, err = testClient.GetSettings(&GetSettingsInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.GetSettings(&GetSettingsInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } } @@ -88,17 +88,17 @@ func TestClient_GetSettings_validation(t *testing.T) { func TestClient_UpdateSettings_validation(t *testing.T) { var err error _, err = testClient.UpdateSettings(&UpdateSettingsInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.UpdateSettings(&UpdateSettingsInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } } diff --git a/fastly/sftp.go b/fastly/sftp.go index db4385da3..9ffb2e6cd 100644 --- a/fastly/sftp.go +++ b/fastly/sftp.go @@ -46,24 +46,24 @@ func (s sftpsByName) Less(i, j int) bool { // ListSFTPsInput is used as input to the ListSFTPs function. type ListSFTPsInput struct { - // Service is the ID of the service (required). - Service string + // ServiceID is the ID of the service (required). + ServiceID string - // Version is the specific configuration version (required). - Version int + // ServiceVersion is the specific configuration version (required). + ServiceVersion int } // ListSFTPs returns the list of sftps for the configuration version. func (c *Client) ListSFTPs(i *ListSFTPsInput) ([]*SFTP, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/sftp", i.Service, i.Version) + path := fmt.Sprintf("/service/%s/version/%d/logging/sftp", i.ServiceID, i.ServiceVersion) resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -79,10 +79,11 @@ func (c *Client) ListSFTPs(i *ListSFTPsInput) ([]*SFTP, error) { // CreateSFTPInput is used as input to the CreateSFTP function. type CreateSFTPInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int Name *string `form:"name,omitempty"` Address *string `form:"address,omitempty"` @@ -105,15 +106,15 @@ type CreateSFTPInput struct { // CreateSFTP creates a new Fastly SFTP. func (c *Client) CreateSFTP(i *CreateSFTPInput) (*SFTP, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/sftp", i.Service, i.Version) + path := fmt.Sprintf("/service/%s/version/%d/logging/sftp", i.ServiceID, i.ServiceVersion) resp, err := c.PostForm(path, i, nil) if err != nil { return nil, err @@ -128,10 +129,11 @@ func (c *Client) CreateSFTP(i *CreateSFTPInput) (*SFTP, error) { // GetSFTPInput is used as input to the GetSFTP function. type GetSFTPInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int // Name is the name of the SFTP to fetch. Name string @@ -139,19 +141,19 @@ type GetSFTPInput struct { // GetSFTP gets the SFTP configuration with the given parameters. func (c *Client) GetSFTP(i *GetSFTPInput) (*SFTP, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } if i.Name == "" { return nil, ErrMissingName } - path := fmt.Sprintf("/service/%s/version/%d/logging/sftp/%s", i.Service, i.Version, url.PathEscape(i.Name)) + path := fmt.Sprintf("/service/%s/version/%d/logging/sftp/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -166,10 +168,11 @@ func (c *Client) GetSFTP(i *GetSFTPInput) (*SFTP, error) { // UpdateSFTPInput is used as input to the UpdateSFTP function. type UpdateSFTPInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int // Name is the name of the SFTP to update. Name string @@ -195,19 +198,19 @@ type UpdateSFTPInput struct { // UpdateSFTP updates a specific SFTP. func (c *Client) UpdateSFTP(i *UpdateSFTPInput) (*SFTP, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } if i.Name == "" { return nil, ErrMissingName } - path := fmt.Sprintf("/service/%s/version/%d/logging/sftp/%s", i.Service, i.Version, url.PathEscape(i.Name)) + path := fmt.Sprintf("/service/%s/version/%d/logging/sftp/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) resp, err := c.PutForm(path, i, nil) if err != nil { return nil, err @@ -222,10 +225,11 @@ func (c *Client) UpdateSFTP(i *UpdateSFTPInput) (*SFTP, error) { // DeleteSFTPInput is the input parameter to DeleteSFTP. type DeleteSFTPInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int // Name is the name of the SFTP to delete (required). Name string @@ -233,19 +237,19 @@ type DeleteSFTPInput struct { // DeleteSFTP deletes the given SFTP version. func (c *Client) DeleteSFTP(i *DeleteSFTPInput) error { - if i.Service == "" { - return ErrMissingService + if i.ServiceID == "" { + return ErrMissingServiceID } - if i.Version == 0 { - return ErrMissingVersion + if i.ServiceVersion == 0 { + return ErrMissingServiceVersion } if i.Name == "" { return ErrMissingName } - path := fmt.Sprintf("/service/%s/version/%d/logging/sftp/%s", i.Service, i.Version, url.PathEscape(i.Name)) + path := fmt.Sprintf("/service/%s/version/%d/logging/sftp/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) resp, err := c.Delete(path, nil) if err != nil { return err diff --git a/fastly/sftp_test.go b/fastly/sftp_test.go index 3989ddf6a..4b1ea5a53 100644 --- a/fastly/sftp_test.go +++ b/fastly/sftp_test.go @@ -15,8 +15,8 @@ func TestClient_SFTPs(t *testing.T) { var sftp *SFTP record(t, "sftps/create", func(c *Client) { sftp, err = c.CreateSFTP(&CreateSFTPInput{ - Service: testServiceID, - Version: tv.Number, + ServiceID: testServiceID, + ServiceVersion: tv.Number, Name: String("test-sftp"), Address: String("example.com"), Port: Uint(1234), @@ -43,15 +43,15 @@ func TestClient_SFTPs(t *testing.T) { defer func() { record(t, "sftps/cleanup", func(c *Client) { c.DeleteSFTP(&DeleteSFTPInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-sftp", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "test-sftp", }) c.DeleteSFTP(&DeleteSFTPInput{ - Service: testServiceID, - Version: tv.Number, - Name: "new-test-sftp", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "new-test-sftp", }) }) }() @@ -109,8 +109,8 @@ func TestClient_SFTPs(t *testing.T) { var sftps []*SFTP record(t, "sftps/list", func(c *Client) { sftps, err = c.ListSFTPs(&ListSFTPsInput{ - Service: testServiceID, - Version: tv.Number, + ServiceID: testServiceID, + ServiceVersion: tv.Number, }) }) if err != nil { @@ -124,9 +124,9 @@ func TestClient_SFTPs(t *testing.T) { var nsftp *SFTP record(t, "sftps/get", func(c *Client) { nsftp, err = c.GetSFTP(&GetSFTPInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-sftp", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "test-sftp", }) }) if err != nil { @@ -185,12 +185,12 @@ func TestClient_SFTPs(t *testing.T) { var usftp *SFTP record(t, "sftps/update", func(c *Client) { usftp, err = c.UpdateSFTP(&UpdateSFTPInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-sftp", - NewName: String("new-test-sftp"), - GzipLevel: Uint(0), - MessageType: String("classic"), + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "test-sftp", + NewName: String("new-test-sftp"), + GzipLevel: Uint(0), + MessageType: String("classic"), }) }) if err != nil { @@ -209,9 +209,9 @@ func TestClient_SFTPs(t *testing.T) { // Delete record(t, "sftps/delete", func(c *Client) { err = c.DeleteSFTP(&DeleteSFTPInput{ - Service: testServiceID, - Version: tv.Number, - Name: "new-test-sftp", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "new-test-sftp", }) }) if err != nil { @@ -222,17 +222,17 @@ func TestClient_SFTPs(t *testing.T) { func TestClient_ListSFTPs_validation(t *testing.T) { var err error _, err = testClient.ListSFTPs(&ListSFTPsInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.ListSFTPs(&ListSFTPsInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } } @@ -240,17 +240,17 @@ func TestClient_ListSFTPs_validation(t *testing.T) { func TestClient_CreateSFTP_validation(t *testing.T) { var err error _, err = testClient.CreateSFTP(&CreateSFTPInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.CreateSFTP(&CreateSFTPInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } } @@ -258,24 +258,24 @@ func TestClient_CreateSFTP_validation(t *testing.T) { func TestClient_GetSFTP_validation(t *testing.T) { var err error _, err = testClient.GetSFTP(&GetSFTPInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.GetSFTP(&GetSFTPInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } _, err = testClient.GetSFTP(&GetSFTPInput{ - Service: "foo", - Version: 1, - Name: "", + ServiceID: "foo", + ServiceVersion: 1, + Name: "", }) if err != ErrMissingName { t.Errorf("bad error: %s", err) @@ -285,24 +285,24 @@ func TestClient_GetSFTP_validation(t *testing.T) { func TestClient_UpdateSFTP_validation(t *testing.T) { var err error _, err = testClient.UpdateSFTP(&UpdateSFTPInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.UpdateSFTP(&UpdateSFTPInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } _, err = testClient.UpdateSFTP(&UpdateSFTPInput{ - Service: "foo", - Version: 1, - Name: "", + ServiceID: "foo", + ServiceVersion: 1, + Name: "", }) if err != ErrMissingName { t.Errorf("bad error: %s", err) @@ -312,24 +312,24 @@ func TestClient_UpdateSFTP_validation(t *testing.T) { func TestClient_DeleteSFTP_validation(t *testing.T) { var err error err = testClient.DeleteSFTP(&DeleteSFTPInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } err = testClient.DeleteSFTP(&DeleteSFTPInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } err = testClient.DeleteSFTP(&DeleteSFTPInput{ - Service: "foo", - Version: 1, - Name: "", + ServiceID: "foo", + ServiceVersion: 1, + Name: "", }) if err != ErrMissingName { t.Errorf("bad error: %s", err) diff --git a/fastly/splunk.go b/fastly/splunk.go index 6805d9fdc..14c0c818d 100644 --- a/fastly/splunk.go +++ b/fastly/splunk.go @@ -38,24 +38,24 @@ func (s splunkByName) Less(i, j int) bool { // ListSplunksInput is used as input to the ListSplunks function. type ListSplunksInput struct { - // Service is the ID of the service (required). - Service string + // ServiceID is the ID of the service (required). + ServiceID string - // Version is the specific configuration version (required). - Version int + // ServiceVersion is the specific configuration version (required). + ServiceVersion int } // ListSplunks returns the list of splunks for the configuration version. func (c *Client) ListSplunks(i *ListSplunksInput) ([]*Splunk, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/splunk", i.Service, i.Version) + path := fmt.Sprintf("/service/%s/version/%d/logging/splunk", i.ServiceID, i.ServiceVersion) resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -71,10 +71,11 @@ func (c *Client) ListSplunks(i *ListSplunksInput) ([]*Splunk, error) { // CreateSplunkInput is used as input to the CreateSplunk function. type CreateSplunkInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int Name string `form:"name,omitempty"` URL string `form:"url,omitempty"` @@ -89,15 +90,15 @@ type CreateSplunkInput struct { // CreateSplunk creates a new Fastly splunk. func (c *Client) CreateSplunk(i *CreateSplunkInput) (*Splunk, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/splunk", i.Service, i.Version) + path := fmt.Sprintf("/service/%s/version/%d/logging/splunk", i.ServiceID, i.ServiceVersion) resp, err := c.PostForm(path, i, nil) if err != nil { return nil, err @@ -112,10 +113,11 @@ func (c *Client) CreateSplunk(i *CreateSplunkInput) (*Splunk, error) { // GetSplunkInput is used as input to the GetSplunk function. type GetSplunkInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int // Name is the name of the splunk to fetch. Name string @@ -123,19 +125,19 @@ type GetSplunkInput struct { // GetSplunk gets the splunk configuration with the given parameters. func (c *Client) GetSplunk(i *GetSplunkInput) (*Splunk, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } if i.Name == "" { return nil, ErrMissingName } - path := fmt.Sprintf("/service/%s/version/%d/logging/splunk/%s", i.Service, i.Version, url.PathEscape(i.Name)) + path := fmt.Sprintf("/service/%s/version/%d/logging/splunk/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -150,10 +152,11 @@ func (c *Client) GetSplunk(i *GetSplunkInput) (*Splunk, error) { // UpdateSplunkInput is used as input to the UpdateSplunk function. type UpdateSplunkInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int // Name is the name of the splunk to update. Name string @@ -171,19 +174,19 @@ type UpdateSplunkInput struct { // UpdateSplunk updates a specific splunk. func (c *Client) UpdateSplunk(i *UpdateSplunkInput) (*Splunk, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } if i.Name == "" { return nil, ErrMissingName } - path := fmt.Sprintf("/service/%s/version/%d/logging/splunk/%s", i.Service, i.Version, url.PathEscape(i.Name)) + path := fmt.Sprintf("/service/%s/version/%d/logging/splunk/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) resp, err := c.PutForm(path, i, nil) if err != nil { return nil, err @@ -198,10 +201,11 @@ func (c *Client) UpdateSplunk(i *UpdateSplunkInput) (*Splunk, error) { // DeleteSplunkInput is the input parameter to DeleteSplunk. type DeleteSplunkInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int // Name is the name of the splunk to delete (required). Name string @@ -209,19 +213,19 @@ type DeleteSplunkInput struct { // DeleteSplunk deletes the given splunk version. func (c *Client) DeleteSplunk(i *DeleteSplunkInput) error { - if i.Service == "" { - return ErrMissingService + if i.ServiceID == "" { + return ErrMissingServiceID } - if i.Version == 0 { - return ErrMissingVersion + if i.ServiceVersion == 0 { + return ErrMissingServiceVersion } if i.Name == "" { return ErrMissingName } - path := fmt.Sprintf("/service/%s/version/%d/logging/splunk/%s", i.Service, i.Version, url.PathEscape(i.Name)) + path := fmt.Sprintf("/service/%s/version/%d/logging/splunk/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) resp, err := c.Delete(path, nil) if err != nil { return err diff --git a/fastly/splunk_test.go b/fastly/splunk_test.go index 4f5c00bc1..a36411ab5 100644 --- a/fastly/splunk_test.go +++ b/fastly/splunk_test.go @@ -36,16 +36,16 @@ Wm7DCfrPNGVwFWUQOmsPue9rZBgO var s *Splunk record(t, "splunks/create", func(c *Client) { s, err = c.CreateSplunk(&CreateSplunkInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-splunk", - URL: "https://mysplunkendpoint.example.com/services/collector/event", - Format: "%h %l %u %t \"%r\" %>s %b", - FormatVersion: 2, - Placement: "waf_debug", - Token: "super-secure-token", - TLSCACert: caCert, - TLSHostname: "example.com", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "test-splunk", + URL: "https://mysplunkendpoint.example.com/services/collector/event", + Format: "%h %l %u %t \"%r\" %>s %b", + FormatVersion: 2, + Placement: "waf_debug", + Token: "super-secure-token", + TLSCACert: caCert, + TLSHostname: "example.com", }) }) if err != nil { @@ -56,15 +56,15 @@ Wm7DCfrPNGVwFWUQOmsPue9rZBgO defer func() { record(t, "splunks/cleanup", func(c *Client) { c.DeleteSplunk(&DeleteSplunkInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-splunk", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "test-splunk", }) c.DeleteSplunk(&DeleteSplunkInput{ - Service: testServiceID, - Version: tv.Number, - Name: "new-test-splunk", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "new-test-splunk", }) }) }() @@ -98,8 +98,8 @@ Wm7DCfrPNGVwFWUQOmsPue9rZBgO var ss []*Splunk record(t, "splunks/list", func(c *Client) { ss, err = c.ListSplunks(&ListSplunksInput{ - Service: testServiceID, - Version: tv.Number, + ServiceID: testServiceID, + ServiceVersion: tv.Number, }) }) if err != nil { @@ -113,9 +113,9 @@ Wm7DCfrPNGVwFWUQOmsPue9rZBgO var ns *Splunk record(t, "splunks/get", func(c *Client) { ns, err = c.GetSplunk(&GetSplunkInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-splunk", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "test-splunk", }) }) if err != nil { @@ -150,10 +150,10 @@ Wm7DCfrPNGVwFWUQOmsPue9rZBgO var us *Splunk record(t, "splunks/update", func(c *Client) { us, err = c.UpdateSplunk(&UpdateSplunkInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-splunk", - NewName: "new-test-splunk", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "test-splunk", + NewName: "new-test-splunk", }) }) if err != nil { @@ -166,9 +166,9 @@ Wm7DCfrPNGVwFWUQOmsPue9rZBgO // Delete record(t, "splunks/delete", func(c *Client) { err = c.DeleteSplunk(&DeleteSplunkInput{ - Service: testServiceID, - Version: tv.Number, - Name: "new-test-splunk", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "new-test-splunk", }) }) if err != nil { @@ -179,17 +179,17 @@ Wm7DCfrPNGVwFWUQOmsPue9rZBgO func TestClient_ListSplunks_validation(t *testing.T) { var err error _, err = testClient.ListSplunks(&ListSplunksInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.ListSplunks(&ListSplunksInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } } @@ -197,17 +197,17 @@ func TestClient_ListSplunks_validation(t *testing.T) { func TestClient_CreateSplunk_validation(t *testing.T) { var err error _, err = testClient.CreateSplunk(&CreateSplunkInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.CreateSplunk(&CreateSplunkInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } } @@ -215,24 +215,24 @@ func TestClient_CreateSplunk_validation(t *testing.T) { func TestClient_GetSplunk_validation(t *testing.T) { var err error _, err = testClient.GetSplunk(&GetSplunkInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.GetSplunk(&GetSplunkInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } _, err = testClient.GetSplunk(&GetSplunkInput{ - Service: "foo", - Version: 1, - Name: "", + ServiceID: "foo", + ServiceVersion: 1, + Name: "", }) if err != ErrMissingName { t.Errorf("bad error: %s", err) @@ -242,24 +242,24 @@ func TestClient_GetSplunk_validation(t *testing.T) { func TestClient_UpdateSplunk_validation(t *testing.T) { var err error _, err = testClient.UpdateSplunk(&UpdateSplunkInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.UpdateSplunk(&UpdateSplunkInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } _, err = testClient.UpdateSplunk(&UpdateSplunkInput{ - Service: "foo", - Version: 1, - Name: "", + ServiceID: "foo", + ServiceVersion: 1, + Name: "", }) if err != ErrMissingName { t.Errorf("bad error: %s", err) @@ -269,24 +269,24 @@ func TestClient_UpdateSplunk_validation(t *testing.T) { func TestClient_DeleteSplunk_validation(t *testing.T) { var err error err = testClient.DeleteSplunk(&DeleteSplunkInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } err = testClient.DeleteSplunk(&DeleteSplunkInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } err = testClient.DeleteSplunk(&DeleteSplunkInput{ - Service: "foo", - Version: 1, - Name: "", + ServiceID: "foo", + ServiceVersion: 1, + Name: "", }) if err != ErrMissingName { t.Errorf("bad error: %s", err) diff --git a/fastly/sumologic.go b/fastly/sumologic.go index 8e024315c..6e23ee4d0 100644 --- a/fastly/sumologic.go +++ b/fastly/sumologic.go @@ -37,24 +37,24 @@ func (s sumologicsByName) Less(i, j int) bool { // ListSumologicsInput is used as input to the ListSumologics function. type ListSumologicsInput struct { - // Service is the ID of the service (required). - Service string + // ServiceID is the ID of the service (required). + ServiceID string - // Version is the specific configuration version (required). - Version int + // ServiceVersion is the specific configuration version (required). + ServiceVersion int } // ListSumologics returns the list of sumologics for the configuration version. func (c *Client) ListSumologics(i *ListSumologicsInput) ([]*Sumologic, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/sumologic", i.Service, i.Version) + path := fmt.Sprintf("/service/%s/version/%d/logging/sumologic", i.ServiceID, i.ServiceVersion) resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -70,10 +70,11 @@ func (c *Client) ListSumologics(i *ListSumologicsInput) ([]*Sumologic, error) { // CreateSumologicInput is used as input to the CreateSumologic function. type CreateSumologicInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int Name string `form:"name,omitempty"` Address string `form:"address,omitempty"` @@ -87,15 +88,15 @@ type CreateSumologicInput struct { // CreateSumologic creates a new Fastly sumologic. func (c *Client) CreateSumologic(i *CreateSumologicInput) (*Sumologic, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/sumologic", i.Service, i.Version) + path := fmt.Sprintf("/service/%s/version/%d/logging/sumologic", i.ServiceID, i.ServiceVersion) resp, err := c.PostForm(path, i, nil) if err != nil { return nil, err @@ -110,10 +111,11 @@ func (c *Client) CreateSumologic(i *CreateSumologicInput) (*Sumologic, error) { // GetSumologicInput is used as input to the GetSumologic function. type GetSumologicInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int // Name is the name of the sumologic to fetch. Name string @@ -121,19 +123,19 @@ type GetSumologicInput struct { // GetSumologic gets the sumologic configuration with the given parameters. func (c *Client) GetSumologic(i *GetSumologicInput) (*Sumologic, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } if i.Name == "" { return nil, ErrMissingName } - path := fmt.Sprintf("/service/%s/version/%d/logging/sumologic/%s", i.Service, i.Version, url.PathEscape(i.Name)) + path := fmt.Sprintf("/service/%s/version/%d/logging/sumologic/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -148,10 +150,11 @@ func (c *Client) GetSumologic(i *GetSumologicInput) (*Sumologic, error) { // UpdateSumologicInput is used as input to the UpdateSumologic function. type UpdateSumologicInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int // Name is the name of the sumologic to update. Name string @@ -168,19 +171,19 @@ type UpdateSumologicInput struct { // UpdateSumologic updates a specific sumologic. func (c *Client) UpdateSumologic(i *UpdateSumologicInput) (*Sumologic, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } if i.Name == "" { return nil, ErrMissingName } - path := fmt.Sprintf("/service/%s/version/%d/logging/sumologic/%s", i.Service, i.Version, url.PathEscape(i.Name)) + path := fmt.Sprintf("/service/%s/version/%d/logging/sumologic/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) resp, err := c.PutForm(path, i, nil) if err != nil { return nil, err @@ -195,10 +198,11 @@ func (c *Client) UpdateSumologic(i *UpdateSumologicInput) (*Sumologic, error) { // DeleteSumologicInput is the input parameter to DeleteSumologic. type DeleteSumologicInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int // Name is the name of the sumologic to delete (required). Name string @@ -206,19 +210,19 @@ type DeleteSumologicInput struct { // DeleteSumologic deletes the given sumologic version. func (c *Client) DeleteSumologic(i *DeleteSumologicInput) error { - if i.Service == "" { - return ErrMissingService + if i.ServiceID == "" { + return ErrMissingServiceID } - if i.Version == 0 { - return ErrMissingVersion + if i.ServiceVersion == 0 { + return ErrMissingServiceVersion } if i.Name == "" { return ErrMissingName } - path := fmt.Sprintf("/service/%s/version/%d/logging/sumologic/%s", i.Service, i.Version, url.PathEscape(i.Name)) + path := fmt.Sprintf("/service/%s/version/%d/logging/sumologic/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) resp, err := c.Delete(path, nil) if err != nil { return err diff --git a/fastly/sumologic_test.go b/fastly/sumologic_test.go index 89382ef40..3e58761b5 100644 --- a/fastly/sumologic_test.go +++ b/fastly/sumologic_test.go @@ -15,14 +15,14 @@ func TestClient_Sumologics(t *testing.T) { var s *Sumologic record(t, "sumologics/create", func(c *Client) { s, err = c.CreateSumologic(&CreateSumologicInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-sumologic", - URL: "https://foo.sumologic.com", - Format: "format", - FormatVersion: 1, - MessageType: "classic", - Placement: "waf_debug", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "test-sumologic", + URL: "https://foo.sumologic.com", + Format: "format", + FormatVersion: 1, + MessageType: "classic", + Placement: "waf_debug", }) }) if err != nil { @@ -33,15 +33,15 @@ func TestClient_Sumologics(t *testing.T) { defer func() { record(t, "sumologics/cleanup", func(c *Client) { c.DeleteSumologic(&DeleteSumologicInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-sumologic", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "test-sumologic", }) c.DeleteSumologic(&DeleteSumologicInput{ - Service: testServiceID, - Version: tv.Number, - Name: "new-test-sumologic", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "new-test-sumologic", }) }) }() @@ -69,8 +69,8 @@ func TestClient_Sumologics(t *testing.T) { var ss []*Sumologic record(t, "sumologics/list", func(c *Client) { ss, err = c.ListSumologics(&ListSumologicsInput{ - Service: testServiceID, - Version: tv.Number, + ServiceID: testServiceID, + ServiceVersion: tv.Number, }) }) if err != nil { @@ -84,9 +84,9 @@ func TestClient_Sumologics(t *testing.T) { var ns *Sumologic record(t, "sumologics/get", func(c *Client) { ns, err = c.GetSumologic(&GetSumologicInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-sumologic", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "test-sumologic", }) }) if err != nil { @@ -115,10 +115,10 @@ func TestClient_Sumologics(t *testing.T) { var us *Sumologic record(t, "sumologics/update", func(c *Client) { us, err = c.UpdateSumologic(&UpdateSumologicInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-sumologic", - NewName: "new-test-sumologic", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "test-sumologic", + NewName: "new-test-sumologic", }) }) if err != nil { @@ -131,9 +131,9 @@ func TestClient_Sumologics(t *testing.T) { // Delete record(t, "sumologics/delete", func(c *Client) { err = c.DeleteSumologic(&DeleteSumologicInput{ - Service: testServiceID, - Version: tv.Number, - Name: "new-test-sumologic", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "new-test-sumologic", }) }) if err != nil { @@ -144,17 +144,17 @@ func TestClient_Sumologics(t *testing.T) { func TestClient_ListSumologics_validation(t *testing.T) { var err error _, err = testClient.ListSumologics(&ListSumologicsInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.ListSumologics(&ListSumologicsInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } } @@ -162,17 +162,17 @@ func TestClient_ListSumologics_validation(t *testing.T) { func TestClient_CreateSumologic_validation(t *testing.T) { var err error _, err = testClient.CreateSumologic(&CreateSumologicInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.CreateSumologic(&CreateSumologicInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } } @@ -180,24 +180,24 @@ func TestClient_CreateSumologic_validation(t *testing.T) { func TestClient_GetSumologic_validation(t *testing.T) { var err error _, err = testClient.GetSumologic(&GetSumologicInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.GetSumologic(&GetSumologicInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } _, err = testClient.GetSumologic(&GetSumologicInput{ - Service: "foo", - Version: 1, - Name: "", + ServiceID: "foo", + ServiceVersion: 1, + Name: "", }) if err != ErrMissingName { t.Errorf("bad error: %s", err) @@ -207,24 +207,24 @@ func TestClient_GetSumologic_validation(t *testing.T) { func TestClient_UpdateSumologic_validation(t *testing.T) { var err error _, err = testClient.UpdateSumologic(&UpdateSumologicInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.UpdateSumologic(&UpdateSumologicInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } _, err = testClient.UpdateSumologic(&UpdateSumologicInput{ - Service: "foo", - Version: 1, - Name: "", + ServiceID: "foo", + ServiceVersion: 1, + Name: "", }) if err != ErrMissingName { t.Errorf("bad error: %s", err) @@ -234,24 +234,24 @@ func TestClient_UpdateSumologic_validation(t *testing.T) { func TestClient_DeleteSumologic_validation(t *testing.T) { var err error err = testClient.DeleteSumologic(&DeleteSumologicInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } err = testClient.DeleteSumologic(&DeleteSumologicInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } err = testClient.DeleteSumologic(&DeleteSumologicInput{ - Service: "foo", - Version: 1, - Name: "", + ServiceID: "foo", + ServiceVersion: 1, + Name: "", }) if err != ErrMissingName { t.Errorf("bad error: %s", err) diff --git a/fastly/syslog.go b/fastly/syslog.go index 958baadc7..36702f41d 100644 --- a/fastly/syslog.go +++ b/fastly/syslog.go @@ -45,24 +45,24 @@ func (s syslogsByName) Less(i, j int) bool { // ListSyslogsInput is used as input to the ListSyslogs function. type ListSyslogsInput struct { - // Service is the ID of the service (required). - Service string + // ServiceID is the ID of the service (required). + ServiceID string - // Version is the specific configuration version (required). - Version int + // ServiceVersion is the specific configuration version (required). + ServiceVersion int } // ListSyslogs returns the list of syslogs for the configuration version. func (c *Client) ListSyslogs(i *ListSyslogsInput) ([]*Syslog, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/syslog", i.Service, i.Version) + path := fmt.Sprintf("/service/%s/version/%d/logging/syslog", i.ServiceID, i.ServiceVersion) resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -78,10 +78,11 @@ func (c *Client) ListSyslogs(i *ListSyslogsInput) ([]*Syslog, error) { // CreateSyslogInput is used as input to the CreateSyslog function. type CreateSyslogInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int Name string `form:"name,omitempty"` Address string `form:"address,omitempty"` @@ -103,15 +104,15 @@ type CreateSyslogInput struct { // CreateSyslog creates a new Fastly syslog. func (c *Client) CreateSyslog(i *CreateSyslogInput) (*Syslog, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/syslog", i.Service, i.Version) + path := fmt.Sprintf("/service/%s/version/%d/logging/syslog", i.ServiceID, i.ServiceVersion) resp, err := c.PostForm(path, i, nil) if err != nil { return nil, err @@ -126,10 +127,11 @@ func (c *Client) CreateSyslog(i *CreateSyslogInput) (*Syslog, error) { // GetSyslogInput is used as input to the GetSyslog function. type GetSyslogInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int // Name is the name of the syslog to fetch. Name string @@ -137,19 +139,19 @@ type GetSyslogInput struct { // GetSyslog gets the syslog configuration with the given parameters. func (c *Client) GetSyslog(i *GetSyslogInput) (*Syslog, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } if i.Name == "" { return nil, ErrMissingName } - path := fmt.Sprintf("/service/%s/version/%d/logging/syslog/%s", i.Service, i.Version, url.PathEscape(i.Name)) + path := fmt.Sprintf("/service/%s/version/%d/logging/syslog/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -164,10 +166,11 @@ func (c *Client) GetSyslog(i *GetSyslogInput) (*Syslog, error) { // UpdateSyslogInput is used as input to the UpdateSyslog function. type UpdateSyslogInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int // Name is the name of the syslog to update. Name string @@ -192,19 +195,19 @@ type UpdateSyslogInput struct { // UpdateSyslog updates a specific syslog. func (c *Client) UpdateSyslog(i *UpdateSyslogInput) (*Syslog, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } if i.Name == "" { return nil, ErrMissingName } - path := fmt.Sprintf("/service/%s/version/%d/logging/syslog/%s", i.Service, i.Version, url.PathEscape(i.Name)) + path := fmt.Sprintf("/service/%s/version/%d/logging/syslog/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) resp, err := c.PutForm(path, i, nil) if err != nil { return nil, err @@ -219,10 +222,11 @@ func (c *Client) UpdateSyslog(i *UpdateSyslogInput) (*Syslog, error) { // DeleteSyslogInput is the input parameter to DeleteSyslog. type DeleteSyslogInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int // Name is the name of the syslog to delete (required). Name string @@ -230,19 +234,19 @@ type DeleteSyslogInput struct { // DeleteSyslog deletes the given syslog version. func (c *Client) DeleteSyslog(i *DeleteSyslogInput) error { - if i.Service == "" { - return ErrMissingService + if i.ServiceID == "" { + return ErrMissingServiceID } - if i.Version == 0 { - return ErrMissingVersion + if i.ServiceVersion == 0 { + return ErrMissingServiceVersion } if i.Name == "" { return ErrMissingName } - path := fmt.Sprintf("/service/%s/version/%d/logging/syslog/%s", i.Service, i.Version, url.PathEscape(i.Name)) + path := fmt.Sprintf("/service/%s/version/%d/logging/syslog/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) resp, err := c.Delete(path, nil) if err != nil { return err diff --git a/fastly/syslog_test.go b/fastly/syslog_test.go index b9c85fd9a..3192cac6b 100644 --- a/fastly/syslog_test.go +++ b/fastly/syslog_test.go @@ -38,22 +38,22 @@ Wm7DCfrPNGVwFWUQOmsPue9rZBgO var s *Syslog record(t, "syslogs/create", func(c *Client) { s, err = c.CreateSyslog(&CreateSyslogInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-syslog", - Address: "example.com", - Hostname: "example.com", - Port: 1234, - UseTLS: CBool(true), - TLSCACert: caCert, - TLSHostname: "example.com", - TLSClientCert: clientCert, - TLSClientKey: clientKey, - Token: "abcd1234", - Format: "format", - FormatVersion: 2, - MessageType: "classic", - Placement: "waf_debug", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "test-syslog", + Address: "example.com", + Hostname: "example.com", + Port: 1234, + UseTLS: CBool(true), + TLSCACert: caCert, + TLSHostname: "example.com", + TLSClientCert: clientCert, + TLSClientKey: clientKey, + Token: "abcd1234", + Format: "format", + FormatVersion: 2, + MessageType: "classic", + Placement: "waf_debug", }) }) if err != nil { @@ -64,15 +64,15 @@ Wm7DCfrPNGVwFWUQOmsPue9rZBgO defer func() { record(t, "syslogs/cleanup", func(c *Client) { c.DeleteSyslog(&DeleteSyslogInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-syslog", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "test-syslog", }) c.DeleteSyslog(&DeleteSyslogInput{ - Service: testServiceID, - Version: tv.Number, - Name: "new-test-syslog", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "new-test-syslog", }) }) }() @@ -124,8 +124,8 @@ Wm7DCfrPNGVwFWUQOmsPue9rZBgO var ss []*Syslog record(t, "syslogs/list", func(c *Client) { ss, err = c.ListSyslogs(&ListSyslogsInput{ - Service: testServiceID, - Version: tv.Number, + ServiceID: testServiceID, + ServiceVersion: tv.Number, }) }) if err != nil { @@ -139,9 +139,9 @@ Wm7DCfrPNGVwFWUQOmsPue9rZBgO var ns *Syslog record(t, "syslogs/get", func(c *Client) { ns, err = c.GetSyslog(&GetSyslogInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-syslog", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "test-syslog", }) }) if err != nil { @@ -194,11 +194,11 @@ Wm7DCfrPNGVwFWUQOmsPue9rZBgO var us *Syslog record(t, "syslogs/update", func(c *Client) { us, err = c.UpdateSyslog(&UpdateSyslogInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-syslog", - NewName: "new-test-syslog", - FormatVersion: 2, + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "test-syslog", + NewName: "new-test-syslog", + FormatVersion: 2, }) }) if err != nil { @@ -215,9 +215,9 @@ Wm7DCfrPNGVwFWUQOmsPue9rZBgO // Delete record(t, "syslogs/delete", func(c *Client) { err = c.DeleteSyslog(&DeleteSyslogInput{ - Service: testServiceID, - Version: tv.Number, - Name: "new-test-syslog", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "new-test-syslog", }) }) if err != nil { @@ -228,17 +228,17 @@ Wm7DCfrPNGVwFWUQOmsPue9rZBgO func TestClient_ListSyslogs_validation(t *testing.T) { var err error _, err = testClient.ListSyslogs(&ListSyslogsInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.ListSyslogs(&ListSyslogsInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } } @@ -246,17 +246,17 @@ func TestClient_ListSyslogs_validation(t *testing.T) { func TestClient_CreateSyslog_validation(t *testing.T) { var err error _, err = testClient.CreateSyslog(&CreateSyslogInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.CreateSyslog(&CreateSyslogInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } } @@ -264,24 +264,24 @@ func TestClient_CreateSyslog_validation(t *testing.T) { func TestClient_GetSyslog_validation(t *testing.T) { var err error _, err = testClient.GetSyslog(&GetSyslogInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.GetSyslog(&GetSyslogInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } _, err = testClient.GetSyslog(&GetSyslogInput{ - Service: "foo", - Version: 1, - Name: "", + ServiceID: "foo", + ServiceVersion: 1, + Name: "", }) if err != ErrMissingName { t.Errorf("bad error: %s", err) @@ -291,24 +291,24 @@ func TestClient_GetSyslog_validation(t *testing.T) { func TestClient_UpdateSyslog_validation(t *testing.T) { var err error _, err = testClient.UpdateSyslog(&UpdateSyslogInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.UpdateSyslog(&UpdateSyslogInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } _, err = testClient.UpdateSyslog(&UpdateSyslogInput{ - Service: "foo", - Version: 1, - Name: "", + ServiceID: "foo", + ServiceVersion: 1, + Name: "", }) if err != ErrMissingName { t.Errorf("bad error: %s", err) @@ -318,24 +318,24 @@ func TestClient_UpdateSyslog_validation(t *testing.T) { func TestClient_DeleteSyslog_validation(t *testing.T) { var err error err = testClient.DeleteSyslog(&DeleteSyslogInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } err = testClient.DeleteSyslog(&DeleteSyslogInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } err = testClient.DeleteSyslog(&DeleteSyslogInput{ - Service: "foo", - Version: 1, - Name: "", + ServiceID: "foo", + ServiceVersion: 1, + Name: "", }) if err != ErrMissingName { t.Errorf("bad error: %s", err) diff --git a/fastly/vcl.go b/fastly/vcl.go index 8895dbe5f..7b2b08d50 100644 --- a/fastly/vcl.go +++ b/fastly/vcl.go @@ -32,24 +32,24 @@ func (s vclsByName) Less(i, j int) bool { // ListVCLsInput is used as input to the ListVCLs function. type ListVCLsInput struct { - // Service is the ID of the service (required). - Service string + // ServiceID is the ID of the service (required). + ServiceID string - // Version is the specific configuration version (required). - Version int + // ServiceVersion is the specific configuration version (required). + ServiceVersion int } // ListVCLs returns the list of VCLs for the configuration version. func (c *Client) ListVCLs(i *ListVCLsInput) ([]*VCL, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/vcl", i.Service, i.Version) + path := fmt.Sprintf("/service/%s/version/%d/vcl", i.ServiceID, i.ServiceVersion) resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -65,10 +65,11 @@ func (c *Client) ListVCLs(i *ListVCLsInput) ([]*VCL, error) { // GetVCLInput is used as input to the GetVCL function. type GetVCLInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int // Name is the name of the VCL to fetch. Name string @@ -76,19 +77,19 @@ type GetVCLInput struct { // GetVCL gets the VCL configuration with the given parameters. func (c *Client) GetVCL(i *GetVCLInput) (*VCL, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } if i.Name == "" { return nil, ErrMissingName } - path := fmt.Sprintf("/service/%s/version/%d/vcl/%s", i.Service, i.Version, url.PathEscape(i.Name)) + path := fmt.Sprintf("/service/%s/version/%d/vcl/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -103,23 +104,24 @@ func (c *Client) GetVCL(i *GetVCLInput) (*VCL, error) { // GetGeneratedVCLInput is used as input to the GetGeneratedVCL function. type GetGeneratedVCLInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int } // GetGeneratedVCL gets the VCL configuration with the given parameters. func (c *Client) GetGeneratedVCL(i *GetGeneratedVCLInput) (*VCL, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/generated_vcl", i.Service, i.Version) + path := fmt.Sprintf("/service/%s/version/%d/generated_vcl", i.ServiceID, i.ServiceVersion) resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -134,10 +136,11 @@ func (c *Client) GetGeneratedVCL(i *GetGeneratedVCLInput) (*VCL, error) { // CreateVCLInput is used as input to the CreateVCL function. type CreateVCLInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int Name string `form:"name,omitempty"` Content string `form:"content,omitempty"` @@ -146,15 +149,15 @@ type CreateVCLInput struct { // CreateVCL creates a new Fastly VCL. func (c *Client) CreateVCL(i *CreateVCLInput) (*VCL, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/vcl", i.Service, i.Version) + path := fmt.Sprintf("/service/%s/version/%d/vcl", i.ServiceID, i.ServiceVersion) resp, err := c.PostForm(path, i, nil) if err != nil { return nil, err @@ -169,10 +172,11 @@ func (c *Client) CreateVCL(i *CreateVCLInput) (*VCL, error) { // UpdateVCLInput is used as input to the UpdateVCL function. type UpdateVCLInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int // Name is the name of the VCL to update (required). Name string @@ -183,19 +187,19 @@ type UpdateVCLInput struct { // UpdateVCL creates a new Fastly VCL. func (c *Client) UpdateVCL(i *UpdateVCLInput) (*VCL, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } if i.Name == "" { return nil, ErrMissingName } - path := fmt.Sprintf("/service/%s/version/%d/vcl/%s", i.Service, i.Version, url.PathEscape(i.Name)) + path := fmt.Sprintf("/service/%s/version/%d/vcl/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) resp, err := c.PutForm(path, i, nil) if err != nil { return nil, err @@ -210,10 +214,11 @@ func (c *Client) UpdateVCL(i *UpdateVCLInput) (*VCL, error) { // ActivateVCLInput is used as input to the ActivateVCL function. type ActivateVCLInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int // Name is the name of the VCL to mark as main (required). Name string @@ -221,19 +226,19 @@ type ActivateVCLInput struct { // ActivateVCL creates a new Fastly VCL. func (c *Client) ActivateVCL(i *ActivateVCLInput) (*VCL, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } if i.Name == "" { return nil, ErrMissingName } - path := fmt.Sprintf("/service/%s/version/%d/vcl/%s/main", i.Service, i.Version, url.PathEscape(i.Name)) + path := fmt.Sprintf("/service/%s/version/%d/vcl/%s/main", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) resp, err := c.Put(path, nil) if err != nil { return nil, err @@ -248,10 +253,11 @@ func (c *Client) ActivateVCL(i *ActivateVCLInput) (*VCL, error) { // DeleteVCLInput is the input parameter to DeleteVCL. type DeleteVCLInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int // Name is the name of the VCL to delete (required). Name string @@ -259,19 +265,19 @@ type DeleteVCLInput struct { // DeleteVCL deletes the given VCL version. func (c *Client) DeleteVCL(i *DeleteVCLInput) error { - if i.Service == "" { - return ErrMissingService + if i.ServiceID == "" { + return ErrMissingServiceID } - if i.Version == 0 { - return ErrMissingVersion + if i.ServiceVersion == 0 { + return ErrMissingServiceVersion } if i.Name == "" { return ErrMissingName } - path := fmt.Sprintf("/service/%s/version/%d/vcl/%s", i.Service, i.Version, url.PathEscape(i.Name)) + path := fmt.Sprintf("/service/%s/version/%d/vcl/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) resp, err := c.Delete(path, nil) if err != nil { return err diff --git a/fastly/vcl_snippets.go b/fastly/vcl_snippets.go index 48d7ce0c1..2dc75df15 100644 --- a/fastly/vcl_snippets.go +++ b/fastly/vcl_snippets.go @@ -63,11 +63,11 @@ type Snippet struct { // CreateSnippetInput is the input for CreateSnippet type CreateSnippetInput struct { - // Service is the ID of the Service to add the snippet to. - Service string + // ServiceID is the ID of the service to add the snippet to (required). + ServiceID string - // Version is the editable version of the service - Version int + // ServiceVersion is the editable configuration version (required). + ServiceVersion int // Name is the name for the snippet. Name string `form:"name"` @@ -87,12 +87,12 @@ type CreateSnippetInput struct { // CreateSnippet creates a new snippet or dynamic snippet on a unlocked version func (c *Client) CreateSnippet(i *CreateSnippetInput) (*Snippet, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } if i.Name == "" { @@ -103,7 +103,7 @@ func (c *Client) CreateSnippet(i *CreateSnippetInput) (*Snippet, error) { return nil, ErrMissingContent } - path := fmt.Sprintf("/service/%s/version/%d/snippet", i.Service, i.Version) + path := fmt.Sprintf("/service/%s/version/%d/snippet", i.ServiceID, i.ServiceVersion) resp, err := c.PostForm(path, i, nil) if err != nil { return nil, err @@ -118,11 +118,11 @@ func (c *Client) CreateSnippet(i *CreateSnippetInput) (*Snippet, error) { // UpdateSnippetInput is the input for UpdateSnippet type UpdateSnippetInput struct { - // Service is the ID of the Service to add the snippet to. - Service string + // ServiceID is the ID of the service to add the snippet to (required). + ServiceID string - // Version is the editable version of the service - Version int + // ServiceVersion is the editable configuration version (required). + ServiceVersion int Name string @@ -144,12 +144,12 @@ type UpdateSnippetInput struct { // UpdateSnippet updates a snippet on a unlocked version func (c *Client) UpdateSnippet(i *UpdateSnippetInput) (*Snippet, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } if i.Name == "" { @@ -160,7 +160,7 @@ func (c *Client) UpdateSnippet(i *UpdateSnippetInput) (*Snippet, error) { return nil, ErrMissingContent } - path := fmt.Sprintf("/service/%s/version/%d/snippet/%s", i.Service, i.Version, url.PathEscape(i.Name)) + path := fmt.Sprintf("/service/%s/version/%d/snippet/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) resp, err := c.PutForm(path, i, nil) if err != nil { return nil, err @@ -185,8 +185,8 @@ type DynamicSnippet struct { // UpdateDynamicSnippetInput is the input for UpdateDynamicSnippet type UpdateDynamicSnippetInput struct { - // Service is the ID of the Service to add the snippet to. - Service string + // ServiceID is the ID of the Service to add the snippet to. + ServiceID string // ID is the ID of the Snippet to modify ID string @@ -197,15 +197,15 @@ type UpdateDynamicSnippetInput struct { // UpdateDynamicSnippet replaces the content of a Dynamic Snippet func (c *Client) UpdateDynamicSnippet(i *UpdateDynamicSnippetInput) (*DynamicSnippet, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } if i.ID == "" { return nil, ErrMissingID } - path := fmt.Sprintf("/service/%s/snippet/%s", i.Service, i.ID) + path := fmt.Sprintf("/service/%s/snippet/%s", i.ServiceID, i.ID) resp, err := c.PutForm(path, i, nil) if err != nil { return nil, err @@ -219,30 +219,30 @@ func (c *Client) UpdateDynamicSnippet(i *UpdateDynamicSnippetInput) (*DynamicSni } type DeleteSnippetInput struct { - // Service is the ID of the Service to add the snippet to. - Service string + // ServiceID is the ID of the Service to add the snippet to. + ServiceID string // Name is the Name of the Snippet to Delete Name string - // Version is the editable version of the service - Version int + // ServiceVersion is the editable configuration version (required). + ServiceVersion int } func (c *Client) DeleteSnippet(i *DeleteSnippetInput) error { - if i.Service == "" { - return ErrMissingService + if i.ServiceID == "" { + return ErrMissingServiceID } - if i.Version == 0 { - return ErrMissingVersion + if i.ServiceVersion == 0 { + return ErrMissingServiceVersion } if i.Name == "" { return ErrMissingName } - path := fmt.Sprintf("/service/%s/version/%d/snippet/%s", i.Service, i.Version, url.PathEscape(i.Name)) + path := fmt.Sprintf("/service/%s/version/%d/snippet/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) resp, err := c.Delete(path, nil) if err != nil { return err @@ -260,11 +260,11 @@ func (c *Client) DeleteSnippet(i *DeleteSnippetInput) error { // ListSnippetsInput is used as input to the ListSnippets function. type ListSnippetsInput struct { - // Service is the ID of the service (required). - Service string + // ServiceID is the ID of the service (required). + ServiceID string - // Version is the specific configuration version (required). - Version int + // ServiceVersion is the specific configuration version (required). + ServiceVersion int } // snippetsByName is a sortable list of Snippets. @@ -280,15 +280,15 @@ func (s snippetsByName) Less(i, j int) bool { // ListSnippets returns the list of Snippets for the configuration version. Content is not displayed for Dynmanic Snippets due to them being // versionless, use the GetDynamicSnippet function to show current content. func (c *Client) ListSnippets(i *ListSnippetsInput) ([]*Snippet, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/snippet", i.Service, i.Version) + path := fmt.Sprintf("/service/%s/version/%d/snippet", i.ServiceID, i.ServiceVersion) resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -304,10 +304,11 @@ func (c *Client) ListSnippets(i *ListSnippetsInput) ([]*Snippet, error) { // GetSnippetInput is used as input to the GetSnippet function. type GetSnippetInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int // Name is the name of the Snippet to fetch. Name string @@ -316,19 +317,19 @@ type GetSnippetInput struct { // GetSnippet gets the Snippet configuration with the given parameters. Dynamic Snippets will not show content due to them // being versionless, use GetDynamicSnippet to see content. func (c *Client) GetSnippet(i *GetSnippetInput) (*Snippet, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } if i.Name == "" { return nil, ErrMissingName } - path := fmt.Sprintf("/service/%s/version/%d/snippet/%s", i.Service, i.Version, url.PathEscape(i.Name)) + path := fmt.Sprintf("/service/%s/version/%d/snippet/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -343,8 +344,8 @@ func (c *Client) GetSnippet(i *GetSnippetInput) (*Snippet, error) { // GetDynamicSnippetInput is used as input to the GetDynamicSnippet function. type GetDynamicSnippetInput struct { - // Service is the ID of the service. - Service string + // ServiceID is the ID of the service (required). + ServiceID string // ID is the ID of the Snippet to fetch. ID string @@ -353,15 +354,15 @@ type GetDynamicSnippetInput struct { // GetDynamicSnippet gets the Snippet configuration with the given parameters. This will show the current content // associated with a Dynamic Snippet. func (c *Client) GetDynamicSnippet(i *GetDynamicSnippetInput) (*DynamicSnippet, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } if i.ID == "" { return nil, ErrMissingID } - path := fmt.Sprintf("/service/%s/snippet/%s", i.Service, i.ID) + path := fmt.Sprintf("/service/%s/snippet/%s", i.ServiceID, i.ID) resp, err := c.Get(path, nil) if err != nil { return nil, err diff --git a/fastly/vcl_snippets_test.go b/fastly/vcl_snippets_test.go index 328f2fe9f..6c449ebe9 100644 --- a/fastly/vcl_snippets_test.go +++ b/fastly/vcl_snippets_test.go @@ -52,13 +52,13 @@ func Test_Snippets(t *testing.T) { var cs *Snippet record(t, "vcl_snippets/create", func(c *Client) { cs, err = c.CreateSnippet(&CreateSnippetInput{ - Service: testServiceID, - Version: tv.Number, - Name: testSnippetName, - Type: SnippetTypeRecv, - Priority: 100, - Dynamic: 0, - Content: content, + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: testSnippetName, + Type: SnippetTypeRecv, + Priority: 100, + Dynamic: 0, + Content: content, }) }) @@ -82,13 +82,13 @@ func Test_Snippets(t *testing.T) { var cds *Snippet record(t, "vcl_snippets/create_dyn", func(c *Client) { cds, err = c.CreateSnippet(&CreateSnippetInput{ - Service: testServiceID, - Version: tv.Number, - Name: testDynSnippetName, - Type: SnippetTypeRecv, - Priority: 100, - Dynamic: 1, - Content: dynContent, + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: testDynSnippetName, + Type: SnippetTypeRecv, + Priority: 100, + Dynamic: 1, + Content: dynContent, }) }) @@ -109,9 +109,9 @@ func Test_Snippets(t *testing.T) { var uds *DynamicSnippet record(t, "vcl_snippets/update_dyn", func(c *Client) { uds, err = c.UpdateDynamicSnippet(&UpdateDynamicSnippetInput{ - Service: testServiceID, - ID: cds.ID, - Content: updatedDynContent, + ServiceID: testServiceID, + ID: cds.ID, + Content: updatedDynContent, }) }) if err != nil { @@ -125,9 +125,9 @@ func Test_Snippets(t *testing.T) { // Delete record(t, "vcl_snippets/delete", func(c *Client) { err = c.DeleteSnippet(&DeleteSnippetInput{ - Service: testServiceID, - Name: testDynSnippetName, - Version: tv.Number, + ServiceID: testServiceID, + Name: testDynSnippetName, + ServiceVersion: tv.Number, }) }) if err != nil { @@ -138,8 +138,8 @@ func Test_Snippets(t *testing.T) { var ds *DynamicSnippet record(t, "vcl_snippets/get_dynamic", func(c *Client) { ds, err = c.GetDynamicSnippet(&GetDynamicSnippetInput{ - Service: testServiceID, - ID: cds.ID, + ServiceID: testServiceID, + ID: cds.ID, }) }) @@ -157,9 +157,9 @@ func Test_Snippets(t *testing.T) { var gs *Snippet record(t, "vcl_snippets/get", func(c *Client) { gs, err = c.GetSnippet(&GetSnippetInput{ - Service: testServiceID, - Name: testSnippetName, - Version: tv.Number, + ServiceID: testServiceID, + Name: testSnippetName, + ServiceVersion: tv.Number, }) }) @@ -180,14 +180,14 @@ func Test_Snippets(t *testing.T) { var us *Snippet record(t, "vcl_snippets/update", func(c *Client) { us, err = c.UpdateSnippet(&UpdateSnippetInput{ - Service: testServiceID, - Name: testSnippetName, - NewName: "newTestSnippetName", - Content: updatedDynContent, - Dynamic: 0, - Type: "none", - Priority: 50, - Version: tv.Number, + ServiceID: testServiceID, + Name: testSnippetName, + NewName: "newTestSnippetName", + Content: updatedDynContent, + Dynamic: 0, + Type: "none", + Priority: 50, + ServiceVersion: tv.Number, }) }) if err != nil { @@ -213,8 +213,8 @@ func Test_Snippets(t *testing.T) { var sl []*Snippet record(t, "vcl_snippets/list", func(c *Client) { sl, err = c.ListSnippets(&ListSnippetsInput{ - Service: testServiceID, - Version: tv.Number, + ServiceID: testServiceID, + ServiceVersion: tv.Number, }) }) @@ -226,32 +226,32 @@ func Test_Snippets(t *testing.T) { t.Errorf("bad service: %q", x.ServiceID) } if x.Version != tv.Number { - t.Errorf("bad Version: %q", x.Version) + t.Errorf("bad ServiceVersion: %q", x.Version) } } _, err = testClient.GetDynamicSnippet(&GetDynamicSnippetInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.GetDynamicSnippet(&GetDynamicSnippetInput{ - Service: testServiceID, - ID: "", + ServiceID: testServiceID, + ID: "", }) if err != ErrMissingID { t.Errorf("bad error: %s", err) } _, err = testClient.CreateSnippet(&CreateSnippetInput{ - Service: testServiceID, - Version: tv.Number, - Name: testSnippetName, - Type: SnippetTypeRecv, - Priority: 100, - Dynamic: 0, - Content: "", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: testSnippetName, + Type: SnippetTypeRecv, + Priority: 100, + Dynamic: 0, + Content: "", }) if err != ErrMissingContent { diff --git a/fastly/vcl_test.go b/fastly/vcl_test.go index d39f438c1..4e8c9c7f0 100644 --- a/fastly/vcl_test.go +++ b/fastly/vcl_test.go @@ -32,10 +32,10 @@ sub vcl_hash { var vcl *VCL record(t, "vcls/create", func(c *Client) { vcl, err = c.CreateVCL(&CreateVCLInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-vcl", - Content: content, + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "test-vcl", + Content: content, }) }) if err != nil { @@ -46,15 +46,15 @@ sub vcl_hash { defer func() { record(t, "vcls/cleanup", func(c *Client) { c.DeleteVCL(&DeleteVCLInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-vcl", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "test-vcl", }) c.DeleteVCL(&DeleteVCLInput{ - Service: testServiceID, - Version: tv.Number, - Name: "new-test-vcl", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "new-test-vcl", }) }) }() @@ -70,8 +70,8 @@ sub vcl_hash { var vcls []*VCL record(t, "vcls/list", func(c *Client) { vcls, err = c.ListVCLs(&ListVCLsInput{ - Service: testServiceID, - Version: tv.Number, + ServiceID: testServiceID, + ServiceVersion: tv.Number, }) }) if err != nil { @@ -85,9 +85,9 @@ sub vcl_hash { var nvcl *VCL record(t, "vcls/get", func(c *Client) { nvcl, err = c.GetVCL(&GetVCLInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-vcl", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "test-vcl", }) }) if err != nil { @@ -104,10 +104,10 @@ sub vcl_hash { var uvcl *VCL record(t, "vcls/update", func(c *Client) { uvcl, err = c.UpdateVCL(&UpdateVCLInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-vcl", - NewName: "new-test-vcl", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "test-vcl", + NewName: "new-test-vcl", }) }) if err != nil { @@ -121,9 +121,9 @@ sub vcl_hash { var avcl *VCL record(t, "vcls/activate", func(c *Client) { avcl, err = c.ActivateVCL(&ActivateVCLInput{ - Service: testServiceID, - Version: tv.Number, - Name: "new-test-vcl", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "new-test-vcl", }) }) if err != nil { @@ -136,9 +136,9 @@ sub vcl_hash { // Delete record(t, "vcls/delete", func(c *Client) { err = c.DeleteVCL(&DeleteVCLInput{ - Service: testServiceID, - Version: tv.Number, - Name: "new-test-vcl", + ServiceID: testServiceID, + ServiceVersion: tv.Number, + Name: "new-test-vcl", }) }) if err != nil { @@ -149,17 +149,17 @@ sub vcl_hash { func TestClient_ListVCLs_validation(t *testing.T) { var err error _, err = testClient.ListVCLs(&ListVCLsInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.ListVCLs(&ListVCLsInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } } @@ -167,17 +167,17 @@ func TestClient_ListVCLs_validation(t *testing.T) { func TestClient_CreateVCL_validation(t *testing.T) { var err error _, err = testClient.CreateVCL(&CreateVCLInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.CreateVCL(&CreateVCLInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } } @@ -185,24 +185,24 @@ func TestClient_CreateVCL_validation(t *testing.T) { func TestClient_GetVCL_validation(t *testing.T) { var err error _, err = testClient.GetVCL(&GetVCLInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.GetVCL(&GetVCLInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } _, err = testClient.GetVCL(&GetVCLInput{ - Service: "foo", - Version: 1, - Name: "", + ServiceID: "foo", + ServiceVersion: 1, + Name: "", }) if err != ErrMissingName { t.Errorf("bad error: %s", err) @@ -212,24 +212,24 @@ func TestClient_GetVCL_validation(t *testing.T) { func TestClient_UpdateVCL_validation(t *testing.T) { var err error _, err = testClient.UpdateVCL(&UpdateVCLInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.UpdateVCL(&UpdateVCLInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } _, err = testClient.UpdateVCL(&UpdateVCLInput{ - Service: "foo", - Version: 1, - Name: "", + ServiceID: "foo", + ServiceVersion: 1, + Name: "", }) if err != ErrMissingName { t.Errorf("bad error: %s", err) @@ -239,24 +239,24 @@ func TestClient_UpdateVCL_validation(t *testing.T) { func TestClient_ActivateVCL_validation(t *testing.T) { var err error _, err = testClient.ActivateVCL(&ActivateVCLInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.ActivateVCL(&ActivateVCLInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } _, err = testClient.ActivateVCL(&ActivateVCLInput{ - Service: "foo", - Version: 1, - Name: "", + ServiceID: "foo", + ServiceVersion: 1, + Name: "", }) if err != ErrMissingName { t.Errorf("bad error: %s", err) @@ -266,24 +266,24 @@ func TestClient_ActivateVCL_validation(t *testing.T) { func TestClient_DeleteVCL_validation(t *testing.T) { var err error err = testClient.DeleteVCL(&DeleteVCLInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } err = testClient.DeleteVCL(&DeleteVCLInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } err = testClient.DeleteVCL(&DeleteVCLInput{ - Service: "foo", - Version: 1, - Name: "", + ServiceID: "foo", + ServiceVersion: 1, + Name: "", }) if err != ErrMissingName { t.Errorf("bad error: %s", err) diff --git a/fastly/version.go b/fastly/version.go index eee0a1214..c06afb3ba 100644 --- a/fastly/version.go +++ b/fastly/version.go @@ -34,17 +34,17 @@ func (s versionsByNumber) Less(i, j int) bool { // ListVersionsInput is the input to the ListVersions function. type ListVersionsInput struct { - // Service is the ID of the service (required). - Service string + // ServiceID is the ID of the service (required). + ServiceID string } // ListVersions returns the full list of all versions of the given service. func (c *Client) ListVersions(i *ListVersionsInput) ([]*Version, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - path := fmt.Sprintf("/service/%s/version", i.Service) + path := fmt.Sprintf("/service/%s/version", i.ServiceID) resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -61,18 +61,18 @@ func (c *Client) ListVersions(i *ListVersionsInput) ([]*Version, error) { // LatestVersionInput is the input to the LatestVersion function. type LatestVersionInput struct { - // Service is the ID of the service (required). - Service string + // ServiceID is the ID of the service (required). + ServiceID string } // LatestVersion fetches the latest version. If there are no versions, this // function will return nil (but not an error). func (c *Client) LatestVersion(i *LatestVersionInput) (*Version, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - list, err := c.ListVersions(&ListVersionsInput{Service: i.Service}) + list, err := c.ListVersions(&ListVersionsInput{ServiceID: i.ServiceID}) if err != nil { return nil, err } @@ -86,8 +86,8 @@ func (c *Client) LatestVersion(i *LatestVersionInput) (*Version, error) { // CreateVersionInput is the input to the CreateVersion function. type CreateVersionInput struct { - // Service is the ID of the service (required). - Service string + // ServiceID is the ID of the service (required). + ServiceID string // A personal freeform descriptive note. Comment string `form:"comment,omitempty"` @@ -97,11 +97,11 @@ type CreateVersionInput struct { // preferred in almost all scenarios, since `Create()` creates a _blank_ // configuration where `Clone()` builds off of an existing configuration. func (c *Client) CreateVersion(i *CreateVersionInput) (*Version, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - path := fmt.Sprintf("/service/%s/version", i.Service) + path := fmt.Sprintf("/service/%s/version", i.ServiceID) resp, err := c.PostForm(path, i, nil) if err != nil { return nil, err @@ -116,24 +116,24 @@ func (c *Client) CreateVersion(i *CreateVersionInput) (*Version, error) { // GetVersionInput is the input to the GetVersion function. type GetVersionInput struct { - // Service is the ID of the service (required). - Service string + // ServiceID is the ID of the service (required). + ServiceID string - // Version is the version number to fetch (required). - Version int + // SrrviceVersion is the version number to fetch (required). + ServiceVersion int } // GetVersion fetches a version with the given information. func (c *Client) GetVersion(i *GetVersionInput) (*Version, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d", i.Service, i.Version) + path := fmt.Sprintf("/service/%s/version/%d", i.ServiceID, i.ServiceVersion) resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -148,10 +148,11 @@ func (c *Client) GetVersion(i *GetVersionInput) (*Version, error) { // UpdateVersionInput is the input to the UpdateVersion function. type UpdateVersionInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int // A personal freeform descriptive note. Comment string `form:"comment,omitempty"` @@ -159,15 +160,15 @@ type UpdateVersionInput struct { // UpdateVersion updates the given version func (c *Client) UpdateVersion(i *UpdateVersionInput) (*Version, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d", i.Service, i.Version) + path := fmt.Sprintf("/service/%s/version/%d", i.ServiceID, i.ServiceVersion) resp, err := c.PutForm(path, i, nil) if err != nil { return nil, err @@ -182,23 +183,24 @@ func (c *Client) UpdateVersion(i *UpdateVersionInput) (*Version, error) { // ActivateVersionInput is the input to the ActivateVersion function. type ActivateVersionInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int } // ActivateVersion activates the given version. func (c *Client) ActivateVersion(i *ActivateVersionInput) (*Version, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/activate", i.Service, i.Version) + path := fmt.Sprintf("/service/%s/version/%d/activate", i.ServiceID, i.ServiceVersion) resp, err := c.Put(path, nil) if err != nil { return nil, err @@ -213,23 +215,24 @@ func (c *Client) ActivateVersion(i *ActivateVersionInput) (*Version, error) { // DeactivateVersionInput is the input to the DeactivateVersion function. type DeactivateVersionInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int } // DeactivateVersion deactivates the given version. func (c *Client) DeactivateVersion(i *DeactivateVersionInput) (*Version, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/deactivate", i.Service, i.Version) + path := fmt.Sprintf("/service/%s/version/%d/deactivate", i.ServiceID, i.ServiceVersion) resp, err := c.Put(path, nil) if err != nil { return nil, err @@ -244,25 +247,26 @@ func (c *Client) DeactivateVersion(i *DeactivateVersionInput) (*Version, error) // CloneVersionInput is the input to the CloneVersion function. type CloneVersionInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int } // CloneVersion creates a clone of the version with and returns a new // configuration version with all the same configuration options, but an // incremented number. func (c *Client) CloneVersion(i *CloneVersionInput) (*Version, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/clone", i.Service, i.Version) + path := fmt.Sprintf("/service/%s/version/%d/clone", i.ServiceID, i.ServiceVersion) resp, err := c.Put(path, nil) if err != nil { return nil, err @@ -277,25 +281,26 @@ func (c *Client) CloneVersion(i *CloneVersionInput) (*Version, error) { // ValidateVersionInput is the input to the ValidateVersion function. type ValidateVersionInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int } // ValidateVersion validates if the given version is okay. func (c *Client) ValidateVersion(i *ValidateVersionInput) (bool, string, error) { var msg string - if i.Service == "" { - return false, msg, ErrMissingService + if i.ServiceID == "" { + return false, msg, ErrMissingServiceID } - if i.Version == 0 { - return false, msg, ErrMissingVersion + if i.ServiceVersion == 0 { + return false, msg, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/validate", i.Service, i.Version) + path := fmt.Sprintf("/service/%s/version/%d/validate", i.ServiceID, i.ServiceVersion) resp, err := c.Get(path, nil) if err != nil { return false, msg, err @@ -312,23 +317,24 @@ func (c *Client) ValidateVersion(i *ValidateVersionInput) (bool, string, error) // LockVersionInput is the input to the LockVersion function. type LockVersionInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version int + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int } // LockVersion locks the specified version. func (c *Client) LockVersion(i *LockVersionInput) (*Version, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == 0 { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/lock", i.Service, i.Version) + path := fmt.Sprintf("/service/%s/version/%d/lock", i.ServiceID, i.ServiceVersion) resp, err := c.Put(path, nil) if err != nil { return nil, err diff --git a/fastly/version_test.go b/fastly/version_test.go index b6cf45afb..7cb668d22 100644 --- a/fastly/version_test.go +++ b/fastly/version_test.go @@ -17,8 +17,8 @@ func TestClient_Versions(t *testing.T) { var v *Version record(t, "versions/create", func(c *Client) { v, err = c.CreateVersion(&CreateVersionInput{ - Service: testServiceID, - Comment: "test comment", + ServiceID: testServiceID, + Comment: "test comment", }) }) if err != nil { @@ -38,7 +38,7 @@ func TestClient_Versions(t *testing.T) { var vs []*Version record(t, "versions/list", func(c *Client) { vs, err = c.ListVersions(&ListVersionsInput{ - Service: testServiceID, + ServiceID: testServiceID, }) }) if err != nil { @@ -52,8 +52,8 @@ func TestClient_Versions(t *testing.T) { var nv *Version record(t, "versions/get", func(c *Client) { nv, err = c.GetVersion(&GetVersionInput{ - Service: testServiceID, - Version: v.Number, + ServiceID: testServiceID, + ServiceVersion: v.Number, }) }) if err != nil { @@ -70,9 +70,9 @@ func TestClient_Versions(t *testing.T) { var uv *Version record(t, "versions/update", func(c *Client) { uv, err = c.UpdateVersion(&UpdateVersionInput{ - Service: testServiceID, - Version: v.Number, - Comment: "new comment", + ServiceID: testServiceID, + ServiceVersion: v.Number, + Comment: "new comment", }) }) if err != nil { @@ -86,8 +86,8 @@ func TestClient_Versions(t *testing.T) { var vl *Version record(t, "versions/lock", func(c *Client) { vl, err = c.LockVersion(&LockVersionInput{ - Service: testServiceID, - Version: v.Number, + ServiceID: testServiceID, + ServiceVersion: v.Number, }) }) if err != nil { @@ -101,8 +101,8 @@ func TestClient_Versions(t *testing.T) { var cv *Version record(t, "versions/clone", func(c *Client) { cv, err = c.CloneVersion(&CloneVersionInput{ - Service: testServiceID, - Version: v.Number, + ServiceID: testServiceID, + ServiceVersion: v.Number, }) }) if err != nil { @@ -133,9 +133,9 @@ func TestClient_SortVersions(t *testing.T) { func TestClient_ListVersions_validation(t *testing.T) { var err error _, err = testClient.ListVersions(&ListVersionsInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } } @@ -143,9 +143,9 @@ func TestClient_ListVersions_validation(t *testing.T) { func TestClient_CreateVersion_validation(t *testing.T) { var err error _, err = testClient.CreateVersion(&CreateVersionInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } } @@ -153,17 +153,17 @@ func TestClient_CreateVersion_validation(t *testing.T) { func TestClient_GetVersion_validation(t *testing.T) { var err error _, err = testClient.GetVersion(&GetVersionInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.GetVersion(&GetVersionInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } } @@ -171,17 +171,17 @@ func TestClient_GetVersion_validation(t *testing.T) { func TestClient_UpdateVersion_validation(t *testing.T) { var err error _, err = testClient.UpdateVersion(&UpdateVersionInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.UpdateVersion(&UpdateVersionInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } } @@ -189,17 +189,17 @@ func TestClient_UpdateVersion_validation(t *testing.T) { func TestClient_ActivateVersion_validation(t *testing.T) { var err error _, err = testClient.ActivateVersion(&ActivateVersionInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.ActivateVersion(&ActivateVersionInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } } @@ -207,17 +207,17 @@ func TestClient_ActivateVersion_validation(t *testing.T) { func TestClient_DeactivateVersion_validation(t *testing.T) { var err error _, err = testClient.DeactivateVersion(&DeactivateVersionInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.DeactivateVersion(&DeactivateVersionInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } } @@ -225,17 +225,17 @@ func TestClient_DeactivateVersion_validation(t *testing.T) { func TestClient_CloneVersion_validation(t *testing.T) { var err error _, err = testClient.CloneVersion(&CloneVersionInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.CloneVersion(&CloneVersionInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } } @@ -243,17 +243,17 @@ func TestClient_CloneVersion_validation(t *testing.T) { func TestClient_ValidateVersion_validation(t *testing.T) { var err error _, _, err = testClient.ValidateVersion(&ValidateVersionInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, _, err = testClient.ValidateVersion(&ValidateVersionInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } } @@ -261,17 +261,17 @@ func TestClient_ValidateVersion_validation(t *testing.T) { func TestClient_LockVersion_validation(t *testing.T) { var err error _, err = testClient.LockVersion(&LockVersionInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.LockVersion(&LockVersionInput{ - Service: "foo", - Version: 0, + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } } diff --git a/fastly/waf.go b/fastly/waf.go index 4539684b9..40b958319 100644 --- a/fastly/waf.go +++ b/fastly/waf.go @@ -126,23 +126,25 @@ func (c *Client) ListWAFs(i *ListWAFsInput) (*WAFResponse, error) { // CreateWAFInput is used as input to the CreateWAF function. type CreateWAFInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. ID string `jsonapi:"primary,waf_firewall"` - Service string `jsonapi:"attr,service_id"` - Version string `jsonapi:"attr,service_version_number"` PrefetchCondition string `jsonapi:"attr,prefetch_condition"` Response string `jsonapi:"attr,response"` + + // ServiceID is the ID of the service (required). + ServiceID string `jsonapi:"attr,service_id"` + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int `jsonapi:"attr,service_version_number"` } // CreateWAF creates a new Fastly WAF. func (c *Client) CreateWAF(i *CreateWAFInput) (*WAF, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == "" { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } path := "/waf/firewalls" @@ -160,22 +162,24 @@ func (c *Client) CreateWAF(i *CreateWAFInput) (*WAF, error) { // GetWAFInput is used as input to the GetWAF function. type GetWAFInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. - Service string - Version string + // ServiceID is the ID of the service (required). + ServiceID string + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int + // ID is the WAF's ID. ID string } // GetWAF gets details for given WAF func (c *Client) GetWAF(i *GetWAFInput) (*WAF, error) { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == "" { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } if i.ID == "" { @@ -185,7 +189,7 @@ func (c *Client) GetWAF(i *GetWAFInput) (*WAF, error) { path := fmt.Sprintf("/waf/firewalls/%s", i.ID) resp, err := c.Get(path, &RequestOptions{ Params: map[string]string{ - "filter[service_version_number]": i.Version, + "filter[service_version_number]": strconv.Itoa(i.ServiceVersion), }, }) if err != nil { @@ -201,11 +205,13 @@ func (c *Client) GetWAF(i *GetWAFInput) (*WAF, error) { // UpdateWAFInput is used as input to the UpdateWAF function. type UpdateWAFInput struct { - // Service is the ID of the service. Version is the specific configuration - // version. Both fields are required. + // ServiceID is the ID of the service (required). + ServiceID string `jsonapi:"attr,service_id,omitempty"` + + // ServiceVersion is the specific configuration version (required). + ServiceVersion int `jsonapi:"attr,service_version_number,omitempty"` + ID string `jsonapi:"primary,waf_firewall"` - Service string `jsonapi:"attr,service_id,omitempty"` - Version string `jsonapi:"attr,service_version_number,omitempty"` PrefetchCondition string `jsonapi:"attr,prefetch_condition,omitempty"` Response string `jsonapi:"attr,response,omitempty"` Disabled *bool `jsonapi:"attr,disabled,omitempty"` @@ -224,12 +230,12 @@ func (c *Client) UpdateWAF(i *UpdateWAFInput) (*WAF, error) { // if 'PrefetchCondition' or 'Response' are // not empty if i.Disabled == nil || i.PrefetchCondition != "" || i.Response != "" { - if i.Service == "" { - return nil, ErrMissingService + if i.ServiceID == "" { + return nil, ErrMissingServiceID } - if i.Version == "" { - return nil, ErrMissingVersion + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion } } @@ -251,14 +257,14 @@ type DeleteWAFInput struct { // This is the WAF ID. ID string `jsonapi:"primary,waf_firewall"` // The service version. - Version string `jsonapi:"attr,service_version_number"` + ServiceVersion int `jsonapi:"attr,service_version_number"` } // DeleteWAF deletes a given WAF from its service. func (c *Client) DeleteWAF(i *DeleteWAFInput) error { - if i.Version == "" { - return ErrMissingVersion + if i.ServiceVersion == 0 { + return ErrMissingServiceVersion } if i.ID == "" { diff --git a/fastly/waf_active_rule_test.go b/fastly/waf_active_rule_test.go index d4d61890a..62475c243 100644 --- a/fastly/waf_active_rule_test.go +++ b/fastly/waf_active_rule_test.go @@ -1,7 +1,6 @@ package fastly import ( - "strconv" "testing" ) @@ -24,8 +23,8 @@ func TestClient_WAF_Active_Rules(t *testing.T) { responseName := "WAf_Response" createTestWAFResponseObject(t, fixtureBase+"/response_object/create", testService.ID, responseName, tv.Number) - waf := createWAF(t, fixtureBase+"/waf/create", testService.ID, strconv.Itoa(tv.Number), prefetch, responseName) - defer deleteWAF(t, fixtureBase+"/waf/delete", waf.ID, "1") + waf := createWAF(t, fixtureBase+"/waf/create", testService.ID, prefetch, responseName, tv.Number) + defer deleteWAF(t, fixtureBase+"/waf/delete", waf.ID, 1) var err error diff --git a/fastly/waf_rule_exclusion_test.go b/fastly/waf_rule_exclusion_test.go index 3648fc0d9..c380e1ceb 100644 --- a/fastly/waf_rule_exclusion_test.go +++ b/fastly/waf_rule_exclusion_test.go @@ -16,7 +16,7 @@ func TestClient_WAF_Rule_Exclusion_list(t *testing.T) { waf := createWAFWithRulesForExclusion(t, fixtureBase, testService, serviceVersion, responseName) defer deleteTestService(t, fixtureBase+"service/delete", testService.ID) - defer deleteWAF(t, fixtureBase+"waf/delete", waf.ID, "1") + defer deleteWAF(t, fixtureBase+"waf/delete", waf.ID, 1) excl1In := buildWAFRuleExclusion1(waf.ID, 1) excl2In := buildWAFRuleExclusion2(waf.ID, 1) @@ -41,7 +41,7 @@ func TestClient_WAF_Rule_Exclusion_list_filters(t *testing.T) { waf := createWAFWithRulesForExclusion(t, fixtureBase, testService, serviceVersion, responseName) defer deleteTestService(t, fixtureBase+"service/delete", testService.ID) - defer deleteWAF(t, fixtureBase+"waf/delete", waf.ID, "1") + defer deleteWAF(t, fixtureBase+"waf/delete", waf.ID, 1) excl1In := buildWAFRuleExclusion1(waf.ID, 1) excl2In := buildWAFRuleExclusion2(waf.ID, 1) @@ -73,7 +73,7 @@ func TestClient_WAF_Rule_Exclusion_create(t *testing.T) { waf := createWAFWithRulesForExclusion(t, fixtureBase, testService, serviceVersion, responseName) defer deleteTestService(t, fixtureBase+"service/delete", testService.ID) - defer deleteWAF(t, fixtureBase+"waf/delete", waf.ID, "1") + defer deleteWAF(t, fixtureBase+"waf/delete", waf.ID, 1) exclIn := buildWAFRuleExclusion1(waf.ID, 1) createWAFRuleExclusion(t, fixtureBase+"waf_rule_exclusions/create", exclIn) @@ -94,7 +94,7 @@ func TestClient_WAF_Rule_Exclusion_update(t *testing.T) { waf := createWAFWithRulesForExclusion(t, fixtureBase, testService, serviceVersion, responseName) defer deleteTestService(t, fixtureBase+"service/delete", testService.ID) - defer deleteWAF(t, fixtureBase+"waf/delete", waf.ID, "1") + defer deleteWAF(t, fixtureBase+"waf/delete", waf.ID, 1) exclIn := buildWAFRuleExclusion1(waf.ID, 1) exclOut := createWAFRuleExclusion(t, fixtureBase+"waf_rule_exclusions/create", exclIn) @@ -118,7 +118,7 @@ func TestClient_WAF_Rule_Exclusion_delete(t *testing.T) { waf := createWAFWithRulesForExclusion(t, fixtureBase, testService, serviceVersion, responseName) defer deleteTestService(t, fixtureBase+"service/delete", testService.ID) - defer deleteWAF(t, fixtureBase+"waf/delete", waf.ID, "1") + defer deleteWAF(t, fixtureBase+"waf/delete", waf.ID, 1) exclIn := buildWAFRuleExclusion1(waf.ID, 1) exclOut := createWAFRuleExclusion(t, fixtureBase+"waf_rule_exclusions/create", exclIn) @@ -327,7 +327,7 @@ func extractModSecId(wafRule []*WAFRule) []int { } func createWAFWithRulesForExclusion(t *testing.T, fixtureBase string, testService *Service, version *Version, responseName string) *WAF { - waf := createWAF(t, fixtureBase+"waf/create", testService.ID, strconv.Itoa(version.Number), "", responseName) + waf := createWAF(t, fixtureBase+"waf/create", testService.ID, "", responseName, version.Number) var err error rulesIn := buildWAFRulesForExclusion("log") diff --git a/fastly/waf_test.go b/fastly/waf_test.go index f4291708e..349b4f892 100644 --- a/fastly/waf_test.go +++ b/fastly/waf_test.go @@ -2,7 +2,6 @@ package fastly import ( "reflect" - "strconv" "testing" ) @@ -32,8 +31,8 @@ func TestClient_WAFs(t *testing.T) { var waf *WAF record(t, fixtureBase+"/create", func(c *Client) { waf, err = c.CreateWAF(&CreateWAFInput{ - Service: testService.ID, - Version: strconv.Itoa(tv.Number), + ServiceID: testService.ID, + ServiceVersion: tv.Number, PrefetchCondition: condition.Name, Response: ro.Name, }) @@ -61,8 +60,8 @@ func TestClient_WAFs(t *testing.T) { defer func() { record(t, fixtureBase+"/cleanup", func(c *Client) { c.DeleteWAF(&DeleteWAFInput{ - Version: strconv.Itoa(tv.Number), - ID: waf.ID, + ServiceVersion: tv.Number, + ID: waf.ID, }) }) }() @@ -81,9 +80,9 @@ func TestClient_WAFs(t *testing.T) { var nwaf *WAF record(t, fixtureBase+"/get", func(c *Client) { nwaf, err = c.GetWAF(&GetWAFInput{ - Service: testService.ID, - Version: strconv.Itoa(tv.Number), - ID: waf.ID, + ServiceID: testService.ID, + ServiceVersion: tv.Number, + ID: waf.ID, }) }) if err != nil { @@ -99,10 +98,10 @@ func TestClient_WAFs(t *testing.T) { var uwaf *WAF record(t, fixtureBase+"/update", func(c *Client) { uwaf, err = c.UpdateWAF(&UpdateWAFInput{ - Service: testService.ID, - Version: strconv.Itoa(tv.Number), - ID: waf.ID, - Response: nro.Name, + ServiceID: testService.ID, + ServiceVersion: tv.Number, + ID: waf.ID, + Response: nro.Name, }) }) if err != nil { @@ -143,8 +142,8 @@ func TestClient_WAFs(t *testing.T) { // Delete record(t, fixtureBase+"/delete", func(c *Client) { err = c.DeleteWAF(&DeleteWAFInput{ - Version: strconv.Itoa(tv.Number), - ID: waf.ID, + ServiceVersion: tv.Number, + ID: waf.ID, }) }) if err != nil { @@ -155,17 +154,17 @@ func TestClient_WAFs(t *testing.T) { func TestClient_CreateWAF_validation(t *testing.T) { var err error _, err = testClient.CreateWAF(&CreateWAFInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.CreateWAF(&CreateWAFInput{ - Service: "foo", - Version: "", + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } } @@ -173,23 +172,23 @@ func TestClient_CreateWAF_validation(t *testing.T) { func TestClient_GetWAF_validation(t *testing.T) { var err error _, err = testClient.GetWAF(&GetWAFInput{ - Service: "", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.GetWAF(&GetWAFInput{ - Service: "foo", - Version: "", + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } _, err = testClient.GetWAF(&GetWAFInput{ - Service: "foo", - Version: "1", + ServiceID: "foo", + ServiceVersion: 1, }) if err != ErrMissingWAFID { t.Errorf("bad error: %s", err) @@ -200,28 +199,28 @@ func TestClient_UpdateWAF_validation(t *testing.T) { var err error _, err = testClient.UpdateWAF(&UpdateWAFInput{ - Service: "foo", - Version: "1", - ID: "", + ServiceID: "foo", + ServiceVersion: 1, + ID: "", }) if err != ErrMissingWAFID { t.Errorf("bad error: %s", err) } _, err = testClient.UpdateWAF(&UpdateWAFInput{ - ID: "123", - Service: "", + ID: "123", + ServiceID: "", }) - if err != ErrMissingService { + if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.UpdateWAF(&UpdateWAFInput{ - ID: "123", - Service: "foo", - Version: "", + ID: "123", + ServiceID: "foo", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } } @@ -229,15 +228,15 @@ func TestClient_UpdateWAF_validation(t *testing.T) { func TestClient_DeleteWAF_validation(t *testing.T) { var err error err = testClient.DeleteWAF(&DeleteWAFInput{ - Version: "", + ServiceVersion: 0, }) - if err != ErrMissingVersion { + if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) } err = testClient.DeleteWAF(&DeleteWAFInput{ - Version: "1", - ID: "", + ServiceVersion: 1, + ID: "", }) if err != ErrMissingWAFID { t.Errorf("bad error: %s", err) diff --git a/fastly/waf_version_test.go b/fastly/waf_version_test.go index b323537c2..83b4d48f6 100644 --- a/fastly/waf_version_test.go +++ b/fastly/waf_version_test.go @@ -3,7 +3,6 @@ package fastly import ( "fmt" "reflect" - "strconv" "testing" "time" ) @@ -33,8 +32,8 @@ func TestClient_WAF_Versions(t *testing.T) { var waf *WAF record(t, fixtureBase+"/waf/create", func(c *Client) { waf, err = c.CreateWAF(&CreateWAFInput{ - Service: testService.ID, - Version: strconv.Itoa(tv.Number), + ServiceID: testService.ID, + ServiceVersion: tv.Number, PrefetchCondition: condition.Name, Response: ro.Name, }) @@ -45,8 +44,8 @@ func TestClient_WAF_Versions(t *testing.T) { defer func() { record(t, fixtureBase+"/waf/delete", func(c *Client) { if err := c.DeleteWAF(&DeleteWAFInput{ - Version: strconv.Itoa(tv.Number), - ID: waf.ID, + ServiceVersion: tv.Number, + ID: waf.ID, }); err != nil { t.Fatal(err) } From de4838283fd06578c9835738c87538e98a6d29e3 Mon Sep 17 00:00:00 2001 From: integralist Date: Fri, 6 Nov 2020 17:59:46 +0000 Subject: [PATCH 26/37] use pointers as field values for optional basic types reference: https://willnorris.com/2014/05/go-rest-apis-and-pointers/ --- README.md | 8 ++- fastly/acl_entries_batch_test.go | 96 ++++++++++++++++---------------- fastly/acl_entry.go | 24 ++++---- fastly/acl_entry_test.go | 10 ++-- fastly/backend.go | 88 ++++++++++++++--------------- fastly/backend_test.go | 14 ++--- fastly/basictypes_helper.go | 38 +++++++++++++ fastly/bigquery.go | 44 +++++++-------- fastly/bigquery_test.go | 22 ++++---- fastly/blobstorage.go | 56 +++++++++---------- fastly/blobstorage_test.go | 28 +++++----- fastly/cache_setting.go | 16 +++--- fastly/cache_setting_test.go | 8 +-- fastly/condition.go | 16 +++--- fastly/condition_test.go | 10 ++-- fastly/content.go | 4 +- fastly/content_test.go | 2 +- fastly/dictionary.go | 4 +- fastly/dictionary_item.go | 6 +- fastly/dictionary_item_test.go | 6 +- fastly/dictionary_test.go | 4 +- fastly/diff_test.go | 4 +- fastly/director.go | 24 ++++---- fastly/director_test.go | 10 ++-- fastly/domain.go | 4 +- fastly/domain_test.go | 2 +- fastly/fastly.go | 24 -------- fastly/fastly_test.go | 42 +++++++------- fastly/ftp.go | 60 ++++++++++---------- fastly/ftp_test.go | 32 +++++------ fastly/gcs.go | 52 ++++++++--------- fastly/gcs_test.go | 28 +++++----- fastly/gzip.go | 16 +++--- fastly/gzip_test.go | 6 +- fastly/header.go | 36 ++++++------ fastly/header_test.go | 14 ++--- fastly/health_check.go | 48 ++++++++-------- fastly/health_check_test.go | 24 ++++---- fastly/https.go | 72 ++++++++++++------------ fastly/https_test.go | 38 ++++++------- fastly/logentries.go | 28 +++++----- fastly/logentries_test.go | 14 ++--- fastly/papertrail.go | 28 +++++----- fastly/papertrail_test.go | 14 ++--- fastly/request_setting.go | 20 +++---- fastly/request_setting_test.go | 10 ++-- fastly/response_object.go | 28 +++++----- fastly/response_object_test.go | 12 ++-- fastly/s3.go | 68 +++++++++++----------- fastly/s3_test.go | 42 +++++++------- fastly/service.go | 10 ++-- fastly/service_test.go | 6 +- fastly/settings.go | 8 +-- fastly/settings_test.go | 4 +- fastly/splunk.go | 36 ++++++------ fastly/splunk_test.go | 18 +++--- fastly/sumologic.go | 32 +++++------ fastly/sumologic_test.go | 14 ++--- fastly/syslog.go | 60 ++++++++++---------- fastly/syslog_test.go | 30 +++++----- fastly/tls.go | 8 +-- fastly/tls_test.go | 8 +-- fastly/token.go | 6 +- fastly/token_test.go | 10 ++-- fastly/user.go | 6 +- fastly/user_test.go | 6 +- fastly/vcl.go | 10 ++-- fastly/vcl_test.go | 6 +- fastly/version.go | 4 +- fastly/version_test.go | 4 +- fastly/waf.go | 31 +++++------ fastly/waf_test.go | 20 +++---- 72 files changed, 826 insertions(+), 815 deletions(-) create mode 100644 fastly/basictypes_helper.go diff --git a/README.md b/README.md index 3a93b52d9..e7ac09c22 100644 --- a/README.md +++ b/README.md @@ -86,9 +86,9 @@ fmt.Println(domain.Name) backend, err := client.CreateBackend(&fastly.CreateBackendInput{ Service: serviceID, Version: version.Number, - Name: "example-backend", - Address: "127.0.0.1", - Port: 80, + Name: fastly.String("example-backend"), + Address: fastly.String("127.0.0.1"), + Port: fastly.Uint(80), }) if err != nil { log.Fatal(err) @@ -122,6 +122,8 @@ if err != nil { fmt.Printf("%t\n", activeVersion.Locked) ``` +> Note: [basic types](https://tour.golang.org/basics/11) that are _optional_, must be provided as pointers to avoid unexpected behaviours when dealing with their zero value ([reference](https://willnorris.com/2014/05/go-rest-apis-and-pointers/)). We provide helper functions for this [here](./fastly/basictypes_helper.go). + More information can be found in the [Fastly Godoc][godocs]. diff --git a/fastly/acl_entries_batch_test.go b/fastly/acl_entries_batch_test.go index 31bbc0ea4..2417380d0 100644 --- a/fastly/acl_entries_batch_test.go +++ b/fastly/acl_entries_batch_test.go @@ -25,17 +25,17 @@ func TestClient_BatchModifyAclEntries_Create(t *testing.T) { Entries: []*BatchACLEntry{ { Operation: CreateBatchOperation, - IP: "127.0.0.1", - Subnet: "24", - Negated: false, - Comment: "ACL Entry 1", + IP: String("127.0.0.1"), + Subnet: String("24"), + Negated: Bool(false), + Comment: String("ACL Entry 1"), }, { Operation: CreateBatchOperation, - IP: "192.168.0.1", - Subnet: "24", - Negated: false, - Comment: "ACL Entry 2", + IP: String("192.168.0.1"), + Subnet: String("24"), + Negated: Bool(false), + Comment: String("ACL Entry 2"), }, }, } @@ -77,29 +77,29 @@ func TestClient_BatchModifyAclEntries_Create(t *testing.T) { actualIp := entry.IP expectedIp := batchCreateOperations.Entries[i].IP - if actualIp != expectedIp { - t.Errorf("IP did not match, expected %s, got %s", expectedIp, actualIp) + if actualIp != *expectedIp { + t.Errorf("IP did not match, expected %v, got %v", expectedIp, actualIp) } actualSubnet := entry.Subnet expectedSubnet := batchCreateOperations.Entries[i].Subnet - if actualSubnet != expectedSubnet { - t.Errorf("Subnet did not match, expected %s, got %s", expectedSubnet, actualSubnet) + if actualSubnet != *expectedSubnet { + t.Errorf("Subnet did not match, expected %v, got %v", expectedSubnet, actualSubnet) } actualNegated := entry.Negated expectedNegated := batchCreateOperations.Entries[i].Negated - if actualNegated != expectedNegated { - t.Errorf("Negated did not match, expected %t, got %t", expectedNegated, actualNegated) + if actualNegated != *expectedNegated { + t.Errorf("Negated did not match, expected %v, got %v", expectedNegated, actualNegated) } actualComment := entry.Comment expectedComment := batchCreateOperations.Entries[i].Comment - if actualComment != expectedComment { - t.Errorf("Comment did not match, expected %s, got %s", expectedComment, actualComment) + if actualComment != *expectedComment { + t.Errorf("Comment did not match, expected %v, got %v", expectedComment, actualComment) } } @@ -125,17 +125,17 @@ func TestClient_BatchModifyAclEntries_Delete(t *testing.T) { Entries: []*BatchACLEntry{ { Operation: CreateBatchOperation, - IP: "127.0.0.1", - Subnet: "24", - Negated: false, - Comment: "ACL Entry 1", + IP: String("127.0.0.1"), + Subnet: String("24"), + Negated: Bool(false), + Comment: String("ACL Entry 1"), }, { Operation: CreateBatchOperation, - IP: "192.168.0.1", - Subnet: "24", - Negated: false, - Comment: "ACL Entry 2", + IP: String("192.168.0.1"), + Subnet: String("24"), + Negated: Bool(false), + Comment: String("ACL Entry 2"), }, }, } @@ -171,7 +171,7 @@ func TestClient_BatchModifyAclEntries_Delete(t *testing.T) { Entries: []*BatchACLEntry{ { Operation: DeleteBatchOperation, - ID: createdACLEntries[0].ID, + ID: String(createdACLEntries[0].ID), }, }, } @@ -227,17 +227,17 @@ func TestClient_BatchModifyAclEntries_Update(t *testing.T) { Entries: []*BatchACLEntry{ { Operation: CreateBatchOperation, - IP: "127.0.0.1", - Subnet: "24", - Negated: false, - Comment: "ACL Entry 1", + IP: String("127.0.0.1"), + Subnet: String("24"), + Negated: Bool(false), + Comment: String("ACL Entry 1"), }, { Operation: CreateBatchOperation, - IP: "192.168.0.1", - Subnet: "24", - Negated: false, - Comment: "ACL Entry 2", + IP: String("192.168.0.1"), + Subnet: String("24"), + Negated: Bool(false), + Comment: String("ACL Entry 2"), }, }, } @@ -273,11 +273,11 @@ func TestClient_BatchModifyAclEntries_Update(t *testing.T) { Entries: []*BatchACLEntry{ { Operation: UpdateBatchOperation, - ID: createdACLEntries[0].ID, - IP: "127.0.0.2", - Subnet: "16", - Negated: true, - Comment: "Updated ACL Entry 1", + ID: String(createdACLEntries[0].ID), + IP: String("127.0.0.2"), + Subnet: String("16"), + Negated: Bool(true), + Comment: String("Updated ACL Entry 1"), }, }, } @@ -315,36 +315,36 @@ func TestClient_BatchModifyAclEntries_Update(t *testing.T) { actualID := actualACLEntries[0].ID expectedID := batchUpdateOperations.Entries[0].ID - if actualID != expectedID { - t.Errorf("First ID did not match, expected %s, got %s", expectedID, actualID) + if actualID != *expectedID { + t.Errorf("First ID did not match, expected %v, got %v", expectedID, actualID) } actualIP := actualACLEntries[0].IP expectedIP := batchUpdateOperations.Entries[0].IP - if actualIP != expectedIP { - t.Errorf("First IP did not match, expected %s, got %s", expectedIP, actualIP) + if actualIP != *expectedIP { + t.Errorf("First IP did not match, expected %v, got %v", expectedIP, actualIP) } actualSubnet := actualACLEntries[0].Subnet expectedSubnet := batchUpdateOperations.Entries[0].Subnet - if actualSubnet != expectedSubnet { - t.Errorf("First Subnet did not match, expected %s, got %s", expectedSubnet, actualSubnet) + if actualSubnet != *expectedSubnet { + t.Errorf("First Subnet did not match, expected %v, got %v", expectedSubnet, actualSubnet) } actualNegated := actualACLEntries[0].Negated expectedNegated := batchUpdateOperations.Entries[0].Negated - if actualNegated != expectedNegated { - t.Errorf("First Subnet did not match, expected %t, got %t", expectedNegated, actualNegated) + if actualNegated != *expectedNegated { + t.Errorf("First Subnet did not match, expected %v, got %v", expectedNegated, actualNegated) } actualComment := actualACLEntries[0].Comment expectedComment := batchUpdateOperations.Entries[0].Comment - if actualComment != expectedComment { - t.Errorf("First Comment did not match, expected %s, got %s", expectedComment, actualComment) + if actualComment != *expectedComment { + t.Errorf("First Comment did not match, expected %v, got %v", expectedComment, actualComment) } } diff --git a/fastly/acl_entry.go b/fastly/acl_entry.go index c8e21c73a..ce41e58fe 100644 --- a/fastly/acl_entry.go +++ b/fastly/acl_entry.go @@ -107,9 +107,9 @@ type CreateACLEntryInput struct { IP string `form:"ip"` // Optional fields - Subnet string `form:"subnet,omitempty"` - Negated bool `form:"negated,omitempty"` - Comment string `form:"comment,omitempty"` + Subnet *string `form:"subnet,omitempty"` + Negated *bool `form:"negated,omitempty"` + Comment *string `form:"comment,omitempty"` } // CreateACLEntry creates and returns a new ACL entry. @@ -190,10 +190,10 @@ type UpdateACLEntryInput struct { ID string // Optional fields - IP string `form:"ip,omitempty"` - Subnet string `form:"subnet,omitempty"` - Negated bool `form:"negated,omitempty"` - Comment string `form:"comment,omitempty"` + IP *string `form:"ip,omitempty"` + Subnet *string `form:"subnet,omitempty"` + Negated *bool `form:"negated,omitempty"` + Comment *string `form:"comment,omitempty"` } // UpdateACLEntry updates an ACL entry @@ -234,11 +234,11 @@ type BatchModifyACLEntriesInput struct { type BatchACLEntry struct { Operation BatchOperation `json:"op"` - ID string `json:"id,omitempty"` - IP string `json:"ip,omitempty"` - Subnet string `json:"subnet,omitempty"` - Negated bool `json:"negated,omitempty"` - Comment string `json:"comment,omitempty"` + ID *string `json:"id,omitempty"` + IP *string `json:"ip,omitempty"` + Subnet *string `json:"subnet,omitempty"` + Negated *bool `json:"negated,omitempty"` + Comment *string `json:"comment,omitempty"` } func (c *Client) BatchModifyACLEntries(i *BatchModifyACLEntriesInput) error { diff --git a/fastly/acl_entry_test.go b/fastly/acl_entry_test.go index 0dcdfe2dc..175164ba1 100644 --- a/fastly/acl_entry_test.go +++ b/fastly/acl_entry_test.go @@ -23,9 +23,9 @@ func TestClient_ACLEntries(t *testing.T) { Service: testService.ID, ACL: testACL.ID, IP: "10.0.0.3", - Subnet: "8", - Negated: false, - Comment: "test entry", + Subnet: String("8"), + Negated: Bool(false), + Comment: String("test entry"), }) }) if err != nil { @@ -97,8 +97,8 @@ func TestClient_ACLEntries(t *testing.T) { Service: testService.ID, ACL: testACL.ID, ID: e.ID, - IP: "10.0.0.4", - Negated: true, + IP: String("10.0.0.4"), + Negated: Bool(true), }) }) if err != nil { diff --git a/fastly/backend.go b/fastly/backend.go index 0febabcff..13d630064 100644 --- a/fastly/backend.go +++ b/fastly/backend.go @@ -95,31 +95,31 @@ type CreateBackendInput struct { // ServiceVersion is the specific configuration version (required). ServiceVersion int - Name string `form:"name,omitempty"` - Comment string `form:"comment,omitempty"` - Address string `form:"address,omitempty"` - Port uint `form:"port,omitempty"` - OverrideHost string `form:"override_host,omitempty"` - ConnectTimeout uint `form:"connect_timeout,omitempty"` - MaxConn uint `form:"max_conn,omitempty"` - ErrorThreshold uint `form:"error_threshold,omitempty"` - FirstByteTimeout uint `form:"first_byte_timeout,omitempty"` - BetweenBytesTimeout uint `form:"between_bytes_timeout,omitempty"` + Name *string `form:"name,omitempty"` + Comment *string `form:"comment,omitempty"` + Address *string `form:"address,omitempty"` + Port *uint `form:"port,omitempty"` + OverrideHost *string `form:"override_host,omitempty"` + ConnectTimeout *uint `form:"connect_timeout,omitempty"` + MaxConn *uint `form:"max_conn,omitempty"` + ErrorThreshold *uint `form:"error_threshold,omitempty"` + FirstByteTimeout *uint `form:"first_byte_timeout,omitempty"` + BetweenBytesTimeout *uint `form:"between_bytes_timeout,omitempty"` AutoLoadbalance *Compatibool `form:"auto_loadbalance,omitempty"` - Weight uint `form:"weight,omitempty"` - RequestCondition string `form:"request_condition,omitempty"` - HealthCheck string `form:"healthcheck,omitempty"` - Shield string `form:"shield,omitempty"` + Weight *uint `form:"weight,omitempty"` + RequestCondition *string `form:"request_condition,omitempty"` + HealthCheck *string `form:"healthcheck,omitempty"` + Shield *string `form:"shield,omitempty"` UseSSL *Compatibool `form:"use_ssl,omitempty"` SSLCheckCert *Compatibool `form:"ssl_check_cert,omitempty"` - SSLCACert string `form:"ssl_ca_cert,omitempty"` - SSLClientCert string `form:"ssl_client_cert,omitempty"` - SSLClientKey string `form:"ssl_client_key,omitempty"` - SSLHostname string `form:"ssl_hostname,omitempty"` - SSLCertHostname string `form:"ssl_cert_hostname,omitempty"` - SSLSNIHostname string `form:"ssl_sni_hostname,omitempty"` - MinTLSVersion string `form:"min_tls_version,omitempty"` - MaxTLSVersion string `form:"max_tls_version,omitempty"` + SSLCACert *string `form:"ssl_ca_cert,omitempty"` + SSLClientCert *string `form:"ssl_client_cert,omitempty"` + SSLClientKey *string `form:"ssl_client_key,omitempty"` + SSLHostname *string `form:"ssl_hostname,omitempty"` + SSLCertHostname *string `form:"ssl_cert_hostname,omitempty"` + SSLSNIHostname *string `form:"ssl_sni_hostname,omitempty"` + MinTLSVersion *string `form:"min_tls_version,omitempty"` + MaxTLSVersion *string `form:"max_tls_version,omitempty"` SSLCiphers []string `form:"ssl_ciphers,omitempty"` } @@ -196,31 +196,31 @@ type UpdateBackendInput struct { // Name is the name of the backend to update. Name string - NewName string `form:"name,omitempty"` - Comment string `form:"comment,omitempty"` - Address string `form:"address,omitempty"` - Port uint `form:"port,omitempty"` - OverrideHost string `form:"override_host,omitempty"` - ConnectTimeout uint `form:"connect_timeout,omitempty"` - MaxConn uint `form:"max_conn,omitempty"` - ErrorThreshold uint `form:"error_threshold,omitempty"` - FirstByteTimeout uint `form:"first_byte_timeout,omitempty"` - BetweenBytesTimeout uint `form:"between_bytes_timeout,omitempty"` + NewName *string `form:"name,omitempty"` + Comment *string `form:"comment,omitempty"` + Address *string `form:"address,omitempty"` + Port *uint `form:"port,omitempty"` + OverrideHost *string `form:"override_host,omitempty"` + ConnectTimeout *uint `form:"connect_timeout,omitempty"` + MaxConn *uint `form:"max_conn,omitempty"` + ErrorThreshold *uint `form:"error_threshold,omitempty"` + FirstByteTimeout *uint `form:"first_byte_timeout,omitempty"` + BetweenBytesTimeout *uint `form:"between_bytes_timeout,omitempty"` AutoLoadbalance *Compatibool `form:"auto_loadbalance,omitempty"` - Weight uint `form:"weight,omitempty"` - RequestCondition string `form:"request_condition,omitempty"` - HealthCheck string `form:"healthcheck,omitempty"` - Shield string `form:"shield,omitempty"` + Weight *uint `form:"weight,omitempty"` + RequestCondition *string `form:"request_condition,omitempty"` + HealthCheck *string `form:"healthcheck,omitempty"` + Shield *string `form:"shield,omitempty"` UseSSL *Compatibool `form:"use_ssl,omitempty"` SSLCheckCert *Compatibool `form:"ssl_check_cert,omitempty"` - SSLCACert string `form:"ssl_ca_cert,omitempty"` - SSLClientCert string `form:"ssl_client_cert,omitempty"` - SSLClientKey string `form:"ssl_client_key,omitempty"` - SSLHostname string `form:"ssl_hostname,omitempty"` - SSLCertHostname string `form:"ssl_cert_hostname,omitempty"` - SSLSNIHostname string `form:"ssl_sni_hostname,omitempty"` - MinTLSVersion string `form:"min_tls_version,omitempty"` - MaxTLSVersion string `form:"max_tls_version,omitempty"` + SSLCACert *string `form:"ssl_ca_cert,omitempty"` + SSLClientCert *string `form:"ssl_client_cert,omitempty"` + SSLClientKey *string `form:"ssl_client_key,omitempty"` + SSLHostname *string `form:"ssl_hostname,omitempty"` + SSLCertHostname *string `form:"ssl_cert_hostname,omitempty"` + SSLSNIHostname *string `form:"ssl_sni_hostname,omitempty"` + MinTLSVersion *string `form:"min_tls_version,omitempty"` + MaxTLSVersion *string `form:"max_tls_version,omitempty"` SSLCiphers []string `form:"ssl_ciphers,omitempty"` } diff --git a/fastly/backend_test.go b/fastly/backend_test.go index 48f44b9b9..3ba4d6c8f 100644 --- a/fastly/backend_test.go +++ b/fastly/backend_test.go @@ -17,11 +17,11 @@ func TestClient_Backends(t *testing.T) { b, err = c.CreateBackend(&CreateBackendInput{ ServiceID: testServiceID, ServiceVersion: tv.Number, - Name: "test-backend", - Address: "integ-test.go-fastly.com", - Port: 1234, - ConnectTimeout: 1500, - OverrideHost: "origin.example.com", + Name: String("test-backend"), + Address: String("integ-test.go-fastly.com"), + Port: Uint(1234), + ConnectTimeout: Uint(1500), + OverrideHost: String("origin.example.com"), }) }) if err != nil { @@ -111,8 +111,8 @@ func TestClient_Backends(t *testing.T) { ServiceID: testServiceID, ServiceVersion: tv.Number, Name: "test-backend", - NewName: "new-test-backend", - OverrideHost: "www.example.com", + NewName: String("new-test-backend"), + OverrideHost: String("www.example.com"), }) }) if err != nil { diff --git a/fastly/basictypes_helper.go b/fastly/basictypes_helper.go new file mode 100644 index 000000000..1ae3b01c3 --- /dev/null +++ b/fastly/basictypes_helper.go @@ -0,0 +1,38 @@ +package fastly + +// String is a helper that returns a pointer to the string value passed in. +func String(v string) *string { + return &v +} + +// Int is a helper that returns a pointer to the int value passed in. +func Int(v int) *int { + return &v +} + +// Uint is a helper that returns a pointer to the uint value passed in. +func Uint(v uint) *uint { + return &v +} + +// Uint8 is a helper that returns a pointer to the uint8 value passed in. +func Uint8(v uint8) *uint8 { + return &v +} + +// Bool is a helper that returns a pointer to the bool value passed in. +func Bool(v bool) *bool { + return &v +} + +// NullString is a helper that returns a pointer to the string value passed in +// or nil if the string is empty. +// +// NOTE: historically this has only been utilized by +// https://github.com/fastly/terraform-provider-fastly +func NullString(v string) *string { + if v == "" { + return nil + } + return &v +} diff --git a/fastly/bigquery.go b/fastly/bigquery.go index 1ca94c2ff..f88534a2b 100644 --- a/fastly/bigquery.go +++ b/fastly/bigquery.go @@ -79,17 +79,17 @@ type CreateBigQueryInput struct { // ServiceVersion is the specific configuration version (required). ServiceVersion int - Name string `form:"name,omitempty"` - ProjectID string `form:"project_id,omitempty"` - Dataset string `form:"dataset,omitempty"` - Table string `form:"table,omitempty"` - Template string `form:"template_suffix,omitempty"` - User string `form:"user,omitempty"` - SecretKey string `form:"secret_key,omitempty"` - Format string `form:"format,omitempty"` - ResponseCondition string `form:"response_condition,omitempty"` - Placement string `form:"placement,omitempty"` - FormatVersion uint `form:"format_version,omitempty"` + Name *string `form:"name,omitempty"` + ProjectID *string `form:"project_id,omitempty"` + Dataset *string `form:"dataset,omitempty"` + Table *string `form:"table,omitempty"` + Template *string `form:"template_suffix,omitempty"` + User *string `form:"user,omitempty"` + SecretKey *string `form:"secret_key,omitempty"` + Format *string `form:"format,omitempty"` + ResponseCondition *string `form:"response_condition,omitempty"` + Placement *string `form:"placement,omitempty"` + FormatVersion *uint `form:"format_version,omitempty"` } // CreateBigQuery creates a new Fastly BigQuery. @@ -165,17 +165,17 @@ type UpdateBigQueryInput struct { // Name is the name of the BigQuery to update. Name string - NewName string `form:"name,omitempty"` - ProjectID string `form:"project_id,omitempty"` - Dataset string `form:"dataset,omitempty"` - Table string `form:"table,omitempty"` - Template string `form:"template_suffix,omitempty"` - User string `form:"user,omitempty"` - SecretKey string `form:"secret_key,omitempty"` - Format string `form:"format,omitempty"` - ResponseCondition string `form:"response_condition,omitempty"` - Placement string `form:"placement,omitempty"` - FormatVersion uint `form:"format_version,omitempty"` + NewName *string `form:"name,omitempty"` + ProjectID *string `form:"project_id,omitempty"` + Dataset *string `form:"dataset,omitempty"` + Table *string `form:"table,omitempty"` + Template *string `form:"template_suffix,omitempty"` + User *string `form:"user,omitempty"` + SecretKey *string `form:"secret_key,omitempty"` + Format *string `form:"format,omitempty"` + ResponseCondition *string `form:"response_condition,omitempty"` + Placement *string `form:"placement,omitempty"` + FormatVersion *uint `form:"format_version,omitempty"` } // UpdateBigQuery updates a specific BigQuery. diff --git a/fastly/bigquery_test.go b/fastly/bigquery_test.go index 0d2c9012e..7b787a821 100644 --- a/fastly/bigquery_test.go +++ b/fastly/bigquery_test.go @@ -21,16 +21,16 @@ func TestClient_Bigqueries(t *testing.T) { bq, err = c.CreateBigQuery(&CreateBigQueryInput{ ServiceID: testServiceID, ServiceVersion: tv.Number, - Name: "test-bigquery", - ProjectID: "example-fastly-log", - Dataset: "fastly_log_test", - Table: "fastly_logs", - Template: "", - User: "fastly-bigquery-log@example-fastly-log.iam.gserviceaccount.com", - SecretKey: secretKey, - Format: "{\n \"timestamp\":\"%{begin:%Y-%m-%dT%H:%M:%S}t\",\n \"time_elapsed\":%{time.elapsed.usec}V,\n \"is_tls\":%{if(req.is_ssl, \"true\", \"false\")}V,\n \"client_ip\":\"%{req.http.Fastly-Client-IP}V\",\n \"geo_city\":\"%{client.geo.city}V\",\n \"geo_country_code\":\"%{client.geo.country_code}V\",\n \"request\":\"%{req.request}V\",\n \"host\":\"%{req.http.Fastly-Orig-Host}V\",\n \"url\":\"%{json.escape(req.url)}V\",\n \"request_referer\":\"%{json.escape(req.http.Referer)}V\",\n \"request_user_agent\":\"%{json.escape(req.http.User-Agent)}V\",\n \"request_accept_language\":\"%{json.escape(req.http.Accept-Language)}V\",\n \"request_accept_charset\":\"%{json.escape(req.http.Accept-Charset)}V\",\n \"cache_status\":\"%{regsub(fastly_info.state, \"^(HIT-(SYNTH)|(HITPASS|HIT|MISS|PASS|ERROR|PIPE)).*\", \"\\\\2\\\\3\") }V\"\n}", - Placement: "waf_debug", - FormatVersion: 2, + Name: String("test-bigquery"), + ProjectID: String("example-fastly-log"), + Dataset: String("fastly_log_test"), + Table: String("fastly_logs"), + Template: String(""), + User: String("fastly-bigquery-log@example-fastly-log.iam.gserviceaccount.com"), + SecretKey: String(secretKey), + Format: String("{\n \"timestamp\":\"%{begin:%Y-%m-%dT%H:%M:%S}t\"),\n \"time_elapsed\":%{time.elapsed.usec}V,\n \"is_tls\":%{if(req.is_ssl, \"true\", \"false\")}V,\n \"client_ip\":\"%{req.http.Fastly-Client-IP}V\",\n \"geo_city\":\"%{client.geo.city}V\",\n \"geo_country_code\":\"%{client.geo.country_code}V\",\n \"request\":\"%{req.request}V\",\n \"host\":\"%{req.http.Fastly-Orig-Host}V\",\n \"url\":\"%{json.escape(req.url)}V\",\n \"request_referer\":\"%{json.escape(req.http.Referer)}V\",\n \"request_user_agent\":\"%{json.escape(req.http.User-Agent)}V\",\n \"request_accept_language\":\"%{json.escape(req.http.Accept-Language)}V\",\n \"request_accept_charset\":\"%{json.escape(req.http.Accept-Charset)}V\",\n \"cache_status\":\"%{regsub(fastly_info.state, \"^(HIT-(SYNTH)|(HITPASS|HIT|MISS|PASS|ERROR|PIPE)).*\", \"\\\\2\\\\3\") }V\"\n}"), + Placement: String("waf_debug"), + FormatVersion: Uint(2), }) }) if err != nil { @@ -156,7 +156,7 @@ func TestClient_Bigqueries(t *testing.T) { ServiceID: testServiceID, ServiceVersion: tv.Number, Name: "test-bigquery", - NewName: "new-test-bigquery", + NewName: String("new-test-bigquery"), }) }) if err != nil { diff --git a/fastly/blobstorage.go b/fastly/blobstorage.go index 78124b890..c59b0a216 100644 --- a/fastly/blobstorage.go +++ b/fastly/blobstorage.go @@ -82,20 +82,20 @@ type CreateBlobStorageInput struct { // ServiceVersion is the specific configuration version (required). ServiceVersion int - Name string `form:"name,omitempty"` - Path string `form:"path,omitempty"` - AccountName string `form:"account_name,omitempty"` - Container string `form:"container,omitempty"` - SASToken string `form:"sas_token,omitempty"` - Period uint `form:"period,omitempty"` - TimestampFormat string `form:"timestamp_format,omitempty"` - GzipLevel uint `form:"gzip_level,omitempty"` - PublicKey string `form:"public_key,omitempty"` - Format string `form:"format,omitempty"` - FormatVersion uint `form:"format_version,omitempty"` - MessageType string `form:"message_type,omitempty"` - Placement string `form:"placement,omitempty"` - ResponseCondition string `form:"response_condition,omitempty"` + Name *string `form:"name,omitempty"` + Path *string `form:"path,omitempty"` + AccountName *string `form:"account_name,omitempty"` + Container *string `form:"container,omitempty"` + SASToken *string `form:"sas_token,omitempty"` + Period *uint `form:"period,omitempty"` + TimestampFormat *string `form:"timestamp_format,omitempty"` + GzipLevel *uint `form:"gzip_level,omitempty"` + PublicKey *string `form:"public_key,omitempty"` + Format *string `form:"format,omitempty"` + FormatVersion *uint `form:"format_version,omitempty"` + MessageType *string `form:"message_type,omitempty"` + Placement *string `form:"placement,omitempty"` + ResponseCondition *string `form:"response_condition,omitempty"` } // CreateBlobStorage creates a new Fastly blob storage. @@ -171,20 +171,20 @@ type UpdateBlobStorageInput struct { // Name is the name of the blob storage to update. Name string - NewName string `form:"name,omitempty"` - Path string `form:"path,omitempty"` - AccountName string `form:"account_name,omitempty"` - Container string `form:"container,omitempty"` - SASToken string `form:"sas_token,omitempty"` - Period uint `form:"period,omitempty"` - TimestampFormat string `form:"timestamp_format,omitempty"` - GzipLevel uint `form:"gzip_level,omitempty"` - PublicKey string `form:"public_key,omitempty"` - Format string `form:"format,omitempty"` - FormatVersion uint `form:"format_version,omitempty"` - MessageType string `form:"message_type,omitempty"` - Placement string `form:"placement,omitempty"` - ResponseCondition string `form:"response_condition,omitempty"` + NewName *string `form:"name,omitempty"` + Path *string `form:"path,omitempty"` + AccountName *string `form:"account_name,omitempty"` + Container *string `form:"container,omitempty"` + SASToken *string `form:"sas_token,omitempty"` + Period *uint `form:"period,omitempty"` + TimestampFormat *string `form:"timestamp_format,omitempty"` + GzipLevel *uint `form:"gzip_level,omitempty"` + PublicKey *string `form:"public_key,omitempty"` + Format *string `form:"format,omitempty"` + FormatVersion *uint `form:"format_version,omitempty"` + MessageType *string `form:"message_type,omitempty"` + Placement *string `form:"placement,omitempty"` + ResponseCondition *string `form:"response_condition,omitempty"` } // UpdateBlobStorage updates a specific blob storage. diff --git a/fastly/blobstorage_test.go b/fastly/blobstorage_test.go index 9e8ed6e46..18f9456b4 100644 --- a/fastly/blobstorage_test.go +++ b/fastly/blobstorage_test.go @@ -17,19 +17,19 @@ func TestClient_BlobStorages(t *testing.T) { bs, err = c.CreateBlobStorage(&CreateBlobStorageInput{ ServiceID: testServiceID, ServiceVersion: tv.Number, - Name: "test-blobstorage", - Path: "/logs", - AccountName: "test", - Container: "fastly", - SASToken: "sv=2015-04-05&ss=b&srt=sco&sp=rw&se=2019-07-21T18%3A00%3A00Z&sig=3ABdLOJZosCp0o491T%2BqZGKIhafF1nlM3MzESDDD3Gg%3D", - Period: 12, - TimestampFormat: "%Y-%m-%dT%H:%M:%S.000", - GzipLevel: 9, - PublicKey: "-----BEGIN PGP PUBLIC KEY BLOCK-----\n\nmQENBFyUD8sBCACyFnB39AuuTygseek+eA4fo0cgwva6/FSjnWq7riouQee8GgQ/\nibXTRyv4iVlwI12GswvMTIy7zNvs1R54i0qvsLr+IZ4GVGJqs6ZJnvQcqe3xPoR4\n8AnBfw90o32r/LuHf6QCJXi+AEu35koNlNAvLJ2B+KACaNB7N0EeWmqpV/1V2k9p\nlDYk+th7LcCuaFNGqKS/PrMnnMqR6VDLCjHhNx4KR79b0Twm/2qp6an3hyNRu8Gn\ndwxpf1/BUu3JWf+LqkN4Y3mbOmSUL3MaJNvyQguUzTfS0P0uGuBDHrJCVkMZCzDB\n89ag55jCPHyGeHBTd02gHMWzsg3WMBWvCsrzABEBAAG0JXRlcnJhZm9ybSAodGVz\ndCkgPHRlc3RAdGVycmFmb3JtLmNvbT6JAU4EEwEIADgWIQSHYyc6Kj9l6HzQsau6\nvFFc9jxV/wUCXJQPywIbAwULCQgHAgYVCgkICwIEFgIDAQIeAQIXgAAKCRC6vFFc\n9jxV/815CAClb32OxV7wG01yF97TzlyTl8TnvjMtoG29Mw4nSyg+mjM3b8N7iXm9\nOLX59fbDAWtBSldSZE22RXd3CvlFOG/EnKBXSjBtEqfyxYSnyOPkMPBYWGL/ApkX\nSvPYJ4LKdvipYToKFh3y9kk2gk1DcDBDyaaHvR+3rv1u3aoy7/s2EltAfDS3ZQIq\n7/cWTLJml/lleeB/Y6rPj8xqeCYhE5ahw9gsV/Mdqatl24V9Tks30iijx0Hhw+Gx\nkATUikMGr2GDVqoIRga5kXI7CzYff4rkc0Twn47fMHHHe/KY9M2yVnMHUXmAZwbG\nM1cMI/NH1DjevCKdGBLcRJlhuLPKF/anuQENBFyUD8sBCADIpd7r7GuPd6n/Ikxe\nu6h7umV6IIPoAm88xCYpTbSZiaK30Svh6Ywra9jfE2KlU9o6Y/art8ip0VJ3m07L\n4RSfSpnzqgSwdjSq5hNour2Fo/BzYhK7yaz2AzVSbe33R0+RYhb4b/6N+bKbjwGF\nftCsqVFMH+PyvYkLbvxyQrHlA9woAZaNThI1ztO5rGSnGUR8xt84eup28WIFKg0K\nUEGUcTzz+8QGAwAra+0ewPXo/AkO+8BvZjDidP417u6gpBHOJ9qYIcO9FxHeqFyu\nYrjlrxowEgXn5wO8xuNz6Vu1vhHGDHGDsRbZF8pv1d5O+0F1G7ttZ2GRRgVBZPwi\nkiyRABEBAAGJATYEGAEIACAWIQSHYyc6Kj9l6HzQsau6vFFc9jxV/wUCXJQPywIb\nDAAKCRC6vFFc9jxV/9YOCACe8qmOSnKQpQfW+PqYOqo3dt7JyweTs3FkD6NT8Zml\ndYy/vkstbTjPpX6aTvUZjkb46BVi7AOneVHpD5GBqvRsZ9iVgDYHaehmLCdKiG5L\n3Tp90NN+QY5WDbsGmsyk6+6ZMYejb4qYfweQeduOj27aavCJdLkCYMoRKfcFYI8c\nFaNmEfKKy/r1PO20NXEG6t9t05K/frHy6ZG8bCNYdpagfFVot47r9JaQqWlTNtIR\n5+zkkSq/eG9BEtRij3a6cTdQbktdBzx2KBeI0PYc1vlZR0LpuFKZqY9vlE6vTGLR\nwMfrTEOvx0NxUM3rpaCgEmuWbB1G1Hu371oyr4srrr+N\n=28dr\n-----END PGP PUBLIC KEY BLOCK-----\n", - Format: "%h %l %u %{now}V %{req.method}V %{req.url}V %>s %{resp.http.Content-Length}V", - FormatVersion: 2, - MessageType: "classic", - Placement: "waf_debug", + Name: String("test-blobstorage"), + Path: String("/logs"), + AccountName: String("test"), + Container: String("fastly"), + SASToken: String("sv=2015-04-05&ss=b&srt=sco&sp=rw&se=2019-07-21T18%3A00%3A00Z&sig=3ABdLOJZosCp0o491T%2BqZGKIhafF1nlM3MzESDDD3Gg%3D"), + Period: Uint(12), + TimestampFormat: String("%Y-%m-%dT%H:%M:%S.000"), + GzipLevel: Uint(9), + PublicKey: String("-----BEGIN PGP PUBLIC KEY BLOCK-----\n\nmQENBFyUD8sBCACyFnB39AuuTygseek+eA4fo0cgwva6/FSjnWq7riouQee8GgQ/\nibXTRyv4iVlwI12GswvMTIy7zNvs1R54i0qvsLr+IZ4GVGJqs6ZJnvQcqe3xPoR4\n8AnBfw90o32r/LuHf6QCJXi+AEu35koNlNAvLJ2B+KACaNB7N0EeWmqpV/1V2k9p\nlDYk+th7LcCuaFNGqKS/PrMnnMqR6VDLCjHhNx4KR79b0Twm/2qp6an3hyNRu8Gn\ndwxpf1/BUu3JWf+LqkN4Y3mbOmSUL3MaJNvyQguUzTfS0P0uGuBDHrJCVkMZCzDB\n89ag55jCPHyGeHBTd02gHMWzsg3WMBWvCsrzABEBAAG0JXRlcnJhZm9ybSAodGVz\ndCkgPHRlc3RAdGVycmFmb3JtLmNvbT6JAU4EEwEIADgWIQSHYyc6Kj9l6HzQsau6\nvFFc9jxV/wUCXJQPywIbAwULCQgHAgYVCgkICwIEFgIDAQIeAQIXgAAKCRC6vFFc\n9jxV/815CAClb32OxV7wG01yF97TzlyTl8TnvjMtoG29Mw4nSyg+mjM3b8N7iXm9\nOLX59fbDAWtBSldSZE22RXd3CvlFOG/EnKBXSjBtEqfyxYSnyOPkMPBYWGL/ApkX\nSvPYJ4LKdvipYToKFh3y9kk2gk1DcDBDyaaHvR+3rv1u3aoy7/s2EltAfDS3ZQIq\n7/cWTLJml/lleeB/Y6rPj8xqeCYhE5ahw9gsV/Mdqatl24V9Tks30iijx0Hhw+Gx\nkATUikMGr2GDVqoIRga5kXI7CzYff4rkc0Twn47fMHHHe/KY9M2yVnMHUXmAZwbG\nM1cMI/NH1DjevCKdGBLcRJlhuLPKF/anuQENBFyUD8sBCADIpd7r7GuPd6n/Ikxe\nu6h7umV6IIPoAm88xCYpTbSZiaK30Svh6Ywra9jfE2KlU9o6Y/art8ip0VJ3m07L\n4RSfSpnzqgSwdjSq5hNour2Fo/BzYhK7yaz2AzVSbe33R0+RYhb4b/6N+bKbjwGF\nftCsqVFMH+PyvYkLbvxyQrHlA9woAZaNThI1ztO5rGSnGUR8xt84eup28WIFKg0K\nUEGUcTzz+8QGAwAra+0ewPXo/AkO+8BvZjDidP417u6gpBHOJ9qYIcO9FxHeqFyu\nYrjlrxowEgXn5wO8xuNz6Vu1vhHGDHGDsRbZF8pv1d5O+0F1G7ttZ2GRRgVBZPwi\nkiyRABEBAAGJATYEGAEIACAWIQSHYyc6Kj9l6HzQsau6vFFc9jxV/wUCXJQPywIb\nDAAKCRC6vFFc9jxV/9YOCACe8qmOSnKQpQfW+PqYOqo3dt7JyweTs3FkD6NT8Zml\ndYy/vkstbTjPpX6aTvUZjkb46BVi7AOneVHpD5GBqvRsZ9iVgDYHaehmLCdKiG5L\n3Tp90NN+QY5WDbsGmsyk6+6ZMYejb4qYfweQeduOj27aavCJdLkCYMoRKfcFYI8c\nFaNmEfKKy/r1PO20NXEG6t9t05K/frHy6ZG8bCNYdpagfFVot47r9JaQqWlTNtIR\n5+zkkSq/eG9BEtRij3a6cTdQbktdBzx2KBeI0PYc1vlZR0LpuFKZqY9vlE6vTGLR\nwMfrTEOvx0NxUM3rpaCgEmuWbB1G1Hu371oyr4srrr+N\n=28dr\n-----END PGP PUBLIC KEY BLOCK-----\n"), + Format: String("%h %l %u %{now}V %{req.method}V %{req.url}V %>s %{resp.http.Content-Length}V"), + FormatVersion: Uint(2), + MessageType: String("classic"), + Placement: String("waf_debug"), }) }) if err != nil { @@ -167,7 +167,7 @@ func TestClient_BlobStorages(t *testing.T) { ServiceID: testServiceID, ServiceVersion: tv.Number, Name: "test-blobstorage", - NewName: "new-test-blobstorage", + NewName: String("new-test-blobstorage"), }) }) if err != nil { diff --git a/fastly/cache_setting.go b/fastly/cache_setting.go index df9a4ce71..578fba694 100644 --- a/fastly/cache_setting.go +++ b/fastly/cache_setting.go @@ -88,11 +88,11 @@ type CreateCacheSettingInput struct { // ServiceVersion is the specific configuration version (required). ServiceVersion int - Name string `form:"name,omitempty"` + Name *string `form:"name,omitempty"` Action CacheSettingAction `form:"action,omitempty"` - TTL uint `form:"ttl,omitempty"` - StaleTTL uint `form:"stale_ttl,omitempty"` - CacheCondition string `form:"cache_condition,omitempty"` + TTL *uint `form:"ttl,omitempty"` + StaleTTL *uint `form:"stale_ttl,omitempty"` + CacheCondition *string `form:"cache_condition,omitempty"` } // CreateCacheSetting creates a new Fastly cache setting. @@ -169,11 +169,11 @@ type UpdateCacheSettingInput struct { // Name is the name of the cache setting to update. Name string - NewName string `form:"name,omitempty"` + NewName *string `form:"name,omitempty"` Action CacheSettingAction `form:"action,omitempty"` - TTL uint `form:"ttl,omitempty"` - StaleTTL uint `form:"stale_ttl,omitempty"` - CacheCondition string `form:"cache_condition,omitempty"` + TTL *uint `form:"ttl,omitempty"` + StaleTTL *uint `form:"stale_ttl,omitempty"` + CacheCondition *string `form:"cache_condition,omitempty"` } // UpdateCacheSetting updates a specific cache setting. diff --git a/fastly/cache_setting_test.go b/fastly/cache_setting_test.go index b6d28a973..e6ee4cfde 100644 --- a/fastly/cache_setting_test.go +++ b/fastly/cache_setting_test.go @@ -17,10 +17,10 @@ func TestClient_CacheSettings(t *testing.T) { cacheSetting, err = c.CreateCacheSetting(&CreateCacheSettingInput{ ServiceID: testServiceID, ServiceVersion: tv.Number, - Name: "test-cache-setting", + Name: String("test-cache-setting"), Action: CacheSettingActionCache, - TTL: 1234, - StaleTTL: 1500, + TTL: Uint(1234), + StaleTTL: Uint(1500), }) }) if err != nil { @@ -104,7 +104,7 @@ func TestClient_CacheSettings(t *testing.T) { ServiceID: testServiceID, ServiceVersion: tv.Number, Name: "test-cache-setting", - NewName: "new-test-cache-setting", + NewName: String("new-test-cache-setting"), }) }) if err != nil { diff --git a/fastly/condition.go b/fastly/condition.go index 6cf47af71..ff2cd598b 100644 --- a/fastly/condition.go +++ b/fastly/condition.go @@ -73,10 +73,10 @@ type CreateConditionInput struct { // ServiceVersion is the specific configuration version (required). ServiceVersion int - Name string `form:"name,omitempty"` - Statement string `form:"statement,omitempty"` - Type string `form:"type,omitempty"` - Priority int `form:"priority,omitempty"` + Name *string `form:"name,omitempty"` + Statement *string `form:"statement,omitempty"` + Type *string `form:"type,omitempty"` + Priority *int `form:"priority,omitempty"` } // CreateCondition creates a new Fastly condition. @@ -152,10 +152,10 @@ type UpdateConditionInput struct { // Name is the name of the condition to update. Name string - Comment string `form:"comment,omitempty"` - Statement string `form:"statement,omitempty"` - Type string `form:"type,omitempty"` - Priority int `form:"priority,omitempty"` + Comment *string `form:"comment,omitempty"` + Statement *string `form:"statement,omitempty"` + Type *string `form:"type,omitempty"` + Priority *int `form:"priority,omitempty"` } // UpdateCondition updates a specific condition. diff --git a/fastly/condition_test.go b/fastly/condition_test.go index 9f759c6c3..7f6990574 100644 --- a/fastly/condition_test.go +++ b/fastly/condition_test.go @@ -17,10 +17,10 @@ func TestClient_Conditions(t *testing.T) { condition, err = c.CreateCondition(&CreateConditionInput{ ServiceID: testServiceID, ServiceVersion: tv.Number, - Name: "test/condition", - Statement: "req.url~+\"index.html\"", - Type: "REQUEST", - Priority: 1, + Name: String("test/condition"), + Statement: String("req.url~+\"index.html\""), + Type: String("REQUEST"), + Priority: Int(1), }) }) if err != nil { @@ -98,7 +98,7 @@ func TestClient_Conditions(t *testing.T) { ServiceID: testServiceID, ServiceVersion: tv.Number, Name: "test/condition", - Statement: "req.url~+\"updated.html\"", + Statement: String("req.url~+\"updated.html\""), }) }) if err != nil { diff --git a/fastly/content.go b/fastly/content.go index 26127b78f..de6113f15 100644 --- a/fastly/content.go +++ b/fastly/content.go @@ -26,7 +26,7 @@ type EdgeCheckResponse struct { // EdgeCheckInput is used as input to the EdgeCheck function. type EdgeCheckInput struct { - URL string `form:"url,omitempty"` + URL *string `form:"url,omitempty"` } // EdgeCheck queries the edge cache for all of Fastly's servers for the given @@ -34,7 +34,7 @@ type EdgeCheckInput struct { func (c *Client) EdgeCheck(i *EdgeCheckInput) ([]*EdgeCheck, error) { resp, err := c.Get("/content/edge_check", &RequestOptions{ Params: map[string]string{ - "url": i.URL, + "url": *i.URL, }, }) if err != nil { diff --git a/fastly/content_test.go b/fastly/content_test.go index ca5f666eb..958ff50d2 100644 --- a/fastly/content_test.go +++ b/fastly/content_test.go @@ -9,7 +9,7 @@ func TestClient_EdgeCheck(t *testing.T) { var edges []*EdgeCheck record(t, "content/check", func(c *Client) { edges, err = c.EdgeCheck(&EdgeCheckInput{ - URL: "releases.hashicorp.com", + URL: String("releases.hashicorp.com"), }) }) if err != nil { diff --git a/fastly/dictionary.go b/fastly/dictionary.go index b2e81d3e5..68a21eb4f 100644 --- a/fastly/dictionary.go +++ b/fastly/dictionary.go @@ -71,7 +71,7 @@ type CreateDictionaryInput struct { // ServiceVersion is the specific configuration version (required). ServiceVersion int - Name string `form:"name,omitempty"` + Name *string `form:"name,omitempty"` WriteOnly *Compatibool `form:"write_only,omitempty"` } @@ -148,7 +148,7 @@ type UpdateDictionaryInput struct { // Name is the name of the dictionary to update. Name string - NewName string `form:"name,omitempty"` + NewName *string `form:"name,omitempty"` WriteOnly *Compatibool `form:"write_only,omitempty"` } diff --git a/fastly/dictionary_item.go b/fastly/dictionary_item.go index 144c6d395..0508116b5 100644 --- a/fastly/dictionary_item.go +++ b/fastly/dictionary_item.go @@ -71,8 +71,8 @@ type CreateDictionaryItemInput struct { // DictionaryID is the ID of the dictionary to retrieve items for (required). DictionaryID string - ItemKey string `form:"item_key,omitempty"` - ItemValue string `form:"item_value,omitempty"` + ItemKey *string `form:"item_key,omitempty"` + ItemValue *string `form:"item_value,omitempty"` } // CreateDictionaryItem creates a new Fastly dictionary item. @@ -162,7 +162,7 @@ type UpdateDictionaryItemInput struct { // ItemKey is the name of the dictionary item to fetch. ItemKey string - ItemValue string `form:"item_value,omitempty"` + ItemValue *string `form:"item_value,omitempty"` } // UpdateDictionaryItem updates a specific dictionary item. diff --git a/fastly/dictionary_item_test.go b/fastly/dictionary_item_test.go index 042538533..17cf3b268 100644 --- a/fastly/dictionary_item_test.go +++ b/fastly/dictionary_item_test.go @@ -22,8 +22,8 @@ func TestClient_DictionaryItems(t *testing.T) { createdDictionaryItem, err = c.CreateDictionaryItem(&CreateDictionaryItemInput{ ServiceID: testService.ID, DictionaryID: testDictionary.ID, - ItemKey: "test-dictionary-item", - ItemValue: "value", + ItemKey: String("test-dictionary-item"), + ItemValue: String("value"), }) }) if err != nil { @@ -89,7 +89,7 @@ func TestClient_DictionaryItems(t *testing.T) { ServiceID: testService.ID, DictionaryID: testDictionary.ID, ItemKey: "test-dictionary-item", - ItemValue: "new-value", + ItemValue: String("new-value"), }) }) if err != nil { diff --git a/fastly/dictionary_test.go b/fastly/dictionary_test.go index 31ce7a86d..489564a13 100644 --- a/fastly/dictionary_test.go +++ b/fastly/dictionary_test.go @@ -16,7 +16,7 @@ func TestClient_Dictionaries(t *testing.T) { d, err = c.CreateDictionary(&CreateDictionaryInput{ ServiceID: testServiceID, ServiceVersion: testVersion.Number, - Name: "test_dictionary", + Name: String("test_dictionary"), }) }) if err != nil { @@ -82,7 +82,7 @@ func TestClient_Dictionaries(t *testing.T) { ServiceID: testServiceID, ServiceVersion: testVersion.Number, Name: "test_dictionary", - NewName: "new_test_dictionary", + NewName: String("new_test_dictionary"), }) }) if err != nil { diff --git a/fastly/diff_test.go b/fastly/diff_test.go index d7d1ddc17..87e75c626 100644 --- a/fastly/diff_test.go +++ b/fastly/diff_test.go @@ -34,8 +34,8 @@ func TestClient_Diff(t *testing.T) { _, err = c.CreateBackend(&CreateBackendInput{ ServiceID: testServiceID, ServiceVersion: tv2.Number, - Name: "test-backend", - Address: "integ-test.go-fastly.com", + Name: String("test-backend"), + Address: String("integ-test.go-fastly.com"), }) }) if err != nil { diff --git a/fastly/director.go b/fastly/director.go index ed12d0473..10f804b87 100644 --- a/fastly/director.go +++ b/fastly/director.go @@ -92,13 +92,13 @@ type CreateDirectorInput struct { // ServiceVersion is the specific configuration version (required). ServiceVersion int - Name string `form:"name,omitempty"` - Comment string `form:"comment,omitempty"` - Shield string `form:"shield,omitempty"` - Quorum uint `form:"quorum,omitempty"` + Name *string `form:"name,omitempty"` + Comment *string `form:"comment,omitempty"` + Shield *string `form:"shield,omitempty"` + Quorum *uint `form:"quorum,omitempty"` Type DirectorType `form:"type,omitempty"` - Retries uint `form:"retries,omitempty"` - Capacity uint `form:"capacity,omitempty"` + Retries *uint `form:"retries,omitempty"` + Capacity *uint `form:"capacity,omitempty"` } // CreateDirector creates a new Fastly director. @@ -174,13 +174,13 @@ type UpdateDirectorInput struct { // Name is the name of the director to update. Name string - NewName string `form:"name,omitempty"` - Comment string `form:"comment,omitempty"` - Shield string `form:"shield,omitempty"` - Quorum uint `form:"quorum,omitempty"` + NewName *string `form:"name,omitempty"` + Comment *string `form:"comment,omitempty"` + Shield *string `form:"shield,omitempty"` + Quorum *uint `form:"quorum,omitempty"` Type DirectorType `form:"type,omitempty"` - Retries uint `form:"retries,omitempty"` - Capacity uint `form:"capacity,omitempty"` + Retries *uint `form:"retries,omitempty"` + Capacity *uint `form:"capacity,omitempty"` } // UpdateDirector updates a specific director. diff --git a/fastly/director_test.go b/fastly/director_test.go index 8238a0f15..2cb880c03 100644 --- a/fastly/director_test.go +++ b/fastly/director_test.go @@ -17,10 +17,10 @@ func TestClient_Directors(t *testing.T) { b, err = c.CreateDirector(&CreateDirectorInput{ ServiceID: testServiceID, ServiceVersion: tv.Number, - Name: "test-director", - Quorum: 50, + Name: String("test-director"), + Quorum: Uint(50), Type: DirectorTypeRandom, - Retries: 5, + Retries: Uint(5), }) }) if err != nil { @@ -104,8 +104,8 @@ func TestClient_Directors(t *testing.T) { ServiceID: testServiceID, ServiceVersion: tv.Number, Name: "test-director", - NewName: "new-test-director", - Quorum: 100, + NewName: String("new-test-director"), + Quorum: Uint(100), }) }) if err != nil { diff --git a/fastly/domain.go b/fastly/domain.go index 76a953da3..83d3407df 100644 --- a/fastly/domain.go +++ b/fastly/domain.go @@ -74,7 +74,7 @@ type CreateDomainInput struct { Name string `form:"name"` // Comment is a personal, freeform descriptive note. - Comment string `form:"comment,omitempty"` + Comment *string `form:"comment,omitempty"` } // CreateDomain creates a new domain with the given information. @@ -154,7 +154,7 @@ type UpdateDomainInput struct { NewName string `form:"name"` // Comment is a personal, freeform descriptive note. - Comment string `form:"comment,omitempty"` + Comment *string `form:"comment,omitempty"` } // UpdateDomain updates a single domain for the current service. The only allowed diff --git a/fastly/domain_test.go b/fastly/domain_test.go index 5d25a38f1..204f76b61 100644 --- a/fastly/domain_test.go +++ b/fastly/domain_test.go @@ -18,7 +18,7 @@ func TestClient_Domains(t *testing.T) { ServiceID: testServiceID, ServiceVersion: tv.Number, Name: "integ-test.go-fastly.com", - Comment: "comment", + Comment: String("comment"), }) }) if err != nil { diff --git a/fastly/fastly.go b/fastly/fastly.go index f34e5c568..c622a2fa3 100644 --- a/fastly/fastly.go +++ b/fastly/fastly.go @@ -64,27 +64,3 @@ func (b *Compatibool) UnmarshalText(t []byte) error { } return nil } - -// String is a helper that returns a pointer to the string value passed in. -func String(v string) *string { - return &v -} - -// NullString is a helper that returns a pointer to the string value passed in -// or nil if the string is empty. -func NullString(v string) *string { - if v == "" { - return nil - } - return &v -} - -// Uint is a helper that returns a pointer to the uint value passed in. -func Uint(v uint) *uint { - return &v -} - -// Bool is a helper that returns a pointer to the bool value passed in. -func Bool(v bool) *bool { - return &v -} diff --git a/fastly/fastly_test.go b/fastly/fastly_test.go index 219988c08..8e7609ec5 100644 --- a/fastly/fastly_test.go +++ b/fastly/fastly_test.go @@ -126,9 +126,9 @@ func createTestService(t *testing.T, serviceFixture string, serviceNameSuffix st record(t, serviceFixture, func(client *Client) { service, err = client.CreateService(&CreateServiceInput{ - Name: fmt.Sprintf("test_service_%s", serviceNameSuffix), - Comment: "go-fastly client test", - Type: ServiceTypeVCL, + Name: String(fmt.Sprintf("test_service_%s", serviceNameSuffix)), + Comment: String("go-fastly client test"), + Type: String(ServiceTypeVCL), }) }) if err != nil { @@ -145,9 +145,9 @@ func createTestServiceWasm(t *testing.T, serviceFixture string, serviceNameSuffi record(t, serviceFixture, func(client *Client) { service, err = client.CreateService(&CreateServiceInput{ - Name: fmt.Sprintf("test_service_wasm_%s", serviceNameSuffix), - Comment: "go-fastly wasm client test", - Type: ServiceTypeWasm, + Name: String(fmt.Sprintf("test_service_wasm_%s", serviceNameSuffix)), + Comment: String("go-fastly wasm client test"), + Type: String(ServiceTypeWasm), }) }) if err != nil { @@ -200,7 +200,7 @@ func createTestDictionary(t *testing.T, dictionaryFixture string, serviceId stri dictionary, err = client.CreateDictionary(&CreateDictionaryInput{ ServiceID: serviceId, ServiceVersion: version, - Name: fmt.Sprintf("test_dictionary_%s", dictionaryNameSuffix), + Name: String(fmt.Sprintf("test_dictionary_%s", dictionaryNameSuffix)), }) }) if err != nil { @@ -286,14 +286,14 @@ func createTestLogging(t *testing.T, fixture, serviceID string, serviceNumber in log, err = c.CreateSyslog(&CreateSyslogInput{ ServiceID: serviceID, ServiceVersion: serviceNumber, - Name: "test-syslog", - Address: "example.com", - Hostname: "example.com", - Port: 1234, - Token: "abcd1234", - Format: "format", - FormatVersion: 2, - MessageType: "classic", + Name: String("test-syslog"), + Address: String("example.com"), + Hostname: String("example.com"), + Port: Uint(1234), + Token: String("abcd1234"), + Format: String("format"), + FormatVersion: Uint(2), + MessageType: String("classic"), }) }) if err != nil { @@ -344,10 +344,10 @@ func createTestWAFCondition(t *testing.T, fixture, serviceID, name string, servi condition, err = c.CreateCondition(&CreateConditionInput{ ServiceID: serviceID, ServiceVersion: serviceNumber, - Name: name, - Statement: "req.url~+\"index.html\"", - Type: "PREFETCH", // This must be a prefetch condition - Priority: 1, + Name: String(name), + Statement: String("req.url~+\"index.html\""), + Type: String("PREFETCH"), // This must be a prefetch condition + Priority: Int(1), }) }) if err != nil { @@ -381,8 +381,8 @@ func createTestWAFResponseObject(t *testing.T, fixture, serviceID, name string, ro, err = c.CreateResponseObject(&CreateResponseObjectInput{ ServiceID: serviceID, ServiceVersion: serviceNumber, - Name: name, - Status: 403, + Name: String(name), + Status: Uint(403), }) }) if err != nil { diff --git a/fastly/ftp.go b/fastly/ftp.go index 3f1dd7e43..973bb0c1b 100644 --- a/fastly/ftp.go +++ b/fastly/ftp.go @@ -83,21 +83,21 @@ type CreateFTPInput struct { // ServiceVersion is the specific configuration version (required). ServiceVersion int - Name string `form:"name,omitempty"` - Address string `form:"address,omitempty"` - Port uint `form:"port,omitempty"` - Username string `form:"user,omitempty"` - Password string `form:"password,omitempty"` - PublicKey string `form:"public_key,omitempty"` - Path string `form:"path,omitempty"` - Period uint `form:"period,omitempty"` - FormatVersion uint `form:"format_version,omitempty"` - GzipLevel uint8 `form:"gzip_level,omitempty"` - Format string `form:"format,omitempty"` - ResponseCondition string `form:"response_condition,omitempty"` - MessageType string `form:"message_type,omitempty"` - TimestampFormat string `form:"timestamp_format,omitempty"` - Placement string `form:"placement,omitempty"` + Name *string `form:"name,omitempty"` + Address *string `form:"address,omitempty"` + Port *uint `form:"port,omitempty"` + Username *string `form:"user,omitempty"` + Password *string `form:"password,omitempty"` + PublicKey *string `form:"public_key,omitempty"` + Path *string `form:"path,omitempty"` + Period *uint `form:"period,omitempty"` + FormatVersion *uint `form:"format_version,omitempty"` + GzipLevel *uint8 `form:"gzip_level,omitempty"` + Format *string `form:"format,omitempty"` + ResponseCondition *string `form:"response_condition,omitempty"` + MessageType *string `form:"message_type,omitempty"` + TimestampFormat *string `form:"timestamp_format,omitempty"` + Placement *string `form:"placement,omitempty"` } // CreateFTP creates a new Fastly FTP. @@ -173,21 +173,21 @@ type UpdateFTPInput struct { // Name is the name of the FTP to update. Name string - NewName string `form:"name,omitempty"` - Address string `form:"address,omitempty"` - Port uint `form:"port,omitempty"` - PublicKey string `form:"public_key,omitempty"` - Username string `form:"user,omitempty"` - Password string `form:"password,omitempty"` - Path string `form:"path,omitempty"` - Period uint `form:"period,omitempty"` - FormatVersion uint `form:"format_version,omitempty"` - GzipLevel uint8 `form:"gzip_level,omitempty"` - Format string `form:"format,omitempty"` - ResponseCondition string `form:"response_condition,omitempty"` - MessageType string `form:"message_type,omitempty"` - TimestampFormat string `form:"timestamp_format,omitempty"` - Placement string `form:"placement,omitempty"` + NewName *string `form:"name,omitempty"` + Address *string `form:"address,omitempty"` + Port *uint `form:"port,omitempty"` + PublicKey *string `form:"public_key,omitempty"` + Username *string `form:"user,omitempty"` + Password *string `form:"password,omitempty"` + Path *string `form:"path,omitempty"` + Period *uint `form:"period,omitempty"` + FormatVersion *uint `form:"format_version,omitempty"` + GzipLevel *uint8 `form:"gzip_level,omitempty"` + Format *string `form:"format,omitempty"` + ResponseCondition *string `form:"response_condition,omitempty"` + MessageType *string `form:"message_type,omitempty"` + TimestampFormat *string `form:"timestamp_format,omitempty"` + Placement *string `form:"placement,omitempty"` } // UpdateFTP updates a specific FTP. diff --git a/fastly/ftp_test.go b/fastly/ftp_test.go index ca0307343..d75eaa835 100644 --- a/fastly/ftp_test.go +++ b/fastly/ftp_test.go @@ -16,20 +16,20 @@ func TestClient_FTPs(t *testing.T) { ftp, err = c.CreateFTP(&CreateFTPInput{ ServiceID: testServiceID, ServiceVersion: tv.Number, - Name: "test-ftp", - Address: "example.com", - Port: 1234, - PublicKey: pgpPublicKey(), - Username: "username", - Password: "password", - Path: "/dir", - Period: 12, - GzipLevel: 9, - FormatVersion: 2, - Format: "format", - TimestampFormat: "%Y", - Placement: "waf_debug", - MessageType: "classic", + Name: String("test-ftp"), + Address: String("example.com"), + Port: Uint(1234), + PublicKey: String(pgpPublicKey()), + Username: String("username"), + Password: String("password"), + Path: String("/dir"), + Period: Uint(12), + GzipLevel: Uint8(9), + FormatVersion: Uint(2), + Format: String("format"), + TimestampFormat: String("%Y"), + Placement: String("waf_debug"), + MessageType: String("classic"), }) }) if err != nil { @@ -173,8 +173,8 @@ func TestClient_FTPs(t *testing.T) { ServiceID: testServiceID, ServiceVersion: tv.Number, Name: "test-ftp", - NewName: "new-test-ftp", - GzipLevel: 0, + NewName: String("new-test-ftp"), + GzipLevel: Uint8(0), }) }) if err != nil { diff --git a/fastly/gcs.go b/fastly/gcs.go index 9415bd1ad..fbfc2cbc8 100644 --- a/fastly/gcs.go +++ b/fastly/gcs.go @@ -81,19 +81,19 @@ type CreateGCSInput struct { // ServiceVersion is the specific configuration version (required). ServiceVersion int - Name string `form:"name,omitempty"` - Bucket string `form:"bucket_name,omitempty"` - User string `form:"user,omitempty"` - SecretKey string `form:"secret_key,omitempty"` - Path string `form:"path,omitempty"` - Period uint `form:"period,omitempty"` - FormatVersion uint `form:"format_version,omitempty"` - GzipLevel uint8 `form:"gzip_level,omitempty"` - Format string `form:"format,omitempty"` - MessageType string `form:"message_type,omitempty"` - ResponseCondition string `form:"response_condition,omitempty"` - TimestampFormat string `form:"timestamp_format,omitempty"` - Placement string `form:"placement,omitempty"` + Name *string `form:"name,omitempty"` + Bucket *string `form:"bucket_name,omitempty"` + User *string `form:"user,omitempty"` + SecretKey *string `form:"secret_key,omitempty"` + Path *string `form:"path,omitempty"` + Period *uint `form:"period,omitempty"` + FormatVersion *uint `form:"format_version,omitempty"` + GzipLevel *uint8 `form:"gzip_level,omitempty"` + Format *string `form:"format,omitempty"` + MessageType *string `form:"message_type,omitempty"` + ResponseCondition *string `form:"response_condition,omitempty"` + TimestampFormat *string `form:"timestamp_format,omitempty"` + Placement *string `form:"placement,omitempty"` } // CreateGCS creates a new Fastly GCS. @@ -169,19 +169,19 @@ type UpdateGCSInput struct { // Name is the name of the GCS to update. Name string - NewName string `form:"name,omitempty"` - Bucket string `form:"bucket_name,omitempty"` - User string `form:"user,omitempty"` - SecretKey string `form:"secret_key,omitempty"` - Path string `form:"path,omitempty"` - Period uint `form:"period,omitempty"` - FormatVersion uint `form:"format_version,omitempty"` - GzipLevel uint8 `form:"gzip_level,omitempty"` - Format string `form:"format,omitempty"` - MessageType string `form:"message_type,omitempty"` - ResponseCondition string `form:"response_condition,omitempty"` - TimestampFormat string `form:"timestamp_format,omitempty"` - Placement string `form:"placement,omitempty"` + NewName *string `form:"name,omitempty"` + Bucket *string `form:"bucket_name,omitempty"` + User *string `form:"user,omitempty"` + SecretKey *string `form:"secret_key,omitempty"` + Path *string `form:"path,omitempty"` + Period *uint `form:"period,omitempty"` + FormatVersion *uint `form:"format_version,omitempty"` + GzipLevel *uint8 `form:"gzip_level,omitempty"` + Format *string `form:"format,omitempty"` + MessageType *string `form:"message_type,omitempty"` + ResponseCondition *string `form:"response_condition,omitempty"` + TimestampFormat *string `form:"timestamp_format,omitempty"` + Placement *string `form:"placement,omitempty"` } // UpdateGCS updates a specific GCS. diff --git a/fastly/gcs_test.go b/fastly/gcs_test.go index 4afa7f054..dcc13333c 100644 --- a/fastly/gcs_test.go +++ b/fastly/gcs_test.go @@ -17,18 +17,18 @@ func TestClient_GCSs(t *testing.T) { gcs, err = c.CreateGCS(&CreateGCSInput{ ServiceID: testServiceID, ServiceVersion: tv.Number, - Name: "test-gcs", - Bucket: "bucket", - User: "user", - SecretKey: "-----BEGIN PRIVATE KEY-----\nMIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQC9aQoqdHVA86oq\nTdRQ5HqwMfpiLBBMKNQcAJsO71RKNrDWwJJZiyYbvM4FOWRZFtRSdPIDgX0C0Wg1\nNnqWYvHDyA5Ug+T8kowiQDn56dU6Km2FWO4wnqZeA8q5G7rQVXlqdibuiP7FglHA\neURUzFsqyymXMUGrqDPqrHsVWC2E3NTJEb4QlywtrwI13qbhlvTx6/9oRfUjytXJ\nRuUIE5xL8yhRCagNr5ZW250aa+wBwu5DSCk5fDNr0eDuZjw84WHDll+mHxBFGV+X\nKJ5jCOmGumGqjVWZesJpNN1My3M9bsY9layNJJ0eiDeHDEi/yXhhO/mNEXhvhq/R\nfN0Jh2A3AgMBAAECggEAef+CEL5aF6/aVs0yh7fiXkKSp1ECXkud8ztgpEn63KJF\nXM1EdnBt50fA2xSQUeGmeEXi6+cngf0nRb8FToAEgLoGoOEjSJuLrzP3I8U9Fe3m\nBRG2uZI2Ti/bD0eRGEc1oSDhCpsqnkTGK1bwcD4AKpwY+c08Izh/2BOoY6McDoqh\ndQ89jzTuMtD4cNlnPiIrY9HbxoNjshK2ax1OaeXyYKZFG1TxqMFv5gA/G5+S3Cwr\nVG4fkAxYi5vdIK3b8jUXrTM/kpoTl+d3dlQ7rRZYf7KyT31/HtJ/GNzxFI6upzO7\niDNrrUOyeOPjWXdzUh9budv3j+6UfbYK7uZIoebHIQKBgQDykYX1L/akGaOC2tfS\njzCWUzPxGFYVZQ7zD1PM6UyouuS1KLURDEGk9RxqVzTPh/pYd8Ivnz3vOVski5Zt\n19ozLGxdtDhn122DcnVpfCdYzHBdAzPCzORenFohX+MhiX5fEotTlVi7wfOmzTP5\nhUCMSd/17bJrV4XMLhkdrMRBFQKBgQDH5fwV7o+Ej/ZfcdGIa3mAFazToPDzxhHU\nnwADxaxpNGKRU03XCaiYkykarLYdG6Rk+7dXUv8eLy+6Dcq1SWQtfCWKEor++IIp\n1RwWmFHfYriHGkmxSkkEkLFvL8old9xM5YWbEXc4QIXvnfR4BZxdyJHVzIDdbI2i\nFgcn17U3GwKBgDd1njMY7ENIuWHJt16k7m7wRwfwkH4DxQ89ieNn0+cgE/p3fC6R\nptCYWg7WMXThmhNwDi3lMrvnWTdZ0uL6XyEkHwKtmdfkIV3UZZPglv5uf6JEgSkg\nv3YCOXk3+y5HyWTjUIejtc334kVY1XFPThrFKTeJSSnRsP2l7IgkYBqhAoGAYGsr\nM3z1FrDF2nWw5odIfKJ30UAw2LRyB0eGH0uqhLgyzvwKcK2E98sLqYUi9llN6zOK\n1IEA8xM5hxl97AFxY4sdJEMbbi55wim7uZ5Q51nbvbbNUsmM/Lm6C/JWI8pzpVeU\nIR7EjYp50AE1WOsD6CyFQ0W35pWkn0jWvL4L938CgYEAlax4dLE5+YCG5DeLT1/N\nin6kQjl7JS4oCNlPEj6aRPLX2OJresI7oOn+uNatKvlVyfPm6rdxeHCmER1FpR7Q\nA/aNVjPeViKT/R4nK9ytsa+s/1IJVrwLFHJK3toGE660g5w3vKrCjWisMdP4yzzQ\nbv1KwcKoQbNVXwauH79JKc0=\n-----END PRIVATE KEY-----\n", - Path: "/path", - Period: 12, - GzipLevel: 9, - FormatVersion: 2, - Format: "format", - MessageType: "blank", - TimestampFormat: "%Y", - Placement: "waf_debug", + Name: String("test-gcs"), + Bucket: String("bucket"), + User: String("user"), + SecretKey: String("-----BEGIN PRIVATE KEY-----\nMIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQC9aQoqdHVA86oq\nTdRQ5HqwMfpiLBBMKNQcAJsO71RKNrDWwJJZiyYbvM4FOWRZFtRSdPIDgX0C0Wg1\nNnqWYvHDyA5Ug+T8kowiQDn56dU6Km2FWO4wnqZeA8q5G7rQVXlqdibuiP7FglHA\neURUzFsqyymXMUGrqDPqrHsVWC2E3NTJEb4QlywtrwI13qbhlvTx6/9oRfUjytXJ\nRuUIE5xL8yhRCagNr5ZW250aa+wBwu5DSCk5fDNr0eDuZjw84WHDll+mHxBFGV+X\nKJ5jCOmGumGqjVWZesJpNN1My3M9bsY9layNJJ0eiDeHDEi/yXhhO/mNEXhvhq/R\nfN0Jh2A3AgMBAAECggEAef+CEL5aF6/aVs0yh7fiXkKSp1ECXkud8ztgpEn63KJF\nXM1EdnBt50fA2xSQUeGmeEXi6+cngf0nRb8FToAEgLoGoOEjSJuLrzP3I8U9Fe3m\nBRG2uZI2Ti/bD0eRGEc1oSDhCpsqnkTGK1bwcD4AKpwY+c08Izh/2BOoY6McDoqh\ndQ89jzTuMtD4cNlnPiIrY9HbxoNjshK2ax1OaeXyYKZFG1TxqMFv5gA/G5+S3Cwr\nVG4fkAxYi5vdIK3b8jUXrTM/kpoTl+d3dlQ7rRZYf7KyT31/HtJ/GNzxFI6upzO7\niDNrrUOyeOPjWXdzUh9budv3j+6UfbYK7uZIoebHIQKBgQDykYX1L/akGaOC2tfS\njzCWUzPxGFYVZQ7zD1PM6UyouuS1KLURDEGk9RxqVzTPh/pYd8Ivnz3vOVski5Zt\n19ozLGxdtDhn122DcnVpfCdYzHBdAzPCzORenFohX+MhiX5fEotTlVi7wfOmzTP5\nhUCMSd/17bJrV4XMLhkdrMRBFQKBgQDH5fwV7o+Ej/ZfcdGIa3mAFazToPDzxhHU\nnwADxaxpNGKRU03XCaiYkykarLYdG6Rk+7dXUv8eLy+6Dcq1SWQtfCWKEor++IIp\n1RwWmFHfYriHGkmxSkkEkLFvL8old9xM5YWbEXc4QIXvnfR4BZxdyJHVzIDdbI2i\nFgcn17U3GwKBgDd1njMY7ENIuWHJt16k7m7wRwfwkH4DxQ89ieNn0+cgE/p3fC6R\nptCYWg7WMXThmhNwDi3lMrvnWTdZ0uL6XyEkHwKtmdfkIV3UZZPglv5uf6JEgSkg\nv3YCOXk3+y5HyWTjUIejtc334kVY1XFPThrFKTeJSSnRsP2l7IgkYBqhAoGAYGsr\nM3z1FrDF2nWw5odIfKJ30UAw2LRyB0eGH0uqhLgyzvwKcK2E98sLqYUi9llN6zOK\n1IEA8xM5hxl97AFxY4sdJEMbbi55wim7uZ5Q51nbvbbNUsmM/Lm6C/JWI8pzpVeU\nIR7EjYp50AE1WOsD6CyFQ0W35pWkn0jWvL4L938CgYEAlax4dLE5+YCG5DeLT1/N\nin6kQjl7JS4oCNlPEj6aRPLX2OJresI7oOn+uNatKvlVyfPm6rdxeHCmER1FpR7Q\nA/aNVjPeViKT/R4nK9ytsa+s/1IJVrwLFHJK3toGE660g5w3vKrCjWisMdP4yzzQ\nbv1KwcKoQbNVXwauH79JKc0=\n-----END PRIVATE KEY-----\n"), + Path: String("/path"), + Period: Uint(12), + GzipLevel: Uint8(9), + FormatVersion: Uint(2), + Format: String("format"), + MessageType: String("blank"), + TimestampFormat: String("%Y"), + Placement: String("waf_debug"), }) }) if err != nil { @@ -160,8 +160,8 @@ func TestClient_GCSs(t *testing.T) { ServiceID: testServiceID, ServiceVersion: tv.Number, Name: "test-gcs", - NewName: "new-test-gcs", - MessageType: "classic", + NewName: String("new-test-gcs"), + MessageType: String("classic"), }) }) if err != nil { diff --git a/fastly/gzip.go b/fastly/gzip.go index a0391d05f..0bbd9c7fe 100644 --- a/fastly/gzip.go +++ b/fastly/gzip.go @@ -72,10 +72,10 @@ type CreateGzipInput struct { // ServiceVersion is the specific configuration version (required). ServiceVersion int - Name string `form:"name,omitempty"` - ContentTypes string `form:"content_types"` - Extensions string `form:"extensions"` - CacheCondition string `form:"cache_condition,omitempty"` + Name *string `form:"name,omitempty"` + ContentTypes string `form:"content_types"` + Extensions string `form:"extensions"` + CacheCondition *string `form:"cache_condition,omitempty"` } // CreateGzip creates a new Fastly Gzip. @@ -151,10 +151,10 @@ type UpdateGzipInput struct { // Name is the name of the Gzip to update. Name string - NewName string `form:"name,omitempty"` - ContentTypes string `form:"content_types,omitempty"` - Extensions string `form:"extensions,omitempty"` - CacheCondition string `form:"cache_condition,omitempty"` + NewName *string `form:"name,omitempty"` + ContentTypes *string `form:"content_types,omitempty"` + Extensions *string `form:"extensions,omitempty"` + CacheCondition *string `form:"cache_condition,omitempty"` } // UpdateGzip updates a specific Gzip. diff --git a/fastly/gzip_test.go b/fastly/gzip_test.go index 198e75293..43263666a 100644 --- a/fastly/gzip_test.go +++ b/fastly/gzip_test.go @@ -17,7 +17,7 @@ func TestClient_Gzips(t *testing.T) { gzip, err = c.CreateGzip(&CreateGzipInput{ ServiceID: testServiceID, ServiceVersion: tv.Number, - Name: "test-gzip", + Name: String("test-gzip"), ContentTypes: "text/html text/css", Extensions: "html css", }) @@ -32,7 +32,7 @@ func TestClient_Gzips(t *testing.T) { gzipomit, err = c.CreateGzip(&CreateGzipInput{ ServiceID: testServiceID, ServiceVersion: tv.Number, - Name: "test-gzip-omit", + Name: String("test-gzip-omit"), }) }) if err != nil { @@ -122,7 +122,7 @@ func TestClient_Gzips(t *testing.T) { ServiceID: testServiceID, ServiceVersion: tv.Number, Name: "test-gzip", - NewName: "new-test-gzip", + NewName: String("new-test-gzip"), }) }) if err != nil { diff --git a/fastly/header.go b/fastly/header.go index e259a9c13..84902f5a2 100644 --- a/fastly/header.go +++ b/fastly/header.go @@ -123,18 +123,18 @@ type CreateHeaderInput struct { // ServiceVersion is the specific configuration version (required). ServiceVersion int - Name string `form:"name,omitempty"` + Name *string `form:"name,omitempty"` Action HeaderAction `form:"action,omitempty"` IgnoreIfSet *Compatibool `form:"ignore_if_set,omitempty"` Type HeaderType `form:"type,omitempty"` - Destination string `form:"dst,omitempty"` - Source string `form:"src,omitempty"` - Regex string `form:"regex,omitempty"` - Substitution string `form:"substitution,omitempty"` - Priority uint `form:"priority,omitempty"` - RequestCondition string `form:"request_condition,omitempty"` - CacheCondition string `form:"cache_condition,omitempty"` - ResponseCondition string `form:"response_condition,omitempty"` + Destination *string `form:"dst,omitempty"` + Source *string `form:"src,omitempty"` + Regex *string `form:"regex,omitempty"` + Substitution *string `form:"substitution,omitempty"` + Priority *uint `form:"priority,omitempty"` + RequestCondition *string `form:"request_condition,omitempty"` + CacheCondition *string `form:"cache_condition,omitempty"` + ResponseCondition *string `form:"response_condition,omitempty"` } // CreateHeader creates a new Fastly header. @@ -210,18 +210,18 @@ type UpdateHeaderInput struct { // Name is the name of the header to update. Name string - NewName string `form:"name,omitempty"` + NewName *string `form:"name,omitempty"` Action HeaderAction `form:"action,omitempty"` IgnoreIfSet *Compatibool `form:"ignore_if_set,omitempty"` Type HeaderType `form:"type,omitempty"` - Destination string `form:"dst,omitempty"` - Source string `form:"src,omitempty"` - Regex string `form:"regex,omitempty"` - Substitution string `form:"substitution,omitempty"` - Priority uint `form:"priority,omitempty"` - RequestCondition string `form:"request_condition,omitempty"` - CacheCondition string `form:"cache_condition,omitempty"` - ResponseCondition string `form:"response_condition,omitempty"` + Destination *string `form:"dst,omitempty"` + Source *string `form:"src,omitempty"` + Regex *string `form:"regex,omitempty"` + Substitution *string `form:"substitution,omitempty"` + Priority *uint `form:"priority,omitempty"` + RequestCondition *string `form:"request_condition,omitempty"` + CacheCondition *string `form:"cache_condition,omitempty"` + ResponseCondition *string `form:"response_condition,omitempty"` } // UpdateHeader updates a specific header. diff --git a/fastly/header_test.go b/fastly/header_test.go index fdb833ef5..ad4a8c43b 100644 --- a/fastly/header_test.go +++ b/fastly/header_test.go @@ -17,15 +17,15 @@ func TestClient_Headers(t *testing.T) { h, err = c.CreateHeader(&CreateHeaderInput{ ServiceID: testServiceID, ServiceVersion: tv.Number, - Name: "test-header", + Name: String("test-header"), Action: HeaderActionSet, IgnoreIfSet: CBool(false), Type: HeaderTypeRequest, - Destination: "http.foo", - Source: "client.ip", - Regex: "foobar", - Substitution: "123", - Priority: 50, + Destination: String("http.foo"), + Source: String("client.ip"), + Regex: String("foobar"), + Substitution: String("123"), + Priority: Uint(50), }) }) if err != nil { @@ -139,7 +139,7 @@ func TestClient_Headers(t *testing.T) { ServiceID: testServiceID, ServiceVersion: tv.Number, Name: "test-header", - NewName: "new-test-header", + NewName: String("new-test-header"), }) }) if err != nil { diff --git a/fastly/health_check.go b/fastly/health_check.go index 307d17d52..c34a14b37 100644 --- a/fastly/health_check.go +++ b/fastly/health_check.go @@ -81,18 +81,18 @@ type CreateHealthCheckInput struct { // ServiceVersion is the specific configuration version (required). ServiceVersion int - Name string `form:"name,omitempty"` - Comment string `form:"comment,omitempty"` - Method string `form:"method,omitempty"` - Host string `form:"host,omitempty"` - Path string `form:"path,omitempty"` - HTTPVersion string `form:"http_version,omitempty"` - Timeout uint `form:"timeout,omitempty"` - CheckInterval uint `form:"check_interval,omitempty"` - ExpectedResponse uint `form:"expected_response,omitempty"` - Window uint `form:"window,omitempty"` - Threshold uint `form:"threshold,omitempty"` - Initial uint `form:"initial,omitempty"` + Name *string `form:"name,omitempty"` + Comment *string `form:"comment,omitempty"` + Method *string `form:"method,omitempty"` + Host *string `form:"host,omitempty"` + Path *string `form:"path,omitempty"` + HTTPVersion *string `form:"http_version,omitempty"` + Timeout *uint `form:"timeout,omitempty"` + CheckInterval *uint `form:"check_interval,omitempty"` + ExpectedResponse *uint `form:"expected_response,omitempty"` + Window *uint `form:"window,omitempty"` + Threshold *uint `form:"threshold,omitempty"` + Initial *uint `form:"initial,omitempty"` } // CreateHealthCheck creates a new Fastly health check. @@ -168,18 +168,18 @@ type UpdateHealthCheckInput struct { // Name is the name of the health check to update. Name string - NewName string `form:"name,omitempty"` - Comment string `form:"comment,omitempty"` - Method string `form:"method,omitempty"` - Host string `form:"host,omitempty"` - Path string `form:"path,omitempty"` - HTTPVersion string `form:"http_version,omitempty"` - Timeout uint `form:"timeout,omitempty"` - CheckInterval uint `form:"check_interval,omitempty"` - ExpectedResponse uint `form:"expected_response,omitempty"` - Window uint `form:"window,omitempty"` - Threshold uint `form:"threshold,omitempty"` - Initial uint `form:"initial,omitempty"` + NewName *string `form:"name,omitempty"` + Comment *string `form:"comment,omitempty"` + Method *string `form:"method,omitempty"` + Host *string `form:"host,omitempty"` + Path *string `form:"path,omitempty"` + HTTPVersion *string `form:"http_version,omitempty"` + Timeout *uint `form:"timeout,omitempty"` + CheckInterval *uint `form:"check_interval,omitempty"` + ExpectedResponse *uint `form:"expected_response,omitempty"` + Window *uint `form:"window,omitempty"` + Threshold *uint `form:"threshold,omitempty"` + Initial *uint `form:"initial,omitempty"` } // UpdateHealthCheck updates a specific health check. diff --git a/fastly/health_check_test.go b/fastly/health_check_test.go index 25a0d140d..60b9e7015 100644 --- a/fastly/health_check_test.go +++ b/fastly/health_check_test.go @@ -17,17 +17,17 @@ func TestClient_HealthChecks(t *testing.T) { hc, err = c.CreateHealthCheck(&CreateHealthCheckInput{ ServiceID: testServiceID, ServiceVersion: tv.Number, - Name: "test-healthcheck", - Method: "HEAD", - Host: "example.com", - Path: "/foo", - HTTPVersion: "1.1", - Timeout: 1500, - CheckInterval: 2500, - ExpectedResponse: 200, - Window: 5000, - Threshold: 10, - Initial: 10, + Name: String("test-healthcheck"), + Method: String("HEAD"), + Host: String("example.com"), + Path: String("/foo"), + HTTPVersion: String("1.1"), + Timeout: Uint(1500), + CheckInterval: Uint(2500), + ExpectedResponse: Uint(200), + Window: Uint(5000), + Threshold: Uint(10), + Initial: Uint(10), }) }) if err != nil { @@ -153,7 +153,7 @@ func TestClient_HealthChecks(t *testing.T) { ServiceID: testServiceID, ServiceVersion: tv.Number, Name: "test-healthcheck", - NewName: "new-test-healthcheck", + NewName: String("new-test-healthcheck"), }) }) if err != nil { diff --git a/fastly/https.go b/fastly/https.go index c721f9196..9f2cc9cc4 100644 --- a/fastly/https.go +++ b/fastly/https.go @@ -86,24 +86,24 @@ type CreateHTTPSInput struct { // ServiceVersion is the specific configuration version (required). ServiceVersion int - Name string `form:"name,omitempty"` - ResponseCondition string `form:"response_condition,omitempty"` - Format string `form:"format,omitempty"` - URL string `form:"url,omitempty"` - RequestMaxEntries uint `form:"request_max_entries,omitempty"` - RequestMaxBytes uint `form:"request_max_bytes,omitempty"` - ContentType string `form:"content_type,omitempty"` - HeaderName string `form:"header_name,omitempty"` - HeaderValue string `form:"header_value,omitempty"` - Method string `form:"method,omitempty"` - JSONFormat string `form:"json_format,omitempty"` - Placement string `form:"placement,omitempty"` - TLSCACert string `form:"tls_ca_cert,omitempty"` - TLSClientCert string `form:"tls_client_cert,omitempty"` - TLSClientKey string `form:"tls_client_key,omitempty"` - TLSHostname string `form:"tls_hostname,omitempty"` - MessageType string `form:"message_type,omitempty"` - FormatVersion uint `form:"format_version,omitempty"` + Name *string `form:"name,omitempty"` + ResponseCondition *string `form:"response_condition,omitempty"` + Format *string `form:"format,omitempty"` + URL *string `form:"url,omitempty"` + RequestMaxEntries *uint `form:"request_max_entries,omitempty"` + RequestMaxBytes *uint `form:"request_max_bytes,omitempty"` + ContentType *string `form:"content_type,omitempty"` + HeaderName *string `form:"header_name,omitempty"` + HeaderValue *string `form:"header_value,omitempty"` + Method *string `form:"method,omitempty"` + JSONFormat *string `form:"json_format,omitempty"` + Placement *string `form:"placement,omitempty"` + TLSCACert *string `form:"tls_ca_cert,omitempty"` + TLSClientCert *string `form:"tls_client_cert,omitempty"` + TLSClientKey *string `form:"tls_client_key,omitempty"` + TLSHostname *string `form:"tls_hostname,omitempty"` + MessageType *string `form:"message_type,omitempty"` + FormatVersion *uint `form:"format_version,omitempty"` } // CreateHTTPS creates a new Fastly HTTPS logging endpoint. @@ -178,24 +178,24 @@ type UpdateHTTPSInput struct { // Name is the name of the HTTPS endpoint to fetch. Name string - NewName string `form:"name,omitempty"` - ResponseCondition string `form:"response_condition,omitempty"` - Format string `form:"format,omitempty"` - URL string `form:"url,omitempty"` - RequestMaxEntries uint `form:"request_max_entries,omitempty"` - RequestMaxBytes uint `form:"request_max_bytes,omitempty"` - ContentType string `form:"content_type,omitempty"` - HeaderName string `form:"header_name,omitempty"` - HeaderValue string `form:"header_value,omitempty"` - Method string `form:"method,omitempty"` - JSONFormat string `form:"json_format,omitempty"` - Placement string `form:"placement,omitempty"` - TLSCACert string `form:"tls_ca_cert,omitempty"` - TLSClientCert string `form:"tls_client_cert,omitempty"` - TLSClientKey string `form:"tls_client_key,omitempty"` - TLSHostname string `form:"tls_hostname,omitempty"` - MessageType string `form:"message_type,omitempty"` - FormatVersion uint `form:"format_version,omitempty"` + NewName *string `form:"name,omitempty"` + ResponseCondition *string `form:"response_condition,omitempty"` + Format *string `form:"format,omitempty"` + URL *string `form:"url,omitempty"` + RequestMaxEntries *uint `form:"request_max_entries,omitempty"` + RequestMaxBytes *uint `form:"request_max_bytes,omitempty"` + ContentType *string `form:"content_type,omitempty"` + HeaderName *string `form:"header_name,omitempty"` + HeaderValue *string `form:"header_value,omitempty"` + Method *string `form:"method,omitempty"` + JSONFormat *string `form:"json_format,omitempty"` + Placement *string `form:"placement,omitempty"` + TLSCACert *string `form:"tls_ca_cert,omitempty"` + TLSClientCert *string `form:"tls_client_cert,omitempty"` + TLSClientKey *string `form:"tls_client_key,omitempty"` + TLSHostname *string `form:"tls_hostname,omitempty"` + MessageType *string `form:"message_type,omitempty"` + FormatVersion *uint `form:"format_version,omitempty"` } func (c *Client) UpdateHTTPS(i *UpdateHTTPSInput) (*HTTPS, error) { diff --git a/fastly/https_test.go b/fastly/https_test.go index 67e202e23..588a5ffad 100644 --- a/fastly/https_test.go +++ b/fastly/https_test.go @@ -40,23 +40,23 @@ Wm7DCfrPNGVwFWUQOmsPue9rZBgO h, err = c.CreateHTTPS(&CreateHTTPSInput{ ServiceID: testServiceID, ServiceVersion: tv.Number, - Name: "test-https", - Format: "format", - URL: "https://example.com/", - RequestMaxEntries: 1, - RequestMaxBytes: 1000, - ContentType: "application/json", - HeaderName: "X-Example-Header", - HeaderValue: "ExampleValue", - Method: "PUT", - JSONFormat: "2", - Placement: "waf_debug", - TLSCACert: caCert, - TLSClientCert: clientCert, - TLSClientKey: clientKey, - TLSHostname: "example.com", - MessageType: "blank", - FormatVersion: 2, + Name: String("test-https"), + Format: String("format"), + URL: String("https://example.com/"), + RequestMaxEntries: Uint(1), + RequestMaxBytes: Uint(1000), + ContentType: String("application/json"), + HeaderName: String("X-Example-Header"), + HeaderValue: String("ExampleValue"), + Method: String("PUT"), + JSONFormat: String("2"), + Placement: String("waf_debug"), + TLSCACert: String(caCert), + TLSClientCert: String(clientCert), + TLSClientKey: String(clientKey), + TLSHostname: String("example.com"), + MessageType: String("blank"), + FormatVersion: Uint(2), }) }) if err != nil { @@ -219,8 +219,8 @@ Wm7DCfrPNGVwFWUQOmsPue9rZBgO ServiceID: testServiceID, ServiceVersion: tv.Number, Name: "test-https", - NewName: "new-test-https", - Method: "POST", + NewName: String("new-test-https"), + Method: String("POST"), }) }) if err != nil { diff --git a/fastly/logentries.go b/fastly/logentries.go index b0d497424..854374411 100644 --- a/fastly/logentries.go +++ b/fastly/logentries.go @@ -76,14 +76,14 @@ type CreateLogentriesInput struct { // ServiceVersion is the specific configuration version (required). ServiceVersion int - Name string `form:"name,omitempty"` - Port uint `form:"port,omitempty"` + Name *string `form:"name,omitempty"` + Port *uint `form:"port,omitempty"` UseTLS *Compatibool `form:"use_tls,omitempty"` - Token string `form:"token,omitempty"` - Format string `form:"format,omitempty"` - FormatVersion uint `form:"format_version,omitempty"` - ResponseCondition string `form:"response_condition,omitempty"` - Placement string `form:"placement,omitempty"` + Token *string `form:"token,omitempty"` + Format *string `form:"format,omitempty"` + FormatVersion *uint `form:"format_version,omitempty"` + ResponseCondition *string `form:"response_condition,omitempty"` + Placement *string `form:"placement,omitempty"` } // CreateLogentries creates a new Fastly logentries. @@ -159,14 +159,14 @@ type UpdateLogentriesInput struct { // Name is the name of the logentries to update. Name string - NewName string `form:"name,omitempty"` - Port uint `form:"port,omitempty"` + NewName *string `form:"name,omitempty"` + Port *uint `form:"port,omitempty"` UseTLS *Compatibool `form:"use_tls,omitempty"` - Token string `form:"token,omitempty"` - Format string `form:"format,omitempty"` - FormatVersion uint `form:"format_version,omitempty"` - ResponseCondition string `form:"response_condition,omitempty"` - Placement string `form:"placement,omitempty"` + Token *string `form:"token,omitempty"` + Format *string `form:"format,omitempty"` + FormatVersion *uint `form:"format_version,omitempty"` + ResponseCondition *string `form:"response_condition,omitempty"` + Placement *string `form:"placement,omitempty"` } // UpdateLogentries updates a specific logentries. diff --git a/fastly/logentries_test.go b/fastly/logentries_test.go index 57cb0a0c8..e7c681502 100644 --- a/fastly/logentries_test.go +++ b/fastly/logentries_test.go @@ -17,12 +17,12 @@ func TestClient_Logentries(t *testing.T) { le, err = c.CreateLogentries(&CreateLogentriesInput{ ServiceID: testServiceID, ServiceVersion: tv.Number, - Name: "test-logentries", - Port: 1234, + Name: String("test-logentries"), + Port: Uint(1234), UseTLS: CBool(true), - Token: "abcd1234", - Format: "format", - Placement: "waf_debug", + Token: String("abcd1234"), + Format: String("format"), + Placement: String("waf_debug"), }) }) if err != nil { @@ -124,8 +124,8 @@ func TestClient_Logentries(t *testing.T) { ServiceID: testServiceID, ServiceVersion: tv.Number, Name: "test-logentries", - NewName: "new-test-logentries", - FormatVersion: 2, + NewName: String("new-test-logentries"), + FormatVersion: Uint(2), }) }) if err != nil { diff --git a/fastly/papertrail.go b/fastly/papertrail.go index a55d4965f..f47d7c767 100644 --- a/fastly/papertrail.go +++ b/fastly/papertrail.go @@ -75,16 +75,16 @@ type CreatePapertrailInput struct { // ServiceVersion is the specific configuration version (required). ServiceVersion int - Name string `form:"name,omitempty"` - Address string `form:"address,omitempty"` - Port uint `form:"port,omitempty"` - FormatVersion uint `form:"format_version,omitempty"` - Format string `form:"format,omitempty"` - ResponseCondition string `form:"response_condition,omitempty"` + Name *string `form:"name,omitempty"` + Address *string `form:"address,omitempty"` + Port *uint `form:"port,omitempty"` + FormatVersion *uint `form:"format_version,omitempty"` + Format *string `form:"format,omitempty"` + ResponseCondition *string `form:"response_condition,omitempty"` CreatedAt *time.Time `form:"created_at,omitempty"` UpdatedAt *time.Time `form:"updated_at,omitempty"` DeletedAt *time.Time `form:"deleted_at,omitempty"` - Placement string `form:"placement,omitempty"` + Placement *string `form:"placement,omitempty"` } // CreatePapertrail creates a new Fastly papertrail. @@ -160,16 +160,16 @@ type UpdatePapertrailInput struct { // Name is the name of the papertrail to update. Name string - NewName string `form:"name,omitempty"` - Address string `form:"address,omitempty"` - Port uint `form:"port,omitempty"` - FormatVersion uint `form:"format_version,omitempty"` - Format string `form:"format,omitempty"` - ResponseCondition string `form:"response_condition,omitempty"` + NewName *string `form:"name,omitempty"` + Address *string `form:"address,omitempty"` + Port *uint `form:"port,omitempty"` + FormatVersion *uint `form:"format_version,omitempty"` + Format *string `form:"format,omitempty"` + ResponseCondition *string `form:"response_condition,omitempty"` CreatedAt *time.Time `form:"created_at,omitempty"` UpdatedAt *time.Time `form:"updated_at,omitempty"` DeletedAt *time.Time `form:"deleted_at,omitempty"` - Placement string `form:"placement,omitempty"` + Placement *string `form:"placement,omitempty"` } // UpdatePapertrail updates a specific papertrail. diff --git a/fastly/papertrail_test.go b/fastly/papertrail_test.go index 7ef4036be..a60187347 100644 --- a/fastly/papertrail_test.go +++ b/fastly/papertrail_test.go @@ -17,12 +17,12 @@ func TestClient_Papertrails(t *testing.T) { p, err = c.CreatePapertrail(&CreatePapertrailInput{ ServiceID: testServiceID, ServiceVersion: tv.Number, - Name: "test-papertrail", - Address: "integ-test.go-fastly.com", - Port: 1234, - FormatVersion: 2, - Format: "format", - Placement: "waf_debug", + Name: String("test-papertrail"), + Address: String("integ-test.go-fastly.com"), + Port: Uint(1234), + FormatVersion: Uint(2), + Format: String("format"), + Placement: String("waf_debug"), }) }) if err != nil { @@ -118,7 +118,7 @@ func TestClient_Papertrails(t *testing.T) { ServiceID: testServiceID, ServiceVersion: tv.Number, Name: "test-papertrail", - NewName: "new-test-papertrail", + NewName: String("new-test-papertrail"), }) }) if err != nil { diff --git a/fastly/request_setting.go b/fastly/request_setting.go index 6d17ef02b..8a74b5fa5 100644 --- a/fastly/request_setting.go +++ b/fastly/request_setting.go @@ -115,18 +115,18 @@ type CreateRequestSettingInput struct { // ServiceVersion is the specific configuration version (required). ServiceVersion int - Name string `form:"name,omitempty"` + Name *string `form:"name,omitempty"` ForceMiss *Compatibool `form:"force_miss,omitempty"` ForceSSL *Compatibool `form:"force_ssl,omitempty"` Action RequestSettingAction `form:"action,omitempty"` BypassBusyWait *Compatibool `form:"bypass_busy_wait,omitempty"` - MaxStaleAge uint `form:"max_stale_age,omitempty"` - HashKeys string `form:"hash_keys,omitempty"` + MaxStaleAge *uint `form:"max_stale_age,omitempty"` + HashKeys *string `form:"hash_keys,omitempty"` XForwardedFor RequestSettingXFF `form:"xff,omitempty"` TimerSupport *Compatibool `form:"timer_support,omitempty"` GeoHeaders *Compatibool `form:"geo_headers,omitempty"` - DefaultHost string `form:"default_host,omitempty"` - RequestCondition string `form:"request_condition,omitempty"` + DefaultHost *string `form:"default_host,omitempty"` + RequestCondition *string `form:"request_condition,omitempty"` } // CreateRequestSetting creates a new Fastly request settings. @@ -204,18 +204,18 @@ type UpdateRequestSettingInput struct { // Name is the name of the request settings to update. Name string - NewName string `form:"name,omitempty"` + NewName *string `form:"name,omitempty"` ForceMiss *Compatibool `form:"force_miss,omitempty"` ForceSSL *Compatibool `form:"force_ssl,omitempty"` Action RequestSettingAction `form:"action,omitempty"` BypassBusyWait *Compatibool `form:"bypass_busy_wait,omitempty"` - MaxStaleAge uint `form:"max_stale_age,omitempty"` - HashKeys string `form:"hash_keys,omitempty"` + MaxStaleAge *uint `form:"max_stale_age,omitempty"` + HashKeys *string `form:"hash_keys,omitempty"` XForwardedFor RequestSettingXFF `form:"xff,omitempty"` TimerSupport *Compatibool `form:"timer_support,omitempty"` GeoHeaders *Compatibool `form:"geo_headers,omitempty"` - DefaultHost string `form:"default_host,omitempty"` - RequestCondition string `form:"request_condition,omitempty"` + DefaultHost *string `form:"default_host,omitempty"` + RequestCondition *string `form:"request_condition,omitempty"` } // UpdateRequestSetting updates a specific request settings. diff --git a/fastly/request_setting_test.go b/fastly/request_setting_test.go index e4ef270aa..a085c82ad 100644 --- a/fastly/request_setting_test.go +++ b/fastly/request_setting_test.go @@ -17,17 +17,17 @@ func TestClient_RequestSettings(t *testing.T) { rs, err = c.CreateRequestSetting(&CreateRequestSettingInput{ ServiceID: testServiceID, ServiceVersion: tv.Number, - Name: "test-request-setting", + Name: String("test-request-setting"), ForceMiss: CBool(true), ForceSSL: CBool(true), Action: RequestSettingActionLookup, BypassBusyWait: CBool(true), - MaxStaleAge: 30, - HashKeys: "a,b,c", + MaxStaleAge: Uint(30), + HashKeys: String("a,b,c"), XForwardedFor: RequestSettingXFFLeave, TimerSupport: CBool(true), GeoHeaders: CBool(true), - DefaultHost: "example.com", + DefaultHost: String("example.com"), }) }) if err != nil { @@ -153,7 +153,7 @@ func TestClient_RequestSettings(t *testing.T) { ServiceID: testServiceID, ServiceVersion: tv.Number, Name: "test-request-setting", - NewName: "new-test-request-setting", + NewName: String("new-test-request-setting"), }) }) if err != nil { diff --git a/fastly/response_object.go b/fastly/response_object.go index 92bf73898..89f36897e 100644 --- a/fastly/response_object.go +++ b/fastly/response_object.go @@ -78,13 +78,13 @@ type CreateResponseObjectInput struct { // ServiceVersion is the specific configuration version (required). ServiceVersion int - Name string `form:"name,omitempty"` - Status uint `form:"status,omitempty"` - Response string `form:"response,omitempty"` - Content string `form:"content,omitempty"` - ContentType string `form:"content_type,omitempty"` - RequestCondition string `form:"request_condition,omitempty"` - CacheCondition string `form:"cache_condition,omitempty"` + Name *string `form:"name,omitempty"` + Status *uint `form:"status,omitempty"` + Response *string `form:"response,omitempty"` + Content *string `form:"content,omitempty"` + ContentType *string `form:"content_type,omitempty"` + RequestCondition *string `form:"request_condition,omitempty"` + CacheCondition *string `form:"cache_condition,omitempty"` } // CreateResponseObject creates a new Fastly response object. @@ -162,13 +162,13 @@ type UpdateResponseObjectInput struct { // Name is the name of the response object to update. Name string - NewName string `form:"name,omitempty"` - Status uint `form:"status,omitempty"` - Response string `form:"response,omitempty"` - Content string `form:"content,omitempty"` - ContentType string `form:"content_type,omitempty"` - RequestCondition string `form:"request_condition,omitempty"` - CacheCondition string `form:"cache_condition,omitempty"` + NewName *string `form:"name,omitempty"` + Status *uint `form:"status,omitempty"` + Response *string `form:"response,omitempty"` + Content *string `form:"content,omitempty"` + ContentType *string `form:"content_type,omitempty"` + RequestCondition *string `form:"request_condition,omitempty"` + CacheCondition *string `form:"cache_condition,omitempty"` } // UpdateResponseObject updates a specific response object. diff --git a/fastly/response_object_test.go b/fastly/response_object_test.go index cb988bcaf..ccc9b3f03 100644 --- a/fastly/response_object_test.go +++ b/fastly/response_object_test.go @@ -17,11 +17,11 @@ func TestClient_ResponseObjects(t *testing.T) { ro, err = c.CreateResponseObject(&CreateResponseObjectInput{ ServiceID: testServiceID, ServiceVersion: tv.Number, - Name: "test-response-object", - Status: 200, - Response: "Ok", - Content: "abcd", - ContentType: "text/plain", + Name: String("test-response-object"), + Status: Uint(200), + Response: String("Ok"), + Content: String("abcd"), + ContentType: String("text/plain"), }) }) if err != nil { @@ -111,7 +111,7 @@ func TestClient_ResponseObjects(t *testing.T) { ServiceID: testServiceID, ServiceVersion: tv.Number, Name: "test-response-object", - NewName: "new-test-response-object", + NewName: String("new-test-response-object"), }) }) if err != nil { diff --git a/fastly/s3.go b/fastly/s3.go index 0c4b48c24..efb7d85b4 100644 --- a/fastly/s3.go +++ b/fastly/s3.go @@ -96,23 +96,23 @@ type CreateS3Input struct { // ServiceVersion is the specific configuration version (required). ServiceVersion int - Name string `form:"name,omitempty"` - BucketName string `form:"bucket_name,omitempty"` - Domain string `form:"domain,omitempty"` - AccessKey string `form:"access_key,omitempty"` - SecretKey string `form:"secret_key,omitempty"` - Path string `form:"path,omitempty"` - Period uint `form:"period,omitempty"` - GzipLevel uint `form:"gzip_level,omitempty"` - Format string `form:"format,omitempty"` - MessageType string `form:"message_type,omitempty"` - FormatVersion uint `form:"format_version,omitempty"` - ResponseCondition string `form:"response_condition,omitempty"` - TimestampFormat string `form:"timestamp_format,omitempty"` + Name *string `form:"name,omitempty"` + BucketName *string `form:"bucket_name,omitempty"` + Domain *string `form:"domain,omitempty"` + AccessKey *string `form:"access_key,omitempty"` + SecretKey *string `form:"secret_key,omitempty"` + Path *string `form:"path,omitempty"` + Period *uint `form:"period,omitempty"` + GzipLevel *uint `form:"gzip_level,omitempty"` + Format *string `form:"format,omitempty"` + MessageType *string `form:"message_type,omitempty"` + FormatVersion *uint `form:"format_version,omitempty"` + ResponseCondition *string `form:"response_condition,omitempty"` + TimestampFormat *string `form:"timestamp_format,omitempty"` Redundancy S3Redundancy `form:"redundancy,omitempty"` - Placement string `form:"placement,omitempty"` - PublicKey string `form:"public_key,omitempty"` - ServerSideEncryptionKMSKeyID string `form:"server_side_encryption_kms_key_id,omitempty"` + Placement *string `form:"placement,omitempty"` + PublicKey *string `form:"public_key,omitempty"` + ServerSideEncryptionKMSKeyID *string `form:"server_side_encryption_kms_key_id,omitempty"` ServerSideEncryption S3ServerSideEncryption `form:"server_side_encryption,omitempty"` } @@ -126,7 +126,7 @@ func (c *Client) CreateS3(i *CreateS3Input) (*S3, error) { return nil, ErrMissingServiceVersion } - if i.ServerSideEncryption == S3ServerSideEncryptionKMS && i.ServerSideEncryptionKMSKeyID == "" { + if i.ServerSideEncryption == S3ServerSideEncryptionKMS && *i.ServerSideEncryptionKMSKeyID == "" { return nil, ErrMissingKMSKeyID } @@ -193,23 +193,23 @@ type UpdateS3Input struct { // Name is the name of the S3 to update. Name string - NewName string `form:"name,omitempty"` - BucketName string `form:"bucket_name,omitempty"` - Domain string `form:"domain,omitempty"` - AccessKey string `form:"access_key,omitempty"` - SecretKey string `form:"secret_key,omitempty"` - Path string `form:"path,omitempty"` - Period uint `form:"period,omitempty"` - GzipLevel uint `form:"gzip_level,omitempty"` - Format string `form:"format,omitempty"` - FormatVersion uint `form:"format_version,omitempty"` - ResponseCondition string `form:"response_condition,omitempty"` - MessageType string `form:"message_type,omitempty"` - TimestampFormat string `form:"timestamp_format,omitempty"` + NewName *string `form:"name,omitempty"` + BucketName *string `form:"bucket_name,omitempty"` + Domain *string `form:"domain,omitempty"` + AccessKey *string `form:"access_key,omitempty"` + SecretKey *string `form:"secret_key,omitempty"` + Path *string `form:"path,omitempty"` + Period *uint `form:"period,omitempty"` + GzipLevel *uint `form:"gzip_level,omitempty"` + Format *string `form:"format,omitempty"` + FormatVersion *uint `form:"format_version,omitempty"` + ResponseCondition *string `form:"response_condition,omitempty"` + MessageType *string `form:"message_type,omitempty"` + TimestampFormat *string `form:"timestamp_format,omitempty"` Redundancy S3Redundancy `form:"redundancy,omitempty"` - Placement string `form:"placement,omitempty"` - PublicKey string `form:"public_key,omitempty"` - ServerSideEncryptionKMSKeyID string `form:"server_side_encryption_kms_key_id,omitempty"` + Placement *string `form:"placement,omitempty"` + PublicKey *string `form:"public_key,omitempty"` + ServerSideEncryptionKMSKeyID *string `form:"server_side_encryption_kms_key_id,omitempty"` ServerSideEncryption S3ServerSideEncryption `form:"server_side_encryption,omitempty"` } @@ -227,7 +227,7 @@ func (c *Client) UpdateS3(i *UpdateS3Input) (*S3, error) { return nil, ErrMissingName } - if i.ServerSideEncryption == S3ServerSideEncryptionKMS && i.ServerSideEncryptionKMSKeyID == "" { + if i.ServerSideEncryption == S3ServerSideEncryptionKMS && *i.ServerSideEncryptionKMSKeyID == "" { return nil, ErrMissingKMSKeyID } diff --git a/fastly/s3_test.go b/fastly/s3_test.go index 56df9e547..a4abe88f8 100644 --- a/fastly/s3_test.go +++ b/fastly/s3_test.go @@ -17,23 +17,23 @@ func TestClient_S3s(t *testing.T) { s3, err = c.CreateS3(&CreateS3Input{ ServiceID: testServiceID, ServiceVersion: tv.Number, - Name: "test-s3", - BucketName: "bucket-name", - Domain: "s3.us-east-1.amazonaws.com", - AccessKey: "AKIAIOSFODNN7EXAMPLE", - SecretKey: "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY", - Path: "/path", - Period: 12, - GzipLevel: 9, - Format: "format", - FormatVersion: 2, - ResponseCondition: "", - TimestampFormat: "%Y", - MessageType: "classic", + Name: String("test-s3"), + BucketName: String("bucket-name"), + Domain: String("s3.us-east-1.amazonaws.com"), + AccessKey: String("AKIAIOSFODNN7EXAMPLE"), + SecretKey: String("wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"), + Path: String("/path"), + Period: Uint(12), + GzipLevel: Uint(9), + Format: String("format"), + FormatVersion: Uint(2), + ResponseCondition: String(""), + TimestampFormat: String("%Y"), + MessageType: String("classic"), Redundancy: S3RedundancyReduced, - Placement: "waf_debug", - PublicKey: pgpPublicKey(), - ServerSideEncryptionKMSKeyID: "1234", + Placement: String("waf_debug"), + PublicKey: String(pgpPublicKey()), + ServerSideEncryptionKMSKeyID: String("1234"), ServerSideEncryption: S3ServerSideEncryptionKMS, }) }) @@ -200,8 +200,8 @@ func TestClient_S3s(t *testing.T) { ServiceID: testServiceID, ServiceVersion: tv.Number, Name: "test-s3", - NewName: "new-test-s3", - PublicKey: pgpPublicKeyUpdate(), + NewName: String("new-test-s3"), + PublicKey: String(pgpPublicKeyUpdate()), }) }) if err != nil { @@ -265,9 +265,9 @@ func TestClient_CreateS3_validation(t *testing.T) { _, err = testClient.CreateS3(&CreateS3Input{ ServiceID: "foo", ServiceVersion: 1, - Name: "test-service", + Name: String("test-service"), ServerSideEncryption: S3ServerSideEncryptionKMS, - ServerSideEncryptionKMSKeyID: "", + ServerSideEncryptionKMSKeyID: String(""), }) if err != ErrMissingKMSKeyID { t.Errorf("bad error: %s", err) @@ -332,7 +332,7 @@ func TestClient_UpdateS3_validation(t *testing.T) { ServiceVersion: 1, Name: "test-service", ServerSideEncryption: S3ServerSideEncryptionKMS, - ServerSideEncryptionKMSKeyID: "", + ServerSideEncryptionKMSKeyID: String(""), }) if err != ErrMissingKMSKeyID { t.Errorf("bad error: %s", err) diff --git a/fastly/service.go b/fastly/service.go index f19789dbf..c242a2c5b 100644 --- a/fastly/service.go +++ b/fastly/service.go @@ -76,9 +76,9 @@ func (c *Client) ListServices(i *ListServicesInput) ([]*Service, error) { // CreateServiceInput is used as input to the CreateService function. type CreateServiceInput struct { - Name string `form:"name,omitempty"` - Type string `form:"type,omitempty"` - Comment string `form:"comment,omitempty"` + Name *string `form:"name,omitempty"` + Type *string `form:"type,omitempty"` + Comment *string `form:"comment,omitempty"` } // CreateService creates a new service with the given information. @@ -147,8 +147,8 @@ func (c *Client) GetServiceDetails(i *GetServiceInput) (*ServiceDetail, error) { type UpdateServiceInput struct { ID string - Name string `form:"name,omitempty"` - Comment string `form:"comment,omitempty"` + Name *string `form:"name,omitempty"` + Comment *string `form:"comment,omitempty"` } // UpdateService updates the service with the given input. diff --git a/fastly/service_test.go b/fastly/service_test.go index abc8f736a..e8f20a9a4 100644 --- a/fastly/service_test.go +++ b/fastly/service_test.go @@ -11,8 +11,8 @@ func TestClient_Services(t *testing.T) { var s *Service record(t, "services/create", func(c *Client) { s, err = c.CreateService(&CreateServiceInput{ - Name: "test-service", - Comment: "comment", + Name: String("test-service"), + Comment: String("comment"), }) }) if err != nil { @@ -123,7 +123,7 @@ func TestClient_Services(t *testing.T) { record(t, "services/update", func(c *Client) { us, err = c.UpdateService(&UpdateServiceInput{ ID: s.ID, - Name: "new-test-service", + Name: String("new-test-service"), }) }) if err != nil { diff --git a/fastly/settings.go b/fastly/settings.go index 15eb441cf..4c5de67e8 100644 --- a/fastly/settings.go +++ b/fastly/settings.go @@ -53,10 +53,10 @@ type UpdateSettingsInput struct { // ServiceVersion is the specific configuration version (required). ServiceVersion int - DefaultTTL uint `form:"general.default_ttl"` - DefaultHost string `form:"general.default_host,omitempty"` - StaleIfError bool `form:"general.stale_if_error,omitempty"` - StaleIfErrorTTL uint `form:"general.stale_if_error_ttl,omitempty"` + DefaultTTL uint `form:"general.default_ttl"` + DefaultHost *string `form:"general.default_host,omitempty"` + StaleIfError *bool `form:"general.stale_if_error,omitempty"` + StaleIfErrorTTL *uint `form:"general.stale_if_error_ttl,omitempty"` } // UpdateSettings updates a specific backend. diff --git a/fastly/settings_test.go b/fastly/settings_test.go index 393b3eb57..31c08b68d 100644 --- a/fastly/settings_test.go +++ b/fastly/settings_test.go @@ -38,8 +38,8 @@ func TestClient_Settings(t *testing.T) { ServiceID: testServiceID, ServiceVersion: tv.Number, DefaultTTL: 1800, - StaleIfError: true, - StaleIfErrorTTL: 57600, + StaleIfError: Bool(true), + StaleIfErrorTTL: Uint(57600), }) }) if err != nil { diff --git a/fastly/splunk.go b/fastly/splunk.go index 14c0c818d..07d03849f 100644 --- a/fastly/splunk.go +++ b/fastly/splunk.go @@ -77,15 +77,15 @@ type CreateSplunkInput struct { // ServiceVersion is the specific configuration version (required). ServiceVersion int - Name string `form:"name,omitempty"` - URL string `form:"url,omitempty"` - Format string `form:"format,omitempty"` - FormatVersion uint `form:"format_version,omitempty"` - ResponseCondition string `form:"response_condition,omitempty"` - Placement string `form:"placement,omitempty"` - Token string `form:"token,omitempty"` - TLSCACert string `form:"tls_ca_cert,omitempty"` - TLSHostname string `form:"tls_hostname,omitempty"` + Name *string `form:"name,omitempty"` + URL *string `form:"url,omitempty"` + Format *string `form:"format,omitempty"` + FormatVersion *uint `form:"format_version,omitempty"` + ResponseCondition *string `form:"response_condition,omitempty"` + Placement *string `form:"placement,omitempty"` + Token *string `form:"token,omitempty"` + TLSCACert *string `form:"tls_ca_cert,omitempty"` + TLSHostname *string `form:"tls_hostname,omitempty"` } // CreateSplunk creates a new Fastly splunk. @@ -161,15 +161,15 @@ type UpdateSplunkInput struct { // Name is the name of the splunk to update. Name string - NewName string `form:"name,omitempty"` - URL string `form:"url,omitempty"` - Format string `form:"format,omitempty"` - FormatVersion uint `form:"format_version,omitempty"` - ResponseCondition string `form:"response_condition,omitempty"` - Placement string `form:"placement,omitempty"` - Token string `form:"token,omitempty"` - TLSCACert string `form:"tls_ca_cert,omitempty"` - TLSHostname string `form:"tls_hostname,omitempty"` + NewName *string `form:"name,omitempty"` + URL *string `form:"url,omitempty"` + Format *string `form:"format,omitempty"` + FormatVersion *uint `form:"format_version,omitempty"` + ResponseCondition *string `form:"response_condition,omitempty"` + Placement *string `form:"placement,omitempty"` + Token *string `form:"token,omitempty"` + TLSCACert *string `form:"tls_ca_cert,omitempty"` + TLSHostname *string `form:"tls_hostname,omitempty"` } // UpdateSplunk updates a specific splunk. diff --git a/fastly/splunk_test.go b/fastly/splunk_test.go index a36411ab5..dfb54d176 100644 --- a/fastly/splunk_test.go +++ b/fastly/splunk_test.go @@ -38,14 +38,14 @@ Wm7DCfrPNGVwFWUQOmsPue9rZBgO s, err = c.CreateSplunk(&CreateSplunkInput{ ServiceID: testServiceID, ServiceVersion: tv.Number, - Name: "test-splunk", - URL: "https://mysplunkendpoint.example.com/services/collector/event", - Format: "%h %l %u %t \"%r\" %>s %b", - FormatVersion: 2, - Placement: "waf_debug", - Token: "super-secure-token", - TLSCACert: caCert, - TLSHostname: "example.com", + Name: String("test-splunk"), + URL: String("https://mysplunkendpoint.example.com/services/collector/event"), + Format: String("%h %l %u %t \"%r\" %>s %b"), + FormatVersion: Uint(2), + Placement: String("waf_debug"), + Token: String("super-secure-token"), + TLSCACert: String(caCert), + TLSHostname: String("example.com"), }) }) if err != nil { @@ -153,7 +153,7 @@ Wm7DCfrPNGVwFWUQOmsPue9rZBgO ServiceID: testServiceID, ServiceVersion: tv.Number, Name: "test-splunk", - NewName: "new-test-splunk", + NewName: String("new-test-splunk"), }) }) if err != nil { diff --git a/fastly/sumologic.go b/fastly/sumologic.go index 6e23ee4d0..3c1b65ad1 100644 --- a/fastly/sumologic.go +++ b/fastly/sumologic.go @@ -76,14 +76,14 @@ type CreateSumologicInput struct { // ServiceVersion is the specific configuration version (required). ServiceVersion int - Name string `form:"name,omitempty"` - Address string `form:"address,omitempty"` - URL string `form:"url,omitempty"` - Format string `form:"format,omitempty"` - ResponseCondition string `form:"response_condition,omitempty"` - MessageType string `form:"message_type,omitempty"` - FormatVersion int `form:"format_version,omitempty"` - Placement string `form:"placement,omitempty"` + Name *string `form:"name,omitempty"` + Address *string `form:"address,omitempty"` + URL *string `form:"url,omitempty"` + Format *string `form:"format,omitempty"` + ResponseCondition *string `form:"response_condition,omitempty"` + MessageType *string `form:"message_type,omitempty"` + FormatVersion *int `form:"format_version,omitempty"` + Placement *string `form:"placement,omitempty"` } // CreateSumologic creates a new Fastly sumologic. @@ -159,14 +159,14 @@ type UpdateSumologicInput struct { // Name is the name of the sumologic to update. Name string - NewName string `form:"name,omitempty"` - Address string `form:"address,omitempty"` - URL string `form:"url,omitempty"` - Format string `form:"format,omitempty"` - ResponseCondition string `form:"response_condition,omitempty"` - MessageType string `form:"message_type,omitempty"` - FormatVersion int `form:"format_version,omitempty"` - Placement string `form:"placement,omitempty"` + NewName *string `form:"name,omitempty"` + Address *string `form:"address,omitempty"` + URL *string `form:"url,omitempty"` + Format *string `form:"format,omitempty"` + ResponseCondition *string `form:"response_condition,omitempty"` + MessageType *string `form:"message_type,omitempty"` + FormatVersion *int `form:"format_version,omitempty"` + Placement *string `form:"placement,omitempty"` } // UpdateSumologic updates a specific sumologic. diff --git a/fastly/sumologic_test.go b/fastly/sumologic_test.go index 3e58761b5..5c7b85b75 100644 --- a/fastly/sumologic_test.go +++ b/fastly/sumologic_test.go @@ -17,12 +17,12 @@ func TestClient_Sumologics(t *testing.T) { s, err = c.CreateSumologic(&CreateSumologicInput{ ServiceID: testServiceID, ServiceVersion: tv.Number, - Name: "test-sumologic", - URL: "https://foo.sumologic.com", - Format: "format", - FormatVersion: 1, - MessageType: "classic", - Placement: "waf_debug", + Name: String("test-sumologic"), + URL: String("https://foo.sumologic.com"), + Format: String("format"), + FormatVersion: Int(1), + MessageType: String("classic"), + Placement: String("waf_debug"), }) }) if err != nil { @@ -118,7 +118,7 @@ func TestClient_Sumologics(t *testing.T) { ServiceID: testServiceID, ServiceVersion: tv.Number, Name: "test-sumologic", - NewName: "new-test-sumologic", + NewName: String("new-test-sumologic"), }) }) if err != nil { diff --git a/fastly/syslog.go b/fastly/syslog.go index 36702f41d..481a0b74c 100644 --- a/fastly/syslog.go +++ b/fastly/syslog.go @@ -84,22 +84,22 @@ type CreateSyslogInput struct { // ServiceVersion is the specific configuration version (required). ServiceVersion int - Name string `form:"name,omitempty"` - Address string `form:"address,omitempty"` - Hostname string `form:"hostname,omitempty"` - Port uint `form:"port,omitempty"` + Name *string `form:"name,omitempty"` + Address *string `form:"address,omitempty"` + Hostname *string `form:"hostname,omitempty"` + Port *uint `form:"port,omitempty"` UseTLS *Compatibool `form:"use_tls,omitempty"` - IPV4 string `form:"ipv4,omitempty"` - TLSCACert string `form:"tls_ca_cert,omitempty"` - TLSHostname string `form:"tls_hostname,omitempty"` - TLSClientCert string `form:"tls_client_cert,omitempty"` - TLSClientKey string `form:"tls_client_key,omitempty"` - Token string `form:"token,omitempty"` - Format string `form:"format,omitempty"` - FormatVersion uint `form:"format_version,omitempty"` - MessageType string `form:"message_type,omitempty"` - ResponseCondition string `form:"response_condition,omitempty"` - Placement string `form:"placement,omitempty"` + IPV4 *string `form:"ipv4,omitempty"` + TLSCACert *string `form:"tls_ca_cert,omitempty"` + TLSHostname *string `form:"tls_hostname,omitempty"` + TLSClientCert *string `form:"tls_client_cert,omitempty"` + TLSClientKey *string `form:"tls_client_key,omitempty"` + Token *string `form:"token,omitempty"` + Format *string `form:"format,omitempty"` + FormatVersion *uint `form:"format_version,omitempty"` + MessageType *string `form:"message_type,omitempty"` + ResponseCondition *string `form:"response_condition,omitempty"` + Placement *string `form:"placement,omitempty"` } // CreateSyslog creates a new Fastly syslog. @@ -175,22 +175,22 @@ type UpdateSyslogInput struct { // Name is the name of the syslog to update. Name string - NewName string `form:"name,omitempty"` - Address string `form:"address,omitempty"` - Hostname string `form:"hostname,omitempty"` - Port uint `form:"port,omitempty"` + NewName *string `form:"name,omitempty"` + Address *string `form:"address,omitempty"` + Hostname *string `form:"hostname,omitempty"` + Port *uint `form:"port,omitempty"` UseTLS *Compatibool `form:"use_tls,omitempty"` - IPV4 string `form:"ipv4,omitempty"` - TLSCACert string `form:"tls_ca_cert,omitempty"` - TLSHostname string `form:"tls_hostname,omitempty"` - TLSClientCert string `form:"tls_client_cert,omitempty"` - TLSClientKey string `form:"tls_client_key,omitempty"` - Token string `form:"token,omitempty"` - Format string `form:"format,omitempty"` - FormatVersion uint `form:"format_version,omitempty"` - MessageType string `form:"message_type,omitempty"` - ResponseCondition string `form:"response_condition,omitempty"` - Placement string `form:"placement,omitempty"` + IPV4 *string `form:"ipv4,omitempty"` + TLSCACert *string `form:"tls_ca_cert,omitempty"` + TLSHostname *string `form:"tls_hostname,omitempty"` + TLSClientCert *string `form:"tls_client_cert,omitempty"` + TLSClientKey *string `form:"tls_client_key,omitempty"` + Token *string `form:"token,omitempty"` + Format *string `form:"format,omitempty"` + FormatVersion *uint `form:"format_version,omitempty"` + MessageType *string `form:"message_type,omitempty"` + ResponseCondition *string `form:"response_condition,omitempty"` + Placement *string `form:"placement,omitempty"` } // UpdateSyslog updates a specific syslog. diff --git a/fastly/syslog_test.go b/fastly/syslog_test.go index 3192cac6b..d5226e1aa 100644 --- a/fastly/syslog_test.go +++ b/fastly/syslog_test.go @@ -40,20 +40,20 @@ Wm7DCfrPNGVwFWUQOmsPue9rZBgO s, err = c.CreateSyslog(&CreateSyslogInput{ ServiceID: testServiceID, ServiceVersion: tv.Number, - Name: "test-syslog", - Address: "example.com", - Hostname: "example.com", - Port: 1234, + Name: String("test-syslog"), + Address: String("example.com"), + Hostname: String("example.com"), + Port: Uint(1234), UseTLS: CBool(true), - TLSCACert: caCert, - TLSHostname: "example.com", - TLSClientCert: clientCert, - TLSClientKey: clientKey, - Token: "abcd1234", - Format: "format", - FormatVersion: 2, - MessageType: "classic", - Placement: "waf_debug", + TLSCACert: String(caCert), + TLSHostname: String("example.com"), + TLSClientCert: String(clientCert), + TLSClientKey: String(clientKey), + Token: String("abcd1234"), + Format: String("format"), + FormatVersion: Uint(2), + MessageType: String("classic"), + Placement: String("waf_debug"), }) }) if err != nil { @@ -197,8 +197,8 @@ Wm7DCfrPNGVwFWUQOmsPue9rZBgO ServiceID: testServiceID, ServiceVersion: tv.Number, Name: "test-syslog", - NewName: "new-test-syslog", - FormatVersion: 2, + NewName: String("new-test-syslog"), + FormatVersion: Uint(2), }) }) if err != nil { diff --git a/fastly/tls.go b/fastly/tls.go index 285ee7515..5ca6d2661 100644 --- a/fastly/tls.go +++ b/fastly/tls.go @@ -105,8 +105,8 @@ func (c *Client) GetPrivateKey(i *GetPrivateKeyInput) (*PrivateKey, error) { // CreatePrivateKeyInput is used as input to the CreatePrivateKey function. type CreatePrivateKeyInput struct { - Key string `jsonapi:"attr,key,omitempty"` - Name string `jsonapi:"attr,name,omitempty"` + Key *string `jsonapi:"attr,key,omitempty"` + Name *string `jsonapi:"attr,name,omitempty"` } // CreatePrivateKey create a TLS private key. @@ -114,11 +114,11 @@ func (c *Client) CreatePrivateKey(i *CreatePrivateKeyInput) (*PrivateKey, error) p := "/tls/private_keys" - if i.Key == "" { + if *i.Key == "" { return nil, ErrMissingKey } - if i.Name == "" { + if *i.Name == "" { return nil, ErrMissingName } diff --git a/fastly/tls_test.go b/fastly/tls_test.go index 4e438aff4..846f56202 100644 --- a/fastly/tls_test.go +++ b/fastly/tls_test.go @@ -12,8 +12,8 @@ func TestClient_PrivateKey(t *testing.T) { var pk *PrivateKey record(t, fixtureBase+"create", func(c *Client) { pk, err = c.CreatePrivateKey(&CreatePrivateKeyInput{ - Key: "-----BEGIN PRIVATE KEY-----\n...\n-----END PRIVATE KEY-----\n", - Name: "My private key", + Key: String("-----BEGIN PRIVATE KEY-----\n...\n-----END PRIVATE KEY-----\n"), + Name: String("My private key"), }) }) if err != nil { @@ -98,8 +98,8 @@ func TestClient_CreatePrivateKey_validation(t *testing.T) { var err error record(t, "tls/create", func(c *Client) { _, err = c.CreatePrivateKey(&CreatePrivateKeyInput{ - Key: "-----BEGIN PRIVATE KEY-----\n...\n-----END PRIVATE KEY-----\n", - Name: "My private key", + Key: String("-----BEGIN PRIVATE KEY-----\n...\n-----END PRIVATE KEY-----\n"), + Name: String("My private key"), }) }) if err != nil { diff --git a/fastly/token.go b/fastly/token.go index daa15c68d..53ffe9ffb 100644 --- a/fastly/token.go +++ b/fastly/token.go @@ -107,10 +107,10 @@ func (c *Client) GetTokenSelf() (*Token, error) { // CreateTokenInput is used as input to the Token function. type CreateTokenInput struct { - Name string `form:"name,omitempty"` + Name *string `form:"name,omitempty"` Scope TokenScope `form:"scope,omitempty"` - Username string `form:"username,omitempty"` - Password string `form:"password,omitempty"` + Username *string `form:"username,omitempty"` + Password *string `form:"password,omitempty"` Services []string `form:"services,omitempty"` ExpiresAt *time.Time `form:"expires_at,omitempty"` } diff --git a/fastly/token_test.go b/fastly/token_test.go index 2ce42eba7..3ebbf3b59 100644 --- a/fastly/token_test.go +++ b/fastly/token_test.go @@ -54,10 +54,10 @@ func TestClient_CreateToken(t *testing.T) { t.Parallel() input := &CreateTokenInput{ - Name: "my-test-token", + Name: String("my-test-token"), Scope: "global", - Username: "xxxxxxxxxxxxxxxxxxxx", - Password: "xxxxxxxxxxxxxxxxxxxx", + Username: String("xxxxxxxxxxxxxxxxxxxx"), + Password: String("xxxxxxxxxxxxxxxxxxxx"), } var token *Token @@ -69,8 +69,8 @@ func TestClient_CreateToken(t *testing.T) { t.Fatal(err) } - if token.Name != input.Name { - t.Errorf("returned invalid name, got %s, want %s", token.Name, input.Name) + if token.Name != *input.Name { + t.Errorf("returned invalid name, got %s, want %s", token.Name, *input.Name) } if token.Scope != input.Scope { diff --git a/fastly/user.go b/fastly/user.go index 04ad3f486..7f260b9f7 100644 --- a/fastly/user.go +++ b/fastly/user.go @@ -106,7 +106,7 @@ type CreateUserInput struct { Login string `form:"login"` Name string `form:"name"` - Role string `form:"role,omitempty"` + Role *string `form:"role,omitempty"` } // CreateUser creates a new API token with the given information. @@ -135,8 +135,8 @@ func (c *Client) CreateUser(i *CreateUserInput) (*User, error) { type UpdateUserInput struct { ID string `form:"-"` - Name string `form:"name,omitempty"` - Role string `form:"role,omitempty"` + Name *string `form:"name,omitempty"` + Role *string `form:"role,omitempty"` } // UpdateUser updates the user with the given input. diff --git a/fastly/user_test.go b/fastly/user_test.go index 88f2537f7..165bdd822 100644 --- a/fastly/user_test.go +++ b/fastly/user_test.go @@ -28,7 +28,7 @@ func TestClient_Users(t *testing.T) { u, err = c.CreateUser(&CreateUserInput{ Login: "test+user@example.com", Name: "test user", - Role: "engineer", + Role: String("engineer"), }) }) if err != nil { @@ -89,8 +89,8 @@ func TestClient_Users(t *testing.T) { record(t, fixtureBase+"update", func(c *Client) { uu, err = c.UpdateUser(&UpdateUserInput{ ID: u.ID, - Name: "updated user", - Role: "superuser", + Name: String("updated user"), + Role: String("superuser"), }) }) if err != nil { diff --git a/fastly/vcl.go b/fastly/vcl.go index 7b2b08d50..6c65b35b6 100644 --- a/fastly/vcl.go +++ b/fastly/vcl.go @@ -142,9 +142,9 @@ type CreateVCLInput struct { // ServiceVersion is the specific configuration version (required). ServiceVersion int - Name string `form:"name,omitempty"` - Content string `form:"content,omitempty"` - Main bool `form:"main,omitempty"` + Name *string `form:"name,omitempty"` + Content *string `form:"content,omitempty"` + Main *bool `form:"main,omitempty"` } // CreateVCL creates a new Fastly VCL. @@ -181,8 +181,8 @@ type UpdateVCLInput struct { // Name is the name of the VCL to update (required). Name string - NewName string `form:"name,omitempty"` - Content string `form:"content,omitempty"` + NewName *string `form:"name,omitempty"` + Content *string `form:"content,omitempty"` } // UpdateVCL creates a new Fastly VCL. diff --git a/fastly/vcl_test.go b/fastly/vcl_test.go index 4e8c9c7f0..623d2da54 100644 --- a/fastly/vcl_test.go +++ b/fastly/vcl_test.go @@ -34,8 +34,8 @@ sub vcl_hash { vcl, err = c.CreateVCL(&CreateVCLInput{ ServiceID: testServiceID, ServiceVersion: tv.Number, - Name: "test-vcl", - Content: content, + Name: String("test-vcl"), + Content: String(content), }) }) if err != nil { @@ -107,7 +107,7 @@ sub vcl_hash { ServiceID: testServiceID, ServiceVersion: tv.Number, Name: "test-vcl", - NewName: "new-test-vcl", + NewName: String("new-test-vcl"), }) }) if err != nil { diff --git a/fastly/version.go b/fastly/version.go index c06afb3ba..d313adc29 100644 --- a/fastly/version.go +++ b/fastly/version.go @@ -90,7 +90,7 @@ type CreateVersionInput struct { ServiceID string // A personal freeform descriptive note. - Comment string `form:"comment,omitempty"` + Comment *string `form:"comment,omitempty"` } // CreateVersion constructs a new version. Note that `CloneVersion` is @@ -155,7 +155,7 @@ type UpdateVersionInput struct { ServiceVersion int // A personal freeform descriptive note. - Comment string `form:"comment,omitempty"` + Comment *string `form:"comment,omitempty"` } // UpdateVersion updates the given version diff --git a/fastly/version_test.go b/fastly/version_test.go index 7cb668d22..fbfbd5e46 100644 --- a/fastly/version_test.go +++ b/fastly/version_test.go @@ -18,7 +18,7 @@ func TestClient_Versions(t *testing.T) { record(t, "versions/create", func(c *Client) { v, err = c.CreateVersion(&CreateVersionInput{ ServiceID: testServiceID, - Comment: "test comment", + Comment: String("test comment"), }) }) if err != nil { @@ -72,7 +72,7 @@ func TestClient_Versions(t *testing.T) { uv, err = c.UpdateVersion(&UpdateVersionInput{ ServiceID: testServiceID, ServiceVersion: v.Number, - Comment: "new comment", + Comment: String("new comment"), }) }) if err != nil { diff --git a/fastly/waf.go b/fastly/waf.go index 40b958319..62dfc35e4 100644 --- a/fastly/waf.go +++ b/fastly/waf.go @@ -205,16 +205,16 @@ func (c *Client) GetWAF(i *GetWAFInput) (*WAF, error) { // UpdateWAFInput is used as input to the UpdateWAF function. type UpdateWAFInput struct { - // ServiceID is the ID of the service (required). - ServiceID string `jsonapi:"attr,service_id,omitempty"` + // ServiceID is the ID of the service. + ServiceID *string `jsonapi:"attr,service_id,omitempty"` - // ServiceVersion is the specific configuration version (required). - ServiceVersion int `jsonapi:"attr,service_version_number,omitempty"` + // ServiceVersion is the specific configuration version. + ServiceVersion *int `jsonapi:"attr,service_version_number,omitempty"` - ID string `jsonapi:"primary,waf_firewall"` - PrefetchCondition string `jsonapi:"attr,prefetch_condition,omitempty"` - Response string `jsonapi:"attr,response,omitempty"` - Disabled *bool `jsonapi:"attr,disabled,omitempty"` + ID string `jsonapi:"primary,waf_firewall"` + PrefetchCondition *string `jsonapi:"attr,prefetch_condition,omitempty"` + Response *string `jsonapi:"attr,response,omitempty"` + Disabled *bool `jsonapi:"attr,disabled,omitempty"` } // UpdateWAF updates a specific WAF. @@ -223,18 +223,15 @@ func (c *Client) UpdateWAF(i *UpdateWAFInput) (*WAF, error) { return nil, ErrMissingWAFID } - // 'Service' and 'Version' are mandatory - // if 'Disabled' is not specified. - // - // 'Service' and 'Version' are mandatory - // if 'PrefetchCondition' or 'Response' are - // not empty - if i.Disabled == nil || i.PrefetchCondition != "" || i.Response != "" { - if i.ServiceID == "" { + // 'Service' and 'Version' are mandatory if: + // - 'Disabled' is not specified. + // - 'PrefetchCondition' or 'Response' are NOT empty. + if i.Disabled == nil || i.PrefetchCondition != nil || i.Response != nil { + if i.ServiceID == nil { return nil, ErrMissingServiceID } - if i.ServiceVersion == 0 { + if i.ServiceVersion == nil { return nil, ErrMissingServiceVersion } } diff --git a/fastly/waf_test.go b/fastly/waf_test.go index 349b4f892..d366fa8f0 100644 --- a/fastly/waf_test.go +++ b/fastly/waf_test.go @@ -98,10 +98,10 @@ func TestClient_WAFs(t *testing.T) { var uwaf *WAF record(t, fixtureBase+"/update", func(c *Client) { uwaf, err = c.UpdateWAF(&UpdateWAFInput{ - ServiceID: testService.ID, - ServiceVersion: tv.Number, + ServiceID: &testService.ID, + ServiceVersion: &tv.Number, ID: waf.ID, - Response: nro.Name, + Response: &nro.Name, }) }) if err != nil { @@ -199,26 +199,24 @@ func TestClient_UpdateWAF_validation(t *testing.T) { var err error _, err = testClient.UpdateWAF(&UpdateWAFInput{ - ServiceID: "foo", - ServiceVersion: 1, - ID: "", + ID: "", }) if err != ErrMissingWAFID { t.Errorf("bad error: %s", err) } _, err = testClient.UpdateWAF(&UpdateWAFInput{ - ID: "123", - ServiceID: "", + ID: "123999", }) if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } + serviceID := "foo" + _, err = testClient.UpdateWAF(&UpdateWAFInput{ - ID: "123", - ServiceID: "foo", - ServiceVersion: 0, + ID: "123", + ServiceID: &serviceID, }) if err != ErrMissingServiceVersion { t.Errorf("bad error: %s", err) From 3a232f87f116d517b56da7f8b7be246b763b9e99 Mon Sep 17 00:00:00 2001 From: integralist Date: Mon, 9 Nov 2020 21:23:39 +0000 Subject: [PATCH 27/37] Implement /stats/field API Fixes #214 --- .../stats/service_stats_by_field.yaml | 46 +++++++++++++++++++ fastly/stats.go | 22 +++++++++ fastly/stats_test.go | 17 +++++++ 3 files changed, 85 insertions(+) create mode 100644 fastly/fixtures/stats/service_stats_by_field.yaml diff --git a/fastly/fixtures/stats/service_stats_by_field.yaml b/fastly/fixtures/stats/service_stats_by_field.yaml new file mode 100644 index 000000000..8a6cc3dc5 --- /dev/null +++ b/fastly/fixtures/stats/service_stats_by_field.yaml @@ -0,0 +1,46 @@ +--- +version: 1 +interactions: +- request: + body: "" + form: {} + headers: + User-Agent: + - FastlyGo/1.17.0 (+github.com/fastly/go-fastly; go1.15.2) + url: https://api.fastly.com/stats/field/bandwidth?by=minute&from=1+hour+ago®ion=europe&to=now + method: GET + response: + body: '{"data":{"0LYAcrizS7EHSM5vq7f4Df":[{"service_id":"0LYAcrizS7EHSM5vq7f4Df","start_time":1604952420,"bandwidth":8988},{"service_id":"0LYAcrizS7EHSM5vq7f4Df","start_time":1604953320,"bandwidth":14842},{"service_id":"0LYAcrizS7EHSM5vq7f4Df","start_time":1604953560,"bandwidth":1211}],"0u0Hm9JVjE9EaBIQXU6GLW":[{"service_id":"0u0Hm9JVjE9EaBIQXU6GLW","start_time":1604951820,"bandwidth":779813374},{"service_id":"0u0Hm9JVjE9EaBIQXU6GLW","start_time":1604951880,"bandwidth":780773789},{"service_id":"0u0Hm9JVjE9EaBIQXU6GLW","start_time":1604951940,"bandwidth":780729838},{"service_id":"0u0Hm9JVjE9EaBIQXU6GLW","start_time":1604952000,"bandwidth":785496535},{"service_id":"0u0Hm9JVjE9EaBIQXU6GLW","start_time":1604952060,"bandwidth":781266710},{"service_id":"0u0Hm9JVjE9EaBIQXU6GLW","start_time":1604952120,"bandwidth":778540784},{"service_id":"0u0Hm9JVjE9EaBIQXU6GLW","start_time":1604952180,"bandwidth":777156298},{"service_id":"0u0Hm9JVjE9EaBIQXU6GLW","start_time":1604952240,"bandwidth":775162857},{"service_id":"0u0Hm9JVjE9EaBIQXU6GLW","start_time":1604952300,"bandwidth":775676713},{"service_id":"0u0Hm9JVjE9EaBIQXU6GLW","start_time":1604952360,"bandwidth":776388503},{"service_id":"0u0Hm9JVjE9EaBIQXU6GLW","start_time":1604952420,"bandwidth":773197827},{"service_id":"0u0Hm9JVjE9EaBIQXU6GLW","start_time":1604952480,"bandwidth":773403244},{"service_id":"0u0Hm9JVjE9EaBIQXU6GLW","start_time":1604952540,"bandwidth":774218126},{"service_id":"0u0Hm9JVjE9EaBIQXU6GLW","start_time":1604952600,"bandwidth":778516210},{"service_id":"0u0Hm9JVjE9EaBIQXU6GLW","start_time":1604952660,"bandwidth":778372384},{"service_id":"0u0Hm9JVjE9EaBIQXU6GLW","start_time":1604952720,"bandwidth":775214810},{"service_id":"0u0Hm9JVjE9EaBIQXU6GLW","start_time":1604952780,"bandwidth":772508683},{"service_id":"0u0Hm9JVjE9EaBIQXU6GLW","start_time":1604952840,"bandwidth":774669042},{"service_id":"0u0Hm9JVjE9EaBIQXU6GLW","start_time":1604952900,"bandwidth":775480424},{"service_id":"0u0Hm9JVjE9EaBIQXU6GLW","start_time":1604952960,"bandwidth":771649837},{"service_id":"0u0Hm9JVjE9EaBIQXU6GLW","start_time":1604953020,"bandwidth":770614389},{"service_id":"0u0Hm9JVjE9EaBIQXU6GLW","start_time":1604953080,"bandwidth":768824315},{"service_id":"0u0Hm9JVjE9EaBIQXU6GLW","start_time":1604953140,"bandwidth":768243901},{"service_id":"0u0Hm9JVjE9EaBIQXU6GLW","start_time":1604953200,"bandwidth":768181210},{"service_id":"0u0Hm9JVjE9EaBIQXU6GLW","start_time":1604953260,"bandwidth":767689649},{"service_id":"0u0Hm9JVjE9EaBIQXU6GLW","start_time":1604953320,"bandwidth":766423118},{"service_id":"0u0Hm9JVjE9EaBIQXU6GLW","start_time":1604953380,"bandwidth":765804713},{"service_id":"0u0Hm9JVjE9EaBIQXU6GLW","start_time":1604953440,"bandwidth":764375982},{"service_id":"0u0Hm9JVjE9EaBIQXU6GLW","start_time":1604953500,"bandwidth":764259856},{"service_id":"0u0Hm9JVjE9EaBIQXU6GLW","start_time":1604953560,"bandwidth":764628117},{"service_id":"0u0Hm9JVjE9EaBIQXU6GLW","start_time":1604953620,"bandwidth":764991593},{"service_id":"0u0Hm9JVjE9EaBIQXU6GLW","start_time":1604953680,"bandwidth":763845407},{"service_id":"0u0Hm9JVjE9EaBIQXU6GLW","start_time":1604953740,"bandwidth":761812454},{"service_id":"0u0Hm9JVjE9EaBIQXU6GLW","start_time":1604953800,"bandwidth":766294304},{"service_id":"0u0Hm9JVjE9EaBIQXU6GLW","start_time":1604953860,"bandwidth":759150675},{"service_id":"0u0Hm9JVjE9EaBIQXU6GLW","start_time":1604953920,"bandwidth":757068899},{"service_id":"0u0Hm9JVjE9EaBIQXU6GLW","start_time":1604953980,"bandwidth":755043812},{"service_id":"0u0Hm9JVjE9EaBIQXU6GLW","start_time":1604954040,"bandwidth":755329386},{"service_id":"0u0Hm9JVjE9EaBIQXU6GLW","start_time":1604954100,"bandwidth":755443026},{"service_id":"0u0Hm9JVjE9EaBIQXU6GLW","start_time":1604954160,"bandwidth":752598526},{"service_id":"0u0Hm9JVjE9EaBIQXU6GLW","start_time":1604954220,"bandwidth":750338850},{"service_id":"0u0Hm9JVjE9EaBIQXU6GLW","start_time":1604954280,"bandwidth":751205924},{"service_id":"0u0Hm9JVjE9EaBIQXU6GLW","start_time":1604954340,"bandwidth":750849420},{"service_id":"0u0Hm9JVjE9EaBIQXU6GLW","start_time":1604954400,"bandwidth":751151095},{"service_id":"0u0Hm9JVjE9EaBIQXU6GLW","start_time":1604954460,"bandwidth":751113864},{"service_id":"0u0Hm9JVjE9EaBIQXU6GLW","start_time":1604954520,"bandwidth":750680461},{"service_id":"0u0Hm9JVjE9EaBIQXU6GLW","start_time":1604954580,"bandwidth":749582978},{"service_id":"0u0Hm9JVjE9EaBIQXU6GLW","start_time":1604954640,"bandwidth":748294249},{"service_id":"0u0Hm9JVjE9EaBIQXU6GLW","start_time":1604954700,"bandwidth":750028062},{"service_id":"0u0Hm9JVjE9EaBIQXU6GLW","start_time":1604954760,"bandwidth":751878501},{"service_id":"0u0Hm9JVjE9EaBIQXU6GLW","start_time":1604954820,"bandwidth":745705942},{"service_id":"0u0Hm9JVjE9EaBIQXU6GLW","start_time":1604954880,"bandwidth":745318994},{"service_id":"0u0Hm9JVjE9EaBIQXU6GLW","start_time":1604954940,"bandwidth":746720890},{"service_id":"0u0Hm9JVjE9EaBIQXU6GLW","start_time":1604955000,"bandwidth":746469590},{"service_id":"0u0Hm9JVjE9EaBIQXU6GLW","start_time":1604955060,"bandwidth":743604919},{"service_id":"0u0Hm9JVjE9EaBIQXU6GLW","start_time":1604955120,"bandwidth":743807027},{"service_id":"0u0Hm9JVjE9EaBIQXU6GLW","start_time":1604955180,"bandwidth":741657322},{"service_id":"0u0Hm9JVjE9EaBIQXU6GLW","start_time":1604955240,"bandwidth":742056813},{"service_id":"0u0Hm9JVjE9EaBIQXU6GLW","start_time":1604955300,"bandwidth":741189468}],"1jlmtMz1ncwA0KC3TBGD0X":[{"service_id":"1jlmtMz1ncwA0KC3TBGD0X","start_time":1604951820,"bandwidth":17854524},{"service_id":"1jlmtMz1ncwA0KC3TBGD0X","start_time":1604951880,"bandwidth":14670638},{"service_id":"1jlmtMz1ncwA0KC3TBGD0X","start_time":1604951940,"bandwidth":17204935},{"service_id":"1jlmtMz1ncwA0KC3TBGD0X","start_time":1604952000,"bandwidth":35703091},{"service_id":"1jlmtMz1ncwA0KC3TBGD0X","start_time":1604952060,"bandwidth":20500296},{"service_id":"1jlmtMz1ncwA0KC3TBGD0X","start_time":1604952120,"bandwidth":22589686},{"service_id":"1jlmtMz1ncwA0KC3TBGD0X","start_time":1604952180,"bandwidth":19729205},{"service_id":"1jlmtMz1ncwA0KC3TBGD0X","start_time":1604952240,"bandwidth":18002055},{"service_id":"1jlmtMz1ncwA0KC3TBGD0X","start_time":1604952300,"bandwidth":19592248},{"service_id":"1jlmtMz1ncwA0KC3TBGD0X","start_time":1604952360,"bandwidth":17885975},{"service_id":"1jlmtMz1ncwA0KC3TBGD0X","start_time":1604952420,"bandwidth":18874125},{"service_id":"1jlmtMz1ncwA0KC3TBGD0X","start_time":1604952480,"bandwidth":16378112},{"service_id":"1jlmtMz1ncwA0KC3TBGD0X","start_time":1604952540,"bandwidth":18681209},{"service_id":"1jlmtMz1ncwA0KC3TBGD0X","start_time":1604952600,"bandwidth":19010982},{"service_id":"1jlmtMz1ncwA0KC3TBGD0X","start_time":1604952660,"bandwidth":20876712},{"service_id":"1jlmtMz1ncwA0KC3TBGD0X","start_time":1604952720,"bandwidth":21911302},{"service_id":"1jlmtMz1ncwA0KC3TBGD0X","start_time":1604952780,"bandwidth":16831537},{"service_id":"1jlmtMz1ncwA0KC3TBGD0X","start_time":1604952840,"bandwidth":17620304},{"service_id":"1jlmtMz1ncwA0KC3TBGD0X","start_time":1604952900,"bandwidth":36862810},{"service_id":"1jlmtMz1ncwA0KC3TBGD0X","start_time":1604952960,"bandwidth":17683775},{"service_id":"1jlmtMz1ncwA0KC3TBGD0X","start_time":1604953020,"bandwidth":19205923},{"service_id":"1jlmtMz1ncwA0KC3TBGD0X","start_time":1604953080,"bandwidth":21504709},{"service_id":"1jlmtMz1ncwA0KC3TBGD0X","start_time":1604953140,"bandwidth":18088099},{"service_id":"1jlmtMz1ncwA0KC3TBGD0X","start_time":1604953200,"bandwidth":17741019},{"service_id":"1jlmtMz1ncwA0KC3TBGD0X","start_time":1604953260,"bandwidth":18216254},{"service_id":"1jlmtMz1ncwA0KC3TBGD0X","start_time":1604953320,"bandwidth":23217873},{"service_id":"1jlmtMz1ncwA0KC3TBGD0X","start_time":1604953380,"bandwidth":19074164},{"service_id":"1jlmtMz1ncwA0KC3TBGD0X","start_time":1604953440,"bandwidth":18165200},{"service_id":"1jlmtMz1ncwA0KC3TBGD0X","start_time":1604953500,"bandwidth":19801256},{"service_id":"1jlmtMz1ncwA0KC3TBGD0X","start_time":1604953560,"bandwidth":20053933},{"service_id":"1jlmtMz1ncwA0KC3TBGD0X","start_time":1604953620,"bandwidth":24841616},{"service_id":"1jlmtMz1ncwA0KC3TBGD0X","start_time":1604953680,"bandwidth":15296222},{"service_id":"1jlmtMz1ncwA0KC3TBGD0X","start_time":1604953740,"bandwidth":18343946},{"service_id":"1jlmtMz1ncwA0KC3TBGD0X","start_time":1604953800,"bandwidth":38922620},{"service_id":"1jlmtMz1ncwA0KC3TBGD0X","start_time":1604953860,"bandwidth":21019881},{"service_id":"1jlmtMz1ncwA0KC3TBGD0X","start_time":1604953920,"bandwidth":24525338},{"service_id":"1jlmtMz1ncwA0KC3TBGD0X","start_time":1604953980,"bandwidth":20856582},{"service_id":"1jlmtMz1ncwA0KC3TBGD0X","start_time":1604954040,"bandwidth":18251720},{"service_id":"1jlmtMz1ncwA0KC3TBGD0X","start_time":1604954100,"bandwidth":25248635},{"service_id":"1jlmtMz1ncwA0KC3TBGD0X","start_time":1604954160,"bandwidth":17528578},{"service_id":"1jlmtMz1ncwA0KC3TBGD0X","start_time":1604954220,"bandwidth":18938707},{"service_id":"1jlmtMz1ncwA0KC3TBGD0X","start_time":1604954280,"bandwidth":16113145},{"service_id":"1jlmtMz1ncwA0KC3TBGD0X","start_time":1604954340,"bandwidth":18509258},{"service_id":"1jlmtMz1ncwA0KC3TBGD0X","start_time":1604954400,"bandwidth":18318763},{"service_id":"1jlmtMz1ncwA0KC3TBGD0X","start_time":1604954460,"bandwidth":19807754},{"service_id":"1jlmtMz1ncwA0KC3TBGD0X","start_time":1604954520,"bandwidth":23942130},{"service_id":"1jlmtMz1ncwA0KC3TBGD0X","start_time":1604954580,"bandwidth":16855271},{"service_id":"1jlmtMz1ncwA0KC3TBGD0X","start_time":1604954640,"bandwidth":17681832},{"service_id":"1jlmtMz1ncwA0KC3TBGD0X","start_time":1604954700,"bandwidth":39217165},{"service_id":"1jlmtMz1ncwA0KC3TBGD0X","start_time":1604954760,"bandwidth":21294001},{"service_id":"1jlmtMz1ncwA0KC3TBGD0X","start_time":1604954820,"bandwidth":22785613},{"service_id":"1jlmtMz1ncwA0KC3TBGD0X","start_time":1604954880,"bandwidth":19136380},{"service_id":"1jlmtMz1ncwA0KC3TBGD0X","start_time":1604954940,"bandwidth":19565761},{"service_id":"1jlmtMz1ncwA0KC3TBGD0X","start_time":1604955000,"bandwidth":21584356},{"service_id":"1jlmtMz1ncwA0KC3TBGD0X","start_time":1604955060,"bandwidth":20475404},{"service_id":"1jlmtMz1ncwA0KC3TBGD0X","start_time":1604955120,"bandwidth":22347412},{"service_id":"1jlmtMz1ncwA0KC3TBGD0X","start_time":1604955180,"bandwidth":17829795},{"service_id":"1jlmtMz1ncwA0KC3TBGD0X","start_time":1604955240,"bandwidth":16199900},{"service_id":"1jlmtMz1ncwA0KC3TBGD0X","start_time":1604955300,"bandwidth":19105359}],"1o0FBeoYCKh2dWADipvTNu":[{"service_id":"1o0FBeoYCKh2dWADipvTNu","start_time":1604951940,"bandwidth":1758},{"service_id":"1o0FBeoYCKh2dWADipvTNu","start_time":1604952000,"bandwidth":2929},{"service_id":"1o0FBeoYCKh2dWADipvTNu","start_time":1604952060,"bandwidth":1758},{"service_id":"1o0FBeoYCKh2dWADipvTNu","start_time":1604952240,"bandwidth":7325},{"service_id":"1o0FBeoYCKh2dWADipvTNu","start_time":1604952300,"bandwidth":879},{"service_id":"1o0FBeoYCKh2dWADipvTNu","start_time":1604952420,"bandwidth":879},{"service_id":"1o0FBeoYCKh2dWADipvTNu","start_time":1604952480,"bandwidth":879},{"service_id":"1o0FBeoYCKh2dWADipvTNu","start_time":1604952540,"bandwidth":876},{"service_id":"1o0FBeoYCKh2dWADipvTNu","start_time":1604952600,"bandwidth":1758},{"service_id":"1o0FBeoYCKh2dWADipvTNu","start_time":1604952660,"bandwidth":3516},{"service_id":"1o0FBeoYCKh2dWADipvTNu","start_time":1604952780,"bandwidth":879},{"service_id":"1o0FBeoYCKh2dWADipvTNu","start_time":1604952840,"bandwidth":293},{"service_id":"1o0FBeoYCKh2dWADipvTNu","start_time":1604952960,"bandwidth":879},{"service_id":"1o0FBeoYCKh2dWADipvTNu","start_time":1604953080,"bandwidth":585},{"service_id":"1o0FBeoYCKh2dWADipvTNu","start_time":1604953200,"bandwidth":2331},{"service_id":"1o0FBeoYCKh2dWADipvTNu","start_time":1604953260,"bandwidth":1758},{"service_id":"1o0FBeoYCKh2dWADipvTNu","start_time":1604953380,"bandwidth":7325},{"service_id":"1o0FBeoYCKh2dWADipvTNu","start_time":1604953500,"bandwidth":1924},{"service_id":"1o0FBeoYCKh2dWADipvTNu","start_time":1604953680,"bandwidth":1452},{"service_id":"1o0FBeoYCKh2dWADipvTNu","start_time":1604953800,"bandwidth":1443},{"service_id":"1o0FBeoYCKh2dWADipvTNu","start_time":1604954040,"bandwidth":1936},{"service_id":"1o0FBeoYCKh2dWADipvTNu","start_time":1604954100,"bandwidth":1452},{"service_id":"1o0FBeoYCKh2dWADipvTNu","start_time":1604954400,"bandwidth":585},{"service_id":"1o0FBeoYCKh2dWADipvTNu","start_time":1604954580,"bandwidth":879},{"service_id":"1o0FBeoYCKh2dWADipvTNu","start_time":1604954760,"bandwidth":1452},{"service_id":"1o0FBeoYCKh2dWADipvTNu","start_time":1604954820,"bandwidth":2344},{"service_id":"1o0FBeoYCKh2dWADipvTNu","start_time":1604954880,"bandwidth":1752},{"service_id":"1o0FBeoYCKh2dWADipvTNu","start_time":1604954940,"bandwidth":293},{"service_id":"1o0FBeoYCKh2dWADipvTNu","start_time":1604955000,"bandwidth":1172},{"service_id":"1o0FBeoYCKh2dWADipvTNu","start_time":1604955060,"bandwidth":879},{"service_id":"1o0FBeoYCKh2dWADipvTNu","start_time":1604955120,"bandwidth":879},{"service_id":"1o0FBeoYCKh2dWADipvTNu","start_time":1604955180,"bandwidth":1172},{"service_id":"1o0FBeoYCKh2dWADipvTNu","start_time":1604955240,"bandwidth":879}],"2NrLCWkZ5TWySajbrhJsok":[{"service_id":"2NrLCWkZ5TWySajbrhJsok","start_time":1604952000,"bandwidth":1454}],"2y905BGJWKaA7xBqmdis1J":[{"service_id":"2y905BGJWKaA7xBqmdis1J","start_time":1604951820,"bandwidth":534194234},{"service_id":"2y905BGJWKaA7xBqmdis1J","start_time":1604951880,"bandwidth":524496176},{"service_id":"2y905BGJWKaA7xBqmdis1J","start_time":1604951940,"bandwidth":456355083},{"service_id":"2y905BGJWKaA7xBqmdis1J","start_time":1604952000,"bandwidth":439249139},{"service_id":"2y905BGJWKaA7xBqmdis1J","start_time":1604952060,"bandwidth":395416466},{"service_id":"2y905BGJWKaA7xBqmdis1J","start_time":1604952120,"bandwidth":385584132},{"service_id":"2y905BGJWKaA7xBqmdis1J","start_time":1604952180,"bandwidth":476303711},{"service_id":"2y905BGJWKaA7xBqmdis1J","start_time":1604952240,"bandwidth":588986957},{"service_id":"2y905BGJWKaA7xBqmdis1J","start_time":1604952300,"bandwidth":616700152},{"service_id":"2y905BGJWKaA7xBqmdis1J","start_time":1604952360,"bandwidth":573199647},{"service_id":"2y905BGJWKaA7xBqmdis1J","start_time":1604952420,"bandwidth":573529610},{"service_id":"2y905BGJWKaA7xBqmdis1J","start_time":1604952480,"bandwidth":373966356},{"service_id":"2y905BGJWKaA7xBqmdis1J","start_time":1604952540,"bandwidth":378756179},{"service_id":"2y905BGJWKaA7xBqmdis1J","start_time":1604952600,"bandwidth":334163069},{"service_id":"2y905BGJWKaA7xBqmdis1J","start_time":1604952660,"bandwidth":392503362},{"service_id":"2y905BGJWKaA7xBqmdis1J","start_time":1604952720,"bandwidth":462953239},{"service_id":"2y905BGJWKaA7xBqmdis1J","start_time":1604952780,"bandwidth":577836066},{"service_id":"2y905BGJWKaA7xBqmdis1J","start_time":1604952840,"bandwidth":556911398},{"service_id":"2y905BGJWKaA7xBqmdis1J","start_time":1604952900,"bandwidth":556960344},{"service_id":"2y905BGJWKaA7xBqmdis1J","start_time":1604952960,"bandwidth":540146340},{"service_id":"2y905BGJWKaA7xBqmdis1J","start_time":1604953020,"bandwidth":334336964},{"service_id":"2y905BGJWKaA7xBqmdis1J","start_time":1604953080,"bandwidth":334563171},{"service_id":"2y905BGJWKaA7xBqmdis1J","start_time":1604953140,"bandwidth":419593388},{"service_id":"2y905BGJWKaA7xBqmdis1J","start_time":1604953200,"bandwidth":392001611},{"service_id":"2y905BGJWKaA7xBqmdis1J","start_time":1604953260,"bandwidth":515884046},{"service_id":"2y905BGJWKaA7xBqmdis1J","start_time":1604953320,"bandwidth":626725447},{"service_id":"2y905BGJWKaA7xBqmdis1J","start_time":1604953380,"bandwidth":638056365},{"service_id":"2y905BGJWKaA7xBqmdis1J","start_time":1604953440,"bandwidth":622201781},{"service_id":"2y905BGJWKaA7xBqmdis1J","start_time":1604953500,"bandwidth":577719201},{"service_id":"2y905BGJWKaA7xBqmdis1J","start_time":1604953560,"bandwidth":522490314},{"service_id":"2y905BGJWKaA7xBqmdis1J","start_time":1604953620,"bandwidth":368637789},{"service_id":"2y905BGJWKaA7xBqmdis1J","start_time":1604953680,"bandwidth":348570770},{"service_id":"2y905BGJWKaA7xBqmdis1J","start_time":1604953740,"bandwidth":322883553},{"service_id":"2y905BGJWKaA7xBqmdis1J","start_time":1604953800,"bandwidth":410694643},{"service_id":"2y905BGJWKaA7xBqmdis1J","start_time":1604953860,"bandwidth":507942864},{"service_id":"2y905BGJWKaA7xBqmdis1J","start_time":1604953920,"bandwidth":600005345},{"service_id":"2y905BGJWKaA7xBqmdis1J","start_time":1604953980,"bandwidth":491212453},{"service_id":"2y905BGJWKaA7xBqmdis1J","start_time":1604954040,"bandwidth":521908510},{"service_id":"2y905BGJWKaA7xBqmdis1J","start_time":1604954100,"bandwidth":379065540},{"service_id":"2y905BGJWKaA7xBqmdis1J","start_time":1604954160,"bandwidth":367879214},{"service_id":"2y905BGJWKaA7xBqmdis1J","start_time":1604954220,"bandwidth":315334115},{"service_id":"2y905BGJWKaA7xBqmdis1J","start_time":1604954280,"bandwidth":400987133},{"service_id":"2y905BGJWKaA7xBqmdis1J","start_time":1604954340,"bandwidth":514410147},{"service_id":"2y905BGJWKaA7xBqmdis1J","start_time":1604954400,"bandwidth":641507604},{"service_id":"2y905BGJWKaA7xBqmdis1J","start_time":1604954460,"bandwidth":577956899},{"service_id":"2y905BGJWKaA7xBqmdis1J","start_time":1604954520,"bandwidth":432627137},{"service_id":"2y905BGJWKaA7xBqmdis1J","start_time":1604954580,"bandwidth":421067348},{"service_id":"2y905BGJWKaA7xBqmdis1J","start_time":1604954640,"bandwidth":350153091},{"service_id":"2y905BGJWKaA7xBqmdis1J","start_time":1604954700,"bandwidth":377154469},{"service_id":"2y905BGJWKaA7xBqmdis1J","start_time":1604954760,"bandwidth":402181720},{"service_id":"2y905BGJWKaA7xBqmdis1J","start_time":1604954820,"bandwidth":434188681},{"service_id":"2y905BGJWKaA7xBqmdis1J","start_time":1604954880,"bandwidth":367694235},{"service_id":"2y905BGJWKaA7xBqmdis1J","start_time":1604954940,"bandwidth":454099915},{"service_id":"2y905BGJWKaA7xBqmdis1J","start_time":1604955000,"bandwidth":386944591},{"service_id":"2y905BGJWKaA7xBqmdis1J","start_time":1604955060,"bandwidth":314781782},{"service_id":"2y905BGJWKaA7xBqmdis1J","start_time":1604955120,"bandwidth":344859635},{"service_id":"2y905BGJWKaA7xBqmdis1J","start_time":1604955180,"bandwidth":433360332},{"service_id":"2y905BGJWKaA7xBqmdis1J","start_time":1604955240,"bandwidth":488103862},{"service_id":"2y905BGJWKaA7xBqmdis1J","start_time":1604955300,"bandwidth":558588854}],"3EQ6yFohMypsVUndAwHpb3":[{"service_id":"3EQ6yFohMypsVUndAwHpb3","start_time":1604951820,"bandwidth":4915},{"service_id":"3EQ6yFohMypsVUndAwHpb3","start_time":1604951880,"bandwidth":366367},{"service_id":"3EQ6yFohMypsVUndAwHpb3","start_time":1604951940,"bandwidth":1475},{"service_id":"3EQ6yFohMypsVUndAwHpb3","start_time":1604952300,"bandwidth":158836},{"service_id":"3EQ6yFohMypsVUndAwHpb3","start_time":1604952420,"bandwidth":423147},{"service_id":"3EQ6yFohMypsVUndAwHpb3","start_time":1604952480,"bandwidth":527012},{"service_id":"3EQ6yFohMypsVUndAwHpb3","start_time":1604952600,"bandwidth":37614},{"service_id":"3EQ6yFohMypsVUndAwHpb3","start_time":1604952660,"bandwidth":403262},{"service_id":"3EQ6yFohMypsVUndAwHpb3","start_time":1604952900,"bandwidth":334716},{"service_id":"3EQ6yFohMypsVUndAwHpb3","start_time":1604952960,"bandwidth":1476},{"service_id":"3EQ6yFohMypsVUndAwHpb3","start_time":1604953020,"bandwidth":8054},{"service_id":"3EQ6yFohMypsVUndAwHpb3","start_time":1604953140,"bandwidth":282431},{"service_id":"3EQ6yFohMypsVUndAwHpb3","start_time":1604953260,"bandwidth":31506},{"service_id":"3EQ6yFohMypsVUndAwHpb3","start_time":1604953380,"bandwidth":444665},{"service_id":"3EQ6yFohMypsVUndAwHpb3","start_time":1604953440,"bandwidth":16085},{"service_id":"3EQ6yFohMypsVUndAwHpb3","start_time":1604953620,"bandwidth":240972},{"service_id":"3EQ6yFohMypsVUndAwHpb3","start_time":1604953740,"bandwidth":12797},{"service_id":"3EQ6yFohMypsVUndAwHpb3","start_time":1604953920,"bandwidth":1476},{"service_id":"3EQ6yFohMypsVUndAwHpb3","start_time":1604953980,"bandwidth":15153},{"service_id":"3EQ6yFohMypsVUndAwHpb3","start_time":1604954040,"bandwidth":496608},{"service_id":"3EQ6yFohMypsVUndAwHpb3","start_time":1604954220,"bandwidth":338076},{"service_id":"3EQ6yFohMypsVUndAwHpb3","start_time":1604954880,"bandwidth":1476},{"service_id":"3EQ6yFohMypsVUndAwHpb3","start_time":1604955060,"bandwidth":15625},{"service_id":"3EQ6yFohMypsVUndAwHpb3","start_time":1604955120,"bandwidth":24926},{"service_id":"3EQ6yFohMypsVUndAwHpb3","start_time":1604955180,"bandwidth":425697},{"service_id":"3EQ6yFohMypsVUndAwHpb3","start_time":1604955240,"bandwidth":397278}],"3KvJ5pgf8WtxKcn9aqBzWi":[{"service_id":"3KvJ5pgf8WtxKcn9aqBzWi","start_time":1604951880,"bandwidth":3394598},{"service_id":"3KvJ5pgf8WtxKcn9aqBzWi","start_time":1604951940,"bandwidth":699449},{"service_id":"3KvJ5pgf8WtxKcn9aqBzWi","start_time":1604952000,"bandwidth":11728},{"service_id":"3KvJ5pgf8WtxKcn9aqBzWi","start_time":1604952060,"bandwidth":11031},{"service_id":"3KvJ5pgf8WtxKcn9aqBzWi","start_time":1604952120,"bandwidth":11026},{"service_id":"3KvJ5pgf8WtxKcn9aqBzWi","start_time":1604952180,"bandwidth":5353452},{"service_id":"3KvJ5pgf8WtxKcn9aqBzWi","start_time":1604952240,"bandwidth":11029},{"service_id":"3KvJ5pgf8WtxKcn9aqBzWi","start_time":1604952300,"bandwidth":57805},{"service_id":"3KvJ5pgf8WtxKcn9aqBzWi","start_time":1604952360,"bandwidth":369641},{"service_id":"3KvJ5pgf8WtxKcn9aqBzWi","start_time":1604952420,"bandwidth":3890},{"service_id":"3KvJ5pgf8WtxKcn9aqBzWi","start_time":1604952480,"bandwidth":57901},{"service_id":"3KvJ5pgf8WtxKcn9aqBzWi","start_time":1604952540,"bandwidth":35178},{"service_id":"3KvJ5pgf8WtxKcn9aqBzWi","start_time":1604952600,"bandwidth":11689},{"service_id":"3KvJ5pgf8WtxKcn9aqBzWi","start_time":1604952660,"bandwidth":11033},{"service_id":"3KvJ5pgf8WtxKcn9aqBzWi","start_time":1604952720,"bandwidth":46209},{"service_id":"3KvJ5pgf8WtxKcn9aqBzWi","start_time":1604952780,"bandwidth":11691},{"service_id":"3KvJ5pgf8WtxKcn9aqBzWi","start_time":1604952840,"bandwidth":4396606},{"service_id":"3KvJ5pgf8WtxKcn9aqBzWi","start_time":1604952900,"bandwidth":11033},{"service_id":"3KvJ5pgf8WtxKcn9aqBzWi","start_time":1604952960,"bandwidth":74516},{"service_id":"3KvJ5pgf8WtxKcn9aqBzWi","start_time":1604953020,"bandwidth":2459},{"service_id":"3KvJ5pgf8WtxKcn9aqBzWi","start_time":1604953080,"bandwidth":22718},{"service_id":"3KvJ5pgf8WtxKcn9aqBzWi","start_time":1604953200,"bandwidth":11727},{"service_id":"3KvJ5pgf8WtxKcn9aqBzWi","start_time":1604953260,"bandwidth":35233},{"service_id":"3KvJ5pgf8WtxKcn9aqBzWi","start_time":1604953320,"bandwidth":437436},{"service_id":"3KvJ5pgf8WtxKcn9aqBzWi","start_time":1604953380,"bandwidth":11687},{"service_id":"3KvJ5pgf8WtxKcn9aqBzWi","start_time":1604953440,"bandwidth":11029},{"service_id":"3KvJ5pgf8WtxKcn9aqBzWi","start_time":1604953500,"bandwidth":22754},{"service_id":"3KvJ5pgf8WtxKcn9aqBzWi","start_time":1604953560,"bandwidth":27656},{"service_id":"3KvJ5pgf8WtxKcn9aqBzWi","start_time":1604953680,"bandwidth":22716},{"service_id":"3KvJ5pgf8WtxKcn9aqBzWi","start_time":1604953740,"bandwidth":60604},{"service_id":"3KvJ5pgf8WtxKcn9aqBzWi","start_time":1604953800,"bandwidth":11722},{"service_id":"3KvJ5pgf8WtxKcn9aqBzWi","start_time":1604953860,"bandwidth":35905},{"service_id":"3KvJ5pgf8WtxKcn9aqBzWi","start_time":1604953920,"bandwidth":48210},{"service_id":"3KvJ5pgf8WtxKcn9aqBzWi","start_time":1604953980,"bandwidth":11692},{"service_id":"3KvJ5pgf8WtxKcn9aqBzWi","start_time":1604954040,"bandwidth":11029},{"service_id":"3KvJ5pgf8WtxKcn9aqBzWi","start_time":1604954100,"bandwidth":22758},{"service_id":"3KvJ5pgf8WtxKcn9aqBzWi","start_time":1604954160,"bandwidth":1111597},{"service_id":"3KvJ5pgf8WtxKcn9aqBzWi","start_time":1604954280,"bandwidth":22756},{"service_id":"3KvJ5pgf8WtxKcn9aqBzWi","start_time":1604954400,"bandwidth":11691},{"service_id":"3KvJ5pgf8WtxKcn9aqBzWi","start_time":1604954460,"bandwidth":33799},{"service_id":"3KvJ5pgf8WtxKcn9aqBzWi","start_time":1604954520,"bandwidth":11027},{"service_id":"3KvJ5pgf8WtxKcn9aqBzWi","start_time":1604954580,"bandwidth":1416132},{"service_id":"3KvJ5pgf8WtxKcn9aqBzWi","start_time":1604954640,"bandwidth":11033},{"service_id":"3KvJ5pgf8WtxKcn9aqBzWi","start_time":1604954700,"bandwidth":27743},{"service_id":"3KvJ5pgf8WtxKcn9aqBzWi","start_time":1604954760,"bandwidth":27648},{"service_id":"3KvJ5pgf8WtxKcn9aqBzWi","start_time":1604954880,"bandwidth":380955},{"service_id":"3KvJ5pgf8WtxKcn9aqBzWi","start_time":1604954940,"bandwidth":2575},{"service_id":"3KvJ5pgf8WtxKcn9aqBzWi","start_time":1604955000,"bandwidth":46777},{"service_id":"3KvJ5pgf8WtxKcn9aqBzWi","start_time":1604955060,"bandwidth":11026},{"service_id":"3KvJ5pgf8WtxKcn9aqBzWi","start_time":1604955120,"bandwidth":11026},{"service_id":"3KvJ5pgf8WtxKcn9aqBzWi","start_time":1604955180,"bandwidth":526181},{"service_id":"3KvJ5pgf8WtxKcn9aqBzWi","start_time":1604955240,"bandwidth":1228562},{"service_id":"3KvJ5pgf8WtxKcn9aqBzWi","start_time":1604955300,"bandwidth":22757}],"3U3TD3PPul0gI5QXQNWHhw":[{"service_id":"3U3TD3PPul0gI5QXQNWHhw","start_time":1604951820,"bandwidth":1324481503},{"service_id":"3U3TD3PPul0gI5QXQNWHhw","start_time":1604951880,"bandwidth":1293559049},{"service_id":"3U3TD3PPul0gI5QXQNWHhw","start_time":1604951940,"bandwidth":1305682655},{"service_id":"3U3TD3PPul0gI5QXQNWHhw","start_time":1604952000,"bandwidth":1295820162},{"service_id":"3U3TD3PPul0gI5QXQNWHhw","start_time":1604952060,"bandwidth":1327913358},{"service_id":"3U3TD3PPul0gI5QXQNWHhw","start_time":1604952120,"bandwidth":1315034420},{"service_id":"3U3TD3PPul0gI5QXQNWHhw","start_time":1604952180,"bandwidth":1309938178},{"service_id":"3U3TD3PPul0gI5QXQNWHhw","start_time":1604952240,"bandwidth":1285880484},{"service_id":"3U3TD3PPul0gI5QXQNWHhw","start_time":1604952300,"bandwidth":1297899420},{"service_id":"3U3TD3PPul0gI5QXQNWHhw","start_time":1604952360,"bandwidth":1280638938},{"service_id":"3U3TD3PPul0gI5QXQNWHhw","start_time":1604952420,"bandwidth":1304075581},{"service_id":"3U3TD3PPul0gI5QXQNWHhw","start_time":1604952480,"bandwidth":1284692328},{"service_id":"3U3TD3PPul0gI5QXQNWHhw","start_time":1604952540,"bandwidth":1276300981},{"service_id":"3U3TD3PPul0gI5QXQNWHhw","start_time":1604952600,"bandwidth":1280137366},{"service_id":"3U3TD3PPul0gI5QXQNWHhw","start_time":1604952660,"bandwidth":1279058909},{"service_id":"3U3TD3PPul0gI5QXQNWHhw","start_time":1604952720,"bandwidth":1270374471},{"service_id":"3U3TD3PPul0gI5QXQNWHhw","start_time":1604952780,"bandwidth":1277944293},{"service_id":"3U3TD3PPul0gI5QXQNWHhw","start_time":1604952840,"bandwidth":1286703219},{"service_id":"3U3TD3PPul0gI5QXQNWHhw","start_time":1604952900,"bandwidth":1292771075},{"service_id":"3U3TD3PPul0gI5QXQNWHhw","start_time":1604952960,"bandwidth":1283461934},{"service_id":"3U3TD3PPul0gI5QXQNWHhw","start_time":1604953020,"bandwidth":1268615562},{"service_id":"3U3TD3PPul0gI5QXQNWHhw","start_time":1604953080,"bandwidth":1290880902},{"service_id":"3U3TD3PPul0gI5QXQNWHhw","start_time":1604953140,"bandwidth":1253283483},{"service_id":"3U3TD3PPul0gI5QXQNWHhw","start_time":1604953200,"bandwidth":1266696156},{"service_id":"3U3TD3PPul0gI5QXQNWHhw","start_time":1604953260,"bandwidth":1274193708},{"service_id":"3U3TD3PPul0gI5QXQNWHhw","start_time":1604953320,"bandwidth":1271810423},{"service_id":"3U3TD3PPul0gI5QXQNWHhw","start_time":1604953380,"bandwidth":1275198934},{"service_id":"3U3TD3PPul0gI5QXQNWHhw","start_time":1604953440,"bandwidth":1278909084},{"service_id":"3U3TD3PPul0gI5QXQNWHhw","start_time":1604953500,"bandwidth":1257642491},{"service_id":"3U3TD3PPul0gI5QXQNWHhw","start_time":1604953560,"bandwidth":1283621628},{"service_id":"3U3TD3PPul0gI5QXQNWHhw","start_time":1604953620,"bandwidth":1257635552},{"service_id":"3U3TD3PPul0gI5QXQNWHhw","start_time":1604953680,"bandwidth":1275949432},{"service_id":"3U3TD3PPul0gI5QXQNWHhw","start_time":1604953740,"bandwidth":1274838864},{"service_id":"3U3TD3PPul0gI5QXQNWHhw","start_time":1604953800,"bandwidth":1255621266},{"service_id":"3U3TD3PPul0gI5QXQNWHhw","start_time":1604953860,"bandwidth":1266699894},{"service_id":"3U3TD3PPul0gI5QXQNWHhw","start_time":1604953920,"bandwidth":1238443960},{"service_id":"3U3TD3PPul0gI5QXQNWHhw","start_time":1604953980,"bandwidth":1247395659},{"service_id":"3U3TD3PPul0gI5QXQNWHhw","start_time":1604954040,"bandwidth":1262139721},{"service_id":"3U3TD3PPul0gI5QXQNWHhw","start_time":1604954100,"bandwidth":1239341570},{"service_id":"3U3TD3PPul0gI5QXQNWHhw","start_time":1604954160,"bandwidth":1271017107},{"service_id":"3U3TD3PPul0gI5QXQNWHhw","start_time":1604954220,"bandwidth":1249164219},{"service_id":"3U3TD3PPul0gI5QXQNWHhw","start_time":1604954280,"bandwidth":1250245872},{"service_id":"3U3TD3PPul0gI5QXQNWHhw","start_time":1604954340,"bandwidth":1253629277},{"service_id":"3U3TD3PPul0gI5QXQNWHhw","start_time":1604954400,"bandwidth":1261717673},{"service_id":"3U3TD3PPul0gI5QXQNWHhw","start_time":1604954460,"bandwidth":1266796739},{"service_id":"3U3TD3PPul0gI5QXQNWHhw","start_time":1604954520,"bandwidth":1254279535},{"service_id":"3U3TD3PPul0gI5QXQNWHhw","start_time":1604954580,"bandwidth":1228386333},{"service_id":"3U3TD3PPul0gI5QXQNWHhw","start_time":1604954640,"bandwidth":1258756745},{"service_id":"3U3TD3PPul0gI5QXQNWHhw","start_time":1604954700,"bandwidth":1255960848},{"service_id":"3U3TD3PPul0gI5QXQNWHhw","start_time":1604954760,"bandwidth":1249655186},{"service_id":"3U3TD3PPul0gI5QXQNWHhw","start_time":1604954820,"bandwidth":1236466615},{"service_id":"3U3TD3PPul0gI5QXQNWHhw","start_time":1604954880,"bandwidth":1252555372},{"service_id":"3U3TD3PPul0gI5QXQNWHhw","start_time":1604954940,"bandwidth":1249005797},{"service_id":"3U3TD3PPul0gI5QXQNWHhw","start_time":1604955000,"bandwidth":1255927424},{"service_id":"3U3TD3PPul0gI5QXQNWHhw","start_time":1604955060,"bandwidth":1255778459},{"service_id":"3U3TD3PPul0gI5QXQNWHhw","start_time":1604955120,"bandwidth":1238213457},{"service_id":"3U3TD3PPul0gI5QXQNWHhw","start_time":1604955180,"bandwidth":1233226128},{"service_id":"3U3TD3PPul0gI5QXQNWHhw","start_time":1604955240,"bandwidth":1219034742},{"service_id":"3U3TD3PPul0gI5QXQNWHhw","start_time":1604955300,"bandwidth":1221600718}],"3WYFWVWOeUE2EL5fvgDveQ":[{"service_id":"3WYFWVWOeUE2EL5fvgDveQ","start_time":1604954580,"bandwidth":1278}],"3iaImYs8FyO6a8aG1hE72O":[{"service_id":"3iaImYs8FyO6a8aG1hE72O","start_time":1604952060,"bandwidth":2529},{"service_id":"3iaImYs8FyO6a8aG1hE72O","start_time":1604952120,"bandwidth":281},{"service_id":"3iaImYs8FyO6a8aG1hE72O","start_time":1604952180,"bandwidth":579},{"service_id":"3iaImYs8FyO6a8aG1hE72O","start_time":1604952360,"bandwidth":578},{"service_id":"3iaImYs8FyO6a8aG1hE72O","start_time":1604952540,"bandwidth":281},{"service_id":"3iaImYs8FyO6a8aG1hE72O","start_time":1604953260,"bandwidth":560},{"service_id":"3iaImYs8FyO6a8aG1hE72O","start_time":1604953320,"bandwidth":1139},{"service_id":"3iaImYs8FyO6a8aG1hE72O","start_time":1604953680,"bandwidth":281},{"service_id":"3iaImYs8FyO6a8aG1hE72O","start_time":1604953800,"bandwidth":280},{"service_id":"3iaImYs8FyO6a8aG1hE72O","start_time":1604954220,"bandwidth":578},{"service_id":"3iaImYs8FyO6a8aG1hE72O","start_time":1604954460,"bandwidth":281},{"service_id":"3iaImYs8FyO6a8aG1hE72O","start_time":1604955120,"bandwidth":578},{"service_id":"3iaImYs8FyO6a8aG1hE72O","start_time":1604955180,"bandwidth":280}],"3wB69F8qQ6wLZNcrI5bTeI":[{"service_id":"3wB69F8qQ6wLZNcrI5bTeI","start_time":1604951820,"bandwidth":1381},{"service_id":"3wB69F8qQ6wLZNcrI5bTeI","start_time":1604951880,"bandwidth":1382},{"service_id":"3wB69F8qQ6wLZNcrI5bTeI","start_time":1604951940,"bandwidth":1380},{"service_id":"3wB69F8qQ6wLZNcrI5bTeI","start_time":1604952000,"bandwidth":1381},{"service_id":"3wB69F8qQ6wLZNcrI5bTeI","start_time":1604952120,"bandwidth":24642},{"service_id":"3wB69F8qQ6wLZNcrI5bTeI","start_time":1604952180,"bandwidth":691},{"service_id":"3wB69F8qQ6wLZNcrI5bTeI","start_time":1604952240,"bandwidth":690},{"service_id":"3wB69F8qQ6wLZNcrI5bTeI","start_time":1604952360,"bandwidth":2072},{"service_id":"3wB69F8qQ6wLZNcrI5bTeI","start_time":1604952540,"bandwidth":1382},{"service_id":"3wB69F8qQ6wLZNcrI5bTeI","start_time":1604952600,"bandwidth":690},{"service_id":"3wB69F8qQ6wLZNcrI5bTeI","start_time":1604952660,"bandwidth":23767},{"service_id":"3wB69F8qQ6wLZNcrI5bTeI","start_time":1604952780,"bandwidth":691},{"service_id":"3wB69F8qQ6wLZNcrI5bTeI","start_time":1604952900,"bandwidth":1381},{"service_id":"3wB69F8qQ6wLZNcrI5bTeI","start_time":1604952960,"bandwidth":690},{"service_id":"3wB69F8qQ6wLZNcrI5bTeI","start_time":1604953020,"bandwidth":25330},{"service_id":"3wB69F8qQ6wLZNcrI5bTeI","start_time":1604953080,"bandwidth":690},{"service_id":"3wB69F8qQ6wLZNcrI5bTeI","start_time":1604953140,"bandwidth":690},{"service_id":"3wB69F8qQ6wLZNcrI5bTeI","start_time":1604953200,"bandwidth":691},{"service_id":"3wB69F8qQ6wLZNcrI5bTeI","start_time":1604953260,"bandwidth":690},{"service_id":"3wB69F8qQ6wLZNcrI5bTeI","start_time":1604953320,"bandwidth":1382},{"service_id":"3wB69F8qQ6wLZNcrI5bTeI","start_time":1604953440,"bandwidth":690},{"service_id":"3wB69F8qQ6wLZNcrI5bTeI","start_time":1604953500,"bandwidth":1382},{"service_id":"3wB69F8qQ6wLZNcrI5bTeI","start_time":1604953560,"bandwidth":691},{"service_id":"3wB69F8qQ6wLZNcrI5bTeI","start_time":1604953620,"bandwidth":690},{"service_id":"3wB69F8qQ6wLZNcrI5bTeI","start_time":1604953680,"bandwidth":26096},{"service_id":"3wB69F8qQ6wLZNcrI5bTeI","start_time":1604953740,"bandwidth":1380},{"service_id":"3wB69F8qQ6wLZNcrI5bTeI","start_time":1604953800,"bandwidth":1381},{"service_id":"3wB69F8qQ6wLZNcrI5bTeI","start_time":1604953920,"bandwidth":24642},{"service_id":"3wB69F8qQ6wLZNcrI5bTeI","start_time":1604953980,"bandwidth":691},{"service_id":"3wB69F8qQ6wLZNcrI5bTeI","start_time":1604954040,"bandwidth":690},{"service_id":"3wB69F8qQ6wLZNcrI5bTeI","start_time":1604954160,"bandwidth":2072},{"service_id":"3wB69F8qQ6wLZNcrI5bTeI","start_time":1604954340,"bandwidth":1382},{"service_id":"3wB69F8qQ6wLZNcrI5bTeI","start_time":1604954400,"bandwidth":691},{"service_id":"3wB69F8qQ6wLZNcrI5bTeI","start_time":1604954460,"bandwidth":1382},{"service_id":"3wB69F8qQ6wLZNcrI5bTeI","start_time":1604954580,"bandwidth":690},{"service_id":"3wB69F8qQ6wLZNcrI5bTeI","start_time":1604954640,"bandwidth":24025},{"service_id":"3wB69F8qQ6wLZNcrI5bTeI","start_time":1604954700,"bandwidth":1381},{"service_id":"3wB69F8qQ6wLZNcrI5bTeI","start_time":1604954760,"bandwidth":690},{"service_id":"3wB69F8qQ6wLZNcrI5bTeI","start_time":1604954820,"bandwidth":12070},{"service_id":"3wB69F8qQ6wLZNcrI5bTeI","start_time":1604954880,"bandwidth":13949},{"service_id":"3wB69F8qQ6wLZNcrI5bTeI","start_time":1604954940,"bandwidth":690},{"service_id":"3wB69F8qQ6wLZNcrI5bTeI","start_time":1604955000,"bandwidth":691},{"service_id":"3wB69F8qQ6wLZNcrI5bTeI","start_time":1604955060,"bandwidth":691},{"service_id":"3wB69F8qQ6wLZNcrI5bTeI","start_time":1604955120,"bandwidth":1382},{"service_id":"3wB69F8qQ6wLZNcrI5bTeI","start_time":1604955240,"bandwidth":690},{"service_id":"3wB69F8qQ6wLZNcrI5bTeI","start_time":1604955300,"bandwidth":1382}],"47JpM4rOtfeP0ml6CgIlKd":[{"service_id":"47JpM4rOtfeP0ml6CgIlKd","start_time":1604951820,"bandwidth":20186},{"service_id":"47JpM4rOtfeP0ml6CgIlKd","start_time":1604951880,"bandwidth":20304},{"service_id":"47JpM4rOtfeP0ml6CgIlKd","start_time":1604951940,"bandwidth":20303},{"service_id":"47JpM4rOtfeP0ml6CgIlKd","start_time":1604952000,"bandwidth":20303},{"service_id":"47JpM4rOtfeP0ml6CgIlKd","start_time":1604952060,"bandwidth":20304},{"service_id":"47JpM4rOtfeP0ml6CgIlKd","start_time":1604952120,"bandwidth":20304},{"service_id":"47JpM4rOtfeP0ml6CgIlKd","start_time":1604952180,"bandwidth":20303},{"service_id":"47JpM4rOtfeP0ml6CgIlKd","start_time":1604952240,"bandwidth":20334},{"service_id":"47JpM4rOtfeP0ml6CgIlKd","start_time":1604952300,"bandwidth":20186},{"service_id":"47JpM4rOtfeP0ml6CgIlKd","start_time":1604952360,"bandwidth":20303},{"service_id":"47JpM4rOtfeP0ml6CgIlKd","start_time":1604952420,"bandwidth":20303},{"service_id":"47JpM4rOtfeP0ml6CgIlKd","start_time":1604952480,"bandwidth":20304},{"service_id":"47JpM4rOtfeP0ml6CgIlKd","start_time":1604952540,"bandwidth":20304},{"service_id":"47JpM4rOtfeP0ml6CgIlKd","start_time":1604952600,"bandwidth":20304},{"service_id":"47JpM4rOtfeP0ml6CgIlKd","start_time":1604952660,"bandwidth":20303},{"service_id":"47JpM4rOtfeP0ml6CgIlKd","start_time":1604952720,"bandwidth":20303},{"service_id":"47JpM4rOtfeP0ml6CgIlKd","start_time":1604952780,"bandwidth":20304},{"service_id":"47JpM4rOtfeP0ml6CgIlKd","start_time":1604952840,"bandwidth":20304},{"service_id":"47JpM4rOtfeP0ml6CgIlKd","start_time":1604952900,"bandwidth":457960},{"service_id":"47JpM4rOtfeP0ml6CgIlKd","start_time":1604952960,"bandwidth":457882},{"service_id":"47JpM4rOtfeP0ml6CgIlKd","start_time":1604953020,"bandwidth":22455},{"service_id":"47JpM4rOtfeP0ml6CgIlKd","start_time":1604953080,"bandwidth":22455},{"service_id":"47JpM4rOtfeP0ml6CgIlKd","start_time":1604953140,"bandwidth":20304},{"service_id":"47JpM4rOtfeP0ml6CgIlKd","start_time":1604953200,"bandwidth":20304},{"service_id":"47JpM4rOtfeP0ml6CgIlKd","start_time":1604953260,"bandwidth":20304},{"service_id":"47JpM4rOtfeP0ml6CgIlKd","start_time":1604953320,"bandwidth":20186},{"service_id":"47JpM4rOtfeP0ml6CgIlKd","start_time":1604953380,"bandwidth":20304},{"service_id":"47JpM4rOtfeP0ml6CgIlKd","start_time":1604953440,"bandwidth":20304},{"service_id":"47JpM4rOtfeP0ml6CgIlKd","start_time":1604953500,"bandwidth":20334},{"service_id":"47JpM4rOtfeP0ml6CgIlKd","start_time":1604953560,"bandwidth":20304},{"service_id":"47JpM4rOtfeP0ml6CgIlKd","start_time":1604953620,"bandwidth":20303},{"service_id":"47JpM4rOtfeP0ml6CgIlKd","start_time":1604953680,"bandwidth":20304},{"service_id":"47JpM4rOtfeP0ml6CgIlKd","start_time":1604953740,"bandwidth":20303},{"service_id":"47JpM4rOtfeP0ml6CgIlKd","start_time":1604953800,"bandwidth":20304},{"service_id":"47JpM4rOtfeP0ml6CgIlKd","start_time":1604953860,"bandwidth":20304},{"service_id":"47JpM4rOtfeP0ml6CgIlKd","start_time":1604953920,"bandwidth":20304},{"service_id":"47JpM4rOtfeP0ml6CgIlKd","start_time":1604953980,"bandwidth":20304},{"service_id":"47JpM4rOtfeP0ml6CgIlKd","start_time":1604954040,"bandwidth":20304},{"service_id":"47JpM4rOtfeP0ml6CgIlKd","start_time":1604954100,"bandwidth":20303},{"service_id":"47JpM4rOtfeP0ml6CgIlKd","start_time":1604954160,"bandwidth":20304},{"service_id":"47JpM4rOtfeP0ml6CgIlKd","start_time":1604954220,"bandwidth":20304},{"service_id":"47JpM4rOtfeP0ml6CgIlKd","start_time":1604954280,"bandwidth":20303},{"service_id":"47JpM4rOtfeP0ml6CgIlKd","start_time":1604954340,"bandwidth":20303},{"service_id":"47JpM4rOtfeP0ml6CgIlKd","start_time":1604954400,"bandwidth":20303},{"service_id":"47JpM4rOtfeP0ml6CgIlKd","start_time":1604954460,"bandwidth":452945},{"service_id":"47JpM4rOtfeP0ml6CgIlKd","start_time":1604954520,"bandwidth":20208},{"service_id":"47JpM4rOtfeP0ml6CgIlKd","start_time":1604954580,"bandwidth":20238},{"service_id":"47JpM4rOtfeP0ml6CgIlKd","start_time":1604954640,"bandwidth":20207},{"service_id":"47JpM4rOtfeP0ml6CgIlKd","start_time":1604954700,"bandwidth":20238},{"service_id":"47JpM4rOtfeP0ml6CgIlKd","start_time":1604954760,"bandwidth":20208},{"service_id":"47JpM4rOtfeP0ml6CgIlKd","start_time":1604954820,"bandwidth":20208},{"service_id":"47JpM4rOtfeP0ml6CgIlKd","start_time":1604954880,"bandwidth":20208},{"service_id":"47JpM4rOtfeP0ml6CgIlKd","start_time":1604954940,"bandwidth":20207},{"service_id":"47JpM4rOtfeP0ml6CgIlKd","start_time":1604955000,"bandwidth":20208},{"service_id":"47JpM4rOtfeP0ml6CgIlKd","start_time":1604955060,"bandwidth":20208},{"service_id":"47JpM4rOtfeP0ml6CgIlKd","start_time":1604955120,"bandwidth":20208},{"service_id":"47JpM4rOtfeP0ml6CgIlKd","start_time":1604955180,"bandwidth":20208},{"service_id":"47JpM4rOtfeP0ml6CgIlKd","start_time":1604955240,"bandwidth":20207},{"service_id":"47JpM4rOtfeP0ml6CgIlKd","start_time":1604955300,"bandwidth":20208}],"4Ch9CTHpkVjoA5pRUfgbCY":[{"service_id":"4Ch9CTHpkVjoA5pRUfgbCY","start_time":1604951820,"bandwidth":9719570},{"service_id":"4Ch9CTHpkVjoA5pRUfgbCY","start_time":1604951880,"bandwidth":9967928},{"service_id":"4Ch9CTHpkVjoA5pRUfgbCY","start_time":1604951940,"bandwidth":9069416},{"service_id":"4Ch9CTHpkVjoA5pRUfgbCY","start_time":1604952000,"bandwidth":9893644},{"service_id":"4Ch9CTHpkVjoA5pRUfgbCY","start_time":1604952060,"bandwidth":9242947},{"service_id":"4Ch9CTHpkVjoA5pRUfgbCY","start_time":1604952120,"bandwidth":10372553},{"service_id":"4Ch9CTHpkVjoA5pRUfgbCY","start_time":1604952180,"bandwidth":9848155},{"service_id":"4Ch9CTHpkVjoA5pRUfgbCY","start_time":1604952240,"bandwidth":10472973},{"service_id":"4Ch9CTHpkVjoA5pRUfgbCY","start_time":1604952300,"bandwidth":9057920},{"service_id":"4Ch9CTHpkVjoA5pRUfgbCY","start_time":1604952360,"bandwidth":9004163},{"service_id":"4Ch9CTHpkVjoA5pRUfgbCY","start_time":1604952420,"bandwidth":8848077},{"service_id":"4Ch9CTHpkVjoA5pRUfgbCY","start_time":1604952480,"bandwidth":8474370},{"service_id":"4Ch9CTHpkVjoA5pRUfgbCY","start_time":1604952540,"bandwidth":8886765},{"service_id":"4Ch9CTHpkVjoA5pRUfgbCY","start_time":1604952600,"bandwidth":8835458},{"service_id":"4Ch9CTHpkVjoA5pRUfgbCY","start_time":1604952660,"bandwidth":9000825},{"service_id":"4Ch9CTHpkVjoA5pRUfgbCY","start_time":1604952720,"bandwidth":8326087},{"service_id":"4Ch9CTHpkVjoA5pRUfgbCY","start_time":1604952780,"bandwidth":8352834},{"service_id":"4Ch9CTHpkVjoA5pRUfgbCY","start_time":1604952840,"bandwidth":9104547},{"service_id":"4Ch9CTHpkVjoA5pRUfgbCY","start_time":1604952900,"bandwidth":9340035},{"service_id":"4Ch9CTHpkVjoA5pRUfgbCY","start_time":1604952960,"bandwidth":9315207},{"service_id":"4Ch9CTHpkVjoA5pRUfgbCY","start_time":1604953020,"bandwidth":9273904},{"service_id":"4Ch9CTHpkVjoA5pRUfgbCY","start_time":1604953080,"bandwidth":8464937},{"service_id":"4Ch9CTHpkVjoA5pRUfgbCY","start_time":1604953140,"bandwidth":8152596},{"service_id":"4Ch9CTHpkVjoA5pRUfgbCY","start_time":1604953200,"bandwidth":9047347},{"service_id":"4Ch9CTHpkVjoA5pRUfgbCY","start_time":1604953260,"bandwidth":9307745},{"service_id":"4Ch9CTHpkVjoA5pRUfgbCY","start_time":1604953320,"bandwidth":8893484},{"service_id":"4Ch9CTHpkVjoA5pRUfgbCY","start_time":1604953380,"bandwidth":8623585},{"service_id":"4Ch9CTHpkVjoA5pRUfgbCY","start_time":1604953440,"bandwidth":8544468},{"service_id":"4Ch9CTHpkVjoA5pRUfgbCY","start_time":1604953500,"bandwidth":8993250},{"service_id":"4Ch9CTHpkVjoA5pRUfgbCY","start_time":1604953560,"bandwidth":8621844},{"service_id":"4Ch9CTHpkVjoA5pRUfgbCY","start_time":1604953620,"bandwidth":8768231},{"service_id":"4Ch9CTHpkVjoA5pRUfgbCY","start_time":1604953680,"bandwidth":8659740},{"service_id":"4Ch9CTHpkVjoA5pRUfgbCY","start_time":1604953740,"bandwidth":8645605},{"service_id":"4Ch9CTHpkVjoA5pRUfgbCY","start_time":1604953800,"bandwidth":9296538},{"service_id":"4Ch9CTHpkVjoA5pRUfgbCY","start_time":1604953860,"bandwidth":8851481},{"service_id":"4Ch9CTHpkVjoA5pRUfgbCY","start_time":1604953920,"bandwidth":9023448},{"service_id":"4Ch9CTHpkVjoA5pRUfgbCY","start_time":1604953980,"bandwidth":8916338},{"service_id":"4Ch9CTHpkVjoA5pRUfgbCY","start_time":1604954040,"bandwidth":9005031},{"service_id":"4Ch9CTHpkVjoA5pRUfgbCY","start_time":1604954100,"bandwidth":9255145},{"service_id":"4Ch9CTHpkVjoA5pRUfgbCY","start_time":1604954160,"bandwidth":8767453},{"service_id":"4Ch9CTHpkVjoA5pRUfgbCY","start_time":1604954220,"bandwidth":8442752},{"service_id":"4Ch9CTHpkVjoA5pRUfgbCY","start_time":1604954280,"bandwidth":8736562},{"service_id":"4Ch9CTHpkVjoA5pRUfgbCY","start_time":1604954340,"bandwidth":8561523},{"service_id":"4Ch9CTHpkVjoA5pRUfgbCY","start_time":1604954400,"bandwidth":8714219},{"service_id":"4Ch9CTHpkVjoA5pRUfgbCY","start_time":1604954460,"bandwidth":8421773},{"service_id":"4Ch9CTHpkVjoA5pRUfgbCY","start_time":1604954520,"bandwidth":8456284},{"service_id":"4Ch9CTHpkVjoA5pRUfgbCY","start_time":1604954580,"bandwidth":8632313},{"service_id":"4Ch9CTHpkVjoA5pRUfgbCY","start_time":1604954640,"bandwidth":8249497},{"service_id":"4Ch9CTHpkVjoA5pRUfgbCY","start_time":1604954700,"bandwidth":9694716},{"service_id":"4Ch9CTHpkVjoA5pRUfgbCY","start_time":1604954760,"bandwidth":8971459},{"service_id":"4Ch9CTHpkVjoA5pRUfgbCY","start_time":1604954820,"bandwidth":8463941},{"service_id":"4Ch9CTHpkVjoA5pRUfgbCY","start_time":1604954880,"bandwidth":8533964},{"service_id":"4Ch9CTHpkVjoA5pRUfgbCY","start_time":1604954940,"bandwidth":9175558},{"service_id":"4Ch9CTHpkVjoA5pRUfgbCY","start_time":1604955000,"bandwidth":8984910},{"service_id":"4Ch9CTHpkVjoA5pRUfgbCY","start_time":1604955060,"bandwidth":7984129},{"service_id":"4Ch9CTHpkVjoA5pRUfgbCY","start_time":1604955120,"bandwidth":9220838},{"service_id":"4Ch9CTHpkVjoA5pRUfgbCY","start_time":1604955180,"bandwidth":8942481},{"service_id":"4Ch9CTHpkVjoA5pRUfgbCY","start_time":1604955240,"bandwidth":8182285},{"service_id":"4Ch9CTHpkVjoA5pRUfgbCY","start_time":1604955300,"bandwidth":8282705}],"4mGp0VGIkEaRwuxPjYP3WY":[{"service_id":"4mGp0VGIkEaRwuxPjYP3WY","start_time":1604951820,"bandwidth":5714},{"service_id":"4mGp0VGIkEaRwuxPjYP3WY","start_time":1604951880,"bandwidth":4866},{"service_id":"4mGp0VGIkEaRwuxPjYP3WY","start_time":1604951940,"bandwidth":6085},{"service_id":"4mGp0VGIkEaRwuxPjYP3WY","start_time":1604952000,"bandwidth":3648},{"service_id":"4mGp0VGIkEaRwuxPjYP3WY","start_time":1604952060,"bandwidth":6935},{"service_id":"4mGp0VGIkEaRwuxPjYP3WY","start_time":1604952120,"bandwidth":3700},{"service_id":"4mGp0VGIkEaRwuxPjYP3WY","start_time":1604952180,"bandwidth":8532},{"service_id":"4mGp0VGIkEaRwuxPjYP3WY","start_time":1604952240,"bandwidth":7799},{"service_id":"4mGp0VGIkEaRwuxPjYP3WY","start_time":1604952300,"bandwidth":6590},{"service_id":"4mGp0VGIkEaRwuxPjYP3WY","start_time":1604952360,"bandwidth":3280},{"service_id":"4mGp0VGIkEaRwuxPjYP3WY","start_time":1604952420,"bandwidth":6084},{"service_id":"4mGp0VGIkEaRwuxPjYP3WY","start_time":1604952480,"bandwidth":8172},{"service_id":"4mGp0VGIkEaRwuxPjYP3WY","start_time":1604952540,"bandwidth":6087},{"service_id":"4mGp0VGIkEaRwuxPjYP3WY","start_time":1604952600,"bandwidth":9741},{"service_id":"4mGp0VGIkEaRwuxPjYP3WY","start_time":1604952660,"bandwidth":9420},{"service_id":"4mGp0VGIkEaRwuxPjYP3WY","start_time":1604952720,"bandwidth":10578},{"service_id":"4mGp0VGIkEaRwuxPjYP3WY","start_time":1604952780,"bandwidth":5717},{"service_id":"4mGp0VGIkEaRwuxPjYP3WY","start_time":1604952840,"bandwidth":6087},{"service_id":"4mGp0VGIkEaRwuxPjYP3WY","start_time":1604952900,"bandwidth":7796},{"service_id":"4mGp0VGIkEaRwuxPjYP3WY","start_time":1604952960,"bandwidth":8145},{"service_id":"4mGp0VGIkEaRwuxPjYP3WY","start_time":1604953020,"bandwidth":8531},{"service_id":"4mGp0VGIkEaRwuxPjYP3WY","start_time":1604953080,"bandwidth":5701},{"service_id":"4mGp0VGIkEaRwuxPjYP3WY","start_time":1604953140,"bandwidth":5723},{"service_id":"4mGp0VGIkEaRwuxPjYP3WY","start_time":1604953200,"bandwidth":7304},{"service_id":"4mGp0VGIkEaRwuxPjYP3WY","start_time":1604953260,"bandwidth":8158},{"service_id":"4mGp0VGIkEaRwuxPjYP3WY","start_time":1604953320,"bandwidth":10245},{"service_id":"4mGp0VGIkEaRwuxPjYP3WY","start_time":1604953380,"bandwidth":6914},{"service_id":"4mGp0VGIkEaRwuxPjYP3WY","start_time":1604953440,"bandwidth":13035},{"service_id":"4mGp0VGIkEaRwuxPjYP3WY","start_time":1604953500,"bandwidth":4921},{"service_id":"4mGp0VGIkEaRwuxPjYP3WY","start_time":1604953560,"bandwidth":4870},{"service_id":"4mGp0VGIkEaRwuxPjYP3WY","start_time":1604953620,"bandwidth":10198},{"service_id":"4mGp0VGIkEaRwuxPjYP3WY","start_time":1604953680,"bandwidth":6080},{"service_id":"4mGp0VGIkEaRwuxPjYP3WY","start_time":1604953740,"bandwidth":8512},{"service_id":"4mGp0VGIkEaRwuxPjYP3WY","start_time":1604953800,"bandwidth":5710},{"service_id":"4mGp0VGIkEaRwuxPjYP3WY","start_time":1604953860,"bandwidth":7303},{"service_id":"4mGp0VGIkEaRwuxPjYP3WY","start_time":1604953920,"bandwidth":9058},{"service_id":"4mGp0VGIkEaRwuxPjYP3WY","start_time":1604953980,"bandwidth":6557},{"service_id":"4mGp0VGIkEaRwuxPjYP3WY","start_time":1604954040,"bandwidth":6935},{"service_id":"4mGp0VGIkEaRwuxPjYP3WY","start_time":1604954100,"bandwidth":7351},{"service_id":"4mGp0VGIkEaRwuxPjYP3WY","start_time":1604954160,"bandwidth":6943},{"service_id":"4mGp0VGIkEaRwuxPjYP3WY","start_time":1604954220,"bandwidth":6092},{"service_id":"4mGp0VGIkEaRwuxPjYP3WY","start_time":1604954280,"bandwidth":4864},{"service_id":"4mGp0VGIkEaRwuxPjYP3WY","start_time":1604954340,"bandwidth":6081},{"service_id":"4mGp0VGIkEaRwuxPjYP3WY","start_time":1604954400,"bandwidth":8134},{"service_id":"4mGp0VGIkEaRwuxPjYP3WY","start_time":1604954460,"bandwidth":5792},{"service_id":"4mGp0VGIkEaRwuxPjYP3WY","start_time":1604954520,"bandwidth":6917},{"service_id":"4mGp0VGIkEaRwuxPjYP3WY","start_time":1604954580,"bandwidth":8153},{"service_id":"4mGp0VGIkEaRwuxPjYP3WY","start_time":1604954640,"bandwidth":5734},{"service_id":"4mGp0VGIkEaRwuxPjYP3WY","start_time":1604954700,"bandwidth":5706},{"service_id":"4mGp0VGIkEaRwuxPjYP3WY","start_time":1604954760,"bandwidth":5724},{"service_id":"4mGp0VGIkEaRwuxPjYP3WY","start_time":1604954820,"bandwidth":8155},{"service_id":"4mGp0VGIkEaRwuxPjYP3WY","start_time":1604954880,"bandwidth":2433},{"service_id":"4mGp0VGIkEaRwuxPjYP3WY","start_time":1604954940,"bandwidth":2442},{"service_id":"4mGp0VGIkEaRwuxPjYP3WY","start_time":1604955000,"bandwidth":5736},{"service_id":"4mGp0VGIkEaRwuxPjYP3WY","start_time":1604955060,"bandwidth":4868},{"service_id":"4mGp0VGIkEaRwuxPjYP3WY","start_time":1604955120,"bandwidth":2426},{"service_id":"4mGp0VGIkEaRwuxPjYP3WY","start_time":1604955180,"bandwidth":3652},{"service_id":"4mGp0VGIkEaRwuxPjYP3WY","start_time":1604955240,"bandwidth":4868},{"service_id":"4mGp0VGIkEaRwuxPjYP3WY","start_time":1604955300,"bandwidth":4486}],"4sVOnCeUCD2q5jnR4GiIsS":[{"service_id":"4sVOnCeUCD2q5jnR4GiIsS","start_time":1604951820,"bandwidth":1173451},{"service_id":"4sVOnCeUCD2q5jnR4GiIsS","start_time":1604951880,"bandwidth":300},{"service_id":"4sVOnCeUCD2q5jnR4GiIsS","start_time":1604952000,"bandwidth":179444},{"service_id":"4sVOnCeUCD2q5jnR4GiIsS","start_time":1604952060,"bandwidth":2056},{"service_id":"4sVOnCeUCD2q5jnR4GiIsS","start_time":1604952780,"bandwidth":108775},{"service_id":"4sVOnCeUCD2q5jnR4GiIsS","start_time":1604952840,"bandwidth":74966},{"service_id":"4sVOnCeUCD2q5jnR4GiIsS","start_time":1604953140,"bandwidth":627400},{"service_id":"4sVOnCeUCD2q5jnR4GiIsS","start_time":1604953380,"bandwidth":757759},{"service_id":"4sVOnCeUCD2q5jnR4GiIsS","start_time":1604953500,"bandwidth":62905},{"service_id":"4sVOnCeUCD2q5jnR4GiIsS","start_time":1604953620,"bandwidth":641278},{"service_id":"4sVOnCeUCD2q5jnR4GiIsS","start_time":1604953680,"bandwidth":2056},{"service_id":"4sVOnCeUCD2q5jnR4GiIsS","start_time":1604953740,"bandwidth":36664},{"service_id":"4sVOnCeUCD2q5jnR4GiIsS","start_time":1604953980,"bandwidth":515642},{"service_id":"4sVOnCeUCD2q5jnR4GiIsS","start_time":1604954040,"bandwidth":18066},{"service_id":"4sVOnCeUCD2q5jnR4GiIsS","start_time":1604954400,"bandwidth":589303},{"service_id":"4sVOnCeUCD2q5jnR4GiIsS","start_time":1604954940,"bandwidth":3897}],"538NiEwiHVOH26fhTf6UrO":[{"service_id":"538NiEwiHVOH26fhTf6UrO","start_time":1604952780,"bandwidth":538557},{"service_id":"538NiEwiHVOH26fhTf6UrO","start_time":1604952900,"bandwidth":215221},{"service_id":"538NiEwiHVOH26fhTf6UrO","start_time":1604952960,"bandwidth":132339},{"service_id":"538NiEwiHVOH26fhTf6UrO","start_time":1604953020,"bandwidth":136608},{"service_id":"538NiEwiHVOH26fhTf6UrO","start_time":1604953080,"bandwidth":140877},{"service_id":"538NiEwiHVOH26fhTf6UrO","start_time":1604953140,"bandwidth":140877},{"service_id":"538NiEwiHVOH26fhTf6UrO","start_time":1604953200,"bandwidth":128070},{"service_id":"538NiEwiHVOH26fhTf6UrO","start_time":1604953260,"bandwidth":132339},{"service_id":"538NiEwiHVOH26fhTf6UrO","start_time":1604953320,"bandwidth":132339},{"service_id":"538NiEwiHVOH26fhTf6UrO","start_time":1604953380,"bandwidth":124198}],"55bpXlUWjZbkgNfCdexONi":[{"service_id":"55bpXlUWjZbkgNfCdexONi","start_time":1604951880,"bandwidth":10783},{"service_id":"55bpXlUWjZbkgNfCdexONi","start_time":1604951940,"bandwidth":5784},{"service_id":"55bpXlUWjZbkgNfCdexONi","start_time":1604952000,"bandwidth":17962},{"service_id":"55bpXlUWjZbkgNfCdexONi","start_time":1604952060,"bandwidth":1900}],"56YY7KfopnH6d67QFr8PLp":[{"service_id":"56YY7KfopnH6d67QFr8PLp","start_time":1604951820,"bandwidth":16908633},{"service_id":"56YY7KfopnH6d67QFr8PLp","start_time":1604951880,"bandwidth":16365489},{"service_id":"56YY7KfopnH6d67QFr8PLp","start_time":1604951940,"bandwidth":17856575},{"service_id":"56YY7KfopnH6d67QFr8PLp","start_time":1604952000,"bandwidth":17596671},{"service_id":"56YY7KfopnH6d67QFr8PLp","start_time":1604952060,"bandwidth":16768738},{"service_id":"56YY7KfopnH6d67QFr8PLp","start_time":1604952120,"bandwidth":18204125},{"service_id":"56YY7KfopnH6d67QFr8PLp","start_time":1604952180,"bandwidth":18134466},{"service_id":"56YY7KfopnH6d67QFr8PLp","start_time":1604952240,"bandwidth":16435593},{"service_id":"56YY7KfopnH6d67QFr8PLp","start_time":1604952300,"bandwidth":18124202},{"service_id":"56YY7KfopnH6d67QFr8PLp","start_time":1604952360,"bandwidth":17627289},{"service_id":"56YY7KfopnH6d67QFr8PLp","start_time":1604952420,"bandwidth":16389026},{"service_id":"56YY7KfopnH6d67QFr8PLp","start_time":1604952480,"bandwidth":16159287},{"service_id":"56YY7KfopnH6d67QFr8PLp","start_time":1604952540,"bandwidth":16986392},{"service_id":"56YY7KfopnH6d67QFr8PLp","start_time":1604952600,"bandwidth":17221016},{"service_id":"56YY7KfopnH6d67QFr8PLp","start_time":1604952660,"bandwidth":17430142},{"service_id":"56YY7KfopnH6d67QFr8PLp","start_time":1604952720,"bandwidth":16148893},{"service_id":"56YY7KfopnH6d67QFr8PLp","start_time":1604952780,"bandwidth":16512365},{"service_id":"56YY7KfopnH6d67QFr8PLp","start_time":1604952840,"bandwidth":17640516},{"service_id":"56YY7KfopnH6d67QFr8PLp","start_time":1604952900,"bandwidth":17261175},{"service_id":"56YY7KfopnH6d67QFr8PLp","start_time":1604952960,"bandwidth":17365218},{"service_id":"56YY7KfopnH6d67QFr8PLp","start_time":1604953020,"bandwidth":16712850},{"service_id":"56YY7KfopnH6d67QFr8PLp","start_time":1604953080,"bandwidth":17520356},{"service_id":"56YY7KfopnH6d67QFr8PLp","start_time":1604953140,"bandwidth":16566397},{"service_id":"56YY7KfopnH6d67QFr8PLp","start_time":1604953200,"bandwidth":17063126},{"service_id":"56YY7KfopnH6d67QFr8PLp","start_time":1604953260,"bandwidth":17009394},{"service_id":"56YY7KfopnH6d67QFr8PLp","start_time":1604953320,"bandwidth":18889555},{"service_id":"56YY7KfopnH6d67QFr8PLp","start_time":1604953380,"bandwidth":16799055},{"service_id":"56YY7KfopnH6d67QFr8PLp","start_time":1604953440,"bandwidth":16298996},{"service_id":"56YY7KfopnH6d67QFr8PLp","start_time":1604953500,"bandwidth":17593855},{"service_id":"56YY7KfopnH6d67QFr8PLp","start_time":1604953560,"bandwidth":16094514},{"service_id":"56YY7KfopnH6d67QFr8PLp","start_time":1604953620,"bandwidth":18069880},{"service_id":"56YY7KfopnH6d67QFr8PLp","start_time":1604953680,"bandwidth":18862737},{"service_id":"56YY7KfopnH6d67QFr8PLp","start_time":1604953740,"bandwidth":16892207},{"service_id":"56YY7KfopnH6d67QFr8PLp","start_time":1604953800,"bandwidth":17987576},{"service_id":"56YY7KfopnH6d67QFr8PLp","start_time":1604953860,"bandwidth":20346688},{"service_id":"56YY7KfopnH6d67QFr8PLp","start_time":1604953920,"bandwidth":17802083},{"service_id":"56YY7KfopnH6d67QFr8PLp","start_time":1604953980,"bandwidth":18370866},{"service_id":"56YY7KfopnH6d67QFr8PLp","start_time":1604954040,"bandwidth":17512005},{"service_id":"56YY7KfopnH6d67QFr8PLp","start_time":1604954100,"bandwidth":17575895},{"service_id":"56YY7KfopnH6d67QFr8PLp","start_time":1604954160,"bandwidth":17309233},{"service_id":"56YY7KfopnH6d67QFr8PLp","start_time":1604954220,"bandwidth":17815174},{"service_id":"56YY7KfopnH6d67QFr8PLp","start_time":1604954280,"bandwidth":17037834},{"service_id":"56YY7KfopnH6d67QFr8PLp","start_time":1604954340,"bandwidth":17545927},{"service_id":"56YY7KfopnH6d67QFr8PLp","start_time":1604954400,"bandwidth":16568496},{"service_id":"56YY7KfopnH6d67QFr8PLp","start_time":1604954460,"bandwidth":17300679},{"service_id":"56YY7KfopnH6d67QFr8PLp","start_time":1604954520,"bandwidth":16926514},{"service_id":"56YY7KfopnH6d67QFr8PLp","start_time":1604954580,"bandwidth":18192168},{"service_id":"56YY7KfopnH6d67QFr8PLp","start_time":1604954640,"bandwidth":17856139},{"service_id":"56YY7KfopnH6d67QFr8PLp","start_time":1604954700,"bandwidth":17528727},{"service_id":"56YY7KfopnH6d67QFr8PLp","start_time":1604954760,"bandwidth":16054731},{"service_id":"56YY7KfopnH6d67QFr8PLp","start_time":1604954820,"bandwidth":17644920},{"service_id":"56YY7KfopnH6d67QFr8PLp","start_time":1604954880,"bandwidth":17308113},{"service_id":"56YY7KfopnH6d67QFr8PLp","start_time":1604954940,"bandwidth":15864986},{"service_id":"56YY7KfopnH6d67QFr8PLp","start_time":1604955000,"bandwidth":17615099},{"service_id":"56YY7KfopnH6d67QFr8PLp","start_time":1604955060,"bandwidth":16333624},{"service_id":"56YY7KfopnH6d67QFr8PLp","start_time":1604955120,"bandwidth":17418701},{"service_id":"56YY7KfopnH6d67QFr8PLp","start_time":1604955180,"bandwidth":20387148},{"service_id":"56YY7KfopnH6d67QFr8PLp","start_time":1604955240,"bandwidth":16833209},{"service_id":"56YY7KfopnH6d67QFr8PLp","start_time":1604955300,"bandwidth":17661475}],"5Sf5hTdTdthaxbP9JUObjU":[{"service_id":"5Sf5hTdTdthaxbP9JUObjU","start_time":1604951820,"bandwidth":82746},{"service_id":"5Sf5hTdTdthaxbP9JUObjU","start_time":1604951880,"bandwidth":1601186},{"service_id":"5Sf5hTdTdthaxbP9JUObjU","start_time":1604951940,"bandwidth":1646172},{"service_id":"5Sf5hTdTdthaxbP9JUObjU","start_time":1604952000,"bandwidth":134910},{"service_id":"5Sf5hTdTdthaxbP9JUObjU","start_time":1604952060,"bandwidth":232869},{"service_id":"5Sf5hTdTdthaxbP9JUObjU","start_time":1604952120,"bandwidth":82907},{"service_id":"5Sf5hTdTdthaxbP9JUObjU","start_time":1604952180,"bandwidth":82889},{"service_id":"5Sf5hTdTdthaxbP9JUObjU","start_time":1604952240,"bandwidth":71968},{"service_id":"5Sf5hTdTdthaxbP9JUObjU","start_time":1604952300,"bandwidth":1634648},{"service_id":"5Sf5hTdTdthaxbP9JUObjU","start_time":1604952360,"bandwidth":78293},{"service_id":"5Sf5hTdTdthaxbP9JUObjU","start_time":1604952420,"bandwidth":90133},{"service_id":"5Sf5hTdTdthaxbP9JUObjU","start_time":1604952480,"bandwidth":1643750},{"service_id":"5Sf5hTdTdthaxbP9JUObjU","start_time":1604952540,"bandwidth":53180},{"service_id":"5Sf5hTdTdthaxbP9JUObjU","start_time":1604952600,"bandwidth":86167},{"service_id":"5Sf5hTdTdthaxbP9JUObjU","start_time":1604952660,"bandwidth":78289},{"service_id":"5Sf5hTdTdthaxbP9JUObjU","start_time":1604952720,"bandwidth":85393},{"service_id":"5Sf5hTdTdthaxbP9JUObjU","start_time":1604952780,"bandwidth":1612753},{"service_id":"5Sf5hTdTdthaxbP9JUObjU","start_time":1604952840,"bandwidth":92293},{"service_id":"5Sf5hTdTdthaxbP9JUObjU","start_time":1604952900,"bandwidth":75641},{"service_id":"5Sf5hTdTdthaxbP9JUObjU","start_time":1604952960,"bandwidth":80908},{"service_id":"5Sf5hTdTdthaxbP9JUObjU","start_time":1604953020,"bandwidth":93937},{"service_id":"5Sf5hTdTdthaxbP9JUObjU","start_time":1604953080,"bandwidth":78211},{"service_id":"5Sf5hTdTdthaxbP9JUObjU","start_time":1604953140,"bandwidth":54382},{"service_id":"5Sf5hTdTdthaxbP9JUObjU","start_time":1604953200,"bandwidth":1363951},{"service_id":"5Sf5hTdTdthaxbP9JUObjU","start_time":1604953260,"bandwidth":80926},{"service_id":"5Sf5hTdTdthaxbP9JUObjU","start_time":1604953320,"bandwidth":87396},{"service_id":"5Sf5hTdTdthaxbP9JUObjU","start_time":1604953380,"bandwidth":78208},{"service_id":"5Sf5hTdTdthaxbP9JUObjU","start_time":1604953440,"bandwidth":59049},{"service_id":"5Sf5hTdTdthaxbP9JUObjU","start_time":1604953500,"bandwidth":1207114},{"service_id":"5Sf5hTdTdthaxbP9JUObjU","start_time":1604953560,"bandwidth":114903},{"service_id":"5Sf5hTdTdthaxbP9JUObjU","start_time":1604953620,"bandwidth":78274},{"service_id":"5Sf5hTdTdthaxbP9JUObjU","start_time":1604953680,"bandwidth":78212},{"service_id":"5Sf5hTdTdthaxbP9JUObjU","start_time":1604953740,"bandwidth":63700},{"service_id":"5Sf5hTdTdthaxbP9JUObjU","start_time":1604953800,"bandwidth":60274},{"service_id":"5Sf5hTdTdthaxbP9JUObjU","start_time":1604953860,"bandwidth":95298},{"service_id":"5Sf5hTdTdthaxbP9JUObjU","start_time":1604953920,"bandwidth":3234276},{"service_id":"5Sf5hTdTdthaxbP9JUObjU","start_time":1604953980,"bandwidth":72019},{"service_id":"5Sf5hTdTdthaxbP9JUObjU","start_time":1604954040,"bandwidth":1267945},{"service_id":"5Sf5hTdTdthaxbP9JUObjU","start_time":1604954100,"bandwidth":80984},{"service_id":"5Sf5hTdTdthaxbP9JUObjU","start_time":1604954160,"bandwidth":1186606},{"service_id":"5Sf5hTdTdthaxbP9JUObjU","start_time":1604954220,"bandwidth":117220},{"service_id":"5Sf5hTdTdthaxbP9JUObjU","start_time":1604954280,"bandwidth":70935},{"service_id":"5Sf5hTdTdthaxbP9JUObjU","start_time":1604954340,"bandwidth":66317},{"service_id":"5Sf5hTdTdthaxbP9JUObjU","start_time":1604954400,"bandwidth":100449},{"service_id":"5Sf5hTdTdthaxbP9JUObjU","start_time":1604954460,"bandwidth":99036},{"service_id":"5Sf5hTdTdthaxbP9JUObjU","start_time":1604954520,"bandwidth":88735},{"service_id":"5Sf5hTdTdthaxbP9JUObjU","start_time":1604954580,"bandwidth":1919162},{"service_id":"5Sf5hTdTdthaxbP9JUObjU","start_time":1604954640,"bandwidth":94007},{"service_id":"5Sf5hTdTdthaxbP9JUObjU","start_time":1604954700,"bandwidth":1587369},{"service_id":"5Sf5hTdTdthaxbP9JUObjU","start_time":1604954760,"bandwidth":143454},{"service_id":"5Sf5hTdTdthaxbP9JUObjU","start_time":1604954820,"bandwidth":7048826},{"service_id":"5Sf5hTdTdthaxbP9JUObjU","start_time":1604954880,"bandwidth":87919},{"service_id":"5Sf5hTdTdthaxbP9JUObjU","start_time":1604954940,"bandwidth":438320},{"service_id":"5Sf5hTdTdthaxbP9JUObjU","start_time":1604955000,"bandwidth":1281404},{"service_id":"5Sf5hTdTdthaxbP9JUObjU","start_time":1604955060,"bandwidth":1038680},{"service_id":"5Sf5hTdTdthaxbP9JUObjU","start_time":1604955120,"bandwidth":1319858},{"service_id":"5Sf5hTdTdthaxbP9JUObjU","start_time":1604955180,"bandwidth":90196},{"service_id":"5Sf5hTdTdthaxbP9JUObjU","start_time":1604955240,"bandwidth":76078},{"service_id":"5Sf5hTdTdthaxbP9JUObjU","start_time":1604955300,"bandwidth":63684}],"5c0gagbyrVn5FVNKnGQB2c":[{"service_id":"5c0gagbyrVn5FVNKnGQB2c","start_time":1604951820,"bandwidth":3851754},{"service_id":"5c0gagbyrVn5FVNKnGQB2c","start_time":1604951940,"bandwidth":5964},{"service_id":"5c0gagbyrVn5FVNKnGQB2c","start_time":1604952000,"bandwidth":185982847},{"service_id":"5c0gagbyrVn5FVNKnGQB2c","start_time":1604952060,"bandwidth":145562082},{"service_id":"5c0gagbyrVn5FVNKnGQB2c","start_time":1604952120,"bandwidth":163803282},{"service_id":"5c0gagbyrVn5FVNKnGQB2c","start_time":1604952180,"bandwidth":262410217},{"service_id":"5c0gagbyrVn5FVNKnGQB2c","start_time":1604952240,"bandwidth":175766089},{"service_id":"5c0gagbyrVn5FVNKnGQB2c","start_time":1604952300,"bandwidth":87635812},{"service_id":"5c0gagbyrVn5FVNKnGQB2c","start_time":1604952360,"bandwidth":69530808},{"service_id":"5c0gagbyrVn5FVNKnGQB2c","start_time":1604952420,"bandwidth":66084918},{"service_id":"5c0gagbyrVn5FVNKnGQB2c","start_time":1604952480,"bandwidth":28386648},{"service_id":"5c0gagbyrVn5FVNKnGQB2c","start_time":1604952540,"bandwidth":21598900},{"service_id":"5c0gagbyrVn5FVNKnGQB2c","start_time":1604952600,"bandwidth":8523161},{"service_id":"5c0gagbyrVn5FVNKnGQB2c","start_time":1604952660,"bandwidth":5182782},{"service_id":"5c0gagbyrVn5FVNKnGQB2c","start_time":1604952720,"bandwidth":3960498},{"service_id":"5c0gagbyrVn5FVNKnGQB2c","start_time":1604952780,"bandwidth":101362},{"service_id":"5c0gagbyrVn5FVNKnGQB2c","start_time":1604952840,"bandwidth":4482},{"service_id":"5c0gagbyrVn5FVNKnGQB2c","start_time":1604952900,"bandwidth":186891055},{"service_id":"5c0gagbyrVn5FVNKnGQB2c","start_time":1604952960,"bandwidth":146577152},{"service_id":"5c0gagbyrVn5FVNKnGQB2c","start_time":1604953020,"bandwidth":158423320},{"service_id":"5c0gagbyrVn5FVNKnGQB2c","start_time":1604953080,"bandwidth":272446301},{"service_id":"5c0gagbyrVn5FVNKnGQB2c","start_time":1604953140,"bandwidth":170178852},{"service_id":"5c0gagbyrVn5FVNKnGQB2c","start_time":1604953200,"bandwidth":88462254},{"service_id":"5c0gagbyrVn5FVNKnGQB2c","start_time":1604953260,"bandwidth":71259569},{"service_id":"5c0gagbyrVn5FVNKnGQB2c","start_time":1604953320,"bandwidth":63959807},{"service_id":"5c0gagbyrVn5FVNKnGQB2c","start_time":1604953380,"bandwidth":29394390},{"service_id":"5c0gagbyrVn5FVNKnGQB2c","start_time":1604953440,"bandwidth":19669874},{"service_id":"5c0gagbyrVn5FVNKnGQB2c","start_time":1604953500,"bandwidth":9122475},{"service_id":"5c0gagbyrVn5FVNKnGQB2c","start_time":1604953560,"bandwidth":4257198},{"service_id":"5c0gagbyrVn5FVNKnGQB2c","start_time":1604953620,"bandwidth":3547668},{"service_id":"5c0gagbyrVn5FVNKnGQB2c","start_time":1604953680,"bandwidth":309001},{"service_id":"5c0gagbyrVn5FVNKnGQB2c","start_time":1604953740,"bandwidth":5964},{"service_id":"5c0gagbyrVn5FVNKnGQB2c","start_time":1604953800,"bandwidth":190746371},{"service_id":"5c0gagbyrVn5FVNKnGQB2c","start_time":1604953860,"bandwidth":140693795},{"service_id":"5c0gagbyrVn5FVNKnGQB2c","start_time":1604953920,"bandwidth":164512119},{"service_id":"5c0gagbyrVn5FVNKnGQB2c","start_time":1604953980,"bandwidth":265655587},{"service_id":"5c0gagbyrVn5FVNKnGQB2c","start_time":1604954040,"bandwidth":175058349},{"service_id":"5c0gagbyrVn5FVNKnGQB2c","start_time":1604954100,"bandwidth":85410718},{"service_id":"5c0gagbyrVn5FVNKnGQB2c","start_time":1604954160,"bandwidth":65375469},{"service_id":"5c0gagbyrVn5FVNKnGQB2c","start_time":1604954220,"bandwidth":65055845},{"service_id":"5c0gagbyrVn5FVNKnGQB2c","start_time":1604954280,"bandwidth":32238007},{"service_id":"5c0gagbyrVn5FVNKnGQB2c","start_time":1604954340,"bandwidth":19973974},{"service_id":"5c0gagbyrVn5FVNKnGQB2c","start_time":1604954400,"bandwidth":10795901},{"service_id":"5c0gagbyrVn5FVNKnGQB2c","start_time":1604954460,"bandwidth":4470351},{"service_id":"5c0gagbyrVn5FVNKnGQB2c","start_time":1604954520,"bandwidth":2434176},{"service_id":"5c0gagbyrVn5FVNKnGQB2c","start_time":1604954580,"bandwidth":2027237},{"service_id":"5c0gagbyrVn5FVNKnGQB2c","start_time":1604954640,"bandwidth":4482},{"service_id":"5c0gagbyrVn5FVNKnGQB2c","start_time":1604954700,"bandwidth":187091027},{"service_id":"5c0gagbyrVn5FVNKnGQB2c","start_time":1604954760,"bandwidth":145462296},{"service_id":"5c0gagbyrVn5FVNKnGQB2c","start_time":1604954820,"bandwidth":162050083},{"service_id":"5c0gagbyrVn5FVNKnGQB2c","start_time":1604954880,"bandwidth":269101645},{"service_id":"5c0gagbyrVn5FVNKnGQB2c","start_time":1604954940,"bandwidth":172408979},{"service_id":"5c0gagbyrVn5FVNKnGQB2c","start_time":1604955000,"bandwidth":87354681},{"service_id":"5c0gagbyrVn5FVNKnGQB2c","start_time":1604955060,"bandwidth":67712582},{"service_id":"5c0gagbyrVn5FVNKnGQB2c","start_time":1604955120,"bandwidth":63449974},{"service_id":"5c0gagbyrVn5FVNKnGQB2c","start_time":1604955180,"bandwidth":30812913},{"service_id":"5c0gagbyrVn5FVNKnGQB2c","start_time":1604955240,"bandwidth":18152451},{"service_id":"5c0gagbyrVn5FVNKnGQB2c","start_time":1604955300,"bandwidth":11857829}],"5lnAyusJSAZbvE9a7pkK33":[{"service_id":"5lnAyusJSAZbvE9a7pkK33","start_time":1604952120,"bandwidth":284}],"5oYej0l0heMydtjaVPOq4z":[{"service_id":"5oYej0l0heMydtjaVPOq4z","start_time":1604951820,"bandwidth":118363},{"service_id":"5oYej0l0heMydtjaVPOq4z","start_time":1604953440,"bandwidth":118802},{"service_id":"5oYej0l0heMydtjaVPOq4z","start_time":1604954640,"bandwidth":1379},{"service_id":"5oYej0l0heMydtjaVPOq4z","start_time":1604955120,"bandwidth":117839}],"5vrXMNWaz9itI17TrjlTnP":[{"service_id":"5vrXMNWaz9itI17TrjlTnP","start_time":1604951820,"bandwidth":109065},{"service_id":"5vrXMNWaz9itI17TrjlTnP","start_time":1604951880,"bandwidth":81712},{"service_id":"5vrXMNWaz9itI17TrjlTnP","start_time":1604952000,"bandwidth":239043},{"service_id":"5vrXMNWaz9itI17TrjlTnP","start_time":1604952060,"bandwidth":458109},{"service_id":"5vrXMNWaz9itI17TrjlTnP","start_time":1604952120,"bandwidth":602560},{"service_id":"5vrXMNWaz9itI17TrjlTnP","start_time":1604952180,"bandwidth":589322},{"service_id":"5vrXMNWaz9itI17TrjlTnP","start_time":1604952240,"bandwidth":718534},{"service_id":"5vrXMNWaz9itI17TrjlTnP","start_time":1604952300,"bandwidth":810065},{"service_id":"5vrXMNWaz9itI17TrjlTnP","start_time":1604952360,"bandwidth":596670},{"service_id":"5vrXMNWaz9itI17TrjlTnP","start_time":1604952420,"bandwidth":352663},{"service_id":"5vrXMNWaz9itI17TrjlTnP","start_time":1604952480,"bandwidth":161102},{"service_id":"5vrXMNWaz9itI17TrjlTnP","start_time":1604952540,"bandwidth":292549},{"service_id":"5vrXMNWaz9itI17TrjlTnP","start_time":1604952600,"bandwidth":560729},{"service_id":"5vrXMNWaz9itI17TrjlTnP","start_time":1604952660,"bandwidth":791598},{"service_id":"5vrXMNWaz9itI17TrjlTnP","start_time":1604952720,"bandwidth":1234865},{"service_id":"5vrXMNWaz9itI17TrjlTnP","start_time":1604952780,"bandwidth":1122753},{"service_id":"5vrXMNWaz9itI17TrjlTnP","start_time":1604952840,"bandwidth":773572},{"service_id":"5vrXMNWaz9itI17TrjlTnP","start_time":1604952900,"bandwidth":651959},{"service_id":"5vrXMNWaz9itI17TrjlTnP","start_time":1604952960,"bandwidth":638604},{"service_id":"5vrXMNWaz9itI17TrjlTnP","start_time":1604953020,"bandwidth":927932},{"service_id":"5vrXMNWaz9itI17TrjlTnP","start_time":1604953080,"bandwidth":882513},{"service_id":"5vrXMNWaz9itI17TrjlTnP","start_time":1604953140,"bandwidth":761212},{"service_id":"5vrXMNWaz9itI17TrjlTnP","start_time":1604953200,"bandwidth":602604},{"service_id":"5vrXMNWaz9itI17TrjlTnP","start_time":1604953260,"bandwidth":212520},{"service_id":"5vrXMNWaz9itI17TrjlTnP","start_time":1604953320,"bandwidth":290090},{"service_id":"5vrXMNWaz9itI17TrjlTnP","start_time":1604953380,"bandwidth":325238},{"service_id":"5vrXMNWaz9itI17TrjlTnP","start_time":1604953440,"bandwidth":305095},{"service_id":"5vrXMNWaz9itI17TrjlTnP","start_time":1604953500,"bandwidth":216805},{"service_id":"5vrXMNWaz9itI17TrjlTnP","start_time":1604953800,"bandwidth":292997},{"service_id":"5vrXMNWaz9itI17TrjlTnP","start_time":1604953860,"bandwidth":306657},{"service_id":"5vrXMNWaz9itI17TrjlTnP","start_time":1604953920,"bandwidth":472386},{"service_id":"5vrXMNWaz9itI17TrjlTnP","start_time":1604953980,"bandwidth":506157},{"service_id":"5vrXMNWaz9itI17TrjlTnP","start_time":1604954040,"bandwidth":606538},{"service_id":"5vrXMNWaz9itI17TrjlTnP","start_time":1604954100,"bandwidth":504235},{"service_id":"5vrXMNWaz9itI17TrjlTnP","start_time":1604954160,"bandwidth":364418},{"service_id":"5vrXMNWaz9itI17TrjlTnP","start_time":1604954220,"bandwidth":311422},{"service_id":"5vrXMNWaz9itI17TrjlTnP","start_time":1604954280,"bandwidth":178463},{"service_id":"5vrXMNWaz9itI17TrjlTnP","start_time":1604954340,"bandwidth":1662},{"service_id":"5vrXMNWaz9itI17TrjlTnP","start_time":1604955240,"bandwidth":205469},{"service_id":"5vrXMNWaz9itI17TrjlTnP","start_time":1604955300,"bandwidth":219974}],"60DDadU92S5JbqEJDIvnYE":[{"service_id":"60DDadU92S5JbqEJDIvnYE","start_time":1604951820,"bandwidth":42350378},{"service_id":"60DDadU92S5JbqEJDIvnYE","start_time":1604951880,"bandwidth":40650856},{"service_id":"60DDadU92S5JbqEJDIvnYE","start_time":1604951940,"bandwidth":30676942},{"service_id":"60DDadU92S5JbqEJDIvnYE","start_time":1604952000,"bandwidth":25505139},{"service_id":"60DDadU92S5JbqEJDIvnYE","start_time":1604952060,"bandwidth":33139081},{"service_id":"60DDadU92S5JbqEJDIvnYE","start_time":1604952120,"bandwidth":35843909},{"service_id":"60DDadU92S5JbqEJDIvnYE","start_time":1604952180,"bandwidth":45726237},{"service_id":"60DDadU92S5JbqEJDIvnYE","start_time":1604952240,"bandwidth":47853334},{"service_id":"60DDadU92S5JbqEJDIvnYE","start_time":1604952300,"bandwidth":41166647},{"service_id":"60DDadU92S5JbqEJDIvnYE","start_time":1604952360,"bandwidth":39271543},{"service_id":"60DDadU92S5JbqEJDIvnYE","start_time":1604952420,"bandwidth":46486977},{"service_id":"60DDadU92S5JbqEJDIvnYE","start_time":1604952480,"bandwidth":50371062},{"service_id":"60DDadU92S5JbqEJDIvnYE","start_time":1604952540,"bandwidth":42689056},{"service_id":"60DDadU92S5JbqEJDIvnYE","start_time":1604952600,"bandwidth":36230045},{"service_id":"60DDadU92S5JbqEJDIvnYE","start_time":1604952660,"bandwidth":46021769},{"service_id":"60DDadU92S5JbqEJDIvnYE","start_time":1604952720,"bandwidth":49086660},{"service_id":"60DDadU92S5JbqEJDIvnYE","start_time":1604952780,"bandwidth":58160197},{"service_id":"60DDadU92S5JbqEJDIvnYE","start_time":1604952840,"bandwidth":46111559},{"service_id":"60DDadU92S5JbqEJDIvnYE","start_time":1604952900,"bandwidth":41918810},{"service_id":"60DDadU92S5JbqEJDIvnYE","start_time":1604952960,"bandwidth":45969546},{"service_id":"60DDadU92S5JbqEJDIvnYE","start_time":1604953020,"bandwidth":44449437},{"service_id":"60DDadU92S5JbqEJDIvnYE","start_time":1604953080,"bandwidth":36951375},{"service_id":"60DDadU92S5JbqEJDIvnYE","start_time":1604953140,"bandwidth":32115420},{"service_id":"60DDadU92S5JbqEJDIvnYE","start_time":1604953200,"bandwidth":21005072},{"service_id":"60DDadU92S5JbqEJDIvnYE","start_time":1604953260,"bandwidth":20248124},{"service_id":"60DDadU92S5JbqEJDIvnYE","start_time":1604953320,"bandwidth":26073619},{"service_id":"60DDadU92S5JbqEJDIvnYE","start_time":1604953380,"bandwidth":33282783},{"service_id":"60DDadU92S5JbqEJDIvnYE","start_time":1604953440,"bandwidth":29521538},{"service_id":"60DDadU92S5JbqEJDIvnYE","start_time":1604953500,"bandwidth":33334516},{"service_id":"60DDadU92S5JbqEJDIvnYE","start_time":1604953560,"bandwidth":40309920},{"service_id":"60DDadU92S5JbqEJDIvnYE","start_time":1604953620,"bandwidth":45809901},{"service_id":"60DDadU92S5JbqEJDIvnYE","start_time":1604953680,"bandwidth":41269886},{"service_id":"60DDadU92S5JbqEJDIvnYE","start_time":1604953740,"bandwidth":31137633},{"service_id":"60DDadU92S5JbqEJDIvnYE","start_time":1604953800,"bandwidth":25299488},{"service_id":"60DDadU92S5JbqEJDIvnYE","start_time":1604953860,"bandwidth":33335800},{"service_id":"60DDadU92S5JbqEJDIvnYE","start_time":1604953920,"bandwidth":36013256},{"service_id":"60DDadU92S5JbqEJDIvnYE","start_time":1604953980,"bandwidth":47427291},{"service_id":"60DDadU92S5JbqEJDIvnYE","start_time":1604954040,"bandwidth":48562534},{"service_id":"60DDadU92S5JbqEJDIvnYE","start_time":1604954100,"bandwidth":42023345},{"service_id":"60DDadU92S5JbqEJDIvnYE","start_time":1604954160,"bandwidth":37872117},{"service_id":"60DDadU92S5JbqEJDIvnYE","start_time":1604954220,"bandwidth":47548430},{"service_id":"60DDadU92S5JbqEJDIvnYE","start_time":1604954280,"bandwidth":49813613},{"service_id":"60DDadU92S5JbqEJDIvnYE","start_time":1604954340,"bandwidth":38512506},{"service_id":"60DDadU92S5JbqEJDIvnYE","start_time":1604954400,"bandwidth":36558509},{"service_id":"60DDadU92S5JbqEJDIvnYE","start_time":1604954460,"bandwidth":44377871},{"service_id":"60DDadU92S5JbqEJDIvnYE","start_time":1604954520,"bandwidth":48341925},{"service_id":"60DDadU92S5JbqEJDIvnYE","start_time":1604954580,"bandwidth":58167034},{"service_id":"60DDadU92S5JbqEJDIvnYE","start_time":1604954640,"bandwidth":48072848},{"service_id":"60DDadU92S5JbqEJDIvnYE","start_time":1604954700,"bandwidth":45998604},{"service_id":"60DDadU92S5JbqEJDIvnYE","start_time":1604954760,"bandwidth":46137844},{"service_id":"60DDadU92S5JbqEJDIvnYE","start_time":1604954820,"bandwidth":46345382},{"service_id":"60DDadU92S5JbqEJDIvnYE","start_time":1604954880,"bandwidth":37747269},{"service_id":"60DDadU92S5JbqEJDIvnYE","start_time":1604954940,"bandwidth":33089327},{"service_id":"60DDadU92S5JbqEJDIvnYE","start_time":1604955000,"bandwidth":22189620},{"service_id":"60DDadU92S5JbqEJDIvnYE","start_time":1604955060,"bandwidth":21252459},{"service_id":"60DDadU92S5JbqEJDIvnYE","start_time":1604955120,"bandwidth":25264828},{"service_id":"60DDadU92S5JbqEJDIvnYE","start_time":1604955180,"bandwidth":33737020},{"service_id":"60DDadU92S5JbqEJDIvnYE","start_time":1604955240,"bandwidth":30265853},{"service_id":"60DDadU92S5JbqEJDIvnYE","start_time":1604955300,"bandwidth":34210745}],"65XA7H1AJsCGb4dhW1HBEk":[{"service_id":"65XA7H1AJsCGb4dhW1HBEk","start_time":1604953080,"bandwidth":6036},{"service_id":"65XA7H1AJsCGb4dhW1HBEk","start_time":1604955060,"bandwidth":5430407}],"69lb4WKsyEnVtEScZRPPaq":[{"service_id":"69lb4WKsyEnVtEScZRPPaq","start_time":1604951820,"bandwidth":348167752},{"service_id":"69lb4WKsyEnVtEScZRPPaq","start_time":1604951880,"bandwidth":352162769},{"service_id":"69lb4WKsyEnVtEScZRPPaq","start_time":1604951940,"bandwidth":344751551},{"service_id":"69lb4WKsyEnVtEScZRPPaq","start_time":1604952000,"bandwidth":364460043},{"service_id":"69lb4WKsyEnVtEScZRPPaq","start_time":1604952060,"bandwidth":361424814},{"service_id":"69lb4WKsyEnVtEScZRPPaq","start_time":1604952120,"bandwidth":347764784},{"service_id":"69lb4WKsyEnVtEScZRPPaq","start_time":1604952180,"bandwidth":360212568},{"service_id":"69lb4WKsyEnVtEScZRPPaq","start_time":1604952240,"bandwidth":361016245},{"service_id":"69lb4WKsyEnVtEScZRPPaq","start_time":1604952300,"bandwidth":345343375},{"service_id":"69lb4WKsyEnVtEScZRPPaq","start_time":1604952360,"bandwidth":348213827},{"service_id":"69lb4WKsyEnVtEScZRPPaq","start_time":1604952420,"bandwidth":358547625},{"service_id":"69lb4WKsyEnVtEScZRPPaq","start_time":1604952480,"bandwidth":353135855},{"service_id":"69lb4WKsyEnVtEScZRPPaq","start_time":1604952540,"bandwidth":353364775},{"service_id":"69lb4WKsyEnVtEScZRPPaq","start_time":1604952600,"bandwidth":350677941},{"service_id":"69lb4WKsyEnVtEScZRPPaq","start_time":1604952660,"bandwidth":349575806},{"service_id":"69lb4WKsyEnVtEScZRPPaq","start_time":1604952720,"bandwidth":357599787},{"service_id":"69lb4WKsyEnVtEScZRPPaq","start_time":1604952780,"bandwidth":332715685},{"service_id":"69lb4WKsyEnVtEScZRPPaq","start_time":1604952840,"bandwidth":339949512},{"service_id":"69lb4WKsyEnVtEScZRPPaq","start_time":1604952900,"bandwidth":332910586},{"service_id":"69lb4WKsyEnVtEScZRPPaq","start_time":1604952960,"bandwidth":341930197},{"service_id":"69lb4WKsyEnVtEScZRPPaq","start_time":1604953020,"bandwidth":335538730},{"service_id":"69lb4WKsyEnVtEScZRPPaq","start_time":1604953080,"bandwidth":344856390},{"service_id":"69lb4WKsyEnVtEScZRPPaq","start_time":1604953140,"bandwidth":342923773},{"service_id":"69lb4WKsyEnVtEScZRPPaq","start_time":1604953200,"bandwidth":344382983},{"service_id":"69lb4WKsyEnVtEScZRPPaq","start_time":1604953260,"bandwidth":347646395},{"service_id":"69lb4WKsyEnVtEScZRPPaq","start_time":1604953320,"bandwidth":337178400},{"service_id":"69lb4WKsyEnVtEScZRPPaq","start_time":1604953380,"bandwidth":341217409},{"service_id":"69lb4WKsyEnVtEScZRPPaq","start_time":1604953440,"bandwidth":329802770},{"service_id":"69lb4WKsyEnVtEScZRPPaq","start_time":1604953500,"bandwidth":343095693},{"service_id":"69lb4WKsyEnVtEScZRPPaq","start_time":1604953560,"bandwidth":337970088},{"service_id":"69lb4WKsyEnVtEScZRPPaq","start_time":1604953620,"bandwidth":324492115},{"service_id":"69lb4WKsyEnVtEScZRPPaq","start_time":1604953680,"bandwidth":321699674},{"service_id":"69lb4WKsyEnVtEScZRPPaq","start_time":1604953740,"bandwidth":333045044},{"service_id":"69lb4WKsyEnVtEScZRPPaq","start_time":1604953800,"bandwidth":334602279},{"service_id":"69lb4WKsyEnVtEScZRPPaq","start_time":1604953860,"bandwidth":335781468},{"service_id":"69lb4WKsyEnVtEScZRPPaq","start_time":1604953920,"bandwidth":336066637},{"service_id":"69lb4WKsyEnVtEScZRPPaq","start_time":1604953980,"bandwidth":334140098},{"service_id":"69lb4WKsyEnVtEScZRPPaq","start_time":1604954040,"bandwidth":321873684},{"service_id":"69lb4WKsyEnVtEScZRPPaq","start_time":1604954100,"bandwidth":330624779},{"service_id":"69lb4WKsyEnVtEScZRPPaq","start_time":1604954160,"bandwidth":334811342},{"service_id":"69lb4WKsyEnVtEScZRPPaq","start_time":1604954220,"bandwidth":330420481},{"service_id":"69lb4WKsyEnVtEScZRPPaq","start_time":1604954280,"bandwidth":329787248},{"service_id":"69lb4WKsyEnVtEScZRPPaq","start_time":1604954340,"bandwidth":327105565},{"service_id":"69lb4WKsyEnVtEScZRPPaq","start_time":1604954400,"bandwidth":330764499},{"service_id":"69lb4WKsyEnVtEScZRPPaq","start_time":1604954460,"bandwidth":330533182},{"service_id":"69lb4WKsyEnVtEScZRPPaq","start_time":1604954520,"bandwidth":324345638},{"service_id":"69lb4WKsyEnVtEScZRPPaq","start_time":1604954580,"bandwidth":322299203},{"service_id":"69lb4WKsyEnVtEScZRPPaq","start_time":1604954640,"bandwidth":325189937},{"service_id":"69lb4WKsyEnVtEScZRPPaq","start_time":1604954700,"bandwidth":329203399},{"service_id":"69lb4WKsyEnVtEScZRPPaq","start_time":1604954760,"bandwidth":327590095},{"service_id":"69lb4WKsyEnVtEScZRPPaq","start_time":1604954820,"bandwidth":327507236},{"service_id":"69lb4WKsyEnVtEScZRPPaq","start_time":1604954880,"bandwidth":309958199},{"service_id":"69lb4WKsyEnVtEScZRPPaq","start_time":1604954940,"bandwidth":318014873},{"service_id":"69lb4WKsyEnVtEScZRPPaq","start_time":1604955000,"bandwidth":318284641},{"service_id":"69lb4WKsyEnVtEScZRPPaq","start_time":1604955060,"bandwidth":322403146},{"service_id":"69lb4WKsyEnVtEScZRPPaq","start_time":1604955120,"bandwidth":323329747},{"service_id":"69lb4WKsyEnVtEScZRPPaq","start_time":1604955180,"bandwidth":314535454},{"service_id":"69lb4WKsyEnVtEScZRPPaq","start_time":1604955240,"bandwidth":304142532},{"service_id":"69lb4WKsyEnVtEScZRPPaq","start_time":1604955300,"bandwidth":303553100}],"6Nwb2Zsdhd3Rx7Z9kTagtv":[{"service_id":"6Nwb2Zsdhd3Rx7Z9kTagtv","start_time":1604951820,"bandwidth":21559},{"service_id":"6Nwb2Zsdhd3Rx7Z9kTagtv","start_time":1604953080,"bandwidth":310240},{"service_id":"6Nwb2Zsdhd3Rx7Z9kTagtv","start_time":1604953140,"bandwidth":270564},{"service_id":"6Nwb2Zsdhd3Rx7Z9kTagtv","start_time":1604953200,"bandwidth":67470},{"service_id":"6Nwb2Zsdhd3Rx7Z9kTagtv","start_time":1604953380,"bandwidth":15292},{"service_id":"6Nwb2Zsdhd3Rx7Z9kTagtv","start_time":1604953680,"bandwidth":360738},{"service_id":"6Nwb2Zsdhd3Rx7Z9kTagtv","start_time":1604953800,"bandwidth":216079},{"service_id":"6Nwb2Zsdhd3Rx7Z9kTagtv","start_time":1604953860,"bandwidth":151528},{"service_id":"6Nwb2Zsdhd3Rx7Z9kTagtv","start_time":1604953920,"bandwidth":117188},{"service_id":"6Nwb2Zsdhd3Rx7Z9kTagtv","start_time":1604953980,"bandwidth":113952},{"service_id":"6Nwb2Zsdhd3Rx7Z9kTagtv","start_time":1604954040,"bandwidth":162273},{"service_id":"6Nwb2Zsdhd3Rx7Z9kTagtv","start_time":1604954100,"bandwidth":589395},{"service_id":"6Nwb2Zsdhd3Rx7Z9kTagtv","start_time":1604954160,"bandwidth":385437},{"service_id":"6Nwb2Zsdhd3Rx7Z9kTagtv","start_time":1604954220,"bandwidth":303241},{"service_id":"6Nwb2Zsdhd3Rx7Z9kTagtv","start_time":1604954280,"bandwidth":123228},{"service_id":"6Nwb2Zsdhd3Rx7Z9kTagtv","start_time":1604954340,"bandwidth":110424},{"service_id":"6Nwb2Zsdhd3Rx7Z9kTagtv","start_time":1604954400,"bandwidth":83760},{"service_id":"6Nwb2Zsdhd3Rx7Z9kTagtv","start_time":1604954520,"bandwidth":438281},{"service_id":"6Nwb2Zsdhd3Rx7Z9kTagtv","start_time":1604954580,"bandwidth":172462},{"service_id":"6Nwb2Zsdhd3Rx7Z9kTagtv","start_time":1604954640,"bandwidth":147473},{"service_id":"6Nwb2Zsdhd3Rx7Z9kTagtv","start_time":1604954820,"bandwidth":2440},{"service_id":"6Nwb2Zsdhd3Rx7Z9kTagtv","start_time":1604954940,"bandwidth":944603}],"6Of0F2vDQpLM0NNQmhqkxL":[{"service_id":"6Of0F2vDQpLM0NNQmhqkxL","start_time":1604952540,"bandwidth":2703}],"6e1bQ8wPg2nPrX27CKuYqS":[{"service_id":"6e1bQ8wPg2nPrX27CKuYqS","start_time":1604951820,"bandwidth":0},{"service_id":"6e1bQ8wPg2nPrX27CKuYqS","start_time":1604951880,"bandwidth":0},{"service_id":"6e1bQ8wPg2nPrX27CKuYqS","start_time":1604951940,"bandwidth":0},{"service_id":"6e1bQ8wPg2nPrX27CKuYqS","start_time":1604952000,"bandwidth":0},{"service_id":"6e1bQ8wPg2nPrX27CKuYqS","start_time":1604952060,"bandwidth":0},{"service_id":"6e1bQ8wPg2nPrX27CKuYqS","start_time":1604952120,"bandwidth":0},{"service_id":"6e1bQ8wPg2nPrX27CKuYqS","start_time":1604952180,"bandwidth":0},{"service_id":"6e1bQ8wPg2nPrX27CKuYqS","start_time":1604952240,"bandwidth":0},{"service_id":"6e1bQ8wPg2nPrX27CKuYqS","start_time":1604952300,"bandwidth":0},{"service_id":"6e1bQ8wPg2nPrX27CKuYqS","start_time":1604952360,"bandwidth":0},{"service_id":"6e1bQ8wPg2nPrX27CKuYqS","start_time":1604952420,"bandwidth":0},{"service_id":"6e1bQ8wPg2nPrX27CKuYqS","start_time":1604952480,"bandwidth":0},{"service_id":"6e1bQ8wPg2nPrX27CKuYqS","start_time":1604952540,"bandwidth":0},{"service_id":"6e1bQ8wPg2nPrX27CKuYqS","start_time":1604952600,"bandwidth":0},{"service_id":"6e1bQ8wPg2nPrX27CKuYqS","start_time":1604952660,"bandwidth":0},{"service_id":"6e1bQ8wPg2nPrX27CKuYqS","start_time":1604952720,"bandwidth":0},{"service_id":"6e1bQ8wPg2nPrX27CKuYqS","start_time":1604952780,"bandwidth":0},{"service_id":"6e1bQ8wPg2nPrX27CKuYqS","start_time":1604952840,"bandwidth":0},{"service_id":"6e1bQ8wPg2nPrX27CKuYqS","start_time":1604952900,"bandwidth":0},{"service_id":"6e1bQ8wPg2nPrX27CKuYqS","start_time":1604952960,"bandwidth":0},{"service_id":"6e1bQ8wPg2nPrX27CKuYqS","start_time":1604953020,"bandwidth":0},{"service_id":"6e1bQ8wPg2nPrX27CKuYqS","start_time":1604953080,"bandwidth":0},{"service_id":"6e1bQ8wPg2nPrX27CKuYqS","start_time":1604953140,"bandwidth":0},{"service_id":"6e1bQ8wPg2nPrX27CKuYqS","start_time":1604953200,"bandwidth":0},{"service_id":"6e1bQ8wPg2nPrX27CKuYqS","start_time":1604953260,"bandwidth":0},{"service_id":"6e1bQ8wPg2nPrX27CKuYqS","start_time":1604953320,"bandwidth":0},{"service_id":"6e1bQ8wPg2nPrX27CKuYqS","start_time":1604953380,"bandwidth":0},{"service_id":"6e1bQ8wPg2nPrX27CKuYqS","start_time":1604953440,"bandwidth":0},{"service_id":"6e1bQ8wPg2nPrX27CKuYqS","start_time":1604953500,"bandwidth":0},{"service_id":"6e1bQ8wPg2nPrX27CKuYqS","start_time":1604953560,"bandwidth":0},{"service_id":"6e1bQ8wPg2nPrX27CKuYqS","start_time":1604953620,"bandwidth":0},{"service_id":"6e1bQ8wPg2nPrX27CKuYqS","start_time":1604953680,"bandwidth":0},{"service_id":"6e1bQ8wPg2nPrX27CKuYqS","start_time":1604953740,"bandwidth":0},{"service_id":"6e1bQ8wPg2nPrX27CKuYqS","start_time":1604953800,"bandwidth":0},{"service_id":"6e1bQ8wPg2nPrX27CKuYqS","start_time":1604953860,"bandwidth":0},{"service_id":"6e1bQ8wPg2nPrX27CKuYqS","start_time":1604953920,"bandwidth":0},{"service_id":"6e1bQ8wPg2nPrX27CKuYqS","start_time":1604953980,"bandwidth":0},{"service_id":"6e1bQ8wPg2nPrX27CKuYqS","start_time":1604954040,"bandwidth":0},{"service_id":"6e1bQ8wPg2nPrX27CKuYqS","start_time":1604954100,"bandwidth":0},{"service_id":"6e1bQ8wPg2nPrX27CKuYqS","start_time":1604954160,"bandwidth":0},{"service_id":"6e1bQ8wPg2nPrX27CKuYqS","start_time":1604954220,"bandwidth":0},{"service_id":"6e1bQ8wPg2nPrX27CKuYqS","start_time":1604954280,"bandwidth":0},{"service_id":"6e1bQ8wPg2nPrX27CKuYqS","start_time":1604954340,"bandwidth":0},{"service_id":"6e1bQ8wPg2nPrX27CKuYqS","start_time":1604954400,"bandwidth":0},{"service_id":"6e1bQ8wPg2nPrX27CKuYqS","start_time":1604954460,"bandwidth":0},{"service_id":"6e1bQ8wPg2nPrX27CKuYqS","start_time":1604954520,"bandwidth":0},{"service_id":"6e1bQ8wPg2nPrX27CKuYqS","start_time":1604954580,"bandwidth":0},{"service_id":"6e1bQ8wPg2nPrX27CKuYqS","start_time":1604954640,"bandwidth":0},{"service_id":"6e1bQ8wPg2nPrX27CKuYqS","start_time":1604954700,"bandwidth":0},{"service_id":"6e1bQ8wPg2nPrX27CKuYqS","start_time":1604954760,"bandwidth":0},{"service_id":"6e1bQ8wPg2nPrX27CKuYqS","start_time":1604954820,"bandwidth":0},{"service_id":"6e1bQ8wPg2nPrX27CKuYqS","start_time":1604954880,"bandwidth":0},{"service_id":"6e1bQ8wPg2nPrX27CKuYqS","start_time":1604954940,"bandwidth":0},{"service_id":"6e1bQ8wPg2nPrX27CKuYqS","start_time":1604955000,"bandwidth":0},{"service_id":"6e1bQ8wPg2nPrX27CKuYqS","start_time":1604955060,"bandwidth":0},{"service_id":"6e1bQ8wPg2nPrX27CKuYqS","start_time":1604955120,"bandwidth":0},{"service_id":"6e1bQ8wPg2nPrX27CKuYqS","start_time":1604955180,"bandwidth":0},{"service_id":"6e1bQ8wPg2nPrX27CKuYqS","start_time":1604955240,"bandwidth":0},{"service_id":"6e1bQ8wPg2nPrX27CKuYqS","start_time":1604955300,"bandwidth":0}],"6tY0pHJ7JtYETE4Ualpe1t":[{"service_id":"6tY0pHJ7JtYETE4Ualpe1t","start_time":1604951880,"bandwidth":778}],"6vSkwcl2AOm9fED8Ofv6wP":[{"service_id":"6vSkwcl2AOm9fED8Ofv6wP","start_time":1604951880,"bandwidth":3553810},{"service_id":"6vSkwcl2AOm9fED8Ofv6wP","start_time":1604952360,"bandwidth":114120},{"service_id":"6vSkwcl2AOm9fED8Ofv6wP","start_time":1604953740,"bandwidth":114168},{"service_id":"6vSkwcl2AOm9fED8Ofv6wP","start_time":1604954640,"bandwidth":1713}],"6xvc9iYYDfem0c7xbpVQMH":[{"service_id":"6xvc9iYYDfem0c7xbpVQMH","start_time":1604951820,"bandwidth":173872},{"service_id":"6xvc9iYYDfem0c7xbpVQMH","start_time":1604951940,"bandwidth":2543},{"service_id":"6xvc9iYYDfem0c7xbpVQMH","start_time":1604952000,"bandwidth":126800},{"service_id":"6xvc9iYYDfem0c7xbpVQMH","start_time":1604952060,"bandwidth":286227},{"service_id":"6xvc9iYYDfem0c7xbpVQMH","start_time":1604952120,"bandwidth":33213455},{"service_id":"6xvc9iYYDfem0c7xbpVQMH","start_time":1604952180,"bandwidth":23566410},{"service_id":"6xvc9iYYDfem0c7xbpVQMH","start_time":1604952240,"bandwidth":909881},{"service_id":"6xvc9iYYDfem0c7xbpVQMH","start_time":1604952300,"bandwidth":218363},{"service_id":"6xvc9iYYDfem0c7xbpVQMH","start_time":1604952360,"bandwidth":18959972},{"service_id":"6xvc9iYYDfem0c7xbpVQMH","start_time":1604952420,"bandwidth":69816784},{"service_id":"6xvc9iYYDfem0c7xbpVQMH","start_time":1604952480,"bandwidth":196586},{"service_id":"6xvc9iYYDfem0c7xbpVQMH","start_time":1604952540,"bandwidth":66800308},{"service_id":"6xvc9iYYDfem0c7xbpVQMH","start_time":1604952600,"bandwidth":1282482},{"service_id":"6xvc9iYYDfem0c7xbpVQMH","start_time":1604952660,"bandwidth":351592},{"service_id":"6xvc9iYYDfem0c7xbpVQMH","start_time":1604952900,"bandwidth":119325},{"service_id":"6xvc9iYYDfem0c7xbpVQMH","start_time":1604952960,"bandwidth":169420},{"service_id":"6xvc9iYYDfem0c7xbpVQMH","start_time":1604953020,"bandwidth":214065},{"service_id":"6xvc9iYYDfem0c7xbpVQMH","start_time":1604953080,"bandwidth":206341},{"service_id":"6xvc9iYYDfem0c7xbpVQMH","start_time":1604953140,"bandwidth":254675},{"service_id":"6xvc9iYYDfem0c7xbpVQMH","start_time":1604953200,"bandwidth":230203},{"service_id":"6xvc9iYYDfem0c7xbpVQMH","start_time":1604953260,"bandwidth":195618},{"service_id":"6xvc9iYYDfem0c7xbpVQMH","start_time":1604953320,"bandwidth":195611},{"service_id":"6xvc9iYYDfem0c7xbpVQMH","start_time":1604953380,"bandwidth":160935},{"service_id":"6xvc9iYYDfem0c7xbpVQMH","start_time":1604953440,"bandwidth":212439},{"service_id":"6xvc9iYYDfem0c7xbpVQMH","start_time":1604953500,"bandwidth":60895},{"service_id":"6xvc9iYYDfem0c7xbpVQMH","start_time":1604953800,"bandwidth":137241},{"service_id":"6xvc9iYYDfem0c7xbpVQMH","start_time":1604953860,"bandwidth":199954},{"service_id":"6xvc9iYYDfem0c7xbpVQMH","start_time":1604953920,"bandwidth":11746502},{"service_id":"6xvc9iYYDfem0c7xbpVQMH","start_time":1604953980,"bandwidth":76931815},{"service_id":"6xvc9iYYDfem0c7xbpVQMH","start_time":1604954040,"bandwidth":232627},{"service_id":"6xvc9iYYDfem0c7xbpVQMH","start_time":1604954100,"bandwidth":66790088},{"service_id":"6xvc9iYYDfem0c7xbpVQMH","start_time":1604954160,"bandwidth":197876},{"service_id":"6xvc9iYYDfem0c7xbpVQMH","start_time":1604954220,"bandwidth":208194},{"service_id":"6xvc9iYYDfem0c7xbpVQMH","start_time":1604954280,"bandwidth":213516},{"service_id":"6xvc9iYYDfem0c7xbpVQMH","start_time":1604954340,"bandwidth":238671},{"service_id":"6xvc9iYYDfem0c7xbpVQMH","start_time":1604954400,"bandwidth":58433},{"service_id":"6xvc9iYYDfem0c7xbpVQMH","start_time":1604954460,"bandwidth":2552},{"service_id":"6xvc9iYYDfem0c7xbpVQMH","start_time":1604954520,"bandwidth":2904},{"service_id":"6xvc9iYYDfem0c7xbpVQMH","start_time":1604954640,"bandwidth":4412},{"service_id":"6xvc9iYYDfem0c7xbpVQMH","start_time":1604954700,"bandwidth":106683},{"service_id":"6xvc9iYYDfem0c7xbpVQMH","start_time":1604954760,"bandwidth":192931},{"service_id":"6xvc9iYYDfem0c7xbpVQMH","start_time":1604954820,"bandwidth":218486},{"service_id":"6xvc9iYYDfem0c7xbpVQMH","start_time":1604954880,"bandwidth":208924},{"service_id":"6xvc9iYYDfem0c7xbpVQMH","start_time":1604954940,"bandwidth":209402},{"service_id":"6xvc9iYYDfem0c7xbpVQMH","start_time":1604955000,"bandwidth":184538},{"service_id":"6xvc9iYYDfem0c7xbpVQMH","start_time":1604955060,"bandwidth":181144},{"service_id":"6xvc9iYYDfem0c7xbpVQMH","start_time":1604955120,"bandwidth":215072},{"service_id":"6xvc9iYYDfem0c7xbpVQMH","start_time":1604955180,"bandwidth":211732},{"service_id":"6xvc9iYYDfem0c7xbpVQMH","start_time":1604955240,"bandwidth":237688},{"service_id":"6xvc9iYYDfem0c7xbpVQMH","start_time":1604955300,"bandwidth":45760}],"7HTStZdokK2tTgRbMHY9xO":[{"service_id":"7HTStZdokK2tTgRbMHY9xO","start_time":1604951880,"bandwidth":988830},{"service_id":"7HTStZdokK2tTgRbMHY9xO","start_time":1604954640,"bandwidth":1242}],"CI2LkXSZslPkSEUkCxgt3":[{"service_id":"CI2LkXSZslPkSEUkCxgt3","start_time":1604952060,"bandwidth":322},{"service_id":"CI2LkXSZslPkSEUkCxgt3","start_time":1604954040,"bandwidth":426}],"F0KYAkWMIAVHfGkrYYuj3":[{"service_id":"F0KYAkWMIAVHfGkrYYuj3","start_time":1604952120,"bandwidth":582431},{"service_id":"F0KYAkWMIAVHfGkrYYuj3","start_time":1604952420,"bandwidth":46121},{"service_id":"F0KYAkWMIAVHfGkrYYuj3","start_time":1604952660,"bandwidth":536368},{"service_id":"F0KYAkWMIAVHfGkrYYuj3","start_time":1604952720,"bandwidth":46122},{"service_id":"F0KYAkWMIAVHfGkrYYuj3","start_time":1604953020,"bandwidth":582431},{"service_id":"F0KYAkWMIAVHfGkrYYuj3","start_time":1604953320,"bandwidth":46121},{"service_id":"F0KYAkWMIAVHfGkrYYuj3","start_time":1604953680,"bandwidth":559429},{"service_id":"F0KYAkWMIAVHfGkrYYuj3","start_time":1604953920,"bandwidth":536310},{"service_id":"F0KYAkWMIAVHfGkrYYuj3","start_time":1604953980,"bandwidth":46121},{"service_id":"F0KYAkWMIAVHfGkrYYuj3","start_time":1604954280,"bandwidth":46121},{"service_id":"F0KYAkWMIAVHfGkrYYuj3","start_time":1604954580,"bandwidth":46121},{"service_id":"F0KYAkWMIAVHfGkrYYuj3","start_time":1604954640,"bandwidth":536368},{"service_id":"F0KYAkWMIAVHfGkrYYuj3","start_time":1604954820,"bandwidth":23209},{"service_id":"F0KYAkWMIAVHfGkrYYuj3","start_time":1604954880,"bandwidth":513101},{"service_id":"F0KYAkWMIAVHfGkrYYuj3","start_time":1604954940,"bandwidth":46121},{"service_id":"F0KYAkWMIAVHfGkrYYuj3","start_time":1604955240,"bandwidth":46121}],"Itqvn0vpOBp2s7uIrNmmz":[{"service_id":"Itqvn0vpOBp2s7uIrNmmz","start_time":1604952240,"bandwidth":25472},{"service_id":"Itqvn0vpOBp2s7uIrNmmz","start_time":1604953140,"bandwidth":25471},{"service_id":"Itqvn0vpOBp2s7uIrNmmz","start_time":1604953560,"bandwidth":25471},{"service_id":"Itqvn0vpOBp2s7uIrNmmz","start_time":1604953980,"bandwidth":25466},{"service_id":"Itqvn0vpOBp2s7uIrNmmz","start_time":1604954460,"bandwidth":25471}],"VlQAy3xUCgger24j2R0Cf":[{"service_id":"VlQAy3xUCgger24j2R0Cf","start_time":1604951820,"bandwidth":140272},{"service_id":"VlQAy3xUCgger24j2R0Cf","start_time":1604951880,"bandwidth":124248},{"service_id":"VlQAy3xUCgger24j2R0Cf","start_time":1604951940,"bandwidth":142130},{"service_id":"VlQAy3xUCgger24j2R0Cf","start_time":1604952000,"bandwidth":127538},{"service_id":"VlQAy3xUCgger24j2R0Cf","start_time":1604952060,"bandwidth":134583},{"service_id":"VlQAy3xUCgger24j2R0Cf","start_time":1604952120,"bandwidth":149465},{"service_id":"VlQAy3xUCgger24j2R0Cf","start_time":1604952180,"bandwidth":138845},{"service_id":"VlQAy3xUCgger24j2R0Cf","start_time":1604952240,"bandwidth":148240},{"service_id":"VlQAy3xUCgger24j2R0Cf","start_time":1604952300,"bandwidth":120008},{"service_id":"VlQAy3xUCgger24j2R0Cf","start_time":1604952360,"bandwidth":139769},{"service_id":"VlQAy3xUCgger24j2R0Cf","start_time":1604952420,"bandwidth":124693},{"service_id":"VlQAy3xUCgger24j2R0Cf","start_time":1604952480,"bandwidth":115288},{"service_id":"VlQAy3xUCgger24j2R0Cf","start_time":1604952540,"bandwidth":131304},{"service_id":"VlQAy3xUCgger24j2R0Cf","start_time":1604952600,"bandwidth":146807},{"service_id":"VlQAy3xUCgger24j2R0Cf","start_time":1604952660,"bandwidth":129893},{"service_id":"VlQAy3xUCgger24j2R0Cf","start_time":1604952720,"bandwidth":176035},{"service_id":"VlQAy3xUCgger24j2R0Cf","start_time":1604952780,"bandwidth":144963},{"service_id":"VlQAy3xUCgger24j2R0Cf","start_time":1604952840,"bandwidth":105904},{"service_id":"VlQAy3xUCgger24j2R0Cf","start_time":1604952900,"bandwidth":124245},{"service_id":"VlQAy3xUCgger24j2R0Cf","start_time":1604952960,"bandwidth":122365},{"service_id":"VlQAy3xUCgger24j2R0Cf","start_time":1604953020,"bandwidth":111993},{"service_id":"VlQAy3xUCgger24j2R0Cf","start_time":1604953080,"bandwidth":125654},{"service_id":"VlQAy3xUCgger24j2R0Cf","start_time":1604953140,"bandwidth":107315},{"service_id":"VlQAy3xUCgger24j2R0Cf","start_time":1604953200,"bandwidth":134880},{"service_id":"VlQAy3xUCgger24j2R0Cf","start_time":1604953260,"bandwidth":112464},{"service_id":"VlQAy3xUCgger24j2R0Cf","start_time":1604953320,"bandwidth":143685},{"service_id":"VlQAy3xUCgger24j2R0Cf","start_time":1604953380,"bandwidth":139256},{"service_id":"VlQAy3xUCgger24j2R0Cf","start_time":1604953440,"bandwidth":120476},{"service_id":"VlQAy3xUCgger24j2R0Cf","start_time":1604953500,"bandwidth":135987},{"service_id":"VlQAy3xUCgger24j2R0Cf","start_time":1604953560,"bandwidth":127532},{"service_id":"VlQAy3xUCgger24j2R0Cf","start_time":1604953620,"bandwidth":141660},{"service_id":"VlQAy3xUCgger24j2R0Cf","start_time":1604953680,"bandwidth":131764},{"service_id":"VlQAy3xUCgger24j2R0Cf","start_time":1604953740,"bandwidth":126116},{"service_id":"VlQAy3xUCgger24j2R0Cf","start_time":1604953800,"bandwidth":153532},{"service_id":"VlQAy3xUCgger24j2R0Cf","start_time":1604953860,"bandwidth":142602},{"service_id":"VlQAy3xUCgger24j2R0Cf","start_time":1604953920,"bandwidth":141183},{"service_id":"VlQAy3xUCgger24j2R0Cf","start_time":1604953980,"bandwidth":112479},{"service_id":"VlQAy3xUCgger24j2R0Cf","start_time":1604954040,"bandwidth":134109},{"service_id":"VlQAy3xUCgger24j2R0Cf","start_time":1604954100,"bandwidth":124244},{"service_id":"VlQAy3xUCgger24j2R0Cf","start_time":1604954160,"bandwidth":153977},{"service_id":"VlQAy3xUCgger24j2R0Cf","start_time":1604954220,"bandwidth":114827},{"service_id":"VlQAy3xUCgger24j2R0Cf","start_time":1604954280,"bandwidth":112890},{"service_id":"VlQAy3xUCgger24j2R0Cf","start_time":1604954340,"bandwidth":140265},{"service_id":"VlQAy3xUCgger24j2R0Cf","start_time":1604954400,"bandwidth":145917},{"service_id":"VlQAy3xUCgger24j2R0Cf","start_time":1604954460,"bandwidth":111535},{"service_id":"VlQAy3xUCgger24j2R0Cf","start_time":1604954520,"bandwidth":129911},{"service_id":"VlQAy3xUCgger24j2R0Cf","start_time":1604954580,"bandwidth":128950},{"service_id":"VlQAy3xUCgger24j2R0Cf","start_time":1604954640,"bandwidth":123777},{"service_id":"VlQAy3xUCgger24j2R0Cf","start_time":1604954700,"bandwidth":122830},{"service_id":"VlQAy3xUCgger24j2R0Cf","start_time":1604954760,"bandwidth":130835},{"service_id":"VlQAy3xUCgger24j2R0Cf","start_time":1604954820,"bandwidth":121239},{"service_id":"VlQAy3xUCgger24j2R0Cf","start_time":1604954880,"bandwidth":119520},{"service_id":"VlQAy3xUCgger24j2R0Cf","start_time":1604954940,"bandwidth":123771},{"service_id":"VlQAy3xUCgger24j2R0Cf","start_time":1604955000,"bandwidth":123282},{"service_id":"VlQAy3xUCgger24j2R0Cf","start_time":1604955060,"bandwidth":131303},{"service_id":"VlQAy3xUCgger24j2R0Cf","start_time":1604955120,"bandwidth":114762},{"service_id":"VlQAy3xUCgger24j2R0Cf","start_time":1604955180,"bandwidth":120006},{"service_id":"VlQAy3xUCgger24j2R0Cf","start_time":1604955240,"bandwidth":135950},{"service_id":"VlQAy3xUCgger24j2R0Cf","start_time":1604955300,"bandwidth":121901}]},"status":"success","msg":null,"meta":{"from":"2020-11-09 + 19:56:27 UTC","to":"2020-11-09 20:56:27 UTC","by":"minute","region":"europe"}}' + headers: + Accept-Ranges: + - bytes + Content-Type: + - application/json + Date: + - Mon, 09 Nov 2020 20:56:29 GMT + Server: + - nginx + Status: + - 200 OK + Strict-Transport-Security: + - max-age=31536000 + Vary: + - Accept-Encoding + Via: + - 1.1 varnish, 1.1 varnish + X-Cache: + - MISS, MISS + X-Cache-Hits: + - 0, 0 + X-Content-Type-Options: + - nosniff + X-Host-Name: + - df-prod-us-central1-timespiral02 + X-Served-By: + - cache-control-slwdc9037-CONTROL-SLWDC, cache-man4138-MAN + X-Timer: + - S1604955387.106640,VS0,VE1903 + status: 200 OK + code: 200 + duration: "" diff --git a/fastly/stats.go b/fastly/stats.go index 26698ef6f..ea2ea0a38 100644 --- a/fastly/stats.go +++ b/fastly/stats.go @@ -102,6 +102,14 @@ type StatsResponse struct { Data []*Stats `mapstructure:"data"` } +// StatsFieldResponse is a response from the service stats/field API endpoint +type StatsFieldResponse struct { + Status string `mapstructure:"status"` + Meta map[string]string `mapstructure:"meta"` + Message string `mapstructure:"msg"` + Data map[string][]*Stats `mapstructure:"data"` +} + // GetStats returns stats data based on GetStatsInput func (c *Client) GetStats(i *GetStatsInput) (*StatsResponse, error) { var resp interface{} @@ -116,6 +124,20 @@ func (c *Client) GetStats(i *GetStatsInput) (*StatsResponse, error) { return sr, nil } +// GetStatsField returns stats field data based on GetStatsInput +func (c *Client) GetStatsField(i *GetStatsInput) (*StatsFieldResponse, error) { + var resp interface{} + if err := c.GetStatsJSON(i, &resp); err != nil { + return nil, err + } + + var sr *StatsFieldResponse + if err := decodeMap(resp, &sr); err != nil { + return nil, err + } + return sr, nil +} + // GetStatsJSON fetches stats and decodes the response directly to the JSON struct dst. func (c *Client) GetStatsJSON(i *GetStatsInput, dst interface{}) error { p := "/stats" diff --git a/fastly/stats_test.go b/fastly/stats_test.go index c206ce3d7..f1ee997d8 100644 --- a/fastly/stats_test.go +++ b/fastly/stats_test.go @@ -20,7 +20,24 @@ func TestClient_GetStats(t *testing.T) { if err != nil { t.Fatal(err) } +} + +func TestClient_GetStats_ByField(t *testing.T) { + t.Parallel() + var err error + record(t, "stats/service_stats_by_field", func(c *Client) { + _, err = c.GetStatsField(&GetStatsInput{ + Field: "bandwidth", + From: "1 hour ago", + To: "now", + By: "minute", + Region: "europe", + }) + }) + if err != nil { + t.Fatal(err) + } } func TestClient_GetStatsJSON(t *testing.T) { From e060da9b01423820d5e290855f8cbe0e301ffbe2 Mon Sep 17 00:00:00 2001 From: integralist Date: Mon, 16 Nov 2020 09:35:17 +0000 Subject: [PATCH 28/37] README consistency with updated field identifiers --- README.md | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index e7ac09c22..5d38e6f4f 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ var serviceID = "SERVICE_ID" // Get the latest active version latest, err := client.LatestVersion(&fastly.LatestVersionInput{ - Service: serviceID, + ServiceID: serviceID, }) if err != nil { log.Fatal(err) @@ -61,8 +61,8 @@ if err != nil { // Clone the latest version so we can make changes without affecting the // active configuration. version, err := client.CloneVersion(&fastly.CloneVersionInput{ - Service: serviceID, - Version: latest.Number, + ServiceID: serviceID, + ServiceVersion: latest.Number, }) if err != nil { log.Fatal(err) @@ -71,9 +71,9 @@ if err != nil { // Now you can make any changes to the new version. In this example, we will add // a new domain. domain, err := client.CreateDomain(&fastly.CreateDomainInput{ - Service: serviceID, - Version: version.Number, - Name: "example.com", + ServiceID: serviceID, + ServiceVersion: version.Number, + Name: "example.com", }) if err != nil { log.Fatal(err) @@ -84,11 +84,11 @@ fmt.Println(domain.Name) // And we will also add a new backend. backend, err := client.CreateBackend(&fastly.CreateBackendInput{ - Service: serviceID, - Version: version.Number, - Name: fastly.String("example-backend"), - Address: fastly.String("127.0.0.1"), - Port: fastly.Uint(80), + ServiceID: serviceID, + ServiceVersion: version.Number, + Name: fastly.String("example-backend"), + Address: fastly.String("127.0.0.1"), + Port: fastly.Uint(80), }) if err != nil { log.Fatal(err) @@ -99,8 +99,8 @@ fmt.Println(backend.Name) // Now we can validate that our version is valid. valid, _, err := client.ValidateVersion(&fastly.ValidateVersionInput{ - Service: serviceID, - Version: version.Number, + ServiceID: serviceID, + ServiceVersion: version.Number, }) if err != nil { log.Fatal(err) @@ -111,8 +111,8 @@ if !valid { // Finally, activate this new version. activeVersion, err := client.ActivateVersion(&fastly.ActivateVersionInput{ - Service: serviceID, - Version: version.Number, + ServiceID: serviceID, + ServiceVersion: version.Number, }) if err != nil { log.Fatal(err) From 498097396f862913dbc4d60f6fe0c39b3bda3da7 Mon Sep 17 00:00:00 2001 From: integralist Date: Mon, 16 Nov 2020 09:49:43 +0000 Subject: [PATCH 29/37] modernize the markdown syntax for defining headers --- README.md | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 5d38e6f4f..a161b2bf6 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -Go Fastly -========= +# Go Fastly + [![Go Documentation](http://img.shields.io/badge/go-documentation-blue.svg?style=flat-square)][godocs] [godocs]: https://pkg.go.dev/github.com/fastly/go-fastly/fastly?tab=doc @@ -7,13 +7,13 @@ Go Fastly Go Fastly is a Golang API client for interacting with most facets of the [Fastly API](https://docs.fastly.com/api). -Installation ------------- +## Installation + This is a client library, so there is nothing to install. But, it uses Go modules, so you must be running Go 1.11 or higher. -Usage ------ +## Usage + Fetch the library: ``` @@ -26,8 +26,8 @@ Import the library into your tool: import "github.com/fastly/go-fastly/fastly" ``` -Examples --------- +## Examples + Fastly's API is designed to work in the following manner: 1. Create (or clone) a new configuration version for the service @@ -127,8 +127,7 @@ fmt.Printf("%t\n", activeVersion.Locked) More information can be found in the [Fastly Godoc][godocs]. -Developing -------- +## Developing 1. Clone the project to your preferred directory, using your preferred method. 2. Download the module and accompanying developer tooling. @@ -144,8 +143,8 @@ Developing $ make all ``` -Testing -------- +## Testing + Go Fastly uses [go-vcr](https://github.com/dnaeon/go-vcr) to "record" and "replay" API request fixtures to improve the speed and portability of integration tests. The test suite uses a single test service ID for all test @@ -198,13 +197,12 @@ unset FASTLY_TEST_SERVICE_ID FASTLY_API_KEY make test ``` -Contributing --------------------------- +## Contributing Refer to [CONTRIBUTING.md](./CONTRIBUTING.md) -License -------- +## License + ``` Copyright 2015 Seth Vargo From b505e72cc2da0778f117279be2a79f6ee2c14fca Mon Sep 17 00:00:00 2001 From: integralist Date: Mon, 16 Nov 2020 09:50:09 +0000 Subject: [PATCH 30/37] add migration notice for v1 to v2 --- README.md | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a161b2bf6..323c72ec7 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,15 @@ Import the library into your tool: import "github.com/fastly/go-fastly/fastly" ``` +## Migrating from v1 to v2 + +The move from major version 1 to 2 as resulted in a couple of fundamental changes to the library: + +- Consistent field name format for `ServiceID`, `ServiceVersion`, `DictionaryID`, `PoolID`. +- Input struct fields (for write/update operations) that are optional (i.e. `omitempty`) and use basic types, are now defined as pointers. + +> Note: [basic types](https://tour.golang.org/basics/11) that are _optional_, must be provided as pointers to avoid unexpected behaviours when dealing with their zero value ([reference](https://willnorris.com/2014/05/go-rest-apis-and-pointers/)). We provide helper functions for this [here](./fastly/basictypes_helper.go). + ## Examples Fastly's API is designed to work in the following manner: @@ -122,8 +131,6 @@ if err != nil { fmt.Printf("%t\n", activeVersion.Locked) ``` -> Note: [basic types](https://tour.golang.org/basics/11) that are _optional_, must be provided as pointers to avoid unexpected behaviours when dealing with their zero value ([reference](https://willnorris.com/2014/05/go-rest-apis-and-pointers/)). We provide helper functions for this [here](./fastly/basictypes_helper.go). - More information can be found in the [Fastly Godoc][godocs]. From 94ea6dfeb5061c60d3c8627cc04be2bc12b90312 Mon Sep 17 00:00:00 2001 From: integralist Date: Mon, 16 Nov 2020 14:55:52 +0000 Subject: [PATCH 31/37] Update README with v1 and v2 tagged releases --- README.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 323c72ec7..3b11a8b8e 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,8 @@ [![Go Documentation](http://img.shields.io/badge/go-documentation-blue.svg?style=flat-square)][godocs] [godocs]: https://pkg.go.dev/github.com/fastly/go-fastly/fastly?tab=doc +[v2]: https://pkg.go.dev/github.com/fastly/go-fastly@v2.0.0/fastly +[v1]: https://pkg.go.dev/github.com/fastly/go-fastly@v1.18.0/fastly Go Fastly is a Golang API client for interacting with most facets of the [Fastly API](https://docs.fastly.com/api). @@ -28,12 +30,14 @@ import "github.com/fastly/go-fastly/fastly" ## Migrating from v1 to v2 -The move from major version 1 to 2 as resulted in a couple of fundamental changes to the library: +The move from major version [1][v1] to [2][v2] has resulted in a couple of fundamental changes to the library: -- Consistent field name format for `ServiceID`, `ServiceVersion`, `DictionaryID`, `PoolID`. +- Consistent field name format for IDs and Versions (e.g. `DictionaryID`, `PoolID`, `ServiceID`, `ServiceVersion` etc). - Input struct fields (for write/update operations) that are optional (i.e. `omitempty`) and use basic types, are now defined as pointers. -> Note: [basic types](https://tour.golang.org/basics/11) that are _optional_, must be provided as pointers to avoid unexpected behaviours when dealing with their zero value ([reference](https://willnorris.com/2014/05/go-rest-apis-and-pointers/)). We provide helper functions for this [here](./fastly/basictypes_helper.go). +The move to more consistent field names in some cases will have resulted in the corresponding sentinel error name to be updated also. For example, `ServiceID` has resulted in a change from `ErrMissingService` to `ErrMissingServiceID`. + +The change in type for [basic types](https://tour.golang.org/basics/11) that are optional on input structs related to write/update operations is designed to avoid unexpected behaviours when dealing with their zero value (see [this reference](https://willnorris.com/2014/05/go-rest-apis-and-pointers/) for more details). As part of this change we now provide [helper functions](./fastly/basictypes_helper.go) to assist with generating the new pointer types required. ## Examples From d2a0e632ef37bf2a1f2f44352e08ec91a59c6d8d Mon Sep 17 00:00:00 2001 From: integralist Date: Mon, 16 Nov 2020 17:10:58 +0000 Subject: [PATCH 32/37] Consistency in response struct fields --- fastly/acl.go | 4 +- fastly/acl_entries_batch_test.go | 40 +++++------ fastly/acl_entry.go | 80 +++++++++++----------- fastly/acl_entry_test.go | 110 +++++++++++++++---------------- fastly/backend.go | 4 +- fastly/bigquery.go | 4 +- fastly/billing.go | 4 +- fastly/blobstorage.go | 4 +- fastly/cache_setting.go | 4 +- fastly/cloudfiles.go | 4 +- fastly/condition.go | 4 +- fastly/datadog.go | 4 +- fastly/dictionary.go | 4 +- fastly/digitalocean.go | 4 +- fastly/director.go | 4 +- fastly/director_backend.go | 4 +- fastly/domain.go | 4 +- fastly/elasticsearch.go | 4 +- fastly/errors.go | 6 +- fastly/fastly_test.go | 6 +- fastly/ftp.go | 4 +- fastly/gcs.go | 4 +- fastly/gzip.go | 4 +- fastly/header.go | 4 +- fastly/health_check.go | 4 +- fastly/heroku.go | 4 +- fastly/honeycomb.go | 4 +- fastly/https.go | 4 +- fastly/kafka.go | 4 +- fastly/logentries.go | 4 +- fastly/loggly.go | 4 +- fastly/logshuttle.go | 4 +- fastly/newrelic.go | 4 +- fastly/openstack.go | 4 +- fastly/package.go | 22 +++---- fastly/package_test.go | 8 +-- fastly/papertrail.go | 4 +- fastly/pool.go | 4 +- fastly/pubsub.go | 4 +- fastly/request_setting.go | 4 +- fastly/response_object.go | 4 +- fastly/s3.go | 4 +- fastly/scalyr.go | 4 +- fastly/service.go | 16 ++--- fastly/settings.go | 4 +- fastly/sftp.go | 4 +- fastly/splunk.go | 4 +- fastly/sumologic.go | 4 +- fastly/syslog.go | 4 +- fastly/vcl.go | 4 +- fastly/vcl_snippets.go | 4 +- fastly/vcl_snippets_test.go | 4 +- 52 files changed, 232 insertions(+), 232 deletions(-) diff --git a/fastly/acl.go b/fastly/acl.go index 1cc18428b..ea4080938 100644 --- a/fastly/acl.go +++ b/fastly/acl.go @@ -8,8 +8,8 @@ import ( ) type ACL struct { - ServiceID string `mapstructure:"service_id"` - Version int `mapstructure:"version"` + ServiceID string `mapstructure:"service_id"` + ServiceVersion int `mapstructure:"version"` Name string `mapstructure:"name"` ID string `mapstructure:"id"` diff --git a/fastly/acl_entries_batch_test.go b/fastly/acl_entries_batch_test.go index 2417380d0..2f11d222e 100644 --- a/fastly/acl_entries_batch_test.go +++ b/fastly/acl_entries_batch_test.go @@ -20,8 +20,8 @@ func TestClient_BatchModifyAclEntries_Create(t *testing.T) { defer deleteTestACL(t, testACL, fixtureBase+"delete_acl") batchCreateOperations := &BatchModifyACLEntriesInput{ - Service: testService.ID, - ACL: testACL.ID, + ServiceID: testService.ID, + ACLID: testACL.ID, Entries: []*BatchACLEntry{ { Operation: CreateBatchOperation, @@ -54,8 +54,8 @@ func TestClient_BatchModifyAclEntries_Create(t *testing.T) { var actualACLEntries []*ACLEntry record(t, fixtureBase+"list_after_create", func(c *Client) { actualACLEntries, err = c.ListACLEntries(&ListACLEntriesInput{ - Service: testService.ID, - ACL: testACL.ID, + ServiceID: testService.ID, + ACLID: testACL.ID, }) }) if err != nil { @@ -120,8 +120,8 @@ func TestClient_BatchModifyAclEntries_Delete(t *testing.T) { defer deleteTestACL(t, testACL, fixtureBase+"delete_acl") batchCreateOperations := &BatchModifyACLEntriesInput{ - Service: testService.ID, - ACL: testACL.ID, + ServiceID: testService.ID, + ACLID: testACL.ID, Entries: []*BatchACLEntry{ { Operation: CreateBatchOperation, @@ -152,8 +152,8 @@ func TestClient_BatchModifyAclEntries_Delete(t *testing.T) { var createdACLEntries []*ACLEntry record(t, fixtureBase+"list_before_delete", func(client *Client) { createdACLEntries, err = client.ListACLEntries(&ListACLEntriesInput{ - Service: testService.ID, - ACL: testACL.ID, + ServiceID: testService.ID, + ACLID: testACL.ID, }) }) if err != nil { @@ -166,8 +166,8 @@ func TestClient_BatchModifyAclEntries_Delete(t *testing.T) { // When: I execute the batch delete operations against the Fastly API, batchDeleteOperations := &BatchModifyACLEntriesInput{ - Service: testService.ID, - ACL: testACL.ID, + ServiceID: testService.ID, + ACLID: testACL.ID, Entries: []*BatchACLEntry{ { Operation: DeleteBatchOperation, @@ -188,8 +188,8 @@ func TestClient_BatchModifyAclEntries_Delete(t *testing.T) { var actualACLEntries []*ACLEntry record(t, fixtureBase+"list_after_delete", func(client *Client) { actualACLEntries, err = client.ListACLEntries(&ListACLEntriesInput{ - Service: testService.ID, - ACL: testACL.ID, + ServiceID: testService.ID, + ACLID: testACL.ID, }) }) if err != nil { @@ -222,8 +222,8 @@ func TestClient_BatchModifyAclEntries_Update(t *testing.T) { defer deleteTestACL(t, testACL, fixtureBase+"delete_acl") batchCreateOperations := &BatchModifyACLEntriesInput{ - Service: testService.ID, - ACL: testACL.ID, + ServiceID: testService.ID, + ACLID: testACL.ID, Entries: []*BatchACLEntry{ { Operation: CreateBatchOperation, @@ -254,8 +254,8 @@ func TestClient_BatchModifyAclEntries_Update(t *testing.T) { var createdACLEntries []*ACLEntry record(t, fixtureBase+"list_before_update", func(client *Client) { createdACLEntries, err = client.ListACLEntries(&ListACLEntriesInput{ - Service: testService.ID, - ACL: testACL.ID, + ServiceID: testService.ID, + ACLID: testACL.ID, }) }) if err != nil { @@ -268,8 +268,8 @@ func TestClient_BatchModifyAclEntries_Update(t *testing.T) { // When: I execute the batch update operations against the Fastly API, batchUpdateOperations := &BatchModifyACLEntriesInput{ - Service: testService.ID, - ACL: testACL.ID, + ServiceID: testService.ID, + ACLID: testACL.ID, Entries: []*BatchACLEntry{ { Operation: UpdateBatchOperation, @@ -294,8 +294,8 @@ func TestClient_BatchModifyAclEntries_Update(t *testing.T) { var actualACLEntries []*ACLEntry record(t, fixtureBase+"list_after_update", func(client *Client) { actualACLEntries, err = client.ListACLEntries(&ListACLEntriesInput{ - Service: testService.ID, - ACL: testACL.ID, + ServiceID: testService.ID, + ACLID: testACL.ID, }) }) if err != nil { diff --git a/fastly/acl_entry.go b/fastly/acl_entry.go index ce41e58fe..8b1aeaa59 100644 --- a/fastly/acl_entry.go +++ b/fastly/acl_entry.go @@ -32,21 +32,21 @@ func (s entriesById) Less(i, j int) bool { // ListACLEntriesInput is the input parameter to ListACLEntries function. type ListACLEntriesInput struct { - Service string - ACL string + ServiceID string + ACLID string } // ListACLEntries return a list of entries for an ACL func (c *Client) ListACLEntries(i *ListACLEntriesInput) ([]*ACLEntry, error) { - if i.Service == "" { + if i.ServiceID == "" { return nil, ErrMissingServiceID } - if i.ACL == "" { - return nil, ErrMissingACL + if i.ACLID == "" { + return nil, ErrMissingACLID } - path := fmt.Sprintf("/service/%s/acl/%s/entries", i.Service, i.ACL) + path := fmt.Sprintf("/service/%s/acl/%s/entries", i.ServiceID, i.ACLID) resp, err := c.Get(path, nil) if err != nil { @@ -65,26 +65,26 @@ func (c *Client) ListACLEntries(i *ListACLEntriesInput) ([]*ACLEntry, error) { // GetACLEntryInput is the input parameter to GetACLEntry function. type GetACLEntryInput struct { - Service string - ACL string - ID string + ServiceID string + ACLID string + ID string } // GetACLEntry returns a single ACL entry based on its ID. func (c *Client) GetACLEntry(i *GetACLEntryInput) (*ACLEntry, error) { - if i.Service == "" { + if i.ServiceID == "" { return nil, ErrMissingServiceID } - if i.ACL == "" { - return nil, ErrMissingACL + if i.ACLID == "" { + return nil, ErrMissingACLID } if i.ID == "" { return nil, ErrMissingID } - path := fmt.Sprintf("/service/%s/acl/%s/entry/%s", i.Service, i.ACL, i.ID) + path := fmt.Sprintf("/service/%s/acl/%s/entry/%s", i.ServiceID, i.ACLID, i.ID) resp, err := c.Get(path, nil) if err != nil { @@ -102,9 +102,9 @@ func (c *Client) GetACLEntry(i *GetACLEntryInput) (*ACLEntry, error) { // CreateACLEntryInput the input parameter to CreateACLEntry function. type CreateACLEntryInput struct { // Required fields - Service string - ACL string - IP string `form:"ip"` + ServiceID string + ACLID string + IP string `form:"ip"` // Optional fields Subnet *string `form:"subnet,omitempty"` @@ -114,19 +114,19 @@ type CreateACLEntryInput struct { // CreateACLEntry creates and returns a new ACL entry. func (c *Client) CreateACLEntry(i *CreateACLEntryInput) (*ACLEntry, error) { - if i.Service == "" { + if i.ServiceID == "" { return nil, ErrMissingServiceID } - if i.ACL == "" { - return nil, ErrMissingACL + if i.ACLID == "" { + return nil, ErrMissingACLID } if i.IP == "" { return nil, ErrMissingIP } - path := fmt.Sprintf("/service/%s/acl/%s/entry", i.Service, i.ACL) + path := fmt.Sprintf("/service/%s/acl/%s/entry", i.ServiceID, i.ACLID) resp, err := c.PostForm(path, i, nil) if err != nil { @@ -143,26 +143,26 @@ func (c *Client) CreateACLEntry(i *CreateACLEntryInput) (*ACLEntry, error) { // DeleteACLEntryInput the input parameter to DeleteACLEntry function. type DeleteACLEntryInput struct { - Service string - ACL string - ID string + ServiceID string + ACLID string + ID string } // DeleteACLEntry deletes an entry from an ACL based on its ID func (c *Client) DeleteACLEntry(i *DeleteACLEntryInput) error { - if i.Service == "" { + if i.ServiceID == "" { return ErrMissingServiceID } - if i.ACL == "" { - return ErrMissingACL + if i.ACLID == "" { + return ErrMissingACLID } if i.ID == "" { return ErrMissingID } - path := fmt.Sprintf("/service/%s/acl/%s/entry/%s", i.Service, i.ACL, i.ID) + path := fmt.Sprintf("/service/%s/acl/%s/entry/%s", i.ServiceID, i.ACLID, i.ID) resp, err := c.Delete(path, nil) if err != nil { @@ -185,9 +185,9 @@ func (c *Client) DeleteACLEntry(i *DeleteACLEntryInput) error { // UpdateACLEntryInput is the input parameter to UpdateACLEntry function. type UpdateACLEntryInput struct { // Required fields - Service string - ACL string - ID string + ServiceID string + ACLID string + ID string // Optional fields IP *string `form:"ip,omitempty"` @@ -198,19 +198,19 @@ type UpdateACLEntryInput struct { // UpdateACLEntry updates an ACL entry func (c *Client) UpdateACLEntry(i *UpdateACLEntryInput) (*ACLEntry, error) { - if i.Service == "" { + if i.ServiceID == "" { return nil, ErrMissingServiceID } - if i.ACL == "" { - return nil, ErrMissingACL + if i.ACLID == "" { + return nil, ErrMissingACLID } if i.ID == "" { return nil, ErrMissingID } - path := fmt.Sprintf("/service/%s/acl/%s/entry/%s", i.Service, i.ACL, i.ID) + path := fmt.Sprintf("/service/%s/acl/%s/entry/%s", i.ServiceID, i.ACLID, i.ID) resp, err := c.RequestForm("PATCH", path, i, nil) if err != nil { @@ -226,8 +226,8 @@ func (c *Client) UpdateACLEntry(i *UpdateACLEntryInput) (*ACLEntry, error) { } type BatchModifyACLEntriesInput struct { - Service string `json:"-"` - ACL string `json:"-"` + ServiceID string `json:"-"` + ACLID string `json:"-"` Entries []*BatchACLEntry `json:"entries"` } @@ -243,19 +243,19 @@ type BatchACLEntry struct { func (c *Client) BatchModifyACLEntries(i *BatchModifyACLEntriesInput) error { - if i.Service == "" { + if i.ServiceID == "" { return ErrMissingServiceID } - if i.ACL == "" { - return ErrMissingACL + if i.ACLID == "" { + return ErrMissingACLID } if len(i.Entries) > BatchModifyMaximumOperations { return ErrBatchUpdateMaximumOperationsExceeded } - path := fmt.Sprintf("/service/%s/acl/%s/entries", i.Service, i.ACL) + path := fmt.Sprintf("/service/%s/acl/%s/entries", i.ServiceID, i.ACLID) resp, err := c.PatchJSON(path, i, nil) if err != nil { return err diff --git a/fastly/acl_entry_test.go b/fastly/acl_entry_test.go index 175164ba1..39be03788 100644 --- a/fastly/acl_entry_test.go +++ b/fastly/acl_entry_test.go @@ -20,12 +20,12 @@ func TestClient_ACLEntries(t *testing.T) { var e *ACLEntry record(t, fixtureBase+"create", func(c *Client) { e, err = c.CreateACLEntry(&CreateACLEntryInput{ - Service: testService.ID, - ACL: testACL.ID, - IP: "10.0.0.3", - Subnet: String("8"), - Negated: Bool(false), - Comment: String("test entry"), + ServiceID: testService.ID, + ACLID: testACL.ID, + IP: "10.0.0.3", + Subnet: String("8"), + Negated: Bool(false), + Comment: String("test entry"), }) }) if err != nil { @@ -52,8 +52,8 @@ func TestClient_ACLEntries(t *testing.T) { var es []*ACLEntry record(t, fixtureBase+"list", func(c *Client) { es, err = c.ListACLEntries(&ListACLEntriesInput{ - Service: testService.ID, - ACL: testACL.ID, + ServiceID: testService.ID, + ACLID: testACL.ID, }) }) if err != nil { @@ -68,9 +68,9 @@ func TestClient_ACLEntries(t *testing.T) { var ne *ACLEntry record(t, fixtureBase+"get", func(c *Client) { ne, err = c.GetACLEntry(&GetACLEntryInput{ - Service: testService.ID, - ACL: testACL.ID, - ID: e.ID, + ServiceID: testService.ID, + ACLID: testACL.ID, + ID: e.ID, }) }) @@ -94,11 +94,11 @@ func TestClient_ACLEntries(t *testing.T) { var ue *ACLEntry record(t, fixtureBase+"update", func(c *Client) { ue, err = c.UpdateACLEntry(&UpdateACLEntryInput{ - Service: testService.ID, - ACL: testACL.ID, - ID: e.ID, - IP: String("10.0.0.4"), - Negated: Bool(true), + ServiceID: testService.ID, + ACLID: testACL.ID, + ID: e.ID, + IP: String("10.0.0.4"), + Negated: Bool(true), }) }) if err != nil { @@ -123,9 +123,9 @@ func TestClient_ACLEntries(t *testing.T) { // Delete record(t, fixtureBase+"delete", func(c *Client) { err = c.DeleteACLEntry(&DeleteACLEntryInput{ - Service: testService.ID, - ACL: testACL.ID, - ID: e.ID, + ServiceID: testService.ID, + ACLID: testACL.ID, + ID: e.ID, }) }) if err != nil { @@ -137,17 +137,17 @@ func TestClient_ACLEntries(t *testing.T) { func TestClient_ListACLEntries_validation(t *testing.T) { var err error _, err = testClient.ListACLEntries(&ListACLEntriesInput{ - Service: "", + ServiceID: "", }) if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.ListACLEntries(&ListACLEntriesInput{ - Service: "foo", - ACL: "", + ServiceID: "foo", + ACLID: "", }) - if err != ErrMissingACL { + if err != ErrMissingACLID { t.Errorf("bad error: %s", err) } } @@ -155,17 +155,17 @@ func TestClient_ListACLEntries_validation(t *testing.T) { func TestClient_CreateACLEntry_validation(t *testing.T) { var err error _, err = testClient.CreateACLEntry(&CreateACLEntryInput{ - Service: "", + ServiceID: "", }) if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.CreateACLEntry(&CreateACLEntryInput{ - Service: "foo", - ACL: "", + ServiceID: "foo", + ACLID: "", }) - if err != ErrMissingACL { + if err != ErrMissingACLID { t.Errorf("bad error: %s", err) } } @@ -173,24 +173,24 @@ func TestClient_CreateACLEntry_validation(t *testing.T) { func TestClient_GetACLEntry_validation(t *testing.T) { var err error _, err = testClient.GetACLEntry(&GetACLEntryInput{ - Service: "", + ServiceID: "", }) if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.GetACLEntry(&GetACLEntryInput{ - Service: "foo", - ACL: "", + ServiceID: "foo", + ACLID: "", }) - if err != ErrMissingACL { + if err != ErrMissingACLID { t.Errorf("bad error: %s", err) } _, err = testClient.GetACLEntry(&GetACLEntryInput{ - Service: "foo", - ACL: "acl", - ID: "", + ServiceID: "foo", + ACLID: "acl", + ID: "", }) if err != ErrMissingID { t.Errorf("bad error: %s", err) @@ -200,24 +200,24 @@ func TestClient_GetACLEntry_validation(t *testing.T) { func TestClient_UpdateACLEntry_validation(t *testing.T) { var err error _, err = testClient.UpdateACLEntry(&UpdateACLEntryInput{ - Service: "", + ServiceID: "", }) if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } _, err = testClient.UpdateACLEntry(&UpdateACLEntryInput{ - Service: "foo", - ACL: "", + ServiceID: "foo", + ACLID: "", }) - if err != ErrMissingACL { + if err != ErrMissingACLID { t.Errorf("bad error: %s", err) } _, err = testClient.UpdateACLEntry(&UpdateACLEntryInput{ - Service: "foo", - ACL: "acl", - ID: "", + ServiceID: "foo", + ACLID: "acl", + ID: "", }) if err != ErrMissingID { t.Errorf("bad error: %s", err) @@ -227,24 +227,24 @@ func TestClient_UpdateACLEntry_validation(t *testing.T) { func TestClient_DeleteACLEntry_validation(t *testing.T) { var err error err = testClient.DeleteACLEntry(&DeleteACLEntryInput{ - Service: "", + ServiceID: "", }) if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } err = testClient.DeleteACLEntry(&DeleteACLEntryInput{ - Service: "foo", - ACL: "", + ServiceID: "foo", + ACLID: "", }) - if err != ErrMissingACL { + if err != ErrMissingACLID { t.Errorf("bad error: %s", err) } err = testClient.DeleteACLEntry(&DeleteACLEntryInput{ - Service: "foo", - ACL: "acl", - ID: "", + ServiceID: "foo", + ACLID: "acl", + ID: "", }) if err != ErrMissingID { t.Errorf("bad error: %s", err) @@ -254,24 +254,24 @@ func TestClient_DeleteACLEntry_validation(t *testing.T) { func TestClient_BatchModifyACLEntries_validation(t *testing.T) { var err error err = testClient.BatchModifyACLEntries(&BatchModifyACLEntriesInput{ - Service: "", + ServiceID: "", }) if err != ErrMissingServiceID { t.Errorf("bad error: %s", err) } err = testClient.BatchModifyACLEntries(&BatchModifyACLEntriesInput{ - Service: "foo", - ACL: "", + ServiceID: "foo", + ACLID: "", }) - if err != ErrMissingACL { + if err != ErrMissingACLID { t.Errorf("bad error: %s", err) } oversizedACLEntries := make([]*BatchACLEntry, BatchModifyMaximumOperations+1) err = testClient.BatchModifyACLEntries(&BatchModifyACLEntriesInput{ - Service: "foo", - ACL: "bar", - Entries: oversizedACLEntries, + ServiceID: "foo", + ACLID: "bar", + Entries: oversizedACLEntries, }) if err != ErrBatchUpdateMaximumOperationsExceeded { t.Errorf("bad error: %s", err) diff --git a/fastly/backend.go b/fastly/backend.go index 13d630064..b28268c57 100644 --- a/fastly/backend.go +++ b/fastly/backend.go @@ -9,8 +9,8 @@ import ( // Backend represents a backend response from the Fastly API. type Backend struct { - ServiceID string `mapstructure:"service_id"` - Version int `mapstructure:"version"` + ServiceID string `mapstructure:"service_id"` + ServiceVersion int `mapstructure:"version"` Name string `mapstructure:"name"` Comment string `mapstructure:"comment"` diff --git a/fastly/bigquery.go b/fastly/bigquery.go index f88534a2b..3f1976abf 100644 --- a/fastly/bigquery.go +++ b/fastly/bigquery.go @@ -9,8 +9,8 @@ import ( // BigQuery represents a BigQuery response from the Fastly API. type BigQuery struct { - ServiceID string `mapstructure:"service_id"` - Version int `mapstructure:"version"` + ServiceID string `mapstructure:"service_id"` + ServiceVersion int `mapstructure:"version"` Name string `mapstructure:"name"` Format string `mapstructure:"format"` diff --git a/fastly/billing.go b/fastly/billing.go index f9396ae90..91de1db39 100644 --- a/fastly/billing.go +++ b/fastly/billing.go @@ -23,8 +23,8 @@ type BillingStatus struct { SentAt *time.Time `mapstructure:"sent_at"` } -// BillingTotal is a repsentation of the status of the usage for this bill from -// the Fastly API. +// BillingTotal is a representation of the status of the usage for this bill +// from the Fastly API. type BillingTotal struct { PlanName string `mapstructure:"plan_name"` PlanCode string `mapstructure:"plan_code"` diff --git a/fastly/blobstorage.go b/fastly/blobstorage.go index c59b0a216..adbf303d0 100644 --- a/fastly/blobstorage.go +++ b/fastly/blobstorage.go @@ -9,8 +9,8 @@ import ( // BlobStorage represents a blob storage response from the Fastly API. type BlobStorage struct { - ServiceID string `mapstructure:"service_id"` - Version int `mapstructure:"version"` + ServiceID string `mapstructure:"service_id"` + ServiceVersion int `mapstructure:"version"` Name string `mapstructure:"name"` Path string `mapstructure:"path"` diff --git a/fastly/cache_setting.go b/fastly/cache_setting.go index 578fba694..07242ac0a 100644 --- a/fastly/cache_setting.go +++ b/fastly/cache_setting.go @@ -23,8 +23,8 @@ type CacheSettingAction string // CacheSetting represents a response from Fastly's API for cache settings. type CacheSetting struct { - ServiceID string `mapstructure:"service_id"` - Version int `mapstructure:"version"` + ServiceID string `mapstructure:"service_id"` + ServiceVersion int `mapstructure:"version"` Name string `mapstructure:"name"` Action CacheSettingAction `mapstructure:"action"` diff --git a/fastly/cloudfiles.go b/fastly/cloudfiles.go index fa515a37f..3f83445b2 100644 --- a/fastly/cloudfiles.go +++ b/fastly/cloudfiles.go @@ -9,8 +9,8 @@ import ( // Cloudfiles represents a Cloudfiles response from the Fastly API. type Cloudfiles struct { - ServiceID string `mapstructure:"service_id"` - Version int `mapstructure:"version"` + ServiceID string `mapstructure:"service_id"` + ServiceVersion int `mapstructure:"version"` Name string `mapstructure:"name"` User string `mapstructure:"user"` diff --git a/fastly/condition.go b/fastly/condition.go index ff2cd598b..cfbec89c7 100644 --- a/fastly/condition.go +++ b/fastly/condition.go @@ -9,8 +9,8 @@ import ( // Condition represents a condition response from the Fastly API. type Condition struct { - ServiceID string `mapstructure:"service_id"` - Version int `mapstructure:"version"` + ServiceID string `mapstructure:"service_id"` + ServiceVersion int `mapstructure:"version"` Name string `mapstructure:"name"` Comment string `mapstructure:"comment"` diff --git a/fastly/datadog.go b/fastly/datadog.go index db4609c58..268fbef42 100644 --- a/fastly/datadog.go +++ b/fastly/datadog.go @@ -9,8 +9,8 @@ import ( // Datadog represents a Datadog response from the Fastly API. type Datadog struct { - ServiceID string `mapstructure:"service_id"` - Version int `mapstructure:"version"` + ServiceID string `mapstructure:"service_id"` + ServiceVersion int `mapstructure:"version"` Name string `mapstructure:"name"` Token string `mapstructure:"token"` diff --git a/fastly/dictionary.go b/fastly/dictionary.go index 68a21eb4f..5bd021b78 100644 --- a/fastly/dictionary.go +++ b/fastly/dictionary.go @@ -9,8 +9,8 @@ import ( // Dictionary represents a dictionary response from the Fastly API. type Dictionary struct { - ServiceID string `mapstructure:"service_id"` - Version int `mapstructure:"version"` + ServiceID string `mapstructure:"service_id"` + ServiceVersion int `mapstructure:"version"` ID string `mapstructure:"id"` Name string `mapstructure:"name"` diff --git a/fastly/digitalocean.go b/fastly/digitalocean.go index 6deceac5a..9241f38ab 100644 --- a/fastly/digitalocean.go +++ b/fastly/digitalocean.go @@ -9,8 +9,8 @@ import ( // DigitalOcean represents a DigitalOcean response from the Fastly API. type DigitalOcean struct { - ServiceID string `mapstructure:"service_id"` - Version int `mapstructure:"version"` + ServiceID string `mapstructure:"service_id"` + ServiceVersion int `mapstructure:"version"` Name string `mapstructure:"name"` BucketName string `mapstructure:"bucket_name"` diff --git a/fastly/director.go b/fastly/director.go index 10f804b87..8978d0733 100644 --- a/fastly/director.go +++ b/fastly/director.go @@ -26,8 +26,8 @@ type DirectorType uint8 // Director represents a director response from the Fastly API. type Director struct { - ServiceID string `mapstructure:"service_id"` - Version int `mapstructure:"version"` + ServiceID string `mapstructure:"service_id"` + ServiceVersion int `mapstructure:"version"` Name string `mapstructure:"name"` Comment string `mapstructure:"comment"` diff --git a/fastly/director_backend.go b/fastly/director_backend.go index 1bcc57a34..e69eb804f 100644 --- a/fastly/director_backend.go +++ b/fastly/director_backend.go @@ -9,8 +9,8 @@ import ( // DirectorBackend is the relationship between a director and a backend in the // Fastly API. type DirectorBackend struct { - ServiceID string `mapstructure:"service_id"` - Version int `mapstructure:"version"` + ServiceID string `mapstructure:"service_id"` + ServiceVersion int `mapstructure:"version"` Director string `mapstructure:"director_name"` Backend string `mapstructure:"backend_name"` diff --git a/fastly/domain.go b/fastly/domain.go index 83d3407df..ff2fa87dc 100644 --- a/fastly/domain.go +++ b/fastly/domain.go @@ -9,8 +9,8 @@ import ( // Domain represents the the domain name Fastly will serve content for. type Domain struct { - ServiceID string `mapstructure:"service_id"` - Version int `mapstructure:"version"` + ServiceID string `mapstructure:"service_id"` + ServiceVersion int `mapstructure:"version"` Name string `mapstructure:"name"` Comment string `mapstructure:"comment"` diff --git a/fastly/elasticsearch.go b/fastly/elasticsearch.go index 031caf156..20ae99aa7 100644 --- a/fastly/elasticsearch.go +++ b/fastly/elasticsearch.go @@ -9,8 +9,8 @@ import ( // Elasticsearch represents an Elasticsearch Logging response from the Fastly API. type Elasticsearch struct { - ServiceID string `mapstructure:"service_id"` - Version int `mapstructure:"version"` + ServiceID string `mapstructure:"service_id"` + ServiceVersion int `mapstructure:"version"` Name string `mapstructure:"name"` ResponseCondition string `mapstructure:"response_condition"` diff --git a/fastly/errors.go b/fastly/errors.go index cb9316291..cbab4b9e5 100644 --- a/fastly/errors.go +++ b/fastly/errors.go @@ -85,9 +85,9 @@ var ErrMissingMonth = errors.New("missing required field 'Month'") // requires a "NewName" key, but one was not set var ErrMissingNewName = errors.New("missing required field 'NewName'") -// ErrMissingAcl is an error that is returned when an input struct -// required an "Acl" key, but one is not set -var ErrMissingACL = errors.New("missing required field 'ACL'") +// ErrMissingACLID is an error that is returned when an input struct +// required an "ACLID" key, but one is not set +var ErrMissingACLID = errors.New("missing required field 'ACLID'") // ErrMissingIP is an error that is returned when an input struct // required an "IP" key, but one is not set diff --git a/fastly/fastly_test.go b/fastly/fastly_test.go index 8e7609ec5..b0c6ecf35 100644 --- a/fastly/fastly_test.go +++ b/fastly/fastly_test.go @@ -216,7 +216,7 @@ func deleteTestDictionary(t *testing.T, dictionary *Dictionary, deleteFixture st record(t, deleteFixture, func(client *Client) { err = client.DeleteDictionary(&DeleteDictionaryInput{ ServiceID: dictionary.ServiceID, - ServiceVersion: dictionary.Version, + ServiceVersion: dictionary.ServiceVersion, Name: dictionary.Name, }) }) @@ -250,7 +250,7 @@ func deleteTestACL(t *testing.T, acl *ACL, deleteFixture string) { record(t, deleteFixture, func(client *Client) { err = client.DeleteACL(&DeleteACLInput{ ServiceID: acl.ServiceID, - ServiceVersion: acl.Version, + ServiceVersion: acl.ServiceVersion, Name: acl.Name, }) }) @@ -310,7 +310,7 @@ func deleteTestPool(t *testing.T, pool *Pool, deleteFixture string) { record(t, deleteFixture, func(client *Client) { err = client.DeletePool(&DeletePoolInput{ ServiceID: pool.ServiceID, - ServiceVersion: pool.Version, + ServiceVersion: pool.ServiceVersion, Name: pool.Name, }) }) diff --git a/fastly/ftp.go b/fastly/ftp.go index 973bb0c1b..56027886a 100644 --- a/fastly/ftp.go +++ b/fastly/ftp.go @@ -9,8 +9,8 @@ import ( // FTP represents an FTP logging response from the Fastly API. type FTP struct { - ServiceID string `mapstructure:"service_id"` - Version int `mapstructure:"version"` + ServiceID string `mapstructure:"service_id"` + ServiceVersion int `mapstructure:"version"` Name string `mapstructure:"name"` Address string `mapstructure:"address"` diff --git a/fastly/gcs.go b/fastly/gcs.go index fbfc2cbc8..211c6975f 100644 --- a/fastly/gcs.go +++ b/fastly/gcs.go @@ -9,8 +9,8 @@ import ( // GCS represents an GCS logging response from the Fastly API. type GCS struct { - ServiceID string `mapstructure:"service_id"` - Version int `mapstructure:"version"` + ServiceID string `mapstructure:"service_id"` + ServiceVersion int `mapstructure:"version"` Name string `mapstructure:"name"` Bucket string `mapstructure:"bucket_name"` diff --git a/fastly/gzip.go b/fastly/gzip.go index 0bbd9c7fe..9d068e93a 100644 --- a/fastly/gzip.go +++ b/fastly/gzip.go @@ -9,8 +9,8 @@ import ( // Gzip represents an Gzip logging response from the Fastly API. type Gzip struct { - ServiceID string `mapstructure:"service_id"` - Version int `mapstructure:"version"` + ServiceID string `mapstructure:"service_id"` + ServiceVersion int `mapstructure:"version"` Name string `mapstructure:"name"` ContentTypes string `mapstructure:"content_types"` diff --git a/fastly/header.go b/fastly/header.go index 84902f5a2..15516792e 100644 --- a/fastly/header.go +++ b/fastly/header.go @@ -52,8 +52,8 @@ type HeaderType string // Header represents a header response from the Fastly API. type Header struct { - ServiceID string `mapstructure:"service_id"` - Version int `mapstructure:"version"` + ServiceID string `mapstructure:"service_id"` + ServiceVersion int `mapstructure:"version"` Name string `mapstructure:"name"` Action HeaderAction `mapstructure:"action"` diff --git a/fastly/health_check.go b/fastly/health_check.go index c34a14b37..12df3476c 100644 --- a/fastly/health_check.go +++ b/fastly/health_check.go @@ -9,8 +9,8 @@ import ( // HealthCheck represents a health check response from the Fastly API. type HealthCheck struct { - ServiceID string `mapstructure:"service_id"` - Version int `mapstructure:"version"` + ServiceID string `mapstructure:"service_id"` + ServiceVersion int `mapstructure:"version"` Name string `mapstructure:"name"` Comment string `mapstructure:"comment"` diff --git a/fastly/heroku.go b/fastly/heroku.go index d78d5e7db..7a2bad7ac 100644 --- a/fastly/heroku.go +++ b/fastly/heroku.go @@ -9,8 +9,8 @@ import ( // Heroku represents a heroku response from the Fastly API. type Heroku struct { - ServiceID string `mapstructure:"service_id"` - Version int `mapstructure:"version"` + ServiceID string `mapstructure:"service_id"` + ServiceVersion int `mapstructure:"version"` Name string `mapstructure:"name"` Format string `mapstructure:"format"` diff --git a/fastly/honeycomb.go b/fastly/honeycomb.go index 16ac26c79..4cd85bffc 100644 --- a/fastly/honeycomb.go +++ b/fastly/honeycomb.go @@ -9,8 +9,8 @@ import ( // Honeycomb represents a honeycomb response from the Fastly API. type Honeycomb struct { - ServiceID string `mapstructure:"service_id"` - Version int `mapstructure:"version"` + ServiceID string `mapstructure:"service_id"` + ServiceVersion int `mapstructure:"version"` Name string `mapstructure:"name"` Format string `mapstructure:"format"` diff --git a/fastly/https.go b/fastly/https.go index 9f2cc9cc4..e428d4808 100644 --- a/fastly/https.go +++ b/fastly/https.go @@ -9,8 +9,8 @@ import ( // HTTPS represents an HTTPS Logging response from the Fastly API. type HTTPS struct { - ServiceID string `mapstructure:"service_id"` - Version int `mapstructure:"version"` + ServiceID string `mapstructure:"service_id"` + ServiceVersion int `mapstructure:"version"` Name string `mapstructure:"name"` ResponseCondition string `mapstructure:"response_condition"` diff --git a/fastly/kafka.go b/fastly/kafka.go index b5df581f6..314f1edb4 100644 --- a/fastly/kafka.go +++ b/fastly/kafka.go @@ -9,8 +9,8 @@ import ( // Kafka represents a kafka response from the Fastly API. type Kafka struct { - ServiceID string `mapstructure:"service_id"` - Version int `mapstructure:"version"` + ServiceID string `mapstructure:"service_id"` + ServiceVersion int `mapstructure:"version"` Name string `mapstructure:"name"` Brokers string `mapstructure:"brokers"` diff --git a/fastly/logentries.go b/fastly/logentries.go index 854374411..70b711b85 100644 --- a/fastly/logentries.go +++ b/fastly/logentries.go @@ -9,8 +9,8 @@ import ( // Logentries represents a logentries response from the Fastly API. type Logentries struct { - ServiceID string `mapstructure:"service_id"` - Version int `mapstructure:"version"` + ServiceID string `mapstructure:"service_id"` + ServiceVersion int `mapstructure:"version"` Name string `mapstructure:"name"` Port uint `mapstructure:"port"` diff --git a/fastly/loggly.go b/fastly/loggly.go index 52d83fb2b..d68df06ba 100644 --- a/fastly/loggly.go +++ b/fastly/loggly.go @@ -9,8 +9,8 @@ import ( // Loggly represents a loggly response from the Fastly API. type Loggly struct { - ServiceID string `mapstructure:"service_id"` - Version int `mapstructure:"version"` + ServiceID string `mapstructure:"service_id"` + ServiceVersion int `mapstructure:"version"` Name string `mapstructure:"name"` Token string `mapstructure:"token"` diff --git a/fastly/logshuttle.go b/fastly/logshuttle.go index 2a9838a69..053fda354 100644 --- a/fastly/logshuttle.go +++ b/fastly/logshuttle.go @@ -9,8 +9,8 @@ import ( // Logshuttle represents a logshuttle response from the Fastly API. type Logshuttle struct { - ServiceID string `mapstructure:"service_id"` - Version int `mapstructure:"version"` + ServiceID string `mapstructure:"service_id"` + ServiceVersion int `mapstructure:"version"` Name string `mapstructure:"name"` Format string `mapstructure:"format"` diff --git a/fastly/newrelic.go b/fastly/newrelic.go index f4bf4de62..5c246db68 100644 --- a/fastly/newrelic.go +++ b/fastly/newrelic.go @@ -9,8 +9,8 @@ import ( // NewRelic represents a newrelic response from the Fastly API. type NewRelic struct { - ServiceID string `mapstructure:"service_id"` - Version int `mapstructure:"version"` + ServiceID string `mapstructure:"service_id"` + ServiceVersion int `mapstructure:"version"` Name string `mapstructure:"name"` Token string `mapstructure:"token"` diff --git a/fastly/openstack.go b/fastly/openstack.go index 898103c90..d3a336ebc 100644 --- a/fastly/openstack.go +++ b/fastly/openstack.go @@ -9,8 +9,8 @@ import ( // Openstack represents a Openstack response from the Fastly API. type Openstack struct { - ServiceID string `mapstructure:"service_id"` - Version int `mapstructure:"version"` + ServiceID string `mapstructure:"service_id"` + ServiceVersion int `mapstructure:"version"` Name string `mapstructure:"name"` User string `mapstructure:"user"` diff --git a/fastly/package.go b/fastly/package.go index f6ea7266d..6434e11e1 100644 --- a/fastly/package.go +++ b/fastly/package.go @@ -8,13 +8,13 @@ import ( // Package is a container for data returned about a package. type Package struct { - ID string - ServiceID string `mapstructure:"service_id"` - Version int - Metadata PackageMetadata - CreatedAt *time.Time `mapstructure:"created_at"` - UpdatedAt *time.Time `mapstructure:"updated_at"` - DeletedAt *time.Time `mapstructure:"deleted_at"` + ID string + ServiceID string `mapstructure:"service_id"` + ServiceVersion int `mapstructure:"version"` + Metadata PackageMetadata + CreatedAt *time.Time `mapstructure:"created_at"` + UpdatedAt *time.Time `mapstructure:"updated_at"` + DeletedAt *time.Time `mapstructure:"deleted_at"` } // Package is a container for metadata returned about a package. @@ -82,14 +82,14 @@ func (c *Client) UpdatePackage(i *UpdatePackageInput) (*Package, error) { } // MakePackagePath ensures we create the correct REST path for referencing packages in the API. -func MakePackagePath(Service string, Version int) (string, error) { - if Service == "" { +func MakePackagePath(ServiceID string, ServiceVersion int) (string, error) { + if ServiceID == "" { return "", ErrMissingServiceID } - if Version == 0 { + if ServiceVersion == 0 { return "", ErrMissingServiceVersion } - return fmt.Sprintf("/service/%s/version/%d/package", Service, Version), nil + return fmt.Sprintf("/service/%s/version/%d/package", ServiceID, ServiceVersion), nil } // PopulatePackage encapsulates the decoding of returned package data. diff --git a/fastly/package_test.go b/fastly/package_test.go index ee731d493..5aee8015e 100644 --- a/fastly/package_test.go +++ b/fastly/package_test.go @@ -41,8 +41,8 @@ func TestClient_Package(t *testing.T) { if wp.ServiceID != testService.ID { t.Errorf("bad serviceID: %q != %q", wp.ID, testService.ID) } - if wp.Version != testVersion.Number { - t.Errorf("bad serviceID: %q != %q", wp.ID, testService.ID) + if wp.ServiceVersion != testVersion.Number { + t.Errorf("bad serviceVersion: %d != %d", wp.ServiceVersion, testVersion.Number) } // Get @@ -59,8 +59,8 @@ func TestClient_Package(t *testing.T) { if wp.ServiceID != testService.ID { t.Errorf("bad serviceID: %q != %q", wp.ID, testService.ID) } - if wp.Version != testVersion.Number { - t.Errorf("bad serviceID: %q != %q", wp.ID, testService.ID) + if wp.ServiceVersion != testVersion.Number { + t.Errorf("bad serviceVersion: %d != %d", wp.ServiceVersion, testVersion.Number) } if wp.Metadata.Name != testData.Metadata.Name { diff --git a/fastly/papertrail.go b/fastly/papertrail.go index f47d7c767..caa176781 100644 --- a/fastly/papertrail.go +++ b/fastly/papertrail.go @@ -9,8 +9,8 @@ import ( // Papertrail represents a papertrail response from the Fastly API. type Papertrail struct { - ServiceID string `mapstructure:"service_id"` - Version int `mapstructure:"version"` + ServiceID string `mapstructure:"service_id"` + ServiceVersion int `mapstructure:"version"` Name string `mapstructure:"name"` Address string `mapstructure:"address"` diff --git a/fastly/pool.go b/fastly/pool.go index 3ca29438c..16c88bcd0 100644 --- a/fastly/pool.go +++ b/fastly/pool.go @@ -23,8 +23,8 @@ type PoolType string // Pool represents a pool response from the Fastly API. type Pool struct { - ServiceID string `mapstructure:"service_id"` - Version int `mapstructure:"version"` + ServiceID string `mapstructure:"service_id"` + ServiceVersion int `mapstructure:"version"` ID string `mapstructure:"id"` Name string `mapstructure:"name"` diff --git a/fastly/pubsub.go b/fastly/pubsub.go index 8a3780810..c59de47cd 100644 --- a/fastly/pubsub.go +++ b/fastly/pubsub.go @@ -9,8 +9,8 @@ import ( // Pubsub represents an Pubsub logging response from the Fastly API. type Pubsub struct { - ServiceID string `mapstructure:"service_id"` - Version int `mapstructure:"version"` + ServiceID string `mapstructure:"service_id"` + ServiceVersion int `mapstructure:"version"` Name string `mapstructure:"name"` Topic string `mapstructure:"topic"` diff --git a/fastly/request_setting.go b/fastly/request_setting.go index 8a74b5fa5..a78238c3c 100644 --- a/fastly/request_setting.go +++ b/fastly/request_setting.go @@ -41,8 +41,8 @@ type RequestSettingXFF string // RequestSetting represents a request setting response from the Fastly API. type RequestSetting struct { - ServiceID string `mapstructure:"service_id"` - Version int `mapstructure:"version"` + ServiceID string `mapstructure:"service_id"` + ServiceVersion int `mapstructure:"version"` Name string `mapstructure:"name"` ForceMiss bool `mapstructure:"force_miss"` diff --git a/fastly/response_object.go b/fastly/response_object.go index 89f36897e..77fd4d5e5 100644 --- a/fastly/response_object.go +++ b/fastly/response_object.go @@ -9,8 +9,8 @@ import ( // ResponseObject represents a response object response from the Fastly API. type ResponseObject struct { - ServiceID string `mapstructure:"service_id"` - Version int `mapstructure:"version"` + ServiceID string `mapstructure:"service_id"` + ServiceVersion int `mapstructure:"version"` Name string `mapstructure:"name"` Status uint `mapstructure:"status"` diff --git a/fastly/s3.go b/fastly/s3.go index efb7d85b4..1343a4c79 100644 --- a/fastly/s3.go +++ b/fastly/s3.go @@ -19,8 +19,8 @@ const ( // S3 represents a S3 response from the Fastly API. type S3 struct { - ServiceID string `mapstructure:"service_id"` - Version int `mapstructure:"version"` + ServiceID string `mapstructure:"service_id"` + ServiceVersion int `mapstructure:"version"` Name string `mapstructure:"name"` BucketName string `mapstructure:"bucket_name"` diff --git a/fastly/scalyr.go b/fastly/scalyr.go index d09ef824d..e9034712f 100644 --- a/fastly/scalyr.go +++ b/fastly/scalyr.go @@ -9,8 +9,8 @@ import ( // Scalyr represents a scalyr response from the Fastly API. type Scalyr struct { - ServiceID string `mapstructure:"service_id"` - Version int `mapstructure:"version"` + ServiceID string `mapstructure:"service_id"` + ServiceVersion int `mapstructure:"version"` Name string `mapstructure:"name"` Format string `mapstructure:"format"` diff --git a/fastly/service.go b/fastly/service.go index c242a2c5b..a15325eaa 100644 --- a/fastly/service.go +++ b/fastly/service.go @@ -35,14 +35,14 @@ type ServiceDetail struct { } type ServiceDomain struct { - Locked bool `mapstructure:"locked"` - Version int64 `mapstructure:"version"` - Name string `mapstructure:"name"` - DeletedAt *time.Time `mapstructure:"deleted_at"` - ServiceID string `mapstructure:"service_id"` - CreatedAt *time.Time `mapstructure:"created_at"` - Comment string `mapstructure:"comment"` - UpdatedAt *time.Time `mapstructure:"updated_at"` + Locked bool `mapstructure:"locked"` + Name string `mapstructure:"name"` + DeletedAt *time.Time `mapstructure:"deleted_at"` + ServiceID string `mapstructure:"service_id"` + ServiceVersion int64 `mapstructure:"version"` + CreatedAt *time.Time `mapstructure:"created_at"` + Comment string `mapstructure:"comment"` + UpdatedAt *time.Time `mapstructure:"updated_at"` } type ServiceDomainsList []*ServiceDomain diff --git a/fastly/settings.go b/fastly/settings.go index 4c5de67e8..3cc2b3780 100644 --- a/fastly/settings.go +++ b/fastly/settings.go @@ -4,8 +4,8 @@ import "fmt" // Settings represents a backend response from the Fastly API. type Settings struct { - ServiceID string `mapstructure:"service_id"` - Version int `mapstructure:"version"` + ServiceID string `mapstructure:"service_id"` + ServiceVersion int `mapstructure:"version"` DefaultTTL uint `mapstructure:"general.default_ttl"` DefaultHost string `mapstructure:"general.default_host"` diff --git a/fastly/sftp.go b/fastly/sftp.go index 9ffb2e6cd..dda7fe36c 100644 --- a/fastly/sftp.go +++ b/fastly/sftp.go @@ -9,8 +9,8 @@ import ( // SFTP represents an SFTP logging response from the Fastly API. type SFTP struct { - ServiceID string `mapstructure:"service_id"` - Version int `mapstructure:"version"` + ServiceID string `mapstructure:"service_id"` + ServiceVersion int `mapstructure:"version"` Name string `mapstructure:"name"` Address string `mapstructure:"address"` diff --git a/fastly/splunk.go b/fastly/splunk.go index 07d03849f..f60435925 100644 --- a/fastly/splunk.go +++ b/fastly/splunk.go @@ -9,8 +9,8 @@ import ( // Splunk represents a splunk response from the Fastly API. type Splunk struct { - ServiceID string `mapstructure:"service_id"` - Version int `mapstructure:"version"` + ServiceID string `mapstructure:"service_id"` + ServiceVersion int `mapstructure:"version"` Name string `mapstructure:"name"` URL string `mapstructure:"url"` diff --git a/fastly/sumologic.go b/fastly/sumologic.go index 3c1b65ad1..b570b1a77 100644 --- a/fastly/sumologic.go +++ b/fastly/sumologic.go @@ -9,8 +9,8 @@ import ( // Sumologic represents a sumologic response from the Fastly API. type Sumologic struct { - ServiceID string `mapstructure:"service_id"` - Version int `mapstructure:"version"` + ServiceID string `mapstructure:"service_id"` + ServiceVersion int `mapstructure:"version"` Name string `mapstructure:"name"` Address string `mapstructure:"address"` diff --git a/fastly/syslog.go b/fastly/syslog.go index 481a0b74c..7eb2ed995 100644 --- a/fastly/syslog.go +++ b/fastly/syslog.go @@ -9,8 +9,8 @@ import ( // Syslog represents a syslog response from the Fastly API. type Syslog struct { - ServiceID string `mapstructure:"service_id"` - Version int `mapstructure:"version"` + ServiceID string `mapstructure:"service_id"` + ServiceVersion int `mapstructure:"version"` Name string `mapstructure:"name"` Address string `mapstructure:"address"` diff --git a/fastly/vcl.go b/fastly/vcl.go index 6c65b35b6..f6c88af4b 100644 --- a/fastly/vcl.go +++ b/fastly/vcl.go @@ -9,8 +9,8 @@ import ( // VCL represents a response about VCL from the Fastly API. type VCL struct { - ServiceID string `mapstructure:"service_id"` - Version int `mapstructure:"version"` + ServiceID string `mapstructure:"service_id"` + ServiceVersion int `mapstructure:"version"` Name string `mapstructure:"name"` Main bool `mapstructure:"main"` diff --git a/fastly/vcl_snippets.go b/fastly/vcl_snippets.go index 2dc75df15..db5be0d98 100644 --- a/fastly/vcl_snippets.go +++ b/fastly/vcl_snippets.go @@ -47,8 +47,8 @@ type SnippetType string // Snippet is the Fastly Snippet object type Snippet struct { - ServiceID string `mapstructure:"service_id"` - Version int `mapstructure:"version"` + ServiceID string `mapstructure:"service_id"` + ServiceVersion int `mapstructure:"version"` Name string `mapstructure:"name"` ID string `mapstructure:"id"` diff --git a/fastly/vcl_snippets_test.go b/fastly/vcl_snippets_test.go index 6c449ebe9..bf24eda4f 100644 --- a/fastly/vcl_snippets_test.go +++ b/fastly/vcl_snippets_test.go @@ -225,8 +225,8 @@ func Test_Snippets(t *testing.T) { if x.ServiceID != testServiceID { t.Errorf("bad service: %q", x.ServiceID) } - if x.Version != tv.Number { - t.Errorf("bad ServiceVersion: %q", x.Version) + if x.ServiceVersion != tv.Number { + t.Errorf("bad ServiceVersion: %q", x.ServiceVersion) } } From 85ba74dd0cf51119b694798e3e81c0eb74adbe7f Mon Sep 17 00:00:00 2001 From: integralist Date: Mon, 16 Nov 2020 18:04:14 +0000 Subject: [PATCH 33/37] remove pointer references for non write/update structs... NOTE: this does not include 'create' structs that already had pointer references on them as I'm unaware of the context related to why they are pointers. --- fastly/acl_entry.go | 6 ++--- fastly/acl_entry_test.go | 6 ++--- fastly/backend.go | 44 +++++++++++++++++----------------- fastly/backend_test.go | 10 ++++---- fastly/bigquery.go | 22 ++++++++--------- fastly/bigquery_test.go | 20 ++++++++-------- fastly/blobstorage.go | 28 +++++++++++----------- fastly/blobstorage_test.go | 26 ++++++++++---------- fastly/cache_setting.go | 8 +++---- fastly/cache_setting_test.go | 6 ++--- fastly/condition.go | 8 +++---- fastly/condition_test.go | 8 +++---- fastly/content.go | 4 ++-- fastly/content_test.go | 2 +- fastly/dictionary.go | 2 +- fastly/dictionary_item.go | 4 ++-- fastly/dictionary_item_test.go | 4 ++-- fastly/dictionary_test.go | 2 +- fastly/diff_test.go | 4 ++-- fastly/director.go | 12 +++++----- fastly/director_test.go | 6 ++--- fastly/domain.go | 2 +- fastly/domain_test.go | 2 +- fastly/fastly_test.go | 42 ++++++++++++++++---------------- fastly/ftp.go | 30 +++++++++++------------ fastly/ftp_test.go | 28 +++++++++++----------- fastly/gcs.go | 26 ++++++++++---------- fastly/gcs_test.go | 24 +++++++++---------- fastly/gzip.go | 8 +++---- fastly/gzip_test.go | 4 ++-- fastly/header.go | 18 +++++++------- fastly/header_test.go | 12 +++++----- fastly/health_check.go | 24 +++++++++---------- fastly/health_check_test.go | 22 ++++++++--------- fastly/honeycomb.go | 14 +++++------ fastly/honeycomb_test.go | 12 +++++----- fastly/https.go | 36 ++++++++++++++-------------- fastly/https_test.go | 34 +++++++++++++------------- fastly/logentries.go | 14 +++++------ fastly/logentries_test.go | 10 ++++---- fastly/papertrail.go | 14 +++++------ fastly/papertrail_test.go | 12 +++++----- fastly/request_setting.go | 10 ++++---- fastly/request_setting_test.go | 8 +++---- fastly/response_object.go | 14 +++++------ fastly/response_object_test.go | 10 ++++---- fastly/s3.go | 34 +++++++++++++------------- fastly/s3_test.go | 36 ++++++++++++++-------------- fastly/service.go | 6 ++--- fastly/service_test.go | 4 ++-- fastly/splunk.go | 18 +++++++------- fastly/splunk_test.go | 16 ++++++------- fastly/sumologic.go | 16 ++++++------- fastly/sumologic_test.go | 12 +++++----- fastly/syslog.go | 30 +++++++++++------------ fastly/syslog_test.go | 26 ++++++++++---------- fastly/tls.go | 8 +++---- fastly/tls_test.go | 8 +++---- fastly/token.go | 6 ++--- fastly/token_test.go | 10 ++++---- fastly/user.go | 2 +- fastly/user_test.go | 2 +- fastly/vcl.go | 6 ++--- fastly/vcl_test.go | 4 ++-- fastly/version.go | 2 +- fastly/version_test.go | 2 +- 66 files changed, 455 insertions(+), 455 deletions(-) diff --git a/fastly/acl_entry.go b/fastly/acl_entry.go index 8b1aeaa59..b990c4324 100644 --- a/fastly/acl_entry.go +++ b/fastly/acl_entry.go @@ -107,9 +107,9 @@ type CreateACLEntryInput struct { IP string `form:"ip"` // Optional fields - Subnet *string `form:"subnet,omitempty"` - Negated *bool `form:"negated,omitempty"` - Comment *string `form:"comment,omitempty"` + Subnet string `form:"subnet,omitempty"` + Negated bool `form:"negated,omitempty"` + Comment string `form:"comment,omitempty"` } // CreateACLEntry creates and returns a new ACL entry. diff --git a/fastly/acl_entry_test.go b/fastly/acl_entry_test.go index 39be03788..f4d6ad086 100644 --- a/fastly/acl_entry_test.go +++ b/fastly/acl_entry_test.go @@ -23,9 +23,9 @@ func TestClient_ACLEntries(t *testing.T) { ServiceID: testService.ID, ACLID: testACL.ID, IP: "10.0.0.3", - Subnet: String("8"), - Negated: Bool(false), - Comment: String("test entry"), + Subnet: "8", + Negated: false, + Comment: "test entry", }) }) if err != nil { diff --git a/fastly/backend.go b/fastly/backend.go index b28268c57..769c763b6 100644 --- a/fastly/backend.go +++ b/fastly/backend.go @@ -95,31 +95,31 @@ type CreateBackendInput struct { // ServiceVersion is the specific configuration version (required). ServiceVersion int - Name *string `form:"name,omitempty"` - Comment *string `form:"comment,omitempty"` - Address *string `form:"address,omitempty"` - Port *uint `form:"port,omitempty"` - OverrideHost *string `form:"override_host,omitempty"` - ConnectTimeout *uint `form:"connect_timeout,omitempty"` - MaxConn *uint `form:"max_conn,omitempty"` - ErrorThreshold *uint `form:"error_threshold,omitempty"` - FirstByteTimeout *uint `form:"first_byte_timeout,omitempty"` - BetweenBytesTimeout *uint `form:"between_bytes_timeout,omitempty"` + Name string `form:"name,omitempty"` + Comment string `form:"comment,omitempty"` + Address string `form:"address,omitempty"` + Port uint `form:"port,omitempty"` + OverrideHost string `form:"override_host,omitempty"` + ConnectTimeout uint `form:"connect_timeout,omitempty"` + MaxConn uint `form:"max_conn,omitempty"` + ErrorThreshold uint `form:"error_threshold,omitempty"` + FirstByteTimeout uint `form:"first_byte_timeout,omitempty"` + BetweenBytesTimeout uint `form:"between_bytes_timeout,omitempty"` AutoLoadbalance *Compatibool `form:"auto_loadbalance,omitempty"` - Weight *uint `form:"weight,omitempty"` - RequestCondition *string `form:"request_condition,omitempty"` - HealthCheck *string `form:"healthcheck,omitempty"` - Shield *string `form:"shield,omitempty"` + Weight uint `form:"weight,omitempty"` + RequestCondition string `form:"request_condition,omitempty"` + HealthCheck string `form:"healthcheck,omitempty"` + Shield string `form:"shield,omitempty"` UseSSL *Compatibool `form:"use_ssl,omitempty"` SSLCheckCert *Compatibool `form:"ssl_check_cert,omitempty"` - SSLCACert *string `form:"ssl_ca_cert,omitempty"` - SSLClientCert *string `form:"ssl_client_cert,omitempty"` - SSLClientKey *string `form:"ssl_client_key,omitempty"` - SSLHostname *string `form:"ssl_hostname,omitempty"` - SSLCertHostname *string `form:"ssl_cert_hostname,omitempty"` - SSLSNIHostname *string `form:"ssl_sni_hostname,omitempty"` - MinTLSVersion *string `form:"min_tls_version,omitempty"` - MaxTLSVersion *string `form:"max_tls_version,omitempty"` + SSLCACert string `form:"ssl_ca_cert,omitempty"` + SSLClientCert string `form:"ssl_client_cert,omitempty"` + SSLClientKey string `form:"ssl_client_key,omitempty"` + SSLHostname string `form:"ssl_hostname,omitempty"` + SSLCertHostname string `form:"ssl_cert_hostname,omitempty"` + SSLSNIHostname string `form:"ssl_sni_hostname,omitempty"` + MinTLSVersion string `form:"min_tls_version,omitempty"` + MaxTLSVersion string `form:"max_tls_version,omitempty"` SSLCiphers []string `form:"ssl_ciphers,omitempty"` } diff --git a/fastly/backend_test.go b/fastly/backend_test.go index 3ba4d6c8f..9cac145d6 100644 --- a/fastly/backend_test.go +++ b/fastly/backend_test.go @@ -17,11 +17,11 @@ func TestClient_Backends(t *testing.T) { b, err = c.CreateBackend(&CreateBackendInput{ ServiceID: testServiceID, ServiceVersion: tv.Number, - Name: String("test-backend"), - Address: String("integ-test.go-fastly.com"), - Port: Uint(1234), - ConnectTimeout: Uint(1500), - OverrideHost: String("origin.example.com"), + Name: "test-backend", + Address: "integ-test.go-fastly.com", + Port: 1234, + ConnectTimeout: 1500, + OverrideHost: "origin.example.com", }) }) if err != nil { diff --git a/fastly/bigquery.go b/fastly/bigquery.go index 3f1976abf..6415fa52a 100644 --- a/fastly/bigquery.go +++ b/fastly/bigquery.go @@ -79,17 +79,17 @@ type CreateBigQueryInput struct { // ServiceVersion is the specific configuration version (required). ServiceVersion int - Name *string `form:"name,omitempty"` - ProjectID *string `form:"project_id,omitempty"` - Dataset *string `form:"dataset,omitempty"` - Table *string `form:"table,omitempty"` - Template *string `form:"template_suffix,omitempty"` - User *string `form:"user,omitempty"` - SecretKey *string `form:"secret_key,omitempty"` - Format *string `form:"format,omitempty"` - ResponseCondition *string `form:"response_condition,omitempty"` - Placement *string `form:"placement,omitempty"` - FormatVersion *uint `form:"format_version,omitempty"` + Name string `form:"name,omitempty"` + ProjectID string `form:"project_id,omitempty"` + Dataset string `form:"dataset,omitempty"` + Table string `form:"table,omitempty"` + Template string `form:"template_suffix,omitempty"` + User string `form:"user,omitempty"` + SecretKey string `form:"secret_key,omitempty"` + Format string `form:"format,omitempty"` + ResponseCondition string `form:"response_condition,omitempty"` + Placement string `form:"placement,omitempty"` + FormatVersion uint `form:"format_version,omitempty"` } // CreateBigQuery creates a new Fastly BigQuery. diff --git a/fastly/bigquery_test.go b/fastly/bigquery_test.go index 7b787a821..152c74176 100644 --- a/fastly/bigquery_test.go +++ b/fastly/bigquery_test.go @@ -21,16 +21,16 @@ func TestClient_Bigqueries(t *testing.T) { bq, err = c.CreateBigQuery(&CreateBigQueryInput{ ServiceID: testServiceID, ServiceVersion: tv.Number, - Name: String("test-bigquery"), - ProjectID: String("example-fastly-log"), - Dataset: String("fastly_log_test"), - Table: String("fastly_logs"), - Template: String(""), - User: String("fastly-bigquery-log@example-fastly-log.iam.gserviceaccount.com"), - SecretKey: String(secretKey), - Format: String("{\n \"timestamp\":\"%{begin:%Y-%m-%dT%H:%M:%S}t\"),\n \"time_elapsed\":%{time.elapsed.usec}V,\n \"is_tls\":%{if(req.is_ssl, \"true\", \"false\")}V,\n \"client_ip\":\"%{req.http.Fastly-Client-IP}V\",\n \"geo_city\":\"%{client.geo.city}V\",\n \"geo_country_code\":\"%{client.geo.country_code}V\",\n \"request\":\"%{req.request}V\",\n \"host\":\"%{req.http.Fastly-Orig-Host}V\",\n \"url\":\"%{json.escape(req.url)}V\",\n \"request_referer\":\"%{json.escape(req.http.Referer)}V\",\n \"request_user_agent\":\"%{json.escape(req.http.User-Agent)}V\",\n \"request_accept_language\":\"%{json.escape(req.http.Accept-Language)}V\",\n \"request_accept_charset\":\"%{json.escape(req.http.Accept-Charset)}V\",\n \"cache_status\":\"%{regsub(fastly_info.state, \"^(HIT-(SYNTH)|(HITPASS|HIT|MISS|PASS|ERROR|PIPE)).*\", \"\\\\2\\\\3\") }V\"\n}"), - Placement: String("waf_debug"), - FormatVersion: Uint(2), + Name: "test-bigquery", + ProjectID: "example-fastly-log", + Dataset: "fastly_log_test", + Table: "fastly_logs", + Template: "", + User: "fastly-bigquery-log@example-fastly-log.iam.gserviceaccount.com", + SecretKey: secretKey, + Format: "{\n \"timestamp\":\"%{begin:%Y-%m-%dT%H:%M:%S}t\",\n \"time_elapsed\":%{time.elapsed.usec}V,\n \"is_tls\":%{if(req.is_ssl, \"true\", \"false\")}V,\n \"client_ip\":\"%{req.http.Fastly-Client-IP}V\",\n \"geo_city\":\"%{client.geo.city}V\",\n \"geo_country_code\":\"%{client.geo.country_code}V\",\n \"request\":\"%{req.request}V\",\n \"host\":\"%{req.http.Fastly-Orig-Host}V\",\n \"url\":\"%{json.escape(req.url)}V\",\n \"request_referer\":\"%{json.escape(req.http.Referer)}V\",\n \"request_user_agent\":\"%{json.escape(req.http.User-Agent)}V\",\n \"request_accept_language\":\"%{json.escape(req.http.Accept-Language)}V\",\n \"request_accept_charset\":\"%{json.escape(req.http.Accept-Charset)}V\",\n \"cache_status\":\"%{regsub(fastly_info.state, \"^(HIT-(SYNTH)|(HITPASS|HIT|MISS|PASS|ERROR|PIPE)).*\", \"\\\\2\\\\3\") }V\"\n}", + Placement: "waf_debug", + FormatVersion: 2, }) }) if err != nil { diff --git a/fastly/blobstorage.go b/fastly/blobstorage.go index adbf303d0..de9cc0b18 100644 --- a/fastly/blobstorage.go +++ b/fastly/blobstorage.go @@ -82,20 +82,20 @@ type CreateBlobStorageInput struct { // ServiceVersion is the specific configuration version (required). ServiceVersion int - Name *string `form:"name,omitempty"` - Path *string `form:"path,omitempty"` - AccountName *string `form:"account_name,omitempty"` - Container *string `form:"container,omitempty"` - SASToken *string `form:"sas_token,omitempty"` - Period *uint `form:"period,omitempty"` - TimestampFormat *string `form:"timestamp_format,omitempty"` - GzipLevel *uint `form:"gzip_level,omitempty"` - PublicKey *string `form:"public_key,omitempty"` - Format *string `form:"format,omitempty"` - FormatVersion *uint `form:"format_version,omitempty"` - MessageType *string `form:"message_type,omitempty"` - Placement *string `form:"placement,omitempty"` - ResponseCondition *string `form:"response_condition,omitempty"` + Name string `form:"name,omitempty"` + Path string `form:"path,omitempty"` + AccountName string `form:"account_name,omitempty"` + Container string `form:"container,omitempty"` + SASToken string `form:"sas_token,omitempty"` + Period uint `form:"period,omitempty"` + TimestampFormat string `form:"timestamp_format,omitempty"` + GzipLevel uint `form:"gzip_level,omitempty"` + PublicKey string `form:"public_key,omitempty"` + Format string `form:"format,omitempty"` + FormatVersion uint `form:"format_version,omitempty"` + MessageType string `form:"message_type,omitempty"` + Placement string `form:"placement,omitempty"` + ResponseCondition string `form:"response_condition,omitempty"` } // CreateBlobStorage creates a new Fastly blob storage. diff --git a/fastly/blobstorage_test.go b/fastly/blobstorage_test.go index 18f9456b4..5d53f7bd0 100644 --- a/fastly/blobstorage_test.go +++ b/fastly/blobstorage_test.go @@ -17,19 +17,19 @@ func TestClient_BlobStorages(t *testing.T) { bs, err = c.CreateBlobStorage(&CreateBlobStorageInput{ ServiceID: testServiceID, ServiceVersion: tv.Number, - Name: String("test-blobstorage"), - Path: String("/logs"), - AccountName: String("test"), - Container: String("fastly"), - SASToken: String("sv=2015-04-05&ss=b&srt=sco&sp=rw&se=2019-07-21T18%3A00%3A00Z&sig=3ABdLOJZosCp0o491T%2BqZGKIhafF1nlM3MzESDDD3Gg%3D"), - Period: Uint(12), - TimestampFormat: String("%Y-%m-%dT%H:%M:%S.000"), - GzipLevel: Uint(9), - PublicKey: String("-----BEGIN PGP PUBLIC KEY BLOCK-----\n\nmQENBFyUD8sBCACyFnB39AuuTygseek+eA4fo0cgwva6/FSjnWq7riouQee8GgQ/\nibXTRyv4iVlwI12GswvMTIy7zNvs1R54i0qvsLr+IZ4GVGJqs6ZJnvQcqe3xPoR4\n8AnBfw90o32r/LuHf6QCJXi+AEu35koNlNAvLJ2B+KACaNB7N0EeWmqpV/1V2k9p\nlDYk+th7LcCuaFNGqKS/PrMnnMqR6VDLCjHhNx4KR79b0Twm/2qp6an3hyNRu8Gn\ndwxpf1/BUu3JWf+LqkN4Y3mbOmSUL3MaJNvyQguUzTfS0P0uGuBDHrJCVkMZCzDB\n89ag55jCPHyGeHBTd02gHMWzsg3WMBWvCsrzABEBAAG0JXRlcnJhZm9ybSAodGVz\ndCkgPHRlc3RAdGVycmFmb3JtLmNvbT6JAU4EEwEIADgWIQSHYyc6Kj9l6HzQsau6\nvFFc9jxV/wUCXJQPywIbAwULCQgHAgYVCgkICwIEFgIDAQIeAQIXgAAKCRC6vFFc\n9jxV/815CAClb32OxV7wG01yF97TzlyTl8TnvjMtoG29Mw4nSyg+mjM3b8N7iXm9\nOLX59fbDAWtBSldSZE22RXd3CvlFOG/EnKBXSjBtEqfyxYSnyOPkMPBYWGL/ApkX\nSvPYJ4LKdvipYToKFh3y9kk2gk1DcDBDyaaHvR+3rv1u3aoy7/s2EltAfDS3ZQIq\n7/cWTLJml/lleeB/Y6rPj8xqeCYhE5ahw9gsV/Mdqatl24V9Tks30iijx0Hhw+Gx\nkATUikMGr2GDVqoIRga5kXI7CzYff4rkc0Twn47fMHHHe/KY9M2yVnMHUXmAZwbG\nM1cMI/NH1DjevCKdGBLcRJlhuLPKF/anuQENBFyUD8sBCADIpd7r7GuPd6n/Ikxe\nu6h7umV6IIPoAm88xCYpTbSZiaK30Svh6Ywra9jfE2KlU9o6Y/art8ip0VJ3m07L\n4RSfSpnzqgSwdjSq5hNour2Fo/BzYhK7yaz2AzVSbe33R0+RYhb4b/6N+bKbjwGF\nftCsqVFMH+PyvYkLbvxyQrHlA9woAZaNThI1ztO5rGSnGUR8xt84eup28WIFKg0K\nUEGUcTzz+8QGAwAra+0ewPXo/AkO+8BvZjDidP417u6gpBHOJ9qYIcO9FxHeqFyu\nYrjlrxowEgXn5wO8xuNz6Vu1vhHGDHGDsRbZF8pv1d5O+0F1G7ttZ2GRRgVBZPwi\nkiyRABEBAAGJATYEGAEIACAWIQSHYyc6Kj9l6HzQsau6vFFc9jxV/wUCXJQPywIb\nDAAKCRC6vFFc9jxV/9YOCACe8qmOSnKQpQfW+PqYOqo3dt7JyweTs3FkD6NT8Zml\ndYy/vkstbTjPpX6aTvUZjkb46BVi7AOneVHpD5GBqvRsZ9iVgDYHaehmLCdKiG5L\n3Tp90NN+QY5WDbsGmsyk6+6ZMYejb4qYfweQeduOj27aavCJdLkCYMoRKfcFYI8c\nFaNmEfKKy/r1PO20NXEG6t9t05K/frHy6ZG8bCNYdpagfFVot47r9JaQqWlTNtIR\n5+zkkSq/eG9BEtRij3a6cTdQbktdBzx2KBeI0PYc1vlZR0LpuFKZqY9vlE6vTGLR\nwMfrTEOvx0NxUM3rpaCgEmuWbB1G1Hu371oyr4srrr+N\n=28dr\n-----END PGP PUBLIC KEY BLOCK-----\n"), - Format: String("%h %l %u %{now}V %{req.method}V %{req.url}V %>s %{resp.http.Content-Length}V"), - FormatVersion: Uint(2), - MessageType: String("classic"), - Placement: String("waf_debug"), + Name: "test-blobstorage", + Path: "/logs", + AccountName: "test", + Container: "fastly", + SASToken: "sv=2015-04-05&ss=b&srt=sco&sp=rw&se=2019-07-21T18%3A00%3A00Z&sig=3ABdLOJZosCp0o491T%2BqZGKIhafF1nlM3MzESDDD3Gg%3D", + Period: 12, + TimestampFormat: "%Y-%m-%dT%H:%M:%S.000", + GzipLevel: 9, + PublicKey: "-----BEGIN PGP PUBLIC KEY BLOCK-----\n\nmQENBFyUD8sBCACyFnB39AuuTygseek+eA4fo0cgwva6/FSjnWq7riouQee8GgQ/\nibXTRyv4iVlwI12GswvMTIy7zNvs1R54i0qvsLr+IZ4GVGJqs6ZJnvQcqe3xPoR4\n8AnBfw90o32r/LuHf6QCJXi+AEu35koNlNAvLJ2B+KACaNB7N0EeWmqpV/1V2k9p\nlDYk+th7LcCuaFNGqKS/PrMnnMqR6VDLCjHhNx4KR79b0Twm/2qp6an3hyNRu8Gn\ndwxpf1/BUu3JWf+LqkN4Y3mbOmSUL3MaJNvyQguUzTfS0P0uGuBDHrJCVkMZCzDB\n89ag55jCPHyGeHBTd02gHMWzsg3WMBWvCsrzABEBAAG0JXRlcnJhZm9ybSAodGVz\ndCkgPHRlc3RAdGVycmFmb3JtLmNvbT6JAU4EEwEIADgWIQSHYyc6Kj9l6HzQsau6\nvFFc9jxV/wUCXJQPywIbAwULCQgHAgYVCgkICwIEFgIDAQIeAQIXgAAKCRC6vFFc\n9jxV/815CAClb32OxV7wG01yF97TzlyTl8TnvjMtoG29Mw4nSyg+mjM3b8N7iXm9\nOLX59fbDAWtBSldSZE22RXd3CvlFOG/EnKBXSjBtEqfyxYSnyOPkMPBYWGL/ApkX\nSvPYJ4LKdvipYToKFh3y9kk2gk1DcDBDyaaHvR+3rv1u3aoy7/s2EltAfDS3ZQIq\n7/cWTLJml/lleeB/Y6rPj8xqeCYhE5ahw9gsV/Mdqatl24V9Tks30iijx0Hhw+Gx\nkATUikMGr2GDVqoIRga5kXI7CzYff4rkc0Twn47fMHHHe/KY9M2yVnMHUXmAZwbG\nM1cMI/NH1DjevCKdGBLcRJlhuLPKF/anuQENBFyUD8sBCADIpd7r7GuPd6n/Ikxe\nu6h7umV6IIPoAm88xCYpTbSZiaK30Svh6Ywra9jfE2KlU9o6Y/art8ip0VJ3m07L\n4RSfSpnzqgSwdjSq5hNour2Fo/BzYhK7yaz2AzVSbe33R0+RYhb4b/6N+bKbjwGF\nftCsqVFMH+PyvYkLbvxyQrHlA9woAZaNThI1ztO5rGSnGUR8xt84eup28WIFKg0K\nUEGUcTzz+8QGAwAra+0ewPXo/AkO+8BvZjDidP417u6gpBHOJ9qYIcO9FxHeqFyu\nYrjlrxowEgXn5wO8xuNz6Vu1vhHGDHGDsRbZF8pv1d5O+0F1G7ttZ2GRRgVBZPwi\nkiyRABEBAAGJATYEGAEIACAWIQSHYyc6Kj9l6HzQsau6vFFc9jxV/wUCXJQPywIb\nDAAKCRC6vFFc9jxV/9YOCACe8qmOSnKQpQfW+PqYOqo3dt7JyweTs3FkD6NT8Zml\ndYy/vkstbTjPpX6aTvUZjkb46BVi7AOneVHpD5GBqvRsZ9iVgDYHaehmLCdKiG5L\n3Tp90NN+QY5WDbsGmsyk6+6ZMYejb4qYfweQeduOj27aavCJdLkCYMoRKfcFYI8c\nFaNmEfKKy/r1PO20NXEG6t9t05K/frHy6ZG8bCNYdpagfFVot47r9JaQqWlTNtIR\n5+zkkSq/eG9BEtRij3a6cTdQbktdBzx2KBeI0PYc1vlZR0LpuFKZqY9vlE6vTGLR\nwMfrTEOvx0NxUM3rpaCgEmuWbB1G1Hu371oyr4srrr+N\n=28dr\n-----END PGP PUBLIC KEY BLOCK-----\n", + Format: "%h %l %u %{now}V %{req.method}V %{req.url}V %>s %{resp.http.Content-Length}V", + FormatVersion: 2, + MessageType: "classic", + Placement: "waf_debug", }) }) if err != nil { diff --git a/fastly/cache_setting.go b/fastly/cache_setting.go index 07242ac0a..41d707b98 100644 --- a/fastly/cache_setting.go +++ b/fastly/cache_setting.go @@ -88,11 +88,11 @@ type CreateCacheSettingInput struct { // ServiceVersion is the specific configuration version (required). ServiceVersion int - Name *string `form:"name,omitempty"` + Name string `form:"name,omitempty"` Action CacheSettingAction `form:"action,omitempty"` - TTL *uint `form:"ttl,omitempty"` - StaleTTL *uint `form:"stale_ttl,omitempty"` - CacheCondition *string `form:"cache_condition,omitempty"` + TTL uint `form:"ttl,omitempty"` + StaleTTL uint `form:"stale_ttl,omitempty"` + CacheCondition string `form:"cache_condition,omitempty"` } // CreateCacheSetting creates a new Fastly cache setting. diff --git a/fastly/cache_setting_test.go b/fastly/cache_setting_test.go index e6ee4cfde..7a064ed5c 100644 --- a/fastly/cache_setting_test.go +++ b/fastly/cache_setting_test.go @@ -17,10 +17,10 @@ func TestClient_CacheSettings(t *testing.T) { cacheSetting, err = c.CreateCacheSetting(&CreateCacheSettingInput{ ServiceID: testServiceID, ServiceVersion: tv.Number, - Name: String("test-cache-setting"), + Name: "test-cache-setting", Action: CacheSettingActionCache, - TTL: Uint(1234), - StaleTTL: Uint(1500), + TTL: 1234, + StaleTTL: 1500, }) }) if err != nil { diff --git a/fastly/condition.go b/fastly/condition.go index cfbec89c7..08ed29940 100644 --- a/fastly/condition.go +++ b/fastly/condition.go @@ -73,10 +73,10 @@ type CreateConditionInput struct { // ServiceVersion is the specific configuration version (required). ServiceVersion int - Name *string `form:"name,omitempty"` - Statement *string `form:"statement,omitempty"` - Type *string `form:"type,omitempty"` - Priority *int `form:"priority,omitempty"` + Name string `form:"name,omitempty"` + Statement string `form:"statement,omitempty"` + Type string `form:"type,omitempty"` + Priority int `form:"priority,omitempty"` } // CreateCondition creates a new Fastly condition. diff --git a/fastly/condition_test.go b/fastly/condition_test.go index 7f6990574..7b3e54ae1 100644 --- a/fastly/condition_test.go +++ b/fastly/condition_test.go @@ -17,10 +17,10 @@ func TestClient_Conditions(t *testing.T) { condition, err = c.CreateCondition(&CreateConditionInput{ ServiceID: testServiceID, ServiceVersion: tv.Number, - Name: String("test/condition"), - Statement: String("req.url~+\"index.html\""), - Type: String("REQUEST"), - Priority: Int(1), + Name: "test/condition", + Statement: "req.url~+\"index.html\"", + Type: "REQUEST", + Priority: 1, }) }) if err != nil { diff --git a/fastly/content.go b/fastly/content.go index de6113f15..26127b78f 100644 --- a/fastly/content.go +++ b/fastly/content.go @@ -26,7 +26,7 @@ type EdgeCheckResponse struct { // EdgeCheckInput is used as input to the EdgeCheck function. type EdgeCheckInput struct { - URL *string `form:"url,omitempty"` + URL string `form:"url,omitempty"` } // EdgeCheck queries the edge cache for all of Fastly's servers for the given @@ -34,7 +34,7 @@ type EdgeCheckInput struct { func (c *Client) EdgeCheck(i *EdgeCheckInput) ([]*EdgeCheck, error) { resp, err := c.Get("/content/edge_check", &RequestOptions{ Params: map[string]string{ - "url": *i.URL, + "url": i.URL, }, }) if err != nil { diff --git a/fastly/content_test.go b/fastly/content_test.go index 958ff50d2..ca5f666eb 100644 --- a/fastly/content_test.go +++ b/fastly/content_test.go @@ -9,7 +9,7 @@ func TestClient_EdgeCheck(t *testing.T) { var edges []*EdgeCheck record(t, "content/check", func(c *Client) { edges, err = c.EdgeCheck(&EdgeCheckInput{ - URL: String("releases.hashicorp.com"), + URL: "releases.hashicorp.com", }) }) if err != nil { diff --git a/fastly/dictionary.go b/fastly/dictionary.go index 5bd021b78..cb8e832bd 100644 --- a/fastly/dictionary.go +++ b/fastly/dictionary.go @@ -71,7 +71,7 @@ type CreateDictionaryInput struct { // ServiceVersion is the specific configuration version (required). ServiceVersion int - Name *string `form:"name,omitempty"` + Name string `form:"name,omitempty"` WriteOnly *Compatibool `form:"write_only,omitempty"` } diff --git a/fastly/dictionary_item.go b/fastly/dictionary_item.go index 0508116b5..9f6593241 100644 --- a/fastly/dictionary_item.go +++ b/fastly/dictionary_item.go @@ -71,8 +71,8 @@ type CreateDictionaryItemInput struct { // DictionaryID is the ID of the dictionary to retrieve items for (required). DictionaryID string - ItemKey *string `form:"item_key,omitempty"` - ItemValue *string `form:"item_value,omitempty"` + ItemKey string `form:"item_key,omitempty"` + ItemValue string `form:"item_value,omitempty"` } // CreateDictionaryItem creates a new Fastly dictionary item. diff --git a/fastly/dictionary_item_test.go b/fastly/dictionary_item_test.go index 17cf3b268..00f5e0b3b 100644 --- a/fastly/dictionary_item_test.go +++ b/fastly/dictionary_item_test.go @@ -22,8 +22,8 @@ func TestClient_DictionaryItems(t *testing.T) { createdDictionaryItem, err = c.CreateDictionaryItem(&CreateDictionaryItemInput{ ServiceID: testService.ID, DictionaryID: testDictionary.ID, - ItemKey: String("test-dictionary-item"), - ItemValue: String("value"), + ItemKey: "test-dictionary-item", + ItemValue: "value", }) }) if err != nil { diff --git a/fastly/dictionary_test.go b/fastly/dictionary_test.go index 489564a13..7b597713c 100644 --- a/fastly/dictionary_test.go +++ b/fastly/dictionary_test.go @@ -16,7 +16,7 @@ func TestClient_Dictionaries(t *testing.T) { d, err = c.CreateDictionary(&CreateDictionaryInput{ ServiceID: testServiceID, ServiceVersion: testVersion.Number, - Name: String("test_dictionary"), + Name: "test_dictionary", }) }) if err != nil { diff --git a/fastly/diff_test.go b/fastly/diff_test.go index 87e75c626..d7d1ddc17 100644 --- a/fastly/diff_test.go +++ b/fastly/diff_test.go @@ -34,8 +34,8 @@ func TestClient_Diff(t *testing.T) { _, err = c.CreateBackend(&CreateBackendInput{ ServiceID: testServiceID, ServiceVersion: tv2.Number, - Name: String("test-backend"), - Address: String("integ-test.go-fastly.com"), + Name: "test-backend", + Address: "integ-test.go-fastly.com", }) }) if err != nil { diff --git a/fastly/director.go b/fastly/director.go index 8978d0733..5c2bf115f 100644 --- a/fastly/director.go +++ b/fastly/director.go @@ -92,13 +92,13 @@ type CreateDirectorInput struct { // ServiceVersion is the specific configuration version (required). ServiceVersion int - Name *string `form:"name,omitempty"` - Comment *string `form:"comment,omitempty"` - Shield *string `form:"shield,omitempty"` - Quorum *uint `form:"quorum,omitempty"` + Name string `form:"name,omitempty"` + Comment string `form:"comment,omitempty"` + Shield string `form:"shield,omitempty"` + Quorum uint `form:"quorum,omitempty"` Type DirectorType `form:"type,omitempty"` - Retries *uint `form:"retries,omitempty"` - Capacity *uint `form:"capacity,omitempty"` + Retries uint `form:"retries,omitempty"` + Capacity uint `form:"capacity,omitempty"` } // CreateDirector creates a new Fastly director. diff --git a/fastly/director_test.go b/fastly/director_test.go index 2cb880c03..7a95e23ec 100644 --- a/fastly/director_test.go +++ b/fastly/director_test.go @@ -17,10 +17,10 @@ func TestClient_Directors(t *testing.T) { b, err = c.CreateDirector(&CreateDirectorInput{ ServiceID: testServiceID, ServiceVersion: tv.Number, - Name: String("test-director"), - Quorum: Uint(50), + Name: "test-director", + Quorum: 50, Type: DirectorTypeRandom, - Retries: Uint(5), + Retries: 5, }) }) if err != nil { diff --git a/fastly/domain.go b/fastly/domain.go index ff2fa87dc..01ce4176e 100644 --- a/fastly/domain.go +++ b/fastly/domain.go @@ -74,7 +74,7 @@ type CreateDomainInput struct { Name string `form:"name"` // Comment is a personal, freeform descriptive note. - Comment *string `form:"comment,omitempty"` + Comment string `form:"comment,omitempty"` } // CreateDomain creates a new domain with the given information. diff --git a/fastly/domain_test.go b/fastly/domain_test.go index 204f76b61..5d25a38f1 100644 --- a/fastly/domain_test.go +++ b/fastly/domain_test.go @@ -18,7 +18,7 @@ func TestClient_Domains(t *testing.T) { ServiceID: testServiceID, ServiceVersion: tv.Number, Name: "integ-test.go-fastly.com", - Comment: String("comment"), + Comment: "comment", }) }) if err != nil { diff --git a/fastly/fastly_test.go b/fastly/fastly_test.go index b0c6ecf35..cb4e06cf9 100644 --- a/fastly/fastly_test.go +++ b/fastly/fastly_test.go @@ -126,9 +126,9 @@ func createTestService(t *testing.T, serviceFixture string, serviceNameSuffix st record(t, serviceFixture, func(client *Client) { service, err = client.CreateService(&CreateServiceInput{ - Name: String(fmt.Sprintf("test_service_%s", serviceNameSuffix)), - Comment: String("go-fastly client test"), - Type: String(ServiceTypeVCL), + Name: fmt.Sprintf("test_service_%s", serviceNameSuffix), + Comment: "go-fastly client test", + Type: ServiceTypeVCL, }) }) if err != nil { @@ -145,9 +145,9 @@ func createTestServiceWasm(t *testing.T, serviceFixture string, serviceNameSuffi record(t, serviceFixture, func(client *Client) { service, err = client.CreateService(&CreateServiceInput{ - Name: String(fmt.Sprintf("test_service_wasm_%s", serviceNameSuffix)), - Comment: String("go-fastly wasm client test"), - Type: String(ServiceTypeWasm), + Name: fmt.Sprintf("test_service_wasm_%s", serviceNameSuffix), + Comment: "go-fastly wasm client test", + Type: ServiceTypeWasm, }) }) if err != nil { @@ -200,7 +200,7 @@ func createTestDictionary(t *testing.T, dictionaryFixture string, serviceId stri dictionary, err = client.CreateDictionary(&CreateDictionaryInput{ ServiceID: serviceId, ServiceVersion: version, - Name: String(fmt.Sprintf("test_dictionary_%s", dictionaryNameSuffix)), + Name: fmt.Sprintf("test_dictionary_%s", dictionaryNameSuffix), }) }) if err != nil { @@ -286,14 +286,14 @@ func createTestLogging(t *testing.T, fixture, serviceID string, serviceNumber in log, err = c.CreateSyslog(&CreateSyslogInput{ ServiceID: serviceID, ServiceVersion: serviceNumber, - Name: String("test-syslog"), - Address: String("example.com"), - Hostname: String("example.com"), - Port: Uint(1234), - Token: String("abcd1234"), - Format: String("format"), - FormatVersion: Uint(2), - MessageType: String("classic"), + Name: "test-syslog", + Address: "example.com", + Hostname: "example.com", + Port: 1234, + Token: "abcd1234", + Format: "format", + FormatVersion: 2, + MessageType: "classic", }) }) if err != nil { @@ -344,10 +344,10 @@ func createTestWAFCondition(t *testing.T, fixture, serviceID, name string, servi condition, err = c.CreateCondition(&CreateConditionInput{ ServiceID: serviceID, ServiceVersion: serviceNumber, - Name: String(name), - Statement: String("req.url~+\"index.html\""), - Type: String("PREFETCH"), // This must be a prefetch condition - Priority: Int(1), + Name: name, + Statement: "req.url~+\"index.html\"", + Type: "PREFETCH", // This must be a prefetch condition + Priority: 1, }) }) if err != nil { @@ -381,8 +381,8 @@ func createTestWAFResponseObject(t *testing.T, fixture, serviceID, name string, ro, err = c.CreateResponseObject(&CreateResponseObjectInput{ ServiceID: serviceID, ServiceVersion: serviceNumber, - Name: String(name), - Status: Uint(403), + Name: name, + Status: 403, }) }) if err != nil { diff --git a/fastly/ftp.go b/fastly/ftp.go index 56027886a..21340a44a 100644 --- a/fastly/ftp.go +++ b/fastly/ftp.go @@ -83,21 +83,21 @@ type CreateFTPInput struct { // ServiceVersion is the specific configuration version (required). ServiceVersion int - Name *string `form:"name,omitempty"` - Address *string `form:"address,omitempty"` - Port *uint `form:"port,omitempty"` - Username *string `form:"user,omitempty"` - Password *string `form:"password,omitempty"` - PublicKey *string `form:"public_key,omitempty"` - Path *string `form:"path,omitempty"` - Period *uint `form:"period,omitempty"` - FormatVersion *uint `form:"format_version,omitempty"` - GzipLevel *uint8 `form:"gzip_level,omitempty"` - Format *string `form:"format,omitempty"` - ResponseCondition *string `form:"response_condition,omitempty"` - MessageType *string `form:"message_type,omitempty"` - TimestampFormat *string `form:"timestamp_format,omitempty"` - Placement *string `form:"placement,omitempty"` + Name string `form:"name,omitempty"` + Address string `form:"address,omitempty"` + Port uint `form:"port,omitempty"` + Username string `form:"user,omitempty"` + Password string `form:"password,omitempty"` + PublicKey string `form:"public_key,omitempty"` + Path string `form:"path,omitempty"` + Period uint `form:"period,omitempty"` + FormatVersion uint `form:"format_version,omitempty"` + GzipLevel uint8 `form:"gzip_level,omitempty"` + Format string `form:"format,omitempty"` + ResponseCondition string `form:"response_condition,omitempty"` + MessageType string `form:"message_type,omitempty"` + TimestampFormat string `form:"timestamp_format,omitempty"` + Placement string `form:"placement,omitempty"` } // CreateFTP creates a new Fastly FTP. diff --git a/fastly/ftp_test.go b/fastly/ftp_test.go index d75eaa835..c3338eaec 100644 --- a/fastly/ftp_test.go +++ b/fastly/ftp_test.go @@ -16,20 +16,20 @@ func TestClient_FTPs(t *testing.T) { ftp, err = c.CreateFTP(&CreateFTPInput{ ServiceID: testServiceID, ServiceVersion: tv.Number, - Name: String("test-ftp"), - Address: String("example.com"), - Port: Uint(1234), - PublicKey: String(pgpPublicKey()), - Username: String("username"), - Password: String("password"), - Path: String("/dir"), - Period: Uint(12), - GzipLevel: Uint8(9), - FormatVersion: Uint(2), - Format: String("format"), - TimestampFormat: String("%Y"), - Placement: String("waf_debug"), - MessageType: String("classic"), + Name: "test-ftp", + Address: "example.com", + Port: 1234, + PublicKey: pgpPublicKey(), + Username: "username", + Password: "password", + Path: "/dir", + Period: 12, + GzipLevel: 9, + FormatVersion: 2, + Format: "format", + TimestampFormat: "%Y", + Placement: "waf_debug", + MessageType: "classic", }) }) if err != nil { diff --git a/fastly/gcs.go b/fastly/gcs.go index 211c6975f..d5ab15081 100644 --- a/fastly/gcs.go +++ b/fastly/gcs.go @@ -81,19 +81,19 @@ type CreateGCSInput struct { // ServiceVersion is the specific configuration version (required). ServiceVersion int - Name *string `form:"name,omitempty"` - Bucket *string `form:"bucket_name,omitempty"` - User *string `form:"user,omitempty"` - SecretKey *string `form:"secret_key,omitempty"` - Path *string `form:"path,omitempty"` - Period *uint `form:"period,omitempty"` - FormatVersion *uint `form:"format_version,omitempty"` - GzipLevel *uint8 `form:"gzip_level,omitempty"` - Format *string `form:"format,omitempty"` - MessageType *string `form:"message_type,omitempty"` - ResponseCondition *string `form:"response_condition,omitempty"` - TimestampFormat *string `form:"timestamp_format,omitempty"` - Placement *string `form:"placement,omitempty"` + Name string `form:"name,omitempty"` + Bucket string `form:"bucket_name,omitempty"` + User string `form:"user,omitempty"` + SecretKey string `form:"secret_key,omitempty"` + Path string `form:"path,omitempty"` + Period uint `form:"period,omitempty"` + FormatVersion uint `form:"format_version,omitempty"` + GzipLevel uint8 `form:"gzip_level,omitempty"` + Format string `form:"format,omitempty"` + MessageType string `form:"message_type,omitempty"` + ResponseCondition string `form:"response_condition,omitempty"` + TimestampFormat string `form:"timestamp_format,omitempty"` + Placement string `form:"placement,omitempty"` } // CreateGCS creates a new Fastly GCS. diff --git a/fastly/gcs_test.go b/fastly/gcs_test.go index dcc13333c..e4f7146a7 100644 --- a/fastly/gcs_test.go +++ b/fastly/gcs_test.go @@ -17,18 +17,18 @@ func TestClient_GCSs(t *testing.T) { gcs, err = c.CreateGCS(&CreateGCSInput{ ServiceID: testServiceID, ServiceVersion: tv.Number, - Name: String("test-gcs"), - Bucket: String("bucket"), - User: String("user"), - SecretKey: String("-----BEGIN PRIVATE KEY-----\nMIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQC9aQoqdHVA86oq\nTdRQ5HqwMfpiLBBMKNQcAJsO71RKNrDWwJJZiyYbvM4FOWRZFtRSdPIDgX0C0Wg1\nNnqWYvHDyA5Ug+T8kowiQDn56dU6Km2FWO4wnqZeA8q5G7rQVXlqdibuiP7FglHA\neURUzFsqyymXMUGrqDPqrHsVWC2E3NTJEb4QlywtrwI13qbhlvTx6/9oRfUjytXJ\nRuUIE5xL8yhRCagNr5ZW250aa+wBwu5DSCk5fDNr0eDuZjw84WHDll+mHxBFGV+X\nKJ5jCOmGumGqjVWZesJpNN1My3M9bsY9layNJJ0eiDeHDEi/yXhhO/mNEXhvhq/R\nfN0Jh2A3AgMBAAECggEAef+CEL5aF6/aVs0yh7fiXkKSp1ECXkud8ztgpEn63KJF\nXM1EdnBt50fA2xSQUeGmeEXi6+cngf0nRb8FToAEgLoGoOEjSJuLrzP3I8U9Fe3m\nBRG2uZI2Ti/bD0eRGEc1oSDhCpsqnkTGK1bwcD4AKpwY+c08Izh/2BOoY6McDoqh\ndQ89jzTuMtD4cNlnPiIrY9HbxoNjshK2ax1OaeXyYKZFG1TxqMFv5gA/G5+S3Cwr\nVG4fkAxYi5vdIK3b8jUXrTM/kpoTl+d3dlQ7rRZYf7KyT31/HtJ/GNzxFI6upzO7\niDNrrUOyeOPjWXdzUh9budv3j+6UfbYK7uZIoebHIQKBgQDykYX1L/akGaOC2tfS\njzCWUzPxGFYVZQ7zD1PM6UyouuS1KLURDEGk9RxqVzTPh/pYd8Ivnz3vOVski5Zt\n19ozLGxdtDhn122DcnVpfCdYzHBdAzPCzORenFohX+MhiX5fEotTlVi7wfOmzTP5\nhUCMSd/17bJrV4XMLhkdrMRBFQKBgQDH5fwV7o+Ej/ZfcdGIa3mAFazToPDzxhHU\nnwADxaxpNGKRU03XCaiYkykarLYdG6Rk+7dXUv8eLy+6Dcq1SWQtfCWKEor++IIp\n1RwWmFHfYriHGkmxSkkEkLFvL8old9xM5YWbEXc4QIXvnfR4BZxdyJHVzIDdbI2i\nFgcn17U3GwKBgDd1njMY7ENIuWHJt16k7m7wRwfwkH4DxQ89ieNn0+cgE/p3fC6R\nptCYWg7WMXThmhNwDi3lMrvnWTdZ0uL6XyEkHwKtmdfkIV3UZZPglv5uf6JEgSkg\nv3YCOXk3+y5HyWTjUIejtc334kVY1XFPThrFKTeJSSnRsP2l7IgkYBqhAoGAYGsr\nM3z1FrDF2nWw5odIfKJ30UAw2LRyB0eGH0uqhLgyzvwKcK2E98sLqYUi9llN6zOK\n1IEA8xM5hxl97AFxY4sdJEMbbi55wim7uZ5Q51nbvbbNUsmM/Lm6C/JWI8pzpVeU\nIR7EjYp50AE1WOsD6CyFQ0W35pWkn0jWvL4L938CgYEAlax4dLE5+YCG5DeLT1/N\nin6kQjl7JS4oCNlPEj6aRPLX2OJresI7oOn+uNatKvlVyfPm6rdxeHCmER1FpR7Q\nA/aNVjPeViKT/R4nK9ytsa+s/1IJVrwLFHJK3toGE660g5w3vKrCjWisMdP4yzzQ\nbv1KwcKoQbNVXwauH79JKc0=\n-----END PRIVATE KEY-----\n"), - Path: String("/path"), - Period: Uint(12), - GzipLevel: Uint8(9), - FormatVersion: Uint(2), - Format: String("format"), - MessageType: String("blank"), - TimestampFormat: String("%Y"), - Placement: String("waf_debug"), + Name: "test-gcs", + Bucket: "bucket", + User: "user", + SecretKey: "-----BEGIN PRIVATE KEY-----\nMIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQC9aQoqdHVA86oq\nTdRQ5HqwMfpiLBBMKNQcAJsO71RKNrDWwJJZiyYbvM4FOWRZFtRSdPIDgX0C0Wg1\nNnqWYvHDyA5Ug+T8kowiQDn56dU6Km2FWO4wnqZeA8q5G7rQVXlqdibuiP7FglHA\neURUzFsqyymXMUGrqDPqrHsVWC2E3NTJEb4QlywtrwI13qbhlvTx6/9oRfUjytXJ\nRuUIE5xL8yhRCagNr5ZW250aa+wBwu5DSCk5fDNr0eDuZjw84WHDll+mHxBFGV+X\nKJ5jCOmGumGqjVWZesJpNN1My3M9bsY9layNJJ0eiDeHDEi/yXhhO/mNEXhvhq/R\nfN0Jh2A3AgMBAAECggEAef+CEL5aF6/aVs0yh7fiXkKSp1ECXkud8ztgpEn63KJF\nXM1EdnBt50fA2xSQUeGmeEXi6+cngf0nRb8FToAEgLoGoOEjSJuLrzP3I8U9Fe3m\nBRG2uZI2Ti/bD0eRGEc1oSDhCpsqnkTGK1bwcD4AKpwY+c08Izh/2BOoY6McDoqh\ndQ89jzTuMtD4cNlnPiIrY9HbxoNjshK2ax1OaeXyYKZFG1TxqMFv5gA/G5+S3Cwr\nVG4fkAxYi5vdIK3b8jUXrTM/kpoTl+d3dlQ7rRZYf7KyT31/HtJ/GNzxFI6upzO7\niDNrrUOyeOPjWXdzUh9budv3j+6UfbYK7uZIoebHIQKBgQDykYX1L/akGaOC2tfS\njzCWUzPxGFYVZQ7zD1PM6UyouuS1KLURDEGk9RxqVzTPh/pYd8Ivnz3vOVski5Zt\n19ozLGxdtDhn122DcnVpfCdYzHBdAzPCzORenFohX+MhiX5fEotTlVi7wfOmzTP5\nhUCMSd/17bJrV4XMLhkdrMRBFQKBgQDH5fwV7o+Ej/ZfcdGIa3mAFazToPDzxhHU\nnwADxaxpNGKRU03XCaiYkykarLYdG6Rk+7dXUv8eLy+6Dcq1SWQtfCWKEor++IIp\n1RwWmFHfYriHGkmxSkkEkLFvL8old9xM5YWbEXc4QIXvnfR4BZxdyJHVzIDdbI2i\nFgcn17U3GwKBgDd1njMY7ENIuWHJt16k7m7wRwfwkH4DxQ89ieNn0+cgE/p3fC6R\nptCYWg7WMXThmhNwDi3lMrvnWTdZ0uL6XyEkHwKtmdfkIV3UZZPglv5uf6JEgSkg\nv3YCOXk3+y5HyWTjUIejtc334kVY1XFPThrFKTeJSSnRsP2l7IgkYBqhAoGAYGsr\nM3z1FrDF2nWw5odIfKJ30UAw2LRyB0eGH0uqhLgyzvwKcK2E98sLqYUi9llN6zOK\n1IEA8xM5hxl97AFxY4sdJEMbbi55wim7uZ5Q51nbvbbNUsmM/Lm6C/JWI8pzpVeU\nIR7EjYp50AE1WOsD6CyFQ0W35pWkn0jWvL4L938CgYEAlax4dLE5+YCG5DeLT1/N\nin6kQjl7JS4oCNlPEj6aRPLX2OJresI7oOn+uNatKvlVyfPm6rdxeHCmER1FpR7Q\nA/aNVjPeViKT/R4nK9ytsa+s/1IJVrwLFHJK3toGE660g5w3vKrCjWisMdP4yzzQ\nbv1KwcKoQbNVXwauH79JKc0=\n-----END PRIVATE KEY-----\n", + Path: "/path", + Period: 12, + GzipLevel: 9, + FormatVersion: 2, + Format: "format", + MessageType: "blank", + TimestampFormat: "%Y", + Placement: "waf_debug", }) }) if err != nil { diff --git a/fastly/gzip.go b/fastly/gzip.go index 9d068e93a..b50353f82 100644 --- a/fastly/gzip.go +++ b/fastly/gzip.go @@ -72,10 +72,10 @@ type CreateGzipInput struct { // ServiceVersion is the specific configuration version (required). ServiceVersion int - Name *string `form:"name,omitempty"` - ContentTypes string `form:"content_types"` - Extensions string `form:"extensions"` - CacheCondition *string `form:"cache_condition,omitempty"` + Name string `form:"name,omitempty"` + ContentTypes string `form:"content_types"` + Extensions string `form:"extensions"` + CacheCondition string `form:"cache_condition,omitempty"` } // CreateGzip creates a new Fastly Gzip. diff --git a/fastly/gzip_test.go b/fastly/gzip_test.go index 43263666a..c6fac7067 100644 --- a/fastly/gzip_test.go +++ b/fastly/gzip_test.go @@ -17,7 +17,7 @@ func TestClient_Gzips(t *testing.T) { gzip, err = c.CreateGzip(&CreateGzipInput{ ServiceID: testServiceID, ServiceVersion: tv.Number, - Name: String("test-gzip"), + Name: "test-gzip", ContentTypes: "text/html text/css", Extensions: "html css", }) @@ -32,7 +32,7 @@ func TestClient_Gzips(t *testing.T) { gzipomit, err = c.CreateGzip(&CreateGzipInput{ ServiceID: testServiceID, ServiceVersion: tv.Number, - Name: String("test-gzip-omit"), + Name: "test-gzip-omit", }) }) if err != nil { diff --git a/fastly/header.go b/fastly/header.go index 15516792e..68b87d228 100644 --- a/fastly/header.go +++ b/fastly/header.go @@ -123,18 +123,18 @@ type CreateHeaderInput struct { // ServiceVersion is the specific configuration version (required). ServiceVersion int - Name *string `form:"name,omitempty"` + Name string `form:"name,omitempty"` Action HeaderAction `form:"action,omitempty"` IgnoreIfSet *Compatibool `form:"ignore_if_set,omitempty"` Type HeaderType `form:"type,omitempty"` - Destination *string `form:"dst,omitempty"` - Source *string `form:"src,omitempty"` - Regex *string `form:"regex,omitempty"` - Substitution *string `form:"substitution,omitempty"` - Priority *uint `form:"priority,omitempty"` - RequestCondition *string `form:"request_condition,omitempty"` - CacheCondition *string `form:"cache_condition,omitempty"` - ResponseCondition *string `form:"response_condition,omitempty"` + Destination string `form:"dst,omitempty"` + Source string `form:"src,omitempty"` + Regex string `form:"regex,omitempty"` + Substitution string `form:"substitution,omitempty"` + Priority uint `form:"priority,omitempty"` + RequestCondition string `form:"request_condition,omitempty"` + CacheCondition string `form:"cache_condition,omitempty"` + ResponseCondition string `form:"response_condition,omitempty"` } // CreateHeader creates a new Fastly header. diff --git a/fastly/header_test.go b/fastly/header_test.go index ad4a8c43b..0ee100356 100644 --- a/fastly/header_test.go +++ b/fastly/header_test.go @@ -17,15 +17,15 @@ func TestClient_Headers(t *testing.T) { h, err = c.CreateHeader(&CreateHeaderInput{ ServiceID: testServiceID, ServiceVersion: tv.Number, - Name: String("test-header"), + Name: "test-header", Action: HeaderActionSet, IgnoreIfSet: CBool(false), Type: HeaderTypeRequest, - Destination: String("http.foo"), - Source: String("client.ip"), - Regex: String("foobar"), - Substitution: String("123"), - Priority: Uint(50), + Destination: "http.foo", + Source: "client.ip", + Regex: "foobar", + Substitution: "123", + Priority: 50, }) }) if err != nil { diff --git a/fastly/health_check.go b/fastly/health_check.go index 12df3476c..75c213433 100644 --- a/fastly/health_check.go +++ b/fastly/health_check.go @@ -81,18 +81,18 @@ type CreateHealthCheckInput struct { // ServiceVersion is the specific configuration version (required). ServiceVersion int - Name *string `form:"name,omitempty"` - Comment *string `form:"comment,omitempty"` - Method *string `form:"method,omitempty"` - Host *string `form:"host,omitempty"` - Path *string `form:"path,omitempty"` - HTTPVersion *string `form:"http_version,omitempty"` - Timeout *uint `form:"timeout,omitempty"` - CheckInterval *uint `form:"check_interval,omitempty"` - ExpectedResponse *uint `form:"expected_response,omitempty"` - Window *uint `form:"window,omitempty"` - Threshold *uint `form:"threshold,omitempty"` - Initial *uint `form:"initial,omitempty"` + Name string `form:"name,omitempty"` + Comment string `form:"comment,omitempty"` + Method string `form:"method,omitempty"` + Host string `form:"host,omitempty"` + Path string `form:"path,omitempty"` + HTTPVersion string `form:"http_version,omitempty"` + Timeout uint `form:"timeout,omitempty"` + CheckInterval uint `form:"check_interval,omitempty"` + ExpectedResponse uint `form:"expected_response,omitempty"` + Window uint `form:"window,omitempty"` + Threshold uint `form:"threshold,omitempty"` + Initial uint `form:"initial,omitempty"` } // CreateHealthCheck creates a new Fastly health check. diff --git a/fastly/health_check_test.go b/fastly/health_check_test.go index 60b9e7015..18a166867 100644 --- a/fastly/health_check_test.go +++ b/fastly/health_check_test.go @@ -17,17 +17,17 @@ func TestClient_HealthChecks(t *testing.T) { hc, err = c.CreateHealthCheck(&CreateHealthCheckInput{ ServiceID: testServiceID, ServiceVersion: tv.Number, - Name: String("test-healthcheck"), - Method: String("HEAD"), - Host: String("example.com"), - Path: String("/foo"), - HTTPVersion: String("1.1"), - Timeout: Uint(1500), - CheckInterval: Uint(2500), - ExpectedResponse: Uint(200), - Window: Uint(5000), - Threshold: Uint(10), - Initial: Uint(10), + Name: "test-healthcheck", + Method: "HEAD", + Host: "example.com", + Path: "/foo", + HTTPVersion: "1.1", + Timeout: 1500, + CheckInterval: 2500, + ExpectedResponse: 200, + Window: 5000, + Threshold: 10, + Initial: 10, }) }) if err != nil { diff --git a/fastly/honeycomb.go b/fastly/honeycomb.go index 4cd85bffc..99ff8053a 100644 --- a/fastly/honeycomb.go +++ b/fastly/honeycomb.go @@ -75,13 +75,13 @@ type CreateHoneycombInput struct { // ServiceVersion is the specific configuration version (required). ServiceVersion int - Name *string `form:"name,omitempty"` - Format *string `form:"format,omitempty"` - FormatVersion *uint `form:"format_version,omitempty"` - Dataset *string `form:"dataset,omitempty"` - Token *string `form:"token,omitempty"` - ResponseCondition *string `form:"response_condition,omitempty"` - Placement *string `form:"placement,omitempty"` + Name string `form:"name,omitempty"` + Format string `form:"format,omitempty"` + FormatVersion uint `form:"format_version,omitempty"` + Dataset string `form:"dataset,omitempty"` + Token string `form:"token,omitempty"` + ResponseCondition string `form:"response_condition,omitempty"` + Placement string `form:"placement,omitempty"` } // CreateHoneycomb creates a new Fastly honeycomb. diff --git a/fastly/honeycomb_test.go b/fastly/honeycomb_test.go index 7df0f7258..eb123e3bd 100644 --- a/fastly/honeycomb_test.go +++ b/fastly/honeycomb_test.go @@ -19,12 +19,12 @@ func TestClient_Honeycombs(t *testing.T) { h, err = c.CreateHoneycomb(&CreateHoneycombInput{ ServiceID: testServiceID, ServiceVersion: tv.Number, - Name: String("test-honeycomb"), - Format: String("%h %l %u %t \"%r\" %>s %b"), - FormatVersion: Uint(2), - Placement: String("waf_debug"), - Token: String("super-secure-token"), - Dataset: String("testDataset"), + Name: "test-honeycomb", + Format: "%h %l %u %t \"%r\" %>s %b", + FormatVersion: 2, + Placement: "waf_debug", + Token: "super-secure-token", + Dataset: "testDataset", }) }) if err != nil { diff --git a/fastly/https.go b/fastly/https.go index e428d4808..0da58fc91 100644 --- a/fastly/https.go +++ b/fastly/https.go @@ -86,24 +86,24 @@ type CreateHTTPSInput struct { // ServiceVersion is the specific configuration version (required). ServiceVersion int - Name *string `form:"name,omitempty"` - ResponseCondition *string `form:"response_condition,omitempty"` - Format *string `form:"format,omitempty"` - URL *string `form:"url,omitempty"` - RequestMaxEntries *uint `form:"request_max_entries,omitempty"` - RequestMaxBytes *uint `form:"request_max_bytes,omitempty"` - ContentType *string `form:"content_type,omitempty"` - HeaderName *string `form:"header_name,omitempty"` - HeaderValue *string `form:"header_value,omitempty"` - Method *string `form:"method,omitempty"` - JSONFormat *string `form:"json_format,omitempty"` - Placement *string `form:"placement,omitempty"` - TLSCACert *string `form:"tls_ca_cert,omitempty"` - TLSClientCert *string `form:"tls_client_cert,omitempty"` - TLSClientKey *string `form:"tls_client_key,omitempty"` - TLSHostname *string `form:"tls_hostname,omitempty"` - MessageType *string `form:"message_type,omitempty"` - FormatVersion *uint `form:"format_version,omitempty"` + Name string `form:"name,omitempty"` + ResponseCondition string `form:"response_condition,omitempty"` + Format string `form:"format,omitempty"` + URL string `form:"url,omitempty"` + RequestMaxEntries uint `form:"request_max_entries,omitempty"` + RequestMaxBytes uint `form:"request_max_bytes,omitempty"` + ContentType string `form:"content_type,omitempty"` + HeaderName string `form:"header_name,omitempty"` + HeaderValue string `form:"header_value,omitempty"` + Method string `form:"method,omitempty"` + JSONFormat string `form:"json_format,omitempty"` + Placement string `form:"placement,omitempty"` + TLSCACert string `form:"tls_ca_cert,omitempty"` + TLSClientCert string `form:"tls_client_cert,omitempty"` + TLSClientKey string `form:"tls_client_key,omitempty"` + TLSHostname string `form:"tls_hostname,omitempty"` + MessageType string `form:"message_type,omitempty"` + FormatVersion uint `form:"format_version,omitempty"` } // CreateHTTPS creates a new Fastly HTTPS logging endpoint. diff --git a/fastly/https_test.go b/fastly/https_test.go index 588a5ffad..b742377af 100644 --- a/fastly/https_test.go +++ b/fastly/https_test.go @@ -40,23 +40,23 @@ Wm7DCfrPNGVwFWUQOmsPue9rZBgO h, err = c.CreateHTTPS(&CreateHTTPSInput{ ServiceID: testServiceID, ServiceVersion: tv.Number, - Name: String("test-https"), - Format: String("format"), - URL: String("https://example.com/"), - RequestMaxEntries: Uint(1), - RequestMaxBytes: Uint(1000), - ContentType: String("application/json"), - HeaderName: String("X-Example-Header"), - HeaderValue: String("ExampleValue"), - Method: String("PUT"), - JSONFormat: String("2"), - Placement: String("waf_debug"), - TLSCACert: String(caCert), - TLSClientCert: String(clientCert), - TLSClientKey: String(clientKey), - TLSHostname: String("example.com"), - MessageType: String("blank"), - FormatVersion: Uint(2), + Name: "test-https", + Format: "format", + URL: "https://example.com/", + RequestMaxEntries: 1, + RequestMaxBytes: 1000, + ContentType: "application/json", + HeaderName: "X-Example-Header", + HeaderValue: "ExampleValue", + Method: "PUT", + JSONFormat: "2", + Placement: "waf_debug", + TLSCACert: caCert, + TLSClientCert: clientCert, + TLSClientKey: clientKey, + TLSHostname: "example.com", + MessageType: "blank", + FormatVersion: 2, }) }) if err != nil { diff --git a/fastly/logentries.go b/fastly/logentries.go index 70b711b85..c84be304b 100644 --- a/fastly/logentries.go +++ b/fastly/logentries.go @@ -76,14 +76,14 @@ type CreateLogentriesInput struct { // ServiceVersion is the specific configuration version (required). ServiceVersion int - Name *string `form:"name,omitempty"` - Port *uint `form:"port,omitempty"` + Name string `form:"name,omitempty"` + Port uint `form:"port,omitempty"` UseTLS *Compatibool `form:"use_tls,omitempty"` - Token *string `form:"token,omitempty"` - Format *string `form:"format,omitempty"` - FormatVersion *uint `form:"format_version,omitempty"` - ResponseCondition *string `form:"response_condition,omitempty"` - Placement *string `form:"placement,omitempty"` + Token string `form:"token,omitempty"` + Format string `form:"format,omitempty"` + FormatVersion uint `form:"format_version,omitempty"` + ResponseCondition string `form:"response_condition,omitempty"` + Placement string `form:"placement,omitempty"` } // CreateLogentries creates a new Fastly logentries. diff --git a/fastly/logentries_test.go b/fastly/logentries_test.go index e7c681502..34731ea10 100644 --- a/fastly/logentries_test.go +++ b/fastly/logentries_test.go @@ -17,12 +17,12 @@ func TestClient_Logentries(t *testing.T) { le, err = c.CreateLogentries(&CreateLogentriesInput{ ServiceID: testServiceID, ServiceVersion: tv.Number, - Name: String("test-logentries"), - Port: Uint(1234), + Name: "test-logentries", + Port: 1234, UseTLS: CBool(true), - Token: String("abcd1234"), - Format: String("format"), - Placement: String("waf_debug"), + Token: "abcd1234", + Format: "format", + Placement: "waf_debug", }) }) if err != nil { diff --git a/fastly/papertrail.go b/fastly/papertrail.go index caa176781..804655bd4 100644 --- a/fastly/papertrail.go +++ b/fastly/papertrail.go @@ -75,16 +75,16 @@ type CreatePapertrailInput struct { // ServiceVersion is the specific configuration version (required). ServiceVersion int - Name *string `form:"name,omitempty"` - Address *string `form:"address,omitempty"` - Port *uint `form:"port,omitempty"` - FormatVersion *uint `form:"format_version,omitempty"` - Format *string `form:"format,omitempty"` - ResponseCondition *string `form:"response_condition,omitempty"` + Name string `form:"name,omitempty"` + Address string `form:"address,omitempty"` + Port uint `form:"port,omitempty"` + FormatVersion uint `form:"format_version,omitempty"` + Format string `form:"format,omitempty"` + ResponseCondition string `form:"response_condition,omitempty"` CreatedAt *time.Time `form:"created_at,omitempty"` UpdatedAt *time.Time `form:"updated_at,omitempty"` DeletedAt *time.Time `form:"deleted_at,omitempty"` - Placement *string `form:"placement,omitempty"` + Placement string `form:"placement,omitempty"` } // CreatePapertrail creates a new Fastly papertrail. diff --git a/fastly/papertrail_test.go b/fastly/papertrail_test.go index a60187347..8d8aaadab 100644 --- a/fastly/papertrail_test.go +++ b/fastly/papertrail_test.go @@ -17,12 +17,12 @@ func TestClient_Papertrails(t *testing.T) { p, err = c.CreatePapertrail(&CreatePapertrailInput{ ServiceID: testServiceID, ServiceVersion: tv.Number, - Name: String("test-papertrail"), - Address: String("integ-test.go-fastly.com"), - Port: Uint(1234), - FormatVersion: Uint(2), - Format: String("format"), - Placement: String("waf_debug"), + Name: "test-papertrail", + Address: "integ-test.go-fastly.com", + Port: 1234, + FormatVersion: 2, + Format: "format", + Placement: "waf_debug", }) }) if err != nil { diff --git a/fastly/request_setting.go b/fastly/request_setting.go index a78238c3c..b3ed75f0e 100644 --- a/fastly/request_setting.go +++ b/fastly/request_setting.go @@ -115,18 +115,18 @@ type CreateRequestSettingInput struct { // ServiceVersion is the specific configuration version (required). ServiceVersion int - Name *string `form:"name,omitempty"` + Name string `form:"name,omitempty"` ForceMiss *Compatibool `form:"force_miss,omitempty"` ForceSSL *Compatibool `form:"force_ssl,omitempty"` Action RequestSettingAction `form:"action,omitempty"` BypassBusyWait *Compatibool `form:"bypass_busy_wait,omitempty"` - MaxStaleAge *uint `form:"max_stale_age,omitempty"` - HashKeys *string `form:"hash_keys,omitempty"` + MaxStaleAge uint `form:"max_stale_age,omitempty"` + HashKeys string `form:"hash_keys,omitempty"` XForwardedFor RequestSettingXFF `form:"xff,omitempty"` TimerSupport *Compatibool `form:"timer_support,omitempty"` GeoHeaders *Compatibool `form:"geo_headers,omitempty"` - DefaultHost *string `form:"default_host,omitempty"` - RequestCondition *string `form:"request_condition,omitempty"` + DefaultHost string `form:"default_host,omitempty"` + RequestCondition string `form:"request_condition,omitempty"` } // CreateRequestSetting creates a new Fastly request settings. diff --git a/fastly/request_setting_test.go b/fastly/request_setting_test.go index a085c82ad..afa0c6d1f 100644 --- a/fastly/request_setting_test.go +++ b/fastly/request_setting_test.go @@ -17,17 +17,17 @@ func TestClient_RequestSettings(t *testing.T) { rs, err = c.CreateRequestSetting(&CreateRequestSettingInput{ ServiceID: testServiceID, ServiceVersion: tv.Number, - Name: String("test-request-setting"), + Name: "test-request-setting", ForceMiss: CBool(true), ForceSSL: CBool(true), Action: RequestSettingActionLookup, BypassBusyWait: CBool(true), - MaxStaleAge: Uint(30), - HashKeys: String("a,b,c"), + MaxStaleAge: 30, + HashKeys: "a,b,c", XForwardedFor: RequestSettingXFFLeave, TimerSupport: CBool(true), GeoHeaders: CBool(true), - DefaultHost: String("example.com"), + DefaultHost: "example.com", }) }) if err != nil { diff --git a/fastly/response_object.go b/fastly/response_object.go index 77fd4d5e5..77b0049f7 100644 --- a/fastly/response_object.go +++ b/fastly/response_object.go @@ -78,13 +78,13 @@ type CreateResponseObjectInput struct { // ServiceVersion is the specific configuration version (required). ServiceVersion int - Name *string `form:"name,omitempty"` - Status *uint `form:"status,omitempty"` - Response *string `form:"response,omitempty"` - Content *string `form:"content,omitempty"` - ContentType *string `form:"content_type,omitempty"` - RequestCondition *string `form:"request_condition,omitempty"` - CacheCondition *string `form:"cache_condition,omitempty"` + Name string `form:"name,omitempty"` + Status uint `form:"status,omitempty"` + Response string `form:"response,omitempty"` + Content string `form:"content,omitempty"` + ContentType string `form:"content_type,omitempty"` + RequestCondition string `form:"request_condition,omitempty"` + CacheCondition string `form:"cache_condition,omitempty"` } // CreateResponseObject creates a new Fastly response object. diff --git a/fastly/response_object_test.go b/fastly/response_object_test.go index ccc9b3f03..44657a72b 100644 --- a/fastly/response_object_test.go +++ b/fastly/response_object_test.go @@ -17,11 +17,11 @@ func TestClient_ResponseObjects(t *testing.T) { ro, err = c.CreateResponseObject(&CreateResponseObjectInput{ ServiceID: testServiceID, ServiceVersion: tv.Number, - Name: String("test-response-object"), - Status: Uint(200), - Response: String("Ok"), - Content: String("abcd"), - ContentType: String("text/plain"), + Name: "test-response-object", + Status: 200, + Response: "Ok", + Content: "abcd", + ContentType: "text/plain", }) }) if err != nil { diff --git a/fastly/s3.go b/fastly/s3.go index 1343a4c79..162b5b07f 100644 --- a/fastly/s3.go +++ b/fastly/s3.go @@ -96,23 +96,23 @@ type CreateS3Input struct { // ServiceVersion is the specific configuration version (required). ServiceVersion int - Name *string `form:"name,omitempty"` - BucketName *string `form:"bucket_name,omitempty"` - Domain *string `form:"domain,omitempty"` - AccessKey *string `form:"access_key,omitempty"` - SecretKey *string `form:"secret_key,omitempty"` - Path *string `form:"path,omitempty"` - Period *uint `form:"period,omitempty"` - GzipLevel *uint `form:"gzip_level,omitempty"` - Format *string `form:"format,omitempty"` - MessageType *string `form:"message_type,omitempty"` - FormatVersion *uint `form:"format_version,omitempty"` - ResponseCondition *string `form:"response_condition,omitempty"` - TimestampFormat *string `form:"timestamp_format,omitempty"` + Name string `form:"name,omitempty"` + BucketName string `form:"bucket_name,omitempty"` + Domain string `form:"domain,omitempty"` + AccessKey string `form:"access_key,omitempty"` + SecretKey string `form:"secret_key,omitempty"` + Path string `form:"path,omitempty"` + Period uint `form:"period,omitempty"` + GzipLevel uint `form:"gzip_level,omitempty"` + Format string `form:"format,omitempty"` + MessageType string `form:"message_type,omitempty"` + FormatVersion uint `form:"format_version,omitempty"` + ResponseCondition string `form:"response_condition,omitempty"` + TimestampFormat string `form:"timestamp_format,omitempty"` Redundancy S3Redundancy `form:"redundancy,omitempty"` - Placement *string `form:"placement,omitempty"` - PublicKey *string `form:"public_key,omitempty"` - ServerSideEncryptionKMSKeyID *string `form:"server_side_encryption_kms_key_id,omitempty"` + Placement string `form:"placement,omitempty"` + PublicKey string `form:"public_key,omitempty"` + ServerSideEncryptionKMSKeyID string `form:"server_side_encryption_kms_key_id,omitempty"` ServerSideEncryption S3ServerSideEncryption `form:"server_side_encryption,omitempty"` } @@ -126,7 +126,7 @@ func (c *Client) CreateS3(i *CreateS3Input) (*S3, error) { return nil, ErrMissingServiceVersion } - if i.ServerSideEncryption == S3ServerSideEncryptionKMS && *i.ServerSideEncryptionKMSKeyID == "" { + if i.ServerSideEncryption == S3ServerSideEncryptionKMS && i.ServerSideEncryptionKMSKeyID == "" { return nil, ErrMissingKMSKeyID } diff --git a/fastly/s3_test.go b/fastly/s3_test.go index a4abe88f8..fdf85f40f 100644 --- a/fastly/s3_test.go +++ b/fastly/s3_test.go @@ -17,23 +17,23 @@ func TestClient_S3s(t *testing.T) { s3, err = c.CreateS3(&CreateS3Input{ ServiceID: testServiceID, ServiceVersion: tv.Number, - Name: String("test-s3"), - BucketName: String("bucket-name"), - Domain: String("s3.us-east-1.amazonaws.com"), - AccessKey: String("AKIAIOSFODNN7EXAMPLE"), - SecretKey: String("wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"), - Path: String("/path"), - Period: Uint(12), - GzipLevel: Uint(9), - Format: String("format"), - FormatVersion: Uint(2), - ResponseCondition: String(""), - TimestampFormat: String("%Y"), - MessageType: String("classic"), + Name: "test-s3", + BucketName: "bucket-name", + Domain: "s3.us-east-1.amazonaws.com", + AccessKey: "AKIAIOSFODNN7EXAMPLE", + SecretKey: "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY", + Path: "/path", + Period: 12, + GzipLevel: 9, + Format: "format", + FormatVersion: 2, + ResponseCondition: "", + TimestampFormat: "%Y", + MessageType: "classic", Redundancy: S3RedundancyReduced, - Placement: String("waf_debug"), - PublicKey: String(pgpPublicKey()), - ServerSideEncryptionKMSKeyID: String("1234"), + Placement: "waf_debug", + PublicKey: pgpPublicKey(), + ServerSideEncryptionKMSKeyID: "1234", ServerSideEncryption: S3ServerSideEncryptionKMS, }) }) @@ -265,9 +265,9 @@ func TestClient_CreateS3_validation(t *testing.T) { _, err = testClient.CreateS3(&CreateS3Input{ ServiceID: "foo", ServiceVersion: 1, - Name: String("test-service"), + Name: "test-service", ServerSideEncryption: S3ServerSideEncryptionKMS, - ServerSideEncryptionKMSKeyID: String(""), + ServerSideEncryptionKMSKeyID: "", }) if err != ErrMissingKMSKeyID { t.Errorf("bad error: %s", err) diff --git a/fastly/service.go b/fastly/service.go index a15325eaa..2964d3d11 100644 --- a/fastly/service.go +++ b/fastly/service.go @@ -76,9 +76,9 @@ func (c *Client) ListServices(i *ListServicesInput) ([]*Service, error) { // CreateServiceInput is used as input to the CreateService function. type CreateServiceInput struct { - Name *string `form:"name,omitempty"` - Type *string `form:"type,omitempty"` - Comment *string `form:"comment,omitempty"` + Name string `form:"name,omitempty"` + Type string `form:"type,omitempty"` + Comment string `form:"comment,omitempty"` } // CreateService creates a new service with the given information. diff --git a/fastly/service_test.go b/fastly/service_test.go index e8f20a9a4..51fff108e 100644 --- a/fastly/service_test.go +++ b/fastly/service_test.go @@ -11,8 +11,8 @@ func TestClient_Services(t *testing.T) { var s *Service record(t, "services/create", func(c *Client) { s, err = c.CreateService(&CreateServiceInput{ - Name: String("test-service"), - Comment: String("comment"), + Name: "test-service", + Comment: "comment", }) }) if err != nil { diff --git a/fastly/splunk.go b/fastly/splunk.go index f60435925..db2a893de 100644 --- a/fastly/splunk.go +++ b/fastly/splunk.go @@ -77,15 +77,15 @@ type CreateSplunkInput struct { // ServiceVersion is the specific configuration version (required). ServiceVersion int - Name *string `form:"name,omitempty"` - URL *string `form:"url,omitempty"` - Format *string `form:"format,omitempty"` - FormatVersion *uint `form:"format_version,omitempty"` - ResponseCondition *string `form:"response_condition,omitempty"` - Placement *string `form:"placement,omitempty"` - Token *string `form:"token,omitempty"` - TLSCACert *string `form:"tls_ca_cert,omitempty"` - TLSHostname *string `form:"tls_hostname,omitempty"` + Name string `form:"name,omitempty"` + URL string `form:"url,omitempty"` + Format string `form:"format,omitempty"` + FormatVersion uint `form:"format_version,omitempty"` + ResponseCondition string `form:"response_condition,omitempty"` + Placement string `form:"placement,omitempty"` + Token string `form:"token,omitempty"` + TLSCACert string `form:"tls_ca_cert,omitempty"` + TLSHostname string `form:"tls_hostname,omitempty"` } // CreateSplunk creates a new Fastly splunk. diff --git a/fastly/splunk_test.go b/fastly/splunk_test.go index dfb54d176..1cef1bb1e 100644 --- a/fastly/splunk_test.go +++ b/fastly/splunk_test.go @@ -38,14 +38,14 @@ Wm7DCfrPNGVwFWUQOmsPue9rZBgO s, err = c.CreateSplunk(&CreateSplunkInput{ ServiceID: testServiceID, ServiceVersion: tv.Number, - Name: String("test-splunk"), - URL: String("https://mysplunkendpoint.example.com/services/collector/event"), - Format: String("%h %l %u %t \"%r\" %>s %b"), - FormatVersion: Uint(2), - Placement: String("waf_debug"), - Token: String("super-secure-token"), - TLSCACert: String(caCert), - TLSHostname: String("example.com"), + Name: "test-splunk", + URL: "https://mysplunkendpoint.example.com/services/collector/event", + Format: "%h %l %u %t \"%r\" %>s %b", + FormatVersion: 2, + Placement: "waf_debug", + Token: "super-secure-token", + TLSCACert: caCert, + TLSHostname: "example.com", }) }) if err != nil { diff --git a/fastly/sumologic.go b/fastly/sumologic.go index b570b1a77..94069bb15 100644 --- a/fastly/sumologic.go +++ b/fastly/sumologic.go @@ -76,14 +76,14 @@ type CreateSumologicInput struct { // ServiceVersion is the specific configuration version (required). ServiceVersion int - Name *string `form:"name,omitempty"` - Address *string `form:"address,omitempty"` - URL *string `form:"url,omitempty"` - Format *string `form:"format,omitempty"` - ResponseCondition *string `form:"response_condition,omitempty"` - MessageType *string `form:"message_type,omitempty"` - FormatVersion *int `form:"format_version,omitempty"` - Placement *string `form:"placement,omitempty"` + Name string `form:"name,omitempty"` + Address string `form:"address,omitempty"` + URL string `form:"url,omitempty"` + Format string `form:"format,omitempty"` + ResponseCondition string `form:"response_condition,omitempty"` + MessageType string `form:"message_type,omitempty"` + FormatVersion int `form:"format_version,omitempty"` + Placement string `form:"placement,omitempty"` } // CreateSumologic creates a new Fastly sumologic. diff --git a/fastly/sumologic_test.go b/fastly/sumologic_test.go index 5c7b85b75..f4eebcf7e 100644 --- a/fastly/sumologic_test.go +++ b/fastly/sumologic_test.go @@ -17,12 +17,12 @@ func TestClient_Sumologics(t *testing.T) { s, err = c.CreateSumologic(&CreateSumologicInput{ ServiceID: testServiceID, ServiceVersion: tv.Number, - Name: String("test-sumologic"), - URL: String("https://foo.sumologic.com"), - Format: String("format"), - FormatVersion: Int(1), - MessageType: String("classic"), - Placement: String("waf_debug"), + Name: "test-sumologic", + URL: "https://foo.sumologic.com", + Format: "format", + FormatVersion: 1, + MessageType: "classic", + Placement: "waf_debug", }) }) if err != nil { diff --git a/fastly/syslog.go b/fastly/syslog.go index 7eb2ed995..9b7c89110 100644 --- a/fastly/syslog.go +++ b/fastly/syslog.go @@ -84,22 +84,22 @@ type CreateSyslogInput struct { // ServiceVersion is the specific configuration version (required). ServiceVersion int - Name *string `form:"name,omitempty"` - Address *string `form:"address,omitempty"` - Hostname *string `form:"hostname,omitempty"` - Port *uint `form:"port,omitempty"` + Name string `form:"name,omitempty"` + Address string `form:"address,omitempty"` + Hostname string `form:"hostname,omitempty"` + Port uint `form:"port,omitempty"` UseTLS *Compatibool `form:"use_tls,omitempty"` - IPV4 *string `form:"ipv4,omitempty"` - TLSCACert *string `form:"tls_ca_cert,omitempty"` - TLSHostname *string `form:"tls_hostname,omitempty"` - TLSClientCert *string `form:"tls_client_cert,omitempty"` - TLSClientKey *string `form:"tls_client_key,omitempty"` - Token *string `form:"token,omitempty"` - Format *string `form:"format,omitempty"` - FormatVersion *uint `form:"format_version,omitempty"` - MessageType *string `form:"message_type,omitempty"` - ResponseCondition *string `form:"response_condition,omitempty"` - Placement *string `form:"placement,omitempty"` + IPV4 string `form:"ipv4,omitempty"` + TLSCACert string `form:"tls_ca_cert,omitempty"` + TLSHostname string `form:"tls_hostname,omitempty"` + TLSClientCert string `form:"tls_client_cert,omitempty"` + TLSClientKey string `form:"tls_client_key,omitempty"` + Token string `form:"token,omitempty"` + Format string `form:"format,omitempty"` + FormatVersion uint `form:"format_version,omitempty"` + MessageType string `form:"message_type,omitempty"` + ResponseCondition string `form:"response_condition,omitempty"` + Placement string `form:"placement,omitempty"` } // CreateSyslog creates a new Fastly syslog. diff --git a/fastly/syslog_test.go b/fastly/syslog_test.go index d5226e1aa..96f10b36c 100644 --- a/fastly/syslog_test.go +++ b/fastly/syslog_test.go @@ -40,20 +40,20 @@ Wm7DCfrPNGVwFWUQOmsPue9rZBgO s, err = c.CreateSyslog(&CreateSyslogInput{ ServiceID: testServiceID, ServiceVersion: tv.Number, - Name: String("test-syslog"), - Address: String("example.com"), - Hostname: String("example.com"), - Port: Uint(1234), + Name: "test-syslog", + Address: "example.com", + Hostname: "example.com", + Port: 1234, UseTLS: CBool(true), - TLSCACert: String(caCert), - TLSHostname: String("example.com"), - TLSClientCert: String(clientCert), - TLSClientKey: String(clientKey), - Token: String("abcd1234"), - Format: String("format"), - FormatVersion: Uint(2), - MessageType: String("classic"), - Placement: String("waf_debug"), + TLSCACert: caCert, + TLSHostname: "example.com", + TLSClientCert: clientCert, + TLSClientKey: clientKey, + Token: "abcd1234", + Format: "format", + FormatVersion: 2, + MessageType: "classic", + Placement: "waf_debug", }) }) if err != nil { diff --git a/fastly/tls.go b/fastly/tls.go index 5ca6d2661..285ee7515 100644 --- a/fastly/tls.go +++ b/fastly/tls.go @@ -105,8 +105,8 @@ func (c *Client) GetPrivateKey(i *GetPrivateKeyInput) (*PrivateKey, error) { // CreatePrivateKeyInput is used as input to the CreatePrivateKey function. type CreatePrivateKeyInput struct { - Key *string `jsonapi:"attr,key,omitempty"` - Name *string `jsonapi:"attr,name,omitempty"` + Key string `jsonapi:"attr,key,omitempty"` + Name string `jsonapi:"attr,name,omitempty"` } // CreatePrivateKey create a TLS private key. @@ -114,11 +114,11 @@ func (c *Client) CreatePrivateKey(i *CreatePrivateKeyInput) (*PrivateKey, error) p := "/tls/private_keys" - if *i.Key == "" { + if i.Key == "" { return nil, ErrMissingKey } - if *i.Name == "" { + if i.Name == "" { return nil, ErrMissingName } diff --git a/fastly/tls_test.go b/fastly/tls_test.go index 846f56202..4e438aff4 100644 --- a/fastly/tls_test.go +++ b/fastly/tls_test.go @@ -12,8 +12,8 @@ func TestClient_PrivateKey(t *testing.T) { var pk *PrivateKey record(t, fixtureBase+"create", func(c *Client) { pk, err = c.CreatePrivateKey(&CreatePrivateKeyInput{ - Key: String("-----BEGIN PRIVATE KEY-----\n...\n-----END PRIVATE KEY-----\n"), - Name: String("My private key"), + Key: "-----BEGIN PRIVATE KEY-----\n...\n-----END PRIVATE KEY-----\n", + Name: "My private key", }) }) if err != nil { @@ -98,8 +98,8 @@ func TestClient_CreatePrivateKey_validation(t *testing.T) { var err error record(t, "tls/create", func(c *Client) { _, err = c.CreatePrivateKey(&CreatePrivateKeyInput{ - Key: String("-----BEGIN PRIVATE KEY-----\n...\n-----END PRIVATE KEY-----\n"), - Name: String("My private key"), + Key: "-----BEGIN PRIVATE KEY-----\n...\n-----END PRIVATE KEY-----\n", + Name: "My private key", }) }) if err != nil { diff --git a/fastly/token.go b/fastly/token.go index 53ffe9ffb..daa15c68d 100644 --- a/fastly/token.go +++ b/fastly/token.go @@ -107,10 +107,10 @@ func (c *Client) GetTokenSelf() (*Token, error) { // CreateTokenInput is used as input to the Token function. type CreateTokenInput struct { - Name *string `form:"name,omitempty"` + Name string `form:"name,omitempty"` Scope TokenScope `form:"scope,omitempty"` - Username *string `form:"username,omitempty"` - Password *string `form:"password,omitempty"` + Username string `form:"username,omitempty"` + Password string `form:"password,omitempty"` Services []string `form:"services,omitempty"` ExpiresAt *time.Time `form:"expires_at,omitempty"` } diff --git a/fastly/token_test.go b/fastly/token_test.go index 3ebbf3b59..2ce42eba7 100644 --- a/fastly/token_test.go +++ b/fastly/token_test.go @@ -54,10 +54,10 @@ func TestClient_CreateToken(t *testing.T) { t.Parallel() input := &CreateTokenInput{ - Name: String("my-test-token"), + Name: "my-test-token", Scope: "global", - Username: String("xxxxxxxxxxxxxxxxxxxx"), - Password: String("xxxxxxxxxxxxxxxxxxxx"), + Username: "xxxxxxxxxxxxxxxxxxxx", + Password: "xxxxxxxxxxxxxxxxxxxx", } var token *Token @@ -69,8 +69,8 @@ func TestClient_CreateToken(t *testing.T) { t.Fatal(err) } - if token.Name != *input.Name { - t.Errorf("returned invalid name, got %s, want %s", token.Name, *input.Name) + if token.Name != input.Name { + t.Errorf("returned invalid name, got %s, want %s", token.Name, input.Name) } if token.Scope != input.Scope { diff --git a/fastly/user.go b/fastly/user.go index 7f260b9f7..aeb6c0744 100644 --- a/fastly/user.go +++ b/fastly/user.go @@ -106,7 +106,7 @@ type CreateUserInput struct { Login string `form:"login"` Name string `form:"name"` - Role *string `form:"role,omitempty"` + Role string `form:"role,omitempty"` } // CreateUser creates a new API token with the given information. diff --git a/fastly/user_test.go b/fastly/user_test.go index 165bdd822..c0d0d2e94 100644 --- a/fastly/user_test.go +++ b/fastly/user_test.go @@ -28,7 +28,7 @@ func TestClient_Users(t *testing.T) { u, err = c.CreateUser(&CreateUserInput{ Login: "test+user@example.com", Name: "test user", - Role: String("engineer"), + Role: "engineer", }) }) if err != nil { diff --git a/fastly/vcl.go b/fastly/vcl.go index f6c88af4b..42b785e42 100644 --- a/fastly/vcl.go +++ b/fastly/vcl.go @@ -142,9 +142,9 @@ type CreateVCLInput struct { // ServiceVersion is the specific configuration version (required). ServiceVersion int - Name *string `form:"name,omitempty"` - Content *string `form:"content,omitempty"` - Main *bool `form:"main,omitempty"` + Name string `form:"name,omitempty"` + Content string `form:"content,omitempty"` + Main bool `form:"main,omitempty"` } // CreateVCL creates a new Fastly VCL. diff --git a/fastly/vcl_test.go b/fastly/vcl_test.go index 623d2da54..8c7f2370c 100644 --- a/fastly/vcl_test.go +++ b/fastly/vcl_test.go @@ -34,8 +34,8 @@ sub vcl_hash { vcl, err = c.CreateVCL(&CreateVCLInput{ ServiceID: testServiceID, ServiceVersion: tv.Number, - Name: String("test-vcl"), - Content: String(content), + Name: "test-vcl", + Content: content, }) }) if err != nil { diff --git a/fastly/version.go b/fastly/version.go index d313adc29..405d03916 100644 --- a/fastly/version.go +++ b/fastly/version.go @@ -90,7 +90,7 @@ type CreateVersionInput struct { ServiceID string // A personal freeform descriptive note. - Comment *string `form:"comment,omitempty"` + Comment string `form:"comment,omitempty"` } // CreateVersion constructs a new version. Note that `CloneVersion` is diff --git a/fastly/version_test.go b/fastly/version_test.go index fbfbd5e46..6c07e8f57 100644 --- a/fastly/version_test.go +++ b/fastly/version_test.go @@ -18,7 +18,7 @@ func TestClient_Versions(t *testing.T) { record(t, "versions/create", func(c *Client) { v, err = c.CreateVersion(&CreateVersionInput{ ServiceID: testServiceID, - Comment: String("test comment"), + Comment: "test comment", }) }) if err != nil { From c99b0052873059178855cb8584b96410adb282ab Mon Sep 17 00:00:00 2001 From: integralist Date: Tue, 17 Nov 2020 10:34:50 +0000 Subject: [PATCH 34/37] remove pointer references for existing non write/update structs --- fastly/cloudfiles.go | 30 +++++++++++++++--------------- fastly/cloudfiles_test.go | 28 ++++++++++++++-------------- fastly/datadog.go | 14 +++++++------- fastly/datadog_test.go | 10 +++++----- fastly/digitalocean.go | 30 +++++++++++++++--------------- fastly/digitalocean_test.go | 28 ++++++++++++++-------------- fastly/elasticsearch.go | 32 ++++++++++++++++---------------- fastly/elasticsearch_test.go | 30 +++++++++++++++--------------- fastly/heroku.go | 14 +++++++------- fastly/heroku_test.go | 12 ++++++------ fastly/kafka.go | 34 +++++++++++++++++----------------- fastly/kafka_test.go | 32 ++++++++++++++++---------------- fastly/loggly.go | 12 ++++++------ fastly/loggly_test.go | 8 ++++---- fastly/logshuttle.go | 14 +++++++------- fastly/logshuttle_test.go | 12 ++++++------ fastly/newrelic.go | 12 ++++++------ fastly/newrelic_test.go | 8 ++++---- fastly/openstack.go | 30 +++++++++++++++--------------- fastly/openstack_test.go | 28 ++++++++++++++-------------- fastly/pool.go | 34 +++++++++++++++++----------------- fastly/pool_test.go | 6 +++--- fastly/pubsub.go | 18 +++++++++--------- fastly/pubsub_test.go | 16 ++++++++-------- fastly/scalyr.go | 14 +++++++------- fastly/scalyr_test.go | 12 ++++++------ fastly/server.go | 12 ++++++------ fastly/sftp.go | 34 +++++++++++++++++----------------- fastly/sftp_test.go | 32 ++++++++++++++++---------------- 29 files changed, 298 insertions(+), 298 deletions(-) diff --git a/fastly/cloudfiles.go b/fastly/cloudfiles.go index 3f83445b2..325dd47e0 100644 --- a/fastly/cloudfiles.go +++ b/fastly/cloudfiles.go @@ -83,21 +83,21 @@ type CreateCloudfilesInput struct { // ServiceVersion is the specific configuration version (required). ServiceVersion int - Name *string `form:"name,omitempty"` - User *string `form:"user,omitempty"` - AccessKey *string `form:"access_key,omitempty"` - BucketName *string `form:"bucket_name,omitempty"` - Path *string `form:"path,omitempty"` - Region *string `form:"region,omitempty"` - Placement *string `form:"placement,omitempty"` - Period *uint `form:"period,omitempty"` - GzipLevel *uint `form:"gzip_level,omitempty"` - Format *string `form:"format,omitempty"` - FormatVersion *uint `form:"format_version,omitempty"` - ResponseCondition *string `form:"response_condition,omitempty"` - MessageType *string `form:"message_type,omitempty"` - TimestampFormat *string `form:"timestamp_format,omitempty"` - PublicKey *string `form:"public_key,omitempty"` + Name string `form:"name,omitempty"` + User string `form:"user,omitempty"` + AccessKey string `form:"access_key,omitempty"` + BucketName string `form:"bucket_name,omitempty"` + Path string `form:"path,omitempty"` + Region string `form:"region,omitempty"` + Placement string `form:"placement,omitempty"` + Period uint `form:"period,omitempty"` + GzipLevel uint `form:"gzip_level,omitempty"` + Format string `form:"format,omitempty"` + FormatVersion uint `form:"format_version,omitempty"` + ResponseCondition string `form:"response_condition,omitempty"` + MessageType string `form:"message_type,omitempty"` + TimestampFormat string `form:"timestamp_format,omitempty"` + PublicKey string `form:"public_key,omitempty"` } // CreateCloudfiles creates a new Fastly Cloudfiles. diff --git a/fastly/cloudfiles_test.go b/fastly/cloudfiles_test.go index 1a706bae7..2d06b70bb 100644 --- a/fastly/cloudfiles_test.go +++ b/fastly/cloudfiles_test.go @@ -17,20 +17,20 @@ func TestClient_Cloudfiles(t *testing.T) { cloudfiles, err = c.CreateCloudfiles(&CreateCloudfilesInput{ ServiceID: testServiceID, ServiceVersion: tv.Number, - Name: String("test-cloudfiles"), - User: String("user"), - AccessKey: String("secret-key"), - BucketName: String("bucket-name"), - Path: String("/path"), - Region: String("DFW"), - Period: Uint(12), - GzipLevel: Uint(9), - Format: String("format"), - FormatVersion: Uint(1), - TimestampFormat: String("%Y"), - MessageType: String("classic"), - Placement: String("waf_debug"), - PublicKey: String(pgpPublicKey()), + Name: "test-cloudfiles", + User: "user", + AccessKey: "secret-key", + BucketName: "bucket-name", + Path: "/path", + Region: "DFW", + Period: 12, + GzipLevel: 9, + Format: "format", + FormatVersion: 1, + TimestampFormat: "%Y", + MessageType: "classic", + Placement: "waf_debug", + PublicKey: pgpPublicKey(), }) }) if err != nil { diff --git a/fastly/datadog.go b/fastly/datadog.go index 268fbef42..f2e48b622 100644 --- a/fastly/datadog.go +++ b/fastly/datadog.go @@ -75,13 +75,13 @@ type CreateDatadogInput struct { // ServiceVersion is the specific configuration version (required). ServiceVersion int - Name *string `form:"name,omitempty"` - Token *string `form:"token,omitempty"` - Region *string `form:"region,omitempty"` - Format *string `form:"format,omitempty"` - FormatVersion *uint `form:"format_version,omitempty"` - ResponseCondition *string `form:"response_condition,omitempty"` - Placement *string `form:"placement,omitempty"` + Name string `form:"name,omitempty"` + Token string `form:"token,omitempty"` + Region string `form:"region,omitempty"` + Format string `form:"format,omitempty"` + FormatVersion uint `form:"format_version,omitempty"` + ResponseCondition string `form:"response_condition,omitempty"` + Placement string `form:"placement,omitempty"` } // CreateDatadog creates a new Datadog logging endpoint on a Fastly service version. diff --git a/fastly/datadog_test.go b/fastly/datadog_test.go index 4e878ec0f..b20e3afa7 100644 --- a/fastly/datadog_test.go +++ b/fastly/datadog_test.go @@ -17,11 +17,11 @@ func TestClient_Datadog(t *testing.T) { d, err = c.CreateDatadog(&CreateDatadogInput{ ServiceID: testServiceID, ServiceVersion: tv.Number, - Name: String("test-datadog"), - Region: String("US"), - Token: String("abcd1234"), - Format: String("format"), - Placement: String("waf_debug"), + Name: "test-datadog", + Region: "US", + Token: "abcd1234", + Format: "format", + Placement: "waf_debug", }) }) if err != nil { diff --git a/fastly/digitalocean.go b/fastly/digitalocean.go index 9241f38ab..608d7a5ad 100644 --- a/fastly/digitalocean.go +++ b/fastly/digitalocean.go @@ -83,21 +83,21 @@ type CreateDigitalOceanInput struct { // ServiceVersion is the specific configuration version (required). ServiceVersion int - Name *string `form:"name,omitempty"` - BucketName *string `form:"bucket_name,omitempty"` - Domain *string `form:"domain,omitempty"` - AccessKey *string `form:"access_key,omitempty"` - SecretKey *string `form:"secret_key,omitempty"` - Path *string `form:"path,omitempty"` - Period *uint `form:"period,omitempty"` - GzipLevel *uint `form:"gzip_level,omitempty"` - Format *string `form:"format,omitempty"` - MessageType *string `form:"message_type,omitempty"` - FormatVersion *uint `form:"format_version,omitempty"` - ResponseCondition *string `form:"response_condition,omitempty"` - TimestampFormat *string `form:"timestamp_format,omitempty"` - Placement *string `form:"placement,omitempty"` - PublicKey *string `form:"public_key,omitempty"` + Name string `form:"name,omitempty"` + BucketName string `form:"bucket_name,omitempty"` + Domain string `form:"domain,omitempty"` + AccessKey string `form:"access_key,omitempty"` + SecretKey string `form:"secret_key,omitempty"` + Path string `form:"path,omitempty"` + Period uint `form:"period,omitempty"` + GzipLevel uint `form:"gzip_level,omitempty"` + Format string `form:"format,omitempty"` + MessageType string `form:"message_type,omitempty"` + FormatVersion uint `form:"format_version,omitempty"` + ResponseCondition string `form:"response_condition,omitempty"` + TimestampFormat string `form:"timestamp_format,omitempty"` + Placement string `form:"placement,omitempty"` + PublicKey string `form:"public_key,omitempty"` } // CreateDigitalOcean creates a new Fastly DigitalOcean. diff --git a/fastly/digitalocean_test.go b/fastly/digitalocean_test.go index 9124148c0..dccff56eb 100644 --- a/fastly/digitalocean_test.go +++ b/fastly/digitalocean_test.go @@ -17,20 +17,20 @@ func TestClient_DigitalOceans(t *testing.T) { digitalocean, err = c.CreateDigitalOcean(&CreateDigitalOceanInput{ ServiceID: testServiceID, ServiceVersion: tv.Number, - Name: String("test-digitalocean"), - BucketName: String("bucket-name"), - Domain: String("fra1.digitaloceanspaces.com"), - AccessKey: String("AKIAIOSFODNN7EXAMPLE"), - SecretKey: String("wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"), - Path: String("/path"), - Period: Uint(12), - GzipLevel: Uint(9), - Format: String("format"), - FormatVersion: Uint(2), - TimestampFormat: String("%Y"), - MessageType: String("classic"), - Placement: String("waf_debug"), - PublicKey: String(pgpPublicKey()), + Name: "test-digitalocean", + BucketName: "bucket-name", + Domain: "fra1.digitaloceanspaces.com", + AccessKey: "AKIAIOSFODNN7EXAMPLE", + SecretKey: "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY", + Path: "/path", + Period: 12, + GzipLevel: 9, + Format: "format", + FormatVersion: 2, + TimestampFormat: "%Y", + MessageType: "classic", + Placement: "waf_debug", + PublicKey: pgpPublicKey(), }) }) if err != nil { diff --git a/fastly/elasticsearch.go b/fastly/elasticsearch.go index 20ae99aa7..183ade1c4 100644 --- a/fastly/elasticsearch.go +++ b/fastly/elasticsearch.go @@ -84,22 +84,22 @@ type CreateElasticsearchInput struct { // ServiceVersion is the specific configuration version (required). ServiceVersion int - Name *string `form:"name,omitempty"` - ResponseCondition *string `form:"response_condition,omitempty"` - Format *string `form:"format,omitempty"` - Index *string `form:"index,omitempty"` - URL *string `form:"url,omitempty"` - Pipeline *string `form:"pipeline,omitempty"` - User *string `form:"user,omitempty"` - Password *string `form:"password,omitempty"` - RequestMaxEntries *uint `form:"request_max_entries,omitempty"` - RequestMaxBytes *uint `form:"request_max_bytes,omitempty"` - Placement *string `form:"placement,omitempty"` - TLSCACert *string `form:"tls_ca_cert,omitempty"` - TLSClientCert *string `form:"tls_client_cert,omitempty"` - TLSClientKey *string `form:"tls_client_key,omitempty"` - TLSHostname *string `form:"tls_hostname,omitempty"` - FormatVersion *uint `form:"format_version,omitempty"` + Name string `form:"name,omitempty"` + ResponseCondition string `form:"response_condition,omitempty"` + Format string `form:"format,omitempty"` + Index string `form:"index,omitempty"` + URL string `form:"url,omitempty"` + Pipeline string `form:"pipeline,omitempty"` + User string `form:"user,omitempty"` + Password string `form:"password,omitempty"` + RequestMaxEntries uint `form:"request_max_entries,omitempty"` + RequestMaxBytes uint `form:"request_max_bytes,omitempty"` + Placement string `form:"placement,omitempty"` + TLSCACert string `form:"tls_ca_cert,omitempty"` + TLSClientCert string `form:"tls_client_cert,omitempty"` + TLSClientKey string `form:"tls_client_key,omitempty"` + TLSHostname string `form:"tls_hostname,omitempty"` + FormatVersion uint `form:"format_version,omitempty"` } // CreateElasticsearch creates a new Fastly Elasticsearch logging endpoint. diff --git a/fastly/elasticsearch_test.go b/fastly/elasticsearch_test.go index 222d7fe36..2abd81985 100644 --- a/fastly/elasticsearch_test.go +++ b/fastly/elasticsearch_test.go @@ -40,21 +40,21 @@ Wm7DCfrPNGVwFWUQOmsPue9rZBgO es, err = c.CreateElasticsearch(&CreateElasticsearchInput{ ServiceID: testServiceID, ServiceVersion: tv.Number, - Name: String("test-elasticsearch"), - Format: String("format"), - Index: String("#{%F}"), - URL: String("https://example.com/"), - Pipeline: String("my_pipeline_id"), - User: String("user"), - Password: String("password"), - RequestMaxEntries: Uint(1), - RequestMaxBytes: Uint(1000), - Placement: String("waf_debug"), - TLSCACert: String(caCert), - TLSClientCert: String(clientCert), - TLSClientKey: String(clientKey), - TLSHostname: String("example.com"), - FormatVersion: Uint(2), + Name: "test-elasticsearch", + Format: "format", + Index: "#{%F}", + URL: "https://example.com/", + Pipeline: "my_pipeline_id", + User: "user", + Password: "password", + RequestMaxEntries: 1, + RequestMaxBytes: 1000, + Placement: "waf_debug", + TLSCACert: caCert, + TLSClientCert: clientCert, + TLSClientKey: clientKey, + TLSHostname: "example.com", + FormatVersion: 2, }) }) if err != nil { diff --git a/fastly/heroku.go b/fastly/heroku.go index 7a2bad7ac..86c860789 100644 --- a/fastly/heroku.go +++ b/fastly/heroku.go @@ -75,13 +75,13 @@ type CreateHerokuInput struct { // ServiceVersion is the specific configuration version (required). ServiceVersion int - Name *string `form:"name,omitempty"` - Format *string `form:"format,omitempty"` - FormatVersion *uint `form:"format_version,omitempty"` - URL *string `form:"url,omitempty"` - Token *string `form:"token,omitempty"` - ResponseCondition *string `form:"response_condition,omitempty"` - Placement *string `form:"placement,omitempty"` + Name string `form:"name,omitempty"` + Format string `form:"format,omitempty"` + FormatVersion uint `form:"format_version,omitempty"` + URL string `form:"url,omitempty"` + Token string `form:"token,omitempty"` + ResponseCondition string `form:"response_condition,omitempty"` + Placement string `form:"placement,omitempty"` } // CreateHeroku creates a new Fastly heroku. diff --git a/fastly/heroku_test.go b/fastly/heroku_test.go index 1f4a5290a..7085e4a03 100644 --- a/fastly/heroku_test.go +++ b/fastly/heroku_test.go @@ -19,12 +19,12 @@ func TestClient_Herokus(t *testing.T) { h, err = c.CreateHeroku(&CreateHerokuInput{ ServiceID: testServiceID, ServiceVersion: tv.Number, - Name: String("test-heroku"), - Format: String("%h %l %u %t \"%r\" %>s %b"), - FormatVersion: Uint(2), - Placement: String("waf_debug"), - Token: String("super-secure-token"), - URL: String("https://1.us.logplex.io/logs"), + Name: "test-heroku", + Format: "%h %l %u %t \"%r\" %>s %b", + FormatVersion: 2, + Placement: "waf_debug", + Token: "super-secure-token", + URL: "https://1.us.logplex.io/logs", }) }) if err != nil { diff --git a/fastly/kafka.go b/fastly/kafka.go index 314f1edb4..9c3670a1c 100644 --- a/fastly/kafka.go +++ b/fastly/kafka.go @@ -87,25 +87,25 @@ type CreateKafkaInput struct { // ServiceVersion is the specific configuration version (required). ServiceVersion int - Name *string `form:"name,omitempty"` - Brokers *string `form:"brokers,omitempty"` - Topic *string `form:"topic,omitempty"` - RequiredACKs *string `form:"required_acks,omitempty"` + Name string `form:"name,omitempty"` + Brokers string `form:"brokers,omitempty"` + Topic string `form:"topic,omitempty"` + RequiredACKs string `form:"required_acks,omitempty"` UseTLS *Compatibool `form:"use_tls,omitempty"` - CompressionCodec *string `form:"compression_codec,omitempty"` - Format *string `form:"format,omitempty"` - FormatVersion *uint `form:"format_version,omitempty"` - ResponseCondition *string `form:"response_condition,omitempty"` - Placement *string `form:"placement,omitempty"` - TLSCACert *string `form:"tls_ca_cert,omitempty"` - TLSHostname *string `form:"tls_hostname,omitempty"` - TLSClientCert *string `form:"tls_client_cert,omitempty"` - TLSClientKey *string `form:"tls_client_key,omitempty"` + CompressionCodec string `form:"compression_codec,omitempty"` + Format string `form:"format,omitempty"` + FormatVersion uint `form:"format_version,omitempty"` + ResponseCondition string `form:"response_condition,omitempty"` + Placement string `form:"placement,omitempty"` + TLSCACert string `form:"tls_ca_cert,omitempty"` + TLSHostname string `form:"tls_hostname,omitempty"` + TLSClientCert string `form:"tls_client_cert,omitempty"` + TLSClientKey string `form:"tls_client_key,omitempty"` ParseLogKeyvals *Compatibool `form:"parse_log_keyvals,omitempty"` - RequestMaxBytes *uint `form:"request_max_bytes,omitempty"` - AuthMethod *string `form:"auth_method,omitempty"` - User *string `form:"user,omitempty"` - Password *string `form:"password,omitempty"` + RequestMaxBytes uint `form:"request_max_bytes,omitempty"` + AuthMethod string `form:"auth_method,omitempty"` + User string `form:"user,omitempty"` + Password string `form:"password,omitempty"` } // CreateKafka creates a new Fastly kafka. diff --git a/fastly/kafka_test.go b/fastly/kafka_test.go index 4d81d07d2..8f6573593 100644 --- a/fastly/kafka_test.go +++ b/fastly/kafka_test.go @@ -24,24 +24,24 @@ func TestClient_Kafkas(t *testing.T) { k, err = c.CreateKafka(&CreateKafkaInput{ ServiceID: testServiceID, ServiceVersion: tv.Number, - Name: String("test-kafka"), - Brokers: String("192.168.1.1,192.168.1.2"), - Topic: String("kafka-topic"), - RequiredACKs: String("-1"), + Name: "test-kafka", + Brokers: "192.168.1.1,192.168.1.2", + Topic: "kafka-topic", + RequiredACKs: "-1", UseTLS: CBool(true), - CompressionCodec: String("lz4"), - Format: String("%h %l %u %t \"%r\" %>s %b"), - FormatVersion: Uint(2), - Placement: String("waf_debug"), - TLSCACert: String(caCert), - TLSHostname: String("example.com"), - TLSClientCert: String(clientCert), - TLSClientKey: String(clientKey), + CompressionCodec: "lz4", + Format: "%h %l %u %t \"%r\" %>s %b", + FormatVersion: 2, + Placement: "waf_debug", + TLSCACert: caCert, + TLSHostname: "example.com", + TLSClientCert: clientCert, + TLSClientKey: clientKey, ParseLogKeyvals: CBool(true), - RequestMaxBytes: Uint(1024), - AuthMethod: String("scram-sha-512"), - User: String("foobar"), - Password: String("deadbeef"), + RequestMaxBytes: 1024, + AuthMethod: "scram-sha-512", + User: "foobar", + Password: "deadbeef", }) }) if err != nil { diff --git a/fastly/loggly.go b/fastly/loggly.go index d68df06ba..bad2e72e6 100644 --- a/fastly/loggly.go +++ b/fastly/loggly.go @@ -74,12 +74,12 @@ type CreateLogglyInput struct { // ServiceVersion is the specific configuration version (required). ServiceVersion int - Name *string `form:"name,omitempty"` - Token *string `form:"token,omitempty"` - Format *string `form:"format,omitempty"` - FormatVersion *uint `form:"format_version,omitempty"` - ResponseCondition *string `form:"response_condition,omitempty"` - Placement *string `form:"placement,omitempty"` + Name string `form:"name,omitempty"` + Token string `form:"token,omitempty"` + Format string `form:"format,omitempty"` + FormatVersion uint `form:"format_version,omitempty"` + ResponseCondition string `form:"response_condition,omitempty"` + Placement string `form:"placement,omitempty"` } // CreateLoggly creates a new Fastly loggly. diff --git a/fastly/loggly_test.go b/fastly/loggly_test.go index 956c146a5..c3e56354f 100644 --- a/fastly/loggly_test.go +++ b/fastly/loggly_test.go @@ -17,10 +17,10 @@ func TestClient_Loggly(t *testing.T) { lg, err = c.CreateLoggly(&CreateLogglyInput{ ServiceID: testServiceID, ServiceVersion: tv.Number, - Name: String("test-loggly"), - Token: String("abcd1234"), - Format: String("format"), - Placement: String("waf_debug"), + Name: "test-loggly", + Token: "abcd1234", + Format: "format", + Placement: "waf_debug", }) }) if err != nil { diff --git a/fastly/logshuttle.go b/fastly/logshuttle.go index 053fda354..dfb77e7d7 100644 --- a/fastly/logshuttle.go +++ b/fastly/logshuttle.go @@ -75,13 +75,13 @@ type CreateLogshuttleInput struct { // ServiceVersion is the specific configuration version (required). ServiceVersion int - Name *string `form:"name,omitempty"` - Format *string `form:"format,omitempty"` - FormatVersion *uint `form:"format_version,omitempty"` - URL *string `form:"url,omitempty"` - Token *string `form:"token,omitempty"` - ResponseCondition *string `form:"response_condition,omitempty"` - Placement *string `form:"placement,omitempty"` + Name string `form:"name,omitempty"` + Format string `form:"format,omitempty"` + FormatVersion uint `form:"format_version,omitempty"` + URL string `form:"url,omitempty"` + Token string `form:"token,omitempty"` + ResponseCondition string `form:"response_condition,omitempty"` + Placement string `form:"placement,omitempty"` } // CreateLogshuttle creates a new Fastly logshuttle. diff --git a/fastly/logshuttle_test.go b/fastly/logshuttle_test.go index 962fe82f5..abea34e76 100644 --- a/fastly/logshuttle_test.go +++ b/fastly/logshuttle_test.go @@ -19,12 +19,12 @@ func TestClient_Logshuttles(t *testing.T) { l, err = c.CreateLogshuttle(&CreateLogshuttleInput{ ServiceID: testServiceID, ServiceVersion: tv.Number, - Name: String("test-logshuttle"), - Format: String("%h %l %u %t \"%r\" %>s %b"), - FormatVersion: Uint(2), - Placement: String("waf_debug"), - Token: String("super-secure-token"), - URL: String("https://logs.example.com"), + Name: "test-logshuttle", + Format: "%h %l %u %t \"%r\" %>s %b", + FormatVersion: 2, + Placement: "waf_debug", + Token: "super-secure-token", + URL: "https://logs.example.com", }) }) if err != nil { diff --git a/fastly/newrelic.go b/fastly/newrelic.go index 5c246db68..78dfce50f 100644 --- a/fastly/newrelic.go +++ b/fastly/newrelic.go @@ -74,12 +74,12 @@ type CreateNewRelicInput struct { // ServiceVersion is the specific configuration version (required). ServiceVersion int - Name *string `form:"name,omitempty"` - Token *string `form:"token,omitempty"` - Format *string `form:"format,omitempty"` - FormatVersion *uint `form:"format_version,omitempty"` - ResponseCondition *string `form:"response_condition,omitempty"` - Placement *string `form:"placement,omitempty"` + Name string `form:"name,omitempty"` + Token string `form:"token,omitempty"` + Format string `form:"format,omitempty"` + FormatVersion uint `form:"format_version,omitempty"` + ResponseCondition string `form:"response_condition,omitempty"` + Placement string `form:"placement,omitempty"` } // CreateNewRelic creates a new Fastly newrelic. diff --git a/fastly/newrelic_test.go b/fastly/newrelic_test.go index 49dcbcbf1..8080add8c 100644 --- a/fastly/newrelic_test.go +++ b/fastly/newrelic_test.go @@ -17,10 +17,10 @@ func TestClient_NewRelic(t *testing.T) { n, err = c.CreateNewRelic(&CreateNewRelicInput{ ServiceID: testServiceID, ServiceVersion: tv.Number, - Name: String("test-newrelic"), - Token: String("abcd1234"), - Format: String("format"), - Placement: String("waf_debug"), + Name: "test-newrelic", + Token: "abcd1234", + Format: "format", + Placement: "waf_debug", }) }) if err != nil { diff --git a/fastly/openstack.go b/fastly/openstack.go index d3a336ebc..83da6cf62 100644 --- a/fastly/openstack.go +++ b/fastly/openstack.go @@ -83,21 +83,21 @@ type CreateOpenstackInput struct { // ServiceVersion is the specific configuration version (required). ServiceVersion int - Name *string `form:"name,omitempty"` - User *string `form:"user,omitempty"` - AccessKey *string `form:"access_key,omitempty"` - BucketName *string `form:"bucket_name,omitempty"` - URL *string `form:"url,omitempty"` - Path *string `form:"path,omitempty"` - Placement *string `form:"placement,omitempty"` - Period *uint `form:"period,omitempty"` - GzipLevel *uint `form:"gzip_level,omitempty"` - Format *string `form:"format,omitempty"` - FormatVersion *uint `form:"format_version,omitempty"` - ResponseCondition *string `form:"response_condition,omitempty"` - MessageType *string `form:"message_type,omitempty"` - TimestampFormat *string `form:"timestamp_format,omitempty"` - PublicKey *string `form:"public_key,omitempty"` + Name string `form:"name,omitempty"` + User string `form:"user,omitempty"` + AccessKey string `form:"access_key,omitempty"` + BucketName string `form:"bucket_name,omitempty"` + URL string `form:"url,omitempty"` + Path string `form:"path,omitempty"` + Placement string `form:"placement,omitempty"` + Period uint `form:"period,omitempty"` + GzipLevel uint `form:"gzip_level,omitempty"` + Format string `form:"format,omitempty"` + FormatVersion uint `form:"format_version,omitempty"` + ResponseCondition string `form:"response_condition,omitempty"` + MessageType string `form:"message_type,omitempty"` + TimestampFormat string `form:"timestamp_format,omitempty"` + PublicKey string `form:"public_key,omitempty"` } // CreateOpenstack creates a new Fastly Openstack. diff --git a/fastly/openstack_test.go b/fastly/openstack_test.go index 7d954a671..458ba33c3 100644 --- a/fastly/openstack_test.go +++ b/fastly/openstack_test.go @@ -17,20 +17,20 @@ func TestClient_Openstack(t *testing.T) { openstack, err = c.CreateOpenstack(&CreateOpenstackInput{ ServiceID: testServiceID, ServiceVersion: tv.Number, - Name: String("test-openstack"), - User: String("user"), - AccessKey: String("secret-key"), - BucketName: String("bucket-name"), - URL: String("https://logs.example.com/v1.0"), - Path: String("/path"), - Period: Uint(12), - GzipLevel: Uint(9), - Format: String("format"), - FormatVersion: Uint(2), - TimestampFormat: String("%Y"), - MessageType: String("classic"), - Placement: String("waf_debug"), - PublicKey: String(pgpPublicKey()), + Name: "test-openstack", + User: "user", + AccessKey: "secret-key", + BucketName: "bucket-name", + URL: "https://logs.example.com/v1.0", + Path: "/path", + Period: 12, + GzipLevel: 9, + Format: "format", + FormatVersion: 2, + TimestampFormat: "%Y", + MessageType: "classic", + Placement: "waf_debug", + PublicKey: pgpPublicKey(), }) }) if err != nil { diff --git a/fastly/pool.go b/fastly/pool.go index 16c88bcd0..6602cec85 100644 --- a/fastly/pool.go +++ b/fastly/pool.go @@ -108,26 +108,26 @@ type CreatePoolInput struct { Name string `form:"name"` // Optional fields. - Comment *string `form:"comment,omitempty"` - Shield *string `form:"shield,omitempty"` - RequestCondition *string `form:"request_condition,omitempty"` - MaxConnDefault *uint `form:"max_conn_default,omitempty"` - ConnectTimeout *uint `form:"connect_timeout,omitempty"` - FirstByteTimeout *uint `form:"first_byte_timeout,omitempty"` - Quorum *uint `form:"quorum,omitempty"` + Comment string `form:"comment,omitempty"` + Shield string `form:"shield,omitempty"` + RequestCondition string `form:"request_condition,omitempty"` + MaxConnDefault uint `form:"max_conn_default,omitempty"` + ConnectTimeout uint `form:"connect_timeout,omitempty"` + FirstByteTimeout uint `form:"first_byte_timeout,omitempty"` + Quorum uint `form:"quorum,omitempty"` UseTLS *Compatibool `form:"use_tls,omitempty"` - TLSCACert *string `form:"tls_ca_cert,omitempty"` - TLSCiphers *string `form:"tls_ciphers,omitempty"` - TLSClientKey *string `form:"tls_client_key,omitempty"` - TLSClientCert *string `form:"tls_client_cert,omitempty"` - TLSSNIHostname *string `form:"tls_sni_hostname,omitempty"` + TLSCACert string `form:"tls_ca_cert,omitempty"` + TLSCiphers string `form:"tls_ciphers,omitempty"` + TLSClientKey string `form:"tls_client_key,omitempty"` + TLSClientCert string `form:"tls_client_cert,omitempty"` + TLSSNIHostname string `form:"tls_sni_hostname,omitempty"` TLSCheckCert *Compatibool `form:"tls_check_cert,omitempty"` - TLSCertHostname *string `form:"tls_cert_hostname,omitempty"` - MinTLSVersion *string `form:"min_tls_version,omitempty"` - MaxTLSVersion *string `form:"max_tls_version,omitempty"` - Healthcheck *string `form:"healthcheck,omitempty"` + TLSCertHostname string `form:"tls_cert_hostname,omitempty"` + MinTLSVersion string `form:"min_tls_version,omitempty"` + MaxTLSVersion string `form:"max_tls_version,omitempty"` + Healthcheck string `form:"healthcheck,omitempty"` Type PoolType `form:"type,omitempty"` - OverrideHost *string `form:"override_host,omitempty"` + OverrideHost string `form:"override_host,omitempty"` } // CreatePool creates a pool for a particular service and version. diff --git a/fastly/pool_test.go b/fastly/pool_test.go index c4d3614e6..8c9229e41 100644 --- a/fastly/pool_test.go +++ b/fastly/pool_test.go @@ -18,10 +18,10 @@ func TestClient_Pools(t *testing.T) { ServiceID: testServiceID, ServiceVersion: tv.Number, Name: "test_pool", - Comment: String("test pool"), - Quorum: Uint(50), + Comment: "test pool", + Quorum: 50, UseTLS: CBool(true), - TLSCertHostname: String("example.com"), + TLSCertHostname: "example.com", Type: PoolTypeRandom, }) }) diff --git a/fastly/pubsub.go b/fastly/pubsub.go index c59de47cd..3370c61da 100644 --- a/fastly/pubsub.go +++ b/fastly/pubsub.go @@ -77,15 +77,15 @@ type CreatePubsubInput struct { // ServiceVersion is the specific configuration version (required). ServiceVersion int - Name *string `form:"name,omitempty"` - Topic *string `form:"topic,omitempty"` - User *string `form:"user,omitempty"` - SecretKey *string `form:"secret_key,omitempty"` - ProjectID *string `form:"project_id,omitempty"` - FormatVersion *uint `form:"format_version,omitempty"` - Format *string `form:"format,omitempty"` - ResponseCondition *string `form:"response_condition,omitempty"` - Placement *string `form:"placement,omitempty"` + Name string `form:"name,omitempty"` + Topic string `form:"topic,omitempty"` + User string `form:"user,omitempty"` + SecretKey string `form:"secret_key,omitempty"` + ProjectID string `form:"project_id,omitempty"` + FormatVersion uint `form:"format_version,omitempty"` + Format string `form:"format,omitempty"` + ResponseCondition string `form:"response_condition,omitempty"` + Placement string `form:"placement,omitempty"` } // CreatePubsub creates a new Fastly Pubsub. diff --git a/fastly/pubsub_test.go b/fastly/pubsub_test.go index d8bdea61d..f90d44d19 100644 --- a/fastly/pubsub_test.go +++ b/fastly/pubsub_test.go @@ -17,14 +17,14 @@ func TestClient_Pubsubs(t *testing.T) { pubsub, err = c.CreatePubsub(&CreatePubsubInput{ ServiceID: testServiceID, ServiceVersion: tv.Number, - Name: String("test-pubsub"), - Topic: String("topic"), - User: String("user"), - SecretKey: String("-----BEGIN PRIVATE KEY-----\nMIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQC9aQoqdHVA86oq\nTdRQ5HqwMfpiLBBMKNQcAJsO71RKNrDWwJJZiyYbvM4FOWRZFtRSdPIDgX0C0Wg1\nNnqWYvHDyA5Ug+T8kowiQDn56dU6Km2FWO4wnqZeA8q5G7rQVXlqdibuiP7FglHA\neURUzFsqyymXMUGrqDPqrHsVWC2E3NTJEb4QlywtrwI13qbhlvTx6/9oRfUjytXJ\nRuUIE5xL8yhRCagNr5ZW250aa+wBwu5DSCk5fDNr0eDuZjw84WHDll+mHxBFGV+X\nKJ5jCOmGumGqjVWZesJpNN1My3M9bsY9layNJJ0eiDeHDEi/yXhhO/mNEXhvhq/R\nfN0Jh2A3AgMBAAECggEAef+CEL5aF6/aVs0yh7fiXkKSp1ECXkud8ztgpEn63KJF\nXM1EdnBt50fA2xSQUeGmeEXi6+cngf0nRb8FToAEgLoGoOEjSJuLrzP3I8U9Fe3m\nBRG2uZI2Ti/bD0eRGEc1oSDhCpsqnkTGK1bwcD4AKpwY+c08Izh/2BOoY6McDoqh\ndQ89jzTuMtD4cNlnPiIrY9HbxoNjshK2ax1OaeXyYKZFG1TxqMFv5gA/G5+S3Cwr\nVG4fkAxYi5vdIK3b8jUXrTM/kpoTl+d3dlQ7rRZYf7KyT31/HtJ/GNzxFI6upzO7\niDNrrUOyeOPjWXdzUh9budv3j+6UfbYK7uZIoebHIQKBgQDykYX1L/akGaOC2tfS\njzCWUzPxGFYVZQ7zD1PM6UyouuS1KLURDEGk9RxqVzTPh/pYd8Ivnz3vOVski5Zt\n19ozLGxdtDhn122DcnVpfCdYzHBdAzPCzORenFohX+MhiX5fEotTlVi7wfOmzTP5\nhUCMSd/17bJrV4XMLhkdrMRBFQKBgQDH5fwV7o+Ej/ZfcdGIa3mAFazToPDzxhHU\nnwADxaxpNGKRU03XCaiYkykarLYdG6Rk+7dXUv8eLy+6Dcq1SWQtfCWKEor++IIp\n1RwWmFHfYriHGkmxSkkEkLFvL8old9xM5YWbEXc4QIXvnfR4BZxdyJHVzIDdbI2i\nFgcn17U3GwKBgDd1njMY7ENIuWHJt16k7m7wRwfwkH4DxQ89ieNn0+cgE/p3fC6R\nptCYWg7WMXThmhNwDi3lMrvnWTdZ0uL6XyEkHwKtmdfkIV3UZZPglv5uf6JEgSkg\nv3YCOXk3+y5HyWTjUIejtc334kVY1XFPThrFKTeJSSnRsP2l7IgkYBqhAoGAYGsr\nM3z1FrDF2nWw5odIfKJ30UAw2LRyB0eGH0uqhLgyzvwKcK2E98sLqYUi9llN6zOK\n1IEA8xM5hxl97AFxY4sdJEMbbi55wim7uZ5Q51nbvbbNUsmM/Lm6C/JWI8pzpVeU\nIR7EjYp50AE1WOsD6CyFQ0W35pWkn0jWvL4L938CgYEAlax4dLE5+YCG5DeLT1/N\nin6kQjl7JS4oCNlPEj6aRPLX2OJresI7oOn+uNatKvlVyfPm6rdxeHCmER1FpR7Q\nA/aNVjPeViKT/R4nK9ytsa+s/1IJVrwLFHJK3toGE660g5w3vKrCjWisMdP4yzzQ\nbv1KwcKoQbNVXwauH79JKc0=\n-----END PRIVATE KEY-----\n"), - ProjectID: String("project-id"), - FormatVersion: Uint(2), - Format: String("format"), - Placement: String("waf_debug"), + Name: "test-pubsub", + Topic: "topic", + User: "user", + SecretKey: "-----BEGIN PRIVATE KEY-----\nMIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQC9aQoqdHVA86oq\nTdRQ5HqwMfpiLBBMKNQcAJsO71RKNrDWwJJZiyYbvM4FOWRZFtRSdPIDgX0C0Wg1\nNnqWYvHDyA5Ug+T8kowiQDn56dU6Km2FWO4wnqZeA8q5G7rQVXlqdibuiP7FglHA\neURUzFsqyymXMUGrqDPqrHsVWC2E3NTJEb4QlywtrwI13qbhlvTx6/9oRfUjytXJ\nRuUIE5xL8yhRCagNr5ZW250aa+wBwu5DSCk5fDNr0eDuZjw84WHDll+mHxBFGV+X\nKJ5jCOmGumGqjVWZesJpNN1My3M9bsY9layNJJ0eiDeHDEi/yXhhO/mNEXhvhq/R\nfN0Jh2A3AgMBAAECggEAef+CEL5aF6/aVs0yh7fiXkKSp1ECXkud8ztgpEn63KJF\nXM1EdnBt50fA2xSQUeGmeEXi6+cngf0nRb8FToAEgLoGoOEjSJuLrzP3I8U9Fe3m\nBRG2uZI2Ti/bD0eRGEc1oSDhCpsqnkTGK1bwcD4AKpwY+c08Izh/2BOoY6McDoqh\ndQ89jzTuMtD4cNlnPiIrY9HbxoNjshK2ax1OaeXyYKZFG1TxqMFv5gA/G5+S3Cwr\nVG4fkAxYi5vdIK3b8jUXrTM/kpoTl+d3dlQ7rRZYf7KyT31/HtJ/GNzxFI6upzO7\niDNrrUOyeOPjWXdzUh9budv3j+6UfbYK7uZIoebHIQKBgQDykYX1L/akGaOC2tfS\njzCWUzPxGFYVZQ7zD1PM6UyouuS1KLURDEGk9RxqVzTPh/pYd8Ivnz3vOVski5Zt\n19ozLGxdtDhn122DcnVpfCdYzHBdAzPCzORenFohX+MhiX5fEotTlVi7wfOmzTP5\nhUCMSd/17bJrV4XMLhkdrMRBFQKBgQDH5fwV7o+Ej/ZfcdGIa3mAFazToPDzxhHU\nnwADxaxpNGKRU03XCaiYkykarLYdG6Rk+7dXUv8eLy+6Dcq1SWQtfCWKEor++IIp\n1RwWmFHfYriHGkmxSkkEkLFvL8old9xM5YWbEXc4QIXvnfR4BZxdyJHVzIDdbI2i\nFgcn17U3GwKBgDd1njMY7ENIuWHJt16k7m7wRwfwkH4DxQ89ieNn0+cgE/p3fC6R\nptCYWg7WMXThmhNwDi3lMrvnWTdZ0uL6XyEkHwKtmdfkIV3UZZPglv5uf6JEgSkg\nv3YCOXk3+y5HyWTjUIejtc334kVY1XFPThrFKTeJSSnRsP2l7IgkYBqhAoGAYGsr\nM3z1FrDF2nWw5odIfKJ30UAw2LRyB0eGH0uqhLgyzvwKcK2E98sLqYUi9llN6zOK\n1IEA8xM5hxl97AFxY4sdJEMbbi55wim7uZ5Q51nbvbbNUsmM/Lm6C/JWI8pzpVeU\nIR7EjYp50AE1WOsD6CyFQ0W35pWkn0jWvL4L938CgYEAlax4dLE5+YCG5DeLT1/N\nin6kQjl7JS4oCNlPEj6aRPLX2OJresI7oOn+uNatKvlVyfPm6rdxeHCmER1FpR7Q\nA/aNVjPeViKT/R4nK9ytsa+s/1IJVrwLFHJK3toGE660g5w3vKrCjWisMdP4yzzQ\nbv1KwcKoQbNVXwauH79JKc0=\n-----END PRIVATE KEY-----\n", + ProjectID: "project-id", + FormatVersion: 2, + Format: "format", + Placement: "waf_debug", }) }) if err != nil { diff --git a/fastly/scalyr.go b/fastly/scalyr.go index e9034712f..1879770c8 100644 --- a/fastly/scalyr.go +++ b/fastly/scalyr.go @@ -75,13 +75,13 @@ type CreateScalyrInput struct { // ServiceVersion is the specific configuration version (required). ServiceVersion int - Name *string `form:"name,omitempty"` - Format *string `form:"format,omitempty"` - FormatVersion *uint `form:"format_version,omitempty"` - Token *string `form:"token,omitempty"` - Region *string `form:"region,omitempty"` - ResponseCondition *string `form:"response_condition,omitempty"` - Placement *string `form:"placement,omitempty"` + Name string `form:"name,omitempty"` + Format string `form:"format,omitempty"` + FormatVersion uint `form:"format_version,omitempty"` + Token string `form:"token,omitempty"` + Region string `form:"region,omitempty"` + ResponseCondition string `form:"response_condition,omitempty"` + Placement string `form:"placement,omitempty"` } // CreateScalyr creates a new Fastly scalyr. diff --git a/fastly/scalyr_test.go b/fastly/scalyr_test.go index e9e0c28c9..26ccbec44 100644 --- a/fastly/scalyr_test.go +++ b/fastly/scalyr_test.go @@ -19,12 +19,12 @@ func TestClient_Scalyrs(t *testing.T) { s, err = c.CreateScalyr(&CreateScalyrInput{ ServiceID: testServiceID, ServiceVersion: tv.Number, - Name: String("test-scalyr"), - Format: String("%h %l %u %t \"%r\" %>s %b"), - FormatVersion: Uint(2), - Placement: String("waf_debug"), - Region: String("US"), - Token: String("super-secure-token"), + Name: "test-scalyr", + Format: "%h %l %u %t \"%r\" %>s %b", + FormatVersion: 2, + Placement: "waf_debug", + Region: "US", + Token: "super-secure-token", }) }) if err != nil { diff --git a/fastly/server.go b/fastly/server.go index 2906d6ec1..01c6765a5 100644 --- a/fastly/server.go +++ b/fastly/server.go @@ -79,12 +79,12 @@ type CreateServerInput struct { Address string `form:"address"` // Optional fields. - Comment *string `form:"comment,omitempty"` - Weight *uint `form:"weight,omitempty"` - MaxConn *uint `form:"max_conn,omitempty"` - Port *uint `form:"port,omitempty"` - Disabled *bool `form:"disabled,omitempty"` - OverrideHost *string `form:"override_host,omitempty"` + Comment string `form:"comment,omitempty"` + Weight uint `form:"weight,omitempty"` + MaxConn uint `form:"max_conn,omitempty"` + Port uint `form:"port,omitempty"` + Disabled bool `form:"disabled,omitempty"` + OverrideHost string `form:"override_host,omitempty"` } // CreateServer creates a single server for a particular service and pool. diff --git a/fastly/sftp.go b/fastly/sftp.go index dda7fe36c..ce7aace0e 100644 --- a/fastly/sftp.go +++ b/fastly/sftp.go @@ -85,23 +85,23 @@ type CreateSFTPInput struct { // ServiceVersion is the specific configuration version (required). ServiceVersion int - Name *string `form:"name,omitempty"` - Address *string `form:"address,omitempty"` - Port *uint `form:"port,omitempty"` - User *string `form:"user,omitempty"` - Password *string `form:"password,omitempty"` - PublicKey *string `form:"public_key,omitempty"` - SecretKey *string `form:"secret_key,omitempty"` - SSHKnownHosts *string `form:"ssh_known_hosts,omitempty"` - Path *string `form:"path,omitempty"` - Period *uint `form:"period,omitempty"` - FormatVersion *uint `form:"format_version,omitempty"` - GzipLevel *uint `form:"gzip_level,omitempty"` - Format *string `form:"format,omitempty"` - ResponseCondition *string `form:"response_condition,omitempty"` - TimestampFormat *string `form:"timestamp_format,omitempty"` - MessageType *string `form:"message_type,omitempty"` - Placement *string `form:"placement,omitempty"` + Name string `form:"name,omitempty"` + Address string `form:"address,omitempty"` + Port uint `form:"port,omitempty"` + User string `form:"user,omitempty"` + Password string `form:"password,omitempty"` + PublicKey string `form:"public_key,omitempty"` + SecretKey string `form:"secret_key,omitempty"` + SSHKnownHosts string `form:"ssh_known_hosts,omitempty"` + Path string `form:"path,omitempty"` + Period uint `form:"period,omitempty"` + FormatVersion uint `form:"format_version,omitempty"` + GzipLevel uint `form:"gzip_level,omitempty"` + Format string `form:"format,omitempty"` + ResponseCondition string `form:"response_condition,omitempty"` + TimestampFormat string `form:"timestamp_format,omitempty"` + MessageType string `form:"message_type,omitempty"` + Placement string `form:"placement,omitempty"` } // CreateSFTP creates a new Fastly SFTP. diff --git a/fastly/sftp_test.go b/fastly/sftp_test.go index 4b1ea5a53..d4ee319ce 100644 --- a/fastly/sftp_test.go +++ b/fastly/sftp_test.go @@ -17,22 +17,22 @@ func TestClient_SFTPs(t *testing.T) { sftp, err = c.CreateSFTP(&CreateSFTPInput{ ServiceID: testServiceID, ServiceVersion: tv.Number, - Name: String("test-sftp"), - Address: String("example.com"), - Port: Uint(1234), - PublicKey: String(pgpPublicKey()), - SecretKey: String(privateKey()), - SSHKnownHosts: String(knownHosts), - User: String("username"), - Password: String("password"), - Path: String("/dir"), - Period: Uint(12), - GzipLevel: Uint(9), - FormatVersion: Uint(2), - Format: String("format"), - MessageType: String("blank"), - TimestampFormat: String("%Y"), - Placement: String("waf_debug"), + Name: "test-sftp", + Address: "example.com", + Port: 1234, + PublicKey: pgpPublicKey(), + SecretKey: privateKey(), + SSHKnownHosts: knownHosts, + User: "username", + Password: "password", + Path: "/dir", + Period: 12, + GzipLevel: 9, + FormatVersion: 2, + Format: "format", + MessageType: "blank", + TimestampFormat: "%Y", + Placement: "waf_debug", }) }) if err != nil { From 42bfb45a0493a6bb664b96ef198a65c32c7fa542 Mon Sep 17 00:00:00 2001 From: integralist Date: Tue, 17 Nov 2020 12:04:10 +0000 Subject: [PATCH 35/37] Compatibool should be non-pointer for 'create' structs --- fastly/backend.go | 52 +++++++++++++++++----------------- fastly/dictionary.go | 4 +-- fastly/header.go | 2 +- fastly/header_test.go | 2 +- fastly/kafka.go | 38 ++++++++++++------------- fastly/kafka_test.go | 4 +-- fastly/logentries.go | 16 +++++------ fastly/logentries_test.go | 2 +- fastly/pool.go | 40 +++++++++++++------------- fastly/pool_test.go | 2 +- fastly/request_setting.go | 10 +++---- fastly/request_setting_test.go | 10 +++---- fastly/syslog.go | 32 ++++++++++----------- fastly/syslog_test.go | 2 +- 14 files changed, 108 insertions(+), 108 deletions(-) diff --git a/fastly/backend.go b/fastly/backend.go index 769c763b6..fbdec35c7 100644 --- a/fastly/backend.go +++ b/fastly/backend.go @@ -95,32 +95,32 @@ type CreateBackendInput struct { // ServiceVersion is the specific configuration version (required). ServiceVersion int - Name string `form:"name,omitempty"` - Comment string `form:"comment,omitempty"` - Address string `form:"address,omitempty"` - Port uint `form:"port,omitempty"` - OverrideHost string `form:"override_host,omitempty"` - ConnectTimeout uint `form:"connect_timeout,omitempty"` - MaxConn uint `form:"max_conn,omitempty"` - ErrorThreshold uint `form:"error_threshold,omitempty"` - FirstByteTimeout uint `form:"first_byte_timeout,omitempty"` - BetweenBytesTimeout uint `form:"between_bytes_timeout,omitempty"` - AutoLoadbalance *Compatibool `form:"auto_loadbalance,omitempty"` - Weight uint `form:"weight,omitempty"` - RequestCondition string `form:"request_condition,omitempty"` - HealthCheck string `form:"healthcheck,omitempty"` - Shield string `form:"shield,omitempty"` - UseSSL *Compatibool `form:"use_ssl,omitempty"` - SSLCheckCert *Compatibool `form:"ssl_check_cert,omitempty"` - SSLCACert string `form:"ssl_ca_cert,omitempty"` - SSLClientCert string `form:"ssl_client_cert,omitempty"` - SSLClientKey string `form:"ssl_client_key,omitempty"` - SSLHostname string `form:"ssl_hostname,omitempty"` - SSLCertHostname string `form:"ssl_cert_hostname,omitempty"` - SSLSNIHostname string `form:"ssl_sni_hostname,omitempty"` - MinTLSVersion string `form:"min_tls_version,omitempty"` - MaxTLSVersion string `form:"max_tls_version,omitempty"` - SSLCiphers []string `form:"ssl_ciphers,omitempty"` + Name string `form:"name,omitempty"` + Comment string `form:"comment,omitempty"` + Address string `form:"address,omitempty"` + Port uint `form:"port,omitempty"` + OverrideHost string `form:"override_host,omitempty"` + ConnectTimeout uint `form:"connect_timeout,omitempty"` + MaxConn uint `form:"max_conn,omitempty"` + ErrorThreshold uint `form:"error_threshold,omitempty"` + FirstByteTimeout uint `form:"first_byte_timeout,omitempty"` + BetweenBytesTimeout uint `form:"between_bytes_timeout,omitempty"` + AutoLoadbalance Compatibool `form:"auto_loadbalance,omitempty"` + Weight uint `form:"weight,omitempty"` + RequestCondition string `form:"request_condition,omitempty"` + HealthCheck string `form:"healthcheck,omitempty"` + Shield string `form:"shield,omitempty"` + UseSSL Compatibool `form:"use_ssl,omitempty"` + SSLCheckCert Compatibool `form:"ssl_check_cert,omitempty"` + SSLCACert string `form:"ssl_ca_cert,omitempty"` + SSLClientCert string `form:"ssl_client_cert,omitempty"` + SSLClientKey string `form:"ssl_client_key,omitempty"` + SSLHostname string `form:"ssl_hostname,omitempty"` + SSLCertHostname string `form:"ssl_cert_hostname,omitempty"` + SSLSNIHostname string `form:"ssl_sni_hostname,omitempty"` + MinTLSVersion string `form:"min_tls_version,omitempty"` + MaxTLSVersion string `form:"max_tls_version,omitempty"` + SSLCiphers []string `form:"ssl_ciphers,omitempty"` } // CreateBackend creates a new Fastly backend. diff --git a/fastly/dictionary.go b/fastly/dictionary.go index cb8e832bd..6e30938c7 100644 --- a/fastly/dictionary.go +++ b/fastly/dictionary.go @@ -71,8 +71,8 @@ type CreateDictionaryInput struct { // ServiceVersion is the specific configuration version (required). ServiceVersion int - Name string `form:"name,omitempty"` - WriteOnly *Compatibool `form:"write_only,omitempty"` + Name string `form:"name,omitempty"` + WriteOnly Compatibool `form:"write_only,omitempty"` } // CreateDictionary creates a new Fastly dictionary. diff --git a/fastly/header.go b/fastly/header.go index 68b87d228..82d2db525 100644 --- a/fastly/header.go +++ b/fastly/header.go @@ -125,7 +125,7 @@ type CreateHeaderInput struct { Name string `form:"name,omitempty"` Action HeaderAction `form:"action,omitempty"` - IgnoreIfSet *Compatibool `form:"ignore_if_set,omitempty"` + IgnoreIfSet Compatibool `form:"ignore_if_set,omitempty"` Type HeaderType `form:"type,omitempty"` Destination string `form:"dst,omitempty"` Source string `form:"src,omitempty"` diff --git a/fastly/header_test.go b/fastly/header_test.go index 0ee100356..95278d5c3 100644 --- a/fastly/header_test.go +++ b/fastly/header_test.go @@ -19,7 +19,7 @@ func TestClient_Headers(t *testing.T) { ServiceVersion: tv.Number, Name: "test-header", Action: HeaderActionSet, - IgnoreIfSet: CBool(false), + IgnoreIfSet: false, Type: HeaderTypeRequest, Destination: "http.foo", Source: "client.ip", diff --git a/fastly/kafka.go b/fastly/kafka.go index 9c3670a1c..6cf816c46 100644 --- a/fastly/kafka.go +++ b/fastly/kafka.go @@ -87,25 +87,25 @@ type CreateKafkaInput struct { // ServiceVersion is the specific configuration version (required). ServiceVersion int - Name string `form:"name,omitempty"` - Brokers string `form:"brokers,omitempty"` - Topic string `form:"topic,omitempty"` - RequiredACKs string `form:"required_acks,omitempty"` - UseTLS *Compatibool `form:"use_tls,omitempty"` - CompressionCodec string `form:"compression_codec,omitempty"` - Format string `form:"format,omitempty"` - FormatVersion uint `form:"format_version,omitempty"` - ResponseCondition string `form:"response_condition,omitempty"` - Placement string `form:"placement,omitempty"` - TLSCACert string `form:"tls_ca_cert,omitempty"` - TLSHostname string `form:"tls_hostname,omitempty"` - TLSClientCert string `form:"tls_client_cert,omitempty"` - TLSClientKey string `form:"tls_client_key,omitempty"` - ParseLogKeyvals *Compatibool `form:"parse_log_keyvals,omitempty"` - RequestMaxBytes uint `form:"request_max_bytes,omitempty"` - AuthMethod string `form:"auth_method,omitempty"` - User string `form:"user,omitempty"` - Password string `form:"password,omitempty"` + Name string `form:"name,omitempty"` + Brokers string `form:"brokers,omitempty"` + Topic string `form:"topic,omitempty"` + RequiredACKs string `form:"required_acks,omitempty"` + UseTLS Compatibool `form:"use_tls,omitempty"` + CompressionCodec string `form:"compression_codec,omitempty"` + Format string `form:"format,omitempty"` + FormatVersion uint `form:"format_version,omitempty"` + ResponseCondition string `form:"response_condition,omitempty"` + Placement string `form:"placement,omitempty"` + TLSCACert string `form:"tls_ca_cert,omitempty"` + TLSHostname string `form:"tls_hostname,omitempty"` + TLSClientCert string `form:"tls_client_cert,omitempty"` + TLSClientKey string `form:"tls_client_key,omitempty"` + ParseLogKeyvals Compatibool `form:"parse_log_keyvals,omitempty"` + RequestMaxBytes uint `form:"request_max_bytes,omitempty"` + AuthMethod string `form:"auth_method,omitempty"` + User string `form:"user,omitempty"` + Password string `form:"password,omitempty"` } // CreateKafka creates a new Fastly kafka. diff --git a/fastly/kafka_test.go b/fastly/kafka_test.go index 8f6573593..57269d78e 100644 --- a/fastly/kafka_test.go +++ b/fastly/kafka_test.go @@ -28,7 +28,7 @@ func TestClient_Kafkas(t *testing.T) { Brokers: "192.168.1.1,192.168.1.2", Topic: "kafka-topic", RequiredACKs: "-1", - UseTLS: CBool(true), + UseTLS: true, CompressionCodec: "lz4", Format: "%h %l %u %t \"%r\" %>s %b", FormatVersion: 2, @@ -37,7 +37,7 @@ func TestClient_Kafkas(t *testing.T) { TLSHostname: "example.com", TLSClientCert: clientCert, TLSClientKey: clientKey, - ParseLogKeyvals: CBool(true), + ParseLogKeyvals: true, RequestMaxBytes: 1024, AuthMethod: "scram-sha-512", User: "foobar", diff --git a/fastly/logentries.go b/fastly/logentries.go index c84be304b..4febf1a3a 100644 --- a/fastly/logentries.go +++ b/fastly/logentries.go @@ -76,14 +76,14 @@ type CreateLogentriesInput struct { // ServiceVersion is the specific configuration version (required). ServiceVersion int - Name string `form:"name,omitempty"` - Port uint `form:"port,omitempty"` - UseTLS *Compatibool `form:"use_tls,omitempty"` - Token string `form:"token,omitempty"` - Format string `form:"format,omitempty"` - FormatVersion uint `form:"format_version,omitempty"` - ResponseCondition string `form:"response_condition,omitempty"` - Placement string `form:"placement,omitempty"` + Name string `form:"name,omitempty"` + Port uint `form:"port,omitempty"` + UseTLS Compatibool `form:"use_tls,omitempty"` + Token string `form:"token,omitempty"` + Format string `form:"format,omitempty"` + FormatVersion uint `form:"format_version,omitempty"` + ResponseCondition string `form:"response_condition,omitempty"` + Placement string `form:"placement,omitempty"` } // CreateLogentries creates a new Fastly logentries. diff --git a/fastly/logentries_test.go b/fastly/logentries_test.go index 34731ea10..aa8e7c0f1 100644 --- a/fastly/logentries_test.go +++ b/fastly/logentries_test.go @@ -19,7 +19,7 @@ func TestClient_Logentries(t *testing.T) { ServiceVersion: tv.Number, Name: "test-logentries", Port: 1234, - UseTLS: CBool(true), + UseTLS: true, Token: "abcd1234", Format: "format", Placement: "waf_debug", diff --git a/fastly/pool.go b/fastly/pool.go index 6602cec85..c88dbecc4 100644 --- a/fastly/pool.go +++ b/fastly/pool.go @@ -108,26 +108,26 @@ type CreatePoolInput struct { Name string `form:"name"` // Optional fields. - Comment string `form:"comment,omitempty"` - Shield string `form:"shield,omitempty"` - RequestCondition string `form:"request_condition,omitempty"` - MaxConnDefault uint `form:"max_conn_default,omitempty"` - ConnectTimeout uint `form:"connect_timeout,omitempty"` - FirstByteTimeout uint `form:"first_byte_timeout,omitempty"` - Quorum uint `form:"quorum,omitempty"` - UseTLS *Compatibool `form:"use_tls,omitempty"` - TLSCACert string `form:"tls_ca_cert,omitempty"` - TLSCiphers string `form:"tls_ciphers,omitempty"` - TLSClientKey string `form:"tls_client_key,omitempty"` - TLSClientCert string `form:"tls_client_cert,omitempty"` - TLSSNIHostname string `form:"tls_sni_hostname,omitempty"` - TLSCheckCert *Compatibool `form:"tls_check_cert,omitempty"` - TLSCertHostname string `form:"tls_cert_hostname,omitempty"` - MinTLSVersion string `form:"min_tls_version,omitempty"` - MaxTLSVersion string `form:"max_tls_version,omitempty"` - Healthcheck string `form:"healthcheck,omitempty"` - Type PoolType `form:"type,omitempty"` - OverrideHost string `form:"override_host,omitempty"` + Comment string `form:"comment,omitempty"` + Shield string `form:"shield,omitempty"` + RequestCondition string `form:"request_condition,omitempty"` + MaxConnDefault uint `form:"max_conn_default,omitempty"` + ConnectTimeout uint `form:"connect_timeout,omitempty"` + FirstByteTimeout uint `form:"first_byte_timeout,omitempty"` + Quorum uint `form:"quorum,omitempty"` + UseTLS Compatibool `form:"use_tls,omitempty"` + TLSCACert string `form:"tls_ca_cert,omitempty"` + TLSCiphers string `form:"tls_ciphers,omitempty"` + TLSClientKey string `form:"tls_client_key,omitempty"` + TLSClientCert string `form:"tls_client_cert,omitempty"` + TLSSNIHostname string `form:"tls_sni_hostname,omitempty"` + TLSCheckCert Compatibool `form:"tls_check_cert,omitempty"` + TLSCertHostname string `form:"tls_cert_hostname,omitempty"` + MinTLSVersion string `form:"min_tls_version,omitempty"` + MaxTLSVersion string `form:"max_tls_version,omitempty"` + Healthcheck string `form:"healthcheck,omitempty"` + Type PoolType `form:"type,omitempty"` + OverrideHost string `form:"override_host,omitempty"` } // CreatePool creates a pool for a particular service and version. diff --git a/fastly/pool_test.go b/fastly/pool_test.go index 8c9229e41..abc337c78 100644 --- a/fastly/pool_test.go +++ b/fastly/pool_test.go @@ -20,7 +20,7 @@ func TestClient_Pools(t *testing.T) { Name: "test_pool", Comment: "test pool", Quorum: 50, - UseTLS: CBool(true), + UseTLS: true, TLSCertHostname: "example.com", Type: PoolTypeRandom, }) diff --git a/fastly/request_setting.go b/fastly/request_setting.go index b3ed75f0e..5feefe91a 100644 --- a/fastly/request_setting.go +++ b/fastly/request_setting.go @@ -116,15 +116,15 @@ type CreateRequestSettingInput struct { ServiceVersion int Name string `form:"name,omitempty"` - ForceMiss *Compatibool `form:"force_miss,omitempty"` - ForceSSL *Compatibool `form:"force_ssl,omitempty"` + ForceMiss Compatibool `form:"force_miss,omitempty"` + ForceSSL Compatibool `form:"force_ssl,omitempty"` Action RequestSettingAction `form:"action,omitempty"` - BypassBusyWait *Compatibool `form:"bypass_busy_wait,omitempty"` + BypassBusyWait Compatibool `form:"bypass_busy_wait,omitempty"` MaxStaleAge uint `form:"max_stale_age,omitempty"` HashKeys string `form:"hash_keys,omitempty"` XForwardedFor RequestSettingXFF `form:"xff,omitempty"` - TimerSupport *Compatibool `form:"timer_support,omitempty"` - GeoHeaders *Compatibool `form:"geo_headers,omitempty"` + TimerSupport Compatibool `form:"timer_support,omitempty"` + GeoHeaders Compatibool `form:"geo_headers,omitempty"` DefaultHost string `form:"default_host,omitempty"` RequestCondition string `form:"request_condition,omitempty"` } diff --git a/fastly/request_setting_test.go b/fastly/request_setting_test.go index afa0c6d1f..1fd3775bc 100644 --- a/fastly/request_setting_test.go +++ b/fastly/request_setting_test.go @@ -18,15 +18,15 @@ func TestClient_RequestSettings(t *testing.T) { ServiceID: testServiceID, ServiceVersion: tv.Number, Name: "test-request-setting", - ForceMiss: CBool(true), - ForceSSL: CBool(true), + ForceMiss: true, + ForceSSL: true, Action: RequestSettingActionLookup, - BypassBusyWait: CBool(true), + BypassBusyWait: true, MaxStaleAge: 30, HashKeys: "a,b,c", XForwardedFor: RequestSettingXFFLeave, - TimerSupport: CBool(true), - GeoHeaders: CBool(true), + TimerSupport: true, + GeoHeaders: true, DefaultHost: "example.com", }) }) diff --git a/fastly/syslog.go b/fastly/syslog.go index 9b7c89110..39b49ede6 100644 --- a/fastly/syslog.go +++ b/fastly/syslog.go @@ -84,22 +84,22 @@ type CreateSyslogInput struct { // ServiceVersion is the specific configuration version (required). ServiceVersion int - Name string `form:"name,omitempty"` - Address string `form:"address,omitempty"` - Hostname string `form:"hostname,omitempty"` - Port uint `form:"port,omitempty"` - UseTLS *Compatibool `form:"use_tls,omitempty"` - IPV4 string `form:"ipv4,omitempty"` - TLSCACert string `form:"tls_ca_cert,omitempty"` - TLSHostname string `form:"tls_hostname,omitempty"` - TLSClientCert string `form:"tls_client_cert,omitempty"` - TLSClientKey string `form:"tls_client_key,omitempty"` - Token string `form:"token,omitempty"` - Format string `form:"format,omitempty"` - FormatVersion uint `form:"format_version,omitempty"` - MessageType string `form:"message_type,omitempty"` - ResponseCondition string `form:"response_condition,omitempty"` - Placement string `form:"placement,omitempty"` + Name string `form:"name,omitempty"` + Address string `form:"address,omitempty"` + Hostname string `form:"hostname,omitempty"` + Port uint `form:"port,omitempty"` + UseTLS Compatibool `form:"use_tls,omitempty"` + IPV4 string `form:"ipv4,omitempty"` + TLSCACert string `form:"tls_ca_cert,omitempty"` + TLSHostname string `form:"tls_hostname,omitempty"` + TLSClientCert string `form:"tls_client_cert,omitempty"` + TLSClientKey string `form:"tls_client_key,omitempty"` + Token string `form:"token,omitempty"` + Format string `form:"format,omitempty"` + FormatVersion uint `form:"format_version,omitempty"` + MessageType string `form:"message_type,omitempty"` + ResponseCondition string `form:"response_condition,omitempty"` + Placement string `form:"placement,omitempty"` } // CreateSyslog creates a new Fastly syslog. diff --git a/fastly/syslog_test.go b/fastly/syslog_test.go index 96f10b36c..17a069086 100644 --- a/fastly/syslog_test.go +++ b/fastly/syslog_test.go @@ -44,7 +44,7 @@ Wm7DCfrPNGVwFWUQOmsPue9rZBgO Address: "example.com", Hostname: "example.com", Port: 1234, - UseTLS: CBool(true), + UseTLS: true, TLSCACert: caCert, TLSHostname: "example.com", TLSClientCert: clientCert, From 02739ccdd5e26af4a26d202f6bc5598700e9ca7f Mon Sep 17 00:00:00 2001 From: integralist Date: Tue, 17 Nov 2020 12:15:04 +0000 Subject: [PATCH 36/37] Use pointer reference for Header* constants on write/update structs. --- fastly/header.go | 36 ++++++++++++++++++++++++------------ fastly/header_test.go | 2 ++ 2 files changed, 26 insertions(+), 12 deletions(-) diff --git a/fastly/header.go b/fastly/header.go index 82d2db525..b333e8582 100644 --- a/fastly/header.go +++ b/fastly/header.go @@ -29,6 +29,12 @@ const ( // HeaderAction is a type of header action. type HeaderAction string +// PHeaderAction returns pointer to HeaderAction. +func PHeaderAction(t HeaderAction) *HeaderAction { + ha := HeaderAction(t) + return &ha +} + const ( // HeaderTypeRequest is a header type that performs on the request before // lookups. @@ -50,6 +56,12 @@ const ( // HeaderType is a type of header. type HeaderType string +// PHeaderType returns pointer to HeaderType. +func PHeaderType(t HeaderType) *HeaderType { + ht := HeaderType(t) + return &ht +} + // Header represents a header response from the Fastly API. type Header struct { ServiceID string `mapstructure:"service_id"` @@ -210,18 +222,18 @@ type UpdateHeaderInput struct { // Name is the name of the header to update. Name string - NewName *string `form:"name,omitempty"` - Action HeaderAction `form:"action,omitempty"` - IgnoreIfSet *Compatibool `form:"ignore_if_set,omitempty"` - Type HeaderType `form:"type,omitempty"` - Destination *string `form:"dst,omitempty"` - Source *string `form:"src,omitempty"` - Regex *string `form:"regex,omitempty"` - Substitution *string `form:"substitution,omitempty"` - Priority *uint `form:"priority,omitempty"` - RequestCondition *string `form:"request_condition,omitempty"` - CacheCondition *string `form:"cache_condition,omitempty"` - ResponseCondition *string `form:"response_condition,omitempty"` + NewName *string `form:"name,omitempty"` + Action *HeaderAction `form:"action,omitempty"` + IgnoreIfSet *Compatibool `form:"ignore_if_set,omitempty"` + Type *HeaderType `form:"type,omitempty"` + Destination *string `form:"dst,omitempty"` + Source *string `form:"src,omitempty"` + Regex *string `form:"regex,omitempty"` + Substitution *string `form:"substitution,omitempty"` + Priority *uint `form:"priority,omitempty"` + RequestCondition *string `form:"request_condition,omitempty"` + CacheCondition *string `form:"cache_condition,omitempty"` + ResponseCondition *string `form:"response_condition,omitempty"` } // UpdateHeader updates a specific header. diff --git a/fastly/header_test.go b/fastly/header_test.go index 95278d5c3..0abdf3ac3 100644 --- a/fastly/header_test.go +++ b/fastly/header_test.go @@ -140,6 +140,8 @@ func TestClient_Headers(t *testing.T) { ServiceVersion: tv.Number, Name: "test-header", NewName: String("new-test-header"), + Action: PHeaderAction(HeaderActionAppend), + Type: PHeaderType(HeaderTypeFetch), }) }) if err != nil { From 902e3c03be332cb90f54c34936f7223dadfd9a9e Mon Sep 17 00:00:00 2001 From: integralist Date: Tue, 17 Nov 2020 12:18:51 +0000 Subject: [PATCH 37/37] Use pointer reference for PoolType constants on write/update structs. --- fastly/pool.go | 8 +++++++- fastly/pool_test.go | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/fastly/pool.go b/fastly/pool.go index c88dbecc4..0bb0c18fe 100644 --- a/fastly/pool.go +++ b/fastly/pool.go @@ -21,6 +21,12 @@ const ( // PoolType is a type of pool. type PoolType string +// PPoolType returns pointer to PoolType. +func PPoolType(t PoolType) *PoolType { + pt := PoolType(t) + return &pt +} + // Pool represents a pool response from the Fastly API. type Pool struct { ServiceID string `mapstructure:"service_id"` @@ -227,7 +233,7 @@ type UpdatePoolInput struct { MinTLSVersion *string `form:"min_tls_version,omitempty"` MaxTLSVersion *string `form:"max_tls_version,omitempty"` Healthcheck *string `form:"healthcheck,omitempty"` - Type PoolType `form:"type,omitempty"` + Type *PoolType `form:"type,omitempty"` OverrideHost *string `form:"override_host,omitempty"` } diff --git a/fastly/pool_test.go b/fastly/pool_test.go index abc337c78..857ef1aa4 100644 --- a/fastly/pool_test.go +++ b/fastly/pool_test.go @@ -112,6 +112,7 @@ func TestClient_Pools(t *testing.T) { Name: "test_pool", NewName: String("new_test_pool"), Quorum: Uint(0), + Type: PPoolType(PoolTypeHash), }) }) if err != nil {