io.swagger.v3.oas.annotations.parameters.RequestBody Java Examples

The following examples show how to use io.swagger.v3.oas.annotations.parameters.RequestBody. 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: HelloController.java    From springdoc-openapi with Apache License 2.0 9 votes vote down vote up
@PostMapping("/test2")
@RequestBody(
		description = "Details of the Item to be created",
		required = true,
		content = @Content(
				schema = @Schema(implementation = User.class),
				mediaType = MediaType.APPLICATION_JSON_VALUE,
				examples = {
						@ExampleObject(
								name = "An example request with the minimum required fields to create.",
								value = "min",
								summary = "Minimal request"),
						@ExampleObject(
								name = "An example request with all fields provided with example values.",
								value = "full",
								summary = "Full request") }))
public void test2(String hello) {
}
 
Example #2
Source File: SlaveResource.java    From Singularity with Apache License 2.0 6 votes vote down vote up
@POST
@Path("/slave/{slaveId}/activate")
@Operation(
  summary = "Activate a decomissioning slave, canceling decomission without erasing history"
)
@Consumes({ MediaType.APPLICATION_JSON })
public Response activateSlave(
  @Context HttpServletRequest requestContext,
  @Parameter(hidden = true) @Auth SingularityUser user,
  @Parameter(required = true, description = "Active slaveId") @PathParam(
    "slaveId"
  ) String slaveId,
  @RequestBody(
    description = "Settings related to changing the state of a slave"
  ) SingularityMachineChangeRequest changeRequest
) {
  return maybeProxyToLeader(
    requestContext,
    Response.class,
    changeRequest,
    () -> {
      activateSlave(user, slaveId, changeRequest);
      return Response.ok().build();
    }
  );
}
 
Example #3
Source File: QuoteRouter.java    From springdoc-openapi with Apache License 2.0 6 votes vote down vote up
@RouterOperations({
		@RouterOperation(path = "/hello", operation = @Operation(operationId = "hello", responses = @ApiResponse(responseCode = "200"))),
		@RouterOperation(path = "/echo", produces = TEXT_PLAIN_VALUE, operation = @Operation(operationId = "echo", requestBody = @RequestBody(content = @Content(schema = @Schema(type = "string"))),
				responses = @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(type = "string"))))),
		@RouterOperation(path = "/echo",produces = APPLICATION_JSON_VALUE,  operation = @Operation(operationId = "echo", requestBody = @RequestBody(content = @Content(schema = @Schema(type = "string"))),
				responses = @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(type = "string"))))),
		@RouterOperation(path = "/quotes", produces = APPLICATION_JSON_VALUE, operation = @Operation(operationId = "fetchQuotes", parameters = @Parameter(name = "size", in = ParameterIn.QUERY, schema = @Schema(type = "string")),
				responses = @ApiResponse(responseCode = "200", content = @Content(array = @ArraySchema(schema = @Schema(implementation = Quote.class)))))),
		@RouterOperation(path = "/quotes", produces = APPLICATION_STREAM_JSON_VALUE, operation = @Operation(operationId = "fetchQuotes",
				responses = @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = Quote.class))))) })
@Bean
public RouterFunction<ServerResponse> route(QuoteHandler quoteHandler) {
	return RouterFunctions
			.route(GET("/hello").and(accept(TEXT_PLAIN)), quoteHandler::hello)
			.andRoute(POST("/echo").and(accept(TEXT_PLAIN).and(contentType(TEXT_PLAIN))), quoteHandler::echo)
			.andRoute(POST("/echo").and(accept(APPLICATION_JSON).and(contentType(APPLICATION_JSON))), quoteHandler::echo)
			.andRoute(GET("/quotes").and(accept(APPLICATION_JSON)), quoteHandler::fetchQuotes)
			.andRoute(GET("/quotes").and(accept(APPLICATION_STREAM_JSON)), quoteHandler::streamQuotes);
}
 
