From dbe29c12d9289ef891ce4ee8c766dfb49c15d2b9 Mon Sep 17 00:00:00 2001 From: "Federico G. Schwindt" Date: Wed, 15 Nov 2023 18:02:29 +0000 Subject: [PATCH] fix(token): add ListTokensInput to ListTokens (#487) This is to enable optional fields in the future and supports consistency with other list methods. --- fastly/token.go | 7 ++++++- fastly/token_test.go | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/fastly/token.go b/fastly/token.go index 71b8cca0b..8e32866d7 100644 --- a/fastly/token.go +++ b/fastly/token.go @@ -54,8 +54,13 @@ func (s tokensByName) Less(i, j int) bool { return s[i].Name < s[j].Name } +// ListTokensInput is used as input to the ListTokens function. +type ListTokensInput struct { + // For backward compatibility. +} + // ListTokens retrieves all resources. -func (c *Client) ListTokens() ([]*Token, error) { +func (c *Client) ListTokens(i *ListTokensInput) ([]*Token, error) { resp, err := c.Get("/tokens", nil) if err != nil { return nil, err diff --git a/fastly/token_test.go b/fastly/token_test.go index c12eb19f3..049a2ca94 100644 --- a/fastly/token_test.go +++ b/fastly/token_test.go @@ -8,7 +8,7 @@ func TestClient_ListTokens(t *testing.T) { var tokens []*Token var err error record(t, "tokens/list", func(c *Client) { - tokens, err = c.ListTokens() + tokens, err = c.ListTokens(&ListTokensInput{}) }) if err != nil { t.Fatal(err)