@@ -67,6 +67,7 @@ class Routine(object):
67
67
"type_" : "routineType" ,
68
68
"description" : "description" ,
69
69
"determinism_level" : "determinismLevel" ,
70
+ "remote_function_options" : "remoteFunctionOptions" ,
70
71
}
71
72
72
73
def __init__ (self , routine_ref , ** kwargs ) -> None :
@@ -297,6 +298,37 @@ def determinism_level(self):
297
298
def determinism_level (self , value ):
298
299
self ._properties [self ._PROPERTY_TO_API_FIELD ["determinism_level" ]] = value
299
300
301
+ @property
302
+ def remote_function_options (self ):
303
+ """Optional[google.cloud.bigquery.routine.RemoteFunctionOptions]: Configures remote function
304
+ options for a routine.
305
+
306
+ Raises:
307
+ ValueError:
308
+ If the value is not
309
+ :class:`~google.cloud.bigquery.routine.RemoteFunctionOptions` or
310
+ :data:`None`.
311
+ """
312
+ prop = self ._properties .get (
313
+ self ._PROPERTY_TO_API_FIELD ["remote_function_options" ]
314
+ )
315
+ if prop is not None :
316
+ return RemoteFunctionOptions .from_api_repr (prop )
317
+
318
+ @remote_function_options .setter
319
+ def remote_function_options (self , value ):
320
+ api_repr = value
321
+ if isinstance (value , RemoteFunctionOptions ):
322
+ api_repr = value .to_api_repr ()
323
+ elif value is not None :
324
+ raise ValueError (
325
+ "value must be google.cloud.bigquery.routine.RemoteFunctionOptions "
326
+ "or None"
327
+ )
328
+ self ._properties [
329
+ self ._PROPERTY_TO_API_FIELD ["remote_function_options" ]
330
+ ] = api_repr
331
+
300
332
@classmethod
301
333
def from_api_repr (cls , resource : dict ) -> "Routine" :
302
334
"""Factory: construct a routine given its API representation.
@@ -563,3 +595,124 @@ def __str__(self):
563
595
This is a fully-qualified ID, including the project ID and dataset ID.
564
596
"""
565
597
return "{}.{}.{}" .format (self .project , self .dataset_id , self .routine_id )
598
+
599
+
600
+ class RemoteFunctionOptions (object ):
601
+ """Configuration options for controlling remote BigQuery functions."""
602
+
603
+ _PROPERTY_TO_API_FIELD = {
604
+ "endpoint" : "endpoint" ,
605
+ "connection" : "connection" ,
606
+ "max_batching_rows" : "maxBatchingRows" ,
607
+ "user_defined_context" : "userDefinedContext" ,
608
+ }
609
+
610
+ def __init__ (
611
+ self ,
612
+ endpoint = None ,
613
+ connection = None ,
614
+ max_batching_rows = None ,
615
+ user_defined_context = None ,
616
+ _properties = None ,
617
+ ) -> None :
618
+ if _properties is None :
619
+ _properties = {}
620
+ self ._properties = _properties
621
+
622
+ if endpoint is not None :
623
+ self .endpoint = endpoint
624
+ if connection is not None :
625
+ self .connection = connection
626
+ if max_batching_rows is not None :
627
+ self .max_batching_rows = max_batching_rows
628
+ if user_defined_context is not None :
629
+ self .user_defined_context = user_defined_context
630
+
631
+ @property
632
+ def connection (self ):
633
+ """string: Fully qualified name of the user-provided connection object which holds the authentication information to send requests to the remote service.
634
+
635
+ Format is "projects/{projectId}/locations/{locationId}/connections/{connectionId}"
636
+ """
637
+ return _helpers ._str_or_none (self ._properties .get ("connection" ))
638
+
639
+ @connection .setter
640
+ def connection (self , value ):
641
+ self ._properties ["connection" ] = _helpers ._str_or_none (value )
642
+
643
+ @property
644
+ def endpoint (self ):
645
+ """string: Endpoint of the user-provided remote service
646
+
647
+ Example: "https://us-east1-my_gcf_project.cloudfunctions.net/remote_add"
648
+ """
649
+ return _helpers ._str_or_none (self ._properties .get ("endpoint" ))
650
+
651
+ @endpoint .setter
652
+ def endpoint (self , value ):
653
+ self ._properties ["endpoint" ] = _helpers ._str_or_none (value )
654
+
655
+ @property
656
+ def max_batching_rows (self ):
657
+ """int64: Max number of rows in each batch sent to the remote service.
658
+
659
+ If absent or if 0, BigQuery dynamically decides the number of rows in a batch.
660
+ """
661
+ return _helpers ._int_or_none (self ._properties .get ("maxBatchingRows" ))
662
+
663
+ @max_batching_rows .setter
664
+ def max_batching_rows (self , value ):
665
+ self ._properties ["maxBatchingRows" ] = _helpers ._str_or_none (value )
666
+
667
+ @property
668
+ def user_defined_context (self ):
669
+ """Dict[str, str]: User-defined context as a set of key/value pairs,
670
+ which will be sent as function invocation context together with
671
+ batched arguments in the requests to the remote service. The total
672
+ number of bytes of keys and values must be less than 8KB.
673
+ """
674
+ return self ._properties .get ("userDefinedContext" )
675
+
676
+ @user_defined_context .setter
677
+ def user_defined_context (self , value ):
678
+ if not isinstance (value , dict ):
679
+ raise ValueError ("value must be dictionary" )
680
+ self ._properties ["userDefinedContext" ] = value
681
+
682
+ @classmethod
683
+ def from_api_repr (cls , resource : dict ) -> "RemoteFunctionOptions" :
684
+ """Factory: construct remote function options given its API representation.
685
+
686
+ Args:
687
+ resource (Dict[str, object]): Resource, as returned from the API.
688
+
689
+ Returns:
690
+ google.cloud.bigquery.routine.RemoteFunctionOptions:
691
+ Python object, as parsed from ``resource``.
692
+ """
693
+ ref = cls ()
694
+ ref ._properties = resource
695
+ return ref
696
+
697
+ def to_api_repr (self ) -> dict :
698
+ """Construct the API resource representation of this RemoteFunctionOptions.
699
+
700
+ Returns:
701
+ Dict[str, object]: Remote function options represented as an API resource.
702
+ """
703
+ return self ._properties
704
+
705
+ def __eq__ (self , other ):
706
+ if not isinstance (other , RemoteFunctionOptions ):
707
+ return NotImplemented
708
+ return self ._properties == other ._properties
709
+
710
+ def __ne__ (self , other ):
711
+ return not self == other
712
+
713
+ def __repr__ (self ):
714
+ all_properties = [
715
+ "{}={}" .format (property_name , repr (getattr (self , property_name )))
716
+ for property_name in sorted (self ._PROPERTY_TO_API_FIELD )
717
+ ]
718
+ return "RemoteFunctionOptions({})" .format (", " .join (all_properties ))
0 commit comments