From 6d0ba1d8c9698836e27b4facb73f489bde38e4fb Mon Sep 17 00:00:00 2001 From: Dabo Ross Date: Mon, 15 Apr 2024 11:45:03 -0700 Subject: [PATCH 01/13] Add API for new Image Optimizer default settings API --- fastly/errors.go | 4 + .../disable_product.yaml | 45 ++++ .../enable_product.yaml | 54 ++++ .../final_reset.yaml | 53 ++++ .../incorrect_fetch.yaml | 54 ++++ .../original_fetch.yaml | 45 ++++ .../update_1_get.yaml | 45 ++++ .../update_1_patch.yaml | 53 ++++ .../update_2_get.yaml | 45 ++++ .../update_2_patch.yaml | 53 ++++ .../version.yaml | 51 ++++ fastly/image_optimizer_default_settings.go | 140 +++++++++++ .../image_optimizer_default_settings_test.go | 235 ++++++++++++++++++ 13 files changed, 877 insertions(+) create mode 100644 fastly/fixtures/image_optimizer_default_settings/disable_product.yaml create mode 100644 fastly/fixtures/image_optimizer_default_settings/enable_product.yaml create mode 100644 fastly/fixtures/image_optimizer_default_settings/final_reset.yaml create mode 100644 fastly/fixtures/image_optimizer_default_settings/incorrect_fetch.yaml create mode 100644 fastly/fixtures/image_optimizer_default_settings/original_fetch.yaml create mode 100644 fastly/fixtures/image_optimizer_default_settings/update_1_get.yaml create mode 100644 fastly/fixtures/image_optimizer_default_settings/update_1_patch.yaml create mode 100644 fastly/fixtures/image_optimizer_default_settings/update_2_get.yaml create mode 100644 fastly/fixtures/image_optimizer_default_settings/update_2_patch.yaml create mode 100644 fastly/fixtures/image_optimizer_default_settings/version.yaml create mode 100644 fastly/image_optimizer_default_settings.go create mode 100644 fastly/image_optimizer_default_settings_test.go diff --git a/fastly/errors.go b/fastly/errors.go index 06e1a376..c622f938 100644 --- a/fastly/errors.go +++ b/fastly/errors.go @@ -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) diff --git a/fastly/fixtures/image_optimizer_default_settings/disable_product.yaml b/fastly/fixtures/image_optimizer_default_settings/disable_product.yaml new file mode 100644 index 00000000..cbcd2da1 --- /dev/null +++ b/fastly/fixtures/image_optimizer_default_settings/disable_product.yaml @@ -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: "" diff --git a/fastly/fixtures/image_optimizer_default_settings/enable_product.yaml b/fastly/fixtures/image_optimizer_default_settings/enable_product.yaml new file mode 100644 index 00000000..0ea26f88 --- /dev/null +++ b/fastly/fixtures/image_optimizer_default_settings/enable_product.yaml @@ -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: "" diff --git a/fastly/fixtures/image_optimizer_default_settings/final_reset.yaml b/fastly/fixtures/image_optimizer_default_settings/final_reset.yaml new file mode 100644 index 00000000..6ee93c62 --- /dev/null +++ b/fastly/fixtures/image_optimizer_default_settings/final_reset.yaml @@ -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: "" diff --git a/fastly/fixtures/image_optimizer_default_settings/incorrect_fetch.yaml b/fastly/fixtures/image_optimizer_default_settings/incorrect_fetch.yaml new file mode 100644 index 00000000..a94206ad --- /dev/null +++ b/fastly/fixtures/image_optimizer_default_settings/incorrect_fetch.yaml @@ -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: "" diff --git a/fastly/fixtures/image_optimizer_default_settings/original_fetch.yaml b/fastly/fixtures/image_optimizer_default_settings/original_fetch.yaml new file mode 100644 index 00000000..b91af4d9 --- /dev/null +++ b/fastly/fixtures/image_optimizer_default_settings/original_fetch.yaml @@ -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: "" diff --git a/fastly/fixtures/image_optimizer_default_settings/update_1_get.yaml b/fastly/fixtures/image_optimizer_default_settings/update_1_get.yaml new file mode 100644 index 00000000..8bd6dff0 --- /dev/null +++ b/fastly/fixtures/image_optimizer_default_settings/update_1_get.yaml @@ -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: "" diff --git a/fastly/fixtures/image_optimizer_default_settings/update_1_patch.yaml b/fastly/fixtures/image_optimizer_default_settings/update_1_patch.yaml new file mode 100644 index 00000000..17a11169 --- /dev/null +++ b/fastly/fixtures/image_optimizer_default_settings/update_1_patch.yaml @@ -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: "" diff --git a/fastly/fixtures/image_optimizer_default_settings/update_2_get.yaml b/fastly/fixtures/image_optimizer_default_settings/update_2_get.yaml new file mode 100644 index 00000000..e8b3ddf1 --- /dev/null +++ b/fastly/fixtures/image_optimizer_default_settings/update_2_get.yaml @@ -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":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: + - Sat, 13 Apr 2024 05:21:41 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: + - S1712985701.938658,VS0,VE162 + status: 200 OK + code: 200 + duration: "" diff --git a/fastly/fixtures/image_optimizer_default_settings/update_2_patch.yaml b/fastly/fixtures/image_optimizer_default_settings/update_2_patch.yaml new file mode 100644 index 00000000..342e3168 --- /dev/null +++ b/fastly/fixtures/image_optimizer_default_settings/update_2_patch.yaml @@ -0,0 +1,53 @@ +--- +version: 1 +interactions: +- request: + body: '{"webp":true,"webp_quality":42,"upscale":true}' + 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":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: + - Sat, 13 Apr 2024 05:21:40 GMT + Fastly-Ratelimit-Remaining: + - "982" + 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.625696,VS0,VE263 + status: 200 OK + code: 200 + duration: "" diff --git a/fastly/fixtures/image_optimizer_default_settings/version.yaml b/fastly/fixtures/image_optimizer_default_settings/version.yaml new file mode 100644 index 00000000..f3ac20c0 --- /dev/null +++ b/fastly/fixtures/image_optimizer_default_settings/version.yaml @@ -0,0 +1,51 @@ +--- +version: 1 +interactions: +- request: + body: "" + form: {} + 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/service/7i6HN3TK9wS159v2gPAZ8A/version + method: POST + response: + body: '{"service_id":"7i6HN3TK9wS159v2gPAZ8A","number":22}' + headers: + Accept-Ranges: + - bytes + Cache-Control: + - no-store + Content-Type: + - application/json + Date: + - Sat, 13 Apr 2024 05:21:38 GMT + Fastly-Ratelimit-Remaining: + - "984" + 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: + - S1712985699.594687,VS0,VE275 + status: 200 OK + code: 200 + duration: "" diff --git a/fastly/image_optimizer_default_settings.go b/fastly/image_optimizer_default_settings.go new file mode 100644 index 00000000..bd2b6650 --- /dev/null +++ b/fastly/image_optimizer_default_settings.go @@ -0,0 +1,140 @@ +package fastly + +import ( + "encoding/json" + "fmt" +) + +// ResizeFilter is a base for the different ResizeFilter variants. +type ResizeFilter int64 + +func (r ResizeFilter) String() string { + switch r { + case Lanczos3: + return "lanczos3" + case Lanczos2: + return "lanczos2" + case Bicubic: + return "bicubic" + case Bilinear: + return "bilinear" + case Nearest: + return "nearest" + } + return "lanczos3" // default +} + +const ( + Lanczos3 ResizeFilter = iota + Lanczos2 + Bicubic + Bilinear + Nearest +) + +// ImageOptimizerDefaultSettings represents the returned default settings for Image Optimizer on a given service. +type ImageOptimizerDefaultSettings struct { + // Type of filter to use while resizing an image. + ResizeFilter string `json:"resize_filter"` + // Whether or not to default to webp output when the client supports it. This is equivalent to adding "auto=webp" to all image optimizer requests. + Webp bool `json:"webp"` + // Default quality to use with webp output. This can be overriden with the second option in the "quality" URL parameter on specific image optimizer + // requests. + WebpQuality int `json:"webp_quality"` + // Default type of jpeg output to use. This can be overriden with "format=bjpeg" and "format=pjpeg" on specific image optimizer requests. + JpegType string `json:"jpeg_type"` + // Default quality to use with jpeg output. This can be overridden with the "quality" parameter on specific image optimizer requests. + JpegQuality int `json:"jpeg_quality"` + // Whether or not we should allow output images to render at sizes larger than input. + Upscale bool `json:"upscale"` + // Enables GIF to MP4 transformations on this service. + AllowVideo bool `json:"allow_video"` +} + +// GetImageOptimizerDefaultSettingsInput is used as input to the +// GetImageOptimizerDefaultSettings function. +type GetImageOptimizerDefaultSettingsInput struct { + // ServiceID is the ID of the service (required). + ServiceID string + // ServiceVersion is the specific configuration version (required). + ServiceVersion int +} + +// UpdateImageOptimizerDefaultSettingsInput is used as input to the +// UpdateImageOptimizerDefaultSettings function. +// +// A minimum of one optional field is required. +type UpdateImageOptimizerDefaultSettingsInput struct { + // ServiceID is the ID of the service (required). + ServiceID string `json:"-"` + // ServiceVersion is the specific configuration version (required). + ServiceVersion int `json:"-"` + // Type of filter to use while resizing an image. + ResizeFilter *ResizeFilter `json:"resize_filter,omitempty"` + // Whether or not to default to webp output when the client supports it. This is equivalent to adding "auto=webp" to all image optimizer requests. + Webp *bool `json:"webp,omitempty"` + // Default quality to use with webp output. This can be overriden with the second option in the "quality" URL parameter on specific image optimizer + // requests. + WebpQuality *int `json:"webp_quality,omitempty"` + // Default type of jpeg output to use. This can be overriden with "format=bjpeg" and "format=pjpeg" on specific image optimizer requests. + JpegType *string `json:"jpeg_type,omitempty"` + // Default quality to use with jpeg output. This can be overridden with the "quality" parameter on specific image optimizer requests. + JpegQuality *int `json:"jpeg_quality,omitempty"` + // Whether or not we should allow output images to render at sizes larger than input. + Upscale *bool `json:"upscale,omitempty"` + // Enables GIF to MP4 transformations on this service. + AllowVideo *bool `json:"allow_video,omitempty"` +} + +// GetImageOptimizerDefaultSettings retrives the current Image Optimizer default settings on a given service version. +func (c *Client) GetImageOptimizerDefaultSettings(i *GetImageOptimizerDefaultSettingsInput) (*ImageOptimizerDefaultSettings, error) { + if i.ServiceID == "" { + return nil, ErrMissingServiceID + } + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion + } + + path := fmt.Sprintf("/service/%s/version/%d/image_optimizer_default_settings", i.ServiceID, i.ServiceVersion) + + resp, err := c.Get(path, nil) + if err != nil { + return nil, err + } + defer resp.Body.Close() + + var iods *ImageOptimizerDefaultSettings + if err := json.NewDecoder(resp.Body).Decode(&iods); err != nil { + return nil, err + } + + return iods, nil +} + +// UpdateImageOptimizerDefaultSettings changes one or more Image Optimizer default settings on a given service version. +func (c *Client) UpdateImageOptimizerDefaultSettings(i *UpdateImageOptimizerDefaultSettingsInput) (*ImageOptimizerDefaultSettings, error) { + if i.ServiceID == "" { + return nil, ErrMissingServiceID + } + if i.ServiceVersion == 0 { + return nil, ErrMissingServiceVersion + } + if i.ResizeFilter == nil && i.Webp == nil && i.WebpQuality == nil && i.JpegType == nil && i.JpegQuality == nil && i.Upscale == nil && i.AllowVideo == nil { + return nil, ErrMissingImageOptimizerDefaultSetting + } + + path := fmt.Sprintf("/service/%s/version/%d/image_optimizer_default_settings", i.ServiceID, i.ServiceVersion) + + resp, err := c.PatchJSON(path, i, nil) + if err != nil { + return nil, err + } + defer resp.Body.Close() + + var iods *ImageOptimizerDefaultSettings + if err := json.NewDecoder(resp.Body).Decode(&iods); err != nil { + return nil, err + } + + return iods, nil +} diff --git a/fastly/image_optimizer_default_settings_test.go b/fastly/image_optimizer_default_settings_test.go new file mode 100644 index 00000000..49a48d5f --- /dev/null +++ b/fastly/image_optimizer_default_settings_test.go @@ -0,0 +1,235 @@ +package fastly + +import ( + "strings" + "testing" +) + +// TestClient_ImageOptimizerDefaultSettings tests the Image Optimizer Default Settings API +// +// Note: to run this, all backends on the active version of the test service must have shielding +// enabled, and the test service's account must be allowed to enable Image Optimization. +func TestClient_ImageOptimizerDefaultSettings(t *testing.T) { + t.Parallel() + + fixtureBase := "image_optimizer_default_settings/" + + testVersion := createTestVersion(t, fixtureBase+"version", testServiceID) + + var err error + + // Enable IO + record(t, fixtureBase+"enable_product", func(c *Client) { + _, err = c.EnableProduct(&ProductEnablementInput{ + ProductID: ProductImageOptimizer, + ServiceID: testServiceID, + }) + }) + if err != nil { + t.Fatal(err) + } + + // Ensure we disable IO on the service after the test + defer func() { + record(t, fixtureBase+"disable_product", func(c *Client) { + c.DisableProduct(&ProductEnablementInput{ + ProductID: ProductImageOptimizer, + ServiceID: testServiceID, + }) + }) + }() + + var defaultSettings *ImageOptimizerDefaultSettings + + // Fetch + record(t, fixtureBase+"original_fetch", func(c *Client) { + defaultSettings, err = c.GetImageOptimizerDefaultSettings(&GetImageOptimizerDefaultSettingsInput{ + ServiceID: testServiceID, + ServiceVersion: *testVersion.Number, + }) + }) + if err != nil { + t.Fatal(err) + } + + originalSettings := defaultSettings + + // Reset our settings back to the original + defer func() { + record(t, fixtureBase+"final_reset", func(c *Client) { + _, err = c.UpdateImageOptimizerDefaultSettings(&UpdateImageOptimizerDefaultSettingsInput{ + ServiceID: testServiceID, + ServiceVersion: *testVersion.Number, + Webp: &originalSettings.Webp, + WebpQuality: &originalSettings.WebpQuality, + Upscale: &originalSettings.Upscale, + }) + }) + }() + + newWebp := false + newWebpQuality := 20 + newUpscale := false + + // Change some stuff + record(t, fixtureBase+"update_1_patch", func(c *Client) { + defaultSettings, err = c.UpdateImageOptimizerDefaultSettings(&UpdateImageOptimizerDefaultSettingsInput{ + ServiceID: testServiceID, + ServiceVersion: *testVersion.Number, + Webp: &newWebp, + WebpQuality: &newWebpQuality, + Upscale: &newUpscale, + }) + }) + if err != nil { + t.Fatal(err) + } + + if defaultSettings.Webp != newWebp { + t.Fatalf("expected Webp: %v; got: %v", newWebp, defaultSettings.Webp) + } + if defaultSettings.WebpQuality != newWebpQuality { + t.Fatalf("expected WebpQuality %v; got: %v", newWebp, defaultSettings.WebpQuality) + } + if defaultSettings.Upscale != newUpscale { + t.Fatalf("expected Upscale: %v; got: %v", newUpscale, defaultSettings.Webp) + } + + // Confirm our changes were applied permanently + record(t, fixtureBase+"update_1_get", func(c *Client) { + defaultSettings, err = c.GetImageOptimizerDefaultSettings(&GetImageOptimizerDefaultSettingsInput{ + ServiceID: testServiceID, + ServiceVersion: *testVersion.Number, + }) + }) + if err != nil { + t.Fatal(err) + } + + if defaultSettings.Webp != newWebp { + t.Fatalf("expected Webp: %v; got: %v", newWebp, defaultSettings.Webp) + } + if defaultSettings.WebpQuality != newWebpQuality { + t.Fatalf("expected WebpQuality %v; got: %v", newWebp, defaultSettings.WebpQuality) + } + if defaultSettings.Upscale != newUpscale { + t.Fatalf("expected Upscale: %v; got: %v", newUpscale, defaultSettings.Webp) + } + + // Change settings again (to ensure we don't accidentally pass a test by just having the settings already set) + newWebp = true + newWebpQuality = 42 + newUpscale = true + + record(t, fixtureBase+"update_2_patch", func(c *Client) { + defaultSettings, err = c.UpdateImageOptimizerDefaultSettings(&UpdateImageOptimizerDefaultSettingsInput{ + ServiceID: testServiceID, + ServiceVersion: *testVersion.Number, + Webp: &newWebp, + WebpQuality: &newWebpQuality, + Upscale: &newUpscale, + }) + }) + if err != nil { + t.Fatal(err) + } + + if defaultSettings.Webp != newWebp { + t.Fatalf("expected Webp: %v; got: %v", newWebp, defaultSettings.Webp) + } + if defaultSettings.WebpQuality != newWebpQuality { + t.Fatalf("expected WebpQuality %v; got: %v", newWebp, defaultSettings.WebpQuality) + } + if defaultSettings.Upscale != newUpscale { + t.Fatalf("expected Upscale: %v; got: %v", newUpscale, defaultSettings.Webp) + } + + // Confirm our changes were applied permanently (again) + record(t, fixtureBase+"update_2_get", func(c *Client) { + defaultSettings, err = c.GetImageOptimizerDefaultSettings(&GetImageOptimizerDefaultSettingsInput{ + ServiceID: testServiceID, + ServiceVersion: *testVersion.Number, + }) + }) + if err != nil { + t.Fatal(err) + } + + if defaultSettings.Webp != newWebp { + t.Fatalf("expected Webp: %v; got: %v", newWebp, defaultSettings.Webp) + } + if defaultSettings.WebpQuality != newWebpQuality { + t.Fatalf("expected WebpQuality %v; got: %v", newWebp, defaultSettings.WebpQuality) + } + if defaultSettings.Upscale != newUpscale { + t.Fatalf("expected Upscale: %v; got: %v", newUpscale, defaultSettings.Webp) + } + + // Apply a setting that produces a server-side error, and confirm it's handled well. + newWebpQuality = 105 + + record(t, fixtureBase+"incorrect_fetch", func(c *Client) { + _, err = c.UpdateImageOptimizerDefaultSettings(&UpdateImageOptimizerDefaultSettingsInput{ + ServiceID: testServiceID, + ServiceVersion: *testVersion.Number, + WebpQuality: &newWebpQuality, + }) + }) + if err == nil { + t.Fatalf("missing err") + } + expectedErr := "Webp quality must be less than or equal to 100" + if !strings.Contains(err.Error(), expectedErr) { + t.Fatalf("expected error to include '%s'; got: %v", expectedErr, err) + } +} + +func TestClient_GetImageOptimizerDefaultSettings_validation(t *testing.T) { + var err error + _, err = testClient.GetImageOptimizerDefaultSettings(&GetImageOptimizerDefaultSettingsInput{ + ServiceID: "", + ServiceVersion: 3, + }) + if err != ErrMissingServiceID { + t.Errorf("expected error %v; got: %v", ErrMissingServiceID, err) + } + + _, err = testClient.GetImageOptimizerDefaultSettings(&GetImageOptimizerDefaultSettingsInput{ + ServiceID: "foo", + ServiceVersion: 0, + }) + if err != ErrMissingServiceVersion { + t.Errorf("expected error %v; got: %v", ErrMissingServiceVersion, err) + } +} + +func TestClient_UpdateImageOptimizerDefaultSettings_validation(t *testing.T) { + newUpscale := true + + var err error + _, err = testClient.UpdateImageOptimizerDefaultSettings(&UpdateImageOptimizerDefaultSettingsInput{ + ServiceID: "", + ServiceVersion: 3, + Upscale: &newUpscale, + }) + if err != ErrMissingServiceID { + t.Errorf("expected error %v; got: %v", ErrMissingServiceID, err) + } + + _, err = testClient.UpdateImageOptimizerDefaultSettings(&UpdateImageOptimizerDefaultSettingsInput{ + ServiceID: "foo", + ServiceVersion: 0, + Upscale: &newUpscale, + }) + if err != ErrMissingServiceVersion { + t.Errorf("expected error %v; got: %v", ErrMissingServiceVersion, err) + } + + _, err = testClient.UpdateImageOptimizerDefaultSettings(&UpdateImageOptimizerDefaultSettingsInput{ + ServiceID: "foo", + ServiceVersion: 3, + }) + if err != ErrMissingImageOptimizerDefaultSetting { + t.Errorf("expected error: %v, got: %v", ErrMissingImageOptimizerDefaultSetting, err) + } +} From e4f3e82ac256e9bcb8b1cf8fd33778af8ab32ce3 Mon Sep 17 00:00:00 2001 From: Mark McDonnell Date: Thu, 18 Apr 2024 10:21:00 +0100 Subject: [PATCH 02/13] Update fastly/image_optimizer_default_settings_test.go --- fastly/image_optimizer_default_settings_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fastly/image_optimizer_default_settings_test.go b/fastly/image_optimizer_default_settings_test.go index 49a48d5f..63fb5743 100644 --- a/fastly/image_optimizer_default_settings_test.go +++ b/fastly/image_optimizer_default_settings_test.go @@ -7,7 +7,7 @@ import ( // TestClient_ImageOptimizerDefaultSettings tests the Image Optimizer Default Settings API // -// Note: to run this, all backends on the active version of the test service must have shielding +// NOTE: to run this, all backends on the active version of the test service must have shielding // enabled, and the test service's account must be allowed to enable Image Optimization. func TestClient_ImageOptimizerDefaultSettings(t *testing.T) { t.Parallel() From 1fe12f212a3741f240d2836874b15dc5ef3fe149 Mon Sep 17 00:00:00 2001 From: Dabo Ross Date: Thu, 18 Apr 2024 19:05:31 -0700 Subject: [PATCH 03/13] Explicitly handle error 404 the API can return. I'd forgotten about this case, but it's used when the user hasn't set any Image Optimizer settings, and it's useful for terraform to be able to easily detect this case. I assume other users of this API will also appreciate this explicit error handling, as opposed to having to check for error 404 themselves. --- fastly/image_optimizer_default_settings.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/fastly/image_optimizer_default_settings.go b/fastly/image_optimizer_default_settings.go index bd2b6650..8bac2602 100644 --- a/fastly/image_optimizer_default_settings.go +++ b/fastly/image_optimizer_default_settings.go @@ -87,6 +87,8 @@ type UpdateImageOptimizerDefaultSettingsInput struct { } // GetImageOptimizerDefaultSettings retrives the current Image Optimizer default settings on a given service version. +// +// Returns (nil, nil) if no default settings are set. func (c *Client) GetImageOptimizerDefaultSettings(i *GetImageOptimizerDefaultSettingsInput) (*ImageOptimizerDefaultSettings, error) { if i.ServiceID == "" { return nil, ErrMissingServiceID @@ -99,6 +101,12 @@ func (c *Client) GetImageOptimizerDefaultSettings(i *GetImageOptimizerDefaultSet resp, err := c.Get(path, nil) if err != nil { + if herr, ok := err.(*HTTPError); ok { + if herr.StatusCode == 404 { + // API endpoint returns 404 for services without Image Optimizer settings set. + return nil, nil + } + } return nil, err } defer resp.Body.Close() From 8dd042d10b8658a9dd45ef66a4e219855775bb6a Mon Sep 17 00:00:00 2001 From: Dabo Ross Date: Thu, 18 Apr 2024 19:52:50 -0700 Subject: [PATCH 04/13] Make JpegType a constant, fix ResizeFilter values, and expand testing Previously, ResizeFilter was missing a custom json marshalling function, and any request with a resize filter resulted in a server error. I've expanded testing to test all resize filter values, all jpeg type values, and to include a request which sends all possible keys - just to patch up any other missing untested parts. --- .../disable_product.yaml | 12 ++-- .../enable_product.yaml | 18 +++--- .../final_reset.yaml | 16 +++--- .../incorrect_fetch.yaml | 16 +++--- .../original_fetch.yaml | 12 ++-- .../set_full.yaml | 55 +++++++++++++++++++ .../set_jpeg_type/auto.yaml | 55 +++++++++++++++++++ .../set_jpeg_type/baseline.yaml | 55 +++++++++++++++++++ .../set_jpeg_type/progressive.yaml | 55 +++++++++++++++++++ .../set_resize_filter/bicubic.yaml | 55 +++++++++++++++++++ .../set_resize_filter/bilinear.yaml | 55 +++++++++++++++++++ .../set_resize_filter/lanczos2.yaml | 55 +++++++++++++++++++ .../set_resize_filter/lanczos3.yaml | 55 +++++++++++++++++++ .../set_resize_filter/nearest.yaml | 55 +++++++++++++++++++ .../update_1_get.yaml | 12 ++-- .../update_1_patch.yaml | 16 +++--- .../update_2_get.yaml | 12 ++-- .../update_2_patch.yaml | 16 +++--- .../version.yaml | 18 +++--- fastly/image_optimizer_default_settings.go | 31 ++++++++++- .../image_optimizer_default_settings_test.go | 42 ++++++++++++++ 21 files changed, 651 insertions(+), 65 deletions(-) create mode 100644 fastly/fixtures/image_optimizer_default_settings/set_full.yaml create mode 100644 fastly/fixtures/image_optimizer_default_settings/set_jpeg_type/auto.yaml create mode 100644 fastly/fixtures/image_optimizer_default_settings/set_jpeg_type/baseline.yaml create mode 100644 fastly/fixtures/image_optimizer_default_settings/set_jpeg_type/progressive.yaml create mode 100644 fastly/fixtures/image_optimizer_default_settings/set_resize_filter/bicubic.yaml create mode 100644 fastly/fixtures/image_optimizer_default_settings/set_resize_filter/bilinear.yaml create mode 100644 fastly/fixtures/image_optimizer_default_settings/set_resize_filter/lanczos2.yaml create mode 100644 fastly/fixtures/image_optimizer_default_settings/set_resize_filter/lanczos3.yaml create mode 100644 fastly/fixtures/image_optimizer_default_settings/set_resize_filter/nearest.yaml diff --git a/fastly/fixtures/image_optimizer_default_settings/disable_product.yaml b/fastly/fixtures/image_optimizer_default_settings/disable_product.yaml index cbcd2da1..2a8ba8d6 100644 --- a/fastly/fixtures/image_optimizer_default_settings/disable_product.yaml +++ b/fastly/fixtures/image_optimizer_default_settings/disable_product.yaml @@ -6,8 +6,8 @@ interactions: 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 + - FastlyGo/9.3.1 (+github.com/fastly/go-fastly; go1.22.2) + url: https://api.fastly.com/enabled-products/image_optimizer/services/qDAwPNSjDoCytjIZ6SfjF5 method: DELETE response: body: "" @@ -16,10 +16,12 @@ interactions: - bytes Cache-Control: - no-store + Connection: + - keep-alive Content-Type: - application/json Date: - - Sat, 13 Apr 2024 05:21:42 GMT + - Fri, 19 Apr 2024 02:52:16 GMT Pragma: - no-cache Server: @@ -37,9 +39,9 @@ interactions: X-Cache-Hits: - "0" X-Served-By: - - cache-bfi-krnt7300024-BFI + - cache-bfi-krnt7300112-BFI X-Timer: - - S1712985702.726396,VS0,VE671 + - S1713495135.395036,VS0,VE693 status: 204 No Content code: 204 duration: "" diff --git a/fastly/fixtures/image_optimizer_default_settings/enable_product.yaml b/fastly/fixtures/image_optimizer_default_settings/enable_product.yaml index 0ea26f88..ba4311d3 100644 --- a/fastly/fixtures/image_optimizer_default_settings/enable_product.yaml +++ b/fastly/fixtures/image_optimizer_default_settings/enable_product.yaml @@ -2,33 +2,35 @@ version: 1 interactions: - request: - body: ProductID=image_optimizer&ServiceID=7i6HN3TK9wS159v2gPAZ8A + body: ProductID=image_optimizer&ServiceID=qDAwPNSjDoCytjIZ6SfjF5 form: ProductID: - image_optimizer ServiceID: - - 7i6HN3TK9wS159v2gPAZ8A + - qDAwPNSjDoCytjIZ6SfjF5 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 + - FastlyGo/9.3.1 (+github.com/fastly/go-fastly; go1.22.2) + url: https://api.fastly.com/enabled-products/image_optimizer/services/qDAwPNSjDoCytjIZ6SfjF5 method: PUT response: body: | - {"product":{"id":"image_optimizer","object":"product"},"service":{"id":"7i6HN3TK9wS159v2gPAZ8A","object":"service"},"_links":{"self":"/enabled-products/image_optimizer/services/7i6HN3TK9wS159v2gPAZ8A"}} + {"product":{"id":"image_optimizer","object":"product"},"service":{"id":"qDAwPNSjDoCytjIZ6SfjF5","object":"service"},"_links":{"self":"/enabled-products/image_optimizer/services/qDAwPNSjDoCytjIZ6SfjF5"}} headers: Accept-Ranges: - bytes Cache-Control: - no-store + Connection: + - keep-alive Content-Length: - "203" Content-Type: - application/json Date: - - Sat, 13 Apr 2024 05:21:39 GMT + - Fri, 19 Apr 2024 02:52:10 GMT Pragma: - no-cache Server: @@ -46,9 +48,9 @@ interactions: X-Cache-Hits: - "0" X-Served-By: - - cache-bfi-krnt7300024-BFI + - cache-bfi-krnt7300112-BFI X-Timer: - - S1712985699.911813,VS0,VE952 + - S1713495130.808709,VS0,VE992 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/image_optimizer_default_settings/final_reset.yaml b/fastly/fixtures/image_optimizer_default_settings/final_reset.yaml index 6ee93c62..510e7fb0 100644 --- a/fastly/fixtures/image_optimizer_default_settings/final_reset.yaml +++ b/fastly/fixtures/image_optimizer_default_settings/final_reset.yaml @@ -10,8 +10,8 @@ interactions: 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 + - FastlyGo/9.3.1 (+github.com/fastly/go-fastly; go1.22.2) + url: https://api.fastly.com/service/qDAwPNSjDoCytjIZ6SfjF5/version/38/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}' @@ -20,14 +20,16 @@ interactions: - bytes Cache-Control: - no-store + Connection: + - keep-alive Content-Type: - application/json Date: - - Sat, 13 Apr 2024 05:21:41 GMT + - Fri, 19 Apr 2024 02:52:15 GMT Fastly-Ratelimit-Remaining: - - "980" + - "927" Fastly-Ratelimit-Reset: - - "1712988000" + - "1713495600" Pragma: - no-cache Server: @@ -45,9 +47,9 @@ interactions: X-Cache-Hits: - "0" X-Served-By: - - cache-bfi-krnt7300024-BFI + - cache-bfi-krnt7300112-BFI X-Timer: - - S1712985701.362264,VS0,VE305 + - S1713495135.056363,VS0,VE253 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/image_optimizer_default_settings/incorrect_fetch.yaml b/fastly/fixtures/image_optimizer_default_settings/incorrect_fetch.yaml index a94206ad..2abe7bfa 100644 --- a/fastly/fixtures/image_optimizer_default_settings/incorrect_fetch.yaml +++ b/fastly/fixtures/image_optimizer_default_settings/incorrect_fetch.yaml @@ -10,8 +10,8 @@ interactions: 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 + - FastlyGo/9.3.1 (+github.com/fastly/go-fastly; go1.22.2) + url: https://api.fastly.com/service/qDAwPNSjDoCytjIZ6SfjF5/version/38/image_optimizer_default_settings method: PATCH response: body: '{"type":"https://www.fastly.com/documentation/reference/api/services/image_optimizer_default_settings/","title":"Bad @@ -21,14 +21,16 @@ interactions: - bytes Cache-Control: - no-store + Connection: + - keep-alive Content-Type: - application/json Date: - - Sat, 13 Apr 2024 05:21:41 GMT + - Fri, 19 Apr 2024 02:52:12 GMT Fastly-Ratelimit-Remaining: - - "981" + - "937" Fastly-Ratelimit-Reset: - - "1712988000" + - "1713495600" Pragma: - no-cache Server: @@ -46,9 +48,9 @@ interactions: X-Cache-Hits: - "0" X-Served-By: - - cache-bfi-krnt7300024-BFI + - cache-bfi-krnt7300112-BFI X-Timer: - - S1712985701.156217,VS0,VE150 + - S1713495132.050585,VS0,VE155 status: 400 Bad Request code: 400 duration: "" diff --git a/fastly/fixtures/image_optimizer_default_settings/original_fetch.yaml b/fastly/fixtures/image_optimizer_default_settings/original_fetch.yaml index b91af4d9..9da927b7 100644 --- a/fastly/fixtures/image_optimizer_default_settings/original_fetch.yaml +++ b/fastly/fixtures/image_optimizer_default_settings/original_fetch.yaml @@ -6,8 +6,8 @@ interactions: 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 + - FastlyGo/9.3.1 (+github.com/fastly/go-fastly; go1.22.2) + url: https://api.fastly.com/service/qDAwPNSjDoCytjIZ6SfjF5/version/38/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}' @@ -16,10 +16,12 @@ interactions: - bytes Cache-Control: - no-store + Connection: + - keep-alive Content-Type: - application/json Date: - - Sat, 13 Apr 2024 05:21:40 GMT + - Fri, 19 Apr 2024 02:52:11 GMT Pragma: - no-cache Server: @@ -37,9 +39,9 @@ interactions: X-Cache-Hits: - "0" X-Served-By: - - cache-bfi-krnt7300024-BFI + - cache-bfi-krnt7300112-BFI X-Timer: - - S1712985700.911043,VS0,VE160 + - S1713495131.868264,VS0,VE188 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/image_optimizer_default_settings/set_full.yaml b/fastly/fixtures/image_optimizer_default_settings/set_full.yaml new file mode 100644 index 00000000..97a7c098 --- /dev/null +++ b/fastly/fixtures/image_optimizer_default_settings/set_full.yaml @@ -0,0 +1,55 @@ +--- +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.1 (+github.com/fastly/go-fastly; go1.22.2) + url: https://api.fastly.com/service/qDAwPNSjDoCytjIZ6SfjF5/version/38/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 + Connection: + - keep-alive + Content-Type: + - application/json + Date: + - Fri, 19 Apr 2024 02:52:15 GMT + Fastly-Ratelimit-Remaining: + - "928" + Fastly-Ratelimit-Reset: + - "1713495600" + 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-krnt7300112-BFI + X-Timer: + - S1713495135.776020,VS0,VE264 + status: 200 OK + code: 200 + duration: "" diff --git a/fastly/fixtures/image_optimizer_default_settings/set_jpeg_type/auto.yaml b/fastly/fixtures/image_optimizer_default_settings/set_jpeg_type/auto.yaml new file mode 100644 index 00000000..84eccb6c --- /dev/null +++ b/fastly/fixtures/image_optimizer_default_settings/set_jpeg_type/auto.yaml @@ -0,0 +1,55 @@ +--- +version: 1 +interactions: +- request: + body: '{"jpeg_type":"auto"}' + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + User-Agent: + - FastlyGo/9.3.1 (+github.com/fastly/go-fastly; go1.22.2) + url: https://api.fastly.com/service/qDAwPNSjDoCytjIZ6SfjF5/version/38/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 + Connection: + - keep-alive + Content-Type: + - application/json + Date: + - Fri, 19 Apr 2024 02:52:14 GMT + Fastly-Ratelimit-Remaining: + - "931" + Fastly-Ratelimit-Reset: + - "1713495600" + 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-krnt7300112-BFI + X-Timer: + - S1713495134.887720,VS0,VE237 + status: 200 OK + code: 200 + duration: "" diff --git a/fastly/fixtures/image_optimizer_default_settings/set_jpeg_type/baseline.yaml b/fastly/fixtures/image_optimizer_default_settings/set_jpeg_type/baseline.yaml new file mode 100644 index 00000000..87beb98b --- /dev/null +++ b/fastly/fixtures/image_optimizer_default_settings/set_jpeg_type/baseline.yaml @@ -0,0 +1,55 @@ +--- +version: 1 +interactions: +- request: + body: '{"jpeg_type":"baseline"}' + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + User-Agent: + - FastlyGo/9.3.1 (+github.com/fastly/go-fastly; go1.22.2) + url: https://api.fastly.com/service/qDAwPNSjDoCytjIZ6SfjF5/version/38/image_optimizer_default_settings + method: PATCH + response: + body: '{"resize_filter":"nearest","webp":true,"webp_quality":42,"jpeg_type":"baseline","jpeg_quality":85,"upscale":true,"allow_video":false}' + headers: + Accept-Ranges: + - bytes + Cache-Control: + - no-store + Connection: + - keep-alive + Content-Type: + - application/json + Date: + - Fri, 19 Apr 2024 02:52:14 GMT + Fastly-Ratelimit-Remaining: + - "930" + Fastly-Ratelimit-Reset: + - "1713495600" + 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-krnt7300112-BFI + X-Timer: + - S1713495134.144395,VS0,VE289 + status: 200 OK + code: 200 + duration: "" diff --git a/fastly/fixtures/image_optimizer_default_settings/set_jpeg_type/progressive.yaml b/fastly/fixtures/image_optimizer_default_settings/set_jpeg_type/progressive.yaml new file mode 100644 index 00000000..de249654 --- /dev/null +++ b/fastly/fixtures/image_optimizer_default_settings/set_jpeg_type/progressive.yaml @@ -0,0 +1,55 @@ +--- +version: 1 +interactions: +- request: + body: '{"jpeg_type":"progressive"}' + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + User-Agent: + - FastlyGo/9.3.1 (+github.com/fastly/go-fastly; go1.22.2) + url: https://api.fastly.com/service/qDAwPNSjDoCytjIZ6SfjF5/version/38/image_optimizer_default_settings + method: PATCH + response: + body: '{"resize_filter":"nearest","webp":true,"webp_quality":42,"jpeg_type":"progressive","jpeg_quality":85,"upscale":true,"allow_video":false}' + headers: + Accept-Ranges: + - bytes + Cache-Control: + - no-store + Connection: + - keep-alive + Content-Type: + - application/json + Date: + - Fri, 19 Apr 2024 02:52:14 GMT + Fastly-Ratelimit-Remaining: + - "929" + Fastly-Ratelimit-Reset: + - "1713495600" + 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-krnt7300112-BFI + X-Timer: + - S1713495134.451909,VS0,VE274 + status: 200 OK + code: 200 + duration: "" diff --git a/fastly/fixtures/image_optimizer_default_settings/set_resize_filter/bicubic.yaml b/fastly/fixtures/image_optimizer_default_settings/set_resize_filter/bicubic.yaml new file mode 100644 index 00000000..bdb2cc1d --- /dev/null +++ b/fastly/fixtures/image_optimizer_default_settings/set_resize_filter/bicubic.yaml @@ -0,0 +1,55 @@ +--- +version: 1 +interactions: +- request: + body: '{"resize_filter":"bicubic"}' + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + User-Agent: + - FastlyGo/9.3.1 (+github.com/fastly/go-fastly; go1.22.2) + url: https://api.fastly.com/service/qDAwPNSjDoCytjIZ6SfjF5/version/38/image_optimizer_default_settings + method: PATCH + response: + body: '{"resize_filter":"bicubic","webp":true,"webp_quality":42,"jpeg_type":"auto","jpeg_quality":85,"upscale":true,"allow_video":false}' + headers: + Accept-Ranges: + - bytes + Cache-Control: + - no-store + Connection: + - keep-alive + Content-Type: + - application/json + Date: + - Fri, 19 Apr 2024 02:52:13 GMT + Fastly-Ratelimit-Remaining: + - "934" + Fastly-Ratelimit-Reset: + - "1713495600" + 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-krnt7300112-BFI + X-Timer: + - S1713495133.730258,VS0,VE304 + status: 200 OK + code: 200 + duration: "" diff --git a/fastly/fixtures/image_optimizer_default_settings/set_resize_filter/bilinear.yaml b/fastly/fixtures/image_optimizer_default_settings/set_resize_filter/bilinear.yaml new file mode 100644 index 00000000..5f4d75a0 --- /dev/null +++ b/fastly/fixtures/image_optimizer_default_settings/set_resize_filter/bilinear.yaml @@ -0,0 +1,55 @@ +--- +version: 1 +interactions: +- request: + body: '{"resize_filter":"bilinear"}' + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + User-Agent: + - FastlyGo/9.3.1 (+github.com/fastly/go-fastly; go1.22.2) + url: https://api.fastly.com/service/qDAwPNSjDoCytjIZ6SfjF5/version/38/image_optimizer_default_settings + method: PATCH + response: + body: '{"resize_filter":"bilinear","webp":true,"webp_quality":42,"jpeg_type":"auto","jpeg_quality":85,"upscale":true,"allow_video":false}' + headers: + Accept-Ranges: + - bytes + Cache-Control: + - no-store + Connection: + - keep-alive + Content-Type: + - application/json + Date: + - Fri, 19 Apr 2024 02:52:13 GMT + Fastly-Ratelimit-Remaining: + - "933" + Fastly-Ratelimit-Reset: + - "1713495600" + 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-krnt7300112-BFI + X-Timer: + - S1713495133.057831,VS0,VE345 + status: 200 OK + code: 200 + duration: "" diff --git a/fastly/fixtures/image_optimizer_default_settings/set_resize_filter/lanczos2.yaml b/fastly/fixtures/image_optimizer_default_settings/set_resize_filter/lanczos2.yaml new file mode 100644 index 00000000..88382007 --- /dev/null +++ b/fastly/fixtures/image_optimizer_default_settings/set_resize_filter/lanczos2.yaml @@ -0,0 +1,55 @@ +--- +version: 1 +interactions: +- request: + body: '{"resize_filter":"lanczos2"}' + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + User-Agent: + - FastlyGo/9.3.1 (+github.com/fastly/go-fastly; go1.22.2) + url: https://api.fastly.com/service/qDAwPNSjDoCytjIZ6SfjF5/version/38/image_optimizer_default_settings + method: PATCH + response: + body: '{"resize_filter":"lanczos2","webp":true,"webp_quality":42,"jpeg_type":"auto","jpeg_quality":85,"upscale":true,"allow_video":false}' + headers: + Accept-Ranges: + - bytes + Cache-Control: + - no-store + Connection: + - keep-alive + Content-Type: + - application/json + Date: + - Fri, 19 Apr 2024 02:52:12 GMT + Fastly-Ratelimit-Remaining: + - "935" + Fastly-Ratelimit-Reset: + - "1713495600" + 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-krnt7300112-BFI + X-Timer: + - S1713495132.481266,VS0,VE226 + status: 200 OK + code: 200 + duration: "" diff --git a/fastly/fixtures/image_optimizer_default_settings/set_resize_filter/lanczos3.yaml b/fastly/fixtures/image_optimizer_default_settings/set_resize_filter/lanczos3.yaml new file mode 100644 index 00000000..bdc62a5d --- /dev/null +++ b/fastly/fixtures/image_optimizer_default_settings/set_resize_filter/lanczos3.yaml @@ -0,0 +1,55 @@ +--- +version: 1 +interactions: +- request: + body: '{"resize_filter":"lanczos3"}' + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + User-Agent: + - FastlyGo/9.3.1 (+github.com/fastly/go-fastly; go1.22.2) + url: https://api.fastly.com/service/qDAwPNSjDoCytjIZ6SfjF5/version/38/image_optimizer_default_settings + method: PATCH + response: + body: '{"resize_filter":"lanczos3","webp":true,"webp_quality":42,"jpeg_type":"auto","jpeg_quality":85,"upscale":true,"allow_video":false}' + headers: + Accept-Ranges: + - bytes + Cache-Control: + - no-store + Connection: + - keep-alive + Content-Type: + - application/json + Date: + - Fri, 19 Apr 2024 02:52:12 GMT + Fastly-Ratelimit-Remaining: + - "936" + Fastly-Ratelimit-Reset: + - "1713495600" + 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-krnt7300112-BFI + X-Timer: + - S1713495132.224587,VS0,VE239 + status: 200 OK + code: 200 + duration: "" diff --git a/fastly/fixtures/image_optimizer_default_settings/set_resize_filter/nearest.yaml b/fastly/fixtures/image_optimizer_default_settings/set_resize_filter/nearest.yaml new file mode 100644 index 00000000..2252aab7 --- /dev/null +++ b/fastly/fixtures/image_optimizer_default_settings/set_resize_filter/nearest.yaml @@ -0,0 +1,55 @@ +--- +version: 1 +interactions: +- request: + body: '{"resize_filter":"nearest"}' + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + User-Agent: + - FastlyGo/9.3.1 (+github.com/fastly/go-fastly; go1.22.2) + url: https://api.fastly.com/service/qDAwPNSjDoCytjIZ6SfjF5/version/38/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 + Connection: + - keep-alive + Content-Type: + - application/json + Date: + - Fri, 19 Apr 2024 02:52:13 GMT + Fastly-Ratelimit-Remaining: + - "932" + Fastly-Ratelimit-Reset: + - "1713495600" + 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-krnt7300112-BFI + X-Timer: + - S1713495133.431590,VS0,VE334 + status: 200 OK + code: 200 + duration: "" diff --git a/fastly/fixtures/image_optimizer_default_settings/update_1_get.yaml b/fastly/fixtures/image_optimizer_default_settings/update_1_get.yaml index 8bd6dff0..30420330 100644 --- a/fastly/fixtures/image_optimizer_default_settings/update_1_get.yaml +++ b/fastly/fixtures/image_optimizer_default_settings/update_1_get.yaml @@ -6,8 +6,8 @@ interactions: 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 + - FastlyGo/9.3.1 (+github.com/fastly/go-fastly; go1.22.2) + url: https://api.fastly.com/service/qDAwPNSjDoCytjIZ6SfjF5/version/38/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}' @@ -16,10 +16,12 @@ interactions: - bytes Cache-Control: - no-store + Connection: + - keep-alive Content-Type: - application/json Date: - - Sat, 13 Apr 2024 05:21:40 GMT + - Fri, 19 Apr 2024 02:52:11 GMT Pragma: - no-cache Server: @@ -37,9 +39,9 @@ interactions: X-Cache-Hits: - "0" X-Served-By: - - cache-bfi-krnt7300024-BFI + - cache-bfi-krnt7300112-BFI X-Timer: - - S1712985700.407525,VS0,VE169 + - S1713495131.397009,VS0,VE136 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/image_optimizer_default_settings/update_1_patch.yaml b/fastly/fixtures/image_optimizer_default_settings/update_1_patch.yaml index 17a11169..0055ccde 100644 --- a/fastly/fixtures/image_optimizer_default_settings/update_1_patch.yaml +++ b/fastly/fixtures/image_optimizer_default_settings/update_1_patch.yaml @@ -10,8 +10,8 @@ interactions: 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 + - FastlyGo/9.3.1 (+github.com/fastly/go-fastly; go1.22.2) + url: https://api.fastly.com/service/qDAwPNSjDoCytjIZ6SfjF5/version/38/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}' @@ -20,14 +20,16 @@ interactions: - bytes Cache-Control: - no-store + Connection: + - keep-alive Content-Type: - application/json Date: - - Sat, 13 Apr 2024 05:21:40 GMT + - Fri, 19 Apr 2024 02:52:11 GMT Fastly-Ratelimit-Remaining: - - "983" + - "939" Fastly-Ratelimit-Reset: - - "1712988000" + - "1713495600" Pragma: - no-cache Server: @@ -45,9 +47,9 @@ interactions: X-Cache-Hits: - "0" X-Served-By: - - cache-bfi-krnt7300024-BFI + - cache-bfi-krnt7300112-BFI X-Timer: - - S1712985700.118285,VS0,VE241 + - S1713495131.125925,VS0,VE256 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/image_optimizer_default_settings/update_2_get.yaml b/fastly/fixtures/image_optimizer_default_settings/update_2_get.yaml index e8b3ddf1..20cd73d1 100644 --- a/fastly/fixtures/image_optimizer_default_settings/update_2_get.yaml +++ b/fastly/fixtures/image_optimizer_default_settings/update_2_get.yaml @@ -6,8 +6,8 @@ interactions: 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 + - FastlyGo/9.3.1 (+github.com/fastly/go-fastly; go1.22.2) + url: https://api.fastly.com/service/qDAwPNSjDoCytjIZ6SfjF5/version/38/image_optimizer_default_settings method: GET response: body: '{"resize_filter":"lanczos3","webp":true,"webp_quality":42,"jpeg_type":"auto","jpeg_quality":85,"upscale":true,"allow_video":false}' @@ -16,10 +16,12 @@ interactions: - bytes Cache-Control: - no-store + Connection: + - keep-alive Content-Type: - application/json Date: - - Sat, 13 Apr 2024 05:21:41 GMT + - Fri, 19 Apr 2024 02:52:12 GMT Pragma: - no-cache Server: @@ -37,9 +39,9 @@ interactions: X-Cache-Hits: - "0" X-Served-By: - - cache-bfi-krnt7300024-BFI + - cache-bfi-krnt7300112-BFI X-Timer: - - S1712985701.938658,VS0,VE162 + - S1713495132.856072,VS0,VE180 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/image_optimizer_default_settings/update_2_patch.yaml b/fastly/fixtures/image_optimizer_default_settings/update_2_patch.yaml index 342e3168..2a61484d 100644 --- a/fastly/fixtures/image_optimizer_default_settings/update_2_patch.yaml +++ b/fastly/fixtures/image_optimizer_default_settings/update_2_patch.yaml @@ -10,8 +10,8 @@ interactions: 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 + - FastlyGo/9.3.1 (+github.com/fastly/go-fastly; go1.22.2) + url: https://api.fastly.com/service/qDAwPNSjDoCytjIZ6SfjF5/version/38/image_optimizer_default_settings method: PATCH response: body: '{"resize_filter":"lanczos3","webp":true,"webp_quality":42,"jpeg_type":"auto","jpeg_quality":85,"upscale":true,"allow_video":false}' @@ -20,14 +20,16 @@ interactions: - bytes Cache-Control: - no-store + Connection: + - keep-alive Content-Type: - application/json Date: - - Sat, 13 Apr 2024 05:21:40 GMT + - Fri, 19 Apr 2024 02:52:11 GMT Fastly-Ratelimit-Remaining: - - "982" + - "938" Fastly-Ratelimit-Reset: - - "1712988000" + - "1713495600" Pragma: - no-cache Server: @@ -45,9 +47,9 @@ interactions: X-Cache-Hits: - "0" X-Served-By: - - cache-bfi-krnt7300024-BFI + - cache-bfi-krnt7300112-BFI X-Timer: - - S1712985701.625696,VS0,VE263 + - S1713495132.550616,VS0,VE286 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/image_optimizer_default_settings/version.yaml b/fastly/fixtures/image_optimizer_default_settings/version.yaml index f3ac20c0..fcdc9397 100644 --- a/fastly/fixtures/image_optimizer_default_settings/version.yaml +++ b/fastly/fixtures/image_optimizer_default_settings/version.yaml @@ -8,24 +8,26 @@ interactions: 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/service/7i6HN3TK9wS159v2gPAZ8A/version + - FastlyGo/9.3.1 (+github.com/fastly/go-fastly; go1.22.2) + url: https://api.fastly.com/service/qDAwPNSjDoCytjIZ6SfjF5/version method: POST response: - body: '{"service_id":"7i6HN3TK9wS159v2gPAZ8A","number":22}' + body: '{"service_id":"qDAwPNSjDoCytjIZ6SfjF5","number":38}' headers: Accept-Ranges: - bytes Cache-Control: - no-store + Connection: + - keep-alive Content-Type: - application/json Date: - - Sat, 13 Apr 2024 05:21:38 GMT + - Fri, 19 Apr 2024 02:52:09 GMT Fastly-Ratelimit-Remaining: - - "984" + - "940" Fastly-Ratelimit-Reset: - - "1712988000" + - "1713495600" Pragma: - no-cache Server: @@ -43,9 +45,9 @@ interactions: X-Cache-Hits: - "0" X-Served-By: - - cache-bfi-krnt7300024-BFI + - cache-bfi-krnt7300112-BFI X-Timer: - - S1712985699.594687,VS0,VE275 + - S1713495129.491623,VS0,VE255 status: 200 OK code: 200 duration: "" diff --git a/fastly/image_optimizer_default_settings.go b/fastly/image_optimizer_default_settings.go index 8bac2602..0ca0156e 100644 --- a/fastly/image_optimizer_default_settings.go +++ b/fastly/image_optimizer_default_settings.go @@ -24,6 +24,10 @@ func (r ResizeFilter) String() string { return "lanczos3" // default } +func (r ResizeFilter) MarshalJSON() ([]byte, error) { + return json.Marshal(r.String()) +} + const ( Lanczos3 ResizeFilter = iota Lanczos2 @@ -32,6 +36,31 @@ const ( Nearest ) +// JpegType is a base for different JpegType variants +type JpegType int64 + +func (r JpegType) String() string { + switch r { + case Auto: + return "auto" + case Baseline: + return "baseline" + case Progressive: + return "progressive" + } + return "auto" // default +} + +func (r JpegType) MarshalJSON() ([]byte, error) { + return json.Marshal(r.String()) +} + +const ( + Auto JpegType = iota + Baseline + Progressive +) + // ImageOptimizerDefaultSettings represents the returned default settings for Image Optimizer on a given service. type ImageOptimizerDefaultSettings struct { // Type of filter to use while resizing an image. @@ -77,7 +106,7 @@ type UpdateImageOptimizerDefaultSettingsInput struct { // requests. WebpQuality *int `json:"webp_quality,omitempty"` // Default type of jpeg output to use. This can be overriden with "format=bjpeg" and "format=pjpeg" on specific image optimizer requests. - JpegType *string `json:"jpeg_type,omitempty"` + JpegType *JpegType `json:"jpeg_type,omitempty"` // Default quality to use with jpeg output. This can be overridden with the "quality" parameter on specific image optimizer requests. JpegQuality *int `json:"jpeg_quality,omitempty"` // Whether or not we should allow output images to render at sizes larger than input. diff --git a/fastly/image_optimizer_default_settings_test.go b/fastly/image_optimizer_default_settings_test.go index 63fb5743..b78381a2 100644 --- a/fastly/image_optimizer_default_settings_test.go +++ b/fastly/image_optimizer_default_settings_test.go @@ -182,6 +182,48 @@ func TestClient_ImageOptimizerDefaultSettings(t *testing.T) { if !strings.Contains(err.Error(), expectedErr) { t.Fatalf("expected error to include '%s'; got: %v", expectedErr, err) } + + // Confirm all resize_filter & jpeg_type values are accepted + for _, resizeFilter := range []ResizeFilter{Lanczos3, Lanczos2, Bicubic, Bilinear, Nearest} { + record(t, fixtureBase+"set_resize_filter/"+resizeFilter.String(), func(c *Client) { + defaultSettings, err = c.UpdateImageOptimizerDefaultSettings(&UpdateImageOptimizerDefaultSettingsInput{ + ServiceID: testServiceID, + ServiceVersion: *testVersion.Number, + ResizeFilter: &resizeFilter, + }) + }) + if defaultSettings.ResizeFilter != resizeFilter.String() { + t.Fatalf("expected ResizeFilter: %s; got: %s", resizeFilter.String(), defaultSettings.ResizeFilter) + } + } + + for _, jpegType := range []JpegType{Auto, Baseline, Progressive} { + record(t, fixtureBase+"set_jpeg_type/"+jpegType.String(), func(c *Client) { + defaultSettings, err = c.UpdateImageOptimizerDefaultSettings(&UpdateImageOptimizerDefaultSettingsInput{ + ServiceID: testServiceID, + ServiceVersion: *testVersion.Number, + JpegType: &jpegType, + }) + }) + if defaultSettings.JpegType != jpegType.String() { + t.Fatalf("expected JpegType: %s; got: %s", jpegType.String(), defaultSettings.JpegType) + } + } + + // Confirm a full request is accepted - that all parameters in our library match the API's expectations + record(t, fixtureBase+"set_full", func(c *Client) { + defaultSettings, err = c.UpdateImageOptimizerDefaultSettings(&UpdateImageOptimizerDefaultSettingsInput{ + ServiceID: testServiceID, + ServiceVersion: *testVersion.Number, + ResizeFilter: ToPointer(Lanczos3), + Webp: ToPointer(false), + WebpQuality: ToPointer(85), + JpegType: ToPointer(Auto), + JpegQuality: ToPointer(85), + Upscale: ToPointer(false), + AllowVideo: ToPointer(false), + }) + }) } func TestClient_GetImageOptimizerDefaultSettings_validation(t *testing.T) { From 5b449db3c88b513b25343e1e6c094a0172d2c400 Mon Sep 17 00:00:00 2001 From: Dabo Ross Date: Fri, 26 Apr 2024 10:36:26 -0700 Subject: [PATCH 05/13] Update field docs to match final api-documentation PR --- fastly/image_optimizer_default_settings.go | 38 ++++++++++++++-------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/fastly/image_optimizer_default_settings.go b/fastly/image_optimizer_default_settings.go index 0ca0156e..6a7ed7d2 100644 --- a/fastly/image_optimizer_default_settings.go +++ b/fastly/image_optimizer_default_settings.go @@ -29,10 +29,15 @@ func (r ResizeFilter) MarshalJSON() ([]byte, error) { } const ( + // A Lanczos filter with a kernel size of 3. Lanczos filters can detect edges and linear features within an image, providing the best possible reconstruction. Lanczos3 ResizeFilter = iota + // A Lanczos filter with a kernel size of 2. Lanczos2 + // A filter using an average of a 4x4 environment of pixels, weighing the innermost pixels higher. Bicubic + // A filter using an average of a 2x2 environment of pixels. Bilinear + // A filter using the value of nearby translated pixel values. Preserves hard edges. Nearest ) @@ -56,23 +61,25 @@ func (r JpegType) MarshalJSON() ([]byte, error) { } const ( + // Match the input JPEG type, or baseline if transforming from a non-JPEG input. Auto JpegType = iota + // Output baseline JPEG images Baseline + // Output progressive JPEG images Progressive ) -// ImageOptimizerDefaultSettings represents the returned default settings for Image Optimizer on a given service. +// ImageOptimizerDefaultSettings represents the returned Image Optimizer default settings for a given service. type ImageOptimizerDefaultSettings struct { - // Type of filter to use while resizing an image. + // The type of filter to use while resizing an image. ResizeFilter string `json:"resize_filter"` - // Whether or not to default to webp output when the client supports it. This is equivalent to adding "auto=webp" to all image optimizer requests. + // Controls whether or not to default to WebP output when the client supports it. This is equivalent to adding "auto=webp" to all image optimizer requests. Webp bool `json:"webp"` - // Default quality to use with webp output. This can be overriden with the second option in the "quality" URL parameter on specific image optimizer - // requests. + // The default quality to use with WebP output. This can be overridden with the second option in the "quality" URL parameter on specific image optimizer requests. WebpQuality int `json:"webp_quality"` - // Default type of jpeg output to use. This can be overriden with "format=bjpeg" and "format=pjpeg" on specific image optimizer requests. + // The default type of JPEG output to use. This can be overridden with "format=bjpeg" and "format=pjpeg" on specific image optimizer requests. JpegType string `json:"jpeg_type"` - // Default quality to use with jpeg output. This can be overridden with the "quality" parameter on specific image optimizer requests. + // The default quality to use with JPEG output. This can be overridden with the "quality" parameter on specific image optimizer requests. JpegQuality int `json:"jpeg_quality"` // Whether or not we should allow output images to render at sizes larger than input. Upscale bool `json:"upscale"` @@ -98,16 +105,15 @@ type UpdateImageOptimizerDefaultSettingsInput struct { ServiceID string `json:"-"` // ServiceVersion is the specific configuration version (required). ServiceVersion int `json:"-"` - // Type of filter to use while resizing an image. + // The type of filter to use while resizing an image. ResizeFilter *ResizeFilter `json:"resize_filter,omitempty"` - // Whether or not to default to webp output when the client supports it. This is equivalent to adding "auto=webp" to all image optimizer requests. + // Controls whether or not to default to WebP output when the client supports it. This is equivalent to adding "auto=webp" to all image optimizer requests. Webp *bool `json:"webp,omitempty"` - // Default quality to use with webp output. This can be overriden with the second option in the "quality" URL parameter on specific image optimizer - // requests. + // The default quality to use with WebP output. This can be overridden with the second option in the "quality" URL parameter on specific image optimizer requests. WebpQuality *int `json:"webp_quality,omitempty"` - // Default type of jpeg output to use. This can be overriden with "format=bjpeg" and "format=pjpeg" on specific image optimizer requests. + // The default type of JPEG output to use. This can be overridden with "format=bjpeg" and "format=pjpeg" on specific image optimizer requests. JpegType *JpegType `json:"jpeg_type,omitempty"` - // Default quality to use with jpeg output. This can be overridden with the "quality" parameter on specific image optimizer requests. + // The default quality to use with JPEG output. This can be overridden with the "quality" parameter on specific image optimizer requests. JpegQuality *int `json:"jpeg_quality,omitempty"` // Whether or not we should allow output images to render at sizes larger than input. Upscale *bool `json:"upscale,omitempty"` @@ -148,7 +154,11 @@ func (c *Client) GetImageOptimizerDefaultSettings(i *GetImageOptimizerDefaultSet return iods, nil } -// UpdateImageOptimizerDefaultSettings changes one or more Image Optimizer default settings on a given service version. +// UpdateImageOptimizerDefaultSettings Update one or more default settings. +// +// A minimum of one non-nil property is required. +// +// Returns the new Image Optimizer default settings. func (c *Client) UpdateImageOptimizerDefaultSettings(i *UpdateImageOptimizerDefaultSettingsInput) (*ImageOptimizerDefaultSettings, error) { if i.ServiceID == "" { return nil, ErrMissingServiceID From 7985ea5cce195255603599587fd55c2ce916769f Mon Sep 17 00:00:00 2001 From: Dabo Ross Date: Mon, 13 May 2024 14:28:13 -0700 Subject: [PATCH 06/13] Fail tests on error during deferred settings resets --- .../image_optimizer_default_settings_test.go | 29 ++++++++++++++----- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/fastly/image_optimizer_default_settings_test.go b/fastly/image_optimizer_default_settings_test.go index b78381a2..d6bf52b0 100644 --- a/fastly/image_optimizer_default_settings_test.go +++ b/fastly/image_optimizer_default_settings_test.go @@ -32,11 +32,15 @@ func TestClient_ImageOptimizerDefaultSettings(t *testing.T) { // Ensure we disable IO on the service after the test defer func() { record(t, fixtureBase+"disable_product", func(c *Client) { - c.DisableProduct(&ProductEnablementInput{ + err = c.DisableProduct(&ProductEnablementInput{ ProductID: ProductImageOptimizer, ServiceID: testServiceID, }) }) + + if err != nil { + t.Fatal(err) + } }() var defaultSettings *ImageOptimizerDefaultSettings @@ -57,14 +61,23 @@ func TestClient_ImageOptimizerDefaultSettings(t *testing.T) { // Reset our settings back to the original defer func() { record(t, fixtureBase+"final_reset", func(c *Client) { - _, err = c.UpdateImageOptimizerDefaultSettings(&UpdateImageOptimizerDefaultSettingsInput{ - ServiceID: testServiceID, - ServiceVersion: *testVersion.Number, - Webp: &originalSettings.Webp, - WebpQuality: &originalSettings.WebpQuality, - Upscale: &originalSettings.Upscale, - }) + if originalSettings != nil { + _, err = c.UpdateImageOptimizerDefaultSettings(&UpdateImageOptimizerDefaultSettingsInput{ + ServiceID: testServiceID, + ServiceVersion: *testVersion.Number, + // ResizeFilter: &originalSettings.ResizeFilter, + Webp: &originalSettings.Webp, + WebpQuality: &originalSettings.WebpQuality, + // JpegType: &originalSettings.JpegType, + JpegQuality: &originalSettings.JpegQuality, + Upscale: &originalSettings.Upscale, + AllowVideo: &originalSettings.AllowVideo, + }) + } }) + if err != nil { + t.Fatal(err) + } }() newWebp := false From 078cd6f4e292ac2ab7f588224a85c2cc75731cdf Mon Sep 17 00:00:00 2001 From: Dabo Ross Date: Mon, 13 May 2024 14:28:30 -0700 Subject: [PATCH 07/13] Update tested error message to match Northstar update. --- fastly/image_optimizer_default_settings_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fastly/image_optimizer_default_settings_test.go b/fastly/image_optimizer_default_settings_test.go index d6bf52b0..159383b9 100644 --- a/fastly/image_optimizer_default_settings_test.go +++ b/fastly/image_optimizer_default_settings_test.go @@ -191,7 +191,7 @@ func TestClient_ImageOptimizerDefaultSettings(t *testing.T) { if err == nil { t.Fatalf("missing err") } - expectedErr := "Webp quality must be less than or equal to 100" + expectedErr := "WebP quality must be less than or equal to 100" if !strings.Contains(err.Error(), expectedErr) { t.Fatalf("expected error to include '%s'; got: %v", expectedErr, err) } From 4fc3b72a2acdb2d78eb160e02bde739037a4b3b3 Mon Sep 17 00:00:00 2001 From: Dabo Ross Date: Mon, 13 May 2024 14:28:46 -0700 Subject: [PATCH 08/13] Update Image Optimizer default settings fixtures --- .../disable_product.yaml | 10 ++++------ .../enable_product.yaml | 16 +++++++-------- .../final_reset.yaml | 16 +++++++-------- .../incorrect_fetch.yaml | 20 +++++++++---------- .../original_fetch.yaml | 10 ++++------ .../set_full.yaml | 14 ++++++------- .../set_jpeg_type/auto.yaml | 14 ++++++------- .../set_jpeg_type/baseline.yaml | 14 ++++++------- .../set_jpeg_type/progressive.yaml | 14 ++++++------- .../set_resize_filter/bicubic.yaml | 14 ++++++------- .../set_resize_filter/bilinear.yaml | 14 ++++++------- .../set_resize_filter/lanczos2.yaml | 14 ++++++------- .../set_resize_filter/lanczos3.yaml | 14 ++++++------- .../set_resize_filter/nearest.yaml | 14 ++++++------- .../update_1_get.yaml | 10 ++++------ .../update_1_patch.yaml | 14 ++++++------- .../update_2_get.yaml | 10 ++++------ .../update_2_patch.yaml | 14 ++++++------- .../version.yaml | 16 +++++++-------- 19 files changed, 112 insertions(+), 150 deletions(-) diff --git a/fastly/fixtures/image_optimizer_default_settings/disable_product.yaml b/fastly/fixtures/image_optimizer_default_settings/disable_product.yaml index 2a8ba8d6..ade5167e 100644 --- a/fastly/fixtures/image_optimizer_default_settings/disable_product.yaml +++ b/fastly/fixtures/image_optimizer_default_settings/disable_product.yaml @@ -7,7 +7,7 @@ interactions: headers: User-Agent: - FastlyGo/9.3.1 (+github.com/fastly/go-fastly; go1.22.2) - url: https://api.fastly.com/enabled-products/image_optimizer/services/qDAwPNSjDoCytjIZ6SfjF5 + url: https://api.fastly.com/enabled-products/image_optimizer/services/7i6HN3TK9wS159v2gPAZ8A method: DELETE response: body: "" @@ -16,12 +16,10 @@ interactions: - bytes Cache-Control: - no-store - Connection: - - keep-alive Content-Type: - application/json Date: - - Fri, 19 Apr 2024 02:52:16 GMT + - Mon, 13 May 2024 21:27:45 GMT Pragma: - no-cache Server: @@ -39,9 +37,9 @@ interactions: X-Cache-Hits: - "0" X-Served-By: - - cache-bfi-krnt7300112-BFI + - cache-bfi-krnt7300118-BFI X-Timer: - - S1713495135.395036,VS0,VE693 + - S1715635665.011325,VS0,VE856 status: 204 No Content code: 204 duration: "" diff --git a/fastly/fixtures/image_optimizer_default_settings/enable_product.yaml b/fastly/fixtures/image_optimizer_default_settings/enable_product.yaml index ba4311d3..a37cd60d 100644 --- a/fastly/fixtures/image_optimizer_default_settings/enable_product.yaml +++ b/fastly/fixtures/image_optimizer_default_settings/enable_product.yaml @@ -2,35 +2,33 @@ version: 1 interactions: - request: - body: ProductID=image_optimizer&ServiceID=qDAwPNSjDoCytjIZ6SfjF5 + body: ProductID=image_optimizer&ServiceID=7i6HN3TK9wS159v2gPAZ8A form: ProductID: - image_optimizer ServiceID: - - qDAwPNSjDoCytjIZ6SfjF5 + - 7i6HN3TK9wS159v2gPAZ8A headers: Content-Type: - application/x-www-form-urlencoded User-Agent: - FastlyGo/9.3.1 (+github.com/fastly/go-fastly; go1.22.2) - url: https://api.fastly.com/enabled-products/image_optimizer/services/qDAwPNSjDoCytjIZ6SfjF5 + url: https://api.fastly.com/enabled-products/image_optimizer/services/7i6HN3TK9wS159v2gPAZ8A method: PUT response: body: | - {"product":{"id":"image_optimizer","object":"product"},"service":{"id":"qDAwPNSjDoCytjIZ6SfjF5","object":"service"},"_links":{"self":"/enabled-products/image_optimizer/services/qDAwPNSjDoCytjIZ6SfjF5"}} + {"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 - Connection: - - keep-alive Content-Length: - "203" Content-Type: - application/json Date: - - Fri, 19 Apr 2024 02:52:10 GMT + - Mon, 13 May 2024 21:27:39 GMT Pragma: - no-cache Server: @@ -48,9 +46,9 @@ interactions: X-Cache-Hits: - "0" X-Served-By: - - cache-bfi-krnt7300112-BFI + - cache-bfi-krnt7300118-BFI X-Timer: - - S1713495130.808709,VS0,VE992 + - S1715635658.927563,VS0,VE1264 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/image_optimizer_default_settings/final_reset.yaml b/fastly/fixtures/image_optimizer_default_settings/final_reset.yaml index 510e7fb0..b17f3f25 100644 --- a/fastly/fixtures/image_optimizer_default_settings/final_reset.yaml +++ b/fastly/fixtures/image_optimizer_default_settings/final_reset.yaml @@ -2,7 +2,7 @@ version: 1 interactions: - request: - body: '{"webp":false,"webp_quality":85,"upscale":false}' + body: '{"webp":false,"webp_quality":85,"jpeg_quality":85,"upscale":false,"allow_video":false}' form: {} headers: Accept: @@ -11,7 +11,7 @@ interactions: - application/json User-Agent: - FastlyGo/9.3.1 (+github.com/fastly/go-fastly; go1.22.2) - url: https://api.fastly.com/service/qDAwPNSjDoCytjIZ6SfjF5/version/38/image_optimizer_default_settings + url: https://api.fastly.com/service/7i6HN3TK9wS159v2gPAZ8A/version/86/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}' @@ -20,16 +20,14 @@ interactions: - bytes Cache-Control: - no-store - Connection: - - keep-alive Content-Type: - application/json Date: - - Fri, 19 Apr 2024 02:52:15 GMT + - Mon, 13 May 2024 21:27:44 GMT Fastly-Ratelimit-Remaining: - - "927" + - "978" Fastly-Ratelimit-Reset: - - "1713495600" + - "1715637600" Pragma: - no-cache Server: @@ -47,9 +45,9 @@ interactions: X-Cache-Hits: - "0" X-Served-By: - - cache-bfi-krnt7300112-BFI + - cache-bfi-krnt7300118-BFI X-Timer: - - S1713495135.056363,VS0,VE253 + - S1715635665.681277,VS0,VE319 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/image_optimizer_default_settings/incorrect_fetch.yaml b/fastly/fixtures/image_optimizer_default_settings/incorrect_fetch.yaml index 2abe7bfa..6233cc8a 100644 --- a/fastly/fixtures/image_optimizer_default_settings/incorrect_fetch.yaml +++ b/fastly/fixtures/image_optimizer_default_settings/incorrect_fetch.yaml @@ -11,26 +11,24 @@ interactions: - application/json User-Agent: - FastlyGo/9.3.1 (+github.com/fastly/go-fastly; go1.22.2) - url: https://api.fastly.com/service/qDAwPNSjDoCytjIZ6SfjF5/version/38/image_optimizer_default_settings + url: https://api.fastly.com/service/7i6HN3TK9wS159v2gPAZ8A/version/86/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"}' + 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 - Connection: - - keep-alive Content-Type: - - application/json + - application/problem+json Date: - - Fri, 19 Apr 2024 02:52:12 GMT + - Mon, 13 May 2024 21:27:40 GMT Fastly-Ratelimit-Remaining: - - "937" + - "988" Fastly-Ratelimit-Reset: - - "1713495600" + - "1715637600" Pragma: - no-cache Server: @@ -48,9 +46,9 @@ interactions: X-Cache-Hits: - "0" X-Served-By: - - cache-bfi-krnt7300112-BFI + - cache-bfi-krnt7300118-BFI X-Timer: - - S1713495132.050585,VS0,VE155 + - S1715635661.735633,VS0,VE196 status: 400 Bad Request code: 400 duration: "" diff --git a/fastly/fixtures/image_optimizer_default_settings/original_fetch.yaml b/fastly/fixtures/image_optimizer_default_settings/original_fetch.yaml index 9da927b7..3af9a1bd 100644 --- a/fastly/fixtures/image_optimizer_default_settings/original_fetch.yaml +++ b/fastly/fixtures/image_optimizer_default_settings/original_fetch.yaml @@ -7,7 +7,7 @@ interactions: headers: User-Agent: - FastlyGo/9.3.1 (+github.com/fastly/go-fastly; go1.22.2) - url: https://api.fastly.com/service/qDAwPNSjDoCytjIZ6SfjF5/version/38/image_optimizer_default_settings + url: https://api.fastly.com/service/7i6HN3TK9wS159v2gPAZ8A/version/86/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}' @@ -16,12 +16,10 @@ interactions: - bytes Cache-Control: - no-store - Connection: - - keep-alive Content-Type: - application/json Date: - - Fri, 19 Apr 2024 02:52:11 GMT + - Mon, 13 May 2024 21:27:39 GMT Pragma: - no-cache Server: @@ -39,9 +37,9 @@ interactions: X-Cache-Hits: - "0" X-Served-By: - - cache-bfi-krnt7300112-BFI + - cache-bfi-krnt7300118-BFI X-Timer: - - S1713495131.868264,VS0,VE188 + - S1715635659.213525,VS0,VE330 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/image_optimizer_default_settings/set_full.yaml b/fastly/fixtures/image_optimizer_default_settings/set_full.yaml index 97a7c098..21dd0a9f 100644 --- a/fastly/fixtures/image_optimizer_default_settings/set_full.yaml +++ b/fastly/fixtures/image_optimizer_default_settings/set_full.yaml @@ -11,7 +11,7 @@ interactions: - application/json User-Agent: - FastlyGo/9.3.1 (+github.com/fastly/go-fastly; go1.22.2) - url: https://api.fastly.com/service/qDAwPNSjDoCytjIZ6SfjF5/version/38/image_optimizer_default_settings + url: https://api.fastly.com/service/7i6HN3TK9wS159v2gPAZ8A/version/86/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}' @@ -20,16 +20,14 @@ interactions: - bytes Cache-Control: - no-store - Connection: - - keep-alive Content-Type: - application/json Date: - - Fri, 19 Apr 2024 02:52:15 GMT + - Mon, 13 May 2024 21:27:44 GMT Fastly-Ratelimit-Remaining: - - "928" + - "979" Fastly-Ratelimit-Reset: - - "1713495600" + - "1715637600" Pragma: - no-cache Server: @@ -47,9 +45,9 @@ interactions: X-Cache-Hits: - "0" X-Served-By: - - cache-bfi-krnt7300112-BFI + - cache-bfi-krnt7300118-BFI X-Timer: - - S1713495135.776020,VS0,VE264 + - S1715635664.186982,VS0,VE392 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/image_optimizer_default_settings/set_jpeg_type/auto.yaml b/fastly/fixtures/image_optimizer_default_settings/set_jpeg_type/auto.yaml index 84eccb6c..36830721 100644 --- a/fastly/fixtures/image_optimizer_default_settings/set_jpeg_type/auto.yaml +++ b/fastly/fixtures/image_optimizer_default_settings/set_jpeg_type/auto.yaml @@ -11,7 +11,7 @@ interactions: - application/json User-Agent: - FastlyGo/9.3.1 (+github.com/fastly/go-fastly; go1.22.2) - url: https://api.fastly.com/service/qDAwPNSjDoCytjIZ6SfjF5/version/38/image_optimizer_default_settings + url: https://api.fastly.com/service/7i6HN3TK9wS159v2gPAZ8A/version/86/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}' @@ -20,16 +20,14 @@ interactions: - bytes Cache-Control: - no-store - Connection: - - keep-alive Content-Type: - application/json Date: - - Fri, 19 Apr 2024 02:52:14 GMT + - Mon, 13 May 2024 21:27:43 GMT Fastly-Ratelimit-Remaining: - - "931" + - "982" Fastly-Ratelimit-Reset: - - "1713495600" + - "1715637600" Pragma: - no-cache Server: @@ -47,9 +45,9 @@ interactions: X-Cache-Hits: - "0" X-Served-By: - - cache-bfi-krnt7300112-BFI + - cache-bfi-krnt7300118-BFI X-Timer: - - S1713495134.887720,VS0,VE237 + - S1715635663.973275,VS0,VE274 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/image_optimizer_default_settings/set_jpeg_type/baseline.yaml b/fastly/fixtures/image_optimizer_default_settings/set_jpeg_type/baseline.yaml index 87beb98b..f7692003 100644 --- a/fastly/fixtures/image_optimizer_default_settings/set_jpeg_type/baseline.yaml +++ b/fastly/fixtures/image_optimizer_default_settings/set_jpeg_type/baseline.yaml @@ -11,7 +11,7 @@ interactions: - application/json User-Agent: - FastlyGo/9.3.1 (+github.com/fastly/go-fastly; go1.22.2) - url: https://api.fastly.com/service/qDAwPNSjDoCytjIZ6SfjF5/version/38/image_optimizer_default_settings + url: https://api.fastly.com/service/7i6HN3TK9wS159v2gPAZ8A/version/86/image_optimizer_default_settings method: PATCH response: body: '{"resize_filter":"nearest","webp":true,"webp_quality":42,"jpeg_type":"baseline","jpeg_quality":85,"upscale":true,"allow_video":false}' @@ -20,16 +20,14 @@ interactions: - bytes Cache-Control: - no-store - Connection: - - keep-alive Content-Type: - application/json Date: - - Fri, 19 Apr 2024 02:52:14 GMT + - Mon, 13 May 2024 21:27:43 GMT Fastly-Ratelimit-Remaining: - - "930" + - "981" Fastly-Ratelimit-Reset: - - "1713495600" + - "1715637600" Pragma: - no-cache Server: @@ -47,9 +45,9 @@ interactions: X-Cache-Hits: - "0" X-Served-By: - - cache-bfi-krnt7300112-BFI + - cache-bfi-krnt7300118-BFI X-Timer: - - S1713495134.144395,VS0,VE289 + - S1715635663.364952,VS0,VE309 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/image_optimizer_default_settings/set_jpeg_type/progressive.yaml b/fastly/fixtures/image_optimizer_default_settings/set_jpeg_type/progressive.yaml index de249654..756e71a7 100644 --- a/fastly/fixtures/image_optimizer_default_settings/set_jpeg_type/progressive.yaml +++ b/fastly/fixtures/image_optimizer_default_settings/set_jpeg_type/progressive.yaml @@ -11,7 +11,7 @@ interactions: - application/json User-Agent: - FastlyGo/9.3.1 (+github.com/fastly/go-fastly; go1.22.2) - url: https://api.fastly.com/service/qDAwPNSjDoCytjIZ6SfjF5/version/38/image_optimizer_default_settings + url: https://api.fastly.com/service/7i6HN3TK9wS159v2gPAZ8A/version/86/image_optimizer_default_settings method: PATCH response: body: '{"resize_filter":"nearest","webp":true,"webp_quality":42,"jpeg_type":"progressive","jpeg_quality":85,"upscale":true,"allow_video":false}' @@ -20,16 +20,14 @@ interactions: - bytes Cache-Control: - no-store - Connection: - - keep-alive Content-Type: - application/json Date: - - Fri, 19 Apr 2024 02:52:14 GMT + - Mon, 13 May 2024 21:27:44 GMT Fastly-Ratelimit-Remaining: - - "929" + - "980" Fastly-Ratelimit-Reset: - - "1713495600" + - "1715637600" Pragma: - no-cache Server: @@ -47,9 +45,9 @@ interactions: X-Cache-Hits: - "0" X-Served-By: - - cache-bfi-krnt7300112-BFI + - cache-bfi-krnt7300118-BFI X-Timer: - - S1713495134.451909,VS0,VE274 + - S1715635664.774726,VS0,VE351 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/image_optimizer_default_settings/set_resize_filter/bicubic.yaml b/fastly/fixtures/image_optimizer_default_settings/set_resize_filter/bicubic.yaml index bdb2cc1d..e11487a0 100644 --- a/fastly/fixtures/image_optimizer_default_settings/set_resize_filter/bicubic.yaml +++ b/fastly/fixtures/image_optimizer_default_settings/set_resize_filter/bicubic.yaml @@ -11,7 +11,7 @@ interactions: - application/json User-Agent: - FastlyGo/9.3.1 (+github.com/fastly/go-fastly; go1.22.2) - url: https://api.fastly.com/service/qDAwPNSjDoCytjIZ6SfjF5/version/38/image_optimizer_default_settings + url: https://api.fastly.com/service/7i6HN3TK9wS159v2gPAZ8A/version/86/image_optimizer_default_settings method: PATCH response: body: '{"resize_filter":"bicubic","webp":true,"webp_quality":42,"jpeg_type":"auto","jpeg_quality":85,"upscale":true,"allow_video":false}' @@ -20,16 +20,14 @@ interactions: - bytes Cache-Control: - no-store - Connection: - - keep-alive Content-Type: - application/json Date: - - Fri, 19 Apr 2024 02:52:13 GMT + - Mon, 13 May 2024 21:27:42 GMT Fastly-Ratelimit-Remaining: - - "934" + - "985" Fastly-Ratelimit-Reset: - - "1713495600" + - "1715637600" Pragma: - no-cache Server: @@ -47,9 +45,9 @@ interactions: X-Cache-Hits: - "0" X-Served-By: - - cache-bfi-krnt7300112-BFI + - cache-bfi-krnt7300118-BFI X-Timer: - - S1713495133.730258,VS0,VE304 + - S1715635662.724934,VS0,VE402 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/image_optimizer_default_settings/set_resize_filter/bilinear.yaml b/fastly/fixtures/image_optimizer_default_settings/set_resize_filter/bilinear.yaml index 5f4d75a0..265e8112 100644 --- a/fastly/fixtures/image_optimizer_default_settings/set_resize_filter/bilinear.yaml +++ b/fastly/fixtures/image_optimizer_default_settings/set_resize_filter/bilinear.yaml @@ -11,7 +11,7 @@ interactions: - application/json User-Agent: - FastlyGo/9.3.1 (+github.com/fastly/go-fastly; go1.22.2) - url: https://api.fastly.com/service/qDAwPNSjDoCytjIZ6SfjF5/version/38/image_optimizer_default_settings + url: https://api.fastly.com/service/7i6HN3TK9wS159v2gPAZ8A/version/86/image_optimizer_default_settings method: PATCH response: body: '{"resize_filter":"bilinear","webp":true,"webp_quality":42,"jpeg_type":"auto","jpeg_quality":85,"upscale":true,"allow_video":false}' @@ -20,16 +20,14 @@ interactions: - bytes Cache-Control: - no-store - Connection: - - keep-alive Content-Type: - application/json Date: - - Fri, 19 Apr 2024 02:52:13 GMT + - Mon, 13 May 2024 21:27:42 GMT Fastly-Ratelimit-Remaining: - - "933" + - "984" Fastly-Ratelimit-Reset: - - "1713495600" + - "1715637600" Pragma: - no-cache Server: @@ -47,9 +45,9 @@ interactions: X-Cache-Hits: - "0" X-Served-By: - - cache-bfi-krnt7300112-BFI + - cache-bfi-krnt7300118-BFI X-Timer: - - S1713495133.057831,VS0,VE345 + - S1715635662.140496,VS0,VE411 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/image_optimizer_default_settings/set_resize_filter/lanczos2.yaml b/fastly/fixtures/image_optimizer_default_settings/set_resize_filter/lanczos2.yaml index 88382007..af5b5f53 100644 --- a/fastly/fixtures/image_optimizer_default_settings/set_resize_filter/lanczos2.yaml +++ b/fastly/fixtures/image_optimizer_default_settings/set_resize_filter/lanczos2.yaml @@ -11,7 +11,7 @@ interactions: - application/json User-Agent: - FastlyGo/9.3.1 (+github.com/fastly/go-fastly; go1.22.2) - url: https://api.fastly.com/service/qDAwPNSjDoCytjIZ6SfjF5/version/38/image_optimizer_default_settings + url: https://api.fastly.com/service/7i6HN3TK9wS159v2gPAZ8A/version/86/image_optimizer_default_settings method: PATCH response: body: '{"resize_filter":"lanczos2","webp":true,"webp_quality":42,"jpeg_type":"auto","jpeg_quality":85,"upscale":true,"allow_video":false}' @@ -20,16 +20,14 @@ interactions: - bytes Cache-Control: - no-store - Connection: - - keep-alive Content-Type: - application/json Date: - - Fri, 19 Apr 2024 02:52:12 GMT + - Mon, 13 May 2024 21:27:41 GMT Fastly-Ratelimit-Remaining: - - "935" + - "986" Fastly-Ratelimit-Reset: - - "1713495600" + - "1715637600" Pragma: - no-cache Server: @@ -47,9 +45,9 @@ interactions: X-Cache-Hits: - "0" X-Served-By: - - cache-bfi-krnt7300112-BFI + - cache-bfi-krnt7300118-BFI X-Timer: - - S1713495132.481266,VS0,VE226 + - S1715635661.324109,VS0,VE281 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/image_optimizer_default_settings/set_resize_filter/lanczos3.yaml b/fastly/fixtures/image_optimizer_default_settings/set_resize_filter/lanczos3.yaml index bdc62a5d..d0157a4b 100644 --- a/fastly/fixtures/image_optimizer_default_settings/set_resize_filter/lanczos3.yaml +++ b/fastly/fixtures/image_optimizer_default_settings/set_resize_filter/lanczos3.yaml @@ -11,7 +11,7 @@ interactions: - application/json User-Agent: - FastlyGo/9.3.1 (+github.com/fastly/go-fastly; go1.22.2) - url: https://api.fastly.com/service/qDAwPNSjDoCytjIZ6SfjF5/version/38/image_optimizer_default_settings + url: https://api.fastly.com/service/7i6HN3TK9wS159v2gPAZ8A/version/86/image_optimizer_default_settings method: PATCH response: body: '{"resize_filter":"lanczos3","webp":true,"webp_quality":42,"jpeg_type":"auto","jpeg_quality":85,"upscale":true,"allow_video":false}' @@ -20,16 +20,14 @@ interactions: - bytes Cache-Control: - no-store - Connection: - - keep-alive Content-Type: - application/json Date: - - Fri, 19 Apr 2024 02:52:12 GMT + - Mon, 13 May 2024 21:27:41 GMT Fastly-Ratelimit-Remaining: - - "936" + - "987" Fastly-Ratelimit-Reset: - - "1713495600" + - "1715637600" Pragma: - no-cache Server: @@ -47,9 +45,9 @@ interactions: X-Cache-Hits: - "0" X-Served-By: - - cache-bfi-krnt7300112-BFI + - cache-bfi-krnt7300118-BFI X-Timer: - - S1713495132.224587,VS0,VE239 + - S1715635661.967136,VS0,VE345 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/image_optimizer_default_settings/set_resize_filter/nearest.yaml b/fastly/fixtures/image_optimizer_default_settings/set_resize_filter/nearest.yaml index 2252aab7..be29e8ac 100644 --- a/fastly/fixtures/image_optimizer_default_settings/set_resize_filter/nearest.yaml +++ b/fastly/fixtures/image_optimizer_default_settings/set_resize_filter/nearest.yaml @@ -11,7 +11,7 @@ interactions: - application/json User-Agent: - FastlyGo/9.3.1 (+github.com/fastly/go-fastly; go1.22.2) - url: https://api.fastly.com/service/qDAwPNSjDoCytjIZ6SfjF5/version/38/image_optimizer_default_settings + url: https://api.fastly.com/service/7i6HN3TK9wS159v2gPAZ8A/version/86/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}' @@ -20,16 +20,14 @@ interactions: - bytes Cache-Control: - no-store - Connection: - - keep-alive Content-Type: - application/json Date: - - Fri, 19 Apr 2024 02:52:13 GMT + - Mon, 13 May 2024 21:27:42 GMT Fastly-Ratelimit-Remaining: - - "932" + - "983" Fastly-Ratelimit-Reset: - - "1713495600" + - "1715637600" Pragma: - no-cache Server: @@ -47,9 +45,9 @@ interactions: X-Cache-Hits: - "0" X-Served-By: - - cache-bfi-krnt7300112-BFI + - cache-bfi-krnt7300118-BFI X-Timer: - - S1713495133.431590,VS0,VE334 + - S1715635663.652577,VS0,VE303 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/image_optimizer_default_settings/update_1_get.yaml b/fastly/fixtures/image_optimizer_default_settings/update_1_get.yaml index 30420330..9d6558f2 100644 --- a/fastly/fixtures/image_optimizer_default_settings/update_1_get.yaml +++ b/fastly/fixtures/image_optimizer_default_settings/update_1_get.yaml @@ -7,7 +7,7 @@ interactions: headers: User-Agent: - FastlyGo/9.3.1 (+github.com/fastly/go-fastly; go1.22.2) - url: https://api.fastly.com/service/qDAwPNSjDoCytjIZ6SfjF5/version/38/image_optimizer_default_settings + url: https://api.fastly.com/service/7i6HN3TK9wS159v2gPAZ8A/version/86/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}' @@ -16,12 +16,10 @@ interactions: - bytes Cache-Control: - no-store - Connection: - - keep-alive Content-Type: - application/json Date: - - Fri, 19 Apr 2024 02:52:11 GMT + - Mon, 13 May 2024 21:27:40 GMT Pragma: - no-cache Server: @@ -39,9 +37,9 @@ interactions: X-Cache-Hits: - "0" X-Served-By: - - cache-bfi-krnt7300112-BFI + - cache-bfi-krnt7300118-BFI X-Timer: - - S1713495131.397009,VS0,VE136 + - S1715635660.942200,VS0,VE180 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/image_optimizer_default_settings/update_1_patch.yaml b/fastly/fixtures/image_optimizer_default_settings/update_1_patch.yaml index 0055ccde..cf8a068b 100644 --- a/fastly/fixtures/image_optimizer_default_settings/update_1_patch.yaml +++ b/fastly/fixtures/image_optimizer_default_settings/update_1_patch.yaml @@ -11,7 +11,7 @@ interactions: - application/json User-Agent: - FastlyGo/9.3.1 (+github.com/fastly/go-fastly; go1.22.2) - url: https://api.fastly.com/service/qDAwPNSjDoCytjIZ6SfjF5/version/38/image_optimizer_default_settings + url: https://api.fastly.com/service/7i6HN3TK9wS159v2gPAZ8A/version/86/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}' @@ -20,16 +20,14 @@ interactions: - bytes Cache-Control: - no-store - Connection: - - keep-alive Content-Type: - application/json Date: - - Fri, 19 Apr 2024 02:52:11 GMT + - Mon, 13 May 2024 21:27:39 GMT Fastly-Ratelimit-Remaining: - - "939" + - "990" Fastly-Ratelimit-Reset: - - "1713495600" + - "1715637600" Pragma: - no-cache Server: @@ -47,9 +45,9 @@ interactions: X-Cache-Hits: - "0" X-Served-By: - - cache-bfi-krnt7300112-BFI + - cache-bfi-krnt7300118-BFI X-Timer: - - S1713495131.125925,VS0,VE256 + - S1715635660.573008,VS0,VE355 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/image_optimizer_default_settings/update_2_get.yaml b/fastly/fixtures/image_optimizer_default_settings/update_2_get.yaml index 20cd73d1..ea6df489 100644 --- a/fastly/fixtures/image_optimizer_default_settings/update_2_get.yaml +++ b/fastly/fixtures/image_optimizer_default_settings/update_2_get.yaml @@ -7,7 +7,7 @@ interactions: headers: User-Agent: - FastlyGo/9.3.1 (+github.com/fastly/go-fastly; go1.22.2) - url: https://api.fastly.com/service/qDAwPNSjDoCytjIZ6SfjF5/version/38/image_optimizer_default_settings + url: https://api.fastly.com/service/7i6HN3TK9wS159v2gPAZ8A/version/86/image_optimizer_default_settings method: GET response: body: '{"resize_filter":"lanczos3","webp":true,"webp_quality":42,"jpeg_type":"auto","jpeg_quality":85,"upscale":true,"allow_video":false}' @@ -16,12 +16,10 @@ interactions: - bytes Cache-Control: - no-store - Connection: - - keep-alive Content-Type: - application/json Date: - - Fri, 19 Apr 2024 02:52:12 GMT + - Mon, 13 May 2024 21:27:40 GMT Pragma: - no-cache Server: @@ -39,9 +37,9 @@ interactions: X-Cache-Hits: - "0" X-Served-By: - - cache-bfi-krnt7300112-BFI + - cache-bfi-krnt7300118-BFI X-Timer: - - S1713495132.856072,VS0,VE180 + - S1715635660.487457,VS0,VE215 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/image_optimizer_default_settings/update_2_patch.yaml b/fastly/fixtures/image_optimizer_default_settings/update_2_patch.yaml index 2a61484d..ba16f9da 100644 --- a/fastly/fixtures/image_optimizer_default_settings/update_2_patch.yaml +++ b/fastly/fixtures/image_optimizer_default_settings/update_2_patch.yaml @@ -11,7 +11,7 @@ interactions: - application/json User-Agent: - FastlyGo/9.3.1 (+github.com/fastly/go-fastly; go1.22.2) - url: https://api.fastly.com/service/qDAwPNSjDoCytjIZ6SfjF5/version/38/image_optimizer_default_settings + url: https://api.fastly.com/service/7i6HN3TK9wS159v2gPAZ8A/version/86/image_optimizer_default_settings method: PATCH response: body: '{"resize_filter":"lanczos3","webp":true,"webp_quality":42,"jpeg_type":"auto","jpeg_quality":85,"upscale":true,"allow_video":false}' @@ -20,16 +20,14 @@ interactions: - bytes Cache-Control: - no-store - Connection: - - keep-alive Content-Type: - application/json Date: - - Fri, 19 Apr 2024 02:52:11 GMT + - Mon, 13 May 2024 21:27:40 GMT Fastly-Ratelimit-Remaining: - - "938" + - "989" Fastly-Ratelimit-Reset: - - "1713495600" + - "1715637600" Pragma: - no-cache Server: @@ -47,9 +45,9 @@ interactions: X-Cache-Hits: - "0" X-Served-By: - - cache-bfi-krnt7300112-BFI + - cache-bfi-krnt7300118-BFI X-Timer: - - S1713495132.550616,VS0,VE286 + - S1715635660.152170,VS0,VE304 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/image_optimizer_default_settings/version.yaml b/fastly/fixtures/image_optimizer_default_settings/version.yaml index fcdc9397..8d31660f 100644 --- a/fastly/fixtures/image_optimizer_default_settings/version.yaml +++ b/fastly/fixtures/image_optimizer_default_settings/version.yaml @@ -9,25 +9,23 @@ interactions: - application/x-www-form-urlencoded User-Agent: - FastlyGo/9.3.1 (+github.com/fastly/go-fastly; go1.22.2) - url: https://api.fastly.com/service/qDAwPNSjDoCytjIZ6SfjF5/version + url: https://api.fastly.com/service/7i6HN3TK9wS159v2gPAZ8A/version method: POST response: - body: '{"service_id":"qDAwPNSjDoCytjIZ6SfjF5","number":38}' + body: '{"service_id":"7i6HN3TK9wS159v2gPAZ8A","number":86}' headers: Accept-Ranges: - bytes Cache-Control: - no-store - Connection: - - keep-alive Content-Type: - application/json Date: - - Fri, 19 Apr 2024 02:52:09 GMT + - Mon, 13 May 2024 21:27:37 GMT Fastly-Ratelimit-Remaining: - - "940" + - "991" Fastly-Ratelimit-Reset: - - "1713495600" + - "1715637600" Pragma: - no-cache Server: @@ -45,9 +43,9 @@ interactions: X-Cache-Hits: - "0" X-Served-By: - - cache-bfi-krnt7300112-BFI + - cache-bfi-krnt7300118-BFI X-Timer: - - S1713495129.491623,VS0,VE255 + - S1715635657.443280,VS0,VE466 status: 200 OK code: 200 duration: "" From 59f3ddbe997bfe2092f14b9eae3f99190d0f383a Mon Sep 17 00:00:00 2001 From: Dabo Ross Date: Tue, 14 May 2024 09:13:13 -0700 Subject: [PATCH 09/13] Fix image_optimizer_default_settings enum constant names --- fastly/image_optimizer_default_settings.go | 32 +++++++++---------- .../image_optimizer_default_settings_test.go | 8 ++--- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/fastly/image_optimizer_default_settings.go b/fastly/image_optimizer_default_settings.go index 6a7ed7d2..ff75a3ea 100644 --- a/fastly/image_optimizer_default_settings.go +++ b/fastly/image_optimizer_default_settings.go @@ -10,15 +10,15 @@ type ResizeFilter int64 func (r ResizeFilter) String() string { switch r { - case Lanczos3: + case ImageOptoLanczos3: return "lanczos3" - case Lanczos2: + case ImageOptoLanczos2: return "lanczos2" - case Bicubic: + case ImageOptoBicubic: return "bicubic" - case Bilinear: + case ImageOptoBilinear: return "bilinear" - case Nearest: + case ImageOptoNearest: return "nearest" } return "lanczos3" // default @@ -30,15 +30,15 @@ func (r ResizeFilter) MarshalJSON() ([]byte, error) { const ( // A Lanczos filter with a kernel size of 3. Lanczos filters can detect edges and linear features within an image, providing the best possible reconstruction. - Lanczos3 ResizeFilter = iota + ImageOptoLanczos3 ResizeFilter = iota // A Lanczos filter with a kernel size of 2. - Lanczos2 + ImageOptoLanczos2 // A filter using an average of a 4x4 environment of pixels, weighing the innermost pixels higher. - Bicubic + ImageOptoBicubic // A filter using an average of a 2x2 environment of pixels. - Bilinear + ImageOptoBilinear // A filter using the value of nearby translated pixel values. Preserves hard edges. - Nearest + ImageOptoNearest ) // JpegType is a base for different JpegType variants @@ -46,11 +46,11 @@ type JpegType int64 func (r JpegType) String() string { switch r { - case Auto: + case ImageOptoAuto: return "auto" - case Baseline: + case ImageOptoBaseline: return "baseline" - case Progressive: + case ImageOptoProgressive: return "progressive" } return "auto" // default @@ -62,11 +62,11 @@ func (r JpegType) MarshalJSON() ([]byte, error) { const ( // Match the input JPEG type, or baseline if transforming from a non-JPEG input. - Auto JpegType = iota + ImageOptoAuto JpegType = iota // Output baseline JPEG images - Baseline + ImageOptoBaseline // Output progressive JPEG images - Progressive + ImageOptoProgressive ) // ImageOptimizerDefaultSettings represents the returned Image Optimizer default settings for a given service. diff --git a/fastly/image_optimizer_default_settings_test.go b/fastly/image_optimizer_default_settings_test.go index 159383b9..f2cdba5d 100644 --- a/fastly/image_optimizer_default_settings_test.go +++ b/fastly/image_optimizer_default_settings_test.go @@ -197,7 +197,7 @@ func TestClient_ImageOptimizerDefaultSettings(t *testing.T) { } // Confirm all resize_filter & jpeg_type values are accepted - for _, resizeFilter := range []ResizeFilter{Lanczos3, Lanczos2, Bicubic, Bilinear, Nearest} { + for _, resizeFilter := range []ResizeFilter{ImageOptoLanczos3, ImageOptoLanczos2, ImageOptoBicubic, ImageOptoBilinear, ImageOptoNearest} { record(t, fixtureBase+"set_resize_filter/"+resizeFilter.String(), func(c *Client) { defaultSettings, err = c.UpdateImageOptimizerDefaultSettings(&UpdateImageOptimizerDefaultSettingsInput{ ServiceID: testServiceID, @@ -210,7 +210,7 @@ func TestClient_ImageOptimizerDefaultSettings(t *testing.T) { } } - for _, jpegType := range []JpegType{Auto, Baseline, Progressive} { + for _, jpegType := range []JpegType{ImageOptoAuto, ImageOptoBaseline, ImageOptoProgressive} { record(t, fixtureBase+"set_jpeg_type/"+jpegType.String(), func(c *Client) { defaultSettings, err = c.UpdateImageOptimizerDefaultSettings(&UpdateImageOptimizerDefaultSettingsInput{ ServiceID: testServiceID, @@ -228,10 +228,10 @@ func TestClient_ImageOptimizerDefaultSettings(t *testing.T) { defaultSettings, err = c.UpdateImageOptimizerDefaultSettings(&UpdateImageOptimizerDefaultSettingsInput{ ServiceID: testServiceID, ServiceVersion: *testVersion.Number, - ResizeFilter: ToPointer(Lanczos3), + ResizeFilter: ToPointer(ImageOptoLanczos3), Webp: ToPointer(false), WebpQuality: ToPointer(85), - JpegType: ToPointer(Auto), + JpegType: ToPointer(ImageOptoAuto), JpegQuality: ToPointer(85), Upscale: ToPointer(false), AllowVideo: ToPointer(false), From 005601ae4333d139ead37a5ca9ac738603436493 Mon Sep 17 00:00:00 2001 From: Dabo Ross Date: Tue, 14 May 2024 09:14:58 -0700 Subject: [PATCH 10/13] Replace commented lines in test deferred reset. --- fastly/image_optimizer_default_settings_test.go | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/fastly/image_optimizer_default_settings_test.go b/fastly/image_optimizer_default_settings_test.go index f2cdba5d..1b06ba97 100644 --- a/fastly/image_optimizer_default_settings_test.go +++ b/fastly/image_optimizer_default_settings_test.go @@ -65,13 +65,15 @@ func TestClient_ImageOptimizerDefaultSettings(t *testing.T) { _, err = c.UpdateImageOptimizerDefaultSettings(&UpdateImageOptimizerDefaultSettingsInput{ ServiceID: testServiceID, ServiceVersion: *testVersion.Number, - // ResizeFilter: &originalSettings.ResizeFilter, - Webp: &originalSettings.Webp, - WebpQuality: &originalSettings.WebpQuality, - // JpegType: &originalSettings.JpegType, - JpegQuality: &originalSettings.JpegQuality, - Upscale: &originalSettings.Upscale, - AllowVideo: &originalSettings.AllowVideo, + // just use default resizefilter & jpegtype since it doesn't matter much, and it's annoying + // to parse the API output strings back into enums. + ResizeFilter: ToPointer(ImageOptoNearest), + Webp: &originalSettings.Webp, + WebpQuality: &originalSettings.WebpQuality, + JpegType: ToPointer(ImageOptoAuto), + JpegQuality: &originalSettings.JpegQuality, + Upscale: &originalSettings.Upscale, + AllowVideo: &originalSettings.AllowVideo, }) } }) From 811acaceec6f781a99c2e225826bb3e6a05f1837 Mon Sep 17 00:00:00 2001 From: Dabo Ross Date: Tue, 14 May 2024 09:17:08 -0700 Subject: [PATCH 11/13] Update fixtures again. --- .../disable_product.yaml | 8 ++++---- .../enable_product.yaml | 8 ++++---- .../final_reset.yaml | 18 +++++++++--------- .../incorrect_fetch.yaml | 14 +++++++------- .../original_fetch.yaml | 10 +++++----- .../set_full.yaml | 14 +++++++------- .../set_jpeg_type/auto.yaml | 14 +++++++------- .../set_jpeg_type/baseline.yaml | 14 +++++++------- .../set_jpeg_type/progressive.yaml | 14 +++++++------- .../set_resize_filter/bicubic.yaml | 14 +++++++------- .../set_resize_filter/bilinear.yaml | 14 +++++++------- .../set_resize_filter/lanczos2.yaml | 14 +++++++------- .../set_resize_filter/lanczos3.yaml | 14 +++++++------- .../set_resize_filter/nearest.yaml | 14 +++++++------- .../update_1_get.yaml | 10 +++++----- .../update_1_patch.yaml | 14 +++++++------- .../update_2_get.yaml | 10 +++++----- .../update_2_patch.yaml | 14 +++++++------- .../version.yaml | 14 +++++++------- 19 files changed, 123 insertions(+), 123 deletions(-) diff --git a/fastly/fixtures/image_optimizer_default_settings/disable_product.yaml b/fastly/fixtures/image_optimizer_default_settings/disable_product.yaml index ade5167e..b3d889ed 100644 --- a/fastly/fixtures/image_optimizer_default_settings/disable_product.yaml +++ b/fastly/fixtures/image_optimizer_default_settings/disable_product.yaml @@ -6,7 +6,7 @@ interactions: form: {} headers: User-Agent: - - FastlyGo/9.3.1 (+github.com/fastly/go-fastly; go1.22.2) + - 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: @@ -19,7 +19,7 @@ interactions: Content-Type: - application/json Date: - - Mon, 13 May 2024 21:27:45 GMT + - Tue, 14 May 2024 16:16:36 GMT Pragma: - no-cache Server: @@ -37,9 +37,9 @@ interactions: X-Cache-Hits: - "0" X-Served-By: - - cache-bfi-krnt7300118-BFI + - cache-bfi-krnt7300110-BFI X-Timer: - - S1715635665.011325,VS0,VE856 + - S1715703395.638107,VS0,VE1368 status: 204 No Content code: 204 duration: "" diff --git a/fastly/fixtures/image_optimizer_default_settings/enable_product.yaml b/fastly/fixtures/image_optimizer_default_settings/enable_product.yaml index a37cd60d..3188ed72 100644 --- a/fastly/fixtures/image_optimizer_default_settings/enable_product.yaml +++ b/fastly/fixtures/image_optimizer_default_settings/enable_product.yaml @@ -12,7 +12,7 @@ interactions: Content-Type: - application/x-www-form-urlencoded User-Agent: - - FastlyGo/9.3.1 (+github.com/fastly/go-fastly; go1.22.2) + - 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: @@ -28,7 +28,7 @@ interactions: Content-Type: - application/json Date: - - Mon, 13 May 2024 21:27:39 GMT + - Tue, 14 May 2024 16:16:29 GMT Pragma: - no-cache Server: @@ -46,9 +46,9 @@ interactions: X-Cache-Hits: - "0" X-Served-By: - - cache-bfi-krnt7300118-BFI + - cache-bfi-krnt7300110-BFI X-Timer: - - S1715635658.927563,VS0,VE1264 + - S1715703388.864441,VS0,VE1596 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/image_optimizer_default_settings/final_reset.yaml b/fastly/fixtures/image_optimizer_default_settings/final_reset.yaml index b17f3f25..0287df5c 100644 --- a/fastly/fixtures/image_optimizer_default_settings/final_reset.yaml +++ b/fastly/fixtures/image_optimizer_default_settings/final_reset.yaml @@ -2,7 +2,7 @@ version: 1 interactions: - request: - body: '{"webp":false,"webp_quality":85,"jpeg_quality":85,"upscale":false,"allow_video":false}' + body: '{"resize_filter":"nearest","webp":false,"webp_quality":85,"jpeg_type":"auto","jpeg_quality":85,"upscale":false,"allow_video":false}' form: {} headers: Accept: @@ -10,11 +10,11 @@ interactions: Content-Type: - application/json User-Agent: - - FastlyGo/9.3.1 (+github.com/fastly/go-fastly; go1.22.2) - url: https://api.fastly.com/service/7i6HN3TK9wS159v2gPAZ8A/version/86/image_optimizer_default_settings + - 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}' + body: '{"resize_filter":"nearest","webp":false,"webp_quality":85,"jpeg_type":"auto","jpeg_quality":85,"upscale":false,"allow_video":false}' headers: Accept-Ranges: - bytes @@ -23,11 +23,11 @@ interactions: Content-Type: - application/json Date: - - Mon, 13 May 2024 21:27:44 GMT + - Tue, 14 May 2024 16:16:34 GMT Fastly-Ratelimit-Remaining: - - "978" + - "986" Fastly-Ratelimit-Reset: - - "1715637600" + - "1715706000" Pragma: - no-cache Server: @@ -45,9 +45,9 @@ interactions: X-Cache-Hits: - "0" X-Served-By: - - cache-bfi-krnt7300118-BFI + - cache-bfi-krnt7300110-BFI X-Timer: - - S1715635665.681277,VS0,VE319 + - S1715703394.322383,VS0,VE301 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/image_optimizer_default_settings/incorrect_fetch.yaml b/fastly/fixtures/image_optimizer_default_settings/incorrect_fetch.yaml index 6233cc8a..2342ffa8 100644 --- a/fastly/fixtures/image_optimizer_default_settings/incorrect_fetch.yaml +++ b/fastly/fixtures/image_optimizer_default_settings/incorrect_fetch.yaml @@ -10,8 +10,8 @@ interactions: Content-Type: - application/json User-Agent: - - FastlyGo/9.3.1 (+github.com/fastly/go-fastly; go1.22.2) - url: https://api.fastly.com/service/7i6HN3TK9wS159v2gPAZ8A/version/86/image_optimizer_default_settings + - 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 @@ -24,11 +24,11 @@ interactions: Content-Type: - application/problem+json Date: - - Mon, 13 May 2024 21:27:40 GMT + - Tue, 14 May 2024 16:16:31 GMT Fastly-Ratelimit-Remaining: - - "988" + - "996" Fastly-Ratelimit-Reset: - - "1715637600" + - "1715706000" Pragma: - no-cache Server: @@ -46,9 +46,9 @@ interactions: X-Cache-Hits: - "0" X-Served-By: - - cache-bfi-krnt7300118-BFI + - cache-bfi-krnt7300110-BFI X-Timer: - - S1715635661.735633,VS0,VE196 + - S1715703391.172090,VS0,VE235 status: 400 Bad Request code: 400 duration: "" diff --git a/fastly/fixtures/image_optimizer_default_settings/original_fetch.yaml b/fastly/fixtures/image_optimizer_default_settings/original_fetch.yaml index 3af9a1bd..e58c3c02 100644 --- a/fastly/fixtures/image_optimizer_default_settings/original_fetch.yaml +++ b/fastly/fixtures/image_optimizer_default_settings/original_fetch.yaml @@ -6,8 +6,8 @@ interactions: form: {} headers: User-Agent: - - FastlyGo/9.3.1 (+github.com/fastly/go-fastly; go1.22.2) - url: https://api.fastly.com/service/7i6HN3TK9wS159v2gPAZ8A/version/86/image_optimizer_default_settings + - 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}' @@ -19,7 +19,7 @@ interactions: Content-Type: - application/json Date: - - Mon, 13 May 2024 21:27:39 GMT + - Tue, 14 May 2024 16:16:29 GMT Pragma: - no-cache Server: @@ -37,9 +37,9 @@ interactions: X-Cache-Hits: - "0" X-Served-By: - - cache-bfi-krnt7300118-BFI + - cache-bfi-krnt7300110-BFI X-Timer: - - S1715635659.213525,VS0,VE330 + - S1715703390.548942,VS0,VE308 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/image_optimizer_default_settings/set_full.yaml b/fastly/fixtures/image_optimizer_default_settings/set_full.yaml index 21dd0a9f..7a1676af 100644 --- a/fastly/fixtures/image_optimizer_default_settings/set_full.yaml +++ b/fastly/fixtures/image_optimizer_default_settings/set_full.yaml @@ -10,8 +10,8 @@ interactions: Content-Type: - application/json User-Agent: - - FastlyGo/9.3.1 (+github.com/fastly/go-fastly; go1.22.2) - url: https://api.fastly.com/service/7i6HN3TK9wS159v2gPAZ8A/version/86/image_optimizer_default_settings + - 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}' @@ -23,11 +23,11 @@ interactions: Content-Type: - application/json Date: - - Mon, 13 May 2024 21:27:44 GMT + - Tue, 14 May 2024 16:16:34 GMT Fastly-Ratelimit-Remaining: - - "979" + - "987" Fastly-Ratelimit-Reset: - - "1715637600" + - "1715706000" Pragma: - no-cache Server: @@ -45,9 +45,9 @@ interactions: X-Cache-Hits: - "0" X-Served-By: - - cache-bfi-krnt7300118-BFI + - cache-bfi-krnt7300110-BFI X-Timer: - - S1715635664.186982,VS0,VE392 + - S1715703394.881247,VS0,VE425 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/image_optimizer_default_settings/set_jpeg_type/auto.yaml b/fastly/fixtures/image_optimizer_default_settings/set_jpeg_type/auto.yaml index 36830721..e6f738bc 100644 --- a/fastly/fixtures/image_optimizer_default_settings/set_jpeg_type/auto.yaml +++ b/fastly/fixtures/image_optimizer_default_settings/set_jpeg_type/auto.yaml @@ -10,8 +10,8 @@ interactions: Content-Type: - application/json User-Agent: - - FastlyGo/9.3.1 (+github.com/fastly/go-fastly; go1.22.2) - url: https://api.fastly.com/service/7i6HN3TK9wS159v2gPAZ8A/version/86/image_optimizer_default_settings + - 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}' @@ -23,11 +23,11 @@ interactions: Content-Type: - application/json Date: - - Mon, 13 May 2024 21:27:43 GMT + - Tue, 14 May 2024 16:16:33 GMT Fastly-Ratelimit-Remaining: - - "982" + - "990" Fastly-Ratelimit-Reset: - - "1715637600" + - "1715706000" Pragma: - no-cache Server: @@ -45,9 +45,9 @@ interactions: X-Cache-Hits: - "0" X-Served-By: - - cache-bfi-krnt7300118-BFI + - cache-bfi-krnt7300110-BFI X-Timer: - - S1715635663.973275,VS0,VE274 + - S1715703393.016316,VS0,VE239 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/image_optimizer_default_settings/set_jpeg_type/baseline.yaml b/fastly/fixtures/image_optimizer_default_settings/set_jpeg_type/baseline.yaml index f7692003..af682ee3 100644 --- a/fastly/fixtures/image_optimizer_default_settings/set_jpeg_type/baseline.yaml +++ b/fastly/fixtures/image_optimizer_default_settings/set_jpeg_type/baseline.yaml @@ -10,8 +10,8 @@ interactions: Content-Type: - application/json User-Agent: - - FastlyGo/9.3.1 (+github.com/fastly/go-fastly; go1.22.2) - url: https://api.fastly.com/service/7i6HN3TK9wS159v2gPAZ8A/version/86/image_optimizer_default_settings + - 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":"baseline","jpeg_quality":85,"upscale":true,"allow_video":false}' @@ -23,11 +23,11 @@ interactions: Content-Type: - application/json Date: - - Mon, 13 May 2024 21:27:43 GMT + - Tue, 14 May 2024 16:16:33 GMT Fastly-Ratelimit-Remaining: - - "981" + - "989" Fastly-Ratelimit-Reset: - - "1715637600" + - "1715706000" Pragma: - no-cache Server: @@ -45,9 +45,9 @@ interactions: X-Cache-Hits: - "0" X-Served-By: - - cache-bfi-krnt7300118-BFI + - cache-bfi-krnt7300110-BFI X-Timer: - - S1715635663.364952,VS0,VE309 + - S1715703393.270782,VS0,VE295 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/image_optimizer_default_settings/set_jpeg_type/progressive.yaml b/fastly/fixtures/image_optimizer_default_settings/set_jpeg_type/progressive.yaml index 756e71a7..9f7ea073 100644 --- a/fastly/fixtures/image_optimizer_default_settings/set_jpeg_type/progressive.yaml +++ b/fastly/fixtures/image_optimizer_default_settings/set_jpeg_type/progressive.yaml @@ -10,8 +10,8 @@ interactions: Content-Type: - application/json User-Agent: - - FastlyGo/9.3.1 (+github.com/fastly/go-fastly; go1.22.2) - url: https://api.fastly.com/service/7i6HN3TK9wS159v2gPAZ8A/version/86/image_optimizer_default_settings + - 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":"progressive","jpeg_quality":85,"upscale":true,"allow_video":false}' @@ -23,11 +23,11 @@ interactions: Content-Type: - application/json Date: - - Mon, 13 May 2024 21:27:44 GMT + - Tue, 14 May 2024 16:16:33 GMT Fastly-Ratelimit-Remaining: - - "980" + - "988" Fastly-Ratelimit-Reset: - - "1715637600" + - "1715706000" Pragma: - no-cache Server: @@ -45,9 +45,9 @@ interactions: X-Cache-Hits: - "0" X-Served-By: - - cache-bfi-krnt7300118-BFI + - cache-bfi-krnt7300110-BFI X-Timer: - - S1715635664.774726,VS0,VE351 + - S1715703394.581626,VS0,VE257 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/image_optimizer_default_settings/set_resize_filter/bicubic.yaml b/fastly/fixtures/image_optimizer_default_settings/set_resize_filter/bicubic.yaml index e11487a0..85330b54 100644 --- a/fastly/fixtures/image_optimizer_default_settings/set_resize_filter/bicubic.yaml +++ b/fastly/fixtures/image_optimizer_default_settings/set_resize_filter/bicubic.yaml @@ -10,8 +10,8 @@ interactions: Content-Type: - application/json User-Agent: - - FastlyGo/9.3.1 (+github.com/fastly/go-fastly; go1.22.2) - url: https://api.fastly.com/service/7i6HN3TK9wS159v2gPAZ8A/version/86/image_optimizer_default_settings + - 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":"bicubic","webp":true,"webp_quality":42,"jpeg_type":"auto","jpeg_quality":85,"upscale":true,"allow_video":false}' @@ -23,11 +23,11 @@ interactions: Content-Type: - application/json Date: - - Mon, 13 May 2024 21:27:42 GMT + - Tue, 14 May 2024 16:16:32 GMT Fastly-Ratelimit-Remaining: - - "985" + - "993" Fastly-Ratelimit-Reset: - - "1715637600" + - "1715706000" Pragma: - no-cache Server: @@ -45,9 +45,9 @@ interactions: X-Cache-Hits: - "0" X-Served-By: - - cache-bfi-krnt7300118-BFI + - cache-bfi-krnt7300110-BFI X-Timer: - - S1715635662.724934,VS0,VE402 + - S1715703392.111690,VS0,VE297 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/image_optimizer_default_settings/set_resize_filter/bilinear.yaml b/fastly/fixtures/image_optimizer_default_settings/set_resize_filter/bilinear.yaml index 265e8112..79b58e25 100644 --- a/fastly/fixtures/image_optimizer_default_settings/set_resize_filter/bilinear.yaml +++ b/fastly/fixtures/image_optimizer_default_settings/set_resize_filter/bilinear.yaml @@ -10,8 +10,8 @@ interactions: Content-Type: - application/json User-Agent: - - FastlyGo/9.3.1 (+github.com/fastly/go-fastly; go1.22.2) - url: https://api.fastly.com/service/7i6HN3TK9wS159v2gPAZ8A/version/86/image_optimizer_default_settings + - 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":"bilinear","webp":true,"webp_quality":42,"jpeg_type":"auto","jpeg_quality":85,"upscale":true,"allow_video":false}' @@ -23,11 +23,11 @@ interactions: Content-Type: - application/json Date: - - Mon, 13 May 2024 21:27:42 GMT + - Tue, 14 May 2024 16:16:32 GMT Fastly-Ratelimit-Remaining: - - "984" + - "992" Fastly-Ratelimit-Reset: - - "1715637600" + - "1715706000" Pragma: - no-cache Server: @@ -45,9 +45,9 @@ interactions: X-Cache-Hits: - "0" X-Served-By: - - cache-bfi-krnt7300118-BFI + - cache-bfi-krnt7300110-BFI X-Timer: - - S1715635662.140496,VS0,VE411 + - S1715703392.422974,VS0,VE295 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/image_optimizer_default_settings/set_resize_filter/lanczos2.yaml b/fastly/fixtures/image_optimizer_default_settings/set_resize_filter/lanczos2.yaml index af5b5f53..519f99df 100644 --- a/fastly/fixtures/image_optimizer_default_settings/set_resize_filter/lanczos2.yaml +++ b/fastly/fixtures/image_optimizer_default_settings/set_resize_filter/lanczos2.yaml @@ -10,8 +10,8 @@ interactions: Content-Type: - application/json User-Agent: - - FastlyGo/9.3.1 (+github.com/fastly/go-fastly; go1.22.2) - url: https://api.fastly.com/service/7i6HN3TK9wS159v2gPAZ8A/version/86/image_optimizer_default_settings + - 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":"lanczos2","webp":true,"webp_quality":42,"jpeg_type":"auto","jpeg_quality":85,"upscale":true,"allow_video":false}' @@ -23,11 +23,11 @@ interactions: Content-Type: - application/json Date: - - Mon, 13 May 2024 21:27:41 GMT + - Tue, 14 May 2024 16:16:32 GMT Fastly-Ratelimit-Remaining: - - "986" + - "994" Fastly-Ratelimit-Reset: - - "1715637600" + - "1715706000" Pragma: - no-cache Server: @@ -45,9 +45,9 @@ interactions: X-Cache-Hits: - "0" X-Served-By: - - cache-bfi-krnt7300118-BFI + - cache-bfi-krnt7300110-BFI X-Timer: - - S1715635661.324109,VS0,VE281 + - S1715703392.734838,VS0,VE362 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/image_optimizer_default_settings/set_resize_filter/lanczos3.yaml b/fastly/fixtures/image_optimizer_default_settings/set_resize_filter/lanczos3.yaml index d0157a4b..b6f62627 100644 --- a/fastly/fixtures/image_optimizer_default_settings/set_resize_filter/lanczos3.yaml +++ b/fastly/fixtures/image_optimizer_default_settings/set_resize_filter/lanczos3.yaml @@ -10,8 +10,8 @@ interactions: Content-Type: - application/json User-Agent: - - FastlyGo/9.3.1 (+github.com/fastly/go-fastly; go1.22.2) - url: https://api.fastly.com/service/7i6HN3TK9wS159v2gPAZ8A/version/86/image_optimizer_default_settings + - 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":true,"webp_quality":42,"jpeg_type":"auto","jpeg_quality":85,"upscale":true,"allow_video":false}' @@ -23,11 +23,11 @@ interactions: Content-Type: - application/json Date: - - Mon, 13 May 2024 21:27:41 GMT + - Tue, 14 May 2024 16:16:31 GMT Fastly-Ratelimit-Remaining: - - "987" + - "995" Fastly-Ratelimit-Reset: - - "1715637600" + - "1715706000" Pragma: - no-cache Server: @@ -45,9 +45,9 @@ interactions: X-Cache-Hits: - "0" X-Served-By: - - cache-bfi-krnt7300118-BFI + - cache-bfi-krnt7300110-BFI X-Timer: - - S1715635661.967136,VS0,VE345 + - S1715703391.424341,VS0,VE294 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/image_optimizer_default_settings/set_resize_filter/nearest.yaml b/fastly/fixtures/image_optimizer_default_settings/set_resize_filter/nearest.yaml index be29e8ac..cfdef9de 100644 --- a/fastly/fixtures/image_optimizer_default_settings/set_resize_filter/nearest.yaml +++ b/fastly/fixtures/image_optimizer_default_settings/set_resize_filter/nearest.yaml @@ -10,8 +10,8 @@ interactions: Content-Type: - application/json User-Agent: - - FastlyGo/9.3.1 (+github.com/fastly/go-fastly; go1.22.2) - url: https://api.fastly.com/service/7i6HN3TK9wS159v2gPAZ8A/version/86/image_optimizer_default_settings + - 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}' @@ -23,11 +23,11 @@ interactions: Content-Type: - application/json Date: - - Mon, 13 May 2024 21:27:42 GMT + - Tue, 14 May 2024 16:16:33 GMT Fastly-Ratelimit-Remaining: - - "983" + - "991" Fastly-Ratelimit-Reset: - - "1715637600" + - "1715706000" Pragma: - no-cache Server: @@ -45,9 +45,9 @@ interactions: X-Cache-Hits: - "0" X-Served-By: - - cache-bfi-krnt7300118-BFI + - cache-bfi-krnt7300110-BFI X-Timer: - - S1715635663.652577,VS0,VE303 + - S1715703393.733035,VS0,VE271 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/image_optimizer_default_settings/update_1_get.yaml b/fastly/fixtures/image_optimizer_default_settings/update_1_get.yaml index 9d6558f2..74f39bce 100644 --- a/fastly/fixtures/image_optimizer_default_settings/update_1_get.yaml +++ b/fastly/fixtures/image_optimizer_default_settings/update_1_get.yaml @@ -6,8 +6,8 @@ interactions: form: {} headers: User-Agent: - - FastlyGo/9.3.1 (+github.com/fastly/go-fastly; go1.22.2) - url: https://api.fastly.com/service/7i6HN3TK9wS159v2gPAZ8A/version/86/image_optimizer_default_settings + - 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":20,"jpeg_type":"auto","jpeg_quality":85,"upscale":false,"allow_video":false}' @@ -19,7 +19,7 @@ interactions: Content-Type: - application/json Date: - - Mon, 13 May 2024 21:27:40 GMT + - Tue, 14 May 2024 16:16:30 GMT Pragma: - no-cache Server: @@ -37,9 +37,9 @@ interactions: X-Cache-Hits: - "0" X-Served-By: - - cache-bfi-krnt7300118-BFI + - cache-bfi-krnt7300110-BFI X-Timer: - - S1715635660.942200,VS0,VE180 + - S1715703390.390128,VS0,VE177 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/image_optimizer_default_settings/update_1_patch.yaml b/fastly/fixtures/image_optimizer_default_settings/update_1_patch.yaml index cf8a068b..5576ce60 100644 --- a/fastly/fixtures/image_optimizer_default_settings/update_1_patch.yaml +++ b/fastly/fixtures/image_optimizer_default_settings/update_1_patch.yaml @@ -10,8 +10,8 @@ interactions: Content-Type: - application/json User-Agent: - - FastlyGo/9.3.1 (+github.com/fastly/go-fastly; go1.22.2) - url: https://api.fastly.com/service/7i6HN3TK9wS159v2gPAZ8A/version/86/image_optimizer_default_settings + - 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":20,"jpeg_type":"auto","jpeg_quality":85,"upscale":false,"allow_video":false}' @@ -23,11 +23,11 @@ interactions: Content-Type: - application/json Date: - - Mon, 13 May 2024 21:27:39 GMT + - Tue, 14 May 2024 16:16:30 GMT Fastly-Ratelimit-Remaining: - - "990" + - "998" Fastly-Ratelimit-Reset: - - "1715637600" + - "1715706000" Pragma: - no-cache Server: @@ -45,9 +45,9 @@ interactions: X-Cache-Hits: - "0" X-Served-By: - - cache-bfi-krnt7300118-BFI + - cache-bfi-krnt7300110-BFI X-Timer: - - S1715635660.573008,VS0,VE355 + - S1715703390.918211,VS0,VE458 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/image_optimizer_default_settings/update_2_get.yaml b/fastly/fixtures/image_optimizer_default_settings/update_2_get.yaml index ea6df489..76332024 100644 --- a/fastly/fixtures/image_optimizer_default_settings/update_2_get.yaml +++ b/fastly/fixtures/image_optimizer_default_settings/update_2_get.yaml @@ -6,8 +6,8 @@ interactions: form: {} headers: User-Agent: - - FastlyGo/9.3.1 (+github.com/fastly/go-fastly; go1.22.2) - url: https://api.fastly.com/service/7i6HN3TK9wS159v2gPAZ8A/version/86/image_optimizer_default_settings + - 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":true,"webp_quality":42,"jpeg_type":"auto","jpeg_quality":85,"upscale":true,"allow_video":false}' @@ -19,7 +19,7 @@ interactions: Content-Type: - application/json Date: - - Mon, 13 May 2024 21:27:40 GMT + - Tue, 14 May 2024 16:16:31 GMT Pragma: - no-cache Server: @@ -37,9 +37,9 @@ interactions: X-Cache-Hits: - "0" X-Served-By: - - cache-bfi-krnt7300118-BFI + - cache-bfi-krnt7300110-BFI X-Timer: - - S1715635660.487457,VS0,VE215 + - S1715703391.910192,VS0,VE249 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/image_optimizer_default_settings/update_2_patch.yaml b/fastly/fixtures/image_optimizer_default_settings/update_2_patch.yaml index ba16f9da..a20d8fa6 100644 --- a/fastly/fixtures/image_optimizer_default_settings/update_2_patch.yaml +++ b/fastly/fixtures/image_optimizer_default_settings/update_2_patch.yaml @@ -10,8 +10,8 @@ interactions: Content-Type: - application/json User-Agent: - - FastlyGo/9.3.1 (+github.com/fastly/go-fastly; go1.22.2) - url: https://api.fastly.com/service/7i6HN3TK9wS159v2gPAZ8A/version/86/image_optimizer_default_settings + - 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":true,"webp_quality":42,"jpeg_type":"auto","jpeg_quality":85,"upscale":true,"allow_video":false}' @@ -23,11 +23,11 @@ interactions: Content-Type: - application/json Date: - - Mon, 13 May 2024 21:27:40 GMT + - Tue, 14 May 2024 16:16:30 GMT Fastly-Ratelimit-Remaining: - - "989" + - "997" Fastly-Ratelimit-Reset: - - "1715637600" + - "1715706000" Pragma: - no-cache Server: @@ -45,9 +45,9 @@ interactions: X-Cache-Hits: - "0" X-Served-By: - - cache-bfi-krnt7300118-BFI + - cache-bfi-krnt7300110-BFI X-Timer: - - S1715635660.152170,VS0,VE304 + - S1715703391.584378,VS0,VE312 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/image_optimizer_default_settings/version.yaml b/fastly/fixtures/image_optimizer_default_settings/version.yaml index 8d31660f..85b1be26 100644 --- a/fastly/fixtures/image_optimizer_default_settings/version.yaml +++ b/fastly/fixtures/image_optimizer_default_settings/version.yaml @@ -8,11 +8,11 @@ interactions: Content-Type: - application/x-www-form-urlencoded User-Agent: - - FastlyGo/9.3.1 (+github.com/fastly/go-fastly; go1.22.2) + - FastlyGo/9.3.2 (+github.com/fastly/go-fastly; go1.22.2) url: https://api.fastly.com/service/7i6HN3TK9wS159v2gPAZ8A/version method: POST response: - body: '{"service_id":"7i6HN3TK9wS159v2gPAZ8A","number":86}' + body: '{"service_id":"7i6HN3TK9wS159v2gPAZ8A","number":87}' headers: Accept-Ranges: - bytes @@ -21,11 +21,11 @@ interactions: Content-Type: - application/json Date: - - Mon, 13 May 2024 21:27:37 GMT + - Tue, 14 May 2024 16:16:27 GMT Fastly-Ratelimit-Remaining: - - "991" + - "999" Fastly-Ratelimit-Reset: - - "1715637600" + - "1715706000" Pragma: - no-cache Server: @@ -43,9 +43,9 @@ interactions: X-Cache-Hits: - "0" X-Served-By: - - cache-bfi-krnt7300118-BFI + - cache-bfi-krnt7300110-BFI X-Timer: - - S1715635657.443280,VS0,VE466 + - S1715703387.397400,VS0,VE452 status: 200 OK code: 200 duration: "" From 7416e275ab1b12a5da15c18333a3b400da68363c Mon Sep 17 00:00:00 2001 From: Dabo Ross Date: Tue, 14 May 2024 11:37:57 -0700 Subject: [PATCH 12/13] Add ImageOpto prefix to type names too. --- fastly/image_optimizer_default_settings.go | 24 +++++++++---------- .../image_optimizer_default_settings_test.go | 4 ++-- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/fastly/image_optimizer_default_settings.go b/fastly/image_optimizer_default_settings.go index ff75a3ea..eb450bc9 100644 --- a/fastly/image_optimizer_default_settings.go +++ b/fastly/image_optimizer_default_settings.go @@ -5,10 +5,10 @@ import ( "fmt" ) -// ResizeFilter is a base for the different ResizeFilter variants. -type ResizeFilter int64 +// ImageOptoResizeFilter is a base for the different ImageOptoResizeFilter variants. +type ImageOptoResizeFilter int64 -func (r ResizeFilter) String() string { +func (r ImageOptoResizeFilter) String() string { switch r { case ImageOptoLanczos3: return "lanczos3" @@ -24,13 +24,13 @@ func (r ResizeFilter) String() string { return "lanczos3" // default } -func (r ResizeFilter) MarshalJSON() ([]byte, error) { +func (r ImageOptoResizeFilter) MarshalJSON() ([]byte, error) { return json.Marshal(r.String()) } const ( // A Lanczos filter with a kernel size of 3. Lanczos filters can detect edges and linear features within an image, providing the best possible reconstruction. - ImageOptoLanczos3 ResizeFilter = iota + ImageOptoLanczos3 ImageOptoResizeFilter = iota // A Lanczos filter with a kernel size of 2. ImageOptoLanczos2 // A filter using an average of a 4x4 environment of pixels, weighing the innermost pixels higher. @@ -41,10 +41,10 @@ const ( ImageOptoNearest ) -// JpegType is a base for different JpegType variants -type JpegType int64 +// ImageOptoJpegType is a base for different ImageOptoJpegType variants +type ImageOptoJpegType int64 -func (r JpegType) String() string { +func (r ImageOptoJpegType) String() string { switch r { case ImageOptoAuto: return "auto" @@ -56,13 +56,13 @@ func (r JpegType) String() string { return "auto" // default } -func (r JpegType) MarshalJSON() ([]byte, error) { +func (r ImageOptoJpegType) MarshalJSON() ([]byte, error) { return json.Marshal(r.String()) } const ( // Match the input JPEG type, or baseline if transforming from a non-JPEG input. - ImageOptoAuto JpegType = iota + ImageOptoAuto ImageOptoJpegType = iota // Output baseline JPEG images ImageOptoBaseline // Output progressive JPEG images @@ -106,13 +106,13 @@ type UpdateImageOptimizerDefaultSettingsInput struct { // ServiceVersion is the specific configuration version (required). ServiceVersion int `json:"-"` // The type of filter to use while resizing an image. - ResizeFilter *ResizeFilter `json:"resize_filter,omitempty"` + ResizeFilter *ImageOptoResizeFilter `json:"resize_filter,omitempty"` // Controls whether or not to default to WebP output when the client supports it. This is equivalent to adding "auto=webp" to all image optimizer requests. Webp *bool `json:"webp,omitempty"` // The default quality to use with WebP output. This can be overridden with the second option in the "quality" URL parameter on specific image optimizer requests. WebpQuality *int `json:"webp_quality,omitempty"` // The default type of JPEG output to use. This can be overridden with "format=bjpeg" and "format=pjpeg" on specific image optimizer requests. - JpegType *JpegType `json:"jpeg_type,omitempty"` + JpegType *ImageOptoJpegType `json:"jpeg_type,omitempty"` // The default quality to use with JPEG output. This can be overridden with the "quality" parameter on specific image optimizer requests. JpegQuality *int `json:"jpeg_quality,omitempty"` // Whether or not we should allow output images to render at sizes larger than input. diff --git a/fastly/image_optimizer_default_settings_test.go b/fastly/image_optimizer_default_settings_test.go index 1b06ba97..fb564c9e 100644 --- a/fastly/image_optimizer_default_settings_test.go +++ b/fastly/image_optimizer_default_settings_test.go @@ -199,7 +199,7 @@ func TestClient_ImageOptimizerDefaultSettings(t *testing.T) { } // Confirm all resize_filter & jpeg_type values are accepted - for _, resizeFilter := range []ResizeFilter{ImageOptoLanczos3, ImageOptoLanczos2, ImageOptoBicubic, ImageOptoBilinear, ImageOptoNearest} { + for _, resizeFilter := range []ImageOptoResizeFilter{ImageOptoLanczos3, ImageOptoLanczos2, ImageOptoBicubic, ImageOptoBilinear, ImageOptoNearest} { record(t, fixtureBase+"set_resize_filter/"+resizeFilter.String(), func(c *Client) { defaultSettings, err = c.UpdateImageOptimizerDefaultSettings(&UpdateImageOptimizerDefaultSettingsInput{ ServiceID: testServiceID, @@ -212,7 +212,7 @@ func TestClient_ImageOptimizerDefaultSettings(t *testing.T) { } } - for _, jpegType := range []JpegType{ImageOptoAuto, ImageOptoBaseline, ImageOptoProgressive} { + for _, jpegType := range []ImageOptoJpegType{ImageOptoAuto, ImageOptoBaseline, ImageOptoProgressive} { record(t, fixtureBase+"set_jpeg_type/"+jpegType.String(), func(c *Client) { defaultSettings, err = c.UpdateImageOptimizerDefaultSettings(&UpdateImageOptimizerDefaultSettingsInput{ ServiceID: testServiceID, From 3f7693934a1bb324112ec4e8d8bef96b6d4cc6e8 Mon Sep 17 00:00:00 2001 From: Dabo Ross Date: Tue, 14 May 2024 11:42:13 -0700 Subject: [PATCH 13/13] ImageOpto->ImageOptimizer --- fastly/image_optimizer_default_settings.go | 52 +++++++++---------- .../image_optimizer_default_settings_test.go | 12 ++--- 2 files changed, 32 insertions(+), 32 deletions(-) diff --git a/fastly/image_optimizer_default_settings.go b/fastly/image_optimizer_default_settings.go index eb450bc9..0e352547 100644 --- a/fastly/image_optimizer_default_settings.go +++ b/fastly/image_optimizer_default_settings.go @@ -5,68 +5,68 @@ import ( "fmt" ) -// ImageOptoResizeFilter is a base for the different ImageOptoResizeFilter variants. -type ImageOptoResizeFilter int64 +// ImageOptimizerResizeFilter is a base for the different ImageOptimizerResizeFilter variants. +type ImageOptimizerResizeFilter int64 -func (r ImageOptoResizeFilter) String() string { +func (r ImageOptimizerResizeFilter) String() string { switch r { - case ImageOptoLanczos3: + case ImageOptimizerLanczos3: return "lanczos3" - case ImageOptoLanczos2: + case ImageOptimizerLanczos2: return "lanczos2" - case ImageOptoBicubic: + case ImageOptimizerBicubic: return "bicubic" - case ImageOptoBilinear: + case ImageOptimizerBilinear: return "bilinear" - case ImageOptoNearest: + case ImageOptimizerNearest: return "nearest" } return "lanczos3" // default } -func (r ImageOptoResizeFilter) MarshalJSON() ([]byte, error) { +func (r ImageOptimizerResizeFilter) MarshalJSON() ([]byte, error) { return json.Marshal(r.String()) } const ( // A Lanczos filter with a kernel size of 3. Lanczos filters can detect edges and linear features within an image, providing the best possible reconstruction. - ImageOptoLanczos3 ImageOptoResizeFilter = iota + ImageOptimizerLanczos3 ImageOptimizerResizeFilter = iota // A Lanczos filter with a kernel size of 2. - ImageOptoLanczos2 + ImageOptimizerLanczos2 // A filter using an average of a 4x4 environment of pixels, weighing the innermost pixels higher. - ImageOptoBicubic + ImageOptimizerBicubic // A filter using an average of a 2x2 environment of pixels. - ImageOptoBilinear + ImageOptimizerBilinear // A filter using the value of nearby translated pixel values. Preserves hard edges. - ImageOptoNearest + ImageOptimizerNearest ) -// ImageOptoJpegType is a base for different ImageOptoJpegType variants -type ImageOptoJpegType int64 +// ImageOptimizerJpegType is a base for different ImageOptimizerJpegType variants +type ImageOptimizerJpegType int64 -func (r ImageOptoJpegType) String() string { +func (r ImageOptimizerJpegType) String() string { switch r { - case ImageOptoAuto: + case ImageOptimizerAuto: return "auto" - case ImageOptoBaseline: + case ImageOptimizerBaseline: return "baseline" - case ImageOptoProgressive: + case ImageOptimizerProgressive: return "progressive" } return "auto" // default } -func (r ImageOptoJpegType) MarshalJSON() ([]byte, error) { +func (r ImageOptimizerJpegType) MarshalJSON() ([]byte, error) { return json.Marshal(r.String()) } const ( // Match the input JPEG type, or baseline if transforming from a non-JPEG input. - ImageOptoAuto ImageOptoJpegType = iota + ImageOptimizerAuto ImageOptimizerJpegType = iota // Output baseline JPEG images - ImageOptoBaseline + ImageOptimizerBaseline // Output progressive JPEG images - ImageOptoProgressive + ImageOptimizerProgressive ) // ImageOptimizerDefaultSettings represents the returned Image Optimizer default settings for a given service. @@ -106,13 +106,13 @@ type UpdateImageOptimizerDefaultSettingsInput struct { // ServiceVersion is the specific configuration version (required). ServiceVersion int `json:"-"` // The type of filter to use while resizing an image. - ResizeFilter *ImageOptoResizeFilter `json:"resize_filter,omitempty"` + ResizeFilter *ImageOptimizerResizeFilter `json:"resize_filter,omitempty"` // Controls whether or not to default to WebP output when the client supports it. This is equivalent to adding "auto=webp" to all image optimizer requests. Webp *bool `json:"webp,omitempty"` // The default quality to use with WebP output. This can be overridden with the second option in the "quality" URL parameter on specific image optimizer requests. WebpQuality *int `json:"webp_quality,omitempty"` // The default type of JPEG output to use. This can be overridden with "format=bjpeg" and "format=pjpeg" on specific image optimizer requests. - JpegType *ImageOptoJpegType `json:"jpeg_type,omitempty"` + JpegType *ImageOptimizerJpegType `json:"jpeg_type,omitempty"` // The default quality to use with JPEG output. This can be overridden with the "quality" parameter on specific image optimizer requests. JpegQuality *int `json:"jpeg_quality,omitempty"` // Whether or not we should allow output images to render at sizes larger than input. diff --git a/fastly/image_optimizer_default_settings_test.go b/fastly/image_optimizer_default_settings_test.go index fb564c9e..d48609dc 100644 --- a/fastly/image_optimizer_default_settings_test.go +++ b/fastly/image_optimizer_default_settings_test.go @@ -67,10 +67,10 @@ func TestClient_ImageOptimizerDefaultSettings(t *testing.T) { ServiceVersion: *testVersion.Number, // just use default resizefilter & jpegtype since it doesn't matter much, and it's annoying // to parse the API output strings back into enums. - ResizeFilter: ToPointer(ImageOptoNearest), + ResizeFilter: ToPointer(ImageOptimizerNearest), Webp: &originalSettings.Webp, WebpQuality: &originalSettings.WebpQuality, - JpegType: ToPointer(ImageOptoAuto), + JpegType: ToPointer(ImageOptimizerAuto), JpegQuality: &originalSettings.JpegQuality, Upscale: &originalSettings.Upscale, AllowVideo: &originalSettings.AllowVideo, @@ -199,7 +199,7 @@ func TestClient_ImageOptimizerDefaultSettings(t *testing.T) { } // Confirm all resize_filter & jpeg_type values are accepted - for _, resizeFilter := range []ImageOptoResizeFilter{ImageOptoLanczos3, ImageOptoLanczos2, ImageOptoBicubic, ImageOptoBilinear, ImageOptoNearest} { + for _, resizeFilter := range []ImageOptimizerResizeFilter{ImageOptimizerLanczos3, ImageOptimizerLanczos2, ImageOptimizerBicubic, ImageOptimizerBilinear, ImageOptimizerNearest} { record(t, fixtureBase+"set_resize_filter/"+resizeFilter.String(), func(c *Client) { defaultSettings, err = c.UpdateImageOptimizerDefaultSettings(&UpdateImageOptimizerDefaultSettingsInput{ ServiceID: testServiceID, @@ -212,7 +212,7 @@ func TestClient_ImageOptimizerDefaultSettings(t *testing.T) { } } - for _, jpegType := range []ImageOptoJpegType{ImageOptoAuto, ImageOptoBaseline, ImageOptoProgressive} { + for _, jpegType := range []ImageOptimizerJpegType{ImageOptimizerAuto, ImageOptimizerBaseline, ImageOptimizerProgressive} { record(t, fixtureBase+"set_jpeg_type/"+jpegType.String(), func(c *Client) { defaultSettings, err = c.UpdateImageOptimizerDefaultSettings(&UpdateImageOptimizerDefaultSettingsInput{ ServiceID: testServiceID, @@ -230,10 +230,10 @@ func TestClient_ImageOptimizerDefaultSettings(t *testing.T) { defaultSettings, err = c.UpdateImageOptimizerDefaultSettings(&UpdateImageOptimizerDefaultSettingsInput{ ServiceID: testServiceID, ServiceVersion: *testVersion.Number, - ResizeFilter: ToPointer(ImageOptoLanczos3), + ResizeFilter: ToPointer(ImageOptimizerLanczos3), Webp: ToPointer(false), WebpQuality: ToPointer(85), - JpegType: ToPointer(ImageOptoAuto), + JpegType: ToPointer(ImageOptimizerAuto), JpegQuality: ToPointer(85), Upscale: ToPointer(false), AllowVideo: ToPointer(false),