io.swagger.annotations.ApiResponse Java Examples

The following examples show how to use io.swagger.annotations.ApiResponse. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RoleBindingController.java    From pulsar-manager with Apache License 2.0 8 votes vote down vote up
@ApiOperation(value = "Delete a role binding")
@ApiResponses({
        @ApiResponse(code = 200, message = "ok"),
        @ApiResponse(code = 404, message = "Not found"),
        @ApiResponse(code = 500, message = "Internal server error")
})
@RequestMapping(value = "/role-binding", method =  RequestMethod.DELETE)
public ResponseEntity<Map<String, Object>> deleteRoleBinding(@RequestBody RoleBindingEntity roleBindingEntity) {
    Map<String, Object> result = Maps.newHashMap();
    HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
    String token = request.getHeader("token");
    Map<String, String> stringMap = roleBindingService.validateCurrentUser(token, roleBindingEntity);
    if (stringMap.get("error") != null) {
        result.put("error", stringMap.get("error"));
        return ResponseEntity.ok(result);
    }
    Optional<RoleBindingEntity> roleBindingEntityOptional = roleBindingRepository.findByUserIdAndRoleId(
            roleBindingEntity.getUserId(), roleBindingEntity.getRoleId());
    if (!roleBindingEntityOptional.isPresent()) {
        result.put("error", "This role binding no exist");
        return ResponseEntity.ok(result);
    }
    roleBindingRepository.delete(roleBindingEntity.getRoleId(), roleBindingEntity.getUserId());
    result.put("message", "Delete role binding success");
    return ResponseEntity.ok(result);
}
 
Example #2
Source File: ApiV1.java    From pravega with Apache License 2.0 6 votes vote down vote up
@PUT
@Path("/{scopeName}/streams/{streamName}")
@Consumes({ "application/json" })
@Produces({ "application/json" })
@ApiOperation(value = "", notes = "", response = StreamProperty.class, tags = {  })
@ApiResponses(value = {
        @ApiResponse(
                code = 200,
                message = "Successfully updated the stream configuration",
                response = StreamProperty.class),

        @ApiResponse(
                code = 404, message = "Scope or stream not found", response = StreamProperty.class),

        @ApiResponse(
                code = 500, message = "Server error", response = StreamProperty.class) })
void updateStream(@ApiParam(value = "Scope name", required = true) @PathParam("scopeName") String scopeName,
        @ApiParam(value = "Stream name", required = true) @PathParam("streamName") String streamName,
        @ApiParam(value = "The new stream configuration", required = true)
                          UpdateStreamRequest updateStreamRequest,
        @Context SecurityContext securityContext, @Suspended final AsyncResponse asyncResponse);
 
Example #3
Source File: PermissionsService.java    From che with Eclipse Public License 2.0 6 votes vote down vote up
@POST
@Consumes(APPLICATION_JSON)
@ApiOperation("Store given permissions")
@ApiResponses({
  @ApiResponse(code = 200, message = "The permissions successfully stored"),
  @ApiResponse(code = 400, message = "Missed required parameters, parameters are not valid"),
  @ApiResponse(code = 404, message = "Domain of permissions is not supported"),
  @ApiResponse(
      code = 409,
      message = "New permissions removes last 'setPermissions' of given instance"),
  @ApiResponse(
      code = 409,
      message = "Given domain requires non nullable value for instance but it is null"),
  @ApiResponse(code = 500, message = "Internal server error occurred during permissions storing")
})
public void storePermissions(
    @ApiParam(value = "The permissions to store", required = true) PermissionsDto permissionsDto)
    throws ServerException, BadRequestException, ConflictException, NotFoundException {
  checkArgument(permissionsDto != null, "Permissions descriptor required");
  checkArgument(!isNullOrEmpty(permissionsDto.getUserId()), "User required");
  checkArgument(!isNullOrEmpty(permissionsDto.getDomainId()), "Domain required");
  instanceValidator.validate(permissionsDto.getDomainId(), permissionsDto.getInstanceId());
  checkArgument(!permissionsDto.getActions().isEmpty(), "One or more actions required");

  permissionsManager.storePermission(permissionsDto);
}
 
