All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.nagyesta.lowkeyvault.controller.v7_5.CertificatePolicyController Maven / Gradle / Ivy

The newest version!
package com.github.nagyesta.lowkeyvault.controller.v7_5;

import com.github.nagyesta.lowkeyvault.controller.common.CommonCertificatePolicyController;
import com.github.nagyesta.lowkeyvault.mapper.common.registry.CertificateConverterRegistry;
import com.github.nagyesta.lowkeyvault.model.common.ApiConstants;
import com.github.nagyesta.lowkeyvault.model.v7_3.certificate.CertificatePolicyModel;
import com.github.nagyesta.lowkeyvault.model.v7_3.certificate.KeyVaultPendingCertificateModel;
import com.github.nagyesta.lowkeyvault.service.vault.VaultService;
import jakarta.validation.Valid;
import jakarta.validation.constraints.Pattern;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.lang.NonNull;
import org.springframework.stereotype.Component;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.net.URI;

import static com.github.nagyesta.lowkeyvault.model.common.ApiConstants.API_VERSION_7_5;
import static com.github.nagyesta.lowkeyvault.model.common.ApiConstants.V_7_5;
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;

@Slf4j
@RestController
@Validated
@Component("CertificatePolicyControllerV75")
public class CertificatePolicyController extends CommonCertificatePolicyController {
    @Autowired
    public CertificatePolicyController(@NonNull final CertificateConverterRegistry registry, @NonNull final VaultService vaultService) {
        super(registry, vaultService);
    }

    @Override
    @GetMapping(value = {"/certificates/{certificateName}/pending", "/certificates/{certificateName}/pending/"},
            params = API_VERSION_7_5,
            produces = APPLICATION_JSON_VALUE)
    public ResponseEntity pendingCreate(
            @PathVariable @Valid @Pattern(regexp = NAME_PATTERN) final String certificateName,
            @RequestAttribute(name = ApiConstants.REQUEST_BASE_URI) final URI baseUri) {
        return super.pendingCreate(certificateName, baseUri);
    }

    @Override
    @DeleteMapping(value = {"/certificates/{certificateName}/pending", "/certificates/{certificateName}/pending/"},
            params = API_VERSION_7_5,
            produces = APPLICATION_JSON_VALUE)
    public ResponseEntity pendingDelete(
            @PathVariable @Valid @Pattern(regexp = NAME_PATTERN) final String certificateName,
            @RequestAttribute(name = ApiConstants.REQUEST_BASE_URI) final URI baseUri) {
        return super.pendingDelete(certificateName, baseUri);
    }

    @Override
    @GetMapping(value = {"/certificates/{certificateName}/policy", "/certificates/{certificateName}/policy/"},
            params = API_VERSION_7_5,
            produces = APPLICATION_JSON_VALUE)
    public ResponseEntity getPolicy(
            @PathVariable @Valid @Pattern(regexp = NAME_PATTERN) final String certificateName,
            @RequestAttribute(name = ApiConstants.REQUEST_BASE_URI) final URI baseUri) {
        return super.getPolicy(certificateName, baseUri);
    }

    @Override
    @PatchMapping(value = {"/certificates/{certificateName}/policy", "/certificates/{certificateName}/policy/"},
            params = API_VERSION_7_5,
            produces = APPLICATION_JSON_VALUE)
    public ResponseEntity updatePolicy(
            @PathVariable @Valid @Pattern(regexp = NAME_PATTERN) final String certificateName,
            @RequestAttribute(name = ApiConstants.REQUEST_BASE_URI) final URI baseUri,
            @Valid @RequestBody final CertificatePolicyModel request) {
        return super.updatePolicy(certificateName, baseUri, request);
    }

    @Override
    protected String apiVersion() {
        return V_7_5;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy