| 49 | |
| 50 | |
| 51 | class CollectionManager: |
| 52 | |
| 53 | def __init__(self, |
| 54 | client_adapter: ClientAdapter, |
| 55 | bucket_name: str, |
| 56 | observability_instruments: ObservabilityInstruments) -> None: |
| 57 | self._bucket_name = bucket_name |
| 58 | self._impl = CollectionMgmtImpl(client_adapter, observability_instruments) |
| 59 | |
| 60 | def create_scope(self, |
| 61 | scope_name: str, |
| 62 | *options: CreateScopeOptions, |
| 63 | **kwargs: Any |
| 64 | ) -> None: |
| 65 | """Creates a new scope. |
| 66 | |
| 67 | Args: |
| 68 | scope_name (str): The name of the scope. |
| 69 | options (:class:`~couchbase.management.options.CreateScopeOptions`): Optional parameters for this operation. |
| 70 | **kwargs (Dict[str, Any]): keyword arguments that can be used as optional parameters for this operation. |
| 71 | |
| 72 | Raises: |
| 73 | :class:`~couchbase.exceptions.ScopeAlreadyExistsException`: If the scope already exists. |
| 74 | """ # noqa: E501 |
| 75 | op_type = CollectionMgmtOperationType.ScopeCreate |
| 76 | with ObservableRequestHandler(op_type, self._impl.observability_instruments) as obs_handler: |
| 77 | req = self._impl.request_builder.build_create_scope_request(self._bucket_name, |
| 78 | scope_name, |
| 79 | obs_handler, |
| 80 | *options, |
| 81 | **kwargs) |
| 82 | self._impl.create_scope(req, obs_handler) |
| 83 | |
| 84 | def drop_scope(self, |
| 85 | scope_name: str, |
| 86 | *options: DropScopeOptions, |
| 87 | **kwargs: Any |
| 88 | ) -> None: |
| 89 | """Drops an existing scope. |
| 90 | |
| 91 | Args: |
| 92 | scope_name (str): The name of the scope. |
| 93 | options (:class:`~couchbase.management.options.DropScopeOptions`): Optional parameters for this operation. |
| 94 | **kwargs (Dict[str, Any]): keyword arguments that can be used as optional parameters for this operation. |
| 95 | |
| 96 | Raises: |
| 97 | :class:`~couchbase.exceptions.ScopeNotFoundException`: If the scope does not exist. |
| 98 | """ # noqa: E501 |
| 99 | op_type = CollectionMgmtOperationType.ScopeDrop |
| 100 | with ObservableRequestHandler(op_type, self._impl.observability_instruments) as obs_handler: |
| 101 | req = self._impl.request_builder.build_drop_scope_request(self._bucket_name, |
| 102 | scope_name, |
| 103 | obs_handler, |
| 104 | *options, |
| 105 | **kwargs) |
| 106 | self._impl.drop_scope(req, obs_handler) |
| 107 | |
| 108 | def get_all_scopes(self, |