Example #4
Source File: PositionRouter.java    From springdoc-openapi with Apache License 2.0 6 votes vote down vote up
@Bean
@RouterOperations({ @RouterOperation(path = "/getAllPositions", operation = @Operation(description = "Get all positions", operationId = "findAll",tags = "positions",
		responses = @ApiResponse(responseCode = "200", content = @Content(array = @ArraySchema(schema = @Schema(implementation = Position.class)))))),
		@RouterOperation(path = "/getPosition/{id}", operation = @Operation(description = "Find all", operationId = "findById", tags = "positions",parameters = @Parameter(name = "id", in = ParameterIn.PATH),
				 responses = @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = Position.class))))),
		@RouterOperation(path = "/createPosition",  operation = @Operation(description = "Save position", operationId = "save", tags = "positions",requestBody = @RequestBody(content = @Content(schema = @Schema(implementation = Position.class))),
				responses = @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = Position.class))))),
		@RouterOperation(path = "/deletePosition/{id}", operation = @Operation(description = "Delete By Id", operationId = "deleteBy",tags = "positions", parameters = @Parameter(name = "id", in = ParameterIn.PATH),
				responses = @ApiResponse(responseCode = "200", content = @Content)))})
public RouterFunction<ServerResponse> positionRoute(PositionHandler handler) {
	return RouterFunctions
			.route(GET("/getAllPositions").and(accept(MediaType.APPLICATION_JSON)), handler::findAll)
			.andRoute(GET("/getPosition/{id}").and(accept(MediaType.APPLICATION_STREAM_JSON)), handler::findById)
			.andRoute(POST("/createPosition").and(accept(MediaType.APPLICATION_JSON)), handler::save)
			.andRoute(DELETE("/deletePosition/{id}").and(accept(MediaType.APPLICATION_JSON)), handler::delete);
}
 
Example #5
Source File: PostRouter.java    From springdoc-openapi with Apache License 2.0 6 votes vote down vote up
@RouterOperations({ @RouterOperation(path = "/posts", method = RequestMethod.GET, headers = {"x-header1=test1","x-header2=test2"}, operation = @Operation(operationId = "all",
		parameters = { @Parameter(name = "key", description = "sample description"),@Parameter(name = "test", description = "sample desc")},
		responses = @ApiResponse(responseCode = "200", content = @Content(array = @ArraySchema(schema = @Schema(implementation = Post.class)))))),
		@RouterOperation(path = "/posts", method = RequestMethod.POST, operation = @Operation(operationId = "create",
				requestBody = @RequestBody(content = @Content(schema = @Schema(implementation = Post.class))), responses = @ApiResponse(responseCode = "201"))),
		@RouterOperation(path = "/posts/{id}", method = RequestMethod.GET, operation = @Operation(operationId = "get",
				parameters = @Parameter(name = "id", in = ParameterIn.PATH),
				responses = @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = Post.class))))),
		@RouterOperation(path = "/posts/{id}", method = RequestMethod.PUT, operation = @Operation(operationId = "update",
				parameters = @Parameter(name = "id", in = ParameterIn.PATH),
				responses = @ApiResponse(responseCode = "202", content = @Content(schema = @Schema(implementation = Post.class))))) })
@Bean
public RouterFunction<ServerResponse> routes(PostHandler postController) {
	return route(GET("/posts").and(queryParam("key", "value")), postController::all)
			.andRoute(POST("/posts"), postController::create)
			.andRoute(GET("/posts/{id}"), postController::get)
			.andRoute(PUT("/posts/{id}"), postController::update);
}
 
