-
Notifications
You must be signed in to change notification settings - Fork 127
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. The GetProduct, EnableProduct, and DisableProduct functions now support 'ProductLogExplorerInsights'.
- Loading branch information
Showing
6 changed files
with
303 additions
and
0 deletions.
There are no files selected for viewing
43 changes: 43 additions & 0 deletions
43
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,43 @@ | ||
--- | ||
version: 1 | ||
interactions: | ||
- request: | ||
body: "" | ||
form: {} | ||
headers: | ||
User-Agent: | ||
- FastlyGo/7.2.0 (+github.com/fastly/go-fastly; go1.18.5) | ||
url: https://api.fastly.com/enabled-products/log_explorer_insights/services/7i6HN3TK9wS159v2gPAZ8A | ||
method: DELETE | ||
response: | ||
body: "" | ||
headers: | ||
Accept-Ranges: | ||
- bytes | ||
Content-Type: | ||
- application/json | ||
Date: | ||
- Fri, 17 Feb 2023 15:08:02 GMT | ||
Fastly-Ratelimit-Remaining: | ||
- "998" | ||
Fastly-Ratelimit-Reset: | ||
- "1676649600" | ||
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-control-cp-aws-us-east-2-prod-7-CONTROL-AWS-UE2, cache-lhr7368-LHR | ||
X-Timer: | ||
- S1676646482.821386,VS0,VE327 | ||
status: 204 No Content | ||
code: 204 | ||
duration: "" |
52 changes: 52 additions & 0 deletions
52
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,52 @@ | ||
--- | ||
version: 1 | ||
interactions: | ||
- request: | ||
body: ProductID=log_explorer_insights&ServiceID=7i6HN3TK9wS159v2gPAZ8A | ||
form: | ||
ProductID: | ||
- log_explorer_insights | ||
ServiceID: | ||
- 7i6HN3TK9wS159v2gPAZ8A | ||
headers: | ||
Content-Type: | ||
- application/x-www-form-urlencoded | ||
User-Agent: | ||
- FastlyGo/7.2.0 (+github.com/fastly/go-fastly; go1.18.5) | ||
url: https://api.fastly.com/enabled-products/log_explorer_insights/services/7i6HN3TK9wS159v2gPAZ8A | ||
method: PUT | ||
response: | ||
body: | | ||
{"product":{"id":"log_explorer_insights","object":"product"},"service":{"id":"7i6HN3TK9wS159v2gPAZ8A","object":"service"},"_links":{"self":"/enabled-products/log_explorer_insights/services/7i6HN3TK9wS159v2gPAZ8A"}} | ||
headers: | ||
Accept-Ranges: | ||
- bytes | ||
Content-Length: | ||
- "209" | ||
Content-Type: | ||
- application/json | ||
Date: | ||
- Fri, 17 Feb 2023 15:08:01 GMT | ||
Fastly-Ratelimit-Remaining: | ||
- "999" | ||
Fastly-Ratelimit-Reset: | ||
- "1676649600" | ||
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-control-cp-aws-us-east-2-prod-1-CONTROL-AWS-UE2, cache-lhr7368-LHR | ||
X-Timer: | ||
- S1676646481.093534,VS0,VE491 | ||
status: 200 OK | ||
code: 200 | ||
duration: "" |
42 changes: 42 additions & 0 deletions
42
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,42 @@ | ||
--- | ||
version: 1 | ||
interactions: | ||
- request: | ||
body: "" | ||
form: {} | ||
headers: | ||
User-Agent: | ||
- FastlyGo/7.2.0 (+github.com/fastly/go-fastly; go1.18.5) | ||
url: https://api.fastly.com/enabled-products/log_explorer_insights/services/7i6HN3TK9wS159v2gPAZ8A | ||
method: GET | ||
response: | ||
body: | | ||
{"type":"","title":"no product on service","status":400,"errors":null,"detail":""} | ||
headers: | ||
Accept-Ranges: | ||
- bytes | ||
Content-Length: | ||
- "83" | ||
Content-Type: | ||
- application/json | ||
Date: | ||
- Fri, 17 Feb 2023 15:08:02 GMT | ||
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-control-cp-aws-us-east-2-prod-1-CONTROL-AWS-UE2, cache-lhr7368-LHR | ||
X-Timer: | ||
- S1676646482.180149,VS0,VE194 | ||
status: 400 Bad Request | ||
code: 400 | ||
duration: "" |
42 changes: 42 additions & 0 deletions
42
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,42 @@ | ||
--- | ||
version: 1 | ||
interactions: | ||
- request: | ||
body: "" | ||
form: {} | ||
headers: | ||
User-Agent: | ||
- FastlyGo/7.2.0 (+github.com/fastly/go-fastly; go1.18.5) | ||
url: https://api.fastly.com/enabled-products/log_explorer_insights/services/7i6HN3TK9wS159v2gPAZ8A | ||
method: GET | ||
response: | ||
body: | | ||
{"product":{"id":"log_explorer_insights","object":"product"},"service":{"id":"7i6HN3TK9wS159v2gPAZ8A","object":"service"},"_links":{"self":"/enabled-products/log_explorer_insights/services/7i6HN3TK9wS159v2gPAZ8A"}} | ||
headers: | ||
Accept-Ranges: | ||
- bytes | ||
Content-Length: | ||
- "209" | ||
Content-Type: | ||
- application/json | ||
Date: | ||
- Fri, 17 Feb 2023 15:08:01 GMT | ||
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-control-cp-aws-us-east-2-prod-2-CONTROL-AWS-UE2, cache-lhr7368-LHR | ||
X-Timer: | ||
- S1676646482.611546,VS0,VE190 | ||
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) | ||
} | ||
} |