(
data: VerifyCredentialsRequest,
)
| 32 | include_in_schema=False, |
| 33 | ) |
| 34 | async def api_verify_credentials( |
| 35 | data: VerifyCredentialsRequest, |
| 36 | ): |
| 37 | # encryption |
| 38 | bundle_handler: BundleHandler = get_bundle_handler(data.bundle_id) |
| 39 | if not bundle_handler: |
| 40 | raise_http_error(ErrorCode.OBJECT_NOT_FOUND, f"Bundle {data.bundle_id} not found.") |
| 41 | |
| 42 | try: |
| 43 | |
| 44 | await bundle_handler.verify(data.credentials) |
| 45 | |
| 46 | except TKHttpException as e: |
| 47 | if isinstance(getattr(e, "detail"), dict): |
| 48 | message = e.detail.get("message") |
| 49 | if message: |
| 50 | message = " " + message |
| 51 | e.detail["message"] = f"Model credentials validation failed.{message}" |
| 52 | raise e |
| 53 | |
| 54 | except Exception as e: |
| 55 | raise_http_error( |
| 56 | ErrorCode.CREDENTIALS_VALIDATION_ERROR, |
| 57 | message="Model credentials validation failed, please check if your credentials are correct.", |
| 58 | ) |
| 59 | |
| 60 | data.credentials.encrypt() |
| 61 | return BaseSuccessDataResponse( |
| 62 | data={ |
| 63 | "encrypted_credentials": data.credentials.credentials, |
| 64 | } |
| 65 | ) |
nothing calls this directly
no test coverage detected