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

com.azure.resourcemanager.recoveryservices.models.RawCertificateData Maven / Gradle / Ivy

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

package com.azure.resourcemanager.recoveryservices.models;

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

/**
 * Raw certificate data.
 */
@Fluent
public final class RawCertificateData implements JsonSerializable {
    /*
     * Specifies the authentication type.
     */
    private AuthType authType;

    /*
     * The base64 encoded certificate raw data string
     */
    private byte[] certificate;

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

    /**
     * Get the authType property: Specifies the authentication type.
     * 
     * @return the authType value.
     */
    public AuthType authType() {
        return this.authType;
    }

    /**
     * Set the authType property: Specifies the authentication type.
     * 
     * @param authType the authType value to set.
     * @return the RawCertificateData object itself.
     */
    public RawCertificateData withAuthType(AuthType authType) {
        this.authType = authType;
        return this;
    }

    /**
     * Get the certificate property: The base64 encoded certificate raw data string.
     * 
     * @return the certificate value.
     */
    public byte[] certificate() {
        return CoreUtils.clone(this.certificate);
    }

    /**
     * Set the certificate property: The base64 encoded certificate raw data string.
     * 
     * @param certificate the certificate value to set.
     * @return the RawCertificateData object itself.
     */
    public RawCertificateData withCertificate(byte[] certificate) {
        this.certificate = CoreUtils.clone(certificate);
        return this;
    }

    /**
     * Validates the instance.
     * 
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    public void validate() {
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
        jsonWriter.writeStartObject();
        jsonWriter.writeStringField("authType", this.authType == null ? null : this.authType.toString());
        jsonWriter.writeBinaryField("certificate", this.certificate);
        return jsonWriter.writeEndObject();
    }

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

                if ("authType".equals(fieldName)) {
                    deserializedRawCertificateData.authType = AuthType.fromString(reader.getString());
                } else if ("certificate".equals(fieldName)) {
                    deserializedRawCertificateData.certificate = reader.getBinary();
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedRawCertificateData;
        });
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy