@@ -295,7 +295,7 @@ def connect(**kwargs):
295295 :type port: ``integer``
296296 :param scheme: The scheme for accessing the service (the default is "https").
297297 :type scheme: "https" or "http"
298- :param verify: Enable (True) or disable (False) SSL verrification for
298+ :param verify: Enable (True) or disable (False) SSL verification for
299299 https connections. (optional, the default is True)
300300 :type verify: ``Boolean``
301301 :param `owner`: The owner context of the namespace (optional).
@@ -318,6 +318,8 @@ def connect(**kwargs):
318318 :type username: ``string``
319319 :param `password`: The password for the Splunk account.
320320 :type password: ``string``
321+ :param `context`: The SSLContext that can be used when setting verify=True (optional)
322+ :type context: ``SSLContext``
321323 :return: An initialized :class:`Service` connection.
322324
323325 **Example**::
@@ -365,7 +367,7 @@ class Service(_BaseService):
365367 :type port: ``integer``
366368 :param scheme: The scheme for accessing the service (the default is "https").
367369 :type scheme: "https" or "http"
368- :param verify: Enable (True) or disable (False) SSL verrification for
370+ :param verify: Enable (True) or disable (False) SSL verification for
369371 https connections. (optional, the default is True)
370372 :type verify: ``Boolean``
371373 :param `owner`: The owner context of the namespace (optional; use "-" for wildcard).
@@ -401,6 +403,7 @@ class Service(_BaseService):
401403 def __init__ (self , ** kwargs ):
402404 super (Service , self ).__init__ (** kwargs )
403405 self ._splunk_version = None
406+ self ._kvstore_owner = None
404407
405408 @property
406409 def apps (self ):
@@ -673,12 +676,34 @@ def splunk_version(self):
673676 self ._splunk_version = tuple ([int (p ) for p in self .info ['version' ].split ('.' )])
674677 return self ._splunk_version
675678
679+ @property
680+ def kvstore_owner (self ):
681+ """Returns the KVStore owner for this instance of Splunk.
682+
683+ By default is the kvstore owner is not set, it will return "nobody"
684+ :return: A string with the KVStore owner.
685+ """
686+ if self ._kvstore_owner is None :
687+ self ._kvstore_owner = "nobody"
688+ return self ._kvstore_owner
689+
690+ @kvstore_owner .setter
691+ def kvstore_owner (self , value ):
692+ """
693+ kvstore is refreshed, when the owner value is changed
694+ """
695+ self ._kvstore_owner = value
696+ self .kvstore
697+
676698 @property
677699 def kvstore (self ):
678700 """Returns the collection of KV Store collections.
679701
702+ sets the owner for the namespace, before retrieving the KVStore Collection
703+
680704 :return: A :class:`KVStoreCollections` collection of :class:`KVStoreCollection` entities.
681705 """
706+ self .namespace ['owner' ] = self .kvstore_owner
682707 return KVStoreCollections (self )
683708
684709 @property
@@ -856,7 +881,7 @@ class Entity(Endpoint):
856881 ent.whitelist
857882
858883 However, because some of the field names are not valid Python identifiers,
859- the dictionary-like syntax is preferrable .
884+ the dictionary-like syntax is preferable .
860885
861886 The state of an :class:`Entity` object is cached, so accessing a field
862887 does not contact the server. If you think the values on the
@@ -3619,7 +3644,7 @@ def __init__(self, collection):
36193644 self .service = collection .service
36203645 self .collection = collection
36213646 self .owner , self .app , self .sharing = collection ._proper_namespace ()
3622- self .path = 'storage/collections/data/' + UrlEncoded (self .collection .name ) + '/'
3647+ self .path = 'storage/collections/data/' + UrlEncoded (self .collection .name , encode_slash = True ) + '/'
36233648
36243649 def _get (self , url , ** kwargs ):
36253650 return self .service .get (self .path + url , owner = self .owner , app = self .app , sharing = self .sharing , ** kwargs )
@@ -3640,6 +3665,11 @@ def query(self, **query):
36403665 :return: Array of documents retrieved by query.
36413666 :rtype: ``array``
36423667 """
3668+
3669+ for key , value in query .items ():
3670+ if isinstance (query [key ], dict ):
3671+ query [key ] = json .dumps (value )
3672+
36433673 return json .loads (self ._get ('' , ** query ).body .read ().decode ('utf-8' ))
36443674
36453675 def query_by_id (self , id ):
@@ -3652,7 +3682,7 @@ def query_by_id(self, id):
36523682 :return: Document with id
36533683 :rtype: ``dict``
36543684 """
3655- return json .loads (self ._get (UrlEncoded (str (id ))).body .read ().decode ('utf-8' ))
3685+ return json .loads (self ._get (UrlEncoded (str (id ), encode_slash = True )).body .read ().decode ('utf-8' ))
36563686
36573687 def insert (self , data ):
36583688 """
@@ -3664,6 +3694,8 @@ def insert(self, data):
36643694 :return: _id of inserted object
36653695 :rtype: ``dict``
36663696 """
3697+ if isinstance (data , dict ):
3698+ data = json .dumps (data )
36673699 return json .loads (self ._post ('' , headers = KVStoreCollectionData .JSON_HEADER , body = data ).body .read ().decode ('utf-8' ))
36683700
36693701 def delete (self , query = None ):
@@ -3686,7 +3718,7 @@ def delete_by_id(self, id):
36863718
36873719 :return: Result of DELETE request
36883720 """
3689- return self ._delete (UrlEncoded (str (id )))
3721+ return self ._delete (UrlEncoded (str (id ), encode_slash = True ))
36903722
36913723 def update (self , id , data ):
36923724 """
@@ -3700,7 +3732,9 @@ def update(self, id, data):
37003732 :return: id of replaced document
37013733 :rtype: ``dict``
37023734 """
3703- return json .loads (self ._post (UrlEncoded (str (id )), headers = KVStoreCollectionData .JSON_HEADER , body = data ).body .read ().decode ('utf-8' ))
3735+ if isinstance (data , dict ):
3736+ data = json .dumps (data )
3737+ return json .loads (self ._post (UrlEncoded (str (id ), encode_slash = True ), headers = KVStoreCollectionData .JSON_HEADER , body = data ).body .read ().decode ('utf-8' ))
37043738
37053739 def batch_find (self , * dbqueries ):
37063740 """
0 commit comments