forked from fastly/go-fastly
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(product_enablement): Add support for Log Explorer & Insights pro…
…duct. (fastly#558) The GetProduct, EnableProduct, and DisableProduct functions now support 'ProductLogExplorerInsights'.
- Loading branch information
Showing
6 changed files
with
319 additions
and
0 deletions.
There are no files selected for viewing
45 changes: 45 additions & 0 deletions
45
fastly/fixtures/product_enablement/disable_log_explorer_insights.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
--- | ||
version: 1 | ||
interactions: | ||
- request: | ||
body: "" | ||
form: {} | ||
headers: | ||
User-Agent: | ||
- FastlyGo/9.11.0 (+github.com/fastly/go-fastly; go1.23.2) | ||
url: https://api.fastly.com/enabled-products/log_explorer_insights/services/VR3OlB58JjX9oVWj4lz2o5 | ||
method: DELETE | ||
response: | ||
body: "" | ||
headers: | ||
Accept-Ranges: | ||
- bytes | ||
Cache-Control: | ||
- no-store | ||
Content-Type: | ||
- application/json | ||
Date: | ||
- Mon, 04 Nov 2024 16:04:30 GMT | ||
Pragma: | ||
- no-cache | ||
Server: | ||
- control-gateway | ||
Status: | ||
- 204 No Content | ||
Strict-Transport-Security: | ||
- max-age=31536000 | ||
Vary: | ||
- Accept-Encoding | ||
Via: | ||
- 1.1 varnish, 1.1 varnish | ||
X-Cache: | ||
- MISS, MISS | ||
X-Cache-Hits: | ||
- 0, 0 | ||
X-Served-By: | ||
- cache-chi-klot8100072-CHI, cache-nyc-kteb1890096-NYC | ||
X-Timer: | ||
- S1730736270.029325,VS0,VE435 | ||
status: 204 No Content | ||
code: 204 | ||
duration: "" |
54 changes: 54 additions & 0 deletions
54
fastly/fixtures/product_enablement/enable_log_explorer_insights.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
--- | ||
version: 1 | ||
interactions: | ||
- request: | ||
body: ProductID=log_explorer_insights&ServiceID=VR3OlB58JjX9oVWj4lz2o5 | ||
form: | ||
ProductID: | ||
- log_explorer_insights | ||
ServiceID: | ||
- VR3OlB58JjX9oVWj4lz2o5 | ||
headers: | ||
Content-Type: | ||
- application/x-www-form-urlencoded | ||
User-Agent: | ||
- FastlyGo/9.11.0 (+github.com/fastly/go-fastly; go1.23.2) | ||
url: https://api.fastly.com/enabled-products/log_explorer_insights/services/VR3OlB58JjX9oVWj4lz2o5 | ||
method: PUT | ||
response: | ||
body: | | ||
{"product":{"id":"log_explorer_insights","object":"product"},"service":{"id":"VR3OlB58JjX9oVWj4lz2o5","object":"service"},"_links":{"self":"/enabled-products/log_explorer_insights/services/VR3OlB58JjX9oVWj4lz2o5"}} | ||
headers: | ||
Accept-Ranges: | ||
- bytes | ||
Cache-Control: | ||
- no-store | ||
Content-Length: | ||
- "215" | ||
Content-Type: | ||
- application/json | ||
Date: | ||
- Mon, 04 Nov 2024 16:04:29 GMT | ||
Pragma: | ||
- no-cache | ||
Server: | ||
- control-gateway | ||
Status: | ||
- 200 OK | ||
Strict-Transport-Security: | ||
- max-age=31536000 | ||
Vary: | ||
- Accept-Encoding | ||
Via: | ||
- 1.1 varnish, 1.1 varnish | ||
X-Cache: | ||
- MISS, MISS | ||
X-Cache-Hits: | ||
- 0, 0 | ||
X-Served-By: | ||
- cache-chi-klot8100072-CHI, cache-nyc-kteb1890096-NYC | ||
X-Timer: | ||
- S1730736269.965258,VS0,VE916 | ||
status: 200 OK | ||
code: 200 | ||
duration: "" |
48 changes: 48 additions & 0 deletions
48
fastly/fixtures/product_enablement/get-disabled_log_explorer_insights.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
--- | ||
version: 1 | ||
interactions: | ||
- request: | ||
body: "" | ||
form: {} | ||
headers: | ||
User-Agent: | ||
- FastlyGo/9.11.0 (+github.com/fastly/go-fastly; go1.23.2) | ||
url: https://api.fastly.com/enabled-products/log_explorer_insights/services/VR3OlB58JjX9oVWj4lz2o5 | ||
method: GET | ||
response: | ||
body: | | ||
{"type":"","title":"no product on service","status":400,"errors":null,"detail":""} | ||
headers: | ||
Accept-Ranges: | ||
- bytes | ||
Cache-Control: | ||
- no-store | ||
Content-Length: | ||
- "83" | ||
Content-Type: | ||
- application/json | ||
Date: | ||
- Mon, 04 Nov 2024 16:04:30 GMT | ||
Pragma: | ||
- no-cache | ||
Server: | ||
- control-gateway | ||
Status: | ||
- 400 Bad Request | ||
Strict-Transport-Security: | ||
- max-age=31536000 | ||
Vary: | ||
- Accept-Encoding | ||
Via: | ||
- 1.1 varnish, 1.1 varnish | ||
X-Cache: | ||
- MISS, MISS | ||
X-Cache-Hits: | ||
- 0, 0 | ||
X-Served-By: | ||
- cache-chi-klot8100072-CHI, cache-nyc-kteb1890096-NYC | ||
X-Timer: | ||
- S1730736270.469785,VS0,VE96 | ||
status: 400 Bad Request | ||
code: 400 | ||
duration: "" |
48 changes: 48 additions & 0 deletions
48
fastly/fixtures/product_enablement/get_log_explorer_insights.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
--- | ||
version: 1 | ||
interactions: | ||
- request: | ||
body: "" | ||
form: {} | ||
headers: | ||
User-Agent: | ||
- FastlyGo/9.11.0 (+github.com/fastly/go-fastly; go1.23.2) | ||
url: https://api.fastly.com/enabled-products/log_explorer_insights/services/VR3OlB58JjX9oVWj4lz2o5 | ||
method: GET | ||
response: | ||
body: | | ||
{"product":{"id":"log_explorer_insights","object":"product"},"service":{"id":"VR3OlB58JjX9oVWj4lz2o5","object":"service"},"_links":{"self":"/enabled-products/log_explorer_insights/services/VR3OlB58JjX9oVWj4lz2o5"}} | ||
headers: | ||
Accept-Ranges: | ||
- bytes | ||
Cache-Control: | ||
- no-store | ||
Content-Length: | ||
- "215" | ||
Content-Type: | ||
- application/json | ||
Date: | ||
- Mon, 04 Nov 2024 16:04:30 GMT | ||
Pragma: | ||
- no-cache | ||
Server: | ||
- control-gateway | ||
Status: | ||
- 200 OK | ||
Strict-Transport-Security: | ||
- max-age=31536000 | ||
Vary: | ||
- Accept-Encoding | ||
Via: | ||
- 1.1 varnish, 1.1 varnish | ||
X-Cache: | ||
- MISS, MISS | ||
X-Cache-Hits: | ||
- 0, 0 | ||
X-Served-By: | ||
- cache-chi-klot8100072-CHI, cache-nyc-kteb1890096-NYC | ||
X-Timer: | ||
- S1730736270.894139,VS0,VE129 | ||
status: 200 OK | ||
code: 200 | ||
duration: "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
121 changes: 121 additions & 0 deletions
121
fastly/product_enablement_log_explorer_insights_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
package fastly | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func TestClient_ProductEnablement_log_explorer_insights(t *testing.T) { | ||
t.Parallel() | ||
|
||
var err error | ||
|
||
// Enable Product - Log Explorer & Insights | ||
var pe *ProductEnablement | ||
record(t, "product_enablement/enable_log_explorer_insights", func(c *Client) { | ||
pe, err = c.EnableProduct(&ProductEnablementInput{ | ||
ProductID: ProductLogExplorerInsights, | ||
ServiceID: testServiceID, | ||
}) | ||
}) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
if *pe.Product.ProductID != ProductLogExplorerInsights.String() { | ||
t.Errorf("bad feature_revision: %s", *pe.Product.ProductID) | ||
} | ||
|
||
// Get Product status | ||
var gpe *ProductEnablement | ||
record(t, "product_enablement/get_log_explorer_insights", func(c *Client) { | ||
gpe, err = c.GetProduct(&ProductEnablementInput{ | ||
ProductID: ProductLogExplorerInsights, | ||
ServiceID: testServiceID, | ||
}) | ||
}) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
if *gpe.Product.ProductID != ProductLogExplorerInsights.String() { | ||
t.Errorf("bad feature_revision: %s", *gpe.Product.ProductID) | ||
} | ||
|
||
// Disable Product | ||
record(t, "product_enablement/disable_log_explorer_insights", func(c *Client) { | ||
err = c.DisableProduct(&ProductEnablementInput{ | ||
ProductID: ProductLogExplorerInsights, | ||
ServiceID: testServiceID, | ||
}) | ||
}) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
// Get Product status again to check disabled | ||
record(t, "product_enablement/get-disabled_log_explorer_insights", func(c *Client) { | ||
gpe, err = c.GetProduct(&ProductEnablementInput{ | ||
ProductID: ProductLogExplorerInsights, | ||
ServiceID: testServiceID, | ||
}) | ||
}) | ||
|
||
// The API returns a 400 if Product is not enabled. | ||
// The API client returns an error if a non-2xx is returned from the API. | ||
if err == nil { | ||
t.Fatal("expected a 400 from the API but got a 2xx") | ||
} | ||
} | ||
|
||
func TestClient_GetProduct_validation_log_explorer_insights(t *testing.T) { | ||
var err error | ||
|
||
_, err = testClient.GetProduct(&ProductEnablementInput{ | ||
ProductID: ProductLogExplorerInsights, | ||
}) | ||
if err != ErrMissingServiceID { | ||
t.Errorf("bad error: %s", err) | ||
} | ||
|
||
_, err = testClient.GetProduct(&ProductEnablementInput{ | ||
ServiceID: "foo", | ||
}) | ||
if err != ErrMissingProductID { | ||
t.Errorf("bad error: %s", err) | ||
} | ||
} | ||
|
||
func TestClient_EnableProduct_validation_log_explorer_insights(t *testing.T) { | ||
var err error | ||
_, err = testClient.EnableProduct(&ProductEnablementInput{ | ||
ProductID: ProductLogExplorerInsights, | ||
}) | ||
if err != ErrMissingServiceID { | ||
t.Errorf("bad error: %s", err) | ||
} | ||
|
||
_, err = testClient.EnableProduct(&ProductEnablementInput{ | ||
ServiceID: "foo", | ||
}) | ||
if err != ErrMissingProductID { | ||
t.Errorf("bad error: %s", err) | ||
} | ||
} | ||
|
||
func TestClient_DisableProduct_validation_log_explorer_insights(t *testing.T) { | ||
var err error | ||
|
||
err = testClient.DisableProduct(&ProductEnablementInput{ | ||
ProductID: ProductLogExplorerInsights, | ||
}) | ||
if err != ErrMissingServiceID { | ||
t.Errorf("bad error: %s", err) | ||
} | ||
|
||
err = testClient.DisableProduct(&ProductEnablementInput{ | ||
ServiceID: "foo", | ||
}) | ||
if err != ErrMissingProductID { | ||
t.Errorf("bad error: %s", err) | ||
} | ||
} |