techprotrade commited on
Commit
d120491
·
verified ·
1 Parent(s): 89a8953

Add loan-advisor-agent (part 10)

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .gitattributes +95 -0
  2. loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/llm_utility_service/__init__.py +22 -0
  3. loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/llm_utility_service/__pycache__/__init__.cpython-312.pyc +0 -0
  4. loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/llm_utility_service/__pycache__/async_client.cpython-312.pyc +0 -0
  5. loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/llm_utility_service/__pycache__/client.cpython-312.pyc +0 -0
  6. loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/llm_utility_service/async_client.py +1269 -0
  7. loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/llm_utility_service/client.py +1793 -0
  8. loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/llm_utility_service/transports/__init__.py +54 -0
  9. loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/llm_utility_service/transports/__pycache__/__init__.cpython-312.pyc +0 -0
  10. loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/llm_utility_service/transports/__pycache__/base.cpython-312.pyc +0 -0
  11. loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/llm_utility_service/transports/__pycache__/grpc.cpython-312.pyc +0 -0
  12. loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/llm_utility_service/transports/__pycache__/grpc_asyncio.cpython-312.pyc +0 -0
  13. loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/llm_utility_service/transports/__pycache__/rest.cpython-312.pyc +0 -0
  14. loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/llm_utility_service/transports/__pycache__/rest_asyncio.cpython-312.pyc +0 -0
  15. loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/llm_utility_service/transports/__pycache__/rest_base.cpython-312.pyc +0 -0
  16. loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/llm_utility_service/transports/base.py +344 -0
  17. loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/llm_utility_service/transports/grpc.py +598 -0
  18. loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/llm_utility_service/transports/grpc_asyncio.py +677 -0
  19. loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/llm_utility_service/transports/rest.py +2252 -0
  20. loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/llm_utility_service/transports/rest_asyncio.py +0 -0
  21. loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/llm_utility_service/transports/rest_base.py +0 -0
  22. loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/match_service/__init__.py +22 -0
  23. loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/match_service/__pycache__/__init__.cpython-312.pyc +0 -0
  24. loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/match_service/__pycache__/async_client.cpython-312.pyc +0 -0
  25. loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/match_service/__pycache__/client.cpython-312.pyc +0 -0
  26. loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/match_service/async_client.py +1193 -0
  27. loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/match_service/client.py +1695 -0
  28. loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/match_service/transports/__init__.py +54 -0
  29. loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/match_service/transports/__pycache__/__init__.cpython-312.pyc +0 -0
  30. loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/match_service/transports/__pycache__/base.cpython-312.pyc +0 -0
  31. loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/match_service/transports/__pycache__/grpc.cpython-312.pyc +0 -0
  32. loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/match_service/transports/__pycache__/grpc_asyncio.cpython-312.pyc +0 -0
  33. loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/match_service/transports/__pycache__/rest.cpython-312.pyc +0 -0
  34. loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/match_service/transports/__pycache__/rest_asyncio.cpython-312.pyc +0 -0
  35. loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/match_service/transports/__pycache__/rest_base.cpython-312.pyc +0 -0
  36. loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/match_service/transports/base.py +343 -0
  37. loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/match_service/transports/grpc.py +601 -0
  38. loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/match_service/transports/grpc_asyncio.py +680 -0
  39. loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/match_service/transports/rest.py +2262 -0
  40. loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/match_service/transports/rest_asyncio.py +0 -0
  41. loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/match_service/transports/rest_base.py +0 -0
  42. loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/metadata_service/__init__.py +22 -0
  43. loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/metadata_service/__pycache__/__init__.cpython-312.pyc +0 -0
  44. loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/metadata_service/__pycache__/async_client.cpython-312.pyc +3 -0
  45. loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/metadata_service/__pycache__/client.cpython-312.pyc +3 -0
  46. loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/metadata_service/__pycache__/pagers.cpython-312.pyc +0 -0
  47. loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/metadata_service/async_client.py +0 -0
  48. loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/metadata_service/client.py +0 -0
  49. loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/metadata_service/pagers.py +827 -0
  50. loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/metadata_service/transports/__init__.py +54 -0
.gitattributes CHANGED
@@ -260,3 +260,98 @@ loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/j
260
  loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/job_service/transports/__pycache__/rest.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
261
  loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/job_service/transports/__pycache__/rest_asyncio.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
262
  loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/job_service/transports/__pycache__/rest_base.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
260
  loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/job_service/transports/__pycache__/rest.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
261
  loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/job_service/transports/__pycache__/rest_asyncio.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
262
  loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/job_service/transports/__pycache__/rest_base.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
263
+ loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/metadata_service/__pycache__/async_client.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
264
+ loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/metadata_service/__pycache__/client.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
265
+ loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/metadata_service/transports/__pycache__/rest.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
266
+ loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/metadata_service/transports/__pycache__/rest_asyncio.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
267
+ loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/metadata_service/transports/__pycache__/rest_base.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
268
+ loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/migration_service/transports/__pycache__/rest.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
269
+ loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/migration_service/transports/__pycache__/rest_asyncio.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
270
+ loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/model_garden_service/transports/__pycache__/rest.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
271
+ loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/model_garden_service/transports/__pycache__/rest_asyncio.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
272
+ loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/model_service/__pycache__/async_client.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
273
+ loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/model_service/__pycache__/client.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
274
+ loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/model_service/transports/__pycache__/rest.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
275
+ loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/model_service/transports/__pycache__/rest_asyncio.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
276
+ loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/model_service/transports/__pycache__/rest_base.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
277
+ loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/notebook_service/__pycache__/async_client.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
278
+ loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/notebook_service/__pycache__/client.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
279
+ loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/notebook_service/transports/__pycache__/rest.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
280
+ loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/notebook_service/transports/__pycache__/rest_asyncio.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
281
+ loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/persistent_resource_service/transports/__pycache__/rest.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
282
+ loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/persistent_resource_service/transports/__pycache__/rest_asyncio.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
283
+ loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/pipeline_service/__pycache__/async_client.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
284
+ loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/pipeline_service/__pycache__/client.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
285
+ loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/pipeline_service/transports/__pycache__/rest.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
286
+ loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/pipeline_service/transports/__pycache__/rest_asyncio.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
287
+ loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/prediction_service/__pycache__/async_client.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
288
+ loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/prediction_service/__pycache__/client.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
289
+ loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/prediction_service/transports/__pycache__/rest.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
290
+ loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/prediction_service/transports/__pycache__/rest_asyncio.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
291
+ loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/reasoning_engine_service/transports/__pycache__/rest.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
292
+ loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/reasoning_engine_service/transports/__pycache__/rest_asyncio.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
293
+ loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/schedule_service/__pycache__/client.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
294
+ loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/schedule_service/transports/__pycache__/rest.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
295
+ loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/schedule_service/transports/__pycache__/rest_asyncio.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
296
+ loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/session_service/transports/__pycache__/rest.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
297
+ loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/session_service/transports/__pycache__/rest_asyncio.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
298
+ loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/specialist_pool_service/transports/__pycache__/rest.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
299
+ loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/specialist_pool_service/transports/__pycache__/rest_asyncio.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
300
+ loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/tensorboard_service/__pycache__/async_client.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
301
+ loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/tensorboard_service/__pycache__/client.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
302
+ loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/tensorboard_service/transports/__pycache__/rest.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
303
+ loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/tensorboard_service/transports/__pycache__/rest_asyncio.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
304
+ loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/tensorboard_service/transports/__pycache__/rest_base.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
305
+ loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/vertex_rag_data_service/__pycache__/async_client.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
306
+ loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/vertex_rag_data_service/__pycache__/client.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
307
+ loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/vertex_rag_data_service/transports/__pycache__/rest.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
308
+ loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/vertex_rag_data_service/transports/__pycache__/rest_asyncio.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
309
+ loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/vertex_rag_service/transports/__pycache__/rest.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
310
+ loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/vertex_rag_service/transports/__pycache__/rest_asyncio.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
311
+ loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/vizier_service/__pycache__/async_client.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
312
+ loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/vizier_service/__pycache__/client.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
313
+ loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/vizier_service/transports/__pycache__/rest.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
314
+ loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/vizier_service/transports/__pycache__/rest_asyncio.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
315
+ loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/types/__pycache__/evaluation_service.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
316
+ loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1beta1/services/dataset_service/__pycache__/async_client.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
317
+ loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1beta1/services/dataset_service/__pycache__/client.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
318
+ loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1beta1/services/dataset_service/transports/__pycache__/rest.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
319
+ loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1beta1/services/dataset_service/transports/__pycache__/rest_asyncio.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
320
+ loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1beta1/services/dataset_service/transports/__pycache__/rest_base.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
321
+ loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1beta1/services/deployment_resource_pool_service/transports/__pycache__/rest.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
322
+ loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1beta1/services/deployment_resource_pool_service/transports/__pycache__/rest_asyncio.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
323
+ loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1beta1/services/endpoint_service/__pycache__/async_client.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
324
+ loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1beta1/services/endpoint_service/__pycache__/client.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
325
+ loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1beta1/services/endpoint_service/transports/__pycache__/rest.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
326
+ loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1beta1/services/endpoint_service/transports/__pycache__/rest_asyncio.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
327
+ loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1beta1/services/evaluation_service/transports/__pycache__/rest.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
328
+ loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1beta1/services/evaluation_service/transports/__pycache__/rest_asyncio.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
329
+ loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1beta1/services/example_store_service/__pycache__/client.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
330
+ loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1beta1/services/example_store_service/transports/__pycache__/rest.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
331
+ loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1beta1/services/example_store_service/transports/__pycache__/rest_asyncio.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
332
+ loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1beta1/services/extension_registry_service/transports/__pycache__/rest.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
333
+ loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1beta1/services/extension_registry_service/transports/__pycache__/rest_asyncio.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
334
+ loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1beta1/services/feature_online_store_admin_service/__pycache__/async_client.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
335
+ loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1beta1/services/feature_online_store_admin_service/__pycache__/client.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
336
+ loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1beta1/services/feature_online_store_admin_service/transports/__pycache__/rest.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
337
+ loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1beta1/services/feature_online_store_admin_service/transports/__pycache__/rest_asyncio.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
338
+ loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1beta1/services/feature_online_store_service/transports/__pycache__/rest_asyncio.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
339
+ loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1beta1/services/feature_registry_service/__pycache__/async_client.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
340
+ loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1beta1/services/feature_registry_service/__pycache__/client.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
341
+ loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1beta1/services/feature_registry_service/transports/__pycache__/rest.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
342
+ loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1beta1/services/feature_registry_service/transports/__pycache__/rest_asyncio.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
343
+ loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1beta1/services/feature_registry_service/transports/__pycache__/rest_base.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
344
+ loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1beta1/services/featurestore_online_serving_service/transports/__pycache__/rest_asyncio.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
345
+ loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1beta1/services/featurestore_service/__pycache__/async_client.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
346
+ loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1beta1/services/featurestore_service/__pycache__/client.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
347
+ loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1beta1/services/featurestore_service/transports/__pycache__/rest.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
348
+ loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1beta1/services/featurestore_service/transports/__pycache__/rest_asyncio.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
349
+ loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1beta1/services/featurestore_service/transports/__pycache__/rest_base.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
350
+ loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1beta1/services/gen_ai_cache_service/transports/__pycache__/rest.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
351
+ loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1beta1/services/gen_ai_cache_service/transports/__pycache__/rest_asyncio.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
352
+ loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1beta1/services/gen_ai_tuning_service/transports/__pycache__/rest.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
353
+ loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1beta1/services/gen_ai_tuning_service/transports/__pycache__/rest_asyncio.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
354
+ loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1beta1/services/index_endpoint_service/__pycache__/client.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
355
+ loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1beta1/services/index_endpoint_service/transports/__pycache__/rest.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
356
+ loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1beta1/services/index_endpoint_service/transports/__pycache__/rest_asyncio.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
357
+ loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1beta1/services/index_service/transports/__pycache__/rest.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/llm_utility_service/__init__.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright 2025 Google LLC
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+ from .client import LlmUtilityServiceClient
17
+ from .async_client import LlmUtilityServiceAsyncClient
18
+
19
+ __all__ = (
20
+ "LlmUtilityServiceClient",
21
+ "LlmUtilityServiceAsyncClient",
22
+ )
loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/llm_utility_service/__pycache__/__init__.cpython-312.pyc ADDED
Binary file (389 Bytes). View file
 
loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/llm_utility_service/__pycache__/async_client.cpython-312.pyc ADDED
Binary file (51.8 kB). View file
 
loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/llm_utility_service/__pycache__/client.cpython-312.pyc ADDED
Binary file (72.1 kB). View file
 
loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/llm_utility_service/async_client.py ADDED
@@ -0,0 +1,1269 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright 2025 Google LLC
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+ import logging as std_logging
17
+ from collections import OrderedDict
18
+ import re
19
+ from typing import (
20
+ Dict,
21
+ Callable,
22
+ Mapping,
23
+ MutableMapping,
24
+ MutableSequence,
25
+ Optional,
26
+ Sequence,
27
+ Tuple,
28
+ Type,
29
+ Union,
30
+ )
31
+
32
+ from google.cloud.aiplatform_v1 import gapic_version as package_version
33
+
34
+ from google.api_core.client_options import ClientOptions
35
+ from google.api_core import exceptions as core_exceptions
36
+ from google.api_core import gapic_v1
37
+ from google.api_core import retry_async as retries
38
+ from google.auth import credentials as ga_credentials # type: ignore
39
+ from google.oauth2 import service_account # type: ignore
40
+ import google.protobuf
41
+
42
+
43
+ try:
44
+ OptionalRetry = Union[retries.AsyncRetry, gapic_v1.method._MethodDefault, None]
45
+ except AttributeError: # pragma: NO COVER
46
+ OptionalRetry = Union[retries.AsyncRetry, object, None] # type: ignore
47
+
48
+ from google.cloud.aiplatform_v1.types import content
49
+ from google.cloud.aiplatform_v1.types import llm_utility_service
50
+ from google.cloud.aiplatform_v1.types import prediction_service
51
+ from google.cloud.location import locations_pb2 # type: ignore
52
+ from google.iam.v1 import iam_policy_pb2 # type: ignore
53
+ from google.iam.v1 import policy_pb2 # type: ignore
54
+ from google.longrunning import operations_pb2 # type: ignore
55
+ import google.protobuf.struct_pb2 as struct_pb2 # type: ignore
56
+ from .transports.base import LlmUtilityServiceTransport, DEFAULT_CLIENT_INFO
57
+ from .transports.grpc_asyncio import LlmUtilityServiceGrpcAsyncIOTransport
58
+ from .client import LlmUtilityServiceClient
59
+
60
+ try:
61
+ from google.api_core import client_logging # type: ignore
62
+
63
+ CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER
64
+ except ImportError: # pragma: NO COVER
65
+ CLIENT_LOGGING_SUPPORTED = False
66
+
67
+ _LOGGER = std_logging.getLogger(__name__)
68
+
69
+
70
+ class LlmUtilityServiceAsyncClient:
71
+ """Service for LLM related utility functions."""
72
+
73
+ _client: LlmUtilityServiceClient
74
+
75
+ # Copy defaults from the synchronous client for use here.
76
+ # Note: DEFAULT_ENDPOINT is deprecated. Use _DEFAULT_ENDPOINT_TEMPLATE instead.
77
+ DEFAULT_ENDPOINT = LlmUtilityServiceClient.DEFAULT_ENDPOINT
78
+ DEFAULT_MTLS_ENDPOINT = LlmUtilityServiceClient.DEFAULT_MTLS_ENDPOINT
79
+ _DEFAULT_ENDPOINT_TEMPLATE = LlmUtilityServiceClient._DEFAULT_ENDPOINT_TEMPLATE
80
+ _DEFAULT_UNIVERSE = LlmUtilityServiceClient._DEFAULT_UNIVERSE
81
+
82
+ endpoint_path = staticmethod(LlmUtilityServiceClient.endpoint_path)
83
+ parse_endpoint_path = staticmethod(LlmUtilityServiceClient.parse_endpoint_path)
84
+ rag_corpus_path = staticmethod(LlmUtilityServiceClient.rag_corpus_path)
85
+ parse_rag_corpus_path = staticmethod(LlmUtilityServiceClient.parse_rag_corpus_path)
86
+ common_billing_account_path = staticmethod(
87
+ LlmUtilityServiceClient.common_billing_account_path
88
+ )
89
+ parse_common_billing_account_path = staticmethod(
90
+ LlmUtilityServiceClient.parse_common_billing_account_path
91
+ )
92
+ common_folder_path = staticmethod(LlmUtilityServiceClient.common_folder_path)
93
+ parse_common_folder_path = staticmethod(
94
+ LlmUtilityServiceClient.parse_common_folder_path
95
+ )
96
+ common_organization_path = staticmethod(
97
+ LlmUtilityServiceClient.common_organization_path
98
+ )
99
+ parse_common_organization_path = staticmethod(
100
+ LlmUtilityServiceClient.parse_common_organization_path
101
+ )
102
+ common_project_path = staticmethod(LlmUtilityServiceClient.common_project_path)
103
+ parse_common_project_path = staticmethod(
104
+ LlmUtilityServiceClient.parse_common_project_path
105
+ )
106
+ common_location_path = staticmethod(LlmUtilityServiceClient.common_location_path)
107
+ parse_common_location_path = staticmethod(
108
+ LlmUtilityServiceClient.parse_common_location_path
109
+ )
110
+
111
+ @classmethod
112
+ def from_service_account_info(cls, info: dict, *args, **kwargs):
113
+ """Creates an instance of this client using the provided credentials
114
+ info.
115
+
116
+ Args:
117
+ info (dict): The service account private key info.
118
+ args: Additional arguments to pass to the constructor.
119
+ kwargs: Additional arguments to pass to the constructor.
120
+
121
+ Returns:
122
+ LlmUtilityServiceAsyncClient: The constructed client.
123
+ """
124
+ sa_info_func = (
125
+ LlmUtilityServiceClient.from_service_account_info.__func__ # type: ignore
126
+ )
127
+ return sa_info_func(LlmUtilityServiceAsyncClient, info, *args, **kwargs)
128
+
129
+ @classmethod
130
+ def from_service_account_file(cls, filename: str, *args, **kwargs):
131
+ """Creates an instance of this client using the provided credentials
132
+ file.
133
+
134
+ Args:
135
+ filename (str): The path to the service account private key json
136
+ file.
137
+ args: Additional arguments to pass to the constructor.
138
+ kwargs: Additional arguments to pass to the constructor.
139
+
140
+ Returns:
141
+ LlmUtilityServiceAsyncClient: The constructed client.
142
+ """
143
+ sa_file_func = (
144
+ LlmUtilityServiceClient.from_service_account_file.__func__ # type: ignore
145
+ )
146
+ return sa_file_func(LlmUtilityServiceAsyncClient, filename, *args, **kwargs)
147
+
148
+ from_service_account_json = from_service_account_file
149
+
150
+ @classmethod
151
+ def get_mtls_endpoint_and_cert_source(
152
+ cls, client_options: Optional[ClientOptions] = None
153
+ ):
154
+ """Return the API endpoint and client cert source for mutual TLS.
155
+
156
+ The client cert source is determined in the following order:
157
+ (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the
158
+ client cert source is None.
159
+ (2) if `client_options.client_cert_source` is provided, use the provided one; if the
160
+ default client cert source exists, use the default one; otherwise the client cert
161
+ source is None.
162
+
163
+ The API endpoint is determined in the following order:
164
+ (1) if `client_options.api_endpoint` if provided, use the provided one.
165
+ (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the
166
+ default mTLS endpoint; if the environment variable is "never", use the default API
167
+ endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise
168
+ use the default API endpoint.
169
+
170
+ More details can be found at https://google.aip.dev/auth/4114.
171
+
172
+ Args:
173
+ client_options (google.api_core.client_options.ClientOptions): Custom options for the
174
+ client. Only the `api_endpoint` and `client_cert_source` properties may be used
175
+ in this method.
176
+
177
+ Returns:
178
+ Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the
179
+ client cert source to use.
180
+
181
+ Raises:
182
+ google.auth.exceptions.MutualTLSChannelError: If any errors happen.
183
+ """
184
+ return LlmUtilityServiceClient.get_mtls_endpoint_and_cert_source(client_options) # type: ignore
185
+
186
+ @property
187
+ def transport(self) -> LlmUtilityServiceTransport:
188
+ """Returns the transport used by the client instance.
189
+
190
+ Returns:
191
+ LlmUtilityServiceTransport: The transport used by the client instance.
192
+ """
193
+ return self._client.transport
194
+
195
+ @property
196
+ def api_endpoint(self):
197
+ """Return the API endpoint used by the client instance.
198
+
199
+ Returns:
200
+ str: The API endpoint used by the client instance.
201
+ """
202
+ return self._client._api_endpoint
203
+
204
+ @property
205
+ def universe_domain(self) -> str:
206
+ """Return the universe domain used by the client instance.
207
+
208
+ Returns:
209
+ str: The universe domain used
210
+ by the client instance.
211
+ """
212
+ return self._client._universe_domain
213
+
214
+ get_transport_class = LlmUtilityServiceClient.get_transport_class
215
+
216
+ def __init__(
217
+ self,
218
+ *,
219
+ credentials: Optional[ga_credentials.Credentials] = None,
220
+ transport: Optional[
221
+ Union[
222
+ str,
223
+ LlmUtilityServiceTransport,
224
+ Callable[..., LlmUtilityServiceTransport],
225
+ ]
226
+ ] = "grpc_asyncio",
227
+ client_options: Optional[ClientOptions] = None,
228
+ client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
229
+ ) -> None:
230
+ """Instantiates the llm utility service async client.
231
+
232
+ Args:
233
+ credentials (Optional[google.auth.credentials.Credentials]): The
234
+ authorization credentials to attach to requests. These
235
+ credentials identify the application to the service; if none
236
+ are specified, the client will attempt to ascertain the
237
+ credentials from the environment.
238
+ transport (Optional[Union[str,LlmUtilityServiceTransport,Callable[..., LlmUtilityServiceTransport]]]):
239
+ The transport to use, or a Callable that constructs and returns a new transport to use.
240
+ If a Callable is given, it will be called with the same set of initialization
241
+ arguments as used in the LlmUtilityServiceTransport constructor.
242
+ If set to None, a transport is chosen automatically.
243
+ client_options (Optional[Union[google.api_core.client_options.ClientOptions, dict]]):
244
+ Custom options for the client.
245
+
246
+ 1. The ``api_endpoint`` property can be used to override the
247
+ default endpoint provided by the client when ``transport`` is
248
+ not explicitly provided. Only if this property is not set and
249
+ ``transport`` was not explicitly provided, the endpoint is
250
+ determined by the GOOGLE_API_USE_MTLS_ENDPOINT environment
251
+ variable, which have one of the following values:
252
+ "always" (always use the default mTLS endpoint), "never" (always
253
+ use the default regular endpoint) and "auto" (auto-switch to the
254
+ default mTLS endpoint if client certificate is present; this is
255
+ the default value).
256
+
257
+ 2. If the GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable
258
+ is "true", then the ``client_cert_source`` property can be used
259
+ to provide a client certificate for mTLS transport. If
260
+ not provided, the default SSL client certificate will be used if
261
+ present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is "false" or not
262
+ set, no client certificate will be used.
263
+
264
+ 3. The ``universe_domain`` property can be used to override the
265
+ default "googleapis.com" universe. Note that ``api_endpoint``
266
+ property still takes precedence; and ``universe_domain`` is
267
+ currently not supported for mTLS.
268
+
269
+ client_info (google.api_core.gapic_v1.client_info.ClientInfo):
270
+ The client info used to send a user-agent string along with
271
+ API requests. If ``None``, then default info will be used.
272
+ Generally, you only need to set this if you're developing
273
+ your own client library.
274
+
275
+ Raises:
276
+ google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport
277
+ creation failed for any reason.
278
+ """
279
+ self._client = LlmUtilityServiceClient(
280
+ credentials=credentials,
281
+ transport=transport,
282
+ client_options=client_options,
283
+ client_info=client_info,
284
+ )
285
+
286
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
287
+ std_logging.DEBUG
288
+ ): # pragma: NO COVER
289
+ _LOGGER.debug(
290
+ "Created client `google.cloud.aiplatform_v1.LlmUtilityServiceAsyncClient`.",
291
+ extra=(
292
+ {
293
+ "serviceName": "google.cloud.aiplatform.v1.LlmUtilityService",
294
+ "universeDomain": getattr(
295
+ self._client._transport._credentials, "universe_domain", ""
296
+ ),
297
+ "credentialsType": f"{type(self._client._transport._credentials).__module__}.{type(self._client._transport._credentials).__qualname__}",
298
+ "credentialsInfo": getattr(
299
+ self.transport._credentials, "get_cred_info", lambda: None
300
+ )(),
301
+ }
302
+ if hasattr(self._client._transport, "_credentials")
303
+ else {
304
+ "serviceName": "google.cloud.aiplatform.v1.LlmUtilityService",
305
+ "credentialsType": None,
306
+ }
307
+ ),
308
+ )
309
+
310
+ async def count_tokens(
311
+ self,
312
+ request: Optional[Union[prediction_service.CountTokensRequest, dict]] = None,
313
+ *,
314
+ endpoint: Optional[str] = None,
315
+ instances: Optional[MutableSequence[struct_pb2.Value]] = None,
316
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
317
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
318
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
319
+ ) -> prediction_service.CountTokensResponse:
320
+ r"""Perform a token counting.
321
+
322
+ .. code-block:: python
323
+
324
+ # This snippet has been automatically generated and should be regarded as a
325
+ # code template only.
326
+ # It will require modifications to work:
327
+ # - It may require correct/in-range values for request initialization.
328
+ # - It may require specifying regional endpoints when creating the service
329
+ # client as shown in:
330
+ # https://googleapis.dev/python/google-api-core/latest/client_options.html
331
+ from google.cloud import aiplatform_v1
332
+
333
+ async def sample_count_tokens():
334
+ # Create a client
335
+ client = aiplatform_v1.LlmUtilityServiceAsyncClient()
336
+
337
+ # Initialize request argument(s)
338
+ request = aiplatform_v1.CountTokensRequest(
339
+ endpoint="endpoint_value",
340
+ )
341
+
342
+ # Make the request
343
+ response = await client.count_tokens(request=request)
344
+
345
+ # Handle the response
346
+ print(response)
347
+
348
+ Args:
349
+ request (Optional[Union[google.cloud.aiplatform_v1.types.CountTokensRequest, dict]]):
350
+ The request object. Request message for [PredictionService.CountTokens][].
351
+ endpoint (:class:`str`):
352
+ Required. The name of the Endpoint requested to perform
353
+ token counting. Format:
354
+ ``projects/{project}/locations/{location}/endpoints/{endpoint}``
355
+
356
+ This corresponds to the ``endpoint`` field
357
+ on the ``request`` instance; if ``request`` is provided, this
358
+ should not be set.
359
+ instances (:class:`MutableSequence[google.protobuf.struct_pb2.Value]`):
360
+ Optional. The instances that are the
361
+ input to token counting call. Schema is
362
+ identical to the prediction schema of
363
+ the underlying model.
364
+
365
+ This corresponds to the ``instances`` field
366
+ on the ``request`` instance; if ``request`` is provided, this
367
+ should not be set.
368
+ retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
369
+ should be retried.
370
+ timeout (float): The timeout for this request.
371
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
372
+ sent along with the request as metadata. Normally, each value must be of type `str`,
373
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
374
+ be of type `bytes`.
375
+
376
+ Returns:
377
+ google.cloud.aiplatform_v1.types.CountTokensResponse:
378
+ Response message for [PredictionService.CountTokens][].
379
+ """
380
+ # Create or coerce a protobuf request object.
381
+ # - Quick check: If we got a request object, we should *not* have
382
+ # gotten any keyword arguments that map to the request.
383
+ flattened_params = [endpoint, instances]
384
+ has_flattened_params = (
385
+ len([param for param in flattened_params if param is not None]) > 0
386
+ )
387
+ if request is not None and has_flattened_params:
388
+ raise ValueError(
389
+ "If the `request` argument is set, then none of "
390
+ "the individual field arguments should be set."
391
+ )
392
+
393
+ # - Use the request object if provided (there's no risk of modifying the input as
394
+ # there are no flattened fields), or create one.
395
+ if not isinstance(request, prediction_service.CountTokensRequest):
396
+ request = prediction_service.CountTokensRequest(request)
397
+
398
+ # If we have keyword arguments corresponding to fields on the
399
+ # request, apply these.
400
+ if endpoint is not None:
401
+ request.endpoint = endpoint
402
+ if instances:
403
+ request.instances.extend(instances)
404
+
405
+ # Wrap the RPC method; this adds retry and timeout information,
406
+ # and friendly error handling.
407
+ rpc = self._client._transport._wrapped_methods[
408
+ self._client._transport.count_tokens
409
+ ]
410
+
411
+ # Certain fields should be provided within the metadata header;
412
+ # add these here.
413
+ metadata = tuple(metadata) + (
414
+ gapic_v1.routing_header.to_grpc_metadata((("endpoint", request.endpoint),)),
415
+ )
416
+
417
+ # Validate the universe domain.
418
+ self._client._validate_universe_domain()
419
+
420
+ # Send the request.
421
+ response = await rpc(
422
+ request,
423
+ retry=retry,
424
+ timeout=timeout,
425
+ metadata=metadata,
426
+ )
427
+
428
+ # Done; return the response.
429
+ return response
430
+
431
+ async def compute_tokens(
432
+ self,
433
+ request: Optional[Union[llm_utility_service.ComputeTokensRequest, dict]] = None,
434
+ *,
435
+ endpoint: Optional[str] = None,
436
+ instances: Optional[MutableSequence[struct_pb2.Value]] = None,
437
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
438
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
439
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
440
+ ) -> llm_utility_service.ComputeTokensResponse:
441
+ r"""Return a list of tokens based on the input text.
442
+
443
+ .. code-block:: python
444
+
445
+ # This snippet has been automatically generated and should be regarded as a
446
+ # code template only.
447
+ # It will require modifications to work:
448
+ # - It may require correct/in-range values for request initialization.
449
+ # - It may require specifying regional endpoints when creating the service
450
+ # client as shown in:
451
+ # https://googleapis.dev/python/google-api-core/latest/client_options.html
452
+ from google.cloud import aiplatform_v1
453
+
454
+ async def sample_compute_tokens():
455
+ # Create a client
456
+ client = aiplatform_v1.LlmUtilityServiceAsyncClient()
457
+
458
+ # Initialize request argument(s)
459
+ request = aiplatform_v1.ComputeTokensRequest(
460
+ endpoint="endpoint_value",
461
+ )
462
+
463
+ # Make the request
464
+ response = await client.compute_tokens(request=request)
465
+
466
+ # Handle the response
467
+ print(response)
468
+
469
+ Args:
470
+ request (Optional[Union[google.cloud.aiplatform_v1.types.ComputeTokensRequest, dict]]):
471
+ The request object. Request message for ComputeTokens RPC
472
+ call.
473
+ endpoint (:class:`str`):
474
+ Required. The name of the Endpoint
475
+ requested to get lists of tokens and
476
+ token ids.
477
+
478
+ This corresponds to the ``endpoint`` field
479
+ on the ``request`` instance; if ``request`` is provided, this
480
+ should not be set.
481
+ instances (:class:`MutableSequence[google.protobuf.struct_pb2.Value]`):
482
+ Optional. The instances that are the
483
+ input to token computing API call.
484
+ Schema is identical to the prediction
485
+ schema of the text model, even for the
486
+ non-text models, like chat models, or
487
+ Codey models.
488
+
489
+ This corresponds to the ``instances`` field
490
+ on the ``request`` instance; if ``request`` is provided, this
491
+ should not be set.
492
+ retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
493
+ should be retried.
494
+ timeout (float): The timeout for this request.
495
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
496
+ sent along with the request as metadata. Normally, each value must be of type `str`,
497
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
498
+ be of type `bytes`.
499
+
500
+ Returns:
501
+ google.cloud.aiplatform_v1.types.ComputeTokensResponse:
502
+ Response message for ComputeTokens
503
+ RPC call.
504
+
505
+ """
506
+ # Create or coerce a protobuf request object.
507
+ # - Quick check: If we got a request object, we should *not* have
508
+ # gotten any keyword arguments that map to the request.
509
+ flattened_params = [endpoint, instances]
510
+ has_flattened_params = (
511
+ len([param for param in flattened_params if param is not None]) > 0
512
+ )
513
+ if request is not None and has_flattened_params:
514
+ raise ValueError(
515
+ "If the `request` argument is set, then none of "
516
+ "the individual field arguments should be set."
517
+ )
518
+
519
+ # - Use the request object if provided (there's no risk of modifying the input as
520
+ # there are no flattened fields), or create one.
521
+ if not isinstance(request, llm_utility_service.ComputeTokensRequest):
522
+ request = llm_utility_service.ComputeTokensRequest(request)
523
+
524
+ # If we have keyword arguments corresponding to fields on the
525
+ # request, apply these.
526
+ if endpoint is not None:
527
+ request.endpoint = endpoint
528
+ if instances:
529
+ request.instances.extend(instances)
530
+
531
+ # Wrap the RPC method; this adds retry and timeout information,
532
+ # and friendly error handling.
533
+ rpc = self._client._transport._wrapped_methods[
534
+ self._client._transport.compute_tokens
535
+ ]
536
+
537
+ # Certain fields should be provided within the metadata header;
538
+ # add these here.
539
+ metadata = tuple(metadata) + (
540
+ gapic_v1.routing_header.to_grpc_metadata((("endpoint", request.endpoint),)),
541
+ )
542
+
543
+ # Validate the universe domain.
544
+ self._client._validate_universe_domain()
545
+
546
+ # Send the request.
547
+ response = await rpc(
548
+ request,
549
+ retry=retry,
550
+ timeout=timeout,
551
+ metadata=metadata,
552
+ )
553
+
554
+ # Done; return the response.
555
+ return response
556
+
557
+ async def list_operations(
558
+ self,
559
+ request: Optional[operations_pb2.ListOperationsRequest] = None,
560
+ *,
561
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
562
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
563
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
564
+ ) -> operations_pb2.ListOperationsResponse:
565
+ r"""Lists operations that match the specified filter in the request.
566
+
567
+ Args:
568
+ request (:class:`~.operations_pb2.ListOperationsRequest`):
569
+ The request object. Request message for
570
+ `ListOperations` method.
571
+ retry (google.api_core.retry_async.AsyncRetry): Designation of what errors,
572
+ if any, should be retried.
573
+ timeout (float): The timeout for this request.
574
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
575
+ sent along with the request as metadata. Normally, each value must be of type `str`,
576
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
577
+ be of type `bytes`.
578
+ Returns:
579
+ ~.operations_pb2.ListOperationsResponse:
580
+ Response message for ``ListOperations`` method.
581
+ """
582
+ # Create or coerce a protobuf request object.
583
+ # The request isn't a proto-plus wrapped type,
584
+ # so it must be constructed via keyword expansion.
585
+ if isinstance(request, dict):
586
+ request = operations_pb2.ListOperationsRequest(**request)
587
+
588
+ # Wrap the RPC method; this adds retry and timeout information,
589
+ # and friendly error handling.
590
+ rpc = self.transport._wrapped_methods[self._client._transport.list_operations]
591
+
592
+ # Certain fields should be provided within the metadata header;
593
+ # add these here.
594
+ metadata = tuple(metadata) + (
595
+ gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
596
+ )
597
+
598
+ # Validate the universe domain.
599
+ self._client._validate_universe_domain()
600
+
601
+ # Send the request.
602
+ response = await rpc(
603
+ request,
604
+ retry=retry,
605
+ timeout=timeout,
606
+ metadata=metadata,
607
+ )
608
+
609
+ # Done; return the response.
610
+ return response
611
+
612
+ async def get_operation(
613
+ self,
614
+ request: Optional[operations_pb2.GetOperationRequest] = None,
615
+ *,
616
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
617
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
618
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
619
+ ) -> operations_pb2.Operation:
620
+ r"""Gets the latest state of a long-running operation.
621
+
622
+ Args:
623
+ request (:class:`~.operations_pb2.GetOperationRequest`):
624
+ The request object. Request message for
625
+ `GetOperation` method.
626
+ retry (google.api_core.retry_async.AsyncRetry): Designation of what errors,
627
+ if any, should be retried.
628
+ timeout (float): The timeout for this request.
629
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
630
+ sent along with the request as metadata. Normally, each value must be of type `str`,
631
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
632
+ be of type `bytes`.
633
+ Returns:
634
+ ~.operations_pb2.Operation:
635
+ An ``Operation`` object.
636
+ """
637
+ # Create or coerce a protobuf request object.
638
+ # The request isn't a proto-plus wrapped type,
639
+ # so it must be constructed via keyword expansion.
640
+ if isinstance(request, dict):
641
+ request = operations_pb2.GetOperationRequest(**request)
642
+
643
+ # Wrap the RPC method; this adds retry and timeout information,
644
+ # and friendly error handling.
645
+ rpc = self.transport._wrapped_methods[self._client._transport.get_operation]
646
+
647
+ # Certain fields should be provided within the metadata header;
648
+ # add these here.
649
+ metadata = tuple(metadata) + (
650
+ gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
651
+ )
652
+
653
+ # Validate the universe domain.
654
+ self._client._validate_universe_domain()
655
+
656
+ # Send the request.
657
+ response = await rpc(
658
+ request,
659
+ retry=retry,
660
+ timeout=timeout,
661
+ metadata=metadata,
662
+ )
663
+
664
+ # Done; return the response.
665
+ return response
666
+
667
+ async def delete_operation(
668
+ self,
669
+ request: Optional[operations_pb2.DeleteOperationRequest] = None,
670
+ *,
671
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
672
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
673
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
674
+ ) -> None:
675
+ r"""Deletes a long-running operation.
676
+
677
+ This method indicates that the client is no longer interested
678
+ in the operation result. It does not cancel the operation.
679
+ If the server doesn't support this method, it returns
680
+ `google.rpc.Code.UNIMPLEMENTED`.
681
+
682
+ Args:
683
+ request (:class:`~.operations_pb2.DeleteOperationRequest`):
684
+ The request object. Request message for
685
+ `DeleteOperation` method.
686
+ retry (google.api_core.retry_async.AsyncRetry): Designation of what errors,
687
+ if any, should be retried.
688
+ timeout (float): The timeout for this request.
689
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
690
+ sent along with the request as metadata. Normally, each value must be of type `str`,
691
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
692
+ be of type `bytes`.
693
+ Returns:
694
+ None
695
+ """
696
+ # Create or coerce a protobuf request object.
697
+ # The request isn't a proto-plus wrapped type,
698
+ # so it must be constructed via keyword expansion.
699
+ if isinstance(request, dict):
700
+ request = operations_pb2.DeleteOperationRequest(**request)
701
+
702
+ # Wrap the RPC method; this adds retry and timeout information,
703
+ # and friendly error handling.
704
+ rpc = self.transport._wrapped_methods[self._client._transport.delete_operation]
705
+
706
+ # Certain fields should be provided within the metadata header;
707
+ # add these here.
708
+ metadata = tuple(metadata) + (
709
+ gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
710
+ )
711
+
712
+ # Validate the universe domain.
713
+ self._client._validate_universe_domain()
714
+
715
+ # Send the request.
716
+ await rpc(
717
+ request,
718
+ retry=retry,
719
+ timeout=timeout,
720
+ metadata=metadata,
721
+ )
722
+
723
+ async def cancel_operation(
724
+ self,
725
+ request: Optional[operations_pb2.CancelOperationRequest] = None,
726
+ *,
727
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
728
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
729
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
730
+ ) -> None:
731
+ r"""Starts asynchronous cancellation on a long-running operation.
732
+
733
+ The server makes a best effort to cancel the operation, but success
734
+ is not guaranteed. If the server doesn't support this method, it returns
735
+ `google.rpc.Code.UNIMPLEMENTED`.
736
+
737
+ Args:
738
+ request (:class:`~.operations_pb2.CancelOperationRequest`):
739
+ The request object. Request message for
740
+ `CancelOperation` method.
741
+ retry (google.api_core.retry_async.AsyncRetry): Designation of what errors,
742
+ if any, should be retried.
743
+ timeout (float): The timeout for this request.
744
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
745
+ sent along with the request as metadata. Normally, each value must be of type `str`,
746
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
747
+ be of type `bytes`.
748
+ Returns:
749
+ None
750
+ """
751
+ # Create or coerce a protobuf request object.
752
+ # The request isn't a proto-plus wrapped type,
753
+ # so it must be constructed via keyword expansion.
754
+ if isinstance(request, dict):
755
+ request = operations_pb2.CancelOperationRequest(**request)
756
+
757
+ # Wrap the RPC method; this adds retry and timeout information,
758
+ # and friendly error handling.
759
+ rpc = self.transport._wrapped_methods[self._client._transport.cancel_operation]
760
+
761
+ # Certain fields should be provided within the metadata header;
762
+ # add these here.
763
+ metadata = tuple(metadata) + (
764
+ gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
765
+ )
766
+
767
+ # Validate the universe domain.
768
+ self._client._validate_universe_domain()
769
+
770
+ # Send the request.
771
+ await rpc(
772
+ request,
773
+ retry=retry,
774
+ timeout=timeout,
775
+ metadata=metadata,
776
+ )
777
+
778
+ async def wait_operation(
779
+ self,
780
+ request: Optional[operations_pb2.WaitOperationRequest] = None,
781
+ *,
782
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
783
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
784
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
785
+ ) -> operations_pb2.Operation:
786
+ r"""Waits until the specified long-running operation is done or reaches at most
787
+ a specified timeout, returning the latest state.
788
+
789
+ If the operation is already done, the latest state is immediately returned.
790
+ If the timeout specified is greater than the default HTTP/RPC timeout, the HTTP/RPC
791
+ timeout is used. If the server does not support this method, it returns
792
+ `google.rpc.Code.UNIMPLEMENTED`.
793
+
794
+ Args:
795
+ request (:class:`~.operations_pb2.WaitOperationRequest`):
796
+ The request object. Request message for
797
+ `WaitOperation` method.
798
+ retry (google.api_core.retry_async.AsyncRetry): Designation of what errors,
799
+ if any, should be retried.
800
+ timeout (float): The timeout for this request.
801
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
802
+ sent along with the request as metadata. Normally, each value must be of type `str`,
803
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
804
+ be of type `bytes`.
805
+ Returns:
806
+ ~.operations_pb2.Operation:
807
+ An ``Operation`` object.
808
+ """
809
+ # Create or coerce a protobuf request object.
810
+ # The request isn't a proto-plus wrapped type,
811
+ # so it must be constructed via keyword expansion.
812
+ if isinstance(request, dict):
813
+ request = operations_pb2.WaitOperationRequest(**request)
814
+
815
+ # Wrap the RPC method; this adds retry and timeout information,
816
+ # and friendly error handling.
817
+ rpc = self.transport._wrapped_methods[self._client._transport.wait_operation]
818
+
819
+ # Certain fields should be provided within the metadata header;
820
+ # add these here.
821
+ metadata = tuple(metadata) + (
822
+ gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
823
+ )
824
+
825
+ # Validate the universe domain.
826
+ self._client._validate_universe_domain()
827
+
828
+ # Send the request.
829
+ response = await rpc(
830
+ request,
831
+ retry=retry,
832
+ timeout=timeout,
833
+ metadata=metadata,
834
+ )
835
+
836
+ # Done; return the response.
837
+ return response
838
+
839
+ async def set_iam_policy(
840
+ self,
841
+ request: Optional[iam_policy_pb2.SetIamPolicyRequest] = None,
842
+ *,
843
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
844
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
845
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
846
+ ) -> policy_pb2.Policy:
847
+ r"""Sets the IAM access control policy on the specified function.
848
+
849
+ Replaces any existing policy.
850
+
851
+ Args:
852
+ request (:class:`~.iam_policy_pb2.SetIamPolicyRequest`):
853
+ The request object. Request message for `SetIamPolicy`
854
+ method.
855
+ retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
856
+ should be retried.
857
+ timeout (float): The timeout for this request.
858
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
859
+ sent along with the request as metadata. Normally, each value must be of type `str`,
860
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
861
+ be of type `bytes`.
862
+ Returns:
863
+ ~.policy_pb2.Policy:
864
+ Defines an Identity and Access Management (IAM) policy.
865
+ It is used to specify access control policies for Cloud
866
+ Platform resources.
867
+ A ``Policy`` is a collection of ``bindings``. A
868
+ ``binding`` binds one or more ``members`` to a single
869
+ ``role``. Members can be user accounts, service
870
+ accounts, Google groups, and domains (such as G Suite).
871
+ A ``role`` is a named list of permissions (defined by
872
+ IAM or configured by users). A ``binding`` can
873
+ optionally specify a ``condition``, which is a logic
874
+ expression that further constrains the role binding
875
+ based on attributes about the request and/or target
876
+ resource.
877
+
878
+ **JSON Example**
879
+
880
+ ::
881
+
882
+ {
883
+ "bindings": [
884
+ {
885
+ "role": "roles/resourcemanager.organizationAdmin",
886
+ "members": [
887
+ "user:mike@example.com",
888
+ "group:admins@example.com",
889
+ "domain:google.com",
890
+ "serviceAccount:my-project-id@appspot.gserviceaccount.com"
891
+ ]
892
+ },
893
+ {
894
+ "role": "roles/resourcemanager.organizationViewer",
895
+ "members": ["user:eve@example.com"],
896
+ "condition": {
897
+ "title": "expirable access",
898
+ "description": "Does not grant access after Sep 2020",
899
+ "expression": "request.time <
900
+ timestamp('2020-10-01T00:00:00.000Z')",
901
+ }
902
+ }
903
+ ]
904
+ }
905
+
906
+ **YAML Example**
907
+
908
+ ::
909
+
910
+ bindings:
911
+ - members:
912
+ - user:mike@example.com
913
+ - group:admins@example.com
914
+ - domain:google.com
915
+ - serviceAccount:my-project-id@appspot.gserviceaccount.com
916
+ role: roles/resourcemanager.organizationAdmin
917
+ - members:
918
+ - user:eve@example.com
919
+ role: roles/resourcemanager.organizationViewer
920
+ condition:
921
+ title: expirable access
922
+ description: Does not grant access after Sep 2020
923
+ expression: request.time < timestamp('2020-10-01T00:00:00.000Z')
924
+
925
+ For a description of IAM and its features, see the `IAM
926
+ developer's
927
+ guide <https://cloud.google.com/iam/docs>`__.
928
+ """
929
+ # Create or coerce a protobuf request object.
930
+
931
+ # The request isn't a proto-plus wrapped type,
932
+ # so it must be constructed via keyword expansion.
933
+ if isinstance(request, dict):
934
+ request = iam_policy_pb2.SetIamPolicyRequest(**request)
935
+
936
+ # Wrap the RPC method; this adds retry and timeout information,
937
+ # and friendly error handling.
938
+ rpc = self.transport._wrapped_methods[self._client._transport.set_iam_policy]
939
+
940
+ # Certain fields should be provided within the metadata header;
941
+ # add these here.
942
+ metadata = tuple(metadata) + (
943
+ gapic_v1.routing_header.to_grpc_metadata((("resource", request.resource),)),
944
+ )
945
+
946
+ # Validate the universe domain.
947
+ self._client._validate_universe_domain()
948
+
949
+ # Send the request.
950
+ response = await rpc(
951
+ request,
952
+ retry=retry,
953
+ timeout=timeout,
954
+ metadata=metadata,
955
+ )
956
+
957
+ # Done; return the response.
958
+ return response
959
+
960
+ async def get_iam_policy(
961
+ self,
962
+ request: Optional[iam_policy_pb2.GetIamPolicyRequest] = None,
963
+ *,
964
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
965
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
966
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
967
+ ) -> policy_pb2.Policy:
968
+ r"""Gets the IAM access control policy for a function.
969
+
970
+ Returns an empty policy if the function exists and does not have a
971
+ policy set.
972
+
973
+ Args:
974
+ request (:class:`~.iam_policy_pb2.GetIamPolicyRequest`):
975
+ The request object. Request message for `GetIamPolicy`
976
+ method.
977
+ retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if
978
+ any, should be retried.
979
+ timeout (float): The timeout for this request.
980
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
981
+ sent along with the request as metadata. Normally, each value must be of type `str`,
982
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
983
+ be of type `bytes`.
984
+ Returns:
985
+ ~.policy_pb2.Policy:
986
+ Defines an Identity and Access Management (IAM) policy.
987
+ It is used to specify access control policies for Cloud
988
+ Platform resources.
989
+ A ``Policy`` is a collection of ``bindings``. A
990
+ ``binding`` binds one or more ``members`` to a single
991
+ ``role``. Members can be user accounts, service
992
+ accounts, Google groups, and domains (such as G Suite).
993
+ A ``role`` is a named list of permissions (defined by
994
+ IAM or configured by users). A ``binding`` can
995
+ optionally specify a ``condition``, which is a logic
996
+ expression that further constrains the role binding
997
+ based on attributes about the request and/or target
998
+ resource.
999
+
1000
+ **JSON Example**
1001
+
1002
+ ::
1003
+
1004
+ {
1005
+ "bindings": [
1006
+ {
1007
+ "role": "roles/resourcemanager.organizationAdmin",
1008
+ "members": [
1009
+ "user:mike@example.com",
1010
+ "group:admins@example.com",
1011
+ "domain:google.com",
1012
+ "serviceAccount:my-project-id@appspot.gserviceaccount.com"
1013
+ ]
1014
+ },
1015
+ {
1016
+ "role": "roles/resourcemanager.organizationViewer",
1017
+ "members": ["user:eve@example.com"],
1018
+ "condition": {
1019
+ "title": "expirable access",
1020
+ "description": "Does not grant access after Sep 2020",
1021
+ "expression": "request.time <
1022
+ timestamp('2020-10-01T00:00:00.000Z')",
1023
+ }
1024
+ }
1025
+ ]
1026
+ }
1027
+
1028
+ **YAML Example**
1029
+
1030
+ ::
1031
+
1032
+ bindings:
1033
+ - members:
1034
+ - user:mike@example.com
1035
+ - group:admins@example.com
1036
+ - domain:google.com
1037
+ - serviceAccount:my-project-id@appspot.gserviceaccount.com
1038
+ role: roles/resourcemanager.organizationAdmin
1039
+ - members:
1040
+ - user:eve@example.com
1041
+ role: roles/resourcemanager.organizationViewer
1042
+ condition:
1043
+ title: expirable access
1044
+ description: Does not grant access after Sep 2020
1045
+ expression: request.time < timestamp('2020-10-01T00:00:00.000Z')
1046
+
1047
+ For a description of IAM and its features, see the `IAM
1048
+ developer's
1049
+ guide <https://cloud.google.com/iam/docs>`__.
1050
+ """
1051
+ # Create or coerce a protobuf request object.
1052
+
1053
+ # The request isn't a proto-plus wrapped type,
1054
+ # so it must be constructed via keyword expansion.
1055
+ if isinstance(request, dict):
1056
+ request = iam_policy_pb2.GetIamPolicyRequest(**request)
1057
+
1058
+ # Wrap the RPC method; this adds retry and timeout information,
1059
+ # and friendly error handling.
1060
+ rpc = self.transport._wrapped_methods[self._client._transport.get_iam_policy]
1061
+
1062
+ # Certain fields should be provided within the metadata header;
1063
+ # add these here.
1064
+ metadata = tuple(metadata) + (
1065
+ gapic_v1.routing_header.to_grpc_metadata((("resource", request.resource),)),
1066
+ )
1067
+
1068
+ # Validate the universe domain.
1069
+ self._client._validate_universe_domain()
1070
+
1071
+ # Send the request.
1072
+ response = await rpc(
1073
+ request,
1074
+ retry=retry,
1075
+ timeout=timeout,
1076
+ metadata=metadata,
1077
+ )
1078
+
1079
+ # Done; return the response.
1080
+ return response
1081
+
1082
+ async def test_iam_permissions(
1083
+ self,
1084
+ request: Optional[iam_policy_pb2.TestIamPermissionsRequest] = None,
1085
+ *,
1086
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
1087
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
1088
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
1089
+ ) -> iam_policy_pb2.TestIamPermissionsResponse:
1090
+ r"""Tests the specified IAM permissions against the IAM access control
1091
+ policy for a function.
1092
+
1093
+ If the function does not exist, this will return an empty set
1094
+ of permissions, not a NOT_FOUND error.
1095
+
1096
+ Args:
1097
+ request (:class:`~.iam_policy_pb2.TestIamPermissionsRequest`):
1098
+ The request object. Request message for
1099
+ `TestIamPermissions` method.
1100
+ retry (google.api_core.retry_async.AsyncRetry): Designation of what errors,
1101
+ if any, should be retried.
1102
+ timeout (float): The timeout for this request.
1103
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1104
+ sent along with the request as metadata. Normally, each value must be of type `str`,
1105
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
1106
+ be of type `bytes`.
1107
+ Returns:
1108
+ ~.iam_policy_pb2.TestIamPermissionsResponse:
1109
+ Response message for ``TestIamPermissions`` method.
1110
+ """
1111
+ # Create or coerce a protobuf request object.
1112
+
1113
+ # The request isn't a proto-plus wrapped type,
1114
+ # so it must be constructed via keyword expansion.
1115
+ if isinstance(request, dict):
1116
+ request = iam_policy_pb2.TestIamPermissionsRequest(**request)
1117
+
1118
+ # Wrap the RPC method; this adds retry and timeout information,
1119
+ # and friendly error handling.
1120
+ rpc = self.transport._wrapped_methods[
1121
+ self._client._transport.test_iam_permissions
1122
+ ]
1123
+
1124
+ # Certain fields should be provided within the metadata header;
1125
+ # add these here.
1126
+ metadata = tuple(metadata) + (
1127
+ gapic_v1.routing_header.to_grpc_metadata((("resource", request.resource),)),
1128
+ )
1129
+
1130
+ # Validate the universe domain.
1131
+ self._client._validate_universe_domain()
1132
+
1133
+ # Send the request.
1134
+ response = await rpc(
1135
+ request,
1136
+ retry=retry,
1137
+ timeout=timeout,
1138
+ metadata=metadata,
1139
+ )
1140
+
1141
+ # Done; return the response.
1142
+ return response
1143
+
1144
+ async def get_location(
1145
+ self,
1146
+ request: Optional[locations_pb2.GetLocationRequest] = None,
1147
+ *,
1148
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
1149
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
1150
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
1151
+ ) -> locations_pb2.Location:
1152
+ r"""Gets information about a location.
1153
+
1154
+ Args:
1155
+ request (:class:`~.location_pb2.GetLocationRequest`):
1156
+ The request object. Request message for
1157
+ `GetLocation` method.
1158
+ retry (google.api_core.retry_async.AsyncRetry): Designation of what errors,
1159
+ if any, should be retried.
1160
+ timeout (float): The timeout for this request.
1161
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1162
+ sent along with the request as metadata. Normally, each value must be of type `str`,
1163
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
1164
+ be of type `bytes`.
1165
+ Returns:
1166
+ ~.location_pb2.Location:
1167
+ Location object.
1168
+ """
1169
+ # Create or coerce a protobuf request object.
1170
+ # The request isn't a proto-plus wrapped type,
1171
+ # so it must be constructed via keyword expansion.
1172
+ if isinstance(request, dict):
1173
+ request = locations_pb2.GetLocationRequest(**request)
1174
+
1175
+ # Wrap the RPC method; this adds retry and timeout information,
1176
+ # and friendly error handling.
1177
+ rpc = self.transport._wrapped_methods[self._client._transport.get_location]
1178
+
1179
+ # Certain fields should be provided within the metadata header;
1180
+ # add these here.
1181
+ metadata = tuple(metadata) + (
1182
+ gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
1183
+ )
1184
+
1185
+ # Validate the universe domain.
1186
+ self._client._validate_universe_domain()
1187
+
1188
+ # Send the request.
1189
+ response = await rpc(
1190
+ request,
1191
+ retry=retry,
1192
+ timeout=timeout,
1193
+ metadata=metadata,
1194
+ )
1195
+
1196
+ # Done; return the response.
1197
+ return response
1198
+
1199
+ async def list_locations(
1200
+ self,
1201
+ request: Optional[locations_pb2.ListLocationsRequest] = None,
1202
+ *,
1203
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
1204
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
1205
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
1206
+ ) -> locations_pb2.ListLocationsResponse:
1207
+ r"""Lists information about the supported locations for this service.
1208
+
1209
+ Args:
1210
+ request (:class:`~.location_pb2.ListLocationsRequest`):
1211
+ The request object. Request message for
1212
+ `ListLocations` method.
1213
+ retry (google.api_core.retry_async.AsyncRetry): Designation of what errors,
1214
+ if any, should be retried.
1215
+ timeout (float): The timeout for this request.
1216
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1217
+ sent along with the request as metadata. Normally, each value must be of type `str`,
1218
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
1219
+ be of type `bytes`.
1220
+ Returns:
1221
+ ~.location_pb2.ListLocationsResponse:
1222
+ Response message for ``ListLocations`` method.
1223
+ """
1224
+ # Create or coerce a protobuf request object.
1225
+ # The request isn't a proto-plus wrapped type,
1226
+ # so it must be constructed via keyword expansion.
1227
+ if isinstance(request, dict):
1228
+ request = locations_pb2.ListLocationsRequest(**request)
1229
+
1230
+ # Wrap the RPC method; this adds retry and timeout information,
1231
+ # and friendly error handling.
1232
+ rpc = self.transport._wrapped_methods[self._client._transport.list_locations]
1233
+
1234
+ # Certain fields should be provided within the metadata header;
1235
+ # add these here.
1236
+ metadata = tuple(metadata) + (
1237
+ gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
1238
+ )
1239
+
1240
+ # Validate the universe domain.
1241
+ self._client._validate_universe_domain()
1242
+
1243
+ # Send the request.
1244
+ response = await rpc(
1245
+ request,
1246
+ retry=retry,
1247
+ timeout=timeout,
1248
+ metadata=metadata,
1249
+ )
1250
+
1251
+ # Done; return the response.
1252
+ return response
1253
+
1254
+ async def __aenter__(self) -> "LlmUtilityServiceAsyncClient":
1255
+ return self
1256
+
1257
+ async def __aexit__(self, exc_type, exc, tb):
1258
+ await self.transport.close()
1259
+
1260
+
1261
+ DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
1262
+ gapic_version=package_version.__version__
1263
+ )
1264
+
1265
+ if hasattr(DEFAULT_CLIENT_INFO, "protobuf_runtime_version"): # pragma: NO COVER
1266
+ DEFAULT_CLIENT_INFO.protobuf_runtime_version = google.protobuf.__version__
1267
+
1268
+
1269
+ __all__ = ("LlmUtilityServiceAsyncClient",)
loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/llm_utility_service/client.py ADDED
@@ -0,0 +1,1793 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright 2025 Google LLC
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+ from collections import OrderedDict
17
+ from http import HTTPStatus
18
+ import json
19
+ import logging as std_logging
20
+ import os
21
+ import re
22
+ from typing import (
23
+ Dict,
24
+ Callable,
25
+ Mapping,
26
+ MutableMapping,
27
+ MutableSequence,
28
+ Optional,
29
+ Sequence,
30
+ Tuple,
31
+ Type,
32
+ Union,
33
+ cast,
34
+ )
35
+ import warnings
36
+
37
+ from google.cloud.aiplatform_v1 import gapic_version as package_version
38
+
39
+ from google.api_core import client_options as client_options_lib
40
+ from google.api_core import exceptions as core_exceptions
41
+ from google.api_core import gapic_v1
42
+ from google.api_core import retry as retries
43
+ from google.auth import credentials as ga_credentials # type: ignore
44
+ from google.auth.transport import mtls # type: ignore
45
+ from google.auth.transport.grpc import SslCredentials # type: ignore
46
+ from google.auth.exceptions import MutualTLSChannelError # type: ignore
47
+ from google.oauth2 import service_account # type: ignore
48
+ import google.protobuf
49
+
50
+ try:
51
+ OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault, None]
52
+ except AttributeError: # pragma: NO COVER
53
+ OptionalRetry = Union[retries.Retry, object, None] # type: ignore
54
+
55
+ try:
56
+ from google.api_core import client_logging # type: ignore
57
+
58
+ CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER
59
+ except ImportError: # pragma: NO COVER
60
+ CLIENT_LOGGING_SUPPORTED = False
61
+
62
+ _LOGGER = std_logging.getLogger(__name__)
63
+
64
+ from google.cloud.aiplatform_v1.types import content
65
+ from google.cloud.aiplatform_v1.types import llm_utility_service
66
+ from google.cloud.aiplatform_v1.types import prediction_service
67
+ from google.cloud.location import locations_pb2 # type: ignore
68
+ from google.iam.v1 import iam_policy_pb2 # type: ignore
69
+ from google.iam.v1 import policy_pb2 # type: ignore
70
+ from google.longrunning import operations_pb2 # type: ignore
71
+ import google.protobuf.struct_pb2 as struct_pb2 # type: ignore
72
+ from .transports.base import LlmUtilityServiceTransport, DEFAULT_CLIENT_INFO
73
+ from .transports.grpc import LlmUtilityServiceGrpcTransport
74
+ from .transports.grpc_asyncio import LlmUtilityServiceGrpcAsyncIOTransport
75
+ from .transports.rest import LlmUtilityServiceRestTransport
76
+
77
+ try:
78
+ from .transports.rest_asyncio import AsyncLlmUtilityServiceRestTransport
79
+
80
+ HAS_ASYNC_REST_DEPENDENCIES = True
81
+ except ImportError as e: # pragma: NO COVER
82
+ HAS_ASYNC_REST_DEPENDENCIES = False
83
+ ASYNC_REST_EXCEPTION = e
84
+
85
+
86
+ class LlmUtilityServiceClientMeta(type):
87
+ """Metaclass for the LlmUtilityService client.
88
+
89
+ This provides class-level methods for building and retrieving
90
+ support objects (e.g. transport) without polluting the client instance
91
+ objects.
92
+ """
93
+
94
+ _transport_registry = (
95
+ OrderedDict()
96
+ ) # type: Dict[str, Type[LlmUtilityServiceTransport]]
97
+ _transport_registry["grpc"] = LlmUtilityServiceGrpcTransport
98
+ _transport_registry["grpc_asyncio"] = LlmUtilityServiceGrpcAsyncIOTransport
99
+ _transport_registry["rest"] = LlmUtilityServiceRestTransport
100
+ if HAS_ASYNC_REST_DEPENDENCIES: # pragma: NO COVER
101
+ _transport_registry["rest_asyncio"] = AsyncLlmUtilityServiceRestTransport
102
+
103
+ def get_transport_class(
104
+ cls,
105
+ label: Optional[str] = None,
106
+ ) -> Type[LlmUtilityServiceTransport]:
107
+ """Returns an appropriate transport class.
108
+
109
+ Args:
110
+ label: The name of the desired transport. If none is
111
+ provided, then the first transport in the registry is used.
112
+
113
+ Returns:
114
+ The transport class to use.
115
+ """
116
+ # If a specific transport is requested, return that one.
117
+ if (
118
+ label == "rest_asyncio" and not HAS_ASYNC_REST_DEPENDENCIES
119
+ ): # pragma: NO COVER
120
+ raise ASYNC_REST_EXCEPTION
121
+ if label:
122
+ return cls._transport_registry[label]
123
+
124
+ # No transport is requested; return the default (that is, the first one
125
+ # in the dictionary).
126
+ return next(iter(cls._transport_registry.values()))
127
+
128
+
129
+ class LlmUtilityServiceClient(metaclass=LlmUtilityServiceClientMeta):
130
+ """Service for LLM related utility functions."""
131
+
132
+ @staticmethod
133
+ def _get_default_mtls_endpoint(api_endpoint):
134
+ """Converts api endpoint to mTLS endpoint.
135
+
136
+ Convert "*.sandbox.googleapis.com" and "*.googleapis.com" to
137
+ "*.mtls.sandbox.googleapis.com" and "*.mtls.googleapis.com" respectively.
138
+ Args:
139
+ api_endpoint (Optional[str]): the api endpoint to convert.
140
+ Returns:
141
+ str: converted mTLS api endpoint.
142
+ """
143
+ if not api_endpoint:
144
+ return api_endpoint
145
+
146
+ mtls_endpoint_re = re.compile(
147
+ r"(?P<name>[^.]+)(?P<mtls>\.mtls)?(?P<sandbox>\.sandbox)?(?P<googledomain>\.googleapis\.com)?"
148
+ )
149
+
150
+ m = mtls_endpoint_re.match(api_endpoint)
151
+ name, mtls, sandbox, googledomain = m.groups()
152
+ if mtls or not googledomain:
153
+ return api_endpoint
154
+
155
+ if sandbox:
156
+ return api_endpoint.replace(
157
+ "sandbox.googleapis.com", "mtls.sandbox.googleapis.com"
158
+ )
159
+
160
+ return api_endpoint.replace(".googleapis.com", ".mtls.googleapis.com")
161
+
162
+ # Note: DEFAULT_ENDPOINT is deprecated. Use _DEFAULT_ENDPOINT_TEMPLATE instead.
163
+ DEFAULT_ENDPOINT = "aiplatform.googleapis.com"
164
+ DEFAULT_MTLS_ENDPOINT = _get_default_mtls_endpoint.__func__( # type: ignore
165
+ DEFAULT_ENDPOINT
166
+ )
167
+
168
+ _DEFAULT_ENDPOINT_TEMPLATE = "aiplatform.{UNIVERSE_DOMAIN}"
169
+ _DEFAULT_UNIVERSE = "googleapis.com"
170
+
171
+ @staticmethod
172
+ def _use_client_cert_effective():
173
+ """Returns whether client certificate should be used for mTLS if the
174
+ google-auth version supports should_use_client_cert automatic mTLS enablement.
175
+
176
+ Alternatively, read from the GOOGLE_API_USE_CLIENT_CERTIFICATE env var.
177
+
178
+ Returns:
179
+ bool: whether client certificate should be used for mTLS
180
+ Raises:
181
+ ValueError: (If using a version of google-auth without should_use_client_cert and
182
+ GOOGLE_API_USE_CLIENT_CERTIFICATE is set to an unexpected value.)
183
+ """
184
+ # check if google-auth version supports should_use_client_cert for automatic mTLS enablement
185
+ if hasattr(mtls, "should_use_client_cert"): # pragma: NO COVER
186
+ return mtls.should_use_client_cert()
187
+ else: # pragma: NO COVER
188
+ # if unsupported, fallback to reading from env var
189
+ use_client_cert_str = os.getenv(
190
+ "GOOGLE_API_USE_CLIENT_CERTIFICATE", "false"
191
+ ).lower()
192
+ if use_client_cert_str not in ("true", "false"):
193
+ raise ValueError(
194
+ "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be"
195
+ " either `true` or `false`"
196
+ )
197
+ return use_client_cert_str == "true"
198
+
199
+ @classmethod
200
+ def from_service_account_info(cls, info: dict, *args, **kwargs):
201
+ """Creates an instance of this client using the provided credentials
202
+ info.
203
+
204
+ Args:
205
+ info (dict): The service account private key info.
206
+ args: Additional arguments to pass to the constructor.
207
+ kwargs: Additional arguments to pass to the constructor.
208
+
209
+ Returns:
210
+ LlmUtilityServiceClient: The constructed client.
211
+ """
212
+ credentials = service_account.Credentials.from_service_account_info(info)
213
+ kwargs["credentials"] = credentials
214
+ return cls(*args, **kwargs)
215
+
216
+ @classmethod
217
+ def from_service_account_file(cls, filename: str, *args, **kwargs):
218
+ """Creates an instance of this client using the provided credentials
219
+ file.
220
+
221
+ Args:
222
+ filename (str): The path to the service account private key json
223
+ file.
224
+ args: Additional arguments to pass to the constructor.
225
+ kwargs: Additional arguments to pass to the constructor.
226
+
227
+ Returns:
228
+ LlmUtilityServiceClient: The constructed client.
229
+ """
230
+ credentials = service_account.Credentials.from_service_account_file(filename)
231
+ kwargs["credentials"] = credentials
232
+ return cls(*args, **kwargs)
233
+
234
+ from_service_account_json = from_service_account_file
235
+
236
+ @property
237
+ def transport(self) -> LlmUtilityServiceTransport:
238
+ """Returns the transport used by the client instance.
239
+
240
+ Returns:
241
+ LlmUtilityServiceTransport: The transport used by the client
242
+ instance.
243
+ """
244
+ return self._transport
245
+
246
+ @staticmethod
247
+ def endpoint_path(
248
+ project: str,
249
+ location: str,
250
+ endpoint: str,
251
+ ) -> str:
252
+ """Returns a fully-qualified endpoint string."""
253
+ return "projects/{project}/locations/{location}/endpoints/{endpoint}".format(
254
+ project=project,
255
+ location=location,
256
+ endpoint=endpoint,
257
+ )
258
+
259
+ @staticmethod
260
+ def parse_endpoint_path(path: str) -> Dict[str, str]:
261
+ """Parses a endpoint path into its component segments."""
262
+ m = re.match(
263
+ r"^projects/(?P<project>.+?)/locations/(?P<location>.+?)/endpoints/(?P<endpoint>.+?)$",
264
+ path,
265
+ )
266
+ return m.groupdict() if m else {}
267
+
268
+ @staticmethod
269
+ def rag_corpus_path(
270
+ project: str,
271
+ location: str,
272
+ rag_corpus: str,
273
+ ) -> str:
274
+ """Returns a fully-qualified rag_corpus string."""
275
+ return "projects/{project}/locations/{location}/ragCorpora/{rag_corpus}".format(
276
+ project=project,
277
+ location=location,
278
+ rag_corpus=rag_corpus,
279
+ )
280
+
281
+ @staticmethod
282
+ def parse_rag_corpus_path(path: str) -> Dict[str, str]:
283
+ """Parses a rag_corpus path into its component segments."""
284
+ m = re.match(
285
+ r"^projects/(?P<project>.+?)/locations/(?P<location>.+?)/ragCorpora/(?P<rag_corpus>.+?)$",
286
+ path,
287
+ )
288
+ return m.groupdict() if m else {}
289
+
290
+ @staticmethod
291
+ def common_billing_account_path(
292
+ billing_account: str,
293
+ ) -> str:
294
+ """Returns a fully-qualified billing_account string."""
295
+ return "billingAccounts/{billing_account}".format(
296
+ billing_account=billing_account,
297
+ )
298
+
299
+ @staticmethod
300
+ def parse_common_billing_account_path(path: str) -> Dict[str, str]:
301
+ """Parse a billing_account path into its component segments."""
302
+ m = re.match(r"^billingAccounts/(?P<billing_account>.+?)$", path)
303
+ return m.groupdict() if m else {}
304
+
305
+ @staticmethod
306
+ def common_folder_path(
307
+ folder: str,
308
+ ) -> str:
309
+ """Returns a fully-qualified folder string."""
310
+ return "folders/{folder}".format(
311
+ folder=folder,
312
+ )
313
+
314
+ @staticmethod
315
+ def parse_common_folder_path(path: str) -> Dict[str, str]:
316
+ """Parse a folder path into its component segments."""
317
+ m = re.match(r"^folders/(?P<folder>.+?)$", path)
318
+ return m.groupdict() if m else {}
319
+
320
+ @staticmethod
321
+ def common_organization_path(
322
+ organization: str,
323
+ ) -> str:
324
+ """Returns a fully-qualified organization string."""
325
+ return "organizations/{organization}".format(
326
+ organization=organization,
327
+ )
328
+
329
+ @staticmethod
330
+ def parse_common_organization_path(path: str) -> Dict[str, str]:
331
+ """Parse a organization path into its component segments."""
332
+ m = re.match(r"^organizations/(?P<organization>.+?)$", path)
333
+ return m.groupdict() if m else {}
334
+
335
+ @staticmethod
336
+ def common_project_path(
337
+ project: str,
338
+ ) -> str:
339
+ """Returns a fully-qualified project string."""
340
+ return "projects/{project}".format(
341
+ project=project,
342
+ )
343
+
344
+ @staticmethod
345
+ def parse_common_project_path(path: str) -> Dict[str, str]:
346
+ """Parse a project path into its component segments."""
347
+ m = re.match(r"^projects/(?P<project>.+?)$", path)
348
+ return m.groupdict() if m else {}
349
+
350
+ @staticmethod
351
+ def common_location_path(
352
+ project: str,
353
+ location: str,
354
+ ) -> str:
355
+ """Returns a fully-qualified location string."""
356
+ return "projects/{project}/locations/{location}".format(
357
+ project=project,
358
+ location=location,
359
+ )
360
+
361
+ @staticmethod
362
+ def parse_common_location_path(path: str) -> Dict[str, str]:
363
+ """Parse a location path into its component segments."""
364
+ m = re.match(r"^projects/(?P<project>.+?)/locations/(?P<location>.+?)$", path)
365
+ return m.groupdict() if m else {}
366
+
367
+ @classmethod
368
+ def get_mtls_endpoint_and_cert_source(
369
+ cls, client_options: Optional[client_options_lib.ClientOptions] = None
370
+ ):
371
+ """Deprecated. Return the API endpoint and client cert source for mutual TLS.
372
+
373
+ The client cert source is determined in the following order:
374
+ (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the
375
+ client cert source is None.
376
+ (2) if `client_options.client_cert_source` is provided, use the provided one; if the
377
+ default client cert source exists, use the default one; otherwise the client cert
378
+ source is None.
379
+
380
+ The API endpoint is determined in the following order:
381
+ (1) if `client_options.api_endpoint` if provided, use the provided one.
382
+ (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the
383
+ default mTLS endpoint; if the environment variable is "never", use the default API
384
+ endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise
385
+ use the default API endpoint.
386
+
387
+ More details can be found at https://google.aip.dev/auth/4114.
388
+
389
+ Args:
390
+ client_options (google.api_core.client_options.ClientOptions): Custom options for the
391
+ client. Only the `api_endpoint` and `client_cert_source` properties may be used
392
+ in this method.
393
+
394
+ Returns:
395
+ Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the
396
+ client cert source to use.
397
+
398
+ Raises:
399
+ google.auth.exceptions.MutualTLSChannelError: If any errors happen.
400
+ """
401
+
402
+ warnings.warn(
403
+ "get_mtls_endpoint_and_cert_source is deprecated. Use the api_endpoint property instead.",
404
+ DeprecationWarning,
405
+ )
406
+ if client_options is None:
407
+ client_options = client_options_lib.ClientOptions()
408
+ use_client_cert = LlmUtilityServiceClient._use_client_cert_effective()
409
+ use_mtls_endpoint = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto")
410
+ if use_mtls_endpoint not in ("auto", "never", "always"):
411
+ raise MutualTLSChannelError(
412
+ "Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`"
413
+ )
414
+
415
+ # Figure out the client cert source to use.
416
+ client_cert_source = None
417
+ if use_client_cert:
418
+ if client_options.client_cert_source:
419
+ client_cert_source = client_options.client_cert_source
420
+ elif mtls.has_default_client_cert_source():
421
+ client_cert_source = mtls.default_client_cert_source()
422
+
423
+ # Figure out which api endpoint to use.
424
+ if client_options.api_endpoint is not None:
425
+ api_endpoint = client_options.api_endpoint
426
+ elif use_mtls_endpoint == "always" or (
427
+ use_mtls_endpoint == "auto" and client_cert_source
428
+ ):
429
+ api_endpoint = cls.DEFAULT_MTLS_ENDPOINT
430
+ else:
431
+ api_endpoint = cls.DEFAULT_ENDPOINT
432
+
433
+ return api_endpoint, client_cert_source
434
+
435
+ @staticmethod
436
+ def _read_environment_variables():
437
+ """Returns the environment variables used by the client.
438
+
439
+ Returns:
440
+ Tuple[bool, str, str]: returns the GOOGLE_API_USE_CLIENT_CERTIFICATE,
441
+ GOOGLE_API_USE_MTLS_ENDPOINT, and GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variables.
442
+
443
+ Raises:
444
+ ValueError: If GOOGLE_API_USE_CLIENT_CERTIFICATE is not
445
+ any of ["true", "false"].
446
+ google.auth.exceptions.MutualTLSChannelError: If GOOGLE_API_USE_MTLS_ENDPOINT
447
+ is not any of ["auto", "never", "always"].
448
+ """
449
+ use_client_cert = LlmUtilityServiceClient._use_client_cert_effective()
450
+ use_mtls_endpoint = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto").lower()
451
+ universe_domain_env = os.getenv("GOOGLE_CLOUD_UNIVERSE_DOMAIN")
452
+ if use_mtls_endpoint not in ("auto", "never", "always"):
453
+ raise MutualTLSChannelError(
454
+ "Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`"
455
+ )
456
+ return use_client_cert, use_mtls_endpoint, universe_domain_env
457
+
458
+ @staticmethod
459
+ def _get_client_cert_source(provided_cert_source, use_cert_flag):
460
+ """Return the client cert source to be used by the client.
461
+
462
+ Args:
463
+ provided_cert_source (bytes): The client certificate source provided.
464
+ use_cert_flag (bool): A flag indicating whether to use the client certificate.
465
+
466
+ Returns:
467
+ bytes or None: The client cert source to be used by the client.
468
+ """
469
+ client_cert_source = None
470
+ if use_cert_flag:
471
+ if provided_cert_source:
472
+ client_cert_source = provided_cert_source
473
+ elif mtls.has_default_client_cert_source():
474
+ client_cert_source = mtls.default_client_cert_source()
475
+ return client_cert_source
476
+
477
+ @staticmethod
478
+ def _get_api_endpoint(
479
+ api_override, client_cert_source, universe_domain, use_mtls_endpoint
480
+ ):
481
+ """Return the API endpoint used by the client.
482
+
483
+ Args:
484
+ api_override (str): The API endpoint override. If specified, this is always
485
+ the return value of this function and the other arguments are not used.
486
+ client_cert_source (bytes): The client certificate source used by the client.
487
+ universe_domain (str): The universe domain used by the client.
488
+ use_mtls_endpoint (str): How to use the mTLS endpoint, which depends also on the other parameters.
489
+ Possible values are "always", "auto", or "never".
490
+
491
+ Returns:
492
+ str: The API endpoint to be used by the client.
493
+ """
494
+ if api_override is not None:
495
+ api_endpoint = api_override
496
+ elif use_mtls_endpoint == "always" or (
497
+ use_mtls_endpoint == "auto" and client_cert_source
498
+ ):
499
+ _default_universe = LlmUtilityServiceClient._DEFAULT_UNIVERSE
500
+ if universe_domain != _default_universe:
501
+ raise MutualTLSChannelError(
502
+ f"mTLS is not supported in any universe other than {_default_universe}."
503
+ )
504
+ api_endpoint = LlmUtilityServiceClient.DEFAULT_MTLS_ENDPOINT
505
+ else:
506
+ api_endpoint = LlmUtilityServiceClient._DEFAULT_ENDPOINT_TEMPLATE.format(
507
+ UNIVERSE_DOMAIN=universe_domain
508
+ )
509
+ return api_endpoint
510
+
511
+ @staticmethod
512
+ def _get_universe_domain(
513
+ client_universe_domain: Optional[str], universe_domain_env: Optional[str]
514
+ ) -> str:
515
+ """Return the universe domain used by the client.
516
+
517
+ Args:
518
+ client_universe_domain (Optional[str]): The universe domain configured via the client options.
519
+ universe_domain_env (Optional[str]): The universe domain configured via the "GOOGLE_CLOUD_UNIVERSE_DOMAIN" environment variable.
520
+
521
+ Returns:
522
+ str: The universe domain to be used by the client.
523
+
524
+ Raises:
525
+ ValueError: If the universe domain is an empty string.
526
+ """
527
+ universe_domain = LlmUtilityServiceClient._DEFAULT_UNIVERSE
528
+ if client_universe_domain is not None:
529
+ universe_domain = client_universe_domain
530
+ elif universe_domain_env is not None:
531
+ universe_domain = universe_domain_env
532
+ if len(universe_domain.strip()) == 0:
533
+ raise ValueError("Universe Domain cannot be an empty string.")
534
+ return universe_domain
535
+
536
+ def _validate_universe_domain(self):
537
+ """Validates client's and credentials' universe domains are consistent.
538
+
539
+ Returns:
540
+ bool: True iff the configured universe domain is valid.
541
+
542
+ Raises:
543
+ ValueError: If the configured universe domain is not valid.
544
+ """
545
+
546
+ # NOTE (b/349488459): universe validation is disabled until further notice.
547
+ return True
548
+
549
+ def _add_cred_info_for_auth_errors(
550
+ self, error: core_exceptions.GoogleAPICallError
551
+ ) -> None:
552
+ """Adds credential info string to error details for 401/403/404 errors.
553
+
554
+ Args:
555
+ error (google.api_core.exceptions.GoogleAPICallError): The error to add the cred info.
556
+ """
557
+ if error.code not in [
558
+ HTTPStatus.UNAUTHORIZED,
559
+ HTTPStatus.FORBIDDEN,
560
+ HTTPStatus.NOT_FOUND,
561
+ ]:
562
+ return
563
+
564
+ cred = self._transport._credentials
565
+
566
+ # get_cred_info is only available in google-auth>=2.35.0
567
+ if not hasattr(cred, "get_cred_info"):
568
+ return
569
+
570
+ # ignore the type check since pypy test fails when get_cred_info
571
+ # is not available
572
+ cred_info = cred.get_cred_info() # type: ignore
573
+ if cred_info and hasattr(error._details, "append"):
574
+ error._details.append(json.dumps(cred_info))
575
+
576
+ @property
577
+ def api_endpoint(self):
578
+ """Return the API endpoint used by the client instance.
579
+
580
+ Returns:
581
+ str: The API endpoint used by the client instance.
582
+ """
583
+ return self._api_endpoint
584
+
585
+ @property
586
+ def universe_domain(self) -> str:
587
+ """Return the universe domain used by the client instance.
588
+
589
+ Returns:
590
+ str: The universe domain used by the client instance.
591
+ """
592
+ return self._universe_domain
593
+
594
+ def __init__(
595
+ self,
596
+ *,
597
+ credentials: Optional[ga_credentials.Credentials] = None,
598
+ transport: Optional[
599
+ Union[
600
+ str,
601
+ LlmUtilityServiceTransport,
602
+ Callable[..., LlmUtilityServiceTransport],
603
+ ]
604
+ ] = None,
605
+ client_options: Optional[Union[client_options_lib.ClientOptions, dict]] = None,
606
+ client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
607
+ ) -> None:
608
+ """Instantiates the llm utility service client.
609
+
610
+ Args:
611
+ credentials (Optional[google.auth.credentials.Credentials]): The
612
+ authorization credentials to attach to requests. These
613
+ credentials identify the application to the service; if none
614
+ are specified, the client will attempt to ascertain the
615
+ credentials from the environment.
616
+ transport (Optional[Union[str,LlmUtilityServiceTransport,Callable[..., LlmUtilityServiceTransport]]]):
617
+ The transport to use, or a Callable that constructs and returns a new transport.
618
+ If a Callable is given, it will be called with the same set of initialization
619
+ arguments as used in the LlmUtilityServiceTransport constructor.
620
+ If set to None, a transport is chosen automatically.
621
+ client_options (Optional[Union[google.api_core.client_options.ClientOptions, dict]]):
622
+ Custom options for the client.
623
+
624
+ 1. The ``api_endpoint`` property can be used to override the
625
+ default endpoint provided by the client when ``transport`` is
626
+ not explicitly provided. Only if this property is not set and
627
+ ``transport`` was not explicitly provided, the endpoint is
628
+ determined by the GOOGLE_API_USE_MTLS_ENDPOINT environment
629
+ variable, which have one of the following values:
630
+ "always" (always use the default mTLS endpoint), "never" (always
631
+ use the default regular endpoint) and "auto" (auto-switch to the
632
+ default mTLS endpoint if client certificate is present; this is
633
+ the default value).
634
+
635
+ 2. If the GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable
636
+ is "true", then the ``client_cert_source`` property can be used
637
+ to provide a client certificate for mTLS transport. If
638
+ not provided, the default SSL client certificate will be used if
639
+ present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is "false" or not
640
+ set, no client certificate will be used.
641
+
642
+ 3. The ``universe_domain`` property can be used to override the
643
+ default "googleapis.com" universe. Note that the ``api_endpoint``
644
+ property still takes precedence; and ``universe_domain`` is
645
+ currently not supported for mTLS.
646
+
647
+ client_info (google.api_core.gapic_v1.client_info.ClientInfo):
648
+ The client info used to send a user-agent string along with
649
+ API requests. If ``None``, then default info will be used.
650
+ Generally, you only need to set this if you're developing
651
+ your own client library.
652
+
653
+ Raises:
654
+ google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport
655
+ creation failed for any reason.
656
+ """
657
+ self._client_options = client_options
658
+ if isinstance(self._client_options, dict):
659
+ self._client_options = client_options_lib.from_dict(self._client_options)
660
+ if self._client_options is None:
661
+ self._client_options = client_options_lib.ClientOptions()
662
+ self._client_options = cast(
663
+ client_options_lib.ClientOptions, self._client_options
664
+ )
665
+
666
+ universe_domain_opt = getattr(self._client_options, "universe_domain", None)
667
+
668
+ self._use_client_cert, self._use_mtls_endpoint, self._universe_domain_env = (
669
+ LlmUtilityServiceClient._read_environment_variables()
670
+ )
671
+ self._client_cert_source = LlmUtilityServiceClient._get_client_cert_source(
672
+ self._client_options.client_cert_source, self._use_client_cert
673
+ )
674
+ self._universe_domain = LlmUtilityServiceClient._get_universe_domain(
675
+ universe_domain_opt, self._universe_domain_env
676
+ )
677
+ self._api_endpoint = None # updated below, depending on `transport`
678
+
679
+ # Initialize the universe domain validation.
680
+ self._is_universe_domain_valid = False
681
+
682
+ if CLIENT_LOGGING_SUPPORTED: # pragma: NO COVER
683
+ # Setup logging.
684
+ client_logging.initialize_logging()
685
+
686
+ api_key_value = getattr(self._client_options, "api_key", None)
687
+ if api_key_value and credentials:
688
+ raise ValueError(
689
+ "client_options.api_key and credentials are mutually exclusive"
690
+ )
691
+
692
+ # Save or instantiate the transport.
693
+ # Ordinarily, we provide the transport, but allowing a custom transport
694
+ # instance provides an extensibility point for unusual situations.
695
+ transport_provided = isinstance(transport, LlmUtilityServiceTransport)
696
+ if transport_provided:
697
+ # transport is a LlmUtilityServiceTransport instance.
698
+ if credentials or self._client_options.credentials_file or api_key_value:
699
+ raise ValueError(
700
+ "When providing a transport instance, "
701
+ "provide its credentials directly."
702
+ )
703
+ if self._client_options.scopes:
704
+ raise ValueError(
705
+ "When providing a transport instance, provide its scopes "
706
+ "directly."
707
+ )
708
+ self._transport = cast(LlmUtilityServiceTransport, transport)
709
+ self._api_endpoint = self._transport.host
710
+
711
+ self._api_endpoint = (
712
+ self._api_endpoint
713
+ or LlmUtilityServiceClient._get_api_endpoint(
714
+ self._client_options.api_endpoint,
715
+ self._client_cert_source,
716
+ self._universe_domain,
717
+ self._use_mtls_endpoint,
718
+ )
719
+ )
720
+
721
+ if not transport_provided:
722
+ transport_init: Union[
723
+ Type[LlmUtilityServiceTransport],
724
+ Callable[..., LlmUtilityServiceTransport],
725
+ ] = (
726
+ LlmUtilityServiceClient.get_transport_class(transport)
727
+ if isinstance(transport, str) or transport is None
728
+ else cast(Callable[..., LlmUtilityServiceTransport], transport)
729
+ )
730
+
731
+ if "rest_asyncio" in str(transport_init):
732
+ unsupported_params = {
733
+ "google.api_core.client_options.ClientOptions.credentials_file": self._client_options.credentials_file,
734
+ "google.api_core.client_options.ClientOptions.scopes": self._client_options.scopes,
735
+ "google.api_core.client_options.ClientOptions.quota_project_id": self._client_options.quota_project_id,
736
+ "google.api_core.client_options.ClientOptions.client_cert_source": self._client_options.client_cert_source,
737
+ "google.api_core.client_options.ClientOptions.api_audience": self._client_options.api_audience,
738
+ }
739
+ provided_unsupported_params = [
740
+ name
741
+ for name, value in unsupported_params.items()
742
+ if value is not None
743
+ ]
744
+ if provided_unsupported_params:
745
+ raise core_exceptions.AsyncRestUnsupportedParameterError( # type: ignore
746
+ f"The following provided parameters are not supported for `transport=rest_asyncio`: {', '.join(provided_unsupported_params)}"
747
+ )
748
+ self._transport = transport_init(
749
+ credentials=credentials,
750
+ host=self._api_endpoint,
751
+ client_info=client_info,
752
+ )
753
+ return
754
+
755
+ import google.auth._default # type: ignore
756
+
757
+ if api_key_value and hasattr(
758
+ google.auth._default, "get_api_key_credentials"
759
+ ):
760
+ credentials = google.auth._default.get_api_key_credentials(
761
+ api_key_value
762
+ )
763
+
764
+ # initialize with the provided callable or the passed in class
765
+ self._transport = transport_init(
766
+ credentials=credentials,
767
+ credentials_file=self._client_options.credentials_file,
768
+ host=self._api_endpoint,
769
+ scopes=self._client_options.scopes,
770
+ client_cert_source_for_mtls=self._client_cert_source,
771
+ quota_project_id=self._client_options.quota_project_id,
772
+ client_info=client_info,
773
+ always_use_jwt_access=True,
774
+ api_audience=self._client_options.api_audience,
775
+ )
776
+
777
+ if "async" not in str(self._transport):
778
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
779
+ std_logging.DEBUG
780
+ ): # pragma: NO COVER
781
+ _LOGGER.debug(
782
+ "Created client `google.cloud.aiplatform_v1.LlmUtilityServiceClient`.",
783
+ extra=(
784
+ {
785
+ "serviceName": "google.cloud.aiplatform.v1.LlmUtilityService",
786
+ "universeDomain": getattr(
787
+ self._transport._credentials, "universe_domain", ""
788
+ ),
789
+ "credentialsType": f"{type(self._transport._credentials).__module__}.{type(self._transport._credentials).__qualname__}",
790
+ "credentialsInfo": getattr(
791
+ self.transport._credentials,
792
+ "get_cred_info",
793
+ lambda: None,
794
+ )(),
795
+ }
796
+ if hasattr(self._transport, "_credentials")
797
+ else {
798
+ "serviceName": "google.cloud.aiplatform.v1.LlmUtilityService",
799
+ "credentialsType": None,
800
+ }
801
+ ),
802
+ )
803
+
804
+ def count_tokens(
805
+ self,
806
+ request: Optional[Union[prediction_service.CountTokensRequest, dict]] = None,
807
+ *,
808
+ endpoint: Optional[str] = None,
809
+ instances: Optional[MutableSequence[struct_pb2.Value]] = None,
810
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
811
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
812
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
813
+ ) -> prediction_service.CountTokensResponse:
814
+ r"""Perform a token counting.
815
+
816
+ .. code-block:: python
817
+
818
+ # This snippet has been automatically generated and should be regarded as a
819
+ # code template only.
820
+ # It will require modifications to work:
821
+ # - It may require correct/in-range values for request initialization.
822
+ # - It may require specifying regional endpoints when creating the service
823
+ # client as shown in:
824
+ # https://googleapis.dev/python/google-api-core/latest/client_options.html
825
+ from google.cloud import aiplatform_v1
826
+
827
+ def sample_count_tokens():
828
+ # Create a client
829
+ client = aiplatform_v1.LlmUtilityServiceClient()
830
+
831
+ # Initialize request argument(s)
832
+ request = aiplatform_v1.CountTokensRequest(
833
+ endpoint="endpoint_value",
834
+ )
835
+
836
+ # Make the request
837
+ response = client.count_tokens(request=request)
838
+
839
+ # Handle the response
840
+ print(response)
841
+
842
+ Args:
843
+ request (Union[google.cloud.aiplatform_v1.types.CountTokensRequest, dict]):
844
+ The request object. Request message for [PredictionService.CountTokens][].
845
+ endpoint (str):
846
+ Required. The name of the Endpoint requested to perform
847
+ token counting. Format:
848
+ ``projects/{project}/locations/{location}/endpoints/{endpoint}``
849
+
850
+ This corresponds to the ``endpoint`` field
851
+ on the ``request`` instance; if ``request`` is provided, this
852
+ should not be set.
853
+ instances (MutableSequence[google.protobuf.struct_pb2.Value]):
854
+ Optional. The instances that are the
855
+ input to token counting call. Schema is
856
+ identical to the prediction schema of
857
+ the underlying model.
858
+
859
+ This corresponds to the ``instances`` field
860
+ on the ``request`` instance; if ``request`` is provided, this
861
+ should not be set.
862
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
863
+ should be retried.
864
+ timeout (float): The timeout for this request.
865
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
866
+ sent along with the request as metadata. Normally, each value must be of type `str`,
867
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
868
+ be of type `bytes`.
869
+
870
+ Returns:
871
+ google.cloud.aiplatform_v1.types.CountTokensResponse:
872
+ Response message for [PredictionService.CountTokens][].
873
+ """
874
+ # Create or coerce a protobuf request object.
875
+ # - Quick check: If we got a request object, we should *not* have
876
+ # gotten any keyword arguments that map to the request.
877
+ flattened_params = [endpoint, instances]
878
+ has_flattened_params = (
879
+ len([param for param in flattened_params if param is not None]) > 0
880
+ )
881
+ if request is not None and has_flattened_params:
882
+ raise ValueError(
883
+ "If the `request` argument is set, then none of "
884
+ "the individual field arguments should be set."
885
+ )
886
+
887
+ # - Use the request object if provided (there's no risk of modifying the input as
888
+ # there are no flattened fields), or create one.
889
+ if not isinstance(request, prediction_service.CountTokensRequest):
890
+ request = prediction_service.CountTokensRequest(request)
891
+ # If we have keyword arguments corresponding to fields on the
892
+ # request, apply these.
893
+ if endpoint is not None:
894
+ request.endpoint = endpoint
895
+ if instances is not None:
896
+ request.instances.extend(instances)
897
+
898
+ # Wrap the RPC method; this adds retry and timeout information,
899
+ # and friendly error handling.
900
+ rpc = self._transport._wrapped_methods[self._transport.count_tokens]
901
+
902
+ # Certain fields should be provided within the metadata header;
903
+ # add these here.
904
+ metadata = tuple(metadata) + (
905
+ gapic_v1.routing_header.to_grpc_metadata((("endpoint", request.endpoint),)),
906
+ )
907
+
908
+ # Validate the universe domain.
909
+ self._validate_universe_domain()
910
+
911
+ # Send the request.
912
+ response = rpc(
913
+ request,
914
+ retry=retry,
915
+ timeout=timeout,
916
+ metadata=metadata,
917
+ )
918
+
919
+ # Done; return the response.
920
+ return response
921
+
922
+ def compute_tokens(
923
+ self,
924
+ request: Optional[Union[llm_utility_service.ComputeTokensRequest, dict]] = None,
925
+ *,
926
+ endpoint: Optional[str] = None,
927
+ instances: Optional[MutableSequence[struct_pb2.Value]] = None,
928
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
929
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
930
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
931
+ ) -> llm_utility_service.ComputeTokensResponse:
932
+ r"""Return a list of tokens based on the input text.
933
+
934
+ .. code-block:: python
935
+
936
+ # This snippet has been automatically generated and should be regarded as a
937
+ # code template only.
938
+ # It will require modifications to work:
939
+ # - It may require correct/in-range values for request initialization.
940
+ # - It may require specifying regional endpoints when creating the service
941
+ # client as shown in:
942
+ # https://googleapis.dev/python/google-api-core/latest/client_options.html
943
+ from google.cloud import aiplatform_v1
944
+
945
+ def sample_compute_tokens():
946
+ # Create a client
947
+ client = aiplatform_v1.LlmUtilityServiceClient()
948
+
949
+ # Initialize request argument(s)
950
+ request = aiplatform_v1.ComputeTokensRequest(
951
+ endpoint="endpoint_value",
952
+ )
953
+
954
+ # Make the request
955
+ response = client.compute_tokens(request=request)
956
+
957
+ # Handle the response
958
+ print(response)
959
+
960
+ Args:
961
+ request (Union[google.cloud.aiplatform_v1.types.ComputeTokensRequest, dict]):
962
+ The request object. Request message for ComputeTokens RPC
963
+ call.
964
+ endpoint (str):
965
+ Required. The name of the Endpoint
966
+ requested to get lists of tokens and
967
+ token ids.
968
+
969
+ This corresponds to the ``endpoint`` field
970
+ on the ``request`` instance; if ``request`` is provided, this
971
+ should not be set.
972
+ instances (MutableSequence[google.protobuf.struct_pb2.Value]):
973
+ Optional. The instances that are the
974
+ input to token computing API call.
975
+ Schema is identical to the prediction
976
+ schema of the text model, even for the
977
+ non-text models, like chat models, or
978
+ Codey models.
979
+
980
+ This corresponds to the ``instances`` field
981
+ on the ``request`` instance; if ``request`` is provided, this
982
+ should not be set.
983
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
984
+ should be retried.
985
+ timeout (float): The timeout for this request.
986
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
987
+ sent along with the request as metadata. Normally, each value must be of type `str`,
988
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
989
+ be of type `bytes`.
990
+
991
+ Returns:
992
+ google.cloud.aiplatform_v1.types.ComputeTokensResponse:
993
+ Response message for ComputeTokens
994
+ RPC call.
995
+
996
+ """
997
+ # Create or coerce a protobuf request object.
998
+ # - Quick check: If we got a request object, we should *not* have
999
+ # gotten any keyword arguments that map to the request.
1000
+ flattened_params = [endpoint, instances]
1001
+ has_flattened_params = (
1002
+ len([param for param in flattened_params if param is not None]) > 0
1003
+ )
1004
+ if request is not None and has_flattened_params:
1005
+ raise ValueError(
1006
+ "If the `request` argument is set, then none of "
1007
+ "the individual field arguments should be set."
1008
+ )
1009
+
1010
+ # - Use the request object if provided (there's no risk of modifying the input as
1011
+ # there are no flattened fields), or create one.
1012
+ if not isinstance(request, llm_utility_service.ComputeTokensRequest):
1013
+ request = llm_utility_service.ComputeTokensRequest(request)
1014
+ # If we have keyword arguments corresponding to fields on the
1015
+ # request, apply these.
1016
+ if endpoint is not None:
1017
+ request.endpoint = endpoint
1018
+ if instances is not None:
1019
+ request.instances.extend(instances)
1020
+
1021
+ # Wrap the RPC method; this adds retry and timeout information,
1022
+ # and friendly error handling.
1023
+ rpc = self._transport._wrapped_methods[self._transport.compute_tokens]
1024
+
1025
+ # Certain fields should be provided within the metadata header;
1026
+ # add these here.
1027
+ metadata = tuple(metadata) + (
1028
+ gapic_v1.routing_header.to_grpc_metadata((("endpoint", request.endpoint),)),
1029
+ )
1030
+
1031
+ # Validate the universe domain.
1032
+ self._validate_universe_domain()
1033
+
1034
+ # Send the request.
1035
+ response = rpc(
1036
+ request,
1037
+ retry=retry,
1038
+ timeout=timeout,
1039
+ metadata=metadata,
1040
+ )
1041
+
1042
+ # Done; return the response.
1043
+ return response
1044
+
1045
+ def __enter__(self) -> "LlmUtilityServiceClient":
1046
+ return self
1047
+
1048
+ def __exit__(self, type, value, traceback):
1049
+ """Releases underlying transport's resources.
1050
+
1051
+ .. warning::
1052
+ ONLY use as a context manager if the transport is NOT shared
1053
+ with other clients! Exiting the with block will CLOSE the transport
1054
+ and may cause errors in other clients!
1055
+ """
1056
+ self.transport.close()
1057
+
1058
+ def list_operations(
1059
+ self,
1060
+ request: Optional[operations_pb2.ListOperationsRequest] = None,
1061
+ *,
1062
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
1063
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
1064
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
1065
+ ) -> operations_pb2.ListOperationsResponse:
1066
+ r"""Lists operations that match the specified filter in the request.
1067
+
1068
+ Args:
1069
+ request (:class:`~.operations_pb2.ListOperationsRequest`):
1070
+ The request object. Request message for
1071
+ `ListOperations` method.
1072
+ retry (google.api_core.retry.Retry): Designation of what errors,
1073
+ if any, should be retried.
1074
+ timeout (float): The timeout for this request.
1075
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1076
+ sent along with the request as metadata. Normally, each value must be of type `str`,
1077
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
1078
+ be of type `bytes`.
1079
+ Returns:
1080
+ ~.operations_pb2.ListOperationsResponse:
1081
+ Response message for ``ListOperations`` method.
1082
+ """
1083
+ # Create or coerce a protobuf request object.
1084
+ # The request isn't a proto-plus wrapped type,
1085
+ # so it must be constructed via keyword expansion.
1086
+ if isinstance(request, dict):
1087
+ request = operations_pb2.ListOperationsRequest(**request)
1088
+
1089
+ # Wrap the RPC method; this adds retry and timeout information,
1090
+ # and friendly error handling.
1091
+ rpc = self._transport._wrapped_methods[self._transport.list_operations]
1092
+
1093
+ # Certain fields should be provided within the metadata header;
1094
+ # add these here.
1095
+ metadata = tuple(metadata) + (
1096
+ gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
1097
+ )
1098
+
1099
+ # Validate the universe domain.
1100
+ self._validate_universe_domain()
1101
+
1102
+ try:
1103
+ # Send the request.
1104
+ response = rpc(
1105
+ request,
1106
+ retry=retry,
1107
+ timeout=timeout,
1108
+ metadata=metadata,
1109
+ )
1110
+
1111
+ # Done; return the response.
1112
+ return response
1113
+ except core_exceptions.GoogleAPICallError as e:
1114
+ self._add_cred_info_for_auth_errors(e)
1115
+ raise e
1116
+
1117
+ def get_operation(
1118
+ self,
1119
+ request: Optional[operations_pb2.GetOperationRequest] = None,
1120
+ *,
1121
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
1122
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
1123
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
1124
+ ) -> operations_pb2.Operation:
1125
+ r"""Gets the latest state of a long-running operation.
1126
+
1127
+ Args:
1128
+ request (:class:`~.operations_pb2.GetOperationRequest`):
1129
+ The request object. Request message for
1130
+ `GetOperation` method.
1131
+ retry (google.api_core.retry.Retry): Designation of what errors,
1132
+ if any, should be retried.
1133
+ timeout (float): The timeout for this request.
1134
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1135
+ sent along with the request as metadata. Normally, each value must be of type `str`,
1136
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
1137
+ be of type `bytes`.
1138
+ Returns:
1139
+ ~.operations_pb2.Operation:
1140
+ An ``Operation`` object.
1141
+ """
1142
+ # Create or coerce a protobuf request object.
1143
+ # The request isn't a proto-plus wrapped type,
1144
+ # so it must be constructed via keyword expansion.
1145
+ if isinstance(request, dict):
1146
+ request = operations_pb2.GetOperationRequest(**request)
1147
+
1148
+ # Wrap the RPC method; this adds retry and timeout information,
1149
+ # and friendly error handling.
1150
+ rpc = self._transport._wrapped_methods[self._transport.get_operation]
1151
+
1152
+ # Certain fields should be provided within the metadata header;
1153
+ # add these here.
1154
+ metadata = tuple(metadata) + (
1155
+ gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
1156
+ )
1157
+
1158
+ # Validate the universe domain.
1159
+ self._validate_universe_domain()
1160
+
1161
+ try:
1162
+ # Send the request.
1163
+ response = rpc(
1164
+ request,
1165
+ retry=retry,
1166
+ timeout=timeout,
1167
+ metadata=metadata,
1168
+ )
1169
+
1170
+ # Done; return the response.
1171
+ return response
1172
+ except core_exceptions.GoogleAPICallError as e:
1173
+ self._add_cred_info_for_auth_errors(e)
1174
+ raise e
1175
+
1176
+ def delete_operation(
1177
+ self,
1178
+ request: Optional[operations_pb2.DeleteOperationRequest] = None,
1179
+ *,
1180
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
1181
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
1182
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
1183
+ ) -> None:
1184
+ r"""Deletes a long-running operation.
1185
+
1186
+ This method indicates that the client is no longer interested
1187
+ in the operation result. It does not cancel the operation.
1188
+ If the server doesn't support this method, it returns
1189
+ `google.rpc.Code.UNIMPLEMENTED`.
1190
+
1191
+ Args:
1192
+ request (:class:`~.operations_pb2.DeleteOperationRequest`):
1193
+ The request object. Request message for
1194
+ `DeleteOperation` method.
1195
+ retry (google.api_core.retry.Retry): Designation of what errors,
1196
+ if any, should be retried.
1197
+ timeout (float): The timeout for this request.
1198
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1199
+ sent along with the request as metadata. Normally, each value must be of type `str`,
1200
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
1201
+ be of type `bytes`.
1202
+ Returns:
1203
+ None
1204
+ """
1205
+ # Create or coerce a protobuf request object.
1206
+ # The request isn't a proto-plus wrapped type,
1207
+ # so it must be constructed via keyword expansion.
1208
+ if isinstance(request, dict):
1209
+ request = operations_pb2.DeleteOperationRequest(**request)
1210
+
1211
+ # Wrap the RPC method; this adds retry and timeout information,
1212
+ # and friendly error handling.
1213
+ rpc = self._transport._wrapped_methods[self._transport.delete_operation]
1214
+
1215
+ # Certain fields should be provided within the metadata header;
1216
+ # add these here.
1217
+ metadata = tuple(metadata) + (
1218
+ gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
1219
+ )
1220
+
1221
+ # Validate the universe domain.
1222
+ self._validate_universe_domain()
1223
+
1224
+ # Send the request.
1225
+ rpc(
1226
+ request,
1227
+ retry=retry,
1228
+ timeout=timeout,
1229
+ metadata=metadata,
1230
+ )
1231
+
1232
+ def cancel_operation(
1233
+ self,
1234
+ request: Optional[operations_pb2.CancelOperationRequest] = None,
1235
+ *,
1236
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
1237
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
1238
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
1239
+ ) -> None:
1240
+ r"""Starts asynchronous cancellation on a long-running operation.
1241
+
1242
+ The server makes a best effort to cancel the operation, but success
1243
+ is not guaranteed. If the server doesn't support this method, it returns
1244
+ `google.rpc.Code.UNIMPLEMENTED`.
1245
+
1246
+ Args:
1247
+ request (:class:`~.operations_pb2.CancelOperationRequest`):
1248
+ The request object. Request message for
1249
+ `CancelOperation` method.
1250
+ retry (google.api_core.retry.Retry): Designation of what errors,
1251
+ if any, should be retried.
1252
+ timeout (float): The timeout for this request.
1253
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1254
+ sent along with the request as metadata. Normally, each value must be of type `str`,
1255
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
1256
+ be of type `bytes`.
1257
+ Returns:
1258
+ None
1259
+ """
1260
+ # Create or coerce a protobuf request object.
1261
+ # The request isn't a proto-plus wrapped type,
1262
+ # so it must be constructed via keyword expansion.
1263
+ if isinstance(request, dict):
1264
+ request = operations_pb2.CancelOperationRequest(**request)
1265
+
1266
+ # Wrap the RPC method; this adds retry and timeout information,
1267
+ # and friendly error handling.
1268
+ rpc = self._transport._wrapped_methods[self._transport.cancel_operation]
1269
+
1270
+ # Certain fields should be provided within the metadata header;
1271
+ # add these here.
1272
+ metadata = tuple(metadata) + (
1273
+ gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
1274
+ )
1275
+
1276
+ # Validate the universe domain.
1277
+ self._validate_universe_domain()
1278
+
1279
+ # Send the request.
1280
+ rpc(
1281
+ request,
1282
+ retry=retry,
1283
+ timeout=timeout,
1284
+ metadata=metadata,
1285
+ )
1286
+
1287
+ def wait_operation(
1288
+ self,
1289
+ request: Optional[operations_pb2.WaitOperationRequest] = None,
1290
+ *,
1291
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
1292
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
1293
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
1294
+ ) -> operations_pb2.Operation:
1295
+ r"""Waits until the specified long-running operation is done or reaches at most
1296
+ a specified timeout, returning the latest state.
1297
+
1298
+ If the operation is already done, the latest state is immediately returned.
1299
+ If the timeout specified is greater than the default HTTP/RPC timeout, the HTTP/RPC
1300
+ timeout is used. If the server does not support this method, it returns
1301
+ `google.rpc.Code.UNIMPLEMENTED`.
1302
+
1303
+ Args:
1304
+ request (:class:`~.operations_pb2.WaitOperationRequest`):
1305
+ The request object. Request message for
1306
+ `WaitOperation` method.
1307
+ retry (google.api_core.retry.Retry): Designation of what errors,
1308
+ if any, should be retried.
1309
+ timeout (float): The timeout for this request.
1310
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1311
+ sent along with the request as metadata. Normally, each value must be of type `str`,
1312
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
1313
+ be of type `bytes`.
1314
+ Returns:
1315
+ ~.operations_pb2.Operation:
1316
+ An ``Operation`` object.
1317
+ """
1318
+ # Create or coerce a protobuf request object.
1319
+ # The request isn't a proto-plus wrapped type,
1320
+ # so it must be constructed via keyword expansion.
1321
+ if isinstance(request, dict):
1322
+ request = operations_pb2.WaitOperationRequest(**request)
1323
+
1324
+ # Wrap the RPC method; this adds retry and timeout information,
1325
+ # and friendly error handling.
1326
+ rpc = self._transport._wrapped_methods[self._transport.wait_operation]
1327
+
1328
+ # Certain fields should be provided within the metadata header;
1329
+ # add these here.
1330
+ metadata = tuple(metadata) + (
1331
+ gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
1332
+ )
1333
+
1334
+ # Validate the universe domain.
1335
+ self._validate_universe_domain()
1336
+
1337
+ try:
1338
+ # Send the request.
1339
+ response = rpc(
1340
+ request,
1341
+ retry=retry,
1342
+ timeout=timeout,
1343
+ metadata=metadata,
1344
+ )
1345
+
1346
+ # Done; return the response.
1347
+ return response
1348
+ except core_exceptions.GoogleAPICallError as e:
1349
+ self._add_cred_info_for_auth_errors(e)
1350
+ raise e
1351
+
1352
+ def set_iam_policy(
1353
+ self,
1354
+ request: Optional[iam_policy_pb2.SetIamPolicyRequest] = None,
1355
+ *,
1356
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
1357
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
1358
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
1359
+ ) -> policy_pb2.Policy:
1360
+ r"""Sets the IAM access control policy on the specified function.
1361
+
1362
+ Replaces any existing policy.
1363
+
1364
+ Args:
1365
+ request (:class:`~.iam_policy_pb2.SetIamPolicyRequest`):
1366
+ The request object. Request message for `SetIamPolicy`
1367
+ method.
1368
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
1369
+ should be retried.
1370
+ timeout (float): The timeout for this request.
1371
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1372
+ sent along with the request as metadata. Normally, each value must be of type `str`,
1373
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
1374
+ be of type `bytes`.
1375
+ Returns:
1376
+ ~.policy_pb2.Policy:
1377
+ Defines an Identity and Access Management (IAM) policy.
1378
+ It is used to specify access control policies for Cloud
1379
+ Platform resources.
1380
+ A ``Policy`` is a collection of ``bindings``. A
1381
+ ``binding`` binds one or more ``members`` to a single
1382
+ ``role``. Members can be user accounts, service
1383
+ accounts, Google groups, and domains (such as G Suite).
1384
+ A ``role`` is a named list of permissions (defined by
1385
+ IAM or configured by users). A ``binding`` can
1386
+ optionally specify a ``condition``, which is a logic
1387
+ expression that further constrains the role binding
1388
+ based on attributes about the request and/or target
1389
+ resource.
1390
+
1391
+ **JSON Example**
1392
+
1393
+ ::
1394
+
1395
+ {
1396
+ "bindings": [
1397
+ {
1398
+ "role": "roles/resourcemanager.organizationAdmin",
1399
+ "members": [
1400
+ "user:mike@example.com",
1401
+ "group:admins@example.com",
1402
+ "domain:google.com",
1403
+ "serviceAccount:my-project-id@appspot.gserviceaccount.com"
1404
+ ]
1405
+ },
1406
+ {
1407
+ "role": "roles/resourcemanager.organizationViewer",
1408
+ "members": ["user:eve@example.com"],
1409
+ "condition": {
1410
+ "title": "expirable access",
1411
+ "description": "Does not grant access after Sep 2020",
1412
+ "expression": "request.time <
1413
+ timestamp('2020-10-01T00:00:00.000Z')",
1414
+ }
1415
+ }
1416
+ ]
1417
+ }
1418
+
1419
+ **YAML Example**
1420
+
1421
+ ::
1422
+
1423
+ bindings:
1424
+ - members:
1425
+ - user:mike@example.com
1426
+ - group:admins@example.com
1427
+ - domain:google.com
1428
+ - serviceAccount:my-project-id@appspot.gserviceaccount.com
1429
+ role: roles/resourcemanager.organizationAdmin
1430
+ - members:
1431
+ - user:eve@example.com
1432
+ role: roles/resourcemanager.organizationViewer
1433
+ condition:
1434
+ title: expirable access
1435
+ description: Does not grant access after Sep 2020
1436
+ expression: request.time < timestamp('2020-10-01T00:00:00.000Z')
1437
+
1438
+ For a description of IAM and its features, see the `IAM
1439
+ developer's
1440
+ guide <https://cloud.google.com/iam/docs>`__.
1441
+ """
1442
+ # Create or coerce a protobuf request object.
1443
+
1444
+ # The request isn't a proto-plus wrapped type,
1445
+ # so it must be constructed via keyword expansion.
1446
+ if isinstance(request, dict):
1447
+ request = iam_policy_pb2.SetIamPolicyRequest(**request)
1448
+
1449
+ # Wrap the RPC method; this adds retry and timeout information,
1450
+ # and friendly error handling.
1451
+ rpc = self._transport._wrapped_methods[self._transport.set_iam_policy]
1452
+
1453
+ # Certain fields should be provided within the metadata header;
1454
+ # add these here.
1455
+ metadata = tuple(metadata) + (
1456
+ gapic_v1.routing_header.to_grpc_metadata((("resource", request.resource),)),
1457
+ )
1458
+
1459
+ # Validate the universe domain.
1460
+ self._validate_universe_domain()
1461
+
1462
+ try:
1463
+ # Send the request.
1464
+ response = rpc(
1465
+ request,
1466
+ retry=retry,
1467
+ timeout=timeout,
1468
+ metadata=metadata,
1469
+ )
1470
+
1471
+ # Done; return the response.
1472
+ return response
1473
+ except core_exceptions.GoogleAPICallError as e:
1474
+ self._add_cred_info_for_auth_errors(e)
1475
+ raise e
1476
+
1477
+ def get_iam_policy(
1478
+ self,
1479
+ request: Optional[iam_policy_pb2.GetIamPolicyRequest] = None,
1480
+ *,
1481
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
1482
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
1483
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
1484
+ ) -> policy_pb2.Policy:
1485
+ r"""Gets the IAM access control policy for a function.
1486
+
1487
+ Returns an empty policy if the function exists and does not have a
1488
+ policy set.
1489
+
1490
+ Args:
1491
+ request (:class:`~.iam_policy_pb2.GetIamPolicyRequest`):
1492
+ The request object. Request message for `GetIamPolicy`
1493
+ method.
1494
+ retry (google.api_core.retry.Retry): Designation of what errors, if
1495
+ any, should be retried.
1496
+ timeout (float): The timeout for this request.
1497
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1498
+ sent along with the request as metadata. Normally, each value must be of type `str`,
1499
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
1500
+ be of type `bytes`.
1501
+ Returns:
1502
+ ~.policy_pb2.Policy:
1503
+ Defines an Identity and Access Management (IAM) policy.
1504
+ It is used to specify access control policies for Cloud
1505
+ Platform resources.
1506
+ A ``Policy`` is a collection of ``bindings``. A
1507
+ ``binding`` binds one or more ``members`` to a single
1508
+ ``role``. Members can be user accounts, service
1509
+ accounts, Google groups, and domains (such as G Suite).
1510
+ A ``role`` is a named list of permissions (defined by
1511
+ IAM or configured by users). A ``binding`` can
1512
+ optionally specify a ``condition``, which is a logic
1513
+ expression that further constrains the role binding
1514
+ based on attributes about the request and/or target
1515
+ resource.
1516
+
1517
+ **JSON Example**
1518
+
1519
+ ::
1520
+
1521
+ {
1522
+ "bindings": [
1523
+ {
1524
+ "role": "roles/resourcemanager.organizationAdmin",
1525
+ "members": [
1526
+ "user:mike@example.com",
1527
+ "group:admins@example.com",
1528
+ "domain:google.com",
1529
+ "serviceAccount:my-project-id@appspot.gserviceaccount.com"
1530
+ ]
1531
+ },
1532
+ {
1533
+ "role": "roles/resourcemanager.organizationViewer",
1534
+ "members": ["user:eve@example.com"],
1535
+ "condition": {
1536
+ "title": "expirable access",
1537
+ "description": "Does not grant access after Sep 2020",
1538
+ "expression": "request.time <
1539
+ timestamp('2020-10-01T00:00:00.000Z')",
1540
+ }
1541
+ }
1542
+ ]
1543
+ }
1544
+
1545
+ **YAML Example**
1546
+
1547
+ ::
1548
+
1549
+ bindings:
1550
+ - members:
1551
+ - user:mike@example.com
1552
+ - group:admins@example.com
1553
+ - domain:google.com
1554
+ - serviceAccount:my-project-id@appspot.gserviceaccount.com
1555
+ role: roles/resourcemanager.organizationAdmin
1556
+ - members:
1557
+ - user:eve@example.com
1558
+ role: roles/resourcemanager.organizationViewer
1559
+ condition:
1560
+ title: expirable access
1561
+ description: Does not grant access after Sep 2020
1562
+ expression: request.time < timestamp('2020-10-01T00:00:00.000Z')
1563
+
1564
+ For a description of IAM and its features, see the `IAM
1565
+ developer's
1566
+ guide <https://cloud.google.com/iam/docs>`__.
1567
+ """
1568
+ # Create or coerce a protobuf request object.
1569
+
1570
+ # The request isn't a proto-plus wrapped type,
1571
+ # so it must be constructed via keyword expansion.
1572
+ if isinstance(request, dict):
1573
+ request = iam_policy_pb2.GetIamPolicyRequest(**request)
1574
+
1575
+ # Wrap the RPC method; this adds retry and timeout information,
1576
+ # and friendly error handling.
1577
+ rpc = self._transport._wrapped_methods[self._transport.get_iam_policy]
1578
+
1579
+ # Certain fields should be provided within the metadata header;
1580
+ # add these here.
1581
+ metadata = tuple(metadata) + (
1582
+ gapic_v1.routing_header.to_grpc_metadata((("resource", request.resource),)),
1583
+ )
1584
+
1585
+ # Validate the universe domain.
1586
+ self._validate_universe_domain()
1587
+
1588
+ try:
1589
+ # Send the request.
1590
+ response = rpc(
1591
+ request,
1592
+ retry=retry,
1593
+ timeout=timeout,
1594
+ metadata=metadata,
1595
+ )
1596
+
1597
+ # Done; return the response.
1598
+ return response
1599
+ except core_exceptions.GoogleAPICallError as e:
1600
+ self._add_cred_info_for_auth_errors(e)
1601
+ raise e
1602
+
1603
+ def test_iam_permissions(
1604
+ self,
1605
+ request: Optional[iam_policy_pb2.TestIamPermissionsRequest] = None,
1606
+ *,
1607
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
1608
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
1609
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
1610
+ ) -> iam_policy_pb2.TestIamPermissionsResponse:
1611
+ r"""Tests the specified IAM permissions against the IAM access control
1612
+ policy for a function.
1613
+
1614
+ If the function does not exist, this will return an empty set
1615
+ of permissions, not a NOT_FOUND error.
1616
+
1617
+ Args:
1618
+ request (:class:`~.iam_policy_pb2.TestIamPermissionsRequest`):
1619
+ The request object. Request message for
1620
+ `TestIamPermissions` method.
1621
+ retry (google.api_core.retry.Retry): Designation of what errors,
1622
+ if any, should be retried.
1623
+ timeout (float): The timeout for this request.
1624
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1625
+ sent along with the request as metadata. Normally, each value must be of type `str`,
1626
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
1627
+ be of type `bytes`.
1628
+ Returns:
1629
+ ~.iam_policy_pb2.TestIamPermissionsResponse:
1630
+ Response message for ``TestIamPermissions`` method.
1631
+ """
1632
+ # Create or coerce a protobuf request object.
1633
+
1634
+ # The request isn't a proto-plus wrapped type,
1635
+ # so it must be constructed via keyword expansion.
1636
+ if isinstance(request, dict):
1637
+ request = iam_policy_pb2.TestIamPermissionsRequest(**request)
1638
+
1639
+ # Wrap the RPC method; this adds retry and timeout information,
1640
+ # and friendly error handling.
1641
+ rpc = self._transport._wrapped_methods[self._transport.test_iam_permissions]
1642
+
1643
+ # Certain fields should be provided within the metadata header;
1644
+ # add these here.
1645
+ metadata = tuple(metadata) + (
1646
+ gapic_v1.routing_header.to_grpc_metadata((("resource", request.resource),)),
1647
+ )
1648
+
1649
+ # Validate the universe domain.
1650
+ self._validate_universe_domain()
1651
+
1652
+ try:
1653
+ # Send the request.
1654
+ response = rpc(
1655
+ request,
1656
+ retry=retry,
1657
+ timeout=timeout,
1658
+ metadata=metadata,
1659
+ )
1660
+
1661
+ # Done; return the response.
1662
+ return response
1663
+ except core_exceptions.GoogleAPICallError as e:
1664
+ self._add_cred_info_for_auth_errors(e)
1665
+ raise e
1666
+
1667
+ def get_location(
1668
+ self,
1669
+ request: Optional[locations_pb2.GetLocationRequest] = None,
1670
+ *,
1671
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
1672
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
1673
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
1674
+ ) -> locations_pb2.Location:
1675
+ r"""Gets information about a location.
1676
+
1677
+ Args:
1678
+ request (:class:`~.location_pb2.GetLocationRequest`):
1679
+ The request object. Request message for
1680
+ `GetLocation` method.
1681
+ retry (google.api_core.retry.Retry): Designation of what errors,
1682
+ if any, should be retried.
1683
+ timeout (float): The timeout for this request.
1684
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1685
+ sent along with the request as metadata. Normally, each value must be of type `str`,
1686
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
1687
+ be of type `bytes`.
1688
+ Returns:
1689
+ ~.location_pb2.Location:
1690
+ Location object.
1691
+ """
1692
+ # Create or coerce a protobuf request object.
1693
+ # The request isn't a proto-plus wrapped type,
1694
+ # so it must be constructed via keyword expansion.
1695
+ if isinstance(request, dict):
1696
+ request = locations_pb2.GetLocationRequest(**request)
1697
+
1698
+ # Wrap the RPC method; this adds retry and timeout information,
1699
+ # and friendly error handling.
1700
+ rpc = self._transport._wrapped_methods[self._transport.get_location]
1701
+
1702
+ # Certain fields should be provided within the metadata header;
1703
+ # add these here.
1704
+ metadata = tuple(metadata) + (
1705
+ gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
1706
+ )
1707
+
1708
+ # Validate the universe domain.
1709
+ self._validate_universe_domain()
1710
+
1711
+ try:
1712
+ # Send the request.
1713
+ response = rpc(
1714
+ request,
1715
+ retry=retry,
1716
+ timeout=timeout,
1717
+ metadata=metadata,
1718
+ )
1719
+
1720
+ # Done; return the response.
1721
+ return response
1722
+ except core_exceptions.GoogleAPICallError as e:
1723
+ self._add_cred_info_for_auth_errors(e)
1724
+ raise e
1725
+
1726
+ def list_locations(
1727
+ self,
1728
+ request: Optional[locations_pb2.ListLocationsRequest] = None,
1729
+ *,
1730
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
1731
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
1732
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
1733
+ ) -> locations_pb2.ListLocationsResponse:
1734
+ r"""Lists information about the supported locations for this service.
1735
+
1736
+ Args:
1737
+ request (:class:`~.location_pb2.ListLocationsRequest`):
1738
+ The request object. Request message for
1739
+ `ListLocations` method.
1740
+ retry (google.api_core.retry.Retry): Designation of what errors,
1741
+ if any, should be retried.
1742
+ timeout (float): The timeout for this request.
1743
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1744
+ sent along with the request as metadata. Normally, each value must be of type `str`,
1745
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
1746
+ be of type `bytes`.
1747
+ Returns:
1748
+ ~.location_pb2.ListLocationsResponse:
1749
+ Response message for ``ListLocations`` method.
1750
+ """
1751
+ # Create or coerce a protobuf request object.
1752
+ # The request isn't a proto-plus wrapped type,
1753
+ # so it must be constructed via keyword expansion.
1754
+ if isinstance(request, dict):
1755
+ request = locations_pb2.ListLocationsRequest(**request)
1756
+
1757
+ # Wrap the RPC method; this adds retry and timeout information,
1758
+ # and friendly error handling.
1759
+ rpc = self._transport._wrapped_methods[self._transport.list_locations]
1760
+
1761
+ # Certain fields should be provided within the metadata header;
1762
+ # add these here.
1763
+ metadata = tuple(metadata) + (
1764
+ gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
1765
+ )
1766
+
1767
+ # Validate the universe domain.
1768
+ self._validate_universe_domain()
1769
+
1770
+ try:
1771
+ # Send the request.
1772
+ response = rpc(
1773
+ request,
1774
+ retry=retry,
1775
+ timeout=timeout,
1776
+ metadata=metadata,
1777
+ )
1778
+
1779
+ # Done; return the response.
1780
+ return response
1781
+ except core_exceptions.GoogleAPICallError as e:
1782
+ self._add_cred_info_for_auth_errors(e)
1783
+ raise e
1784
+
1785
+
1786
+ DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
1787
+ gapic_version=package_version.__version__
1788
+ )
1789
+
1790
+ if hasattr(DEFAULT_CLIENT_INFO, "protobuf_runtime_version"): # pragma: NO COVER
1791
+ DEFAULT_CLIENT_INFO.protobuf_runtime_version = google.protobuf.__version__
1792
+
1793
+ __all__ = ("LlmUtilityServiceClient",)
loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/llm_utility_service/transports/__init__.py ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright 2025 Google LLC
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+ from collections import OrderedDict
17
+ from typing import Dict, Type, Tuple
18
+
19
+ from .base import LlmUtilityServiceTransport
20
+ from .grpc import LlmUtilityServiceGrpcTransport
21
+ from .grpc_asyncio import LlmUtilityServiceGrpcAsyncIOTransport
22
+ from .rest import LlmUtilityServiceRestTransport
23
+ from .rest import LlmUtilityServiceRestInterceptor
24
+
25
+ ASYNC_REST_CLASSES: Tuple[str, ...]
26
+ try:
27
+ from .rest_asyncio import AsyncLlmUtilityServiceRestTransport
28
+ from .rest_asyncio import AsyncLlmUtilityServiceRestInterceptor
29
+
30
+ ASYNC_REST_CLASSES = (
31
+ "AsyncLlmUtilityServiceRestTransport",
32
+ "AsyncLlmUtilityServiceRestInterceptor",
33
+ )
34
+ HAS_REST_ASYNC = True
35
+ except ImportError: # pragma: NO COVER
36
+ ASYNC_REST_CLASSES = ()
37
+ HAS_REST_ASYNC = False
38
+
39
+
40
+ # Compile a registry of transports.
41
+ _transport_registry = OrderedDict() # type: Dict[str, Type[LlmUtilityServiceTransport]]
42
+ _transport_registry["grpc"] = LlmUtilityServiceGrpcTransport
43
+ _transport_registry["grpc_asyncio"] = LlmUtilityServiceGrpcAsyncIOTransport
44
+ _transport_registry["rest"] = LlmUtilityServiceRestTransport
45
+ if HAS_REST_ASYNC: # pragma: NO COVER
46
+ _transport_registry["rest_asyncio"] = AsyncLlmUtilityServiceRestTransport
47
+
48
+ __all__ = (
49
+ "LlmUtilityServiceTransport",
50
+ "LlmUtilityServiceGrpcTransport",
51
+ "LlmUtilityServiceGrpcAsyncIOTransport",
52
+ "LlmUtilityServiceRestTransport",
53
+ "LlmUtilityServiceRestInterceptor",
54
+ ) + ASYNC_REST_CLASSES
loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/llm_utility_service/transports/__pycache__/__init__.cpython-312.pyc ADDED
Binary file (1.27 kB). View file
 
loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/llm_utility_service/transports/__pycache__/base.cpython-312.pyc ADDED
Binary file (12.8 kB). View file
 
loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/llm_utility_service/transports/__pycache__/grpc.cpython-312.pyc ADDED
Binary file (25.7 kB). View file
 
loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/llm_utility_service/transports/__pycache__/grpc_asyncio.cpython-312.pyc ADDED
Binary file (29 kB). View file
 
loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/llm_utility_service/transports/__pycache__/rest.cpython-312.pyc ADDED
Binary file (82 kB). View file
 
loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/llm_utility_service/transports/__pycache__/rest_asyncio.cpython-312.pyc ADDED
Binary file (90.3 kB). View file
 
loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/llm_utility_service/transports/__pycache__/rest_base.cpython-312.pyc ADDED
Binary file (69 kB). View file
 
loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/llm_utility_service/transports/base.py ADDED
@@ -0,0 +1,344 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright 2025 Google LLC
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+ import abc
17
+ from typing import Awaitable, Callable, Dict, Optional, Sequence, Union
18
+
19
+ from google.cloud.aiplatform_v1 import gapic_version as package_version
20
+
21
+ import google.auth # type: ignore
22
+ import google.api_core
23
+ from google.api_core import exceptions as core_exceptions
24
+ from google.api_core import gapic_v1
25
+ from google.api_core import retry as retries
26
+ from google.auth import credentials as ga_credentials # type: ignore
27
+ from google.oauth2 import service_account # type: ignore
28
+ import google.protobuf
29
+
30
+ from google.cloud.aiplatform_v1.types import llm_utility_service
31
+ from google.cloud.aiplatform_v1.types import prediction_service
32
+ from google.cloud.location import locations_pb2 # type: ignore
33
+ from google.iam.v1 import iam_policy_pb2 # type: ignore
34
+ from google.iam.v1 import policy_pb2 # type: ignore
35
+ from google.longrunning import operations_pb2 # type: ignore
36
+
37
+ DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
38
+ gapic_version=package_version.__version__
39
+ )
40
+
41
+ if hasattr(DEFAULT_CLIENT_INFO, "protobuf_runtime_version"): # pragma: NO COVER
42
+ DEFAULT_CLIENT_INFO.protobuf_runtime_version = google.protobuf.__version__
43
+
44
+
45
+ class LlmUtilityServiceTransport(abc.ABC):
46
+ """Abstract transport class for LlmUtilityService."""
47
+
48
+ AUTH_SCOPES = ("https://www.googleapis.com/auth/cloud-platform",)
49
+
50
+ DEFAULT_HOST: str = "aiplatform.googleapis.com"
51
+
52
+ def __init__(
53
+ self,
54
+ *,
55
+ host: str = DEFAULT_HOST,
56
+ credentials: Optional[ga_credentials.Credentials] = None,
57
+ credentials_file: Optional[str] = None,
58
+ scopes: Optional[Sequence[str]] = None,
59
+ quota_project_id: Optional[str] = None,
60
+ client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
61
+ always_use_jwt_access: Optional[bool] = False,
62
+ api_audience: Optional[str] = None,
63
+ **kwargs,
64
+ ) -> None:
65
+ """Instantiate the transport.
66
+
67
+ Args:
68
+ host (Optional[str]):
69
+ The hostname to connect to (default: 'aiplatform.googleapis.com').
70
+ credentials (Optional[google.auth.credentials.Credentials]): The
71
+ authorization credentials to attach to requests. These
72
+ credentials identify the application to the service; if none
73
+ are specified, the client will attempt to ascertain the
74
+ credentials from the environment.
75
+ credentials_file (Optional[str]): Deprecated. A file with credentials that can
76
+ be loaded with :func:`google.auth.load_credentials_from_file`.
77
+ This argument is mutually exclusive with credentials. This argument will be
78
+ removed in the next major version of this library.
79
+ scopes (Optional[Sequence[str]]): A list of scopes.
80
+ quota_project_id (Optional[str]): An optional project to use for billing
81
+ and quota.
82
+ client_info (google.api_core.gapic_v1.client_info.ClientInfo):
83
+ The client info used to send a user-agent string along with
84
+ API requests. If ``None``, then default info will be used.
85
+ Generally, you only need to set this if you're developing
86
+ your own client library.
87
+ always_use_jwt_access (Optional[bool]): Whether self signed JWT should
88
+ be used for service account credentials.
89
+ """
90
+
91
+ # Save the scopes.
92
+ self._scopes = scopes
93
+ if not hasattr(self, "_ignore_credentials"):
94
+ self._ignore_credentials: bool = False
95
+
96
+ # If no credentials are provided, then determine the appropriate
97
+ # defaults.
98
+ if credentials and credentials_file:
99
+ raise core_exceptions.DuplicateCredentialArgs(
100
+ "'credentials_file' and 'credentials' are mutually exclusive"
101
+ )
102
+
103
+ if credentials_file is not None:
104
+ credentials, _ = google.auth.load_credentials_from_file(
105
+ credentials_file,
106
+ scopes=scopes,
107
+ quota_project_id=quota_project_id,
108
+ default_scopes=self.AUTH_SCOPES,
109
+ )
110
+ elif credentials is None and not self._ignore_credentials:
111
+ credentials, _ = google.auth.default(
112
+ scopes=scopes,
113
+ quota_project_id=quota_project_id,
114
+ default_scopes=self.AUTH_SCOPES,
115
+ )
116
+ # Don't apply audience if the credentials file passed from user.
117
+ if hasattr(credentials, "with_gdch_audience"):
118
+ credentials = credentials.with_gdch_audience(
119
+ api_audience if api_audience else host
120
+ )
121
+
122
+ # If the credentials are service account credentials, then always try to use self signed JWT.
123
+ if (
124
+ always_use_jwt_access
125
+ and isinstance(credentials, service_account.Credentials)
126
+ and hasattr(service_account.Credentials, "with_always_use_jwt_access")
127
+ ):
128
+ credentials = credentials.with_always_use_jwt_access(True)
129
+
130
+ # Save the credentials.
131
+ self._credentials = credentials
132
+
133
+ # Save the hostname. Default to port 443 (HTTPS) if none is specified.
134
+ if ":" not in host:
135
+ host += ":443"
136
+ self._host = host
137
+
138
+ @property
139
+ def host(self):
140
+ return self._host
141
+
142
+ def _prep_wrapped_messages(self, client_info):
143
+ # Precompute the wrapped methods.
144
+ self._wrapped_methods = {
145
+ self.count_tokens: gapic_v1.method.wrap_method(
146
+ self.count_tokens,
147
+ default_timeout=None,
148
+ client_info=client_info,
149
+ ),
150
+ self.compute_tokens: gapic_v1.method.wrap_method(
151
+ self.compute_tokens,
152
+ default_timeout=None,
153
+ client_info=client_info,
154
+ ),
155
+ self.get_location: gapic_v1.method.wrap_method(
156
+ self.get_location,
157
+ default_timeout=None,
158
+ client_info=client_info,
159
+ ),
160
+ self.list_locations: gapic_v1.method.wrap_method(
161
+ self.list_locations,
162
+ default_timeout=None,
163
+ client_info=client_info,
164
+ ),
165
+ self.get_iam_policy: gapic_v1.method.wrap_method(
166
+ self.get_iam_policy,
167
+ default_timeout=None,
168
+ client_info=client_info,
169
+ ),
170
+ self.set_iam_policy: gapic_v1.method.wrap_method(
171
+ self.set_iam_policy,
172
+ default_timeout=None,
173
+ client_info=client_info,
174
+ ),
175
+ self.test_iam_permissions: gapic_v1.method.wrap_method(
176
+ self.test_iam_permissions,
177
+ default_timeout=None,
178
+ client_info=client_info,
179
+ ),
180
+ self.cancel_operation: gapic_v1.method.wrap_method(
181
+ self.cancel_operation,
182
+ default_timeout=None,
183
+ client_info=client_info,
184
+ ),
185
+ self.delete_operation: gapic_v1.method.wrap_method(
186
+ self.delete_operation,
187
+ default_timeout=None,
188
+ client_info=client_info,
189
+ ),
190
+ self.get_operation: gapic_v1.method.wrap_method(
191
+ self.get_operation,
192
+ default_timeout=None,
193
+ client_info=client_info,
194
+ ),
195
+ self.list_operations: gapic_v1.method.wrap_method(
196
+ self.list_operations,
197
+ default_timeout=None,
198
+ client_info=client_info,
199
+ ),
200
+ self.wait_operation: gapic_v1.method.wrap_method(
201
+ self.wait_operation,
202
+ default_timeout=None,
203
+ client_info=client_info,
204
+ ),
205
+ }
206
+
207
+ def close(self):
208
+ """Closes resources associated with the transport.
209
+
210
+ .. warning::
211
+ Only call this method if the transport is NOT shared
212
+ with other clients - this may cause errors in other clients!
213
+ """
214
+ raise NotImplementedError()
215
+
216
+ @property
217
+ def count_tokens(
218
+ self,
219
+ ) -> Callable[
220
+ [prediction_service.CountTokensRequest],
221
+ Union[
222
+ prediction_service.CountTokensResponse,
223
+ Awaitable[prediction_service.CountTokensResponse],
224
+ ],
225
+ ]:
226
+ raise NotImplementedError()
227
+
228
+ @property
229
+ def compute_tokens(
230
+ self,
231
+ ) -> Callable[
232
+ [llm_utility_service.ComputeTokensRequest],
233
+ Union[
234
+ llm_utility_service.ComputeTokensResponse,
235
+ Awaitable[llm_utility_service.ComputeTokensResponse],
236
+ ],
237
+ ]:
238
+ raise NotImplementedError()
239
+
240
+ @property
241
+ def list_operations(
242
+ self,
243
+ ) -> Callable[
244
+ [operations_pb2.ListOperationsRequest],
245
+ Union[
246
+ operations_pb2.ListOperationsResponse,
247
+ Awaitable[operations_pb2.ListOperationsResponse],
248
+ ],
249
+ ]:
250
+ raise NotImplementedError()
251
+
252
+ @property
253
+ def get_operation(
254
+ self,
255
+ ) -> Callable[
256
+ [operations_pb2.GetOperationRequest],
257
+ Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]],
258
+ ]:
259
+ raise NotImplementedError()
260
+
261
+ @property
262
+ def cancel_operation(
263
+ self,
264
+ ) -> Callable[
265
+ [operations_pb2.CancelOperationRequest],
266
+ None,
267
+ ]:
268
+ raise NotImplementedError()
269
+
270
+ @property
271
+ def delete_operation(
272
+ self,
273
+ ) -> Callable[
274
+ [operations_pb2.DeleteOperationRequest],
275
+ None,
276
+ ]:
277
+ raise NotImplementedError()
278
+
279
+ @property
280
+ def wait_operation(
281
+ self,
282
+ ) -> Callable[
283
+ [operations_pb2.WaitOperationRequest],
284
+ Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]],
285
+ ]:
286
+ raise NotImplementedError()
287
+
288
+ @property
289
+ def set_iam_policy(
290
+ self,
291
+ ) -> Callable[
292
+ [iam_policy_pb2.SetIamPolicyRequest],
293
+ Union[policy_pb2.Policy, Awaitable[policy_pb2.Policy]],
294
+ ]:
295
+ raise NotImplementedError()
296
+
297
+ @property
298
+ def get_iam_policy(
299
+ self,
300
+ ) -> Callable[
301
+ [iam_policy_pb2.GetIamPolicyRequest],
302
+ Union[policy_pb2.Policy, Awaitable[policy_pb2.Policy]],
303
+ ]:
304
+ raise NotImplementedError()
305
+
306
+ @property
307
+ def test_iam_permissions(
308
+ self,
309
+ ) -> Callable[
310
+ [iam_policy_pb2.TestIamPermissionsRequest],
311
+ Union[
312
+ iam_policy_pb2.TestIamPermissionsResponse,
313
+ Awaitable[iam_policy_pb2.TestIamPermissionsResponse],
314
+ ],
315
+ ]:
316
+ raise NotImplementedError()
317
+
318
+ @property
319
+ def get_location(
320
+ self,
321
+ ) -> Callable[
322
+ [locations_pb2.GetLocationRequest],
323
+ Union[locations_pb2.Location, Awaitable[locations_pb2.Location]],
324
+ ]:
325
+ raise NotImplementedError()
326
+
327
+ @property
328
+ def list_locations(
329
+ self,
330
+ ) -> Callable[
331
+ [locations_pb2.ListLocationsRequest],
332
+ Union[
333
+ locations_pb2.ListLocationsResponse,
334
+ Awaitable[locations_pb2.ListLocationsResponse],
335
+ ],
336
+ ]:
337
+ raise NotImplementedError()
338
+
339
+ @property
340
+ def kind(self) -> str:
341
+ raise NotImplementedError()
342
+
343
+
344
+ __all__ = ("LlmUtilityServiceTransport",)
loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/llm_utility_service/transports/grpc.py ADDED
@@ -0,0 +1,598 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright 2025 Google LLC
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+ import json
17
+ import logging as std_logging
18
+ import pickle
19
+ import warnings
20
+ from typing import Callable, Dict, Optional, Sequence, Tuple, Union
21
+
22
+ from google.api_core import grpc_helpers
23
+ from google.api_core import gapic_v1
24
+ import google.auth # type: ignore
25
+ from google.auth import credentials as ga_credentials # type: ignore
26
+ from google.auth.transport.grpc import SslCredentials # type: ignore
27
+ from google.protobuf.json_format import MessageToJson
28
+ import google.protobuf.message
29
+
30
+ import grpc # type: ignore
31
+ import proto # type: ignore
32
+
33
+ from google.cloud.aiplatform_v1.types import llm_utility_service
34
+ from google.cloud.aiplatform_v1.types import prediction_service
35
+ from google.cloud.location import locations_pb2 # type: ignore
36
+ from google.iam.v1 import iam_policy_pb2 # type: ignore
37
+ from google.iam.v1 import policy_pb2 # type: ignore
38
+ from google.longrunning import operations_pb2 # type: ignore
39
+ from .base import LlmUtilityServiceTransport, DEFAULT_CLIENT_INFO
40
+
41
+ try:
42
+ from google.api_core import client_logging # type: ignore
43
+
44
+ CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER
45
+ except ImportError: # pragma: NO COVER
46
+ CLIENT_LOGGING_SUPPORTED = False
47
+
48
+ _LOGGER = std_logging.getLogger(__name__)
49
+
50
+
51
+ class _LoggingClientInterceptor(grpc.UnaryUnaryClientInterceptor): # pragma: NO COVER
52
+ def intercept_unary_unary(self, continuation, client_call_details, request):
53
+ logging_enabled = CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
54
+ std_logging.DEBUG
55
+ )
56
+ if logging_enabled: # pragma: NO COVER
57
+ request_metadata = client_call_details.metadata
58
+ if isinstance(request, proto.Message):
59
+ request_payload = type(request).to_json(request)
60
+ elif isinstance(request, google.protobuf.message.Message):
61
+ request_payload = MessageToJson(request)
62
+ else:
63
+ request_payload = f"{type(request).__name__}: {pickle.dumps(request)}"
64
+
65
+ request_metadata = {
66
+ key: value.decode("utf-8") if isinstance(value, bytes) else value
67
+ for key, value in request_metadata
68
+ }
69
+ grpc_request = {
70
+ "payload": request_payload,
71
+ "requestMethod": "grpc",
72
+ "metadata": dict(request_metadata),
73
+ }
74
+ _LOGGER.debug(
75
+ f"Sending request for {client_call_details.method}",
76
+ extra={
77
+ "serviceName": "google.cloud.aiplatform.v1.LlmUtilityService",
78
+ "rpcName": str(client_call_details.method),
79
+ "request": grpc_request,
80
+ "metadata": grpc_request["metadata"],
81
+ },
82
+ )
83
+ response = continuation(client_call_details, request)
84
+ if logging_enabled: # pragma: NO COVER
85
+ response_metadata = response.trailing_metadata()
86
+ # Convert gRPC metadata `<class 'grpc.aio._metadata.Metadata'>` to list of tuples
87
+ metadata = (
88
+ dict([(k, str(v)) for k, v in response_metadata])
89
+ if response_metadata
90
+ else None
91
+ )
92
+ result = response.result()
93
+ if isinstance(result, proto.Message):
94
+ response_payload = type(result).to_json(result)
95
+ elif isinstance(result, google.protobuf.message.Message):
96
+ response_payload = MessageToJson(result)
97
+ else:
98
+ response_payload = f"{type(result).__name__}: {pickle.dumps(result)}"
99
+ grpc_response = {
100
+ "payload": response_payload,
101
+ "metadata": metadata,
102
+ "status": "OK",
103
+ }
104
+ _LOGGER.debug(
105
+ f"Received response for {client_call_details.method}.",
106
+ extra={
107
+ "serviceName": "google.cloud.aiplatform.v1.LlmUtilityService",
108
+ "rpcName": client_call_details.method,
109
+ "response": grpc_response,
110
+ "metadata": grpc_response["metadata"],
111
+ },
112
+ )
113
+ return response
114
+
115
+
116
+ class LlmUtilityServiceGrpcTransport(LlmUtilityServiceTransport):
117
+ """gRPC backend transport for LlmUtilityService.
118
+
119
+ Service for LLM related utility functions.
120
+
121
+ This class defines the same methods as the primary client, so the
122
+ primary client can load the underlying transport implementation
123
+ and call it.
124
+
125
+ It sends protocol buffers over the wire using gRPC (which is built on
126
+ top of HTTP/2); the ``grpcio`` package must be installed.
127
+ """
128
+
129
+ _stubs: Dict[str, Callable]
130
+
131
+ def __init__(
132
+ self,
133
+ *,
134
+ host: str = "aiplatform.googleapis.com",
135
+ credentials: Optional[ga_credentials.Credentials] = None,
136
+ credentials_file: Optional[str] = None,
137
+ scopes: Optional[Sequence[str]] = None,
138
+ channel: Optional[Union[grpc.Channel, Callable[..., grpc.Channel]]] = None,
139
+ api_mtls_endpoint: Optional[str] = None,
140
+ client_cert_source: Optional[Callable[[], Tuple[bytes, bytes]]] = None,
141
+ ssl_channel_credentials: Optional[grpc.ChannelCredentials] = None,
142
+ client_cert_source_for_mtls: Optional[Callable[[], Tuple[bytes, bytes]]] = None,
143
+ quota_project_id: Optional[str] = None,
144
+ client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
145
+ always_use_jwt_access: Optional[bool] = False,
146
+ api_audience: Optional[str] = None,
147
+ ) -> None:
148
+ """Instantiate the transport.
149
+
150
+ Args:
151
+ host (Optional[str]):
152
+ The hostname to connect to (default: 'aiplatform.googleapis.com').
153
+ credentials (Optional[google.auth.credentials.Credentials]): The
154
+ authorization credentials to attach to requests. These
155
+ credentials identify the application to the service; if none
156
+ are specified, the client will attempt to ascertain the
157
+ credentials from the environment.
158
+ This argument is ignored if a ``channel`` instance is provided.
159
+ credentials_file (Optional[str]): Deprecated. A file with credentials that can
160
+ be loaded with :func:`google.auth.load_credentials_from_file`.
161
+ This argument is ignored if a ``channel`` instance is provided.
162
+ This argument will be removed in the next major version of this library.
163
+ scopes (Optional(Sequence[str])): A list of scopes. This argument is
164
+ ignored if a ``channel`` instance is provided.
165
+ channel (Optional[Union[grpc.Channel, Callable[..., grpc.Channel]]]):
166
+ A ``Channel`` instance through which to make calls, or a Callable
167
+ that constructs and returns one. If set to None, ``self.create_channel``
168
+ is used to create the channel. If a Callable is given, it will be called
169
+ with the same arguments as used in ``self.create_channel``.
170
+ api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint.
171
+ If provided, it overrides the ``host`` argument and tries to create
172
+ a mutual TLS channel with client SSL credentials from
173
+ ``client_cert_source`` or application default SSL credentials.
174
+ client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]):
175
+ Deprecated. A callback to provide client SSL certificate bytes and
176
+ private key bytes, both in PEM format. It is ignored if
177
+ ``api_mtls_endpoint`` is None.
178
+ ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials
179
+ for the grpc channel. It is ignored if a ``channel`` instance is provided.
180
+ client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]):
181
+ A callback to provide client certificate bytes and private key bytes,
182
+ both in PEM format. It is used to configure a mutual TLS channel. It is
183
+ ignored if a ``channel`` instance or ``ssl_channel_credentials`` is provided.
184
+ quota_project_id (Optional[str]): An optional project to use for billing
185
+ and quota.
186
+ client_info (google.api_core.gapic_v1.client_info.ClientInfo):
187
+ The client info used to send a user-agent string along with
188
+ API requests. If ``None``, then default info will be used.
189
+ Generally, you only need to set this if you're developing
190
+ your own client library.
191
+ always_use_jwt_access (Optional[bool]): Whether self signed JWT should
192
+ be used for service account credentials.
193
+
194
+ Raises:
195
+ google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport
196
+ creation failed for any reason.
197
+ google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials``
198
+ and ``credentials_file`` are passed.
199
+ """
200
+ self._grpc_channel = None
201
+ self._ssl_channel_credentials = ssl_channel_credentials
202
+ self._stubs: Dict[str, Callable] = {}
203
+
204
+ if api_mtls_endpoint:
205
+ warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning)
206
+ if client_cert_source:
207
+ warnings.warn("client_cert_source is deprecated", DeprecationWarning)
208
+
209
+ if isinstance(channel, grpc.Channel):
210
+ # Ignore credentials if a channel was passed.
211
+ credentials = None
212
+ self._ignore_credentials = True
213
+ # If a channel was explicitly provided, set it.
214
+ self._grpc_channel = channel
215
+ self._ssl_channel_credentials = None
216
+
217
+ else:
218
+ if api_mtls_endpoint:
219
+ host = api_mtls_endpoint
220
+
221
+ # Create SSL credentials with client_cert_source or application
222
+ # default SSL credentials.
223
+ if client_cert_source:
224
+ cert, key = client_cert_source()
225
+ self._ssl_channel_credentials = grpc.ssl_channel_credentials(
226
+ certificate_chain=cert, private_key=key
227
+ )
228
+ else:
229
+ self._ssl_channel_credentials = SslCredentials().ssl_credentials
230
+
231
+ else:
232
+ if client_cert_source_for_mtls and not ssl_channel_credentials:
233
+ cert, key = client_cert_source_for_mtls()
234
+ self._ssl_channel_credentials = grpc.ssl_channel_credentials(
235
+ certificate_chain=cert, private_key=key
236
+ )
237
+
238
+ # The base transport sets the host, credentials and scopes
239
+ super().__init__(
240
+ host=host,
241
+ credentials=credentials,
242
+ credentials_file=credentials_file,
243
+ scopes=scopes,
244
+ quota_project_id=quota_project_id,
245
+ client_info=client_info,
246
+ always_use_jwt_access=always_use_jwt_access,
247
+ api_audience=api_audience,
248
+ )
249
+
250
+ if not self._grpc_channel:
251
+ # initialize with the provided callable or the default channel
252
+ channel_init = channel or type(self).create_channel
253
+ self._grpc_channel = channel_init(
254
+ self._host,
255
+ # use the credentials which are saved
256
+ credentials=self._credentials,
257
+ # Set ``credentials_file`` to ``None`` here as
258
+ # the credentials that we saved earlier should be used.
259
+ credentials_file=None,
260
+ scopes=self._scopes,
261
+ ssl_credentials=self._ssl_channel_credentials,
262
+ quota_project_id=quota_project_id,
263
+ options=[
264
+ ("grpc.max_send_message_length", -1),
265
+ ("grpc.max_receive_message_length", -1),
266
+ ],
267
+ )
268
+
269
+ self._interceptor = _LoggingClientInterceptor()
270
+ self._logged_channel = grpc.intercept_channel(
271
+ self._grpc_channel, self._interceptor
272
+ )
273
+
274
+ # Wrap messages. This must be done after self._logged_channel exists
275
+ self._prep_wrapped_messages(client_info)
276
+
277
+ @classmethod
278
+ def create_channel(
279
+ cls,
280
+ host: str = "aiplatform.googleapis.com",
281
+ credentials: Optional[ga_credentials.Credentials] = None,
282
+ credentials_file: Optional[str] = None,
283
+ scopes: Optional[Sequence[str]] = None,
284
+ quota_project_id: Optional[str] = None,
285
+ **kwargs,
286
+ ) -> grpc.Channel:
287
+ """Create and return a gRPC channel object.
288
+ Args:
289
+ host (Optional[str]): The host for the channel to use.
290
+ credentials (Optional[~.Credentials]): The
291
+ authorization credentials to attach to requests. These
292
+ credentials identify this application to the service. If
293
+ none are specified, the client will attempt to ascertain
294
+ the credentials from the environment.
295
+ credentials_file (Optional[str]): Deprecated. A file with credentials that can
296
+ be loaded with :func:`google.auth.load_credentials_from_file`.
297
+ This argument is mutually exclusive with credentials. This argument will be
298
+ removed in the next major version of this library.
299
+ scopes (Optional[Sequence[str]]): A optional list of scopes needed for this
300
+ service. These are only used when credentials are not specified and
301
+ are passed to :func:`google.auth.default`.
302
+ quota_project_id (Optional[str]): An optional project to use for billing
303
+ and quota.
304
+ kwargs (Optional[dict]): Keyword arguments, which are passed to the
305
+ channel creation.
306
+ Returns:
307
+ grpc.Channel: A gRPC channel object.
308
+
309
+ Raises:
310
+ google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials``
311
+ and ``credentials_file`` are passed.
312
+ """
313
+
314
+ return grpc_helpers.create_channel(
315
+ host,
316
+ credentials=credentials,
317
+ credentials_file=credentials_file,
318
+ quota_project_id=quota_project_id,
319
+ default_scopes=cls.AUTH_SCOPES,
320
+ scopes=scopes,
321
+ default_host=cls.DEFAULT_HOST,
322
+ **kwargs,
323
+ )
324
+
325
+ @property
326
+ def grpc_channel(self) -> grpc.Channel:
327
+ """Return the channel designed to connect to this service."""
328
+ return self._grpc_channel
329
+
330
+ @property
331
+ def count_tokens(
332
+ self,
333
+ ) -> Callable[
334
+ [prediction_service.CountTokensRequest], prediction_service.CountTokensResponse
335
+ ]:
336
+ r"""Return a callable for the count tokens method over gRPC.
337
+
338
+ Perform a token counting.
339
+
340
+ Returns:
341
+ Callable[[~.CountTokensRequest],
342
+ ~.CountTokensResponse]:
343
+ A function that, when called, will call the underlying RPC
344
+ on the server.
345
+ """
346
+ # Generate a "stub function" on-the-fly which will actually make
347
+ # the request.
348
+ # gRPC handles serialization and deserialization, so we just need
349
+ # to pass in the functions for each.
350
+ if "count_tokens" not in self._stubs:
351
+ self._stubs["count_tokens"] = self._logged_channel.unary_unary(
352
+ "/google.cloud.aiplatform.v1.LlmUtilityService/CountTokens",
353
+ request_serializer=prediction_service.CountTokensRequest.serialize,
354
+ response_deserializer=prediction_service.CountTokensResponse.deserialize,
355
+ )
356
+ return self._stubs["count_tokens"]
357
+
358
+ @property
359
+ def compute_tokens(
360
+ self,
361
+ ) -> Callable[
362
+ [llm_utility_service.ComputeTokensRequest],
363
+ llm_utility_service.ComputeTokensResponse,
364
+ ]:
365
+ r"""Return a callable for the compute tokens method over gRPC.
366
+
367
+ Return a list of tokens based on the input text.
368
+
369
+ Returns:
370
+ Callable[[~.ComputeTokensRequest],
371
+ ~.ComputeTokensResponse]:
372
+ A function that, when called, will call the underlying RPC
373
+ on the server.
374
+ """
375
+ # Generate a "stub function" on-the-fly which will actually make
376
+ # the request.
377
+ # gRPC handles serialization and deserialization, so we just need
378
+ # to pass in the functions for each.
379
+ if "compute_tokens" not in self._stubs:
380
+ self._stubs["compute_tokens"] = self._logged_channel.unary_unary(
381
+ "/google.cloud.aiplatform.v1.LlmUtilityService/ComputeTokens",
382
+ request_serializer=llm_utility_service.ComputeTokensRequest.serialize,
383
+ response_deserializer=llm_utility_service.ComputeTokensResponse.deserialize,
384
+ )
385
+ return self._stubs["compute_tokens"]
386
+
387
+ def close(self):
388
+ self._logged_channel.close()
389
+
390
+ @property
391
+ def delete_operation(
392
+ self,
393
+ ) -> Callable[[operations_pb2.DeleteOperationRequest], None]:
394
+ r"""Return a callable for the delete_operation method over gRPC."""
395
+ # Generate a "stub function" on-the-fly which will actually make
396
+ # the request.
397
+ # gRPC handles serialization and deserialization, so we just need
398
+ # to pass in the functions for each.
399
+ if "delete_operation" not in self._stubs:
400
+ self._stubs["delete_operation"] = self._logged_channel.unary_unary(
401
+ "/google.longrunning.Operations/DeleteOperation",
402
+ request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString,
403
+ response_deserializer=None,
404
+ )
405
+ return self._stubs["delete_operation"]
406
+
407
+ @property
408
+ def cancel_operation(
409
+ self,
410
+ ) -> Callable[[operations_pb2.CancelOperationRequest], None]:
411
+ r"""Return a callable for the cancel_operation method over gRPC."""
412
+ # Generate a "stub function" on-the-fly which will actually make
413
+ # the request.
414
+ # gRPC handles serialization and deserialization, so we just need
415
+ # to pass in the functions for each.
416
+ if "cancel_operation" not in self._stubs:
417
+ self._stubs["cancel_operation"] = self._logged_channel.unary_unary(
418
+ "/google.longrunning.Operations/CancelOperation",
419
+ request_serializer=operations_pb2.CancelOperationRequest.SerializeToString,
420
+ response_deserializer=None,
421
+ )
422
+ return self._stubs["cancel_operation"]
423
+
424
+ @property
425
+ def wait_operation(
426
+ self,
427
+ ) -> Callable[[operations_pb2.WaitOperationRequest], None]:
428
+ r"""Return a callable for the wait_operation method over gRPC."""
429
+ # Generate a "stub function" on-the-fly which will actually make
430
+ # the request.
431
+ # gRPC handles serialization and deserialization, so we just need
432
+ # to pass in the functions for each.
433
+ if "wait_operation" not in self._stubs:
434
+ self._stubs["wait_operation"] = self._logged_channel.unary_unary(
435
+ "/google.longrunning.Operations/WaitOperation",
436
+ request_serializer=operations_pb2.WaitOperationRequest.SerializeToString,
437
+ response_deserializer=None,
438
+ )
439
+ return self._stubs["wait_operation"]
440
+
441
+ @property
442
+ def get_operation(
443
+ self,
444
+ ) -> Callable[[operations_pb2.GetOperationRequest], operations_pb2.Operation]:
445
+ r"""Return a callable for the get_operation method over gRPC."""
446
+ # Generate a "stub function" on-the-fly which will actually make
447
+ # the request.
448
+ # gRPC handles serialization and deserialization, so we just need
449
+ # to pass in the functions for each.
450
+ if "get_operation" not in self._stubs:
451
+ self._stubs["get_operation"] = self._logged_channel.unary_unary(
452
+ "/google.longrunning.Operations/GetOperation",
453
+ request_serializer=operations_pb2.GetOperationRequest.SerializeToString,
454
+ response_deserializer=operations_pb2.Operation.FromString,
455
+ )
456
+ return self._stubs["get_operation"]
457
+
458
+ @property
459
+ def list_operations(
460
+ self,
461
+ ) -> Callable[
462
+ [operations_pb2.ListOperationsRequest], operations_pb2.ListOperationsResponse
463
+ ]:
464
+ r"""Return a callable for the list_operations method over gRPC."""
465
+ # Generate a "stub function" on-the-fly which will actually make
466
+ # the request.
467
+ # gRPC handles serialization and deserialization, so we just need
468
+ # to pass in the functions for each.
469
+ if "list_operations" not in self._stubs:
470
+ self._stubs["list_operations"] = self._logged_channel.unary_unary(
471
+ "/google.longrunning.Operations/ListOperations",
472
+ request_serializer=operations_pb2.ListOperationsRequest.SerializeToString,
473
+ response_deserializer=operations_pb2.ListOperationsResponse.FromString,
474
+ )
475
+ return self._stubs["list_operations"]
476
+
477
+ @property
478
+ def list_locations(
479
+ self,
480
+ ) -> Callable[
481
+ [locations_pb2.ListLocationsRequest], locations_pb2.ListLocationsResponse
482
+ ]:
483
+ r"""Return a callable for the list locations method over gRPC."""
484
+ # Generate a "stub function" on-the-fly which will actually make
485
+ # the request.
486
+ # gRPC handles serialization and deserialization, so we just need
487
+ # to pass in the functions for each.
488
+ if "list_locations" not in self._stubs:
489
+ self._stubs["list_locations"] = self._logged_channel.unary_unary(
490
+ "/google.cloud.location.Locations/ListLocations",
491
+ request_serializer=locations_pb2.ListLocationsRequest.SerializeToString,
492
+ response_deserializer=locations_pb2.ListLocationsResponse.FromString,
493
+ )
494
+ return self._stubs["list_locations"]
495
+
496
+ @property
497
+ def get_location(
498
+ self,
499
+ ) -> Callable[[locations_pb2.GetLocationRequest], locations_pb2.Location]:
500
+ r"""Return a callable for the list locations method over gRPC."""
501
+ # Generate a "stub function" on-the-fly which will actually make
502
+ # the request.
503
+ # gRPC handles serialization and deserialization, so we just need
504
+ # to pass in the functions for each.
505
+ if "get_location" not in self._stubs:
506
+ self._stubs["get_location"] = self._logged_channel.unary_unary(
507
+ "/google.cloud.location.Locations/GetLocation",
508
+ request_serializer=locations_pb2.GetLocationRequest.SerializeToString,
509
+ response_deserializer=locations_pb2.Location.FromString,
510
+ )
511
+ return self._stubs["get_location"]
512
+
513
+ @property
514
+ def set_iam_policy(
515
+ self,
516
+ ) -> Callable[[iam_policy_pb2.SetIamPolicyRequest], policy_pb2.Policy]:
517
+ r"""Return a callable for the set iam policy method over gRPC.
518
+ Sets the IAM access control policy on the specified
519
+ function. Replaces any existing policy.
520
+ Returns:
521
+ Callable[[~.SetIamPolicyRequest],
522
+ ~.Policy]:
523
+ A function that, when called, will call the underlying RPC
524
+ on the server.
525
+ """
526
+ # Generate a "stub function" on-the-fly which will actually make
527
+ # the request.
528
+ # gRPC handles serialization and deserialization, so we just need
529
+ # to pass in the functions for each.
530
+ if "set_iam_policy" not in self._stubs:
531
+ self._stubs["set_iam_policy"] = self._logged_channel.unary_unary(
532
+ "/google.iam.v1.IAMPolicy/SetIamPolicy",
533
+ request_serializer=iam_policy_pb2.SetIamPolicyRequest.SerializeToString,
534
+ response_deserializer=policy_pb2.Policy.FromString,
535
+ )
536
+ return self._stubs["set_iam_policy"]
537
+
538
+ @property
539
+ def get_iam_policy(
540
+ self,
541
+ ) -> Callable[[iam_policy_pb2.GetIamPolicyRequest], policy_pb2.Policy]:
542
+ r"""Return a callable for the get iam policy method over gRPC.
543
+ Gets the IAM access control policy for a function.
544
+ Returns an empty policy if the function exists and does
545
+ not have a policy set.
546
+ Returns:
547
+ Callable[[~.GetIamPolicyRequest],
548
+ ~.Policy]:
549
+ A function that, when called, will call the underlying RPC
550
+ on the server.
551
+ """
552
+ # Generate a "stub function" on-the-fly which will actually make
553
+ # the request.
554
+ # gRPC handles serialization and deserialization, so we just need
555
+ # to pass in the functions for each.
556
+ if "get_iam_policy" not in self._stubs:
557
+ self._stubs["get_iam_policy"] = self._logged_channel.unary_unary(
558
+ "/google.iam.v1.IAMPolicy/GetIamPolicy",
559
+ request_serializer=iam_policy_pb2.GetIamPolicyRequest.SerializeToString,
560
+ response_deserializer=policy_pb2.Policy.FromString,
561
+ )
562
+ return self._stubs["get_iam_policy"]
563
+
564
+ @property
565
+ def test_iam_permissions(
566
+ self,
567
+ ) -> Callable[
568
+ [iam_policy_pb2.TestIamPermissionsRequest],
569
+ iam_policy_pb2.TestIamPermissionsResponse,
570
+ ]:
571
+ r"""Return a callable for the test iam permissions method over gRPC.
572
+ Tests the specified permissions against the IAM access control
573
+ policy for a function. If the function does not exist, this will
574
+ return an empty set of permissions, not a NOT_FOUND error.
575
+ Returns:
576
+ Callable[[~.TestIamPermissionsRequest],
577
+ ~.TestIamPermissionsResponse]:
578
+ A function that, when called, will call the underlying RPC
579
+ on the server.
580
+ """
581
+ # Generate a "stub function" on-the-fly which will actually make
582
+ # the request.
583
+ # gRPC handles serialization and deserialization, so we just need
584
+ # to pass in the functions for each.
585
+ if "test_iam_permissions" not in self._stubs:
586
+ self._stubs["test_iam_permissions"] = self._logged_channel.unary_unary(
587
+ "/google.iam.v1.IAMPolicy/TestIamPermissions",
588
+ request_serializer=iam_policy_pb2.TestIamPermissionsRequest.SerializeToString,
589
+ response_deserializer=iam_policy_pb2.TestIamPermissionsResponse.FromString,
590
+ )
591
+ return self._stubs["test_iam_permissions"]
592
+
593
+ @property
594
+ def kind(self) -> str:
595
+ return "grpc"
596
+
597
+
598
+ __all__ = ("LlmUtilityServiceGrpcTransport",)
loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/llm_utility_service/transports/grpc_asyncio.py ADDED
@@ -0,0 +1,677 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright 2025 Google LLC
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+ import inspect
17
+ import json
18
+ import pickle
19
+ import logging as std_logging
20
+ import warnings
21
+ from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union
22
+
23
+ from google.api_core import gapic_v1
24
+ from google.api_core import grpc_helpers_async
25
+ from google.api_core import exceptions as core_exceptions
26
+ from google.api_core import retry_async as retries
27
+ from google.auth import credentials as ga_credentials # type: ignore
28
+ from google.auth.transport.grpc import SslCredentials # type: ignore
29
+ from google.protobuf.json_format import MessageToJson
30
+ import google.protobuf.message
31
+
32
+ import grpc # type: ignore
33
+ import proto # type: ignore
34
+ from grpc.experimental import aio # type: ignore
35
+
36
+ from google.cloud.aiplatform_v1.types import llm_utility_service
37
+ from google.cloud.aiplatform_v1.types import prediction_service
38
+ from google.cloud.location import locations_pb2 # type: ignore
39
+ from google.iam.v1 import iam_policy_pb2 # type: ignore
40
+ from google.iam.v1 import policy_pb2 # type: ignore
41
+ from google.longrunning import operations_pb2 # type: ignore
42
+ from .base import LlmUtilityServiceTransport, DEFAULT_CLIENT_INFO
43
+ from .grpc import LlmUtilityServiceGrpcTransport
44
+
45
+ try:
46
+ from google.api_core import client_logging # type: ignore
47
+
48
+ CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER
49
+ except ImportError: # pragma: NO COVER
50
+ CLIENT_LOGGING_SUPPORTED = False
51
+
52
+ _LOGGER = std_logging.getLogger(__name__)
53
+
54
+
55
+ class _LoggingClientAIOInterceptor(
56
+ grpc.aio.UnaryUnaryClientInterceptor
57
+ ): # pragma: NO COVER
58
+ async def intercept_unary_unary(self, continuation, client_call_details, request):
59
+ logging_enabled = CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
60
+ std_logging.DEBUG
61
+ )
62
+ if logging_enabled: # pragma: NO COVER
63
+ request_metadata = client_call_details.metadata
64
+ if isinstance(request, proto.Message):
65
+ request_payload = type(request).to_json(request)
66
+ elif isinstance(request, google.protobuf.message.Message):
67
+ request_payload = MessageToJson(request)
68
+ else:
69
+ request_payload = f"{type(request).__name__}: {pickle.dumps(request)}"
70
+
71
+ request_metadata = {
72
+ key: value.decode("utf-8") if isinstance(value, bytes) else value
73
+ for key, value in request_metadata
74
+ }
75
+ grpc_request = {
76
+ "payload": request_payload,
77
+ "requestMethod": "grpc",
78
+ "metadata": dict(request_metadata),
79
+ }
80
+ _LOGGER.debug(
81
+ f"Sending request for {client_call_details.method}",
82
+ extra={
83
+ "serviceName": "google.cloud.aiplatform.v1.LlmUtilityService",
84
+ "rpcName": str(client_call_details.method),
85
+ "request": grpc_request,
86
+ "metadata": grpc_request["metadata"],
87
+ },
88
+ )
89
+ response = await continuation(client_call_details, request)
90
+ if logging_enabled: # pragma: NO COVER
91
+ response_metadata = await response.trailing_metadata()
92
+ # Convert gRPC metadata `<class 'grpc.aio._metadata.Metadata'>` to list of tuples
93
+ metadata = (
94
+ dict([(k, str(v)) for k, v in response_metadata])
95
+ if response_metadata
96
+ else None
97
+ )
98
+ result = await response
99
+ if isinstance(result, proto.Message):
100
+ response_payload = type(result).to_json(result)
101
+ elif isinstance(result, google.protobuf.message.Message):
102
+ response_payload = MessageToJson(result)
103
+ else:
104
+ response_payload = f"{type(result).__name__}: {pickle.dumps(result)}"
105
+ grpc_response = {
106
+ "payload": response_payload,
107
+ "metadata": metadata,
108
+ "status": "OK",
109
+ }
110
+ _LOGGER.debug(
111
+ f"Received response to rpc {client_call_details.method}.",
112
+ extra={
113
+ "serviceName": "google.cloud.aiplatform.v1.LlmUtilityService",
114
+ "rpcName": str(client_call_details.method),
115
+ "response": grpc_response,
116
+ "metadata": grpc_response["metadata"],
117
+ },
118
+ )
119
+ return response
120
+
121
+
122
+ class LlmUtilityServiceGrpcAsyncIOTransport(LlmUtilityServiceTransport):
123
+ """gRPC AsyncIO backend transport for LlmUtilityService.
124
+
125
+ Service for LLM related utility functions.
126
+
127
+ This class defines the same methods as the primary client, so the
128
+ primary client can load the underlying transport implementation
129
+ and call it.
130
+
131
+ It sends protocol buffers over the wire using gRPC (which is built on
132
+ top of HTTP/2); the ``grpcio`` package must be installed.
133
+ """
134
+
135
+ _grpc_channel: aio.Channel
136
+ _stubs: Dict[str, Callable] = {}
137
+
138
+ @classmethod
139
+ def create_channel(
140
+ cls,
141
+ host: str = "aiplatform.googleapis.com",
142
+ credentials: Optional[ga_credentials.Credentials] = None,
143
+ credentials_file: Optional[str] = None,
144
+ scopes: Optional[Sequence[str]] = None,
145
+ quota_project_id: Optional[str] = None,
146
+ **kwargs,
147
+ ) -> aio.Channel:
148
+ """Create and return a gRPC AsyncIO channel object.
149
+ Args:
150
+ host (Optional[str]): The host for the channel to use.
151
+ credentials (Optional[~.Credentials]): The
152
+ authorization credentials to attach to requests. These
153
+ credentials identify this application to the service. If
154
+ none are specified, the client will attempt to ascertain
155
+ the credentials from the environment.
156
+ credentials_file (Optional[str]): Deprecated. A file with credentials that can
157
+ be loaded with :func:`google.auth.load_credentials_from_file`. This argument will be
158
+ removed in the next major version of this library.
159
+ scopes (Optional[Sequence[str]]): A optional list of scopes needed for this
160
+ service. These are only used when credentials are not specified and
161
+ are passed to :func:`google.auth.default`.
162
+ quota_project_id (Optional[str]): An optional project to use for billing
163
+ and quota.
164
+ kwargs (Optional[dict]): Keyword arguments, which are passed to the
165
+ channel creation.
166
+ Returns:
167
+ aio.Channel: A gRPC AsyncIO channel object.
168
+ """
169
+
170
+ return grpc_helpers_async.create_channel(
171
+ host,
172
+ credentials=credentials,
173
+ credentials_file=credentials_file,
174
+ quota_project_id=quota_project_id,
175
+ default_scopes=cls.AUTH_SCOPES,
176
+ scopes=scopes,
177
+ default_host=cls.DEFAULT_HOST,
178
+ **kwargs,
179
+ )
180
+
181
+ def __init__(
182
+ self,
183
+ *,
184
+ host: str = "aiplatform.googleapis.com",
185
+ credentials: Optional[ga_credentials.Credentials] = None,
186
+ credentials_file: Optional[str] = None,
187
+ scopes: Optional[Sequence[str]] = None,
188
+ channel: Optional[Union[aio.Channel, Callable[..., aio.Channel]]] = None,
189
+ api_mtls_endpoint: Optional[str] = None,
190
+ client_cert_source: Optional[Callable[[], Tuple[bytes, bytes]]] = None,
191
+ ssl_channel_credentials: Optional[grpc.ChannelCredentials] = None,
192
+ client_cert_source_for_mtls: Optional[Callable[[], Tuple[bytes, bytes]]] = None,
193
+ quota_project_id: Optional[str] = None,
194
+ client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
195
+ always_use_jwt_access: Optional[bool] = False,
196
+ api_audience: Optional[str] = None,
197
+ ) -> None:
198
+ """Instantiate the transport.
199
+
200
+ Args:
201
+ host (Optional[str]):
202
+ The hostname to connect to (default: 'aiplatform.googleapis.com').
203
+ credentials (Optional[google.auth.credentials.Credentials]): The
204
+ authorization credentials to attach to requests. These
205
+ credentials identify the application to the service; if none
206
+ are specified, the client will attempt to ascertain the
207
+ credentials from the environment.
208
+ This argument is ignored if a ``channel`` instance is provided.
209
+ credentials_file (Optional[str]): Deprecated. A file with credentials that can
210
+ be loaded with :func:`google.auth.load_credentials_from_file`.
211
+ This argument is ignored if a ``channel`` instance is provided.
212
+ This argument will be removed in the next major version of this library.
213
+ scopes (Optional[Sequence[str]]): A optional list of scopes needed for this
214
+ service. These are only used when credentials are not specified and
215
+ are passed to :func:`google.auth.default`.
216
+ channel (Optional[Union[aio.Channel, Callable[..., aio.Channel]]]):
217
+ A ``Channel`` instance through which to make calls, or a Callable
218
+ that constructs and returns one. If set to None, ``self.create_channel``
219
+ is used to create the channel. If a Callable is given, it will be called
220
+ with the same arguments as used in ``self.create_channel``.
221
+ api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint.
222
+ If provided, it overrides the ``host`` argument and tries to create
223
+ a mutual TLS channel with client SSL credentials from
224
+ ``client_cert_source`` or application default SSL credentials.
225
+ client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]):
226
+ Deprecated. A callback to provide client SSL certificate bytes and
227
+ private key bytes, both in PEM format. It is ignored if
228
+ ``api_mtls_endpoint`` is None.
229
+ ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials
230
+ for the grpc channel. It is ignored if a ``channel`` instance is provided.
231
+ client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]):
232
+ A callback to provide client certificate bytes and private key bytes,
233
+ both in PEM format. It is used to configure a mutual TLS channel. It is
234
+ ignored if a ``channel`` instance or ``ssl_channel_credentials`` is provided.
235
+ quota_project_id (Optional[str]): An optional project to use for billing
236
+ and quota.
237
+ client_info (google.api_core.gapic_v1.client_info.ClientInfo):
238
+ The client info used to send a user-agent string along with
239
+ API requests. If ``None``, then default info will be used.
240
+ Generally, you only need to set this if you're developing
241
+ your own client library.
242
+ always_use_jwt_access (Optional[bool]): Whether self signed JWT should
243
+ be used for service account credentials.
244
+
245
+ Raises:
246
+ google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport
247
+ creation failed for any reason.
248
+ google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials``
249
+ and ``credentials_file`` are passed.
250
+ """
251
+ self._grpc_channel = None
252
+ self._ssl_channel_credentials = ssl_channel_credentials
253
+ self._stubs: Dict[str, Callable] = {}
254
+
255
+ if api_mtls_endpoint:
256
+ warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning)
257
+ if client_cert_source:
258
+ warnings.warn("client_cert_source is deprecated", DeprecationWarning)
259
+
260
+ if isinstance(channel, aio.Channel):
261
+ # Ignore credentials if a channel was passed.
262
+ credentials = None
263
+ self._ignore_credentials = True
264
+ # If a channel was explicitly provided, set it.
265
+ self._grpc_channel = channel
266
+ self._ssl_channel_credentials = None
267
+ else:
268
+ if api_mtls_endpoint:
269
+ host = api_mtls_endpoint
270
+
271
+ # Create SSL credentials with client_cert_source or application
272
+ # default SSL credentials.
273
+ if client_cert_source:
274
+ cert, key = client_cert_source()
275
+ self._ssl_channel_credentials = grpc.ssl_channel_credentials(
276
+ certificate_chain=cert, private_key=key
277
+ )
278
+ else:
279
+ self._ssl_channel_credentials = SslCredentials().ssl_credentials
280
+
281
+ else:
282
+ if client_cert_source_for_mtls and not ssl_channel_credentials:
283
+ cert, key = client_cert_source_for_mtls()
284
+ self._ssl_channel_credentials = grpc.ssl_channel_credentials(
285
+ certificate_chain=cert, private_key=key
286
+ )
287
+
288
+ # The base transport sets the host, credentials and scopes
289
+ super().__init__(
290
+ host=host,
291
+ credentials=credentials,
292
+ credentials_file=credentials_file,
293
+ scopes=scopes,
294
+ quota_project_id=quota_project_id,
295
+ client_info=client_info,
296
+ always_use_jwt_access=always_use_jwt_access,
297
+ api_audience=api_audience,
298
+ )
299
+
300
+ if not self._grpc_channel:
301
+ # initialize with the provided callable or the default channel
302
+ channel_init = channel or type(self).create_channel
303
+ self._grpc_channel = channel_init(
304
+ self._host,
305
+ # use the credentials which are saved
306
+ credentials=self._credentials,
307
+ # Set ``credentials_file`` to ``None`` here as
308
+ # the credentials that we saved earlier should be used.
309
+ credentials_file=None,
310
+ scopes=self._scopes,
311
+ ssl_credentials=self._ssl_channel_credentials,
312
+ quota_project_id=quota_project_id,
313
+ options=[
314
+ ("grpc.max_send_message_length", -1),
315
+ ("grpc.max_receive_message_length", -1),
316
+ ],
317
+ )
318
+
319
+ self._interceptor = _LoggingClientAIOInterceptor()
320
+ self._grpc_channel._unary_unary_interceptors.append(self._interceptor)
321
+ self._logged_channel = self._grpc_channel
322
+ self._wrap_with_kind = (
323
+ "kind" in inspect.signature(gapic_v1.method_async.wrap_method).parameters
324
+ )
325
+ # Wrap messages. This must be done after self._logged_channel exists
326
+ self._prep_wrapped_messages(client_info)
327
+
328
+ @property
329
+ def grpc_channel(self) -> aio.Channel:
330
+ """Create the channel designed to connect to this service.
331
+
332
+ This property caches on the instance; repeated calls return
333
+ the same channel.
334
+ """
335
+ # Return the channel from cache.
336
+ return self._grpc_channel
337
+
338
+ @property
339
+ def count_tokens(
340
+ self,
341
+ ) -> Callable[
342
+ [prediction_service.CountTokensRequest],
343
+ Awaitable[prediction_service.CountTokensResponse],
344
+ ]:
345
+ r"""Return a callable for the count tokens method over gRPC.
346
+
347
+ Perform a token counting.
348
+
349
+ Returns:
350
+ Callable[[~.CountTokensRequest],
351
+ Awaitable[~.CountTokensResponse]]:
352
+ A function that, when called, will call the underlying RPC
353
+ on the server.
354
+ """
355
+ # Generate a "stub function" on-the-fly which will actually make
356
+ # the request.
357
+ # gRPC handles serialization and deserialization, so we just need
358
+ # to pass in the functions for each.
359
+ if "count_tokens" not in self._stubs:
360
+ self._stubs["count_tokens"] = self._logged_channel.unary_unary(
361
+ "/google.cloud.aiplatform.v1.LlmUtilityService/CountTokens",
362
+ request_serializer=prediction_service.CountTokensRequest.serialize,
363
+ response_deserializer=prediction_service.CountTokensResponse.deserialize,
364
+ )
365
+ return self._stubs["count_tokens"]
366
+
367
+ @property
368
+ def compute_tokens(
369
+ self,
370
+ ) -> Callable[
371
+ [llm_utility_service.ComputeTokensRequest],
372
+ Awaitable[llm_utility_service.ComputeTokensResponse],
373
+ ]:
374
+ r"""Return a callable for the compute tokens method over gRPC.
375
+
376
+ Return a list of tokens based on the input text.
377
+
378
+ Returns:
379
+ Callable[[~.ComputeTokensRequest],
380
+ Awaitable[~.ComputeTokensResponse]]:
381
+ A function that, when called, will call the underlying RPC
382
+ on the server.
383
+ """
384
+ # Generate a "stub function" on-the-fly which will actually make
385
+ # the request.
386
+ # gRPC handles serialization and deserialization, so we just need
387
+ # to pass in the functions for each.
388
+ if "compute_tokens" not in self._stubs:
389
+ self._stubs["compute_tokens"] = self._logged_channel.unary_unary(
390
+ "/google.cloud.aiplatform.v1.LlmUtilityService/ComputeTokens",
391
+ request_serializer=llm_utility_service.ComputeTokensRequest.serialize,
392
+ response_deserializer=llm_utility_service.ComputeTokensResponse.deserialize,
393
+ )
394
+ return self._stubs["compute_tokens"]
395
+
396
+ def _prep_wrapped_messages(self, client_info):
397
+ """Precompute the wrapped methods, overriding the base class method to use async wrappers."""
398
+ self._wrapped_methods = {
399
+ self.count_tokens: self._wrap_method(
400
+ self.count_tokens,
401
+ default_timeout=None,
402
+ client_info=client_info,
403
+ ),
404
+ self.compute_tokens: self._wrap_method(
405
+ self.compute_tokens,
406
+ default_timeout=None,
407
+ client_info=client_info,
408
+ ),
409
+ self.get_location: self._wrap_method(
410
+ self.get_location,
411
+ default_timeout=None,
412
+ client_info=client_info,
413
+ ),
414
+ self.list_locations: self._wrap_method(
415
+ self.list_locations,
416
+ default_timeout=None,
417
+ client_info=client_info,
418
+ ),
419
+ self.get_iam_policy: self._wrap_method(
420
+ self.get_iam_policy,
421
+ default_timeout=None,
422
+ client_info=client_info,
423
+ ),
424
+ self.set_iam_policy: self._wrap_method(
425
+ self.set_iam_policy,
426
+ default_timeout=None,
427
+ client_info=client_info,
428
+ ),
429
+ self.test_iam_permissions: self._wrap_method(
430
+ self.test_iam_permissions,
431
+ default_timeout=None,
432
+ client_info=client_info,
433
+ ),
434
+ self.cancel_operation: self._wrap_method(
435
+ self.cancel_operation,
436
+ default_timeout=None,
437
+ client_info=client_info,
438
+ ),
439
+ self.delete_operation: self._wrap_method(
440
+ self.delete_operation,
441
+ default_timeout=None,
442
+ client_info=client_info,
443
+ ),
444
+ self.get_operation: self._wrap_method(
445
+ self.get_operation,
446
+ default_timeout=None,
447
+ client_info=client_info,
448
+ ),
449
+ self.list_operations: self._wrap_method(
450
+ self.list_operations,
451
+ default_timeout=None,
452
+ client_info=client_info,
453
+ ),
454
+ self.wait_operation: self._wrap_method(
455
+ self.wait_operation,
456
+ default_timeout=None,
457
+ client_info=client_info,
458
+ ),
459
+ }
460
+
461
+ def _wrap_method(self, func, *args, **kwargs):
462
+ if self._wrap_with_kind: # pragma: NO COVER
463
+ kwargs["kind"] = self.kind
464
+ return gapic_v1.method_async.wrap_method(func, *args, **kwargs)
465
+
466
+ def close(self):
467
+ return self._logged_channel.close()
468
+
469
+ @property
470
+ def kind(self) -> str:
471
+ return "grpc_asyncio"
472
+
473
+ @property
474
+ def delete_operation(
475
+ self,
476
+ ) -> Callable[[operations_pb2.DeleteOperationRequest], None]:
477
+ r"""Return a callable for the delete_operation method over gRPC."""
478
+ # Generate a "stub function" on-the-fly which will actually make
479
+ # the request.
480
+ # gRPC handles serialization and deserialization, so we just need
481
+ # to pass in the functions for each.
482
+ if "delete_operation" not in self._stubs:
483
+ self._stubs["delete_operation"] = self._logged_channel.unary_unary(
484
+ "/google.longrunning.Operations/DeleteOperation",
485
+ request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString,
486
+ response_deserializer=None,
487
+ )
488
+ return self._stubs["delete_operation"]
489
+
490
+ @property
491
+ def cancel_operation(
492
+ self,
493
+ ) -> Callable[[operations_pb2.CancelOperationRequest], None]:
494
+ r"""Return a callable for the cancel_operation method over gRPC."""
495
+ # Generate a "stub function" on-the-fly which will actually make
496
+ # the request.
497
+ # gRPC handles serialization and deserialization, so we just need
498
+ # to pass in the functions for each.
499
+ if "cancel_operation" not in self._stubs:
500
+ self._stubs["cancel_operation"] = self._logged_channel.unary_unary(
501
+ "/google.longrunning.Operations/CancelOperation",
502
+ request_serializer=operations_pb2.CancelOperationRequest.SerializeToString,
503
+ response_deserializer=None,
504
+ )
505
+ return self._stubs["cancel_operation"]
506
+
507
+ @property
508
+ def wait_operation(
509
+ self,
510
+ ) -> Callable[[operations_pb2.WaitOperationRequest], None]:
511
+ r"""Return a callable for the wait_operation method over gRPC."""
512
+ # Generate a "stub function" on-the-fly which will actually make
513
+ # the request.
514
+ # gRPC handles serialization and deserialization, so we just need
515
+ # to pass in the functions for each.
516
+ if "wait_operation" not in self._stubs:
517
+ self._stubs["wait_operation"] = self._logged_channel.unary_unary(
518
+ "/google.longrunning.Operations/WaitOperation",
519
+ request_serializer=operations_pb2.WaitOperationRequest.SerializeToString,
520
+ response_deserializer=None,
521
+ )
522
+ return self._stubs["wait_operation"]
523
+
524
+ @property
525
+ def get_operation(
526
+ self,
527
+ ) -> Callable[[operations_pb2.GetOperationRequest], operations_pb2.Operation]:
528
+ r"""Return a callable for the get_operation method over gRPC."""
529
+ # Generate a "stub function" on-the-fly which will actually make
530
+ # the request.
531
+ # gRPC handles serialization and deserialization, so we just need
532
+ # to pass in the functions for each.
533
+ if "get_operation" not in self._stubs:
534
+ self._stubs["get_operation"] = self._logged_channel.unary_unary(
535
+ "/google.longrunning.Operations/GetOperation",
536
+ request_serializer=operations_pb2.GetOperationRequest.SerializeToString,
537
+ response_deserializer=operations_pb2.Operation.FromString,
538
+ )
539
+ return self._stubs["get_operation"]
540
+
541
+ @property
542
+ def list_operations(
543
+ self,
544
+ ) -> Callable[
545
+ [operations_pb2.ListOperationsRequest], operations_pb2.ListOperationsResponse
546
+ ]:
547
+ r"""Return a callable for the list_operations method over gRPC."""
548
+ # Generate a "stub function" on-the-fly which will actually make
549
+ # the request.
550
+ # gRPC handles serialization and deserialization, so we just need
551
+ # to pass in the functions for each.
552
+ if "list_operations" not in self._stubs:
553
+ self._stubs["list_operations"] = self._logged_channel.unary_unary(
554
+ "/google.longrunning.Operations/ListOperations",
555
+ request_serializer=operations_pb2.ListOperationsRequest.SerializeToString,
556
+ response_deserializer=operations_pb2.ListOperationsResponse.FromString,
557
+ )
558
+ return self._stubs["list_operations"]
559
+
560
+ @property
561
+ def list_locations(
562
+ self,
563
+ ) -> Callable[
564
+ [locations_pb2.ListLocationsRequest], locations_pb2.ListLocationsResponse
565
+ ]:
566
+ r"""Return a callable for the list locations method over gRPC."""
567
+ # Generate a "stub function" on-the-fly which will actually make
568
+ # the request.
569
+ # gRPC handles serialization and deserialization, so we just need
570
+ # to pass in the functions for each.
571
+ if "list_locations" not in self._stubs:
572
+ self._stubs["list_locations"] = self._logged_channel.unary_unary(
573
+ "/google.cloud.location.Locations/ListLocations",
574
+ request_serializer=locations_pb2.ListLocationsRequest.SerializeToString,
575
+ response_deserializer=locations_pb2.ListLocationsResponse.FromString,
576
+ )
577
+ return self._stubs["list_locations"]
578
+
579
+ @property
580
+ def get_location(
581
+ self,
582
+ ) -> Callable[[locations_pb2.GetLocationRequest], locations_pb2.Location]:
583
+ r"""Return a callable for the list locations method over gRPC."""
584
+ # Generate a "stub function" on-the-fly which will actually make
585
+ # the request.
586
+ # gRPC handles serialization and deserialization, so we just need
587
+ # to pass in the functions for each.
588
+ if "get_location" not in self._stubs:
589
+ self._stubs["get_location"] = self._logged_channel.unary_unary(
590
+ "/google.cloud.location.Locations/GetLocation",
591
+ request_serializer=locations_pb2.GetLocationRequest.SerializeToString,
592
+ response_deserializer=locations_pb2.Location.FromString,
593
+ )
594
+ return self._stubs["get_location"]
595
+
596
+ @property
597
+ def set_iam_policy(
598
+ self,
599
+ ) -> Callable[[iam_policy_pb2.SetIamPolicyRequest], policy_pb2.Policy]:
600
+ r"""Return a callable for the set iam policy method over gRPC.
601
+ Sets the IAM access control policy on the specified
602
+ function. Replaces any existing policy.
603
+ Returns:
604
+ Callable[[~.SetIamPolicyRequest],
605
+ ~.Policy]:
606
+ A function that, when called, will call the underlying RPC
607
+ on the server.
608
+ """
609
+ # Generate a "stub function" on-the-fly which will actually make
610
+ # the request.
611
+ # gRPC handles serialization and deserialization, so we just need
612
+ # to pass in the functions for each.
613
+ if "set_iam_policy" not in self._stubs:
614
+ self._stubs["set_iam_policy"] = self._logged_channel.unary_unary(
615
+ "/google.iam.v1.IAMPolicy/SetIamPolicy",
616
+ request_serializer=iam_policy_pb2.SetIamPolicyRequest.SerializeToString,
617
+ response_deserializer=policy_pb2.Policy.FromString,
618
+ )
619
+ return self._stubs["set_iam_policy"]
620
+
621
+ @property
622
+ def get_iam_policy(
623
+ self,
624
+ ) -> Callable[[iam_policy_pb2.GetIamPolicyRequest], policy_pb2.Policy]:
625
+ r"""Return a callable for the get iam policy method over gRPC.
626
+ Gets the IAM access control policy for a function.
627
+ Returns an empty policy if the function exists and does
628
+ not have a policy set.
629
+ Returns:
630
+ Callable[[~.GetIamPolicyRequest],
631
+ ~.Policy]:
632
+ A function that, when called, will call the underlying RPC
633
+ on the server.
634
+ """
635
+ # Generate a "stub function" on-the-fly which will actually make
636
+ # the request.
637
+ # gRPC handles serialization and deserialization, so we just need
638
+ # to pass in the functions for each.
639
+ if "get_iam_policy" not in self._stubs:
640
+ self._stubs["get_iam_policy"] = self._logged_channel.unary_unary(
641
+ "/google.iam.v1.IAMPolicy/GetIamPolicy",
642
+ request_serializer=iam_policy_pb2.GetIamPolicyRequest.SerializeToString,
643
+ response_deserializer=policy_pb2.Policy.FromString,
644
+ )
645
+ return self._stubs["get_iam_policy"]
646
+
647
+ @property
648
+ def test_iam_permissions(
649
+ self,
650
+ ) -> Callable[
651
+ [iam_policy_pb2.TestIamPermissionsRequest],
652
+ iam_policy_pb2.TestIamPermissionsResponse,
653
+ ]:
654
+ r"""Return a callable for the test iam permissions method over gRPC.
655
+ Tests the specified permissions against the IAM access control
656
+ policy for a function. If the function does not exist, this will
657
+ return an empty set of permissions, not a NOT_FOUND error.
658
+ Returns:
659
+ Callable[[~.TestIamPermissionsRequest],
660
+ ~.TestIamPermissionsResponse]:
661
+ A function that, when called, will call the underlying RPC
662
+ on the server.
663
+ """
664
+ # Generate a "stub function" on-the-fly which will actually make
665
+ # the request.
666
+ # gRPC handles serialization and deserialization, so we just need
667
+ # to pass in the functions for each.
668
+ if "test_iam_permissions" not in self._stubs:
669
+ self._stubs["test_iam_permissions"] = self._logged_channel.unary_unary(
670
+ "/google.iam.v1.IAMPolicy/TestIamPermissions",
671
+ request_serializer=iam_policy_pb2.TestIamPermissionsRequest.SerializeToString,
672
+ response_deserializer=iam_policy_pb2.TestIamPermissionsResponse.FromString,
673
+ )
674
+ return self._stubs["test_iam_permissions"]
675
+
676
+
677
+ __all__ = ("LlmUtilityServiceGrpcAsyncIOTransport",)
loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/llm_utility_service/transports/rest.py ADDED
@@ -0,0 +1,2252 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright 2025 Google LLC
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+ import logging
17
+ import json # type: ignore
18
+
19
+ from google.auth.transport.requests import AuthorizedSession # type: ignore
20
+ from google.auth import credentials as ga_credentials # type: ignore
21
+ from google.api_core import exceptions as core_exceptions
22
+ from google.api_core import retry as retries
23
+ from google.api_core import rest_helpers
24
+ from google.api_core import rest_streaming
25
+ from google.api_core import gapic_v1
26
+ import google.protobuf
27
+
28
+ from google.protobuf import json_format
29
+ from google.iam.v1 import iam_policy_pb2 # type: ignore
30
+ from google.iam.v1 import policy_pb2 # type: ignore
31
+ from google.cloud.location import locations_pb2 # type: ignore
32
+
33
+ from requests import __version__ as requests_version
34
+ import dataclasses
35
+ from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union
36
+ import warnings
37
+
38
+
39
+ from google.cloud.aiplatform_v1.types import llm_utility_service
40
+ from google.cloud.aiplatform_v1.types import prediction_service
41
+ from google.longrunning import operations_pb2 # type: ignore
42
+
43
+
44
+ from .rest_base import _BaseLlmUtilityServiceRestTransport
45
+ from .base import DEFAULT_CLIENT_INFO as BASE_DEFAULT_CLIENT_INFO
46
+
47
+ try:
48
+ OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault, None]
49
+ except AttributeError: # pragma: NO COVER
50
+ OptionalRetry = Union[retries.Retry, object, None] # type: ignore
51
+
52
+ try:
53
+ from google.api_core import client_logging # type: ignore
54
+
55
+ CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER
56
+ except ImportError: # pragma: NO COVER
57
+ CLIENT_LOGGING_SUPPORTED = False
58
+
59
+ _LOGGER = logging.getLogger(__name__)
60
+
61
+ DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
62
+ gapic_version=BASE_DEFAULT_CLIENT_INFO.gapic_version,
63
+ grpc_version=None,
64
+ rest_version=f"requests@{requests_version}",
65
+ )
66
+
67
+ if hasattr(DEFAULT_CLIENT_INFO, "protobuf_runtime_version"): # pragma: NO COVER
68
+ DEFAULT_CLIENT_INFO.protobuf_runtime_version = google.protobuf.__version__
69
+
70
+
71
+ class LlmUtilityServiceRestInterceptor:
72
+ """Interceptor for LlmUtilityService.
73
+
74
+ Interceptors are used to manipulate requests, request metadata, and responses
75
+ in arbitrary ways.
76
+ Example use cases include:
77
+ * Logging
78
+ * Verifying requests according to service or custom semantics
79
+ * Stripping extraneous information from responses
80
+
81
+ These use cases and more can be enabled by injecting an
82
+ instance of a custom subclass when constructing the LlmUtilityServiceRestTransport.
83
+
84
+ .. code-block:: python
85
+ class MyCustomLlmUtilityServiceInterceptor(LlmUtilityServiceRestInterceptor):
86
+ def pre_compute_tokens(self, request, metadata):
87
+ logging.log(f"Received request: {request}")
88
+ return request, metadata
89
+
90
+ def post_compute_tokens(self, response):
91
+ logging.log(f"Received response: {response}")
92
+ return response
93
+
94
+ def pre_count_tokens(self, request, metadata):
95
+ logging.log(f"Received request: {request}")
96
+ return request, metadata
97
+
98
+ def post_count_tokens(self, response):
99
+ logging.log(f"Received response: {response}")
100
+ return response
101
+
102
+ transport = LlmUtilityServiceRestTransport(interceptor=MyCustomLlmUtilityServiceInterceptor())
103
+ client = LlmUtilityServiceClient(transport=transport)
104
+
105
+
106
+ """
107
+
108
+ def pre_compute_tokens(
109
+ self,
110
+ request: llm_utility_service.ComputeTokensRequest,
111
+ metadata: Sequence[Tuple[str, Union[str, bytes]]],
112
+ ) -> Tuple[
113
+ llm_utility_service.ComputeTokensRequest,
114
+ Sequence[Tuple[str, Union[str, bytes]]],
115
+ ]:
116
+ """Pre-rpc interceptor for compute_tokens
117
+
118
+ Override in a subclass to manipulate the request or metadata
119
+ before they are sent to the LlmUtilityService server.
120
+ """
121
+ return request, metadata
122
+
123
+ def post_compute_tokens(
124
+ self, response: llm_utility_service.ComputeTokensResponse
125
+ ) -> llm_utility_service.ComputeTokensResponse:
126
+ """Post-rpc interceptor for compute_tokens
127
+
128
+ DEPRECATED. Please use the `post_compute_tokens_with_metadata`
129
+ interceptor instead.
130
+
131
+ Override in a subclass to read or manipulate the response
132
+ after it is returned by the LlmUtilityService server but before
133
+ it is returned to user code. This `post_compute_tokens` interceptor runs
134
+ before the `post_compute_tokens_with_metadata` interceptor.
135
+ """
136
+ return response
137
+
138
+ def post_compute_tokens_with_metadata(
139
+ self,
140
+ response: llm_utility_service.ComputeTokensResponse,
141
+ metadata: Sequence[Tuple[str, Union[str, bytes]]],
142
+ ) -> Tuple[
143
+ llm_utility_service.ComputeTokensResponse,
144
+ Sequence[Tuple[str, Union[str, bytes]]],
145
+ ]:
146
+ """Post-rpc interceptor for compute_tokens
147
+
148
+ Override in a subclass to read or manipulate the response or metadata after it
149
+ is returned by the LlmUtilityService server but before it is returned to user code.
150
+
151
+ We recommend only using this `post_compute_tokens_with_metadata`
152
+ interceptor in new development instead of the `post_compute_tokens` interceptor.
153
+ When both interceptors are used, this `post_compute_tokens_with_metadata` interceptor runs after the
154
+ `post_compute_tokens` interceptor. The (possibly modified) response returned by
155
+ `post_compute_tokens` will be passed to
156
+ `post_compute_tokens_with_metadata`.
157
+ """
158
+ return response, metadata
159
+
160
+ def pre_count_tokens(
161
+ self,
162
+ request: prediction_service.CountTokensRequest,
163
+ metadata: Sequence[Tuple[str, Union[str, bytes]]],
164
+ ) -> Tuple[
165
+ prediction_service.CountTokensRequest, Sequence[Tuple[str, Union[str, bytes]]]
166
+ ]:
167
+ """Pre-rpc interceptor for count_tokens
168
+
169
+ Override in a subclass to manipulate the request or metadata
170
+ before they are sent to the LlmUtilityService server.
171
+ """
172
+ return request, metadata
173
+
174
+ def post_count_tokens(
175
+ self, response: prediction_service.CountTokensResponse
176
+ ) -> prediction_service.CountTokensResponse:
177
+ """Post-rpc interceptor for count_tokens
178
+
179
+ DEPRECATED. Please use the `post_count_tokens_with_metadata`
180
+ interceptor instead.
181
+
182
+ Override in a subclass to read or manipulate the response
183
+ after it is returned by the LlmUtilityService server but before
184
+ it is returned to user code. This `post_count_tokens` interceptor runs
185
+ before the `post_count_tokens_with_metadata` interceptor.
186
+ """
187
+ return response
188
+
189
+ def post_count_tokens_with_metadata(
190
+ self,
191
+ response: prediction_service.CountTokensResponse,
192
+ metadata: Sequence[Tuple[str, Union[str, bytes]]],
193
+ ) -> Tuple[
194
+ prediction_service.CountTokensResponse, Sequence[Tuple[str, Union[str, bytes]]]
195
+ ]:
196
+ """Post-rpc interceptor for count_tokens
197
+
198
+ Override in a subclass to read or manipulate the response or metadata after it
199
+ is returned by the LlmUtilityService server but before it is returned to user code.
200
+
201
+ We recommend only using this `post_count_tokens_with_metadata`
202
+ interceptor in new development instead of the `post_count_tokens` interceptor.
203
+ When both interceptors are used, this `post_count_tokens_with_metadata` interceptor runs after the
204
+ `post_count_tokens` interceptor. The (possibly modified) response returned by
205
+ `post_count_tokens` will be passed to
206
+ `post_count_tokens_with_metadata`.
207
+ """
208
+ return response, metadata
209
+
210
+ def pre_get_location(
211
+ self,
212
+ request: locations_pb2.GetLocationRequest,
213
+ metadata: Sequence[Tuple[str, Union[str, bytes]]],
214
+ ) -> Tuple[
215
+ locations_pb2.GetLocationRequest, Sequence[Tuple[str, Union[str, bytes]]]
216
+ ]:
217
+ """Pre-rpc interceptor for get_location
218
+
219
+ Override in a subclass to manipulate the request or metadata
220
+ before they are sent to the LlmUtilityService server.
221
+ """
222
+ return request, metadata
223
+
224
+ def post_get_location(
225
+ self, response: locations_pb2.Location
226
+ ) -> locations_pb2.Location:
227
+ """Post-rpc interceptor for get_location
228
+
229
+ Override in a subclass to manipulate the response
230
+ after it is returned by the LlmUtilityService server but before
231
+ it is returned to user code.
232
+ """
233
+ return response
234
+
235
+ def pre_list_locations(
236
+ self,
237
+ request: locations_pb2.ListLocationsRequest,
238
+ metadata: Sequence[Tuple[str, Union[str, bytes]]],
239
+ ) -> Tuple[
240
+ locations_pb2.ListLocationsRequest, Sequence[Tuple[str, Union[str, bytes]]]
241
+ ]:
242
+ """Pre-rpc interceptor for list_locations
243
+
244
+ Override in a subclass to manipulate the request or metadata
245
+ before they are sent to the LlmUtilityService server.
246
+ """
247
+ return request, metadata
248
+
249
+ def post_list_locations(
250
+ self, response: locations_pb2.ListLocationsResponse
251
+ ) -> locations_pb2.ListLocationsResponse:
252
+ """Post-rpc interceptor for list_locations
253
+
254
+ Override in a subclass to manipulate the response
255
+ after it is returned by the LlmUtilityService server but before
256
+ it is returned to user code.
257
+ """
258
+ return response
259
+
260
+ def pre_get_iam_policy(
261
+ self,
262
+ request: iam_policy_pb2.GetIamPolicyRequest,
263
+ metadata: Sequence[Tuple[str, Union[str, bytes]]],
264
+ ) -> Tuple[
265
+ iam_policy_pb2.GetIamPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]]
266
+ ]:
267
+ """Pre-rpc interceptor for get_iam_policy
268
+
269
+ Override in a subclass to manipulate the request or metadata
270
+ before they are sent to the LlmUtilityService server.
271
+ """
272
+ return request, metadata
273
+
274
+ def post_get_iam_policy(self, response: policy_pb2.Policy) -> policy_pb2.Policy:
275
+ """Post-rpc interceptor for get_iam_policy
276
+
277
+ Override in a subclass to manipulate the response
278
+ after it is returned by the LlmUtilityService server but before
279
+ it is returned to user code.
280
+ """
281
+ return response
282
+
283
+ def pre_set_iam_policy(
284
+ self,
285
+ request: iam_policy_pb2.SetIamPolicyRequest,
286
+ metadata: Sequence[Tuple[str, Union[str, bytes]]],
287
+ ) -> Tuple[
288
+ iam_policy_pb2.SetIamPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]]
289
+ ]:
290
+ """Pre-rpc interceptor for set_iam_policy
291
+
292
+ Override in a subclass to manipulate the request or metadata
293
+ before they are sent to the LlmUtilityService server.
294
+ """
295
+ return request, metadata
296
+
297
+ def post_set_iam_policy(self, response: policy_pb2.Policy) -> policy_pb2.Policy:
298
+ """Post-rpc interceptor for set_iam_policy
299
+
300
+ Override in a subclass to manipulate the response
301
+ after it is returned by the LlmUtilityService server but before
302
+ it is returned to user code.
303
+ """
304
+ return response
305
+
306
+ def pre_test_iam_permissions(
307
+ self,
308
+ request: iam_policy_pb2.TestIamPermissionsRequest,
309
+ metadata: Sequence[Tuple[str, Union[str, bytes]]],
310
+ ) -> Tuple[
311
+ iam_policy_pb2.TestIamPermissionsRequest,
312
+ Sequence[Tuple[str, Union[str, bytes]]],
313
+ ]:
314
+ """Pre-rpc interceptor for test_iam_permissions
315
+
316
+ Override in a subclass to manipulate the request or metadata
317
+ before they are sent to the LlmUtilityService server.
318
+ """
319
+ return request, metadata
320
+
321
+ def post_test_iam_permissions(
322
+ self, response: iam_policy_pb2.TestIamPermissionsResponse
323
+ ) -> iam_policy_pb2.TestIamPermissionsResponse:
324
+ """Post-rpc interceptor for test_iam_permissions
325
+
326
+ Override in a subclass to manipulate the response
327
+ after it is returned by the LlmUtilityService server but before
328
+ it is returned to user code.
329
+ """
330
+ return response
331
+
332
+ def pre_cancel_operation(
333
+ self,
334
+ request: operations_pb2.CancelOperationRequest,
335
+ metadata: Sequence[Tuple[str, Union[str, bytes]]],
336
+ ) -> Tuple[
337
+ operations_pb2.CancelOperationRequest, Sequence[Tuple[str, Union[str, bytes]]]
338
+ ]:
339
+ """Pre-rpc interceptor for cancel_operation
340
+
341
+ Override in a subclass to manipulate the request or metadata
342
+ before they are sent to the LlmUtilityService server.
343
+ """
344
+ return request, metadata
345
+
346
+ def post_cancel_operation(self, response: None) -> None:
347
+ """Post-rpc interceptor for cancel_operation
348
+
349
+ Override in a subclass to manipulate the response
350
+ after it is returned by the LlmUtilityService server but before
351
+ it is returned to user code.
352
+ """
353
+ return response
354
+
355
+ def pre_delete_operation(
356
+ self,
357
+ request: operations_pb2.DeleteOperationRequest,
358
+ metadata: Sequence[Tuple[str, Union[str, bytes]]],
359
+ ) -> Tuple[
360
+ operations_pb2.DeleteOperationRequest, Sequence[Tuple[str, Union[str, bytes]]]
361
+ ]:
362
+ """Pre-rpc interceptor for delete_operation
363
+
364
+ Override in a subclass to manipulate the request or metadata
365
+ before they are sent to the LlmUtilityService server.
366
+ """
367
+ return request, metadata
368
+
369
+ def post_delete_operation(self, response: None) -> None:
370
+ """Post-rpc interceptor for delete_operation
371
+
372
+ Override in a subclass to manipulate the response
373
+ after it is returned by the LlmUtilityService server but before
374
+ it is returned to user code.
375
+ """
376
+ return response
377
+
378
+ def pre_get_operation(
379
+ self,
380
+ request: operations_pb2.GetOperationRequest,
381
+ metadata: Sequence[Tuple[str, Union[str, bytes]]],
382
+ ) -> Tuple[
383
+ operations_pb2.GetOperationRequest, Sequence[Tuple[str, Union[str, bytes]]]
384
+ ]:
385
+ """Pre-rpc interceptor for get_operation
386
+
387
+ Override in a subclass to manipulate the request or metadata
388
+ before they are sent to the LlmUtilityService server.
389
+ """
390
+ return request, metadata
391
+
392
+ def post_get_operation(
393
+ self, response: operations_pb2.Operation
394
+ ) -> operations_pb2.Operation:
395
+ """Post-rpc interceptor for get_operation
396
+
397
+ Override in a subclass to manipulate the response
398
+ after it is returned by the LlmUtilityService server but before
399
+ it is returned to user code.
400
+ """
401
+ return response
402
+
403
+ def pre_list_operations(
404
+ self,
405
+ request: operations_pb2.ListOperationsRequest,
406
+ metadata: Sequence[Tuple[str, Union[str, bytes]]],
407
+ ) -> Tuple[
408
+ operations_pb2.ListOperationsRequest, Sequence[Tuple[str, Union[str, bytes]]]
409
+ ]:
410
+ """Pre-rpc interceptor for list_operations
411
+
412
+ Override in a subclass to manipulate the request or metadata
413
+ before they are sent to the LlmUtilityService server.
414
+ """
415
+ return request, metadata
416
+
417
+ def post_list_operations(
418
+ self, response: operations_pb2.ListOperationsResponse
419
+ ) -> operations_pb2.ListOperationsResponse:
420
+ """Post-rpc interceptor for list_operations
421
+
422
+ Override in a subclass to manipulate the response
423
+ after it is returned by the LlmUtilityService server but before
424
+ it is returned to user code.
425
+ """
426
+ return response
427
+
428
+ def pre_wait_operation(
429
+ self,
430
+ request: operations_pb2.WaitOperationRequest,
431
+ metadata: Sequence[Tuple[str, Union[str, bytes]]],
432
+ ) -> Tuple[
433
+ operations_pb2.WaitOperationRequest, Sequence[Tuple[str, Union[str, bytes]]]
434
+ ]:
435
+ """Pre-rpc interceptor for wait_operation
436
+
437
+ Override in a subclass to manipulate the request or metadata
438
+ before they are sent to the LlmUtilityService server.
439
+ """
440
+ return request, metadata
441
+
442
+ def post_wait_operation(
443
+ self, response: operations_pb2.Operation
444
+ ) -> operations_pb2.Operation:
445
+ """Post-rpc interceptor for wait_operation
446
+
447
+ Override in a subclass to manipulate the response
448
+ after it is returned by the LlmUtilityService server but before
449
+ it is returned to user code.
450
+ """
451
+ return response
452
+
453
+
454
+ @dataclasses.dataclass
455
+ class LlmUtilityServiceRestStub:
456
+ _session: AuthorizedSession
457
+ _host: str
458
+ _interceptor: LlmUtilityServiceRestInterceptor
459
+
460
+
461
+ class LlmUtilityServiceRestTransport(_BaseLlmUtilityServiceRestTransport):
462
+ """REST backend synchronous transport for LlmUtilityService.
463
+
464
+ Service for LLM related utility functions.
465
+
466
+ This class defines the same methods as the primary client, so the
467
+ primary client can load the underlying transport implementation
468
+ and call it.
469
+
470
+ It sends JSON representations of protocol buffers over HTTP/1.1
471
+ """
472
+
473
+ def __init__(
474
+ self,
475
+ *,
476
+ host: str = "aiplatform.googleapis.com",
477
+ credentials: Optional[ga_credentials.Credentials] = None,
478
+ credentials_file: Optional[str] = None,
479
+ scopes: Optional[Sequence[str]] = None,
480
+ client_cert_source_for_mtls: Optional[Callable[[], Tuple[bytes, bytes]]] = None,
481
+ quota_project_id: Optional[str] = None,
482
+ client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
483
+ always_use_jwt_access: Optional[bool] = False,
484
+ url_scheme: str = "https",
485
+ interceptor: Optional[LlmUtilityServiceRestInterceptor] = None,
486
+ api_audience: Optional[str] = None,
487
+ ) -> None:
488
+ """Instantiate the transport.
489
+
490
+ Args:
491
+ host (Optional[str]):
492
+ The hostname to connect to (default: 'aiplatform.googleapis.com').
493
+ credentials (Optional[google.auth.credentials.Credentials]): The
494
+ authorization credentials to attach to requests. These
495
+ credentials identify the application to the service; if none
496
+ are specified, the client will attempt to ascertain the
497
+ credentials from the environment.
498
+
499
+ credentials_file (Optional[str]): Deprecated. A file with credentials that can
500
+ be loaded with :func:`google.auth.load_credentials_from_file`.
501
+ This argument is ignored if ``channel`` is provided. This argument will be
502
+ removed in the next major version of this library.
503
+ scopes (Optional(Sequence[str])): A list of scopes. This argument is
504
+ ignored if ``channel`` is provided.
505
+ client_cert_source_for_mtls (Callable[[], Tuple[bytes, bytes]]): Client
506
+ certificate to configure mutual TLS HTTP channel. It is ignored
507
+ if ``channel`` is provided.
508
+ quota_project_id (Optional[str]): An optional project to use for billing
509
+ and quota.
510
+ client_info (google.api_core.gapic_v1.client_info.ClientInfo):
511
+ The client info used to send a user-agent string along with
512
+ API requests. If ``None``, then default info will be used.
513
+ Generally, you only need to set this if you are developing
514
+ your own client library.
515
+ always_use_jwt_access (Optional[bool]): Whether self signed JWT should
516
+ be used for service account credentials.
517
+ url_scheme: the protocol scheme for the API endpoint. Normally
518
+ "https", but for testing or local servers,
519
+ "http" can be specified.
520
+ """
521
+ # Run the base constructor
522
+ # TODO(yon-mg): resolve other ctor params i.e. scopes, quota, etc.
523
+ # TODO: When custom host (api_endpoint) is set, `scopes` must *also* be set on the
524
+ # credentials object
525
+ super().__init__(
526
+ host=host,
527
+ credentials=credentials,
528
+ client_info=client_info,
529
+ always_use_jwt_access=always_use_jwt_access,
530
+ url_scheme=url_scheme,
531
+ api_audience=api_audience,
532
+ )
533
+ self._session = AuthorizedSession(
534
+ self._credentials, default_host=self.DEFAULT_HOST
535
+ )
536
+ if client_cert_source_for_mtls:
537
+ self._session.configure_mtls_channel(client_cert_source_for_mtls)
538
+ self._interceptor = interceptor or LlmUtilityServiceRestInterceptor()
539
+ self._prep_wrapped_messages(client_info)
540
+
541
+ class _ComputeTokens(
542
+ _BaseLlmUtilityServiceRestTransport._BaseComputeTokens,
543
+ LlmUtilityServiceRestStub,
544
+ ):
545
+ def __hash__(self):
546
+ return hash("LlmUtilityServiceRestTransport.ComputeTokens")
547
+
548
+ @staticmethod
549
+ def _get_response(
550
+ host,
551
+ metadata,
552
+ query_params,
553
+ session,
554
+ timeout,
555
+ transcoded_request,
556
+ body=None,
557
+ ):
558
+
559
+ uri = transcoded_request["uri"]
560
+ method = transcoded_request["method"]
561
+ headers = dict(metadata)
562
+ headers["Content-Type"] = "application/json"
563
+ response = getattr(session, method)(
564
+ "{host}{uri}".format(host=host, uri=uri),
565
+ timeout=timeout,
566
+ headers=headers,
567
+ params=rest_helpers.flatten_query_params(query_params, strict=True),
568
+ data=body,
569
+ )
570
+ return response
571
+
572
+ def __call__(
573
+ self,
574
+ request: llm_utility_service.ComputeTokensRequest,
575
+ *,
576
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
577
+ timeout: Optional[float] = None,
578
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
579
+ ) -> llm_utility_service.ComputeTokensResponse:
580
+ r"""Call the compute tokens method over HTTP.
581
+
582
+ Args:
583
+ request (~.llm_utility_service.ComputeTokensRequest):
584
+ The request object. Request message for ComputeTokens RPC
585
+ call.
586
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
587
+ should be retried.
588
+ timeout (float): The timeout for this request.
589
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
590
+ sent along with the request as metadata. Normally, each value must be of type `str`,
591
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
592
+ be of type `bytes`.
593
+
594
+ Returns:
595
+ ~.llm_utility_service.ComputeTokensResponse:
596
+ Response message for ComputeTokens
597
+ RPC call.
598
+
599
+ """
600
+
601
+ http_options = (
602
+ _BaseLlmUtilityServiceRestTransport._BaseComputeTokens._get_http_options()
603
+ )
604
+
605
+ request, metadata = self._interceptor.pre_compute_tokens(request, metadata)
606
+ transcoded_request = _BaseLlmUtilityServiceRestTransport._BaseComputeTokens._get_transcoded_request(
607
+ http_options, request
608
+ )
609
+
610
+ body = _BaseLlmUtilityServiceRestTransport._BaseComputeTokens._get_request_body_json(
611
+ transcoded_request
612
+ )
613
+
614
+ # Jsonify the query params
615
+ query_params = _BaseLlmUtilityServiceRestTransport._BaseComputeTokens._get_query_params_json(
616
+ transcoded_request
617
+ )
618
+
619
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
620
+ logging.DEBUG
621
+ ): # pragma: NO COVER
622
+ request_url = "{host}{uri}".format(
623
+ host=self._host, uri=transcoded_request["uri"]
624
+ )
625
+ method = transcoded_request["method"]
626
+ try:
627
+ request_payload = type(request).to_json(request)
628
+ except:
629
+ request_payload = None
630
+ http_request = {
631
+ "payload": request_payload,
632
+ "requestMethod": method,
633
+ "requestUrl": request_url,
634
+ "headers": dict(metadata),
635
+ }
636
+ _LOGGER.debug(
637
+ f"Sending request for google.cloud.aiplatform_v1.LlmUtilityServiceClient.ComputeTokens",
638
+ extra={
639
+ "serviceName": "google.cloud.aiplatform.v1.LlmUtilityService",
640
+ "rpcName": "ComputeTokens",
641
+ "httpRequest": http_request,
642
+ "metadata": http_request["headers"],
643
+ },
644
+ )
645
+
646
+ # Send the request
647
+ response = LlmUtilityServiceRestTransport._ComputeTokens._get_response(
648
+ self._host,
649
+ metadata,
650
+ query_params,
651
+ self._session,
652
+ timeout,
653
+ transcoded_request,
654
+ body,
655
+ )
656
+
657
+ # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
658
+ # subclass.
659
+ if response.status_code >= 400:
660
+ raise core_exceptions.from_http_response(response)
661
+
662
+ # Return the response
663
+ resp = llm_utility_service.ComputeTokensResponse()
664
+ pb_resp = llm_utility_service.ComputeTokensResponse.pb(resp)
665
+
666
+ json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True)
667
+
668
+ resp = self._interceptor.post_compute_tokens(resp)
669
+ response_metadata = [(k, str(v)) for k, v in response.headers.items()]
670
+ resp, _ = self._interceptor.post_compute_tokens_with_metadata(
671
+ resp, response_metadata
672
+ )
673
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
674
+ logging.DEBUG
675
+ ): # pragma: NO COVER
676
+ try:
677
+ response_payload = (
678
+ llm_utility_service.ComputeTokensResponse.to_json(response)
679
+ )
680
+ except:
681
+ response_payload = None
682
+ http_response = {
683
+ "payload": response_payload,
684
+ "headers": dict(response.headers),
685
+ "status": response.status_code,
686
+ }
687
+ _LOGGER.debug(
688
+ "Received response for google.cloud.aiplatform_v1.LlmUtilityServiceClient.compute_tokens",
689
+ extra={
690
+ "serviceName": "google.cloud.aiplatform.v1.LlmUtilityService",
691
+ "rpcName": "ComputeTokens",
692
+ "metadata": http_response["headers"],
693
+ "httpResponse": http_response,
694
+ },
695
+ )
696
+ return resp
697
+
698
+ class _CountTokens(
699
+ _BaseLlmUtilityServiceRestTransport._BaseCountTokens, LlmUtilityServiceRestStub
700
+ ):
701
+ def __hash__(self):
702
+ return hash("LlmUtilityServiceRestTransport.CountTokens")
703
+
704
+ @staticmethod
705
+ def _get_response(
706
+ host,
707
+ metadata,
708
+ query_params,
709
+ session,
710
+ timeout,
711
+ transcoded_request,
712
+ body=None,
713
+ ):
714
+
715
+ uri = transcoded_request["uri"]
716
+ method = transcoded_request["method"]
717
+ headers = dict(metadata)
718
+ headers["Content-Type"] = "application/json"
719
+ response = getattr(session, method)(
720
+ "{host}{uri}".format(host=host, uri=uri),
721
+ timeout=timeout,
722
+ headers=headers,
723
+ params=rest_helpers.flatten_query_params(query_params, strict=True),
724
+ data=body,
725
+ )
726
+ return response
727
+
728
+ def __call__(
729
+ self,
730
+ request: prediction_service.CountTokensRequest,
731
+ *,
732
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
733
+ timeout: Optional[float] = None,
734
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
735
+ ) -> prediction_service.CountTokensResponse:
736
+ r"""Call the count tokens method over HTTP.
737
+
738
+ Args:
739
+ request (~.prediction_service.CountTokensRequest):
740
+ The request object. Request message for [PredictionService.CountTokens][].
741
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
742
+ should be retried.
743
+ timeout (float): The timeout for this request.
744
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
745
+ sent along with the request as metadata. Normally, each value must be of type `str`,
746
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
747
+ be of type `bytes`.
748
+
749
+ Returns:
750
+ ~.prediction_service.CountTokensResponse:
751
+ Response message for [PredictionService.CountTokens][].
752
+ """
753
+
754
+ http_options = (
755
+ _BaseLlmUtilityServiceRestTransport._BaseCountTokens._get_http_options()
756
+ )
757
+
758
+ request, metadata = self._interceptor.pre_count_tokens(request, metadata)
759
+ transcoded_request = _BaseLlmUtilityServiceRestTransport._BaseCountTokens._get_transcoded_request(
760
+ http_options, request
761
+ )
762
+
763
+ body = _BaseLlmUtilityServiceRestTransport._BaseCountTokens._get_request_body_json(
764
+ transcoded_request
765
+ )
766
+
767
+ # Jsonify the query params
768
+ query_params = _BaseLlmUtilityServiceRestTransport._BaseCountTokens._get_query_params_json(
769
+ transcoded_request
770
+ )
771
+
772
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
773
+ logging.DEBUG
774
+ ): # pragma: NO COVER
775
+ request_url = "{host}{uri}".format(
776
+ host=self._host, uri=transcoded_request["uri"]
777
+ )
778
+ method = transcoded_request["method"]
779
+ try:
780
+ request_payload = type(request).to_json(request)
781
+ except:
782
+ request_payload = None
783
+ http_request = {
784
+ "payload": request_payload,
785
+ "requestMethod": method,
786
+ "requestUrl": request_url,
787
+ "headers": dict(metadata),
788
+ }
789
+ _LOGGER.debug(
790
+ f"Sending request for google.cloud.aiplatform_v1.LlmUtilityServiceClient.CountTokens",
791
+ extra={
792
+ "serviceName": "google.cloud.aiplatform.v1.LlmUtilityService",
793
+ "rpcName": "CountTokens",
794
+ "httpRequest": http_request,
795
+ "metadata": http_request["headers"],
796
+ },
797
+ )
798
+
799
+ # Send the request
800
+ response = LlmUtilityServiceRestTransport._CountTokens._get_response(
801
+ self._host,
802
+ metadata,
803
+ query_params,
804
+ self._session,
805
+ timeout,
806
+ transcoded_request,
807
+ body,
808
+ )
809
+
810
+ # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
811
+ # subclass.
812
+ if response.status_code >= 400:
813
+ raise core_exceptions.from_http_response(response)
814
+
815
+ # Return the response
816
+ resp = prediction_service.CountTokensResponse()
817
+ pb_resp = prediction_service.CountTokensResponse.pb(resp)
818
+
819
+ json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True)
820
+
821
+ resp = self._interceptor.post_count_tokens(resp)
822
+ response_metadata = [(k, str(v)) for k, v in response.headers.items()]
823
+ resp, _ = self._interceptor.post_count_tokens_with_metadata(
824
+ resp, response_metadata
825
+ )
826
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
827
+ logging.DEBUG
828
+ ): # pragma: NO COVER
829
+ try:
830
+ response_payload = prediction_service.CountTokensResponse.to_json(
831
+ response
832
+ )
833
+ except:
834
+ response_payload = None
835
+ http_response = {
836
+ "payload": response_payload,
837
+ "headers": dict(response.headers),
838
+ "status": response.status_code,
839
+ }
840
+ _LOGGER.debug(
841
+ "Received response for google.cloud.aiplatform_v1.LlmUtilityServiceClient.count_tokens",
842
+ extra={
843
+ "serviceName": "google.cloud.aiplatform.v1.LlmUtilityService",
844
+ "rpcName": "CountTokens",
845
+ "metadata": http_response["headers"],
846
+ "httpResponse": http_response,
847
+ },
848
+ )
849
+ return resp
850
+
851
+ @property
852
+ def compute_tokens(
853
+ self,
854
+ ) -> Callable[
855
+ [llm_utility_service.ComputeTokensRequest],
856
+ llm_utility_service.ComputeTokensResponse,
857
+ ]:
858
+ # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here.
859
+ # In C++ this would require a dynamic_cast
860
+ return self._ComputeTokens(self._session, self._host, self._interceptor) # type: ignore
861
+
862
+ @property
863
+ def count_tokens(
864
+ self,
865
+ ) -> Callable[
866
+ [prediction_service.CountTokensRequest], prediction_service.CountTokensResponse
867
+ ]:
868
+ # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here.
869
+ # In C++ this would require a dynamic_cast
870
+ return self._CountTokens(self._session, self._host, self._interceptor) # type: ignore
871
+
872
+ @property
873
+ def get_location(self):
874
+ return self._GetLocation(self._session, self._host, self._interceptor) # type: ignore
875
+
876
+ class _GetLocation(
877
+ _BaseLlmUtilityServiceRestTransport._BaseGetLocation, LlmUtilityServiceRestStub
878
+ ):
879
+ def __hash__(self):
880
+ return hash("LlmUtilityServiceRestTransport.GetLocation")
881
+
882
+ @staticmethod
883
+ def _get_response(
884
+ host,
885
+ metadata,
886
+ query_params,
887
+ session,
888
+ timeout,
889
+ transcoded_request,
890
+ body=None,
891
+ ):
892
+
893
+ uri = transcoded_request["uri"]
894
+ method = transcoded_request["method"]
895
+ headers = dict(metadata)
896
+ headers["Content-Type"] = "application/json"
897
+ response = getattr(session, method)(
898
+ "{host}{uri}".format(host=host, uri=uri),
899
+ timeout=timeout,
900
+ headers=headers,
901
+ params=rest_helpers.flatten_query_params(query_params, strict=True),
902
+ )
903
+ return response
904
+
905
+ def __call__(
906
+ self,
907
+ request: locations_pb2.GetLocationRequest,
908
+ *,
909
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
910
+ timeout: Optional[float] = None,
911
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
912
+ ) -> locations_pb2.Location:
913
+ r"""Call the get location method over HTTP.
914
+
915
+ Args:
916
+ request (locations_pb2.GetLocationRequest):
917
+ The request object for GetLocation method.
918
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
919
+ should be retried.
920
+ timeout (float): The timeout for this request.
921
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
922
+ sent along with the request as metadata. Normally, each value must be of type `str`,
923
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
924
+ be of type `bytes`.
925
+
926
+ Returns:
927
+ locations_pb2.Location: Response from GetLocation method.
928
+ """
929
+
930
+ http_options = (
931
+ _BaseLlmUtilityServiceRestTransport._BaseGetLocation._get_http_options()
932
+ )
933
+
934
+ request, metadata = self._interceptor.pre_get_location(request, metadata)
935
+ transcoded_request = _BaseLlmUtilityServiceRestTransport._BaseGetLocation._get_transcoded_request(
936
+ http_options, request
937
+ )
938
+
939
+ # Jsonify the query params
940
+ query_params = _BaseLlmUtilityServiceRestTransport._BaseGetLocation._get_query_params_json(
941
+ transcoded_request
942
+ )
943
+
944
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
945
+ logging.DEBUG
946
+ ): # pragma: NO COVER
947
+ request_url = "{host}{uri}".format(
948
+ host=self._host, uri=transcoded_request["uri"]
949
+ )
950
+ method = transcoded_request["method"]
951
+ try:
952
+ request_payload = json_format.MessageToJson(request)
953
+ except:
954
+ request_payload = None
955
+ http_request = {
956
+ "payload": request_payload,
957
+ "requestMethod": method,
958
+ "requestUrl": request_url,
959
+ "headers": dict(metadata),
960
+ }
961
+ _LOGGER.debug(
962
+ f"Sending request for google.cloud.aiplatform_v1.LlmUtilityServiceClient.GetLocation",
963
+ extra={
964
+ "serviceName": "google.cloud.aiplatform.v1.LlmUtilityService",
965
+ "rpcName": "GetLocation",
966
+ "httpRequest": http_request,
967
+ "metadata": http_request["headers"],
968
+ },
969
+ )
970
+
971
+ # Send the request
972
+ response = LlmUtilityServiceRestTransport._GetLocation._get_response(
973
+ self._host,
974
+ metadata,
975
+ query_params,
976
+ self._session,
977
+ timeout,
978
+ transcoded_request,
979
+ )
980
+
981
+ # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
982
+ # subclass.
983
+ if response.status_code >= 400:
984
+ raise core_exceptions.from_http_response(response)
985
+
986
+ content = response.content.decode("utf-8")
987
+ resp = locations_pb2.Location()
988
+ resp = json_format.Parse(content, resp)
989
+ resp = self._interceptor.post_get_location(resp)
990
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
991
+ logging.DEBUG
992
+ ): # pragma: NO COVER
993
+ try:
994
+ response_payload = json_format.MessageToJson(resp)
995
+ except:
996
+ response_payload = None
997
+ http_response = {
998
+ "payload": response_payload,
999
+ "headers": dict(response.headers),
1000
+ "status": response.status_code,
1001
+ }
1002
+ _LOGGER.debug(
1003
+ "Received response for google.cloud.aiplatform_v1.LlmUtilityServiceAsyncClient.GetLocation",
1004
+ extra={
1005
+ "serviceName": "google.cloud.aiplatform.v1.LlmUtilityService",
1006
+ "rpcName": "GetLocation",
1007
+ "httpResponse": http_response,
1008
+ "metadata": http_response["headers"],
1009
+ },
1010
+ )
1011
+ return resp
1012
+
1013
+ @property
1014
+ def list_locations(self):
1015
+ return self._ListLocations(self._session, self._host, self._interceptor) # type: ignore
1016
+
1017
+ class _ListLocations(
1018
+ _BaseLlmUtilityServiceRestTransport._BaseListLocations,
1019
+ LlmUtilityServiceRestStub,
1020
+ ):
1021
+ def __hash__(self):
1022
+ return hash("LlmUtilityServiceRestTransport.ListLocations")
1023
+
1024
+ @staticmethod
1025
+ def _get_response(
1026
+ host,
1027
+ metadata,
1028
+ query_params,
1029
+ session,
1030
+ timeout,
1031
+ transcoded_request,
1032
+ body=None,
1033
+ ):
1034
+
1035
+ uri = transcoded_request["uri"]
1036
+ method = transcoded_request["method"]
1037
+ headers = dict(metadata)
1038
+ headers["Content-Type"] = "application/json"
1039
+ response = getattr(session, method)(
1040
+ "{host}{uri}".format(host=host, uri=uri),
1041
+ timeout=timeout,
1042
+ headers=headers,
1043
+ params=rest_helpers.flatten_query_params(query_params, strict=True),
1044
+ )
1045
+ return response
1046
+
1047
+ def __call__(
1048
+ self,
1049
+ request: locations_pb2.ListLocationsRequest,
1050
+ *,
1051
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
1052
+ timeout: Optional[float] = None,
1053
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
1054
+ ) -> locations_pb2.ListLocationsResponse:
1055
+ r"""Call the list locations method over HTTP.
1056
+
1057
+ Args:
1058
+ request (locations_pb2.ListLocationsRequest):
1059
+ The request object for ListLocations method.
1060
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
1061
+ should be retried.
1062
+ timeout (float): The timeout for this request.
1063
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1064
+ sent along with the request as metadata. Normally, each value must be of type `str`,
1065
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
1066
+ be of type `bytes`.
1067
+
1068
+ Returns:
1069
+ locations_pb2.ListLocationsResponse: Response from ListLocations method.
1070
+ """
1071
+
1072
+ http_options = (
1073
+ _BaseLlmUtilityServiceRestTransport._BaseListLocations._get_http_options()
1074
+ )
1075
+
1076
+ request, metadata = self._interceptor.pre_list_locations(request, metadata)
1077
+ transcoded_request = _BaseLlmUtilityServiceRestTransport._BaseListLocations._get_transcoded_request(
1078
+ http_options, request
1079
+ )
1080
+
1081
+ # Jsonify the query params
1082
+ query_params = _BaseLlmUtilityServiceRestTransport._BaseListLocations._get_query_params_json(
1083
+ transcoded_request
1084
+ )
1085
+
1086
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
1087
+ logging.DEBUG
1088
+ ): # pragma: NO COVER
1089
+ request_url = "{host}{uri}".format(
1090
+ host=self._host, uri=transcoded_request["uri"]
1091
+ )
1092
+ method = transcoded_request["method"]
1093
+ try:
1094
+ request_payload = json_format.MessageToJson(request)
1095
+ except:
1096
+ request_payload = None
1097
+ http_request = {
1098
+ "payload": request_payload,
1099
+ "requestMethod": method,
1100
+ "requestUrl": request_url,
1101
+ "headers": dict(metadata),
1102
+ }
1103
+ _LOGGER.debug(
1104
+ f"Sending request for google.cloud.aiplatform_v1.LlmUtilityServiceClient.ListLocations",
1105
+ extra={
1106
+ "serviceName": "google.cloud.aiplatform.v1.LlmUtilityService",
1107
+ "rpcName": "ListLocations",
1108
+ "httpRequest": http_request,
1109
+ "metadata": http_request["headers"],
1110
+ },
1111
+ )
1112
+
1113
+ # Send the request
1114
+ response = LlmUtilityServiceRestTransport._ListLocations._get_response(
1115
+ self._host,
1116
+ metadata,
1117
+ query_params,
1118
+ self._session,
1119
+ timeout,
1120
+ transcoded_request,
1121
+ )
1122
+
1123
+ # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
1124
+ # subclass.
1125
+ if response.status_code >= 400:
1126
+ raise core_exceptions.from_http_response(response)
1127
+
1128
+ content = response.content.decode("utf-8")
1129
+ resp = locations_pb2.ListLocationsResponse()
1130
+ resp = json_format.Parse(content, resp)
1131
+ resp = self._interceptor.post_list_locations(resp)
1132
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
1133
+ logging.DEBUG
1134
+ ): # pragma: NO COVER
1135
+ try:
1136
+ response_payload = json_format.MessageToJson(resp)
1137
+ except:
1138
+ response_payload = None
1139
+ http_response = {
1140
+ "payload": response_payload,
1141
+ "headers": dict(response.headers),
1142
+ "status": response.status_code,
1143
+ }
1144
+ _LOGGER.debug(
1145
+ "Received response for google.cloud.aiplatform_v1.LlmUtilityServiceAsyncClient.ListLocations",
1146
+ extra={
1147
+ "serviceName": "google.cloud.aiplatform.v1.LlmUtilityService",
1148
+ "rpcName": "ListLocations",
1149
+ "httpResponse": http_response,
1150
+ "metadata": http_response["headers"],
1151
+ },
1152
+ )
1153
+ return resp
1154
+
1155
+ @property
1156
+ def get_iam_policy(self):
1157
+ return self._GetIamPolicy(self._session, self._host, self._interceptor) # type: ignore
1158
+
1159
+ class _GetIamPolicy(
1160
+ _BaseLlmUtilityServiceRestTransport._BaseGetIamPolicy, LlmUtilityServiceRestStub
1161
+ ):
1162
+ def __hash__(self):
1163
+ return hash("LlmUtilityServiceRestTransport.GetIamPolicy")
1164
+
1165
+ @staticmethod
1166
+ def _get_response(
1167
+ host,
1168
+ metadata,
1169
+ query_params,
1170
+ session,
1171
+ timeout,
1172
+ transcoded_request,
1173
+ body=None,
1174
+ ):
1175
+
1176
+ uri = transcoded_request["uri"]
1177
+ method = transcoded_request["method"]
1178
+ headers = dict(metadata)
1179
+ headers["Content-Type"] = "application/json"
1180
+ response = getattr(session, method)(
1181
+ "{host}{uri}".format(host=host, uri=uri),
1182
+ timeout=timeout,
1183
+ headers=headers,
1184
+ params=rest_helpers.flatten_query_params(query_params, strict=True),
1185
+ )
1186
+ return response
1187
+
1188
+ def __call__(
1189
+ self,
1190
+ request: iam_policy_pb2.GetIamPolicyRequest,
1191
+ *,
1192
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
1193
+ timeout: Optional[float] = None,
1194
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
1195
+ ) -> policy_pb2.Policy:
1196
+ r"""Call the get iam policy method over HTTP.
1197
+
1198
+ Args:
1199
+ request (iam_policy_pb2.GetIamPolicyRequest):
1200
+ The request object for GetIamPolicy method.
1201
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
1202
+ should be retried.
1203
+ timeout (float): The timeout for this request.
1204
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1205
+ sent along with the request as metadata. Normally, each value must be of type `str`,
1206
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
1207
+ be of type `bytes`.
1208
+
1209
+ Returns:
1210
+ policy_pb2.Policy: Response from GetIamPolicy method.
1211
+ """
1212
+
1213
+ http_options = (
1214
+ _BaseLlmUtilityServiceRestTransport._BaseGetIamPolicy._get_http_options()
1215
+ )
1216
+
1217
+ request, metadata = self._interceptor.pre_get_iam_policy(request, metadata)
1218
+ transcoded_request = _BaseLlmUtilityServiceRestTransport._BaseGetIamPolicy._get_transcoded_request(
1219
+ http_options, request
1220
+ )
1221
+
1222
+ # Jsonify the query params
1223
+ query_params = _BaseLlmUtilityServiceRestTransport._BaseGetIamPolicy._get_query_params_json(
1224
+ transcoded_request
1225
+ )
1226
+
1227
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
1228
+ logging.DEBUG
1229
+ ): # pragma: NO COVER
1230
+ request_url = "{host}{uri}".format(
1231
+ host=self._host, uri=transcoded_request["uri"]
1232
+ )
1233
+ method = transcoded_request["method"]
1234
+ try:
1235
+ request_payload = json_format.MessageToJson(request)
1236
+ except:
1237
+ request_payload = None
1238
+ http_request = {
1239
+ "payload": request_payload,
1240
+ "requestMethod": method,
1241
+ "requestUrl": request_url,
1242
+ "headers": dict(metadata),
1243
+ }
1244
+ _LOGGER.debug(
1245
+ f"Sending request for google.cloud.aiplatform_v1.LlmUtilityServiceClient.GetIamPolicy",
1246
+ extra={
1247
+ "serviceName": "google.cloud.aiplatform.v1.LlmUtilityService",
1248
+ "rpcName": "GetIamPolicy",
1249
+ "httpRequest": http_request,
1250
+ "metadata": http_request["headers"],
1251
+ },
1252
+ )
1253
+
1254
+ # Send the request
1255
+ response = LlmUtilityServiceRestTransport._GetIamPolicy._get_response(
1256
+ self._host,
1257
+ metadata,
1258
+ query_params,
1259
+ self._session,
1260
+ timeout,
1261
+ transcoded_request,
1262
+ )
1263
+
1264
+ # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
1265
+ # subclass.
1266
+ if response.status_code >= 400:
1267
+ raise core_exceptions.from_http_response(response)
1268
+
1269
+ content = response.content.decode("utf-8")
1270
+ resp = policy_pb2.Policy()
1271
+ resp = json_format.Parse(content, resp)
1272
+ resp = self._interceptor.post_get_iam_policy(resp)
1273
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
1274
+ logging.DEBUG
1275
+ ): # pragma: NO COVER
1276
+ try:
1277
+ response_payload = json_format.MessageToJson(resp)
1278
+ except:
1279
+ response_payload = None
1280
+ http_response = {
1281
+ "payload": response_payload,
1282
+ "headers": dict(response.headers),
1283
+ "status": response.status_code,
1284
+ }
1285
+ _LOGGER.debug(
1286
+ "Received response for google.cloud.aiplatform_v1.LlmUtilityServiceAsyncClient.GetIamPolicy",
1287
+ extra={
1288
+ "serviceName": "google.cloud.aiplatform.v1.LlmUtilityService",
1289
+ "rpcName": "GetIamPolicy",
1290
+ "httpResponse": http_response,
1291
+ "metadata": http_response["headers"],
1292
+ },
1293
+ )
1294
+ return resp
1295
+
1296
+ @property
1297
+ def set_iam_policy(self):
1298
+ return self._SetIamPolicy(self._session, self._host, self._interceptor) # type: ignore
1299
+
1300
+ class _SetIamPolicy(
1301
+ _BaseLlmUtilityServiceRestTransport._BaseSetIamPolicy, LlmUtilityServiceRestStub
1302
+ ):
1303
+ def __hash__(self):
1304
+ return hash("LlmUtilityServiceRestTransport.SetIamPolicy")
1305
+
1306
+ @staticmethod
1307
+ def _get_response(
1308
+ host,
1309
+ metadata,
1310
+ query_params,
1311
+ session,
1312
+ timeout,
1313
+ transcoded_request,
1314
+ body=None,
1315
+ ):
1316
+
1317
+ uri = transcoded_request["uri"]
1318
+ method = transcoded_request["method"]
1319
+ headers = dict(metadata)
1320
+ headers["Content-Type"] = "application/json"
1321
+ response = getattr(session, method)(
1322
+ "{host}{uri}".format(host=host, uri=uri),
1323
+ timeout=timeout,
1324
+ headers=headers,
1325
+ params=rest_helpers.flatten_query_params(query_params, strict=True),
1326
+ data=body,
1327
+ )
1328
+ return response
1329
+
1330
+ def __call__(
1331
+ self,
1332
+ request: iam_policy_pb2.SetIamPolicyRequest,
1333
+ *,
1334
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
1335
+ timeout: Optional[float] = None,
1336
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
1337
+ ) -> policy_pb2.Policy:
1338
+ r"""Call the set iam policy method over HTTP.
1339
+
1340
+ Args:
1341
+ request (iam_policy_pb2.SetIamPolicyRequest):
1342
+ The request object for SetIamPolicy method.
1343
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
1344
+ should be retried.
1345
+ timeout (float): The timeout for this request.
1346
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1347
+ sent along with the request as metadata. Normally, each value must be of type `str`,
1348
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
1349
+ be of type `bytes`.
1350
+
1351
+ Returns:
1352
+ policy_pb2.Policy: Response from SetIamPolicy method.
1353
+ """
1354
+
1355
+ http_options = (
1356
+ _BaseLlmUtilityServiceRestTransport._BaseSetIamPolicy._get_http_options()
1357
+ )
1358
+
1359
+ request, metadata = self._interceptor.pre_set_iam_policy(request, metadata)
1360
+ transcoded_request = _BaseLlmUtilityServiceRestTransport._BaseSetIamPolicy._get_transcoded_request(
1361
+ http_options, request
1362
+ )
1363
+
1364
+ body = _BaseLlmUtilityServiceRestTransport._BaseSetIamPolicy._get_request_body_json(
1365
+ transcoded_request
1366
+ )
1367
+
1368
+ # Jsonify the query params
1369
+ query_params = _BaseLlmUtilityServiceRestTransport._BaseSetIamPolicy._get_query_params_json(
1370
+ transcoded_request
1371
+ )
1372
+
1373
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
1374
+ logging.DEBUG
1375
+ ): # pragma: NO COVER
1376
+ request_url = "{host}{uri}".format(
1377
+ host=self._host, uri=transcoded_request["uri"]
1378
+ )
1379
+ method = transcoded_request["method"]
1380
+ try:
1381
+ request_payload = json_format.MessageToJson(request)
1382
+ except:
1383
+ request_payload = None
1384
+ http_request = {
1385
+ "payload": request_payload,
1386
+ "requestMethod": method,
1387
+ "requestUrl": request_url,
1388
+ "headers": dict(metadata),
1389
+ }
1390
+ _LOGGER.debug(
1391
+ f"Sending request for google.cloud.aiplatform_v1.LlmUtilityServiceClient.SetIamPolicy",
1392
+ extra={
1393
+ "serviceName": "google.cloud.aiplatform.v1.LlmUtilityService",
1394
+ "rpcName": "SetIamPolicy",
1395
+ "httpRequest": http_request,
1396
+ "metadata": http_request["headers"],
1397
+ },
1398
+ )
1399
+
1400
+ # Send the request
1401
+ response = LlmUtilityServiceRestTransport._SetIamPolicy._get_response(
1402
+ self._host,
1403
+ metadata,
1404
+ query_params,
1405
+ self._session,
1406
+ timeout,
1407
+ transcoded_request,
1408
+ body,
1409
+ )
1410
+
1411
+ # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
1412
+ # subclass.
1413
+ if response.status_code >= 400:
1414
+ raise core_exceptions.from_http_response(response)
1415
+
1416
+ content = response.content.decode("utf-8")
1417
+ resp = policy_pb2.Policy()
1418
+ resp = json_format.Parse(content, resp)
1419
+ resp = self._interceptor.post_set_iam_policy(resp)
1420
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
1421
+ logging.DEBUG
1422
+ ): # pragma: NO COVER
1423
+ try:
1424
+ response_payload = json_format.MessageToJson(resp)
1425
+ except:
1426
+ response_payload = None
1427
+ http_response = {
1428
+ "payload": response_payload,
1429
+ "headers": dict(response.headers),
1430
+ "status": response.status_code,
1431
+ }
1432
+ _LOGGER.debug(
1433
+ "Received response for google.cloud.aiplatform_v1.LlmUtilityServiceAsyncClient.SetIamPolicy",
1434
+ extra={
1435
+ "serviceName": "google.cloud.aiplatform.v1.LlmUtilityService",
1436
+ "rpcName": "SetIamPolicy",
1437
+ "httpResponse": http_response,
1438
+ "metadata": http_response["headers"],
1439
+ },
1440
+ )
1441
+ return resp
1442
+
1443
+ @property
1444
+ def test_iam_permissions(self):
1445
+ return self._TestIamPermissions(self._session, self._host, self._interceptor) # type: ignore
1446
+
1447
+ class _TestIamPermissions(
1448
+ _BaseLlmUtilityServiceRestTransport._BaseTestIamPermissions,
1449
+ LlmUtilityServiceRestStub,
1450
+ ):
1451
+ def __hash__(self):
1452
+ return hash("LlmUtilityServiceRestTransport.TestIamPermissions")
1453
+
1454
+ @staticmethod
1455
+ def _get_response(
1456
+ host,
1457
+ metadata,
1458
+ query_params,
1459
+ session,
1460
+ timeout,
1461
+ transcoded_request,
1462
+ body=None,
1463
+ ):
1464
+
1465
+ uri = transcoded_request["uri"]
1466
+ method = transcoded_request["method"]
1467
+ headers = dict(metadata)
1468
+ headers["Content-Type"] = "application/json"
1469
+ response = getattr(session, method)(
1470
+ "{host}{uri}".format(host=host, uri=uri),
1471
+ timeout=timeout,
1472
+ headers=headers,
1473
+ params=rest_helpers.flatten_query_params(query_params, strict=True),
1474
+ )
1475
+ return response
1476
+
1477
+ def __call__(
1478
+ self,
1479
+ request: iam_policy_pb2.TestIamPermissionsRequest,
1480
+ *,
1481
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
1482
+ timeout: Optional[float] = None,
1483
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
1484
+ ) -> iam_policy_pb2.TestIamPermissionsResponse:
1485
+ r"""Call the test iam permissions method over HTTP.
1486
+
1487
+ Args:
1488
+ request (iam_policy_pb2.TestIamPermissionsRequest):
1489
+ The request object for TestIamPermissions method.
1490
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
1491
+ should be retried.
1492
+ timeout (float): The timeout for this request.
1493
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1494
+ sent along with the request as metadata. Normally, each value must be of type `str`,
1495
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
1496
+ be of type `bytes`.
1497
+
1498
+ Returns:
1499
+ iam_policy_pb2.TestIamPermissionsResponse: Response from TestIamPermissions method.
1500
+ """
1501
+
1502
+ http_options = (
1503
+ _BaseLlmUtilityServiceRestTransport._BaseTestIamPermissions._get_http_options()
1504
+ )
1505
+
1506
+ request, metadata = self._interceptor.pre_test_iam_permissions(
1507
+ request, metadata
1508
+ )
1509
+ transcoded_request = _BaseLlmUtilityServiceRestTransport._BaseTestIamPermissions._get_transcoded_request(
1510
+ http_options, request
1511
+ )
1512
+
1513
+ # Jsonify the query params
1514
+ query_params = _BaseLlmUtilityServiceRestTransport._BaseTestIamPermissions._get_query_params_json(
1515
+ transcoded_request
1516
+ )
1517
+
1518
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
1519
+ logging.DEBUG
1520
+ ): # pragma: NO COVER
1521
+ request_url = "{host}{uri}".format(
1522
+ host=self._host, uri=transcoded_request["uri"]
1523
+ )
1524
+ method = transcoded_request["method"]
1525
+ try:
1526
+ request_payload = json_format.MessageToJson(request)
1527
+ except:
1528
+ request_payload = None
1529
+ http_request = {
1530
+ "payload": request_payload,
1531
+ "requestMethod": method,
1532
+ "requestUrl": request_url,
1533
+ "headers": dict(metadata),
1534
+ }
1535
+ _LOGGER.debug(
1536
+ f"Sending request for google.cloud.aiplatform_v1.LlmUtilityServiceClient.TestIamPermissions",
1537
+ extra={
1538
+ "serviceName": "google.cloud.aiplatform.v1.LlmUtilityService",
1539
+ "rpcName": "TestIamPermissions",
1540
+ "httpRequest": http_request,
1541
+ "metadata": http_request["headers"],
1542
+ },
1543
+ )
1544
+
1545
+ # Send the request
1546
+ response = LlmUtilityServiceRestTransport._TestIamPermissions._get_response(
1547
+ self._host,
1548
+ metadata,
1549
+ query_params,
1550
+ self._session,
1551
+ timeout,
1552
+ transcoded_request,
1553
+ )
1554
+
1555
+ # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
1556
+ # subclass.
1557
+ if response.status_code >= 400:
1558
+ raise core_exceptions.from_http_response(response)
1559
+
1560
+ content = response.content.decode("utf-8")
1561
+ resp = iam_policy_pb2.TestIamPermissionsResponse()
1562
+ resp = json_format.Parse(content, resp)
1563
+ resp = self._interceptor.post_test_iam_permissions(resp)
1564
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
1565
+ logging.DEBUG
1566
+ ): # pragma: NO COVER
1567
+ try:
1568
+ response_payload = json_format.MessageToJson(resp)
1569
+ except:
1570
+ response_payload = None
1571
+ http_response = {
1572
+ "payload": response_payload,
1573
+ "headers": dict(response.headers),
1574
+ "status": response.status_code,
1575
+ }
1576
+ _LOGGER.debug(
1577
+ "Received response for google.cloud.aiplatform_v1.LlmUtilityServiceAsyncClient.TestIamPermissions",
1578
+ extra={
1579
+ "serviceName": "google.cloud.aiplatform.v1.LlmUtilityService",
1580
+ "rpcName": "TestIamPermissions",
1581
+ "httpResponse": http_response,
1582
+ "metadata": http_response["headers"],
1583
+ },
1584
+ )
1585
+ return resp
1586
+
1587
+ @property
1588
+ def cancel_operation(self):
1589
+ return self._CancelOperation(self._session, self._host, self._interceptor) # type: ignore
1590
+
1591
+ class _CancelOperation(
1592
+ _BaseLlmUtilityServiceRestTransport._BaseCancelOperation,
1593
+ LlmUtilityServiceRestStub,
1594
+ ):
1595
+ def __hash__(self):
1596
+ return hash("LlmUtilityServiceRestTransport.CancelOperation")
1597
+
1598
+ @staticmethod
1599
+ def _get_response(
1600
+ host,
1601
+ metadata,
1602
+ query_params,
1603
+ session,
1604
+ timeout,
1605
+ transcoded_request,
1606
+ body=None,
1607
+ ):
1608
+
1609
+ uri = transcoded_request["uri"]
1610
+ method = transcoded_request["method"]
1611
+ headers = dict(metadata)
1612
+ headers["Content-Type"] = "application/json"
1613
+ response = getattr(session, method)(
1614
+ "{host}{uri}".format(host=host, uri=uri),
1615
+ timeout=timeout,
1616
+ headers=headers,
1617
+ params=rest_helpers.flatten_query_params(query_params, strict=True),
1618
+ )
1619
+ return response
1620
+
1621
+ def __call__(
1622
+ self,
1623
+ request: operations_pb2.CancelOperationRequest,
1624
+ *,
1625
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
1626
+ timeout: Optional[float] = None,
1627
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
1628
+ ) -> None:
1629
+ r"""Call the cancel operation method over HTTP.
1630
+
1631
+ Args:
1632
+ request (operations_pb2.CancelOperationRequest):
1633
+ The request object for CancelOperation method.
1634
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
1635
+ should be retried.
1636
+ timeout (float): The timeout for this request.
1637
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1638
+ sent along with the request as metadata. Normally, each value must be of type `str`,
1639
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
1640
+ be of type `bytes`.
1641
+ """
1642
+
1643
+ http_options = (
1644
+ _BaseLlmUtilityServiceRestTransport._BaseCancelOperation._get_http_options()
1645
+ )
1646
+
1647
+ request, metadata = self._interceptor.pre_cancel_operation(
1648
+ request, metadata
1649
+ )
1650
+ transcoded_request = _BaseLlmUtilityServiceRestTransport._BaseCancelOperation._get_transcoded_request(
1651
+ http_options, request
1652
+ )
1653
+
1654
+ # Jsonify the query params
1655
+ query_params = _BaseLlmUtilityServiceRestTransport._BaseCancelOperation._get_query_params_json(
1656
+ transcoded_request
1657
+ )
1658
+
1659
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
1660
+ logging.DEBUG
1661
+ ): # pragma: NO COVER
1662
+ request_url = "{host}{uri}".format(
1663
+ host=self._host, uri=transcoded_request["uri"]
1664
+ )
1665
+ method = transcoded_request["method"]
1666
+ try:
1667
+ request_payload = json_format.MessageToJson(request)
1668
+ except:
1669
+ request_payload = None
1670
+ http_request = {
1671
+ "payload": request_payload,
1672
+ "requestMethod": method,
1673
+ "requestUrl": request_url,
1674
+ "headers": dict(metadata),
1675
+ }
1676
+ _LOGGER.debug(
1677
+ f"Sending request for google.cloud.aiplatform_v1.LlmUtilityServiceClient.CancelOperation",
1678
+ extra={
1679
+ "serviceName": "google.cloud.aiplatform.v1.LlmUtilityService",
1680
+ "rpcName": "CancelOperation",
1681
+ "httpRequest": http_request,
1682
+ "metadata": http_request["headers"],
1683
+ },
1684
+ )
1685
+
1686
+ # Send the request
1687
+ response = LlmUtilityServiceRestTransport._CancelOperation._get_response(
1688
+ self._host,
1689
+ metadata,
1690
+ query_params,
1691
+ self._session,
1692
+ timeout,
1693
+ transcoded_request,
1694
+ )
1695
+
1696
+ # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
1697
+ # subclass.
1698
+ if response.status_code >= 400:
1699
+ raise core_exceptions.from_http_response(response)
1700
+
1701
+ return self._interceptor.post_cancel_operation(None)
1702
+
1703
+ @property
1704
+ def delete_operation(self):
1705
+ return self._DeleteOperation(self._session, self._host, self._interceptor) # type: ignore
1706
+
1707
+ class _DeleteOperation(
1708
+ _BaseLlmUtilityServiceRestTransport._BaseDeleteOperation,
1709
+ LlmUtilityServiceRestStub,
1710
+ ):
1711
+ def __hash__(self):
1712
+ return hash("LlmUtilityServiceRestTransport.DeleteOperation")
1713
+
1714
+ @staticmethod
1715
+ def _get_response(
1716
+ host,
1717
+ metadata,
1718
+ query_params,
1719
+ session,
1720
+ timeout,
1721
+ transcoded_request,
1722
+ body=None,
1723
+ ):
1724
+
1725
+ uri = transcoded_request["uri"]
1726
+ method = transcoded_request["method"]
1727
+ headers = dict(metadata)
1728
+ headers["Content-Type"] = "application/json"
1729
+ response = getattr(session, method)(
1730
+ "{host}{uri}".format(host=host, uri=uri),
1731
+ timeout=timeout,
1732
+ headers=headers,
1733
+ params=rest_helpers.flatten_query_params(query_params, strict=True),
1734
+ )
1735
+ return response
1736
+
1737
+ def __call__(
1738
+ self,
1739
+ request: operations_pb2.DeleteOperationRequest,
1740
+ *,
1741
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
1742
+ timeout: Optional[float] = None,
1743
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
1744
+ ) -> None:
1745
+ r"""Call the delete operation method over HTTP.
1746
+
1747
+ Args:
1748
+ request (operations_pb2.DeleteOperationRequest):
1749
+ The request object for DeleteOperation method.
1750
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
1751
+ should be retried.
1752
+ timeout (float): The timeout for this request.
1753
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1754
+ sent along with the request as metadata. Normally, each value must be of type `str`,
1755
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
1756
+ be of type `bytes`.
1757
+ """
1758
+
1759
+ http_options = (
1760
+ _BaseLlmUtilityServiceRestTransport._BaseDeleteOperation._get_http_options()
1761
+ )
1762
+
1763
+ request, metadata = self._interceptor.pre_delete_operation(
1764
+ request, metadata
1765
+ )
1766
+ transcoded_request = _BaseLlmUtilityServiceRestTransport._BaseDeleteOperation._get_transcoded_request(
1767
+ http_options, request
1768
+ )
1769
+
1770
+ # Jsonify the query params
1771
+ query_params = _BaseLlmUtilityServiceRestTransport._BaseDeleteOperation._get_query_params_json(
1772
+ transcoded_request
1773
+ )
1774
+
1775
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
1776
+ logging.DEBUG
1777
+ ): # pragma: NO COVER
1778
+ request_url = "{host}{uri}".format(
1779
+ host=self._host, uri=transcoded_request["uri"]
1780
+ )
1781
+ method = transcoded_request["method"]
1782
+ try:
1783
+ request_payload = json_format.MessageToJson(request)
1784
+ except:
1785
+ request_payload = None
1786
+ http_request = {
1787
+ "payload": request_payload,
1788
+ "requestMethod": method,
1789
+ "requestUrl": request_url,
1790
+ "headers": dict(metadata),
1791
+ }
1792
+ _LOGGER.debug(
1793
+ f"Sending request for google.cloud.aiplatform_v1.LlmUtilityServiceClient.DeleteOperation",
1794
+ extra={
1795
+ "serviceName": "google.cloud.aiplatform.v1.LlmUtilityService",
1796
+ "rpcName": "DeleteOperation",
1797
+ "httpRequest": http_request,
1798
+ "metadata": http_request["headers"],
1799
+ },
1800
+ )
1801
+
1802
+ # Send the request
1803
+ response = LlmUtilityServiceRestTransport._DeleteOperation._get_response(
1804
+ self._host,
1805
+ metadata,
1806
+ query_params,
1807
+ self._session,
1808
+ timeout,
1809
+ transcoded_request,
1810
+ )
1811
+
1812
+ # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
1813
+ # subclass.
1814
+ if response.status_code >= 400:
1815
+ raise core_exceptions.from_http_response(response)
1816
+
1817
+ return self._interceptor.post_delete_operation(None)
1818
+
1819
+ @property
1820
+ def get_operation(self):
1821
+ return self._GetOperation(self._session, self._host, self._interceptor) # type: ignore
1822
+
1823
+ class _GetOperation(
1824
+ _BaseLlmUtilityServiceRestTransport._BaseGetOperation, LlmUtilityServiceRestStub
1825
+ ):
1826
+ def __hash__(self):
1827
+ return hash("LlmUtilityServiceRestTransport.GetOperation")
1828
+
1829
+ @staticmethod
1830
+ def _get_response(
1831
+ host,
1832
+ metadata,
1833
+ query_params,
1834
+ session,
1835
+ timeout,
1836
+ transcoded_request,
1837
+ body=None,
1838
+ ):
1839
+
1840
+ uri = transcoded_request["uri"]
1841
+ method = transcoded_request["method"]
1842
+ headers = dict(metadata)
1843
+ headers["Content-Type"] = "application/json"
1844
+ response = getattr(session, method)(
1845
+ "{host}{uri}".format(host=host, uri=uri),
1846
+ timeout=timeout,
1847
+ headers=headers,
1848
+ params=rest_helpers.flatten_query_params(query_params, strict=True),
1849
+ )
1850
+ return response
1851
+
1852
+ def __call__(
1853
+ self,
1854
+ request: operations_pb2.GetOperationRequest,
1855
+ *,
1856
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
1857
+ timeout: Optional[float] = None,
1858
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
1859
+ ) -> operations_pb2.Operation:
1860
+ r"""Call the get operation method over HTTP.
1861
+
1862
+ Args:
1863
+ request (operations_pb2.GetOperationRequest):
1864
+ The request object for GetOperation method.
1865
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
1866
+ should be retried.
1867
+ timeout (float): The timeout for this request.
1868
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1869
+ sent along with the request as metadata. Normally, each value must be of type `str`,
1870
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
1871
+ be of type `bytes`.
1872
+
1873
+ Returns:
1874
+ operations_pb2.Operation: Response from GetOperation method.
1875
+ """
1876
+
1877
+ http_options = (
1878
+ _BaseLlmUtilityServiceRestTransport._BaseGetOperation._get_http_options()
1879
+ )
1880
+
1881
+ request, metadata = self._interceptor.pre_get_operation(request, metadata)
1882
+ transcoded_request = _BaseLlmUtilityServiceRestTransport._BaseGetOperation._get_transcoded_request(
1883
+ http_options, request
1884
+ )
1885
+
1886
+ # Jsonify the query params
1887
+ query_params = _BaseLlmUtilityServiceRestTransport._BaseGetOperation._get_query_params_json(
1888
+ transcoded_request
1889
+ )
1890
+
1891
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
1892
+ logging.DEBUG
1893
+ ): # pragma: NO COVER
1894
+ request_url = "{host}{uri}".format(
1895
+ host=self._host, uri=transcoded_request["uri"]
1896
+ )
1897
+ method = transcoded_request["method"]
1898
+ try:
1899
+ request_payload = json_format.MessageToJson(request)
1900
+ except:
1901
+ request_payload = None
1902
+ http_request = {
1903
+ "payload": request_payload,
1904
+ "requestMethod": method,
1905
+ "requestUrl": request_url,
1906
+ "headers": dict(metadata),
1907
+ }
1908
+ _LOGGER.debug(
1909
+ f"Sending request for google.cloud.aiplatform_v1.LlmUtilityServiceClient.GetOperation",
1910
+ extra={
1911
+ "serviceName": "google.cloud.aiplatform.v1.LlmUtilityService",
1912
+ "rpcName": "GetOperation",
1913
+ "httpRequest": http_request,
1914
+ "metadata": http_request["headers"],
1915
+ },
1916
+ )
1917
+
1918
+ # Send the request
1919
+ response = LlmUtilityServiceRestTransport._GetOperation._get_response(
1920
+ self._host,
1921
+ metadata,
1922
+ query_params,
1923
+ self._session,
1924
+ timeout,
1925
+ transcoded_request,
1926
+ )
1927
+
1928
+ # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
1929
+ # subclass.
1930
+ if response.status_code >= 400:
1931
+ raise core_exceptions.from_http_response(response)
1932
+
1933
+ content = response.content.decode("utf-8")
1934
+ resp = operations_pb2.Operation()
1935
+ resp = json_format.Parse(content, resp)
1936
+ resp = self._interceptor.post_get_operation(resp)
1937
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
1938
+ logging.DEBUG
1939
+ ): # pragma: NO COVER
1940
+ try:
1941
+ response_payload = json_format.MessageToJson(resp)
1942
+ except:
1943
+ response_payload = None
1944
+ http_response = {
1945
+ "payload": response_payload,
1946
+ "headers": dict(response.headers),
1947
+ "status": response.status_code,
1948
+ }
1949
+ _LOGGER.debug(
1950
+ "Received response for google.cloud.aiplatform_v1.LlmUtilityServiceAsyncClient.GetOperation",
1951
+ extra={
1952
+ "serviceName": "google.cloud.aiplatform.v1.LlmUtilityService",
1953
+ "rpcName": "GetOperation",
1954
+ "httpResponse": http_response,
1955
+ "metadata": http_response["headers"],
1956
+ },
1957
+ )
1958
+ return resp
1959
+
1960
+ @property
1961
+ def list_operations(self):
1962
+ return self._ListOperations(self._session, self._host, self._interceptor) # type: ignore
1963
+
1964
+ class _ListOperations(
1965
+ _BaseLlmUtilityServiceRestTransport._BaseListOperations,
1966
+ LlmUtilityServiceRestStub,
1967
+ ):
1968
+ def __hash__(self):
1969
+ return hash("LlmUtilityServiceRestTransport.ListOperations")
1970
+
1971
+ @staticmethod
1972
+ def _get_response(
1973
+ host,
1974
+ metadata,
1975
+ query_params,
1976
+ session,
1977
+ timeout,
1978
+ transcoded_request,
1979
+ body=None,
1980
+ ):
1981
+
1982
+ uri = transcoded_request["uri"]
1983
+ method = transcoded_request["method"]
1984
+ headers = dict(metadata)
1985
+ headers["Content-Type"] = "application/json"
1986
+ response = getattr(session, method)(
1987
+ "{host}{uri}".format(host=host, uri=uri),
1988
+ timeout=timeout,
1989
+ headers=headers,
1990
+ params=rest_helpers.flatten_query_params(query_params, strict=True),
1991
+ )
1992
+ return response
1993
+
1994
+ def __call__(
1995
+ self,
1996
+ request: operations_pb2.ListOperationsRequest,
1997
+ *,
1998
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
1999
+ timeout: Optional[float] = None,
2000
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
2001
+ ) -> operations_pb2.ListOperationsResponse:
2002
+ r"""Call the list operations method over HTTP.
2003
+
2004
+ Args:
2005
+ request (operations_pb2.ListOperationsRequest):
2006
+ The request object for ListOperations method.
2007
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
2008
+ should be retried.
2009
+ timeout (float): The timeout for this request.
2010
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
2011
+ sent along with the request as metadata. Normally, each value must be of type `str`,
2012
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
2013
+ be of type `bytes`.
2014
+
2015
+ Returns:
2016
+ operations_pb2.ListOperationsResponse: Response from ListOperations method.
2017
+ """
2018
+
2019
+ http_options = (
2020
+ _BaseLlmUtilityServiceRestTransport._BaseListOperations._get_http_options()
2021
+ )
2022
+
2023
+ request, metadata = self._interceptor.pre_list_operations(request, metadata)
2024
+ transcoded_request = _BaseLlmUtilityServiceRestTransport._BaseListOperations._get_transcoded_request(
2025
+ http_options, request
2026
+ )
2027
+
2028
+ # Jsonify the query params
2029
+ query_params = _BaseLlmUtilityServiceRestTransport._BaseListOperations._get_query_params_json(
2030
+ transcoded_request
2031
+ )
2032
+
2033
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
2034
+ logging.DEBUG
2035
+ ): # pragma: NO COVER
2036
+ request_url = "{host}{uri}".format(
2037
+ host=self._host, uri=transcoded_request["uri"]
2038
+ )
2039
+ method = transcoded_request["method"]
2040
+ try:
2041
+ request_payload = json_format.MessageToJson(request)
2042
+ except:
2043
+ request_payload = None
2044
+ http_request = {
2045
+ "payload": request_payload,
2046
+ "requestMethod": method,
2047
+ "requestUrl": request_url,
2048
+ "headers": dict(metadata),
2049
+ }
2050
+ _LOGGER.debug(
2051
+ f"Sending request for google.cloud.aiplatform_v1.LlmUtilityServiceClient.ListOperations",
2052
+ extra={
2053
+ "serviceName": "google.cloud.aiplatform.v1.LlmUtilityService",
2054
+ "rpcName": "ListOperations",
2055
+ "httpRequest": http_request,
2056
+ "metadata": http_request["headers"],
2057
+ },
2058
+ )
2059
+
2060
+ # Send the request
2061
+ response = LlmUtilityServiceRestTransport._ListOperations._get_response(
2062
+ self._host,
2063
+ metadata,
2064
+ query_params,
2065
+ self._session,
2066
+ timeout,
2067
+ transcoded_request,
2068
+ )
2069
+
2070
+ # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
2071
+ # subclass.
2072
+ if response.status_code >= 400:
2073
+ raise core_exceptions.from_http_response(response)
2074
+
2075
+ content = response.content.decode("utf-8")
2076
+ resp = operations_pb2.ListOperationsResponse()
2077
+ resp = json_format.Parse(content, resp)
2078
+ resp = self._interceptor.post_list_operations(resp)
2079
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
2080
+ logging.DEBUG
2081
+ ): # pragma: NO COVER
2082
+ try:
2083
+ response_payload = json_format.MessageToJson(resp)
2084
+ except:
2085
+ response_payload = None
2086
+ http_response = {
2087
+ "payload": response_payload,
2088
+ "headers": dict(response.headers),
2089
+ "status": response.status_code,
2090
+ }
2091
+ _LOGGER.debug(
2092
+ "Received response for google.cloud.aiplatform_v1.LlmUtilityServiceAsyncClient.ListOperations",
2093
+ extra={
2094
+ "serviceName": "google.cloud.aiplatform.v1.LlmUtilityService",
2095
+ "rpcName": "ListOperations",
2096
+ "httpResponse": http_response,
2097
+ "metadata": http_response["headers"],
2098
+ },
2099
+ )
2100
+ return resp
2101
+
2102
+ @property
2103
+ def wait_operation(self):
2104
+ return self._WaitOperation(self._session, self._host, self._interceptor) # type: ignore
2105
+
2106
+ class _WaitOperation(
2107
+ _BaseLlmUtilityServiceRestTransport._BaseWaitOperation,
2108
+ LlmUtilityServiceRestStub,
2109
+ ):
2110
+ def __hash__(self):
2111
+ return hash("LlmUtilityServiceRestTransport.WaitOperation")
2112
+
2113
+ @staticmethod
2114
+ def _get_response(
2115
+ host,
2116
+ metadata,
2117
+ query_params,
2118
+ session,
2119
+ timeout,
2120
+ transcoded_request,
2121
+ body=None,
2122
+ ):
2123
+
2124
+ uri = transcoded_request["uri"]
2125
+ method = transcoded_request["method"]
2126
+ headers = dict(metadata)
2127
+ headers["Content-Type"] = "application/json"
2128
+ response = getattr(session, method)(
2129
+ "{host}{uri}".format(host=host, uri=uri),
2130
+ timeout=timeout,
2131
+ headers=headers,
2132
+ params=rest_helpers.flatten_query_params(query_params, strict=True),
2133
+ )
2134
+ return response
2135
+
2136
+ def __call__(
2137
+ self,
2138
+ request: operations_pb2.WaitOperationRequest,
2139
+ *,
2140
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
2141
+ timeout: Optional[float] = None,
2142
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
2143
+ ) -> operations_pb2.Operation:
2144
+ r"""Call the wait operation method over HTTP.
2145
+
2146
+ Args:
2147
+ request (operations_pb2.WaitOperationRequest):
2148
+ The request object for WaitOperation method.
2149
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
2150
+ should be retried.
2151
+ timeout (float): The timeout for this request.
2152
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
2153
+ sent along with the request as metadata. Normally, each value must be of type `str`,
2154
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
2155
+ be of type `bytes`.
2156
+
2157
+ Returns:
2158
+ operations_pb2.Operation: Response from WaitOperation method.
2159
+ """
2160
+
2161
+ http_options = (
2162
+ _BaseLlmUtilityServiceRestTransport._BaseWaitOperation._get_http_options()
2163
+ )
2164
+
2165
+ request, metadata = self._interceptor.pre_wait_operation(request, metadata)
2166
+ transcoded_request = _BaseLlmUtilityServiceRestTransport._BaseWaitOperation._get_transcoded_request(
2167
+ http_options, request
2168
+ )
2169
+
2170
+ # Jsonify the query params
2171
+ query_params = _BaseLlmUtilityServiceRestTransport._BaseWaitOperation._get_query_params_json(
2172
+ transcoded_request
2173
+ )
2174
+
2175
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
2176
+ logging.DEBUG
2177
+ ): # pragma: NO COVER
2178
+ request_url = "{host}{uri}".format(
2179
+ host=self._host, uri=transcoded_request["uri"]
2180
+ )
2181
+ method = transcoded_request["method"]
2182
+ try:
2183
+ request_payload = json_format.MessageToJson(request)
2184
+ except:
2185
+ request_payload = None
2186
+ http_request = {
2187
+ "payload": request_payload,
2188
+ "requestMethod": method,
2189
+ "requestUrl": request_url,
2190
+ "headers": dict(metadata),
2191
+ }
2192
+ _LOGGER.debug(
2193
+ f"Sending request for google.cloud.aiplatform_v1.LlmUtilityServiceClient.WaitOperation",
2194
+ extra={
2195
+ "serviceName": "google.cloud.aiplatform.v1.LlmUtilityService",
2196
+ "rpcName": "WaitOperation",
2197
+ "httpRequest": http_request,
2198
+ "metadata": http_request["headers"],
2199
+ },
2200
+ )
2201
+
2202
+ # Send the request
2203
+ response = LlmUtilityServiceRestTransport._WaitOperation._get_response(
2204
+ self._host,
2205
+ metadata,
2206
+ query_params,
2207
+ self._session,
2208
+ timeout,
2209
+ transcoded_request,
2210
+ )
2211
+
2212
+ # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
2213
+ # subclass.
2214
+ if response.status_code >= 400:
2215
+ raise core_exceptions.from_http_response(response)
2216
+
2217
+ content = response.content.decode("utf-8")
2218
+ resp = operations_pb2.Operation()
2219
+ resp = json_format.Parse(content, resp)
2220
+ resp = self._interceptor.post_wait_operation(resp)
2221
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
2222
+ logging.DEBUG
2223
+ ): # pragma: NO COVER
2224
+ try:
2225
+ response_payload = json_format.MessageToJson(resp)
2226
+ except:
2227
+ response_payload = None
2228
+ http_response = {
2229
+ "payload": response_payload,
2230
+ "headers": dict(response.headers),
2231
+ "status": response.status_code,
2232
+ }
2233
+ _LOGGER.debug(
2234
+ "Received response for google.cloud.aiplatform_v1.LlmUtilityServiceAsyncClient.WaitOperation",
2235
+ extra={
2236
+ "serviceName": "google.cloud.aiplatform.v1.LlmUtilityService",
2237
+ "rpcName": "WaitOperation",
2238
+ "httpResponse": http_response,
2239
+ "metadata": http_response["headers"],
2240
+ },
2241
+ )
2242
+ return resp
2243
+
2244
+ @property
2245
+ def kind(self) -> str:
2246
+ return "rest"
2247
+
2248
+ def close(self):
2249
+ self._session.close()
2250
+
2251
+
2252
+ __all__ = ("LlmUtilityServiceRestTransport",)
loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/llm_utility_service/transports/rest_asyncio.py ADDED
The diff for this file is too large to render. See raw diff
 
loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/llm_utility_service/transports/rest_base.py ADDED
The diff for this file is too large to render. See raw diff
 
loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/match_service/__init__.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright 2025 Google LLC
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+ from .client import MatchServiceClient
17
+ from .async_client import MatchServiceAsyncClient
18
+
19
+ __all__ = (
20
+ "MatchServiceClient",
21
+ "MatchServiceAsyncClient",
22
+ )
loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/match_service/__pycache__/__init__.cpython-312.pyc ADDED
Binary file (373 Bytes). View file
 
loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/match_service/__pycache__/async_client.cpython-312.pyc ADDED
Binary file (49 kB). View file
 
loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/match_service/__pycache__/client.cpython-312.pyc ADDED
Binary file (68.5 kB). View file
 
loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/match_service/async_client.py ADDED
@@ -0,0 +1,1193 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright 2025 Google LLC
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+ import logging as std_logging
17
+ from collections import OrderedDict
18
+ import re
19
+ from typing import (
20
+ Dict,
21
+ Callable,
22
+ Mapping,
23
+ MutableMapping,
24
+ MutableSequence,
25
+ Optional,
26
+ Sequence,
27
+ Tuple,
28
+ Type,
29
+ Union,
30
+ )
31
+
32
+ from google.cloud.aiplatform_v1 import gapic_version as package_version
33
+
34
+ from google.api_core.client_options import ClientOptions
35
+ from google.api_core import exceptions as core_exceptions
36
+ from google.api_core import gapic_v1
37
+ from google.api_core import retry_async as retries
38
+ from google.auth import credentials as ga_credentials # type: ignore
39
+ from google.oauth2 import service_account # type: ignore
40
+ import google.protobuf
41
+
42
+
43
+ try:
44
+ OptionalRetry = Union[retries.AsyncRetry, gapic_v1.method._MethodDefault, None]
45
+ except AttributeError: # pragma: NO COVER
46
+ OptionalRetry = Union[retries.AsyncRetry, object, None] # type: ignore
47
+
48
+ from google.cloud.aiplatform_v1.types import index
49
+ from google.cloud.aiplatform_v1.types import match_service
50
+ from google.cloud.location import locations_pb2 # type: ignore
51
+ from google.iam.v1 import iam_policy_pb2 # type: ignore
52
+ from google.iam.v1 import policy_pb2 # type: ignore
53
+ from google.longrunning import operations_pb2 # type: ignore
54
+ from .transports.base import MatchServiceTransport, DEFAULT_CLIENT_INFO
55
+ from .transports.grpc_asyncio import MatchServiceGrpcAsyncIOTransport
56
+ from .client import MatchServiceClient
57
+
58
+ try:
59
+ from google.api_core import client_logging # type: ignore
60
+
61
+ CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER
62
+ except ImportError: # pragma: NO COVER
63
+ CLIENT_LOGGING_SUPPORTED = False
64
+
65
+ _LOGGER = std_logging.getLogger(__name__)
66
+
67
+
68
+ class MatchServiceAsyncClient:
69
+ """MatchService is a Google managed service for efficient vector
70
+ similarity search at scale.
71
+ """
72
+
73
+ _client: MatchServiceClient
74
+
75
+ # Copy defaults from the synchronous client for use here.
76
+ # Note: DEFAULT_ENDPOINT is deprecated. Use _DEFAULT_ENDPOINT_TEMPLATE instead.
77
+ DEFAULT_ENDPOINT = MatchServiceClient.DEFAULT_ENDPOINT
78
+ DEFAULT_MTLS_ENDPOINT = MatchServiceClient.DEFAULT_MTLS_ENDPOINT
79
+ _DEFAULT_ENDPOINT_TEMPLATE = MatchServiceClient._DEFAULT_ENDPOINT_TEMPLATE
80
+ _DEFAULT_UNIVERSE = MatchServiceClient._DEFAULT_UNIVERSE
81
+
82
+ index_endpoint_path = staticmethod(MatchServiceClient.index_endpoint_path)
83
+ parse_index_endpoint_path = staticmethod(
84
+ MatchServiceClient.parse_index_endpoint_path
85
+ )
86
+ common_billing_account_path = staticmethod(
87
+ MatchServiceClient.common_billing_account_path
88
+ )
89
+ parse_common_billing_account_path = staticmethod(
90
+ MatchServiceClient.parse_common_billing_account_path
91
+ )
92
+ common_folder_path = staticmethod(MatchServiceClient.common_folder_path)
93
+ parse_common_folder_path = staticmethod(MatchServiceClient.parse_common_folder_path)
94
+ common_organization_path = staticmethod(MatchServiceClient.common_organization_path)
95
+ parse_common_organization_path = staticmethod(
96
+ MatchServiceClient.parse_common_organization_path
97
+ )
98
+ common_project_path = staticmethod(MatchServiceClient.common_project_path)
99
+ parse_common_project_path = staticmethod(
100
+ MatchServiceClient.parse_common_project_path
101
+ )
102
+ common_location_path = staticmethod(MatchServiceClient.common_location_path)
103
+ parse_common_location_path = staticmethod(
104
+ MatchServiceClient.parse_common_location_path
105
+ )
106
+
107
+ @classmethod
108
+ def from_service_account_info(cls, info: dict, *args, **kwargs):
109
+ """Creates an instance of this client using the provided credentials
110
+ info.
111
+
112
+ Args:
113
+ info (dict): The service account private key info.
114
+ args: Additional arguments to pass to the constructor.
115
+ kwargs: Additional arguments to pass to the constructor.
116
+
117
+ Returns:
118
+ MatchServiceAsyncClient: The constructed client.
119
+ """
120
+ sa_info_func = (
121
+ MatchServiceClient.from_service_account_info.__func__ # type: ignore
122
+ )
123
+ return sa_info_func(MatchServiceAsyncClient, info, *args, **kwargs)
124
+
125
+ @classmethod
126
+ def from_service_account_file(cls, filename: str, *args, **kwargs):
127
+ """Creates an instance of this client using the provided credentials
128
+ file.
129
+
130
+ Args:
131
+ filename (str): The path to the service account private key json
132
+ file.
133
+ args: Additional arguments to pass to the constructor.
134
+ kwargs: Additional arguments to pass to the constructor.
135
+
136
+ Returns:
137
+ MatchServiceAsyncClient: The constructed client.
138
+ """
139
+ sa_file_func = (
140
+ MatchServiceClient.from_service_account_file.__func__ # type: ignore
141
+ )
142
+ return sa_file_func(MatchServiceAsyncClient, filename, *args, **kwargs)
143
+
144
+ from_service_account_json = from_service_account_file
145
+
146
+ @classmethod
147
+ def get_mtls_endpoint_and_cert_source(
148
+ cls, client_options: Optional[ClientOptions] = None
149
+ ):
150
+ """Return the API endpoint and client cert source for mutual TLS.
151
+
152
+ The client cert source is determined in the following order:
153
+ (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the
154
+ client cert source is None.
155
+ (2) if `client_options.client_cert_source` is provided, use the provided one; if the
156
+ default client cert source exists, use the default one; otherwise the client cert
157
+ source is None.
158
+
159
+ The API endpoint is determined in the following order:
160
+ (1) if `client_options.api_endpoint` if provided, use the provided one.
161
+ (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the
162
+ default mTLS endpoint; if the environment variable is "never", use the default API
163
+ endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise
164
+ use the default API endpoint.
165
+
166
+ More details can be found at https://google.aip.dev/auth/4114.
167
+
168
+ Args:
169
+ client_options (google.api_core.client_options.ClientOptions): Custom options for the
170
+ client. Only the `api_endpoint` and `client_cert_source` properties may be used
171
+ in this method.
172
+
173
+ Returns:
174
+ Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the
175
+ client cert source to use.
176
+
177
+ Raises:
178
+ google.auth.exceptions.MutualTLSChannelError: If any errors happen.
179
+ """
180
+ return MatchServiceClient.get_mtls_endpoint_and_cert_source(client_options) # type: ignore
181
+
182
+ @property
183
+ def transport(self) -> MatchServiceTransport:
184
+ """Returns the transport used by the client instance.
185
+
186
+ Returns:
187
+ MatchServiceTransport: The transport used by the client instance.
188
+ """
189
+ return self._client.transport
190
+
191
+ @property
192
+ def api_endpoint(self):
193
+ """Return the API endpoint used by the client instance.
194
+
195
+ Returns:
196
+ str: The API endpoint used by the client instance.
197
+ """
198
+ return self._client._api_endpoint
199
+
200
+ @property
201
+ def universe_domain(self) -> str:
202
+ """Return the universe domain used by the client instance.
203
+
204
+ Returns:
205
+ str: The universe domain used
206
+ by the client instance.
207
+ """
208
+ return self._client._universe_domain
209
+
210
+ get_transport_class = MatchServiceClient.get_transport_class
211
+
212
+ def __init__(
213
+ self,
214
+ *,
215
+ credentials: Optional[ga_credentials.Credentials] = None,
216
+ transport: Optional[
217
+ Union[str, MatchServiceTransport, Callable[..., MatchServiceTransport]]
218
+ ] = "grpc_asyncio",
219
+ client_options: Optional[ClientOptions] = None,
220
+ client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
221
+ ) -> None:
222
+ """Instantiates the match service async client.
223
+
224
+ Args:
225
+ credentials (Optional[google.auth.credentials.Credentials]): The
226
+ authorization credentials to attach to requests. These
227
+ credentials identify the application to the service; if none
228
+ are specified, the client will attempt to ascertain the
229
+ credentials from the environment.
230
+ transport (Optional[Union[str,MatchServiceTransport,Callable[..., MatchServiceTransport]]]):
231
+ The transport to use, or a Callable that constructs and returns a new transport to use.
232
+ If a Callable is given, it will be called with the same set of initialization
233
+ arguments as used in the MatchServiceTransport constructor.
234
+ If set to None, a transport is chosen automatically.
235
+ client_options (Optional[Union[google.api_core.client_options.ClientOptions, dict]]):
236
+ Custom options for the client.
237
+
238
+ 1. The ``api_endpoint`` property can be used to override the
239
+ default endpoint provided by the client when ``transport`` is
240
+ not explicitly provided. Only if this property is not set and
241
+ ``transport`` was not explicitly provided, the endpoint is
242
+ determined by the GOOGLE_API_USE_MTLS_ENDPOINT environment
243
+ variable, which have one of the following values:
244
+ "always" (always use the default mTLS endpoint), "never" (always
245
+ use the default regular endpoint) and "auto" (auto-switch to the
246
+ default mTLS endpoint if client certificate is present; this is
247
+ the default value).
248
+
249
+ 2. If the GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable
250
+ is "true", then the ``client_cert_source`` property can be used
251
+ to provide a client certificate for mTLS transport. If
252
+ not provided, the default SSL client certificate will be used if
253
+ present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is "false" or not
254
+ set, no client certificate will be used.
255
+
256
+ 3. The ``universe_domain`` property can be used to override the
257
+ default "googleapis.com" universe. Note that ``api_endpoint``
258
+ property still takes precedence; and ``universe_domain`` is
259
+ currently not supported for mTLS.
260
+
261
+ client_info (google.api_core.gapic_v1.client_info.ClientInfo):
262
+ The client info used to send a user-agent string along with
263
+ API requests. If ``None``, then default info will be used.
264
+ Generally, you only need to set this if you're developing
265
+ your own client library.
266
+
267
+ Raises:
268
+ google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport
269
+ creation failed for any reason.
270
+ """
271
+ self._client = MatchServiceClient(
272
+ credentials=credentials,
273
+ transport=transport,
274
+ client_options=client_options,
275
+ client_info=client_info,
276
+ )
277
+
278
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
279
+ std_logging.DEBUG
280
+ ): # pragma: NO COVER
281
+ _LOGGER.debug(
282
+ "Created client `google.cloud.aiplatform_v1.MatchServiceAsyncClient`.",
283
+ extra=(
284
+ {
285
+ "serviceName": "google.cloud.aiplatform.v1.MatchService",
286
+ "universeDomain": getattr(
287
+ self._client._transport._credentials, "universe_domain", ""
288
+ ),
289
+ "credentialsType": f"{type(self._client._transport._credentials).__module__}.{type(self._client._transport._credentials).__qualname__}",
290
+ "credentialsInfo": getattr(
291
+ self.transport._credentials, "get_cred_info", lambda: None
292
+ )(),
293
+ }
294
+ if hasattr(self._client._transport, "_credentials")
295
+ else {
296
+ "serviceName": "google.cloud.aiplatform.v1.MatchService",
297
+ "credentialsType": None,
298
+ }
299
+ ),
300
+ )
301
+
302
+ async def find_neighbors(
303
+ self,
304
+ request: Optional[Union[match_service.FindNeighborsRequest, dict]] = None,
305
+ *,
306
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
307
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
308
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
309
+ ) -> match_service.FindNeighborsResponse:
310
+ r"""Finds the nearest neighbors of each vector within the
311
+ request.
312
+
313
+ .. code-block:: python
314
+
315
+ # This snippet has been automatically generated and should be regarded as a
316
+ # code template only.
317
+ # It will require modifications to work:
318
+ # - It may require correct/in-range values for request initialization.
319
+ # - It may require specifying regional endpoints when creating the service
320
+ # client as shown in:
321
+ # https://googleapis.dev/python/google-api-core/latest/client_options.html
322
+ from google.cloud import aiplatform_v1
323
+
324
+ async def sample_find_neighbors():
325
+ # Create a client
326
+ client = aiplatform_v1.MatchServiceAsyncClient()
327
+
328
+ # Initialize request argument(s)
329
+ request = aiplatform_v1.FindNeighborsRequest(
330
+ index_endpoint="index_endpoint_value",
331
+ )
332
+
333
+ # Make the request
334
+ response = await client.find_neighbors(request=request)
335
+
336
+ # Handle the response
337
+ print(response)
338
+
339
+ Args:
340
+ request (Optional[Union[google.cloud.aiplatform_v1.types.FindNeighborsRequest, dict]]):
341
+ The request object. The request message for
342
+ [MatchService.FindNeighbors][google.cloud.aiplatform.v1.MatchService.FindNeighbors].
343
+ retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
344
+ should be retried.
345
+ timeout (float): The timeout for this request.
346
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
347
+ sent along with the request as metadata. Normally, each value must be of type `str`,
348
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
349
+ be of type `bytes`.
350
+
351
+ Returns:
352
+ google.cloud.aiplatform_v1.types.FindNeighborsResponse:
353
+ The response message for
354
+ [MatchService.FindNeighbors][google.cloud.aiplatform.v1.MatchService.FindNeighbors].
355
+
356
+ """
357
+ # Create or coerce a protobuf request object.
358
+ # - Use the request object if provided (there's no risk of modifying the input as
359
+ # there are no flattened fields), or create one.
360
+ if not isinstance(request, match_service.FindNeighborsRequest):
361
+ request = match_service.FindNeighborsRequest(request)
362
+
363
+ # Wrap the RPC method; this adds retry and timeout information,
364
+ # and friendly error handling.
365
+ rpc = self._client._transport._wrapped_methods[
366
+ self._client._transport.find_neighbors
367
+ ]
368
+
369
+ # Certain fields should be provided within the metadata header;
370
+ # add these here.
371
+ metadata = tuple(metadata) + (
372
+ gapic_v1.routing_header.to_grpc_metadata(
373
+ (("index_endpoint", request.index_endpoint),)
374
+ ),
375
+ )
376
+
377
+ # Validate the universe domain.
378
+ self._client._validate_universe_domain()
379
+
380
+ # Send the request.
381
+ response = await rpc(
382
+ request,
383
+ retry=retry,
384
+ timeout=timeout,
385
+ metadata=metadata,
386
+ )
387
+
388
+ # Done; return the response.
389
+ return response
390
+
391
+ async def read_index_datapoints(
392
+ self,
393
+ request: Optional[Union[match_service.ReadIndexDatapointsRequest, dict]] = None,
394
+ *,
395
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
396
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
397
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
398
+ ) -> match_service.ReadIndexDatapointsResponse:
399
+ r"""Reads the datapoints/vectors of the given IDs.
400
+ A maximum of 1000 datapoints can be retrieved in a
401
+ batch.
402
+
403
+ .. code-block:: python
404
+
405
+ # This snippet has been automatically generated and should be regarded as a
406
+ # code template only.
407
+ # It will require modifications to work:
408
+ # - It may require correct/in-range values for request initialization.
409
+ # - It may require specifying regional endpoints when creating the service
410
+ # client as shown in:
411
+ # https://googleapis.dev/python/google-api-core/latest/client_options.html
412
+ from google.cloud import aiplatform_v1
413
+
414
+ async def sample_read_index_datapoints():
415
+ # Create a client
416
+ client = aiplatform_v1.MatchServiceAsyncClient()
417
+
418
+ # Initialize request argument(s)
419
+ request = aiplatform_v1.ReadIndexDatapointsRequest(
420
+ index_endpoint="index_endpoint_value",
421
+ )
422
+
423
+ # Make the request
424
+ response = await client.read_index_datapoints(request=request)
425
+
426
+ # Handle the response
427
+ print(response)
428
+
429
+ Args:
430
+ request (Optional[Union[google.cloud.aiplatform_v1.types.ReadIndexDatapointsRequest, dict]]):
431
+ The request object. The request message for
432
+ [MatchService.ReadIndexDatapoints][google.cloud.aiplatform.v1.MatchService.ReadIndexDatapoints].
433
+ retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
434
+ should be retried.
435
+ timeout (float): The timeout for this request.
436
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
437
+ sent along with the request as metadata. Normally, each value must be of type `str`,
438
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
439
+ be of type `bytes`.
440
+
441
+ Returns:
442
+ google.cloud.aiplatform_v1.types.ReadIndexDatapointsResponse:
443
+ The response message for
444
+ [MatchService.ReadIndexDatapoints][google.cloud.aiplatform.v1.MatchService.ReadIndexDatapoints].
445
+
446
+ """
447
+ # Create or coerce a protobuf request object.
448
+ # - Use the request object if provided (there's no risk of modifying the input as
449
+ # there are no flattened fields), or create one.
450
+ if not isinstance(request, match_service.ReadIndexDatapointsRequest):
451
+ request = match_service.ReadIndexDatapointsRequest(request)
452
+
453
+ # Wrap the RPC method; this adds retry and timeout information,
454
+ # and friendly error handling.
455
+ rpc = self._client._transport._wrapped_methods[
456
+ self._client._transport.read_index_datapoints
457
+ ]
458
+
459
+ # Certain fields should be provided within the metadata header;
460
+ # add these here.
461
+ metadata = tuple(metadata) + (
462
+ gapic_v1.routing_header.to_grpc_metadata(
463
+ (("index_endpoint", request.index_endpoint),)
464
+ ),
465
+ )
466
+
467
+ # Validate the universe domain.
468
+ self._client._validate_universe_domain()
469
+
470
+ # Send the request.
471
+ response = await rpc(
472
+ request,
473
+ retry=retry,
474
+ timeout=timeout,
475
+ metadata=metadata,
476
+ )
477
+
478
+ # Done; return the response.
479
+ return response
480
+
481
+ async def list_operations(
482
+ self,
483
+ request: Optional[operations_pb2.ListOperationsRequest] = None,
484
+ *,
485
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
486
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
487
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
488
+ ) -> operations_pb2.ListOperationsResponse:
489
+ r"""Lists operations that match the specified filter in the request.
490
+
491
+ Args:
492
+ request (:class:`~.operations_pb2.ListOperationsRequest`):
493
+ The request object. Request message for
494
+ `ListOperations` method.
495
+ retry (google.api_core.retry_async.AsyncRetry): Designation of what errors,
496
+ if any, should be retried.
497
+ timeout (float): The timeout for this request.
498
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
499
+ sent along with the request as metadata. Normally, each value must be of type `str`,
500
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
501
+ be of type `bytes`.
502
+ Returns:
503
+ ~.operations_pb2.ListOperationsResponse:
504
+ Response message for ``ListOperations`` method.
505
+ """
506
+ # Create or coerce a protobuf request object.
507
+ # The request isn't a proto-plus wrapped type,
508
+ # so it must be constructed via keyword expansion.
509
+ if isinstance(request, dict):
510
+ request = operations_pb2.ListOperationsRequest(**request)
511
+
512
+ # Wrap the RPC method; this adds retry and timeout information,
513
+ # and friendly error handling.
514
+ rpc = self.transport._wrapped_methods[self._client._transport.list_operations]
515
+
516
+ # Certain fields should be provided within the metadata header;
517
+ # add these here.
518
+ metadata = tuple(metadata) + (
519
+ gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
520
+ )
521
+
522
+ # Validate the universe domain.
523
+ self._client._validate_universe_domain()
524
+
525
+ # Send the request.
526
+ response = await rpc(
527
+ request,
528
+ retry=retry,
529
+ timeout=timeout,
530
+ metadata=metadata,
531
+ )
532
+
533
+ # Done; return the response.
534
+ return response
535
+
536
+ async def get_operation(
537
+ self,
538
+ request: Optional[operations_pb2.GetOperationRequest] = None,
539
+ *,
540
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
541
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
542
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
543
+ ) -> operations_pb2.Operation:
544
+ r"""Gets the latest state of a long-running operation.
545
+
546
+ Args:
547
+ request (:class:`~.operations_pb2.GetOperationRequest`):
548
+ The request object. Request message for
549
+ `GetOperation` method.
550
+ retry (google.api_core.retry_async.AsyncRetry): Designation of what errors,
551
+ if any, should be retried.
552
+ timeout (float): The timeout for this request.
553
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
554
+ sent along with the request as metadata. Normally, each value must be of type `str`,
555
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
556
+ be of type `bytes`.
557
+ Returns:
558
+ ~.operations_pb2.Operation:
559
+ An ``Operation`` object.
560
+ """
561
+ # Create or coerce a protobuf request object.
562
+ # The request isn't a proto-plus wrapped type,
563
+ # so it must be constructed via keyword expansion.
564
+ if isinstance(request, dict):
565
+ request = operations_pb2.GetOperationRequest(**request)
566
+
567
+ # Wrap the RPC method; this adds retry and timeout information,
568
+ # and friendly error handling.
569
+ rpc = self.transport._wrapped_methods[self._client._transport.get_operation]
570
+
571
+ # Certain fields should be provided within the metadata header;
572
+ # add these here.
573
+ metadata = tuple(metadata) + (
574
+ gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
575
+ )
576
+
577
+ # Validate the universe domain.
578
+ self._client._validate_universe_domain()
579
+
580
+ # Send the request.
581
+ response = await rpc(
582
+ request,
583
+ retry=retry,
584
+ timeout=timeout,
585
+ metadata=metadata,
586
+ )
587
+
588
+ # Done; return the response.
589
+ return response
590
+
591
+ async def delete_operation(
592
+ self,
593
+ request: Optional[operations_pb2.DeleteOperationRequest] = None,
594
+ *,
595
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
596
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
597
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
598
+ ) -> None:
599
+ r"""Deletes a long-running operation.
600
+
601
+ This method indicates that the client is no longer interested
602
+ in the operation result. It does not cancel the operation.
603
+ If the server doesn't support this method, it returns
604
+ `google.rpc.Code.UNIMPLEMENTED`.
605
+
606
+ Args:
607
+ request (:class:`~.operations_pb2.DeleteOperationRequest`):
608
+ The request object. Request message for
609
+ `DeleteOperation` method.
610
+ retry (google.api_core.retry_async.AsyncRetry): Designation of what errors,
611
+ if any, should be retried.
612
+ timeout (float): The timeout for this request.
613
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
614
+ sent along with the request as metadata. Normally, each value must be of type `str`,
615
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
616
+ be of type `bytes`.
617
+ Returns:
618
+ None
619
+ """
620
+ # Create or coerce a protobuf request object.
621
+ # The request isn't a proto-plus wrapped type,
622
+ # so it must be constructed via keyword expansion.
623
+ if isinstance(request, dict):
624
+ request = operations_pb2.DeleteOperationRequest(**request)
625
+
626
+ # Wrap the RPC method; this adds retry and timeout information,
627
+ # and friendly error handling.
628
+ rpc = self.transport._wrapped_methods[self._client._transport.delete_operation]
629
+
630
+ # Certain fields should be provided within the metadata header;
631
+ # add these here.
632
+ metadata = tuple(metadata) + (
633
+ gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
634
+ )
635
+
636
+ # Validate the universe domain.
637
+ self._client._validate_universe_domain()
638
+
639
+ # Send the request.
640
+ await rpc(
641
+ request,
642
+ retry=retry,
643
+ timeout=timeout,
644
+ metadata=metadata,
645
+ )
646
+
647
+ async def cancel_operation(
648
+ self,
649
+ request: Optional[operations_pb2.CancelOperationRequest] = None,
650
+ *,
651
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
652
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
653
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
654
+ ) -> None:
655
+ r"""Starts asynchronous cancellation on a long-running operation.
656
+
657
+ The server makes a best effort to cancel the operation, but success
658
+ is not guaranteed. If the server doesn't support this method, it returns
659
+ `google.rpc.Code.UNIMPLEMENTED`.
660
+
661
+ Args:
662
+ request (:class:`~.operations_pb2.CancelOperationRequest`):
663
+ The request object. Request message for
664
+ `CancelOperation` method.
665
+ retry (google.api_core.retry_async.AsyncRetry): Designation of what errors,
666
+ if any, should be retried.
667
+ timeout (float): The timeout for this request.
668
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
669
+ sent along with the request as metadata. Normally, each value must be of type `str`,
670
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
671
+ be of type `bytes`.
672
+ Returns:
673
+ None
674
+ """
675
+ # Create or coerce a protobuf request object.
676
+ # The request isn't a proto-plus wrapped type,
677
+ # so it must be constructed via keyword expansion.
678
+ if isinstance(request, dict):
679
+ request = operations_pb2.CancelOperationRequest(**request)
680
+
681
+ # Wrap the RPC method; this adds retry and timeout information,
682
+ # and friendly error handling.
683
+ rpc = self.transport._wrapped_methods[self._client._transport.cancel_operation]
684
+
685
+ # Certain fields should be provided within the metadata header;
686
+ # add these here.
687
+ metadata = tuple(metadata) + (
688
+ gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
689
+ )
690
+
691
+ # Validate the universe domain.
692
+ self._client._validate_universe_domain()
693
+
694
+ # Send the request.
695
+ await rpc(
696
+ request,
697
+ retry=retry,
698
+ timeout=timeout,
699
+ metadata=metadata,
700
+ )
701
+
702
+ async def wait_operation(
703
+ self,
704
+ request: Optional[operations_pb2.WaitOperationRequest] = None,
705
+ *,
706
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
707
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
708
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
709
+ ) -> operations_pb2.Operation:
710
+ r"""Waits until the specified long-running operation is done or reaches at most
711
+ a specified timeout, returning the latest state.
712
+
713
+ If the operation is already done, the latest state is immediately returned.
714
+ If the timeout specified is greater than the default HTTP/RPC timeout, the HTTP/RPC
715
+ timeout is used. If the server does not support this method, it returns
716
+ `google.rpc.Code.UNIMPLEMENTED`.
717
+
718
+ Args:
719
+ request (:class:`~.operations_pb2.WaitOperationRequest`):
720
+ The request object. Request message for
721
+ `WaitOperation` method.
722
+ retry (google.api_core.retry_async.AsyncRetry): Designation of what errors,
723
+ if any, should be retried.
724
+ timeout (float): The timeout for this request.
725
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
726
+ sent along with the request as metadata. Normally, each value must be of type `str`,
727
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
728
+ be of type `bytes`.
729
+ Returns:
730
+ ~.operations_pb2.Operation:
731
+ An ``Operation`` object.
732
+ """
733
+ # Create or coerce a protobuf request object.
734
+ # The request isn't a proto-plus wrapped type,
735
+ # so it must be constructed via keyword expansion.
736
+ if isinstance(request, dict):
737
+ request = operations_pb2.WaitOperationRequest(**request)
738
+
739
+ # Wrap the RPC method; this adds retry and timeout information,
740
+ # and friendly error handling.
741
+ rpc = self.transport._wrapped_methods[self._client._transport.wait_operation]
742
+
743
+ # Certain fields should be provided within the metadata header;
744
+ # add these here.
745
+ metadata = tuple(metadata) + (
746
+ gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
747
+ )
748
+
749
+ # Validate the universe domain.
750
+ self._client._validate_universe_domain()
751
+
752
+ # Send the request.
753
+ response = await rpc(
754
+ request,
755
+ retry=retry,
756
+ timeout=timeout,
757
+ metadata=metadata,
758
+ )
759
+
760
+ # Done; return the response.
761
+ return response
762
+
763
+ async def set_iam_policy(
764
+ self,
765
+ request: Optional[iam_policy_pb2.SetIamPolicyRequest] = None,
766
+ *,
767
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
768
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
769
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
770
+ ) -> policy_pb2.Policy:
771
+ r"""Sets the IAM access control policy on the specified function.
772
+
773
+ Replaces any existing policy.
774
+
775
+ Args:
776
+ request (:class:`~.iam_policy_pb2.SetIamPolicyRequest`):
777
+ The request object. Request message for `SetIamPolicy`
778
+ method.
779
+ retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
780
+ should be retried.
781
+ timeout (float): The timeout for this request.
782
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
783
+ sent along with the request as metadata. Normally, each value must be of type `str`,
784
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
785
+ be of type `bytes`.
786
+ Returns:
787
+ ~.policy_pb2.Policy:
788
+ Defines an Identity and Access Management (IAM) policy.
789
+ It is used to specify access control policies for Cloud
790
+ Platform resources.
791
+ A ``Policy`` is a collection of ``bindings``. A
792
+ ``binding`` binds one or more ``members`` to a single
793
+ ``role``. Members can be user accounts, service
794
+ accounts, Google groups, and domains (such as G Suite).
795
+ A ``role`` is a named list of permissions (defined by
796
+ IAM or configured by users). A ``binding`` can
797
+ optionally specify a ``condition``, which is a logic
798
+ expression that further constrains the role binding
799
+ based on attributes about the request and/or target
800
+ resource.
801
+
802
+ **JSON Example**
803
+
804
+ ::
805
+
806
+ {
807
+ "bindings": [
808
+ {
809
+ "role": "roles/resourcemanager.organizationAdmin",
810
+ "members": [
811
+ "user:mike@example.com",
812
+ "group:admins@example.com",
813
+ "domain:google.com",
814
+ "serviceAccount:my-project-id@appspot.gserviceaccount.com"
815
+ ]
816
+ },
817
+ {
818
+ "role": "roles/resourcemanager.organizationViewer",
819
+ "members": ["user:eve@example.com"],
820
+ "condition": {
821
+ "title": "expirable access",
822
+ "description": "Does not grant access after Sep 2020",
823
+ "expression": "request.time <
824
+ timestamp('2020-10-01T00:00:00.000Z')",
825
+ }
826
+ }
827
+ ]
828
+ }
829
+
830
+ **YAML Example**
831
+
832
+ ::
833
+
834
+ bindings:
835
+ - members:
836
+ - user:mike@example.com
837
+ - group:admins@example.com
838
+ - domain:google.com
839
+ - serviceAccount:my-project-id@appspot.gserviceaccount.com
840
+ role: roles/resourcemanager.organizationAdmin
841
+ - members:
842
+ - user:eve@example.com
843
+ role: roles/resourcemanager.organizationViewer
844
+ condition:
845
+ title: expirable access
846
+ description: Does not grant access after Sep 2020
847
+ expression: request.time < timestamp('2020-10-01T00:00:00.000Z')
848
+
849
+ For a description of IAM and its features, see the `IAM
850
+ developer's
851
+ guide <https://cloud.google.com/iam/docs>`__.
852
+ """
853
+ # Create or coerce a protobuf request object.
854
+
855
+ # The request isn't a proto-plus wrapped type,
856
+ # so it must be constructed via keyword expansion.
857
+ if isinstance(request, dict):
858
+ request = iam_policy_pb2.SetIamPolicyRequest(**request)
859
+
860
+ # Wrap the RPC method; this adds retry and timeout information,
861
+ # and friendly error handling.
862
+ rpc = self.transport._wrapped_methods[self._client._transport.set_iam_policy]
863
+
864
+ # Certain fields should be provided within the metadata header;
865
+ # add these here.
866
+ metadata = tuple(metadata) + (
867
+ gapic_v1.routing_header.to_grpc_metadata((("resource", request.resource),)),
868
+ )
869
+
870
+ # Validate the universe domain.
871
+ self._client._validate_universe_domain()
872
+
873
+ # Send the request.
874
+ response = await rpc(
875
+ request,
876
+ retry=retry,
877
+ timeout=timeout,
878
+ metadata=metadata,
879
+ )
880
+
881
+ # Done; return the response.
882
+ return response
883
+
884
+ async def get_iam_policy(
885
+ self,
886
+ request: Optional[iam_policy_pb2.GetIamPolicyRequest] = None,
887
+ *,
888
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
889
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
890
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
891
+ ) -> policy_pb2.Policy:
892
+ r"""Gets the IAM access control policy for a function.
893
+
894
+ Returns an empty policy if the function exists and does not have a
895
+ policy set.
896
+
897
+ Args:
898
+ request (:class:`~.iam_policy_pb2.GetIamPolicyRequest`):
899
+ The request object. Request message for `GetIamPolicy`
900
+ method.
901
+ retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if
902
+ any, should be retried.
903
+ timeout (float): The timeout for this request.
904
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
905
+ sent along with the request as metadata. Normally, each value must be of type `str`,
906
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
907
+ be of type `bytes`.
908
+ Returns:
909
+ ~.policy_pb2.Policy:
910
+ Defines an Identity and Access Management (IAM) policy.
911
+ It is used to specify access control policies for Cloud
912
+ Platform resources.
913
+ A ``Policy`` is a collection of ``bindings``. A
914
+ ``binding`` binds one or more ``members`` to a single
915
+ ``role``. Members can be user accounts, service
916
+ accounts, Google groups, and domains (such as G Suite).
917
+ A ``role`` is a named list of permissions (defined by
918
+ IAM or configured by users). A ``binding`` can
919
+ optionally specify a ``condition``, which is a logic
920
+ expression that further constrains the role binding
921
+ based on attributes about the request and/or target
922
+ resource.
923
+
924
+ **JSON Example**
925
+
926
+ ::
927
+
928
+ {
929
+ "bindings": [
930
+ {
931
+ "role": "roles/resourcemanager.organizationAdmin",
932
+ "members": [
933
+ "user:mike@example.com",
934
+ "group:admins@example.com",
935
+ "domain:google.com",
936
+ "serviceAccount:my-project-id@appspot.gserviceaccount.com"
937
+ ]
938
+ },
939
+ {
940
+ "role": "roles/resourcemanager.organizationViewer",
941
+ "members": ["user:eve@example.com"],
942
+ "condition": {
943
+ "title": "expirable access",
944
+ "description": "Does not grant access after Sep 2020",
945
+ "expression": "request.time <
946
+ timestamp('2020-10-01T00:00:00.000Z')",
947
+ }
948
+ }
949
+ ]
950
+ }
951
+
952
+ **YAML Example**
953
+
954
+ ::
955
+
956
+ bindings:
957
+ - members:
958
+ - user:mike@example.com
959
+ - group:admins@example.com
960
+ - domain:google.com
961
+ - serviceAccount:my-project-id@appspot.gserviceaccount.com
962
+ role: roles/resourcemanager.organizationAdmin
963
+ - members:
964
+ - user:eve@example.com
965
+ role: roles/resourcemanager.organizationViewer
966
+ condition:
967
+ title: expirable access
968
+ description: Does not grant access after Sep 2020
969
+ expression: request.time < timestamp('2020-10-01T00:00:00.000Z')
970
+
971
+ For a description of IAM and its features, see the `IAM
972
+ developer's
973
+ guide <https://cloud.google.com/iam/docs>`__.
974
+ """
975
+ # Create or coerce a protobuf request object.
976
+
977
+ # The request isn't a proto-plus wrapped type,
978
+ # so it must be constructed via keyword expansion.
979
+ if isinstance(request, dict):
980
+ request = iam_policy_pb2.GetIamPolicyRequest(**request)
981
+
982
+ # Wrap the RPC method; this adds retry and timeout information,
983
+ # and friendly error handling.
984
+ rpc = self.transport._wrapped_methods[self._client._transport.get_iam_policy]
985
+
986
+ # Certain fields should be provided within the metadata header;
987
+ # add these here.
988
+ metadata = tuple(metadata) + (
989
+ gapic_v1.routing_header.to_grpc_metadata((("resource", request.resource),)),
990
+ )
991
+
992
+ # Validate the universe domain.
993
+ self._client._validate_universe_domain()
994
+
995
+ # Send the request.
996
+ response = await rpc(
997
+ request,
998
+ retry=retry,
999
+ timeout=timeout,
1000
+ metadata=metadata,
1001
+ )
1002
+
1003
+ # Done; return the response.
1004
+ return response
1005
+
1006
+ async def test_iam_permissions(
1007
+ self,
1008
+ request: Optional[iam_policy_pb2.TestIamPermissionsRequest] = None,
1009
+ *,
1010
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
1011
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
1012
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
1013
+ ) -> iam_policy_pb2.TestIamPermissionsResponse:
1014
+ r"""Tests the specified IAM permissions against the IAM access control
1015
+ policy for a function.
1016
+
1017
+ If the function does not exist, this will return an empty set
1018
+ of permissions, not a NOT_FOUND error.
1019
+
1020
+ Args:
1021
+ request (:class:`~.iam_policy_pb2.TestIamPermissionsRequest`):
1022
+ The request object. Request message for
1023
+ `TestIamPermissions` method.
1024
+ retry (google.api_core.retry_async.AsyncRetry): Designation of what errors,
1025
+ if any, should be retried.
1026
+ timeout (float): The timeout for this request.
1027
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1028
+ sent along with the request as metadata. Normally, each value must be of type `str`,
1029
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
1030
+ be of type `bytes`.
1031
+ Returns:
1032
+ ~.iam_policy_pb2.TestIamPermissionsResponse:
1033
+ Response message for ``TestIamPermissions`` method.
1034
+ """
1035
+ # Create or coerce a protobuf request object.
1036
+
1037
+ # The request isn't a proto-plus wrapped type,
1038
+ # so it must be constructed via keyword expansion.
1039
+ if isinstance(request, dict):
1040
+ request = iam_policy_pb2.TestIamPermissionsRequest(**request)
1041
+
1042
+ # Wrap the RPC method; this adds retry and timeout information,
1043
+ # and friendly error handling.
1044
+ rpc = self.transport._wrapped_methods[
1045
+ self._client._transport.test_iam_permissions
1046
+ ]
1047
+
1048
+ # Certain fields should be provided within the metadata header;
1049
+ # add these here.
1050
+ metadata = tuple(metadata) + (
1051
+ gapic_v1.routing_header.to_grpc_metadata((("resource", request.resource),)),
1052
+ )
1053
+
1054
+ # Validate the universe domain.
1055
+ self._client._validate_universe_domain()
1056
+
1057
+ # Send the request.
1058
+ response = await rpc(
1059
+ request,
1060
+ retry=retry,
1061
+ timeout=timeout,
1062
+ metadata=metadata,
1063
+ )
1064
+
1065
+ # Done; return the response.
1066
+ return response
1067
+
1068
+ async def get_location(
1069
+ self,
1070
+ request: Optional[locations_pb2.GetLocationRequest] = None,
1071
+ *,
1072
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
1073
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
1074
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
1075
+ ) -> locations_pb2.Location:
1076
+ r"""Gets information about a location.
1077
+
1078
+ Args:
1079
+ request (:class:`~.location_pb2.GetLocationRequest`):
1080
+ The request object. Request message for
1081
+ `GetLocation` method.
1082
+ retry (google.api_core.retry_async.AsyncRetry): Designation of what errors,
1083
+ if any, should be retried.
1084
+ timeout (float): The timeout for this request.
1085
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1086
+ sent along with the request as metadata. Normally, each value must be of type `str`,
1087
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
1088
+ be of type `bytes`.
1089
+ Returns:
1090
+ ~.location_pb2.Location:
1091
+ Location object.
1092
+ """
1093
+ # Create or coerce a protobuf request object.
1094
+ # The request isn't a proto-plus wrapped type,
1095
+ # so it must be constructed via keyword expansion.
1096
+ if isinstance(request, dict):
1097
+ request = locations_pb2.GetLocationRequest(**request)
1098
+
1099
+ # Wrap the RPC method; this adds retry and timeout information,
1100
+ # and friendly error handling.
1101
+ rpc = self.transport._wrapped_methods[self._client._transport.get_location]
1102
+
1103
+ # Certain fields should be provided within the metadata header;
1104
+ # add these here.
1105
+ metadata = tuple(metadata) + (
1106
+ gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
1107
+ )
1108
+
1109
+ # Validate the universe domain.
1110
+ self._client._validate_universe_domain()
1111
+
1112
+ # Send the request.
1113
+ response = await rpc(
1114
+ request,
1115
+ retry=retry,
1116
+ timeout=timeout,
1117
+ metadata=metadata,
1118
+ )
1119
+
1120
+ # Done; return the response.
1121
+ return response
1122
+
1123
+ async def list_locations(
1124
+ self,
1125
+ request: Optional[locations_pb2.ListLocationsRequest] = None,
1126
+ *,
1127
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
1128
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
1129
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
1130
+ ) -> locations_pb2.ListLocationsResponse:
1131
+ r"""Lists information about the supported locations for this service.
1132
+
1133
+ Args:
1134
+ request (:class:`~.location_pb2.ListLocationsRequest`):
1135
+ The request object. Request message for
1136
+ `ListLocations` method.
1137
+ retry (google.api_core.retry_async.AsyncRetry): Designation of what errors,
1138
+ if any, should be retried.
1139
+ timeout (float): The timeout for this request.
1140
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1141
+ sent along with the request as metadata. Normally, each value must be of type `str`,
1142
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
1143
+ be of type `bytes`.
1144
+ Returns:
1145
+ ~.location_pb2.ListLocationsResponse:
1146
+ Response message for ``ListLocations`` method.
1147
+ """
1148
+ # Create or coerce a protobuf request object.
1149
+ # The request isn't a proto-plus wrapped type,
1150
+ # so it must be constructed via keyword expansion.
1151
+ if isinstance(request, dict):
1152
+ request = locations_pb2.ListLocationsRequest(**request)
1153
+
1154
+ # Wrap the RPC method; this adds retry and timeout information,
1155
+ # and friendly error handling.
1156
+ rpc = self.transport._wrapped_methods[self._client._transport.list_locations]
1157
+
1158
+ # Certain fields should be provided within the metadata header;
1159
+ # add these here.
1160
+ metadata = tuple(metadata) + (
1161
+ gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
1162
+ )
1163
+
1164
+ # Validate the universe domain.
1165
+ self._client._validate_universe_domain()
1166
+
1167
+ # Send the request.
1168
+ response = await rpc(
1169
+ request,
1170
+ retry=retry,
1171
+ timeout=timeout,
1172
+ metadata=metadata,
1173
+ )
1174
+
1175
+ # Done; return the response.
1176
+ return response
1177
+
1178
+ async def __aenter__(self) -> "MatchServiceAsyncClient":
1179
+ return self
1180
+
1181
+ async def __aexit__(self, exc_type, exc, tb):
1182
+ await self.transport.close()
1183
+
1184
+
1185
+ DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
1186
+ gapic_version=package_version.__version__
1187
+ )
1188
+
1189
+ if hasattr(DEFAULT_CLIENT_INFO, "protobuf_runtime_version"): # pragma: NO COVER
1190
+ DEFAULT_CLIENT_INFO.protobuf_runtime_version = google.protobuf.__version__
1191
+
1192
+
1193
+ __all__ = ("MatchServiceAsyncClient",)
loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/match_service/client.py ADDED
@@ -0,0 +1,1695 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright 2025 Google LLC
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+ from collections import OrderedDict
17
+ from http import HTTPStatus
18
+ import json
19
+ import logging as std_logging
20
+ import os
21
+ import re
22
+ from typing import (
23
+ Dict,
24
+ Callable,
25
+ Mapping,
26
+ MutableMapping,
27
+ MutableSequence,
28
+ Optional,
29
+ Sequence,
30
+ Tuple,
31
+ Type,
32
+ Union,
33
+ cast,
34
+ )
35
+ import warnings
36
+
37
+ from google.cloud.aiplatform_v1 import gapic_version as package_version
38
+
39
+ from google.api_core import client_options as client_options_lib
40
+ from google.api_core import exceptions as core_exceptions
41
+ from google.api_core import gapic_v1
42
+ from google.api_core import retry as retries
43
+ from google.auth import credentials as ga_credentials # type: ignore
44
+ from google.auth.transport import mtls # type: ignore
45
+ from google.auth.transport.grpc import SslCredentials # type: ignore
46
+ from google.auth.exceptions import MutualTLSChannelError # type: ignore
47
+ from google.oauth2 import service_account # type: ignore
48
+ import google.protobuf
49
+
50
+ try:
51
+ OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault, None]
52
+ except AttributeError: # pragma: NO COVER
53
+ OptionalRetry = Union[retries.Retry, object, None] # type: ignore
54
+
55
+ try:
56
+ from google.api_core import client_logging # type: ignore
57
+
58
+ CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER
59
+ except ImportError: # pragma: NO COVER
60
+ CLIENT_LOGGING_SUPPORTED = False
61
+
62
+ _LOGGER = std_logging.getLogger(__name__)
63
+
64
+ from google.cloud.aiplatform_v1.types import index
65
+ from google.cloud.aiplatform_v1.types import match_service
66
+ from google.cloud.location import locations_pb2 # type: ignore
67
+ from google.iam.v1 import iam_policy_pb2 # type: ignore
68
+ from google.iam.v1 import policy_pb2 # type: ignore
69
+ from google.longrunning import operations_pb2 # type: ignore
70
+ from .transports.base import MatchServiceTransport, DEFAULT_CLIENT_INFO
71
+ from .transports.grpc import MatchServiceGrpcTransport
72
+ from .transports.grpc_asyncio import MatchServiceGrpcAsyncIOTransport
73
+ from .transports.rest import MatchServiceRestTransport
74
+
75
+ try:
76
+ from .transports.rest_asyncio import AsyncMatchServiceRestTransport
77
+
78
+ HAS_ASYNC_REST_DEPENDENCIES = True
79
+ except ImportError as e: # pragma: NO COVER
80
+ HAS_ASYNC_REST_DEPENDENCIES = False
81
+ ASYNC_REST_EXCEPTION = e
82
+
83
+
84
+ class MatchServiceClientMeta(type):
85
+ """Metaclass for the MatchService client.
86
+
87
+ This provides class-level methods for building and retrieving
88
+ support objects (e.g. transport) without polluting the client instance
89
+ objects.
90
+ """
91
+
92
+ _transport_registry = OrderedDict() # type: Dict[str, Type[MatchServiceTransport]]
93
+ _transport_registry["grpc"] = MatchServiceGrpcTransport
94
+ _transport_registry["grpc_asyncio"] = MatchServiceGrpcAsyncIOTransport
95
+ _transport_registry["rest"] = MatchServiceRestTransport
96
+ if HAS_ASYNC_REST_DEPENDENCIES: # pragma: NO COVER
97
+ _transport_registry["rest_asyncio"] = AsyncMatchServiceRestTransport
98
+
99
+ def get_transport_class(
100
+ cls,
101
+ label: Optional[str] = None,
102
+ ) -> Type[MatchServiceTransport]:
103
+ """Returns an appropriate transport class.
104
+
105
+ Args:
106
+ label: The name of the desired transport. If none is
107
+ provided, then the first transport in the registry is used.
108
+
109
+ Returns:
110
+ The transport class to use.
111
+ """
112
+ # If a specific transport is requested, return that one.
113
+ if (
114
+ label == "rest_asyncio" and not HAS_ASYNC_REST_DEPENDENCIES
115
+ ): # pragma: NO COVER
116
+ raise ASYNC_REST_EXCEPTION
117
+ if label:
118
+ return cls._transport_registry[label]
119
+
120
+ # No transport is requested; return the default (that is, the first one
121
+ # in the dictionary).
122
+ return next(iter(cls._transport_registry.values()))
123
+
124
+
125
+ class MatchServiceClient(metaclass=MatchServiceClientMeta):
126
+ """MatchService is a Google managed service for efficient vector
127
+ similarity search at scale.
128
+ """
129
+
130
+ @staticmethod
131
+ def _get_default_mtls_endpoint(api_endpoint):
132
+ """Converts api endpoint to mTLS endpoint.
133
+
134
+ Convert "*.sandbox.googleapis.com" and "*.googleapis.com" to
135
+ "*.mtls.sandbox.googleapis.com" and "*.mtls.googleapis.com" respectively.
136
+ Args:
137
+ api_endpoint (Optional[str]): the api endpoint to convert.
138
+ Returns:
139
+ str: converted mTLS api endpoint.
140
+ """
141
+ if not api_endpoint:
142
+ return api_endpoint
143
+
144
+ mtls_endpoint_re = re.compile(
145
+ r"(?P<name>[^.]+)(?P<mtls>\.mtls)?(?P<sandbox>\.sandbox)?(?P<googledomain>\.googleapis\.com)?"
146
+ )
147
+
148
+ m = mtls_endpoint_re.match(api_endpoint)
149
+ name, mtls, sandbox, googledomain = m.groups()
150
+ if mtls or not googledomain:
151
+ return api_endpoint
152
+
153
+ if sandbox:
154
+ return api_endpoint.replace(
155
+ "sandbox.googleapis.com", "mtls.sandbox.googleapis.com"
156
+ )
157
+
158
+ return api_endpoint.replace(".googleapis.com", ".mtls.googleapis.com")
159
+
160
+ # Note: DEFAULT_ENDPOINT is deprecated. Use _DEFAULT_ENDPOINT_TEMPLATE instead.
161
+ DEFAULT_ENDPOINT = "aiplatform.googleapis.com"
162
+ DEFAULT_MTLS_ENDPOINT = _get_default_mtls_endpoint.__func__( # type: ignore
163
+ DEFAULT_ENDPOINT
164
+ )
165
+
166
+ _DEFAULT_ENDPOINT_TEMPLATE = "aiplatform.{UNIVERSE_DOMAIN}"
167
+ _DEFAULT_UNIVERSE = "googleapis.com"
168
+
169
+ @staticmethod
170
+ def _use_client_cert_effective():
171
+ """Returns whether client certificate should be used for mTLS if the
172
+ google-auth version supports should_use_client_cert automatic mTLS enablement.
173
+
174
+ Alternatively, read from the GOOGLE_API_USE_CLIENT_CERTIFICATE env var.
175
+
176
+ Returns:
177
+ bool: whether client certificate should be used for mTLS
178
+ Raises:
179
+ ValueError: (If using a version of google-auth without should_use_client_cert and
180
+ GOOGLE_API_USE_CLIENT_CERTIFICATE is set to an unexpected value.)
181
+ """
182
+ # check if google-auth version supports should_use_client_cert for automatic mTLS enablement
183
+ if hasattr(mtls, "should_use_client_cert"): # pragma: NO COVER
184
+ return mtls.should_use_client_cert()
185
+ else: # pragma: NO COVER
186
+ # if unsupported, fallback to reading from env var
187
+ use_client_cert_str = os.getenv(
188
+ "GOOGLE_API_USE_CLIENT_CERTIFICATE", "false"
189
+ ).lower()
190
+ if use_client_cert_str not in ("true", "false"):
191
+ raise ValueError(
192
+ "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be"
193
+ " either `true` or `false`"
194
+ )
195
+ return use_client_cert_str == "true"
196
+
197
+ @classmethod
198
+ def from_service_account_info(cls, info: dict, *args, **kwargs):
199
+ """Creates an instance of this client using the provided credentials
200
+ info.
201
+
202
+ Args:
203
+ info (dict): The service account private key info.
204
+ args: Additional arguments to pass to the constructor.
205
+ kwargs: Additional arguments to pass to the constructor.
206
+
207
+ Returns:
208
+ MatchServiceClient: The constructed client.
209
+ """
210
+ credentials = service_account.Credentials.from_service_account_info(info)
211
+ kwargs["credentials"] = credentials
212
+ return cls(*args, **kwargs)
213
+
214
+ @classmethod
215
+ def from_service_account_file(cls, filename: str, *args, **kwargs):
216
+ """Creates an instance of this client using the provided credentials
217
+ file.
218
+
219
+ Args:
220
+ filename (str): The path to the service account private key json
221
+ file.
222
+ args: Additional arguments to pass to the constructor.
223
+ kwargs: Additional arguments to pass to the constructor.
224
+
225
+ Returns:
226
+ MatchServiceClient: The constructed client.
227
+ """
228
+ credentials = service_account.Credentials.from_service_account_file(filename)
229
+ kwargs["credentials"] = credentials
230
+ return cls(*args, **kwargs)
231
+
232
+ from_service_account_json = from_service_account_file
233
+
234
+ @property
235
+ def transport(self) -> MatchServiceTransport:
236
+ """Returns the transport used by the client instance.
237
+
238
+ Returns:
239
+ MatchServiceTransport: The transport used by the client
240
+ instance.
241
+ """
242
+ return self._transport
243
+
244
+ @staticmethod
245
+ def index_endpoint_path(
246
+ project: str,
247
+ location: str,
248
+ index_endpoint: str,
249
+ ) -> str:
250
+ """Returns a fully-qualified index_endpoint string."""
251
+ return "projects/{project}/locations/{location}/indexEndpoints/{index_endpoint}".format(
252
+ project=project,
253
+ location=location,
254
+ index_endpoint=index_endpoint,
255
+ )
256
+
257
+ @staticmethod
258
+ def parse_index_endpoint_path(path: str) -> Dict[str, str]:
259
+ """Parses a index_endpoint path into its component segments."""
260
+ m = re.match(
261
+ r"^projects/(?P<project>.+?)/locations/(?P<location>.+?)/indexEndpoints/(?P<index_endpoint>.+?)$",
262
+ path,
263
+ )
264
+ return m.groupdict() if m else {}
265
+
266
+ @staticmethod
267
+ def common_billing_account_path(
268
+ billing_account: str,
269
+ ) -> str:
270
+ """Returns a fully-qualified billing_account string."""
271
+ return "billingAccounts/{billing_account}".format(
272
+ billing_account=billing_account,
273
+ )
274
+
275
+ @staticmethod
276
+ def parse_common_billing_account_path(path: str) -> Dict[str, str]:
277
+ """Parse a billing_account path into its component segments."""
278
+ m = re.match(r"^billingAccounts/(?P<billing_account>.+?)$", path)
279
+ return m.groupdict() if m else {}
280
+
281
+ @staticmethod
282
+ def common_folder_path(
283
+ folder: str,
284
+ ) -> str:
285
+ """Returns a fully-qualified folder string."""
286
+ return "folders/{folder}".format(
287
+ folder=folder,
288
+ )
289
+
290
+ @staticmethod
291
+ def parse_common_folder_path(path: str) -> Dict[str, str]:
292
+ """Parse a folder path into its component segments."""
293
+ m = re.match(r"^folders/(?P<folder>.+?)$", path)
294
+ return m.groupdict() if m else {}
295
+
296
+ @staticmethod
297
+ def common_organization_path(
298
+ organization: str,
299
+ ) -> str:
300
+ """Returns a fully-qualified organization string."""
301
+ return "organizations/{organization}".format(
302
+ organization=organization,
303
+ )
304
+
305
+ @staticmethod
306
+ def parse_common_organization_path(path: str) -> Dict[str, str]:
307
+ """Parse a organization path into its component segments."""
308
+ m = re.match(r"^organizations/(?P<organization>.+?)$", path)
309
+ return m.groupdict() if m else {}
310
+
311
+ @staticmethod
312
+ def common_project_path(
313
+ project: str,
314
+ ) -> str:
315
+ """Returns a fully-qualified project string."""
316
+ return "projects/{project}".format(
317
+ project=project,
318
+ )
319
+
320
+ @staticmethod
321
+ def parse_common_project_path(path: str) -> Dict[str, str]:
322
+ """Parse a project path into its component segments."""
323
+ m = re.match(r"^projects/(?P<project>.+?)$", path)
324
+ return m.groupdict() if m else {}
325
+
326
+ @staticmethod
327
+ def common_location_path(
328
+ project: str,
329
+ location: str,
330
+ ) -> str:
331
+ """Returns a fully-qualified location string."""
332
+ return "projects/{project}/locations/{location}".format(
333
+ project=project,
334
+ location=location,
335
+ )
336
+
337
+ @staticmethod
338
+ def parse_common_location_path(path: str) -> Dict[str, str]:
339
+ """Parse a location path into its component segments."""
340
+ m = re.match(r"^projects/(?P<project>.+?)/locations/(?P<location>.+?)$", path)
341
+ return m.groupdict() if m else {}
342
+
343
+ @classmethod
344
+ def get_mtls_endpoint_and_cert_source(
345
+ cls, client_options: Optional[client_options_lib.ClientOptions] = None
346
+ ):
347
+ """Deprecated. Return the API endpoint and client cert source for mutual TLS.
348
+
349
+ The client cert source is determined in the following order:
350
+ (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the
351
+ client cert source is None.
352
+ (2) if `client_options.client_cert_source` is provided, use the provided one; if the
353
+ default client cert source exists, use the default one; otherwise the client cert
354
+ source is None.
355
+
356
+ The API endpoint is determined in the following order:
357
+ (1) if `client_options.api_endpoint` if provided, use the provided one.
358
+ (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the
359
+ default mTLS endpoint; if the environment variable is "never", use the default API
360
+ endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise
361
+ use the default API endpoint.
362
+
363
+ More details can be found at https://google.aip.dev/auth/4114.
364
+
365
+ Args:
366
+ client_options (google.api_core.client_options.ClientOptions): Custom options for the
367
+ client. Only the `api_endpoint` and `client_cert_source` properties may be used
368
+ in this method.
369
+
370
+ Returns:
371
+ Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the
372
+ client cert source to use.
373
+
374
+ Raises:
375
+ google.auth.exceptions.MutualTLSChannelError: If any errors happen.
376
+ """
377
+
378
+ warnings.warn(
379
+ "get_mtls_endpoint_and_cert_source is deprecated. Use the api_endpoint property instead.",
380
+ DeprecationWarning,
381
+ )
382
+ if client_options is None:
383
+ client_options = client_options_lib.ClientOptions()
384
+ use_client_cert = MatchServiceClient._use_client_cert_effective()
385
+ use_mtls_endpoint = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto")
386
+ if use_mtls_endpoint not in ("auto", "never", "always"):
387
+ raise MutualTLSChannelError(
388
+ "Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`"
389
+ )
390
+
391
+ # Figure out the client cert source to use.
392
+ client_cert_source = None
393
+ if use_client_cert:
394
+ if client_options.client_cert_source:
395
+ client_cert_source = client_options.client_cert_source
396
+ elif mtls.has_default_client_cert_source():
397
+ client_cert_source = mtls.default_client_cert_source()
398
+
399
+ # Figure out which api endpoint to use.
400
+ if client_options.api_endpoint is not None:
401
+ api_endpoint = client_options.api_endpoint
402
+ elif use_mtls_endpoint == "always" or (
403
+ use_mtls_endpoint == "auto" and client_cert_source
404
+ ):
405
+ api_endpoint = cls.DEFAULT_MTLS_ENDPOINT
406
+ else:
407
+ api_endpoint = cls.DEFAULT_ENDPOINT
408
+
409
+ return api_endpoint, client_cert_source
410
+
411
+ @staticmethod
412
+ def _read_environment_variables():
413
+ """Returns the environment variables used by the client.
414
+
415
+ Returns:
416
+ Tuple[bool, str, str]: returns the GOOGLE_API_USE_CLIENT_CERTIFICATE,
417
+ GOOGLE_API_USE_MTLS_ENDPOINT, and GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variables.
418
+
419
+ Raises:
420
+ ValueError: If GOOGLE_API_USE_CLIENT_CERTIFICATE is not
421
+ any of ["true", "false"].
422
+ google.auth.exceptions.MutualTLSChannelError: If GOOGLE_API_USE_MTLS_ENDPOINT
423
+ is not any of ["auto", "never", "always"].
424
+ """
425
+ use_client_cert = MatchServiceClient._use_client_cert_effective()
426
+ use_mtls_endpoint = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto").lower()
427
+ universe_domain_env = os.getenv("GOOGLE_CLOUD_UNIVERSE_DOMAIN")
428
+ if use_mtls_endpoint not in ("auto", "never", "always"):
429
+ raise MutualTLSChannelError(
430
+ "Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`"
431
+ )
432
+ return use_client_cert, use_mtls_endpoint, universe_domain_env
433
+
434
+ @staticmethod
435
+ def _get_client_cert_source(provided_cert_source, use_cert_flag):
436
+ """Return the client cert source to be used by the client.
437
+
438
+ Args:
439
+ provided_cert_source (bytes): The client certificate source provided.
440
+ use_cert_flag (bool): A flag indicating whether to use the client certificate.
441
+
442
+ Returns:
443
+ bytes or None: The client cert source to be used by the client.
444
+ """
445
+ client_cert_source = None
446
+ if use_cert_flag:
447
+ if provided_cert_source:
448
+ client_cert_source = provided_cert_source
449
+ elif mtls.has_default_client_cert_source():
450
+ client_cert_source = mtls.default_client_cert_source()
451
+ return client_cert_source
452
+
453
+ @staticmethod
454
+ def _get_api_endpoint(
455
+ api_override, client_cert_source, universe_domain, use_mtls_endpoint
456
+ ):
457
+ """Return the API endpoint used by the client.
458
+
459
+ Args:
460
+ api_override (str): The API endpoint override. If specified, this is always
461
+ the return value of this function and the other arguments are not used.
462
+ client_cert_source (bytes): The client certificate source used by the client.
463
+ universe_domain (str): The universe domain used by the client.
464
+ use_mtls_endpoint (str): How to use the mTLS endpoint, which depends also on the other parameters.
465
+ Possible values are "always", "auto", or "never".
466
+
467
+ Returns:
468
+ str: The API endpoint to be used by the client.
469
+ """
470
+ if api_override is not None:
471
+ api_endpoint = api_override
472
+ elif use_mtls_endpoint == "always" or (
473
+ use_mtls_endpoint == "auto" and client_cert_source
474
+ ):
475
+ _default_universe = MatchServiceClient._DEFAULT_UNIVERSE
476
+ if universe_domain != _default_universe:
477
+ raise MutualTLSChannelError(
478
+ f"mTLS is not supported in any universe other than {_default_universe}."
479
+ )
480
+ api_endpoint = MatchServiceClient.DEFAULT_MTLS_ENDPOINT
481
+ else:
482
+ api_endpoint = MatchServiceClient._DEFAULT_ENDPOINT_TEMPLATE.format(
483
+ UNIVERSE_DOMAIN=universe_domain
484
+ )
485
+ return api_endpoint
486
+
487
+ @staticmethod
488
+ def _get_universe_domain(
489
+ client_universe_domain: Optional[str], universe_domain_env: Optional[str]
490
+ ) -> str:
491
+ """Return the universe domain used by the client.
492
+
493
+ Args:
494
+ client_universe_domain (Optional[str]): The universe domain configured via the client options.
495
+ universe_domain_env (Optional[str]): The universe domain configured via the "GOOGLE_CLOUD_UNIVERSE_DOMAIN" environment variable.
496
+
497
+ Returns:
498
+ str: The universe domain to be used by the client.
499
+
500
+ Raises:
501
+ ValueError: If the universe domain is an empty string.
502
+ """
503
+ universe_domain = MatchServiceClient._DEFAULT_UNIVERSE
504
+ if client_universe_domain is not None:
505
+ universe_domain = client_universe_domain
506
+ elif universe_domain_env is not None:
507
+ universe_domain = universe_domain_env
508
+ if len(universe_domain.strip()) == 0:
509
+ raise ValueError("Universe Domain cannot be an empty string.")
510
+ return universe_domain
511
+
512
+ def _validate_universe_domain(self):
513
+ """Validates client's and credentials' universe domains are consistent.
514
+
515
+ Returns:
516
+ bool: True iff the configured universe domain is valid.
517
+
518
+ Raises:
519
+ ValueError: If the configured universe domain is not valid.
520
+ """
521
+
522
+ # NOTE (b/349488459): universe validation is disabled until further notice.
523
+ return True
524
+
525
+ def _add_cred_info_for_auth_errors(
526
+ self, error: core_exceptions.GoogleAPICallError
527
+ ) -> None:
528
+ """Adds credential info string to error details for 401/403/404 errors.
529
+
530
+ Args:
531
+ error (google.api_core.exceptions.GoogleAPICallError): The error to add the cred info.
532
+ """
533
+ if error.code not in [
534
+ HTTPStatus.UNAUTHORIZED,
535
+ HTTPStatus.FORBIDDEN,
536
+ HTTPStatus.NOT_FOUND,
537
+ ]:
538
+ return
539
+
540
+ cred = self._transport._credentials
541
+
542
+ # get_cred_info is only available in google-auth>=2.35.0
543
+ if not hasattr(cred, "get_cred_info"):
544
+ return
545
+
546
+ # ignore the type check since pypy test fails when get_cred_info
547
+ # is not available
548
+ cred_info = cred.get_cred_info() # type: ignore
549
+ if cred_info and hasattr(error._details, "append"):
550
+ error._details.append(json.dumps(cred_info))
551
+
552
+ @property
553
+ def api_endpoint(self):
554
+ """Return the API endpoint used by the client instance.
555
+
556
+ Returns:
557
+ str: The API endpoint used by the client instance.
558
+ """
559
+ return self._api_endpoint
560
+
561
+ @property
562
+ def universe_domain(self) -> str:
563
+ """Return the universe domain used by the client instance.
564
+
565
+ Returns:
566
+ str: The universe domain used by the client instance.
567
+ """
568
+ return self._universe_domain
569
+
570
+ def __init__(
571
+ self,
572
+ *,
573
+ credentials: Optional[ga_credentials.Credentials] = None,
574
+ transport: Optional[
575
+ Union[str, MatchServiceTransport, Callable[..., MatchServiceTransport]]
576
+ ] = None,
577
+ client_options: Optional[Union[client_options_lib.ClientOptions, dict]] = None,
578
+ client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
579
+ ) -> None:
580
+ """Instantiates the match service client.
581
+
582
+ Args:
583
+ credentials (Optional[google.auth.credentials.Credentials]): The
584
+ authorization credentials to attach to requests. These
585
+ credentials identify the application to the service; if none
586
+ are specified, the client will attempt to ascertain the
587
+ credentials from the environment.
588
+ transport (Optional[Union[str,MatchServiceTransport,Callable[..., MatchServiceTransport]]]):
589
+ The transport to use, or a Callable that constructs and returns a new transport.
590
+ If a Callable is given, it will be called with the same set of initialization
591
+ arguments as used in the MatchServiceTransport constructor.
592
+ If set to None, a transport is chosen automatically.
593
+ client_options (Optional[Union[google.api_core.client_options.ClientOptions, dict]]):
594
+ Custom options for the client.
595
+
596
+ 1. The ``api_endpoint`` property can be used to override the
597
+ default endpoint provided by the client when ``transport`` is
598
+ not explicitly provided. Only if this property is not set and
599
+ ``transport`` was not explicitly provided, the endpoint is
600
+ determined by the GOOGLE_API_USE_MTLS_ENDPOINT environment
601
+ variable, which have one of the following values:
602
+ "always" (always use the default mTLS endpoint), "never" (always
603
+ use the default regular endpoint) and "auto" (auto-switch to the
604
+ default mTLS endpoint if client certificate is present; this is
605
+ the default value).
606
+
607
+ 2. If the GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable
608
+ is "true", then the ``client_cert_source`` property can be used
609
+ to provide a client certificate for mTLS transport. If
610
+ not provided, the default SSL client certificate will be used if
611
+ present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is "false" or not
612
+ set, no client certificate will be used.
613
+
614
+ 3. The ``universe_domain`` property can be used to override the
615
+ default "googleapis.com" universe. Note that the ``api_endpoint``
616
+ property still takes precedence; and ``universe_domain`` is
617
+ currently not supported for mTLS.
618
+
619
+ client_info (google.api_core.gapic_v1.client_info.ClientInfo):
620
+ The client info used to send a user-agent string along with
621
+ API requests. If ``None``, then default info will be used.
622
+ Generally, you only need to set this if you're developing
623
+ your own client library.
624
+
625
+ Raises:
626
+ google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport
627
+ creation failed for any reason.
628
+ """
629
+ self._client_options = client_options
630
+ if isinstance(self._client_options, dict):
631
+ self._client_options = client_options_lib.from_dict(self._client_options)
632
+ if self._client_options is None:
633
+ self._client_options = client_options_lib.ClientOptions()
634
+ self._client_options = cast(
635
+ client_options_lib.ClientOptions, self._client_options
636
+ )
637
+
638
+ universe_domain_opt = getattr(self._client_options, "universe_domain", None)
639
+
640
+ self._use_client_cert, self._use_mtls_endpoint, self._universe_domain_env = (
641
+ MatchServiceClient._read_environment_variables()
642
+ )
643
+ self._client_cert_source = MatchServiceClient._get_client_cert_source(
644
+ self._client_options.client_cert_source, self._use_client_cert
645
+ )
646
+ self._universe_domain = MatchServiceClient._get_universe_domain(
647
+ universe_domain_opt, self._universe_domain_env
648
+ )
649
+ self._api_endpoint = None # updated below, depending on `transport`
650
+
651
+ # Initialize the universe domain validation.
652
+ self._is_universe_domain_valid = False
653
+
654
+ if CLIENT_LOGGING_SUPPORTED: # pragma: NO COVER
655
+ # Setup logging.
656
+ client_logging.initialize_logging()
657
+
658
+ api_key_value = getattr(self._client_options, "api_key", None)
659
+ if api_key_value and credentials:
660
+ raise ValueError(
661
+ "client_options.api_key and credentials are mutually exclusive"
662
+ )
663
+
664
+ # Save or instantiate the transport.
665
+ # Ordinarily, we provide the transport, but allowing a custom transport
666
+ # instance provides an extensibility point for unusual situations.
667
+ transport_provided = isinstance(transport, MatchServiceTransport)
668
+ if transport_provided:
669
+ # transport is a MatchServiceTransport instance.
670
+ if credentials or self._client_options.credentials_file or api_key_value:
671
+ raise ValueError(
672
+ "When providing a transport instance, "
673
+ "provide its credentials directly."
674
+ )
675
+ if self._client_options.scopes:
676
+ raise ValueError(
677
+ "When providing a transport instance, provide its scopes "
678
+ "directly."
679
+ )
680
+ self._transport = cast(MatchServiceTransport, transport)
681
+ self._api_endpoint = self._transport.host
682
+
683
+ self._api_endpoint = self._api_endpoint or MatchServiceClient._get_api_endpoint(
684
+ self._client_options.api_endpoint,
685
+ self._client_cert_source,
686
+ self._universe_domain,
687
+ self._use_mtls_endpoint,
688
+ )
689
+
690
+ if not transport_provided:
691
+ transport_init: Union[
692
+ Type[MatchServiceTransport], Callable[..., MatchServiceTransport]
693
+ ] = (
694
+ MatchServiceClient.get_transport_class(transport)
695
+ if isinstance(transport, str) or transport is None
696
+ else cast(Callable[..., MatchServiceTransport], transport)
697
+ )
698
+
699
+ if "rest_asyncio" in str(transport_init):
700
+ unsupported_params = {
701
+ "google.api_core.client_options.ClientOptions.credentials_file": self._client_options.credentials_file,
702
+ "google.api_core.client_options.ClientOptions.scopes": self._client_options.scopes,
703
+ "google.api_core.client_options.ClientOptions.quota_project_id": self._client_options.quota_project_id,
704
+ "google.api_core.client_options.ClientOptions.client_cert_source": self._client_options.client_cert_source,
705
+ "google.api_core.client_options.ClientOptions.api_audience": self._client_options.api_audience,
706
+ }
707
+ provided_unsupported_params = [
708
+ name
709
+ for name, value in unsupported_params.items()
710
+ if value is not None
711
+ ]
712
+ if provided_unsupported_params:
713
+ raise core_exceptions.AsyncRestUnsupportedParameterError( # type: ignore
714
+ f"The following provided parameters are not supported for `transport=rest_asyncio`: {', '.join(provided_unsupported_params)}"
715
+ )
716
+ self._transport = transport_init(
717
+ credentials=credentials,
718
+ host=self._api_endpoint,
719
+ client_info=client_info,
720
+ )
721
+ return
722
+
723
+ import google.auth._default # type: ignore
724
+
725
+ if api_key_value and hasattr(
726
+ google.auth._default, "get_api_key_credentials"
727
+ ):
728
+ credentials = google.auth._default.get_api_key_credentials(
729
+ api_key_value
730
+ )
731
+
732
+ # initialize with the provided callable or the passed in class
733
+ self._transport = transport_init(
734
+ credentials=credentials,
735
+ credentials_file=self._client_options.credentials_file,
736
+ host=self._api_endpoint,
737
+ scopes=self._client_options.scopes,
738
+ client_cert_source_for_mtls=self._client_cert_source,
739
+ quota_project_id=self._client_options.quota_project_id,
740
+ client_info=client_info,
741
+ always_use_jwt_access=True,
742
+ api_audience=self._client_options.api_audience,
743
+ )
744
+
745
+ if "async" not in str(self._transport):
746
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
747
+ std_logging.DEBUG
748
+ ): # pragma: NO COVER
749
+ _LOGGER.debug(
750
+ "Created client `google.cloud.aiplatform_v1.MatchServiceClient`.",
751
+ extra=(
752
+ {
753
+ "serviceName": "google.cloud.aiplatform.v1.MatchService",
754
+ "universeDomain": getattr(
755
+ self._transport._credentials, "universe_domain", ""
756
+ ),
757
+ "credentialsType": f"{type(self._transport._credentials).__module__}.{type(self._transport._credentials).__qualname__}",
758
+ "credentialsInfo": getattr(
759
+ self.transport._credentials,
760
+ "get_cred_info",
761
+ lambda: None,
762
+ )(),
763
+ }
764
+ if hasattr(self._transport, "_credentials")
765
+ else {
766
+ "serviceName": "google.cloud.aiplatform.v1.MatchService",
767
+ "credentialsType": None,
768
+ }
769
+ ),
770
+ )
771
+
772
+ def find_neighbors(
773
+ self,
774
+ request: Optional[Union[match_service.FindNeighborsRequest, dict]] = None,
775
+ *,
776
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
777
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
778
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
779
+ ) -> match_service.FindNeighborsResponse:
780
+ r"""Finds the nearest neighbors of each vector within the
781
+ request.
782
+
783
+ .. code-block:: python
784
+
785
+ # This snippet has been automatically generated and should be regarded as a
786
+ # code template only.
787
+ # It will require modifications to work:
788
+ # - It may require correct/in-range values for request initialization.
789
+ # - It may require specifying regional endpoints when creating the service
790
+ # client as shown in:
791
+ # https://googleapis.dev/python/google-api-core/latest/client_options.html
792
+ from google.cloud import aiplatform_v1
793
+
794
+ def sample_find_neighbors():
795
+ # Create a client
796
+ client = aiplatform_v1.MatchServiceClient()
797
+
798
+ # Initialize request argument(s)
799
+ request = aiplatform_v1.FindNeighborsRequest(
800
+ index_endpoint="index_endpoint_value",
801
+ )
802
+
803
+ # Make the request
804
+ response = client.find_neighbors(request=request)
805
+
806
+ # Handle the response
807
+ print(response)
808
+
809
+ Args:
810
+ request (Union[google.cloud.aiplatform_v1.types.FindNeighborsRequest, dict]):
811
+ The request object. The request message for
812
+ [MatchService.FindNeighbors][google.cloud.aiplatform.v1.MatchService.FindNeighbors].
813
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
814
+ should be retried.
815
+ timeout (float): The timeout for this request.
816
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
817
+ sent along with the request as metadata. Normally, each value must be of type `str`,
818
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
819
+ be of type `bytes`.
820
+
821
+ Returns:
822
+ google.cloud.aiplatform_v1.types.FindNeighborsResponse:
823
+ The response message for
824
+ [MatchService.FindNeighbors][google.cloud.aiplatform.v1.MatchService.FindNeighbors].
825
+
826
+ """
827
+ # Create or coerce a protobuf request object.
828
+ # - Use the request object if provided (there's no risk of modifying the input as
829
+ # there are no flattened fields), or create one.
830
+ if not isinstance(request, match_service.FindNeighborsRequest):
831
+ request = match_service.FindNeighborsRequest(request)
832
+
833
+ # Wrap the RPC method; this adds retry and timeout information,
834
+ # and friendly error handling.
835
+ rpc = self._transport._wrapped_methods[self._transport.find_neighbors]
836
+
837
+ # Certain fields should be provided within the metadata header;
838
+ # add these here.
839
+ metadata = tuple(metadata) + (
840
+ gapic_v1.routing_header.to_grpc_metadata(
841
+ (("index_endpoint", request.index_endpoint),)
842
+ ),
843
+ )
844
+
845
+ # Validate the universe domain.
846
+ self._validate_universe_domain()
847
+
848
+ # Send the request.
849
+ response = rpc(
850
+ request,
851
+ retry=retry,
852
+ timeout=timeout,
853
+ metadata=metadata,
854
+ )
855
+
856
+ # Done; return the response.
857
+ return response
858
+
859
+ def read_index_datapoints(
860
+ self,
861
+ request: Optional[Union[match_service.ReadIndexDatapointsRequest, dict]] = None,
862
+ *,
863
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
864
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
865
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
866
+ ) -> match_service.ReadIndexDatapointsResponse:
867
+ r"""Reads the datapoints/vectors of the given IDs.
868
+ A maximum of 1000 datapoints can be retrieved in a
869
+ batch.
870
+
871
+ .. code-block:: python
872
+
873
+ # This snippet has been automatically generated and should be regarded as a
874
+ # code template only.
875
+ # It will require modifications to work:
876
+ # - It may require correct/in-range values for request initialization.
877
+ # - It may require specifying regional endpoints when creating the service
878
+ # client as shown in:
879
+ # https://googleapis.dev/python/google-api-core/latest/client_options.html
880
+ from google.cloud import aiplatform_v1
881
+
882
+ def sample_read_index_datapoints():
883
+ # Create a client
884
+ client = aiplatform_v1.MatchServiceClient()
885
+
886
+ # Initialize request argument(s)
887
+ request = aiplatform_v1.ReadIndexDatapointsRequest(
888
+ index_endpoint="index_endpoint_value",
889
+ )
890
+
891
+ # Make the request
892
+ response = client.read_index_datapoints(request=request)
893
+
894
+ # Handle the response
895
+ print(response)
896
+
897
+ Args:
898
+ request (Union[google.cloud.aiplatform_v1.types.ReadIndexDatapointsRequest, dict]):
899
+ The request object. The request message for
900
+ [MatchService.ReadIndexDatapoints][google.cloud.aiplatform.v1.MatchService.ReadIndexDatapoints].
901
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
902
+ should be retried.
903
+ timeout (float): The timeout for this request.
904
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
905
+ sent along with the request as metadata. Normally, each value must be of type `str`,
906
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
907
+ be of type `bytes`.
908
+
909
+ Returns:
910
+ google.cloud.aiplatform_v1.types.ReadIndexDatapointsResponse:
911
+ The response message for
912
+ [MatchService.ReadIndexDatapoints][google.cloud.aiplatform.v1.MatchService.ReadIndexDatapoints].
913
+
914
+ """
915
+ # Create or coerce a protobuf request object.
916
+ # - Use the request object if provided (there's no risk of modifying the input as
917
+ # there are no flattened fields), or create one.
918
+ if not isinstance(request, match_service.ReadIndexDatapointsRequest):
919
+ request = match_service.ReadIndexDatapointsRequest(request)
920
+
921
+ # Wrap the RPC method; this adds retry and timeout information,
922
+ # and friendly error handling.
923
+ rpc = self._transport._wrapped_methods[self._transport.read_index_datapoints]
924
+
925
+ # Certain fields should be provided within the metadata header;
926
+ # add these here.
927
+ metadata = tuple(metadata) + (
928
+ gapic_v1.routing_header.to_grpc_metadata(
929
+ (("index_endpoint", request.index_endpoint),)
930
+ ),
931
+ )
932
+
933
+ # Validate the universe domain.
934
+ self._validate_universe_domain()
935
+
936
+ # Send the request.
937
+ response = rpc(
938
+ request,
939
+ retry=retry,
940
+ timeout=timeout,
941
+ metadata=metadata,
942
+ )
943
+
944
+ # Done; return the response.
945
+ return response
946
+
947
+ def __enter__(self) -> "MatchServiceClient":
948
+ return self
949
+
950
+ def __exit__(self, type, value, traceback):
951
+ """Releases underlying transport's resources.
952
+
953
+ .. warning::
954
+ ONLY use as a context manager if the transport is NOT shared
955
+ with other clients! Exiting the with block will CLOSE the transport
956
+ and may cause errors in other clients!
957
+ """
958
+ self.transport.close()
959
+
960
+ def list_operations(
961
+ self,
962
+ request: Optional[operations_pb2.ListOperationsRequest] = None,
963
+ *,
964
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
965
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
966
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
967
+ ) -> operations_pb2.ListOperationsResponse:
968
+ r"""Lists operations that match the specified filter in the request.
969
+
970
+ Args:
971
+ request (:class:`~.operations_pb2.ListOperationsRequest`):
972
+ The request object. Request message for
973
+ `ListOperations` method.
974
+ retry (google.api_core.retry.Retry): Designation of what errors,
975
+ if any, should be retried.
976
+ timeout (float): The timeout for this request.
977
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
978
+ sent along with the request as metadata. Normally, each value must be of type `str`,
979
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
980
+ be of type `bytes`.
981
+ Returns:
982
+ ~.operations_pb2.ListOperationsResponse:
983
+ Response message for ``ListOperations`` method.
984
+ """
985
+ # Create or coerce a protobuf request object.
986
+ # The request isn't a proto-plus wrapped type,
987
+ # so it must be constructed via keyword expansion.
988
+ if isinstance(request, dict):
989
+ request = operations_pb2.ListOperationsRequest(**request)
990
+
991
+ # Wrap the RPC method; this adds retry and timeout information,
992
+ # and friendly error handling.
993
+ rpc = self._transport._wrapped_methods[self._transport.list_operations]
994
+
995
+ # Certain fields should be provided within the metadata header;
996
+ # add these here.
997
+ metadata = tuple(metadata) + (
998
+ gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
999
+ )
1000
+
1001
+ # Validate the universe domain.
1002
+ self._validate_universe_domain()
1003
+
1004
+ try:
1005
+ # Send the request.
1006
+ response = rpc(
1007
+ request,
1008
+ retry=retry,
1009
+ timeout=timeout,
1010
+ metadata=metadata,
1011
+ )
1012
+
1013
+ # Done; return the response.
1014
+ return response
1015
+ except core_exceptions.GoogleAPICallError as e:
1016
+ self._add_cred_info_for_auth_errors(e)
1017
+ raise e
1018
+
1019
+ def get_operation(
1020
+ self,
1021
+ request: Optional[operations_pb2.GetOperationRequest] = None,
1022
+ *,
1023
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
1024
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
1025
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
1026
+ ) -> operations_pb2.Operation:
1027
+ r"""Gets the latest state of a long-running operation.
1028
+
1029
+ Args:
1030
+ request (:class:`~.operations_pb2.GetOperationRequest`):
1031
+ The request object. Request message for
1032
+ `GetOperation` method.
1033
+ retry (google.api_core.retry.Retry): Designation of what errors,
1034
+ if any, should be retried.
1035
+ timeout (float): The timeout for this request.
1036
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1037
+ sent along with the request as metadata. Normally, each value must be of type `str`,
1038
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
1039
+ be of type `bytes`.
1040
+ Returns:
1041
+ ~.operations_pb2.Operation:
1042
+ An ``Operation`` object.
1043
+ """
1044
+ # Create or coerce a protobuf request object.
1045
+ # The request isn't a proto-plus wrapped type,
1046
+ # so it must be constructed via keyword expansion.
1047
+ if isinstance(request, dict):
1048
+ request = operations_pb2.GetOperationRequest(**request)
1049
+
1050
+ # Wrap the RPC method; this adds retry and timeout information,
1051
+ # and friendly error handling.
1052
+ rpc = self._transport._wrapped_methods[self._transport.get_operation]
1053
+
1054
+ # Certain fields should be provided within the metadata header;
1055
+ # add these here.
1056
+ metadata = tuple(metadata) + (
1057
+ gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
1058
+ )
1059
+
1060
+ # Validate the universe domain.
1061
+ self._validate_universe_domain()
1062
+
1063
+ try:
1064
+ # Send the request.
1065
+ response = rpc(
1066
+ request,
1067
+ retry=retry,
1068
+ timeout=timeout,
1069
+ metadata=metadata,
1070
+ )
1071
+
1072
+ # Done; return the response.
1073
+ return response
1074
+ except core_exceptions.GoogleAPICallError as e:
1075
+ self._add_cred_info_for_auth_errors(e)
1076
+ raise e
1077
+
1078
+ def delete_operation(
1079
+ self,
1080
+ request: Optional[operations_pb2.DeleteOperationRequest] = None,
1081
+ *,
1082
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
1083
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
1084
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
1085
+ ) -> None:
1086
+ r"""Deletes a long-running operation.
1087
+
1088
+ This method indicates that the client is no longer interested
1089
+ in the operation result. It does not cancel the operation.
1090
+ If the server doesn't support this method, it returns
1091
+ `google.rpc.Code.UNIMPLEMENTED`.
1092
+
1093
+ Args:
1094
+ request (:class:`~.operations_pb2.DeleteOperationRequest`):
1095
+ The request object. Request message for
1096
+ `DeleteOperation` method.
1097
+ retry (google.api_core.retry.Retry): Designation of what errors,
1098
+ if any, should be retried.
1099
+ timeout (float): The timeout for this request.
1100
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1101
+ sent along with the request as metadata. Normally, each value must be of type `str`,
1102
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
1103
+ be of type `bytes`.
1104
+ Returns:
1105
+ None
1106
+ """
1107
+ # Create or coerce a protobuf request object.
1108
+ # The request isn't a proto-plus wrapped type,
1109
+ # so it must be constructed via keyword expansion.
1110
+ if isinstance(request, dict):
1111
+ request = operations_pb2.DeleteOperationRequest(**request)
1112
+
1113
+ # Wrap the RPC method; this adds retry and timeout information,
1114
+ # and friendly error handling.
1115
+ rpc = self._transport._wrapped_methods[self._transport.delete_operation]
1116
+
1117
+ # Certain fields should be provided within the metadata header;
1118
+ # add these here.
1119
+ metadata = tuple(metadata) + (
1120
+ gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
1121
+ )
1122
+
1123
+ # Validate the universe domain.
1124
+ self._validate_universe_domain()
1125
+
1126
+ # Send the request.
1127
+ rpc(
1128
+ request,
1129
+ retry=retry,
1130
+ timeout=timeout,
1131
+ metadata=metadata,
1132
+ )
1133
+
1134
+ def cancel_operation(
1135
+ self,
1136
+ request: Optional[operations_pb2.CancelOperationRequest] = None,
1137
+ *,
1138
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
1139
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
1140
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
1141
+ ) -> None:
1142
+ r"""Starts asynchronous cancellation on a long-running operation.
1143
+
1144
+ The server makes a best effort to cancel the operation, but success
1145
+ is not guaranteed. If the server doesn't support this method, it returns
1146
+ `google.rpc.Code.UNIMPLEMENTED`.
1147
+
1148
+ Args:
1149
+ request (:class:`~.operations_pb2.CancelOperationRequest`):
1150
+ The request object. Request message for
1151
+ `CancelOperation` method.
1152
+ retry (google.api_core.retry.Retry): Designation of what errors,
1153
+ if any, should be retried.
1154
+ timeout (float): The timeout for this request.
1155
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1156
+ sent along with the request as metadata. Normally, each value must be of type `str`,
1157
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
1158
+ be of type `bytes`.
1159
+ Returns:
1160
+ None
1161
+ """
1162
+ # Create or coerce a protobuf request object.
1163
+ # The request isn't a proto-plus wrapped type,
1164
+ # so it must be constructed via keyword expansion.
1165
+ if isinstance(request, dict):
1166
+ request = operations_pb2.CancelOperationRequest(**request)
1167
+
1168
+ # Wrap the RPC method; this adds retry and timeout information,
1169
+ # and friendly error handling.
1170
+ rpc = self._transport._wrapped_methods[self._transport.cancel_operation]
1171
+
1172
+ # Certain fields should be provided within the metadata header;
1173
+ # add these here.
1174
+ metadata = tuple(metadata) + (
1175
+ gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
1176
+ )
1177
+
1178
+ # Validate the universe domain.
1179
+ self._validate_universe_domain()
1180
+
1181
+ # Send the request.
1182
+ rpc(
1183
+ request,
1184
+ retry=retry,
1185
+ timeout=timeout,
1186
+ metadata=metadata,
1187
+ )
1188
+
1189
+ def wait_operation(
1190
+ self,
1191
+ request: Optional[operations_pb2.WaitOperationRequest] = None,
1192
+ *,
1193
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
1194
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
1195
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
1196
+ ) -> operations_pb2.Operation:
1197
+ r"""Waits until the specified long-running operation is done or reaches at most
1198
+ a specified timeout, returning the latest state.
1199
+
1200
+ If the operation is already done, the latest state is immediately returned.
1201
+ If the timeout specified is greater than the default HTTP/RPC timeout, the HTTP/RPC
1202
+ timeout is used. If the server does not support this method, it returns
1203
+ `google.rpc.Code.UNIMPLEMENTED`.
1204
+
1205
+ Args:
1206
+ request (:class:`~.operations_pb2.WaitOperationRequest`):
1207
+ The request object. Request message for
1208
+ `WaitOperation` method.
1209
+ retry (google.api_core.retry.Retry): Designation of what errors,
1210
+ if any, should be retried.
1211
+ timeout (float): The timeout for this request.
1212
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1213
+ sent along with the request as metadata. Normally, each value must be of type `str`,
1214
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
1215
+ be of type `bytes`.
1216
+ Returns:
1217
+ ~.operations_pb2.Operation:
1218
+ An ``Operation`` object.
1219
+ """
1220
+ # Create or coerce a protobuf request object.
1221
+ # The request isn't a proto-plus wrapped type,
1222
+ # so it must be constructed via keyword expansion.
1223
+ if isinstance(request, dict):
1224
+ request = operations_pb2.WaitOperationRequest(**request)
1225
+
1226
+ # Wrap the RPC method; this adds retry and timeout information,
1227
+ # and friendly error handling.
1228
+ rpc = self._transport._wrapped_methods[self._transport.wait_operation]
1229
+
1230
+ # Certain fields should be provided within the metadata header;
1231
+ # add these here.
1232
+ metadata = tuple(metadata) + (
1233
+ gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
1234
+ )
1235
+
1236
+ # Validate the universe domain.
1237
+ self._validate_universe_domain()
1238
+
1239
+ try:
1240
+ # Send the request.
1241
+ response = rpc(
1242
+ request,
1243
+ retry=retry,
1244
+ timeout=timeout,
1245
+ metadata=metadata,
1246
+ )
1247
+
1248
+ # Done; return the response.
1249
+ return response
1250
+ except core_exceptions.GoogleAPICallError as e:
1251
+ self._add_cred_info_for_auth_errors(e)
1252
+ raise e
1253
+
1254
+ def set_iam_policy(
1255
+ self,
1256
+ request: Optional[iam_policy_pb2.SetIamPolicyRequest] = None,
1257
+ *,
1258
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
1259
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
1260
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
1261
+ ) -> policy_pb2.Policy:
1262
+ r"""Sets the IAM access control policy on the specified function.
1263
+
1264
+ Replaces any existing policy.
1265
+
1266
+ Args:
1267
+ request (:class:`~.iam_policy_pb2.SetIamPolicyRequest`):
1268
+ The request object. Request message for `SetIamPolicy`
1269
+ method.
1270
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
1271
+ should be retried.
1272
+ timeout (float): The timeout for this request.
1273
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1274
+ sent along with the request as metadata. Normally, each value must be of type `str`,
1275
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
1276
+ be of type `bytes`.
1277
+ Returns:
1278
+ ~.policy_pb2.Policy:
1279
+ Defines an Identity and Access Management (IAM) policy.
1280
+ It is used to specify access control policies for Cloud
1281
+ Platform resources.
1282
+ A ``Policy`` is a collection of ``bindings``. A
1283
+ ``binding`` binds one or more ``members`` to a single
1284
+ ``role``. Members can be user accounts, service
1285
+ accounts, Google groups, and domains (such as G Suite).
1286
+ A ``role`` is a named list of permissions (defined by
1287
+ IAM or configured by users). A ``binding`` can
1288
+ optionally specify a ``condition``, which is a logic
1289
+ expression that further constrains the role binding
1290
+ based on attributes about the request and/or target
1291
+ resource.
1292
+
1293
+ **JSON Example**
1294
+
1295
+ ::
1296
+
1297
+ {
1298
+ "bindings": [
1299
+ {
1300
+ "role": "roles/resourcemanager.organizationAdmin",
1301
+ "members": [
1302
+ "user:mike@example.com",
1303
+ "group:admins@example.com",
1304
+ "domain:google.com",
1305
+ "serviceAccount:my-project-id@appspot.gserviceaccount.com"
1306
+ ]
1307
+ },
1308
+ {
1309
+ "role": "roles/resourcemanager.organizationViewer",
1310
+ "members": ["user:eve@example.com"],
1311
+ "condition": {
1312
+ "title": "expirable access",
1313
+ "description": "Does not grant access after Sep 2020",
1314
+ "expression": "request.time <
1315
+ timestamp('2020-10-01T00:00:00.000Z')",
1316
+ }
1317
+ }
1318
+ ]
1319
+ }
1320
+
1321
+ **YAML Example**
1322
+
1323
+ ::
1324
+
1325
+ bindings:
1326
+ - members:
1327
+ - user:mike@example.com
1328
+ - group:admins@example.com
1329
+ - domain:google.com
1330
+ - serviceAccount:my-project-id@appspot.gserviceaccount.com
1331
+ role: roles/resourcemanager.organizationAdmin
1332
+ - members:
1333
+ - user:eve@example.com
1334
+ role: roles/resourcemanager.organizationViewer
1335
+ condition:
1336
+ title: expirable access
1337
+ description: Does not grant access after Sep 2020
1338
+ expression: request.time < timestamp('2020-10-01T00:00:00.000Z')
1339
+
1340
+ For a description of IAM and its features, see the `IAM
1341
+ developer's
1342
+ guide <https://cloud.google.com/iam/docs>`__.
1343
+ """
1344
+ # Create or coerce a protobuf request object.
1345
+
1346
+ # The request isn't a proto-plus wrapped type,
1347
+ # so it must be constructed via keyword expansion.
1348
+ if isinstance(request, dict):
1349
+ request = iam_policy_pb2.SetIamPolicyRequest(**request)
1350
+
1351
+ # Wrap the RPC method; this adds retry and timeout information,
1352
+ # and friendly error handling.
1353
+ rpc = self._transport._wrapped_methods[self._transport.set_iam_policy]
1354
+
1355
+ # Certain fields should be provided within the metadata header;
1356
+ # add these here.
1357
+ metadata = tuple(metadata) + (
1358
+ gapic_v1.routing_header.to_grpc_metadata((("resource", request.resource),)),
1359
+ )
1360
+
1361
+ # Validate the universe domain.
1362
+ self._validate_universe_domain()
1363
+
1364
+ try:
1365
+ # Send the request.
1366
+ response = rpc(
1367
+ request,
1368
+ retry=retry,
1369
+ timeout=timeout,
1370
+ metadata=metadata,
1371
+ )
1372
+
1373
+ # Done; return the response.
1374
+ return response
1375
+ except core_exceptions.GoogleAPICallError as e:
1376
+ self._add_cred_info_for_auth_errors(e)
1377
+ raise e
1378
+
1379
+ def get_iam_policy(
1380
+ self,
1381
+ request: Optional[iam_policy_pb2.GetIamPolicyRequest] = None,
1382
+ *,
1383
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
1384
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
1385
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
1386
+ ) -> policy_pb2.Policy:
1387
+ r"""Gets the IAM access control policy for a function.
1388
+
1389
+ Returns an empty policy if the function exists and does not have a
1390
+ policy set.
1391
+
1392
+ Args:
1393
+ request (:class:`~.iam_policy_pb2.GetIamPolicyRequest`):
1394
+ The request object. Request message for `GetIamPolicy`
1395
+ method.
1396
+ retry (google.api_core.retry.Retry): Designation of what errors, if
1397
+ any, should be retried.
1398
+ timeout (float): The timeout for this request.
1399
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1400
+ sent along with the request as metadata. Normally, each value must be of type `str`,
1401
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
1402
+ be of type `bytes`.
1403
+ Returns:
1404
+ ~.policy_pb2.Policy:
1405
+ Defines an Identity and Access Management (IAM) policy.
1406
+ It is used to specify access control policies for Cloud
1407
+ Platform resources.
1408
+ A ``Policy`` is a collection of ``bindings``. A
1409
+ ``binding`` binds one or more ``members`` to a single
1410
+ ``role``. Members can be user accounts, service
1411
+ accounts, Google groups, and domains (such as G Suite).
1412
+ A ``role`` is a named list of permissions (defined by
1413
+ IAM or configured by users). A ``binding`` can
1414
+ optionally specify a ``condition``, which is a logic
1415
+ expression that further constrains the role binding
1416
+ based on attributes about the request and/or target
1417
+ resource.
1418
+
1419
+ **JSON Example**
1420
+
1421
+ ::
1422
+
1423
+ {
1424
+ "bindings": [
1425
+ {
1426
+ "role": "roles/resourcemanager.organizationAdmin",
1427
+ "members": [
1428
+ "user:mike@example.com",
1429
+ "group:admins@example.com",
1430
+ "domain:google.com",
1431
+ "serviceAccount:my-project-id@appspot.gserviceaccount.com"
1432
+ ]
1433
+ },
1434
+ {
1435
+ "role": "roles/resourcemanager.organizationViewer",
1436
+ "members": ["user:eve@example.com"],
1437
+ "condition": {
1438
+ "title": "expirable access",
1439
+ "description": "Does not grant access after Sep 2020",
1440
+ "expression": "request.time <
1441
+ timestamp('2020-10-01T00:00:00.000Z')",
1442
+ }
1443
+ }
1444
+ ]
1445
+ }
1446
+
1447
+ **YAML Example**
1448
+
1449
+ ::
1450
+
1451
+ bindings:
1452
+ - members:
1453
+ - user:mike@example.com
1454
+ - group:admins@example.com
1455
+ - domain:google.com
1456
+ - serviceAccount:my-project-id@appspot.gserviceaccount.com
1457
+ role: roles/resourcemanager.organizationAdmin
1458
+ - members:
1459
+ - user:eve@example.com
1460
+ role: roles/resourcemanager.organizationViewer
1461
+ condition:
1462
+ title: expirable access
1463
+ description: Does not grant access after Sep 2020
1464
+ expression: request.time < timestamp('2020-10-01T00:00:00.000Z')
1465
+
1466
+ For a description of IAM and its features, see the `IAM
1467
+ developer's
1468
+ guide <https://cloud.google.com/iam/docs>`__.
1469
+ """
1470
+ # Create or coerce a protobuf request object.
1471
+
1472
+ # The request isn't a proto-plus wrapped type,
1473
+ # so it must be constructed via keyword expansion.
1474
+ if isinstance(request, dict):
1475
+ request = iam_policy_pb2.GetIamPolicyRequest(**request)
1476
+
1477
+ # Wrap the RPC method; this adds retry and timeout information,
1478
+ # and friendly error handling.
1479
+ rpc = self._transport._wrapped_methods[self._transport.get_iam_policy]
1480
+
1481
+ # Certain fields should be provided within the metadata header;
1482
+ # add these here.
1483
+ metadata = tuple(metadata) + (
1484
+ gapic_v1.routing_header.to_grpc_metadata((("resource", request.resource),)),
1485
+ )
1486
+
1487
+ # Validate the universe domain.
1488
+ self._validate_universe_domain()
1489
+
1490
+ try:
1491
+ # Send the request.
1492
+ response = rpc(
1493
+ request,
1494
+ retry=retry,
1495
+ timeout=timeout,
1496
+ metadata=metadata,
1497
+ )
1498
+
1499
+ # Done; return the response.
1500
+ return response
1501
+ except core_exceptions.GoogleAPICallError as e:
1502
+ self._add_cred_info_for_auth_errors(e)
1503
+ raise e
1504
+
1505
+ def test_iam_permissions(
1506
+ self,
1507
+ request: Optional[iam_policy_pb2.TestIamPermissionsRequest] = None,
1508
+ *,
1509
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
1510
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
1511
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
1512
+ ) -> iam_policy_pb2.TestIamPermissionsResponse:
1513
+ r"""Tests the specified IAM permissions against the IAM access control
1514
+ policy for a function.
1515
+
1516
+ If the function does not exist, this will return an empty set
1517
+ of permissions, not a NOT_FOUND error.
1518
+
1519
+ Args:
1520
+ request (:class:`~.iam_policy_pb2.TestIamPermissionsRequest`):
1521
+ The request object. Request message for
1522
+ `TestIamPermissions` method.
1523
+ retry (google.api_core.retry.Retry): Designation of what errors,
1524
+ if any, should be retried.
1525
+ timeout (float): The timeout for this request.
1526
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1527
+ sent along with the request as metadata. Normally, each value must be of type `str`,
1528
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
1529
+ be of type `bytes`.
1530
+ Returns:
1531
+ ~.iam_policy_pb2.TestIamPermissionsResponse:
1532
+ Response message for ``TestIamPermissions`` method.
1533
+ """
1534
+ # Create or coerce a protobuf request object.
1535
+
1536
+ # The request isn't a proto-plus wrapped type,
1537
+ # so it must be constructed via keyword expansion.
1538
+ if isinstance(request, dict):
1539
+ request = iam_policy_pb2.TestIamPermissionsRequest(**request)
1540
+
1541
+ # Wrap the RPC method; this adds retry and timeout information,
1542
+ # and friendly error handling.
1543
+ rpc = self._transport._wrapped_methods[self._transport.test_iam_permissions]
1544
+
1545
+ # Certain fields should be provided within the metadata header;
1546
+ # add these here.
1547
+ metadata = tuple(metadata) + (
1548
+ gapic_v1.routing_header.to_grpc_metadata((("resource", request.resource),)),
1549
+ )
1550
+
1551
+ # Validate the universe domain.
1552
+ self._validate_universe_domain()
1553
+
1554
+ try:
1555
+ # Send the request.
1556
+ response = rpc(
1557
+ request,
1558
+ retry=retry,
1559
+ timeout=timeout,
1560
+ metadata=metadata,
1561
+ )
1562
+
1563
+ # Done; return the response.
1564
+ return response
1565
+ except core_exceptions.GoogleAPICallError as e:
1566
+ self._add_cred_info_for_auth_errors(e)
1567
+ raise e
1568
+
1569
+ def get_location(
1570
+ self,
1571
+ request: Optional[locations_pb2.GetLocationRequest] = None,
1572
+ *,
1573
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
1574
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
1575
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
1576
+ ) -> locations_pb2.Location:
1577
+ r"""Gets information about a location.
1578
+
1579
+ Args:
1580
+ request (:class:`~.location_pb2.GetLocationRequest`):
1581
+ The request object. Request message for
1582
+ `GetLocation` method.
1583
+ retry (google.api_core.retry.Retry): Designation of what errors,
1584
+ if any, should be retried.
1585
+ timeout (float): The timeout for this request.
1586
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1587
+ sent along with the request as metadata. Normally, each value must be of type `str`,
1588
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
1589
+ be of type `bytes`.
1590
+ Returns:
1591
+ ~.location_pb2.Location:
1592
+ Location object.
1593
+ """
1594
+ # Create or coerce a protobuf request object.
1595
+ # The request isn't a proto-plus wrapped type,
1596
+ # so it must be constructed via keyword expansion.
1597
+ if isinstance(request, dict):
1598
+ request = locations_pb2.GetLocationRequest(**request)
1599
+
1600
+ # Wrap the RPC method; this adds retry and timeout information,
1601
+ # and friendly error handling.
1602
+ rpc = self._transport._wrapped_methods[self._transport.get_location]
1603
+
1604
+ # Certain fields should be provided within the metadata header;
1605
+ # add these here.
1606
+ metadata = tuple(metadata) + (
1607
+ gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
1608
+ )
1609
+
1610
+ # Validate the universe domain.
1611
+ self._validate_universe_domain()
1612
+
1613
+ try:
1614
+ # Send the request.
1615
+ response = rpc(
1616
+ request,
1617
+ retry=retry,
1618
+ timeout=timeout,
1619
+ metadata=metadata,
1620
+ )
1621
+
1622
+ # Done; return the response.
1623
+ return response
1624
+ except core_exceptions.GoogleAPICallError as e:
1625
+ self._add_cred_info_for_auth_errors(e)
1626
+ raise e
1627
+
1628
+ def list_locations(
1629
+ self,
1630
+ request: Optional[locations_pb2.ListLocationsRequest] = None,
1631
+ *,
1632
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
1633
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
1634
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
1635
+ ) -> locations_pb2.ListLocationsResponse:
1636
+ r"""Lists information about the supported locations for this service.
1637
+
1638
+ Args:
1639
+ request (:class:`~.location_pb2.ListLocationsRequest`):
1640
+ The request object. Request message for
1641
+ `ListLocations` method.
1642
+ retry (google.api_core.retry.Retry): Designation of what errors,
1643
+ if any, should be retried.
1644
+ timeout (float): The timeout for this request.
1645
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1646
+ sent along with the request as metadata. Normally, each value must be of type `str`,
1647
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
1648
+ be of type `bytes`.
1649
+ Returns:
1650
+ ~.location_pb2.ListLocationsResponse:
1651
+ Response message for ``ListLocations`` method.
1652
+ """
1653
+ # Create or coerce a protobuf request object.
1654
+ # The request isn't a proto-plus wrapped type,
1655
+ # so it must be constructed via keyword expansion.
1656
+ if isinstance(request, dict):
1657
+ request = locations_pb2.ListLocationsRequest(**request)
1658
+
1659
+ # Wrap the RPC method; this adds retry and timeout information,
1660
+ # and friendly error handling.
1661
+ rpc = self._transport._wrapped_methods[self._transport.list_locations]
1662
+
1663
+ # Certain fields should be provided within the metadata header;
1664
+ # add these here.
1665
+ metadata = tuple(metadata) + (
1666
+ gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
1667
+ )
1668
+
1669
+ # Validate the universe domain.
1670
+ self._validate_universe_domain()
1671
+
1672
+ try:
1673
+ # Send the request.
1674
+ response = rpc(
1675
+ request,
1676
+ retry=retry,
1677
+ timeout=timeout,
1678
+ metadata=metadata,
1679
+ )
1680
+
1681
+ # Done; return the response.
1682
+ return response
1683
+ except core_exceptions.GoogleAPICallError as e:
1684
+ self._add_cred_info_for_auth_errors(e)
1685
+ raise e
1686
+
1687
+
1688
+ DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
1689
+ gapic_version=package_version.__version__
1690
+ )
1691
+
1692
+ if hasattr(DEFAULT_CLIENT_INFO, "protobuf_runtime_version"): # pragma: NO COVER
1693
+ DEFAULT_CLIENT_INFO.protobuf_runtime_version = google.protobuf.__version__
1694
+
1695
+ __all__ = ("MatchServiceClient",)
loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/match_service/transports/__init__.py ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright 2025 Google LLC
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+ from collections import OrderedDict
17
+ from typing import Dict, Type, Tuple
18
+
19
+ from .base import MatchServiceTransport
20
+ from .grpc import MatchServiceGrpcTransport
21
+ from .grpc_asyncio import MatchServiceGrpcAsyncIOTransport
22
+ from .rest import MatchServiceRestTransport
23
+ from .rest import MatchServiceRestInterceptor
24
+
25
+ ASYNC_REST_CLASSES: Tuple[str, ...]
26
+ try:
27
+ from .rest_asyncio import AsyncMatchServiceRestTransport
28
+ from .rest_asyncio import AsyncMatchServiceRestInterceptor
29
+
30
+ ASYNC_REST_CLASSES = (
31
+ "AsyncMatchServiceRestTransport",
32
+ "AsyncMatchServiceRestInterceptor",
33
+ )
34
+ HAS_REST_ASYNC = True
35
+ except ImportError: # pragma: NO COVER
36
+ ASYNC_REST_CLASSES = ()
37
+ HAS_REST_ASYNC = False
38
+
39
+
40
+ # Compile a registry of transports.
41
+ _transport_registry = OrderedDict() # type: Dict[str, Type[MatchServiceTransport]]
42
+ _transport_registry["grpc"] = MatchServiceGrpcTransport
43
+ _transport_registry["grpc_asyncio"] = MatchServiceGrpcAsyncIOTransport
44
+ _transport_registry["rest"] = MatchServiceRestTransport
45
+ if HAS_REST_ASYNC: # pragma: NO COVER
46
+ _transport_registry["rest_asyncio"] = AsyncMatchServiceRestTransport
47
+
48
+ __all__ = (
49
+ "MatchServiceTransport",
50
+ "MatchServiceGrpcTransport",
51
+ "MatchServiceGrpcAsyncIOTransport",
52
+ "MatchServiceRestTransport",
53
+ "MatchServiceRestInterceptor",
54
+ ) + ASYNC_REST_CLASSES
loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/match_service/transports/__pycache__/__init__.cpython-312.pyc ADDED
Binary file (1.23 kB). View file
 
loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/match_service/transports/__pycache__/base.cpython-312.pyc ADDED
Binary file (12.7 kB). View file
 
loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/match_service/transports/__pycache__/grpc.cpython-312.pyc ADDED
Binary file (25.8 kB). View file
 
loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/match_service/transports/__pycache__/grpc_asyncio.cpython-312.pyc ADDED
Binary file (29 kB). View file
 
loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/match_service/transports/__pycache__/rest.cpython-312.pyc ADDED
Binary file (81.8 kB). View file
 
loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/match_service/transports/__pycache__/rest_asyncio.cpython-312.pyc ADDED
Binary file (90.1 kB). View file
 
loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/match_service/transports/__pycache__/rest_base.cpython-312.pyc ADDED
Binary file (68.2 kB). View file
 
loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/match_service/transports/base.py ADDED
@@ -0,0 +1,343 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright 2025 Google LLC
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+ import abc
17
+ from typing import Awaitable, Callable, Dict, Optional, Sequence, Union
18
+
19
+ from google.cloud.aiplatform_v1 import gapic_version as package_version
20
+
21
+ import google.auth # type: ignore
22
+ import google.api_core
23
+ from google.api_core import exceptions as core_exceptions
24
+ from google.api_core import gapic_v1
25
+ from google.api_core import retry as retries
26
+ from google.auth import credentials as ga_credentials # type: ignore
27
+ from google.oauth2 import service_account # type: ignore
28
+ import google.protobuf
29
+
30
+ from google.cloud.aiplatform_v1.types import match_service
31
+ from google.cloud.location import locations_pb2 # type: ignore
32
+ from google.iam.v1 import iam_policy_pb2 # type: ignore
33
+ from google.iam.v1 import policy_pb2 # type: ignore
34
+ from google.longrunning import operations_pb2 # type: ignore
35
+
36
+ DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
37
+ gapic_version=package_version.__version__
38
+ )
39
+
40
+ if hasattr(DEFAULT_CLIENT_INFO, "protobuf_runtime_version"): # pragma: NO COVER
41
+ DEFAULT_CLIENT_INFO.protobuf_runtime_version = google.protobuf.__version__
42
+
43
+
44
+ class MatchServiceTransport(abc.ABC):
45
+ """Abstract transport class for MatchService."""
46
+
47
+ AUTH_SCOPES = ("https://www.googleapis.com/auth/cloud-platform",)
48
+
49
+ DEFAULT_HOST: str = "aiplatform.googleapis.com"
50
+
51
+ def __init__(
52
+ self,
53
+ *,
54
+ host: str = DEFAULT_HOST,
55
+ credentials: Optional[ga_credentials.Credentials] = None,
56
+ credentials_file: Optional[str] = None,
57
+ scopes: Optional[Sequence[str]] = None,
58
+ quota_project_id: Optional[str] = None,
59
+ client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
60
+ always_use_jwt_access: Optional[bool] = False,
61
+ api_audience: Optional[str] = None,
62
+ **kwargs,
63
+ ) -> None:
64
+ """Instantiate the transport.
65
+
66
+ Args:
67
+ host (Optional[str]):
68
+ The hostname to connect to (default: 'aiplatform.googleapis.com').
69
+ credentials (Optional[google.auth.credentials.Credentials]): The
70
+ authorization credentials to attach to requests. These
71
+ credentials identify the application to the service; if none
72
+ are specified, the client will attempt to ascertain the
73
+ credentials from the environment.
74
+ credentials_file (Optional[str]): Deprecated. A file with credentials that can
75
+ be loaded with :func:`google.auth.load_credentials_from_file`.
76
+ This argument is mutually exclusive with credentials. This argument will be
77
+ removed in the next major version of this library.
78
+ scopes (Optional[Sequence[str]]): A list of scopes.
79
+ quota_project_id (Optional[str]): An optional project to use for billing
80
+ and quota.
81
+ client_info (google.api_core.gapic_v1.client_info.ClientInfo):
82
+ The client info used to send a user-agent string along with
83
+ API requests. If ``None``, then default info will be used.
84
+ Generally, you only need to set this if you're developing
85
+ your own client library.
86
+ always_use_jwt_access (Optional[bool]): Whether self signed JWT should
87
+ be used for service account credentials.
88
+ """
89
+
90
+ # Save the scopes.
91
+ self._scopes = scopes
92
+ if not hasattr(self, "_ignore_credentials"):
93
+ self._ignore_credentials: bool = False
94
+
95
+ # If no credentials are provided, then determine the appropriate
96
+ # defaults.
97
+ if credentials and credentials_file:
98
+ raise core_exceptions.DuplicateCredentialArgs(
99
+ "'credentials_file' and 'credentials' are mutually exclusive"
100
+ )
101
+
102
+ if credentials_file is not None:
103
+ credentials, _ = google.auth.load_credentials_from_file(
104
+ credentials_file,
105
+ scopes=scopes,
106
+ quota_project_id=quota_project_id,
107
+ default_scopes=self.AUTH_SCOPES,
108
+ )
109
+ elif credentials is None and not self._ignore_credentials:
110
+ credentials, _ = google.auth.default(
111
+ scopes=scopes,
112
+ quota_project_id=quota_project_id,
113
+ default_scopes=self.AUTH_SCOPES,
114
+ )
115
+ # Don't apply audience if the credentials file passed from user.
116
+ if hasattr(credentials, "with_gdch_audience"):
117
+ credentials = credentials.with_gdch_audience(
118
+ api_audience if api_audience else host
119
+ )
120
+
121
+ # If the credentials are service account credentials, then always try to use self signed JWT.
122
+ if (
123
+ always_use_jwt_access
124
+ and isinstance(credentials, service_account.Credentials)
125
+ and hasattr(service_account.Credentials, "with_always_use_jwt_access")
126
+ ):
127
+ credentials = credentials.with_always_use_jwt_access(True)
128
+
129
+ # Save the credentials.
130
+ self._credentials = credentials
131
+
132
+ # Save the hostname. Default to port 443 (HTTPS) if none is specified.
133
+ if ":" not in host:
134
+ host += ":443"
135
+ self._host = host
136
+
137
+ @property
138
+ def host(self):
139
+ return self._host
140
+
141
+ def _prep_wrapped_messages(self, client_info):
142
+ # Precompute the wrapped methods.
143
+ self._wrapped_methods = {
144
+ self.find_neighbors: gapic_v1.method.wrap_method(
145
+ self.find_neighbors,
146
+ default_timeout=None,
147
+ client_info=client_info,
148
+ ),
149
+ self.read_index_datapoints: gapic_v1.method.wrap_method(
150
+ self.read_index_datapoints,
151
+ default_timeout=None,
152
+ client_info=client_info,
153
+ ),
154
+ self.get_location: gapic_v1.method.wrap_method(
155
+ self.get_location,
156
+ default_timeout=None,
157
+ client_info=client_info,
158
+ ),
159
+ self.list_locations: gapic_v1.method.wrap_method(
160
+ self.list_locations,
161
+ default_timeout=None,
162
+ client_info=client_info,
163
+ ),
164
+ self.get_iam_policy: gapic_v1.method.wrap_method(
165
+ self.get_iam_policy,
166
+ default_timeout=None,
167
+ client_info=client_info,
168
+ ),
169
+ self.set_iam_policy: gapic_v1.method.wrap_method(
170
+ self.set_iam_policy,
171
+ default_timeout=None,
172
+ client_info=client_info,
173
+ ),
174
+ self.test_iam_permissions: gapic_v1.method.wrap_method(
175
+ self.test_iam_permissions,
176
+ default_timeout=None,
177
+ client_info=client_info,
178
+ ),
179
+ self.cancel_operation: gapic_v1.method.wrap_method(
180
+ self.cancel_operation,
181
+ default_timeout=None,
182
+ client_info=client_info,
183
+ ),
184
+ self.delete_operation: gapic_v1.method.wrap_method(
185
+ self.delete_operation,
186
+ default_timeout=None,
187
+ client_info=client_info,
188
+ ),
189
+ self.get_operation: gapic_v1.method.wrap_method(
190
+ self.get_operation,
191
+ default_timeout=None,
192
+ client_info=client_info,
193
+ ),
194
+ self.list_operations: gapic_v1.method.wrap_method(
195
+ self.list_operations,
196
+ default_timeout=None,
197
+ client_info=client_info,
198
+ ),
199
+ self.wait_operation: gapic_v1.method.wrap_method(
200
+ self.wait_operation,
201
+ default_timeout=None,
202
+ client_info=client_info,
203
+ ),
204
+ }
205
+
206
+ def close(self):
207
+ """Closes resources associated with the transport.
208
+
209
+ .. warning::
210
+ Only call this method if the transport is NOT shared
211
+ with other clients - this may cause errors in other clients!
212
+ """
213
+ raise NotImplementedError()
214
+
215
+ @property
216
+ def find_neighbors(
217
+ self,
218
+ ) -> Callable[
219
+ [match_service.FindNeighborsRequest],
220
+ Union[
221
+ match_service.FindNeighborsResponse,
222
+ Awaitable[match_service.FindNeighborsResponse],
223
+ ],
224
+ ]:
225
+ raise NotImplementedError()
226
+
227
+ @property
228
+ def read_index_datapoints(
229
+ self,
230
+ ) -> Callable[
231
+ [match_service.ReadIndexDatapointsRequest],
232
+ Union[
233
+ match_service.ReadIndexDatapointsResponse,
234
+ Awaitable[match_service.ReadIndexDatapointsResponse],
235
+ ],
236
+ ]:
237
+ raise NotImplementedError()
238
+
239
+ @property
240
+ def list_operations(
241
+ self,
242
+ ) -> Callable[
243
+ [operations_pb2.ListOperationsRequest],
244
+ Union[
245
+ operations_pb2.ListOperationsResponse,
246
+ Awaitable[operations_pb2.ListOperationsResponse],
247
+ ],
248
+ ]:
249
+ raise NotImplementedError()
250
+
251
+ @property
252
+ def get_operation(
253
+ self,
254
+ ) -> Callable[
255
+ [operations_pb2.GetOperationRequest],
256
+ Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]],
257
+ ]:
258
+ raise NotImplementedError()
259
+
260
+ @property
261
+ def cancel_operation(
262
+ self,
263
+ ) -> Callable[
264
+ [operations_pb2.CancelOperationRequest],
265
+ None,
266
+ ]:
267
+ raise NotImplementedError()
268
+
269
+ @property
270
+ def delete_operation(
271
+ self,
272
+ ) -> Callable[
273
+ [operations_pb2.DeleteOperationRequest],
274
+ None,
275
+ ]:
276
+ raise NotImplementedError()
277
+
278
+ @property
279
+ def wait_operation(
280
+ self,
281
+ ) -> Callable[
282
+ [operations_pb2.WaitOperationRequest],
283
+ Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]],
284
+ ]:
285
+ raise NotImplementedError()
286
+
287
+ @property
288
+ def set_iam_policy(
289
+ self,
290
+ ) -> Callable[
291
+ [iam_policy_pb2.SetIamPolicyRequest],
292
+ Union[policy_pb2.Policy, Awaitable[policy_pb2.Policy]],
293
+ ]:
294
+ raise NotImplementedError()
295
+
296
+ @property
297
+ def get_iam_policy(
298
+ self,
299
+ ) -> Callable[
300
+ [iam_policy_pb2.GetIamPolicyRequest],
301
+ Union[policy_pb2.Policy, Awaitable[policy_pb2.Policy]],
302
+ ]:
303
+ raise NotImplementedError()
304
+
305
+ @property
306
+ def test_iam_permissions(
307
+ self,
308
+ ) -> Callable[
309
+ [iam_policy_pb2.TestIamPermissionsRequest],
310
+ Union[
311
+ iam_policy_pb2.TestIamPermissionsResponse,
312
+ Awaitable[iam_policy_pb2.TestIamPermissionsResponse],
313
+ ],
314
+ ]:
315
+ raise NotImplementedError()
316
+
317
+ @property
318
+ def get_location(
319
+ self,
320
+ ) -> Callable[
321
+ [locations_pb2.GetLocationRequest],
322
+ Union[locations_pb2.Location, Awaitable[locations_pb2.Location]],
323
+ ]:
324
+ raise NotImplementedError()
325
+
326
+ @property
327
+ def list_locations(
328
+ self,
329
+ ) -> Callable[
330
+ [locations_pb2.ListLocationsRequest],
331
+ Union[
332
+ locations_pb2.ListLocationsResponse,
333
+ Awaitable[locations_pb2.ListLocationsResponse],
334
+ ],
335
+ ]:
336
+ raise NotImplementedError()
337
+
338
+ @property
339
+ def kind(self) -> str:
340
+ raise NotImplementedError()
341
+
342
+
343
+ __all__ = ("MatchServiceTransport",)
loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/match_service/transports/grpc.py ADDED
@@ -0,0 +1,601 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright 2025 Google LLC
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+ import json
17
+ import logging as std_logging
18
+ import pickle
19
+ import warnings
20
+ from typing import Callable, Dict, Optional, Sequence, Tuple, Union
21
+
22
+ from google.api_core import grpc_helpers
23
+ from google.api_core import gapic_v1
24
+ import google.auth # type: ignore
25
+ from google.auth import credentials as ga_credentials # type: ignore
26
+ from google.auth.transport.grpc import SslCredentials # type: ignore
27
+ from google.protobuf.json_format import MessageToJson
28
+ import google.protobuf.message
29
+
30
+ import grpc # type: ignore
31
+ import proto # type: ignore
32
+
33
+ from google.cloud.aiplatform_v1.types import match_service
34
+ from google.cloud.location import locations_pb2 # type: ignore
35
+ from google.iam.v1 import iam_policy_pb2 # type: ignore
36
+ from google.iam.v1 import policy_pb2 # type: ignore
37
+ from google.longrunning import operations_pb2 # type: ignore
38
+ from .base import MatchServiceTransport, DEFAULT_CLIENT_INFO
39
+
40
+ try:
41
+ from google.api_core import client_logging # type: ignore
42
+
43
+ CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER
44
+ except ImportError: # pragma: NO COVER
45
+ CLIENT_LOGGING_SUPPORTED = False
46
+
47
+ _LOGGER = std_logging.getLogger(__name__)
48
+
49
+
50
+ class _LoggingClientInterceptor(grpc.UnaryUnaryClientInterceptor): # pragma: NO COVER
51
+ def intercept_unary_unary(self, continuation, client_call_details, request):
52
+ logging_enabled = CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
53
+ std_logging.DEBUG
54
+ )
55
+ if logging_enabled: # pragma: NO COVER
56
+ request_metadata = client_call_details.metadata
57
+ if isinstance(request, proto.Message):
58
+ request_payload = type(request).to_json(request)
59
+ elif isinstance(request, google.protobuf.message.Message):
60
+ request_payload = MessageToJson(request)
61
+ else:
62
+ request_payload = f"{type(request).__name__}: {pickle.dumps(request)}"
63
+
64
+ request_metadata = {
65
+ key: value.decode("utf-8") if isinstance(value, bytes) else value
66
+ for key, value in request_metadata
67
+ }
68
+ grpc_request = {
69
+ "payload": request_payload,
70
+ "requestMethod": "grpc",
71
+ "metadata": dict(request_metadata),
72
+ }
73
+ _LOGGER.debug(
74
+ f"Sending request for {client_call_details.method}",
75
+ extra={
76
+ "serviceName": "google.cloud.aiplatform.v1.MatchService",
77
+ "rpcName": str(client_call_details.method),
78
+ "request": grpc_request,
79
+ "metadata": grpc_request["metadata"],
80
+ },
81
+ )
82
+ response = continuation(client_call_details, request)
83
+ if logging_enabled: # pragma: NO COVER
84
+ response_metadata = response.trailing_metadata()
85
+ # Convert gRPC metadata `<class 'grpc.aio._metadata.Metadata'>` to list of tuples
86
+ metadata = (
87
+ dict([(k, str(v)) for k, v in response_metadata])
88
+ if response_metadata
89
+ else None
90
+ )
91
+ result = response.result()
92
+ if isinstance(result, proto.Message):
93
+ response_payload = type(result).to_json(result)
94
+ elif isinstance(result, google.protobuf.message.Message):
95
+ response_payload = MessageToJson(result)
96
+ else:
97
+ response_payload = f"{type(result).__name__}: {pickle.dumps(result)}"
98
+ grpc_response = {
99
+ "payload": response_payload,
100
+ "metadata": metadata,
101
+ "status": "OK",
102
+ }
103
+ _LOGGER.debug(
104
+ f"Received response for {client_call_details.method}.",
105
+ extra={
106
+ "serviceName": "google.cloud.aiplatform.v1.MatchService",
107
+ "rpcName": client_call_details.method,
108
+ "response": grpc_response,
109
+ "metadata": grpc_response["metadata"],
110
+ },
111
+ )
112
+ return response
113
+
114
+
115
+ class MatchServiceGrpcTransport(MatchServiceTransport):
116
+ """gRPC backend transport for MatchService.
117
+
118
+ MatchService is a Google managed service for efficient vector
119
+ similarity search at scale.
120
+
121
+ This class defines the same methods as the primary client, so the
122
+ primary client can load the underlying transport implementation
123
+ and call it.
124
+
125
+ It sends protocol buffers over the wire using gRPC (which is built on
126
+ top of HTTP/2); the ``grpcio`` package must be installed.
127
+ """
128
+
129
+ _stubs: Dict[str, Callable]
130
+
131
+ def __init__(
132
+ self,
133
+ *,
134
+ host: str = "aiplatform.googleapis.com",
135
+ credentials: Optional[ga_credentials.Credentials] = None,
136
+ credentials_file: Optional[str] = None,
137
+ scopes: Optional[Sequence[str]] = None,
138
+ channel: Optional[Union[grpc.Channel, Callable[..., grpc.Channel]]] = None,
139
+ api_mtls_endpoint: Optional[str] = None,
140
+ client_cert_source: Optional[Callable[[], Tuple[bytes, bytes]]] = None,
141
+ ssl_channel_credentials: Optional[grpc.ChannelCredentials] = None,
142
+ client_cert_source_for_mtls: Optional[Callable[[], Tuple[bytes, bytes]]] = None,
143
+ quota_project_id: Optional[str] = None,
144
+ client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
145
+ always_use_jwt_access: Optional[bool] = False,
146
+ api_audience: Optional[str] = None,
147
+ ) -> None:
148
+ """Instantiate the transport.
149
+
150
+ Args:
151
+ host (Optional[str]):
152
+ The hostname to connect to (default: 'aiplatform.googleapis.com').
153
+ credentials (Optional[google.auth.credentials.Credentials]): The
154
+ authorization credentials to attach to requests. These
155
+ credentials identify the application to the service; if none
156
+ are specified, the client will attempt to ascertain the
157
+ credentials from the environment.
158
+ This argument is ignored if a ``channel`` instance is provided.
159
+ credentials_file (Optional[str]): Deprecated. A file with credentials that can
160
+ be loaded with :func:`google.auth.load_credentials_from_file`.
161
+ This argument is ignored if a ``channel`` instance is provided.
162
+ This argument will be removed in the next major version of this library.
163
+ scopes (Optional(Sequence[str])): A list of scopes. This argument is
164
+ ignored if a ``channel`` instance is provided.
165
+ channel (Optional[Union[grpc.Channel, Callable[..., grpc.Channel]]]):
166
+ A ``Channel`` instance through which to make calls, or a Callable
167
+ that constructs and returns one. If set to None, ``self.create_channel``
168
+ is used to create the channel. If a Callable is given, it will be called
169
+ with the same arguments as used in ``self.create_channel``.
170
+ api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint.
171
+ If provided, it overrides the ``host`` argument and tries to create
172
+ a mutual TLS channel with client SSL credentials from
173
+ ``client_cert_source`` or application default SSL credentials.
174
+ client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]):
175
+ Deprecated. A callback to provide client SSL certificate bytes and
176
+ private key bytes, both in PEM format. It is ignored if
177
+ ``api_mtls_endpoint`` is None.
178
+ ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials
179
+ for the grpc channel. It is ignored if a ``channel`` instance is provided.
180
+ client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]):
181
+ A callback to provide client certificate bytes and private key bytes,
182
+ both in PEM format. It is used to configure a mutual TLS channel. It is
183
+ ignored if a ``channel`` instance or ``ssl_channel_credentials`` is provided.
184
+ quota_project_id (Optional[str]): An optional project to use for billing
185
+ and quota.
186
+ client_info (google.api_core.gapic_v1.client_info.ClientInfo):
187
+ The client info used to send a user-agent string along with
188
+ API requests. If ``None``, then default info will be used.
189
+ Generally, you only need to set this if you're developing
190
+ your own client library.
191
+ always_use_jwt_access (Optional[bool]): Whether self signed JWT should
192
+ be used for service account credentials.
193
+
194
+ Raises:
195
+ google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport
196
+ creation failed for any reason.
197
+ google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials``
198
+ and ``credentials_file`` are passed.
199
+ """
200
+ self._grpc_channel = None
201
+ self._ssl_channel_credentials = ssl_channel_credentials
202
+ self._stubs: Dict[str, Callable] = {}
203
+
204
+ if api_mtls_endpoint:
205
+ warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning)
206
+ if client_cert_source:
207
+ warnings.warn("client_cert_source is deprecated", DeprecationWarning)
208
+
209
+ if isinstance(channel, grpc.Channel):
210
+ # Ignore credentials if a channel was passed.
211
+ credentials = None
212
+ self._ignore_credentials = True
213
+ # If a channel was explicitly provided, set it.
214
+ self._grpc_channel = channel
215
+ self._ssl_channel_credentials = None
216
+
217
+ else:
218
+ if api_mtls_endpoint:
219
+ host = api_mtls_endpoint
220
+
221
+ # Create SSL credentials with client_cert_source or application
222
+ # default SSL credentials.
223
+ if client_cert_source:
224
+ cert, key = client_cert_source()
225
+ self._ssl_channel_credentials = grpc.ssl_channel_credentials(
226
+ certificate_chain=cert, private_key=key
227
+ )
228
+ else:
229
+ self._ssl_channel_credentials = SslCredentials().ssl_credentials
230
+
231
+ else:
232
+ if client_cert_source_for_mtls and not ssl_channel_credentials:
233
+ cert, key = client_cert_source_for_mtls()
234
+ self._ssl_channel_credentials = grpc.ssl_channel_credentials(
235
+ certificate_chain=cert, private_key=key
236
+ )
237
+
238
+ # The base transport sets the host, credentials and scopes
239
+ super().__init__(
240
+ host=host,
241
+ credentials=credentials,
242
+ credentials_file=credentials_file,
243
+ scopes=scopes,
244
+ quota_project_id=quota_project_id,
245
+ client_info=client_info,
246
+ always_use_jwt_access=always_use_jwt_access,
247
+ api_audience=api_audience,
248
+ )
249
+
250
+ if not self._grpc_channel:
251
+ # initialize with the provided callable or the default channel
252
+ channel_init = channel or type(self).create_channel
253
+ self._grpc_channel = channel_init(
254
+ self._host,
255
+ # use the credentials which are saved
256
+ credentials=self._credentials,
257
+ # Set ``credentials_file`` to ``None`` here as
258
+ # the credentials that we saved earlier should be used.
259
+ credentials_file=None,
260
+ scopes=self._scopes,
261
+ ssl_credentials=self._ssl_channel_credentials,
262
+ quota_project_id=quota_project_id,
263
+ options=[
264
+ ("grpc.max_send_message_length", -1),
265
+ ("grpc.max_receive_message_length", -1),
266
+ ],
267
+ )
268
+
269
+ self._interceptor = _LoggingClientInterceptor()
270
+ self._logged_channel = grpc.intercept_channel(
271
+ self._grpc_channel, self._interceptor
272
+ )
273
+
274
+ # Wrap messages. This must be done after self._logged_channel exists
275
+ self._prep_wrapped_messages(client_info)
276
+
277
+ @classmethod
278
+ def create_channel(
279
+ cls,
280
+ host: str = "aiplatform.googleapis.com",
281
+ credentials: Optional[ga_credentials.Credentials] = None,
282
+ credentials_file: Optional[str] = None,
283
+ scopes: Optional[Sequence[str]] = None,
284
+ quota_project_id: Optional[str] = None,
285
+ **kwargs,
286
+ ) -> grpc.Channel:
287
+ """Create and return a gRPC channel object.
288
+ Args:
289
+ host (Optional[str]): The host for the channel to use.
290
+ credentials (Optional[~.Credentials]): The
291
+ authorization credentials to attach to requests. These
292
+ credentials identify this application to the service. If
293
+ none are specified, the client will attempt to ascertain
294
+ the credentials from the environment.
295
+ credentials_file (Optional[str]): Deprecated. A file with credentials that can
296
+ be loaded with :func:`google.auth.load_credentials_from_file`.
297
+ This argument is mutually exclusive with credentials. This argument will be
298
+ removed in the next major version of this library.
299
+ scopes (Optional[Sequence[str]]): A optional list of scopes needed for this
300
+ service. These are only used when credentials are not specified and
301
+ are passed to :func:`google.auth.default`.
302
+ quota_project_id (Optional[str]): An optional project to use for billing
303
+ and quota.
304
+ kwargs (Optional[dict]): Keyword arguments, which are passed to the
305
+ channel creation.
306
+ Returns:
307
+ grpc.Channel: A gRPC channel object.
308
+
309
+ Raises:
310
+ google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials``
311
+ and ``credentials_file`` are passed.
312
+ """
313
+
314
+ return grpc_helpers.create_channel(
315
+ host,
316
+ credentials=credentials,
317
+ credentials_file=credentials_file,
318
+ quota_project_id=quota_project_id,
319
+ default_scopes=cls.AUTH_SCOPES,
320
+ scopes=scopes,
321
+ default_host=cls.DEFAULT_HOST,
322
+ **kwargs,
323
+ )
324
+
325
+ @property
326
+ def grpc_channel(self) -> grpc.Channel:
327
+ """Return the channel designed to connect to this service."""
328
+ return self._grpc_channel
329
+
330
+ @property
331
+ def find_neighbors(
332
+ self,
333
+ ) -> Callable[
334
+ [match_service.FindNeighborsRequest], match_service.FindNeighborsResponse
335
+ ]:
336
+ r"""Return a callable for the find neighbors method over gRPC.
337
+
338
+ Finds the nearest neighbors of each vector within the
339
+ request.
340
+
341
+ Returns:
342
+ Callable[[~.FindNeighborsRequest],
343
+ ~.FindNeighborsResponse]:
344
+ A function that, when called, will call the underlying RPC
345
+ on the server.
346
+ """
347
+ # Generate a "stub function" on-the-fly which will actually make
348
+ # the request.
349
+ # gRPC handles serialization and deserialization, so we just need
350
+ # to pass in the functions for each.
351
+ if "find_neighbors" not in self._stubs:
352
+ self._stubs["find_neighbors"] = self._logged_channel.unary_unary(
353
+ "/google.cloud.aiplatform.v1.MatchService/FindNeighbors",
354
+ request_serializer=match_service.FindNeighborsRequest.serialize,
355
+ response_deserializer=match_service.FindNeighborsResponse.deserialize,
356
+ )
357
+ return self._stubs["find_neighbors"]
358
+
359
+ @property
360
+ def read_index_datapoints(
361
+ self,
362
+ ) -> Callable[
363
+ [match_service.ReadIndexDatapointsRequest],
364
+ match_service.ReadIndexDatapointsResponse,
365
+ ]:
366
+ r"""Return a callable for the read index datapoints method over gRPC.
367
+
368
+ Reads the datapoints/vectors of the given IDs.
369
+ A maximum of 1000 datapoints can be retrieved in a
370
+ batch.
371
+
372
+ Returns:
373
+ Callable[[~.ReadIndexDatapointsRequest],
374
+ ~.ReadIndexDatapointsResponse]:
375
+ A function that, when called, will call the underlying RPC
376
+ on the server.
377
+ """
378
+ # Generate a "stub function" on-the-fly which will actually make
379
+ # the request.
380
+ # gRPC handles serialization and deserialization, so we just need
381
+ # to pass in the functions for each.
382
+ if "read_index_datapoints" not in self._stubs:
383
+ self._stubs["read_index_datapoints"] = self._logged_channel.unary_unary(
384
+ "/google.cloud.aiplatform.v1.MatchService/ReadIndexDatapoints",
385
+ request_serializer=match_service.ReadIndexDatapointsRequest.serialize,
386
+ response_deserializer=match_service.ReadIndexDatapointsResponse.deserialize,
387
+ )
388
+ return self._stubs["read_index_datapoints"]
389
+
390
+ def close(self):
391
+ self._logged_channel.close()
392
+
393
+ @property
394
+ def delete_operation(
395
+ self,
396
+ ) -> Callable[[operations_pb2.DeleteOperationRequest], None]:
397
+ r"""Return a callable for the delete_operation method over gRPC."""
398
+ # Generate a "stub function" on-the-fly which will actually make
399
+ # the request.
400
+ # gRPC handles serialization and deserialization, so we just need
401
+ # to pass in the functions for each.
402
+ if "delete_operation" not in self._stubs:
403
+ self._stubs["delete_operation"] = self._logged_channel.unary_unary(
404
+ "/google.longrunning.Operations/DeleteOperation",
405
+ request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString,
406
+ response_deserializer=None,
407
+ )
408
+ return self._stubs["delete_operation"]
409
+
410
+ @property
411
+ def cancel_operation(
412
+ self,
413
+ ) -> Callable[[operations_pb2.CancelOperationRequest], None]:
414
+ r"""Return a callable for the cancel_operation method over gRPC."""
415
+ # Generate a "stub function" on-the-fly which will actually make
416
+ # the request.
417
+ # gRPC handles serialization and deserialization, so we just need
418
+ # to pass in the functions for each.
419
+ if "cancel_operation" not in self._stubs:
420
+ self._stubs["cancel_operation"] = self._logged_channel.unary_unary(
421
+ "/google.longrunning.Operations/CancelOperation",
422
+ request_serializer=operations_pb2.CancelOperationRequest.SerializeToString,
423
+ response_deserializer=None,
424
+ )
425
+ return self._stubs["cancel_operation"]
426
+
427
+ @property
428
+ def wait_operation(
429
+ self,
430
+ ) -> Callable[[operations_pb2.WaitOperationRequest], None]:
431
+ r"""Return a callable for the wait_operation method over gRPC."""
432
+ # Generate a "stub function" on-the-fly which will actually make
433
+ # the request.
434
+ # gRPC handles serialization and deserialization, so we just need
435
+ # to pass in the functions for each.
436
+ if "wait_operation" not in self._stubs:
437
+ self._stubs["wait_operation"] = self._logged_channel.unary_unary(
438
+ "/google.longrunning.Operations/WaitOperation",
439
+ request_serializer=operations_pb2.WaitOperationRequest.SerializeToString,
440
+ response_deserializer=None,
441
+ )
442
+ return self._stubs["wait_operation"]
443
+
444
+ @property
445
+ def get_operation(
446
+ self,
447
+ ) -> Callable[[operations_pb2.GetOperationRequest], operations_pb2.Operation]:
448
+ r"""Return a callable for the get_operation method over gRPC."""
449
+ # Generate a "stub function" on-the-fly which will actually make
450
+ # the request.
451
+ # gRPC handles serialization and deserialization, so we just need
452
+ # to pass in the functions for each.
453
+ if "get_operation" not in self._stubs:
454
+ self._stubs["get_operation"] = self._logged_channel.unary_unary(
455
+ "/google.longrunning.Operations/GetOperation",
456
+ request_serializer=operations_pb2.GetOperationRequest.SerializeToString,
457
+ response_deserializer=operations_pb2.Operation.FromString,
458
+ )
459
+ return self._stubs["get_operation"]
460
+
461
+ @property
462
+ def list_operations(
463
+ self,
464
+ ) -> Callable[
465
+ [operations_pb2.ListOperationsRequest], operations_pb2.ListOperationsResponse
466
+ ]:
467
+ r"""Return a callable for the list_operations method over gRPC."""
468
+ # Generate a "stub function" on-the-fly which will actually make
469
+ # the request.
470
+ # gRPC handles serialization and deserialization, so we just need
471
+ # to pass in the functions for each.
472
+ if "list_operations" not in self._stubs:
473
+ self._stubs["list_operations"] = self._logged_channel.unary_unary(
474
+ "/google.longrunning.Operations/ListOperations",
475
+ request_serializer=operations_pb2.ListOperationsRequest.SerializeToString,
476
+ response_deserializer=operations_pb2.ListOperationsResponse.FromString,
477
+ )
478
+ return self._stubs["list_operations"]
479
+
480
+ @property
481
+ def list_locations(
482
+ self,
483
+ ) -> Callable[
484
+ [locations_pb2.ListLocationsRequest], locations_pb2.ListLocationsResponse
485
+ ]:
486
+ r"""Return a callable for the list locations method over gRPC."""
487
+ # Generate a "stub function" on-the-fly which will actually make
488
+ # the request.
489
+ # gRPC handles serialization and deserialization, so we just need
490
+ # to pass in the functions for each.
491
+ if "list_locations" not in self._stubs:
492
+ self._stubs["list_locations"] = self._logged_channel.unary_unary(
493
+ "/google.cloud.location.Locations/ListLocations",
494
+ request_serializer=locations_pb2.ListLocationsRequest.SerializeToString,
495
+ response_deserializer=locations_pb2.ListLocationsResponse.FromString,
496
+ )
497
+ return self._stubs["list_locations"]
498
+
499
+ @property
500
+ def get_location(
501
+ self,
502
+ ) -> Callable[[locations_pb2.GetLocationRequest], locations_pb2.Location]:
503
+ r"""Return a callable for the list locations method over gRPC."""
504
+ # Generate a "stub function" on-the-fly which will actually make
505
+ # the request.
506
+ # gRPC handles serialization and deserialization, so we just need
507
+ # to pass in the functions for each.
508
+ if "get_location" not in self._stubs:
509
+ self._stubs["get_location"] = self._logged_channel.unary_unary(
510
+ "/google.cloud.location.Locations/GetLocation",
511
+ request_serializer=locations_pb2.GetLocationRequest.SerializeToString,
512
+ response_deserializer=locations_pb2.Location.FromString,
513
+ )
514
+ return self._stubs["get_location"]
515
+
516
+ @property
517
+ def set_iam_policy(
518
+ self,
519
+ ) -> Callable[[iam_policy_pb2.SetIamPolicyRequest], policy_pb2.Policy]:
520
+ r"""Return a callable for the set iam policy method over gRPC.
521
+ Sets the IAM access control policy on the specified
522
+ function. Replaces any existing policy.
523
+ Returns:
524
+ Callable[[~.SetIamPolicyRequest],
525
+ ~.Policy]:
526
+ A function that, when called, will call the underlying RPC
527
+ on the server.
528
+ """
529
+ # Generate a "stub function" on-the-fly which will actually make
530
+ # the request.
531
+ # gRPC handles serialization and deserialization, so we just need
532
+ # to pass in the functions for each.
533
+ if "set_iam_policy" not in self._stubs:
534
+ self._stubs["set_iam_policy"] = self._logged_channel.unary_unary(
535
+ "/google.iam.v1.IAMPolicy/SetIamPolicy",
536
+ request_serializer=iam_policy_pb2.SetIamPolicyRequest.SerializeToString,
537
+ response_deserializer=policy_pb2.Policy.FromString,
538
+ )
539
+ return self._stubs["set_iam_policy"]
540
+
541
+ @property
542
+ def get_iam_policy(
543
+ self,
544
+ ) -> Callable[[iam_policy_pb2.GetIamPolicyRequest], policy_pb2.Policy]:
545
+ r"""Return a callable for the get iam policy method over gRPC.
546
+ Gets the IAM access control policy for a function.
547
+ Returns an empty policy if the function exists and does
548
+ not have a policy set.
549
+ Returns:
550
+ Callable[[~.GetIamPolicyRequest],
551
+ ~.Policy]:
552
+ A function that, when called, will call the underlying RPC
553
+ on the server.
554
+ """
555
+ # Generate a "stub function" on-the-fly which will actually make
556
+ # the request.
557
+ # gRPC handles serialization and deserialization, so we just need
558
+ # to pass in the functions for each.
559
+ if "get_iam_policy" not in self._stubs:
560
+ self._stubs["get_iam_policy"] = self._logged_channel.unary_unary(
561
+ "/google.iam.v1.IAMPolicy/GetIamPolicy",
562
+ request_serializer=iam_policy_pb2.GetIamPolicyRequest.SerializeToString,
563
+ response_deserializer=policy_pb2.Policy.FromString,
564
+ )
565
+ return self._stubs["get_iam_policy"]
566
+
567
+ @property
568
+ def test_iam_permissions(
569
+ self,
570
+ ) -> Callable[
571
+ [iam_policy_pb2.TestIamPermissionsRequest],
572
+ iam_policy_pb2.TestIamPermissionsResponse,
573
+ ]:
574
+ r"""Return a callable for the test iam permissions method over gRPC.
575
+ Tests the specified permissions against the IAM access control
576
+ policy for a function. If the function does not exist, this will
577
+ return an empty set of permissions, not a NOT_FOUND error.
578
+ Returns:
579
+ Callable[[~.TestIamPermissionsRequest],
580
+ ~.TestIamPermissionsResponse]:
581
+ A function that, when called, will call the underlying RPC
582
+ on the server.
583
+ """
584
+ # Generate a "stub function" on-the-fly which will actually make
585
+ # the request.
586
+ # gRPC handles serialization and deserialization, so we just need
587
+ # to pass in the functions for each.
588
+ if "test_iam_permissions" not in self._stubs:
589
+ self._stubs["test_iam_permissions"] = self._logged_channel.unary_unary(
590
+ "/google.iam.v1.IAMPolicy/TestIamPermissions",
591
+ request_serializer=iam_policy_pb2.TestIamPermissionsRequest.SerializeToString,
592
+ response_deserializer=iam_policy_pb2.TestIamPermissionsResponse.FromString,
593
+ )
594
+ return self._stubs["test_iam_permissions"]
595
+
596
+ @property
597
+ def kind(self) -> str:
598
+ return "grpc"
599
+
600
+
601
+ __all__ = ("MatchServiceGrpcTransport",)
loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/match_service/transports/grpc_asyncio.py ADDED
@@ -0,0 +1,680 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright 2025 Google LLC
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+ import inspect
17
+ import json
18
+ import pickle
19
+ import logging as std_logging
20
+ import warnings
21
+ from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union
22
+
23
+ from google.api_core import gapic_v1
24
+ from google.api_core import grpc_helpers_async
25
+ from google.api_core import exceptions as core_exceptions
26
+ from google.api_core import retry_async as retries
27
+ from google.auth import credentials as ga_credentials # type: ignore
28
+ from google.auth.transport.grpc import SslCredentials # type: ignore
29
+ from google.protobuf.json_format import MessageToJson
30
+ import google.protobuf.message
31
+
32
+ import grpc # type: ignore
33
+ import proto # type: ignore
34
+ from grpc.experimental import aio # type: ignore
35
+
36
+ from google.cloud.aiplatform_v1.types import match_service
37
+ from google.cloud.location import locations_pb2 # type: ignore
38
+ from google.iam.v1 import iam_policy_pb2 # type: ignore
39
+ from google.iam.v1 import policy_pb2 # type: ignore
40
+ from google.longrunning import operations_pb2 # type: ignore
41
+ from .base import MatchServiceTransport, DEFAULT_CLIENT_INFO
42
+ from .grpc import MatchServiceGrpcTransport
43
+
44
+ try:
45
+ from google.api_core import client_logging # type: ignore
46
+
47
+ CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER
48
+ except ImportError: # pragma: NO COVER
49
+ CLIENT_LOGGING_SUPPORTED = False
50
+
51
+ _LOGGER = std_logging.getLogger(__name__)
52
+
53
+
54
+ class _LoggingClientAIOInterceptor(
55
+ grpc.aio.UnaryUnaryClientInterceptor
56
+ ): # pragma: NO COVER
57
+ async def intercept_unary_unary(self, continuation, client_call_details, request):
58
+ logging_enabled = CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
59
+ std_logging.DEBUG
60
+ )
61
+ if logging_enabled: # pragma: NO COVER
62
+ request_metadata = client_call_details.metadata
63
+ if isinstance(request, proto.Message):
64
+ request_payload = type(request).to_json(request)
65
+ elif isinstance(request, google.protobuf.message.Message):
66
+ request_payload = MessageToJson(request)
67
+ else:
68
+ request_payload = f"{type(request).__name__}: {pickle.dumps(request)}"
69
+
70
+ request_metadata = {
71
+ key: value.decode("utf-8") if isinstance(value, bytes) else value
72
+ for key, value in request_metadata
73
+ }
74
+ grpc_request = {
75
+ "payload": request_payload,
76
+ "requestMethod": "grpc",
77
+ "metadata": dict(request_metadata),
78
+ }
79
+ _LOGGER.debug(
80
+ f"Sending request for {client_call_details.method}",
81
+ extra={
82
+ "serviceName": "google.cloud.aiplatform.v1.MatchService",
83
+ "rpcName": str(client_call_details.method),
84
+ "request": grpc_request,
85
+ "metadata": grpc_request["metadata"],
86
+ },
87
+ )
88
+ response = await continuation(client_call_details, request)
89
+ if logging_enabled: # pragma: NO COVER
90
+ response_metadata = await response.trailing_metadata()
91
+ # Convert gRPC metadata `<class 'grpc.aio._metadata.Metadata'>` to list of tuples
92
+ metadata = (
93
+ dict([(k, str(v)) for k, v in response_metadata])
94
+ if response_metadata
95
+ else None
96
+ )
97
+ result = await response
98
+ if isinstance(result, proto.Message):
99
+ response_payload = type(result).to_json(result)
100
+ elif isinstance(result, google.protobuf.message.Message):
101
+ response_payload = MessageToJson(result)
102
+ else:
103
+ response_payload = f"{type(result).__name__}: {pickle.dumps(result)}"
104
+ grpc_response = {
105
+ "payload": response_payload,
106
+ "metadata": metadata,
107
+ "status": "OK",
108
+ }
109
+ _LOGGER.debug(
110
+ f"Received response to rpc {client_call_details.method}.",
111
+ extra={
112
+ "serviceName": "google.cloud.aiplatform.v1.MatchService",
113
+ "rpcName": str(client_call_details.method),
114
+ "response": grpc_response,
115
+ "metadata": grpc_response["metadata"],
116
+ },
117
+ )
118
+ return response
119
+
120
+
121
+ class MatchServiceGrpcAsyncIOTransport(MatchServiceTransport):
122
+ """gRPC AsyncIO backend transport for MatchService.
123
+
124
+ MatchService is a Google managed service for efficient vector
125
+ similarity search at scale.
126
+
127
+ This class defines the same methods as the primary client, so the
128
+ primary client can load the underlying transport implementation
129
+ and call it.
130
+
131
+ It sends protocol buffers over the wire using gRPC (which is built on
132
+ top of HTTP/2); the ``grpcio`` package must be installed.
133
+ """
134
+
135
+ _grpc_channel: aio.Channel
136
+ _stubs: Dict[str, Callable] = {}
137
+
138
+ @classmethod
139
+ def create_channel(
140
+ cls,
141
+ host: str = "aiplatform.googleapis.com",
142
+ credentials: Optional[ga_credentials.Credentials] = None,
143
+ credentials_file: Optional[str] = None,
144
+ scopes: Optional[Sequence[str]] = None,
145
+ quota_project_id: Optional[str] = None,
146
+ **kwargs,
147
+ ) -> aio.Channel:
148
+ """Create and return a gRPC AsyncIO channel object.
149
+ Args:
150
+ host (Optional[str]): The host for the channel to use.
151
+ credentials (Optional[~.Credentials]): The
152
+ authorization credentials to attach to requests. These
153
+ credentials identify this application to the service. If
154
+ none are specified, the client will attempt to ascertain
155
+ the credentials from the environment.
156
+ credentials_file (Optional[str]): Deprecated. A file with credentials that can
157
+ be loaded with :func:`google.auth.load_credentials_from_file`. This argument will be
158
+ removed in the next major version of this library.
159
+ scopes (Optional[Sequence[str]]): A optional list of scopes needed for this
160
+ service. These are only used when credentials are not specified and
161
+ are passed to :func:`google.auth.default`.
162
+ quota_project_id (Optional[str]): An optional project to use for billing
163
+ and quota.
164
+ kwargs (Optional[dict]): Keyword arguments, which are passed to the
165
+ channel creation.
166
+ Returns:
167
+ aio.Channel: A gRPC AsyncIO channel object.
168
+ """
169
+
170
+ return grpc_helpers_async.create_channel(
171
+ host,
172
+ credentials=credentials,
173
+ credentials_file=credentials_file,
174
+ quota_project_id=quota_project_id,
175
+ default_scopes=cls.AUTH_SCOPES,
176
+ scopes=scopes,
177
+ default_host=cls.DEFAULT_HOST,
178
+ **kwargs,
179
+ )
180
+
181
+ def __init__(
182
+ self,
183
+ *,
184
+ host: str = "aiplatform.googleapis.com",
185
+ credentials: Optional[ga_credentials.Credentials] = None,
186
+ credentials_file: Optional[str] = None,
187
+ scopes: Optional[Sequence[str]] = None,
188
+ channel: Optional[Union[aio.Channel, Callable[..., aio.Channel]]] = None,
189
+ api_mtls_endpoint: Optional[str] = None,
190
+ client_cert_source: Optional[Callable[[], Tuple[bytes, bytes]]] = None,
191
+ ssl_channel_credentials: Optional[grpc.ChannelCredentials] = None,
192
+ client_cert_source_for_mtls: Optional[Callable[[], Tuple[bytes, bytes]]] = None,
193
+ quota_project_id: Optional[str] = None,
194
+ client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
195
+ always_use_jwt_access: Optional[bool] = False,
196
+ api_audience: Optional[str] = None,
197
+ ) -> None:
198
+ """Instantiate the transport.
199
+
200
+ Args:
201
+ host (Optional[str]):
202
+ The hostname to connect to (default: 'aiplatform.googleapis.com').
203
+ credentials (Optional[google.auth.credentials.Credentials]): The
204
+ authorization credentials to attach to requests. These
205
+ credentials identify the application to the service; if none
206
+ are specified, the client will attempt to ascertain the
207
+ credentials from the environment.
208
+ This argument is ignored if a ``channel`` instance is provided.
209
+ credentials_file (Optional[str]): Deprecated. A file with credentials that can
210
+ be loaded with :func:`google.auth.load_credentials_from_file`.
211
+ This argument is ignored if a ``channel`` instance is provided.
212
+ This argument will be removed in the next major version of this library.
213
+ scopes (Optional[Sequence[str]]): A optional list of scopes needed for this
214
+ service. These are only used when credentials are not specified and
215
+ are passed to :func:`google.auth.default`.
216
+ channel (Optional[Union[aio.Channel, Callable[..., aio.Channel]]]):
217
+ A ``Channel`` instance through which to make calls, or a Callable
218
+ that constructs and returns one. If set to None, ``self.create_channel``
219
+ is used to create the channel. If a Callable is given, it will be called
220
+ with the same arguments as used in ``self.create_channel``.
221
+ api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint.
222
+ If provided, it overrides the ``host`` argument and tries to create
223
+ a mutual TLS channel with client SSL credentials from
224
+ ``client_cert_source`` or application default SSL credentials.
225
+ client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]):
226
+ Deprecated. A callback to provide client SSL certificate bytes and
227
+ private key bytes, both in PEM format. It is ignored if
228
+ ``api_mtls_endpoint`` is None.
229
+ ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials
230
+ for the grpc channel. It is ignored if a ``channel`` instance is provided.
231
+ client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]):
232
+ A callback to provide client certificate bytes and private key bytes,
233
+ both in PEM format. It is used to configure a mutual TLS channel. It is
234
+ ignored if a ``channel`` instance or ``ssl_channel_credentials`` is provided.
235
+ quota_project_id (Optional[str]): An optional project to use for billing
236
+ and quota.
237
+ client_info (google.api_core.gapic_v1.client_info.ClientInfo):
238
+ The client info used to send a user-agent string along with
239
+ API requests. If ``None``, then default info will be used.
240
+ Generally, you only need to set this if you're developing
241
+ your own client library.
242
+ always_use_jwt_access (Optional[bool]): Whether self signed JWT should
243
+ be used for service account credentials.
244
+
245
+ Raises:
246
+ google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport
247
+ creation failed for any reason.
248
+ google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials``
249
+ and ``credentials_file`` are passed.
250
+ """
251
+ self._grpc_channel = None
252
+ self._ssl_channel_credentials = ssl_channel_credentials
253
+ self._stubs: Dict[str, Callable] = {}
254
+
255
+ if api_mtls_endpoint:
256
+ warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning)
257
+ if client_cert_source:
258
+ warnings.warn("client_cert_source is deprecated", DeprecationWarning)
259
+
260
+ if isinstance(channel, aio.Channel):
261
+ # Ignore credentials if a channel was passed.
262
+ credentials = None
263
+ self._ignore_credentials = True
264
+ # If a channel was explicitly provided, set it.
265
+ self._grpc_channel = channel
266
+ self._ssl_channel_credentials = None
267
+ else:
268
+ if api_mtls_endpoint:
269
+ host = api_mtls_endpoint
270
+
271
+ # Create SSL credentials with client_cert_source or application
272
+ # default SSL credentials.
273
+ if client_cert_source:
274
+ cert, key = client_cert_source()
275
+ self._ssl_channel_credentials = grpc.ssl_channel_credentials(
276
+ certificate_chain=cert, private_key=key
277
+ )
278
+ else:
279
+ self._ssl_channel_credentials = SslCredentials().ssl_credentials
280
+
281
+ else:
282
+ if client_cert_source_for_mtls and not ssl_channel_credentials:
283
+ cert, key = client_cert_source_for_mtls()
284
+ self._ssl_channel_credentials = grpc.ssl_channel_credentials(
285
+ certificate_chain=cert, private_key=key
286
+ )
287
+
288
+ # The base transport sets the host, credentials and scopes
289
+ super().__init__(
290
+ host=host,
291
+ credentials=credentials,
292
+ credentials_file=credentials_file,
293
+ scopes=scopes,
294
+ quota_project_id=quota_project_id,
295
+ client_info=client_info,
296
+ always_use_jwt_access=always_use_jwt_access,
297
+ api_audience=api_audience,
298
+ )
299
+
300
+ if not self._grpc_channel:
301
+ # initialize with the provided callable or the default channel
302
+ channel_init = channel or type(self).create_channel
303
+ self._grpc_channel = channel_init(
304
+ self._host,
305
+ # use the credentials which are saved
306
+ credentials=self._credentials,
307
+ # Set ``credentials_file`` to ``None`` here as
308
+ # the credentials that we saved earlier should be used.
309
+ credentials_file=None,
310
+ scopes=self._scopes,
311
+ ssl_credentials=self._ssl_channel_credentials,
312
+ quota_project_id=quota_project_id,
313
+ options=[
314
+ ("grpc.max_send_message_length", -1),
315
+ ("grpc.max_receive_message_length", -1),
316
+ ],
317
+ )
318
+
319
+ self._interceptor = _LoggingClientAIOInterceptor()
320
+ self._grpc_channel._unary_unary_interceptors.append(self._interceptor)
321
+ self._logged_channel = self._grpc_channel
322
+ self._wrap_with_kind = (
323
+ "kind" in inspect.signature(gapic_v1.method_async.wrap_method).parameters
324
+ )
325
+ # Wrap messages. This must be done after self._logged_channel exists
326
+ self._prep_wrapped_messages(client_info)
327
+
328
+ @property
329
+ def grpc_channel(self) -> aio.Channel:
330
+ """Create the channel designed to connect to this service.
331
+
332
+ This property caches on the instance; repeated calls return
333
+ the same channel.
334
+ """
335
+ # Return the channel from cache.
336
+ return self._grpc_channel
337
+
338
+ @property
339
+ def find_neighbors(
340
+ self,
341
+ ) -> Callable[
342
+ [match_service.FindNeighborsRequest],
343
+ Awaitable[match_service.FindNeighborsResponse],
344
+ ]:
345
+ r"""Return a callable for the find neighbors method over gRPC.
346
+
347
+ Finds the nearest neighbors of each vector within the
348
+ request.
349
+
350
+ Returns:
351
+ Callable[[~.FindNeighborsRequest],
352
+ Awaitable[~.FindNeighborsResponse]]:
353
+ A function that, when called, will call the underlying RPC
354
+ on the server.
355
+ """
356
+ # Generate a "stub function" on-the-fly which will actually make
357
+ # the request.
358
+ # gRPC handles serialization and deserialization, so we just need
359
+ # to pass in the functions for each.
360
+ if "find_neighbors" not in self._stubs:
361
+ self._stubs["find_neighbors"] = self._logged_channel.unary_unary(
362
+ "/google.cloud.aiplatform.v1.MatchService/FindNeighbors",
363
+ request_serializer=match_service.FindNeighborsRequest.serialize,
364
+ response_deserializer=match_service.FindNeighborsResponse.deserialize,
365
+ )
366
+ return self._stubs["find_neighbors"]
367
+
368
+ @property
369
+ def read_index_datapoints(
370
+ self,
371
+ ) -> Callable[
372
+ [match_service.ReadIndexDatapointsRequest],
373
+ Awaitable[match_service.ReadIndexDatapointsResponse],
374
+ ]:
375
+ r"""Return a callable for the read index datapoints method over gRPC.
376
+
377
+ Reads the datapoints/vectors of the given IDs.
378
+ A maximum of 1000 datapoints can be retrieved in a
379
+ batch.
380
+
381
+ Returns:
382
+ Callable[[~.ReadIndexDatapointsRequest],
383
+ Awaitable[~.ReadIndexDatapointsResponse]]:
384
+ A function that, when called, will call the underlying RPC
385
+ on the server.
386
+ """
387
+ # Generate a "stub function" on-the-fly which will actually make
388
+ # the request.
389
+ # gRPC handles serialization and deserialization, so we just need
390
+ # to pass in the functions for each.
391
+ if "read_index_datapoints" not in self._stubs:
392
+ self._stubs["read_index_datapoints"] = self._logged_channel.unary_unary(
393
+ "/google.cloud.aiplatform.v1.MatchService/ReadIndexDatapoints",
394
+ request_serializer=match_service.ReadIndexDatapointsRequest.serialize,
395
+ response_deserializer=match_service.ReadIndexDatapointsResponse.deserialize,
396
+ )
397
+ return self._stubs["read_index_datapoints"]
398
+
399
+ def _prep_wrapped_messages(self, client_info):
400
+ """Precompute the wrapped methods, overriding the base class method to use async wrappers."""
401
+ self._wrapped_methods = {
402
+ self.find_neighbors: self._wrap_method(
403
+ self.find_neighbors,
404
+ default_timeout=None,
405
+ client_info=client_info,
406
+ ),
407
+ self.read_index_datapoints: self._wrap_method(
408
+ self.read_index_datapoints,
409
+ default_timeout=None,
410
+ client_info=client_info,
411
+ ),
412
+ self.get_location: self._wrap_method(
413
+ self.get_location,
414
+ default_timeout=None,
415
+ client_info=client_info,
416
+ ),
417
+ self.list_locations: self._wrap_method(
418
+ self.list_locations,
419
+ default_timeout=None,
420
+ client_info=client_info,
421
+ ),
422
+ self.get_iam_policy: self._wrap_method(
423
+ self.get_iam_policy,
424
+ default_timeout=None,
425
+ client_info=client_info,
426
+ ),
427
+ self.set_iam_policy: self._wrap_method(
428
+ self.set_iam_policy,
429
+ default_timeout=None,
430
+ client_info=client_info,
431
+ ),
432
+ self.test_iam_permissions: self._wrap_method(
433
+ self.test_iam_permissions,
434
+ default_timeout=None,
435
+ client_info=client_info,
436
+ ),
437
+ self.cancel_operation: self._wrap_method(
438
+ self.cancel_operation,
439
+ default_timeout=None,
440
+ client_info=client_info,
441
+ ),
442
+ self.delete_operation: self._wrap_method(
443
+ self.delete_operation,
444
+ default_timeout=None,
445
+ client_info=client_info,
446
+ ),
447
+ self.get_operation: self._wrap_method(
448
+ self.get_operation,
449
+ default_timeout=None,
450
+ client_info=client_info,
451
+ ),
452
+ self.list_operations: self._wrap_method(
453
+ self.list_operations,
454
+ default_timeout=None,
455
+ client_info=client_info,
456
+ ),
457
+ self.wait_operation: self._wrap_method(
458
+ self.wait_operation,
459
+ default_timeout=None,
460
+ client_info=client_info,
461
+ ),
462
+ }
463
+
464
+ def _wrap_method(self, func, *args, **kwargs):
465
+ if self._wrap_with_kind: # pragma: NO COVER
466
+ kwargs["kind"] = self.kind
467
+ return gapic_v1.method_async.wrap_method(func, *args, **kwargs)
468
+
469
+ def close(self):
470
+ return self._logged_channel.close()
471
+
472
+ @property
473
+ def kind(self) -> str:
474
+ return "grpc_asyncio"
475
+
476
+ @property
477
+ def delete_operation(
478
+ self,
479
+ ) -> Callable[[operations_pb2.DeleteOperationRequest], None]:
480
+ r"""Return a callable for the delete_operation method over gRPC."""
481
+ # Generate a "stub function" on-the-fly which will actually make
482
+ # the request.
483
+ # gRPC handles serialization and deserialization, so we just need
484
+ # to pass in the functions for each.
485
+ if "delete_operation" not in self._stubs:
486
+ self._stubs["delete_operation"] = self._logged_channel.unary_unary(
487
+ "/google.longrunning.Operations/DeleteOperation",
488
+ request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString,
489
+ response_deserializer=None,
490
+ )
491
+ return self._stubs["delete_operation"]
492
+
493
+ @property
494
+ def cancel_operation(
495
+ self,
496
+ ) -> Callable[[operations_pb2.CancelOperationRequest], None]:
497
+ r"""Return a callable for the cancel_operation method over gRPC."""
498
+ # Generate a "stub function" on-the-fly which will actually make
499
+ # the request.
500
+ # gRPC handles serialization and deserialization, so we just need
501
+ # to pass in the functions for each.
502
+ if "cancel_operation" not in self._stubs:
503
+ self._stubs["cancel_operation"] = self._logged_channel.unary_unary(
504
+ "/google.longrunning.Operations/CancelOperation",
505
+ request_serializer=operations_pb2.CancelOperationRequest.SerializeToString,
506
+ response_deserializer=None,
507
+ )
508
+ return self._stubs["cancel_operation"]
509
+
510
+ @property
511
+ def wait_operation(
512
+ self,
513
+ ) -> Callable[[operations_pb2.WaitOperationRequest], None]:
514
+ r"""Return a callable for the wait_operation method over gRPC."""
515
+ # Generate a "stub function" on-the-fly which will actually make
516
+ # the request.
517
+ # gRPC handles serialization and deserialization, so we just need
518
+ # to pass in the functions for each.
519
+ if "wait_operation" not in self._stubs:
520
+ self._stubs["wait_operation"] = self._logged_channel.unary_unary(
521
+ "/google.longrunning.Operations/WaitOperation",
522
+ request_serializer=operations_pb2.WaitOperationRequest.SerializeToString,
523
+ response_deserializer=None,
524
+ )
525
+ return self._stubs["wait_operation"]
526
+
527
+ @property
528
+ def get_operation(
529
+ self,
530
+ ) -> Callable[[operations_pb2.GetOperationRequest], operations_pb2.Operation]:
531
+ r"""Return a callable for the get_operation method over gRPC."""
532
+ # Generate a "stub function" on-the-fly which will actually make
533
+ # the request.
534
+ # gRPC handles serialization and deserialization, so we just need
535
+ # to pass in the functions for each.
536
+ if "get_operation" not in self._stubs:
537
+ self._stubs["get_operation"] = self._logged_channel.unary_unary(
538
+ "/google.longrunning.Operations/GetOperation",
539
+ request_serializer=operations_pb2.GetOperationRequest.SerializeToString,
540
+ response_deserializer=operations_pb2.Operation.FromString,
541
+ )
542
+ return self._stubs["get_operation"]
543
+
544
+ @property
545
+ def list_operations(
546
+ self,
547
+ ) -> Callable[
548
+ [operations_pb2.ListOperationsRequest], operations_pb2.ListOperationsResponse
549
+ ]:
550
+ r"""Return a callable for the list_operations method over gRPC."""
551
+ # Generate a "stub function" on-the-fly which will actually make
552
+ # the request.
553
+ # gRPC handles serialization and deserialization, so we just need
554
+ # to pass in the functions for each.
555
+ if "list_operations" not in self._stubs:
556
+ self._stubs["list_operations"] = self._logged_channel.unary_unary(
557
+ "/google.longrunning.Operations/ListOperations",
558
+ request_serializer=operations_pb2.ListOperationsRequest.SerializeToString,
559
+ response_deserializer=operations_pb2.ListOperationsResponse.FromString,
560
+ )
561
+ return self._stubs["list_operations"]
562
+
563
+ @property
564
+ def list_locations(
565
+ self,
566
+ ) -> Callable[
567
+ [locations_pb2.ListLocationsRequest], locations_pb2.ListLocationsResponse
568
+ ]:
569
+ r"""Return a callable for the list locations method over gRPC."""
570
+ # Generate a "stub function" on-the-fly which will actually make
571
+ # the request.
572
+ # gRPC handles serialization and deserialization, so we just need
573
+ # to pass in the functions for each.
574
+ if "list_locations" not in self._stubs:
575
+ self._stubs["list_locations"] = self._logged_channel.unary_unary(
576
+ "/google.cloud.location.Locations/ListLocations",
577
+ request_serializer=locations_pb2.ListLocationsRequest.SerializeToString,
578
+ response_deserializer=locations_pb2.ListLocationsResponse.FromString,
579
+ )
580
+ return self._stubs["list_locations"]
581
+
582
+ @property
583
+ def get_location(
584
+ self,
585
+ ) -> Callable[[locations_pb2.GetLocationRequest], locations_pb2.Location]:
586
+ r"""Return a callable for the list locations method over gRPC."""
587
+ # Generate a "stub function" on-the-fly which will actually make
588
+ # the request.
589
+ # gRPC handles serialization and deserialization, so we just need
590
+ # to pass in the functions for each.
591
+ if "get_location" not in self._stubs:
592
+ self._stubs["get_location"] = self._logged_channel.unary_unary(
593
+ "/google.cloud.location.Locations/GetLocation",
594
+ request_serializer=locations_pb2.GetLocationRequest.SerializeToString,
595
+ response_deserializer=locations_pb2.Location.FromString,
596
+ )
597
+ return self._stubs["get_location"]
598
+
599
+ @property
600
+ def set_iam_policy(
601
+ self,
602
+ ) -> Callable[[iam_policy_pb2.SetIamPolicyRequest], policy_pb2.Policy]:
603
+ r"""Return a callable for the set iam policy method over gRPC.
604
+ Sets the IAM access control policy on the specified
605
+ function. Replaces any existing policy.
606
+ Returns:
607
+ Callable[[~.SetIamPolicyRequest],
608
+ ~.Policy]:
609
+ A function that, when called, will call the underlying RPC
610
+ on the server.
611
+ """
612
+ # Generate a "stub function" on-the-fly which will actually make
613
+ # the request.
614
+ # gRPC handles serialization and deserialization, so we just need
615
+ # to pass in the functions for each.
616
+ if "set_iam_policy" not in self._stubs:
617
+ self._stubs["set_iam_policy"] = self._logged_channel.unary_unary(
618
+ "/google.iam.v1.IAMPolicy/SetIamPolicy",
619
+ request_serializer=iam_policy_pb2.SetIamPolicyRequest.SerializeToString,
620
+ response_deserializer=policy_pb2.Policy.FromString,
621
+ )
622
+ return self._stubs["set_iam_policy"]
623
+
624
+ @property
625
+ def get_iam_policy(
626
+ self,
627
+ ) -> Callable[[iam_policy_pb2.GetIamPolicyRequest], policy_pb2.Policy]:
628
+ r"""Return a callable for the get iam policy method over gRPC.
629
+ Gets the IAM access control policy for a function.
630
+ Returns an empty policy if the function exists and does
631
+ not have a policy set.
632
+ Returns:
633
+ Callable[[~.GetIamPolicyRequest],
634
+ ~.Policy]:
635
+ A function that, when called, will call the underlying RPC
636
+ on the server.
637
+ """
638
+ # Generate a "stub function" on-the-fly which will actually make
639
+ # the request.
640
+ # gRPC handles serialization and deserialization, so we just need
641
+ # to pass in the functions for each.
642
+ if "get_iam_policy" not in self._stubs:
643
+ self._stubs["get_iam_policy"] = self._logged_channel.unary_unary(
644
+ "/google.iam.v1.IAMPolicy/GetIamPolicy",
645
+ request_serializer=iam_policy_pb2.GetIamPolicyRequest.SerializeToString,
646
+ response_deserializer=policy_pb2.Policy.FromString,
647
+ )
648
+ return self._stubs["get_iam_policy"]
649
+
650
+ @property
651
+ def test_iam_permissions(
652
+ self,
653
+ ) -> Callable[
654
+ [iam_policy_pb2.TestIamPermissionsRequest],
655
+ iam_policy_pb2.TestIamPermissionsResponse,
656
+ ]:
657
+ r"""Return a callable for the test iam permissions method over gRPC.
658
+ Tests the specified permissions against the IAM access control
659
+ policy for a function. If the function does not exist, this will
660
+ return an empty set of permissions, not a NOT_FOUND error.
661
+ Returns:
662
+ Callable[[~.TestIamPermissionsRequest],
663
+ ~.TestIamPermissionsResponse]:
664
+ A function that, when called, will call the underlying RPC
665
+ on the server.
666
+ """
667
+ # Generate a "stub function" on-the-fly which will actually make
668
+ # the request.
669
+ # gRPC handles serialization and deserialization, so we just need
670
+ # to pass in the functions for each.
671
+ if "test_iam_permissions" not in self._stubs:
672
+ self._stubs["test_iam_permissions"] = self._logged_channel.unary_unary(
673
+ "/google.iam.v1.IAMPolicy/TestIamPermissions",
674
+ request_serializer=iam_policy_pb2.TestIamPermissionsRequest.SerializeToString,
675
+ response_deserializer=iam_policy_pb2.TestIamPermissionsResponse.FromString,
676
+ )
677
+ return self._stubs["test_iam_permissions"]
678
+
679
+
680
+ __all__ = ("MatchServiceGrpcAsyncIOTransport",)
loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/match_service/transports/rest.py ADDED
@@ -0,0 +1,2262 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright 2025 Google LLC
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+ import logging
17
+ import json # type: ignore
18
+
19
+ from google.auth.transport.requests import AuthorizedSession # type: ignore
20
+ from google.auth import credentials as ga_credentials # type: ignore
21
+ from google.api_core import exceptions as core_exceptions
22
+ from google.api_core import retry as retries
23
+ from google.api_core import rest_helpers
24
+ from google.api_core import rest_streaming
25
+ from google.api_core import gapic_v1
26
+ import google.protobuf
27
+
28
+ from google.protobuf import json_format
29
+ from google.iam.v1 import iam_policy_pb2 # type: ignore
30
+ from google.iam.v1 import policy_pb2 # type: ignore
31
+ from google.cloud.location import locations_pb2 # type: ignore
32
+
33
+ from requests import __version__ as requests_version
34
+ import dataclasses
35
+ from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union
36
+ import warnings
37
+
38
+
39
+ from google.cloud.aiplatform_v1.types import match_service
40
+ from google.longrunning import operations_pb2 # type: ignore
41
+
42
+
43
+ from .rest_base import _BaseMatchServiceRestTransport
44
+ from .base import DEFAULT_CLIENT_INFO as BASE_DEFAULT_CLIENT_INFO
45
+
46
+ try:
47
+ OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault, None]
48
+ except AttributeError: # pragma: NO COVER
49
+ OptionalRetry = Union[retries.Retry, object, None] # type: ignore
50
+
51
+ try:
52
+ from google.api_core import client_logging # type: ignore
53
+
54
+ CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER
55
+ except ImportError: # pragma: NO COVER
56
+ CLIENT_LOGGING_SUPPORTED = False
57
+
58
+ _LOGGER = logging.getLogger(__name__)
59
+
60
+ DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
61
+ gapic_version=BASE_DEFAULT_CLIENT_INFO.gapic_version,
62
+ grpc_version=None,
63
+ rest_version=f"requests@{requests_version}",
64
+ )
65
+
66
+ if hasattr(DEFAULT_CLIENT_INFO, "protobuf_runtime_version"): # pragma: NO COVER
67
+ DEFAULT_CLIENT_INFO.protobuf_runtime_version = google.protobuf.__version__
68
+
69
+
70
+ class MatchServiceRestInterceptor:
71
+ """Interceptor for MatchService.
72
+
73
+ Interceptors are used to manipulate requests, request metadata, and responses
74
+ in arbitrary ways.
75
+ Example use cases include:
76
+ * Logging
77
+ * Verifying requests according to service or custom semantics
78
+ * Stripping extraneous information from responses
79
+
80
+ These use cases and more can be enabled by injecting an
81
+ instance of a custom subclass when constructing the MatchServiceRestTransport.
82
+
83
+ .. code-block:: python
84
+ class MyCustomMatchServiceInterceptor(MatchServiceRestInterceptor):
85
+ def pre_find_neighbors(self, request, metadata):
86
+ logging.log(f"Received request: {request}")
87
+ return request, metadata
88
+
89
+ def post_find_neighbors(self, response):
90
+ logging.log(f"Received response: {response}")
91
+ return response
92
+
93
+ def pre_read_index_datapoints(self, request, metadata):
94
+ logging.log(f"Received request: {request}")
95
+ return request, metadata
96
+
97
+ def post_read_index_datapoints(self, response):
98
+ logging.log(f"Received response: {response}")
99
+ return response
100
+
101
+ transport = MatchServiceRestTransport(interceptor=MyCustomMatchServiceInterceptor())
102
+ client = MatchServiceClient(transport=transport)
103
+
104
+
105
+ """
106
+
107
+ def pre_find_neighbors(
108
+ self,
109
+ request: match_service.FindNeighborsRequest,
110
+ metadata: Sequence[Tuple[str, Union[str, bytes]]],
111
+ ) -> Tuple[
112
+ match_service.FindNeighborsRequest, Sequence[Tuple[str, Union[str, bytes]]]
113
+ ]:
114
+ """Pre-rpc interceptor for find_neighbors
115
+
116
+ Override in a subclass to manipulate the request or metadata
117
+ before they are sent to the MatchService server.
118
+ """
119
+ return request, metadata
120
+
121
+ def post_find_neighbors(
122
+ self, response: match_service.FindNeighborsResponse
123
+ ) -> match_service.FindNeighborsResponse:
124
+ """Post-rpc interceptor for find_neighbors
125
+
126
+ DEPRECATED. Please use the `post_find_neighbors_with_metadata`
127
+ interceptor instead.
128
+
129
+ Override in a subclass to read or manipulate the response
130
+ after it is returned by the MatchService server but before
131
+ it is returned to user code. This `post_find_neighbors` interceptor runs
132
+ before the `post_find_neighbors_with_metadata` interceptor.
133
+ """
134
+ return response
135
+
136
+ def post_find_neighbors_with_metadata(
137
+ self,
138
+ response: match_service.FindNeighborsResponse,
139
+ metadata: Sequence[Tuple[str, Union[str, bytes]]],
140
+ ) -> Tuple[
141
+ match_service.FindNeighborsResponse, Sequence[Tuple[str, Union[str, bytes]]]
142
+ ]:
143
+ """Post-rpc interceptor for find_neighbors
144
+
145
+ Override in a subclass to read or manipulate the response or metadata after it
146
+ is returned by the MatchService server but before it is returned to user code.
147
+
148
+ We recommend only using this `post_find_neighbors_with_metadata`
149
+ interceptor in new development instead of the `post_find_neighbors` interceptor.
150
+ When both interceptors are used, this `post_find_neighbors_with_metadata` interceptor runs after the
151
+ `post_find_neighbors` interceptor. The (possibly modified) response returned by
152
+ `post_find_neighbors` will be passed to
153
+ `post_find_neighbors_with_metadata`.
154
+ """
155
+ return response, metadata
156
+
157
+ def pre_read_index_datapoints(
158
+ self,
159
+ request: match_service.ReadIndexDatapointsRequest,
160
+ metadata: Sequence[Tuple[str, Union[str, bytes]]],
161
+ ) -> Tuple[
162
+ match_service.ReadIndexDatapointsRequest,
163
+ Sequence[Tuple[str, Union[str, bytes]]],
164
+ ]:
165
+ """Pre-rpc interceptor for read_index_datapoints
166
+
167
+ Override in a subclass to manipulate the request or metadata
168
+ before they are sent to the MatchService server.
169
+ """
170
+ return request, metadata
171
+
172
+ def post_read_index_datapoints(
173
+ self, response: match_service.ReadIndexDatapointsResponse
174
+ ) -> match_service.ReadIndexDatapointsResponse:
175
+ """Post-rpc interceptor for read_index_datapoints
176
+
177
+ DEPRECATED. Please use the `post_read_index_datapoints_with_metadata`
178
+ interceptor instead.
179
+
180
+ Override in a subclass to read or manipulate the response
181
+ after it is returned by the MatchService server but before
182
+ it is returned to user code. This `post_read_index_datapoints` interceptor runs
183
+ before the `post_read_index_datapoints_with_metadata` interceptor.
184
+ """
185
+ return response
186
+
187
+ def post_read_index_datapoints_with_metadata(
188
+ self,
189
+ response: match_service.ReadIndexDatapointsResponse,
190
+ metadata: Sequence[Tuple[str, Union[str, bytes]]],
191
+ ) -> Tuple[
192
+ match_service.ReadIndexDatapointsResponse,
193
+ Sequence[Tuple[str, Union[str, bytes]]],
194
+ ]:
195
+ """Post-rpc interceptor for read_index_datapoints
196
+
197
+ Override in a subclass to read or manipulate the response or metadata after it
198
+ is returned by the MatchService server but before it is returned to user code.
199
+
200
+ We recommend only using this `post_read_index_datapoints_with_metadata`
201
+ interceptor in new development instead of the `post_read_index_datapoints` interceptor.
202
+ When both interceptors are used, this `post_read_index_datapoints_with_metadata` interceptor runs after the
203
+ `post_read_index_datapoints` interceptor. The (possibly modified) response returned by
204
+ `post_read_index_datapoints` will be passed to
205
+ `post_read_index_datapoints_with_metadata`.
206
+ """
207
+ return response, metadata
208
+
209
+ def pre_get_location(
210
+ self,
211
+ request: locations_pb2.GetLocationRequest,
212
+ metadata: Sequence[Tuple[str, Union[str, bytes]]],
213
+ ) -> Tuple[
214
+ locations_pb2.GetLocationRequest, Sequence[Tuple[str, Union[str, bytes]]]
215
+ ]:
216
+ """Pre-rpc interceptor for get_location
217
+
218
+ Override in a subclass to manipulate the request or metadata
219
+ before they are sent to the MatchService server.
220
+ """
221
+ return request, metadata
222
+
223
+ def post_get_location(
224
+ self, response: locations_pb2.Location
225
+ ) -> locations_pb2.Location:
226
+ """Post-rpc interceptor for get_location
227
+
228
+ Override in a subclass to manipulate the response
229
+ after it is returned by the MatchService server but before
230
+ it is returned to user code.
231
+ """
232
+ return response
233
+
234
+ def pre_list_locations(
235
+ self,
236
+ request: locations_pb2.ListLocationsRequest,
237
+ metadata: Sequence[Tuple[str, Union[str, bytes]]],
238
+ ) -> Tuple[
239
+ locations_pb2.ListLocationsRequest, Sequence[Tuple[str, Union[str, bytes]]]
240
+ ]:
241
+ """Pre-rpc interceptor for list_locations
242
+
243
+ Override in a subclass to manipulate the request or metadata
244
+ before they are sent to the MatchService server.
245
+ """
246
+ return request, metadata
247
+
248
+ def post_list_locations(
249
+ self, response: locations_pb2.ListLocationsResponse
250
+ ) -> locations_pb2.ListLocationsResponse:
251
+ """Post-rpc interceptor for list_locations
252
+
253
+ Override in a subclass to manipulate the response
254
+ after it is returned by the MatchService server but before
255
+ it is returned to user code.
256
+ """
257
+ return response
258
+
259
+ def pre_get_iam_policy(
260
+ self,
261
+ request: iam_policy_pb2.GetIamPolicyRequest,
262
+ metadata: Sequence[Tuple[str, Union[str, bytes]]],
263
+ ) -> Tuple[
264
+ iam_policy_pb2.GetIamPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]]
265
+ ]:
266
+ """Pre-rpc interceptor for get_iam_policy
267
+
268
+ Override in a subclass to manipulate the request or metadata
269
+ before they are sent to the MatchService server.
270
+ """
271
+ return request, metadata
272
+
273
+ def post_get_iam_policy(self, response: policy_pb2.Policy) -> policy_pb2.Policy:
274
+ """Post-rpc interceptor for get_iam_policy
275
+
276
+ Override in a subclass to manipulate the response
277
+ after it is returned by the MatchService server but before
278
+ it is returned to user code.
279
+ """
280
+ return response
281
+
282
+ def pre_set_iam_policy(
283
+ self,
284
+ request: iam_policy_pb2.SetIamPolicyRequest,
285
+ metadata: Sequence[Tuple[str, Union[str, bytes]]],
286
+ ) -> Tuple[
287
+ iam_policy_pb2.SetIamPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]]
288
+ ]:
289
+ """Pre-rpc interceptor for set_iam_policy
290
+
291
+ Override in a subclass to manipulate the request or metadata
292
+ before they are sent to the MatchService server.
293
+ """
294
+ return request, metadata
295
+
296
+ def post_set_iam_policy(self, response: policy_pb2.Policy) -> policy_pb2.Policy:
297
+ """Post-rpc interceptor for set_iam_policy
298
+
299
+ Override in a subclass to manipulate the response
300
+ after it is returned by the MatchService server but before
301
+ it is returned to user code.
302
+ """
303
+ return response
304
+
305
+ def pre_test_iam_permissions(
306
+ self,
307
+ request: iam_policy_pb2.TestIamPermissionsRequest,
308
+ metadata: Sequence[Tuple[str, Union[str, bytes]]],
309
+ ) -> Tuple[
310
+ iam_policy_pb2.TestIamPermissionsRequest,
311
+ Sequence[Tuple[str, Union[str, bytes]]],
312
+ ]:
313
+ """Pre-rpc interceptor for test_iam_permissions
314
+
315
+ Override in a subclass to manipulate the request or metadata
316
+ before they are sent to the MatchService server.
317
+ """
318
+ return request, metadata
319
+
320
+ def post_test_iam_permissions(
321
+ self, response: iam_policy_pb2.TestIamPermissionsResponse
322
+ ) -> iam_policy_pb2.TestIamPermissionsResponse:
323
+ """Post-rpc interceptor for test_iam_permissions
324
+
325
+ Override in a subclass to manipulate the response
326
+ after it is returned by the MatchService server but before
327
+ it is returned to user code.
328
+ """
329
+ return response
330
+
331
+ def pre_cancel_operation(
332
+ self,
333
+ request: operations_pb2.CancelOperationRequest,
334
+ metadata: Sequence[Tuple[str, Union[str, bytes]]],
335
+ ) -> Tuple[
336
+ operations_pb2.CancelOperationRequest, Sequence[Tuple[str, Union[str, bytes]]]
337
+ ]:
338
+ """Pre-rpc interceptor for cancel_operation
339
+
340
+ Override in a subclass to manipulate the request or metadata
341
+ before they are sent to the MatchService server.
342
+ """
343
+ return request, metadata
344
+
345
+ def post_cancel_operation(self, response: None) -> None:
346
+ """Post-rpc interceptor for cancel_operation
347
+
348
+ Override in a subclass to manipulate the response
349
+ after it is returned by the MatchService server but before
350
+ it is returned to user code.
351
+ """
352
+ return response
353
+
354
+ def pre_delete_operation(
355
+ self,
356
+ request: operations_pb2.DeleteOperationRequest,
357
+ metadata: Sequence[Tuple[str, Union[str, bytes]]],
358
+ ) -> Tuple[
359
+ operations_pb2.DeleteOperationRequest, Sequence[Tuple[str, Union[str, bytes]]]
360
+ ]:
361
+ """Pre-rpc interceptor for delete_operation
362
+
363
+ Override in a subclass to manipulate the request or metadata
364
+ before they are sent to the MatchService server.
365
+ """
366
+ return request, metadata
367
+
368
+ def post_delete_operation(self, response: None) -> None:
369
+ """Post-rpc interceptor for delete_operation
370
+
371
+ Override in a subclass to manipulate the response
372
+ after it is returned by the MatchService server but before
373
+ it is returned to user code.
374
+ """
375
+ return response
376
+
377
+ def pre_get_operation(
378
+ self,
379
+ request: operations_pb2.GetOperationRequest,
380
+ metadata: Sequence[Tuple[str, Union[str, bytes]]],
381
+ ) -> Tuple[
382
+ operations_pb2.GetOperationRequest, Sequence[Tuple[str, Union[str, bytes]]]
383
+ ]:
384
+ """Pre-rpc interceptor for get_operation
385
+
386
+ Override in a subclass to manipulate the request or metadata
387
+ before they are sent to the MatchService server.
388
+ """
389
+ return request, metadata
390
+
391
+ def post_get_operation(
392
+ self, response: operations_pb2.Operation
393
+ ) -> operations_pb2.Operation:
394
+ """Post-rpc interceptor for get_operation
395
+
396
+ Override in a subclass to manipulate the response
397
+ after it is returned by the MatchService server but before
398
+ it is returned to user code.
399
+ """
400
+ return response
401
+
402
+ def pre_list_operations(
403
+ self,
404
+ request: operations_pb2.ListOperationsRequest,
405
+ metadata: Sequence[Tuple[str, Union[str, bytes]]],
406
+ ) -> Tuple[
407
+ operations_pb2.ListOperationsRequest, Sequence[Tuple[str, Union[str, bytes]]]
408
+ ]:
409
+ """Pre-rpc interceptor for list_operations
410
+
411
+ Override in a subclass to manipulate the request or metadata
412
+ before they are sent to the MatchService server.
413
+ """
414
+ return request, metadata
415
+
416
+ def post_list_operations(
417
+ self, response: operations_pb2.ListOperationsResponse
418
+ ) -> operations_pb2.ListOperationsResponse:
419
+ """Post-rpc interceptor for list_operations
420
+
421
+ Override in a subclass to manipulate the response
422
+ after it is returned by the MatchService server but before
423
+ it is returned to user code.
424
+ """
425
+ return response
426
+
427
+ def pre_wait_operation(
428
+ self,
429
+ request: operations_pb2.WaitOperationRequest,
430
+ metadata: Sequence[Tuple[str, Union[str, bytes]]],
431
+ ) -> Tuple[
432
+ operations_pb2.WaitOperationRequest, Sequence[Tuple[str, Union[str, bytes]]]
433
+ ]:
434
+ """Pre-rpc interceptor for wait_operation
435
+
436
+ Override in a subclass to manipulate the request or metadata
437
+ before they are sent to the MatchService server.
438
+ """
439
+ return request, metadata
440
+
441
+ def post_wait_operation(
442
+ self, response: operations_pb2.Operation
443
+ ) -> operations_pb2.Operation:
444
+ """Post-rpc interceptor for wait_operation
445
+
446
+ Override in a subclass to manipulate the response
447
+ after it is returned by the MatchService server but before
448
+ it is returned to user code.
449
+ """
450
+ return response
451
+
452
+
453
+ @dataclasses.dataclass
454
+ class MatchServiceRestStub:
455
+ _session: AuthorizedSession
456
+ _host: str
457
+ _interceptor: MatchServiceRestInterceptor
458
+
459
+
460
+ class MatchServiceRestTransport(_BaseMatchServiceRestTransport):
461
+ """REST backend synchronous transport for MatchService.
462
+
463
+ MatchService is a Google managed service for efficient vector
464
+ similarity search at scale.
465
+
466
+ This class defines the same methods as the primary client, so the
467
+ primary client can load the underlying transport implementation
468
+ and call it.
469
+
470
+ It sends JSON representations of protocol buffers over HTTP/1.1
471
+ """
472
+
473
+ def __init__(
474
+ self,
475
+ *,
476
+ host: str = "aiplatform.googleapis.com",
477
+ credentials: Optional[ga_credentials.Credentials] = None,
478
+ credentials_file: Optional[str] = None,
479
+ scopes: Optional[Sequence[str]] = None,
480
+ client_cert_source_for_mtls: Optional[Callable[[], Tuple[bytes, bytes]]] = None,
481
+ quota_project_id: Optional[str] = None,
482
+ client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
483
+ always_use_jwt_access: Optional[bool] = False,
484
+ url_scheme: str = "https",
485
+ interceptor: Optional[MatchServiceRestInterceptor] = None,
486
+ api_audience: Optional[str] = None,
487
+ ) -> None:
488
+ """Instantiate the transport.
489
+
490
+ Args:
491
+ host (Optional[str]):
492
+ The hostname to connect to (default: 'aiplatform.googleapis.com').
493
+ credentials (Optional[google.auth.credentials.Credentials]): The
494
+ authorization credentials to attach to requests. These
495
+ credentials identify the application to the service; if none
496
+ are specified, the client will attempt to ascertain the
497
+ credentials from the environment.
498
+
499
+ credentials_file (Optional[str]): Deprecated. A file with credentials that can
500
+ be loaded with :func:`google.auth.load_credentials_from_file`.
501
+ This argument is ignored if ``channel`` is provided. This argument will be
502
+ removed in the next major version of this library.
503
+ scopes (Optional(Sequence[str])): A list of scopes. This argument is
504
+ ignored if ``channel`` is provided.
505
+ client_cert_source_for_mtls (Callable[[], Tuple[bytes, bytes]]): Client
506
+ certificate to configure mutual TLS HTTP channel. It is ignored
507
+ if ``channel`` is provided.
508
+ quota_project_id (Optional[str]): An optional project to use for billing
509
+ and quota.
510
+ client_info (google.api_core.gapic_v1.client_info.ClientInfo):
511
+ The client info used to send a user-agent string along with
512
+ API requests. If ``None``, then default info will be used.
513
+ Generally, you only need to set this if you are developing
514
+ your own client library.
515
+ always_use_jwt_access (Optional[bool]): Whether self signed JWT should
516
+ be used for service account credentials.
517
+ url_scheme: the protocol scheme for the API endpoint. Normally
518
+ "https", but for testing or local servers,
519
+ "http" can be specified.
520
+ """
521
+ # Run the base constructor
522
+ # TODO(yon-mg): resolve other ctor params i.e. scopes, quota, etc.
523
+ # TODO: When custom host (api_endpoint) is set, `scopes` must *also* be set on the
524
+ # credentials object
525
+ super().__init__(
526
+ host=host,
527
+ credentials=credentials,
528
+ client_info=client_info,
529
+ always_use_jwt_access=always_use_jwt_access,
530
+ url_scheme=url_scheme,
531
+ api_audience=api_audience,
532
+ )
533
+ self._session = AuthorizedSession(
534
+ self._credentials, default_host=self.DEFAULT_HOST
535
+ )
536
+ if client_cert_source_for_mtls:
537
+ self._session.configure_mtls_channel(client_cert_source_for_mtls)
538
+ self._interceptor = interceptor or MatchServiceRestInterceptor()
539
+ self._prep_wrapped_messages(client_info)
540
+
541
+ class _FindNeighbors(
542
+ _BaseMatchServiceRestTransport._BaseFindNeighbors, MatchServiceRestStub
543
+ ):
544
+ def __hash__(self):
545
+ return hash("MatchServiceRestTransport.FindNeighbors")
546
+
547
+ @staticmethod
548
+ def _get_response(
549
+ host,
550
+ metadata,
551
+ query_params,
552
+ session,
553
+ timeout,
554
+ transcoded_request,
555
+ body=None,
556
+ ):
557
+
558
+ uri = transcoded_request["uri"]
559
+ method = transcoded_request["method"]
560
+ headers = dict(metadata)
561
+ headers["Content-Type"] = "application/json"
562
+ response = getattr(session, method)(
563
+ "{host}{uri}".format(host=host, uri=uri),
564
+ timeout=timeout,
565
+ headers=headers,
566
+ params=rest_helpers.flatten_query_params(query_params, strict=True),
567
+ data=body,
568
+ )
569
+ return response
570
+
571
+ def __call__(
572
+ self,
573
+ request: match_service.FindNeighborsRequest,
574
+ *,
575
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
576
+ timeout: Optional[float] = None,
577
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
578
+ ) -> match_service.FindNeighborsResponse:
579
+ r"""Call the find neighbors method over HTTP.
580
+
581
+ Args:
582
+ request (~.match_service.FindNeighborsRequest):
583
+ The request object. The request message for
584
+ [MatchService.FindNeighbors][google.cloud.aiplatform.v1.MatchService.FindNeighbors].
585
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
586
+ should be retried.
587
+ timeout (float): The timeout for this request.
588
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
589
+ sent along with the request as metadata. Normally, each value must be of type `str`,
590
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
591
+ be of type `bytes`.
592
+
593
+ Returns:
594
+ ~.match_service.FindNeighborsResponse:
595
+ The response message for
596
+ [MatchService.FindNeighbors][google.cloud.aiplatform.v1.MatchService.FindNeighbors].
597
+
598
+ """
599
+
600
+ http_options = (
601
+ _BaseMatchServiceRestTransport._BaseFindNeighbors._get_http_options()
602
+ )
603
+
604
+ request, metadata = self._interceptor.pre_find_neighbors(request, metadata)
605
+ transcoded_request = _BaseMatchServiceRestTransport._BaseFindNeighbors._get_transcoded_request(
606
+ http_options, request
607
+ )
608
+
609
+ body = _BaseMatchServiceRestTransport._BaseFindNeighbors._get_request_body_json(
610
+ transcoded_request
611
+ )
612
+
613
+ # Jsonify the query params
614
+ query_params = _BaseMatchServiceRestTransport._BaseFindNeighbors._get_query_params_json(
615
+ transcoded_request
616
+ )
617
+
618
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
619
+ logging.DEBUG
620
+ ): # pragma: NO COVER
621
+ request_url = "{host}{uri}".format(
622
+ host=self._host, uri=transcoded_request["uri"]
623
+ )
624
+ method = transcoded_request["method"]
625
+ try:
626
+ request_payload = type(request).to_json(request)
627
+ except:
628
+ request_payload = None
629
+ http_request = {
630
+ "payload": request_payload,
631
+ "requestMethod": method,
632
+ "requestUrl": request_url,
633
+ "headers": dict(metadata),
634
+ }
635
+ _LOGGER.debug(
636
+ f"Sending request for google.cloud.aiplatform_v1.MatchServiceClient.FindNeighbors",
637
+ extra={
638
+ "serviceName": "google.cloud.aiplatform.v1.MatchService",
639
+ "rpcName": "FindNeighbors",
640
+ "httpRequest": http_request,
641
+ "metadata": http_request["headers"],
642
+ },
643
+ )
644
+
645
+ # Send the request
646
+ response = MatchServiceRestTransport._FindNeighbors._get_response(
647
+ self._host,
648
+ metadata,
649
+ query_params,
650
+ self._session,
651
+ timeout,
652
+ transcoded_request,
653
+ body,
654
+ )
655
+
656
+ # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
657
+ # subclass.
658
+ if response.status_code >= 400:
659
+ raise core_exceptions.from_http_response(response)
660
+
661
+ # Return the response
662
+ resp = match_service.FindNeighborsResponse()
663
+ pb_resp = match_service.FindNeighborsResponse.pb(resp)
664
+
665
+ json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True)
666
+
667
+ resp = self._interceptor.post_find_neighbors(resp)
668
+ response_metadata = [(k, str(v)) for k, v in response.headers.items()]
669
+ resp, _ = self._interceptor.post_find_neighbors_with_metadata(
670
+ resp, response_metadata
671
+ )
672
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
673
+ logging.DEBUG
674
+ ): # pragma: NO COVER
675
+ try:
676
+ response_payload = match_service.FindNeighborsResponse.to_json(
677
+ response
678
+ )
679
+ except:
680
+ response_payload = None
681
+ http_response = {
682
+ "payload": response_payload,
683
+ "headers": dict(response.headers),
684
+ "status": response.status_code,
685
+ }
686
+ _LOGGER.debug(
687
+ "Received response for google.cloud.aiplatform_v1.MatchServiceClient.find_neighbors",
688
+ extra={
689
+ "serviceName": "google.cloud.aiplatform.v1.MatchService",
690
+ "rpcName": "FindNeighbors",
691
+ "metadata": http_response["headers"],
692
+ "httpResponse": http_response,
693
+ },
694
+ )
695
+ return resp
696
+
697
+ class _ReadIndexDatapoints(
698
+ _BaseMatchServiceRestTransport._BaseReadIndexDatapoints, MatchServiceRestStub
699
+ ):
700
+ def __hash__(self):
701
+ return hash("MatchServiceRestTransport.ReadIndexDatapoints")
702
+
703
+ @staticmethod
704
+ def _get_response(
705
+ host,
706
+ metadata,
707
+ query_params,
708
+ session,
709
+ timeout,
710
+ transcoded_request,
711
+ body=None,
712
+ ):
713
+
714
+ uri = transcoded_request["uri"]
715
+ method = transcoded_request["method"]
716
+ headers = dict(metadata)
717
+ headers["Content-Type"] = "application/json"
718
+ response = getattr(session, method)(
719
+ "{host}{uri}".format(host=host, uri=uri),
720
+ timeout=timeout,
721
+ headers=headers,
722
+ params=rest_helpers.flatten_query_params(query_params, strict=True),
723
+ data=body,
724
+ )
725
+ return response
726
+
727
+ def __call__(
728
+ self,
729
+ request: match_service.ReadIndexDatapointsRequest,
730
+ *,
731
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
732
+ timeout: Optional[float] = None,
733
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
734
+ ) -> match_service.ReadIndexDatapointsResponse:
735
+ r"""Call the read index datapoints method over HTTP.
736
+
737
+ Args:
738
+ request (~.match_service.ReadIndexDatapointsRequest):
739
+ The request object. The request message for
740
+ [MatchService.ReadIndexDatapoints][google.cloud.aiplatform.v1.MatchService.ReadIndexDatapoints].
741
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
742
+ should be retried.
743
+ timeout (float): The timeout for this request.
744
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
745
+ sent along with the request as metadata. Normally, each value must be of type `str`,
746
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
747
+ be of type `bytes`.
748
+
749
+ Returns:
750
+ ~.match_service.ReadIndexDatapointsResponse:
751
+ The response message for
752
+ [MatchService.ReadIndexDatapoints][google.cloud.aiplatform.v1.MatchService.ReadIndexDatapoints].
753
+
754
+ """
755
+
756
+ http_options = (
757
+ _BaseMatchServiceRestTransport._BaseReadIndexDatapoints._get_http_options()
758
+ )
759
+
760
+ request, metadata = self._interceptor.pre_read_index_datapoints(
761
+ request, metadata
762
+ )
763
+ transcoded_request = _BaseMatchServiceRestTransport._BaseReadIndexDatapoints._get_transcoded_request(
764
+ http_options, request
765
+ )
766
+
767
+ body = _BaseMatchServiceRestTransport._BaseReadIndexDatapoints._get_request_body_json(
768
+ transcoded_request
769
+ )
770
+
771
+ # Jsonify the query params
772
+ query_params = _BaseMatchServiceRestTransport._BaseReadIndexDatapoints._get_query_params_json(
773
+ transcoded_request
774
+ )
775
+
776
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
777
+ logging.DEBUG
778
+ ): # pragma: NO COVER
779
+ request_url = "{host}{uri}".format(
780
+ host=self._host, uri=transcoded_request["uri"]
781
+ )
782
+ method = transcoded_request["method"]
783
+ try:
784
+ request_payload = type(request).to_json(request)
785
+ except:
786
+ request_payload = None
787
+ http_request = {
788
+ "payload": request_payload,
789
+ "requestMethod": method,
790
+ "requestUrl": request_url,
791
+ "headers": dict(metadata),
792
+ }
793
+ _LOGGER.debug(
794
+ f"Sending request for google.cloud.aiplatform_v1.MatchServiceClient.ReadIndexDatapoints",
795
+ extra={
796
+ "serviceName": "google.cloud.aiplatform.v1.MatchService",
797
+ "rpcName": "ReadIndexDatapoints",
798
+ "httpRequest": http_request,
799
+ "metadata": http_request["headers"],
800
+ },
801
+ )
802
+
803
+ # Send the request
804
+ response = MatchServiceRestTransport._ReadIndexDatapoints._get_response(
805
+ self._host,
806
+ metadata,
807
+ query_params,
808
+ self._session,
809
+ timeout,
810
+ transcoded_request,
811
+ body,
812
+ )
813
+
814
+ # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
815
+ # subclass.
816
+ if response.status_code >= 400:
817
+ raise core_exceptions.from_http_response(response)
818
+
819
+ # Return the response
820
+ resp = match_service.ReadIndexDatapointsResponse()
821
+ pb_resp = match_service.ReadIndexDatapointsResponse.pb(resp)
822
+
823
+ json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True)
824
+
825
+ resp = self._interceptor.post_read_index_datapoints(resp)
826
+ response_metadata = [(k, str(v)) for k, v in response.headers.items()]
827
+ resp, _ = self._interceptor.post_read_index_datapoints_with_metadata(
828
+ resp, response_metadata
829
+ )
830
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
831
+ logging.DEBUG
832
+ ): # pragma: NO COVER
833
+ try:
834
+ response_payload = (
835
+ match_service.ReadIndexDatapointsResponse.to_json(response)
836
+ )
837
+ except:
838
+ response_payload = None
839
+ http_response = {
840
+ "payload": response_payload,
841
+ "headers": dict(response.headers),
842
+ "status": response.status_code,
843
+ }
844
+ _LOGGER.debug(
845
+ "Received response for google.cloud.aiplatform_v1.MatchServiceClient.read_index_datapoints",
846
+ extra={
847
+ "serviceName": "google.cloud.aiplatform.v1.MatchService",
848
+ "rpcName": "ReadIndexDatapoints",
849
+ "metadata": http_response["headers"],
850
+ "httpResponse": http_response,
851
+ },
852
+ )
853
+ return resp
854
+
855
+ @property
856
+ def find_neighbors(
857
+ self,
858
+ ) -> Callable[
859
+ [match_service.FindNeighborsRequest], match_service.FindNeighborsResponse
860
+ ]:
861
+ # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here.
862
+ # In C++ this would require a dynamic_cast
863
+ return self._FindNeighbors(self._session, self._host, self._interceptor) # type: ignore
864
+
865
+ @property
866
+ def read_index_datapoints(
867
+ self,
868
+ ) -> Callable[
869
+ [match_service.ReadIndexDatapointsRequest],
870
+ match_service.ReadIndexDatapointsResponse,
871
+ ]:
872
+ # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here.
873
+ # In C++ this would require a dynamic_cast
874
+ return self._ReadIndexDatapoints(self._session, self._host, self._interceptor) # type: ignore
875
+
876
+ @property
877
+ def get_location(self):
878
+ return self._GetLocation(self._session, self._host, self._interceptor) # type: ignore
879
+
880
+ class _GetLocation(
881
+ _BaseMatchServiceRestTransport._BaseGetLocation, MatchServiceRestStub
882
+ ):
883
+ def __hash__(self):
884
+ return hash("MatchServiceRestTransport.GetLocation")
885
+
886
+ @staticmethod
887
+ def _get_response(
888
+ host,
889
+ metadata,
890
+ query_params,
891
+ session,
892
+ timeout,
893
+ transcoded_request,
894
+ body=None,
895
+ ):
896
+
897
+ uri = transcoded_request["uri"]
898
+ method = transcoded_request["method"]
899
+ headers = dict(metadata)
900
+ headers["Content-Type"] = "application/json"
901
+ response = getattr(session, method)(
902
+ "{host}{uri}".format(host=host, uri=uri),
903
+ timeout=timeout,
904
+ headers=headers,
905
+ params=rest_helpers.flatten_query_params(query_params, strict=True),
906
+ )
907
+ return response
908
+
909
+ def __call__(
910
+ self,
911
+ request: locations_pb2.GetLocationRequest,
912
+ *,
913
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
914
+ timeout: Optional[float] = None,
915
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
916
+ ) -> locations_pb2.Location:
917
+ r"""Call the get location method over HTTP.
918
+
919
+ Args:
920
+ request (locations_pb2.GetLocationRequest):
921
+ The request object for GetLocation method.
922
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
923
+ should be retried.
924
+ timeout (float): The timeout for this request.
925
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
926
+ sent along with the request as metadata. Normally, each value must be of type `str`,
927
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
928
+ be of type `bytes`.
929
+
930
+ Returns:
931
+ locations_pb2.Location: Response from GetLocation method.
932
+ """
933
+
934
+ http_options = (
935
+ _BaseMatchServiceRestTransport._BaseGetLocation._get_http_options()
936
+ )
937
+
938
+ request, metadata = self._interceptor.pre_get_location(request, metadata)
939
+ transcoded_request = (
940
+ _BaseMatchServiceRestTransport._BaseGetLocation._get_transcoded_request(
941
+ http_options, request
942
+ )
943
+ )
944
+
945
+ # Jsonify the query params
946
+ query_params = (
947
+ _BaseMatchServiceRestTransport._BaseGetLocation._get_query_params_json(
948
+ transcoded_request
949
+ )
950
+ )
951
+
952
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
953
+ logging.DEBUG
954
+ ): # pragma: NO COVER
955
+ request_url = "{host}{uri}".format(
956
+ host=self._host, uri=transcoded_request["uri"]
957
+ )
958
+ method = transcoded_request["method"]
959
+ try:
960
+ request_payload = json_format.MessageToJson(request)
961
+ except:
962
+ request_payload = None
963
+ http_request = {
964
+ "payload": request_payload,
965
+ "requestMethod": method,
966
+ "requestUrl": request_url,
967
+ "headers": dict(metadata),
968
+ }
969
+ _LOGGER.debug(
970
+ f"Sending request for google.cloud.aiplatform_v1.MatchServiceClient.GetLocation",
971
+ extra={
972
+ "serviceName": "google.cloud.aiplatform.v1.MatchService",
973
+ "rpcName": "GetLocation",
974
+ "httpRequest": http_request,
975
+ "metadata": http_request["headers"],
976
+ },
977
+ )
978
+
979
+ # Send the request
980
+ response = MatchServiceRestTransport._GetLocation._get_response(
981
+ self._host,
982
+ metadata,
983
+ query_params,
984
+ self._session,
985
+ timeout,
986
+ transcoded_request,
987
+ )
988
+
989
+ # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
990
+ # subclass.
991
+ if response.status_code >= 400:
992
+ raise core_exceptions.from_http_response(response)
993
+
994
+ content = response.content.decode("utf-8")
995
+ resp = locations_pb2.Location()
996
+ resp = json_format.Parse(content, resp)
997
+ resp = self._interceptor.post_get_location(resp)
998
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
999
+ logging.DEBUG
1000
+ ): # pragma: NO COVER
1001
+ try:
1002
+ response_payload = json_format.MessageToJson(resp)
1003
+ except:
1004
+ response_payload = None
1005
+ http_response = {
1006
+ "payload": response_payload,
1007
+ "headers": dict(response.headers),
1008
+ "status": response.status_code,
1009
+ }
1010
+ _LOGGER.debug(
1011
+ "Received response for google.cloud.aiplatform_v1.MatchServiceAsyncClient.GetLocation",
1012
+ extra={
1013
+ "serviceName": "google.cloud.aiplatform.v1.MatchService",
1014
+ "rpcName": "GetLocation",
1015
+ "httpResponse": http_response,
1016
+ "metadata": http_response["headers"],
1017
+ },
1018
+ )
1019
+ return resp
1020
+
1021
+ @property
1022
+ def list_locations(self):
1023
+ return self._ListLocations(self._session, self._host, self._interceptor) # type: ignore
1024
+
1025
+ class _ListLocations(
1026
+ _BaseMatchServiceRestTransport._BaseListLocations, MatchServiceRestStub
1027
+ ):
1028
+ def __hash__(self):
1029
+ return hash("MatchServiceRestTransport.ListLocations")
1030
+
1031
+ @staticmethod
1032
+ def _get_response(
1033
+ host,
1034
+ metadata,
1035
+ query_params,
1036
+ session,
1037
+ timeout,
1038
+ transcoded_request,
1039
+ body=None,
1040
+ ):
1041
+
1042
+ uri = transcoded_request["uri"]
1043
+ method = transcoded_request["method"]
1044
+ headers = dict(metadata)
1045
+ headers["Content-Type"] = "application/json"
1046
+ response = getattr(session, method)(
1047
+ "{host}{uri}".format(host=host, uri=uri),
1048
+ timeout=timeout,
1049
+ headers=headers,
1050
+ params=rest_helpers.flatten_query_params(query_params, strict=True),
1051
+ )
1052
+ return response
1053
+
1054
+ def __call__(
1055
+ self,
1056
+ request: locations_pb2.ListLocationsRequest,
1057
+ *,
1058
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
1059
+ timeout: Optional[float] = None,
1060
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
1061
+ ) -> locations_pb2.ListLocationsResponse:
1062
+ r"""Call the list locations method over HTTP.
1063
+
1064
+ Args:
1065
+ request (locations_pb2.ListLocationsRequest):
1066
+ The request object for ListLocations method.
1067
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
1068
+ should be retried.
1069
+ timeout (float): The timeout for this request.
1070
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1071
+ sent along with the request as metadata. Normally, each value must be of type `str`,
1072
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
1073
+ be of type `bytes`.
1074
+
1075
+ Returns:
1076
+ locations_pb2.ListLocationsResponse: Response from ListLocations method.
1077
+ """
1078
+
1079
+ http_options = (
1080
+ _BaseMatchServiceRestTransport._BaseListLocations._get_http_options()
1081
+ )
1082
+
1083
+ request, metadata = self._interceptor.pre_list_locations(request, metadata)
1084
+ transcoded_request = _BaseMatchServiceRestTransport._BaseListLocations._get_transcoded_request(
1085
+ http_options, request
1086
+ )
1087
+
1088
+ # Jsonify the query params
1089
+ query_params = _BaseMatchServiceRestTransport._BaseListLocations._get_query_params_json(
1090
+ transcoded_request
1091
+ )
1092
+
1093
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
1094
+ logging.DEBUG
1095
+ ): # pragma: NO COVER
1096
+ request_url = "{host}{uri}".format(
1097
+ host=self._host, uri=transcoded_request["uri"]
1098
+ )
1099
+ method = transcoded_request["method"]
1100
+ try:
1101
+ request_payload = json_format.MessageToJson(request)
1102
+ except:
1103
+ request_payload = None
1104
+ http_request = {
1105
+ "payload": request_payload,
1106
+ "requestMethod": method,
1107
+ "requestUrl": request_url,
1108
+ "headers": dict(metadata),
1109
+ }
1110
+ _LOGGER.debug(
1111
+ f"Sending request for google.cloud.aiplatform_v1.MatchServiceClient.ListLocations",
1112
+ extra={
1113
+ "serviceName": "google.cloud.aiplatform.v1.MatchService",
1114
+ "rpcName": "ListLocations",
1115
+ "httpRequest": http_request,
1116
+ "metadata": http_request["headers"],
1117
+ },
1118
+ )
1119
+
1120
+ # Send the request
1121
+ response = MatchServiceRestTransport._ListLocations._get_response(
1122
+ self._host,
1123
+ metadata,
1124
+ query_params,
1125
+ self._session,
1126
+ timeout,
1127
+ transcoded_request,
1128
+ )
1129
+
1130
+ # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
1131
+ # subclass.
1132
+ if response.status_code >= 400:
1133
+ raise core_exceptions.from_http_response(response)
1134
+
1135
+ content = response.content.decode("utf-8")
1136
+ resp = locations_pb2.ListLocationsResponse()
1137
+ resp = json_format.Parse(content, resp)
1138
+ resp = self._interceptor.post_list_locations(resp)
1139
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
1140
+ logging.DEBUG
1141
+ ): # pragma: NO COVER
1142
+ try:
1143
+ response_payload = json_format.MessageToJson(resp)
1144
+ except:
1145
+ response_payload = None
1146
+ http_response = {
1147
+ "payload": response_payload,
1148
+ "headers": dict(response.headers),
1149
+ "status": response.status_code,
1150
+ }
1151
+ _LOGGER.debug(
1152
+ "Received response for google.cloud.aiplatform_v1.MatchServiceAsyncClient.ListLocations",
1153
+ extra={
1154
+ "serviceName": "google.cloud.aiplatform.v1.MatchService",
1155
+ "rpcName": "ListLocations",
1156
+ "httpResponse": http_response,
1157
+ "metadata": http_response["headers"],
1158
+ },
1159
+ )
1160
+ return resp
1161
+
1162
+ @property
1163
+ def get_iam_policy(self):
1164
+ return self._GetIamPolicy(self._session, self._host, self._interceptor) # type: ignore
1165
+
1166
+ class _GetIamPolicy(
1167
+ _BaseMatchServiceRestTransport._BaseGetIamPolicy, MatchServiceRestStub
1168
+ ):
1169
+ def __hash__(self):
1170
+ return hash("MatchServiceRestTransport.GetIamPolicy")
1171
+
1172
+ @staticmethod
1173
+ def _get_response(
1174
+ host,
1175
+ metadata,
1176
+ query_params,
1177
+ session,
1178
+ timeout,
1179
+ transcoded_request,
1180
+ body=None,
1181
+ ):
1182
+
1183
+ uri = transcoded_request["uri"]
1184
+ method = transcoded_request["method"]
1185
+ headers = dict(metadata)
1186
+ headers["Content-Type"] = "application/json"
1187
+ response = getattr(session, method)(
1188
+ "{host}{uri}".format(host=host, uri=uri),
1189
+ timeout=timeout,
1190
+ headers=headers,
1191
+ params=rest_helpers.flatten_query_params(query_params, strict=True),
1192
+ )
1193
+ return response
1194
+
1195
+ def __call__(
1196
+ self,
1197
+ request: iam_policy_pb2.GetIamPolicyRequest,
1198
+ *,
1199
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
1200
+ timeout: Optional[float] = None,
1201
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
1202
+ ) -> policy_pb2.Policy:
1203
+ r"""Call the get iam policy method over HTTP.
1204
+
1205
+ Args:
1206
+ request (iam_policy_pb2.GetIamPolicyRequest):
1207
+ The request object for GetIamPolicy method.
1208
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
1209
+ should be retried.
1210
+ timeout (float): The timeout for this request.
1211
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1212
+ sent along with the request as metadata. Normally, each value must be of type `str`,
1213
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
1214
+ be of type `bytes`.
1215
+
1216
+ Returns:
1217
+ policy_pb2.Policy: Response from GetIamPolicy method.
1218
+ """
1219
+
1220
+ http_options = (
1221
+ _BaseMatchServiceRestTransport._BaseGetIamPolicy._get_http_options()
1222
+ )
1223
+
1224
+ request, metadata = self._interceptor.pre_get_iam_policy(request, metadata)
1225
+ transcoded_request = _BaseMatchServiceRestTransport._BaseGetIamPolicy._get_transcoded_request(
1226
+ http_options, request
1227
+ )
1228
+
1229
+ # Jsonify the query params
1230
+ query_params = (
1231
+ _BaseMatchServiceRestTransport._BaseGetIamPolicy._get_query_params_json(
1232
+ transcoded_request
1233
+ )
1234
+ )
1235
+
1236
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
1237
+ logging.DEBUG
1238
+ ): # pragma: NO COVER
1239
+ request_url = "{host}{uri}".format(
1240
+ host=self._host, uri=transcoded_request["uri"]
1241
+ )
1242
+ method = transcoded_request["method"]
1243
+ try:
1244
+ request_payload = json_format.MessageToJson(request)
1245
+ except:
1246
+ request_payload = None
1247
+ http_request = {
1248
+ "payload": request_payload,
1249
+ "requestMethod": method,
1250
+ "requestUrl": request_url,
1251
+ "headers": dict(metadata),
1252
+ }
1253
+ _LOGGER.debug(
1254
+ f"Sending request for google.cloud.aiplatform_v1.MatchServiceClient.GetIamPolicy",
1255
+ extra={
1256
+ "serviceName": "google.cloud.aiplatform.v1.MatchService",
1257
+ "rpcName": "GetIamPolicy",
1258
+ "httpRequest": http_request,
1259
+ "metadata": http_request["headers"],
1260
+ },
1261
+ )
1262
+
1263
+ # Send the request
1264
+ response = MatchServiceRestTransport._GetIamPolicy._get_response(
1265
+ self._host,
1266
+ metadata,
1267
+ query_params,
1268
+ self._session,
1269
+ timeout,
1270
+ transcoded_request,
1271
+ )
1272
+
1273
+ # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
1274
+ # subclass.
1275
+ if response.status_code >= 400:
1276
+ raise core_exceptions.from_http_response(response)
1277
+
1278
+ content = response.content.decode("utf-8")
1279
+ resp = policy_pb2.Policy()
1280
+ resp = json_format.Parse(content, resp)
1281
+ resp = self._interceptor.post_get_iam_policy(resp)
1282
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
1283
+ logging.DEBUG
1284
+ ): # pragma: NO COVER
1285
+ try:
1286
+ response_payload = json_format.MessageToJson(resp)
1287
+ except:
1288
+ response_payload = None
1289
+ http_response = {
1290
+ "payload": response_payload,
1291
+ "headers": dict(response.headers),
1292
+ "status": response.status_code,
1293
+ }
1294
+ _LOGGER.debug(
1295
+ "Received response for google.cloud.aiplatform_v1.MatchServiceAsyncClient.GetIamPolicy",
1296
+ extra={
1297
+ "serviceName": "google.cloud.aiplatform.v1.MatchService",
1298
+ "rpcName": "GetIamPolicy",
1299
+ "httpResponse": http_response,
1300
+ "metadata": http_response["headers"],
1301
+ },
1302
+ )
1303
+ return resp
1304
+
1305
+ @property
1306
+ def set_iam_policy(self):
1307
+ return self._SetIamPolicy(self._session, self._host, self._interceptor) # type: ignore
1308
+
1309
+ class _SetIamPolicy(
1310
+ _BaseMatchServiceRestTransport._BaseSetIamPolicy, MatchServiceRestStub
1311
+ ):
1312
+ def __hash__(self):
1313
+ return hash("MatchServiceRestTransport.SetIamPolicy")
1314
+
1315
+ @staticmethod
1316
+ def _get_response(
1317
+ host,
1318
+ metadata,
1319
+ query_params,
1320
+ session,
1321
+ timeout,
1322
+ transcoded_request,
1323
+ body=None,
1324
+ ):
1325
+
1326
+ uri = transcoded_request["uri"]
1327
+ method = transcoded_request["method"]
1328
+ headers = dict(metadata)
1329
+ headers["Content-Type"] = "application/json"
1330
+ response = getattr(session, method)(
1331
+ "{host}{uri}".format(host=host, uri=uri),
1332
+ timeout=timeout,
1333
+ headers=headers,
1334
+ params=rest_helpers.flatten_query_params(query_params, strict=True),
1335
+ data=body,
1336
+ )
1337
+ return response
1338
+
1339
+ def __call__(
1340
+ self,
1341
+ request: iam_policy_pb2.SetIamPolicyRequest,
1342
+ *,
1343
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
1344
+ timeout: Optional[float] = None,
1345
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
1346
+ ) -> policy_pb2.Policy:
1347
+ r"""Call the set iam policy method over HTTP.
1348
+
1349
+ Args:
1350
+ request (iam_policy_pb2.SetIamPolicyRequest):
1351
+ The request object for SetIamPolicy method.
1352
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
1353
+ should be retried.
1354
+ timeout (float): The timeout for this request.
1355
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1356
+ sent along with the request as metadata. Normally, each value must be of type `str`,
1357
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
1358
+ be of type `bytes`.
1359
+
1360
+ Returns:
1361
+ policy_pb2.Policy: Response from SetIamPolicy method.
1362
+ """
1363
+
1364
+ http_options = (
1365
+ _BaseMatchServiceRestTransport._BaseSetIamPolicy._get_http_options()
1366
+ )
1367
+
1368
+ request, metadata = self._interceptor.pre_set_iam_policy(request, metadata)
1369
+ transcoded_request = _BaseMatchServiceRestTransport._BaseSetIamPolicy._get_transcoded_request(
1370
+ http_options, request
1371
+ )
1372
+
1373
+ body = (
1374
+ _BaseMatchServiceRestTransport._BaseSetIamPolicy._get_request_body_json(
1375
+ transcoded_request
1376
+ )
1377
+ )
1378
+
1379
+ # Jsonify the query params
1380
+ query_params = (
1381
+ _BaseMatchServiceRestTransport._BaseSetIamPolicy._get_query_params_json(
1382
+ transcoded_request
1383
+ )
1384
+ )
1385
+
1386
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
1387
+ logging.DEBUG
1388
+ ): # pragma: NO COVER
1389
+ request_url = "{host}{uri}".format(
1390
+ host=self._host, uri=transcoded_request["uri"]
1391
+ )
1392
+ method = transcoded_request["method"]
1393
+ try:
1394
+ request_payload = json_format.MessageToJson(request)
1395
+ except:
1396
+ request_payload = None
1397
+ http_request = {
1398
+ "payload": request_payload,
1399
+ "requestMethod": method,
1400
+ "requestUrl": request_url,
1401
+ "headers": dict(metadata),
1402
+ }
1403
+ _LOGGER.debug(
1404
+ f"Sending request for google.cloud.aiplatform_v1.MatchServiceClient.SetIamPolicy",
1405
+ extra={
1406
+ "serviceName": "google.cloud.aiplatform.v1.MatchService",
1407
+ "rpcName": "SetIamPolicy",
1408
+ "httpRequest": http_request,
1409
+ "metadata": http_request["headers"],
1410
+ },
1411
+ )
1412
+
1413
+ # Send the request
1414
+ response = MatchServiceRestTransport._SetIamPolicy._get_response(
1415
+ self._host,
1416
+ metadata,
1417
+ query_params,
1418
+ self._session,
1419
+ timeout,
1420
+ transcoded_request,
1421
+ body,
1422
+ )
1423
+
1424
+ # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
1425
+ # subclass.
1426
+ if response.status_code >= 400:
1427
+ raise core_exceptions.from_http_response(response)
1428
+
1429
+ content = response.content.decode("utf-8")
1430
+ resp = policy_pb2.Policy()
1431
+ resp = json_format.Parse(content, resp)
1432
+ resp = self._interceptor.post_set_iam_policy(resp)
1433
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
1434
+ logging.DEBUG
1435
+ ): # pragma: NO COVER
1436
+ try:
1437
+ response_payload = json_format.MessageToJson(resp)
1438
+ except:
1439
+ response_payload = None
1440
+ http_response = {
1441
+ "payload": response_payload,
1442
+ "headers": dict(response.headers),
1443
+ "status": response.status_code,
1444
+ }
1445
+ _LOGGER.debug(
1446
+ "Received response for google.cloud.aiplatform_v1.MatchServiceAsyncClient.SetIamPolicy",
1447
+ extra={
1448
+ "serviceName": "google.cloud.aiplatform.v1.MatchService",
1449
+ "rpcName": "SetIamPolicy",
1450
+ "httpResponse": http_response,
1451
+ "metadata": http_response["headers"],
1452
+ },
1453
+ )
1454
+ return resp
1455
+
1456
+ @property
1457
+ def test_iam_permissions(self):
1458
+ return self._TestIamPermissions(self._session, self._host, self._interceptor) # type: ignore
1459
+
1460
+ class _TestIamPermissions(
1461
+ _BaseMatchServiceRestTransport._BaseTestIamPermissions, MatchServiceRestStub
1462
+ ):
1463
+ def __hash__(self):
1464
+ return hash("MatchServiceRestTransport.TestIamPermissions")
1465
+
1466
+ @staticmethod
1467
+ def _get_response(
1468
+ host,
1469
+ metadata,
1470
+ query_params,
1471
+ session,
1472
+ timeout,
1473
+ transcoded_request,
1474
+ body=None,
1475
+ ):
1476
+
1477
+ uri = transcoded_request["uri"]
1478
+ method = transcoded_request["method"]
1479
+ headers = dict(metadata)
1480
+ headers["Content-Type"] = "application/json"
1481
+ response = getattr(session, method)(
1482
+ "{host}{uri}".format(host=host, uri=uri),
1483
+ timeout=timeout,
1484
+ headers=headers,
1485
+ params=rest_helpers.flatten_query_params(query_params, strict=True),
1486
+ )
1487
+ return response
1488
+
1489
+ def __call__(
1490
+ self,
1491
+ request: iam_policy_pb2.TestIamPermissionsRequest,
1492
+ *,
1493
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
1494
+ timeout: Optional[float] = None,
1495
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
1496
+ ) -> iam_policy_pb2.TestIamPermissionsResponse:
1497
+ r"""Call the test iam permissions method over HTTP.
1498
+
1499
+ Args:
1500
+ request (iam_policy_pb2.TestIamPermissionsRequest):
1501
+ The request object for TestIamPermissions method.
1502
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
1503
+ should be retried.
1504
+ timeout (float): The timeout for this request.
1505
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1506
+ sent along with the request as metadata. Normally, each value must be of type `str`,
1507
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
1508
+ be of type `bytes`.
1509
+
1510
+ Returns:
1511
+ iam_policy_pb2.TestIamPermissionsResponse: Response from TestIamPermissions method.
1512
+ """
1513
+
1514
+ http_options = (
1515
+ _BaseMatchServiceRestTransport._BaseTestIamPermissions._get_http_options()
1516
+ )
1517
+
1518
+ request, metadata = self._interceptor.pre_test_iam_permissions(
1519
+ request, metadata
1520
+ )
1521
+ transcoded_request = _BaseMatchServiceRestTransport._BaseTestIamPermissions._get_transcoded_request(
1522
+ http_options, request
1523
+ )
1524
+
1525
+ # Jsonify the query params
1526
+ query_params = _BaseMatchServiceRestTransport._BaseTestIamPermissions._get_query_params_json(
1527
+ transcoded_request
1528
+ )
1529
+
1530
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
1531
+ logging.DEBUG
1532
+ ): # pragma: NO COVER
1533
+ request_url = "{host}{uri}".format(
1534
+ host=self._host, uri=transcoded_request["uri"]
1535
+ )
1536
+ method = transcoded_request["method"]
1537
+ try:
1538
+ request_payload = json_format.MessageToJson(request)
1539
+ except:
1540
+ request_payload = None
1541
+ http_request = {
1542
+ "payload": request_payload,
1543
+ "requestMethod": method,
1544
+ "requestUrl": request_url,
1545
+ "headers": dict(metadata),
1546
+ }
1547
+ _LOGGER.debug(
1548
+ f"Sending request for google.cloud.aiplatform_v1.MatchServiceClient.TestIamPermissions",
1549
+ extra={
1550
+ "serviceName": "google.cloud.aiplatform.v1.MatchService",
1551
+ "rpcName": "TestIamPermissions",
1552
+ "httpRequest": http_request,
1553
+ "metadata": http_request["headers"],
1554
+ },
1555
+ )
1556
+
1557
+ # Send the request
1558
+ response = MatchServiceRestTransport._TestIamPermissions._get_response(
1559
+ self._host,
1560
+ metadata,
1561
+ query_params,
1562
+ self._session,
1563
+ timeout,
1564
+ transcoded_request,
1565
+ )
1566
+
1567
+ # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
1568
+ # subclass.
1569
+ if response.status_code >= 400:
1570
+ raise core_exceptions.from_http_response(response)
1571
+
1572
+ content = response.content.decode("utf-8")
1573
+ resp = iam_policy_pb2.TestIamPermissionsResponse()
1574
+ resp = json_format.Parse(content, resp)
1575
+ resp = self._interceptor.post_test_iam_permissions(resp)
1576
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
1577
+ logging.DEBUG
1578
+ ): # pragma: NO COVER
1579
+ try:
1580
+ response_payload = json_format.MessageToJson(resp)
1581
+ except:
1582
+ response_payload = None
1583
+ http_response = {
1584
+ "payload": response_payload,
1585
+ "headers": dict(response.headers),
1586
+ "status": response.status_code,
1587
+ }
1588
+ _LOGGER.debug(
1589
+ "Received response for google.cloud.aiplatform_v1.MatchServiceAsyncClient.TestIamPermissions",
1590
+ extra={
1591
+ "serviceName": "google.cloud.aiplatform.v1.MatchService",
1592
+ "rpcName": "TestIamPermissions",
1593
+ "httpResponse": http_response,
1594
+ "metadata": http_response["headers"],
1595
+ },
1596
+ )
1597
+ return resp
1598
+
1599
+ @property
1600
+ def cancel_operation(self):
1601
+ return self._CancelOperation(self._session, self._host, self._interceptor) # type: ignore
1602
+
1603
+ class _CancelOperation(
1604
+ _BaseMatchServiceRestTransport._BaseCancelOperation, MatchServiceRestStub
1605
+ ):
1606
+ def __hash__(self):
1607
+ return hash("MatchServiceRestTransport.CancelOperation")
1608
+
1609
+ @staticmethod
1610
+ def _get_response(
1611
+ host,
1612
+ metadata,
1613
+ query_params,
1614
+ session,
1615
+ timeout,
1616
+ transcoded_request,
1617
+ body=None,
1618
+ ):
1619
+
1620
+ uri = transcoded_request["uri"]
1621
+ method = transcoded_request["method"]
1622
+ headers = dict(metadata)
1623
+ headers["Content-Type"] = "application/json"
1624
+ response = getattr(session, method)(
1625
+ "{host}{uri}".format(host=host, uri=uri),
1626
+ timeout=timeout,
1627
+ headers=headers,
1628
+ params=rest_helpers.flatten_query_params(query_params, strict=True),
1629
+ )
1630
+ return response
1631
+
1632
+ def __call__(
1633
+ self,
1634
+ request: operations_pb2.CancelOperationRequest,
1635
+ *,
1636
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
1637
+ timeout: Optional[float] = None,
1638
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
1639
+ ) -> None:
1640
+ r"""Call the cancel operation method over HTTP.
1641
+
1642
+ Args:
1643
+ request (operations_pb2.CancelOperationRequest):
1644
+ The request object for CancelOperation method.
1645
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
1646
+ should be retried.
1647
+ timeout (float): The timeout for this request.
1648
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1649
+ sent along with the request as metadata. Normally, each value must be of type `str`,
1650
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
1651
+ be of type `bytes`.
1652
+ """
1653
+
1654
+ http_options = (
1655
+ _BaseMatchServiceRestTransport._BaseCancelOperation._get_http_options()
1656
+ )
1657
+
1658
+ request, metadata = self._interceptor.pre_cancel_operation(
1659
+ request, metadata
1660
+ )
1661
+ transcoded_request = _BaseMatchServiceRestTransport._BaseCancelOperation._get_transcoded_request(
1662
+ http_options, request
1663
+ )
1664
+
1665
+ # Jsonify the query params
1666
+ query_params = _BaseMatchServiceRestTransport._BaseCancelOperation._get_query_params_json(
1667
+ transcoded_request
1668
+ )
1669
+
1670
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
1671
+ logging.DEBUG
1672
+ ): # pragma: NO COVER
1673
+ request_url = "{host}{uri}".format(
1674
+ host=self._host, uri=transcoded_request["uri"]
1675
+ )
1676
+ method = transcoded_request["method"]
1677
+ try:
1678
+ request_payload = json_format.MessageToJson(request)
1679
+ except:
1680
+ request_payload = None
1681
+ http_request = {
1682
+ "payload": request_payload,
1683
+ "requestMethod": method,
1684
+ "requestUrl": request_url,
1685
+ "headers": dict(metadata),
1686
+ }
1687
+ _LOGGER.debug(
1688
+ f"Sending request for google.cloud.aiplatform_v1.MatchServiceClient.CancelOperation",
1689
+ extra={
1690
+ "serviceName": "google.cloud.aiplatform.v1.MatchService",
1691
+ "rpcName": "CancelOperation",
1692
+ "httpRequest": http_request,
1693
+ "metadata": http_request["headers"],
1694
+ },
1695
+ )
1696
+
1697
+ # Send the request
1698
+ response = MatchServiceRestTransport._CancelOperation._get_response(
1699
+ self._host,
1700
+ metadata,
1701
+ query_params,
1702
+ self._session,
1703
+ timeout,
1704
+ transcoded_request,
1705
+ )
1706
+
1707
+ # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
1708
+ # subclass.
1709
+ if response.status_code >= 400:
1710
+ raise core_exceptions.from_http_response(response)
1711
+
1712
+ return self._interceptor.post_cancel_operation(None)
1713
+
1714
+ @property
1715
+ def delete_operation(self):
1716
+ return self._DeleteOperation(self._session, self._host, self._interceptor) # type: ignore
1717
+
1718
+ class _DeleteOperation(
1719
+ _BaseMatchServiceRestTransport._BaseDeleteOperation, MatchServiceRestStub
1720
+ ):
1721
+ def __hash__(self):
1722
+ return hash("MatchServiceRestTransport.DeleteOperation")
1723
+
1724
+ @staticmethod
1725
+ def _get_response(
1726
+ host,
1727
+ metadata,
1728
+ query_params,
1729
+ session,
1730
+ timeout,
1731
+ transcoded_request,
1732
+ body=None,
1733
+ ):
1734
+
1735
+ uri = transcoded_request["uri"]
1736
+ method = transcoded_request["method"]
1737
+ headers = dict(metadata)
1738
+ headers["Content-Type"] = "application/json"
1739
+ response = getattr(session, method)(
1740
+ "{host}{uri}".format(host=host, uri=uri),
1741
+ timeout=timeout,
1742
+ headers=headers,
1743
+ params=rest_helpers.flatten_query_params(query_params, strict=True),
1744
+ )
1745
+ return response
1746
+
1747
+ def __call__(
1748
+ self,
1749
+ request: operations_pb2.DeleteOperationRequest,
1750
+ *,
1751
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
1752
+ timeout: Optional[float] = None,
1753
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
1754
+ ) -> None:
1755
+ r"""Call the delete operation method over HTTP.
1756
+
1757
+ Args:
1758
+ request (operations_pb2.DeleteOperationRequest):
1759
+ The request object for DeleteOperation method.
1760
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
1761
+ should be retried.
1762
+ timeout (float): The timeout for this request.
1763
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1764
+ sent along with the request as metadata. Normally, each value must be of type `str`,
1765
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
1766
+ be of type `bytes`.
1767
+ """
1768
+
1769
+ http_options = (
1770
+ _BaseMatchServiceRestTransport._BaseDeleteOperation._get_http_options()
1771
+ )
1772
+
1773
+ request, metadata = self._interceptor.pre_delete_operation(
1774
+ request, metadata
1775
+ )
1776
+ transcoded_request = _BaseMatchServiceRestTransport._BaseDeleteOperation._get_transcoded_request(
1777
+ http_options, request
1778
+ )
1779
+
1780
+ # Jsonify the query params
1781
+ query_params = _BaseMatchServiceRestTransport._BaseDeleteOperation._get_query_params_json(
1782
+ transcoded_request
1783
+ )
1784
+
1785
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
1786
+ logging.DEBUG
1787
+ ): # pragma: NO COVER
1788
+ request_url = "{host}{uri}".format(
1789
+ host=self._host, uri=transcoded_request["uri"]
1790
+ )
1791
+ method = transcoded_request["method"]
1792
+ try:
1793
+ request_payload = json_format.MessageToJson(request)
1794
+ except:
1795
+ request_payload = None
1796
+ http_request = {
1797
+ "payload": request_payload,
1798
+ "requestMethod": method,
1799
+ "requestUrl": request_url,
1800
+ "headers": dict(metadata),
1801
+ }
1802
+ _LOGGER.debug(
1803
+ f"Sending request for google.cloud.aiplatform_v1.MatchServiceClient.DeleteOperation",
1804
+ extra={
1805
+ "serviceName": "google.cloud.aiplatform.v1.MatchService",
1806
+ "rpcName": "DeleteOperation",
1807
+ "httpRequest": http_request,
1808
+ "metadata": http_request["headers"],
1809
+ },
1810
+ )
1811
+
1812
+ # Send the request
1813
+ response = MatchServiceRestTransport._DeleteOperation._get_response(
1814
+ self._host,
1815
+ metadata,
1816
+ query_params,
1817
+ self._session,
1818
+ timeout,
1819
+ transcoded_request,
1820
+ )
1821
+
1822
+ # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
1823
+ # subclass.
1824
+ if response.status_code >= 400:
1825
+ raise core_exceptions.from_http_response(response)
1826
+
1827
+ return self._interceptor.post_delete_operation(None)
1828
+
1829
+ @property
1830
+ def get_operation(self):
1831
+ return self._GetOperation(self._session, self._host, self._interceptor) # type: ignore
1832
+
1833
+ class _GetOperation(
1834
+ _BaseMatchServiceRestTransport._BaseGetOperation, MatchServiceRestStub
1835
+ ):
1836
+ def __hash__(self):
1837
+ return hash("MatchServiceRestTransport.GetOperation")
1838
+
1839
+ @staticmethod
1840
+ def _get_response(
1841
+ host,
1842
+ metadata,
1843
+ query_params,
1844
+ session,
1845
+ timeout,
1846
+ transcoded_request,
1847
+ body=None,
1848
+ ):
1849
+
1850
+ uri = transcoded_request["uri"]
1851
+ method = transcoded_request["method"]
1852
+ headers = dict(metadata)
1853
+ headers["Content-Type"] = "application/json"
1854
+ response = getattr(session, method)(
1855
+ "{host}{uri}".format(host=host, uri=uri),
1856
+ timeout=timeout,
1857
+ headers=headers,
1858
+ params=rest_helpers.flatten_query_params(query_params, strict=True),
1859
+ )
1860
+ return response
1861
+
1862
+ def __call__(
1863
+ self,
1864
+ request: operations_pb2.GetOperationRequest,
1865
+ *,
1866
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
1867
+ timeout: Optional[float] = None,
1868
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
1869
+ ) -> operations_pb2.Operation:
1870
+ r"""Call the get operation method over HTTP.
1871
+
1872
+ Args:
1873
+ request (operations_pb2.GetOperationRequest):
1874
+ The request object for GetOperation method.
1875
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
1876
+ should be retried.
1877
+ timeout (float): The timeout for this request.
1878
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1879
+ sent along with the request as metadata. Normally, each value must be of type `str`,
1880
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
1881
+ be of type `bytes`.
1882
+
1883
+ Returns:
1884
+ operations_pb2.Operation: Response from GetOperation method.
1885
+ """
1886
+
1887
+ http_options = (
1888
+ _BaseMatchServiceRestTransport._BaseGetOperation._get_http_options()
1889
+ )
1890
+
1891
+ request, metadata = self._interceptor.pre_get_operation(request, metadata)
1892
+ transcoded_request = _BaseMatchServiceRestTransport._BaseGetOperation._get_transcoded_request(
1893
+ http_options, request
1894
+ )
1895
+
1896
+ # Jsonify the query params
1897
+ query_params = (
1898
+ _BaseMatchServiceRestTransport._BaseGetOperation._get_query_params_json(
1899
+ transcoded_request
1900
+ )
1901
+ )
1902
+
1903
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
1904
+ logging.DEBUG
1905
+ ): # pragma: NO COVER
1906
+ request_url = "{host}{uri}".format(
1907
+ host=self._host, uri=transcoded_request["uri"]
1908
+ )
1909
+ method = transcoded_request["method"]
1910
+ try:
1911
+ request_payload = json_format.MessageToJson(request)
1912
+ except:
1913
+ request_payload = None
1914
+ http_request = {
1915
+ "payload": request_payload,
1916
+ "requestMethod": method,
1917
+ "requestUrl": request_url,
1918
+ "headers": dict(metadata),
1919
+ }
1920
+ _LOGGER.debug(
1921
+ f"Sending request for google.cloud.aiplatform_v1.MatchServiceClient.GetOperation",
1922
+ extra={
1923
+ "serviceName": "google.cloud.aiplatform.v1.MatchService",
1924
+ "rpcName": "GetOperation",
1925
+ "httpRequest": http_request,
1926
+ "metadata": http_request["headers"],
1927
+ },
1928
+ )
1929
+
1930
+ # Send the request
1931
+ response = MatchServiceRestTransport._GetOperation._get_response(
1932
+ self._host,
1933
+ metadata,
1934
+ query_params,
1935
+ self._session,
1936
+ timeout,
1937
+ transcoded_request,
1938
+ )
1939
+
1940
+ # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
1941
+ # subclass.
1942
+ if response.status_code >= 400:
1943
+ raise core_exceptions.from_http_response(response)
1944
+
1945
+ content = response.content.decode("utf-8")
1946
+ resp = operations_pb2.Operation()
1947
+ resp = json_format.Parse(content, resp)
1948
+ resp = self._interceptor.post_get_operation(resp)
1949
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
1950
+ logging.DEBUG
1951
+ ): # pragma: NO COVER
1952
+ try:
1953
+ response_payload = json_format.MessageToJson(resp)
1954
+ except:
1955
+ response_payload = None
1956
+ http_response = {
1957
+ "payload": response_payload,
1958
+ "headers": dict(response.headers),
1959
+ "status": response.status_code,
1960
+ }
1961
+ _LOGGER.debug(
1962
+ "Received response for google.cloud.aiplatform_v1.MatchServiceAsyncClient.GetOperation",
1963
+ extra={
1964
+ "serviceName": "google.cloud.aiplatform.v1.MatchService",
1965
+ "rpcName": "GetOperation",
1966
+ "httpResponse": http_response,
1967
+ "metadata": http_response["headers"],
1968
+ },
1969
+ )
1970
+ return resp
1971
+
1972
+ @property
1973
+ def list_operations(self):
1974
+ return self._ListOperations(self._session, self._host, self._interceptor) # type: ignore
1975
+
1976
+ class _ListOperations(
1977
+ _BaseMatchServiceRestTransport._BaseListOperations, MatchServiceRestStub
1978
+ ):
1979
+ def __hash__(self):
1980
+ return hash("MatchServiceRestTransport.ListOperations")
1981
+
1982
+ @staticmethod
1983
+ def _get_response(
1984
+ host,
1985
+ metadata,
1986
+ query_params,
1987
+ session,
1988
+ timeout,
1989
+ transcoded_request,
1990
+ body=None,
1991
+ ):
1992
+
1993
+ uri = transcoded_request["uri"]
1994
+ method = transcoded_request["method"]
1995
+ headers = dict(metadata)
1996
+ headers["Content-Type"] = "application/json"
1997
+ response = getattr(session, method)(
1998
+ "{host}{uri}".format(host=host, uri=uri),
1999
+ timeout=timeout,
2000
+ headers=headers,
2001
+ params=rest_helpers.flatten_query_params(query_params, strict=True),
2002
+ )
2003
+ return response
2004
+
2005
+ def __call__(
2006
+ self,
2007
+ request: operations_pb2.ListOperationsRequest,
2008
+ *,
2009
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
2010
+ timeout: Optional[float] = None,
2011
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
2012
+ ) -> operations_pb2.ListOperationsResponse:
2013
+ r"""Call the list operations method over HTTP.
2014
+
2015
+ Args:
2016
+ request (operations_pb2.ListOperationsRequest):
2017
+ The request object for ListOperations method.
2018
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
2019
+ should be retried.
2020
+ timeout (float): The timeout for this request.
2021
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
2022
+ sent along with the request as metadata. Normally, each value must be of type `str`,
2023
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
2024
+ be of type `bytes`.
2025
+
2026
+ Returns:
2027
+ operations_pb2.ListOperationsResponse: Response from ListOperations method.
2028
+ """
2029
+
2030
+ http_options = (
2031
+ _BaseMatchServiceRestTransport._BaseListOperations._get_http_options()
2032
+ )
2033
+
2034
+ request, metadata = self._interceptor.pre_list_operations(request, metadata)
2035
+ transcoded_request = _BaseMatchServiceRestTransport._BaseListOperations._get_transcoded_request(
2036
+ http_options, request
2037
+ )
2038
+
2039
+ # Jsonify the query params
2040
+ query_params = _BaseMatchServiceRestTransport._BaseListOperations._get_query_params_json(
2041
+ transcoded_request
2042
+ )
2043
+
2044
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
2045
+ logging.DEBUG
2046
+ ): # pragma: NO COVER
2047
+ request_url = "{host}{uri}".format(
2048
+ host=self._host, uri=transcoded_request["uri"]
2049
+ )
2050
+ method = transcoded_request["method"]
2051
+ try:
2052
+ request_payload = json_format.MessageToJson(request)
2053
+ except:
2054
+ request_payload = None
2055
+ http_request = {
2056
+ "payload": request_payload,
2057
+ "requestMethod": method,
2058
+ "requestUrl": request_url,
2059
+ "headers": dict(metadata),
2060
+ }
2061
+ _LOGGER.debug(
2062
+ f"Sending request for google.cloud.aiplatform_v1.MatchServiceClient.ListOperations",
2063
+ extra={
2064
+ "serviceName": "google.cloud.aiplatform.v1.MatchService",
2065
+ "rpcName": "ListOperations",
2066
+ "httpRequest": http_request,
2067
+ "metadata": http_request["headers"],
2068
+ },
2069
+ )
2070
+
2071
+ # Send the request
2072
+ response = MatchServiceRestTransport._ListOperations._get_response(
2073
+ self._host,
2074
+ metadata,
2075
+ query_params,
2076
+ self._session,
2077
+ timeout,
2078
+ transcoded_request,
2079
+ )
2080
+
2081
+ # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
2082
+ # subclass.
2083
+ if response.status_code >= 400:
2084
+ raise core_exceptions.from_http_response(response)
2085
+
2086
+ content = response.content.decode("utf-8")
2087
+ resp = operations_pb2.ListOperationsResponse()
2088
+ resp = json_format.Parse(content, resp)
2089
+ resp = self._interceptor.post_list_operations(resp)
2090
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
2091
+ logging.DEBUG
2092
+ ): # pragma: NO COVER
2093
+ try:
2094
+ response_payload = json_format.MessageToJson(resp)
2095
+ except:
2096
+ response_payload = None
2097
+ http_response = {
2098
+ "payload": response_payload,
2099
+ "headers": dict(response.headers),
2100
+ "status": response.status_code,
2101
+ }
2102
+ _LOGGER.debug(
2103
+ "Received response for google.cloud.aiplatform_v1.MatchServiceAsyncClient.ListOperations",
2104
+ extra={
2105
+ "serviceName": "google.cloud.aiplatform.v1.MatchService",
2106
+ "rpcName": "ListOperations",
2107
+ "httpResponse": http_response,
2108
+ "metadata": http_response["headers"],
2109
+ },
2110
+ )
2111
+ return resp
2112
+
2113
+ @property
2114
+ def wait_operation(self):
2115
+ return self._WaitOperation(self._session, self._host, self._interceptor) # type: ignore
2116
+
2117
+ class _WaitOperation(
2118
+ _BaseMatchServiceRestTransport._BaseWaitOperation, MatchServiceRestStub
2119
+ ):
2120
+ def __hash__(self):
2121
+ return hash("MatchServiceRestTransport.WaitOperation")
2122
+
2123
+ @staticmethod
2124
+ def _get_response(
2125
+ host,
2126
+ metadata,
2127
+ query_params,
2128
+ session,
2129
+ timeout,
2130
+ transcoded_request,
2131
+ body=None,
2132
+ ):
2133
+
2134
+ uri = transcoded_request["uri"]
2135
+ method = transcoded_request["method"]
2136
+ headers = dict(metadata)
2137
+ headers["Content-Type"] = "application/json"
2138
+ response = getattr(session, method)(
2139
+ "{host}{uri}".format(host=host, uri=uri),
2140
+ timeout=timeout,
2141
+ headers=headers,
2142
+ params=rest_helpers.flatten_query_params(query_params, strict=True),
2143
+ )
2144
+ return response
2145
+
2146
+ def __call__(
2147
+ self,
2148
+ request: operations_pb2.WaitOperationRequest,
2149
+ *,
2150
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
2151
+ timeout: Optional[float] = None,
2152
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
2153
+ ) -> operations_pb2.Operation:
2154
+ r"""Call the wait operation method over HTTP.
2155
+
2156
+ Args:
2157
+ request (operations_pb2.WaitOperationRequest):
2158
+ The request object for WaitOperation method.
2159
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
2160
+ should be retried.
2161
+ timeout (float): The timeout for this request.
2162
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
2163
+ sent along with the request as metadata. Normally, each value must be of type `str`,
2164
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
2165
+ be of type `bytes`.
2166
+
2167
+ Returns:
2168
+ operations_pb2.Operation: Response from WaitOperation method.
2169
+ """
2170
+
2171
+ http_options = (
2172
+ _BaseMatchServiceRestTransport._BaseWaitOperation._get_http_options()
2173
+ )
2174
+
2175
+ request, metadata = self._interceptor.pre_wait_operation(request, metadata)
2176
+ transcoded_request = _BaseMatchServiceRestTransport._BaseWaitOperation._get_transcoded_request(
2177
+ http_options, request
2178
+ )
2179
+
2180
+ # Jsonify the query params
2181
+ query_params = _BaseMatchServiceRestTransport._BaseWaitOperation._get_query_params_json(
2182
+ transcoded_request
2183
+ )
2184
+
2185
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
2186
+ logging.DEBUG
2187
+ ): # pragma: NO COVER
2188
+ request_url = "{host}{uri}".format(
2189
+ host=self._host, uri=transcoded_request["uri"]
2190
+ )
2191
+ method = transcoded_request["method"]
2192
+ try:
2193
+ request_payload = json_format.MessageToJson(request)
2194
+ except:
2195
+ request_payload = None
2196
+ http_request = {
2197
+ "payload": request_payload,
2198
+ "requestMethod": method,
2199
+ "requestUrl": request_url,
2200
+ "headers": dict(metadata),
2201
+ }
2202
+ _LOGGER.debug(
2203
+ f"Sending request for google.cloud.aiplatform_v1.MatchServiceClient.WaitOperation",
2204
+ extra={
2205
+ "serviceName": "google.cloud.aiplatform.v1.MatchService",
2206
+ "rpcName": "WaitOperation",
2207
+ "httpRequest": http_request,
2208
+ "metadata": http_request["headers"],
2209
+ },
2210
+ )
2211
+
2212
+ # Send the request
2213
+ response = MatchServiceRestTransport._WaitOperation._get_response(
2214
+ self._host,
2215
+ metadata,
2216
+ query_params,
2217
+ self._session,
2218
+ timeout,
2219
+ transcoded_request,
2220
+ )
2221
+
2222
+ # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
2223
+ # subclass.
2224
+ if response.status_code >= 400:
2225
+ raise core_exceptions.from_http_response(response)
2226
+
2227
+ content = response.content.decode("utf-8")
2228
+ resp = operations_pb2.Operation()
2229
+ resp = json_format.Parse(content, resp)
2230
+ resp = self._interceptor.post_wait_operation(resp)
2231
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
2232
+ logging.DEBUG
2233
+ ): # pragma: NO COVER
2234
+ try:
2235
+ response_payload = json_format.MessageToJson(resp)
2236
+ except:
2237
+ response_payload = None
2238
+ http_response = {
2239
+ "payload": response_payload,
2240
+ "headers": dict(response.headers),
2241
+ "status": response.status_code,
2242
+ }
2243
+ _LOGGER.debug(
2244
+ "Received response for google.cloud.aiplatform_v1.MatchServiceAsyncClient.WaitOperation",
2245
+ extra={
2246
+ "serviceName": "google.cloud.aiplatform.v1.MatchService",
2247
+ "rpcName": "WaitOperation",
2248
+ "httpResponse": http_response,
2249
+ "metadata": http_response["headers"],
2250
+ },
2251
+ )
2252
+ return resp
2253
+
2254
+ @property
2255
+ def kind(self) -> str:
2256
+ return "rest"
2257
+
2258
+ def close(self):
2259
+ self._session.close()
2260
+
2261
+
2262
+ __all__ = ("MatchServiceRestTransport",)
loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/match_service/transports/rest_asyncio.py ADDED
The diff for this file is too large to render. See raw diff
 
loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/match_service/transports/rest_base.py ADDED
The diff for this file is too large to render. See raw diff
 
loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/metadata_service/__init__.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright 2025 Google LLC
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+ from .client import MetadataServiceClient
17
+ from .async_client import MetadataServiceAsyncClient
18
+
19
+ __all__ = (
20
+ "MetadataServiceClient",
21
+ "MetadataServiceAsyncClient",
22
+ )
loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/metadata_service/__pycache__/__init__.cpython-312.pyc ADDED
Binary file (382 Bytes). View file
 
loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/metadata_service/__pycache__/async_client.cpython-312.pyc ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:777b64b4e800ffbbd0cc171148fee0b938b2578201a82aa7e9116feb55005848
3
+ size 197695
loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/metadata_service/__pycache__/client.cpython-312.pyc ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d252e9f48336ddfc70c38fb9c59d657c6fd5f6ef3a6bb8999d47088113a4701c
3
+ size 214294
loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/metadata_service/__pycache__/pagers.cpython-312.pyc ADDED
Binary file (43.2 kB). View file
 
loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/metadata_service/async_client.py ADDED
The diff for this file is too large to render. See raw diff
 
loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/metadata_service/client.py ADDED
The diff for this file is too large to render. See raw diff
 
loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/metadata_service/pagers.py ADDED
@@ -0,0 +1,827 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright 2025 Google LLC
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+ from google.api_core import gapic_v1
17
+ from google.api_core import retry as retries
18
+ from google.api_core import retry_async as retries_async
19
+ from typing import (
20
+ Any,
21
+ AsyncIterator,
22
+ Awaitable,
23
+ Callable,
24
+ Sequence,
25
+ Tuple,
26
+ Optional,
27
+ Iterator,
28
+ Union,
29
+ )
30
+
31
+ try:
32
+ OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault, None]
33
+ OptionalAsyncRetry = Union[
34
+ retries_async.AsyncRetry, gapic_v1.method._MethodDefault, None
35
+ ]
36
+ except AttributeError: # pragma: NO COVER
37
+ OptionalRetry = Union[retries.Retry, object, None] # type: ignore
38
+ OptionalAsyncRetry = Union[retries_async.AsyncRetry, object, None] # type: ignore
39
+
40
+ from google.cloud.aiplatform_v1.types import artifact
41
+ from google.cloud.aiplatform_v1.types import context
42
+ from google.cloud.aiplatform_v1.types import execution
43
+ from google.cloud.aiplatform_v1.types import metadata_schema
44
+ from google.cloud.aiplatform_v1.types import metadata_service
45
+ from google.cloud.aiplatform_v1.types import metadata_store
46
+
47
+
48
+ class ListMetadataStoresPager:
49
+ """A pager for iterating through ``list_metadata_stores`` requests.
50
+
51
+ This class thinly wraps an initial
52
+ :class:`google.cloud.aiplatform_v1.types.ListMetadataStoresResponse` object, and
53
+ provides an ``__iter__`` method to iterate through its
54
+ ``metadata_stores`` field.
55
+
56
+ If there are more pages, the ``__iter__`` method will make additional
57
+ ``ListMetadataStores`` requests and continue to iterate
58
+ through the ``metadata_stores`` field on the
59
+ corresponding responses.
60
+
61
+ All the usual :class:`google.cloud.aiplatform_v1.types.ListMetadataStoresResponse`
62
+ attributes are available on the pager. If multiple requests are made, only
63
+ the most recent response is retained, and thus used for attribute lookup.
64
+ """
65
+
66
+ def __init__(
67
+ self,
68
+ method: Callable[..., metadata_service.ListMetadataStoresResponse],
69
+ request: metadata_service.ListMetadataStoresRequest,
70
+ response: metadata_service.ListMetadataStoresResponse,
71
+ *,
72
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
73
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
74
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()
75
+ ):
76
+ """Instantiate the pager.
77
+
78
+ Args:
79
+ method (Callable): The method that was originally called, and
80
+ which instantiated this pager.
81
+ request (google.cloud.aiplatform_v1.types.ListMetadataStoresRequest):
82
+ The initial request object.
83
+ response (google.cloud.aiplatform_v1.types.ListMetadataStoresResponse):
84
+ The initial response object.
85
+ retry (google.api_core.retry.Retry): Designation of what errors,
86
+ if any, should be retried.
87
+ timeout (float): The timeout for this request.
88
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
89
+ sent along with the request as metadata. Normally, each value must be of type `str`,
90
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
91
+ be of type `bytes`.
92
+ """
93
+ self._method = method
94
+ self._request = metadata_service.ListMetadataStoresRequest(request)
95
+ self._response = response
96
+ self._retry = retry
97
+ self._timeout = timeout
98
+ self._metadata = metadata
99
+
100
+ def __getattr__(self, name: str) -> Any:
101
+ return getattr(self._response, name)
102
+
103
+ @property
104
+ def pages(self) -> Iterator[metadata_service.ListMetadataStoresResponse]:
105
+ yield self._response
106
+ while self._response.next_page_token:
107
+ self._request.page_token = self._response.next_page_token
108
+ self._response = self._method(
109
+ self._request,
110
+ retry=self._retry,
111
+ timeout=self._timeout,
112
+ metadata=self._metadata,
113
+ )
114
+ yield self._response
115
+
116
+ def __iter__(self) -> Iterator[metadata_store.MetadataStore]:
117
+ for page in self.pages:
118
+ yield from page.metadata_stores
119
+
120
+ def __repr__(self) -> str:
121
+ return "{0}<{1!r}>".format(self.__class__.__name__, self._response)
122
+
123
+
124
+ class ListMetadataStoresAsyncPager:
125
+ """A pager for iterating through ``list_metadata_stores`` requests.
126
+
127
+ This class thinly wraps an initial
128
+ :class:`google.cloud.aiplatform_v1.types.ListMetadataStoresResponse` object, and
129
+ provides an ``__aiter__`` method to iterate through its
130
+ ``metadata_stores`` field.
131
+
132
+ If there are more pages, the ``__aiter__`` method will make additional
133
+ ``ListMetadataStores`` requests and continue to iterate
134
+ through the ``metadata_stores`` field on the
135
+ corresponding responses.
136
+
137
+ All the usual :class:`google.cloud.aiplatform_v1.types.ListMetadataStoresResponse`
138
+ attributes are available on the pager. If multiple requests are made, only
139
+ the most recent response is retained, and thus used for attribute lookup.
140
+ """
141
+
142
+ def __init__(
143
+ self,
144
+ method: Callable[..., Awaitable[metadata_service.ListMetadataStoresResponse]],
145
+ request: metadata_service.ListMetadataStoresRequest,
146
+ response: metadata_service.ListMetadataStoresResponse,
147
+ *,
148
+ retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT,
149
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
150
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()
151
+ ):
152
+ """Instantiates the pager.
153
+
154
+ Args:
155
+ method (Callable): The method that was originally called, and
156
+ which instantiated this pager.
157
+ request (google.cloud.aiplatform_v1.types.ListMetadataStoresRequest):
158
+ The initial request object.
159
+ response (google.cloud.aiplatform_v1.types.ListMetadataStoresResponse):
160
+ The initial response object.
161
+ retry (google.api_core.retry.AsyncRetry): Designation of what errors,
162
+ if any, should be retried.
163
+ timeout (float): The timeout for this request.
164
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
165
+ sent along with the request as metadata. Normally, each value must be of type `str`,
166
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
167
+ be of type `bytes`.
168
+ """
169
+ self._method = method
170
+ self._request = metadata_service.ListMetadataStoresRequest(request)
171
+ self._response = response
172
+ self._retry = retry
173
+ self._timeout = timeout
174
+ self._metadata = metadata
175
+
176
+ def __getattr__(self, name: str) -> Any:
177
+ return getattr(self._response, name)
178
+
179
+ @property
180
+ async def pages(self) -> AsyncIterator[metadata_service.ListMetadataStoresResponse]:
181
+ yield self._response
182
+ while self._response.next_page_token:
183
+ self._request.page_token = self._response.next_page_token
184
+ self._response = await self._method(
185
+ self._request,
186
+ retry=self._retry,
187
+ timeout=self._timeout,
188
+ metadata=self._metadata,
189
+ )
190
+ yield self._response
191
+
192
+ def __aiter__(self) -> AsyncIterator[metadata_store.MetadataStore]:
193
+ async def async_generator():
194
+ async for page in self.pages:
195
+ for response in page.metadata_stores:
196
+ yield response
197
+
198
+ return async_generator()
199
+
200
+ def __repr__(self) -> str:
201
+ return "{0}<{1!r}>".format(self.__class__.__name__, self._response)
202
+
203
+
204
+ class ListArtifactsPager:
205
+ """A pager for iterating through ``list_artifacts`` requests.
206
+
207
+ This class thinly wraps an initial
208
+ :class:`google.cloud.aiplatform_v1.types.ListArtifactsResponse` object, and
209
+ provides an ``__iter__`` method to iterate through its
210
+ ``artifacts`` field.
211
+
212
+ If there are more pages, the ``__iter__`` method will make additional
213
+ ``ListArtifacts`` requests and continue to iterate
214
+ through the ``artifacts`` field on the
215
+ corresponding responses.
216
+
217
+ All the usual :class:`google.cloud.aiplatform_v1.types.ListArtifactsResponse`
218
+ attributes are available on the pager. If multiple requests are made, only
219
+ the most recent response is retained, and thus used for attribute lookup.
220
+ """
221
+
222
+ def __init__(
223
+ self,
224
+ method: Callable[..., metadata_service.ListArtifactsResponse],
225
+ request: metadata_service.ListArtifactsRequest,
226
+ response: metadata_service.ListArtifactsResponse,
227
+ *,
228
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
229
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
230
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()
231
+ ):
232
+ """Instantiate the pager.
233
+
234
+ Args:
235
+ method (Callable): The method that was originally called, and
236
+ which instantiated this pager.
237
+ request (google.cloud.aiplatform_v1.types.ListArtifactsRequest):
238
+ The initial request object.
239
+ response (google.cloud.aiplatform_v1.types.ListArtifactsResponse):
240
+ The initial response object.
241
+ retry (google.api_core.retry.Retry): Designation of what errors,
242
+ if any, should be retried.
243
+ timeout (float): The timeout for this request.
244
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
245
+ sent along with the request as metadata. Normally, each value must be of type `str`,
246
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
247
+ be of type `bytes`.
248
+ """
249
+ self._method = method
250
+ self._request = metadata_service.ListArtifactsRequest(request)
251
+ self._response = response
252
+ self._retry = retry
253
+ self._timeout = timeout
254
+ self._metadata = metadata
255
+
256
+ def __getattr__(self, name: str) -> Any:
257
+ return getattr(self._response, name)
258
+
259
+ @property
260
+ def pages(self) -> Iterator[metadata_service.ListArtifactsResponse]:
261
+ yield self._response
262
+ while self._response.next_page_token:
263
+ self._request.page_token = self._response.next_page_token
264
+ self._response = self._method(
265
+ self._request,
266
+ retry=self._retry,
267
+ timeout=self._timeout,
268
+ metadata=self._metadata,
269
+ )
270
+ yield self._response
271
+
272
+ def __iter__(self) -> Iterator[artifact.Artifact]:
273
+ for page in self.pages:
274
+ yield from page.artifacts
275
+
276
+ def __repr__(self) -> str:
277
+ return "{0}<{1!r}>".format(self.__class__.__name__, self._response)
278
+
279
+
280
+ class ListArtifactsAsyncPager:
281
+ """A pager for iterating through ``list_artifacts`` requests.
282
+
283
+ This class thinly wraps an initial
284
+ :class:`google.cloud.aiplatform_v1.types.ListArtifactsResponse` object, and
285
+ provides an ``__aiter__`` method to iterate through its
286
+ ``artifacts`` field.
287
+
288
+ If there are more pages, the ``__aiter__`` method will make additional
289
+ ``ListArtifacts`` requests and continue to iterate
290
+ through the ``artifacts`` field on the
291
+ corresponding responses.
292
+
293
+ All the usual :class:`google.cloud.aiplatform_v1.types.ListArtifactsResponse`
294
+ attributes are available on the pager. If multiple requests are made, only
295
+ the most recent response is retained, and thus used for attribute lookup.
296
+ """
297
+
298
+ def __init__(
299
+ self,
300
+ method: Callable[..., Awaitable[metadata_service.ListArtifactsResponse]],
301
+ request: metadata_service.ListArtifactsRequest,
302
+ response: metadata_service.ListArtifactsResponse,
303
+ *,
304
+ retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT,
305
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
306
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()
307
+ ):
308
+ """Instantiates the pager.
309
+
310
+ Args:
311
+ method (Callable): The method that was originally called, and
312
+ which instantiated this pager.
313
+ request (google.cloud.aiplatform_v1.types.ListArtifactsRequest):
314
+ The initial request object.
315
+ response (google.cloud.aiplatform_v1.types.ListArtifactsResponse):
316
+ The initial response object.
317
+ retry (google.api_core.retry.AsyncRetry): Designation of what errors,
318
+ if any, should be retried.
319
+ timeout (float): The timeout for this request.
320
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
321
+ sent along with the request as metadata. Normally, each value must be of type `str`,
322
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
323
+ be of type `bytes`.
324
+ """
325
+ self._method = method
326
+ self._request = metadata_service.ListArtifactsRequest(request)
327
+ self._response = response
328
+ self._retry = retry
329
+ self._timeout = timeout
330
+ self._metadata = metadata
331
+
332
+ def __getattr__(self, name: str) -> Any:
333
+ return getattr(self._response, name)
334
+
335
+ @property
336
+ async def pages(self) -> AsyncIterator[metadata_service.ListArtifactsResponse]:
337
+ yield self._response
338
+ while self._response.next_page_token:
339
+ self._request.page_token = self._response.next_page_token
340
+ self._response = await self._method(
341
+ self._request,
342
+ retry=self._retry,
343
+ timeout=self._timeout,
344
+ metadata=self._metadata,
345
+ )
346
+ yield self._response
347
+
348
+ def __aiter__(self) -> AsyncIterator[artifact.Artifact]:
349
+ async def async_generator():
350
+ async for page in self.pages:
351
+ for response in page.artifacts:
352
+ yield response
353
+
354
+ return async_generator()
355
+
356
+ def __repr__(self) -> str:
357
+ return "{0}<{1!r}>".format(self.__class__.__name__, self._response)
358
+
359
+
360
+ class ListContextsPager:
361
+ """A pager for iterating through ``list_contexts`` requests.
362
+
363
+ This class thinly wraps an initial
364
+ :class:`google.cloud.aiplatform_v1.types.ListContextsResponse` object, and
365
+ provides an ``__iter__`` method to iterate through its
366
+ ``contexts`` field.
367
+
368
+ If there are more pages, the ``__iter__`` method will make additional
369
+ ``ListContexts`` requests and continue to iterate
370
+ through the ``contexts`` field on the
371
+ corresponding responses.
372
+
373
+ All the usual :class:`google.cloud.aiplatform_v1.types.ListContextsResponse`
374
+ attributes are available on the pager. If multiple requests are made, only
375
+ the most recent response is retained, and thus used for attribute lookup.
376
+ """
377
+
378
+ def __init__(
379
+ self,
380
+ method: Callable[..., metadata_service.ListContextsResponse],
381
+ request: metadata_service.ListContextsRequest,
382
+ response: metadata_service.ListContextsResponse,
383
+ *,
384
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
385
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
386
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()
387
+ ):
388
+ """Instantiate the pager.
389
+
390
+ Args:
391
+ method (Callable): The method that was originally called, and
392
+ which instantiated this pager.
393
+ request (google.cloud.aiplatform_v1.types.ListContextsRequest):
394
+ The initial request object.
395
+ response (google.cloud.aiplatform_v1.types.ListContextsResponse):
396
+ The initial response object.
397
+ retry (google.api_core.retry.Retry): Designation of what errors,
398
+ if any, should be retried.
399
+ timeout (float): The timeout for this request.
400
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
401
+ sent along with the request as metadata. Normally, each value must be of type `str`,
402
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
403
+ be of type `bytes`.
404
+ """
405
+ self._method = method
406
+ self._request = metadata_service.ListContextsRequest(request)
407
+ self._response = response
408
+ self._retry = retry
409
+ self._timeout = timeout
410
+ self._metadata = metadata
411
+
412
+ def __getattr__(self, name: str) -> Any:
413
+ return getattr(self._response, name)
414
+
415
+ @property
416
+ def pages(self) -> Iterator[metadata_service.ListContextsResponse]:
417
+ yield self._response
418
+ while self._response.next_page_token:
419
+ self._request.page_token = self._response.next_page_token
420
+ self._response = self._method(
421
+ self._request,
422
+ retry=self._retry,
423
+ timeout=self._timeout,
424
+ metadata=self._metadata,
425
+ )
426
+ yield self._response
427
+
428
+ def __iter__(self) -> Iterator[context.Context]:
429
+ for page in self.pages:
430
+ yield from page.contexts
431
+
432
+ def __repr__(self) -> str:
433
+ return "{0}<{1!r}>".format(self.__class__.__name__, self._response)
434
+
435
+
436
+ class ListContextsAsyncPager:
437
+ """A pager for iterating through ``list_contexts`` requests.
438
+
439
+ This class thinly wraps an initial
440
+ :class:`google.cloud.aiplatform_v1.types.ListContextsResponse` object, and
441
+ provides an ``__aiter__`` method to iterate through its
442
+ ``contexts`` field.
443
+
444
+ If there are more pages, the ``__aiter__`` method will make additional
445
+ ``ListContexts`` requests and continue to iterate
446
+ through the ``contexts`` field on the
447
+ corresponding responses.
448
+
449
+ All the usual :class:`google.cloud.aiplatform_v1.types.ListContextsResponse`
450
+ attributes are available on the pager. If multiple requests are made, only
451
+ the most recent response is retained, and thus used for attribute lookup.
452
+ """
453
+
454
+ def __init__(
455
+ self,
456
+ method: Callable[..., Awaitable[metadata_service.ListContextsResponse]],
457
+ request: metadata_service.ListContextsRequest,
458
+ response: metadata_service.ListContextsResponse,
459
+ *,
460
+ retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT,
461
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
462
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()
463
+ ):
464
+ """Instantiates the pager.
465
+
466
+ Args:
467
+ method (Callable): The method that was originally called, and
468
+ which instantiated this pager.
469
+ request (google.cloud.aiplatform_v1.types.ListContextsRequest):
470
+ The initial request object.
471
+ response (google.cloud.aiplatform_v1.types.ListContextsResponse):
472
+ The initial response object.
473
+ retry (google.api_core.retry.AsyncRetry): Designation of what errors,
474
+ if any, should be retried.
475
+ timeout (float): The timeout for this request.
476
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
477
+ sent along with the request as metadata. Normally, each value must be of type `str`,
478
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
479
+ be of type `bytes`.
480
+ """
481
+ self._method = method
482
+ self._request = metadata_service.ListContextsRequest(request)
483
+ self._response = response
484
+ self._retry = retry
485
+ self._timeout = timeout
486
+ self._metadata = metadata
487
+
488
+ def __getattr__(self, name: str) -> Any:
489
+ return getattr(self._response, name)
490
+
491
+ @property
492
+ async def pages(self) -> AsyncIterator[metadata_service.ListContextsResponse]:
493
+ yield self._response
494
+ while self._response.next_page_token:
495
+ self._request.page_token = self._response.next_page_token
496
+ self._response = await self._method(
497
+ self._request,
498
+ retry=self._retry,
499
+ timeout=self._timeout,
500
+ metadata=self._metadata,
501
+ )
502
+ yield self._response
503
+
504
+ def __aiter__(self) -> AsyncIterator[context.Context]:
505
+ async def async_generator():
506
+ async for page in self.pages:
507
+ for response in page.contexts:
508
+ yield response
509
+
510
+ return async_generator()
511
+
512
+ def __repr__(self) -> str:
513
+ return "{0}<{1!r}>".format(self.__class__.__name__, self._response)
514
+
515
+
516
+ class ListExecutionsPager:
517
+ """A pager for iterating through ``list_executions`` requests.
518
+
519
+ This class thinly wraps an initial
520
+ :class:`google.cloud.aiplatform_v1.types.ListExecutionsResponse` object, and
521
+ provides an ``__iter__`` method to iterate through its
522
+ ``executions`` field.
523
+
524
+ If there are more pages, the ``__iter__`` method will make additional
525
+ ``ListExecutions`` requests and continue to iterate
526
+ through the ``executions`` field on the
527
+ corresponding responses.
528
+
529
+ All the usual :class:`google.cloud.aiplatform_v1.types.ListExecutionsResponse`
530
+ attributes are available on the pager. If multiple requests are made, only
531
+ the most recent response is retained, and thus used for attribute lookup.
532
+ """
533
+
534
+ def __init__(
535
+ self,
536
+ method: Callable[..., metadata_service.ListExecutionsResponse],
537
+ request: metadata_service.ListExecutionsRequest,
538
+ response: metadata_service.ListExecutionsResponse,
539
+ *,
540
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
541
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
542
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()
543
+ ):
544
+ """Instantiate the pager.
545
+
546
+ Args:
547
+ method (Callable): The method that was originally called, and
548
+ which instantiated this pager.
549
+ request (google.cloud.aiplatform_v1.types.ListExecutionsRequest):
550
+ The initial request object.
551
+ response (google.cloud.aiplatform_v1.types.ListExecutionsResponse):
552
+ The initial response object.
553
+ retry (google.api_core.retry.Retry): Designation of what errors,
554
+ if any, should be retried.
555
+ timeout (float): The timeout for this request.
556
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
557
+ sent along with the request as metadata. Normally, each value must be of type `str`,
558
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
559
+ be of type `bytes`.
560
+ """
561
+ self._method = method
562
+ self._request = metadata_service.ListExecutionsRequest(request)
563
+ self._response = response
564
+ self._retry = retry
565
+ self._timeout = timeout
566
+ self._metadata = metadata
567
+
568
+ def __getattr__(self, name: str) -> Any:
569
+ return getattr(self._response, name)
570
+
571
+ @property
572
+ def pages(self) -> Iterator[metadata_service.ListExecutionsResponse]:
573
+ yield self._response
574
+ while self._response.next_page_token:
575
+ self._request.page_token = self._response.next_page_token
576
+ self._response = self._method(
577
+ self._request,
578
+ retry=self._retry,
579
+ timeout=self._timeout,
580
+ metadata=self._metadata,
581
+ )
582
+ yield self._response
583
+
584
+ def __iter__(self) -> Iterator[execution.Execution]:
585
+ for page in self.pages:
586
+ yield from page.executions
587
+
588
+ def __repr__(self) -> str:
589
+ return "{0}<{1!r}>".format(self.__class__.__name__, self._response)
590
+
591
+
592
+ class ListExecutionsAsyncPager:
593
+ """A pager for iterating through ``list_executions`` requests.
594
+
595
+ This class thinly wraps an initial
596
+ :class:`google.cloud.aiplatform_v1.types.ListExecutionsResponse` object, and
597
+ provides an ``__aiter__`` method to iterate through its
598
+ ``executions`` field.
599
+
600
+ If there are more pages, the ``__aiter__`` method will make additional
601
+ ``ListExecutions`` requests and continue to iterate
602
+ through the ``executions`` field on the
603
+ corresponding responses.
604
+
605
+ All the usual :class:`google.cloud.aiplatform_v1.types.ListExecutionsResponse`
606
+ attributes are available on the pager. If multiple requests are made, only
607
+ the most recent response is retained, and thus used for attribute lookup.
608
+ """
609
+
610
+ def __init__(
611
+ self,
612
+ method: Callable[..., Awaitable[metadata_service.ListExecutionsResponse]],
613
+ request: metadata_service.ListExecutionsRequest,
614
+ response: metadata_service.ListExecutionsResponse,
615
+ *,
616
+ retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT,
617
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
618
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()
619
+ ):
620
+ """Instantiates the pager.
621
+
622
+ Args:
623
+ method (Callable): The method that was originally called, and
624
+ which instantiated this pager.
625
+ request (google.cloud.aiplatform_v1.types.ListExecutionsRequest):
626
+ The initial request object.
627
+ response (google.cloud.aiplatform_v1.types.ListExecutionsResponse):
628
+ The initial response object.
629
+ retry (google.api_core.retry.AsyncRetry): Designation of what errors,
630
+ if any, should be retried.
631
+ timeout (float): The timeout for this request.
632
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
633
+ sent along with the request as metadata. Normally, each value must be of type `str`,
634
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
635
+ be of type `bytes`.
636
+ """
637
+ self._method = method
638
+ self._request = metadata_service.ListExecutionsRequest(request)
639
+ self._response = response
640
+ self._retry = retry
641
+ self._timeout = timeout
642
+ self._metadata = metadata
643
+
644
+ def __getattr__(self, name: str) -> Any:
645
+ return getattr(self._response, name)
646
+
647
+ @property
648
+ async def pages(self) -> AsyncIterator[metadata_service.ListExecutionsResponse]:
649
+ yield self._response
650
+ while self._response.next_page_token:
651
+ self._request.page_token = self._response.next_page_token
652
+ self._response = await self._method(
653
+ self._request,
654
+ retry=self._retry,
655
+ timeout=self._timeout,
656
+ metadata=self._metadata,
657
+ )
658
+ yield self._response
659
+
660
+ def __aiter__(self) -> AsyncIterator[execution.Execution]:
661
+ async def async_generator():
662
+ async for page in self.pages:
663
+ for response in page.executions:
664
+ yield response
665
+
666
+ return async_generator()
667
+
668
+ def __repr__(self) -> str:
669
+ return "{0}<{1!r}>".format(self.__class__.__name__, self._response)
670
+
671
+
672
+ class ListMetadataSchemasPager:
673
+ """A pager for iterating through ``list_metadata_schemas`` requests.
674
+
675
+ This class thinly wraps an initial
676
+ :class:`google.cloud.aiplatform_v1.types.ListMetadataSchemasResponse` object, and
677
+ provides an ``__iter__`` method to iterate through its
678
+ ``metadata_schemas`` field.
679
+
680
+ If there are more pages, the ``__iter__`` method will make additional
681
+ ``ListMetadataSchemas`` requests and continue to iterate
682
+ through the ``metadata_schemas`` field on the
683
+ corresponding responses.
684
+
685
+ All the usual :class:`google.cloud.aiplatform_v1.types.ListMetadataSchemasResponse`
686
+ attributes are available on the pager. If multiple requests are made, only
687
+ the most recent response is retained, and thus used for attribute lookup.
688
+ """
689
+
690
+ def __init__(
691
+ self,
692
+ method: Callable[..., metadata_service.ListMetadataSchemasResponse],
693
+ request: metadata_service.ListMetadataSchemasRequest,
694
+ response: metadata_service.ListMetadataSchemasResponse,
695
+ *,
696
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
697
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
698
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()
699
+ ):
700
+ """Instantiate the pager.
701
+
702
+ Args:
703
+ method (Callable): The method that was originally called, and
704
+ which instantiated this pager.
705
+ request (google.cloud.aiplatform_v1.types.ListMetadataSchemasRequest):
706
+ The initial request object.
707
+ response (google.cloud.aiplatform_v1.types.ListMetadataSchemasResponse):
708
+ The initial response object.
709
+ retry (google.api_core.retry.Retry): Designation of what errors,
710
+ if any, should be retried.
711
+ timeout (float): The timeout for this request.
712
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
713
+ sent along with the request as metadata. Normally, each value must be of type `str`,
714
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
715
+ be of type `bytes`.
716
+ """
717
+ self._method = method
718
+ self._request = metadata_service.ListMetadataSchemasRequest(request)
719
+ self._response = response
720
+ self._retry = retry
721
+ self._timeout = timeout
722
+ self._metadata = metadata
723
+
724
+ def __getattr__(self, name: str) -> Any:
725
+ return getattr(self._response, name)
726
+
727
+ @property
728
+ def pages(self) -> Iterator[metadata_service.ListMetadataSchemasResponse]:
729
+ yield self._response
730
+ while self._response.next_page_token:
731
+ self._request.page_token = self._response.next_page_token
732
+ self._response = self._method(
733
+ self._request,
734
+ retry=self._retry,
735
+ timeout=self._timeout,
736
+ metadata=self._metadata,
737
+ )
738
+ yield self._response
739
+
740
+ def __iter__(self) -> Iterator[metadata_schema.MetadataSchema]:
741
+ for page in self.pages:
742
+ yield from page.metadata_schemas
743
+
744
+ def __repr__(self) -> str:
745
+ return "{0}<{1!r}>".format(self.__class__.__name__, self._response)
746
+
747
+
748
+ class ListMetadataSchemasAsyncPager:
749
+ """A pager for iterating through ``list_metadata_schemas`` requests.
750
+
751
+ This class thinly wraps an initial
752
+ :class:`google.cloud.aiplatform_v1.types.ListMetadataSchemasResponse` object, and
753
+ provides an ``__aiter__`` method to iterate through its
754
+ ``metadata_schemas`` field.
755
+
756
+ If there are more pages, the ``__aiter__`` method will make additional
757
+ ``ListMetadataSchemas`` requests and continue to iterate
758
+ through the ``metadata_schemas`` field on the
759
+ corresponding responses.
760
+
761
+ All the usual :class:`google.cloud.aiplatform_v1.types.ListMetadataSchemasResponse`
762
+ attributes are available on the pager. If multiple requests are made, only
763
+ the most recent response is retained, and thus used for attribute lookup.
764
+ """
765
+
766
+ def __init__(
767
+ self,
768
+ method: Callable[..., Awaitable[metadata_service.ListMetadataSchemasResponse]],
769
+ request: metadata_service.ListMetadataSchemasRequest,
770
+ response: metadata_service.ListMetadataSchemasResponse,
771
+ *,
772
+ retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT,
773
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
774
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()
775
+ ):
776
+ """Instantiates the pager.
777
+
778
+ Args:
779
+ method (Callable): The method that was originally called, and
780
+ which instantiated this pager.
781
+ request (google.cloud.aiplatform_v1.types.ListMetadataSchemasRequest):
782
+ The initial request object.
783
+ response (google.cloud.aiplatform_v1.types.ListMetadataSchemasResponse):
784
+ The initial response object.
785
+ retry (google.api_core.retry.AsyncRetry): Designation of what errors,
786
+ if any, should be retried.
787
+ timeout (float): The timeout for this request.
788
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
789
+ sent along with the request as metadata. Normally, each value must be of type `str`,
790
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
791
+ be of type `bytes`.
792
+ """
793
+ self._method = method
794
+ self._request = metadata_service.ListMetadataSchemasRequest(request)
795
+ self._response = response
796
+ self._retry = retry
797
+ self._timeout = timeout
798
+ self._metadata = metadata
799
+
800
+ def __getattr__(self, name: str) -> Any:
801
+ return getattr(self._response, name)
802
+
803
+ @property
804
+ async def pages(
805
+ self,
806
+ ) -> AsyncIterator[metadata_service.ListMetadataSchemasResponse]:
807
+ yield self._response
808
+ while self._response.next_page_token:
809
+ self._request.page_token = self._response.next_page_token
810
+ self._response = await self._method(
811
+ self._request,
812
+ retry=self._retry,
813
+ timeout=self._timeout,
814
+ metadata=self._metadata,
815
+ )
816
+ yield self._response
817
+
818
+ def __aiter__(self) -> AsyncIterator[metadata_schema.MetadataSchema]:
819
+ async def async_generator():
820
+ async for page in self.pages:
821
+ for response in page.metadata_schemas:
822
+ yield response
823
+
824
+ return async_generator()
825
+
826
+ def __repr__(self) -> str:
827
+ return "{0}<{1!r}>".format(self.__class__.__name__, self._response)
loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1/services/metadata_service/transports/__init__.py ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright 2025 Google LLC
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+ from collections import OrderedDict
17
+ from typing import Dict, Type, Tuple
18
+
19
+ from .base import MetadataServiceTransport
20
+ from .grpc import MetadataServiceGrpcTransport
21
+ from .grpc_asyncio import MetadataServiceGrpcAsyncIOTransport
22
+ from .rest import MetadataServiceRestTransport
23
+ from .rest import MetadataServiceRestInterceptor
24
+
25
+ ASYNC_REST_CLASSES: Tuple[str, ...]
26
+ try:
27
+ from .rest_asyncio import AsyncMetadataServiceRestTransport
28
+ from .rest_asyncio import AsyncMetadataServiceRestInterceptor
29
+
30
+ ASYNC_REST_CLASSES = (
31
+ "AsyncMetadataServiceRestTransport",
32
+ "AsyncMetadataServiceRestInterceptor",
33
+ )
34
+ HAS_REST_ASYNC = True
35
+ except ImportError: # pragma: NO COVER
36
+ ASYNC_REST_CLASSES = ()
37
+ HAS_REST_ASYNC = False
38
+
39
+
40
+ # Compile a registry of transports.
41
+ _transport_registry = OrderedDict() # type: Dict[str, Type[MetadataServiceTransport]]
42
+ _transport_registry["grpc"] = MetadataServiceGrpcTransport
43
+ _transport_registry["grpc_asyncio"] = MetadataServiceGrpcAsyncIOTransport
44
+ _transport_registry["rest"] = MetadataServiceRestTransport
45
+ if HAS_REST_ASYNC: # pragma: NO COVER
46
+ _transport_registry["rest_asyncio"] = AsyncMetadataServiceRestTransport
47
+
48
+ __all__ = (
49
+ "MetadataServiceTransport",
50
+ "MetadataServiceGrpcTransport",
51
+ "MetadataServiceGrpcAsyncIOTransport",
52
+ "MetadataServiceRestTransport",
53
+ "MetadataServiceRestInterceptor",
54
+ ) + ASYNC_REST_CLASSES