Example #4
Source File: ThingResource.java    From openhab-core with Eclipse Public License 2.0 6 votes vote down vote up
@GET
@RolesAllowed({ Role.USER, Role.ADMIN })
@Path("/{thingUID}/status")
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(value = "Gets thing's status.")
@ApiResponses(value = { @ApiResponse(code = 200, message = "OK", response = String.class),
        @ApiResponse(code = 404, message = "Thing not found.") })
public Response getStatus(
        @HeaderParam(HttpHeaders.ACCEPT_LANGUAGE) @ApiParam(value = "language") @Nullable String language,
        @PathParam("thingUID") @ApiParam(value = "thing") String thingUID) throws IOException {
    ThingUID thingUIDObject = new ThingUID(thingUID);

    // Check if the Thing exists, 404 if not
    Thing thing = thingRegistry.get(thingUIDObject);
    if (thing == null) {
        logger.info("Received HTTP GET request for thing config status at '{}' for the unknown thing '{}'.",
                uriInfo.getPath(), thingUID);
        return getThingNotFoundResponse(thingUID);
    }

    ThingStatusInfo thingStatusInfo = thingStatusInfoI18nLocalizationService.getLocalizedThingStatusInfo(thing,
            localeService.getLocale(language));
    return Response.ok().entity(thingStatusInfo).build();
}
 
Example #5
Source File: CweResource.java    From dependency-track with Apache License 2.0 6 votes vote down vote up
@GET
@Path("/{cweId}")
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(
        value = "Returns a specific CWE",
        response = Cwe.class
)
@ApiResponses(value = {
        @ApiResponse(code = 401, message = "Unauthorized"),
        @ApiResponse(code = 404, message = "The CWE could not be found")
})
public Response getCwe(
        @ApiParam(value = "The CWE ID of the CWE to retrieve", required = true)
        @PathParam("cweId") int cweId) {
    try (QueryManager qm = new QueryManager()) {
        final Cwe cwe = qm.getCweById(cweId);
        if (cwe != null) {
            return Response.ok(cwe).build();
        } else {
            return Response.status(Response.Status.NOT_FOUND).entity("The CWE could not be found.").build();
        }
    }
}
 
Example #6
Source File: TagResource.java    From graviteeio-access-management with Apache License 2.0 6 votes vote down vote up
@DELETE
@ApiOperation(value = "Delete the sharding tag",
        notes = "User must have the ORGANIZATION_TAG[DELETE] permission on the specified organization")
@ApiResponses({
        @ApiResponse(code = 204, message = "Sharding tag successfully deleted"),
        @ApiResponse(code = 500, message = "Internal server error")})
public void delete(
        @PathParam("organizationId") String organizationId,
        @PathParam("tag") String tag,
        @Suspended final AsyncResponse response) {
    final User authenticatedUser = getAuthenticatedUser();

    checkPermission(ReferenceType.ORGANIZATION, organizationId, Permission.ORGANIZATION_TAG, Acl.DELETE)
            .andThen(tagService.delete(tag, organizationId, authenticatedUser))
            .subscribe(() -> response.resume(Response.noContent().build()), response::resume);
}
 
Example #7
Source File: ScopeResource.java    From graviteeio-access-management with Apache License 2.0 6 votes vote down vote up
@DELETE
@ApiOperation(value = "Delete a scope",
        notes = "User must have the DOMAIN_SCOPE[DELETE] permission on the specified domain " +
                "or DOMAIN_SCOPE[DELETE] permission on the specified environment " +
                "or DOMAIN_SCOPE[DELETE] permission on the specified organization")
@ApiResponses({
        @ApiResponse(code = 204, message = "Scope successfully deleted"),
        @ApiResponse(code = 500, message = "Internal server error")})
public void delete(
        @PathParam("organizationId") String organizationId,
        @PathParam("environmentId") String environmentId,
        @PathParam("domain") String domain,
        @PathParam("scope") String scope,
        @Suspended final AsyncResponse response) {
    final User authenticatedUser = getAuthenticatedUser();

    checkAnyPermission(organizationId, environmentId, domain, Permission.DOMAIN_SCOPE, Acl.DELETE)
            .andThen(scopeService.delete(scope, false, authenticatedUser))
            .subscribe(() -> response.resume(Response.noContent().build()), response::resume);
}
 
