1313# limitations under the License.
1414import warnings
1515from datetime import datetime
16- from typing import Dict , Optional
16+ from typing import Dict , List , Optional
1717
1818from google .protobuf .json_format import MessageToJson
1919
@@ -40,6 +40,9 @@ class Entity:
4040 owner: The owner of the entity, typically the email of the primary maintainer.
4141 created_timestamp: The time when the entity was created.
4242 last_updated_timestamp: The time when the entity was last updated.
43+ join_keys: A list of property that uniquely identifies different entities within the
44+ collection. This is meant to replace the `join_key` parameter, but currently only
45+ supports a list of size one.
4346 """
4447
4548 name : str
@@ -50,6 +53,7 @@ class Entity:
5053 owner : str
5154 created_timestamp : Optional [datetime ]
5255 last_updated_timestamp : Optional [datetime ]
56+ join_keys : List [str ]
5357
5458 @log_exceptions
5559 def __init__ (
@@ -61,6 +65,7 @@ def __init__(
6165 join_key : Optional [str ] = None ,
6266 tags : Optional [Dict [str , str ]] = None ,
6367 owner : str = "" ,
68+ join_keys : Optional [List [str ]] = None ,
6469 ):
6570 """Creates an Entity object."""
6671 if len (args ) == 1 :
@@ -82,7 +87,17 @@ def __init__(
8287 raise ValueError ("Name needs to be specified" )
8388
8489 self .value_type = value_type
85- self .join_key = join_key if join_key else self .name
90+
91+ self .join_keys = join_keys or []
92+ if join_keys and len (join_keys ) > 1 :
93+ raise ValueError (
94+ "An entity may only have single join key. "
95+ "Multiple join keys will be supported in the future."
96+ )
97+ if join_keys and len (join_keys ) == 1 :
98+ self .join_key = join_keys [0 ]
99+ else :
100+ self .join_key = join_key if join_key else self .name
86101 self .description = description
87102 self .tags = tags if tags is not None else {}
88103 self .owner = owner
0 commit comments