diff --git a/objectstore_credential.go b/objectstore_credential.go index 5c2fa45..ed44c5a 100644 --- a/objectstore_credential.go +++ b/objectstore_credential.go @@ -44,8 +44,13 @@ type UpdateObjectStoreCredentialRequest struct { } // ListObjectStoreCredentials returns all object store credentials in that specific region -func (c *Client) ListObjectStoreCredentials() (*PaginatedObjectStoreCredentials, error) { - resp, err := c.SendGetRequest("/v2/objectstore/credentials") +func (c *Client) ListObjectStoreCredentials(page, perPage int) (*PaginatedObjectStoreCredentials, error) { + url := "/v2/objectstore/credentials" + if page != 0 && perPage != 0 { + url = url + fmt.Sprintf("?page=%d&per_page=%d", page, perPage) + } + + resp, err := c.SendGetRequest(url) if err != nil { return nil, decodeError(err) } @@ -75,7 +80,7 @@ func (c *Client) GetObjectStoreCredential(id string) (*ObjectStoreCredential, er // FindObjectStoreCredential finds an objectstore credential by name or by accesskeyID func (c *Client) FindObjectStoreCredential(search string) (*ObjectStoreCredential, error) { - creds, err := c.ListObjectStoreCredentials() + creds, err := c.ListObjectStoreCredentials(1, 10000) if err != nil { return nil, decodeError(err) } diff --git a/objectstore_credential_test.go b/objectstore_credential_test.go index 73c98c1..1f6a8a1 100644 --- a/objectstore_credential_test.go +++ b/objectstore_credential_test.go @@ -7,20 +7,20 @@ import ( func TestListObjectStoreCredentials(t *testing.T) { client, server, _ := NewClientForTesting(map[string]string{ - "/v2/objectstore/credentials": `{"page": 1, "per_page": 20, "pages": 2, "items":[{"id": "12345", "name": "test-objectstore-cred"}]}`, + "/v2/objectstore/credentials?page=2&per_page=40": `{"page": 2, "per_page": 40, "pages": 3, "items":[{"id": "12345", "name": "test-objectstore-cred"}]}`, }) defer server.Close() - got, err := client.ListObjectStoreCredentials() + got, err := client.ListObjectStoreCredentials(2, 40) if err != nil { t.Errorf("Request returned an error: %s", err) return } expected := &PaginatedObjectStoreCredentials{ - Page: 1, - PerPage: 20, - Pages: 2, + Page: 2, + PerPage: 40, + Pages: 3, Items: []ObjectStoreCredential{ { ID: "12345",