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

com.azure.resourcemanager.automation.fluent.models.CertificateCreateOrUpdateProperties Maven / Gradle / Ivy

Go to download

This package contains Microsoft Azure SDK for Automation Management SDK. For documentation on how to use this package, please see https://aka.ms/azsdk/java/mgmt. Automation Client. Package tag package-2022-02-22.

The newest version!
// 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.fluent.models;

import com.azure.core.annotation.Fluent;
import com.azure.core.util.logging.ClientLogger;
import com.azure.json.JsonReader;
import com.azure.json.JsonSerializable;
import com.azure.json.JsonToken;
import com.azure.json.JsonWriter;
import java.io.IOException;

/**
 * The properties of the create certificate operation.
 */
@Fluent
public final class CertificateCreateOrUpdateProperties
    implements JsonSerializable {
    /*
     * Gets or sets the base64 encoded value of the certificate.
     */
    private String base64Value;

    /*
     * Gets or sets the description of the certificate.
     */
    private String description;

    /*
     * Gets or sets the thumbprint of the certificate.
     */
    private String thumbprint;

    /*
     * Gets or sets the is exportable flag of the certificate.
     */
    private Boolean isExportable;

    /**
     * Creates an instance of CertificateCreateOrUpdateProperties class.
     */
    public CertificateCreateOrUpdateProperties() {
    }

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

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

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

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

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

    /**
     * Set the thumbprint property: Gets or sets the thumbprint of the certificate.
     * 
     * @param thumbprint the thumbprint value to set.
     * @return the CertificateCreateOrUpdateProperties object itself.
     */
    public CertificateCreateOrUpdateProperties withThumbprint(String thumbprint) {
        this.thumbprint = 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.isExportable;
    }

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

    /**
     * Validates the instance.
     * 
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    public void validate() {
        if (base64Value() == null) {
            throw LOGGER.atError()
                .log(new IllegalArgumentException(
                    "Missing required property base64Value in model CertificateCreateOrUpdateProperties"));
        }
    }

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

    /**
     * {@inheritDoc}
     */
    @Override
    public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
        jsonWriter.writeStartObject();
        jsonWriter.writeStringField("base64Value", this.base64Value);
        jsonWriter.writeStringField("description", this.description);
        jsonWriter.writeStringField("thumbprint", this.thumbprint);
        jsonWriter.writeBooleanField("isExportable", this.isExportable);
        return jsonWriter.writeEndObject();
    }

    /**
     * Reads an instance of CertificateCreateOrUpdateProperties from the JsonReader.
     * 
     * @param jsonReader The JsonReader being read.
     * @return An instance of CertificateCreateOrUpdateProperties if the JsonReader was pointing to an instance of it,
     * or null if it was pointing to JSON null.
     * @throws IllegalStateException If the deserialized JSON object was missing any required properties.
     * @throws IOException If an error occurs while reading the CertificateCreateOrUpdateProperties.
     */
    public static CertificateCreateOrUpdateProperties fromJson(JsonReader jsonReader) throws IOException {
        return jsonReader.readObject(reader -> {
            CertificateCreateOrUpdateProperties deserializedCertificateCreateOrUpdateProperties
                = new CertificateCreateOrUpdateProperties();
            while (reader.nextToken() != JsonToken.END_OBJECT) {
                String fieldName = reader.getFieldName();
                reader.nextToken();

                if ("base64Value".equals(fieldName)) {
                    deserializedCertificateCreateOrUpdateProperties.base64Value = reader.getString();
                } else if ("description".equals(fieldName)) {
                    deserializedCertificateCreateOrUpdateProperties.description = reader.getString();
                } else if ("thumbprint".equals(fieldName)) {
                    deserializedCertificateCreateOrUpdateProperties.thumbprint = reader.getString();
                } else if ("isExportable".equals(fieldName)) {
                    deserializedCertificateCreateOrUpdateProperties.isExportable
                        = reader.getNullable(JsonReader::getBoolean);
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedCertificateCreateOrUpdateProperties;
        });
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy