<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: API query with an exact match? in Endpoint Security</title>
    <link>https://community.cisco.com/t5/endpoint-security/api-query-with-an-exact-match/m-p/4105851#M5465</link>
    <description>&lt;P&gt;I got that already...&lt;/P&gt;&lt;P&gt;See my answer to Matt's response.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 18 Jun 2020 18:09:45 GMT</pubDate>
    <dc:creator>Ken Stieers</dc:creator>
    <dc:date>2020-06-18T18:09:45Z</dc:date>
    <item>
      <title>API query with an exact match?</title>
      <link>https://community.cisco.com/t5/endpoint-security/api-query-with-an-exact-match/m-p/4105767#M5460</link>
      <description>&lt;P&gt;Good morning.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;When I do an api call, for groups, using this URI:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;A href="https://api.amp.cisco.com/v1/groups?name=Protect" target="_blank" rel="noopener"&gt;https://api.amp.cisco.com/v1/groups?name=Protect&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;It returns all of the groups with 'Protect' in their names...&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Is there a way to tell the API to just return the ONE group with the name of "Protect"?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Ken&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jun 2020 16:27:52 GMT</pubDate>
      <guid>https://community.cisco.com/t5/endpoint-security/api-query-with-an-exact-match/m-p/4105767#M5460</guid>
      <dc:creator>Ken Stieers</dc:creator>
      <dc:date>2020-06-18T16:27:52Z</dc:date>
    </item>
    <item>
      <title>Re: API query with an exact match?</title>
      <link>https://community.cisco.com/t5/endpoint-security/api-query-with-an-exact-match/m-p/4105832#M5462</link>
      <description>&lt;P&gt;Ken,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The groups API call uses a wildcard for the name search so it will return all groups with Protect in the name.&amp;nbsp; For information on an exact match you would need to use the Group GUID with the &lt;A href="https://api-docs.amp.cisco.com/api_actions/details?api_action=GET+%2Fv1%2Fgroups%2F%7B%3Agroup_guid%7D&amp;amp;api_host=api.amp.cisco.com&amp;amp;api_resource=Group&amp;amp;api_version=v1" target="_self"&gt;groups/{guid} API call&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;Matt&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jun 2020 17:50:58 GMT</pubDate>
      <guid>https://community.cisco.com/t5/endpoint-security/api-query-with-an-exact-match/m-p/4105832#M5462</guid>
      <dc:creator>Matthew Franks</dc:creator>
      <dc:date>2020-06-18T17:50:58Z</dc:date>
    </item>
    <item>
      <title>Re: API query with an exact match?</title>
      <link>https://community.cisco.com/t5/endpoint-security/api-query-with-an-exact-match/m-p/4105845#M5463</link>
      <description>&lt;P&gt;Hi Ken,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks for using Cisco Community, regarding your inquiry you can get a specific group using the API.&lt;/P&gt;
