def serialize(self): def convert_fn(item): if isinstance(item, BaseResource): return item.to_reference().serialize(), True elif isinstance(item, BaseReference): return item.serialize(), True else: return item, False return convert_values({key: value for key, value in self.items()}, convert_fn)
def __init__(self, client, resource_type, **kwargs): def convert_fn(item): if isinstance(item, AbstractResource): return item, True if self.is_reference(item): return client.reference(**item), True return item, False self.resource_type = resource_type kwargs['resourceType'] = resource_type converted_kwargs = convert_values(kwargs, convert_fn) super(BaseResource, self).__init__(client, **converted_kwargs)