API Help for Component Relevance of Baselines

I’ve tried every possible connotation I can think of but still can’t get this to work :frowning:

I need an API call - most likely using WebReports Query - to find out which Baseline Components are relevant to an endpoint.

The components can be part of any baseline with the name starting with “RHEL8” and from a custom site names “RHEL8”

I’m kind of somewhere around this at the moment but keep failing no matter what I try

<Query Resource=“(id of source fixlet of it, name of site of source fixlet of it) of components whose (exists elements whose (name of it as lowercase contains “RH” as lowercase) of applicable computer set of it) of component groups of bes baselines whose (display name of site of it = “RHEL8”)”>

Just to be clear -

  1. You want to get All of the Relevant Computers from all of the Baselines you mentioned.
  2. You want to show the following information for each Relevant Computer -
  • Computer Name
  • Relevant patches from those Baselines
  • do you also want to add from which Baseline the patch is from?

Not quite :frowning:

The API call will specify a single endpoint and for that endpoint I want to see a list of Baseline Components that are relevant for it from the Custom Site “RHEL8” and where the baseline name starts with “RHEL8”

There are going to be multiple baselines in that custom site that start with RHEL8 so I need it to look through all of them and only return the components that are relevant

Ok, I understand.
So each API Call will be for a specific machine - that you will provide.

Testing something

1 Like

(names of item 1 of it, names of item 0 of it, relevant (item 0 of it, item 1 of it)) of (source fixlets of components of component groups of relevant fixlets whose (baseline flag of it AND name of it starts with “RHEL8” AND custom site flag of it AND display name of custom site of it starts with “RHEL8”) of bes computers whose (id of it = 1303991),bes computers whose (id of it = 1303991))

It will Return Something like this:

LAB-ORB, FIXLET - Return TRUE, True
LAB-ORB, FIXLET - Not Relevant Content, False
LAB-ORB, FIXLET - Return TRUE, True
LAB-ORB, FIXLET - Not Relevant Content, False

You of course can limit the answer to return only those which are relevant

Do you also want to know from which Custom Site each “source fixlet” is from?

1 Like

This looks to be spot on! Now I just need to work out how to get it to only show the relevant fixlets

(if (item 2 of it) then (item 0 of it, item 1 of it) else nothing) of (names of item 1 of it, names of item 0 of it, relevant (item 0 of it, item 1 of it) ) of (source fixlets of components of component groups of relevant fixlets whose (baseline flag of it AND name of it starts with “RHEL8 ” AND custom site flag of it AND display name of custom site of it starts with “RHEL8 ”) of bes computers whose (id of it = 1303991 ),bes computers whose (id of it = 1303991 ))

This will Return

LAB-ORB, FIXLET - Return TRUE
LAB-ORB, FIXLET - Return TRUE

5 Likes

Thank you so much! this has saved me an unbelievable amount of time

3 Likes

I’ve been haunted by this again today - is there any chance you could add the custom site baseline name that contains each content too?

@FatScottishGuy Sorry about the delay

(if (item 2 of it) then (item 3 of it, item 1 of it, item 0 of it) else nothing) of (name of item 0 of it, name of item 1 of it, relevant (item 1 of it, item 2 of it), name of item 2 of it) of (item 0 of it,source fixlets of components of component groups of item 0 of it,item 1 of it) of (relevant fixlets whose (baseline flag of it AND name of it starts with "RHEL8 " AND custom site flag of it AND display name of custom site of it starts with "RHEL8 ") of bes computers whose (id of it = 1303991 ),bes computers whose (id of it = 1303991 ))

This will return the Following results:
LAB-ORB, FIXLET - Return TRUE, RHEL8 - Baseline 1
LAB-ORB, FIXLET - Return TRUE, RHEL8 - Baseline 2

I get this :frowning:

<BESAPI xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="BESAPI.xsd">
<Query Resource="(if (item 2 of it) then (item 3 of it, item 1 of it, item 0 of it) else nothing) of (name of item 0 of it, name of item 1 of it, relevant (item 1 of it, item 2 of it), name of item 2 of it) of (item 0 of it,source fixlets of components of component groups of item 0 of it,item 1 of it) of (relevant fixlets whose (baseline flag of it AND name of it starts with "RHEL8 " AND custom site flag of it AND display name of custom site of it starts with "RHEL8 ") of bes computers whose (id of it = 2697954647),bes computers whose (id of it = 2697954647))">
<Result/>
<Evaluation>
<Time>47.193ms</Time>
<Plurality>Plural</Plurality>
</Evaluation>
</Query>
</BESAPI>

