Management

Note

Further updates to the management API docs will come with future 4.0.x releases.

Bucket Management

class couchbase.management.buckets.BucketManager(connection)
create_bucket(settings, *options, **kwargs) None

Creates a new bucket.

Parameters
  • settings (CreateBucketSettings) – The settings to use for the new bucket.

  • options (CreateBucketOptions) – Optional parameters for this operation.

  • **kwargs (Dict[str, Any]) – keyword arguments that can be used as optional parameters for this operation.

Raises
  • BucketAlreadyExistsException – If the bucket already exists.

  • InvalidArgumentsException – If an invalid type or value is provided for the settings argument.

drop_bucket(bucket_name, *options, **kwargs) None

Drops an existing bucket.

Parameters
  • bucket_name (str) – The name of the bucket to drop.

  • options (DropBucketOptions) – Optional parameters for this operation.

  • **kwargs (Dict[str, Any]) – keyword arguments that can be used as optional parameters for this operation.

Raises

BucketDoesNotExistException – If the bucket does not exist.

flush_bucket(bucket_name, *options, **kwargs) None

Flushes the bucket, deleting all the existing data that is stored in it.

Parameters
  • bucket_name (str) – The name of the bucket to flush.

  • options (FlushBucketOptions) – Optional parameters for this operation.

  • **kwargs (Dict[str, Any]) – keyword arguments that can be used as optional parameters for this operation.

Raises
  • BucketDoesNotExistException – If the bucket does not exist.

  • BucketNotFlushableException – If the bucket’s settings have flushing disabled.

get_all_buckets(*options, **kwargs) List[couchbase.management.logic.buckets_logic.BucketSettings]

Returns a list of existing buckets in the cluster.

Parameters
  • options (GetAllBucketOptions) – Optional parameters for this operation.

  • **kwargs (Dict[str, Any]) – keyword arguments that can be used as optional parameters for this operation.

Returns

A list of existing buckets in the cluster.

Return type

List[BucketSettings]

get_bucket(bucket_name, *options, **kwargs) couchbase.management.logic.buckets_logic.BucketSettings

Fetches the settings in use for a specified bucket.

Parameters
  • bucket_name (str) – The name of the bucket to fetch.

  • options (GetBucketOptions) – Optional parameters for this operation.

  • **kwargs (Dict[str, Any]) – keyword arguments that can be used as optional parameters for this operation.

Returns

The settings of the specified bucket.

Return type

BucketSettings

Raises

BucketDoesNotExistException – If the bucket does not exist.

update_bucket(settings, *options, **kwargs) None

Update the settings for an existing bucket.

Parameters
  • settings (BucketSettings) – The settings to use for the new bucket.

  • options (UpdateBucketOptions) – Optional parameters for this operation.

  • **kwargs (Dict[str, Any]) – keyword arguments that can be used as optional parameters for this operation.

Raises

InvalidArgumentsException – If an invalid type or value is provided for the settings argument.

Collection Management

class couchbase.management.collections.CollectionManager(connection, bucket_name)
create_collection(collection, *options, **kwargs) None

Creates a new collection in a specified scope.

Parameters
  • collection (CollectionSpec) – The collection details.

  • options (CreateCollectionOptions) – Optional parameters for this operation.

  • **kwargs (Dict[str, Any]) – keyword arguments that can be used as optional parameters for this operation.

Raises
  • CollectionAlreadyExistsException – If the collection already exists.

  • ScopeNotFoundException – If the scope does not exist.

create_scope(scope_name, *options, **kwargs) None

Creates a new scope.

Parameters
  • scope_name (str) – The name of the scope.

  • options (CreateScopeOptions) – Optional parameters for this operation.

  • **kwargs (Dict[str, Any]) – keyword arguments that can be used as optional parameters for this operation.

Raises

ScopeAlreadyExistsException – If the scope already exists.

drop_collection(collection, *options, **kwargs) None

Drops a collection from a scope.

Parameters
  • collection (CollectionSpec) – The collection details.

  • options (DropCollectionOptions) – Optional parameters for this operation.

  • **kwargs (Dict[str, Any]) – keyword arguments that can be used as optional parameters for this operation.

Raises

CollectionNotFoundException – If the collection does not exist.

drop_scope(scope_name, *options, **kwargs) None

Drops an existing scope.

Parameters
  • scope_name (str) – The name of the scope.

  • options (DropScopeOptions) – Optional parameters for this operation.

  • **kwargs (Dict[str, Any]) – keyword arguments that can be used as optional parameters for this operation.

