Skip to content

Commit b43de5b

Browse files
committed
feat(product_enablement): Add support for Log Explorer & Insights product. (fastly#558)
The GetProduct, EnableProduct, and DisableProduct functions now support 'ProductLogExplorerInsights'.
1 parent 8ce02a6 commit b43de5b

6 files changed

+319
-0
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
---
2+
version: 1
3+
interactions:
4+
- request:
5+
body: ""
6+
form: {}
7+
headers:
8+
User-Agent:
9+
- FastlyGo/9.11.0 (+github.com/fastly/go-fastly; go1.23.2)
10+
url: https://api.fastly.com/enabled-products/log_explorer_insights/services/VR3OlB58JjX9oVWj4lz2o5
11+
method: DELETE
12+
response:
13+
body: ""
14+
headers:
15+
Accept-Ranges:
16+
- bytes
17+
Cache-Control:
18+
- no-store
19+
Content-Type:
20+
- application/json
21+
Date:
22+
- Mon, 04 Nov 2024 16:04:30 GMT
23+
Pragma:
24+
- no-cache
25+
Server:
26+
- control-gateway
27+
Status:
28+
- 204 No Content
29+
Strict-Transport-Security:
30+
- max-age=31536000
31+
Vary:
32+
- Accept-Encoding
33+
Via:
34+
- 1.1 varnish, 1.1 varnish
35+
X-Cache:
36+
- MISS, MISS
37+
X-Cache-Hits:
38+
- 0, 0
39+
X-Served-By:
40+
- cache-chi-klot8100072-CHI, cache-nyc-kteb1890096-NYC
41+
X-Timer:
42+
- S1730736270.029325,VS0,VE435
43+
status: 204 No Content
44+
code: 204
45+
duration: ""
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
---
2+
version: 1
3+
interactions:
4+
- request:
5+
body: ProductID=log_explorer_insights&ServiceID=VR3OlB58JjX9oVWj4lz2o5
6+
form:
7+
ProductID:
8+
- log_explorer_insights
9+
ServiceID:
10+
- VR3OlB58JjX9oVWj4lz2o5
11+
headers:
12+
Content-Type:
13+
- application/x-www-form-urlencoded
14+
User-Agent:
15+
- FastlyGo/9.11.0 (+github.com/fastly/go-fastly; go1.23.2)
16+
url: https://api.fastly.com/enabled-products/log_explorer_insights/services/VR3OlB58JjX9oVWj4lz2o5
17+
method: PUT
18+
response:
19+
body: |
20+
{"product":{"id":"log_explorer_insights","object":"product"},"service":{"id":"VR3OlB58JjX9oVWj4lz2o5","object":"service"},"_links":{"self":"/enabled-products/log_explorer_insights/services/VR3OlB58JjX9oVWj4lz2o5"}}
21+
headers:
22+
Accept-Ranges:
23+
- bytes
24+
Cache-Control:
25+
- no-store
26+
Content-Length:
27+
- "215"
28+
Content-Type:
29+
- application/json
30+
Date:
31+
- Mon, 04 Nov 2024 16:04:29 GMT
32+
Pragma:
33+
- no-cache
34+
Server:
35+
- control-gateway
36+
Status:
37+
- 200 OK
38+
Strict-Transport-Security:
39+
- max-age=31536000
40+
Vary:
41+
- Accept-Encoding
42+
Via:
43+
- 1.1 varnish, 1.1 varnish
44+
X-Cache:
45+
- MISS, MISS
46+
X-Cache-Hits:
47+
- 0, 0
48+
X-Served-By:
49+
- cache-chi-klot8100072-CHI, cache-nyc-kteb1890096-NYC
50+
X-Timer:
51+
- S1730736269.965258,VS0,VE916
52+
status: 200 OK
53+
code: 200
54+
duration: ""
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
---
2+
version: 1
3+
interactions:
4+
- request:
5+
body: ""
6+
form: {}
7+
headers:
8+
User-Agent:
9+
- FastlyGo/9.11.0 (+github.com/fastly/go-fastly; go1.23.2)
10+
url: https://api.fastly.com/enabled-products/log_explorer_insights/services/VR3OlB58JjX9oVWj4lz2o5
11+
method: GET
12+
response:
13+
body: |
14+
{"type":"","title":"no product on service","status":400,"errors":null,"detail":""}
15+
headers:
16+
Accept-Ranges:
17+
- bytes
18+
Cache-Control:
19+
- no-store
20+
Content-Length:
21+
- "83"
22+
Content-Type:
23+
- application/json
24+
Date:
25+
- Mon, 04 Nov 2024 16:04:30 GMT
26+
Pragma:
27+
- no-cache
28+
Server:
29+
- control-gateway
30+
Status:
31+
- 400 Bad Request
32+
Strict-Transport-Security:
33+
- max-age=31536000
34+
Vary:
35+
- Accept-Encoding
36+
Via:
37+
- 1.1 varnish, 1.1 varnish
38+
X-Cache:
39+
- MISS, MISS
40+
X-Cache-Hits:
41+
- 0, 0
42+
X-Served-By:
43+
- cache-chi-klot8100072-CHI, cache-nyc-kteb1890096-NYC
44+
X-Timer:
45+
- S1730736270.469785,VS0,VE96
46+
status: 400 Bad Request
47+
code: 400
48+
duration: ""
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
---
2+
version: 1
3+
interactions:
4+
- request:
5+
body: ""
6+
form: {}
7+
headers:
8+
User-Agent:
9+
- FastlyGo/9.11.0 (+github.com/fastly/go-fastly; go1.23.2)
10+
url: https://api.fastly.com/enabled-products/log_explorer_insights/services/VR3OlB58JjX9oVWj4lz2o5
11+
method: GET
12+
response:
13+
body: |
14+
{"product":{"id":"log_explorer_insights","object":"product"},"service":{"id":"VR3OlB58JjX9oVWj4lz2o5","object":"service"},"_links":{"self":"/enabled-products/log_explorer_insights/services/VR3OlB58JjX9oVWj4lz2o5"}}
15+
headers:
16+
Accept-Ranges:
17+
- bytes
18+
Cache-Control:
19+
- no-store
20+
Content-Length:
21+
- "215"
22+
Content-Type:
23+
- application/json
24+
Date:
25+
- Mon, 04 Nov 2024 16:04:30 GMT
26+
Pragma:
27+
- no-cache
28+
Server:
29+
- control-gateway
30+
Status:
31+
- 200 OK
32+
Strict-Transport-Security:
33+
- max-age=31536000
34+
Vary:
35+
- Accept-Encoding
36+
Via:
37+
- 1.1 varnish, 1.1 varnish
38+
X-Cache:
39+
- MISS, MISS
40+
X-Cache-Hits:
41+
- 0, 0
42+
X-Served-By:
43+
- cache-chi-klot8100072-CHI, cache-nyc-kteb1890096-NYC
44+
X-Timer:
45+
- S1730736270.894139,VS0,VE129
46+
status: 200 OK
47+
code: 200
48+
duration: ""

fastly/product_enablement.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ func (p Product) String() string {
2828
return "fanout"
2929
case ProductImageOptimizer:
3030
return "image_optimizer"
31+
case ProductLogExplorerInsights:
32+
return "log_explorer_insights"
3133
case ProductNGWAF:
3234
return "ngwaf"
3335
case ProductOriginInspector:
@@ -47,6 +49,7 @@ const (
4749
ProductDomainInspector
4850
ProductFanout
4951
ProductImageOptimizer
52+
ProductLogExplorerInsights
5053
ProductNGWAF
5154
ProductOriginInspector
5255
ProductWebSockets
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
package fastly
2+
3+
import (
4+
"testing"
5+
)
6+
7+
func TestClient_ProductEnablement_log_explorer_insights(t *testing.T) {
8+
t.Parallel()
9+
10+
var err error
11+
12+
// Enable Product - Log Explorer & Insights
13+
var pe *ProductEnablement
14+
record(t, "product_enablement/enable_log_explorer_insights", func(c *Client) {
15+
pe, err = c.EnableProduct(&ProductEnablementInput{
16+
ProductID: ProductLogExplorerInsights,
17+
ServiceID: testServiceID,
18+
})
19+
})
20+
if err != nil {
21+
t.Fatal(err)
22+
}
23+
24+
if *pe.Product.ProductID != ProductLogExplorerInsights.String() {
25+
t.Errorf("bad feature_revision: %s", *pe.Product.ProductID)
26+
}
27+
28+
// Get Product status
29+
var gpe *ProductEnablement
30+
record(t, "product_enablement/get_log_explorer_insights", func(c *Client) {
31+
gpe, err = c.GetProduct(&ProductEnablementInput{
32+
ProductID: ProductLogExplorerInsights,
33+
ServiceID: testServiceID,
34+
})
35+
})
36+
if err != nil {
37+
t.Fatal(err)
38+
}
39+
40+
if *gpe.Product.ProductID != ProductLogExplorerInsights.String() {
41+
t.Errorf("bad feature_revision: %s", *gpe.Product.ProductID)
42+
}
43+
44+
// Disable Product
45+
record(t, "product_enablement/disable_log_explorer_insights", func(c *Client) {
46+
err = c.DisableProduct(&ProductEnablementInput{
47+
ProductID: ProductLogExplorerInsights,
48+
ServiceID: testServiceID,
49+
})
50+
})
51+
if err != nil {
52+
t.Fatal(err)
53+
}
54+
55+
// Get Product status again to check disabled
56+
record(t, "product_enablement/get-disabled_log_explorer_insights", func(c *Client) {
57+
gpe, err = c.GetProduct(&ProductEnablementInput{
58+
ProductID: ProductLogExplorerInsights,
59+
ServiceID: testServiceID,
60+
})
61+
})
62+
63+
// The API returns a 400 if Product is not enabled.
64+
// The API client returns an error if a non-2xx is returned from the API.
65+
if err == nil {
66+
t.Fatal("expected a 400 from the API but got a 2xx")
67+
}
68+
}
69+
70+
func TestClient_GetProduct_validation_log_explorer_insights(t *testing.T) {
71+
var err error
72+
73+
_, err = testClient.GetProduct(&ProductEnablementInput{
74+
ProductID: ProductLogExplorerInsights,
75+
})
76+
if err != ErrMissingServiceID {
77+
t.Errorf("bad error: %s", err)
78+
}
79+
80+
_, err = testClient.GetProduct(&ProductEnablementInput{
81+
ServiceID: "foo",
82+
})
83+
if err != ErrMissingProductID {
84+
t.Errorf("bad error: %s", err)
85+
}
86+
}
87+
88+
func TestClient_EnableProduct_validation_log_explorer_insights(t *testing.T) {
89+
var err error
90+
_, err = testClient.EnableProduct(&ProductEnablementInput{
91+
ProductID: ProductLogExplorerInsights,
92+
})
93+
if err != ErrMissingServiceID {
94+
t.Errorf("bad error: %s", err)
95+
}
96+
97+
_, err = testClient.EnableProduct(&ProductEnablementInput{
98+
ServiceID: "foo",
99+
})
100+
if err != ErrMissingProductID {
101+
t.Errorf("bad error: %s", err)
102+
}
103+
}
104+
105+
func TestClient_DisableProduct_validation_log_explorer_insights(t *testing.T) {
106+
var err error
107+
108+
err = testClient.DisableProduct(&ProductEnablementInput{
109+
ProductID: ProductLogExplorerInsights,
110+
})
111+
if err != ErrMissingServiceID {
112+
t.Errorf("bad error: %s", err)
113+
}
114+
115+
err = testClient.DisableProduct(&ProductEnablementInput{
116+
ServiceID: "foo",
117+
})
118+
if err != ErrMissingProductID {
119+
t.Errorf("bad error: %s", err)
120+
}
121+
}

0 commit comments

Comments
 (0)