Source code for juju.delta

from .client import client


[docs]def get_entity_delta(d): return _delta_types[d.entity](d.deltas)
[docs]def get_entity_class(entity_type): return _delta_types[entity_type].get_entity_class()
[docs]class EntityDelta(client.Delta):
[docs] def get_id(self): return self.data['id']
[docs] @classmethod def get_entity_class(self): return None
[docs]class ActionDelta(EntityDelta):
[docs] @classmethod def get_entity_class(self): from .action import Action return Action
[docs]class ApplicationDelta(EntityDelta):
[docs] def get_id(self): return self.data['name']
[docs] @classmethod def get_entity_class(self): from .application import Application return Application
[docs]class AnnotationDelta(EntityDelta):
[docs] def get_id(self): return self.data['tag']
[docs] @classmethod def get_entity_class(self): from .annotation import Annotation return Annotation
[docs]class MachineDelta(EntityDelta):
[docs] @classmethod def get_entity_class(self): from .machine import Machine return Machine
[docs]class UnitDelta(EntityDelta):
[docs] def get_id(self): return self.data['name']
[docs] @classmethod def get_entity_class(self): from .unit import Unit return Unit
[docs]class RelationDelta(EntityDelta):
[docs] @classmethod def get_entity_class(self): from .relation import Relation return Relation
[docs]class RemoteApplicationDelta(EntityDelta):
[docs] def get_id(self): return self.data['name']
[docs] @classmethod def get_entity_class(self): from .remoteapplication import RemoteApplication return RemoteApplication
[docs]class CharmDelta(EntityDelta):
[docs] def get_id(self): return self.data['charm-url']
[docs] @classmethod def get_entity_class(self): from .charm import Charm return Charm
[docs]class ApplicationOfferDelta(EntityDelta):
[docs] def get_id(self): return self.data['application-name']
[docs] @classmethod def get_entity_class(self): from .remoteapplication import ApplicationOffer return ApplicationOffer
_delta_types = { 'action': ActionDelta, 'application': ApplicationDelta, 'annotation': AnnotationDelta, 'machine': MachineDelta, 'unit': UnitDelta, 'relation': RelationDelta, 'remoteApplication': RemoteApplicationDelta, 'charm': CharmDelta, 'applicationOffer': ApplicationOfferDelta, }