Search in sources :

Example 1 with Delivery

use of com.netflix.spinnaker.front50.model.delivery.Delivery in project front50 by spinnaker.

the class DeliveryController method deleteConfig.

@PreAuthorize("hasPermission(#application, 'APPLICATION', 'WRITE')")
@ApiOperation(value = "", notes = "Delete a delivery config")
@RequestMapping(method = RequestMethod.DELETE, value = "/applications/{application}/deliveries/{id}")
void deleteConfig(@PathVariable String application, @PathVariable String id) {
    Delivery config = deliveryRepository.findById(id);
    if (!config.getApplication().equals(application)) {
        throw new InvalidRequestException("No config with id " + id + " found in application " + application);
    }
    deliveryRepository.delete(id);
}
Also used : InvalidRequestException(com.netflix.spinnaker.front50.exceptions.InvalidRequestException) Delivery(com.netflix.spinnaker.front50.model.delivery.Delivery) ApiOperation(io.swagger.annotations.ApiOperation) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Example 2 with Delivery

use of com.netflix.spinnaker.front50.model.delivery.Delivery in project front50 by spinnaker.

the class DeliveryController method upsertConfig.

@PreAuthorize("hasPermission(#config.application, 'APPLICATION', 'WRITE')")
@ApiOperation(value = "", notes = "Update a delivery config")
@RequestMapping(method = RequestMethod.PUT, value = "/deliveries/{id}")
Delivery upsertConfig(@PathVariable String id, @RequestBody Delivery config) {
    if (!id.equals(config.getId())) {
        throw new InvalidRequestException("URL id (" + id + ") does not match submitted id (" + config.getId() + ")");
    }
    try {
        Delivery existing = deliveryRepository.findById(id);
        config.setCreateTs(existing.getCreateTs());
    } catch (NotFoundException e) {
    // ignore because we will create config
    }
    return deliveryRepository.upsertConfig(config);
}
Also used : NotFoundException(com.netflix.spinnaker.kork.web.exceptions.NotFoundException) InvalidRequestException(com.netflix.spinnaker.front50.exceptions.InvalidRequestException) Delivery(com.netflix.spinnaker.front50.model.delivery.Delivery) ApiOperation(io.swagger.annotations.ApiOperation) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Aggregations

InvalidRequestException (com.netflix.spinnaker.front50.exceptions.InvalidRequestException)2 Delivery (com.netflix.spinnaker.front50.model.delivery.Delivery)2 ApiOperation (io.swagger.annotations.ApiOperation)2 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)2 NotFoundException (com.netflix.spinnaker.kork.web.exceptions.NotFoundException)1