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

com.azure.ai.metricsadvisor.implementation.models.DataSourceCredential Maven / Gradle / Ivy

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.ai.metricsadvisor.implementation.models;

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

/**
 * The DataSourceCredential model.
 */
@Fluent
public class DataSourceCredential implements JsonSerializable {
    /*
     * Unique id of data source credential
     */
    private UUID dataSourceCredentialId;

    /*
     * Name of data source credential
     */
    private String dataSourceCredentialName;

    /*
     * Description of data source credential
     */
    private String dataSourceCredentialDescription;

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

    /**
     * Get the dataSourceCredentialId property: Unique id of data source credential.
     * 
     * @return the dataSourceCredentialId value.
     */
    public UUID getDataSourceCredentialId() {
        return this.dataSourceCredentialId;
    }

    /**
     * Set the dataSourceCredentialId property: Unique id of data source credential.
     * 
     * @param dataSourceCredentialId the dataSourceCredentialId value to set.
     * @return the DataSourceCredential object itself.
     */
    DataSourceCredential setDataSourceCredentialId(UUID dataSourceCredentialId) {
        this.dataSourceCredentialId = dataSourceCredentialId;
        return this;
    }

    /**
     * Get the dataSourceCredentialName property: Name of data source credential.
     * 
     * @return the dataSourceCredentialName value.
     */
    public String getDataSourceCredentialName() {
        return this.dataSourceCredentialName;
    }

    /**
     * Set the dataSourceCredentialName property: Name of data source credential.
     * 
     * @param dataSourceCredentialName the dataSourceCredentialName value to set.
     * @return the DataSourceCredential object itself.
     */
    public DataSourceCredential setDataSourceCredentialName(String dataSourceCredentialName) {
        this.dataSourceCredentialName = dataSourceCredentialName;
        return this;
    }

    /**
     * Get the dataSourceCredentialDescription property: Description of data source credential.
     * 
     * @return the dataSourceCredentialDescription value.
     */
    public String getDataSourceCredentialDescription() {
        return this.dataSourceCredentialDescription;
    }

    /**
     * Set the dataSourceCredentialDescription property: Description of data source credential.
     * 
     * @param dataSourceCredentialDescription the dataSourceCredentialDescription value to set.
     * @return the DataSourceCredential object itself.
     */
    public DataSourceCredential setDataSourceCredentialDescription(String dataSourceCredentialDescription) {
        this.dataSourceCredentialDescription = dataSourceCredentialDescription;
        return this;
    }

    @Override
    public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
        jsonWriter.writeStartObject();
        jsonWriter.writeStringField("dataSourceCredentialName", this.dataSourceCredentialName);
        jsonWriter.writeStringField("dataSourceCredentialDescription", this.dataSourceCredentialDescription);
        return jsonWriter.writeEndObject();
    }

    /**
     * Reads an instance of DataSourceCredential from the JsonReader.
     * 
     * @param jsonReader The JsonReader being read.
     * @return An instance of DataSourceCredential 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 or the
     * polymorphic discriminator.
     * @throws IOException If an error occurs while reading the DataSourceCredential.
     */
    public static DataSourceCredential fromJson(JsonReader jsonReader) throws IOException {
        return jsonReader.readObject(reader -> {
            String discriminatorValue = null;
            JsonReader readerToUse = reader.bufferObject();

            readerToUse.nextToken(); // Prepare for reading
            while (readerToUse.nextToken() != JsonToken.END_OBJECT) {
                String fieldName = readerToUse.getFieldName();
                readerToUse.nextToken();
                if ("dataSourceCredentialType".equals(fieldName)) {
                    discriminatorValue = readerToUse.getString();
                    break;
                } else {
                    readerToUse.skipChildren();
                }
            }
            // Use the discriminator value to determine which subtype should be deserialized.
            if ("AzureSQLConnectionString".equals(discriminatorValue)) {
                return AzureSQLConnectionStringCredential.fromJson(readerToUse.reset());
            } else if ("DataLakeGen2SharedKey".equals(discriminatorValue)) {
                return DataLakeGen2SharedKeyCredential.fromJson(readerToUse.reset());
            } else if ("ServicePrincipal".equals(discriminatorValue)) {
                return ServicePrincipalCredential.fromJson(readerToUse.reset());
            } else if ("ServicePrincipalInKV".equals(discriminatorValue)) {
                return ServicePrincipalInKVCredential.fromJson(readerToUse.reset());
            } else {
                return fromJsonKnownDiscriminator(readerToUse.reset());
            }
        });
    }

    static DataSourceCredential fromJsonKnownDiscriminator(JsonReader jsonReader) throws IOException {
        return jsonReader.readObject(reader -> {
            DataSourceCredential deserializedDataSourceCredential = new DataSourceCredential();
            while (reader.nextToken() != JsonToken.END_OBJECT) {
                String fieldName = reader.getFieldName();
                reader.nextToken();

                if ("dataSourceCredentialName".equals(fieldName)) {
                    deserializedDataSourceCredential.dataSourceCredentialName = reader.getString();
                } else if ("dataSourceCredentialId".equals(fieldName)) {
                    deserializedDataSourceCredential.dataSourceCredentialId
                        = reader.getNullable(nonNullReader -> UUID.fromString(nonNullReader.getString()));
                } else if ("dataSourceCredentialDescription".equals(fieldName)) {
                    deserializedDataSourceCredential.dataSourceCredentialDescription = reader.getString();
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedDataSourceCredential;
        });
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy