Foreman API to list puppet classes of certain environment

Hello All,

I am using Foreman 1.6. I am facing a issue to list the all the puppet
classes of certain environment ( i.e Production ). I am unable to list all
the puppet classes either, cause puppet classes are spanned across
different pages and I am having tough time to list all the classes at a
time.

> curl -k -u admin:changeme -H "Accept: version=2,application/json"
> https://server.ip/api/puppetclasses

>
The above command not listing all the classes.

Thanks,
Balasekhar Nelli

··· -- The information in this message may be proprietary and/or confidential, and protected from disclosure. If the reader of this message is not the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please notify ATMECS and delete it from your computer.

Try adding ?per_page=9999 or similar to the URL to increase the page size.

··· On 23/03/15 10:30, Balasekhar Nelli wrote: > Hello All, > > I am using Foreman 1.6. I am facing a issue to list the all the puppet > classes of certain environment ( i.e Production ). I am unable to list > all the puppet classes either, cause puppet classes are spanned across > different pages and I am having tough time to list all the classes at a > time. > > */curl -k -u admin:changeme -H "Accept: version=2,application/json" > https://server.ip/api/puppetclasses/* > > The above command not listing all the classes.


Dominic Cleal
Red Hat Engineering

Hi Balasekhar,

The API is paginated. You should ask for each page by passing the
parameter page=x or change the number of classes you want to display per
page, by using the parameter per_page.

You can do that by just appending the parameters to the URL, for example:

https://server.ip/api/puppetclasses?per_page=50
https://server.ip/api/puppetclasses?page=4

I'd recommend the second option, and programatically retrieve several pages,
as returning all of your puppetclasses by passing a per_page parameter
with a ridiculously large number is likely to clog your Foreman server.

Hope that helped,

··· On 03/23, Balasekhar Nelli wrote: > Hello All, > > I am using Foreman 1.6. I am facing a issue to list the all the puppet > classes of certain environment ( i.e Production ). I am unable to list all > the puppet classes either, cause puppet classes are spanned across > different pages and I am having tough time to list all the classes at a > time. > > > *curl -k -u admin:changeme -H "Accept: version=2,application/json" > > https://server.ip/api/puppetclasses* > > > The above command not listing all the classes. > > Thanks, > Balasekhar Nelli > > -- > The information in this message may be proprietary and/or confidential, and > protected from disclosure. If the reader of this message is not the > intended recipient, you are hereby notified that any dissemination, > distribution or copying of this communication is strictly prohibited. If > you have received this communication in error, please notify ATMECS and > delete it from your computer. > > -- > You received this message because you are subscribed to the Google Groups "foreman-dev" group. > To unsubscribe from this group and stop receiving emails from it, send an email to foreman-dev+unsubscribe@googlegroups.com. > For more options, visit https://groups.google.com/d/optout.


Daniel Lobato Garcia

@eLobatoss
blog.daniellobato.me
daniellobato.me

GPG: http://keys.gnupg.net/pks/lookup?op=get&search=0x7A92D6DD38D6DE30
Keybase: https://keybase.io/elobato