Gets a property of a Resource. id_ : Id of the resource property_name: Name of the property self_deserialize: #Implies use the deserialize method implemented by this resource.
(self, id_, property_name, self_deserialize=True, **kwargs)
| 264 | |
| 265 | @add_auth_token_to_kwargs_from_env |
| 266 | def get_property(self, id_, property_name, self_deserialize=True, **kwargs): |
| 267 | """ |
| 268 | Gets a property of a Resource. |
| 269 | id_ : Id of the resource |
| 270 | property_name: Name of the property |
| 271 | self_deserialize: #Implies use the deserialize method implemented by this resource. |
| 272 | """ |
| 273 | token = kwargs.pop("token", None) |
| 274 | api_key = kwargs.pop("api_key", None) |
| 275 | |
| 276 | if kwargs: |
| 277 | url = "/%s/%s/%s/?%s" % ( |
| 278 | self.resource.get_url_path_name(), |
| 279 | id_, |
| 280 | property_name, |
| 281 | urllib.parse.urlencode(kwargs), |
| 282 | ) |
| 283 | else: |
| 284 | url = "/%s/%s/%s/" % (self.resource.get_url_path_name(), id_, property_name) |
| 285 | |
| 286 | if token: |
| 287 | response = self.client.get(url, token=token) |
| 288 | elif api_key: |
| 289 | response = self.client.get(url, api_key=api_key) |
| 290 | else: |
| 291 | response = self.client.get(url) |
| 292 | |
| 293 | if response.status_code == http_client.NOT_FOUND: |
| 294 | return None |
| 295 | if response.status_code != http_client.OK: |
| 296 | self.handle_error(response) |
| 297 | |
| 298 | if self_deserialize: |
| 299 | return [ |
| 300 | self.resource.deserialize(item) for item in parse_api_response(response) |
| 301 | ] |
| 302 | else: |
| 303 | return parse_api_response(response) |
| 304 | |
| 305 | @add_auth_token_to_kwargs_from_env |
| 306 | def get_by_ref_or_id(self, ref_or_id, **kwargs): |