Raises

ScopeNotFoundException – If the scope does not exist.

get_all_scopes(*options, **kwargs) Iterable[couchbase.management.logic.collections_logic.ScopeSpec]

Returns all configured scopes along with their collections.

Parameters
  • scope_name (str) – The name of the scope.

  • options (GetAllScopesOptions) – Optional parameters for this operation.

  • **kwargs (Dict[str, Any]) – keyword arguments that can be used as optional parameters for this operation.

Returns

A list of all configured scopes.

Return type

Iterable[ScopeSpec]

class couchbase.management.collections.CollectionSpec(collection_name, scope_name='_default', max_ttl=None)
property name: str

The name of the collection

Type

str

property scope_name: str

The name of the collection’s scope

Type

str

property max_ttl: Optional[datetime.timedelta]

The expiry for documents in the collection.

Type

Optional[timedelta]

class couchbase.management.collections.ScopeSpec(name, collections)
property name: str

The name of the scope

Type

str

property collections: Iterable[couchbase.management.logic.collections_logic.CollectionSpec]

A list of the scope’s collections.

Type

List[CollectionSpec]

Query Index Management

class couchbase.management.queries.QueryIndexManager(connection)
build_deferred_indexes(bucket_name, *options, **kwargs) None

Starts building any indexes which were previously created with deferred=True.

Parameters
  • bucket_name (str) – The name of the bucket to perform build on.

  • options (BuildDeferredQueryIndexOptions) – Optional parameters for this operation.

  • **kwargs (Dict[str, Any]) – keyword arguments that can be used as optional parameters for this operation.

Raises

InvalidArgumentException – If the bucket_name is an invalid type.

create_index(bucket_name, index_name, fields, *options, **kwargs) None

Creates a new query index.

Parameters
  • bucket_name (str) – The name of the bucket this index is for.

  • index_name (str) – The name of the index.

  • fields (Iterable[str]) – The fields which this index should cover.

  • options (CreateQueryIndexOptions) – Optional parameters for this operation.

  • **kwargs (Dict[str, Any]) – keyword arguments that can be used as optional parameters for this operation.

Raises
  • InvalidArgumentException – If the bucket_name, index_name or fields are invalid types.

  • QueryIndexAlreadyExistsException – If the index already exists.

create_primary_index(bucket_name, *options, **kwargs) None

Creates a new primary query index.

Parameters
  • bucket_name (str) – The name of the bucket this index is for.

  • options (CreatePrimaryQueryIndexOptions) – Optional parameters for this operation.

  • **kwargs (Dict[str, Any]) – keyword arguments that can be used as optional parameters for this operation.

Raises
  • InvalidArgumentException – If the bucket_name is an invalid type.

  • QueryIndexAlreadyExistsException – If the index already exists.

drop_index(bucket_name, index_name, *options, **kwargs) None

Drops an existing query index.

Parameters
  • bucket_name (str) – The name of the bucket containing the index to drop.

  • index_name (str) – The name of the index to drop.

  • options (DropQueryIndexOptions) – Optional parameters for this operation.

  • **kwargs (Dict[str, Any]) – keyword arguments that can be used as optional parameters for this operation.

Raises
  • InvalidArgumentException – If the bucket_name or index_name are invalid types.

  • QueryIndexNotFoundException – If the index does not exists.

drop_primary_index(bucket_name, *options, **kwargs) None

Drops an existing primary query index.

Parameters
  • bucket_name (str) – The name of the bucket this index to drop.

  • options (DropPrimaryQueryIndexOptions) – Optional parameters for this operation.

  • **kwargs (Dict[str, Any]) – keyword arguments that can be used as optional parameters for this operation.

Raises
  • InvalidArgumentException – If the bucket_name is an invalid type.

  • QueryIndexNotFoundException – If the index does not exists.

get_all_indexes(bucket_name, *options, **kwargs) Iterable[couchbase.management.logic.query_index_logic.QueryIndex]

Returns a list of indexes for a specific bucket.

Parameters
  • bucket_name (str) – The name of the bucket to fetch indexes for.

  • options (GetAllQueryIndexOptions) – Optional parameters for this operation.

  • **kwargs (Dict[str, Any]) – keyword arguments that can be used as optional parameters for this operation.

Returns

A list of indexes for a specific bucket.

Return type

Iterable[QueryIndex]