Example #6
Source File: DeployResource.java    From Singularity with Apache License 2.0 6 votes vote down vote up
@POST
@Path("/update")
@Operation(
  summary = "Update the target active instance count for a pending deploy",
  responses = {
    @ApiResponse(
      responseCode = "400",
      description = "Deploy is not in the pending state pending or is not not present"
    )
  }
)
public SingularityRequestParent updatePendingDeploy(
  @Parameter(hidden = true) @Auth SingularityUser user,
  @Context HttpServletRequest requestContext,
  @RequestBody(required = true) SingularityUpdatePendingDeployRequest updateRequest
) {
  return maybeProxyToLeader(
    requestContext,
    SingularityRequestParent.class,
    updateRequest,
    () -> updatePendingDeploy(user, updateRequest)
  );
}
 
Example #7
Source File: WebhookResource.java    From Singularity with Apache License 2.0 6 votes vote down vote up
@POST
@Consumes({ MediaType.APPLICATION_JSON })
@Operation(
  summary = "Add a new webhook",
  responses = {
    @ApiResponse(
      responseCode = "409",
      description = "Adding new webhooks is currently disabled"
    )
  }
)
public SingularityCreateResult addWebhook(
  @Parameter(hidden = true) @Auth SingularityUser user,
  @RequestBody(
    required = true,
    description = "SingularityWebhook object describing the new webhook to be added"
  ) SingularityWebhook webhook
) {
  authorizationHelper.checkAdminAuthorization(user);
  validator.checkActionEnabled(SingularityAction.ADD_WEBHOOK);
  validator.checkSingularityWebhook(webhook);
  return webhookManager.addWebhook(webhook);
}
 
Example #8
Source File: SlaveResource.java    From Singularity with Apache License 2.0 6 votes vote down vote up
@POST
@Path("/slave/{slaveId}/decommission")
@Operation(summary = "Begin decommissioning a specific active slave")
@Consumes({ MediaType.APPLICATION_JSON })
public Response decommissionSlave(
  @Context HttpServletRequest requestContext,
  @Parameter(hidden = true) @Auth SingularityUser user,
  @Parameter(required = true, description = "Active slaveId") @PathParam(
    "slaveId"
  ) String slaveId,
  @RequestBody(
    description = "Settings related to changing the state of a slave"
  ) SingularityMachineChangeRequest changeRequest
) {
  return maybeProxyToLeader(
    requestContext,
    Response.class,
    changeRequest,
    () -> {
      decommissionSlave(user, slaveId, changeRequest);
      return Response.ok().build();
    }
  );
}
 
Example #9
Source File: SlaveResource.java    From Singularity with Apache License 2.0 6 votes vote down vote up
@POST
@Path("/slave/{slaveId}/freeze")
@Operation(summary = "Freeze tasks on a specific slave")
@Consumes({ MediaType.APPLICATION_JSON })
public Response freezeSlave(
  @Context HttpServletRequest requestContext,
  @Parameter(hidden = true) @Auth SingularityUser user,
  @Parameter(required = true, description = "Slave ID") @PathParam(
    "slaveId"
  ) String slaveId,
  @RequestBody(
    description = "Settings related to changing the state of a slave"
  ) SingularityMachineChangeRequest changeRequest
) {
  return maybeProxyToLeader(
    requestContext,
    Response.class,
    changeRequest,
    () -> {
      freezeSlave(user, slaveId, changeRequest);
      return Response.ok().build();
    }
  );
}
 
Example #10
Source File: RequestBodyParamAnnotationProcessor.java    From servicecomb-toolkit with Apache License 2.0 6 votes vote down vote up
@Override
public void process(RequestBody requestBodyAnnotation, ParameterContext context) {

  context.setIn(InType.BODY);
  io.swagger.v3.oas.models.parameters.RequestBody requestBody = new io.swagger.v3.oas.models.parameters.RequestBody();

  requestBody.setRequired(requestBodyAnnotation.required());
  requestBody.setDescription(requestBodyAnnotation.description());

  if (StringUtils.isNotEmpty(requestBodyAnnotation.ref())) {
    requestBody.set$ref(requestBodyAnnotation.ref());
  }

  Content[] contentAnnotations = requestBodyAnnotation.content();

  List<io.swagger.v3.oas.models.media.Content> contentsFromAnnotation = SwaggerAnnotationUtils
      .getContentFromAnnotation(contentAnnotations);

  Optional.ofNullable(contentsFromAnnotation).ifPresent(contents -> {
    requestBody.content(contents.get(0));
  });

  context.setRequestBody(requestBody);
}
 
