Get everything working on juju-2.0beta11
[osm/N2VC.git] / juju / delta.py
1 from .client import client
2
3
4 def get_entity_delta(d):
5 _delta_types = {
6 'application': ApplicationDelta,
7 'machine': MachineDelta,
8 'unit': UnitDelta,
9 'action': ActionDelta,
10 }
11
12 return _delta_types[d.entity](d.deltas)
13
14
15 class EntityDelta(client.Delta):
16 def get_id(self):
17 return self.data['id']
18
19 def get_entity_class(self):
20 return None
21
22
23 class ApplicationDelta(EntityDelta):
24 def get_id(self):
25 return self.data['name']
26
27 def get_entity_class(self):
28 from .application import Application
29 return Application
30
31
32 class MachineDelta(EntityDelta):
33 def get_entity_class(self):
34 from .machine import Machine
35 return Machine
36
37
38 class UnitDelta(EntityDelta):
39 def get_id(self):
40 return self.data['name']
41
42 def get_entity_class(self):
43 from .unit import Unit
44 return Unit
45
46
47 class ActionDelta(EntityDelta):
48 def get_entity_class(self):
49 from .action import Action
50 return Action