Re: [foreman-users] API to Get Hosts with "configuration_status_label=Active"

2016-10-17 Thread Dominic Cleal
On 17/10/16 04:25, Amrit Atmajit wrote:
> Thanks Dominic,
> 
> This search option is a proper approach to get active hosts rather than
> "configuration_status_label=Active".
> 
> But adding to Vishal's query, our requirement is to list the active
> hosts along with their facts values (like, hostname, macaddress,
> manufacturer, etc.) using a single api.

Foreman doesn't have many APIs that try to combine things, you should
use multiple API calls.

> API we are using to list all hosts and their facts values is:
> "/api/fact_values"
> 
> We can add an external facts value to this api which will provide us
> last_report > "35 minutes ago" .
> But, we are not sure how to get this value.

These searches will only work on the hosts list, the fact_values API has
a more limited ability to search details of hosts.

Fetch the list of hosts using /api/v2/hosts, then query the facts for
each one in turn with GET /api/v2/hosts/example.com/facts.

-- 
Dominic Cleal
domi...@cleal.org

-- 
You received this message because you are subscribed to the Google Groups 
"Foreman users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to foreman-users+unsubscr...@googlegroups.com.
To post to this group, send email to foreman-users@googlegroups.com.
Visit this group at https://groups.google.com/group/foreman-users.
For more options, visit https://groups.google.com/d/optout.


Re: [foreman-users] API to Get Hosts with "configuration_status_label=Active"

2016-10-16 Thread Amrit Atmajit
Thanks Dominic,

This search option is a proper approach to get active hosts rather than 
"configuration_status_label=Active".

But adding to Vishal's query, our requirement is to list the active hosts 
along with their facts values (like, hostname, macaddress, manufacturer, 
etc.) using a single api.

API we are using to list all hosts and their facts values is: 
"/api/fact_values"

We can add an external facts value to this api which will provide us 
last_report > "35 minutes ago" .
But, we are not sure how to get this value.

Thanks,
Amrit


On Thursday, October 13, 2016 at 1:23:10 PM UTC+5:30, Dominic Cleal wrote:
>
> On 12/10/16 18:27, Vishal Sarin wrote: 
> > I want an API query which returns hosts with 
> > "configuration_status_label=Active" 
> > 
> > I am aware of the these APIs but not sure how can I add that query. 
> > 
> > Can someone please help me here? 
> > 
> > APIs I know of 
> > 
> > "hosts": { 
> >   "List all hosts": "/api/hosts", 
>
> Use this API to list all hosts, but pass a search into it. The "active" 
> hosts are those with a certain search query, which you'll find if you 
> follow the active links from the Dashboard or look at your bookmarks 
> (under Administer). 
>
> e.g. GET 
> /api/v2/hosts?search=last_report%20%3E%20%2235%20minutes%20ago%22%20and%20(status.applied%20%3E%200%20or%20status.restarted%20%3E%200)%09
>  
>
>
> (URL-encoded version of last_report > "35 minutes ago" and 
> (status.applied > 0 or status.restarted > 0)) 
>
> -- 
> Dominic Cleal 
> dom...@cleal.org  
>

-- 
You received this message because you are subscribed to the Google Groups 
"Foreman users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to foreman-users+unsubscr...@googlegroups.com.
To post to this group, send email to foreman-users@googlegroups.com.
Visit this group at https://groups.google.com/group/foreman-users.
For more options, visit https://groups.google.com/d/optout.


Re: [foreman-users] API to Get Hosts with "configuration_status_label=Active"

2016-10-12 Thread 'Jason B. Nance' via Foreman users
Hi Vishal, 

> I want an API query which returns hosts with 
> "configuration_status_label=Active" 

I believe the key is 'host.configuration_status_label' (vs just 
'configuration_status_label'), but I don't know if this is something that the 
search API can filter on or not. 

Regards, 

j 



-- 
You received this message because you are subscribed to the Google Groups 
"Foreman users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to foreman-users+unsubscr...@googlegroups.com.
To post to this group, send email to foreman-users@googlegroups.com.
Visit this group at https://groups.google.com/group/foreman-users.
For more options, visit https://groups.google.com/d/optout.