Example #11
Source File: DisastersResource.java    From Singularity with Apache License 2.0 6 votes vote down vote up
@POST
@Path("/disabled-actions/{action}")
@Operation(summary = "Disable a specific action")
public void disableAction(
  @Parameter(hidden = true) @Auth SingularityUser user,
  @Parameter(required = true, description = "The action to disable") @PathParam(
    "action"
  ) SingularityAction action,
  @RequestBody(
    description = "Notes related to a particular disabled action"
  ) SingularityDisabledActionRequest disabledActionRequest
) {
  final Optional<SingularityDisabledActionRequest> maybeRequest = Optional.ofNullable(
    disabledActionRequest
  );
  authorizationHelper.checkAdminAuthorization(user);
  Optional<String> message = maybeRequest.isPresent()
    ? maybeRequest.get().getMessage()
    : Optional.<String>empty();
  disasterManager.disable(action, message, Optional.of(user), false, Optional.empty());
}
 
Example #12
Source File: RequestGroupResource.java    From Singularity with Apache License 2.0 6 votes vote down vote up
@POST
@Operation(summary = "Create a Singularity request group")
public SingularityRequestGroup saveRequestGroup(
  @RequestBody(
    required = true,
    description = "The new request group to create"
  ) SingularityRequestGroup requestGroup,
  @Context HttpServletRequest requestContext
) {
  return maybeProxyToLeader(
    requestContext,
    SingularityRequestGroup.class,
    requestGroup,
    () -> {
      validator.checkRequestGroup(requestGroup);
      requestGroupManager.saveRequestGroup(requestGroup);
      return requestGroup;
    }
  );
}
 
Example #13
Source File: RackResource.java    From Singularity with Apache License 2.0 6 votes vote down vote up
@POST
@Path("/rack/{rackId}/freeze")
@Operation(summary = "Freeze a specific rack")
public Response freezeRack(
  @Context HttpServletRequest requestContext,
  @Parameter(hidden = true) @Auth SingularityUser user,
  @Parameter(required = true, description = "Rack ID") @PathParam(
    "rackId"
  ) String rackId,
  @RequestBody(
    description = "Settings related to changing the state of a slave"
  ) SingularityMachineChangeRequest changeRequest
) {
  return maybeProxyToLeader(
    requestContext,
    Response.class,
    changeRequest,
    () -> {
      final Optional<SingularityMachineChangeRequest> maybeChangeRequest = Optional.ofNullable(
        changeRequest
      );
      super.freeze(rackId, maybeChangeRequest, user, SingularityAction.FREEZE_RACK);
      return Response.ok().build();
    }
  );
}
 
Example #14
Source File: RequestResource.java    From Singularity with Apache License 2.0 6 votes vote down vote up
@POST
@Path("/request/{requestId}/bounce")
@Consumes({ MediaType.APPLICATION_JSON })
@Operation(
  summary = "Bounce a specific Singularity request. A bounce launches replacement task(s), and then kills the original task(s) if the replacement(s) are healthy"
)
public SingularityRequestParent bounce(
  @Parameter(hidden = true) @Auth SingularityUser user,
  @Parameter(required = true, description = "The request ID to bounce") @PathParam(
    "requestId"
  ) String requestId,
  @Context HttpServletRequest requestContext,
  @RequestBody(
    description = "Bounce request options"
  ) SingularityBounceRequest bounceRequest
) {
  final Optional<SingularityBounceRequest> maybeBounceRequest = Optional.ofNullable(
    bounceRequest
  );
  return maybeProxyToLeader(
    requestContext,
    SingularityRequestParent.class,
    maybeBounceRequest.orElse(null),
    () -> bounce(requestId, maybeBounceRequest, user)
  );
}
 
