<?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 How to create or update KV Store via REST endpoints? in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/How-to-create-or-update-KV-Store-via-REST-endpoints/m-p/208070#M41022</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;I want to fill my KVStore with information from a script. The script adds data via a REST Endpoint to the KVStore. &lt;/P&gt;

&lt;P&gt;The key in the store is a hostname of a machine. The problem is, if I want to add a new host to the KVStore, but there is already an entry for this host, I will get an error. On the other hand, I can't use the "Update-method" because if it is a new host, I will get the an error as well.&lt;/P&gt;

&lt;P&gt;I know that I could handle this problem in my script, but I wanted to know if there is a "clever" update function:&lt;/P&gt;

&lt;P&gt;If there is a record in the KVStore then update the item, and if there isn't, create a new one.&lt;/P&gt;

&lt;P&gt;thank you in advance.&lt;/P&gt;</description>
    <pubDate>Thu, 18 Feb 2016 14:14:02 GMT</pubDate>
    <dc:creator>hypePG</dc:creator>
    <dc:date>2016-02-18T14:14:02Z</dc:date>
    <item>
      <title>How to create or update KV Store via REST endpoints?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-create-or-update-KV-Store-via-REST-endpoints/m-p/208070#M41022</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;I want to fill my KVStore with information from a script. The script adds data via a REST Endpoint to the KVStore. &lt;/P&gt;

&lt;P&gt;The key in the store is a hostname of a machine. The problem is, if I want to add a new host to the KVStore, but there is already an entry for this host, I will get an error. On the other hand, I can't use the "Update-method" because if it is a new host, I will get the an error as well.&lt;/P&gt;

&lt;P&gt;I know that I could handle this problem in my script, but I wanted to know if there is a "clever" update function:&lt;/P&gt;

&lt;P&gt;If there is a record in the KVStore then update the item, and if there isn't, create a new one.&lt;/P&gt;

&lt;P&gt;thank you in advance.&lt;/P&gt;</description>
      <pubDate>Thu, 18 Feb 2016 14:14:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-create-or-update-KV-Store-via-REST-endpoints/m-p/208070#M41022</guid>
      <dc:creator>hypePG</dc:creator>
      <dc:date>2016-02-18T14:14:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to create or update KV Store via REST endpoints?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-create-or-update-KV-Store-via-REST-endpoints/m-p/208071#M41023</link>
      <description>&lt;P&gt;I don't think there is an update function to insert/update records in KV Store with that level of intelligence.&lt;/P&gt;

&lt;P&gt;As you said, you can handle this by two way approach in your script using the respective REST End Points. &lt;/P&gt;

&lt;OL&gt;
&lt;LI&gt;Query the KV Store for the existence of the Key&lt;/LI&gt;
&lt;LI&gt;If present, use the &lt;CODE&gt;storage/collections/data/{collection}/{id}&lt;/CODE&gt; end point to update the record&lt;/LI&gt;
&lt;LI&gt;else, use &lt;CODE&gt;storage/collections/data/{collection}/&lt;/CODE&gt; to insert a new record&lt;/LI&gt;
&lt;/OL&gt;

&lt;P&gt;Please refer the links for more details / examples&lt;BR /&gt;
&lt;A href="http://docs.splunk.com/Documentation/Splunk/6.2.2/RESTREF/RESTkvstore"&gt;http://docs.splunk.com/Documentation/Splunk/6.2.2/RESTREF/RESTkvstore&lt;/A&gt;&lt;BR /&gt;
&lt;A href="http://docs.splunk.com/Documentation/Splunk/6.3.3/RESTREF/RESTkvstoreExamples"&gt;http://docs.splunk.com/Documentation/Splunk/6.3.3/RESTREF/RESTkvstoreExamples&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Feb 2016 23:07:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-create-or-update-KV-Store-via-REST-endpoints/m-p/208071#M41023</guid>
      <dc:creator>Murali2888</dc:creator>
      <dc:date>2016-02-18T23:07:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to create or update KV Store via REST endpoints?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-create-or-update-KV-Store-via-REST-endpoints/m-p/208072#M41024</link>
      <description>&lt;P&gt;hi,&lt;/P&gt;

&lt;P&gt;try follow this link: &lt;BR /&gt;
&lt;A href="http://dev.splunk.com/view/webframework-developapps/SP-CAAAEZG"&gt;http://dev.splunk.com/view/webframework-developapps/SP-CAAAEZG&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Feb 2016 23:49:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-create-or-update-KV-Store-via-REST-endpoints/m-p/208072#M41024</guid>
      <dc:creator>gyslainlatsa</dc:creator>
      <dc:date>2016-02-18T23:49:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to create or update KV Store via REST endpoints?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-create-or-update-KV-Store-via-REST-endpoints/m-p/208073#M41025</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;thank you for your answers. The batch_save operation is exactly doing this job.&lt;/P&gt;

&lt;P&gt;thanks!&lt;/P&gt;</description>
      <pubDate>Fri, 19 Feb 2016 08:53:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-create-or-update-KV-Store-via-REST-endpoints/m-p/208073#M41025</guid>
      <dc:creator>hypePG</dc:creator>
      <dc:date>2016-02-19T08:53:13Z</dc:date>
    </item>
  </channel>
</rss>

