Search in sources :

Example 1 with ApiCommand

use of net.ripe.rpki.validator3.api.ApiCommand in project rpki-validator-3 by RIPE-NCC.

the class RoaPrefixAssertionsController method add.

@PostMapping(consumes = { Api.API_MIME_TYPE, "application/json" })
public ResponseEntity<ApiResponse<RoaPrefixAssertionResource>> add(@RequestBody @Valid ApiCommand<AddRoaPrefixAssertion> command) {
    final long id = roaPrefixAssertionsService.execute(command.getData());
    final RoaPrefixAssertion ignoreFilter = roaPrefixAssertions.get(id);
    final Link selfRel = linkTo(methodOn(RoaPrefixAssertionsController.class).get(id)).withSelfRel();
    return ResponseEntity.created(URI.create(selfRel.getHref())).body(ApiResponse.data(toResource(ignoreFilter)));
}
Also used : RoaPrefixAssertion(net.ripe.rpki.validator3.domain.RoaPrefixAssertion) Link(org.springframework.hateoas.Link) PostMapping(org.springframework.web.bind.annotation.PostMapping)

Example 2 with ApiCommand

use of net.ripe.rpki.validator3.api.ApiCommand in project rpki-validator-3 by RIPE-NCC.

the class TrustAnchorController method add.

@PostMapping(consumes = { Api.API_MIME_TYPE, "application/json" })
public ResponseEntity<ApiResponse<TrustAnchorResource>> add(@RequestBody @Valid ApiCommand<AddTrustAnchor> command, Locale locale) {
    long id = trustAnchorService.execute(command.getData());
    TrustAnchor trustAnchor = trustAnchorRepository.get(id);
    Link selfRel = linkTo(methodOn(TrustAnchorController.class).get(id, locale)).withSelfRel();
    return ResponseEntity.created(URI.create(selfRel.getHref())).body(trustAnchorResource(trustAnchor, locale));
}
Also used : TrustAnchor(net.ripe.rpki.validator3.domain.TrustAnchor) Link(org.springframework.hateoas.Link) PostMapping(org.springframework.web.bind.annotation.PostMapping)

Aggregations

Link (org.springframework.hateoas.Link)2 PostMapping (org.springframework.web.bind.annotation.PostMapping)2 RoaPrefixAssertion (net.ripe.rpki.validator3.domain.RoaPrefixAssertion)1 TrustAnchor (net.ripe.rpki.validator3.domain.TrustAnchor)1