Add ConfigurationController 87/114787/3
authorelinuxhenrik <henrik.b.andersson@est.tech>
Wed, 11 Nov 2020 13:11:37 +0000 (14:11 +0100)
committerKAPIL SINGAL <ks220y@att.com>
Tue, 17 Nov 2020 14:23:46 +0000 (14:23 +0000)
Change-Id: I281398dc663c5778ea6a5c34262a5684db4df0d0
Issue-ID: CCSDK-2966
Signed-off-by: elinuxhenrik <henrik.b.andersson@est.tech>
a1-policy-management/pom.xml
a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/configuration/ConfigurationFile.java
a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ConfigurationController.java [new file with mode: 0644]
a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/Consts.java
a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/JsonObject.java [deleted file]
a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RefreshConfigTask.java
a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/configuration/ConfigurationFileTest.java
a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ConfigurationControllerTest.java [new file with mode: 0644]
a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RefreshConfigTaskTest.java
docs/offeredapis/swagger/pms-api.json

index 91f73ad..81a3b5c 100644 (file)
@@ -45,6 +45,7 @@
         <swagger.version>2.0.0</swagger.version>
         <json.version>20190722</json.version>
         <commons-net.version>3.6</commons-net.version>
+        <commons-io.version>2.5</commons-io.version>
         <maven.compile.plugin.version>3.8.0</maven.compile.plugin.version>
         <formatter-maven-plugin.version>2.8.1</formatter-maven-plugin.version>
         <spotless-maven-plugin.version>1.18.0</spotless-maven-plugin.version>
             <artifactId>mockwebserver</artifactId>
             <scope>test</scope>
         </dependency>
+        <dependency>
+            <groupId>commons-io</groupId>
+            <artifactId>commons-io</artifactId>
+            <version>${commons-io.version}</version>
+            <scope>test</scope>
+        </dependency>
     </dependencies>
 
     <build>
index 345722c..26f44bb 100644 (file)
@@ -22,6 +22,7 @@ import com.google.gson.Gson;
 import com.google.gson.JsonElement;
 import com.google.gson.JsonObject;
 import com.google.gson.JsonParser;
+
 import java.io.BufferedInputStream;
 import java.io.File;
 import java.io.FileInputStream;
@@ -30,8 +31,9 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.util.Optional;
+
 import javax.validation.constraints.NotNull;
-import org.onap.ccsdk.oran.a1policymanagementservice.exceptions.ServiceException;
+
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -57,21 +59,19 @@ public class ConfigurationFile {
 
         try (InputStream inputStream = createInputStream(filepath)) {
             JsonObject rootObject = getJsonElement(inputStream).getAsJsonObject();
-            logger.debug("Local configuration file loaded: {}", filepath);
+            logger.debug("Local configuration file read: {}", filepath);
             return Optional.of(rootObject);
         } catch (Exception e) {
-            logger.error("Local configuration file not loaded: {}, {}", filepath, e.getMessage());
+            logger.error("Local configuration file not read: {}, {}", filepath, e.getMessage());
             return Optional.empty();
         }
     }
 