Example #8
Source File: FactoryService.java    From che with Eclipse Public License 2.0 6 votes vote down vote up
@POST
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON)
@ApiOperation(value = "Create a new factory based on configuration")
@ApiResponses({
  @ApiResponse(code = 200, message = "Factory successfully created"),
  @ApiResponse(code = 400, message = "Missed required parameters, parameters are not valid"),
  @ApiResponse(code = 403, message = "User does not have rights to create factory"),
  @ApiResponse(code = 409, message = "When factory with given name and creator already exists"),
  @ApiResponse(code = 500, message = "Internal server error occurred")
})
public FactoryDto saveFactory(FactoryDto factory)
    throws BadRequestException, ServerException, ForbiddenException, ConflictException,
        NotFoundException {
  requiredNotNull(factory, "Factory configuration");
  factoryBuilder.checkValid(factory);
  processDefaults(factory);
  createValidator.validateOnCreate(factory);
  return injectLinks(asDto(factoryManager.saveFactory(factory)));
}
 
Example #9
Source File: IdentitiesApiController.java    From molgenis with GNU Lesser General Public License v3.0 6 votes vote down vote up
@PostMapping(GROUP_END_POINT)
@ApiOperation(value = "Create a new group", response = ResponseEntity.class)
@Transactional
@ApiResponses({
  @ApiResponse(code = 201, message = "New group created", response = ResponseEntity.class),
  @ApiResponse(code = 400, message = "Group name not available", response = ResponseEntity.class)
})
public ResponseEntity createGroup(@RequestBody GroupCommand group) {
  GroupValue groupValue =
      groupValueFactory.createGroup(
          group.getName(), group.getLabel(), GroupService.DEFAULT_ROLES, group.getName());

  if (!groupService.isGroupNameAvailable(groupValue)) {
    throw new GroupNameNotAvailableException(group.getName());
  }

  groupService.persist(groupValue);

  URI location =
      ServletUriComponentsBuilder.fromCurrentRequest()
          .path("/{name}")
          .buildAndExpand(groupValue.getName())
          .toUri();

  return ResponseEntity.created(location).build();
}
 
Example #10
Source File: NonPersistentTopics.java    From pulsar with Apache License 2.0 6 votes vote down vote up
@PUT
@Path("/{property}/{cluster}/{namespace}/{topic}/partitions")
@ApiOperation(hidden = true, value = "Create a partitioned topic.", notes = "It needs to be called before creating a producer on a partitioned topic.")
@ApiResponses(value = { @ApiResponse(code = 403, message = "Don't have admin permission"),
        @ApiResponse(code = 406, message = "The number of partitions should be more than 0 and less than or equal to maxNumPartitionsPerPartitionedTopic"),
        @ApiResponse(code = 409, message = "Partitioned topic already exist") })
public void createPartitionedTopic(@Suspended final AsyncResponse asyncResponse, @PathParam("property") String property, @PathParam("cluster") String cluster,
        @PathParam("namespace") String namespace, @PathParam("topic") @Encoded String encodedTopic,
        int numPartitions) {
    try {
        validateTopicName(property, cluster, namespace, encodedTopic);
        internalCreatePartitionedTopic(asyncResponse, numPartitions);
    } catch (Exception e) {
        log.error("[{}] Failed to create partitioned topic {}", clientAppId(), topicName, e);
        resumeAsyncResponseExceptionally(asyncResponse, e);
    }
}
 
Example #11
Source File: Namespaces.java    From pulsar with Apache License 2.0 6 votes vote down vote up
@POST
@Path("/{tenant}/{namespace}/offloadPolicies")
@ApiOperation(value = " Set offload configuration on a namespace.")
@ApiResponses(value = {
        @ApiResponse(code = 403, message = "Don't have admin permission"),
        @ApiResponse(code = 404, message = "Namespace does not exist"),
        @ApiResponse(code = 409, message = "Concurrent modification"),
        @ApiResponse(code = 412, message = "OffloadPolicies is empty or driver is not supported or bucket is not valid") })
public void setOffloadPolicies(@PathParam("tenant") String tenant, @PathParam("namespace") String namespace,
        @ApiParam(value = "Offload policies for the specified namespace", required = true) OffloadPolicies offload,
        @Suspended final AsyncResponse asyncResponse) {
    try {
        validateNamespaceName(tenant, namespace);
        internalSetOffloadPolicies(asyncResponse, offload);
    } catch (WebApplicationException wae) {
        asyncResponse.resume(wae);
    } catch (Exception e) {
        asyncResponse.resume(new RestException(e));
    }
}
 
Example #12
Source File: CartApi.java    From commerce-cif-api with Apache License 2.0 6 votes vote down vote up
@POST
@Path("/")
@ApiOperation(value = "Creates an empty cart. For convenience it also adds a cart entry when product variant id " +
    "and quantity are provided.")
@ApiResponses(value = {
    @ApiResponse(code = HTTP_CREATED, message = HTTP_CREATED_MESSAGE, response = Cart.class,
            responseHeaders = @ResponseHeader(name = "Location", description = "Location of the newly created cart.", response = String.class)),
    @ApiResponse(code = HTTP_BAD_REQUEST, message = HTTP_BAD_REQUEST_MESSAGE, response = ErrorResponse.class),
    @ApiResponse(code = HTTP_FORBIDDEN, message = HTTP_FORBIDDEN_MESSAGE, response = ErrorResponse.class),
    @ApiResponse(code = HTTP_NOT_FOUND, message = HTTP_NOT_FOUND_MESSAGE, response = ErrorResponse.class)
})
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
Cart postCart(
    @ApiParam(value = "Three-digit currency code.", required = true)
    @FormParam("currency") String currency,

    @ApiParam(value = "The product variant id to be added to the cart entry.")
    @FormParam("productVariantId") String productVariantId,

    @ApiParam(value = "The quantity for the product variant.")
    @FormParam("quantity") int quantity,

    @ApiParam(value = ACCEPT_LANGUAGE_DESC)
    @HeaderParam(ACCEPT_LANGUAGE) String acceptLanguage);
 
Example #13
Source File: ScopesApi.java    From ballerina-message-broker with Apache License 2.0 6 votes vote down vote up
@PUT
@Path("/{name}")
@Consumes({ "application/json" })
@Produces({ "application/json" })
@ApiOperation(value = "Update a scope", notes = "Update given scope", response = ScopeUpdateResponse.class, authorizations = {
    @Authorization(value = "basicAuth")
}, tags={  })
@ApiResponses(value = { 
    @ApiResponse(code = 200, message = "Scope updated", response = ScopeUpdateResponse.class),
    @ApiResponse(code = 400, message = "Bad Request. Invalid request or validation error.", response = Error.class),
    @ApiResponse(code = 401, message = "Authentication Data is missing or invalid", response = Error.class),
    @ApiResponse(code = 404, message = "Scope key not found", response = Error.class),
    @ApiResponse(code = 415, message = "Unsupported media type. The entity of the request was in a not supported format.", response = Error.class) })
public Response updateScope(@Context Request request, @PathParam("name") @ApiParam("Name of the scope needs to update") String name, @Valid ScopeUpdateRequest body) {
    return Response.ok().entity("magic!").build();
}
 
Example #14
Source File: ConfigurationHandler.java    From hawkular-apm with Apache License 2.0 6 votes vote down vote up
@GET
@Path("transaction/full/{name}")
@ApiOperation(value = "Retrieve the transaction configuration for the specified name", response = TransactionConfig.class)
@ApiResponses(value = {
        @ApiResponse(code = 200, message = "Success"),
        @ApiResponse(code = 500, message = "Internal server error") })
public Response getBusinessTxnConfiguration(@BeanParam NamedTransactionRequest request) {
    return withErrorHandler(() -> {
        log.tracef("Get transaction configuration for name [%s]", request.getName());
        TransactionConfig config = configService.getTransaction(getTenant(request), request.getName());
        log.tracef("Got transaction configuration for name [%s] config=[%s]", request.getName(), config);

        return Response
                .status(Response.Status.OK)
                .entity(config)
                .type(APPLICATION_JSON_TYPE)
                .build();
    });
}
 
