Update xapp mgr spec to ver 0.1.2 26/126/1
authorLott, Christopher (cl778h) <cl778h@att.com>
Thu, 9 May 2019 11:32:54 +0000 (07:32 -0400)
committerLott, Christopher (cl778h) <cl778h@att.com>
Thu, 9 May 2019 11:32:54 +0000 (07:32 -0400)
Change-Id: Ic381073fdef6da78637cb9ac9eb83af9873a66a3
Issue-Id: RICPLT-1235
Signed-off-by: Lott, Christopher (cl778h) <cl778h@att.com>
docs/release-notes.rst
webapp-backend/pom.xml
webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/config/XappManagerConfiguration.java
webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/config/XappManagerMockConfiguration.java
webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/controller/XappManagerController.java
xapp-mgr-client/pom.xml
xapp-mgr-client/src/main/resources/xapp_manager_rest_api_v0_1_2.yaml [moved from xapp-mgr-client/src/main/resources/xapp_manager_rest_api_v0_1_1.yaml with 95% similarity]
xapp-mgr-client/src/test/java/org/oransc/ric/portal/dashboard/xappmgr/client/test/XappManagerClientTest.java

index f36b11d..0468273 100644 (file)
 RIC Dashboard Release Notes
 ===========================
 
-Version 1.0.1, 6 May 2019
+Version 1.0.1, 9 May 2019
 -------------------------
 * Add draft A1 Mediator API definition
 * Use E2 Manager API definition dated 2 May 2019, with tag modifications
 * Adjust group IDs and packages for name O-RAN-SC; drop ORAN-OSC
 * Add ANR API spec and client code generator
+* Update xApp Manager API spec to version 0.1.2
 
 Version 1.0.0, 30 Apr 2019
 --------------------------
index df8f18c..f4cf887 100644 (file)
@@ -52,7 +52,7 @@ limitations under the License.
                <dependency>
                        <groupId>org.o-ran-sc.ric.xappmgr.client</groupId>
                        <artifactId>xapp-mgr-client</artifactId>
-                       <version>0.1.1-SNAPSHOT</version>
+                       <version>0.1.2-SNAPSHOT</version>
                </dependency>
                <dependency>
                        <groupId>org.springframework.boot</groupId>
index 6a7777f..9416c67 100644 (file)
@@ -21,7 +21,8 @@ package org.oransc.ric.portal.dashboard.config;
 
 import java.lang.invoke.MethodHandles;
 
-import org.oransc.ric.xappmgr.client.api.DefaultApi;
+import org.oransc.ric.xappmgr.client.api.HealthApi;
+import org.oransc.ric.xappmgr.client.api.XappApi;
 import org.oransc.ric.xappmgr.client.invoker.ApiClient;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -54,13 +55,21 @@ public class XappManagerConfiguration {
        }
 
        /**
-        * @return A DefaultApi with an ApiClient configured from properties
+        * @return A HealthApi with an ApiClient configured from properties
         */
        @Bean
-       public DefaultApi xappClient() {
+       public HealthApi xappHealthApi() {
                ApiClient apiClient = new ApiClient(new RestTemplate());
                apiClient.setBasePath(xappMgrBasepath);
-               return new DefaultApi(apiClient);
+               return new HealthApi(apiClient);
+       }
+       /**
+        * @return An XappApi with an ApiClient configured from properties
+        */
+       @Bean
+       public XappApi xappMgrApi() {
+               ApiClient apiClient = new ApiClient(new RestTemplate());
+               apiClient.setBasePath(xappMgrBasepath);
+               return new XappApi(apiClient);
        }
-
 }
index bbc1160..27d713b 100644 (file)
@@ -26,7 +26,8 @@ import static org.mockito.Mockito.when;
 
 import java.lang.invoke.MethodHandles;
 
-import org.oransc.ric.xappmgr.client.api.DefaultApi;
+import org.oransc.ric.xappmgr.client.api.HealthApi;
+import org.oransc.ric.xappmgr.client.api.XappApi;
 import org.oransc.ric.xappmgr.client.invoker.ApiClient;
 import org.oransc.ric.xappmgr.client.model.AllXapps;
 import org.oransc.ric.xappmgr.client.model.SubscriptionRequest;
