Allow ID to be optional in certain cases 47/34347/1
authorasteroide <thomas.duval@orange.com>
Wed, 3 May 2017 08:52:19 +0000 (10:52 +0200)
committerasteroide <thomas.duval@orange.com>
Wed, 3 May 2017 08:52:19 +0000 (10:52 +0200)
Change-Id: Ia03bdc5bc79b6a2061b6d5381c9ad3273f388aac

moonv4/moon_manager/moon_manager/api/models.py
moonv4/moon_manager/moon_manager/api/policies.py

index 6cb8143..56695c1 100644 (file)
@@ -18,7 +18,7 @@ class Models(object):
 
     def get_models(self, ctx, args):
         try:
-            data = self.manager.get_models(user_id=ctx["user_id"], model_id=ctx["id"])
+            data = self.manager.get_models(user_id=ctx["user_id"], model_id=ctx.get("id"))
         except Exception as e:
             LOG.error(e, exc_info=True)
             return {"result": False,
@@ -28,7 +28,7 @@ class Models(object):
 
     def add_model(self, ctx, args):
         try:
-            data = self.manager.add_model(user_id=ctx["user_id"], model_id=ctx["id"], value=args)
+            data = self.manager.add_model(user_id=ctx["user_id"], model_id=ctx.get("id"), value=args)
         except Exception as e:
             LOG.error(e, exc_info=True)
             return {"result": False,
index 8b24247..88c762a 100644 (file)
@@ -18,7 +18,7 @@ class Policies(object):
 
     def get_policies(self, ctx, args):
         try:
-            data = self.manager.get_policies(user_id=ctx["user_id"], policy_id=ctx["id"])
+            data = self.manager.get_policies(user_id=ctx["user_id"], policy_id=ctx.get("id"))
         except Exception as e:
             LOG.error(e, exc_info=True)
             return {"result": False,
@@ -28,7 +28,7 @@ class Policies(object):
 
     def add_policy(self, ctx, args):
         try:
-            data = self.manager.add_policy(user_id=ctx["user_id"], policy_id=ctx["id"], value=args)
+            data = self.manager.add_policy(user_id=ctx["user_id"], policy_id=ctx.get("id"), value=args)
         except Exception as e:
             LOG.error(e, exc_info=True)
             return {"result": False,