// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.

package com.azure.resourcemanager.deviceprovisioningservices.implementation;

import com.azure.core.annotation.BodyParam;
import com.azure.core.annotation.Delete;
import com.azure.core.annotation.ExpectedResponses;
import com.azure.core.annotation.Get;
import com.azure.core.annotation.HeaderParam;
import com.azure.core.annotation.Headers;
import com.azure.core.annotation.Host;
import com.azure.core.annotation.HostParam;
import com.azure.core.annotation.PathParam;
import com.azure.core.annotation.Post;
import com.azure.core.annotation.Put;
import com.azure.core.annotation.QueryParam;
import com.azure.core.annotation.ReturnType;
import com.azure.core.annotation.ServiceInterface;
import com.azure.core.annotation.ServiceMethod;
import com.azure.core.annotation.UnexpectedResponseExceptionType;
import com.azure.core.http.rest.Response;
import com.azure.core.http.rest.RestProxy;
import com.azure.core.util.Base64Util;
import com.azure.core.util.Context;
import com.azure.core.util.FluxUtil;
import com.azure.resourcemanager.deviceprovisioningservices.fluent.DpsCertificatesClient;
import com.azure.resourcemanager.deviceprovisioningservices.fluent.models.CertificateListDescriptionInner;
import com.azure.resourcemanager.deviceprovisioningservices.fluent.models.CertificateResponseInner;
import com.azure.resourcemanager.deviceprovisioningservices.fluent.models.VerificationCodeResponseInner;
import com.azure.resourcemanager.deviceprovisioningservices.models.CertificatePurpose;
import com.azure.resourcemanager.deviceprovisioningservices.models.ErrorDetailsException;
import com.azure.resourcemanager.deviceprovisioningservices.models.VerificationCodeRequest;
import java.time.OffsetDateTime;
import reactor.core.publisher.Mono;

/** An instance of this class provides access to all the operations defined in DpsCertificatesClient. */
public final class DpsCertificatesClientImpl implements DpsCertificatesClient {
    /** The proxy service used to perform REST calls. */
    private final DpsCertificatesService service;

    /** The service client containing this operation class. */
    private final IotDpsClientImpl client;

    /**
     * Initializes an instance of DpsCertificatesClientImpl.
     *
     * @param client the instance of the service client containing this operation class.
     */
    DpsCertificatesClientImpl(IotDpsClientImpl client) {
        this.service =
            RestProxy.create(DpsCertificatesService.class, client.getHttpPipeline(), client.getSerializerAdapter());
        this.client = client;
    }

    /**
     * The interface defining all the services for IotDpsClientDpsCertificates to be used by the proxy service to
     * perform REST calls.
     */
    @Host("{$host}")
    @ServiceInterface(name = "IotDpsClientDpsCerti")
    private interface DpsCertificatesService {
        @Headers({"Content-Type: application/json"})
        @Get(
            "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices"
                + "/provisioningServices/{provisioningServiceName}/certificates/{certificateName}")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(ErrorDetailsException.class)
        Mono<Response<CertificateResponseInner>> get(
            @HostParam("$host") String endpoint,
            @PathParam("certificateName") String certificateName,
            @PathParam("subscriptionId") String subscriptionId,
            @PathParam("resourceGroupName") String resourceGroupName,
            @PathParam("provisioningServiceName") String provisioningServiceName,
            @HeaderParam("If-Match") String ifMatch,
            @QueryParam("api-version") String apiVersion,
            @HeaderParam("Accept") String accept,
            Context context);

        @Headers({"Content-Type: application/json"})
        @Put(
            "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices"
                + "/provisioningServices/{provisioningServiceName}/certificates/{certificateName}")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(ErrorDetailsException.class)
        Mono<Response<CertificateResponseInner>> createOrUpdate(
            @HostParam("$host") String endpoint,
            @QueryParam("api-version") String apiVersion,
            @PathParam("subscriptionId") String subscriptionId,
            @PathParam("resourceGroupName") String resourceGroupName,
            @PathParam("provisioningServiceName") String provisioningServiceName,
            @PathParam("certificateName") String certificateName,
            @HeaderParam("If-Match") String ifMatch,
            @BodyParam("application/json") CertificateResponseInner certificateDescription,
            @HeaderParam("Accept") String accept,
            Context context);

        @Headers({"Content-Type: application/json"})
        @Delete(
            "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices"
                + "/provisioningServices/{provisioningServiceName}/certificates/{certificateName}")
        @ExpectedResponses({200, 204})
        @UnexpectedResponseExceptionType(ErrorDetailsException.class)
        Mono<Response<Void>> delete(
            @HostParam("$host") String endpoint,
            @PathParam("subscriptionId") String subscriptionId,
            @PathParam("resourceGroupName") String resourceGroupName,
            @HeaderParam("If-Match") String ifMatch,
            @PathParam("provisioningServiceName") String provisioningServiceName,
            @PathParam("certificateName") String certificateName,
            @QueryParam("certificate.name") String certificateName1,
            @QueryParam("certificate.rawBytes") String certificateRawBytes,
            @QueryParam("certificate.isVerified") Boolean certificateIsVerified,
            @QueryParam("certificate.purpose") CertificatePurpose certificatePurpose,
            @QueryParam("certificate.created") OffsetDateTime certificateCreated,
            @QueryParam("certificate.lastUpdated") OffsetDateTime certificateLastUpdated,
            @QueryParam("certificate.hasPrivateKey") Boolean certificateHasPrivateKey,
            @QueryParam("certificate.nonce") String certificateNonce,
            @QueryParam("api-version") String apiVersion,
            @HeaderParam("Accept") String accept,
            Context context);

        @Headers({"Content-Type: application/json"})
        @Get(
            "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices"
                + "/provisioningServices/{provisioningServiceName}/certificates")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(ErrorDetailsException.class)
        Mono<Response<CertificateListDescriptionInner>> list(
            @HostParam("$host") String endpoint,
            @PathParam("subscriptionId") String subscriptionId,
            @PathParam("resourceGroupName") String resourceGroupName,
            @PathParam("provisioningServiceName") String provisioningServiceName,
            @QueryParam("api-version") String apiVersion,
            @HeaderParam("Accept") String accept,
            Context context);

        @Headers({"Content-Type: application/json"})
        @Post(
            "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices"
                + "/provisioningServices/{provisioningServiceName}/certificates/{certificateName}"
                + "/generateVerificationCode")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(ErrorDetailsException.class)
        Mono<Response<VerificationCodeResponseInner>> generateVerificationCode(
            @HostParam("$host") String endpoint,
            @PathParam("certificateName") String certificateName,
            @HeaderParam("If-Match") String ifMatch,
            @PathParam("subscriptionId") String subscriptionId,
            @PathParam("resourceGroupName") String resourceGroupName,
            @PathParam("provisioningServiceName") String provisioningServiceName,
            @QueryParam("certificate.name") String certificateName1,
            @QueryParam("certificate.rawBytes") String certificateRawBytes,
            @QueryParam("certificate.isVerified") Boolean certificateIsVerified,
            @QueryParam("certificate.purpose") CertificatePurpose certificatePurpose,
            @QueryParam("certificate.created") OffsetDateTime certificateCreated,
            @QueryParam("certificate.lastUpdated") OffsetDateTime certificateLastUpdated,
            @QueryParam("certificate.hasPrivateKey") Boolean certificateHasPrivateKey,
            @QueryParam("certificate.nonce") String certificateNonce,
            @QueryParam("api-version") String apiVersion,
            @HeaderParam("Accept") String accept,
            Context context);

