Skip to content

Commit

Permalink
Add API for new Image Optimizer default settings API
Browse files Browse the repository at this point in the history
  • Loading branch information
daboross committed Apr 18, 2024
1 parent d375ad8 commit 1d709f5
Show file tree
Hide file tree
Showing 13 changed files with 877 additions and 0 deletions.
4 changes: 4 additions & 0 deletions fastly/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,10 @@ var ErrMissingCertificateMTLS = NewFieldError("Certificate, MutualAuthentication
// requires a "IntegrationID" key, but one was not set.
var ErrMissingIntegrationID = NewFieldError("IntegrationID")

// ErrMissingImageOptimizerSettings is an error that is returned when an input struct
// requires one of the optional Image Optimizer default settings, but none are set.
var ErrMissingImageOptimizerDefaultSetting = NewFieldError("ResizeFilter, Webp, WebpQuality, JpegType, JpegQuality, Upscale, AllowVideo").Message("at least one of the available optional fields is required")

// Ensure HTTPError is, in fact, an error.
var _ error = (*HTTPError)(nil)

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
---
version: 1
interactions:
- request:
body: ""
form: {}
headers:
User-Agent:
- FastlyGo/9.2.2 (+github.com/fastly/go-fastly; go1.22.2)
url: https://api.fastly.com/enabled-products/image_optimizer/services/7i6HN3TK9wS159v2gPAZ8A
method: DELETE
response:
body: ""
headers:
Accept-Ranges:
- bytes
Cache-Control:
- no-store
Content-Type:
- application/json
Date:
- Sat, 13 Apr 2024 05:21:42 GMT
Pragma:
- no-cache
Server:
- control-gateway
Status:
- 204 No Content
Strict-Transport-Security:
- max-age=31536000
Vary:
- Accept-Encoding
Via:
- 1.1 varnish
X-Cache:
- MISS
X-Cache-Hits:
- "0"
X-Served-By:
- cache-bfi-krnt7300024-BFI
X-Timer:
- S1712985702.726396,VS0,VE671
status: 204 No Content
code: 204
duration: ""
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
---
version: 1
interactions:
- request:
body: ProductID=image_optimizer&ServiceID=7i6HN3TK9wS159v2gPAZ8A
form:
ProductID:
- image_optimizer
ServiceID:
- 7i6HN3TK9wS159v2gPAZ8A
headers:
Content-Type:
- application/x-www-form-urlencoded
User-Agent:
- FastlyGo/9.2.2 (+github.com/fastly/go-fastly; go1.22.2)
url: https://api.fastly.com/enabled-products/image_optimizer/services/7i6HN3TK9wS159v2gPAZ8A
method: PUT
response:
body: |
{"product":{"id":"image_optimizer","object":"product"},"service":{"id":"7i6HN3TK9wS159v2gPAZ8A","object":"service"},"_links":{"self":"/enabled-products/image_optimizer/services/7i6HN3TK9wS159v2gPAZ8A"}}
headers:
Accept-Ranges:
- bytes
Cache-Control:
- no-store
Content-Length:
- "203"
Content-Type:
- application/json
Date:
- Sat, 13 Apr 2024 05:21:39 GMT
Pragma:
- no-cache
Server:
- control-gateway
Status:
- 200 OK
Strict-Transport-Security:
- max-age=31536000
Vary:
- Accept-Encoding
Via:
- 1.1 varnish
X-Cache:
- MISS
X-Cache-Hits:
- "0"
X-Served-By:
- cache-bfi-krnt7300024-BFI
X-Timer:
- S1712985699.911813,VS0,VE952
status: 200 OK
code: 200
duration: ""
53 changes: 53 additions & 0 deletions fastly/fixtures/image_optimizer_default_settings/final_reset.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
---
version: 1
interactions:
- request:
body: '{"webp":false,"webp_quality":85,"upscale":false}'
form: {}
headers:
Accept:
- application/json
Content-Type:
- application/json
User-Agent:
- FastlyGo/9.2.2 (+github.com/fastly/go-fastly; go1.22.2)
url: https://api.fastly.com/service/7i6HN3TK9wS159v2gPAZ8A/version/22/image_optimizer_default_settings
method: PATCH
response:
body: '{"resize_filter":"lanczos3","webp":false,"webp_quality":85,"jpeg_type":"auto","jpeg_quality":85,"upscale":false,"allow_video":false}'
headers:
Accept-Ranges:
- bytes
Cache-Control:
- no-store
Content-Type:
- application/json
Date:
- Sat, 13 Apr 2024 05:21:41 GMT
Fastly-Ratelimit-Remaining:
- "980"
Fastly-Ratelimit-Reset:
- "1712988000"
Pragma:
- no-cache
Server:
- control-gateway
Status:
- 200 OK
Strict-Transport-Security:
- max-age=31536000
Vary:
- Accept-Encoding
Via:
- 1.1 varnish
X-Cache:
- MISS
X-Cache-Hits:
- "0"
X-Served-By:
- cache-bfi-krnt7300024-BFI
X-Timer:
- S1712985701.362264,VS0,VE305
status: 200 OK
code: 200
duration: ""
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
---
version: 1
interactions:
- request:
body: '{"webp_quality":105}'
form: {}
headers:
Accept:
- application/json
Content-Type:
- application/json
User-Agent:
- FastlyGo/9.2.2 (+github.com/fastly/go-fastly; go1.22.2)
url: https://api.fastly.com/service/7i6HN3TK9wS159v2gPAZ8A/version/22/image_optimizer_default_settings
method: PATCH
response:
body: '{"type":"https://www.fastly.com/documentation/reference/api/services/image_optimizer_default_settings/","title":"Bad
request","detail":"Webp quality must be less than or equal to 100"}'
headers:
Accept-Ranges:
- bytes
Cache-Control:
- no-store
Content-Type:
- application/json
Date:
- Sat, 13 Apr 2024 05:21:41 GMT
Fastly-Ratelimit-Remaining:
- "981"
Fastly-Ratelimit-Reset:
- "1712988000"
Pragma:
- no-cache
Server:
- control-gateway
Status:
- 400 Bad Request
Strict-Transport-Security:
- max-age=31536000
Vary:
- Accept-Encoding
Via:
- 1.1 varnish
X-Cache:
- MISS
X-Cache-Hits:
- "0"
X-Served-By:
- cache-bfi-krnt7300024-BFI
X-Timer:
- S1712985701.156217,VS0,VE150
status: 400 Bad Request
code: 400
duration: ""
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
---
version: 1
interactions:
- request:
body: ""
form: {}
headers:
User-Agent:
- FastlyGo/9.2.2 (+github.com/fastly/go-fastly; go1.22.2)
url: https://api.fastly.com/service/7i6HN3TK9wS159v2gPAZ8A/version/22/image_optimizer_default_settings
method: GET
response:
body: '{"resize_filter":"lanczos3","webp":false,"webp_quality":85,"jpeg_type":"auto","jpeg_quality":85,"upscale":false,"allow_video":false}'
headers:
Accept-Ranges:
- bytes
Cache-Control:
- no-store
Content-Type:
- application/json
Date:
- Sat, 13 Apr 2024 05:21:40 GMT
Pragma:
- no-cache
Server:
- control-gateway
Status:
- 200 OK
Strict-Transport-Security:
- max-age=31536000
Vary:
- Accept-Encoding
Via:
- 1.1 varnish
X-Cache:
- MISS
X-Cache-Hits:
- "0"
X-Served-By:
- cache-bfi-krnt7300024-BFI
X-Timer:
- S1712985700.911043,VS0,VE160
status: 200 OK
code: 200
duration: ""
45 changes: 45 additions & 0 deletions fastly/fixtures/image_optimizer_default_settings/update_1_get.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
---
version: 1
interactions:
- request:
body: ""
form: {}
headers:
User-Agent:
- FastlyGo/9.2.2 (+github.com/fastly/go-fastly; go1.22.2)
url: https://api.fastly.com/service/7i6HN3TK9wS159v2gPAZ8A/version/22/image_optimizer_default_settings
method: GET
response:
body: '{"resize_filter":"lanczos3","webp":false,"webp_quality":20,"jpeg_type":"auto","jpeg_quality":85,"upscale":false,"allow_video":false}'
headers:
Accept-Ranges:
- bytes
Cache-Control:
- no-store
Content-Type:
- application/json
Date:
- Sat, 13 Apr 2024 05:21:40 GMT
Pragma:
- no-cache
Server:
- control-gateway
Status:
- 200 OK
Strict-Transport-Security:
- max-age=31536000
Vary:
- Accept-Encoding
Via:
- 1.1 varnish
X-Cache:
- MISS
X-Cache-Hits:
- "0"
X-Served-By:
- cache-bfi-krnt7300024-BFI
X-Timer:
- S1712985700.407525,VS0,VE169
status: 200 OK
code: 200
duration: ""
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
---
version: 1
interactions:
- request:
body: '{"webp":false,"webp_quality":20,"upscale":false}'
form: {}
headers:
Accept:
- application/json
Content-Type:
- application/json
User-Agent:
- FastlyGo/9.2.2 (+github.com/fastly/go-fastly; go1.22.2)
url: https://api.fastly.com/service/7i6HN3TK9wS159v2gPAZ8A/version/22/image_optimizer_default_settings
method: PATCH
response:
body: '{"resize_filter":"lanczos3","webp":false,"webp_quality":20,"jpeg_type":"auto","jpeg_quality":85,"upscale":false,"allow_video":false}'
headers:
Accept-Ranges:
- bytes
Cache-Control:
- no-store
Content-Type:
- application/json
Date:
- Sat, 13 Apr 2024 05:21:40 GMT
Fastly-Ratelimit-Remaining:
- "983"
Fastly-Ratelimit-Reset:
- "1712988000"
Pragma:
- no-cache
Server:
- control-gateway
Status:
- 200 OK
Strict-Transport-Security:
- max-age=31536000
Vary:
- Accept-Encoding
Via:
- 1.1 varnish
X-Cache:
- MISS
X-Cache-Hits:
- "0"
X-Served-By:
- cache-bfi-krnt7300024-BFI
X-Timer:
- S1712985700.118285,VS0,VE241
status: 200 OK
code: 200
duration: ""
Loading

0 comments on commit 1d709f5

Please sign in to comment.