Search in sources :

Example 76 with ApiResponses

use of io.swagger.v3.oas.annotations.responses.ApiResponses in project atlasmap by atlasmap.

the class AtlasService method resetMappingById.

/**
 * Removes the mapping file and catalogs related to specified ID.
 * @param mappingDefinitionId mapping definition ID
 * @return empty response
 */
@DELETE
@Path("/mapping/RESET/{mappingDefinitionId}")
@Produces(MediaType.APPLICATION_JSON)
@Operation(summary = "Remove Mapping by ID", description = "Remove mapping file and catalogs related to specified ID")
@ApiResponses({ @ApiResponse(responseCode = "200", description = "Mapping file and Catalogs were removed successfully"), @ApiResponse(responseCode = "204", description = "Unable to remove mapping file and Catalogs for the specified ID") })
public Response resetMappingById(@Parameter(description = "Mapping ID") @PathParam("mappingDefinitionId") Integer mappingDefinitionId) {
    LOG.debug("resetMappingById {} ", mappingDefinitionId);
    java.nio.file.Path mappingFolderPath = Paths.get(getMappingSubDirectory(mappingDefinitionId));
    File mappingFolderFile = mappingFolderPath.toFile();
    if (mappingFolderFile == null || !mappingFolderFile.exists()) {
        return Response.ok().build();
    }
    if (!mappingFolderFile.isDirectory()) {
        LOG.warn("{} is not a directory - removing anyway", mappingFolderFile.getAbsolutePath());
    }
    AtlasUtil.deleteDirectory(mappingFolderFile);
    return Response.ok().build();
}
Also used : File(java.io.File) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE) Produces(javax.ws.rs.Produces) Operation(io.swagger.v3.oas.annotations.Operation) ApiResponses(io.swagger.v3.oas.annotations.responses.ApiResponses)

Example 77 with ApiResponses

use of io.swagger.v3.oas.annotations.responses.ApiResponses in project atlasmap by atlasmap.

the class AtlasService method listLibraryClasses.

/**
 * Retrieves a list of available Java library class names from uploaded JARs.
 * @param uriInfo URI info
 * @return class names
 */
@GET
@Path("/library/list")
@Produces(MediaType.APPLICATION_JSON)
@Operation(summary = "List Library Classes", description = "Retrieves a list of available Java library class names from uploaded JARs.")
@ApiResponses(@ApiResponse(responseCode = "200", content = @Content(schema = @Schema(type = "ArrayList<String>")), description = "Return a list of loadable class names"))
public Response listLibraryClasses(@Context UriInfo uriInfo) {
    ArrayList<String> classNames;
    try {
        classNames = libraryLoader.getLibraryClassNames();
    } catch (Exception e) {
        if (LOG.isDebugEnabled()) {
            LOG.error("Library class retrieval error.", e);
        }
        throw new WebApplicationException("Error retrieving class names from uploaded JARs.");
    }
    byte[] serialized = toJson(classNames);
    if (LOG.isDebugEnabled()) {
        LOG.debug(new String(serialized));
    }
    return Response.ok().entity(serialized).build();
}
Also used : WebApplicationException(javax.ws.rs.WebApplicationException) WebApplicationException(javax.ws.rs.WebApplicationException) AtlasException(io.atlasmap.api.AtlasException) IOException(java.io.IOException) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) Operation(io.swagger.v3.oas.annotations.Operation) ApiResponses(io.swagger.v3.oas.annotations.responses.ApiResponses)

Example 78 with ApiResponses

use of io.swagger.v3.oas.annotations.responses.ApiResponses in project atlasmap by atlasmap.

the class AtlasService method listFieldActions.

/**
 * Retrieves a list of available field action.
 * @param uriInfo URI info
 * @return {@link ActionDetails} serialized to JSON
 */
@GET
@Path("/fieldActions")
@Produces(MediaType.APPLICATION_JSON)
@Operation(summary = "List FieldActions", description = "Retrieves a list of available field action")
@ApiResponses(@ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = ActionDetails.class)), description = "Return a list of field action detail"))
public Response listFieldActions(@Context UriInfo uriInfo) {
    ActionDetails details = new ActionDetails();
    if (atlasContextFactory == null || atlasContextFactory.getFieldActionService() == null) {
        return Response.ok().entity(toJson(details)).build();
    }
    details.getActionDetail().addAll(atlasContextFactory.getFieldActionService().listActionDetails());
    byte[] serialized = toJson(details);
    if (LOG.isDebugEnabled()) {
        LOG.debug(new String(serialized));
    }
    return Response.ok().entity(serialized).build();
}
Also used : ActionDetails(io.atlasmap.v2.ActionDetails) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) Operation(io.swagger.v3.oas.annotations.Operation) ApiResponses(io.swagger.v3.oas.annotations.responses.ApiResponses)

Example 79 with ApiResponses

use of io.swagger.v3.oas.annotations.responses.ApiResponses in project atlasmap by atlasmap.

the class JsonService method inspect.

/**
 * Inspect a JSON schema or instance and return a Document object.
 * @param requestIn request
 * @return {@link JsonInspectionResponse}
 */
