Delete an API key with the given key prefix for the authenticated user. Args: key_prefix (str): The prefix of the API key to be deleted. request (Request): The incoming request object. Returns: dict: A dictionary containing a success mes
(
self,
key_prefix: str,
*,
request_options: typing.Optional[RequestOptions] = None,
)
| 229 | raise ApiError(status_code=_response.status_code, body=_response_json) |
| 230 | |
| 231 | def delete_api_key( |
| 232 | self, |
| 233 | key_prefix: str, |
| 234 | *, |
| 235 | request_options: typing.Optional[RequestOptions] = None, |
| 236 | ) -> typing.Dict[str, typing.Optional[typing.Any]]: |
| 237 | """ |
| 238 | Delete an API key with the given key prefix for the authenticated user. |
| 239 | |
| 240 | Args: |
| 241 | key_prefix (str): The prefix of the API key to be deleted. |
| 242 | request (Request): The incoming request object. |
| 243 | |
| 244 | Returns: |
| 245 | dict: A dictionary containing a success message upon successful deletion. |
| 246 | |
| 247 | Raises: |
| 248 | HTTPException: If the API key is not found or does not belong to the user. |
| 249 | |
| 250 | Parameters |
| 251 | ---------- |
| 252 | key_prefix : str |
| 253 | |
| 254 | request_options : typing.Optional[RequestOptions] |
| 255 | Request-specific configuration. |
| 256 | |
| 257 | Returns |
| 258 | ------- |
| 259 | typing.Dict[str, typing.Optional[typing.Any]] |
| 260 | Successful Response |
| 261 | |
| 262 | Examples |
| 263 | -------- |
| 264 | from agenta import AgentaApi |
| 265 | |
| 266 | client = AgentaApi( |
| 267 | api_key="YOUR_API_KEY", |
| 268 | base_url="https://yourhost.com/path/to/api", |
| 269 | ) |
| 270 | client.delete_api_key( |
| 271 | key_prefix="key_prefix", |
| 272 | ) |
| 273 | """ |
| 274 | _response = self._client_wrapper.httpx_client.request( |
| 275 | f"keys/{jsonable_encoder(key_prefix)}", |
| 276 | method="DELETE", |
| 277 | request_options=request_options, |
| 278 | ) |
| 279 | try: |
| 280 | if 200 <= _response.status_code < 300: |
| 281 | return typing.cast( |
| 282 | typing.Dict[str, typing.Optional[typing.Any]], |
| 283 | parse_obj_as( |
| 284 | type_=typing.Dict[str, typing.Optional[typing.Any]], # type: ignore |
| 285 | object_=_response.json(), |
| 286 | ), |
| 287 | ) |
| 288 | if _response.status_code == 422: |
no test coverage detected