-    public synchronized void writeFile(JsonObject content) throws ServiceException {
+    public synchronized void writeFile(JsonObject content) throws IOException {
         String filepath = appConfig.getLocalConfigurationFilePath();
         try (FileWriter fileWriter = getFileWriter(filepath)) {
             gson.toJson(content, fileWriter);
-        } catch (IOException e) {
-            logger.error("Local configuration file not written: {}, {}", filepath, e.getMessage());
-            throw new ServiceException("Local configuration file not written");
+            logger.debug("Local configuration file written: {}", filepath);
         }
     }
 
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ConfigurationController.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ConfigurationController.java
new file mode 100644 (file)
index 0000000..5497e0a
--- /dev/null
@@ -0,0 +1,75 @@
+/*-
+ * ========================LICENSE_START=================================
+ * Copyright (C) 2020 Nordix Foundation. All rights reserved.
+ * ======================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ========================LICENSE_END===================================
+ */
+
+package org.onap.ccsdk.oran.a1policymanagementservice.controllers.v2;
+
+import com.google.gson.JsonObject;
+import com.google.gson.JsonParser;
+import com.google.gson.JsonSyntaxException;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiResponse;
+import io.swagger.annotations.ApiResponses;
+
+import java.io.IOException;
+
+import org.onap.ccsdk.oran.a1policymanagementservice.configuration.ApplicationConfigParser;
+import org.onap.ccsdk.oran.a1policymanagementservice.configuration.ConfigurationFile;
+import org.onap.ccsdk.oran.a1policymanagementservice.controllers.VoidResponse;
+import org.onap.ccsdk.oran.a1policymanagementservice.controllers.v2.ErrorResponse.ErrorInfo;
+import org.onap.ccsdk.oran.a1policymanagementservice.exceptions.ServiceException;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.MediaType;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController("ConfigurationControllerV2")
+@Api(tags = {Consts.V2_CONFIG_API_NAME})
+public class ConfigurationController {
+
+    @Autowired
+    ConfigurationFile configurationFile;
+
+    @PutMapping(path = Consts.V2_API_ROOT + "/configuration", consumes = MediaType.APPLICATION_JSON_VALUE)
+    @ApiOperation(value = "Replace the current configuration with the given configuration")
+    @ApiResponses(value = { //
+            @ApiResponse(code = 200, message = "Configuration updated", response = VoidResponse.class), //
+            @ApiResponse(code = 400, message = "Invalid configuration provided", response = ErrorInfo.class), //
+            @ApiResponse(code = 500, message = "Something went wrong when replacing the configuration. Try again.",
+                    response = ErrorResponse.ErrorInfo.class) //
+    })
+    public ResponseEntity<Object> putConfiguration(@RequestBody String configuration) {
+        try {
+            JsonObject configJson = JsonParser.parseString(configuration).getAsJsonObject();
+            ApplicationConfigParser configParser = new ApplicationConfigParser();
+            configParser.parse(configJson);
+            configurationFile.writeFile(configJson);
+        } catch (ServiceException | JsonSyntaxException e) {
+            return ErrorResponse.create(String.format("Faulty configuration. %s", e.getMessage()),
+                    HttpStatus.BAD_REQUEST);
+        } catch (IOException ioe) {
+            ErrorResponse.create("Internal error when writing the configuration. Try again.",
+                    HttpStatus.INTERNAL_SERVER_ERROR);
+        }
+        return new ResponseEntity<>(HttpStatus.OK);
+    }
+}
index 478b8c2..e1961c1 100644 (file)
@@ -30,6 +30,7 @@ public class Consts {
 
     public static final String V2_API_ROOT = "/v2";
     public static final String V2_API_NAME = "A1 Policy Management Version 2.0 (in progress)";
+    public static final String V2_CONFIG_API_NAME = "A1 Policy Management Configuration";
 
     private Consts() {}
 }
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/JsonObject.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/JsonObject.java
deleted file mode 100644 (file)
index fea1d09..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-/*-
- * ========================LICENSE_START=================================
- * ONAP : ccsdk oran
- * ======================================================================
- * Copyright (C) 2020 Nordix Foundation. All rights reserved.
- * ======================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ========================LICENSE_END===================================
- */
-
-package org.onap.ccsdk.oran.a1policymanagementservice.controllers.v2;
-
-import io.swagger.annotations.ApiModel;
-
-import org.immutables.gson.Gson;
-
-@Gson.TypeAdapters
-@ApiModel(value = "json_object",
-        description = "A JSON object defining the configuration of the policy. The schema is defined by the Policy Type.")
-class JsonObject {
-}
index 75fd16c..dfb8d49 100644 (file)
@@ -71,9 +71,9 @@ public class RefreshConfigTask {
     public Properties systemEnvironment;
 
     /**
-     * The time between refreshes of the configuration.
+     * The time between refreshes of the configuration. Not final so tests can modify it.
      */
-    static final Duration CONFIG_REFRESH_INTERVAL = Duration.ofMinutes(1);
+    private static Duration configRefreshInterval = Duration.ofMinutes(1);
 
     final ConfigurationFile configurationFile;
     final ApplicationConfig appConfig;
@@ -118,14 +118,14 @@ public class RefreshConfigTask {
     }
 
     Flux<RicConfigUpdate.Type> createRefreshTask() {
-        Flux<JsonObject> loadFromFile = Flux.interval(Duration.ZERO, CONFIG_REFRESH_INTERVAL) //
+        Flux<JsonObject> loadFromFile = Flux.interval(Duration.ZERO, configRefreshInterval) //
                 .filter(notUsed -> !this.isConsulUsed) //
                 .flatMap(notUsed -> loadConfigurationFromFile()) //
                 .onErrorResume(this::ignoreErrorFlux) //
                 .doOnNext(json -> logger.debug("loadFromFile succeeded")) //
                 .doOnTerminate(() -> logger.error("loadFromFile Terminate"));
 
-        Flux<JsonObject> loadFromConsul = Flux.interval(Duration.ZERO, CONFIG_REFRESH_INTERVAL) //
+        Flux<JsonObject> loadFromConsul = Flux.interval(Duration.ZERO, configRefreshInterval) //
                 .flatMap(i -> getEnvironment(systemEnvironment)) //
                 .flatMap(this::createCbsClient) //
                 .flatMap(this::getFromCbs) //
index ad4cbb8..27a7248 100644 (file)
@@ -19,8 +19,8 @@
 package org.onap.ccsdk.oran.a1policymanagementservice.configuration;
 
 import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.ArgumentMatchers.any;
 import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.doThrow;
 import static org.mockito.Mockito.spy;
 import static org.mockito.Mockito.when;
@@ -28,18 +28,20 @@ import static org.mockito.Mockito.when;
 import ch.qos.logback.classic.Level;
 import ch.qos.logback.classic.spi.ILoggingEvent;
 import ch.qos.logback.core.read.ListAppender;
+
 import com.google.gson.JsonObject;
 import com.google.gson.JsonParser;
+
 import java.io.File;
 import java.io.IOException;
 import java.nio.file.Files;
 import java.util.Optional;
+
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.extension.ExtendWith;
 import org.junit.jupiter.api.io.TempDir;
 import org.mockito.Mock;
 import org.mockito.junit.jupiter.MockitoExtension;
-import org.onap.ccsdk.oran.a1policymanagementservice.exceptions.ServiceException;
 import org.onap.ccsdk.oran.a1policymanagementservice.utils.LoggingUtils;
 
 @ExtendWith(MockitoExtension.class)
@@ -51,22 +53,20 @@ class ConfigurationFileTest {
     public File temporaryFolder;
 
     @Test
-    void writeFileWithError_shouldThrowExceptionAndLogError() throws Exception {
+    void writeFileWithError_shouldThrowException() throws Exception {
         File tempJsonFile = new File(temporaryFolder, "config.json");
         String filePath = tempJsonFile.getAbsolutePath();
 
         ConfigurationFile configFileUnderTestSpy = spy(new ConfigurationFile(applicationConfigMock));
 
         when(applicationConfigMock.getLocalConfigurationFilePath()).thenReturn(filePath);
-        doThrow(new IOException("Error")).when(configFileUnderTestSpy).getFileWriter(any(String.class));
+        String errorMessage = "Error";
+        doThrow(new IOException(errorMessage)).when(configFileUnderTestSpy).getFileWriter(any(String.class));
 
-        ListAppender<ILoggingEvent> logAppender = LoggingUtils.getLogListAppender(ConfigurationFile.class, Level.ERROR);
         Exception actualException =
-                assertThrows(ServiceException.class, () -> configFileUnderTestSpy.writeFile(new JsonObject()));
-
-        assertThat(actualException.getMessage()).startsWith("Local configuration file not written");
+                assertThrows(IOException.class, () -> configFileUnderTestSpy.writeFile(new JsonObject()));
 
-        assertThat(logAppender.list.get(0).getFormattedMessage()).startsWith("Local configuration file not written");
+        assertThat(actualException.getMessage()).isEqualTo(errorMessage);
     }
 
     @Test
@@ -115,6 +115,6 @@ class ConfigurationFileTest {
         assertThat(readContent).isEmpty();
 
         assertThat(logAppender.list.get(0).getFormattedMessage())
-                .isEqualTo("Local configuration file not loaded: " + filePath + ", Not a JSON Object: null");
+                .isEqualTo("Local configuration file not read: " + filePath + ", Not a JSON Object: null");
     }
 }
diff --git a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ConfigurationControllerTest.java b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ConfigurationControllerTest.java
new file mode 100644 (file)
index 0000000..8f9d236
--- /dev/null
@@ -0,0 +1,164 @@
+/*-
+ * ========================LICENSE_START=================================
+ * Copyright (C) 2020 Nordix Foundation. All rights reserved.
+ * ======================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ========================LICENSE_END===================================
+ */
+
+package org.onap.ccsdk.oran.a1policymanagementservice.controllers.v2;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.awaitility.Awaitility.await;
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.io.File;
+import java.lang.reflect.Field;
+import java.time.Duration;
+
+import org.apache.commons.io.FileUtils;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.junit.jupiter.api.io.TempDir;
+import org.onap.ccsdk.oran.a1policymanagementservice.clients.AsyncRestClient;
+import org.onap.ccsdk.oran.a1policymanagementservice.clients.AsyncRestClientFactory;
+import org.onap.ccsdk.oran.a1policymanagementservice.configuration.ApplicationConfig;
+import org.onap.ccsdk.oran.a1policymanagementservice.configuration.ImmutableWebClientConfig;
+import org.onap.ccsdk.oran.a1policymanagementservice.configuration.WebClientConfig;
+import org.onap.ccsdk.oran.a1policymanagementservice.repository.Rics;
+import org.onap.ccsdk.oran.a1policymanagementservice.tasks.RefreshConfigTask;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
+import org.springframework.boot.test.context.TestConfiguration;
+import org.springframework.boot.web.server.LocalServerPort;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.annotation.Bean;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.MediaType;
+import org.springframework.test.context.TestPropertySource;
+import org.springframework.test.context.junit.jupiter.SpringExtension;
+import org.springframework.web.reactive.function.client.WebClientResponseException;
+
+import reactor.core.publisher.Mono;
+import reactor.test.StepVerifier;
+
+@ExtendWith(SpringExtension.class)
+@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
+@TestPropertySource(properties = { //
+        "server.ssl.key-store=./config/keystore.jks", //
+        "app.webclient.trust-store=./config/truststore.jks"})
+class ConfigurationControllerTest {
+    @Autowired
+    ApplicationContext context;
+
+    @Autowired
+    ApplicationConfig applicationConfig;
+
+    @Autowired
+    private Rics rics;
+
+    @TempDir
+    public static File temporaryFolder;
+    private static File configFile;
+
+    @BeforeAll
+    private static void setup() throws Exception {
+        Field f1 = RefreshConfigTask.class.getDeclaredField("configRefreshInterval");
+        f1.setAccessible(true);
+        f1.set(null, Duration.ofSeconds(1));
+    }
+
+    public static class MockApplicationConfig extends ApplicationConfig {
+        @Override
+        public String getLocalConfigurationFilePath() {
+            configFile = new File(temporaryFolder, "config.json");
+            return configFile.getAbsolutePath();
+        }
+    }
+
+    /**
+     * Overrides the BeanFactory.
+     */
+    @TestConfiguration
+    static class TestBeanFactory {
+        @Bean
+        public ApplicationConfig getApplicationConfig() {
+            return new MockApplicationConfig();
+        }
+    }
+
+    @LocalServerPort
+    private int port;
+
+    @Test
+    void putValidConfigurationWithNewRic_shouldUpdateRepository() throws Exception {
+        String url = "https://localhost:" + this.port + "/v2/configuration";
+
+        File configFile = new File(getClass().getClassLoader()
+                .getResource("test_application_configuration_with_dmaap_config.json").getFile());
+        String configFileAsString = FileUtils.readFileToString(configFile, "UTF-8");
+
+        String resp = restClient().put(url, configFileAsString).block();
+
+        assertThat(resp).isEmpty();
+        await().until(rics::size, equalTo(2));
+    }
+
+    @Test
+    void putInvalidConfiguration_shouldReturnError400() throws Exception {
+        String url = "https://localhost:" + this.port + "/v2/configuration";
+
+        // Valid JSON but invalid configuration.
+        testErrorCode(restClient().put(url, "{\"error\":\"error\"}"), HttpStatus.BAD_REQUEST, "Faulty configuration");
+
+        // Invalid JSON.
+        testErrorCode(restClient().put(url, "{\"error\":\"error\""), HttpStatus.BAD_REQUEST, "Faulty configuration");
+    }
+
+    private void testErrorCode(Mono<?> request, HttpStatus expStatus, String responseContains) {
+        StepVerifier.create(request) //
+                .expectSubscription() //
+                .expectErrorMatches(t -> checkWebClientError(t, expStatus, responseContains)) //
+                .verify();
+    }
+
+    private boolean checkWebClientError(Throwable throwable, HttpStatus expStatus, String responseContains) {
+        assertTrue(throwable instanceof WebClientResponseException);
+        WebClientResponseException responseException = (WebClientResponseException) throwable;
+        assertThat(responseException.getStatusCode()).isEqualTo(expStatus);
+        assertThat(responseException.getResponseBodyAsString()).contains(responseContains);
+        assertThat(responseException.getHeaders().getContentType()).isEqualTo(MediaType.APPLICATION_PROBLEM_JSON);
+        return true;
+    }
+
+    private AsyncRestClient restClient() {
+        WebClientConfig config = this.applicationConfig.getWebClientConfig();
+        config = ImmutableWebClientConfig.builder() //
+                .keyStoreType(config.keyStoreType()) //
+                .keyStorePassword(config.keyStorePassword()) //
+                .keyStore(config.keyStore()) //
+                .keyPassword(config.keyPassword()) //
+                .isTrustStoreUsed(true) //
+                .trustStore(config.trustStore()) //
+                .trustStorePassword(config.trustStorePassword()) //
+                .httpProxyConfig(config.httpProxyConfig()) //
+                .build();
+
+        AsyncRestClientFactory f = new AsyncRestClientFactory(config);
+        return f.createRestClient("https://localhost:" + port);
+
+    }
+}
index 07a6201..e789de6 100644 (file)
@@ -34,10 +34,12 @@ import static org.mockito.Mockito.when;
 
 import ch.qos.logback.classic.spi.ILoggingEvent;
 import ch.qos.logback.core.read.ListAppender;
+
 import com.google.common.base.Charsets;
 import com.google.common.io.Resources;
 import com.google.gson.JsonObject;
 import com.google.gson.JsonParser;
+
 import java.io.IOException;
 import java.net.URL;
 import java.time.Duration;
@@ -48,6 +50,7 @@ import java.util.HashMap;
 import java.util.Optional;
 import java.util.Properties;
 import java.util.Vector;
+
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.extension.ExtendWith;
 import org.mockito.Mock;
@@ -74,6 +77,7 @@ import org.onap.ccsdk.oran.a1policymanagementservice.utils.LoggingUtils;
 import org.onap.dcaegen2.services.sdk.rest.services.cbs.client.api.CbsClient;
 import org.onap.dcaegen2.services.sdk.rest.services.cbs.client.model.EnvProperties;
 import org.onap.dcaegen2.services.sdk.rest.services.cbs.client.model.ImmutableEnvProperties;
+
 import reactor.core.publisher.Mono;
 import reactor.test.StepVerifier;
 
@@ -155,13 +159,10 @@ class RefreshConfigTaskTest {
     @Test
     void whenFileExistsButJsonIsIncorrect_thenNoRicsArePutInRepository() throws Exception {
         refreshTaskUnderTest = this.createTestObject(CONFIG_FILE_EXISTS);
-        refreshTaskUnderTest.systemEnvironment = new Properties();
 
         // When
         when(configurationFileMock.readFile()).thenReturn(Optional.empty());
 
-        final ListAppender<ILoggingEvent> logAppender = LoggingUtils.getLogListAppender(RefreshConfigTask.class, ERROR);
-
         StepVerifier //
                 .create(refreshTaskUnderTest.createRefreshTask()) //
                 .expectSubscription() //
index 6ece771..f5cc016 100644 (file)
@@ -5,7 +5,7 @@
             "summary": "Query policy type names",
             "deprecated": false,
             "produces": ["*/*"],
-            "operationId": "getPolicyTypesUsingGET",
+            "operationId": "getPolicyTypesUsingGET_1",
             "responses": {
                 "200": {
                     "schema": {
@@ -35,7 +35,7 @@
             "summary": "Returns status and statistics of this service",
             "deprecated": false,
             "produces": ["application/json"],
-            "operationId": "getStatusUsingGET",
+            "operationId": "getStatusUsingGET_1",
             "responses": {
                 "200": {
                     "schema": {"$ref": "#/definitions/status_info_v2"},
@@ -51,7 +51,7 @@
             "summary": "Query policy type identities",
             "deprecated": false,
             "produces": ["application/json"],
-            "operationId": "getPolicyTypesUsingGET_1",
+            "operationId": "getPolicyTypesUsingGET",
             "responses": {
                 "200": {
                     "schema": {"$ref": "#/definitions/policytype_id_list_v2"},
@@ -79,7 +79,7 @@
                 "summary": "Returns service information",
                 "deprecated": false,
                 "produces": ["*/*"],
-                "operationId": "getServicesUsingGET_1",
+                "operationId": "getServicesUsingGET",
                 "responses": {
                     "200": {
                         "schema": {
                 "summary": "Delete a service",
                 "deprecated": false,
                 "produces": ["*/*"],
-                "operationId": "deleteServiceUsingDELETE_1",
+                "operationId": "deleteServiceUsingDELETE",
                 "responses": {
                     "200": {
                         "schema": {"type": "string"},
             "summary": "Unregister a service",
             "deprecated": false,
             "produces": ["*/*"],
-            "operationId": "deleteServiceUsingDELETE",
+            "operationId": "deleteServiceUsingDELETE_1",
             "responses": {
                 "200": {"description": "Not used"},
                 "401": {"description": "Unauthorized"},
                 "summary": "Returns a policy configuration",
                 "deprecated": false,
                 "produces": ["*/*"],
-                "operationId": "getPolicyUsingGET",
+                "operationId": "getPolicyUsingGET_1",
                 "responses": {
                     "200": {
                         "schema": {"type": "object"},
                 "summary": "Delete a policy",
                 "deprecated": false,
                 "produces": ["*/*"],
-                "operationId": "deletePolicyUsingDELETE",
+                "operationId": "deletePolicyUsingDELETE_1",
                 "responses": {
                     "200": {"description": "Not used"},
                     "401": {"description": "Unauthorized"},
                 "summary": "Put a policy",
                 "deprecated": false,
                 "produces": ["*/*"],
-                "operationId": "putPolicyUsingPUT",
+                "operationId": "putPolicyUsingPUT_1",
                 "responses": {
                     "200": {"description": "Policy updated"},
                     "201": {"description": "Policy created"},
                 "summary": "Returns a policy",
                 "deprecated": false,
                 "produces": ["application/json"],
-                "operationId": "getPolicyUsingGET_1",
+                "operationId": "getPolicyUsingGET",
                 "responses": {
                     "200": {
                         "schema": {"$ref": "#/definitions/policy_info_v2"},
                 "summary": "Delete a policy",
                 "deprecated": false,
                 "produces": ["*/*"],
-                "operationId": "deletePolicyUsingDELETE_1",
+                "operationId": "deletePolicyUsingDELETE",
                 "responses": {
                     "200": {"description": "Not used"},
                     "401": {"description": "Unauthorized"},
             "summary": "Returns a policy status",
             "deprecated": false,
             "produces": ["*/*"],
-            "operationId": "getPolicyStatusUsingGET",
+            "operationId": "getPolicyStatusUsingGET_1",
             "responses": {
                 "200": {
                     "schema": {"type": "object"},
             "summary": "Returns a policy status",
             "deprecated": false,
             "produces": ["application/json"],
-            "operationId": "getPolicyStatusUsingGET_1",
+            "operationId": "getPolicyStatusUsingGET",
             "responses": {
                 "200": {
                     "schema": {"$ref": "#/definitions/policy_status_info_v2"},
             }],
             "tags": ["A1 Policy Management Version 2.0 (in progress)"]
         }},
+        "/v2/configuration": {"put": {
+            "summary": "Replace the current configuration with the given configuration",
+            "deprecated": false,
+            "produces": ["*/*"],
+            "operationId": "putConfigurationUsingPUT",
+            "responses": {
+                "200": {"description": "Configuration updated"},
+                "201": {"description": "Created"},
+                "400": {
+                    "schema": {"$ref": "#/definitions/error_information"},
+                    "description": "Invalid configuration provided"
+                },
+                "401": {"description": "Unauthorized"},
+                "500": {
+                    "schema": {"$ref": "#/definitions/error_information"},
+                    "description": "Something went wrong when replacing the configuration. Try again."
+                },
+                "403": {"description": "Forbidden"},
+                "404": {"description": "Not Found"}
+            },
+            "parameters": [{
+                "schema": {"type": "string"},
+                "in": "body",
+                "name": "configuration",
+                "description": "configuration",
+                "required": true
+            }],
+            "tags": ["A1 Policy Management Configuration"],
+            "consumes": ["application/json"]
+        }},
         "/policy_ids": {"get": {
             "summary": "Query policies, only policy identities returned",
             "deprecated": false,
             "produces": ["*/*"],
-            "operationId": "getPolicyIdsUsingGET",
+            "operationId": "getPolicyIdsUsingGET_1",
             "responses": {
                 "200": {
                     "schema": {
                 "deprecated": false,
                 "produces": ["application/json"],
                 "description": "Either information about a registered service with given identity or all registered services are returned.",
-                "operationId": "getServicesUsingGET",
+                "operationId": "getServicesUsingGET_1",
                 "responses": {
                     "200": {
                         "schema": {"$ref": "#/definitions/service_list_v2"},
                 "deprecated": false,
                 "produces": ["*/*"],
                 "description": "Registering a service is needed to:<ul><li>Get callbacks.<\/li><li>Activate supervision of the service. If a service is inactive, its policies will be deleted.<\/li><\/ul>",
-                "operationId": "putServiceUsingPUT",
+                "operationId": "putServiceUsingPUT_1",
                 "responses": {
                     "200": {
                         "schema": {"type": "object"},
             "summary": "Heartbeat from a service",
             "deprecated": false,
             "produces": ["*/*"],
-            "operationId": "keepAliveServiceUsingPUT_1",
+            "operationId": "keepAliveServiceUsingPUT",
             "responses": {
                 "200": {
                     "schema": {"type": "string"},
             "summary": "Heartbeat indicates that the service is running",
             "deprecated": false,
             "produces": ["*/*"],
-            "operationId": "keepAliveServiceUsingPUT",
+            "operationId": "keepAliveServiceUsingPUT_1",
             "responses": {
                 "200": {
                     "schema": {"type": "object"},
             "summary": "Returns status and statistics of this service",
             "deprecated": false,
             "produces": ["*/*"],
-            "operationId": "getStatusUsingGET_1",
+            "operationId": "getStatusUsingGET",
             "responses": {
                 "200": {
                     "schema": {"type": "string"},
             "summary": "Register a service",
             "deprecated": false,
             "produces": ["*/*"],
-            "operationId": "putServiceUsingPUT_1",
+            "operationId": "putServiceUsingPUT",
             "responses": {
                 "200": {
                     "schema": {"type": "string"},
                 "deprecated": false,
                 "produces": ["application/json"],
                 "description": "Returns a list of A1 policies matching given search criteria. <br>If several query parameters are defined, the policies matching all conditions are returned.",
-                "operationId": "getPolicyIdsUsingGET_1",
+                "operationId": "getPolicyIdsUsingGET",
                 "responses": {
                     "200": {
                         "schema": {"$ref": "#/definitions/policy_id_list_v2"},
                 "summary": "Create or update a policy",
                 "deprecated": false,
                 "produces": ["application/json"],
-                "operationId": "putPolicyUsingPUT_1",
+                "operationId": "putPolicyUsingPUT",
                 "responses": {
                     "200": {"description": "Policy updated"},
                     "201": {"description": "Policy created"},
             }
         }
     },
-    "host": "localhost:38465",
+    "host": "localhost:49657",
     "definitions": {
         "error_information": {
             "description": "Problem as defined in https://tools.ietf.org/html/rfc7807",
         "version": "1.1.0"
     },
     "tags": [
+        {
+            "name": "A1 Policy Management Configuration",
+            "description": "Configuration Controller"
+        },
         {
             "name": "A1 Policy Management Version 1.0",
             "description": "Policy Controller"