        @Headers({"Content-Type: application/json"})
        @Post(
            "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices"
                + "/provisioningServices/{provisioningServiceName}/certificates/{certificateName}/verify")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(ErrorDetailsException.class)
        Mono<Response<CertificateResponseInner>> verifyCertificate(
            @HostParam("$host") String endpoint,
            @PathParam("certificateName") String certificateName,
            @HeaderParam("If-Match") String ifMatch,
            @PathParam("subscriptionId") String subscriptionId,
            @PathParam("resourceGroupName") String resourceGroupName,
            @PathParam("provisioningServiceName") String provisioningServiceName,
            @QueryParam("certificate.name") String certificateName1,
            @QueryParam("certificate.rawBytes") String certificateRawBytes,
            @QueryParam("certificate.isVerified") Boolean certificateIsVerified,
            @QueryParam("certificate.purpose") CertificatePurpose certificatePurpose,
            @QueryParam("certificate.created") OffsetDateTime certificateCreated,
            @QueryParam("certificate.lastUpdated") OffsetDateTime certificateLastUpdated,
            @QueryParam("certificate.hasPrivateKey") Boolean certificateHasPrivateKey,
            @QueryParam("certificate.nonce") String certificateNonce,
            @QueryParam("api-version") String apiVersion,
            @BodyParam("application/json") VerificationCodeRequest request,
            @HeaderParam("Accept") String accept,
            Context context);
    }

    /**
     * Get the certificate from the provisioning service.
     *
     * @param certificateName Name of the certificate to retrieve.
     * @param resourceGroupName Resource group identifier.
     * @param provisioningServiceName Name of the provisioning service the certificate is associated with.
     * @param ifMatch ETag of the certificate.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the certificate from the provisioning service along with {@link Response} on successful completion of
     *     {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<CertificateResponseInner>> getWithResponseAsync(
        String certificateName, String resourceGroupName, String provisioningServiceName, String ifMatch) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (certificateName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter certificateName is required and cannot be null."));
        }
        if (this.client.getSubscriptionId() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getSubscriptionId() is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        if (provisioningServiceName == null) {
            return Mono
                .error(
                    new IllegalArgumentException("Parameter provisioningServiceName is required and cannot be null."));
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .get(
                            this.client.getEndpoint(),
                            certificateName,
                            this.client.getSubscriptionId(),
                            resourceGroupName,
                            provisioningServiceName,
                            ifMatch,
                            this.client.getApiVersion(),
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Get the certificate from the provisioning service.
     *
     * @param certificateName Name of the certificate to retrieve.
     * @param resourceGroupName Resource group identifier.
     * @param provisioningServiceName Name of the provisioning service the certificate is associated with.
     * @param ifMatch ETag of the certificate.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the certificate from the provisioning service along with {@link Response} on successful completion of
     *     {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<CertificateResponseInner>> getWithResponseAsync(
        String certificateName,
        String resourceGroupName,
        String provisioningServiceName,
        String ifMatch,
        Context context) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (certificateName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter certificateName is required and cannot be null."));
        }
        if (this.client.getSubscriptionId() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getSubscriptionId() is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        if (provisioningServiceName == null) {
            return Mono
                .error(
                    new IllegalArgumentException("Parameter provisioningServiceName is required and cannot be null."));
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .get(
                this.client.getEndpoint(),
                certificateName,
                this.client.getSubscriptionId(),
                resourceGroupName,
                provisioningServiceName,
                ifMatch,
                this.client.getApiVersion(),
                accept,
                context);
    }

    /**
     * Get the certificate from the provisioning service.
     *
     * @param certificateName Name of the certificate to retrieve.
     * @param resourceGroupName Resource group identifier.
     * @param provisioningServiceName Name of the provisioning service the certificate is associated with.
     * @param ifMatch ETag of the certificate.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the certificate from the provisioning service on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<CertificateResponseInner> getAsync(
        String certificateName, String resourceGroupName, String provisioningServiceName, String ifMatch) {
        return getWithResponseAsync(certificateName, resourceGroupName, provisioningServiceName, ifMatch)
            .flatMap(res -> Mono.justOrEmpty(res.getValue()));
    }

    /**
     * Get the certificate from the provisioning service.
     *
     * @param certificateName Name of the certificate to retrieve.
     * @param resourceGroupName Resource group identifier.
     * @param provisioningServiceName Name of the provisioning service the certificate is associated with.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the certificate from the provisioning service on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<CertificateResponseInner> getAsync(
        String certificateName, String resourceGroupName, String provisioningServiceName) {
        final String ifMatch = null;
        return getWithResponseAsync(certificateName, resourceGroupName, provisioningServiceName, ifMatch)
            .flatMap(res -> Mono.justOrEmpty(res.getValue()));
    }

    /**
     * Get the certificate from the provisioning service.
     *
     * @param certificateName Name of the certificate to retrieve.
     * @param resourceGroupName Resource group identifier.
     * @param provisioningServiceName Name of the provisioning service the certificate is associated with.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the certificate from the provisioning service.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public CertificateResponseInner get(
        String certificateName, String resourceGroupName, String provisioningServiceName) {
        final String ifMatch = null;
        return getAsync(certificateName, resourceGroupName, provisioningServiceName, ifMatch).block();
    }

    /**
     * Get the certificate from the provisioning service.
     *
     * @param certificateName Name of the certificate to retrieve.
     * @param resourceGroupName Resource group identifier.
     * @param provisioningServiceName Name of the provisioning service the certificate is associated with.
     * @param ifMatch ETag of the certificate.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the certificate from the provisioning service along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<CertificateResponseInner> getWithResponse(
        String certificateName,
        String resourceGroupName,
        String provisioningServiceName,
        String ifMatch,
        Context context) {
        return getWithResponseAsync(certificateName, resourceGroupName, provisioningServiceName, ifMatch, context)
            .block();
    }

    /**
     * Add new certificate or update an existing certificate.
     *
     * @param resourceGroupName Resource group identifier.
     * @param provisioningServiceName The name of the provisioning service.
     * @param certificateName The name of the certificate create or update.
     * @param certificateDescription The certificate body.
     * @param ifMatch ETag of the certificate. This is required to update an existing certificate, and ignored while
     *     creating a brand new certificate.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the X509 Certificate along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<CertificateResponseInner>> createOrUpdateWithResponseAsync(
        String resourceGroupName,
        String provisioningServiceName,
        String certificateName,
        CertificateResponseInner certificateDescription,
        String ifMatch) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (this.client.getSubscriptionId() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getSubscriptionId() is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        if (provisioningServiceName == null) {
            return Mono
                .error(
                    new IllegalArgumentException("Parameter provisioningServiceName is required and cannot be null."));
        }
        if (certificateName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter certificateName is required and cannot be null."));
        }
        if (certificateDescription == null) {
            return Mono
                .error(
                    new IllegalArgumentException("Parameter certificateDescription is required and cannot be null."));
        } else {
            certificateDescription.validate();
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .createOrUpdate(
                            this.client.getEndpoint(),
                            this.client.getApiVersion(),
                            this.client.getSubscriptionId(),
                            resourceGroupName,
                            provisioningServiceName,
                            certificateName,
                            ifMatch,
                            certificateDescription,
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Add new certificate or update an existing certificate.
     *
     * @param resourceGroupName Resource group identifier.
     * @param provisioningServiceName The name of the provisioning service.
     * @param certificateName The name of the certificate create or update.
     * @param certificateDescription The certificate body.
     * @param ifMatch ETag of the certificate. This is required to update an existing certificate, and ignored while
     *     creating a brand new certificate.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the X509 Certificate along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<CertificateResponseInner>> createOrUpdateWithResponseAsync(
        String resourceGroupName,
        String provisioningServiceName,
        String certificateName,
        CertificateResponseInner certificateDescription,
        String ifMatch,
        Context context) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (this.client.getSubscriptionId() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getSubscriptionId() is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        if (provisioningServiceName == null) {
            return Mono
                .error(
                    new IllegalArgumentException("Parameter provisioningServiceName is required and cannot be null."));
        }
        if (certificateName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter certificateName is required and cannot be null."));
        }
        if (certificateDescription == null) {
            return Mono
                .error(
                    new IllegalArgumentException("Parameter certificateDescription is required and cannot be null."));
        } else {
            certificateDescription.validate();
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .createOrUpdate(
                this.client.getEndpoint(),
                this.client.getApiVersion(),
                this.client.getSubscriptionId(),
                resourceGroupName,
                provisioningServiceName,
                certificateName,
                ifMatch,
                certificateDescription,
                accept,
                context);
    }

    /**
     * Add new certificate or update an existing certificate.
     *
     * @param resourceGroupName Resource group identifier.
     * @param provisioningServiceName The name of the provisioning service.
     * @param certificateName The name of the certificate create or update.
     * @param certificateDescription The certificate body.
     * @param ifMatch ETag of the certificate. This is required to update an existing certificate, and ignored while
     *     creating a brand new certificate.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the X509 Certificate on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<CertificateResponseInner> createOrUpdateAsync(
        String resourceGroupName,
        String provisioningServiceName,
        String certificateName,
        CertificateResponseInner certificateDescription,
        String ifMatch) {
        return createOrUpdateWithResponseAsync(
                resourceGroupName, provisioningServiceName, certificateName, certificateDescription, ifMatch)
            .flatMap(res -> Mono.justOrEmpty(res.getValue()));
    }

    /**
     * Add new certificate or update an existing certificate.
     *
     * @param resourceGroupName Resource group identifier.
     * @param provisioningServiceName The name of the provisioning service.
     * @param certificateName The name of the certificate create or update.
     * @param certificateDescription The certificate body.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the X509 Certificate on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<CertificateResponseInner> createOrUpdateAsync(
        String resourceGroupName,
        String provisioningServiceName,
        String certificateName,
        CertificateResponseInner certificateDescription) {
        final String ifMatch = null;
        return createOrUpdateWithResponseAsync(
                resourceGroupName, provisioningServiceName, certificateName, certificateDescription, ifMatch)
            .flatMap(res -> Mono.justOrEmpty(res.getValue()));
    }

    /**
     * Add new certificate or update an existing certificate.
     *
     * @param resourceGroupName Resource group identifier.
     * @param provisioningServiceName The name of the provisioning service.
     * @param certificateName The name of the certificate create or update.
     * @param certificateDescription The certificate body.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the X509 Certificate.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public CertificateResponseInner createOrUpdate(
        String resourceGroupName,
        String provisioningServiceName,
        String certificateName,
        CertificateResponseInner certificateDescription) {
        final String ifMatch = null;
        return createOrUpdateAsync(
                resourceGroupName, provisioningServiceName, certificateName, certificateDescription, ifMatch)
            .block();
    }

    /**
     * Add new certificate or update an existing certificate.
     *
     * @param resourceGroupName Resource group identifier.
     * @param provisioningServiceName The name of the provisioning service.
     * @param certificateName The name of the certificate create or update.
     * @param certificateDescription The certificate body.
     * @param ifMatch ETag of the certificate. This is required to update an existing certificate, and ignored while
     *     creating a brand new certificate.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the X509 Certificate along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<CertificateResponseInner> createOrUpdateWithResponse(
        String resourceGroupName,
        String provisioningServiceName,
        String certificateName,
        CertificateResponseInner certificateDescription,
        String ifMatch,
        Context context) {
        return createOrUpdateWithResponseAsync(
                resourceGroupName, provisioningServiceName, certificateName, certificateDescription, ifMatch, context)
            .block();
    }

    /**
     * Deletes the specified certificate associated with the Provisioning Service.
     *
     * @param resourceGroupName Resource group identifier.
     * @param ifMatch ETag of the certificate.
     * @param provisioningServiceName The name of the provisioning service.
     * @param certificateName This is a mandatory field, and is the logical name of the certificate that the
     *     provisioning service will access by.
     * @param certificateName1 This is optional, and it is the Common Name of the certificate.
     * @param certificateRawBytes Raw data within the certificate.
     * @param certificateIsVerified Indicates if certificate has been verified by owner of the private key.
     * @param certificatePurpose A description that mentions the purpose of the certificate.
     * @param certificateCreated Time the certificate is created.
     * @param certificateLastUpdated Time the certificate is last updated.
     * @param certificateHasPrivateKey Indicates if the certificate contains a private key.
     * @param certificateNonce Random number generated to indicate Proof of Possession.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<Void>> deleteWithResponseAsync(
        String resourceGroupName,
        String ifMatch,
        String provisioningServiceName,
        String certificateName,
        String certificateName1,
        byte[] certificateRawBytes,
        Boolean certificateIsVerified,
        CertificatePurpose certificatePurpose,
        OffsetDateTime certificateCreated,
        OffsetDateTime certificateLastUpdated,
        Boolean certificateHasPrivateKey,
        String certificateNonce) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (this.client.getSubscriptionId() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getSubscriptionId() is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        if (ifMatch == null) {
            return Mono.error(new IllegalArgumentException("Parameter ifMatch is required and cannot be null."));
        }
        if (provisioningServiceName == null) {
            return Mono
                .error(
                    new IllegalArgumentException("Parameter provisioningServiceName is required and cannot be null."));
        }
        if (certificateName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter certificateName is required and cannot be null."));
        }
        final String accept = "application/json";
        String certificateRawBytesConverted = Base64Util.encodeToString(certificateRawBytes);
        return FluxUtil
            .withContext(
                context ->
                    service
                        .delete(
                            this.client.getEndpoint(),
                            this.client.getSubscriptionId(),
                            resourceGroupName,
                            ifMatch,
                            provisioningServiceName,
                            certificateName,
                            certificateName1,
                            certificateRawBytesConverted,
                            certificateIsVerified,
                            certificatePurpose,
                            certificateCreated,
                            certificateLastUpdated,
                            certificateHasPrivateKey,
                            certificateNonce,
                            this.client.getApiVersion(),
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Deletes the specified certificate associated with the Provisioning Service.
     *
     * @param resourceGroupName Resource group identifier.
     * @param ifMatch ETag of the certificate.
     * @param provisioningServiceName The name of the provisioning service.
     * @param certificateName This is a mandatory field, and is the logical name of the certificate that the
     *     provisioning service will access by.
     * @param certificateName1 This is optional, and it is the Common Name of the certificate.
     * @param certificateRawBytes Raw data within the certificate.
     * @param certificateIsVerified Indicates if certificate has been verified by owner of the private key.
     * @param certificatePurpose A description that mentions the purpose of the certificate.
     * @param certificateCreated Time the certificate is created.
     * @param certificateLastUpdated Time the certificate is last updated.
     * @param certificateHasPrivateKey Indicates if the certificate contains a private key.
     * @param certificateNonce Random number generated to indicate Proof of Possession.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<Void>> deleteWithResponseAsync(
        String resourceGroupName,
        String ifMatch,
        String provisioningServiceName,
        String certificateName,
        String certificateName1,
        byte[] certificateRawBytes,
        Boolean certificateIsVerified,
        CertificatePurpose certificatePurpose,
        OffsetDateTime certificateCreated,
        OffsetDateTime certificateLastUpdated,
        Boolean certificateHasPrivateKey,
        String certificateNonce,
        Context context) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (this.client.getSubscriptionId() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getSubscriptionId() is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        if (ifMatch == null) {
            return Mono.error(new IllegalArgumentException("Parameter ifMatch is required and cannot be null."));
        }
        if (provisioningServiceName == null) {
            return Mono
                .error(
                    new IllegalArgumentException("Parameter provisioningServiceName is required and cannot be null."));
        }
        if (certificateName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter certificateName is required and cannot be null."));
        }
        final String accept = "application/json";
        String certificateRawBytesConverted = Base64Util.encodeToString(certificateRawBytes);
        context = this.client.mergeContext(context);
        return service
            .delete(
                this.client.getEndpoint(),
                this.client.getSubscriptionId(),
                resourceGroupName,
                ifMatch,
                provisioningServiceName,
                certificateName,
                certificateName1,
                certificateRawBytesConverted,
                certificateIsVerified,
                certificatePurpose,
                certificateCreated,
                certificateLastUpdated,
                certificateHasPrivateKey,
                certificateNonce,
                this.client.getApiVersion(),
                accept,
                context);
    }

    /**
     * Deletes the specified certificate associated with the Provisioning Service.
     *
     * @param resourceGroupName Resource group identifier.
     * @param ifMatch ETag of the certificate.
     * @param provisioningServiceName The name of the provisioning service.
     * @param certificateName This is a mandatory field, and is the logical name of the certificate that the
     *     provisioning service will access by.
     * @param certificateName1 This is optional, and it is the Common Name of the certificate.
     * @param certificateRawBytes Raw data within the certificate.
     * @param certificateIsVerified Indicates if certificate has been verified by owner of the private key.
     * @param certificatePurpose A description that mentions the purpose of the certificate.
     * @param certificateCreated Time the certificate is created.
     * @param certificateLastUpdated Time the certificate is last updated.
     * @param certificateHasPrivateKey Indicates if the certificate contains a private key.
     * @param certificateNonce Random number generated to indicate Proof of Possession.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return A {@link Mono} that completes when a successful response is received.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Void> deleteAsync(
        String resourceGroupName,
        String ifMatch,
        String provisioningServiceName,
        String certificateName,
        String certificateName1,
        byte[] certificateRawBytes,
        Boolean certificateIsVerified,
        CertificatePurpose certificatePurpose,
        OffsetDateTime certificateCreated,
        OffsetDateTime certificateLastUpdated,
        Boolean certificateHasPrivateKey,
        String certificateNonce) {
        return deleteWithResponseAsync(
                resourceGroupName,
                ifMatch,
                provisioningServiceName,
                certificateName,
                certificateName1,
                certificateRawBytes,
                certificateIsVerified,
                certificatePurpose,
                certificateCreated,
                certificateLastUpdated,
                certificateHasPrivateKey,
                certificateNonce)
            .flatMap(ignored -> Mono.empty());
    }

    /**
     * Deletes the specified certificate associated with the Provisioning Service.
     *
     * @param resourceGroupName Resource group identifier.
     * @param ifMatch ETag of the certificate.
     * @param provisioningServiceName The name of the provisioning service.
     * @param certificateName This is a mandatory field, and is the logical name of the certificate that the
     *     provisioning service will access by.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return A {@link Mono} that completes when a successful response is received.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Void> deleteAsync(
        String resourceGroupName, String ifMatch, String provisioningServiceName, String certificateName) {
        final String certificateName1 = null;
        final byte[] certificateRawBytes = new byte[0];
        final Boolean certificateIsVerified = null;
        final CertificatePurpose certificatePurpose = null;
        final OffsetDateTime certificateCreated = null;
        final OffsetDateTime certificateLastUpdated = null;
        final Boolean certificateHasPrivateKey = null;
        final String certificateNonce = null;
        return deleteWithResponseAsync(
                resourceGroupName,
                ifMatch,
                provisioningServiceName,
                certificateName,
                certificateName1,
                certificateRawBytes,
                certificateIsVerified,
                certificatePurpose,
                certificateCreated,
                certificateLastUpdated,
                certificateHasPrivateKey,
                certificateNonce)
            .flatMap(ignored -> Mono.empty());
    }

    /**
     * Deletes the specified certificate associated with the Provisioning Service.
     *
     * @param resourceGroupName Resource group identifier.
     * @param ifMatch ETag of the certificate.
     * @param provisioningServiceName The name of the provisioning service.
     * @param certificateName This is a mandatory field, and is the logical name of the certificate that the
     *     provisioning service will access by.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public void delete(
        String resourceGroupName, String ifMatch, String provisioningServiceName, String certificateName) {
        final String certificateName1 = null;
        final byte[] certificateRawBytes = new byte[0];
        final Boolean certificateIsVerified = null;
        final CertificatePurpose certificatePurpose = null;
        final OffsetDateTime certificateCreated = null;
        final OffsetDateTime certificateLastUpdated = null;
        final Boolean certificateHasPrivateKey = null;
        final String certificateNonce = null;
        deleteAsync(
                resourceGroupName,
                ifMatch,
                provisioningServiceName,
                certificateName,
                certificateName1,
                certificateRawBytes,
                certificateIsVerified,
                certificatePurpose,
                certificateCreated,
                certificateLastUpdated,
                certificateHasPrivateKey,
                certificateNonce)
            .block();
    }

    /**
     * Deletes the specified certificate associated with the Provisioning Service.
     *
     * @param resourceGroupName Resource group identifier.
     * @param ifMatch ETag of the certificate.
     * @param provisioningServiceName The name of the provisioning service.
     * @param certificateName This is a mandatory field, and is the logical name of the certificate that the
     *     provisioning service will access by.
     * @param certificateName1 This is optional, and it is the Common Name of the certificate.
     * @param certificateRawBytes Raw data within the certificate.
     * @param certificateIsVerified Indicates if certificate has been verified by owner of the private key.
     * @param certificatePurpose A description that mentions the purpose of the certificate.
     * @param certificateCreated Time the certificate is created.
     * @param certificateLastUpdated Time the certificate is last updated.
     * @param certificateHasPrivateKey Indicates if the certificate contains a private key.
     * @param certificateNonce Random number generated to indicate Proof of Possession.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<Void> deleteWithResponse(
        String resourceGroupName,
        String ifMatch,
        String provisioningServiceName,
        String certificateName,
        String certificateName1,
        byte[] certificateRawBytes,
        Boolean certificateIsVerified,
        CertificatePurpose certificatePurpose,
        OffsetDateTime certificateCreated,
        OffsetDateTime certificateLastUpdated,
        Boolean certificateHasPrivateKey,
        String certificateNonce,
        Context context) {
        return deleteWithResponseAsync(
                resourceGroupName,
                ifMatch,
                provisioningServiceName,
                certificateName,
                certificateName1,
                certificateRawBytes,
                certificateIsVerified,
                certificatePurpose,
                certificateCreated,
                certificateLastUpdated,
                certificateHasPrivateKey,
                certificateNonce,
                context)
            .block();
    }

    /**
     * Get all the certificates tied to the provisioning service.
     *
     * @param resourceGroupName Name of resource group.
     * @param provisioningServiceName Name of provisioning service to retrieve certificates for.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return all the certificates tied to the provisioning service along with {@link Response} on successful
     *     completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<CertificateListDescriptionInner>> listWithResponseAsync(
        String resourceGroupName, String provisioningServiceName) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (this.client.getSubscriptionId() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getSubscriptionId() is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        if (provisioningServiceName == null) {
            return Mono
                .error(
                    new IllegalArgumentException("Parameter provisioningServiceName is required and cannot be null."));
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .list(
                            this.client.getEndpoint(),
                            this.client.getSubscriptionId(),
                            resourceGroupName,
                            provisioningServiceName,
                            this.client.getApiVersion(),
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Get all the certificates tied to the provisioning service.
     *
     * @param resourceGroupName Name of resource group.
     * @param provisioningServiceName Name of provisioning service to retrieve certificates for.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return all the certificates tied to the provisioning service along with {@link Response} on successful
     *     completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<CertificateListDescriptionInner>> listWithResponseAsync(
        String resourceGroupName, String provisioningServiceName, Context context) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (this.client.getSubscriptionId() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getSubscriptionId() is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        if (provisioningServiceName == null) {
            return Mono
                .error(
                    new IllegalArgumentException("Parameter provisioningServiceName is required and cannot be null."));
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .list(
                this.client.getEndpoint(),
                this.client.getSubscriptionId(),
                resourceGroupName,
                provisioningServiceName,
                this.client.getApiVersion(),
                accept,
                context);
    }

    /**
     * Get all the certificates tied to the provisioning service.
     *
     * @param resourceGroupName Name of resource group.
     * @param provisioningServiceName Name of provisioning service to retrieve certificates for.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return all the certificates tied to the provisioning service on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<CertificateListDescriptionInner> listAsync(String resourceGroupName, String provisioningServiceName) {
        return listWithResponseAsync(resourceGroupName, provisioningServiceName)
            .flatMap(res -> Mono.justOrEmpty(res.getValue()));
    }

    /**
     * Get all the certificates tied to the provisioning service.
     *
     * @param resourceGroupName Name of resource group.
     * @param provisioningServiceName Name of provisioning service to retrieve certificates for.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return all the certificates tied to the provisioning service.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public CertificateListDescriptionInner list(String resourceGroupName, String provisioningServiceName) {
        return listAsync(resourceGroupName, provisioningServiceName).block();
    }

    /**
     * Get all the certificates tied to the provisioning service.
     *
     * @param resourceGroupName Name of resource group.
     * @param provisioningServiceName Name of provisioning service to retrieve certificates for.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return all the certificates tied to the provisioning service along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<CertificateListDescriptionInner> listWithResponse(
        String resourceGroupName, String provisioningServiceName, Context context) {
        return listWithResponseAsync(resourceGroupName, provisioningServiceName, context).block();
    }

    /**
     * Generate verification code for Proof of Possession.
     *
     * @param certificateName The mandatory logical name of the certificate, that the provisioning service uses to
     *     access.
     * @param ifMatch ETag of the certificate. This is required to update an existing certificate, and ignored while
     *     creating a brand new certificate.
     * @param resourceGroupName name of resource group.
     * @param provisioningServiceName Name of provisioning service.
     * @param certificateName1 Common Name for the certificate.
     * @param certificateRawBytes Raw data of certificate.
     * @param certificateIsVerified Indicates if the certificate has been verified by owner of the private key.
     * @param certificatePurpose Description mentioning the purpose of the certificate.
     * @param certificateCreated Certificate creation time.
     * @param certificateLastUpdated Certificate last updated time.
     * @param certificateHasPrivateKey Indicates if the certificate contains private key.
     * @param certificateNonce Random number generated to indicate Proof of Possession.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return description of the response of the verification code along with {@link Response} on successful completion
     *     of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<VerificationCodeResponseInner>> generateVerificationCodeWithResponseAsync(
        String certificateName,
        String ifMatch,
        String resourceGroupName,
        String provisioningServiceName,
        String certificateName1,
        byte[] certificateRawBytes,
        Boolean certificateIsVerified,
        CertificatePurpose certificatePurpose,
        OffsetDateTime certificateCreated,
        OffsetDateTime certificateLastUpdated,
        Boolean certificateHasPrivateKey,
        String certificateNonce) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (certificateName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter certificateName is required and cannot be null."));
        }
        if (ifMatch == null) {
            return Mono.error(new IllegalArgumentException("Parameter ifMatch is required and cannot be null."));
        }
        if (this.client.getSubscriptionId() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getSubscriptionId() is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        if (provisioningServiceName == null) {
            return Mono
                .error(
                    new IllegalArgumentException("Parameter provisioningServiceName is required and cannot be null."));
        }
        final String accept = "application/json";
        String certificateRawBytesConverted = Base64Util.encodeToString(certificateRawBytes);
        return FluxUtil
            .withContext(
                context ->
                    service
                        .generateVerificationCode(
                            this.client.getEndpoint(),
                            certificateName,
                            ifMatch,
                            this.client.getSubscriptionId(),
                            resourceGroupName,
                            provisioningServiceName,
                            certificateName1,
                            certificateRawBytesConverted,
                            certificateIsVerified,
                            certificatePurpose,
                            certificateCreated,
                            certificateLastUpdated,
                            certificateHasPrivateKey,
                            certificateNonce,
                            this.client.getApiVersion(),
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Generate verification code for Proof of Possession.
     *
     * @param certificateName The mandatory logical name of the certificate, that the provisioning service uses to
     *     access.
     * @param ifMatch ETag of the certificate. This is required to update an existing certificate, and ignored while
     *     creating a brand new certificate.
     * @param resourceGroupName name of resource group.
     * @param provisioningServiceName Name of provisioning service.
     * @param certificateName1 Common Name for the certificate.
     * @param certificateRawBytes Raw data of certificate.
     * @param certificateIsVerified Indicates if the certificate has been verified by owner of the private key.
     * @param certificatePurpose Description mentioning the purpose of the certificate.
     * @param certificateCreated Certificate creation time.
     * @param certificateLastUpdated Certificate last updated time.
     * @param certificateHasPrivateKey Indicates if the certificate contains private key.
     * @param certificateNonce Random number generated to indicate Proof of Possession.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return description of the response of the verification code along with {@link Response} on successful completion
     *     of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<VerificationCodeResponseInner>> generateVerificationCodeWithResponseAsync(
        String certificateName,
        String ifMatch,
        String resourceGroupName,
        String provisioningServiceName,
        String certificateName1,
        byte[] certificateRawBytes,
        Boolean certificateIsVerified,
        CertificatePurpose certificatePurpose,
        OffsetDateTime certificateCreated,
        OffsetDateTime certificateLastUpdated,
        Boolean certificateHasPrivateKey,
        String certificateNonce,
        Context context) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (certificateName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter certificateName is required and cannot be null."));
        }
        if (ifMatch == null) {
            return Mono.error(new IllegalArgumentException("Parameter ifMatch is required and cannot be null."));
        }
        if (this.client.getSubscriptionId() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getSubscriptionId() is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        if (provisioningServiceName == null) {
            return Mono
                .error(
                    new IllegalArgumentException("Parameter provisioningServiceName is required and cannot be null."));
        }
        final String accept = "application/json";
        String certificateRawBytesConverted = Base64Util.encodeToString(certificateRawBytes);
        context = this.client.mergeContext(context);
        return service
            .generateVerificationCode(
                this.client.getEndpoint(),
                certificateName,
                ifMatch,
                this.client.getSubscriptionId(),
                resourceGroupName,
                provisioningServiceName,
                certificateName1,
                certificateRawBytesConverted,
                certificateIsVerified,
                certificatePurpose,
                certificateCreated,
                certificateLastUpdated,
                certificateHasPrivateKey,
                certificateNonce,
                this.client.getApiVersion(),
                accept,
                context);
    }

    /**
     * Generate verification code for Proof of Possession.
     *
     * @param certificateName The mandatory logical name of the certificate, that the provisioning service uses to
     *     access.
     * @param ifMatch ETag of the certificate. This is required to update an existing certificate, and ignored while
     *     creating a brand new certificate.
     * @param resourceGroupName name of resource group.
     * @param provisioningServiceName Name of provisioning service.
     * @param certificateName1 Common Name for the certificate.
     * @param certificateRawBytes Raw data of certificate.
     * @param certificateIsVerified Indicates if the certificate has been verified by owner of the private key.
     * @param certificatePurpose Description mentioning the purpose of the certificate.
     * @param certificateCreated Certificate creation time.
     * @param certificateLastUpdated Certificate last updated time.
     * @param certificateHasPrivateKey Indicates if the certificate contains private key.
     * @param certificateNonce Random number generated to indicate Proof of Possession.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return description of the response of the verification code on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<VerificationCodeResponseInner> generateVerificationCodeAsync(
        String certificateName,
        String ifMatch,
        String resourceGroupName,
        String provisioningServiceName,
        String certificateName1,
        byte[] certificateRawBytes,
        Boolean certificateIsVerified,
        CertificatePurpose certificatePurpose,
        OffsetDateTime certificateCreated,
        OffsetDateTime certificateLastUpdated,
        Boolean certificateHasPrivateKey,
        String certificateNonce) {
        return generateVerificationCodeWithResponseAsync(
                certificateName,
                ifMatch,
                resourceGroupName,
                provisioningServiceName,
                certificateName1,
                certificateRawBytes,
                certificateIsVerified,
                certificatePurpose,
                certificateCreated,
                certificateLastUpdated,
                certificateHasPrivateKey,
                certificateNonce)
            .flatMap(res -> Mono.justOrEmpty(res.getValue()));
    }

    /**
     * Generate verification code for Proof of Possession.
     *
     * @param certificateName The mandatory logical name of the certificate, that the provisioning service uses to
     *     access.
     * @param ifMatch ETag of the certificate. This is required to update an existing certificate, and ignored while
     *     creating a brand new certificate.
     * @param resourceGroupName name of resource group.
     * @param provisioningServiceName Name of provisioning service.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return description of the response of the verification code on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<VerificationCodeResponseInner> generateVerificationCodeAsync(
        String certificateName, String ifMatch, String resourceGroupName, String provisioningServiceName) {
        final String certificateName1 = null;
        final byte[] certificateRawBytes = new byte[0];
        final Boolean certificateIsVerified = null;
        final CertificatePurpose certificatePurpose = null;
        final OffsetDateTime certificateCreated = null;
        final OffsetDateTime certificateLastUpdated = null;
        final Boolean certificateHasPrivateKey = null;
        final String certificateNonce = null;
        return generateVerificationCodeWithResponseAsync(
                certificateName,
                ifMatch,
                resourceGroupName,
                provisioningServiceName,
                certificateName1,
                certificateRawBytes,
                certificateIsVerified,
                certificatePurpose,
                certificateCreated,
                certificateLastUpdated,
                certificateHasPrivateKey,
                certificateNonce)
            .flatMap(res -> Mono.justOrEmpty(res.getValue()));
    }

    /**
     * Generate verification code for Proof of Possession.
     *
     * @param certificateName The mandatory logical name of the certificate, that the provisioning service uses to
     *     access.
     * @param ifMatch ETag of the certificate. This is required to update an existing certificate, and ignored while
     *     creating a brand new certificate.
     * @param resourceGroupName name of resource group.
     * @param provisioningServiceName Name of provisioning service.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return description of the response of the verification code.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public VerificationCodeResponseInner generateVerificationCode(
        String certificateName, String ifMatch, String resourceGroupName, String provisioningServiceName) {
        final String certificateName1 = null;
        final byte[] certificateRawBytes = new byte[0];
        final Boolean certificateIsVerified = null;
        final CertificatePurpose certificatePurpose = null;
        final OffsetDateTime certificateCreated = null;
        final OffsetDateTime certificateLastUpdated = null;
        final Boolean certificateHasPrivateKey = null;
        final String certificateNonce = null;
        return generateVerificationCodeAsync(
                certificateName,
                ifMatch,
                resourceGroupName,
                provisioningServiceName,
                certificateName1,
                certificateRawBytes,
                certificateIsVerified,
                certificatePurpose,
                certificateCreated,
                certificateLastUpdated,
                certificateHasPrivateKey,
                certificateNonce)
            .block();
    }

    /**
     * Generate verification code for Proof of Possession.
     *
     * @param certificateName The mandatory logical name of the certificate, that the provisioning service uses to
     *     access.
     * @param ifMatch ETag of the certificate. This is required to update an existing certificate, and ignored while
     *     creating a brand new certificate.
     * @param resourceGroupName name of resource group.
     * @param provisioningServiceName Name of provisioning service.
     * @param certificateName1 Common Name for the certificate.
     * @param certificateRawBytes Raw data of certificate.
     * @param certificateIsVerified Indicates if the certificate has been verified by owner of the private key.
     * @param certificatePurpose Description mentioning the purpose of the certificate.
     * @param certificateCreated Certificate creation time.
     * @param certificateLastUpdated Certificate last updated time.
     * @param certificateHasPrivateKey Indicates if the certificate contains private key.
     * @param certificateNonce Random number generated to indicate Proof of Possession.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return description of the response of the verification code along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<VerificationCodeResponseInner> generateVerificationCodeWithResponse(
        String certificateName,
        String ifMatch,
        String resourceGroupName,
        String provisioningServiceName,
        String certificateName1,
        byte[] certificateRawBytes,
        Boolean certificateIsVerified,
        CertificatePurpose certificatePurpose,
        OffsetDateTime certificateCreated,
        OffsetDateTime certificateLastUpdated,
        Boolean certificateHasPrivateKey,
        String certificateNonce,
        Context context) {
        return generateVerificationCodeWithResponseAsync(
                certificateName,
                ifMatch,
                resourceGroupName,
                provisioningServiceName,
                certificateName1,
                certificateRawBytes,
                certificateIsVerified,
                certificatePurpose,
                certificateCreated,
                certificateLastUpdated,
                certificateHasPrivateKey,
                certificateNonce,
                context)
            .block();
    }

    /**
     * Verifies the certificate's private key possession by providing the leaf cert issued by the verifying pre uploaded
     * certificate.
     *
     * @param certificateName The mandatory logical name of the certificate, that the provisioning service uses to
     *     access.
     * @param ifMatch ETag of the certificate.
     * @param resourceGroupName Resource group name.
     * @param provisioningServiceName Provisioning service name.
     * @param request The name of the certificate.
     * @param certificateName1 Common Name for the certificate.
     * @param certificateRawBytes Raw data of certificate.
     * @param certificateIsVerified Indicates if the certificate has been verified by owner of the private key.
     * @param certificatePurpose Describe the purpose of the certificate.
     * @param certificateCreated Certificate creation time.
     * @param certificateLastUpdated Certificate last updated time.
     * @param certificateHasPrivateKey Indicates if the certificate contains private key.
     * @param certificateNonce Random number generated to indicate Proof of Possession.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the X509 Certificate along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<CertificateResponseInner>> verifyCertificateWithResponseAsync(
        String certificateName,
        String ifMatch,
        String resourceGroupName,
        String provisioningServiceName,
        VerificationCodeRequest request,
        String certificateName1,
        byte[] certificateRawBytes,
        Boolean certificateIsVerified,
        CertificatePurpose certificatePurpose,
        OffsetDateTime certificateCreated,
        OffsetDateTime certificateLastUpdated,
        Boolean certificateHasPrivateKey,
        String certificateNonce) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (certificateName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter certificateName is required and cannot be null."));
        }
        if (ifMatch == null) {
            return Mono.error(new IllegalArgumentException("Parameter ifMatch is required and cannot be null."));
        }
        if (this.client.getSubscriptionId() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getSubscriptionId() is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        if (provisioningServiceName == null) {
            return Mono
                .error(
                    new IllegalArgumentException("Parameter provisioningServiceName is required and cannot be null."));
        }
        if (request == null) {
            return Mono.error(new IllegalArgumentException("Parameter request is required and cannot be null."));
        } else {
            request.validate();
        }
        final String accept = "application/json";
        String certificateRawBytesConverted = Base64Util.encodeToString(certificateRawBytes);
        return FluxUtil
            .withContext(
                context ->
                    service
                        .verifyCertificate(
                            this.client.getEndpoint(),
                            certificateName,
                            ifMatch,
                            this.client.getSubscriptionId(),
                            resourceGroupName,
                            provisioningServiceName,
                            certificateName1,
                            certificateRawBytesConverted,
                            certificateIsVerified,
                            certificatePurpose,
                            certificateCreated,
                            certificateLastUpdated,
                            certificateHasPrivateKey,
                            certificateNonce,
                            this.client.getApiVersion(),
                            request,
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Verifies the certificate's private key possession by providing the leaf cert issued by the verifying pre uploaded
     * certificate.
     *
     * @param certificateName The mandatory logical name of the certificate, that the provisioning service uses to
     *     access.
     * @param ifMatch ETag of the certificate.
     * @param resourceGroupName Resource group name.
     * @param provisioningServiceName Provisioning service name.
     * @param request The name of the certificate.
     * @param certificateName1 Common Name for the certificate.
     * @param certificateRawBytes Raw data of certificate.
     * @param certificateIsVerified Indicates if the certificate has been verified by owner of the private key.
     * @param certificatePurpose Describe the purpose of the certificate.
     * @param certificateCreated Certificate creation time.
     * @param certificateLastUpdated Certificate last updated time.
     * @param certificateHasPrivateKey Indicates if the certificate contains private key.
     * @param certificateNonce Random number generated to indicate Proof of Possession.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the X509 Certificate along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<CertificateResponseInner>> verifyCertificateWithResponseAsync(
        String certificateName,
        String ifMatch,
        String resourceGroupName,
        String provisioningServiceName,
        VerificationCodeRequest request,
        String certificateName1,
        byte[] certificateRawBytes,
        Boolean certificateIsVerified,
        CertificatePurpose certificatePurpose,
        OffsetDateTime certificateCreated,
        OffsetDateTime certificateLastUpdated,
        Boolean certificateHasPrivateKey,
        String certificateNonce,
        Context context) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (certificateName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter certificateName is required and cannot be null."));
        }
        if (ifMatch == null) {
            return Mono.error(new IllegalArgumentException("Parameter ifMatch is required and cannot be null."));
        }
        if (this.client.getSubscriptionId() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getSubscriptionId() is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        if (provisioningServiceName == null) {
            return Mono
                .error(
                    new IllegalArgumentException("Parameter provisioningServiceName is required and cannot be null."));
        }
        if (request == null) {
            return Mono.error(new IllegalArgumentException("Parameter request is required and cannot be null."));
        } else {
            request.validate();
        }
        final String accept = "application/json";
        String certificateRawBytesConverted = Base64Util.encodeToString(certificateRawBytes);
        context = this.client.mergeContext(context);
        return service
            .verifyCertificate(
                this.client.getEndpoint(),
                certificateName,
                ifMatch,
                this.client.getSubscriptionId(),
                resourceGroupName,
                provisioningServiceName,
                certificateName1,
                certificateRawBytesConverted,
                certificateIsVerified,
                certificatePurpose,
                certificateCreated,
                certificateLastUpdated,
                certificateHasPrivateKey,
                certificateNonce,
                this.client.getApiVersion(),
                request,
                accept,
                context);
    }

    /**
     * Verifies the certificate's private key possession by providing the leaf cert issued by the verifying pre uploaded
     * certificate.
     *
     * @param certificateName The mandatory logical name of the certificate, that the provisioning service uses to
     *     access.
     * @param ifMatch ETag of the certificate.
     * @param resourceGroupName Resource group name.
     * @param provisioningServiceName Provisioning service name.
     * @param request The name of the certificate.
     * @param certificateName1 Common Name for the certificate.
     * @param certificateRawBytes Raw data of certificate.
     * @param certificateIsVerified Indicates if the certificate has been verified by owner of the private key.
     * @param certificatePurpose Describe the purpose of the certificate.
     * @param certificateCreated Certificate creation time.
     * @param certificateLastUpdated Certificate last updated time.
     * @param certificateHasPrivateKey Indicates if the certificate contains private key.
     * @param certificateNonce Random number generated to indicate Proof of Possession.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the X509 Certificate on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<CertificateResponseInner> verifyCertificateAsync(
        String certificateName,
        String ifMatch,
        String resourceGroupName,
        String provisioningServiceName,
        VerificationCodeRequest request,
        String certificateName1,
        byte[] certificateRawBytes,
        Boolean certificateIsVerified,
        CertificatePurpose certificatePurpose,
        OffsetDateTime certificateCreated,
        OffsetDateTime certificateLastUpdated,
        Boolean certificateHasPrivateKey,
        String certificateNonce) {
        return verifyCertificateWithResponseAsync(
                certificateName,
                ifMatch,
                resourceGroupName,
                provisioningServiceName,
                request,
                certificateName1,
                certificateRawBytes,
                certificateIsVerified,
                certificatePurpose,
                certificateCreated,
                certificateLastUpdated,
                certificateHasPrivateKey,
                certificateNonce)
            .flatMap(res -> Mono.justOrEmpty(res.getValue()));
    }

    /**
     * Verifies the certificate's private key possession by providing the leaf cert issued by the verifying pre uploaded
     * certificate.
     *
     * @param certificateName The mandatory logical name of the certificate, that the provisioning service uses to
     *     access.
     * @param ifMatch ETag of the certificate.
     * @param resourceGroupName Resource group name.
     * @param provisioningServiceName Provisioning service name.
     * @param request The name of the certificate.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the X509 Certificate on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<CertificateResponseInner> verifyCertificateAsync(
        String certificateName,
        String ifMatch,
        String resourceGroupName,
        String provisioningServiceName,
        VerificationCodeRequest request) {
        final String certificateName1 = null;
        final byte[] certificateRawBytes = new byte[0];
        final Boolean certificateIsVerified = null;
        final CertificatePurpose certificatePurpose = null;
        final OffsetDateTime certificateCreated = null;
        final OffsetDateTime certificateLastUpdated = null;
        final Boolean certificateHasPrivateKey = null;
        final String certificateNonce = null;
        return verifyCertificateWithResponseAsync(
                certificateName,
                ifMatch,
                resourceGroupName,
                provisioningServiceName,
                request,
                certificateName1,
                certificateRawBytes,
                certificateIsVerified,
                certificatePurpose,
                certificateCreated,
                certificateLastUpdated,
                certificateHasPrivateKey,
                certificateNonce)
            .flatMap(res -> Mono.justOrEmpty(res.getValue()));
    }

    /**
     * Verifies the certificate's private key possession by providing the leaf cert issued by the verifying pre uploaded
     * certificate.
     *
     * @param certificateName The mandatory logical name of the certificate, that the provisioning service uses to
     *     access.
     * @param ifMatch ETag of the certificate.
     * @param resourceGroupName Resource group name.
     * @param provisioningServiceName Provisioning service name.
     * @param request The name of the certificate.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the X509 Certificate.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public CertificateResponseInner verifyCertificate(
        String certificateName,
        String ifMatch,
        String resourceGroupName,
        String provisioningServiceName,
        VerificationCodeRequest request) {
        final String certificateName1 = null;
        final byte[] certificateRawBytes = new byte[0];
        final Boolean certificateIsVerified = null;
        final CertificatePurpose certificatePurpose = null;
        final OffsetDateTime certificateCreated = null;
        final OffsetDateTime certificateLastUpdated = null;
        final Boolean certificateHasPrivateKey = null;
        final String certificateNonce = null;
        return verifyCertificateAsync(
                certificateName,
                ifMatch,
                resourceGroupName,
                provisioningServiceName,
                request,
                certificateName1,
                certificateRawBytes,
                certificateIsVerified,
                certificatePurpose,
                certificateCreated,
                certificateLastUpdated,
                certificateHasPrivateKey,
                certificateNonce)
            .block();
    }

    /**
     * Verifies the certificate's private key possession by providing the leaf cert issued by the verifying pre uploaded
     * certificate.
     *
     * @param certificateName The mandatory logical name of the certificate, that the provisioning service uses to
     *     access.
     * @param ifMatch ETag of the certificate.
     * @param resourceGroupName Resource group name.
     * @param provisioningServiceName Provisioning service name.
     * @param request The name of the certificate.
     * @param certificateName1 Common Name for the certificate.
     * @param certificateRawBytes Raw data of certificate.
     * @param certificateIsVerified Indicates if the certificate has been verified by owner of the private key.
     * @param certificatePurpose Describe the purpose of the certificate.
     * @param certificateCreated Certificate creation time.
     * @param certificateLastUpdated Certificate last updated time.
     * @param certificateHasPrivateKey Indicates if the certificate contains private key.
     * @param certificateNonce Random number generated to indicate Proof of Possession.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the X509 Certificate along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<CertificateResponseInner> verifyCertificateWithResponse(
        String certificateName,
        String ifMatch,
        String resourceGroupName,
        String provisioningServiceName,
        VerificationCodeRequest request,
        String certificateName1,
        byte[] certificateRawBytes,
        Boolean certificateIsVerified,
        CertificatePurpose certificatePurpose,
        OffsetDateTime certificateCreated,
        OffsetDateTime certificateLastUpdated,
        Boolean certificateHasPrivateKey,
        String certificateNonce,
        Context context) {
        return verifyCertificateWithResponseAsync(
                certificateName,
                ifMatch,
                resourceGroupName,
                provisioningServiceName,
                request,
                certificateName1,
                certificateRawBytes,
                certificateIsVerified,
                certificatePurpose,
                certificateCreated,
                certificateLastUpdated,
                certificateHasPrivateKey,
                certificateNonce,
                context)
            .block();
    }
}
