summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--main/pom.xml1
-rw-r--r--main/src/main/java/org/onap/policy/api/main/rest/ApiRestController.java677
-rw-r--r--main/src/main/resources/openapi/openapi.yaml96
-rw-r--r--main/src/test/java/org/onap/policy/api/main/rest/TestApiRestServer.java12
-rw-r--r--main/src/test/java/org/onap/policy/api/main/rest/utils/CommonTestRestController.java24
5 files changed, 145 insertions, 665 deletions
diff --git a/main/pom.xml b/main/pom.xml
index 34765405..aed73eaa 100644
--- a/main/pom.xml
+++ b/main/pom.xml
@@ -152,6 +152,7 @@
ToscaNodeTemplateArray=java.util.List,
HealthCheckReport=org.onap.policy.common.endpoints.report.HealthCheckReport,
StatisticsReport=org.onap.policy.api.main.rest.provider.statistics.StatisticsReport,
+ PolicyFetchMode=org.onap.policy.api.main.rest.PolicyFetchMode
</importMappings>
<configOptions>
<sourceFolder>src/gen/java</sourceFolder>
diff --git a/main/src/main/java/org/onap/policy/api/main/rest/ApiRestController.java b/main/src/main/java/org/onap/policy/api/main/rest/ApiRestController.java
index a734b2d6..d440e1ce 100644
--- a/main/src/main/java/org/onap/policy/api/main/rest/ApiRestController.java
+++ b/main/src/main/java/org/onap/policy/api/main/rest/ApiRestController.java
@@ -4,7 +4,7 @@
* ================================================================================
* Copyright (C) 2018 Samsung Electronics Co., Ltd. All rights reserved.
* Modifications Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2020,2022 Nordix Foundation.
+ * Modifications Copyright (C) 2020-2022 Nordix Foundation.
* Modifications Copyright (C) 2020-2022 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -25,25 +25,12 @@
package org.onap.policy.api.main.rest;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import io.swagger.annotations.ApiParam;
-import io.swagger.annotations.ApiResponse;
-import io.swagger.annotations.ApiResponses;
-import io.swagger.annotations.Authorization;
-import io.swagger.annotations.BasicAuthDefinition;
-import io.swagger.annotations.Extension;
-import io.swagger.annotations.ExtensionProperty;
-import io.swagger.annotations.Info;
-import io.swagger.annotations.ResponseHeader;
-import io.swagger.annotations.SecurityDefinition;
-import io.swagger.annotations.SwaggerDefinition;
-import java.net.HttpURLConnection;
import java.util.List;
import java.util.UUID;
import javax.ws.rs.core.Response.Status;
import lombok.RequiredArgsConstructor;
import org.onap.policy.api.main.exception.PolicyApiRuntimeException;
+import org.onap.policy.api.main.rest.genapi.PolicyDesignApi;
import org.onap.policy.api.main.rest.provider.healthcheck.HealthCheckProvider;
import org.onap.policy.api.main.rest.provider.statistics.ApiStatisticsManager;
import org.onap.policy.api.main.rest.provider.statistics.StatisticsProvider;
@@ -59,14 +46,6 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
-import org.springframework.web.bind.annotation.DeleteMapping;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestHeader;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
@@ -75,24 +54,8 @@ import org.springframework.web.bind.annotation.RestController;
* @author Chenfei Gao (cgao@research.att.com)
*/
@RestController
-@RequestMapping(path = "/policy/api/v1", produces = { "application/json", "application/yaml" })
-@Api(value = "Policy Design API")
-@SwaggerDefinition(
- info = @Info(
- description = "Policy Design API is publicly exposed for clients to Create/Read/Update/Delete"
- + " policy types, policy type implementation and policies which can be recognized"
- + " and executable by incorporated policy engines. It is an"
- + " independent component running rest service that takes all policy design API calls"
- + " from clients and then assign them to different API working functions. Besides"
- + " that, API is also exposed for clients to retrieve healthcheck status of this API"
- + " rest service and the statistics report including the counters of API invocation.",
- version = "1.0.0", title = "Policy Design",
- extensions = {@Extension(properties = {@ExtensionProperty(name = "planned-retirement-date", value = "tbd"),
- @ExtensionProperty(name = "component", value = "Policy Framework")})}),
- schemes = {SwaggerDefinition.Scheme.HTTP, SwaggerDefinition.Scheme.HTTPS},
- securityDefinition = @SecurityDefinition(basicAuthDefinitions = {@BasicAuthDefinition(key = "basicAuth")}))
@RequiredArgsConstructor
-public class ApiRestController extends CommonRestController {
+public class ApiRestController extends CommonRestController implements PolicyDesignApi {
private enum Target {
POLICY,
@@ -110,32 +73,8 @@ public class ApiRestController extends CommonRestController {
*
* @return the Response object containing the results of the API operation
*/
- @GetMapping("/healthcheck")
- @ApiOperation(value = "Perform a system healthcheck", notes = "Returns healthy status of the Policy API component",
- response = HealthCheckReport.class,
- responseHeaders = {
- @ResponseHeader(name = VERSION_MINOR_NAME,
- description = VERSION_MINOR_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = VERSION_PATCH_NAME,
- description = VERSION_PATCH_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = REQUEST_ID_NAME,
- description = REQUEST_ID_HDR_DESCRIPTION, response = UUID.class)},
- authorizations = @Authorization(value = AUTHORIZATION_TYPE), tags = {"HealthCheck", },
- extensions = {
- @Extension(name = EXTENSION_NAME, properties = {
- @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
- @ExtensionProperty(name = LAST_MOD_NAME, value = "Dublin")})})
- @ApiResponses(value = {
- @ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = AUTHENTICATION_ERROR_MESSAGE),
- @ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = AUTHORIZATION_ERROR_MESSAGE),
- @ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = SERVER_ERROR_MESSAGE)})
- public ResponseEntity<HealthCheckReport> getHealthCheck(
- @RequestHeader(name = REQUEST_ID_NAME, required = false)
- @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId) {
+ @Override
+ public ResponseEntity<HealthCheckReport> getHealthCheck(UUID requestId) {
final var report = healthCheckProvider.performHealthCheck();
updateApiStatisticsCounter(Target.OTHER, HttpStatus.resolve(report.getCode()), HttpMethod.GET);
return makeResponse(requestId, report, report.getCode());
@@ -146,33 +85,8 @@ public class ApiRestController extends CommonRestController {
*
* @return the Response object containing the results of the API operation
*/
- @GetMapping("/statistics")
- @ApiOperation(value = "Retrieve current statistics",
- notes = "Returns current statistics including the counters of API invocation",
- response = StatisticsReport.class,
- responseHeaders = {
- @ResponseHeader(name = VERSION_MINOR_NAME,
- description = VERSION_MINOR_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = VERSION_PATCH_NAME,
- description = VERSION_PATCH_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = REQUEST_ID_NAME,
- description = REQUEST_ID_HDR_DESCRIPTION, response = UUID.class)},
- authorizations = @Authorization(value = AUTHORIZATION_TYPE), tags = {"Statistics", },
- extensions = {
- @Extension(name = EXTENSION_NAME, properties = {
- @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
- @ExtensionProperty(name = LAST_MOD_NAME, value = "Dublin")})})
- @ApiResponses(value = {
- @ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = AUTHENTICATION_ERROR_MESSAGE),
- @ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = AUTHORIZATION_ERROR_MESSAGE),
- @ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = SERVER_ERROR_MESSAGE)})
- public ResponseEntity<StatisticsReport> getStatistics(
- @RequestHeader(name = REQUEST_ID_NAME, required = false)
- @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId) {
+ @Override
+ public ResponseEntity<StatisticsReport> getStatistics(UUID requestId) {
updateApiStatisticsCounter(Target.OTHER, HttpStatus.OK, HttpMethod.GET);
return makeOkResponse(requestId, statisticsProvider.fetchCurrentStatistics());
}
@@ -182,33 +96,8 @@ public class ApiRestController extends CommonRestController {
*
* @return the Response object containing the results of the API operation
*/
- @GetMapping("/policytypes")
- @ApiOperation(value = "Retrieve existing policy types",
- notes = "Returns a list of existing policy types stored in Policy Framework",
- response = ToscaServiceTemplate.class,
- responseHeaders = {
- @ResponseHeader(name = VERSION_MINOR_NAME,
- description = VERSION_MINOR_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = VERSION_PATCH_NAME,
- description = VERSION_PATCH_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = REQUEST_ID_NAME,
- description = REQUEST_ID_HDR_DESCRIPTION, response = UUID.class)},
- authorizations = @Authorization(value = AUTHORIZATION_TYPE), tags = {"PolicyType", },
- extensions = {
- @Extension(name = EXTENSION_NAME, properties = {
- @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
- @ExtensionProperty(name = LAST_MOD_NAME, value = "Dublin")})})
- @ApiResponses(value = {
- @ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = AUTHENTICATION_ERROR_MESSAGE),
- @ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = AUTHORIZATION_ERROR_MESSAGE),
- @ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = SERVER_ERROR_MESSAGE)})
- public ResponseEntity<ToscaServiceTemplate> getAllPolicyTypes(
- @RequestHeader(name = REQUEST_ID_NAME, required = false)
- @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId) {
+ @Override
+ public ResponseEntity<ToscaServiceTemplate> getAllPolicyTypes(UUID requestId) {
try {
ToscaServiceTemplate serviceTemplate = toscaServiceTemplateService.fetchPolicyTypes(null, null);
updateApiStatisticsCounter(Target.POLICY_TYPE, HttpStatus.OK, HttpMethod.GET);
@@ -228,35 +117,10 @@ public class ApiRestController extends CommonRestController {
*
* @return the Response object containing the results of the API operation
*/
- @GetMapping("/policytypes/{policyTypeId}")
- @ApiOperation(value = "Retrieve all available versions of a policy type",
- notes = "Returns a list of all available versions for the specified policy type",
- response = ToscaServiceTemplate.class,
- responseHeaders = {
- @ResponseHeader(name = VERSION_MINOR_NAME,
- description = VERSION_MINOR_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = VERSION_PATCH_NAME,
- description = VERSION_PATCH_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = REQUEST_ID_NAME,
- description = REQUEST_ID_HDR_DESCRIPTION, response = UUID.class)},
- authorizations = @Authorization(value = AUTHORIZATION_TYPE), tags = {"PolicyType", },
- extensions = {
- @Extension(name = EXTENSION_NAME, properties = {
- @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
- @ExtensionProperty(name = LAST_MOD_NAME, value = "Dublin")})})
- @ApiResponses(value = {
- @ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = AUTHENTICATION_ERROR_MESSAGE),
- @ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = AUTHORIZATION_ERROR_MESSAGE),
- @ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = NOT_FOUND_MESSAGE),
- @ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = SERVER_ERROR_MESSAGE)})
+ @Override
public ResponseEntity<ToscaServiceTemplate> getAllVersionsOfPolicyType(
- @PathVariable("policyTypeId") @ApiParam(value = "ID of policy type", required = true) String policyTypeId,
- @RequestHeader(name = REQUEST_ID_NAME, required = false)
- @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId) {
+ String policyTypeId,
+ UUID requestId) {
try {
ToscaServiceTemplate serviceTemplate = toscaServiceTemplateService.fetchPolicyTypes(policyTypeId, null);
updateApiStatisticsCounter(Target.POLICY_TYPE, HttpStatus.OK, HttpMethod.GET);
@@ -277,35 +141,11 @@ public class ApiRestController extends CommonRestController {
*
* @return the Response object containing the results of the API operation
*/
- @GetMapping("/policytypes/{policyTypeId}/versions/{versionId}")
- @ApiOperation(value = "Retrieve one particular version of a policy type",
- notes = "Returns a particular version for the specified policy type", response = ToscaServiceTemplate.class,
- responseHeaders = {
- @ResponseHeader(name = VERSION_MINOR_NAME,
- description = VERSION_MINOR_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = VERSION_PATCH_NAME,
- description = VERSION_PATCH_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = REQUEST_ID_NAME,
- description = REQUEST_ID_HDR_DESCRIPTION, response = UUID.class)},
- authorizations = @Authorization(value = AUTHORIZATION_TYPE), tags = {"PolicyType", },
- extensions = {
- @Extension(name = EXTENSION_NAME, properties = {
- @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
- @ExtensionProperty(name = LAST_MOD_NAME, value = "Dublin")})})
- @ApiResponses(value = {
- @ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = AUTHENTICATION_ERROR_MESSAGE),
- @ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = AUTHORIZATION_ERROR_MESSAGE),
- @ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = NOT_FOUND_MESSAGE),
- @ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = SERVER_ERROR_MESSAGE)})
+ @Override
public ResponseEntity<ToscaServiceTemplate> getSpecificVersionOfPolicyType(
- @PathVariable("policyTypeId") @ApiParam(value = "ID of policy type", required = true) String policyTypeId,
- @PathVariable("versionId") @ApiParam(value = "Version of policy type", required = true) String versionId,
- @RequestHeader(name = REQUEST_ID_NAME, required = false)
- @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId) {
+ String policyTypeId,
+ String versionId,
+ UUID requestId) {
try {
ToscaServiceTemplate serviceTemplate =
toscaServiceTemplateService.fetchPolicyTypes(policyTypeId, versionId);
@@ -326,34 +166,10 @@ public class ApiRestController extends CommonRestController {
*
* @return the Response object containing the results of the API operation
*/
- @GetMapping("/policytypes/{policyTypeId}/versions/latest")
- @ApiOperation(value = "Retrieve latest version of a policy type",
- notes = "Returns latest version for the specified policy type", response = ToscaServiceTemplate.class,
- responseHeaders = {
- @ResponseHeader(name = VERSION_MINOR_NAME,
- description = VERSION_MINOR_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = VERSION_PATCH_NAME,
- description = VERSION_PATCH_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = REQUEST_ID_NAME,
- description = REQUEST_ID_HDR_DESCRIPTION, response = UUID.class)},
- authorizations = @Authorization(value = AUTHORIZATION_TYPE), tags = {"PolicyType", },
- extensions = {
- @Extension(name = EXTENSION_NAME, properties = {
- @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
- @ExtensionProperty(name = LAST_MOD_NAME, value = "Dublin")})})
- @ApiResponses(value = {
- @ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = AUTHENTICATION_ERROR_MESSAGE),
- @ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = AUTHORIZATION_ERROR_MESSAGE),
- @ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = NOT_FOUND_MESSAGE),
- @ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = SERVER_ERROR_MESSAGE)})
+ @Override
public ResponseEntity<ToscaServiceTemplate> getLatestVersionOfPolicyType(
- @PathVariable("policyTypeId") @ApiParam(value = "ID of policy type", required = true) String policyTypeId,
- @RequestHeader(name = REQUEST_ID_NAME, required = false)
- @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId) {
+ String policyTypeId,
+ UUID requestId) {
try {
ToscaServiceTemplate serviceTemplate = toscaServiceTemplateService.fetchLatestPolicyTypes(policyTypeId);
updateApiStatisticsCounter(Target.POLICY_TYPE, HttpStatus.OK, HttpMethod.GET);
@@ -373,35 +189,10 @@ public class ApiRestController extends CommonRestController {
*
* @return the Response object containing the results of the API operation
*/
- @PostMapping("/policytypes")
- @ApiOperation(value = "Create a new policy type", notes = "Client should provide TOSCA body of the new policy type",
- authorizations = @Authorization(value = AUTHORIZATION_TYPE), tags = {"PolicyType", },
- response = ToscaServiceTemplate.class,
- responseHeaders = {
- @ResponseHeader(name = VERSION_MINOR_NAME,
- description = VERSION_MINOR_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = VERSION_PATCH_NAME,
- description = VERSION_PATCH_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = REQUEST_ID_NAME,
- description = REQUEST_ID_HDR_DESCRIPTION, response = UUID.class)},
- extensions = {
- @Extension(name = EXTENSION_NAME, properties = {
- @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
- @ExtensionProperty(name = LAST_MOD_NAME, value = "Dublin")})})
- @ApiResponses(value = {
- @ApiResponse(code = HttpURLConnection.HTTP_BAD_REQUEST, message = INVALID_BODY_MESSAGE),
- @ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = AUTHENTICATION_ERROR_MESSAGE),
- @ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = AUTHORIZATION_ERROR_MESSAGE),
- @ApiResponse(code = HttpURLConnection.HTTP_NOT_ACCEPTABLE, message = INVALID_PAYLOAD_MESSAGE),
- @ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = SERVER_ERROR_MESSAGE)})
+ @Override
public ResponseEntity<ToscaServiceTemplate> createPolicyType(
- @RequestBody @ApiParam(value = "Entity body of policy type", required = true) ToscaServiceTemplate body,
- @RequestHeader(name = REQUEST_ID_NAME, required = false)
- @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId) {
+ ToscaServiceTemplate body,
+ UUID requestId) {
if (NetLoggerUtil.getNetworkLogger().isInfoEnabled()) {
NetLoggerUtil.log(EventType.IN, CommInfrastructure.REST, "/policytypes", toJson(body));
}
@@ -425,39 +216,11 @@ public class ApiRestController extends CommonRestController {
*
* @return the Response object containing the results of the API operation
*/
- @DeleteMapping("/policytypes/{policyTypeId}/versions/{versionId}")
- @ApiOperation(value = "Delete one version of a policy type",
- notes = "Rule 1: pre-defined policy types cannot be deleted;"
- + "Rule 2: policy types that are in use (parameterized by a TOSCA policy) cannot be deleted."
- + "The parameterizing TOSCA policies must be deleted first;",
- authorizations = @Authorization(value = AUTHORIZATION_TYPE), tags = {"PolicyType", },
- response = ToscaServiceTemplate.class,
- responseHeaders = {
- @ResponseHeader(name = VERSION_MINOR_NAME,
- description = VERSION_MINOR_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = VERSION_PATCH_NAME,
- description = VERSION_PATCH_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = REQUEST_ID_NAME,
- description = REQUEST_ID_HDR_DESCRIPTION, response = UUID.class)},
- extensions = {
- @Extension(name = EXTENSION_NAME, properties = {
- @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
- @ExtensionProperty(name = LAST_MOD_NAME, value = "Dublin")})})
- @ApiResponses(value = {
- @ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = AUTHENTICATION_ERROR_MESSAGE),
- @ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = AUTHORIZATION_ERROR_MESSAGE),
- @ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = NOT_FOUND_MESSAGE),
- @ApiResponse(code = HttpURLConnection.HTTP_CONFLICT, message = HTTP_CONFLICT_MESSAGE),
- @ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = SERVER_ERROR_MESSAGE)})
+ @Override
public ResponseEntity<ToscaServiceTemplate> deleteSpecificVersionOfPolicyType(
- @PathVariable("policyTypeId") @ApiParam(value = "ID of policy type", required = true) String policyTypeId,
- @PathVariable("versionId") @ApiParam(value = "Version of policy type", required = true) String versionId,
- @RequestHeader(name = REQUEST_ID_NAME, required = false)
- @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId) {
+ String policyTypeId,
+ String versionId,
+ UUID requestId) {
try {
ToscaServiceTemplate serviceTemplate =
toscaServiceTemplateService.deletePolicyType(policyTypeId, versionId);
@@ -479,44 +242,12 @@ public class ApiRestController extends CommonRestController {
*
* @return the Response object containing the results of the API operation
*/
- @GetMapping("/policytypes/{policyTypeId}/versions/{policyTypeVersion}/policies")
- @ApiOperation(
- value = "Retrieve all versions of a policy created for a particular policy type version",
- notes = "Returns a list of all versions of specified policy created for the specified policy type version",
- response = ToscaServiceTemplate.class,
- responseHeaders = {
- @ResponseHeader(name = VERSION_MINOR_NAME,
- description = VERSION_MINOR_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = VERSION_PATCH_NAME,
- description = VERSION_PATCH_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = REQUEST_ID_NAME,
- description = REQUEST_ID_HDR_DESCRIPTION, response = UUID.class)},
- authorizations = @Authorization(value = AUTHORIZATION_TYPE), tags = {"Policy,"},
- extensions = {
- @Extension(name = EXTENSION_NAME, properties = {
- @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
- @ExtensionProperty(name = LAST_MOD_NAME, value = "Dublin")
- })
- }
- )
- @ApiResponses(value = {
- @ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = AUTHENTICATION_ERROR_MESSAGE),
- @ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = AUTHORIZATION_ERROR_MESSAGE),
- @ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = NOT_FOUND_MESSAGE),
- @ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = SERVER_ERROR_MESSAGE)
- })
+ @Override
public ResponseEntity<ToscaServiceTemplate> getAllPolicies(
- @PathVariable("policyTypeId") @ApiParam(value = "ID of policy type", required = true) String policyTypeId,
- @PathVariable("policyTypeVersion") @ApiParam(value = "Version of policy type",
- required = true) String policyTypeVersion,
- @RequestHeader(name = REQUEST_ID_NAME, required = false)
- @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId,
- @RequestParam(name = "mode", defaultValue = "bare") @ApiParam("Fetch mode for policies, BARE for bare"
- + " policies (default), REFERENCED for fully referenced policies") PolicyFetchMode mode) {
+ String policyTypeId,
+ String policyTypeVersion,
+ PolicyFetchMode mode,
+ UUID requestId) {
try {
ToscaServiceTemplate serviceTemplate =
toscaServiceTemplateService.fetchPolicies(policyTypeId, policyTypeVersion, null, null, mode);
@@ -539,43 +270,13 @@ public class ApiRestController extends CommonRestController {
*
* @return the Response object containing the results of the API operation
*/
- @GetMapping("/policytypes/{policyTypeId}/versions/{policyTypeVersion}/policies/{policyId}")
- @ApiOperation(value = "Retrieve all version details of a policy created for a particular policy type version",
- notes = "Returns a list of all version details of the specified policy", response = ToscaServiceTemplate.class,
- responseHeaders = {
- @ResponseHeader(name = VERSION_MINOR_NAME,
- description = VERSION_MINOR_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = VERSION_PATCH_NAME,
- description = VERSION_PATCH_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = REQUEST_ID_NAME,
- description = REQUEST_ID_HDR_DESCRIPTION, response = UUID.class)},
- authorizations = @Authorization(value = AUTHORIZATION_TYPE), tags = {"Policy", },
- extensions = {
- @Extension(name = EXTENSION_NAME, properties = {
- @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
- @ExtensionProperty(name = LAST_MOD_NAME, value = "Dublin")
- })
- }
- )
- @ApiResponses(value = {
- @ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = AUTHENTICATION_ERROR_MESSAGE),
- @ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = AUTHORIZATION_ERROR_MESSAGE),
- @ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = NOT_FOUND_MESSAGE),
- @ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = SERVER_ERROR_MESSAGE)
- })
+ @Override
public ResponseEntity<ToscaServiceTemplate> getAllVersionsOfPolicy(
- @PathVariable("policyTypeId") @ApiParam(value = "ID of policy type", required = true) String policyTypeId,
- @PathVariable("policyTypeVersion") @ApiParam(value = "Version of policy type",
- required = true) String policyTypeVersion,
- @PathVariable("policyId") @ApiParam(value = "ID of policy", required = true) String policyId,
- @RequestHeader(name = REQUEST_ID_NAME, required = false) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId,
- @RequestParam(name = "mode", defaultValue = "bare")
- @ApiParam("Fetch mode for policies, BARE for bare policies (default),"
- + " REFERENCED for fully referenced policies") PolicyFetchMode mode) {
+ String policyId,
+ String policyTypeId,
+ String policyTypeVersion,
+ PolicyFetchMode mode,
+ UUID requestId) {
try {
ToscaServiceTemplate serviceTemplate =
toscaServiceTemplateService.fetchPolicies(policyTypeId, policyTypeVersion, policyId, null, mode);
@@ -600,45 +301,14 @@ public class ApiRestController extends CommonRestController {
*
* @return the Response object containing the results of the API operation
*/
- @GetMapping("/policytypes/{policyTypeId}/versions/{policyTypeVersion}/policies/{policyId}/versions/{policyVersion}")
- @ApiOperation(value = "Retrieve one version of a policy created for a particular policy type version",
- notes = "Returns a particular version of specified policy created for the specified policy type version",
- response = ToscaServiceTemplate.class,
- responseHeaders = {
- @ResponseHeader(name = VERSION_MINOR_NAME,
- description = VERSION_MINOR_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = VERSION_PATCH_NAME,
- description = VERSION_PATCH_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = REQUEST_ID_NAME,
- description = REQUEST_ID_HDR_DESCRIPTION, response = UUID.class)},
- authorizations = @Authorization(value = AUTHORIZATION_TYPE), tags = {"Policy", },
- extensions = {
- @Extension(name = EXTENSION_NAME, properties = {
- @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
- @ExtensionProperty(name = LAST_MOD_NAME, value = "Dublin")
- })
- }
- )
- @ApiResponses(value = {
- @ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = AUTHENTICATION_ERROR_MESSAGE),
- @ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = AUTHORIZATION_ERROR_MESSAGE),
- @ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = NOT_FOUND_MESSAGE),
- @ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = SERVER_ERROR_MESSAGE)
- })
+ @Override
public ResponseEntity<ToscaServiceTemplate> getSpecificVersionOfPolicy(
- @PathVariable("policyTypeId") @ApiParam(value = "ID of policy type", required = true) String policyTypeId,
- @PathVariable("policyTypeVersion") @ApiParam(value = "Version of policy type",
- required = true) String policyTypeVersion,
- @PathVariable("policyId") @ApiParam(value = "ID of policy", required = true) String policyId,
- @PathVariable("policyVersion") @ApiParam(value = "Version of policy", required = true) String policyVersion,
- @RequestHeader(name = REQUEST_ID_NAME, required = false)
- @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId,
- @RequestParam(name = "mode", defaultValue = "bare") @ApiParam("Fetch mode for policies, BARE for bare policies"
- + " (default), REFERENCED for fully referenced policies") PolicyFetchMode mode) {
+ String policyId,
+ String policyTypeId,
+ String policyTypeVersion,
+ String policyVersion,
+ PolicyFetchMode mode,
+ UUID requestId) {
try {
ToscaServiceTemplate serviceTemplate = toscaServiceTemplateService
.fetchPolicies(policyTypeId, policyTypeVersion, policyId, policyVersion, mode);
@@ -662,39 +332,13 @@ public class ApiRestController extends CommonRestController {
*
* @return the Response object containing the results of the API operation
*/
- @GetMapping("/policytypes/{policyTypeId}/versions/{policyTypeVersion}/policies/{policyId}/versions/latest")
- @ApiOperation(value = "Retrieve the latest version of a particular policy",
- notes = "Returns the latest version of specified policy", response = ToscaServiceTemplate.class,
- responseHeaders = {
- @ResponseHeader(name = VERSION_MINOR_NAME,
- description = VERSION_MINOR_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = VERSION_PATCH_NAME,
- description = VERSION_PATCH_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = REQUEST_ID_NAME,
- description = REQUEST_ID_HDR_DESCRIPTION, response = UUID.class)},
- authorizations = @Authorization(value = AUTHORIZATION_TYPE), tags = {"Policy", },
- extensions = {
- @Extension(name = EXTENSION_NAME, properties = {
- @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
- @ExtensionProperty(name = LAST_MOD_NAME, value = "Dublin")})})
- @ApiResponses(value = {
- @ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = AUTHENTICATION_ERROR_MESSAGE),
- @ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = AUTHORIZATION_ERROR_MESSAGE),
- @ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = NOT_FOUND_MESSAGE),
- @ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = SERVER_ERROR_MESSAGE)})
+ @Override
public ResponseEntity<ToscaServiceTemplate> getLatestVersionOfPolicy(
- @PathVariable("policyTypeId") @ApiParam(value = "ID of policy type", required = true) String policyTypeId,
- @PathVariable("policyTypeVersion") @ApiParam(value = "Version of policy type",
- required = true) String policyTypeVersion,
- @PathVariable("policyId") @ApiParam(value = "ID of policy", required = true) String policyId,
- @RequestHeader(name = REQUEST_ID_NAME, required = false)
- @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId,
- @RequestParam(name = "mode", defaultValue = "bare") @ApiParam("Fetch mode for policies, TERSE for bare "
- + "policies (default), REFERENCED for fully referenced policies") PolicyFetchMode mode) {
+ String policyId,
+ String policyTypeId,
+ String policyTypeVersion,
+ PolicyFetchMode mode,
+ UUID requestId) {
try {
ToscaServiceTemplate serviceTemplate =
toscaServiceTemplateService.fetchLatestPolicies(policyTypeId, policyTypeVersion, policyId, mode);
@@ -718,40 +362,12 @@ public class ApiRestController extends CommonRestController {
*
* @return the Response object containing the results of the API operation
*/
- @PostMapping("/policytypes/{policyTypeId}/versions/{policyTypeVersion}/policies")
- @ApiOperation(value = "Create a new policy for a policy type version",
- notes = "Client should provide TOSCA body of the new policy",
- authorizations = @Authorization(value = AUTHORIZATION_TYPE), tags = {"Policy", },
- response = ToscaServiceTemplate.class,
- responseHeaders = {
- @ResponseHeader(name = VERSION_MINOR_NAME,
- description = VERSION_MINOR_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = VERSION_PATCH_NAME,
- description = VERSION_PATCH_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = REQUEST_ID_NAME,
- description = REQUEST_ID_HDR_DESCRIPTION, response = UUID.class)},
- extensions = {
- @Extension(name = EXTENSION_NAME, properties = {
- @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
- @ExtensionProperty(name = LAST_MOD_NAME, value = "Dublin")})})
- @ApiResponses(value = {
- @ApiResponse(code = HttpURLConnection.HTTP_BAD_REQUEST, message = INVALID_BODY_MESSAGE),
- @ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = AUTHENTICATION_ERROR_MESSAGE),
- @ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = AUTHORIZATION_ERROR_MESSAGE),
- @ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = NOT_FOUND_MESSAGE),
- @ApiResponse(code = HttpURLConnection.HTTP_NOT_ACCEPTABLE, message = INVALID_PAYLOAD_MESSAGE),
- @ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = SERVER_ERROR_MESSAGE)})
+ @Override
public ResponseEntity<ToscaServiceTemplate> createPolicy(
- @PathVariable("policyTypeId") @ApiParam(value = "ID of policy type", required = true) String policyTypeId,
- @PathVariable("policyTypeVersion") @ApiParam(value = "Version of policy type",
- required = true) String policyTypeVersion,
- @RequestHeader(name = REQUEST_ID_NAME, required = false)
- @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId,
- @RequestBody @ApiParam(value = "Entity body of policy", required = true) ToscaServiceTemplate body) {
+ String policyTypeId,
+ String policyTypeVersion,
+ ToscaServiceTemplate body,
+ UUID requestId) {
if (NetLoggerUtil.getNetworkLogger().isInfoEnabled()) {
NetLoggerUtil.log(EventType.IN, CommInfrastructure.REST,
"/policytypes/" + policyTypeId + "/versions/" + policyTypeVersion + "/policies", toJson(body));
@@ -779,41 +395,13 @@ public class ApiRestController extends CommonRestController {
*
* @return the Response object containing the results of the API operation
*/
- @DeleteMapping("/policytypes/{policyTypeId}/versions/{policyTypeVersion}/policies/{policyId}/"
- + "versions/{policyVersion}")
- @ApiOperation(value = "Delete a particular version of a policy",
- notes = "Rule: the version that has been deployed in PDP group(s) cannot be deleted",
- authorizations = @Authorization(value = AUTHORIZATION_TYPE), tags = {"Policy", },
- response = ToscaServiceTemplate.class,
- responseHeaders = {
- @ResponseHeader(name = VERSION_MINOR_NAME,
- description = VERSION_MINOR_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = VERSION_PATCH_NAME,
- description = VERSION_PATCH_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = REQUEST_ID_NAME,
- description = REQUEST_ID_HDR_DESCRIPTION, response = UUID.class)},
- extensions = {
- @Extension(name = EXTENSION_NAME, properties = {
- @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
- @ExtensionProperty(name = LAST_MOD_NAME, value = "Dublin")})})
- @ApiResponses(value = {
- @ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = AUTHENTICATION_ERROR_MESSAGE),
- @ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = AUTHORIZATION_ERROR_MESSAGE),
- @ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = NOT_FOUND_MESSAGE),
- @ApiResponse(code = HttpURLConnection.HTTP_CONFLICT, message = HTTP_CONFLICT_MESSAGE),
- @ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = SERVER_ERROR_MESSAGE)})
+ @Override
public ResponseEntity<ToscaServiceTemplate> deleteSpecificVersionOfPolicy(
- @PathVariable("policyTypeId") @ApiParam(value = "PolicyType ID", required = true) String policyTypeId,
- @PathVariable("policyTypeVersion") @ApiParam(value = "Version of policy type",
- required = true) String policyTypeVersion,
- @PathVariable("policyId") @ApiParam(value = "ID of policy", required = true) String policyId,
- @PathVariable("policyVersion") @ApiParam(value = "Version of policy", required = true) String policyVersion,
- @RequestHeader(name = REQUEST_ID_NAME, required = false)
- @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId) {
+ String policyTypeId,
+ String policyTypeVersion,
+ String policyId,
+ String policyVersion,
+ UUID requestId) {
try {
ToscaServiceTemplate serviceTemplate =
toscaServiceTemplateService.deletePolicy(policyTypeId, policyTypeVersion, policyId, policyVersion);
@@ -833,40 +421,10 @@ public class ApiRestController extends CommonRestController {
*
* @return the Response object containing the results of the API operation
*/
- @GetMapping("/policies")
- @ApiOperation(value = "Retrieve all versions of available policies",
- notes = "Returns all version of available policies",
- response = ToscaServiceTemplate.class,
- responseHeaders = {
- @ResponseHeader(name = VERSION_MINOR_NAME,
- description = VERSION_MINOR_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = VERSION_PATCH_NAME,
- description = VERSION_PATCH_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = REQUEST_ID_NAME,
- description = REQUEST_ID_HDR_DESCRIPTION, response = UUID.class)},
- authorizations = @Authorization(value = AUTHORIZATION_TYPE), tags = {"Policy", },
- extensions = {
- @Extension(name = EXTENSION_NAME, properties = {
- @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
- @ExtensionProperty(name = LAST_MOD_NAME, value = "Guilin")
- })
- }
- )
- @ApiResponses(value = {
- @ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = AUTHENTICATION_ERROR_MESSAGE),
- @ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = AUTHORIZATION_ERROR_MESSAGE),
- @ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = NOT_FOUND_MESSAGE),
- @ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = SERVER_ERROR_MESSAGE)
- })
+ @Override
public ResponseEntity<ToscaServiceTemplate> getPolicies(
- @RequestHeader(name = REQUEST_ID_NAME, required = false)
- @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId,
- @RequestParam(name = "mode", defaultValue = "bare") @ApiParam("Fetch mode for policies, BARE for bare"
- + " policies (default), REFERENCED for fully referenced policies") PolicyFetchMode mode) {
+ PolicyFetchMode mode,
+ UUID requestId) {
try {
ToscaServiceTemplate serviceTemplate =
toscaServiceTemplateService.fetchPolicies(null, null, null, null, mode);
@@ -892,42 +450,12 @@ public class ApiRestController extends CommonRestController {
*
* @return the Response object containing the results of the API operation
*/
- @GetMapping("/policies/{policyId}/versions/{policyVersion}")
- @ApiOperation(value = "Retrieve specific version of a specified policy",
- notes = "Returns a particular version of specified policy",
- response = ToscaServiceTemplate.class,
- responseHeaders = {
- @ResponseHeader(name = VERSION_MINOR_NAME,
- description = VERSION_MINOR_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = VERSION_PATCH_NAME,
- description = VERSION_PATCH_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = REQUEST_ID_NAME,
- description = REQUEST_ID_HDR_DESCRIPTION, response = UUID.class)},
- authorizations = @Authorization(value = AUTHORIZATION_TYPE), tags = {"Policy", },
- extensions = {
- @Extension(name = EXTENSION_NAME, properties = {
- @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
- @ExtensionProperty(name = LAST_MOD_NAME, value = "Guilin")
- })
- }
- )
- @ApiResponses(value = {
- @ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = AUTHENTICATION_ERROR_MESSAGE),
- @ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = AUTHORIZATION_ERROR_MESSAGE),
- @ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = NOT_FOUND_MESSAGE),
- @ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = SERVER_ERROR_MESSAGE)
- })
+ @Override
public ResponseEntity<ToscaServiceTemplate> getSpecificPolicy(
- @PathVariable("policyId") @ApiParam(value = "Name of policy", required = true) String policyId,
- @PathVariable("policyVersion") @ApiParam(value = "Version of policy", required = true) String policyVersion,
- @RequestHeader(name = REQUEST_ID_NAME, required = false)
- @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId,
- @RequestParam(name = "mode", defaultValue = "bare") @ApiParam("Fetch mode for policies, BARE for bare"
- + " policies (default), REFERENCED for fully referenced policies") PolicyFetchMode mode) {
+ String policyId,
+ String policyVersion,
+ PolicyFetchMode mode,
+ UUID requestId) {
try {
ToscaServiceTemplate serviceTemplate =
toscaServiceTemplateService.fetchPolicies(null, null, policyId, policyVersion, mode);
@@ -948,37 +476,10 @@ public class ApiRestController extends CommonRestController {
*
* @return the Response object containing the results of the API operation
*/
- @PostMapping("/policies")
- @ApiOperation(value = "Create one or more new policies",
- notes = "Client should provide TOSCA body of the new polic(ies)",
- authorizations = @Authorization(value = AUTHORIZATION_TYPE), tags = {"Policy", },
- response = ToscaServiceTemplate.class,
- responseHeaders = {
- @ResponseHeader(name = VERSION_MINOR_NAME,
- description = VERSION_MINOR_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = VERSION_PATCH_NAME,
- description = VERSION_PATCH_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = REQUEST_ID_NAME,
- description = REQUEST_ID_HDR_DESCRIPTION, response = UUID.class)},
- extensions = {
- @Extension(name = EXTENSION_NAME, properties = {
- @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
- @ExtensionProperty(name = LAST_MOD_NAME, value = "El Alto")})})
- @ApiResponses(value = {
- @ApiResponse(code = HttpURLConnection.HTTP_BAD_REQUEST, message = INVALID_BODY_MESSAGE),
- @ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = AUTHENTICATION_ERROR_MESSAGE),
- @ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = AUTHORIZATION_ERROR_MESSAGE),
- @ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = NOT_FOUND_MESSAGE),
- @ApiResponse(code = HttpURLConnection.HTTP_NOT_ACCEPTABLE, message = INVALID_PAYLOAD_MESSAGE),
- @ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = SERVER_ERROR_MESSAGE)})
+ @Override
public ResponseEntity<ToscaServiceTemplate> createPolicies(
- @RequestHeader(name = REQUEST_ID_NAME, required = false)
- @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId,
- @RequestBody @ApiParam(value = "Entity body of policy", required = true) ToscaServiceTemplate body) {
+ ToscaServiceTemplate body,
+ UUID requestId) {
if (NetLoggerUtil.getNetworkLogger().isInfoEnabled()) {
NetLoggerUtil.log(EventType.IN, CommInfrastructure.REST, "/policies", toJson(body));
}
@@ -1002,37 +503,11 @@ public class ApiRestController extends CommonRestController {
*
* @return the Response object containing the results of the API operation
*/
- @DeleteMapping("/policies/{policyId}/versions/{policyVersion}")
- @ApiOperation(value = "Delete a particular version of a policy",
- notes = "Rule: the version that has been deployed in PDP group(s) cannot be deleted",
- authorizations = @Authorization(value = AUTHORIZATION_TYPE), tags = {"Policy", },
- response = ToscaServiceTemplate.class,
- responseHeaders = {
- @ResponseHeader(name = VERSION_MINOR_NAME,
- description = VERSION_MINOR_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = VERSION_PATCH_NAME,
- description = VERSION_PATCH_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = REQUEST_ID_NAME,
- description = REQUEST_ID_HDR_DESCRIPTION, response = UUID.class)},
- extensions = {
- @Extension(name = EXTENSION_NAME, properties = {
- @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
- @ExtensionProperty(name = LAST_MOD_NAME, value = "Guilin")})})
- @ApiResponses(value = {
- @ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = AUTHENTICATION_ERROR_MESSAGE),
- @ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = AUTHORIZATION_ERROR_MESSAGE),
- @ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = NOT_FOUND_MESSAGE),
- @ApiResponse(code = HttpURLConnection.HTTP_CONFLICT, message = HTTP_CONFLICT_MESSAGE),
- @ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = SERVER_ERROR_MESSAGE)})
+ @Override
public ResponseEntity<ToscaServiceTemplate> deleteSpecificPolicy(
- @PathVariable("policyId") @ApiParam(value = "ID of policy", required = true) String policyId,
- @PathVariable("policyVersion") @ApiParam(value = "Version of policy", required = true) String policyVersion,
- @RequestHeader(name = REQUEST_ID_NAME, required = false)
- @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId) {
+ String policyId,
+ String policyVersion,
+ UUID requestId) {
try {
ToscaServiceTemplate serviceTemplate =
toscaServiceTemplateService.deletePolicy(null, null, policyId, policyVersion);
diff --git a/main/src/main/resources/openapi/openapi.yaml b/main/src/main/resources/openapi/openapi.yaml
index 105019af..4b71aebd 100644
--- a/main/src/main/resources/openapi/openapi.yaml
+++ b/main/src/main/resources/openapi/openapi.yaml
@@ -22,11 +22,20 @@ tags:
node templates which can be recognized and executable by incorporated policy engines. It is an
independent component running rest service that takes all node templates design API calls
from clients and then assign them to different API working functions.
+- name: "Policy Design"
+ description:
+ Policy Design API is publicly exposed for clients to Create/Read/Update/Delete
+ policy types, policy type implementation and policies which can be recognized
+ and executable by incorporated policy engines. It is an
+ independent component running rest service that takes all policy design API calls
+ from clients and then assign them to different API working functions. Besides
+ that, API is also exposed for clients to retrieve healthcheck status of this API
+ rest service and the statistics report including the counters of API invocation.
paths:
/policy/api/v1/healthcheck:
get:
tags:
- - HealthCheck
+ - "Policy Design"
summary: Perform a system healthcheck
description: Returns healthy status of the Policy API component
operationId: getHealthCheck
@@ -919,7 +928,7 @@ paths:
/policy/api/v1/policies:
get:
tags:
- - PolicyInstances
+ - "Policy Design"
summary: Retrieve all versions of available policies
description: Returns all version of available policies
operationId: getPolicies
@@ -929,11 +938,7 @@ paths:
description: Fetch mode for policies, BARE for bare policies (default), REFERENCED
for fully referenced policies
schema:
- type: string
- default: BARE
- enum:
- - BARE
- - REFERENCED
+ $ref: '#/components/schemas/PolicyFetchMode'
- name: X-ONAP-RequestID
in: header
description: RequestID for http transaction
@@ -1040,7 +1045,7 @@ paths:
last-mod-release: Guilin
post:
tags:
- - PolicyInstances
+ - "Policy Design"
summary: Create one or more new policies
description: Client should provide TOSCA body of the new polic(ies)
operationId: createPolicies
@@ -1222,7 +1227,7 @@ paths:
/policy/api/v1/policies/{policyId}/versions/{policyVersion}:
get:
tags:
- - PolicyInstances
+ - "Policy Design"
summary: Retrieve specific version of a specified policy
description: Returns a particular version of specified policy
operationId: getSpecificPolicy
@@ -1232,11 +1237,7 @@ paths:
description: Fetch mode for policies, BARE for bare policies (default), REFERENCED
for fully referenced policies
schema:
- type: string
- default: BARE
- enum:
- - BARE
- - REFERENCED
+ $ref: '#/components/schemas/PolicyFetchMode'
- name: policyId
in: path
description: Name of policy
@@ -1355,7 +1356,7 @@ paths:
last-mod-release: Guilin
delete:
tags:
- - PolicyInstances
+ - "Policy Design"
summary: Delete a particular version of a policy
description: 'Rule: the version that has been deployed in PDP group(s) cannot
be deleted'
@@ -1514,7 +1515,7 @@ paths:
/policy/api/v1/policytypes:
get:
tags:
- - PolicyTypes
+ - "Policy Design"
summary: Retrieve existing policy types
description: Returns a list of existing policy types stored in Policy Framework
operationId: getAllPolicyTypes
@@ -1625,7 +1626,7 @@ paths:
last-mod-release: Dublin
post:
tags:
- - PolicyTypes
+ - "Policy Design"
summary: Create a new policy type
description: Client should provide TOSCA body of the new policy type
operationId: createPolicyType
@@ -1807,7 +1808,7 @@ paths:
/policy/api/v1/policytypes/{policyTypeId}:
get:
tags:
- - PolicyTypes
+ - "Policy Design"
summary: Retrieve all available versions of a policy type
description: Returns a list of all available versions for the specified policy
type
@@ -1926,7 +1927,7 @@ paths:
/policy/api/v1/policytypes/{policyTypeId}/versions/latest:
get:
tags:
- - PolicyTypes
+ - "Policy Design"
summary: Retrieve latest version of a policy type
description: Returns latest version for the specified policy type
operationId: getLatestVersionOfPolicyType
@@ -2044,7 +2045,7 @@ paths:
/policy/api/v1/policytypes/{policyTypeId}/versions/{policyTypeVersion}/policies:
get:
tags:
- - PolicyInstances
+ - "Policy Design"
summary: Retrieve all versions of a policy created for a particular policy type
version
description: Returns a list of all versions of specified policy created for
@@ -2056,11 +2057,7 @@ paths:
description: Fetch mode for policies, BARE for bare policies (default), REFERENCED
for fully referenced policies
schema:
- type: string
- default: BARE
- enum:
- - BARE
- - REFERENCED
+ $ref: '#/components/schemas/PolicyFetchMode'
- name: policyTypeId
in: path
description: ID of policy type
@@ -2179,7 +2176,7 @@ paths:
last-mod-release: Dublin
post:
tags:
- - PolicyInstances
+ - "Policy Design"
summary: Create a new policy for a policy type version
description: Client should provide TOSCA body of the new policy
operationId: createPolicy
@@ -2373,7 +2370,7 @@ paths:
/policy/api/v1/policytypes/{policyTypeId}/versions/{policyTypeVersion}/policies/{policyId}:
get:
tags:
- - PolicyInstances
+ - "Policy Design"
summary: Retrieve all version details of a policy created for a particular policy
type version
description: Returns a list of all version details of the specified policy
@@ -2384,11 +2381,7 @@ paths:
description: Fetch mode for policies, BARE for bare policies (default), REFERENCED
for fully referenced policies
schema:
- type: string
- default: BARE
- enum:
- - BARE
- - REFERENCED
+ $ref: '#/components/schemas/PolicyFetchMode'
- name: policyId
in: path
description: ID of policy
@@ -2514,7 +2507,7 @@ paths:
/policy/api/v1/policytypes/{policyTypeId}/versions/{policyTypeVersion}/policies/{policyId}/versions/latest:
get:
tags:
- - PolicyInstances
+ - "Policy Design"
summary: Retrieve the latest version of a particular policy
description: Returns the latest version of specified policy
operationId: getLatestVersionOfPolicy
@@ -2524,11 +2517,7 @@ paths:
description: Fetch mode for policies, TERSE for bare policies (default), REFERENCED
for fully referenced policies
schema:
- type: string
- default: BARE
- enum:
- - BARE
- - REFERENCED
+ $ref: '#/components/schemas/PolicyFetchMode'
- name: policyId
in: path
description: ID of policy
@@ -2654,7 +2643,7 @@ paths:
/policy/api/v1/policytypes/{policyTypeId}/versions/{policyTypeVersion}/policies/{policyId}/versions/{policyVersion}:
get:
tags:
- - PolicyInstances
+ - "Policy Design"
summary: Retrieve one version of a policy created for a particular policy type
version
description: Returns a particular version of specified policy created for the
@@ -2666,11 +2655,7 @@ paths:
description: Fetch mode for policies, BARE for bare policies (default), REFERENCED
for fully referenced policies
schema:
- type: string
- default: BARE
- enum:
- - BARE
- - REFERENCED
+ $ref: '#/components/schemas/PolicyFetchMode'
- name: policyId
in: path
description: ID of policy
@@ -2801,18 +2786,12 @@ paths:
last-mod-release: Dublin
delete:
tags:
- - PolicyInstances
+ - "Policy Design"
summary: Delete a particular version of a policy
description: 'Rule: the version that has been deployed in PDP group(s) cannot
be deleted'
operationId: deleteSpecificVersionOfPolicy
parameters:
- - name: policyId
- in: path
- description: ID of policy
- required: true
- schema:
- type: string
- name: policyTypeId
in: path
description: PolicyType ID
@@ -2825,6 +2804,12 @@ paths:
required: true
schema:
type: string
+ - name: policyId
+ in: path
+ description: ID of policy
+ required: true
+ schema:
+ type: string
- name: policyVersion
in: path
description: Version of policy
@@ -2972,7 +2957,7 @@ paths:
/policy/api/v1/policytypes/{policyTypeId}/versions/{versionId}:
get:
tags:
- - PolicyTypes
+ - "Policy Design"
summary: Retrieve one particular version of a policy type
description: Returns a particular version for the specified policy type
operationId: getSpecificVersionOfPolicyType
@@ -3095,7 +3080,7 @@ paths:
last-mod-release: Dublin
delete:
tags:
- - PolicyTypes
+ - "Policy Design"
summary: Delete one version of a policy type
description: 'Rule 1: pre-defined policy types cannot be deleted;Rule 2: policy
types that are in use (parameterized by a TOSCA policy) cannot be deleted.The
@@ -3255,7 +3240,7 @@ paths:
/policy/api/v1/statistics:
get:
tags:
- - Statistics
+ - "Policy Design"
summary: Retrieve current statistics
description: Returns current statistics including the counters of API invocation
operationId: getStatistics
@@ -3382,3 +3367,6 @@ components:
StatisticsReport:
title: StatisticsReport
type: object
+ PolicyFetchMode:
+ title: PolicyFetchMode
+ type: object \ No newline at end of file
diff --git a/main/src/test/java/org/onap/policy/api/main/rest/TestApiRestServer.java b/main/src/test/java/org/onap/policy/api/main/rest/TestApiRestServer.java
index 4f4dd6b8..eab9fe72 100644
--- a/main/src/test/java/org/onap/policy/api/main/rest/TestApiRestServer.java
+++ b/main/src/test/java/org/onap/policy/api/main/rest/TestApiRestServer.java
@@ -184,6 +184,11 @@ public class TestApiRestServer extends CommonTestRestController {
}
@Test
+ public void testSwagger() throws Exception {
+ super.testSwagger(apiPort);
+ }
+
+ @Test
public void testCreatePolicyTypes() throws Exception {
for (String resrcName : TOSCA_POLICYTYPE_RESOURCE_NAMES) {
Response rawResponse = createResource(POLICYTYPES, resrcName, apiPort);
@@ -318,7 +323,8 @@ public class TestApiRestServer extends CommonTestRestController {
}
private void testHealthCheckSuccess(String mediaType) throws Exception {
- final Invocation.Builder invocationBuilder = sendHttpsRequest(HEALTHCHECK_ENDPOINT, mediaType, apiPort);
+ final Invocation.Builder invocationBuilder = sendHttpsRequest(
+ CONTEXT_PATH, HEALTHCHECK_ENDPOINT, mediaType, apiPort);
final HealthCheckReport report = invocationBuilder.get(HealthCheckReport.class);
validateHealthCheckReport(NAME, SELF, true, 200, ALIVE, report);
}
@@ -334,11 +340,11 @@ public class TestApiRestServer extends CommonTestRestController {
}
private void testApiStatistics_200(String mediaType) throws Exception {
- Invocation.Builder invocationBuilder = sendHttpsRequest(STATISTICS_ENDPOINT, mediaType, apiPort);
+ Invocation.Builder invocationBuilder = sendHttpsRequest(CONTEXT_PATH, STATISTICS_ENDPOINT, mediaType, apiPort);
StatisticsReport report = invocationBuilder.get(StatisticsReport.class);
validateStatisticsReport(report, 200);
updateApiStatistics();
- invocationBuilder = sendHttpsRequest(STATISTICS_ENDPOINT, mediaType, apiPort);
+ invocationBuilder = sendHttpsRequest(CONTEXT_PATH, STATISTICS_ENDPOINT, mediaType, apiPort);
report = invocationBuilder.get(StatisticsReport.class);
validateStatisticsReport(report, 200);
// ApiStatisticsManager.resetAllStatistics();
diff --git a/main/src/test/java/org/onap/policy/api/main/rest/utils/CommonTestRestController.java b/main/src/test/java/org/onap/policy/api/main/rest/utils/CommonTestRestController.java
index 9289adb2..4f2e8b22 100644
--- a/main/src/test/java/org/onap/policy/api/main/rest/utils/CommonTestRestController.java
+++ b/main/src/test/java/org/onap/policy/api/main/rest/utils/CommonTestRestController.java
@@ -22,6 +22,8 @@
package org.onap.policy.api.main.rest.utils;
+import static org.junit.Assert.assertTrue;
+
import java.security.SecureRandom;
import javax.net.ssl.SSLContext;
import javax.net.ssl.TrustManager;
@@ -54,6 +56,14 @@ public class CommonTestRestController {
protected static final StandardCoder standardCoder = new StandardCoder();
protected static StandardYamlCoder standardYamlCoder = new StandardYamlCoder();
+ protected static final String HTTPS_PREFIX = "https://localhost:";
+ protected static final String CONTEXT_PATH = "/policy/api/v1/";
+
+ protected void testSwagger(final int apiPort) throws Exception {
+ final Invocation.Builder invocationBuilder = sendHttpsRequest("/", "v3/api-docs", APP_JSON, apiPort);
+ final String resp = invocationBuilder.get(String.class);
+ assertTrue((resp).contains("{\"openapi\":\"3.0.1\",\"info\":{\"title\":\"Policy Framework Lifecycle API\""));
+ }
protected Response createResource(String endpoint, String resourceName, int apiPort)
throws Exception {
@@ -63,7 +73,7 @@ public class CommonTestRestController {
mediaType = mediaType == null ? APP_JSON : mediaType;
final Invocation.Builder invocationBuilder;
- invocationBuilder = sendHttpsRequest(endpoint, mediaType, apiPort);
+ invocationBuilder = sendHttpsRequest(CONTEXT_PATH, endpoint, mediaType, apiPort);
Entity<ToscaServiceTemplate> entity = Entity.entity(rawServiceTemplate, mediaType);
return invocationBuilder.post(entity);
}
@@ -71,14 +81,14 @@ public class CommonTestRestController {
protected Response readResource(String endpoint, String mediaType, int apiPort) throws Exception {
final Invocation.Builder invocationBuilder;
- invocationBuilder = sendHttpsRequest(endpoint, mediaType, apiPort);
+ invocationBuilder = sendHttpsRequest(CONTEXT_PATH, endpoint, mediaType, apiPort);
return invocationBuilder.get();
}
protected Response deleteResource(String endpoint, String mediaType, int apiPort) throws Exception {
final Invocation.Builder invocationBuilder;
- invocationBuilder = sendHttpsRequest(endpoint, mediaType, apiPort);
+ invocationBuilder = sendHttpsRequest(CONTEXT_PATH, endpoint, mediaType, apiPort);
return invocationBuilder.delete();
}
@@ -88,7 +98,7 @@ public class CommonTestRestController {
ToscaServiceTemplate rawServiceTemplate = getRawServiceTemplate(resourceName);
final Invocation.Builder invocationBuilder;
- invocationBuilder = sendHttpsRequest(endpoint, mediaType, apiPort);
+ invocationBuilder = sendHttpsRequest(CONTEXT_PATH, endpoint, mediaType, apiPort);
Entity<ToscaServiceTemplate> entity = Entity.entity(rawServiceTemplate, mediaType);
return invocationBuilder.put(entity);
}
@@ -101,8 +111,8 @@ public class CommonTestRestController {
return standardYamlCoder.decode(ResourceUtils.getResourceAsString(resourceName), ToscaServiceTemplate.class);
}
- protected Invocation.Builder sendHttpsRequest(final String endpoint, String mediaType, int apiPort)
- throws Exception {
+ protected Invocation.Builder sendHttpsRequest(
+ final String context, final String endpoint, String mediaType, int apiPort) throws Exception {
final TrustManager[] noopTrustManager = NetworkUtil.getAlwaysTrustingManager();
@@ -121,7 +131,7 @@ public class CommonTestRestController {
client.register(YamlMessageBodyHandler.class);
}
- final WebTarget webTarget = client.target("https://localhost:" + apiPort + "/policy/api/v1/" + endpoint);
+ final WebTarget webTarget = client.target(HTTPS_PREFIX + apiPort + context + endpoint);
final Invocation.Builder invocationBuilder = webTarget.request(mediaType);