MCPcopy Index your code
hub / github.com/couchbase/couchbase-python-client / Bucket

Class Bucket

couchbase/bucket.py:37–216  ·  view source on GitHub ↗

Create a Couchbase Bucket instance. Exposes the operations which are available to be performed against a bucket. Namely the ability to access to Collections as well as performing management operations against the bucket. Args: cluster (:class:`~.Cluster`): A :class:`~.Cluster`

Source from the content-addressed store, hash-verified

35
36
37class Bucket:
38 """Create a Couchbase Bucket instance.
39
40 Exposes the operations which are available to be performed against a bucket. Namely the ability to
41 access to Collections as well as performing management operations against the bucket.
42
43 Args:
44 cluster (:class:`~.Cluster`): A :class:`~.Cluster` instance.
45 bucket_name (str): Name of the bucket.
46
47 Raises:
48 :class:`~couchbase.exceptions.BucketNotFoundException`: If provided `bucket_name` cannot be found.
49
50 """
51
52 def __init__(self, cluster: Cluster, bucket_name: str) -> None:
53 self._impl = BucketImpl(bucket_name, cluster)
54
55 @property
56 def name(self) -> str:
57 return self._impl.bucket_name
58
59 def close(self):
60 """Shuts down this bucket instance. Cleaning up all resources associated with it.
61
62 .. warning::
63 Use of this method is almost *always* unnecessary. Bucket resources should be cleaned
64 up once the bucket instance falls out of scope. However, in some applications tuning resources
65 is necessary and in those types of applications, this method might be beneficial.
66
67 """
68 self._impl.close_bucket()
69
70 def default_scope(self) -> Scope:
71 """Creates a :class:`~.scope.Scope` instance of the default scope.
72
73 Returns:
74 :class:`~.scope.Scope`: A :class:`~.scope.Scope` instance of the default scope.
75
76 """
77 return self.scope(Scope.default_name())
78
79 def scope(self, name: str) -> Scope:
80 """Creates a :class:`~couchbase.scope.Scope` instance of the specified scope.
81
82 Args:
83 name (str): Name of the scope to reference.
84
85 Returns:
86 :class:`~couchbase.scope.Scope`: A :class:`~couchbase.scope.Scope` instance of the specified scope.
87
88 """
89 return Scope(self, name)
90
91 def collection(self, collection_name: str) -> Collection:
92 """Creates a :class:`~couchbase.collection.Collection` instance of the specified collection.
93
94 Args:

Callers 1

bucketMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected