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

com.azure.resourcemanager.datafactory.models.SnowflakeSource 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.datafactory.models;

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

/**
 * A copy activity snowflake source.
 */
@Fluent
public final class SnowflakeSource extends CopySource {
    /*
     * Copy source type.
     */
    private String type = "SnowflakeSource";

    /*
     * Snowflake Sql query. Type: string (or Expression with resultType string).
     */
    private Object query;

    /*
     * Snowflake export settings.
     */
    private SnowflakeExportCopyCommand exportSettings;

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

    /**
     * Get the type property: Copy source type.
     * 
     * @return the type value.
     */
    @Override
    public String type() {
        return this.type;
    }

    /**
     * Get the query property: Snowflake Sql query. Type: string (or Expression with resultType string).
     * 
     * @return the query value.
     */
    public Object query() {
        return this.query;
    }

    /**
     * Set the query property: Snowflake Sql query. Type: string (or Expression with resultType string).
     * 
     * @param query the query value to set.
     * @return the SnowflakeSource object itself.
     */
    public SnowflakeSource withQuery(Object query) {
        this.query = query;
        return this;
    }

    /**
     * Get the exportSettings property: Snowflake export settings.
     * 
     * @return the exportSettings value.
     */
    public SnowflakeExportCopyCommand exportSettings() {
        return this.exportSettings;
    }

    /**
     * Set the exportSettings property: Snowflake export settings.
     * 
     * @param exportSettings the exportSettings value to set.
     * @return the SnowflakeSource object itself.
     */
    public SnowflakeSource withExportSettings(SnowflakeExportCopyCommand exportSettings) {
        this.exportSettings = exportSettings;
        return this;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public SnowflakeSource withSourceRetryCount(Object sourceRetryCount) {
        super.withSourceRetryCount(sourceRetryCount);
        return this;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public SnowflakeSource withSourceRetryWait(Object sourceRetryWait) {
        super.withSourceRetryWait(sourceRetryWait);
        return this;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public SnowflakeSource withMaxConcurrentConnections(Object maxConcurrentConnections) {
        super.withMaxConcurrentConnections(maxConcurrentConnections);
        return this;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public SnowflakeSource withDisableMetricsCollection(Object disableMetricsCollection) {
        super.withDisableMetricsCollection(disableMetricsCollection);
        return this;
    }

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

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

    /**
     * {@inheritDoc}
     */
    @Override
    public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
        jsonWriter.writeStartObject();
        jsonWriter.writeUntypedField("sourceRetryCount", sourceRetryCount());
        jsonWriter.writeUntypedField("sourceRetryWait", sourceRetryWait());
        jsonWriter.writeUntypedField("maxConcurrentConnections", maxConcurrentConnections());
        jsonWriter.writeUntypedField("disableMetricsCollection", disableMetricsCollection());
        jsonWriter.writeJsonField("exportSettings", this.exportSettings);
        jsonWriter.writeStringField("type", this.type);
        jsonWriter.writeUntypedField("query", this.query);
        if (additionalProperties() != null) {
            for (Map.Entry additionalProperty : additionalProperties().entrySet()) {
                jsonWriter.writeUntypedField(additionalProperty.getKey(), additionalProperty.getValue());
            }
        }
        return jsonWriter.writeEndObject();
    }

    /**
     * Reads an instance of SnowflakeSource from the JsonReader.
     * 
     * @param jsonReader The JsonReader being read.
     * @return An instance of SnowflakeSource 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 SnowflakeSource.
     */
    public static SnowflakeSource fromJson(JsonReader jsonReader) throws IOException {
        return jsonReader.readObject(reader -> {
            SnowflakeSource deserializedSnowflakeSource = new SnowflakeSource();
            Map additionalProperties = null;
            while (reader.nextToken() != JsonToken.END_OBJECT) {
                String fieldName = reader.getFieldName();
                reader.nextToken();

                if ("sourceRetryCount".equals(fieldName)) {
                    deserializedSnowflakeSource.withSourceRetryCount(reader.readUntyped());
                } else if ("sourceRetryWait".equals(fieldName)) {
                    deserializedSnowflakeSource.withSourceRetryWait(reader.readUntyped());
                } else if ("maxConcurrentConnections".equals(fieldName)) {
                    deserializedSnowflakeSource.withMaxConcurrentConnections(reader.readUntyped());
                } else if ("disableMetricsCollection".equals(fieldName)) {
                    deserializedSnowflakeSource.withDisableMetricsCollection(reader.readUntyped());
                } else if ("exportSettings".equals(fieldName)) {
                    deserializedSnowflakeSource.exportSettings = SnowflakeExportCopyCommand.fromJson(reader);
                } else if ("type".equals(fieldName)) {
                    deserializedSnowflakeSource.type = reader.getString();
                } else if ("query".equals(fieldName)) {
                    deserializedSnowflakeSource.query = reader.readUntyped();
                } else {
                    if (additionalProperties == null) {
                        additionalProperties = new LinkedHashMap<>();
                    }

                    additionalProperties.put(fieldName, reader.readUntyped());
                }
            }
            deserializedSnowflakeSource.withAdditionalProperties(additionalProperties);

            return deserializedSnowflakeSource;
        });
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy