engineyard / core-client-rb

Engine Yard Core API Ruby client
MIT License
4 stars 22 forks source link

NEW: defaults servers per page to 100. #113

Closed glennr closed 5 years ago

glennr commented 5 years ago

A quick and dirty fix - if you have lots of servers, the pagination default of 20 wont cut the mustard.

ess commented 5 years ago

Hey Glenn!

While I do very much understand the rationale behind wanting to change this default, I'm left wondering if there isn't a better way to accomplish what you're looking to do without making a one-off change to the default per-page for a single resource type.

If I might, are you focused more on programmatic usage, or are you basically looking to make the ey-core servers command output more servers?

ess commented 5 years ago

Bumping to tag @glennr and make sure that this message gets delivered :)

glennr commented 5 years ago

Hi Dennis!

If I might, are you focused more on programmatic usage, or are you basically looking to make the ey-core servers command output more servers?

Programmatic usage. We have an internal tool that wraps your CLI - it fetches a list of all our servers+IPs etc (and caches these locally for faster lookup when we want to do things like ssh in there or grep logs.

The original ey CLI works fine with N servers, but the newer endpoint that this gem uses appears to use a default pagination of 20 (and this lib doesnt provide a way of overriding that).

This was a quick hack to get it working for us, but definitely could use some love. The Right Way (TM) to fix this is for request to check for, and fetch all pages.

ess commented 5 years ago

@glennr

Thanks for getting back to me. There is a (totally undocumented, it would appear) mechanism in place for this sort of thing, though it's (as you might imagine) not exactly the most performant thing ever for a boatload of servers. If a request for 100 is doing for your team, though, I think it should work out Just Fine (TM).

If you would, please give this a spin and let me know how it works out:

api = Ey::Core::Client.new(token: 'your_auth_token')

api.servers.each_entry do |server|
  puts server.provisioned_id
end

api.servers.each_entry.to_a.count