Raises

InvalidArgumentException – If the bucket_name is an invalid type.

watch_indexes(bucket_name, index_names, *options, **kwargs) None

Waits for a number of indexes to finish creation and be ready to use.

Parameters
  • bucket_name (str) – The name of the bucket to watch for indexes on.

  • index_names (Iterable[str]) – The names of the indexes to watch.

  • options (WatchQueryIndexOptions) – Optional parameters for this operation.

  • **kwargs (Dict[str, Any]) – keyword arguments that can be used as optional parameters for this operation.

Raises
  • InvalidArgumentException – If the bucket_name or index_names are invalid types.

  • WatchQueryIndexTimeoutException – If the specified timeout is reached before all the specified indexes are ready to use.

User Management

class couchbase.management.users.UserManager(connection)
drop_user(username, *options, **kwargs) None

Drops an existing user.

Parameters
  • username (str) – The name of the user to drop.

  • options (DropUserOptions) – Optional parameters for this operation.

  • **kwargs (Dict[str, Any]) – keyword arguments that can be used as optional parameters for this operation.

Raises

UserNotFoundException – If the user does not exist.

drop_group(group_name, *options, **kwargs) None

Drops an existing group.

Parameters
  • group_name (str) – The name of the group to drop.

  • options (DropGroupOptions) – Optional parameters for this operation.

  • **kwargs (Dict[str, Any]) – keyword arguments that can be used as optional parameters for this operation.

Raises

GroupNotFoundException – If the group does not exist.

get_all_groups(*options, **kwargs) Iterable[couchbase.management.logic.users_logic.Group]

Returns a list of all existing groups.

Parameters
  • options (GetAllGroupsOptions) – Optional parameters for this operation.

  • **kwargs (Dict[str, Any]) – keyword arguments that can be used as optional parameters for this operation.

Returns

A list of existing groups.

Return type

Iterable[Group]

get_all_users(*options, **kwargs) Iterable[couchbase.management.logic.users_logic.UserAndMetadata]

Returns a list of all existing users.

Parameters
  • options (GetAllUsersOptions) – Optional parameters for this operation.

  • **kwargs (Dict[str, Any]) – keyword arguments that can be used as optional parameters for this operation.

Returns

A list of existing users.

Return type

Iterable[UserAndMetadata]

get_group(group_name, *options, **kwargs) couchbase.management.logic.users_logic.Group

Returns a group by it’s name.

Parameters
  • group_name (str) – The name of the group to retrieve.

  • options (GetGroupOptions) – Optional parameters for this operation.

  • **kwargs (Dict[str, Any]) – keyword arguments that can be used as optional parameters for this operation.

Returns

A Group instance.

Return type

Group

Raises

GroupNotFoundException – If the group does not exist.

get_roles(*options, **kwargs) Iterable[couchbase.management.logic.users_logic.RoleAndDescription]

Returns a list of roles available on the server.

Parameters
  • options (GetRolesOptions) – Optional parameters for this operation.

  • **kwargs (Dict[str, Any]) – keyword arguments that can be used as optional parameters for this operation.

Returns

A list of roles available on the server.

Return type

Iterable[RoleAndDescription]

get_user(username, *options, **kwargs) couchbase.management.logic.users_logic.UserAndMetadata

Returns a user by it’s username.

Parameters
  • username (str) – The name of the user to retrieve.

  • options (GetUserOptions) – Optional parameters for this operation.

  • **kwargs (Dict[str, Any]) – keyword arguments that can be used as optional parameters for this operation.

Returns

A UserAndMetadata instance.

Return type

UserAndMetadata

Raises

UserNotFoundException – If the user does not exist.

upsert_group(group, *options, **kwargs) None

Creates a new group or updates an existing group.

Parameters
  • group (Group) – The group to create or update.

  • options (UpsertGroupOptions) – Optional parameters for this operation.

  • **kwargs (Dict[str, Any]) – keyword arguments that can be used as optional parameters for this operation.

Raises

InvalidArgumentException – If the provided group argument contains an invalid value or type.

upsert_user(user, *options, **kwargs) None

Creates a new user or updates an existing user.

Parameters
  • user (User) – The user to create or update.

  • options (UpsertUserOptions) – Optional parameters for this operation.

  • **kwargs (Dict[str, Any]) – keyword arguments that can be used as optional parameters for this operation.

Raises

InvalidArgumentException – If the provided user argument contains an invalid value or type.