Example #15
Source File: TestMatrixApiController.java    From proctor with Apache License 2.0 6 votes vote down vote up
@ApiOperation(
        value = "Show histories of all tests",
        response = TestHistoriesResponseModel.class,
        produces = "application/json"
)
@ApiResponses(value = {
        @ApiResponse(code = 404, message = "Branch not found")
})
@GetMapping("/{branch}/matrix/testHistories")
public JsonView getTestHistories(
        @ApiParam(allowableValues = "trunk,qa,production", required = true) @PathVariable final String branch,
        @ApiParam(value = "number of tests to show, -1 for unlimited") @RequestParam(required = false, value = "limit", defaultValue = "100") final int limit
) throws StoreException, ResourceNotFoundException {
    final Environment environment = Environment.fromName(branch);
    if (environment == null) {
        throw new ResourceNotFoundException("Branch " + branch + " is not a correct branch name. It must be one of (trunk, qa, production).");
    }
    final Map<String, List<Revision>> histories = queryHistories(environment);
    return new JsonView(new TestHistoriesResponseModel(histories, limit));
}
 
Example #16
Source File: ExtensionResource.java    From openhab-core with Eclipse Public License 2.0 6 votes vote down vote up
@POST
@Path("/url/{url}/install")
@ApiOperation(value = "Installs the extension from the given URL.")
@ApiResponses(value = { @ApiResponse(code = 200, message = "OK"),
        @ApiResponse(code = 400, message = "The given URL is malformed or not valid.") })
public Response installExtensionByURL(
        final @PathParam("url") @ApiParam(value = "extension install URL") String url) {
    try {
        URI extensionURI = new URI(url);
        String extensionId = getExtensionId(extensionURI);
        installExtension(extensionId);
    } catch (URISyntaxException | IllegalArgumentException e) {
        logger.error("Exception while parsing the extension URL '{}': {}", url, e.getMessage());
        return JSONResponse.createErrorResponse(Status.BAD_REQUEST, "The given URL is malformed or not valid.");
    }

    return Response.ok(null, MediaType.TEXT_PLAIN).build();
}
 
Example #17
Source File: RestScenarioController.java    From AuTe-Framework with Apache License 2.0 6 votes vote down vote up
@ApiOperation(
        value = "Updates scenario",
        notes = "If scenario wasn`t exist, new empty scenario will be created and updated with given data",
        nickname = "saveOne",
        consumes = MediaType.APPLICATION_JSON_VALUE,
        produces = MediaType.APPLICATION_JSON_VALUE
)
@ApiResponses({
        @ApiResponse(code = 200, message = "Updated scenario"),
        @ApiResponse(code = 404, message = "Updated scenario haven`t been loaded"),
        @ApiResponse(code = 500, message = "Server error. Cannot read old scenario from file, empty scenario name or troubles while saving")
})
@RequestMapping(value = { "{scenarioCode:.+}", "{scenarioGroup:.+}/{scenarioCode:.+}" }, method = RequestMethod.PUT)
public ScenarioRo saveOne(
        @PathVariable String projectCode,
        @PathVariable(required = false) String scenarioGroup,
        @PathVariable String scenarioCode,
        @RequestBody ScenarioRo scenarioRo) throws IOException {
    String scenarioPath = (StringUtils.isEmpty(scenarioGroup) ? "" : scenarioGroup + "/") + scenarioCode + "/";
    ScenarioRo savedScenario = scenarioService.updateScenarioFormRo(projectCode, scenarioPath, scenarioRo);
    if (savedScenario == null) {
        throw new ResourceNotFoundException();
    }
    return savedScenario;
}
 
Example #18
Source File: ProductCompositeService.java    From Hands-On-Microservices-with-Spring-Boot-and-Spring-Cloud with MIT License 5 votes vote down vote up
/**
 * Sample usage: curl $HOST:$PORT/product-composite/1
 *
 * @param productId
 * @return the composite product info, if found, else null
 */
