Deploy/destroy example
[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 'annotation': AnnotationDelta,
8 'machine': MachineDelta,
9 'unit': UnitDelta,
10 'action': ActionDelta,
11 }
12
13 return _delta_types[d.entity](d.deltas)
14
15
16 class EntityDelta(client.Delta):
17 def get_id(self):
18 return self.data['id']
19
20 def get_entity_class(self):
21 return None
22
23
24 class ApplicationDelta(EntityDelta):
25 def get_id(self):
26 return self.data['name']
27
28 def get_entity_class(self):
29 from .application import Application
30 return Application
31
32
33 class AnnotationDelta(EntityDelta):
34 def get_id(self):
35 return self.data['tag']
36
37 def get_entity_class(self):
38 from .annotation import Annotation
39 return Annotation
40
41
42 class MachineDelta(EntityDelta):
43 def get_entity_class(self):
44 from .machine import Machine
45 return Machine
46
47
48 class UnitDelta(EntityDelta):
49 def get_id(self):
50 return self.data['name']
51
52 def get_entity_class(self):
53 from .unit import Unit
54 return Unit
55
56
57 class ActionDelta(EntityDelta):
58 def get_entity_class(self):
59 from .action import Action
60 return Action