org.springframework.web.bind.annotation.RequestHeader Java Examples

The following examples show how to use org.springframework.web.bind.annotation.RequestHeader. 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: PetApi.java    From openapi-generator with Apache License 2.0 6 votes vote down vote up
/**
 * DELETE /pet/{petId} : Deletes a pet
 *
 * @param petId Pet id to delete (required)
 * @param apiKey  (optional)
 * @return successful operation (status code 200)
 *         or Invalid pet value (status code 400)
 */
@ApiOperation(value = "Deletes a pet", nickname = "deletePet", notes = "", authorizations = {
    @Authorization(value = "petstore_auth", scopes = {
        @AuthorizationScope(scope = "write:pets", description = "modify pets in your account"),
        @AuthorizationScope(scope = "read:pets", description = "read your pets")
        })
}, tags={ "pet", })
@ApiResponses(value = { 
    @ApiResponse(code = 200, message = "successful operation"),
    @ApiResponse(code = 400, message = "Invalid pet value") })
@RequestMapping(value = "/pet/{petId}",
    method = RequestMethod.DELETE)
default ResponseEntity<Void> deletePet(@ApiParam(value = "Pet id to delete",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "" ) @RequestHeader(value="api_key", required=false) Optional<String> apiKey) {
    return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);

}
 
Example #2
Source File: RestNetworkServiceDescriptor.java    From NFVO with Apache License 2.0 6 votes vote down vote up
/**
 * This operation updates the Network Service Descriptor (NSD)
 *
 * @param networkServiceDescriptor : the Network Service Descriptor to be updated
 * @param id : the id of Network Service Descriptor
 * @return networkServiceDescriptor: the Network Service Descriptor updated
 */
@ApiOperation(
    value = "Update a Network Service Descriptor",
    notes =
        "Takes a Network Service Descriptor and updates the Descriptor with the id provided in the URL with the Descriptor from the request body")
