Skip to content

Commit

Permalink
Added IP-Service get by name method
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelfmnk committed Jul 29, 2024
1 parent 6de4b5e commit eb2de47
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions cloudconnexa/ip_services.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,31 @@ func (c *IPServicesService) GetIPByPage(page int, pageSize int) (IPServicePageRe
return response, nil
}

func (c *IPServicesService) GetByName(name string) (*IPServiceResponse, error) {
pageSize := 10
page := 0

for {
response, err := c.GetIPByPage(page, pageSize)
if err != nil {
return nil, err
}

for _, ipService := range response.Content {
if ipService.Name == name {
return &ipService, nil
}
}

if page >= response.TotalPages {
break
}
page++
}

return nil, fmt.Errorf("ip service with name %s not found", name)
}

func (c *IPServicesService) List() ([]IPServiceResponse, error) {
var allIPServices []IPServiceResponse
page := 0
Expand Down

0 comments on commit eb2de47

Please sign in to comment.