Minor cleanups. Added todo list of next work.
[osm/N2VC.git] / juju / delta.py
1 from .client import client
2
3
4 def get_entity_delta(d):
5 _delta_types = {
6 'action': ActionDelta,
7 'application': ApplicationDelta,
8 'annotation': AnnotationDelta,
9 'machine': MachineDelta,
10 'unit': UnitDelta,
11 'relation': RelationDelta,
12 }
13
14 return _delta_types[d.entity](d.deltas)
15
16
17 class EntityDelta(client.Delta):
18 def get_id(self):
19 return self.data['id']
20
21 def get_entity_class(self):
22 return None
23
24
25 class ActionDelta(EntityDelta):
26 def get_entity_class(self):
27 from .action import Action
28 return Action
29
30
31 class ApplicationDelta(EntityDelta):
32 def get_id(self):
33 return self.data['name']
34
35 def get_entity_class(self):
36 from .application import Application
37 return Application
38
39
40 class AnnotationDelta(EntityDelta):
41 def get_id(self):
42 return self.data['tag']
43
44 def get_entity_class(self):
45 from .annotation import Annotation
46 return Annotation
47
48
49 class MachineDelta(EntityDelta):
50 def get_entity_class(self):
51 from .machine import Machine
52 return Machine
53
54
55 class UnitDelta(EntityDelta):
56 def get_id(self):
57 return self.data['name']
58
59 def get_entity_class(self):
60 from .unit import Unit
61 return Unit
62
63
64 class RelationDelta(EntityDelta):
65 def get_entity_class(self):
66 from .relation import Relation
67 return Relation