I would personally write it with sets - looks a bit uglier at first but it would scale to any size of machines & components/baselines. Also, worth noting it does matter on the API account permissions. If for example, baseline or any of the components are “globally hidden” and user essentially is NMO then they won’t be able to see them ; same with the site permissions; machine permissions; etc (can’t bypass the permission limitations is the bottom line).

(name of item 0 of it|"Missing Name", (if (relevant (item 0 of it, item 1 of it)) then (name of item 1 of it, names of elements of intersection of ((set of source fixlets of components of component groups of item 1 of it); relevant fixlet set of item 0 of it)) else (nothing)) of (item 0 of it, elements of item 1 of it)) of (elements of item 0 of it, item 1 of it) of (set of bes computers whose (id of it = 2697954647), set of bes fixlets whose (baseline flag of it AND name of it starts with "RHEL8 " AND custom site flag of it AND display name of custom site of it starts with "RHEL8 "))

1 Like

<BESAPI xmlns:xsi="http://www.w3

.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="BESAPI.xsd">

<Query Resource="(name of item 0 of it|"Missing Name", (if (relevant (item 0 of it, item 1 of it)) then (name of item 1 of it, names of elements of intersection of ((set of source fixlets of components of component groups of item 1 of it)">

<Result/>

<Error>This expression could not be parsed.</Error>

</Query>

</BESAPI>

I get this now

but I also tried

(name of item 0 of it | "Missing Name", (if (relevant (item 0 of it, item 1 of it)) then (name of item 1 of it, names of elements of intersection of (set of source fixlets of components of component groups of item 1 of it, relevant fixlet set of item 0 of it)) else (nothing)) of (item 0 of it, elements of item 1 of it)) of (elements of item 0 of it, item 1 of it) of (set of bes computers whose (id of it = 2697954647), set of bes fixlets whose (baseline flag of it AND name of it starts with "RHEL8 " AND custom site flag of it AND display name of custom site of it starts with "RHEL8 "))

39.911ms

Plural

You need to uri-encode the relevance first, mate. Some of the special characters when you post them as an API call are not automatically escaped by the APi service. Pretty much any programming language would have uri-encode/decode function but if you are looking for something quick with interface, I use this website. You give it the relevance, it gives you the encoded version of it and you plug that into the call.

1 Like

The ‘Query’ field there looks like it was truncated, either by a copy/paste issue or by the tool you’re using to send the query. If you’re using a browser you need to URL-encode the query itself first. If you’re using Python or PowerShell it likely url-encodes it for you. If you’re using curl you may need to specify on the command line.

I encoded it and I’m using the browser but still seem to get an error :frowning:

<BESAPI xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="BESAPI.xsd">
<Query Resource="(name of item 0 of it|"Missing Name", (if (relevant (item 0 of it, item 1 of it)) then (name of item 1 of it, names of elements of intersection of ((set of source fixlets of components of component groups of item 1 of it); relevant fixlet set of item 0 of it)) else (nothing)) of (item 0 of it, elements of item 1 of it)) of (elements of item 0 of it, item 1 of it) of (set of bes computers whose (id of it = 2697954647), set of bes fixlets whose (baseline flag of it AND name of it starts with "RHEL8 " AND custom site flag of it AND display name of custom site of it starts with "RHEL8 "))">
<Result/>
<Evaluation>
<Time>51.844ms</Time>
<Plurality>Plural</Plurality>
</Evaluation>
</Query>
</BESAPI>

Did you check this bit? Have you confirmed your API account has permissions to the site/device and none of the stuff is “globally hidden”, unless the account itself is MO… In fact, any chance you can test it with MO API account (that should rule out permissions)?

1 Like

Hm. There’s something very weird happening here because that result you’re showing isn’t even valid XML. The <Query Resource= is an attribute so the whole query should be wrapped in quotes; but the double quotes you had as part of the original query should have been XML-escaped as &quot; instead of being shown literally.

Can you post a copy of the actual thing you’re putting in the browser bar (replace your server name), and what version of BigFix are you using?

Yeah it’s an MO account that’s running it :frowning:

That’s not it then. I would look at Jason’s thing. How are you posting the API query? Is it via a browser? Try a different tool for example - try powershell (can share a snippet of code to both encode & post if you’d like); if you prefer something with UI, I use Postman occasionally and it is quite good.