&lt;P&gt;This information can be found in the API Documentation:&amp;nbsp;&lt;A href="https://api-docs.amp.cisco.com/api_resources/Group?api_host=api.amp.cisco.com&amp;amp;api_version=v1" target="_blank" rel="noopener"&gt;https://api-docs.amp.cisco.com/api_resources/Group?api_host=api.amp.cisco.com&amp;amp;api_version=v1&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can get the information about a specific group by using the GUID of the group.&lt;/P&gt;
&lt;PRE class="shell" contenteditable="" spellcheck="false"&gt;https://api.amp.cisco.com/v1/groups/5cdf70dd-1b14-46a0-be90-e08da14172d8&lt;/PRE&gt;
&lt;P&gt;The&amp;nbsp;5cdf70dd-1b14-46a0-be90-e08da14172d8 is the GUID of the group, but how to get this ID?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;* Using API&lt;/P&gt;
&lt;P&gt;You can use this query to get all the information about the groups.&lt;/P&gt;
&lt;PRE class="shell" contenteditable="" spellcheck="false"&gt;https://api.amp.cisco.com/v1/groups&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="Screen Shot 2020-06-18 at 13.05.07.png" style="width: 400px;"&gt;&lt;img src="https://community.cisco.com/t5/image/serverpage/image-id/77127i88F788B796831CE5/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Screen Shot 2020-06-18 at 13.05.07.png" alt="Screen Shot 2020-06-18 at 13.05.07.png" /&gt;&lt;/span&gt;&lt;/PRE&gt;
&lt;P&gt;Once you have the GUID you can use it in the query.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE class="shell" contenteditable="" spellcheck="false"&gt;https://api.amp.cisco.com/v1/groups/TheGroupGUID&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="Screen Shot 2020-06-18 at 12.58.19.png" style="width: 400px;"&gt;&lt;img src="https://community.cisco.com/t5/image/serverpage/image-id/77125iCBB904B928AA4590/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Screen Shot 2020-06-18 at 12.58.19.png" alt="Screen Shot 2020-06-18 at 12.58.19.png" /&gt;&lt;/span&gt;&lt;/PRE&gt;
&lt;P&gt;I hope this information can be useful to you.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Have a great day!!!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Uri&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jun 2020 18:05:53 GMT</pubDate>
      <guid>https://community.cisco.com/t5/endpoint-security/api-query-with-an-exact-match/m-p/4105845#M5463</guid>
      <dc:creator>jesutorr@cisco.com</dc:creator>
      <dc:date>2020-06-18T18:05:53Z</dc:date>
    </item>
    <item>
      <title>Re: API query with an exact match?</title>
      <link>https://community.cisco.com/t5/endpoint-security/api-query-with-an-exact-match/m-p/4105850#M5464</link>
      <description>&lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;I'm writing a script to do moves to a group, based on someone not having access to the api. "Move machine x to group y" without knowing what "y" will be...&lt;BR /&gt;&lt;BR /&gt;I hoping I wouldn't have to loop through the returned list.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Thanks!&lt;BR /&gt;&lt;BR /&gt;Ken&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 18 Jun 2020 18:08:09 GMT</pubDate>
      <guid>https://community.cisco.com/t5/endpoint-security/api-query-with-an-exact-match/m-p/4105850#M5464</guid>
      <dc:creator>Ken Stieers</dc:creator>
      <dc:date>2020-06-18T18:08:09Z</dc:date>
    </item>
    <item>
      <title>Re: API query with an exact match?</title>
      <link>https://community.cisco.com/t5/endpoint-security/api-query-with-an-exact-match/m-p/4105851#M5465</link>
      <description>&lt;P&gt;I got that already...&lt;/P&gt;&lt;P&gt;See my answer to Matt's response.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jun 2020 18:09:45 GMT</pubDate>
      <guid>https://community.cisco.com/t5/endpoint-security/api-query-with-an-exact-match/m-p/4105851#M5465</guid>
      <dc:creator>Ken Stieers</dc:creator>
      <dc:date>2020-06-18T18:09:45Z</dc:date>
    </item>
    <item>
      <title>Re: API query with an exact match?</title>
      <link>https://community.cisco.com/t5/endpoint-security/api-query-with-an-exact-match/m-p/4105884#M5466</link>
      <description>&lt;P&gt;Ken,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I did something very similar recently and had to parse the output to get the group GUID.&amp;nbsp; You may find some useful resources at github.com/CiscoSecurity if you're not aware of that repository.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I took the liberty of combining some existing Python code to parse your Groups.&amp;nbsp; You may want some different information but this should be a good start.&amp;nbsp; You just need to input your API credentials.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;import requests

amp_client_id = ''
amp_api_key = ''

def displayGroups():
    url = 'https://api.amp.cisco.com/v1/groups'

    request = requests.get(url, auth=(amp_client_id, amp_api_key))
    response = request.json()

    print('[{:^5}]   {:^30} {:^15}'.format('Index', 'Name', 'Product'))

    index = 0
    for item in response["data"]:
        index = index + 1
        print('[{:^5}]   {:&amp;lt;30} {:^15}'.format(
            index,
            item['name'],
            item['guid'],
        ))
    print("------------------------------------------")
    index = input("Index: ")
    index = index.strip()

    if not index.isdigit():
        print("Invalid index")
        return

    index = int(index) - 1
    if not (0 &amp;lt;= index &amp;lt; len(response['data'])):
        print("Invalid index")
        return

    guid = response['data'][index]['guid']

    # get the details of a particular group
    url = "https://api.amp.cisco.com/v1/groups/" + guid
    request = requests.get(url, auth=(amp_client_id, amp_api_key))
    response = request.json()
    data = response["data"]
    #print(data)

    print("\nGroup details:")
    print("\tName : " + data["name"] )
    print("\tGuid : " + data["guid"])
    print("\n\tPolicies : ")
    for num, policy in enumerate(data['policies'], start=0):
        print("\t\tName: {}".format(data['policies'][num]['name']))
        print("\t\tGuid: {}".format(data['policies'][num]['guid']))
        print("\t\tProduct: {}\n".format(data['policies'][num]['product']))

