<?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: SOAR Cloud - Bulk Delete Containers through API? in Splunk SOAR</title>
    <link>https://community.splunk.com/t5/Splunk-SOAR/SOAR-Cloud-Bulk-Delete-Containers-through-API/m-p/614995#M973</link>
    <description>&lt;P&gt;Only just thought to check dev tools on my browser when deleting multiple containers, and yep - there is a way to pass the data so that it deletes multiple.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;curl -X DELETE -H 'Content-Tpe: application/json' -H "ph-auth-token: &amp;lt;token&amp;gt;"  -d "{'ids': [1234, 1235, 1236, 1237]}"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(might need to slightly play around with this curl statement, as i haven't tried it.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;And in Python it would look something like this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;data = {"ids": [1234, 12345, 1236, 1237]}
requests.delete("https://&amp;lt;soar_base_url_here&amp;gt;/container/"), headers={"ph-auth-token": "&amp;lt;some_token_here&amp;gt;"}, data=json.dumps(data), verify=False)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Enjoy!&lt;/P&gt;</description>
    <pubDate>Wed, 28 Sep 2022 12:41:01 GMT</pubDate>
    <dc:creator>CS_</dc:creator>
    <dc:date>2022-09-28T12:41:01Z</dc:date>
    <item>
      <title>SOAR Cloud - Bulk Delete Containers through API?</title>
      <link>https://community.splunk.com/t5/Splunk-SOAR/SOAR-Cloud-Bulk-Delete-Containers-through-API/m-p/614959#M970</link>
      <description>&lt;P&gt;Hey all,&lt;BR /&gt;&lt;BR /&gt;I'm trying to find a way to bulk delete containers via the API in SOAR Cloud.&lt;BR /&gt;&lt;BR /&gt;Had an issue where Splunk created ~8000 containers&amp;nbsp; to one of my labels when testing, and no way am i going to sit here for an hour deleting them in the GUI.&lt;BR /&gt;&lt;BR /&gt;I've read this post: &lt;A title="How-to-Delete-Multiple-container" href="https://community.splunk.com/t5/Splunk-SOAR-f-k-a-Phantom/How-to-Delete-Multiple-container/m-p/427025" target="_self"&gt;How-to-Delete-Multiple-container&lt;/A&gt;&amp;nbsp;but that really only points me to the single requests.delete option - which is very slow.&lt;BR /&gt;&lt;BR /&gt;I can bulk update containers to change the status using requests.post and a list of container id's, but don't see any way to bulk delete.&lt;BR /&gt;&lt;BR /&gt;For context a for loop + requests.delete on each single container is actually slower than deleting them via the GUI.&lt;BR /&gt;&lt;BR /&gt;Am I missing it somewhere, or is this just not possible through API?&lt;/P&gt;</description>
      <pubDate>Wed, 28 Sep 2022 10:41:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-SOAR/SOAR-Cloud-Bulk-Delete-Containers-through-API/m-p/614959#M970</guid>
      <dc:creator>CS_</dc:creator>
      <dc:date>2022-09-28T10:41:52Z</dc:date>
    </item>
    <item>
      <title>Re: SOAR Cloud - Bulk Delete Containers through API?</title>
      <link>https://community.splunk.com/t5/Splunk-SOAR/SOAR-Cloud-Bulk-Delete-Containers-through-API/m-p/614982#M972</link>
      <description>&lt;P&gt;I just wrote a quick script to handle it, using multiprocessing.&lt;BR /&gt;&lt;BR /&gt;If&amp;nbsp; you want to use it, just be careful how many API requests you are sending to your SOAR instance, and that it can handle it. Use at your own risk.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import requests
import multiprocessing

headers = {"ph-auth-token": "&amp;lt;some auth token here&amp;gt;"}
label = "&amp;lt;some label here&amp;gt;"
soar_base_url = "https://&amp;lt;replace_me.with.soar.url&amp;gt;"

# A function to for multiprocessing
def delete_container(container_id):
    requests.delete("{}/container/{}".format(soar_base_url, container_id), headers=headers, verify=False)
    print(container_id, " - Deleted")

# This is an example search that will get 50 Events from a label that are in the "new" status
# It will then sort them in ascending order (oldest to newset)
res = requests.get("{}/container/?page=0&amp;amp;page_size=50&amp;amp;sort=id&amp;amp;order=asc&amp;amp;_filter_label__in=['{}']&amp;amp;_filter_status__name='new'".format(soar_base_url, label), headers=headers, verify=False)
container_ids = [container_id["id"] for container_id in res.json()["data"]]

for container_id in container_ids:
    p = multiprocessing.Process(target=delete_container, args=(container_id,))
    p.start()
&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 28 Sep 2022 12:00:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-SOAR/SOAR-Cloud-Bulk-Delete-Containers-through-API/m-p/614982#M972</guid>
      <dc:creator>CS_</dc:creator>
      <dc:date>2022-09-28T12:00:20Z</dc:date>
    </item>
    <item>
      <title>Re: SOAR Cloud - Bulk Delete Containers through API?</title>
      <link>https://community.splunk.com/t5/Splunk-SOAR/SOAR-Cloud-Bulk-Delete-Containers-through-API/m-p/614995#M973</link>
      <description>&lt;P&gt;Only just thought to check dev tools on my browser when deleting multiple containers, and yep - there is a way to pass the data so that it deletes multiple.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;curl -X DELETE -H 'Content-Tpe: application/json' -H "ph-auth-token: &amp;lt;token&amp;gt;"  -d "{'ids': [1234, 1235, 1236, 1237]}"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(might need to slightly play around with this curl statement, as i haven't tried it.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;And in Python it would look something like this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;data = {"ids": [1234, 12345, 1236, 1237]}
requests.delete("https://&amp;lt;soar_base_url_here&amp;gt;/container/"), headers={"ph-auth-token": "&amp;lt;some_token_here&amp;gt;"}, data=json.dumps(data), verify=False)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Enjoy!&lt;/P&gt;</description>
      <pubDate>Wed, 28 Sep 2022 12:41:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-SOAR/SOAR-Cloud-Bulk-Delete-Containers-through-API/m-p/614995#M973</guid>
      <dc:creator>CS_</dc:creator>
      <dc:date>2022-09-28T12:41:01Z</dc:date>
    </item>
  </channel>
</rss>

