Automic Workload Automation

 View Only
  • 1.  v24 RESTAPI Question

    Posted 18 days ago
    I am trying to automate adding an existing agent to an agent pool in a client but can’t seem to get it right. Any help would be greatly appreciated! As many of you are aware Broadcom’s documentation for all things Automic is rather lacking! My questions are:

    1. Does this functionality exist in Automic v24?
    2. If it does, has anyone done this and would you share your code with me?
    3. Is there any documentation on the REST API out there that’s better than Broadcom’s?
    4. Here is what Copilot gave me, but doesn’t work. Any suggestions, other than not using Copilot :-)

    # This script adds an agent to an agent group membership using the AE REST API.
    REST_ENDPOINT=“< <https: aoa-rest.idx-pl-live.eislz.com>endPoint>"
    CLIENT=“<clientnumber>"
    AGENTGROUP_ID="WINDOWS_POOL"
    AGENT_ID=“<agentname>"
    read -sp "Enter password: " PASSWORD
    AE_USER_PW=“<username>:$PASSWORD"

    # JSON payload
    PAYLOAD=$(cat << />
    {
    "agent_id": "${AGENT_ID}"
    }
    EOF
    )

    echo "Adding agent $NEW_AGENT to Agent Group $AGENT_GROUP for client $CLIENT"
    URL="$REST_ENDPOINT/ae/api/v1/${CLIENT}/agentgroups/${AGENTGROUP_ID}/agents"
    response=$(curl -X POST "${URL}" \
    --header "Content-Type: application/json" \
    --user "$AE_USER_PW" \
    --data "${PAYLOAD}")
    # Output the response
    echo "Response: ${response}"
    # Check if the response contains an error
    if echo "$response" | grep -q '"error"'; then
    echo "Error adding agent to agent group: $response"
    else
    echo "Agent added successfully."
    fi

    I get the following output:

    Adding agent to Agent Group for client <clientnumber>
    % Total % Received % Xferd Average Speed Time Time Time Current
    Dload Upload Total Spent Left Speed
    100 160 100 125 100 35 1157 324 --:--:-- --:--:-- --:--:-- 1481
    Response: {
    "code" : 45109,
    "error" : "The requested resource cannot be found.",
    "details" : "No detail information available."
    }
    Error adding agent to agent group: {
    "code" : 45109,
    "error" : "The requested resource cannot be found.",
    "details" : "No detail information available."
    }</clientnumber></username></agentname></clientnumber></https:>


  • 2.  RE: v24 RESTAPI Question

    Broadcom Employee
    Posted 17 days ago

    Hi Steven,

    unfortunately there is no POST method the /agentgroups endpoint, only GET (to list agents in an agent group) and DELETE (to disconnect an agent group).

    In order to modify an object please use the PATCH method of the /objects endpoint. In the documentation you will find an example for modifying a HOSTG object including a full JSON.

    Regards, Markus




  • 3.  RE: v24 RESTAPI Question

    Posted 17 days ago

    Are you saying that to do what I want I need to modify the objects via the PATCH /{client_id}/objects/object_name} call, or are you saying what I want to do can't yet be done because there is no POST method to do this?

    Also, can you further explain the DELETE call? What does it mean to disconnect an Agent Group? Does that get rid of the whole group?

    I'm just now getting into using the REST API after writing a simple program to get data from client 0. Now I want to make changes to data in AE

    Thanks!




  • 4.  RE: v24 RESTAPI Question

    Broadcom Employee
    Posted 17 days ago

    Hi Steven,

    I am saying, that the /agentgroups endpoint is not the right one for your use case. Please use the /objects endpoint to update the object.

    Regards, Markus




  • 5.  RE: v24 RESTAPI Question

    Posted 16 days ago

    Thank you for your help! I got adding and removing agents from an agent group with PATCH objects working with lots of trial and error. One surprise with the API is that it doesn't check whether an agent that you specify to be added to the group actually exists. I could add a non-existent agent that I named "FRED_BARNEY" to an agent group and the API happily did it even through that agent doesn't exist anywhere in the Automic system. Also, as part of my trials and errors, I managed to create an agent in my test client that doesn't then show up in Client 0. Is that even legal? And I can't seem to delete it using the UI. I will have to build in a LOT of data checking into my final programs so that everything is Kosher.

    Since the API doesn't do much data checking, I was shocked to find that it does recognize when someone is logged into the agent group edit page when the API is instructed to add/remove an agent from the same agent group. THAT is doesn't let you do, and comes back with an error message saying that "<UserName> is editing the agent group."

    I'd like to see the API beefed up so it prevents a user from making changes that should not be changed (see examples, above).




  • 6.  RE: v24 RESTAPI Question

    Broadcom Employee
    Posted 14 days ago

    Hi Steven,

    a few suggestions:

    1) to prevent users from editing HOSTG object, do not assign them permissions to edit HOSTG objects

    2) Being able to add non-existent agents to HOSTG objects is allowed by design. This allows you to define agent groups to consider agents which have not been installed yet.

    3) Please note that agent groups are able to consider agents based on filters using wildcard or other criteria

    4) Agents can have roles defined. Use those roles to automatically assign agents to specific agent groups. Maybe that makes it obsolete adding them explicitly adding them using the REST API

    Regards, Markus