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

com.github.nagyesta.lowkeyvault.controller.v7_4.CertificateController Maven / Gradle / Ivy

There is a newer version: 2.5.81
Show newest version
package com.github.nagyesta.lowkeyvault.controller.v7_4;

import com.github.nagyesta.lowkeyvault.controller.common.CommonCertificateController;
import com.github.nagyesta.lowkeyvault.mapper.common.registry.CertificateConverterRegistry;
import com.github.nagyesta.lowkeyvault.model.common.ApiConstants;
import com.github.nagyesta.lowkeyvault.model.common.KeyVaultItemListModel;
import com.github.nagyesta.lowkeyvault.model.v7_3.certificate.*;
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_4;
import static com.github.nagyesta.lowkeyvault.model.common.ApiConstants.V_7_4;
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;

@Slf4j
@RestController
@Validated
@Component("CertificateControllerV74")
public class CertificateController extends CommonCertificateController {
    @Autowired
    public CertificateController(@NonNull final CertificateConverterRegistry registry, @NonNull final VaultService vaultService) {
        super(registry, vaultService);
    }

    @Override
    @PostMapping(
            value = {"/certificates/{certificateName}/create", "/certificates/{certificateName}/create/"},
            params = API_VERSION_7_4,
            consumes = APPLICATION_JSON_VALUE,
            produces = APPLICATION_JSON_VALUE)
    public ResponseEntity create(
            @PathVariable @Valid @Pattern(regexp = NAME_PATTERN) final String certificateName,
            @RequestAttribute(name = ApiConstants.REQUEST_BASE_URI) final URI baseUri,
            @Valid @RequestBody final CreateCertificateRequest request) {
        return super.create(certificateName, baseUri, request);
    }

    @Override
    @PostMapping(
            value = {"/certificates/{certificateName}/import", "/certificates/{certificateName}/import/"},
            params = API_VERSION_7_4,
            consumes = APPLICATION_JSON_VALUE,
            produces = APPLICATION_JSON_VALUE)
    public ResponseEntity importCertificate(
            @PathVariable @Valid @Pattern(regexp = NAME_PATTERN) final String certificateName,
            @RequestAttribute(name = ApiConstants.REQUEST_BASE_URI) final URI baseUri,
            @Valid @RequestBody final CertificateImportRequest request) {
        return super.importCertificate(certificateName, baseUri, request);
    }

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

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

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

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

    @Override
    @PostMapping(
            value = {"/deletedcertificates/{certificateName}/recover", "/deletedcertificates/{certificateName}/recover/"},
            params = API_VERSION_7_4,
            produces = APPLICATION_JSON_VALUE)
    public ResponseEntity recoverDeletedCertificate(
            @PathVariable @Valid @Pattern(regexp = NAME_PATTERN) final String certificateName,
            @RequestAttribute(name = ApiConstants.REQUEST_BASE_URI) final URI baseUri) {
        return super.recoverDeletedCertificate(certificateName, baseUri);
    }

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

    @Override
    @GetMapping(
            value = {"/certificates/{certificateName}/versions", "/certificates/{certificateName}/versions/"},
            params = API_VERSION_7_4,
            produces = APPLICATION_JSON_VALUE)
    public ResponseEntity> versions(
            @PathVariable @Valid @Pattern(regexp = NAME_PATTERN) final String certificateName,
            @RequestAttribute(name = ApiConstants.REQUEST_BASE_URI) final URI baseUri,
            @RequestParam(name = MAX_RESULTS_PARAM, required = false, defaultValue = DEFAULT_MAX) final int maxResults,
            @RequestParam(name = SKIP_TOKEN_PARAM, required = false, defaultValue = SKIP_ZERO) final int skipToken) {
        return super.versions(certificateName, baseUri, maxResults, skipToken);
    }

    @Override
    @GetMapping(
            value = {"/certificates", "/certificates/"},
            params = API_VERSION_7_4,
            produces = APPLICATION_JSON_VALUE)
    public ResponseEntity> listCertificates(
            @RequestAttribute(name = ApiConstants.REQUEST_BASE_URI) final URI baseUri,
            @RequestParam(name = MAX_RESULTS_PARAM, required = false, defaultValue = DEFAULT_MAX) final int maxResults,
            @RequestParam(name = SKIP_TOKEN_PARAM, required = false, defaultValue = SKIP_ZERO) final int skipToken,
            @RequestParam(name = INCLUDE_PENDING_PARAM, required = false, defaultValue = TRUE) final boolean includePending) {
        return super.listCertificates(baseUri, maxResults, skipToken, includePending);
    }

    @Override
    @GetMapping(
            value = {"/deletedcertificates", "/deletedcertificates/"},
            params = API_VERSION_7_4,
            produces = APPLICATION_JSON_VALUE)
    public ResponseEntity> listDeletedCertificates(
            @RequestAttribute(name = ApiConstants.REQUEST_BASE_URI) final URI baseUri,
            @RequestParam(name = MAX_RESULTS_PARAM, required = false, defaultValue = DEFAULT_MAX) final int maxResults,
            @RequestParam(name = SKIP_TOKEN_PARAM, required = false, defaultValue = SKIP_ZERO) final int skipToken,
            @RequestParam(name = INCLUDE_PENDING_PARAM, required = false, defaultValue = TRUE) final boolean includePending) {
        return super.listDeletedCertificates(baseUri, maxResults, skipToken, includePending);
    }

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

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy