REST API Updating a Computer Group

(imported topic written by vpetrell)

Hello,

Has anyone been able to use the rest API to add a computer to a computer group?

Any details or advice would be greatly appreciated.

Thanks

(imported comment written by JesperLarsen)

Sounds like you want to point out computers like you do when you create manual groups in the Management Console.

AFAIK you can only operate on dynamic computergroups thrugh the REST API. When doing dynamic groups, you can (if you want to target specific computers) target the computers by relevance:

PUT
https://master.myrest.com:52311/api/computergroup/operator/myoperator/1
23 HTTP

<?xml version="1.0" encoding="utf-8"?>
<BES xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
 <ComputerGroup>
  <Title>TheGroupName</Title>
  <Domain>BESC</Domain>
  <JoinByIntersection>true</JoinByIntersection>
  <SearchComponentRelevance Comparison="IsTrue">
   <Relevance>exists (12344;12345) whose (it = computer id)</Relevance>   
  </SearchComponentRelevance>
</ComputerGroup>
</BES>

/J

(imported comment written by vpetrell)

Thanks for replying, I’m actually looking to add computers to dynamic groups so this is exactly what I need.

I have been able to easily navigate and test the “get” commands but having some trouble with the “put”.

Are there any tools I can use to easily test this out?

I’m currently developing this using the IPL language of Netcool Impact.

(imported comment written by JesperLarsen)

To do these one-off tests, I use a plugin for Chrome called postman.

In postman you just put in the uri of the group ( in this case, the site used is an operatorsite is named ooo) and groupId 123

https://master.myIEMServer.net:52311/api/computergroup/operator/ooo/
123

and then select PUT as method, and paste in the above said XML as raw data and press send.

You can also add the username/pass as a static header if you want to call several times. otherwise, just fire this one and it will prompt you for the user/pass for that site.

(imported comment written by jgstew)

I also use CURL on the command line to get things working before trying to add it to a program.

(imported comment written by vpetrell)

Thanks guys, will give those tools a try!

Hi Guys

I know this is an old topic, but I would use the same title so… :slight_smile:

Is it possible to just edit the relevance of a computer group instead of renewing it?

Use case:
Automatic computer group with relevance hostname contains computer X, computer Y,…

I want to add computer Z with a PUT REST API invoke, but what I need to do know (or what i’m doing now, no idea if it’s correct):

  1. with GET REST API get the existing XML from that computer group
  2. edit the XML
  3. PUT REST API to renew the relevance of the computer group.

Off course I want to skip step 1 and 2 and just have one step:
–> Add host name Z to computer group A.

Is this possible?

With a PUT or POST method you need to provide the complete resource that you’re PUTting or POSTing. So you’ll always need to have the complete XML.

In theory the PATCH method allows this kind of thing but that’s not a supported method in the BigFix REST API.

Hi @gearoid

thanks for answer. So it’s not possible.

Then I have my next question:

Imaging that Computer X and Computer Y is subscribed to computer group A (based on Computer Name contains …). On computer group A is an open policy action (to install something).

I want to add Computer Z so I update the XML with computer X, Y, Z. What happens with the computer X and Y for the evaluation? What’s the impact of that? And when does this evaluate? When the client service restarts?