|
20 | 20 | importcopy |
21 | 21 |
|
22 | 22 | importgoogle.cloud._helpers |
| 23 | + |
23 | 24 | fromgoogle.cloud.bigqueryimport_helpers |
24 | 25 | fromgoogle.cloud.bigquery.modelimportModelReference |
25 | 26 | fromgoogle.cloud.bigquery.routineimportRoutineReference |
@@ -145,38 +146,60 @@ def __init__(self, role, entity_type, entity_id): |
145 | 146 | "Role must be set for entity ""type %r"% (entity_type,) |
146 | 147 | ) |
147 | 148 |
|
148 | | -self.role=role |
149 | | -self.entity_type=entity_type |
150 | | -self.entity_id=entity_id |
| 149 | +self._role=role |
| 150 | +self._entity_type=entity_type |
| 151 | +self._entity_id=entity_id |
| 152 | + |
| 153 | +@property |
| 154 | +defrole(self): |
| 155 | +"""str: The role of the entry.""" |
| 156 | +returnself._role |
| 157 | + |
| 158 | +@property |
| 159 | +defentity_type(self): |
| 160 | +"""str: The entity_type of the entry.""" |
| 161 | +returnself._entity_type |
| 162 | + |
| 163 | +@property |
| 164 | +defentity_id(self): |
| 165 | +"""str: The entity_id of the entry.""" |
| 166 | +returnself._entity_id |
151 | 167 |
|
152 | 168 | def__eq__(self,other): |
153 | 169 | ifnotisinstance(other,AccessEntry): |
154 | 170 | returnNotImplemented |
155 | | -return ( |
156 | | -self.role==other.role |
157 | | -andself.entity_type==other.entity_type |
158 | | -andself.entity_id==other.entity_id |
159 | | - ) |
| 171 | +returnself._key()==other._key() |
160 | 172 |
|
161 | 173 | def__ne__(self,other): |
162 | 174 | returnnotself==other |
163 | 175 |
|
164 | 176 | def__repr__(self): |
165 | 177 | return"<AccessEntry: role=%s, %s=%s>"% ( |
166 | | -self.role, |
167 | | -self.entity_type, |
168 | | -self.entity_id, |
| 178 | +self._role, |
| 179 | +self._entity_type, |
| 180 | +self._entity_id, |
169 | 181 | ) |
170 | 182 |
|
| 183 | +def_key(self): |
| 184 | +""" A tuple key that uniquely describes this field. |
| 185 | + Used to compute this instance's hashcode and evaluate equality. |
| 186 | + Returns: |
| 187 | + Tuple: The contents of this :class:`~google.cloud.bigquery.dataset.AccessEntry`. |
| 188 | + """ |
| 189 | +return (self._role,self._entity_type,self._entity_id) |
| 190 | + |
| 191 | +def__hash__(self): |
| 192 | +returnhash(self._key()) |
| 193 | + |
171 | 194 | defto_api_repr(self): |
172 | 195 | """Construct the API resource representation of this access entry |
173 | 196 |
|
174 | 197 | Returns: |
175 | 198 | Dict[str, object]: Access entry represented as an API resource |
176 | 199 | """ |
177 | | -resource= {self.entity_type:self.entity_id} |
178 | | -ifself.roleisnotNone: |
179 | | -resource["role"]=self.role |
| 200 | +resource= {self._entity_type:self._entity_id} |
| 201 | +ifself._roleisnotNone: |
| 202 | +resource["role"]=self._role |
180 | 203 | returnresource |
181 | 204 |
|
182 | 205 | @classmethod |
|