@ApiOperation(
    value = "${api.product-composite.get-composite-product.description}",
    notes = "${api.product-composite.get-composite-product.notes}")
@ApiResponses(value = {
    @ApiResponse(code = 400, message = "Bad Request, invalid format of the request. See response message for more information."),
    @ApiResponse(code = 404, message = "Not found, the specified id does not exist."),
    @ApiResponse(code = 422, message = "Unprocessable entity, input parameters caused the processing to fail. See response message for more information.")
})
@GetMapping(
    value    = "/product-composite/{productId}",
    produces = "application/json")
Mono<ProductAggregate> getCompositeProduct(@PathVariable int productId);
 
Example #19
Source File: BucketFlowResource.java    From nifi-registry with Apache License 2.0 5 votes vote down vote up
@GET
@Path("{flowId}/versions")
@Consumes(MediaType.WILDCARD)
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(
        value = "Get bucket flow versions",
        notes = "Gets summary information for all versions of a flow. Versions are ordered newest->oldest.",
        response = VersionedFlowSnapshotMetadata.class,
        responseContainer = "List",
        extensions = {
                @Extension(name = "access-policy", properties = {
                        @ExtensionProperty(name = "action", value = "read"),
                        @ExtensionProperty(name = "resource", value = "/buckets/{bucketId}") })
        }
)
@ApiResponses({
        @ApiResponse(code = 401, message = HttpStatusMessages.MESSAGE_401),
        @ApiResponse(code = 403, message = HttpStatusMessages.MESSAGE_403),
        @ApiResponse(code = 404, message = HttpStatusMessages.MESSAGE_404),
        @ApiResponse(code = 409, message = HttpStatusMessages.MESSAGE_409) })
public Response getFlowVersions(
        @PathParam("bucketId")
        @ApiParam("The bucket identifier")
            final String bucketId,
        @PathParam("flowId")
        @ApiParam("The flow identifier")
            final String flowId) {

    final SortedSet<VersionedFlowSnapshotMetadata> snapshots = serviceFacade.getFlowSnapshots(bucketId, flowId);
    return Response.status(Response.Status.OK).entity(snapshots).build();
}
 
Example #20
Source File: SlingApi.java    From swagger-aem with Apache License 2.0 5 votes vote down vote up
@POST
@Path("/{path}/{name}")
@Consumes({ "multipart/form-data" })
@ApiOperation(value = "", tags={ "sling",  })
@ApiResponses(value = { 
    @ApiResponse(code = 200, message = "Default response") })
public void postNode(@PathParam("path") String path, @PathParam("name") String name, @QueryParam(":operation") String colonOperation, @QueryParam("deleteAuthorizable") String deleteAuthorizable,  @Multipart(value = "file" , required = false) Attachment fileDetail);
 
Example #21
Source File: ProductCompositeService.java    From Hands-On-Microservices-with-Spring-Boot-and-Spring-Cloud with MIT License 5 votes vote down vote up
/**
 * Sample usage: curl $HOST:$PORT/product-composite/1
 *
 * @param productId
 * @return the composite product info, if found, else null
 */
@ApiOperation(
    value = "${api.product-composite.get-composite-product.description}",
    notes = "${api.product-composite.get-composite-product.notes}")
@ApiResponses(value = {
    @ApiResponse(code = 400, message = "Bad Request, invalid format of the request. See response message for more information."),
    @ApiResponse(code = 404, message = "Not found, the specified id does not exist."),
    @ApiResponse(code = 422, message = "Unprocessable entity, input parameters caused the processing to fail. See response message for more information.")
})
@GetMapping(
    value    = "/product-composite/{productId}",
    produces = "application/json")
Mono<ProductAggregate> getCompositeProduct(@PathVariable int productId);
 
Example #22
Source File: DossierDocumentManagement.java    From opencps-v2 with GNU Affero General Public License v3.0 5 votes vote down vote up
@GET
@Path("/{id}/documents/preview/{typeCode}")
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.APPLICATION_FORM_URLENCODED })
@ApiOperation(value = "Get a formdata of Plugin", response = DossierResultsModel.class)
@ApiResponses(value = {
		@ApiResponse(code = HttpURLConnection.HTTP_OK, message = "Returns a list of Plugins have been filtered", response = DossierResultsModel.class),
		@ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = "Unauthorized", response = ExceptionModel.class),
		@ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = "Not found", response = ExceptionModel.class),
		@ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = "Access denied", response = ExceptionModel.class) })

public Response getPreview(@Context HttpServletRequest request, @Context HttpHeaders header,
		@Context Company company, @Context Locale locale, @Context User user,
		@Context ServiceContext serviceContext, @PathParam("id") String id, @PathParam("typeCode") String typeCode);
 
Example #23
Source File: TraceHandler.java    From hawkular-apm with Apache License 2.0 5 votes vote down vote up
@GET
@Path("complete/{id}")
@ApiOperation(value = "Retrieve end to end trace for specified id", response = Trace.class)
@ApiResponses(value = {
        @ApiResponse(code = 200, message = "Success, trace found and returned"),
        @ApiResponse(code = 500, message = "Internal server error"),
        @ApiResponse(code = 404, message = "Unknown trace id") })
public Response getTrace(@BeanParam GetByIdRequest request) {
    return withErrorHandler(() -> {
        Trace trace = traceService.getTrace(getTenant(request), request.getId());

        if (trace == null) {
            log.tracef("Trace [%s] not found", request.getId());
            return Response
                    .status(Response.Status.NOT_FOUND)
                    .type(APPLICATION_JSON_TYPE)
                    .build();
        } else {
            log.tracef("Trace [%s] found", request.getId());
            return Response
                    .status(Response.Status.OK)
                    .entity(trace)
                    .type(APPLICATION_JSON_TYPE)
                    .build();
        }
    });
}
 
Example #24
Source File: SignatureManagement.java    From opencps-v2 with GNU Affero General Public License v3.0 5 votes vote down vote up
@PUT
@Path("/{id}/dossierFiles")
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.APPLICATION_FORM_URLENCODED})
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@ApiOperation(value = "Digital Signature")
@ApiResponses(value = {
		@ApiResponse(code = HttpURLConnection.HTTP_OK, message = ""),
		@ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = "Unauthorized", response = ExceptionModel.class),
		@ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = "Access denied", response = ExceptionModel.class),
		@ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = "Internal error", response = ExceptionModel.class) })
public Response updateDossierFilesBySignatureDefault(@Context HttpServletRequest request, @Context HttpHeaders header,
		@Context Company company, @Context Locale locale, @Context User user, @Context ServiceContext serviceContext, 
		@ApiParam(value = "id of dossier", required = true) @PathParam("id") long id, @BeanParam DigitalSignatureInputModel input) throws PortalException, Exception;
 
Example #25
Source File: FreezeResourceDoc.java    From nexus-public with Eclipse Public License 1.0 5 votes vote down vote up
@ApiOperation("Enable read-only")
@ApiResponses(value = {
    @ApiResponse(code = 204, message = "System is now read-only"),
    @ApiResponse(code = 403, message = "Authentication required"),
    @ApiResponse(code = 404, message = "No change to read-only state")
})
void freeze();
 
Example #26
Source File: UserCollectionResource.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
@ApiOperation(value = "Create a user", tags = {"Users"})
@ApiResponses(value = {
    @ApiResponse(code = 201, message = "Indicates the user was created."),
    @ApiResponse(code = 400, message = "Indicates the id of the user was missing.")
})
@RequestMapping(value = "/identity/users", method = RequestMethod.POST, produces = "application/json")
public UserResponse createUser(@RequestBody UserRequest userRequest, HttpServletRequest request, HttpServletResponse response) {
  if (userRequest.getId() == null) {
    throw new ActivitiIllegalArgumentException("Id cannot be null.");
  }

  // Check if a user with the given ID already exists so we return a
  // CONFLICT
  if (identityService.createUserQuery().userId(userRequest.getId()).count() > 0) {
    throw new ActivitiConflictException("A user with id '" + userRequest.getId() + "' already exists.");
  }

  User created = identityService.newUser(userRequest.getId());
  created.setEmail(userRequest.getEmail());
  created.setFirstName(userRequest.getFirstName());
  created.setLastName(userRequest.getLastName());
  created.setPassword(userRequest.getPassword());
  identityService.saveUser(created);

  response.setStatus(HttpStatus.CREATED.value());

  return restResponseFactory.createUserResponse(created, true);
}
 
