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

package com.azure.resourcemanager.automation.models;

import com.azure.core.annotation.Fluent;
import com.azure.core.util.logging.ClientLogger;
import com.azure.resourcemanager.automation.fluent.models.CertificateCreateOrUpdateProperties;
import com.fasterxml.jackson.annotation.JsonProperty;

/** The parameters supplied to the create or update or replace certificate operation. */
@Fluent
public final class CertificateCreateOrUpdateParameters {
    /*
     * Gets or sets the name of the certificate.
     */
    @JsonProperty(value = "name", required = true)
    private String name;

    /*
     * Gets or sets the properties of the certificate.
     */
    @JsonProperty(value = "properties", required = true)
    private CertificateCreateOrUpdateProperties innerProperties = new CertificateCreateOrUpdateProperties();

    /**
     * Get the name property: Gets or sets the name of the certificate.
     *
     * @return the name value.
     */
    public String name() {
        return this.name;
    }

    /**
     * Set the name property: Gets or sets the name of the certificate.
     *
     * @param name the name value to set.
     * @return the CertificateCreateOrUpdateParameters object itself.
     */
    public CertificateCreateOrUpdateParameters withName(String name) {
        this.name = name;
        return this;
    }

    /**
     * Get the innerProperties property: Gets or sets the properties of the certificate.
     *
     * @return the innerProperties value.
     */
    private CertificateCreateOrUpdateProperties innerProperties() {
        return this.innerProperties;
    }

    /**
     * Get the base64Value property: Gets or sets the base64 encoded value of the certificate.
     *
     * @return the base64Value value.
     */
    public String base64Value() {
        return this.innerProperties() == null ? null : this.innerProperties().base64Value();
    }

    /**
     * Set the base64Value property: Gets or sets the base64 encoded value of the certificate.
     *
     * @param base64Value the base64Value value to set.
     * @return the CertificateCreateOrUpdateParameters object itself.
     */
    public CertificateCreateOrUpdateParameters withBase64Value(String base64Value) {
        if (this.innerProperties() == null) {
            this.innerProperties = new CertificateCreateOrUpdateProperties();
        }
        this.innerProperties().withBase64Value(base64Value);
        return this;
    }

    /**
     * Get the description property: Gets or sets the description of the certificate.
     *
     * @return the description value.
     */
    public String description() {
        return this.innerProperties() == null ? null : this.innerProperties().description();
    }

    /**
     * Set the description property: Gets or sets the description of the certificate.
     *
     * @param description the description value to set.
     * @return the CertificateCreateOrUpdateParameters object itself.
     */
    public CertificateCreateOrUpdateParameters withDescription(String description) {
        if (this.innerProperties() == null) {
            this.innerProperties = new CertificateCreateOrUpdateProperties();
        }
        this.innerProperties().withDescription(description);
        return this;
    }

    /**
     * Get the thumbprint property: Gets or sets the thumbprint of the certificate.
     *
     * @return the thumbprint value.
     */
    public String thumbprint() {
        return this.innerProperties() == null ? null : this.innerProperties().thumbprint();
    }

    /**
     * Set the thumbprint property: Gets or sets the thumbprint of the certificate.
     *
     * @param thumbprint the thumbprint value to set.
     * @return the CertificateCreateOrUpdateParameters object itself.
     */
    public CertificateCreateOrUpdateParameters withThumbprint(String thumbprint) {
        if (this.innerProperties() == null) {
            this.innerProperties = new CertificateCreateOrUpdateProperties();
        }
        this.innerProperties().withThumbprint(thumbprint);
        return this;
    }

    /**
     * Get the isExportable property: Gets or sets the is exportable flag of the certificate.
     *
     * @return the isExportable value.
     */
    public Boolean isExportable() {
        return this.innerProperties() == null ? null : this.innerProperties().isExportable();
    }

    /**
     * Set the isExportable property: Gets or sets the is exportable flag of the certificate.
     *
     * @param isExportable the isExportable value to set.
     * @return the CertificateCreateOrUpdateParameters object itself.
     */
    public CertificateCreateOrUpdateParameters withIsExportable(Boolean isExportable) {
        if (this.innerProperties() == null) {
            this.innerProperties = new CertificateCreateOrUpdateProperties();
        }
        this.innerProperties().withIsExportable(isExportable);
        return this;
    }

    /**
     * Validates the instance.
     *
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    public void validate() {
        if (name() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException(
                        "Missing required property name in model CertificateCreateOrUpdateParameters"));
        }
        if (innerProperties() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException(
                        "Missing required property innerProperties in model CertificateCreateOrUpdateParameters"));
        } else {
            innerProperties().validate();
        }
    }

    private static final ClientLogger LOGGER = new ClientLogger(CertificateCreateOrUpdateParameters.class);
}
