Send a POST request to the Data API for this database with an arbitrary, caller-provided payload. Args: body: a JSON-serializable dictionary, the payload of the request. keyspace: the keyspace to use, if any. If a keyspace is employed,
(
self,
body: dict[str, Any],
*,
keyspace: str | None | UnsetType = _UNSET,
collection_or_table_name: str | None = None,
raise_api_errors: bool = True,
general_method_timeout_ms: int | None = None,
request_timeout_ms: int | None = None,
timeout_ms: int | None = None,
)
| 4412 | logger.info(f"finished dropType('{name}')") |
| 4413 | |
| 4414 | async def command( |
| 4415 | self, |
| 4416 | body: dict[str, Any], |
| 4417 | *, |
| 4418 | keyspace: str | None | UnsetType = _UNSET, |
| 4419 | collection_or_table_name: str | None = None, |
| 4420 | raise_api_errors: bool = True, |
| 4421 | general_method_timeout_ms: int | None = None, |
| 4422 | request_timeout_ms: int | None = None, |
| 4423 | timeout_ms: int | None = None, |
| 4424 | ) -> dict[str, Any]: |
| 4425 | """ |
| 4426 | Send a POST request to the Data API for this database with |
| 4427 | an arbitrary, caller-provided payload. |
| 4428 | |
| 4429 | Args: |
| 4430 | body: a JSON-serializable dictionary, the payload of the request. |
| 4431 | keyspace: the keyspace to use, if any. If a keyspace is employed, |
| 4432 | it is used to construct the full request URL. To run a command |
| 4433 | targeting no specific keyspace (rather, the database as a whole), |
| 4434 | pass an explicit `None`: the request URL will lack the suffix |
| 4435 | "/<keyspace>" component. If unspecified, the working keyspace of |
| 4436 | this database is used. If another keyspace is passed, it will be |
| 4437 | used instead of the database's working one. |
| 4438 | collection_or_table_name: if provided, the name is appended at the end |
| 4439 | of the endpoint. In this way, this method allows collection- |
| 4440 | and table-level arbitrary POST requests as well. |
| 4441 | This parameter cannot be used if `keyspace=None` is explicitly provided. |
| 4442 | raise_api_errors: if True, responses with a nonempty 'errors' field |
| 4443 | result in an astrapy exception being raised. |
| 4444 | general_method_timeout_ms: a timeout, in milliseconds, to impose on the |
| 4445 | underlying API request. If not provided, this object's defaults apply. |
| 4446 | (This method issues a single API request, hence all timeout parameters |
| 4447 | are treated the same.) |
| 4448 | request_timeout_ms: an alias for `general_method_timeout_ms`. |
| 4449 | timeout_ms: an alias for `general_method_timeout_ms`. |
| 4450 | |
| 4451 | Returns: |
| 4452 | a dictionary with the response of the HTTP request. |
| 4453 | |
| 4454 | Example: |
| 4455 | >>> # NOTE: may require slight adaptation to an async context. |
| 4456 | >>> |
| 4457 | >>> my_db.command({"findCollections": {}}) |
| 4458 | {'status': {'collections': ['my_coll']}} |
| 4459 | >>> my_db.command({"countDocuments": {}}, collection_or_table_name="my_coll") |
| 4460 | {'status': {'count': 123}} |
| 4461 | """ |
| 4462 | |
| 4463 | _request_timeout_ms, _rt_label = _select_singlereq_timeout_gm( |
| 4464 | timeout_options=self.api_options.timeout_options, |
| 4465 | general_method_timeout_ms=general_method_timeout_ms, |
| 4466 | request_timeout_ms=request_timeout_ms, |
| 4467 | timeout_ms=timeout_ms, |
| 4468 | ) |
| 4469 | _keyspace: str | None |
| 4470 | if keyspace is None: |
| 4471 | if collection_or_table_name is not None: |
nothing calls this directly
no test coverage detected