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

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

/**
 * Power query source.
 */
@Fluent
public final class PowerQuerySource extends DataFlowSource {
    /*
     * source script.
     */
    private String script;

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

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

    /**
     * Set the script property: source script.
     * 
     * @param script the script value to set.
     * @return the PowerQuerySource object itself.
     */
    public PowerQuerySource withScript(String script) {
        this.script = script;
        return this;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public PowerQuerySource withSchemaLinkedService(LinkedServiceReference schemaLinkedService) {
        super.withSchemaLinkedService(schemaLinkedService);
        return this;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public PowerQuerySource withName(String name) {
        super.withName(name);
        return this;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public PowerQuerySource withDescription(String description) {
        super.withDescription(description);
        return this;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public PowerQuerySource withDataset(DatasetReference dataset) {
        super.withDataset(dataset);
        return this;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public PowerQuerySource withLinkedService(LinkedServiceReference linkedService) {
        super.withLinkedService(linkedService);
        return this;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public PowerQuerySource withFlowlet(DataFlowReference flowlet) {
        super.withFlowlet(flowlet);
        return this;
    }

    /**
     * Validates the instance.
     * 
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    @Override
    public void validate() {
        if (name() == null) {
            throw LOGGER.atError()
                .log(new IllegalArgumentException("Missing required property name in model PowerQuerySource"));
        }
        if (dataset() != null) {
            dataset().validate();
        }
        if (linkedService() != null) {
            linkedService().validate();
        }
        if (flowlet() != null) {
            flowlet().validate();
        }
        if (schemaLinkedService() != null) {
            schemaLinkedService().validate();
        }
    }

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

    /**
     * {@inheritDoc}
     */
    @Override
    public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
        jsonWriter.writeStartObject();
        jsonWriter.writeStringField("name", name());
        jsonWriter.writeStringField("description", description());
        jsonWriter.writeJsonField("dataset", dataset());
        jsonWriter.writeJsonField("linkedService", linkedService());
        jsonWriter.writeJsonField("flowlet", flowlet());
        jsonWriter.writeJsonField("schemaLinkedService", schemaLinkedService());
        jsonWriter.writeStringField("script", this.script);
        return jsonWriter.writeEndObject();
    }

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

                if ("name".equals(fieldName)) {
                    deserializedPowerQuerySource.withName(reader.getString());
                } else if ("description".equals(fieldName)) {
                    deserializedPowerQuerySource.withDescription(reader.getString());
                } else if ("dataset".equals(fieldName)) {
                    deserializedPowerQuerySource.withDataset(DatasetReference.fromJson(reader));
                } else if ("linkedService".equals(fieldName)) {
                    deserializedPowerQuerySource.withLinkedService(LinkedServiceReference.fromJson(reader));
                } else if ("flowlet".equals(fieldName)) {
                    deserializedPowerQuerySource.withFlowlet(DataFlowReference.fromJson(reader));
                } else if ("schemaLinkedService".equals(fieldName)) {
                    deserializedPowerQuerySource.withSchemaLinkedService(LinkedServiceReference.fromJson(reader));
                } else if ("script".equals(fieldName)) {
                    deserializedPowerQuerySource.script = reader.getString();
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedPowerQuerySource;
        });
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy