Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Image Optimizer default settings API #516

Merged
merged 13 commits into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.3.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:
- Tue, 14 May 2024 16:16:36 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-krnt7300110-BFI
X-Timer:
- S1715703395.638107,VS0,VE1368
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.3.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:
- Tue, 14 May 2024 16:16:29 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-krnt7300110-BFI
X-Timer:
- S1715703388.864441,VS0,VE1596
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: '{"resize_filter":"nearest","webp":false,"webp_quality":85,"jpeg_type":"auto","jpeg_quality":85,"upscale":false,"allow_video":false}'
form: {}
headers:
Accept:
- application/json
Content-Type:
- application/json
User-Agent:
- FastlyGo/9.3.2 (+github.com/fastly/go-fastly; go1.22.2)
url: https://api.fastly.com/service/7i6HN3TK9wS159v2gPAZ8A/version/87/image_optimizer_default_settings
method: PATCH
response:
body: '{"resize_filter":"nearest","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:
- Tue, 14 May 2024 16:16:34 GMT
Fastly-Ratelimit-Remaining:
- "986"
Fastly-Ratelimit-Reset:
- "1715706000"
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-krnt7300110-BFI
X-Timer:
- S1715703394.322383,VS0,VE301
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.3.2 (+github.com/fastly/go-fastly; go1.22.2)
url: https://api.fastly.com/service/7i6HN3TK9wS159v2gPAZ8A/version/87/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/problem+json
Date:
- Tue, 14 May 2024 16:16:31 GMT
Fastly-Ratelimit-Remaining:
- "996"
Fastly-Ratelimit-Reset:
- "1715706000"
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-krnt7300110-BFI
X-Timer:
- S1715703391.172090,VS0,VE235
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.3.2 (+github.com/fastly/go-fastly; go1.22.2)
url: https://api.fastly.com/service/7i6HN3TK9wS159v2gPAZ8A/version/87/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:
- Tue, 14 May 2024 16:16:29 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-krnt7300110-BFI
X-Timer:
- S1715703390.548942,VS0,VE308
status: 200 OK
code: 200
duration: ""
53 changes: 53 additions & 0 deletions fastly/fixtures/image_optimizer_default_settings/set_full.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
---
version: 1
interactions:
- request:
body: '{"resize_filter":"lanczos3","webp":false,"webp_quality":85,"jpeg_type":"auto","jpeg_quality":85,"upscale":false,"allow_video":false}'
form: {}
headers:
Accept:
- application/json
Content-Type:
- application/json
User-Agent:
- FastlyGo/9.3.2 (+github.com/fastly/go-fastly; go1.22.2)
url: https://api.fastly.com/service/7i6HN3TK9wS159v2gPAZ8A/version/87/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:
- Tue, 14 May 2024 16:16:34 GMT
Fastly-Ratelimit-Remaining:
- "987"
Fastly-Ratelimit-Reset:
- "1715706000"
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-krnt7300110-BFI
X-Timer:
- S1715703394.881247,VS0,VE425
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: '{"jpeg_type":"auto"}'
form: {}
headers:
Accept:
- application/json
Content-Type:
- application/json
User-Agent:
- FastlyGo/9.3.2 (+github.com/fastly/go-fastly; go1.22.2)
url: https://api.fastly.com/service/7i6HN3TK9wS159v2gPAZ8A/version/87/image_optimizer_default_settings
method: PATCH
response:
body: '{"resize_filter":"nearest","webp":true,"webp_quality":42,"jpeg_type":"auto","jpeg_quality":85,"upscale":true,"allow_video":false}'
headers:
Accept-Ranges:
- bytes
Cache-Control:
- no-store
Content-Type:
- application/json
Date:
- Tue, 14 May 2024 16:16:33 GMT
Fastly-Ratelimit-Remaining:
- "990"
Fastly-Ratelimit-Reset:
- "1715706000"
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-krnt7300110-BFI
X-Timer:
- S1715703393.016316,VS0,VE239
status: 200 OK
code: 200
duration: ""
Loading
Loading