get user/project domains with admin/v1/domains 04/8704/6
authortierno <alfonso.tiernosepulveda@telefonica.com>
Thu, 19 Mar 2020 23:22:08 +0000 (23:22 +0000)
committertierno <alfonso.tiernosepulveda@telefonica.com>
Tue, 31 Mar 2020 21:17:10 +0000 (21:17 +0000)
Change-Id: I64c8920eb76d24c517c8e289382de4fa97931e9c
Signed-off-by: tierno <alfonso.tiernosepulveda@telefonica.com>
osm_nbi/nbi.py
osm_nbi/resources_to_operations.yml

index 2d2d635..bd0f2a1 100644 (file)
@@ -266,7 +266,9 @@ valid_url_methods = {
                                   "ROLE_PERMISSION": "k8srepos:id:"
                                   }
                          },
-
+            "domains": {"METHODS": ("GET", ),
+                        "ROLE_PERMISSION": "domains:",
+                        },
         }
     },
     "pdu": {
@@ -657,6 +659,21 @@ class Server(object):
             }
             return self._format_out(problem_details, None)
 
+    def domain(self):
+        try:
+            domains = {
+                "user_domain_name": cherrypy.tree.apps['/osm'].config["authentication"].get("user_domain_name"),
+                "project_domain_name": cherrypy.tree.apps['/osm'].config["authentication"].get("project_domain_name")}
+            return self._format_out(domains)
+        except NbiException as e:
+            cherrypy.response.status = e.http_code.value
+            problem_details = {
+                "code": e.http_code.name,
+                "status": e.http_code.value,
+                "detail": str(e),
+            }
+            return self._format_out(problem_details, None)
+
     @staticmethod
     def _format_login(token_info):
         """
@@ -975,6 +992,8 @@ class Server(object):
             if main_topic == "admin" and topic == "tokens":
                 return self.token(method, _id, kwargs)
             token_info = self.authenticator.authorize(role_permission, query_string_operations, _id)
+            if main_topic == "admin" and topic == "domains":
+                return self.domain()
             engine_session = self._manage_admin_query(token_info, kwargs, method, _id)
             indata = self._format_in(kwargs)
             engine_topic = topic
index 4f1d8dc..7520420 100644 (file)
@@ -175,6 +175,8 @@ resources_to_operations:
 
   "PATCH /admin/v1/users/<id>": "users:id:patch"
 
+  "GET /admin/v1/domains": "domains:get"
+
 ################################################################################
 #################################### Projects ##################################
 ################################################################################