Code stringlengths 103 85.9k | Summary listlengths 0 94 |
|---|---|
Please provide a description of the function:def unlock(self, key, cas):
return _Base.unlock(self, key, cas=cas) | [
"Unlock a Locked Key in Couchbase.\n\n This unlocks an item previously locked by :meth:`lock`\n\n :param key: The key to unlock\n :param cas: The cas returned from :meth:`lock`'s\n :class:`.Result` object.\n\n See :meth:`lock` for an example.\n\n :raise: :exc:`.Temporar... |
Please provide a description of the function:def remove(self, key, cas=0, quiet=None, persist_to=0, replicate_to=0):
return _Base.remove(self, key, cas=cas, quiet=quiet,
persist_to=persist_to, replicate_to=replicate_to) | [
"Remove the key-value entry for a given key in Couchbase.\n\n :param key: A string which is the key to remove. The format and\n type of the key follows the same conventions as in\n :meth:`upsert`\n :type key: string, dict, or tuple/list\n\n :param int cas: The CAS to use f... |
Please provide a description of the function:def counter(self, key, delta=1, initial=None, ttl=0):
return _Base.counter(self, key, delta=delta, initial=initial, ttl=ttl) | [
"Increment or decrement the numeric value of an item.\n\n This method instructs the server to treat the item stored under\n the given key as a numeric counter.\n\n Counter operations require that the stored value\n exists as a string representation of a number (e.g. ``123``). If\n ... |
Please provide a description of the function:def mutate_in(self, key, *specs, **kwargs):
# Note we don't verify the validity of the options. lcb does that for
# us.
sdflags = kwargs.pop('_sd_doc_flags', 0)
if kwargs.pop('insert_doc', False):
sdflags |= _P.CMDSUBDOC... | [
"Perform multiple atomic modifications within a document.\n\n :param key: The key of the document to modify\n :param specs: A list of specs (See :mod:`.couchbase.subdocument`)\n :param bool create_doc:\n Whether the document should be create if it doesn't exist\n :param bool i... |
Please provide a description of the function:def lookup_in(self, key, *specs, **kwargs):
return super(Bucket, self).lookup_in({key: specs}, **kwargs) | [
"Atomically retrieve one or more paths from a document.\n\n :param key: The key of the document to lookup\n :param spec: A list of specs (see :mod:`.couchbase.subdocument`)\n :return: A :class:`.couchbase.result.SubdocResult` object.\n This object contains the results and any errors ... |
Please provide a description of the function:def retrieve_in(self, key, *paths, **kwargs):
import couchbase.subdocument as SD
return self.lookup_in(key, *tuple(SD.get(x) for x in paths), **kwargs) | [
"Atomically fetch one or more paths from a document.\n\n Convenience method for retrieval operations. This functions\n identically to :meth:`lookup_in`. As such, the following two\n forms are equivalent:\n\n .. code-block:: python\n\n import couchbase.subdocument as SD\n ... |
Please provide a description of the function:def stats(self, keys=None, keystats=False):
if keys and not isinstance(keys, (tuple, list)):
keys = (keys,)
return self._stats(keys, keystats=keystats) | [
"Request server statistics.\n\n Fetches stats from each node in the cluster. Without a key\n specified the server will respond with a default set of\n statistical information. It returns the a `dict` with stats keys\n and node-value pairs as a value.\n\n :param keys: One or severa... |
Please provide a description of the function:def observe(self, key, master_only=False):
return _Base.observe(self, key, master_only=master_only) | [
"Return storage information for a key.\n\n It returns a :class:`.ValueResult` object with the ``value``\n field set to a list of :class:`~.ObserveInfo` objects. Each\n element in the list responds to the storage status for the key\n on the given node. The length of the list (and thus the... |
Please provide a description of the function:def endure(self, key, persist_to=-1, replicate_to=-1, cas=0,
check_removed=False, timeout=5.0, interval=0.010):
# We really just wrap 'endure_multi'
kv = {key: cas}
rvs = self.endure_multi(keys=kv, persist_to=persist_to,
... | [
"Wait until a key has been distributed to one or more nodes\n\n By default, when items are stored to Couchbase, the operation is\n considered successful if the vBucket master (i.e. the \"primary\"\n node) for the key has successfully stored the item in its\n memory.\n\n In most si... |
Please provide a description of the function:def durability(self, persist_to=-1, replicate_to=-1, timeout=0.0):
return DurabilityContext(self, persist_to, replicate_to, timeout) | [
"Returns a context manager which will apply the given\n persistence/replication settings to all mutation operations when\n active\n\n :param int persist_to:\n :param int replicate_to:\n\n See :meth:`endure` for the meaning of these two values\n\n Thus, something like::\n\n ... |
Please provide a description of the function:def upsert_multi(self, keys, ttl=0, format=None, persist_to=0, replicate_to=0):
return _Base.upsert_multi(self, keys, ttl=ttl, format=format,
persist_to=persist_to,
replicate_to=replicate_to... | [
"\n Write multiple items to the cluster. Multi version of :meth:`upsert`\n\n :param dict keys: A dictionary of keys to set. The keys are the\n keys as they should be on the server, and the values are the\n values for the keys to be stored.\n\n `keys` may also be a :cla... |
Please provide a description of the function:def insert_multi(self, keys, ttl=0, format=None, persist_to=0, replicate_to=0):
return _Base.insert_multi(self, keys, ttl=ttl, format=format,
persist_to=persist_to,
replicate_to=replicate_to... | [
"Add multiple keys. Multi variant of :meth:`insert`\n\n .. seealso:: :meth:`insert`, :meth:`upsert_multi`, :meth:`upsert`\n "
] |
Please provide a description of the function:def replace_multi(self, keys, ttl=0, format=None,
persist_to=0, replicate_to=0):
return _Base.replace_multi(self, keys, ttl=ttl, format=format,
persist_to=persist_to,
... | [
"Replace multiple keys. Multi variant of :meth:`replace`\n\n .. seealso:: :meth:`replace`, :meth:`upsert_multi`, :meth:`upsert`\n "
] |
Please provide a description of the function:def append_multi(self, keys, format=None, persist_to=0, replicate_to=0):
return _Base.append_multi(self, keys, format=format,
persist_to=persist_to,
replicate_to=replicate_to) | [
"Append to multiple keys. Multi variant of :meth:`append`.\n\n .. warning::\n\n If using the `Item` interface, use the :meth:`append_items`\n and :meth:`prepend_items` instead, as those will\n automatically update the :attr:`.Item.value`\n property upon successful ... |
Please provide a description of the function:def prepend_multi(self, keys, format=None, persist_to=0, replicate_to=0):
return _Base.prepend_multi(self, keys, format=format,
persist_to=persist_to,
replicate_to=replicate_to) | [
"Prepend to multiple keys. Multi variant of :meth:`prepend`\n\n .. seealso:: :meth:`prepend`, :meth:`upsert_multi`, :meth:`upsert`\n "
] |
Please provide a description of the function:def get_multi(self, keys, ttl=0, quiet=None, replica=False, no_format=False):
return _Base.get_multi(self, keys, ttl=ttl, quiet=quiet,
replica=replica, no_format=no_format) | [
"Get multiple keys. Multi variant of :meth:`get`\n\n :param keys: keys the keys to fetch\n :type keys: :ref:`iterable<argtypes>`\n :param int ttl: Set the expiration for all keys when retrieving\n :param boolean replica:\n Whether the results should be obtained from a replica\... |
Please provide a description of the function:def touch_multi(self, keys, ttl=0):
return _Base.touch_multi(self, keys, ttl=ttl) | [
"Touch multiple keys. Multi variant of :meth:`touch`\n\n :param keys: the keys to touch\n :type keys: :ref:`iterable<argtypes>`.\n ``keys`` can also be a dictionary with values being\n integers, in which case the value for each key will be used\n as the TTL instead of ... |
Please provide a description of the function:def lock_multi(self, keys, ttl=0):
return _Base.lock_multi(self, keys, ttl=ttl) | [
"Lock multiple keys. Multi variant of :meth:`lock`\n\n :param keys: the keys to lock\n :type keys: :ref:`iterable<argtypes>`\n :param int ttl: The lock timeout for all keys\n\n :return: a :class:`~.MultiResult` object\n\n .. seealso:: :meth:`lock`\n "
] |
Please provide a description of the function:def observe_multi(self, keys, master_only=False):
return _Base.observe_multi(self, keys, master_only=master_only) | [
"Multi-variant of :meth:`observe`"
] |
Please provide a description of the function:def endure_multi(self, keys, persist_to=-1, replicate_to=-1,
timeout=5.0, interval=0.010, check_removed=False):
return _Base.endure_multi(self, keys, persist_to=persist_to,
replicate_to=replicate_to,
... | [
"Check durability requirements for multiple keys\n\n :param keys: The keys to check\n\n The type of keys may be one of the following:\n * Sequence of keys\n * A :class:`~couchbase.result.MultiResult` object\n * A ``dict`` with CAS values as the dictionary value\n ... |
Please provide a description of the function:def remove_multi(self, kvs, quiet=None):
return _Base.remove_multi(self, kvs, quiet=quiet) | [
"Remove multiple items from the cluster\n\n :param kvs: Iterable of keys to delete from the cluster. If you wish\n to specify a CAS for each item, then you may pass a dictionary\n of keys mapping to cas, like `remove_multi({k1:cas1, k2:cas2}`)\n :param quiet: Whether an exception... |
Please provide a description of the function:def counter_multi(self, kvs, initial=None, delta=1, ttl=0):
return _Base.counter_multi(self, kvs, initial=initial, delta=delta,
ttl=ttl) | [
"Perform counter operations on multiple items\n\n :param kvs: Keys to operate on. See below for more options\n :param initial: Initial value to use for all keys.\n :param delta: Delta value for all keys.\n :param ttl: Expiration value to use for all keys\n\n :return: A :class:`~.M... |
Please provide a description of the function:def rget(self, key, replica_index=None, quiet=None):
if replica_index is not None:
return _Base._rgetix(self, key, replica=replica_index, quiet=quiet)
else:
return _Base._rget(self, key, quiet=quiet) | [
"Get an item from a replica node\n\n :param string key: The key to fetch\n :param int replica_index: The replica index to fetch.\n If this is ``None`` then this method will return once any\n replica responds. Use :attr:`configured_replica_count` to\n figure out the upp... |
Please provide a description of the function:def _view(self, ddoc, view,
use_devmode=False,
params=None,
unrecognized_ok=False,
passthrough=False):
if params:
if not isinstance(params, str):
params = make_options_strin... | [
"Internal method to Execute a view (MapReduce) query\n\n :param string ddoc: Name of the design document\n :param string view: Name of the view function to execute\n :param params: Extra options to pass to the view engine\n :type params: string or dict\n :return: a :class:`~couchb... |
Please provide a description of the function:def query(self, design, view, use_devmode=False, **kwargs):
design = self._mk_devmode(design, use_devmode)
itercls = kwargs.pop('itercls', View)
return itercls(self, design, view, **kwargs) | [
"\n Query a pre-defined MapReduce view, passing parameters.\n\n This method executes a view on the cluster. It accepts various\n parameters for the view and returns an iterable object\n (specifically, a :class:`~.View`).\n\n :param string design: The design document\n :para... |
Please provide a description of the function:def n1ql_query(self, query, *args, **kwargs):
if not isinstance(query, N1QLQuery):
query = N1QLQuery(query)
itercls = kwargs.pop('itercls', N1QLRequest)
return itercls(query, self, *args, **kwargs) | [
"\n Execute a N1QL query.\n\n This method is mainly a wrapper around the :class:`~.N1QLQuery`\n and :class:`~.N1QLRequest` objects, which contain the inputs\n and outputs of the query.\n\n Using an explicit :class:`~.N1QLQuery`::\n\n query = N1QLQuery(\n ... |
Please provide a description of the function:def analytics_query(self, query, host, *args, **kwargs):
if not isinstance(query, AnalyticsQuery):
query = AnalyticsQuery(query, *args, **kwargs)
else:
query.update(*args, **kwargs)
return couchbase.analytics.gen_requ... | [
"\n Execute an Analytics query.\n\n This method is mainly a wrapper around the :class:`~.AnalyticsQuery`\n and :class:`~.AnalyticsRequest` objects, which contain the inputs\n and outputs of the query.\n\n Using an explicit :class:`~.AnalyticsQuery`::\n\n query = Analyti... |
Please provide a description of the function:def search(self, index, query, **kwargs):
itercls = kwargs.pop('itercls', _FTS.SearchRequest)
iterargs = itercls.mk_kwargs(kwargs)
params = kwargs.pop('params', _FTS.Params(**kwargs))
body = _FTS.make_search_body(index, query, params)... | [
"\n Perform full-text searches\n\n .. versionadded:: 2.0.9\n\n .. warning::\n\n The full-text search API is experimental and subject to change\n\n :param str index: Name of the index to query\n :param couchbase.fulltext.SearchQuery query: Query to issue\n :param ... |
Please provide a description of the function:def append_items(self, items, **kwargs):
rv = self.append_multi(items, **kwargs)
# Assume this is an 'ItemOptionDict'
for k, v in items.dict.items():
if k.success:
k.value += v['fragment']
return rv | [
"\n Method to append data to multiple :class:`~.Item` objects.\n\n This method differs from the normal :meth:`append_multi` in that\n each `Item`'s `value` field is updated with the appended data\n upon successful completion of the operation.\n\n\n :param items: The item dictionar... |
Please provide a description of the function:def prepend_items(self, items, **kwargs):
rv = self.prepend_multi(items, **kwargs)
for k, v in items.dict.items():
if k.success:
k.value = v['fragment'] + k.value
return rv | [
"Method to prepend data to multiple :class:`~.Item` objects.\n .. seealso:: :meth:`append_items`\n "
] |
Please provide a description of the function:def is_ssl(self):
mode = self._cntl(op=_LCB.LCB_CNTL_SSL_MODE, value_type='int')
return mode & _LCB.LCB_SSL_ENABLED != 0 | [
"\n Read-only boolean property indicating whether SSL is used for\n this connection.\n\n If this property is true, then all communication between this\n object and the Couchbase cluster is encrypted using SSL.\n\n See :meth:`__init__` for more information on connection options.\n ... |
Please provide a description of the function:def _gen_memd_wrappers(cls, factory):
d = {}
for n in cls._MEMCACHED_OPERATIONS:
for variant in (n, n + "_multi"):
try:
d[variant] = factory(getattr(cls, variant), variant)
except Attrib... | [
"Generates wrappers for all the memcached operations.\n :param factory: A function to be called to return the wrapped\n method. It will be called with two arguments; the first is\n the unbound method being wrapped, and the second is the name\n of such a method.\n\n T... |
Please provide a description of the function:def flush(self):
path = '/pools/default/buckets/{0}/controller/doFlush'
path = path.format(self.bucket)
return self._http_request(type=_LCB.LCB_HTTP_TYPE_MANAGEMENT,
path=path, method=_LCB.LCB_HTTP_METHOD_POS... | [
"\n Clears the bucket's contents.\n\n .. note::\n\n This functionality requires that the flush option be\n enabled for the bucket by the cluster administrator. You\n can enable flush on the bucket using the administrative\n console (See http://docs.couchbase... |
Please provide a description of the function:def map_add(self, key, mapkey, value, create=False, **kwargs):
op = SD.upsert(mapkey, value)
sdres = self.mutate_in(key, op, **kwargs)
return self._wrap_dsop(sdres) | [
"\n Set a value for a key in a map.\n\n .. warning::\n\n The functionality of the various `map_*`, `list_*`, `queue_*`\n and `set_*` functions are considered experimental and are included\n in the library to demonstrate new functionality.\n They may change i... |
Please provide a description of the function:def map_get(self, key, mapkey):
op = SD.get(mapkey)
sdres = self.lookup_in(key, op)
return self._wrap_dsop(sdres, True) | [
"\n Retrieve a value from a map.\n\n :param str key: The document ID\n :param str mapkey: Key within the map to retrieve\n :return: :class:`~.ValueResult`\n :raise: :exc:`IndexError` if the mapkey does not exist\n :raise: :cb_exc:`NotFoundError` if the document does not exi... |
Please provide a description of the function:def map_remove(self, key, mapkey, **kwargs):
op = SD.remove(mapkey)
sdres = self.mutate_in(key, op, **kwargs)
return self._wrap_dsop(sdres) | [
"\n Remove an item from a map.\n\n :param str key: The document ID\n :param str mapkey: The key in the map\n :param kwargs: See :meth:`mutate_in` for options\n :raise: :exc:`IndexError` if the mapkey does not exist\n :raise: :cb_exc:`NotFoundError` if the document does not ... |
Please provide a description of the function:def map_size(self, key):
# TODO: This should use get_count, but we need to check for compat
# with server version (i.e. >= 4.6) first; otherwise it just
# disconnects.
rv = self.get(key)
return len(rv.value) | [
"\n Get the number of items in the map.\n\n :param str key: The document ID of the map\n :return int: The number of items in the map\n :raise: :cb_exc:`NotFoundError` if the document does not exist.\n\n .. seealso:: :meth:`map_add`\n "
] |
Please provide a description of the function:def list_append(self, key, value, create=False, **kwargs):
op = SD.array_append('', value)
sdres = self.mutate_in(key, op, **kwargs)
return self._wrap_dsop(sdres) | [
"\n Add an item to the end of a list.\n\n :param str key: The document ID of the list\n :param value: The value to append\n :param create: Whether the list should be created if it does not\n exist. Note that this option only works on servers >= 4.6\n :param kwargs: A... |
Please provide a description of the function:def list_prepend(self, key, value, create=False, **kwargs):
op = SD.array_prepend('', value)
sdres = self.mutate_in(key, op, **kwargs)
return self._wrap_dsop(sdres) | [
"\n Add an item to the beginning of a list.\n\n :param str key: Document ID\n :param value: Value to prepend\n :param bool create:\n Whether the list should be created if it does not exist\n :param kwargs: Additional arguments to :meth:`mutate_in`.\n :return: :cl... |
Please provide a description of the function:def list_set(self, key, index, value, **kwargs):
op = SD.replace('[{0}]'.format(index), value)
sdres = self.mutate_in(key, op, **kwargs)
return self._wrap_dsop(sdres) | [
"\n Sets an item within a list at a given position.\n\n :param key: The key of the document\n :param index: The position to replace\n :param value: The value to be inserted\n :param kwargs: Additional arguments to :meth:`mutate_in`\n :return: :class:`OperationResult`\n ... |
Please provide a description of the function:def set_add(self, key, value, create=False, **kwargs):
op = SD.array_addunique('', value)
try:
sdres = self.mutate_in(key, op, **kwargs)
return self._wrap_dsop(sdres)
except E.SubdocPathExistsError:
pass | [
"\n Add an item to a set if the item does not yet exist.\n\n :param key: The document ID\n :param value: Value to add\n :param create: Create the set if it does not exist\n :param kwargs: Arguments to :meth:`mutate_in`\n :return: A :class:`~.OperationResult` if the item was... |
Please provide a description of the function:def set_remove(self, key, value, **kwargs):
while True:
rv = self.get(key)
try:
ix = rv.value.index(value)
kwargs['cas'] = rv.cas
return self.list_remove(key, ix, **kwargs)
e... | [
"\n Remove an item from a set.\n\n :param key: The docuent ID\n :param value: Value to remove\n :param kwargs: Arguments to :meth:`mutate_in`\n :return: A :class:`OperationResult` if the item was removed, false\n otherwise\n :raise: :cb_exc:`NotFoundError` i... |
Please provide a description of the function:def set_contains(self, key, value):
rv = self.get(key)
return value in rv.value | [
"\n Determine if an item exists in a set\n :param key: The document ID of the set\n :param value: The value to check for\n :return: True if `value` exists in the set\n :raise: :cb_exc:`NotFoundError` if the document does not exist\n "
] |
Please provide a description of the function:def list_remove(self, key, index, **kwargs):
return self.map_remove(key, '[{0}]'.format(index), **kwargs) | [
"\n Remove the element at a specific index from a list.\n\n :param key: The document ID of the list\n :param index: The index to remove\n :param kwargs: Arguments to :meth:`mutate_in`\n :return: :class:`OperationResult`\n :raise: :exc:`IndexError` if the index does not exis... |
Please provide a description of the function:def queue_push(self, key, value, create=False, **kwargs):
return self.list_prepend(key, value, **kwargs) | [
"\n Add an item to the end of a queue.\n\n :param key: The document ID of the queue\n :param value: The item to add to the queue\n :param create: Whether the queue should be created if it does not exist\n :param kwargs: Arguments to pass to :meth:`mutate_in`\n :return: :cla... |
Please provide a description of the function:def queue_pop(self, key, **kwargs):
while True:
try:
itm = self.list_get(key, -1)
except IndexError:
raise E.QueueEmpty
kwargs['cas'] = itm.cas
try:
self.list_re... | [
"\n Remove and return the first item queue.\n\n :param key: The document ID\n :param kwargs: Arguments passed to :meth:`mutate_in`\n :return: A :class:`ValueResult`\n :raise: :cb_exc:`QueueEmpty` if there are no items in the queue.\n :raise: :cb_exc:`NotFoundError` if the q... |
Please provide a description of the function:def encrypt_fields(self, document, fieldspec, prefix):
json_encoded = json.dumps(document)
encrypted_string = _Base.encrypt_fields(self, json_encoded, fieldspec, prefix)
if not encrypted_string:
raise couchbase.exceptions.Couchbas... | [
"\n Encrypt a document using the registered encryption providers.\n :param document: The document body.\n :param fieldspec: A list of field specifications, each of which is\n a dictionary as follows:\n {\n 'alg' : registered algorithm name,\n 'kid... |
Please provide a description of the function:def _callback(self, mres):
try:
rows = self._process_payload(self.raw.rows)
if rows:
self.on_rows(rows)
if self.raw.done:
self.on_done()
finally:
if self.raw.done:
... | [
"\n This is invoked as the row callback.\n If 'rows' is true, then we are a row callback, otherwise\n the request has ended and it's time to collect the other data\n "
] |
Please provide a description of the function:def create(cls, name, email, cb):
it = cls(name, create_structure=True)
it.value['email'] = email
# In an actual application you'd probably want to use 'add',
# but since this app might be run multiple times, you don't
# want... | [
"\n Create the basic structure of a player\n "
] |
Please provide a description of the function:def _doc_rev(self, res):
jstr = res.headers['X-Couchbase-Meta']
jobj = json.loads(jstr)
return jobj['rev'] | [
"\n Returns the rev id from the header\n "
] |
Please provide a description of the function:def _poll_vq_single(self, dname, use_devmode, ddresp):
vname = None
query = None
v_mr = ddresp.get('views', {})
v_spatial = ddresp.get('spatial', {})
if v_mr:
vname = single_dict_key(v_mr)
query = Query... | [
"\n Initiate a view query for a view located in a design document\n :param ddresp: The design document to poll (as JSON)\n :return: True if successful, False if no views.\n "
] |
Please provide a description of the function:def _design_poll(self, name, mode, oldres, timeout=5, use_devmode=False):
if not timeout:
return True
if timeout < 0:
raise ArgumentError.pyexc("Interval must not be negative")
t_end = time.time() + timeout
o... | [
"\n Poll for an 'async' action to be complete.\n :param string name: The name of the design document\n :param string mode: One of ``add`` or ``del`` to indicate whether\n we should check for addition or deletion of the document\n :param oldres: The old result from the document... |
Please provide a description of the function:def design_create(self, name, ddoc, use_devmode=True, syncwait=0):
name = self._cb._mk_devmode(name, use_devmode)
fqname = "_design/{0}".format(name)
if not isinstance(ddoc, dict):
ddoc = json.loads(ddoc)
ddoc = ddoc.cop... | [
"\n Store a design document\n\n :param string name: The name of the design\n :param ddoc: The actual contents of the design document\n\n :type ddoc: string or dict\n If ``ddoc`` is a string, it is passed, as-is, to the server.\n Otherwise it is serialized as JSON, a... |
Please provide a description of the function:def design_get(self, name, use_devmode=True):
name = self._mk_devmode(name, use_devmode)
existing = self._http_request(type=_LCB.LCB_HTTP_TYPE_VIEW,
path="_design/" + name,
... | [
"\n Retrieve a design document\n\n :param string name: The name of the design document\n :param bool use_devmode: Whether this design document is still in\n \"development\" mode\n\n :return: A :class:`~couchbase.result.HttpResult` containing\n a dict representing th... |
Please provide a description of the function:def design_publish(self, name, syncwait=0):
existing = self.design_get(name, use_devmode=True)
rv = self.design_create(name, existing.value, use_devmode=False,
syncwait=syncwait)
self.design_delete(name, use_devmode... | [
"\n Convert a development mode view into a production mode views.\n Production mode views, as opposed to development views, operate on the\n entire cluster data (rather than a restricted subset thereof).\n\n :param string name: The name of the view to convert.\n\n Once the view ha... |
Please provide a description of the function:def design_delete(self, name, use_devmode=True, syncwait=0):
name = self._mk_devmode(name, use_devmode)
existing = None
if syncwait:
try:
existing = self.design_get(name, use_devmode=False)
except Couch... | [
"\n Delete a design document\n\n :param string name: The name of the design document to delete\n :param bool use_devmode: Whether the design to delete is a development\n mode design doc.\n\n :param float syncwait: Timeout for operation verification. See\n :meth:`des... |
Please provide a description of the function:def design_list(self):
ret = self._http_request(
type=_LCB.LCB_HTTP_TYPE_MANAGEMENT,
path="/pools/default/buckets/{0}/ddocs".format(self._cb.bucket),
method=_LCB.LCB_HTTP_METHOD_GET)
real_rows = {}
for r i... | [
"\n List all design documents for the current bucket.\n\n :return: A :class:`~couchbase.result.HttpResult` containing\n a dict, with keys being the ID of the design document.\n\n .. note::\n\n This information is derived using the\n ``pools/default/buckets/<buck... |
Please provide a description of the function:def n1ql_index_create(self, ix, **kwargs):
defer = kwargs.pop('defer', False)
ignore_exists = kwargs.pop('ignore_exists', False)
primary = kwargs.pop('primary', False)
fields = kwargs.pop('fields', [])
cond = kwargs.pop('condi... | [
"\n Create an index for use with N1QL.\n\n :param str ix: The name of the index to create\n :param bool defer: Whether the building of indexes should be\n deferred. If creating multiple indexes on an existing\n dataset, using the `defer` option in conjunction with\n ... |
Please provide a description of the function:def n1ql_index_create_primary(self, defer=False, ignore_exists=False):
return self.n1ql_index_create(
'', defer=defer, primary=True, ignore_exists=ignore_exists) | [
"\n Create the primary index on the bucket.\n\n Equivalent to::\n\n n1ql_index_create('', primary=True, **kwargs)\n\n :param bool defer:\n :param bool ignore_exists:\n\n .. seealso:: :meth:`create_index`\n "
] |
Please provide a description of the function:def n1ql_index_drop(self, ix, primary=False, **kwargs):
info = self._mk_index_def(ix, primary)
return IxmgmtRequest(self._cb, 'drop', info, **kwargs).execute() | [
"\n Delete an index from the cluster.\n\n :param str ix: the name of the index\n :param bool primary: if this index is a primary index\n :param bool ignore_missing: Do not raise an exception if the index\n does not exist\n :raise: :exc:`~.NotFoundError` if the index doe... |
Please provide a description of the function:def n1ql_index_build_deferred(self, other_buckets=False):
info = N1qlIndex()
if not other_buckets:
info.keyspace = self._cb.bucket
return IxmgmtRequest(self._cb, 'build', info).execute() | [
"\n Instruct the server to begin building any previously deferred index\n definitions.\n\n This method will gather a list of all pending indexes in the cluster\n (including those created using the `defer` option with\n :meth:`create_index`) and start building them in an efficient ... |
Please provide a description of the function:def n1ql_index_watch(self, indexes,
timeout=30, interval=0.2, watch_primary=False):
kwargs = {
'timeout_us': int(timeout * 1000000),
'interval_us': int(interval * 1000000)
}
ixlist = [N1qlIndex... | [
"\n Await completion of index building\n\n This method will wait up to `timeout` seconds for every index in\n `indexes` to have been built. It will poll the cluster every\n `interval` seconds.\n\n :param list indexes: A list of indexes to check. This is returned by\n :m... |
Please provide a description of the function:def _set_range_common(self, k_sugar, k_start, k_end, value):
if not isinstance(value, (list, tuple, _Unspec)):
raise ArgumentError.pyexc(
"Range specification for {0} must be a list, tuple or UNSPEC"
.format(k_sug... | [
"\n Checks to see if the client-side convenience key is present, and if so\n converts the sugar convenience key into its real server-side\n equivalents.\n\n :param string k_sugar: The client-side convenience key\n :param string k_start: The server-side key specifying the beginning... |
Please provide a description of the function:def update(self, copy=False, **params):
if copy:
self = deepcopy(self)
for k, v in params.items():
if not hasattr(self, k):
if not self.unrecognized_ok:
raise ArgumentError.pyexc("Unknown o... | [
"\n Chained assignment operator.\n\n This may be used to quickly assign extra parameters to the\n :class:`Query` object.\n\n Example::\n\n q = Query(reduce=True, full_sec=True)\n\n # Someplace later\n\n v = View(design, view, query=q.update(mapkey_range=[... |
Please provide a description of the function:def from_any(cls, params, **ctor_opts):
if isinstance(params, cls):
return deepcopy(params)
elif isinstance(params, dict):
ctor_opts.update(**params)
if cls is QueryBase:
if ('bbox' in params or 's... | [
"\n Creates a new Query object from input.\n\n :param params: Parameter to convert to query\n :type params: dict, string, or :class:`Query`\n\n If ``params`` is a :class:`Query` object already, a deep copy is made\n and a new :class:`Query` object is returned.\n\n If ``para... |
Please provide a description of the function:def encoded(self):
if not self._encoded:
self._encoded = self._encode()
if self._base_str:
return '&'.join((self._base_str, self._encoded))
else:
return self._encoded | [
"\n Returns an encoded form of the query\n "
] |
Please provide a description of the function:def _long_query_encoded(self):
uristr = self._encode(omit_keys=True)
kstr = "{}"
klist = self._real_options.get('keys', UNSPEC)
if klist != UNSPEC:
kstr = '{{"keys":{0}}}'.format(klist)
return (uristr, kstr) | [
"\n Returns the (uri_part, post_data_part) for a long query.\n "
] |
Please provide a description of the function:def on_rows(self, rowiter):
self.__rows = rowiter
self._d.callback(self)
self._d = None | [
"\n Reimplemented from :meth:`~AsyncViewBase.on_rows`\n "
] |
Please provide a description of the function:def on_error(self, ex):
if self._d:
self._d.errback()
self._d = None | [
"\n Reimplemented from :meth:`~AsyncViewBase.on_error`\n "
] |
Please provide a description of the function:def on_done(self):
if self._d:
self._d.callback(self)
self._d = None | [
"\n Reimplemented from :meth:`~AsyncViewBase.on_done`\n "
] |
Please provide a description of the function:def registerDeferred(self, event, d):
try:
self._evq[event].schedule(d)
except KeyError:
raise ValueError("No such event type", event) | [
"\n Register a defer to be fired at the firing of a specific event.\n\n :param string event: Currently supported values are `connect`. Another\n value may be `_dtor` which will register an event to fire when this\n object has been completely destroyed.\n\n :param event: The de... |
Please provide a description of the function:def defer(self, opres):
d = Deferred()
opres.callback = d.callback
def _on_err(mres, ex_type, ex_val, ex_tb):
try:
raise ex_type(ex_val)
except CouchbaseError:
d.errback()
opres... | [
"\n Converts a raw :class:`couchbase.results.AsyncResult` object\n into a :class:`Deferred`.\n\n This is shorthand for the following \"non-idiom\"::\n\n d = Deferred()\n opres = cb.upsert(\"foo\", \"bar\")\n opres.callback = d.callback\n\n def d_err(res, ex_t... |
Please provide a description of the function:def queryEx(self, viewcls, *args, **kwargs):
kwargs['itercls'] = viewcls
o = super(AsyncBucket, self).query(*args, **kwargs)
if not self.connected:
self.connect().addCallback(lambda x: o.start())
else:
o.start... | [
"\n Query a view, with the ``viewcls`` instance receiving events\n of the query as they arrive.\n\n :param type viewcls: A class (derived from :class:`AsyncViewBase`)\n to instantiate\n\n Other arguments are passed to the standard `query` method.\n\n This functions exactl... |
Please provide a description of the function:def queryAll(self, *args, **kwargs):
if not self.connected:
cb = lambda x: self.queryAll(*args, **kwargs)
return self.connect().addCallback(cb)
kwargs['itercls'] = BatchedView
o = super(RawBucket, self).query(*args, ... | [
"\n Returns a :class:`Deferred` object which will have its callback invoked\n with a :class:`BatchedView` when the results are complete.\n\n Parameters follow conventions of\n :meth:`~couchbase.bucket.Bucket.query`.\n\n Example::\n\n d = cb.queryAll(\"beer\", \"brewery_be... |
Please provide a description of the function:def n1qlQueryEx(self, cls, *args, **kwargs):
kwargs['itercls'] = cls
o = super(AsyncBucket, self).n1ql_query(*args, **kwargs)
if not self.connected:
self.connect().addCallback(lambda x: o.start())
else:
o.start... | [
"\n Execute a N1QL statement providing a custom handler for rows.\n\n This method allows you to define your own subclass (of\n :class:`~AsyncN1QLRequest`) which can handle rows as they are\n received from the network.\n\n :param cls: The subclass (not instance) to use\n :pa... |
Please provide a description of the function:def n1qlQueryAll(self, *args, **kwargs):
if not self.connected:
cb = lambda x: self.n1qlQueryAll(*args, **kwargs)
return self.connect().addCallback(cb)
kwargs['itercls'] = BatchedN1QLRequest
o = super(RawBucket, self)... | [
"\n Execute a N1QL query, retrieving all rows.\n\n This method returns a :class:`Deferred` object which is executed\n with a :class:`~.N1QLRequest` object. The object may be iterated\n over to yield the rows in the result set.\n\n This method is similar to :meth:`~couchbase.bucket... |
Please provide a description of the function:def searchQueryEx(self, cls, *args, **kwargs):
kwargs['itercls'] = cls
o = super(AsyncBucket, self).search(*args, **kwargs)
if not self.connected:
self.connect().addCallback(lambda x: o.start())
else:
o.start()... | [
"\n Experimental Method\n\n Execute a Search query providing a custom handler for rows.\n\n This method allows you to define your own subclass (of\n :class:`~AsyncSearchRequest`) which can handle rows as they are\n received from the network.\n\n :param cls: The subclass (no... |
Please provide a description of the function:def searchQueryAll(self, *args, **kwargs):
if not self.connected:
cb = lambda x: self.searchQueryAll(*args, **kwargs)
return self.connect().addCallback(cb)
kwargs['itercls'] = BatchedSearchRequest
o = super(AsyncBuck... | [
"\n Experimental Method\n\n Execute a Search query, retrieving all rows.\n\n This method returns a :class:`Deferred` object which is executed\n with a :class:`~.SearchRequest` object. The object may be iterated\n over to yield the rows in the result set.\n\n This method is ... |
Please provide a description of the function:def _wrap(self, meth, *args, **kwargs):
if not self.connected:
return self._connectSchedule(self._wrap, meth, *args, **kwargs)
opres = meth(self, *args, **kwargs)
return self.defer(opres) | [
"\n Calls a given method with the appropriate arguments, or defers such\n a call until the instance has been connected\n "
] |
Please provide a description of the function:def get_decode_format(flags):
c_flags = flags & FMT_COMMON_MASK
l_flags = flags & FMT_LEGACY_MASK
if c_flags:
if c_flags not in COMMON_FORMATS:
return FMT_BYTES, False
else:
return COMMON2UNIFIED[c_flags], True
el... | [
"\n Returns a tuple of format, recognized\n "
] |
Please provide a description of the function:def index_to_rawjson(ix):
if isinstance(ix, N1qlIndex):
ix = ix.raw
return _to_json(ix) | [
"\n :param ix: dict or IndexInfo object\n :return: serialized JSON\n "
] |
Please provide a description of the function:def from_any(cls, obj, bucket):
if isinstance(obj, cls):
return cls(obj.raw)
return cls({
'namespace_id': 'default',
'keyspace_id': bucket,
'name': obj if obj else N1QL_PRIMARY_INDEX,
'usin... | [
"\n Ensure the current object is an index. Always returns a new object\n :param obj: string or IndexInfo object\n :param bucket: The bucket name\n :return: A new IndexInfo object\n "
] |
Please provide a description of the function:def http_request(self,
path,
method='GET',
content=None,
content_type="application/json",
response_format=FMT_JSON):
imeth = None
if not method i... | [
"\n Perform an administrative HTTP request. This request is sent out to\n the administrative API interface (i.e. the \"Management/REST API\")\n of the cluster.\n\n Note that this is a fairly low level function. You should use one\n of the helper methods in this class to perform yo... |
Please provide a description of the function:def bucket_create(self, name, bucket_type='couchbase',
bucket_password='', replicas=0, ram_quota=1024,
flush_enabled=False):
params = {
'name': name,
'bucketType': bucket_type,
'... | [
"\n Create a new bucket\n\n :param string name: The name of the bucket to create\n :param string bucket_type: The type of bucket to create. This\n can either be `couchbase` to create a couchbase style\n bucket (which persists data and supports replication) or\n ... |
Please provide a description of the function:def wait_ready(self, name, timeout=5.0, sleep_interval=0.2):
end = time() + timeout
while True:
try:
info = self.bucket_info(name).value
for node in info['nodes']:
if node['status'] != '... | [
"\n Wait for a newly created bucket to be ready.\n\n :param string name: the name to wait for\n :param seconds timeout: the maximum amount of time to wait\n :param seconds sleep_interval: the number of time to sleep\n between each probe\n :raise: :exc:`.CouchbaseError` ... |
Please provide a description of the function:def bucket_update(self, name, current, bucket_password=None, replicas=None,
ram_quota=None, flush_enabled=None):
params = {}
current = current.value
# Merge params
params['authType'] = current['authType']
... | [
"\n Update an existing bucket's settings.\n\n :param string name: The name of the bucket to update\n :param dict current: Current state of the bucket.\n This can be retrieve from :meth:`bucket_info`\n :param str bucket_password: Change the bucket's password\n :param int... |
Please provide a description of the function:def users_get(self, domain):
path = self._get_management_path(domain)
return self.http_request(path=path,
method='GET') | [
"\n Retrieve a list of users from the server.\n\n :param AuthDomain domain: The authentication domain to retrieve users from.\n :return: :class:`~.HttpResult`. The list of users can be obtained from\n the returned object's `value` property.\n "
] |
Please provide a description of the function:def user_get(self, domain, userid):
path = self._get_management_path(domain, userid)
return self.http_request(path=path,
method='GET') | [
"\n Retrieve a user from the server\n\n :param AuthDomain domain: The authentication domain for the user.\n :param userid: The user ID.\n :raise: :exc:`couchbase.exceptions.HTTPError` if the user does not exist.\n :return: :class:`~.HttpResult`. The user can be obtained from the\n... |
Please provide a description of the function:def user_upsert(self, domain, userid, password=None, roles=None, name=None):
if not roles or not isinstance(roles, list):
raise E.ArgumentError("Roles must be a non-empty list")
if password and domain == AuthDomain.External:
... | [
"\n Upsert a user in the cluster\n\n :param AuthDomain domain: The authentication domain for the user.\n :param userid: The user ID\n :param password: The user password\n :param roles: A list of roles. A role can either be a simple string,\n or a list of `(role, bucket)... |
Please provide a description of the function:def user_remove(self, domain, userid):
path = self._get_management_path(domain, userid)
return self.http_request(path=path,
method='DELETE') | [
"\n Remove a user\n :param AuthDomain domain: The authentication domain for the user.\n :param userid: The user ID to remove\n :raise: :exc:`couchbase.exceptions.HTTPError` if the user does not exist.\n :return: :class:`~.HttpResult`\n "
] |
Please provide a description of the function:def _build_connstr(host, port, bucket):
hostlist = []
if isinstance(host, (tuple, list)):
for curhost in host:
if isinstance(curhost, (list, tuple)):
hostlist.append(_fmthost(*curhost))
else:
hostli... | [
"\n Converts a 1.x host:port specification to a connection string\n "
] |
Please provide a description of the function:def convert_1x_args(bucket, **kwargs):
host = kwargs.pop('host', 'localhost')
port = kwargs.pop('port', None)
if not 'connstr' in kwargs and 'connection_string' not in kwargs:
kwargs['connection_string'] = _build_connstr(host, port, bucket)
retur... | [
"\n Converts arguments for 1.x constructors to their 2.x forms\n "
] |
Please provide a description of the function:def parse(cls, ss):
up = urlparse(ss)
path = up.path
query = up.query
if '?' in path:
path, _ = up.path.split('?')
if path.startswith('/'):
path = path[1:]
bucket = path
options = pa... | [
"\n Parses an existing connection string\n\n This method will return a :class:`~.ConnectionString` object\n which will allow further inspection on the input parameters.\n\n :param string ss: The existing connection string\n :return: A new :class:`~.ConnectionString` object\n ... |
Please provide a description of the function:def encode(self):
opt_dict = {}
for k, v in self.options.items():
opt_dict[k] = v[0]
ss = '{0}://{1}'.format(self.scheme, ','.join(self.hosts))
if self.bucket:
ss += '/' + self.bucket
# URL encode opt... | [
"\n Encodes the current state of the object into a string.\n\n :return: The encoded string\n "
] |
Please provide a description of the function:def _mk_lcberr(rc, name=None, default=CouchbaseError, docstr="", extrabase=[]):
categories = C._get_errtype(rc)
if not categories:
return default
bases = extrabase[::]
for cat, base in _LCB_ERRCAT_MAP.items():
if cat & categories:
... | [
"\n Create a new error class derived from the appropriate exceptions.\n :param int rc: libcouchbase error code to map\n :param str name: The name of the new exception\n :param class default: Default exception to return if no categories are found\n :return: a new exception derived from the appropriate... |
Please provide a description of the function:def exc_from_rc(rc, msg=None, obj=None):
newcls = CouchbaseError.rc_to_exctype(rc)
return newcls(params={'rc': rc, 'objextra': obj, 'message': msg}) | [
"\n .. warning:: INTERNAL\n\n For those rare cases when an exception needs to be thrown from\n Python using a libcouchbase error code.\n\n :param rc: The error code\n :param msg: Message (description)\n :param obj: Context\n :return: a raisable exception\n "
] |
Please provide a description of the function:def rc_to_exctype(cls, rc):
try:
return _LCB_ERRNO_MAP[rc]
except KeyError:
newcls = _mk_lcberr(rc)
_LCB_ERRNO_MAP[rc] = newcls
return newcls | [
"\n Map an error code to an exception\n\n :param int rc: The error code received for an operation\n\n :return: a subclass of :class:`CouchbaseError`\n "
] |
Please provide a description of the function:def split_results(self):
ret_ok, ret_fail = {}, {}
count = 0
nokey_prefix = ([""] + sorted(filter(bool, self.all_results.keys())))[-1]
for key, v in self.all_results.items():
if not key:
key = nokey_prefix... | [
"\n Convenience method to separate failed and successful results.\n\n .. versionadded:: 2.0.0\n\n This function will split the results of the failed operation\n (see :attr:`.all_results`) into \"good\" and \"bad\" dictionaries.\n\n The intent is for the application to handle any s... |
Please provide a description of the function:def update_event(self, event, action, flags):
if action == PYCBC_EVACTION_UNWATCH:
if event.flags & LCB_READ_EVENT:
self.reactor.removeReader(event)
if event.flags & LCB_WRITE_EVENT:
self.reactor.remove... | [
"\n Called by libcouchbase to add/remove event watchers\n "
] |
Please provide a description of the function:def update_timer(self, timer, action, usecs):
if action == PYCBC_EVACTION_WATCH:
timer.schedule(usecs, self.reactor)
elif action == PYCBC_EVACTION_UNWATCH:
timer.cancel()
elif action == PYCBC_EVACTION_CLEANUP:
... | [
"\n Called by libcouchbase to add/remove timers\n "
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.