diff --git a/fastly/fixtures/kv_store/batch-create-keys.yaml b/fastly/fixtures/kv_store/batch-create-keys.yaml new file mode 100644 index 000000000..c5c6dddfd --- /dev/null +++ b/fastly/fixtures/kv_store/batch-create-keys.yaml @@ -0,0 +1,39 @@ +--- +version: 1 +interactions: +- request: + body: |- + {"key":"batch-1","value":"VkFMVUU="} + {"key":"batch-2","value":"VkFMVUU="} + form: {} + headers: + Content-Type: + - application/x-ndjson + User-Agent: + - FastlyGo/8.0.3 (+github.com/fastly/go-fastly; go1.18.5) + url: https://api.fastly.com/resources/stores/kv/yvineawuxczxih2d54jsje/batch + method: PUT + response: + body: "" + headers: + Accept-Ranges: + - bytes + Content-Length: + - "0" + Date: + - Wed, 10 May 2023 12:12:21 GMT + Strict-Transport-Security: + - max-age=31536000 + Via: + - 1.1 varnish + X-Cache: + - MISS + X-Cache-Hits: + - "0" + X-Served-By: + - cache-lhr7365-LHR, cache-lhr7365-LHR + X-Timer: + - S1683720741.930472,VS0,VE246 + status: 200 OK + code: 200 + duration: "" diff --git a/fastly/fixtures/kv_store/check-keys.yaml b/fastly/fixtures/kv_store/check-keys.yaml index 990de3dd8..da45ce5ae 100644 --- a/fastly/fixtures/kv_store/check-keys.yaml +++ b/fastly/fixtures/kv_store/check-keys.yaml @@ -6,34 +6,45 @@ interactions: form: {} headers: User-Agent: - - FastlyGo/6.5.0 (+github.com/fastly/go-fastly; go1.19) - url: https://api.fastly.com/resources/stores/kv/fff9gl14gebt6m9kkp54ve/keys/apple + - FastlyGo/8.0.3 (+github.com/fastly/go-fastly; go1.18.5) + url: https://api.fastly.com/resources/stores/kv/yvineawuxczxih2d54jsje/keys/apple method: GET response: body: apple0 headers: Accept-Ranges: - bytes - Cache-Control: - - max-age=86400 + Content-Length: + - "6" Content-Type: - application/octet-stream Date: - - Thu, 15 Sep 2022 17:55:38 GMT - Server-Timing: - - get_object;dur=119, total;dur=123, verify;dur=1 + - Wed, 10 May 2023 12:12:19 GMT + Generation: + - "1683720737565195" + Last-Modified: + - Wed, 10 May 2023 12:12:17 GMT + Metadata: + - "" + Server-Timing-Get-Key: + - transaction_lookup_ok;dur=0, lookup_handle_status_status_fetch;dur=1, backend_request;dur=473, + res_ok;dur=0, finish_write;dur=1, cache_handle_status_FOUND___USABLE;dur=0, + cache_handle_status_USABLE;dur=0, handle_usable;dur=0, lookup_handle_get_body;dur=0, + user_metadata_json;dur=0, total;dur=476 + Stored-Content-Length: + - "6" Strict-Transport-Security: - max-age=31536000 Via: - 1.1 varnish X-Cache: - - MISS + - MISS, MISS X-Cache-Hits: - "0" X-Served-By: - - cache-fty21321-FTY, cache-sea4451-SEA + - cache-lhr7367-LHR, cache-lhr7365-LHR X-Timer: - - S1663264538.181432,VS0,VE183 + - S1683720739.562212,VS0,VE493 status: 200 OK code: 200 duration: "" @@ -42,34 +53,45 @@ interactions: form: {} headers: User-Agent: - - FastlyGo/6.5.0 (+github.com/fastly/go-fastly; go1.19) - url: https://api.fastly.com/resources/stores/kv/fff9gl14gebt6m9kkp54ve/keys/banana + - FastlyGo/8.0.3 (+github.com/fastly/go-fastly; go1.18.5) + url: https://api.fastly.com/resources/stores/kv/yvineawuxczxih2d54jsje/keys/banana method: GET response: body: banana1 headers: Accept-Ranges: - bytes - Cache-Control: - - max-age=86400 + Content-Length: + - "7" Content-Type: - application/octet-stream Date: - - Thu, 15 Sep 2022 17:55:38 GMT - Server-Timing: - - get_object;dur=95, total;dur=99, verify;dur=1 + - Wed, 10 May 2023 12:12:19 GMT + Generation: + - "1683720737774725" + Last-Modified: + - Wed, 10 May 2023 12:12:17 GMT + Metadata: + - "" + Server-Timing-Get-Key: + - transaction_lookup_ok;dur=0, lookup_handle_status_status_fetch;dur=1, backend_request;dur=430, + res_ok;dur=0, finish_write;dur=1, cache_handle_status_FOUND___USABLE;dur=0, + cache_handle_status_USABLE;dur=0, handle_usable;dur=0, lookup_handle_get_body;dur=0, + user_metadata_json;dur=0, total;dur=433 + Stored-Content-Length: + - "7" Strict-Transport-Security: - max-age=31536000 Via: - 1.1 varnish X-Cache: - - MISS + - MISS, MISS X-Cache-Hits: - "0" X-Served-By: - - cache-fty21353-FTY, cache-sea4451-SEA + - cache-lhr7351-LHR, cache-lhr7365-LHR X-Timer: - - S1663264538.383885,VS0,VE160 + - S1683720739.111105,VS0,VE474 status: 200 OK code: 200 duration: "" @@ -78,34 +100,45 @@ interactions: form: {} headers: User-Agent: - - FastlyGo/6.5.0 (+github.com/fastly/go-fastly; go1.19) - url: https://api.fastly.com/resources/stores/kv/fff9gl14gebt6m9kkp54ve/keys/carrot + - FastlyGo/8.0.3 (+github.com/fastly/go-fastly; go1.18.5) + url: https://api.fastly.com/resources/stores/kv/yvineawuxczxih2d54jsje/keys/carrot method: GET response: body: carrot2 headers: Accept-Ranges: - bytes - Cache-Control: - - max-age=86400 + Content-Length: + - "7" Content-Type: - application/octet-stream Date: - - Thu, 15 Sep 2022 17:55:38 GMT - Server-Timing: - - get_object;dur=97, verify;dur=1, total;dur=102 + - Wed, 10 May 2023 12:12:20 GMT + Generation: + - "1683720737987074" + Last-Modified: + - Wed, 10 May 2023 12:12:17 GMT + Metadata: + - "" + Server-Timing-Get-Key: + - transaction_lookup_ok;dur=0, lookup_handle_status_status_fetch;dur=1, backend_request;dur=370, + res_ok;dur=0, finish_write;dur=1, cache_handle_status_FOUND___USABLE;dur=0, + cache_handle_status_USABLE;dur=0, handle_usable;dur=0, lookup_handle_get_body;dur=0, + user_metadata_json;dur=0, total;dur=373 + Stored-Content-Length: + - "7" Strict-Transport-Security: - max-age=31536000 Via: - 1.1 varnish X-Cache: - - MISS + - MISS, MISS X-Cache-Hits: - "0" X-Served-By: - - cache-fty21337-FTY, cache-sea4451-SEA + - cache-lhr7335-LHR, cache-lhr7365-LHR X-Timer: - - S1663264539.560918,VS0,VE166 + - S1683720740.614086,VS0,VE392 status: 200 OK code: 200 duration: "" @@ -114,34 +147,45 @@ interactions: form: {} headers: User-Agent: - - FastlyGo/6.5.0 (+github.com/fastly/go-fastly; go1.19) - url: https://api.fastly.com/resources/stores/kv/fff9gl14gebt6m9kkp54ve/keys/dragonfruit + - FastlyGo/8.0.3 (+github.com/fastly/go-fastly; go1.18.5) + url: https://api.fastly.com/resources/stores/kv/yvineawuxczxih2d54jsje/keys/dragonfruit method: GET response: body: dragonfruit3 headers: Accept-Ranges: - bytes - Cache-Control: - - max-age=86400 + Content-Length: + - "12" Content-Type: - application/octet-stream Date: - - Thu, 15 Sep 2022 17:55:38 GMT - Server-Timing: - - get_object;dur=121, total;dur=125, verify;dur=1 + - Wed, 10 May 2023 12:12:20 GMT + Generation: + - "1683720738237014" + Last-Modified: + - Wed, 10 May 2023 12:12:18 GMT + Metadata: + - "" + Server-Timing-Get-Key: + - transaction_lookup_ok;dur=0, lookup_handle_status_status_fetch;dur=1, backend_request;dur=462, + res_ok;dur=0, finish_write;dur=4, cache_handle_status_FOUND___USABLE;dur=0, + cache_handle_status_USABLE;dur=0, handle_usable;dur=0, lookup_handle_get_body;dur=0, + user_metadata_json;dur=0, total;dur=468 + Stored-Content-Length: + - "12" Strict-Transport-Security: - max-age=31536000 Via: - 1.1 varnish X-Cache: - - MISS + - MISS, MISS X-Cache-Hits: - "0" X-Served-By: - - cache-fty21362-FTY, cache-sea4451-SEA + - cache-lhr7338-LHR, cache-lhr7365-LHR X-Timer: - - S1663264539.742169,VS0,VE185 + - S1683720740.035630,VS0,VE481 status: 200 OK code: 200 duration: "" @@ -150,34 +194,45 @@ interactions: form: {} headers: User-Agent: - - FastlyGo/6.5.0 (+github.com/fastly/go-fastly; go1.19) - url: https://api.fastly.com/resources/stores/kv/fff9gl14gebt6m9kkp54ve/keys/eggplant + - FastlyGo/8.0.3 (+github.com/fastly/go-fastly; go1.18.5) + url: https://api.fastly.com/resources/stores/kv/yvineawuxczxih2d54jsje/keys/eggplant method: GET response: body: eggplant4 headers: Accept-Ranges: - bytes - Cache-Control: - - max-age=86400 + Content-Length: + - "9" Content-Type: - application/octet-stream Date: - - Thu, 15 Sep 2022 17:55:39 GMT - Server-Timing: - - total;dur=121, verify;dur=1, get_object;dur=115 + - Wed, 10 May 2023 12:12:20 GMT + Generation: + - "1683720738460728" + Last-Modified: + - Wed, 10 May 2023 12:12:18 GMT + Metadata: + - "" + Server-Timing-Get-Key: + - transaction_lookup_ok;dur=0, lookup_handle_status_status_fetch;dur=0, backend_request;dur=343, + res_ok;dur=0, finish_write;dur=1, cache_handle_status_FOUND___USABLE;dur=0, + cache_handle_status_USABLE;dur=0, handle_usable;dur=0, lookup_handle_get_body;dur=0, + user_metadata_json;dur=0, total;dur=346 + Stored-Content-Length: + - "9" Strict-Transport-Security: - max-age=31536000 Via: - 1.1 varnish X-Cache: - - MISS + - MISS, MISS X-Cache-Hits: - "0" X-Served-By: - - cache-fty21342-FTY, cache-sea4451-SEA + - cache-lhr7326-LHR, cache-lhr7365-LHR X-Timer: - - S1663264539.945095,VS0,VE182 + - S1683720741.543073,VS0,VE359 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/kv_store/cleanup.yaml b/fastly/fixtures/kv_store/cleanup.yaml index f7a99e7ce..777480734 100644 --- a/fastly/fixtures/kv_store/cleanup.yaml +++ b/fastly/fixtures/kv_store/cleanup.yaml @@ -6,20 +6,18 @@ interactions: form: {} headers: User-Agent: - - FastlyGo/6.5.0 (+github.com/fastly/go-fastly; go1.19) - url: https://api.fastly.com/resources/stores/kv/fff9gl14gebt6m9kkp54ve/keys + - FastlyGo/8.0.3 (+github.com/fastly/go-fastly; go1.18.5) + url: https://api.fastly.com/resources/stores/kv/yvineawuxczxih2d54jsje/keys method: GET response: - body: '{"data":["apple","banana","carrot","dragonfruit","eggplant"],"meta":{"limit":100}}' + body: '{"data":["apple","banana","batch-1","batch-2","carrot","dragonfruit","eggplant"],"meta":{"limit":1000}}' headers: Accept-Ranges: - bytes Content-Type: - application/json Date: - - Thu, 15 Sep 2022 17:55:40 GMT - Server-Timing: - - verify;dur=1, list_buckets;dur=140, total;dur=144 + - Wed, 10 May 2023 12:12:22 GMT Strict-Transport-Security: - max-age=31536000 Via: @@ -29,9 +27,9 @@ interactions: X-Cache-Hits: - "0" X-Served-By: - - cache-fty21373-FTY, cache-sea4451-SEA + - cache-lhr7365-LHR, cache-lhr7365-LHR X-Timer: - - S1663264540.850553,VS0,VE203 + - S1683720742.929949,VS0,VE198 status: 200 OK code: 200 duration: "" @@ -40,8 +38,8 @@ interactions: form: {} headers: User-Agent: - - FastlyGo/6.5.0 (+github.com/fastly/go-fastly; go1.19) - url: https://api.fastly.com/resources/stores/kv/fff9gl14gebt6m9kkp54ve/keys/apple + - FastlyGo/8.0.3 (+github.com/fastly/go-fastly; go1.18.5) + url: https://api.fastly.com/resources/stores/kv/yvineawuxczxih2d54jsje/keys/apple method: DELETE response: body: "" @@ -49,21 +47,19 @@ interactions: Accept-Ranges: - bytes Date: - - Thu, 15 Sep 2022 17:55:40 GMT - Server-Timing: - - total;dur=342, verify;dur=2, delete_object;dur=337 + - Wed, 10 May 2023 12:12:22 GMT Strict-Transport-Security: - max-age=31536000 Via: - 1.1 varnish X-Cache: - - MISS + - MISS, MISS X-Cache-Hits: - "0" X-Served-By: - - cache-fty21373-FTY, cache-sea4451-SEA + - cache-lhr7365-LHR, cache-lhr7365-LHR X-Timer: - - S1663264540.071843,VS0,VE402 + - S1683720742.152083,VS0,VE185 status: 204 No Content code: 204 duration: "" @@ -72,8 +68,8 @@ interactions: form: {} headers: User-Agent: - - FastlyGo/6.5.0 (+github.com/fastly/go-fastly; go1.19) - url: https://api.fastly.com/resources/stores/kv/fff9gl14gebt6m9kkp54ve/keys/banana + - FastlyGo/8.0.3 (+github.com/fastly/go-fastly; go1.18.5) + url: https://api.fastly.com/resources/stores/kv/yvineawuxczxih2d54jsje/keys/banana method: DELETE response: body: "" @@ -81,21 +77,19 @@ interactions: Accept-Ranges: - bytes Date: - - Thu, 15 Sep 2022 17:55:40 GMT - Server-Timing: - - verify;dur=1, total;dur=297, delete_object;dur=293 + - Wed, 10 May 2023 12:12:22 GMT Strict-Transport-Security: - max-age=31536000 Via: - 1.1 varnish X-Cache: - - MISS + - MISS, MISS X-Cache-Hits: - "0" X-Served-By: - - cache-fty21373-FTY, cache-sea4451-SEA + - cache-lhr7365-LHR, cache-lhr7365-LHR X-Timer: - - S1663264541.528713,VS0,VE357 + - S1683720742.367456,VS0,VE188 status: 204 No Content code: 204 duration: "" @@ -104,8 +98,8 @@ interactions: form: {} headers: User-Agent: - - FastlyGo/6.5.0 (+github.com/fastly/go-fastly; go1.19) - url: https://api.fastly.com/resources/stores/kv/fff9gl14gebt6m9kkp54ve/keys/carrot + - FastlyGo/8.0.3 (+github.com/fastly/go-fastly; go1.18.5) + url: https://api.fastly.com/resources/stores/kv/yvineawuxczxih2d54jsje/keys/batch-1 method: DELETE response: body: "" @@ -113,21 +107,19 @@ interactions: Accept-Ranges: - bytes Date: - - Thu, 15 Sep 2022 17:55:41 GMT - Server-Timing: - - total;dur=314, verify;dur=2, delete_object;dur=308 + - Wed, 10 May 2023 12:12:22 GMT Strict-Transport-Security: - max-age=31536000 Via: - 1.1 varnish X-Cache: - - MISS + - MISS, MISS X-Cache-Hits: - "0" X-Served-By: - - cache-fty21373-FTY, cache-sea4451-SEA + - cache-lhr7365-LHR, cache-lhr7365-LHR X-Timer: - - S1663264541.903027,VS0,VE373 + - S1683720743.591727,VS0,VE181 status: 204 No Content code: 204 duration: "" @@ -136,8 +128,8 @@ interactions: form: {} headers: User-Agent: - - FastlyGo/6.5.0 (+github.com/fastly/go-fastly; go1.19) - url: https://api.fastly.com/resources/stores/kv/fff9gl14gebt6m9kkp54ve/keys/dragonfruit + - FastlyGo/8.0.3 (+github.com/fastly/go-fastly; go1.18.5) + url: https://api.fastly.com/resources/stores/kv/yvineawuxczxih2d54jsje/keys/batch-2 method: DELETE response: body: "" @@ -145,21 +137,19 @@ interactions: Accept-Ranges: - bytes Date: - - Thu, 15 Sep 2022 17:55:41 GMT - Server-Timing: - - total;dur=315, verify;dur=1, delete_object;dur=310 + - Wed, 10 May 2023 12:12:22 GMT Strict-Transport-Security: - max-age=31536000 Via: - 1.1 varnish X-Cache: - - MISS + - MISS, MISS X-Cache-Hits: - "0" X-Served-By: - - cache-fty21373-FTY, cache-sea4451-SEA + - cache-lhr7365-LHR, cache-lhr7365-LHR X-Timer: - - S1663264541.338655,VS0,VE374 + - S1683720743.803234,VS0,VE190 status: 204 No Content code: 204 duration: "" @@ -168,8 +158,8 @@ interactions: form: {} headers: User-Agent: - - FastlyGo/6.5.0 (+github.com/fastly/go-fastly; go1.19) - url: https://api.fastly.com/resources/stores/kv/fff9gl14gebt6m9kkp54ve/keys/eggplant + - FastlyGo/8.0.3 (+github.com/fastly/go-fastly; go1.18.5) + url: https://api.fastly.com/resources/stores/kv/yvineawuxczxih2d54jsje/keys/carrot method: DELETE response: body: "" @@ -177,21 +167,19 @@ interactions: Accept-Ranges: - bytes Date: - - Thu, 15 Sep 2022 17:55:42 GMT - Server-Timing: - - total;dur=308, delete_object;dur=304, verify;dur=1 + - Wed, 10 May 2023 12:12:23 GMT Strict-Transport-Security: - max-age=31536000 Via: - 1.1 varnish X-Cache: - - MISS + - MISS, MISS X-Cache-Hits: - "0" X-Served-By: - - cache-fty21373-FTY, cache-sea4451-SEA + - cache-lhr7365-LHR, cache-lhr7365-LHR X-Timer: - - S1663264542.768237,VS0,VE367 + - S1683720743.018149,VS0,VE192 status: 204 No Content code: 204 duration: "" @@ -200,8 +188,8 @@ interactions: form: {} headers: User-Agent: - - FastlyGo/6.5.0 (+github.com/fastly/go-fastly; go1.19) - url: https://api.fastly.com/resources/stores/kv/fff9gl14gebt6m9kkp54ve + - FastlyGo/8.0.3 (+github.com/fastly/go-fastly; go1.18.5) + url: https://api.fastly.com/resources/stores/kv/yvineawuxczxih2d54jsje/keys/dragonfruit method: DELETE response: body: "" @@ -209,21 +197,79 @@ interactions: Accept-Ranges: - bytes Date: - - Thu, 15 Sep 2022 17:55:42 GMT - Server-Timing: - - total;dur=578, delete_attachment;dur=56, verify;dur=1, delete_bucket;dur=518 + - Wed, 10 May 2023 12:12:23 GMT Strict-Transport-Security: - max-age=31536000 Via: - 1.1 varnish X-Cache: - - MISS + - MISS, MISS + X-Cache-Hits: + - "0" + X-Served-By: + - cache-lhr7365-LHR, cache-lhr7365-LHR + X-Timer: + - S1683720743.233186,VS0,VE184 + status: 204 No Content + code: 204 + duration: "" +- request: + body: "" + form: {} + headers: + User-Agent: + - FastlyGo/8.0.3 (+github.com/fastly/go-fastly; go1.18.5) + url: https://api.fastly.com/resources/stores/kv/yvineawuxczxih2d54jsje/keys/eggplant + method: DELETE + response: + body: "" + headers: + Accept-Ranges: + - bytes + Date: + - Wed, 10 May 2023 12:12:23 GMT + Strict-Transport-Security: + - max-age=31536000 + Via: + - 1.1 varnish + X-Cache: + - MISS, MISS + X-Cache-Hits: + - "0" + X-Served-By: + - cache-lhr7365-LHR, cache-lhr7365-LHR + X-Timer: + - S1683720743.449694,VS0,VE196 + status: 204 No Content + code: 204 + duration: "" +- request: + body: "" + form: {} + headers: + User-Agent: + - FastlyGo/8.0.3 (+github.com/fastly/go-fastly; go1.18.5) + url: https://api.fastly.com/resources/stores/kv/yvineawuxczxih2d54jsje + method: DELETE + response: + body: "" + headers: + Accept-Ranges: + - bytes + Date: + - Wed, 10 May 2023 12:12:24 GMT + Strict-Transport-Security: + - max-age=31536000 + Via: + - 1.1 varnish + X-Cache: + - MISS, MISS X-Cache-Hits: - "0" X-Served-By: - - cache-fty21373-FTY, cache-sea4451-SEA + - cache-lhr7365-LHR, cache-lhr7365-LHR X-Timer: - - S1663264542.166765,VS0,VE637 + - S1683720744.674525,VS0,VE842 status: 204 No Content code: 204 duration: "" diff --git a/fastly/fixtures/kv_store/create-keys.yaml b/fastly/fixtures/kv_store/create-keys.yaml index df38a827a..262347bd2 100644 --- a/fastly/fixtures/kv_store/create-keys.yaml +++ b/fastly/fixtures/kv_store/create-keys.yaml @@ -6,8 +6,8 @@ interactions: form: {} headers: User-Agent: - - FastlyGo/6.5.0 (+github.com/fastly/go-fastly; go1.19) - url: https://api.fastly.com/resources/stores/kv/fff9gl14gebt6m9kkp54ve/keys/apple + - FastlyGo/8.0.3 (+github.com/fastly/go-fastly; go1.18.5) + url: https://api.fastly.com/resources/stores/kv/yvineawuxczxih2d54jsje/keys/apple method: PUT response: body: "" @@ -17,9 +17,7 @@ interactions: Content-Length: - "0" Date: - - Thu, 15 Sep 2022 17:55:36 GMT - Server-Timing: - - set_object;dur=275, verify;dur=1, total;dur=279 + - Wed, 10 May 2023 12:12:17 GMT Strict-Transport-Security: - max-age=31536000 Via: @@ -29,9 +27,9 @@ interactions: X-Cache-Hits: - "0" X-Served-By: - - cache-fty21373-FTY, cache-sea4451-SEA + - cache-lhr7365-LHR, cache-lhr7365-LHR X-Timer: - - S1663264536.174126,VS0,VE361 + - S1683720737.442854,VS0,VE197 status: 200 OK code: 200 duration: "" @@ -40,8 +38,8 @@ interactions: form: {} headers: User-Agent: - - FastlyGo/6.5.0 (+github.com/fastly/go-fastly; go1.19) - url: https://api.fastly.com/resources/stores/kv/fff9gl14gebt6m9kkp54ve/keys/banana + - FastlyGo/8.0.3 (+github.com/fastly/go-fastly; go1.18.5) + url: https://api.fastly.com/resources/stores/kv/yvineawuxczxih2d54jsje/keys/banana method: PUT response: body: "" @@ -51,9 +49,7 @@ interactions: Content-Length: - "0" Date: - - Thu, 15 Sep 2022 17:55:37 GMT - Server-Timing: - - total;dur=408, set_object;dur=402, verify;dur=1 + - Wed, 10 May 2023 12:12:17 GMT Strict-Transport-Security: - max-age=31536000 Via: @@ -63,9 +59,9 @@ interactions: X-Cache-Hits: - "0" X-Served-By: - - cache-fty21373-FTY, cache-sea4451-SEA + - cache-lhr7365-LHR, cache-lhr7365-LHR X-Timer: - - S1663264537.554119,VS0,VE472 + - S1683720738.666935,VS0,VE183 status: 200 OK code: 200 duration: "" @@ -74,8 +70,8 @@ interactions: form: {} headers: User-Agent: - - FastlyGo/6.5.0 (+github.com/fastly/go-fastly; go1.19) - url: https://api.fastly.com/resources/stores/kv/fff9gl14gebt6m9kkp54ve/keys/carrot + - FastlyGo/8.0.3 (+github.com/fastly/go-fastly; go1.18.5) + url: https://api.fastly.com/resources/stores/kv/yvineawuxczxih2d54jsje/keys/carrot method: PUT response: body: "" @@ -85,9 +81,7 @@ interactions: Content-Length: - "0" Date: - - Thu, 15 Sep 2022 17:55:37 GMT - Server-Timing: - - verify;dur=1, set_object;dur=319, total;dur=324 + - Wed, 10 May 2023 12:12:18 GMT Strict-Transport-Security: - max-age=31536000 Via: @@ -97,9 +91,9 @@ interactions: X-Cache-Hits: - "0" X-Served-By: - - cache-fty21373-FTY, cache-sea4451-SEA + - cache-lhr7365-LHR, cache-lhr7365-LHR X-Timer: - - S1663264537.042032,VS0,VE384 + - S1683720738.870371,VS0,VE192 status: 200 OK code: 200 duration: "" @@ -108,8 +102,8 @@ interactions: form: {} headers: User-Agent: - - FastlyGo/6.5.0 (+github.com/fastly/go-fastly; go1.19) - url: https://api.fastly.com/resources/stores/kv/fff9gl14gebt6m9kkp54ve/keys/dragonfruit + - FastlyGo/8.0.3 (+github.com/fastly/go-fastly; go1.18.5) + url: https://api.fastly.com/resources/stores/kv/yvineawuxczxih2d54jsje/keys/dragonfruit method: PUT response: body: "" @@ -119,9 +113,7 @@ interactions: Content-Length: - "0" Date: - - Thu, 15 Sep 2022 17:55:37 GMT - Server-Timing: - - total;dur=288, set_object;dur=284, verify;dur=1 + - Wed, 10 May 2023 12:12:18 GMT Strict-Transport-Security: - max-age=31536000 Via: @@ -131,9 +123,9 @@ interactions: X-Cache-Hits: - "0" X-Served-By: - - cache-fty21373-FTY, cache-sea4451-SEA + - cache-lhr7365-LHR, cache-lhr7365-LHR X-Timer: - - S1663264537.446895,VS0,VE352 + - S1683720738.117502,VS0,VE195 status: 200 OK code: 200 duration: "" @@ -142,8 +134,8 @@ interactions: form: {} headers: User-Agent: - - FastlyGo/6.5.0 (+github.com/fastly/go-fastly; go1.19) - url: https://api.fastly.com/resources/stores/kv/fff9gl14gebt6m9kkp54ve/keys/eggplant + - FastlyGo/8.0.3 (+github.com/fastly/go-fastly; go1.18.5) + url: https://api.fastly.com/resources/stores/kv/yvineawuxczxih2d54jsje/keys/eggplant method: PUT response: body: "" @@ -153,9 +145,7 @@ interactions: Content-Length: - "0" Date: - - Thu, 15 Sep 2022 17:55:38 GMT - Server-Timing: - - verify;dur=1, total;dur=244, set_object;dur=240 + - Wed, 10 May 2023 12:12:18 GMT Strict-Transport-Security: - max-age=31536000 Via: @@ -165,9 +155,9 @@ interactions: X-Cache-Hits: - "0" X-Served-By: - - cache-fty21373-FTY, cache-sea4451-SEA + - cache-lhr7365-LHR, cache-lhr7365-LHR X-Timer: - - S1663264538.822351,VS0,VE317 + - S1683720738.341931,VS0,VE194 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/kv_store/create-store.yaml b/fastly/fixtures/kv_store/create-store.yaml index 8152bceb0..3506c628b 100644 --- a/fastly/fixtures/kv_store/create-store.yaml +++ b/fastly/fixtures/kv_store/create-store.yaml @@ -10,32 +10,31 @@ interactions: Content-Type: - application/json User-Agent: - - FastlyGo/6.5.0 (+github.com/fastly/go-fastly; go1.19) + - FastlyGo/8.0.3 (+github.com/fastly/go-fastly; go1.18.5) url: https://api.fastly.com/resources/stores/kv method: POST response: - body: '{"id":"fff9gl14gebt6m9kkp54ve","name":"kv-store-test-store","created_at":"2022-09-15T17:55:35.881Z","updated_at":"2022-09-15T17:55:35.881Z"}' + body: '{"id":"yvineawuxczxih2d54jsje","name":"kv-store-test-store","created_at":"2023-05-10 + 12:12:17","updated_at":"2023-05-10 12:12:17"}' headers: Accept-Ranges: - bytes Content-Type: - application/json Date: - - Thu, 15 Sep 2022 17:55:35 GMT - Server-Timing: - - total;dur=1613, create_bucket;dur=1502, create_attachment;dur=107, verify;dur=1 + - Wed, 10 May 2023 12:12:17 GMT Strict-Transport-Security: - max-age=31536000 Via: - 1.1 varnish X-Cache: - - MISS + - MISS, MISS X-Cache-Hits: - "0" X-Served-By: - - cache-fty21373-FTY, cache-sea4451-SEA + - cache-lhr7365-LHR, cache-lhr7365-LHR X-Timer: - - S1663264534.237962,VS0,VE1672 + - S1683720735.110195,VS0,VE2034 status: 201 Created code: 201 duration: "" diff --git a/fastly/fixtures/kv_store/get-store.yaml b/fastly/fixtures/kv_store/get-store.yaml index b0751604d..033928ccc 100644 --- a/fastly/fixtures/kv_store/get-store.yaml +++ b/fastly/fixtures/kv_store/get-store.yaml @@ -6,20 +6,19 @@ interactions: form: {} headers: User-Agent: - - FastlyGo/6.5.0 (+github.com/fastly/go-fastly; go1.19) - url: https://api.fastly.com/resources/stores/kv/fff9gl14gebt6m9kkp54ve + - FastlyGo/8.0.3 (+github.com/fastly/go-fastly; go1.18.5) + url: https://api.fastly.com/resources/stores/kv/yvineawuxczxih2d54jsje method: GET response: - body: '{"id":"fff9gl14gebt6m9kkp54ve","name":"kv-store-test-store","created_at":"2022-09-15T17:55:36.122Z","updated_at":"2022-09-15T17:55:36.122Z"}' + body: '{"id":"yvineawuxczxih2d54jsje","name":"kv-store-test-store","created_at":"2023-05-10 + 12:12:17","updated_at":"2023-05-10 12:12:17"}' headers: Accept-Ranges: - bytes Content-Type: - application/json Date: - - Thu, 15 Sep 2022 17:55:36 GMT - Server-Timing: - - get_attachment;dur=115, verify;dur=1, total;dur=119 + - Wed, 10 May 2023 12:12:17 GMT Strict-Transport-Security: - max-age=31536000 Via: @@ -29,9 +28,9 @@ interactions: X-Cache-Hits: - "0" X-Served-By: - - cache-fty21321-FTY, cache-sea4451-SEA + - cache-lhr7339-LHR, cache-lhr7365-LHR X-Timer: - - S1663264536.973202,VS0,VE179 + - S1683720737.174369,VS0,VE237 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/kv_store/list-keys-pagination.yaml b/fastly/fixtures/kv_store/list-keys-pagination.yaml index fe9ba95f3..0262e100b 100644 --- a/fastly/fixtures/kv_store/list-keys-pagination.yaml +++ b/fastly/fixtures/kv_store/list-keys-pagination.yaml @@ -6,20 +6,18 @@ interactions: form: {} headers: User-Agent: - - FastlyGo/6.5.0 (+github.com/fastly/go-fastly; go1.19) - url: https://api.fastly.com/resources/stores/kv/fff9gl14gebt6m9kkp54ve/keys?limit=4 + - FastlyGo/8.0.3 (+github.com/fastly/go-fastly; go1.18.5) + url: https://api.fastly.com/resources/stores/kv/yvineawuxczxih2d54jsje/keys?limit=4 method: GET response: - body: '{"data":["apple","banana","carrot","dragonfruit"],"meta":{"limit":4,"next_cursor":"CgtkcmFnb25mcnVpdA=="}}' + body: '{"data":["apple","banana","batch-1","batch-2"],"meta":{"limit":4,"next_cursor":"CgdiYXRjaC0y"}}' headers: Accept-Ranges: - bytes Content-Type: - application/json Date: - - Thu, 15 Sep 2022 17:55:39 GMT - Server-Timing: - - list_buckets;dur=72, verify;dur=1, total;dur=75 + - Wed, 10 May 2023 12:12:21 GMT Strict-Transport-Security: - max-age=31536000 Via: @@ -29,9 +27,9 @@ interactions: X-Cache-Hits: - "0" X-Served-By: - - cache-fty21321-FTY, cache-sea4451-SEA + - cache-lhr7367-LHR, cache-lhr7365-LHR X-Timer: - - S1663264540.531075,VS0,VE136 + - S1683720741.489338,VS0,VE181 status: 200 OK code: 200 duration: "" @@ -40,20 +38,18 @@ interactions: form: {} headers: User-Agent: - - FastlyGo/6.5.0 (+github.com/fastly/go-fastly; go1.19) - url: https://api.fastly.com/resources/stores/kv/fff9gl14gebt6m9kkp54ve/keys?cursor=CgtkcmFnb25mcnVpdA%3D%3D&limit=4 + - FastlyGo/8.0.3 (+github.com/fastly/go-fastly; go1.18.5) + url: https://api.fastly.com/resources/stores/kv/yvineawuxczxih2d54jsje/keys?cursor=CgdiYXRjaC0y&limit=4 method: GET response: - body: '{"data":["eggplant"],"meta":{"limit":4}}' + body: '{"data":["carrot","dragonfruit","eggplant"],"meta":{"limit":4}}' headers: Accept-Ranges: - bytes Content-Type: - application/json Date: - - Thu, 15 Sep 2022 17:55:39 GMT - Server-Timing: - - total;dur=83, verify;dur=1, list_buckets;dur=79 + - Wed, 10 May 2023 12:12:21 GMT Strict-Transport-Security: - max-age=31536000 Via: @@ -63,9 +59,9 @@ interactions: X-Cache-Hits: - "0" X-Served-By: - - cache-fty21332-FTY, cache-sea4451-SEA + - cache-lhr7339-LHR, cache-lhr7365-LHR X-Timer: - - S1663264540.686870,VS0,VE144 + - S1683720742.703523,VS0,VE190 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/kv_store/list-keys.yaml b/fastly/fixtures/kv_store/list-keys.yaml index be76c4bbd..6cb8bf26d 100644 --- a/fastly/fixtures/kv_store/list-keys.yaml +++ b/fastly/fixtures/kv_store/list-keys.yaml @@ -6,20 +6,18 @@ interactions: form: {} headers: User-Agent: - - FastlyGo/6.5.0 (+github.com/fastly/go-fastly; go1.19) - url: https://api.fastly.com/resources/stores/kv/fff9gl14gebt6m9kkp54ve/keys + - FastlyGo/8.0.3 (+github.com/fastly/go-fastly; go1.18.5) + url: https://api.fastly.com/resources/stores/kv/yvineawuxczxih2d54jsje/keys method: GET response: - body: '{"data":["apple","banana","carrot","dragonfruit","eggplant"],"meta":{"limit":100}}' + body: '{"data":["apple","banana","batch-1","batch-2","carrot","dragonfruit","eggplant"],"meta":{"limit":1000}}' headers: Accept-Ranges: - bytes Content-Type: - application/json Date: - - Thu, 15 Sep 2022 17:55:39 GMT - Server-Timing: - - total;dur=111, list_buckets;dur=89, verify;dur=2 + - Wed, 10 May 2023 12:12:21 GMT Strict-Transport-Security: - max-age=31536000 Via: @@ -29,9 +27,9 @@ interactions: X-Cache-Hits: - "0" X-Served-By: - - cache-fty21355-FTY, cache-sea4451-SEA + - cache-lhr7380-LHR, cache-lhr7365-LHR X-Timer: - - S1663264539.145395,VS0,VE345 + - S1683720741.216779,VS0,VE236 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/kv_store/list-store.yaml b/fastly/fixtures/kv_store/list-store.yaml index f0b1b8f15..c35f83ae4 100644 --- a/fastly/fixtures/kv_store/list-store.yaml +++ b/fastly/fixtures/kv_store/list-store.yaml @@ -6,20 +6,29 @@ interactions: form: {} headers: User-Agent: - - FastlyGo/6.5.0 (+github.com/fastly/go-fastly; go1.19) + - FastlyGo/8.0.3 (+github.com/fastly/go-fastly; go1.18.5) url: https://api.fastly.com/resources/stores/kv method: GET response: - body: '{"data":[],"meta":{"limit":100,"total":0}}' + body: '{"data":[{"id":"hy7v4fvn2et8w8ur9pwh28","name":"kvstore s02j4oehp0","created_at":"2023-05-02 + 14:11:16","updated_at":"2023-05-02 14:11:16"},{"id":"bhvp6ieicv312295gytp7n","name":"my-store","created_at":"2023-01-16 + 16:42:05","updated_at":"2023-01-16 16:42:05"},{"id":"877tz9agkk7hp7efnkdsr3","name":"mystore_via_cli","created_at":"2023-01-16 + 16:49:51","updated_at":"2023-01-16 16:49:51"},{"id":"kupym5jumwkdty9tkrvezt","name":"mystore_via_cli2","created_at":"2023-01-16 + 16:51:38","updated_at":"2023-01-16 16:51:38"},{"id":"fnz2r0pwuea2927sx063nv","name":"mystore_via_cli3","created_at":"2023-01-16 + 16:51:46","updated_at":"2023-01-16 16:51:46"},{"id":"5v6bkddzedhlq9882x6612","name":"store_one","created_at":"2023-01-17 + 15:02:05","updated_at":"2023-01-17 15:02:05"},{"id":"9meqixmwv1pkzlxz9l50fw","name":"store_testing_with_resource","created_at":"2023-01-19 + 14:04:50","updated_at":"2023-01-19 14:04:50"},{"id":"cgood8gnuv8hux8nomzsww","name":"store_testing_with_resource_1","created_at":"2023-01-19 + 14:10:21","updated_at":"2023-01-19 14:10:21"},{"id":"hm03bou56ud6zkze9oi036","name":"testing-alias-objectstore","created_at":"2023-04-19 + 19:02:43","updated_at":"2023-04-19 19:02:43"},{"id":"olwenufofbiklsaaz4i1l8","name":"testing-v9","created_at":"2023-04-19 + 16:31:45","updated_at":"2023-04-19 16:31:45"},{"id":"12gc9ydwyqfkzpnjeui3nh","name":"test_store","created_at":"2021-09-21 + 18:53:44","updated_at":"2021-09-21 18:53:44"}],"meta":{"limit":1000,"total":11}}' headers: Accept-Ranges: - bytes Content-Type: - application/json Date: - - Thu, 15 Sep 2022 17:55:34 GMT - Server-Timing: - - get_all_attachments;dur=65, total;dur=69, verify;dur=0 + - Wed, 10 May 2023 12:12:15 GMT Strict-Transport-Security: - max-age=31536000 Via: @@ -29,9 +38,9 @@ interactions: X-Cache-Hits: - "0" X-Served-By: - - cache-fty21328-FTY, cache-sea4451-SEA + - cache-lhr7393-LHR, cache-lhr7365-LHR X-Timer: - - S1663264534.091486,VS0,VE129 + - S1683720735.545489,VS0,VE537 status: 200 OK code: 200 duration: "" diff --git a/fastly/kv_store.go b/fastly/kv_store.go index f33d20cc1..f7ed7eaef 100644 --- a/fastly/kv_store.go +++ b/fastly/kv_store.go @@ -1,6 +1,7 @@ package fastly import ( + "bufio" "io" "net/http" "strconv" @@ -409,3 +410,34 @@ func (c *Client) DeleteKVStoreKey(i *DeleteKVStoreKeyInput) error { return nil } + +// BatchModifyKVStoreKeyInput is the input to the BatchModifyKVStoreKey function. +type BatchModifyKVStoreKeyInput struct { + // ID is the ID of the kv store (required). + ID string + // Body is the HTTP request body containing a collection of JSON objects + // separated by a new line. {"key": "example","value": ""} + // (required). + Body io.Reader +} + +// BatchModifyKVStoreKey streams key/value JSON objects into an kv store. +func (c *Client) BatchModifyKVStoreKey(i *BatchModifyKVStoreKeyInput) error { + if i.ID == "" { + return ErrMissingID + } + + path := "/resources/stores/kv/" + i.ID + "/batch" + resp, err := c.Put(path, &RequestOptions{ + Body: bufio.NewReader(i.Body), + Headers: map[string]string{ + "Content-Type": "application/x-ndjson", + }, + }) + if err != nil { + return err + } + + _, err = checkResp(resp, err) + return err +} diff --git a/fastly/kv_store_test.go b/fastly/kv_store_test.go index 8f953f1bd..4f59ff9db 100644 --- a/fastly/kv_store_test.go +++ b/fastly/kv_store_test.go @@ -4,6 +4,7 @@ import ( "reflect" "sort" "strconv" + "strings" "testing" ) @@ -109,7 +110,23 @@ func TestClient_KVStore(t *testing.T) { } }) - // fetch the keys + record(t, "kv_store/batch-create-keys", func(c *Client) { + keys := `{"key":"batch-1","value":"VkFMVUU="} + {"key":"batch-2","value":"VkFMVUU="}` + err := c.BatchModifyKVStoreKey(&BatchModifyKVStoreKeyInput{ + ID: kvStore.ID, + Body: strings.NewReader(keys), + }) + if err != nil { + t.Errorf("error inserting keys %q: %v", keys, err) + } + }) + + allKeys := []string{"batch-1", "batch-2"} + allKeys = append(allKeys, keys...) + sort.Strings(allKeys) + + // fetch all keys and validate they match our input data var kvStoreListKeys *ListKVStoreKeysResponse record(t, "kv_store/list-keys", func(c *Client) { kvStoreListKeys, err = c.ListKVStoreKeys(&ListKVStoreKeysInput{ID: kvStore.ID}) @@ -120,14 +137,14 @@ func TestClient_KVStore(t *testing.T) { } sort.Strings(kvStoreListKeys.Data) - if !reflect.DeepEqual(keys, kvStoreListKeys.Data) { - t.Errorf("mismatch listing keys: got %q, want %q", kvStoreListKeys.Data, keys) + if !reflect.DeepEqual(allKeys, kvStoreListKeys.Data) { + t.Errorf("mismatch listing keys: got %q, want %q", kvStoreListKeys.Data, allKeys) } record(t, "kv_store/list-keys-pagination", func(c *Client) { p := c.NewListKVStoreKeysPaginator(&ListKVStoreKeysInput{ID: kvStore.ID, Limit: 4}) var listed []string - expected := []int{4, 1} + expected := []int{4, 3} var page int for p.Next() { keys := p.Keys() @@ -141,8 +158,8 @@ func TestClient_KVStore(t *testing.T) { t.Errorf("error during keys pagination: %v", err) } sort.Strings(listed) - if !reflect.DeepEqual(keys, listed) { - t.Errorf("mismatch listing paginated keys: got %q, want %q", kvStoreListKeys.Data, keys) + if !reflect.DeepEqual(allKeys, listed) { + t.Errorf("mismatch listing paginated keys: got %q, want %q", kvStoreListKeys.Data, allKeys) } }) }