diff options
Diffstat (limited to 'main/src')
-rw-r--r-- | main/src/main/java/org/onap/policy/pap/main/rest/PapRestController.java | 42 | ||||
-rw-r--r-- | main/src/test/java/org/onap/policy/pap/main/rest/TestPapRestServer.java | 8 |
2 files changed, 34 insertions, 16 deletions
diff --git a/main/src/main/java/org/onap/policy/pap/main/rest/PapRestController.java b/main/src/main/java/org/onap/policy/pap/main/rest/PapRestController.java index 4e9aa450..8d153f38 100644 --- a/main/src/main/java/org/onap/policy/pap/main/rest/PapRestController.java +++ b/main/src/main/java/org/onap/policy/pap/main/rest/PapRestController.java @@ -22,7 +22,12 @@ package org.onap.policy.pap.main.rest; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiResponse; +import io.swagger.annotations.ApiResponses; +import io.swagger.annotations.Authorization; +import io.swagger.annotations.BasicAuthDefinition; import io.swagger.annotations.Info; +import io.swagger.annotations.SecurityDefinition; import io.swagger.annotations.SwaggerDefinition; import io.swagger.annotations.Tag; @@ -39,29 +44,42 @@ import org.onap.policy.common.endpoints.report.HealthCheckReport; * * @author Ram Krishna Verma (ram.krishna.verma@est.tech) */ -@Path("/") -@Api +@Path("/policy/pap/v1") +@Api(value = "Policy Administration (PAP) API") @Produces(MediaType.APPLICATION_JSON) -@SwaggerDefinition(info = @Info(description = "Policy Pap Service", version = "v1.0", title = "Policy Pap"), - consumes = { MediaType.APPLICATION_JSON }, produces = { MediaType.APPLICATION_JSON }, - schemes = { SwaggerDefinition.Scheme.HTTP }, - tags = { @Tag(name = "policy-pap", description = "Policy Pap Service Operations") }) +@SwaggerDefinition(info = @Info( + description = "Policy Administration is responsible for the deployment life cycle of policies as well as " + + "interworking with the mechanisms required to orchestrate the nodes and containers on which " + + "policies run. It is also responsible for the administration of policies at run time;" + + " ensuring that policies are available to users, that policies are executing correctly," + + " and that the state and status of policies is monitored", + version = "v1.0", title = "Policy Administration"), consumes = { MediaType.APPLICATION_JSON }, + produces = { MediaType.APPLICATION_JSON }, + schemes = { SwaggerDefinition.Scheme.HTTP, SwaggerDefinition.Scheme.HTTPS }, + tags = { @Tag(name = "policy-administration", description = "Policy Administration Service Operations") }, + securityDefinition = @SecurityDefinition(basicAuthDefinitions = { @BasicAuthDefinition(key = "basicAuth") })) public class PapRestController { @GET @Path("healthcheck") - @Produces(MediaType.APPLICATION_JSON) - @ApiOperation(value = "Perform a system healthcheck", notes = "Provides healthy status of the Policy Pap component", - response = HealthCheckReport.class) + @ApiOperation(value = "Perform healthcheck", + notes = "Returns healthy status of the Policy Administration component", response = HealthCheckReport.class, + authorizations = @Authorization(value = "basicAuth")) + @ApiResponses(value = { @ApiResponse(code = 401, message = "Authentication Error"), + @ApiResponse(code = 403, message = "Authorization Error"), + @ApiResponse(code = 500, message = "Internal Server Error") }) public Response healthcheck() { return Response.status(Response.Status.OK).entity(new HealthCheckProvider().performHealthCheck()).build(); } @GET @Path("statistics") - @Produces(MediaType.APPLICATION_JSON) - @ApiOperation(value = "Fetch current statistics", notes = "Provides current statistics of the Policy PAP component", - response = StatisticsReport.class) + @ApiOperation(value = "Fetch current statistics", + notes = "Returns current statistics of the Policy Administration component", + response = StatisticsReport.class, authorizations = @Authorization(value = "basicAuth")) + @ApiResponses(value = { @ApiResponse(code = 401, message = "Authentication Error"), + @ApiResponse(code = 403, message = "Authorization Error"), + @ApiResponse(code = 500, message = "Internal Server Error") }) public Response statistics() { return Response.status(Response.Status.OK).entity(new StatisticsProvider().fetchCurrentStatistics()).build(); } diff --git a/main/src/test/java/org/onap/policy/pap/main/rest/TestPapRestServer.java b/main/src/test/java/org/onap/policy/pap/main/rest/TestPapRestServer.java index 66421b89..a8451992 100644 --- a/main/src/test/java/org/onap/policy/pap/main/rest/TestPapRestServer.java +++ b/main/src/test/java/org/onap/policy/pap/main/rest/TestPapRestServer.java @@ -220,7 +220,7 @@ public class TestPapRestServer { clientConfig.register(feature); final Client client = ClientBuilder.newClient(clientConfig); - final WebTarget webTarget = client.target("http://localhost:6969/" + endpoint); + final WebTarget webTarget = client.target("http://localhost:6969/policy/pap/v1/" + endpoint); final Invocation.Builder invocationBuilder = webTarget.request(MediaType.APPLICATION_JSON); @@ -248,13 +248,13 @@ public class TestPapRestServer { final SSLContext sc = SSLContext.getInstance("TLSv1.2"); sc.init(null, noopTrustManager, new SecureRandom()); - final ClientBuilder clientBuilder = - ClientBuilder.newBuilder().sslContext(sc).hostnameVerifier((host, session) -> true); + final ClientBuilder clientBuilder = ClientBuilder.newBuilder().sslContext(sc).hostnameVerifier((host, + session) -> true); final Client client = clientBuilder.build(); final HttpAuthenticationFeature feature = HttpAuthenticationFeature.basic("healthcheck", "zb!XztG34"); client.register(feature); - final WebTarget webTarget = client.target("https://localhost:6969/" + endpoint); + final WebTarget webTarget = client.target("https://localhost:6969/policy/pap/v1/" + endpoint); final Invocation.Builder invocationBuilder = webTarget.request(MediaType.APPLICATION_JSON); |