Feature/api version support (#109)
[osm/N2VC.git] / juju / client / overrides.py
index 2a6923b..e7e6d34 100644 (file)
@@ -1,14 +1,16 @@
 from collections import namedtuple
 
-from .facade import ReturnMapping, Type
+from .facade import ReturnMapping, Type, TypeEncoder
 from .import _client
 
+
 __all__ = [
     'Delta',
 ]
 
 __patches__ = [
     'ResourcesFacade',
+    'AllWatcherFacade'
 ]
 
 
@@ -80,3 +82,19 @@ class ResourcesFacade(Type):
         _params['resources'] = resources
         reply = await self.rpc(msg)
         return reply
+
+class AllWatcherFacade(Type):
+    """
+    Patch rpc method of allwatcher to add in 'id' stuff.
+
+    """
+    async def rpc(self, msg):
+        if not hasattr(self, 'Id'):
+            client = _client.ClientFacade.from_connection(self.connection)
+
+            result = await client.WatchAll()
+            self.Id = result.watcher_id
+
+        msg['Id'] = self.Id
+        result =  await self.connection.rpc(msg, encoder=TypeEncoder)
+        return result