@RequestMapping(
    value = "{id}",
    method = RequestMethod.PUT,
    consumes = MediaType.APPLICATION_JSON_VALUE,
    produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseStatus(HttpStatus.ACCEPTED)
public NetworkServiceDescriptor update(
    @RequestBody @Valid NetworkServiceDescriptor networkServiceDescriptor,
    @PathVariable("id") String id,
    @RequestHeader(value = "project-id") String projectId)
    throws NotFoundException, BadRequestException {
  return networkServiceDescriptorManagement.update(networkServiceDescriptor, projectId);
}
 
Example #3
Source File: StripePaymentWebhookController.java    From alf.io with GNU General Public License v3.0 6 votes vote down vote up
@PostMapping("/api/payment/webhook/stripe/payment")
public ResponseEntity<String> receivePaymentConfirmation(@RequestHeader(value = "Stripe-Signature") String stripeSignature,
                                                       HttpServletRequest request) {
    return RequestUtils.readRequest(request)
        .map(content -> {
            var result = ticketReservationManager.processTransactionWebhook(content, stripeSignature, PaymentProxy.STRIPE, Map.of());
            if(result.isSuccessful()) {
                return ResponseEntity.ok("OK");
            } else if(result.isError()) {
                return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(result.getReason());
            }
            return ResponseEntity.ok(result.getReason());
        })
        .orElseGet(() -> ResponseEntity.badRequest().body("NOK"));

}
 
Example #4
Source File: CmDjMergeController.java    From oneops with Apache License 2.0 6 votes vote down vote up
@RequestMapping(method=RequestMethod.PUT, value="/dj/simple/cis/{ciId}")
@ResponseBody
public CmsRfcCISimple updateRfcCi(@PathVariable long ciId, 
								  @RequestBody CmsRfcCISimple rfcSimple,
								  @RequestHeader(value="X-Cms-User", required = false)  String userId,
								  @RequestHeader(value="X-Cms-Scope", required = false)  String scope) throws DJException {

	
	scopeVerifier.verifyScope(scope, rfcSimple);
	
	rfcSimple.setCiId(ciId);
	CmsRfcCI rfc = cmsUtil.custRfcCISimple2RfcCI(rfcSimple);
	String[] attrProps = null; 
	if (rfcSimple.getCiAttrProps().size() >0) {
		attrProps = rfcSimple.getCiAttrProps().keySet().toArray(new String[rfcSimple.getCiAttrProps().size()]);
	}
	rfc.setUpdatedBy(userId);
	return cmsUtil.custRfcCI2RfcCISimple(cmdjManager.upsertCiRfc(rfc, userId), attrProps);
}
 
Example #5
Source File: RestNetworkServiceRecord.java    From NFVO with Apache License 2.0 6 votes vote down vote up
@ApiOperation(value = "Stop a VNFC instance", notes = "Stops the specified VNFC Instance")
@RequestMapping(
    value = "{id}/vnfrecords/{idVnf}/vdunits/{idVdu}/vnfcinstances/{idVNFCI}/stop",
    method = RequestMethod.POST,
    consumes = MediaType.APPLICATION_JSON_VALUE)
@ResponseStatus(HttpStatus.CREATED)
public void stopVNFCInstance(
    @PathVariable("id") String id,
    @PathVariable("idVnf") String idVnf,
    @PathVariable("idVdu") String idVdu,
    @PathVariable("idVNFCI") String idVNFCI,
    @RequestHeader(value = "project-id") String projectId)
    throws NotFoundException, BadFormatException, ExecutionException, InterruptedException {
  log.debug("stop a VNF component instance");
  networkServiceRecordManagement.stopVNFCInstance(id, idVnf, idVdu, idVNFCI, projectId);
}
 
Example #6
Source File: DpmtRestController.java    From oneops with Apache License 2.0 6 votes vote down vote up
@RequestMapping(value="/dj/simple/deployments/count", method = RequestMethod.GET)
@ResponseBody
public Map<String, Long> countDeployment(
		@RequestParam(value="nsPath", required = true) String nsPath,  
		@RequestParam(value="deploymentState", required = false) String state,
		@RequestParam(value="recursive", required = false) Boolean recursive,
		@RequestParam(value="groupBy", required = false) String groupBy,
		@RequestHeader(value="X-Cms-Scope", required = false)  String scope){
	
	if (groupBy != null) {
		return djManager.countDeploymentGroupByNsPath(nsPath, state);
	} else{
 		long count =  djManager.countDeployments(nsPath, state, recursive);
 		Map<String, Long> result = new HashMap<>();
 		result.put("Total", count);
 		return result;
	}
}
 
Example #7
Source File: ApplicationShutdownResource.java    From multiapps-controller with Apache License 2.0 6 votes vote down vote up
@PostMapping(produces = { MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_JSON_UTF8_VALUE })
public ApplicationShutdown
       shutdownFlowableJobExecutor(@RequestHeader(name = "x-cf-applicationid", required = false) String applicationId,
                                   @RequestHeader(name = "x-cf-instanceid", required = false) String applicationInstanceId,
                                   @RequestHeader(name = "x-cf-instanceindex", required = false) String applicationInstanceIndex) {

    CompletableFuture.runAsync(() -> {
        LOGGER.info(MessageFormat.format(Messages.APP_SHUTDOWN_REQUEST, applicationId, applicationInstanceId,
                                         applicationInstanceIndex));
        flowableFacade.shutdownJobExecutor();
    })
                     .thenRun(() -> LOGGER.info(MessageFormat.format(Messages.APP_SHUTDOWNED, applicationId, applicationInstanceId,
                                                                     applicationInstanceIndex)));

    return ImmutableApplicationShutdown.builder()
                                       .status(getShutdownStatus())
                                       .applicationInstanceIndex(Integer.parseInt(applicationInstanceIndex))
                                       .applicationId(applicationId)
                                       .applicationInstanceId(applicationInstanceId)
                                       .build();
}
 
Example #8
Source File: DpmtRestController.java    From oneops with Apache License 2.0 6 votes vote down vote up
@RequestMapping(value="/dj/simple/approvals", method = RequestMethod.PUT)
@ResponseBody
public List<CmsDpmtApproval> dpmtApprove(
		@RequestBody CmsDpmtApproval[] approvals,
		@RequestHeader(value="X-Cms-Scope", required = false)  String scope,
		@RequestHeader(value="X-Cms-User", required = true)  String userId,
		@RequestHeader(value="X-Approval-Token", required = false) String approvalToken
){
	
	List<CmsDpmtApproval> toApprove = new ArrayList<>();
	for (CmsDpmtApproval approval : approvals) {
		approval.setUpdatedBy(userId);
		toApprove.add(approval);
	}
    return djManager.updateApprovalList(toApprove, approvalToken);
}
 
Example #9
Source File: HomeController.java    From sophia_scaffolding with Apache License 2.0 6 votes vote down vote up
/**
 * 清除token(注销登录)
 */
@SysLog("登出")
@DeleteMapping("/logout")
@ApiOperation(value = "登出")
public ApiResponse logout(@RequestHeader(value = HttpHeaders.AUTHORIZATION, required = false) String authHeader) {
    if (StringUtils.isBlank(authHeader)) {
        return fail("退出失败,token 为空");
    }
    //注销当前用户
    String tokenValue = authHeader.replace(OAuth2AccessToken.BEARER_TYPE, StringUtils.EMPTY).trim();
    OAuth2AccessToken accessToken = tokenStore.readAccessToken(tokenValue);
    tokenStore.removeAccessToken(accessToken);
    OAuth2RefreshToken refreshToken = accessToken.getRefreshToken();
    tokenStore.removeRefreshToken(refreshToken);
    return success("注销成功");
}
 
Example #10
Source File: CmRestController.java    From oneops with Apache License 2.0 6 votes vote down vote up
@RequestMapping(value="/cm/relations/{relId}", method = RequestMethod.GET)
@ResponseBody
@ReadOnlyDataAccess
public CmsCIRelation getRelationById(
		@PathVariable long relId,
		@RequestHeader(value="X-Cms-Scope", required = false)  String scope) {

	CmsCIRelation rel = cmManager.getRelationById(relId);

	if (rel == null) throw new CmsException(CmsError.CMS_NO_RELATION_WITH_GIVEN_ID_ERROR,
                                                   "There is no relation with this id");

	scopeVerifier.verifyScope(scope, rel);
	
	return rel;
}
 
Example #11
Source File: AuthController.java    From secure-data-service with Apache License 2.0 6 votes vote down vote up
@RequestMapping(value = "token", method = { RequestMethod.POST, RequestMethod.GET })
public ResponseEntity<String> getAccessToken(@RequestParam("code") String authorizationCode,
        @RequestParam("redirect_uri") String redirectUri,
        @RequestHeader(value = "Authorization", required = false) String authz,
        @RequestParam("client_id") String clientId, @RequestParam("client_secret") String clientSecret, Model model)
        throws BadCredentialsException {
    Map<String, String> parameters = new HashMap<String, String>();
    parameters.put("code", authorizationCode);
    parameters.put("redirect_uri", redirectUri);

    String token;
    try {
        token = this.sessionManager.verify(authorizationCode, Pair.of(clientId, clientSecret));
    } catch (OAuthAccessException e) {
        return handleAccessException(e);
    }

    HttpHeaders headers = new HttpHeaders();
    headers.set("Cache-Control", "no-store");
    headers.setContentType(MediaType.APPLICATION_JSON);

    String response = String.format("{\"access_token\":\"%s\"}", token);

    return new ResponseEntity<String>(response, headers, HttpStatus.OK);
}
 
Example #12
Source File: EntityDataController.java    From restfiddle with Apache License 2.0 6 votes vote down vote up
@RequestMapping(value = "/api/{projectId}/entities/{name}/{uuid}", method = RequestMethod.DELETE, headers = "Accept=application/json")
   public @ResponseBody
   StatusResponse deleteEntityData(@PathVariable("projectId") String projectId, @PathVariable("name") String entityName,
    @PathVariable("uuid") String uuid,
    @RequestHeader(value = "authToken", required = false) String authToken) {


StatusResponse res = new StatusResponse();

JSONObject authRes = authService.authorize(projectId,authToken,"USER");
if(!authRes.getBoolean(SUCCESS)){
    res.setStatus("Unauthorized");
    return res;
}

DBCollection dbCollection = mongoTemplate.getCollection(projectId+"_"+entityName);
BasicDBObject queryObject = new BasicDBObject();
queryObject.append("_id", new ObjectId(uuid));
dbCollection.remove(queryObject);


res.setStatus("DELETED");

return res;
   }
 
Example #13
Source File: ApplicationController.java    From steady with Apache License 2.0 6 votes vote down vote up
/**
 * <p>isApplicationExisting.</p>
 *
 * @return 404 {@link HttpStatus#NOT_FOUND} if application with given GAV does not exist, 200 {@link HttpStatus#OK} if the application is found
 * @param mvnGroup a {@link java.lang.String} object.
 * @param artifact a {@link java.lang.String} object.
 * @param version a {@link java.lang.String} object.
 * @param space a {@link java.lang.String} object.
 */
@RequestMapping(value = "/{mvnGroup:.+}/{artifact:.+}/{version:.+}", method = RequestMethod.OPTIONS)
public ResponseEntity<Application> isApplicationExisting(
		@PathVariable String mvnGroup, @PathVariable String artifact, @PathVariable String version,
		@ApiIgnore @RequestHeader(value=Constants.HTTP_SPACE_HEADER, required=false) String space) {

	Space s = null;
	try {
		s = this.spaceRepository.getSpace(space);
	} catch (Exception e){
		log.error("Error retrieving space: " + e);
		return new ResponseEntity<Application>(HttpStatus.NOT_FOUND);
	}

	try {
		ApplicationRepository.FILTER.findOne(this.appRepository.findByGAV(mvnGroup, artifact, version, s));
		return new ResponseEntity<Application>(HttpStatus.OK);
	}
	catch(EntityNotFoundException enfe) {
		return new ResponseEntity<Application>(HttpStatus.NOT_FOUND);
	}
}
 
Example #14
Source File: RemoteAccessApiController.java    From swaggy-jenkins with MIT License 5 votes vote down vote up
public ResponseEntity<Void> postCreateView(@ApiParam(value = "Name of the new view", required = true)  @RequestParam(value = "name", required = true) String name,
    @ApiParam(value = "CSRF protection token" ) @RequestHeader(value="Jenkins-Crumb", required=false) String jenkinsCrumb,
    @ApiParam(value = "Content type header application/xml" ) @RequestHeader(value="Content-Type", required=false) String contentType,
    @ApiParam(value = "View configuration in config.xml format"  )   @RequestBody String body,
    @RequestHeader(value = "Accept", required = false) String accept) throws Exception {
    // do some magic!
    return new ResponseEntity<Void>(HttpStatus.OK);
}
 
Example #15
Source File: DpmtRestController.java    From oneops with Apache License 2.0 5 votes vote down vote up
@RequestMapping(value="/dj/simple/approvals", method = RequestMethod.GET)
@ResponseBody
public List<CmsDpmtApproval> getDeploymentApprovals(
		@RequestParam(value="deploymentId", required = true) long dpmtId,
		@RequestHeader(value="X-Cms-Scope", required = false)  String scope,
		@RequestHeader(value="X-Cms-User", required = false)  String userId){
	
	CmsDeployment dpmt = djManager.getDeployment(dpmtId);
	if (dpmt == null) throw new DJException(CmsError.DJ_NO_DEPLOYMENT_WITH_GIVEN_ID_ERROR,
                               "There is no deployment with this id");
	scopeVerifier.verifyScope(scope, dpmt);
	
	return djManager.getDeploymentApprovals(dpmtId);
}
 
Example #16
Source File: ServletAnnotationControllerHandlerMethodTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@RequestMapping("/map")
public void map(@RequestHeader Map<String, String> headers, Writer writer) throws IOException {
	for (Iterator<Map.Entry<String, String>> it = headers.entrySet().iterator(); it.hasNext();) {
		Map.Entry<String, String> entry = it.next();
		writer.write(entry.getKey() + "=" + entry.getValue());
		if (it.hasNext()) {
			writer.write(',');
		}

	}
}
 
Example #17
Source File: RestNetworkServiceDescriptor.java    From NFVO with Apache License 2.0 5 votes vote down vote up
@ApiOperation(
    value = "Delete VNF Dependency from a VNF part of the NSD",
    notes = "Delete the VNF Dependency only for a specific VNF specified in the NSD")
@RequestMapping(value = "{idNsd}/vnfdependencies/{idVnfd}", method = RequestMethod.DELETE)
@ResponseStatus(HttpStatus.NO_CONTENT)
public void deleteVNFDependency(
    @PathVariable("idNsd") String idNsd,
    @PathVariable("idVnfd") String idVnfd,
    @RequestHeader(value = "project-id") String projectId)
    throws NotFoundException {
  networkServiceDescriptorManagement.deleteVNFDependency(idNsd, idVnfd, projectId);
}
 
Example #18
Source File: SpringRequestHeaderParameterParser.java    From RestDoc with Apache License 2.0 5 votes vote down vote up
@Override
protected String getParameterName(Parameter parameter) {
    var paramName = super.getParameterName(parameter);

    var requestParamAnno = AnnotatedElementUtils.getMergedAnnotation(parameter, RequestHeader.class);
    if (requestParamAnno != null && !StringUtils.isEmpty(requestParamAnno.name()))
    {
        return requestParamAnno.name();
    }
    return paramName;
}
 
Example #19
Source File: MobileOrganisationUnitController.java    From dhis2-core with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@RequestMapping( method = RequestMethod.GET, value = "{clientVersion}/orgUnits/{id}/downloadInterpretation" )
@ResponseBody
public Interpretation downloadInterpretation( String clientVersion, @PathVariable int id,
    @RequestHeader( "uId" ) String uId )
    throws NotAllowedException
{
    Interpretation interpretation = activityReportingService.getInterpretation( uId );
    return interpretation;
}
 
Example #20
Source File: PetApi.java    From openapi-generator with Apache License 2.0 5 votes vote down vote up
@ApiOperation(value = "Finds Pets by status", notes = "Multiple status values can be provided with comma separated strings", response = Pet.class, responseContainer = "List", authorizations = {
    @Authorization(value = "petstore_auth", scopes = {
        @AuthorizationScope(scope = "write:pets", description = "modify pets in your account"),
        @AuthorizationScope(scope = "read:pets", description = "read your pets")
        })
}, tags={ "pet", })
@ApiResponses(value = { 
    @ApiResponse(code = 200, message = "successful operation", response = Pet.class, responseContainer = "List"),
    @ApiResponse(code = 400, message = "Invalid status value") })
@RequestMapping(value = "/pet/findByStatus",
    produces = { "application/xml", "application/json" }, 
    method = RequestMethod.GET)
ResponseEntity<List<Pet>> findPetsByStatus(@ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold", defaultValue = "new ArrayList<>()")  @RequestParam(value = "status", required = true, defaultValue="new ArrayList<>()") List<String> status, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
 
Example #21
Source File: RestComponents.java    From NFVO with Apache License 2.0 5 votes vote down vote up
/** Delete a new Service. */
@ApiOperation(value = "Delete Service", notes = "Remove a specific service")
@RequestMapping(
    value = "/services/{id}",
    method = RequestMethod.DELETE,
    produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseStatus(HttpStatus.OK)
@PreAuthorize("hasAnyRole('ROLE_ADMIN')")
public void deleteService(
    @RequestHeader(value = "project-id") String projectId, @PathVariable("id") String id) {
  log.debug("id is " + id);
  componentManager.removeService(id);
}
 
Example #22
Source File: EncryptionController.java    From spring-cloud-config with Apache License 2.0 5 votes vote down vote up
@RequestMapping(value = "/encrypt/{name}/{profiles}", method = RequestMethod.POST)
public String encrypt(@PathVariable String name, @PathVariable String profiles,
		@RequestBody String data, @RequestHeader("Content-Type") MediaType type) {
	TextEncryptor encryptor = getEncryptor(name, profiles, "");
	validateEncryptionWeakness(encryptor);
	String input = stripFormData(data, type, false);
	Map<String, String> keys = helper.getEncryptorKeys(name, profiles, input);
	String textToEncrypt = helper.stripPrefix(input);
	String encrypted = helper.addPrefix(keys,
			encryptorLocator.locate(keys).encrypt(textToEncrypt));
	logger.info("Encrypted data");
	return encrypted;
}
 
Example #23
Source File: BlueOceanApi.java    From swaggy-jenkins with MIT License 5 votes vote down vote up
@ApiOperation(value = "", notes = "Search for any resource details", response = String.class, authorizations = {
    @Authorization(value = "jenkins_auth")
}, tags={ "blueOcean", })
@ApiResponses(value = { 
    @ApiResponse(code = 200, message = "Successfully retrieved search result", response = String.class),
    @ApiResponse(code = 401, message = "Authentication failed - incorrect username and/or password"),
    @ApiResponse(code = 403, message = "Jenkins requires authentication - please set username and password") })
@RequestMapping(value = "/blue/rest/search/",
    produces = { "application/json" }, 
    method = RequestMethod.GET)
ResponseEntity<String> search(@ApiParam(value = "Query string", required = true)  @RequestParam(value = "q", required = true) String q, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
 
Example #24
Source File: AuthenticationController.java    From iot-device-bosch-indego-controller with Apache License 2.0 5 votes vote down vote up
@RequestMapping(method = RequestMethod.POST)
@ResponseBody
public ResponseEntity<AuthenticationResponse> login(
        @RequestBody AuthenticationRequest request, 
        @RequestHeader(IndegoWebConstants.HEADER_AUTHORIZATION) String authorization) 
                throws IndegoServiceException
{
    if ( authorization == null || !authorization.startsWith("Basic ") ) {
        return new ResponseEntity<>(HttpStatus.UNAUTHORIZED);
    }
    
    byte[] userPassBytes = Base64.getDecoder().decode(authorization.substring(6).trim());
    String[] userPass = new String(userPassBytes).split(":");
    String username = userPass.length > 0 ? userPass[0] : "";
    String password = userPass.length > 1 ? userPass[1] : "";
    
    String userId = srvAuthentication.authenticate(username, password); 
    if ( userId == null ) {
        return new ResponseEntity<>(HttpStatus.UNAUTHORIZED);
    }
    
    IndegoContext context = srvContextHandler.createContextForUser(userId);
    
    AuthenticationResponse result = new AuthenticationResponse();
    result.setAlmSn(context.getDeviceSerial());
    result.setContextId(context.getContext());
    result.setUserId(context.getUserId());
    return new ResponseEntity<AuthenticationResponse>(result, HttpStatus.OK);
}
 
Example #25
Source File: LoginController.java    From SpringBootBucket with MIT License 5 votes vote down vote up
@PostMapping("/login")
public BaseResponse<String> login(@RequestHeader(name = "Content-Type", defaultValue = "application/json") String contentType,
                                  @RequestBody LoginParam loginParam) {
    _logger.info("用户请求登录获取Token");
    String username = loginParam.getUsername();
    String password = loginParam.getPassword();
    return new BaseResponse<>(true, "Login success", username + password);
}
 
Example #26
Source File: RestNetworkServiceRecord.java    From NFVO with Apache License 2.0 5 votes vote down vote up
/**
 * This operation is used to resume a failed Network Service Record
 *
 * @param id : the id of Network Service Record
 */
@ApiOperation(
    value = "Resume a failed Network Service Record",
    notes =
        "Resumes a NSR that failed while executing a script in a VNFR. The id in the URL specifies the Network Service Record that will be resumed.")
@RequestMapping(value = "{id}/resume", method = RequestMethod.POST)
@ResponseStatus(HttpStatus.NO_CONTENT)
public void resume(
    @PathVariable("id") String id, @RequestHeader(value = "project-id") String projectId)
    throws InterruptedException, ExecutionException, NotFoundException, BadFormatException {
  networkServiceRecordManagement.resume(id, projectId);
}
 
Example #27
Source File: RestKeys.java    From NFVO with Apache License 2.0 5 votes vote down vote up
@ApiOperation(
    value = "Remove multiple Keys",
    notes = "The ids of the Keys is passed in a list in the Request Body")
@RequestMapping(
    value = "/multipledelete",
    method = RequestMethod.POST,
    consumes = MediaType.APPLICATION_JSON_VALUE)
@ResponseStatus(HttpStatus.NO_CONTENT)
public void multipleDelete(
    @RequestHeader(value = "project-id") String projectId, @RequestBody @Valid List<String> ids)
    throws NotFoundException {
  for (String id : ids) {
    keyManagement.delete(projectId, id);
  }
}
 
Example #28
Source File: UserApi.java    From openapi-generator with Apache License 2.0 5 votes vote down vote up
@ApiOperation(value = "Get user by user name", notes = "", response = User.class, tags={ "user", })
@ApiResponses(value = { 
    @ApiResponse(code = 200, message = "successful operation", response = User.class),
    @ApiResponse(code = 400, message = "Invalid username supplied"),
    @ApiResponse(code = 404, message = "User not found") })
@RequestMapping(value = "/user/{username}",
    produces = { "application/xml", "application/json" }, 
    method = RequestMethod.GET)
ResponseEntity<User> getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing.",required=true ) @PathVariable("username") String username, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
 
Example #29
Source File: CatalogRestController.java    From oneops with Apache License 2.0 5 votes vote down vote up
@RequestMapping(value="/catalogs/{catalogId}/assemblies", method = RequestMethod.POST)
@ResponseBody
public Map<String,Long> createAssemblyFromCatalog(
		@PathVariable long catalogId,
		@RequestBody CmsCISimple targetCISimple,
		@RequestHeader(value="X-Cms-User", required = false)  String userId,
		@RequestHeader(value="X-Cms-Scope", required = false)  String scope){

	if (userId == null) userId = "oneops-system";
	
	long startTime = System.currentTimeMillis(); 
	
	if (targetCISimple.getCiAttributes().get("description") == null) {
		targetCISimple.addCiAttribute("description", null);
	}
	
	CmsCI targetCI = util.custCISimple2CI(targetCISimple, null);
	
	long resultCiId = dManager.cloneAssembly(targetCI, catalogId, userId, scope);
	Map<String,Long> result = new HashMap<String,Long>(1); 
	result.put("resultCiId", resultCiId);

	long tookTime = System.currentTimeMillis() - startTime;
	logger.debug("Time to generate Assembly/Catalog - " + tookTime);

	return result;
}
 
Example #30
Source File: JobRestController.java    From genie with Apache License 2.0 5 votes vote down vote up
/**
 * Submit a new job.
 *
 * @param jobRequest         The job request information
 * @param clientHost         client host sending the request
 * @param userAgent          The user agent string
 * @param httpServletRequest The http servlet request
 * @return The submitted job
 * @throws GenieException        For any error
 * @throws GenieCheckedException For V4 Agent Execution errors
 */
@PostMapping(consumes = MediaType.APPLICATION_JSON_VALUE)
@ResponseStatus(HttpStatus.ACCEPTED)
public ResponseEntity<Void> submitJob(
    @Valid @RequestBody final JobRequest jobRequest,
    @RequestHeader(value = FORWARDED_FOR_HEADER, required = false) @Nullable final String clientHost,
    @RequestHeader(value = HttpHeaders.USER_AGENT, required = false) @Nullable final String userAgent,
    final HttpServletRequest httpServletRequest
) throws GenieException, GenieCheckedException {
    log.info("[submitJob] Called json method type to submit job: {}", jobRequest);
    this.submitJobWithoutAttachmentsRate.increment();
    return this.handleSubmitJob(jobRequest, null, clientHost, userAgent, httpServletRequest);
}