@@ -358,6 +358,127 @@ def __repr__(self):
358358 dataset_ref = DatasetReference (self .project , self .dataset_id )
359359 return f"TableReference({ dataset_ref !r} , '{ self .table_id } ')"
360360
361+ class PropertyGraphReference :
362+ """PropertyGraphReferences are pointers to property graphs.
363+
364+ Args:
365+ dataset_ref: A pointer to the dataset
366+ property_graph_id: The ID of the property graph
367+ """
368+
369+ _PROPERTY_TO_API_FIELD = {
370+ "dataset_id" : "datasetId" ,
371+ "project" : "projectId" ,
372+ "property_graph_id" : "propertyGraphId" ,
373+ }
374+
375+ def __init__ (self , dataset_ref : "DatasetReference" , property_graph_id : str ):
376+ self ._properties = {}
377+
378+ _helpers ._set_sub_prop (
379+ self ._properties ,
380+ self ._PROPERTY_TO_API_FIELD ["project" ],
381+ dataset_ref .project ,
382+ )
383+ _helpers ._set_sub_prop (
384+ self ._properties ,
385+ self ._PROPERTY_TO_API_FIELD ["dataset_id" ],
386+ dataset_ref .dataset_id ,
387+ )
388+ _helpers ._set_sub_prop (
389+ self ._properties ,
390+ self ._PROPERTY_TO_API_FIELD ["property_graph_id" ],
391+ property_graph_id ,
392+ )
393+
394+ @property
395+ def project (self ) -> str :
396+ """str: Project bound to the property graph."""
397+ return _helpers ._get_sub_prop (
398+ self ._properties , self ._PROPERTY_TO_API_FIELD ["project" ]
399+ )
400+
401+ @property
402+ def dataset_id (self ) -> str :
403+ """str: ID of dataset containing the property graph."""
404+ return _helpers ._get_sub_prop (
405+ self ._properties , self ._PROPERTY_TO_API_FIELD ["dataset_id" ]
406+ )
407+
408+ @property
409+ def property_graph_id (self ) -> str :
410+ """str: The property graph ID."""
411+ return _helpers ._get_sub_prop (
412+ self ._properties , self ._PROPERTY_TO_API_FIELD ["property_graph_id" ]
413+ )
414+
415+ @classmethod
416+ def from_string (
417+ cls , property_graph_id : str , default_project : Optional [str ] = None
418+ ) -> "PropertyGraphReference" :
419+ """Construct a property graph reference from string.
420+
421+ Args:
422+ property_graph_id (str):
423+ A property graph ID in standard SQL format.
424+ default_project (Optional[str]):
425+ The project ID to use when ``property_graph_id`` does not
426+ include a project ID.
427+
428+ Returns:
429+ PropertyGraphReference: Property graph reference parsed from ``property_graph_id``.
430+ """
431+ from google .cloud .bigquery .dataset import DatasetReference
432+
433+ (
434+ output_project_id ,
435+ output_dataset_id ,
436+ output_property_graph_id ,
437+ ) = _helpers ._parse_3_part_id (
438+ property_graph_id , default_project = default_project , property_name = "property_graph_id"
439+ )
440+
441+ return cls (
442+ DatasetReference (output_project_id , output_dataset_id ), output_property_graph_id
443+ )
444+
445+ @classmethod
446+ def from_api_repr (cls , resource : dict ) -> "PropertyGraphReference" :
447+ """Factory: construct a property graph reference given its API representation."""
448+ from google .cloud .bigquery .dataset import DatasetReference
449+
450+ project = resource ["projectId" ]
451+ dataset_id = resource ["datasetId" ]
452+ property_graph_id = resource ["propertyGraphId" ]
453+
454+ return cls (DatasetReference (project , dataset_id ), property_graph_id )
455+
456+ def to_api_repr (self ) -> dict :
457+ """Construct the API resource representation of this property graph reference."""
458+ return copy .deepcopy (self ._properties )
459+
460+ def __str__ (self ):
461+ return f"{ self .project } .{ self .dataset_id } .{ self .property_graph_id } "
462+
463+ def __repr__ (self ):
464+ from google .cloud .bigquery .dataset import DatasetReference
465+
466+ dataset_ref = DatasetReference (self .project , self .dataset_id )
467+ return f"PropertyGraphReference({ dataset_ref !r} , '{ self .property_graph_id } ')"
468+
469+ def __eq__ (self , other ):
470+ if isinstance (other , PropertyGraphReference ):
471+ return (
472+ self .project == other .project
473+ and self .dataset_id == other .dataset_id
474+ and self .property_graph_id == other .property_graph_id
475+ )
476+ else :
477+ return NotImplemented
478+
479+ def __hash__ (self ):
480+ return hash ((self .project , self .dataset_id , self .property_graph_id ))
481+
361482
362483class Table (_TableBase ):
363484 """Tables represent a set of rows whose values correspond to a schema.
0 commit comments