if __name__ == '__main__':
    while True:
        # Print the menu
        print("""
                   Advanced Malware Protection (AMP) - Cloud
    
                Retrieve Information About a Particular Group :
                        """)

        displayGroups()

        again = input(" Do you want to run again?(y/n): ")
        again = again.strip()
        if again == 'y' or again == 'Y':
            continue
        break&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;Matt&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jun 2020 19:11:59 GMT</pubDate>
      <guid>https://community.cisco.com/t5/endpoint-security/api-query-with-an-exact-match/m-p/4105884#M5466</guid>
      <dc:creator>Matthew Franks</dc:creator>
      <dc:date>2020-06-18T19:11:59Z</dc:date>
    </item>
    <item>
      <title>Re: API query with an exact match?</title>
      <link>https://community.cisco.com/t5/endpoint-security/api-query-with-an-exact-match/m-p/4105902#M5467</link>
      <description>That's all in python, I'm doing it Powershell.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;(BTW, this is all an X/Y problem)&lt;BR /&gt;&lt;BR /&gt;The specific issue is new machines go into a group with Orbital turned off, as the Orbital install seems to me messing about with other installs being run by the SCCM task sequence.&lt;BR /&gt;&lt;BR /&gt;So at the end of the task sequence, we'll move the machine to the correct group and let Orbital do its thing later.&lt;BR /&gt;&lt;BR /&gt;But that requires running something that the machine already has, without installing yet more stuff...&lt;BR /&gt;&lt;BR /&gt;So Powershell... and I'm trying to get cute...&lt;BR /&gt;&lt;BR /&gt;Errors written to the event log, the script is "configurable" so that we change one parameter to so change which group, etc.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;So, I'll toss out the feature request for an 'exact match' parameter on queries?&lt;BR /&gt;&lt;BR /&gt;For groups, computers, policies, there are probably others the people might need?&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 18 Jun 2020 19:20:09 GMT</pubDate>
      <guid>https://community.cisco.com/t5/endpoint-security/api-query-with-an-exact-match/m-p/4105902#M5467</guid>
      <dc:creator>Ken Stieers</dc:creator>
      <dc:date>2020-06-18T19:20:09Z</dc:date>
    </item>
    <item>
      <title>Re: API query with an exact match?</title>
      <link>https://community.cisco.com/t5/endpoint-security/api-query-with-an-exact-match/m-p/5123405#M8384</link>
      <description>&lt;P&gt;Hey guys... in powershell, here's how to do it&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Assuming $GroupResponse holds the response to an Invoke-RestMethod to&amp;nbsp;&lt;A href="https://api.amp.cisco.com/v1/groups?name=Protect" target="_blank" rel="noopener nofollow noreferrer"&gt;https://api.amp.cisco.com/v1/groups?name=Protect&lt;/A&gt;, this will get the guid of the exact match:&lt;/P&gt;
&lt;P&gt;$groupguid = $GroupResponse.data | where { $_.name -eq $SourceGroupName } | Select -ExpandProperty Guid&lt;/P&gt;</description>
      <pubDate>Mon, 03 Jun 2024 13:18:56 GMT</pubDate>
      <guid>https://community.cisco.com/t5/endpoint-security/api-query-with-an-exact-match/m-p/5123405#M8384</guid>
      <dc:creator>Ken Stieers</dc:creator>
      <dc:date>2024-06-03T13:18:56Z</dc:date>
    </item>
  </channel>
</rss>