Example #15
Source File: RequestResource.java    From Singularity with Apache License 2.0 6 votes vote down vote up
@Deprecated
@PUT
@Path("/request/{requestId}/skipHealthchecks")
@Consumes({ MediaType.APPLICATION_JSON })
@Operation(
  summary = "Update the skipHealthchecks field for the request, possibly temporarily",
  responses = {
    @ApiResponse(responseCode = "404", description = "No Request with that ID")
  }
)
public SingularityRequestParent skipHealthchecksDeprecated(
  @Parameter(hidden = true) @Auth SingularityUser user,
  @Parameter(required = true, description = "The Request ID to scale") @PathParam(
    "requestId"
  ) String requestId,
  @Context HttpServletRequest requestContext,
  @RequestBody(
    description = "SkipHealtchecks options"
  ) SingularitySkipHealthchecksRequest skipHealthchecksRequest
) {
  return skipHealthchecks(user, requestId, requestContext, skipHealthchecksRequest);
}
 
Example #16
Source File: NotificationsResource.java    From Singularity with Apache License 2.0 6 votes vote down vote up
@POST
@Path("/unsubscribe")
@Operation(summary = "Unsubscribe from Singularity emails.")
public void unsubscribe(
  @Parameter(hidden = true) @Auth SingularityUser user,
  @RequestBody(
    required = true,
    description = "The email address to unsubscribe"
  ) String email,
  @Context HttpServletRequest requestContext
) {
  maybeProxyToLeader(
    requestContext,
    Void.class,
    email,
    () -> {
      notificationsManager.addToBlacklist(getFormattedEmail(email));
      return null;
    }
  );
}
 
Example #17
Source File: NotificationsResource.java    From Singularity with Apache License 2.0 6 votes vote down vote up
@POST
@Path("/subscribe")
@Operation(summary = "Delete an unsubscription for an email address")
public void subscribe(
  @Parameter(hidden = true) @Auth SingularityUser user,
  @RequestBody(
    required = true,
    description = "The email address to re-subscribe"
  ) String email,
  @Context HttpServletRequest requestContext
) {
  maybeProxyToLeader(
    requestContext,
    Void.class,
    email,
    () -> {
      notificationsManager.removeFromBlacklist(getFormattedEmail(email));
      return null;
    }
  );
}
 
Example #18
Source File: AnnotationProcessorTest.java    From servicecomb-toolkit with Apache License 2.0 6 votes vote down vote up
@Test
public void processRequestBodyAnnotation() throws NoSuchMethodException {

  OasContext oasContext = new OasContext(null);
  RequestBodyParamAnnotationProcessor operationMethodAnnotationProcessor = new RequestBodyParamAnnotationProcessor();

  RequestBody requestBody = Mockito.mock(RequestBody.class);
  Mockito.when(requestBody.content()).thenReturn(new Content[] {Mockito.mock(Content.class)});
  Mockito.when(requestBody.ref()).thenReturn("#components/string");

  Method helloMethod = OpenapiDef.class.getDeclaredMethod("hello", String.class, Object.class);
  OperationContext operationContext = new OperationContext(helloMethod, oasContext);
  ParameterContext parameterContext = new ParameterContext(operationContext, null);
  operationMethodAnnotationProcessor.process(requestBody, parameterContext);

  Assert.assertTrue(parameterContext.isRequestBody());
}
 
