diff --git a/go.mod b/go.mod index 4993ea72b..b33c24f59 100644 --- a/go.mod +++ b/go.mod @@ -25,7 +25,7 @@ require ( ) require ( - github.com/fastly/go-fastly/v9 v9.8.0 + github.com/fastly/go-fastly/v9 v9.9.0 github.com/hashicorp/cap v0.7.0 github.com/kennygrant/sanitize v1.2.4 github.com/otiai10/copy v1.14.0 diff --git a/go.sum b/go.sum index cd27f1518..086b18d4c 100644 --- a/go.sum +++ b/go.sum @@ -24,8 +24,8 @@ github.com/dsnet/compress v0.0.2-0.20210315054119-f66993602bf5/go.mod h1:qssHWj6 github.com/dsnet/golib v0.0.0-20171103203638-1ea166775780/go.mod h1:Lj+Z9rebOhdfkVLjJ8T6VcRQv3SXugXy999NBtR9aFY= github.com/dustinkirkland/golang-petname v0.0.0-20231002161417-6a283f1aaaf2 h1:S6Dco8FtAhEI/qkg/00H6RdEGC+MCy5GPiQ+xweNRFE= github.com/dustinkirkland/golang-petname v0.0.0-20231002161417-6a283f1aaaf2/go.mod h1:8AuBTZBRSFqEYBPYULd+NN474/zZBLP+6WeT5S9xlAc= -github.com/fastly/go-fastly/v9 v9.8.0 h1:15dtV3fmLlS/8wbdU3tBsW3Tb0Tj/gQrdS4v5mhtDDE= -github.com/fastly/go-fastly/v9 v9.8.0/go.mod h1:5w2jgJBZqQEebOwM/rRg7wutAcpDTziiMYWb/6qdM7U= +github.com/fastly/go-fastly/v9 v9.9.0 h1:VDCyORoWi608l/LBp+tY+qic3M5/5ZFw+rtAfV6VR9E= +github.com/fastly/go-fastly/v9 v9.9.0/go.mod h1:5w2jgJBZqQEebOwM/rRg7wutAcpDTziiMYWb/6qdM7U= github.com/fastly/kingpin v2.1.12-0.20191105091915-95d230a53780+incompatible h1:FhrXlfhgGCS+uc6YwyiFUt04alnjpoX7vgDKJxS6Qbk= github.com/fastly/kingpin v2.1.12-0.20191105091915-95d230a53780+incompatible/go.mod h1:U8UynVoU1SQaqD2I4ZqgYd5lx3A1ipQYn4aSt2Y5h6c= github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= diff --git a/pkg/commands/products/products_test.go b/pkg/commands/products/products_test.go index d2e0559bd..1e259a4df 100644 --- a/pkg/commands/products/products_test.go +++ b/pkg/commands/products/products_test.go @@ -30,6 +30,7 @@ func TestProductEnablement(t *testing.T) { }, Args: "--service-id 123", WantOutput: `PRODUCT ENABLED +bot_management false brotli_compression false domain_inspector false fanout false @@ -47,6 +48,7 @@ websockets false }, Args: "--service-id 123", WantOutput: `PRODUCT ENABLED +bot_management true brotli_compression true domain_inspector true fanout true @@ -58,12 +60,12 @@ websockets true { Name: "validate flag parsing error for enabling product", Args: "--service-id 123 --enable foo", - WantError: "error parsing arguments: enum value must be one of brotli_compression,domain_inspector,fanout,image_optimizer,origin_inspector,websockets, got 'foo'", + WantError: "error parsing arguments: enum value must be one of bot_management,brotli_compression,domain_inspector,fanout,image_optimizer,origin_inspector,websockets, got 'foo'", }, { Name: "validate flag parsing error for disabling product", Args: "--service-id 123 --disable foo", - WantError: "error parsing arguments: enum value must be one of brotli_compression,domain_inspector,fanout,image_optimizer,origin_inspector,websockets, got 'foo'", + WantError: "error parsing arguments: enum value must be one of bot_management,brotli_compression,domain_inspector,fanout,image_optimizer,origin_inspector,websockets, got 'foo'", }, { Name: "validate success for enabling product", @@ -99,6 +101,7 @@ websockets true }, Args: "--service-id 123 --json", WantOutput: `{ + "bot_management": false, "brotli_compression": false, "domain_inspector": false, "fanout": false, @@ -116,6 +119,7 @@ websockets true }, Args: "--service-id 123 --json", WantOutput: `{ + "bot_management": true, "brotli_compression": true, "domain_inspector": true, "fanout": true, diff --git a/pkg/commands/products/root.go b/pkg/commands/products/root.go index d21acbced..b43655061 100644 --- a/pkg/commands/products/root.go +++ b/pkg/commands/products/root.go @@ -26,6 +26,7 @@ type RootCommand struct { // ProductEnablementOptions is a list of products that can be enabled/disabled. var ProductEnablementOptions = []string{ + "bot_management", "brotli_compression", "domain_inspector", "fanout", @@ -111,6 +112,12 @@ func (c *RootCommand) Exec(_ io.Reader, out io.Writer) error { ps := ProductStatus{} + if _, err = ac.GetProduct(&fastly.ProductEnablementInput{ + ProductID: fastly.ProductBotManagement, + ServiceID: serviceID, + }); err == nil { + ps.BotManagement = true + } if _, err = ac.GetProduct(&fastly.ProductEnablementInput{ ProductID: fastly.ProductBrotliCompression, ServiceID: serviceID, @@ -154,6 +161,7 @@ func (c *RootCommand) Exec(_ io.Reader, out io.Writer) error { t := text.NewTable(out) t.AddHeader("PRODUCT", "ENABLED") + t.AddLine(fastly.ProductBotManagement, ps.BotManagement) t.AddLine(fastly.ProductBrotliCompression, ps.BrotliCompression) t.AddLine(fastly.ProductDomainInspector, ps.DomainInspector) t.AddLine(fastly.ProductFanout, ps.Fanout) @@ -166,6 +174,8 @@ func (c *RootCommand) Exec(_ io.Reader, out io.Writer) error { func identifyProduct(product string) fastly.Product { switch product { + case "bot_management": + return fastly.ProductBotManagement case "brotli_compression": return fastly.ProductBrotliCompression case "domain_inspector": @@ -185,6 +195,7 @@ func identifyProduct(product string) fastly.Product { // ProductStatus indicates the status for each product. type ProductStatus struct { + BotManagement bool `json:"bot_management"` BrotliCompression bool `json:"brotli_compression"` DomainInspector bool `json:"domain_inspector"` Fanout bool `json:"fanout"`