Removes an item at a specific index from the list. Args: index (int): The index to remove. Raises: :class:`~couchbase.exceptions.InvalidArgumentException`: If the index is out of range.
(self, index: int)
| 243 | raise InvalidArgumentException(message=f'Index: {index} is out of range.') from None |
| 244 | |
| 245 | def remove_at(self, index: int) -> None: |
| 246 | """Removes an item at a specific index from the list. |
| 247 | |
| 248 | Args: |
| 249 | index (int): The index to remove. |
| 250 | |
| 251 | Raises: |
| 252 | :class:`~couchbase.exceptions.InvalidArgumentException`: If the index is out of range. |
| 253 | |
| 254 | """ |
| 255 | op_type = DatastructureOperationType.ListRemoveAt |
| 256 | with ObservableRequestHandler(op_type, self._impl.observability_instruments) as ds_obs_handler: |
| 257 | ds_obs_handler.create_kv_span(self._impl._request_builder._collection_dtls.get_details_as_dict()) |
| 258 | kv_op_type = KeyValueOperationType.MutateIn |
| 259 | with ObservableRequestHandler(kv_op_type, self._impl.observability_instruments) as obs_handler: |
| 260 | try: |
| 261 | op = remove(f'[{index}]') |
| 262 | req = self._impl.request_builder.build_mutate_in_request(self._key, |
| 263 | (op,), |
| 264 | obs_handler, |
| 265 | parent_span=ds_obs_handler.wrapped_span) |
| 266 | self._execute_op(self._impl.mutate_in, |
| 267 | req, |
| 268 | obs_handler, |
| 269 | ds_obs_handler.wrapped_span) |
| 270 | except PathNotFoundException: |
| 271 | raise InvalidArgumentException(message=f'Index: {index} is out of range.') from None |
| 272 | |
| 273 | def size(self) -> int: |
| 274 | """Returns the number of items in the list. |