Example #19
Source File: TaskResource.java    From Singularity with Apache License 2.0 5 votes vote down vote up
@DELETE
@Path("/task/{taskId}")
@Consumes({ MediaType.APPLICATION_JSON })
@Operation(
  summary = "Attempt to kill task, optionally overriding an existing cleanup request (that may be waiting for replacement tasks to become healthy)",
  responses = {
    @ApiResponse(
      responseCode = "200",
      description = "Returns the cleanup created to trigger a task kill"
    ),
    @ApiResponse(
      responseCode = "409",
      description = "Task already has a cleanup request (can be overridden with override=true)"
    )
  }
)
public SingularityTaskCleanup killTask(
  @Parameter(description = "Id of the task to kill") @PathParam("taskId") String taskId,
  @Context HttpServletRequest requestContext,
  @RequestBody(
    description = "Overrides related to how the task kill is performed"
  ) SingularityKillTaskRequest killTaskRequest,
  @Parameter(hidden = true) @Auth SingularityUser user
) {
  final Optional<SingularityKillTaskRequest> maybeKillTaskRequest = Optional.ofNullable(
    killTaskRequest
  );
  return maybeProxyToLeader(
    requestContext,
    SingularityTaskCleanup.class,
    maybeKillTaskRequest.orElse(null),
    () -> killTask(taskId, maybeKillTaskRequest, user)
  );
}
 
Example #20
Source File: RequestResource.java    From Singularity with Apache License 2.0 5 votes vote down vote up
@POST
@Consumes({ MediaType.APPLICATION_JSON })
@Operation(
  summary = "Create or update a Singularity Request",
  responses = {
    @ApiResponse(responseCode = "400", description = "Request object is invalid"),
    @ApiResponse(
      responseCode = "409",
      description = "Request object is being cleaned. Try again shortly"
    )
  }
)
public SingularityRequestParent postRequest(
  @Parameter(hidden = true) @Auth SingularityUser user,
  @Context HttpServletRequest requestContext,
  @RequestBody(
    required = true,
    description = "The Singularity request to create or update"
  ) SingularityRequest request
) {
  return maybeProxyToLeader(
    requestContext,
    SingularityRequestParent.class,
    request,
    () -> postRequest(request, user)
  );
}
 
Example #21
Source File: RackResource.java    From Singularity with Apache License 2.0 5 votes vote down vote up
@POST
@Path("/rack/{rackId}/activate")
@Operation(
  summary = "Activate a decomissioning rack, canceling decomission without erasing history"
)
public Response activateRack(
  @Context HttpServletRequest requestContext,
  @Parameter(hidden = true) @Auth SingularityUser user,
  @Parameter(required = true, description = "Rack ID") @PathParam(
    "rackId"
  ) String rackId,
  @RequestBody(
    description = "Settings related to changing the state of a slave"
  ) SingularityMachineChangeRequest changeRequest
) {
  return maybeProxyToLeader(
    requestContext,
    Response.class,
    changeRequest,
    () -> {
      final Optional<SingularityMachineChangeRequest> maybeChangeRequest = Optional.ofNullable(
        changeRequest
      );
      super.activate(rackId, maybeChangeRequest, user, SingularityAction.ACTIVATE_RACK);
      return Response.ok().build();
    }
  );
}
 
Example #22
Source File: RequestResource.java    From Singularity with Apache License 2.0 5 votes vote down vote up
@POST
@Path("/request/{requestId}/groups")
@Operation(
  summary = "Update the group, readOnlyGroups, and readWriteGroups for a SingularityRequest",
  responses = {
    @ApiResponse(responseCode = "400", description = "Request object is invalid"),
    @ApiResponse(
      responseCode = "401",
      description = "User is not authorized to make these updates"
    )
  }
)
public SingularityRequestParent updateAuthorizedGroups(
  @Parameter(hidden = true) @Auth SingularityUser user,
  @Parameter(
    required = true,
    description = "The id of the request to update"
  ) @PathParam("requestId") String requestId,
  @Context HttpServletRequest requestContext,
  @RequestBody(
    required = true,
    description = "Updated group settings"
  ) SingularityUpdateGroupsRequest updateGroupsRequest
) {
  return maybeProxyToLeader(
    requestContext,
    SingularityRequestParent.class,
    updateGroupsRequest,
    () -> updateAuthorizedGroups(user, requestId, updateGroupsRequest)
  );
}
 
Example #23
Source File: RackResource.java    From Singularity with Apache License 2.0 5 votes vote down vote up
@POST
@Path("/rack/{rackId}/decommission")
@Operation(summary = "Begin decommissioning a specific active rack")
public Response decommissionRack(
  @Context HttpServletRequest requestContext,
  @Parameter(hidden = true) @Auth SingularityUser user,
  @Parameter(required = true, description = "Rack ID") @PathParam(
    "rackId"
  ) String rackId,
  @RequestBody(
    description = "Settings related to changing the state of a rack"
  ) SingularityMachineChangeRequest changeRequest
) {
  return maybeProxyToLeader(
    requestContext,
    Response.class,
    changeRequest,
    () -> {
      final Optional<SingularityMachineChangeRequest> maybeChangeRequest = Optional.ofNullable(
        changeRequest
      );
      super.decommission(
        rackId,
        maybeChangeRequest,
        user,
        SingularityAction.DECOMMISSION_RACK
      );
      return Response.ok().build();
    }
  );
}
 
Example #24
Source File: PriorityResource.java    From Singularity with Apache License 2.0 5 votes vote down vote up
@POST
@Path("/freeze")
@Operation(
  summary = "Stop scheduling tasks below a certain priority level",
  responses = {
    @ApiResponse(
      responseCode = "200",
      description = "The priority freeze request was accepted"
    ),
    @ApiResponse(
      responseCode = "400",
      description = "There was a validation error with the priority freeze request"
    )
  }
)
public SingularityPriorityFreezeParent createPriorityFreeze(
  @Parameter(hidden = true) @Auth SingularityUser user,
  @RequestBody(
    description = "the new priority freeze to create"
  ) SingularityPriorityFreeze priorityFreezeRequest
) {
  authorizationHelper.checkAdminAuthorization(user);
  priorityFreezeRequest =
    singularityValidator.checkSingularityPriorityFreeze(priorityFreezeRequest);

  final SingularityPriorityFreezeParent priorityFreezeRequestParent = new SingularityPriorityFreezeParent(
    priorityFreezeRequest,
    System.currentTimeMillis(),
    user.getEmail()
  );

  priorityManager.createPriorityFreeze(priorityFreezeRequestParent);

  if (priorityFreezeRequest.isKillTasks()) {
    priorityManager.setPriorityKill();
  }

  return priorityFreezeRequestParent;
}
 
Example #25
Source File: HelloController.java    From springdoc-openapi with Apache License 2.0 5 votes vote down vote up
@PutMapping("/{itemId}")
@Operation
public ResponseEntity<Item> putItem(
		@CookieValue(
				name = "cookie"
		) String cookie,
		@PathVariable UUID itemId,
		@RequestBody Item item
) {
	return ResponseEntity.ok(item);
}
 
Example #26
Source File: RequestResource.java    From Singularity with Apache License 2.0 5 votes vote down vote up
@POST
@Path("/request/{requestId}/pause")
@Consumes({ MediaType.APPLICATION_JSON })
@Operation(
  summary = "Pause a Singularity request, future tasks will not run until it is manually unpaused. API can optionally choose to kill existing tasks",
  responses = {
    @ApiResponse(
      responseCode = "409",
      description = "Request is already paused or being cleaned"
    )
  }
)
public SingularityRequestParent pause(
  @Parameter(hidden = true) @Auth SingularityUser user,
  @Parameter(required = true, description = "The request ID to pause") @PathParam(
    "requestId"
  ) String requestId,
  @Context HttpServletRequest requestContext,
  @RequestBody(
    description = "Pause Request Options"
  ) SingularityPauseRequest pauseRequest
) {
  final Optional<SingularityPauseRequest> maybePauseRequest = Optional.ofNullable(
    pauseRequest
  );
  return maybeProxyToLeader(
    requestContext,
    SingularityRequestParent.class,
    maybePauseRequest.orElse(null),
    () -> pause(requestId, maybePauseRequest, user)
  );
}
 
Example #27
Source File: RequestResource.java    From Singularity with Apache License 2.0 5 votes vote down vote up
@POST
@Path("/request/{requestId}/unpause")
@Consumes({ MediaType.APPLICATION_JSON })
@Operation(
  summary = "Unpause a Singularity Request, scheduling new tasks immediately",
  responses = {
    @ApiResponse(responseCode = "409", description = "Request is not paused")
  }
)
public SingularityRequestParent unpause(
  @Parameter(hidden = true) @Auth SingularityUser user,
  @Parameter(required = true, description = "The request ID to unpause") @PathParam(
    "requestId"
  ) String requestId,
  @Context HttpServletRequest requestContext,
  @RequestBody(
    description = "Settings for how the unpause should behave"
  ) SingularityUnpauseRequest unpauseRequest
) {
  final Optional<SingularityUnpauseRequest> maybeUnpauseRequest = Optional.ofNullable(
    unpauseRequest
  );
  return maybeProxyToLeader(
    requestContext,
    SingularityRequestParent.class,
    maybeUnpauseRequest.orElse(null),
    () -> unpause(requestId, maybeUnpauseRequest, user)
  );
}
 
Example #28
Source File: HelloController.java    From springdoc-openapi with Apache License 2.0 5 votes vote down vote up
@PostMapping(value = "/test/103", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
@Operation(
		requestBody = @RequestBody(
				content = @Content(
						encoding = @Encoding(name = "body", contentType = "application/json")
				)
		)
)
public String postMyRequestBody(
		@RequestPart("body") ExampleBody body,
		@RequestParam("file") MultipartFile file
) {
	return null;
}
 
Example #29
Source File: RequestResource.java    From Singularity with Apache License 2.0 5 votes vote down vote up
@POST
@Path("/request/{requestId}/exit-cooldown")
@Consumes({ MediaType.APPLICATION_JSON })
@Operation(
  summary = "Immediately exits cooldown, scheduling new tasks immediately",
  responses = {
    @ApiResponse(responseCode = "409", description = "Request is not in cooldown")
  }
)
public SingularityRequestParent exitCooldown(
  @Parameter(hidden = true) @Auth SingularityUser user,
  @Parameter(required = true, description = "The request to operate on") @PathParam(
    "requestId"
  ) String requestId,
  @Context HttpServletRequest requestContext,
  @RequestBody(
    description = "Settings related to how an exit cooldown should behave"
  ) SingularityExitCooldownRequest exitCooldownRequest
) {
  final Optional<SingularityExitCooldownRequest> maybeExitCooldownRequest = Optional.ofNullable(
    exitCooldownRequest
  );
  return maybeProxyToLeader(
    requestContext,
    SingularityRequestParent.class,
    maybeExitCooldownRequest.orElse(null),
    () -> exitCooldown(requestId, maybeExitCooldownRequest, user)
  );
}
 
Example #30
Source File: RequestResource.java    From Singularity with Apache License 2.0 5 votes vote down vote up
@PUT
@Path("/request/{requestId}/scale")
@Consumes({ MediaType.APPLICATION_JSON })
@Operation(
  summary = "Scale the number of instances up or down for a specific Request",
  responses = {
    @ApiResponse(responseCode = "404", description = "No Request with that ID")
  }
)
public SingularityRequestParent scale(
  @Parameter(hidden = true) @Auth SingularityUser user,
  @Parameter(required = true, description = "The Request ID to scale") @PathParam(
    "requestId"
  ) String requestId,
  @Context HttpServletRequest requestContext,
  @RequestBody(
    required = true,
    description = "Object to hold number of instances to request"
  ) SingularityScaleRequest scaleRequest
) {
  return maybeProxyToLeader(
    requestContext,
    SingularityRequestParent.class,
    scaleRequest,
    () -> scale(requestId, scaleRequest, user)
  );
}