@@ -279,6 +279,9 @@ def create(
279
279
sync = True ,
280
280
create_request_timeout : Optional [float ] = None ,
281
281
endpoint_id : Optional [str ] = None ,
282
+ enable_request_response_logging = False ,
283
+ request_response_logging_sampling_rate : Optional [float ] = None ,
284
+ request_response_logging_bq_destination_table : Optional [str ] = None ,
282
285
) -> "Endpoint" :
283
286
"""Creates a new endpoint.
284
287
@@ -339,12 +342,18 @@ def create(
339
342
is populated based on a query string argument, such as
340
343
``?endpoint_id=12345``. This is the fallback for fields
341
344
that are not included in either the URI or the body.
345
+ enable_request_response_logging (bool):
346
+ Optional. Whether to enable request & response logging for this endpoint.
347
+ request_response_logging_sampling_rate (float):
348
+ Optional. The request response logging sampling rate. If not set, default is 0.0.
349
+ request_response_logging_bq_destination_table (str):
350
+ Optional. The request response logging bigquery destination. If not set, will create a table with name:
351
+ ``bq://{project_id}.logging_{endpoint_display_name}_{endpoint_id}.request_response_logging``.
342
352
343
353
Returns:
344
354
endpoint (aiplatform.Endpoint):
345
355
Created endpoint.
346
356
"""
347
-
348
357
api_client = cls ._instantiate_client (location = location , credentials = credentials )
349
358
350
359
if not display_name :
@@ -357,6 +366,17 @@ def create(
357
366
project = project or initializer .global_config .project
358
367
location = location or initializer .global_config .location
359
368
369
+ predict_request_response_logging_config = None
370
+ if enable_request_response_logging :
371
+ predict_request_response_logging_config = (
372
+ gca_endpoint_compat .PredictRequestResponseLoggingConfig (
373
+ enabled = True ,
374
+ sampling_rate = request_response_logging_sampling_rate ,
375
+ bigquery_destination = gca_io_compat .BigQueryDestination (
376
+ output_uri = request_response_logging_bq_destination_table
377
+ ),
378
+ )
379
+ )
360
380
return cls ._create (
361
381
api_client = api_client ,
362
382
display_name = display_name ,
@@ -372,6 +392,7 @@ def create(
372
392
sync = sync ,
373
393
create_request_timeout = create_request_timeout ,
374
394
endpoint_id = endpoint_id ,
395
+ predict_request_response_logging_config = predict_request_response_logging_config ,
375
396
)
376
397
377
398
@classmethod
@@ -391,6 +412,9 @@ def _create(
391
412
sync = True ,
392
413
create_request_timeout : Optional [float ] = None ,
393
414
endpoint_id : Optional [str ] = None ,
415
+ predict_request_response_logging_config : Optional [
416
+ gca_endpoint_compat .PredictRequestResponseLoggingConfig
417
+ ] = None ,
394
418
) -> "Endpoint" :
395
419
"""Creates a new endpoint by calling the API client.
396
420
@@ -453,6 +477,8 @@ def _create(
453
477
is populated based on a query string argument, such as
454
478
``?endpoint_id=12345``. This is the fallback for fields
455
479
that are not included in either the URI or the body.
480
+ predict_request_response_logging_config (aiplatform.endpoint.PredictRequestResponseLoggingConfig):
481
+ Optional. The request response logging configuration for online prediction.
456
482
457
483
Returns:
458
484
endpoint (aiplatform.Endpoint):
@@ -469,6 +495,7 @@ def _create(
469
495
labels = labels ,
470
496
encryption_spec = encryption_spec ,
471
497
network = network ,
498
+ predict_request_response_logging_config = predict_request_response_logging_config ,
472
499
)
473
500
474
501
operation_future = api_client .create_endpoint (
0 commit comments