@@ -72,11 +73,23 @@ public class XappManagerMockConfiguration {
        }
 
        @Bean
-       public DefaultApi xappManagerMockClient() {
+       public HealthApi xappHealthMockApi() {
                ApiClient mockClient = mock(ApiClient.class);
                when(mockClient.getStatusCode()).thenReturn(HttpStatus.OK);
+               HealthApi mockApi = mock(HealthApi.class);
+               when(mockApi.getApiClient()).thenReturn(mockClient);
+               doAnswer(i -> {
+                       return null;
+               }).when(mockApi).getHealth();
+               return mockApi;
+       }
 
-               DefaultApi mockApi = mock(DefaultApi.class);
+       @Bean
+       public XappApi xappMgrMockApi() {
+               ApiClient mockClient = mock(ApiClient.class);
+               when(mockClient.getStatusCode()).thenReturn(HttpStatus.OK);
+
+               XappApi mockApi = mock(XappApi.class);
                when(mockApi.getApiClient()).thenReturn(mockClient);
 
                SubscriptionResponse subRes = new SubscriptionResponse().eventType(SubscriptionResponse.EventTypeEnum.ALL)
@@ -91,9 +104,6 @@ public class XappManagerMockConfiguration {
 
                when(mockApi.getAllXapps()).thenReturn(allXapps);
 
-               doAnswer(i -> {
-                       return null;
-               }).when(mockApi).getHealth();
 
                Xapp xappByName = new Xapp().name("name").status(StatusEnum.UNKNOWN).version("v1");
                when(mockApi.getXappByName(any(String.class))).thenReturn(xappByName);
index 8bcfb46..ef1a918 100644 (file)
@@ -25,7 +25,8 @@ import javax.servlet.http.HttpServletResponse;
 
 import org.oransc.ric.portal.dashboard.DashboardConstants;
 import org.oransc.ric.portal.dashboard.model.ErrorTransport;
-import org.oransc.ric.xappmgr.client.api.DefaultApi;
+import org.oransc.ric.xappmgr.client.api.HealthApi;
+import org.oransc.ric.xappmgr.client.api.XappApi;
 import org.oransc.ric.xappmgr.client.model.AllXapps;
 import org.oransc.ric.xappmgr.client.model.XAppInfo;
 import org.oransc.ric.xappmgr.client.model.Xapp;
@@ -56,37 +57,41 @@ public class XappManagerController {
        private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
 
        // Populated by the autowired constructor
-       private final DefaultApi xappMgrClient;
+       private final HealthApi healthApi;
+       private final XappApi xappApi;
 
        @Autowired
-       public XappManagerController(final DefaultApi xappMgrClient) {
-               Assert.notNull(xappMgrClient, "client must not be null");
+       public XappManagerController(final HealthApi healthApi, final XappApi xappApi) {
+               Assert.notNull(healthApi, "health API must not be null");
+               Assert.notNull(xappApi, "xapp API must not be null");
                if (logger.isDebugEnabled())
-                       logger.debug("ctor: configured with client type {}", xappMgrClient.getClass().getName());
-               this.xappMgrClient = xappMgrClient;
+                       logger.debug("ctor: configured with client types {} and {}", healthApi.getClass().getName(),
+                                       xappApi.getClass().getName());
+               this.healthApi = healthApi;
+               this.xappApi = xappApi;
        }
 
        @ApiOperation(value = "Calls the xApp Manager health check.")
        @RequestMapping(value = "/health", method = RequestMethod.GET)
        public void getHealth(HttpServletResponse response) {
-               logger.debug("getHealth");
-               xappMgrClient.getHealth();
-               response.setStatus(xappMgrClient.getApiClient().getStatusCode().value());
+               logger.debug("getHealt");
+               healthApi.getHealth();
+               response.setStatus(healthApi.getApiClient().getStatusCode().value());
        }
 
        @ApiOperation(value = "Calls the xApp Manager to get the list of xApps.", response = AllXapps.class)
        @RequestMapping(value = "/xapps", method = RequestMethod.GET)
        public AllXapps getAllXapps() {
                if (logger.isDebugEnabled())
-                       logger.debug("getAllXapps via {}", xappMgrClient.getApiClient().getBasePath());
-               return xappMgrClient.getAllXapps();
+                       logger.debug("getAllXapps via {}", xappApi.getApiClient().getBasePath());
+               return xappApi.getAllXapps();
        }
 
        @ApiOperation(value = "Calls the xApp Manager to get the named xApp.", response = Xapp.class)
        @RequestMapping(value = "/xapps/{xAppName}", method = RequestMethod.GET)
        public Xapp getXapp(@PathVariable("xAppName") String xAppName) {
                logger.debug("getXapp {}", xAppName);
-               return xappMgrClient.getXappByName(xAppName);
+               return xappApi.getXappByName(xAppName);
        }
 
        @ApiOperation(value = "Calls the xApp Manager to deploy the specified Xapp.", response = Xapp.class)
@@ -94,7 +99,7 @@ public class XappManagerController {
        public Object deployXapp(@RequestBody XAppInfo xAppInfo, HttpServletResponse response) {
                logger.debug("deployXapp {}", xAppInfo);
                try {
-                       return xappMgrClient.deployXapp(xAppInfo);
+                       return xappApi.deployXapp(xAppInfo);
                } catch (Exception ex) {
                        logger.error("deployXapp failed", ex);
                        response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
@@ -107,7 +112,7 @@ public class XappManagerController {
        public void undeployXapp(@PathVariable("xAppName") String xAppName, HttpServletResponse response) {
                logger.debug("undeployXapp {}", xAppName);
                try {
-                       xappMgrClient.undeployXapp(xAppName);
+                       xappApi.undeployXapp(xAppName);
                } catch (Exception ex) {
                        logger.error("deployXapp failed", ex);
                        response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
index 06afbbe..496510a 100644 (file)
@@ -31,7 +31,7 @@ limitations under the License.
        <groupId>org.o-ran-sc.ric.xappmgr.client</groupId>
        <artifactId>xapp-mgr-client</artifactId>
        <name>RIC xApp Manager client</name>
-       <version>0.1.1-SNAPSHOT</version>
+       <version>0.1.2-SNAPSHOT</version>
        <properties>
                <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
                <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@@ -101,7 +101,7 @@ limitations under the License.
                                                        <goal>generate</goal>
                                                </goals>
                                                <configuration>
-                                                       <inputSpec>${project.basedir}/src/main/resources/xapp_manager_rest_api_v0_1_1.yaml</inputSpec>
+                                                       <inputSpec>${project.basedir}/src/main/resources/xapp_manager_rest_api_v0_1_2.yaml</inputSpec>
                                                        <language>java</language>
                                                        <configOptions>
                                                                <groupId>${project.groupId}</groupId>
@@ -18,7 +18,7 @@
 swagger: '2.0'
 info:
   description: This is a draft API for RIC appmgr
-  version: 0.1.1
+  version: 0.1.2
   title: RIC appmgr
   license:
     name: Apache 2.0
@@ -32,6 +32,8 @@ paths:
   /health:
     get:
       summary: Health check of xApp Manager
+      tags:
+        - health
       operationId: getHealth
       responses:
         '200':
@@ -39,6 +41,8 @@ paths:
   /xapps:
     post:
       summary: Deploy a xapp
+      tags:
+        - xapp
       operationId: deployXapp
       consumes:
         - application/json
@@ -68,6 +72,8 @@ paths:
           description: Internal error
     get:
       summary: Returns the status of all xapps
+      tags:
+        - xapp
       operationId: getAllXapps
       produces:
         - application/json
@@ -81,6 +87,8 @@ paths:
   '/xapps/{xAppName}':
     get:
       summary: Returns the status of a given xapp
+      tags:
+        - xapp
       operationId: getXappByName
       produces:
         - application/json
@@ -103,6 +111,8 @@ paths:
           description: Internal error
     delete:
       summary: Undeploy an existing xapp
+      tags:
+        - xapp
       operationId: undeployXapp
       parameters:
         - name: xAppName
@@ -120,6 +130,8 @@ paths:
   '/xapps/{xAppName}/instances/{xAppInstanceName}':
     get:
       summary: Returns the status of a given xapp
+      tags:
+        - xapp
       operationId: getXappInstanceByName
       produces:
         - application/json
@@ -148,6 +160,8 @@ paths:
   /config:
     post:
       summary: Create xApp config
+      tags:
+        - xapp
       operationId: createXappConfig
       consumes:
         - application/json
@@ -166,10 +180,14 @@ paths:
             $ref: '#/definitions/xAppConfig'
         '400':
           description: Invalid input
+        '422':
+          description: Validation of configuration failed
         '500':
           description: Internal error
     put:
       summary: Modify xApp config
+      tags:
+        - xapp
       operationId: ModifyXappConfig
       consumes:
         - application/json
@@ -188,10 +206,14 @@ paths:
             $ref: '#/definitions/xAppConfig'
         '400':
           description: Invalid input
+        '422':
+          description: Validation of configuration failed
         '500':
           description: Internal error
     get:
       summary: Returns the configuration of all xapps
+      tags:
+        - xapp
       operationId: getAllXappConfig
       produces:
         - application/json
@@ -204,6 +226,8 @@ paths:
           description: Internal error
     delete:
       summary: Delete xApp configuration
+      tags:
+        - xapp
       operationId: deleteXappConfig
       parameters:
         - name: xAppConfigInfo
@@ -221,6 +245,9 @@ paths:
   /subscriptions:
     post:
       summary: Subscribe event
+      tags:
+        - xapp
+        - subscriptions
       operationId: addSubscription
       consumes:
         - application/json
@@ -242,6 +269,9 @@ paths:
           description: Invalid input
     get:
       summary: Returns all subscriptions
+      tags:
+        - xapp
+        - subscriptions
       operationId: getSubscriptions
       produces:
         - application/json
@@ -253,6 +283,9 @@ paths:
   '/subscriptions/{subscriptionId}':
     get:
       summary: Returns the information of subscription
+      tags:
+        - xapp
+        - subscriptions
       operationId: getSubscriptionById
       produces:
         - application/json
@@ -273,6 +306,9 @@ paths:
           description: Subscription not found
     put:
       summary: Modify event subscription
+      tags:
+        - xapp
+        - subscriptions
       operationId: modifySubscription
       consumes:
         - application/json
@@ -299,6 +335,9 @@ paths:
           description: Invalid input
     delete:
       summary: Unsubscribe event
+      tags:
+        - xapp
+        - subscriptions
       description: ''
       operationId: deleteSubscription
       parameters:
index e31244d..82bbd63 100644 (file)
@@ -20,7 +20,8 @@
 package org.oransc.ric.portal.dashboard.xappmgr.client.test;
 
 import org.junit.jupiter.api.Test;
-import org.oransc.ric.xappmgr.client.api.DefaultApi;
+import org.oransc.ric.xappmgr.client.api.HealthApi;
+import org.oransc.ric.xappmgr.client.api.XappApi;
 import org.oransc.ric.xappmgr.client.invoker.ApiClient;
 import org.oransc.ric.xappmgr.client.model.AllXapps;
 import org.oransc.ric.xappmgr.client.model.Xapp;
@@ -30,10 +31,6 @@ import org.springframework.web.client.RestClientException;
  * Demonstrates use of the generated xApp manager client.
  * 
  * The test fails because no server is available.
- * 
- * The ugly name "DefaultApi" is generated because the spec lacks appropriate
- * tags on the operation, also see
- * https://stackoverflow.com/questions/38293236/swagger-swagger-codegen-maven-plugin-generate-default-api-interface
  */
 public class XappManagerClientTest {
 
@@ -41,15 +38,16 @@ public class XappManagerClientTest {
        public void demo() {
                ApiClient apiClient = new ApiClient();
                apiClient.setBasePath("http://localhost:30099/");
-               DefaultApi apiInstance = new DefaultApi(apiClient);
                try {
-                       apiInstance.getHealth();
+                       HealthApi healthApi = new HealthApi(apiClient);
+                       healthApi.getHealth();
                        System.out.println("getHealth answered: " + apiClient.getStatusCode().toString());
                } catch (RestClientException e) {
                        System.err.println("getHealth failed: " + e.toString());
                }
                try {
-                       AllXapps allXapps = apiInstance.getAllXapps();
+                       XappApi xappApi = new XappApi(apiClient);
+                       AllXapps allXapps = xappApi.getAllXapps();
                        System.out.println("getAllXapps answered: " + apiClient.getStatusCode().toString());
                        System.out.println("xApp count: " + allXapps.size());
                        for (Xapp x : allXapps)