Adds a new item to the set. Returning whether the item already existed in the set or not. Args: value (Any): Returns: bool: True if the value was added, False otherwise (meaning the value already exists in the set).
(self, value: Any)
| 697 | transcoder=transcoder) |
| 698 | |
| 699 | def add(self, value: Any) -> bool: |
| 700 | """Adds a new item to the set. Returning whether the item already existed in the set or not. |
| 701 | |
| 702 | Args: |
| 703 | value (Any): |
| 704 | |
| 705 | Returns: |
| 706 | bool: True if the value was added, False otherwise (meaning the value already |
| 707 | exists in the set). |
| 708 | |
| 709 | """ |
| 710 | op_type = DatastructureOperationType.SetAdd |
| 711 | with ObservableRequestHandler(op_type, self._impl.observability_instruments) as ds_obs_handler: |
| 712 | ds_obs_handler.create_kv_span(self._impl._request_builder._collection_dtls.get_details_as_dict()) |
| 713 | kv_op_type = KeyValueOperationType.MutateIn |
| 714 | with ObservableRequestHandler(kv_op_type, self._impl.observability_instruments) as obs_handler: |
| 715 | try: |
| 716 | op = array_addunique('', value) |
| 717 | req = self._impl.request_builder.build_mutate_in_request(self._key, |
| 718 | (op,), |
| 719 | obs_handler, |
| 720 | parent_span=ds_obs_handler.wrapped_span) |
| 721 | self._execute_op(self._impl.mutate_in, |
| 722 | req, |
| 723 | obs_handler, |
| 724 | ds_obs_handler.wrapped_span, |
| 725 | create_type=True) |
| 726 | return True |
| 727 | except PathExistsException: |
| 728 | return False |
| 729 | |
| 730 | def remove(self, value: Any, timeout: Optional[timedelta] = None) -> None: # noqa: C901 |
| 731 | """Removes a specific value from the set. |
nothing calls this directly
no test coverage detected