Skip to content

Commit 6baa50b

Browse files
committed
revert back to the original code
1 parent 6ab2c3c commit 6baa50b

File tree

1 file changed

+4
-39
lines changed

1 file changed

+4
-39
lines changed

google/cloud/bigquery/dataset.py

Lines changed: 4 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -555,20 +555,7 @@ def to_api_repr(self):
555555
Returns:
556556
Dict[str, object]: Access entry represented as an API resource
557557
"""
558-
resource = {}
559-
560-
if self.role is not None:
561-
resource["role"] = self.role
562-
if self.entity_type is not None:
563-
resource[self.entity_type] = self.entity_id
564-
if self.condition is not None:
565-
resource["condition"] = self.condition.to_api_repr()
566-
567-
# Include any extra items preserved in _properties
568-
for k, v in self._properties.items():
569-
if k not in resource:
570-
resource[k] = v
571-
558+
resource = copy.deepcopy(self._properties)
572559
return resource
573560

574561
@classmethod
@@ -583,31 +570,9 @@ def from_api_repr(cls, resource: dict) -> "AccessEntry":
583570
google.cloud.bigquery.dataset.AccessEntry:
584571
Access entry parsed from ``resource``.
585572
"""
586-
role = resource.get("role")
587-
condition = None
588-
if "condition" in resource:
589-
condition = Condition.from_api_repr(resource["condition"])
590-
591-
entity_type = None
592-
entity_id = None
593-
594-
for key, value in resource.items():
595-
if key in ("role","condition"):
596-
continue
597-
entity_type = key
598-
entity_id = value
599-
break
600-
601-
entry = cls(
602-
role=role,
603-
entity_type=entity_type,
604-
entity_id=entity_id,
605-
condition=condition,
606-
)
607-
608-
# Preserve additional _properties for roundtrip consistency:
609-
entry._properties = dict(resource)
610-
return entry
573+
access_entry = cls()
574+
access_entry._properties = resource.copy()
575+
return access_entry
611576

612577

613578
class Dataset(object):

0 commit comments

Comments
 (0)