Example #27
Source File: ProductCompositeService.java    From Hands-On-Microservices-with-Spring-Boot-and-Spring-Cloud with MIT License 5 votes vote down vote up
/**
 * Sample usage: curl $HOST:$PORT/product-composite/1
 *
 * @param productId
 * @return the composite product info, if found, else null
 */
@ApiOperation(
    value = "${api.product-composite.get-composite-product.description}",
    notes = "${api.product-composite.get-composite-product.notes}")
@ApiResponses(value = {
    @ApiResponse(code = 400, message = "Bad Request, invalid format of the request. See response message for more information."),
    @ApiResponse(code = 404, message = "Not found, the specified id does not exist."),
    @ApiResponse(code = 422, message = "Unprocessable entity, input parameters caused the processing to fails. See response message for more information.")
})
@GetMapping(
    value    = "/product-composite/{productId}",
    produces = "application/json")
ProductAggregate getProduct(@PathVariable int productId);
 
Example #28
Source File: RemoteAccessApi.java    From swaggy-jenkins with MIT License 5 votes vote down vote up
@GET
@Path("/view/{name}/api/json")
@Produces({ "application/json" })
@ApiOperation(value = "", tags={  })
@ApiResponses(value = { 
    @ApiResponse(code = 200, message = "Successfully retrieved view details", response = ListView.class),
    @ApiResponse(code = 401, message = "Authentication failed - incorrect username and/or password"),
    @ApiResponse(code = 403, message = "Jenkins requires authentication - please set username and password"),
    @ApiResponse(code = 404, message = "View cannot be found on Jenkins instance") })
public ListView getView(@PathParam("name") String name);
 
Example #29
Source File: Namespaces.java    From pulsar with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("deprecation")
@PUT
@Path("/{property}/{cluster}/{namespace}")
@ApiOperation(hidden = true, value = "Creates a new empty namespace with no policies attached.")
@ApiResponses(value = { @ApiResponse(code = 403, message = "Don't have admin permission"),
        @ApiResponse(code = 404, message = "Property or cluster or namespace doesn't exist"),
        @ApiResponse(code = 409, message = "Namespace already exists"),
        @ApiResponse(code = 412, message = "Namespace name is not valid") })
public void createNamespace(@PathParam("property") String property, @PathParam("cluster") String cluster,
        @PathParam("namespace") String namespace, BundlesData initialBundles) {
    validateNamespaceName(property, cluster, namespace);

    if (!namespaceName.isGlobal()) {
        // If the namespace is non global, make sure property has the access on the cluster. For global namespace,
        // same check is made at the time of setting replication.
        validateClusterForTenant(namespaceName.getTenant(), namespaceName.getCluster());
    }

    Policies policies = new Policies();
    if (initialBundles != null && initialBundles.getNumBundles() > 0) {
        if (initialBundles.getBoundaries() == null || initialBundles.getBoundaries().size() == 0) {
            policies.bundles = getBundles(initialBundles.getNumBundles());
        } else {
            policies.bundles = validateBundlesData(initialBundles);
        }
    } else {
        int defaultNumberOfBundles = config().getDefaultNumberOfNamespaceBundles();
        policies.bundles = getBundles(defaultNumberOfBundles);
    }

    internalCreateNamespace(policies);
}
 
Example #30
Source File: RemoteAccessApi.java    From swaggy-jenkins with MIT License 5 votes vote down vote up
@GET
@Path("/queue/api/json")
@Produces({ "application/json" })
@ApiOperation(value = "", tags={  })
@ApiResponses(value = { 
    @ApiResponse(code = 200, message = "Successfully retrieved queue details", response = Queue.class),
    @ApiResponse(code = 401, message = "Authentication failed - incorrect username and/or password"),
    @ApiResponse(code = 403, message = "Jenkins requires authentication - please set username and password") })
public Queue getQueue();