From 36013285c14c045953b8f72ebe95e4928de603c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20K=C3=A4mmerling?= Date: Thu, 10 Nov 2022 10:58:32 +0100 Subject: [PATCH] PrimaryIPClient Add AllWithOpts (#214) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This was missed when implementing the primary ip client. Signed-off-by: Lukas Kämmerling Signed-off-by: Lukas Kämmerling --- hcloud/primary_ip.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/hcloud/primary_ip.go b/hcloud/primary_ip.go index c534c89a..eccd407b 100644 --- a/hcloud/primary_ip.go +++ b/hcloud/primary_ip.go @@ -240,10 +240,12 @@ func (c *PrimaryIPClient) List(ctx context.Context, opts PrimaryIPListOpts) ([]* // All returns all Primary IPs. func (c *PrimaryIPClient) All(ctx context.Context) ([]*PrimaryIP, error) { - allPrimaryIPs := []*PrimaryIP{} + return c.AllWithOpts(ctx, PrimaryIPListOpts{ListOpts: ListOpts{PerPage: 50}}) +} - opts := PrimaryIPListOpts{} - opts.PerPage = 50 +// AllWithOpts returns all Primary IPs for the given options. +func (c *PrimaryIPClient) AllWithOpts(ctx context.Context, opts PrimaryIPListOpts) ([]*PrimaryIP, error) { + var allPrimaryIPs []*PrimaryIP err := c.client.all(func(page int) (*Response, error) { opts.Page = page