@POST
@Path("/inspect")
@Consumes({ MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_JSON })
@Operation(summary = "Inspect JSON", description = "Inspect a JSON schema or instance and return a Document object")
@RequestBody(description = "JsonInspectionRequest object", content = @Content(schema = @Schema(implementation = JsonInspectionRequest.class)))
@ApiResponses(@ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = JsonInspectionResponse.class)), description = "Return a Document object represented by JsonDocument"))
public Response inspect(InputStream requestIn) {
    JsonInspectionRequest request = fromJson(requestIn, JsonInspectionRequest.class);
    long startTime = System.currentTimeMillis();
    JsonInspectionResponse response = new JsonInspectionResponse();
    JsonDocument d = null;
    try {
        if (request.getType() == null || request.getJsonData() == null) {
            response.setErrorMessage("Json data and Instance or Schema inspection type must be specified in request");
        } else {
            JsonInspectionService s = new JsonInspectionService();
            String jsonData = cleanJsonData(request.getJsonData());
            if (!validJsonData(jsonData)) {
                response.setErrorMessage("Invalid json payload specified");
            } else {
                switch(request.getType()) {
                    case INSTANCE:
                        d = s.inspectJsonDocument(jsonData);
                        break;
                    case SCHEMA:
                        d = s.inspectJsonSchema(jsonData);
                        break;
                    default:
                        response.setErrorMessage("Unsupported inspection type: " + request.getType());
                        break;
                }
            }
        }
    } catch (Exception e) {
        LOG.error("Error inspecting json: " + e.getMessage(), e);
        response.setErrorMessage(e.getMessage());
    } finally {
        response.setExecutionTime(System.currentTimeMillis() - startTime);
    }
    AtlasUtil.excludeNotRequestedFields(d, request.getInspectPaths());
    response.setJsonDocument(d);
    return Response.ok().entity(toJson(response)).build();
}
Also used : JsonInspectionService(io.atlasmap.json.inspect.JsonInspectionService) JsonInspectionResponse(io.atlasmap.json.v2.JsonInspectionResponse) JsonInspectionRequest(io.atlasmap.json.v2.JsonInspectionRequest) JsonDocument(io.atlasmap.json.v2.JsonDocument) IOException(java.io.IOException) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) WebApplicationException(javax.ws.rs.WebApplicationException) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) Operation(io.swagger.v3.oas.annotations.Operation) ApiResponses(io.swagger.v3.oas.annotations.responses.ApiResponses) RequestBody(io.swagger.v3.oas.annotations.parameters.RequestBody)

Example 80 with ApiResponses

use of io.swagger.v3.oas.annotations.responses.ApiResponses in project oxTrust by GluuFederation.

the class ClientWebResource method removeScopeToClient.

@DELETE
@Path(ApiConstants.INUM_PARAM_PATH + ApiConstants.SCOPES + ApiConstants.SCOPE_INUM_PARAM_PATH)
@Operation(summary = "Remove OIDC client scope", description = "Remove an existing scope from client")
@ApiResponses(value = { @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = Scope[].class)), description = "Success"), @ApiResponse(responseCode = "500", description = "Server error") })
@ProtectedApi(scopes = { WRITE_ACCESS })
public Response removeScopeToClient(@PathParam(ApiConstants.INUM) @NotNull String inum, @PathParam(ApiConstants.SCOPE_INUM) @NotNull String sinum) {
    log(logger, "remove scope to client");
    try {
        OxAuthClient client = clientService.getClientByInum(inum);
        Scope scope = scopeService.getScopeByInum(sinum);
        Objects.requireNonNull(client);
        Objects.requireNonNull(scope);
        if (client != null && scope != null) {
            List<String> scopes = new ArrayList<String>(client.getOxAuthScopes());
            scopes.remove(scopeService.getDnForScope(scope.getInum()));
            client.setOxAuthScopes(scopes);
            clientService.updateClient(client);
            return Response.ok(scopes).build();
        } else {
            return Response.status(Response.Status.NOT_FOUND).build();
        }
    } catch (Exception e) {
        log(logger, e);
        return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
    }
}
Also used : Scope(org.oxauth.persistence.model.Scope) OxAuthClient(org.gluu.oxtrust.model.OxAuthClient) ArrayList(java.util.ArrayList) ProtectedApi(org.gluu.oxtrust.service.filter.ProtectedApi) Operation(io.swagger.v3.oas.annotations.Operation) ApiResponses(io.swagger.v3.oas.annotations.responses.ApiResponses)

Aggregations

Operation (io.swagger.v3.oas.annotations.Operation)99 ApiResponses (io.swagger.v3.oas.annotations.responses.ApiResponses)99 ApiResponses (io.swagger.v3.oas.models.responses.ApiResponses)47 ProtectedApi (org.gluu.oxtrust.service.filter.ProtectedApi)47 ApiResponse (io.swagger.v3.oas.models.responses.ApiResponse)46 Operation (io.swagger.v3.oas.models.Operation)39 OpenAPI (io.swagger.v3.oas.models.OpenAPI)34 PathItem (io.swagger.v3.oas.models.PathItem)34 Test (org.testng.annotations.Test)31 ArrayList (java.util.ArrayList)23 Schema (io.swagger.v3.oas.models.media.Schema)22 StringSchema (io.swagger.v3.oas.models.media.StringSchema)21 Content (io.swagger.v3.oas.models.media.Content)20 MediaType (io.swagger.v3.oas.models.media.MediaType)20 ObjectSchema (io.swagger.v3.oas.models.media.ObjectSchema)19 IntegerSchema (io.swagger.v3.oas.models.media.IntegerSchema)17 Path (javax.ws.rs.Path)17 Produces (javax.ws.rs.Produces)17 ArraySchema (io.swagger.v3.oas.models.media.ArraySchema)16 Components (io.swagger.v3.oas.models.Components)10