Get a specific element within a list. :param index: The index to retrieve :return: value for the element :raise: :exc:`IndexError` if the index does not exist
(self, index: int)
| 221 | raise InvalidArgumentException(message=f'Index: {index} is out of range.') from None |
| 222 | |
| 223 | async def get_at(self, index: int) -> Any: |
| 224 | """ |
| 225 | Get a specific element within a list. |
| 226 | |
| 227 | :param index: The index to retrieve |
| 228 | :return: value for the element |
| 229 | :raise: :exc:`IndexError` if the index does not exist |
| 230 | """ |
| 231 | op_type = DatastructureOperationType.ListGetAt |
| 232 | async with ObservableRequestHandler(op_type, self._impl.observability_instruments) as ds_obs_handler: |
| 233 | ds_obs_handler.create_kv_span(self._impl._request_builder._collection_dtls.get_details_as_dict()) |
| 234 | kv_op_type = KeyValueOperationType.LookupIn |
| 235 | async with ObservableRequestHandler(kv_op_type, self._impl.observability_instruments) as obs_handler: |
| 236 | try: |
| 237 | op = subdoc_get(f'[{index}]') |
| 238 | req, transcoder = self._impl.request_builder.build_lookup_in_request(self._key, |
| 239 | (op,), |
| 240 | obs_handler, |
| 241 | parent_span=ds_obs_handler.wrapped_span) # noqa: E501 |
| 242 | sdres: LookupInResult = await self._execute_op(self._impl.lookup_in, |
| 243 | req, |
| 244 | obs_handler, |
| 245 | ds_obs_handler.wrapped_span, |
| 246 | create_type=True, |
| 247 | transcoder=transcoder) |
| 248 | return sdres.value[0].get('value', None) |
| 249 | except PathNotFoundException: |
| 250 | raise InvalidArgumentException(message=f'Index: {index} is out of range.') from None |
| 251 | |
| 252 | async def remove_at(self, index: int) -> None: |
| 253 | """ |