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

com.azure.resourcemanager.datafactory.fluent.models.Pipeline 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.fluent.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 com.azure.resourcemanager.datafactory.models.Activity;
import com.azure.resourcemanager.datafactory.models.ParameterSpecification;
import com.azure.resourcemanager.datafactory.models.PipelineFolder;
import com.azure.resourcemanager.datafactory.models.PipelinePolicy;
import com.azure.resourcemanager.datafactory.models.VariableSpecification;
import java.io.IOException;
import java.util.List;
import java.util.Map;

/**
 * A data factory pipeline.
 */
@Fluent
public final class Pipeline implements JsonSerializable {
    /*
     * The description of the pipeline.
     */
    private String description;

    /*
     * List of activities in pipeline.
     */
    private List activities;

    /*
     * List of parameters for pipeline.
     */
    private Map parameters;

    /*
     * List of variables for pipeline.
     */
    private Map variables;

    /*
     * The max number of concurrent runs for the pipeline.
     */
    private Integer concurrency;

    /*
     * List of tags that can be used for describing the Pipeline.
     */
    private List annotations;

    /*
     * Dimensions emitted by Pipeline.
     */
    private Map runDimensions;

    /*
     * The folder that this Pipeline is in. If not specified, Pipeline will appear at the root level.
     */
    private PipelineFolder folder;

    /*
     * Pipeline Policy.
     */
    private PipelinePolicy policy;

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

    /**
     * Get the description property: The description of the pipeline.
     * 
     * @return the description value.
     */
    public String description() {
        return this.description;
    }

    /**
     * Set the description property: The description of the pipeline.
     * 
     * @param description the description value to set.
     * @return the Pipeline object itself.
     */
    public Pipeline withDescription(String description) {
        this.description = description;
        return this;
    }

    /**
     * Get the activities property: List of activities in pipeline.
     * 
     * @return the activities value.
     */
    public List activities() {
        return this.activities;
    }

    /**
     * Set the activities property: List of activities in pipeline.
     * 
     * @param activities the activities value to set.
     * @return the Pipeline object itself.
     */
    public Pipeline withActivities(List activities) {
        this.activities = activities;
        return this;
    }

    /**
     * Get the parameters property: List of parameters for pipeline.
     * 
     * @return the parameters value.
     */
    public Map parameters() {
        return this.parameters;
    }

    /**
     * Set the parameters property: List of parameters for pipeline.
     * 
     * @param parameters the parameters value to set.
     * @return the Pipeline object itself.
     */
    public Pipeline withParameters(Map parameters) {
        this.parameters = parameters;
        return this;
    }

    /**
     * Get the variables property: List of variables for pipeline.
     * 
     * @return the variables value.
     */
    public Map variables() {
        return this.variables;
    }

    /**
     * Set the variables property: List of variables for pipeline.
     * 
     * @param variables the variables value to set.
     * @return the Pipeline object itself.
     */
    public Pipeline withVariables(Map variables) {
        this.variables = variables;
        return this;
    }

    /**
     * Get the concurrency property: The max number of concurrent runs for the pipeline.
     * 
     * @return the concurrency value.
     */
    public Integer concurrency() {
        return this.concurrency;
    }

    /**
     * Set the concurrency property: The max number of concurrent runs for the pipeline.
     * 
     * @param concurrency the concurrency value to set.
     * @return the Pipeline object itself.
     */
    public Pipeline withConcurrency(Integer concurrency) {
        this.concurrency = concurrency;
        return this;
    }

    /**
     * Get the annotations property: List of tags that can be used for describing the Pipeline.
     * 
     * @return the annotations value.
     */
    public List annotations() {
        return this.annotations;
    }

    /**
     * Set the annotations property: List of tags that can be used for describing the Pipeline.
     * 
     * @param annotations the annotations value to set.
     * @return the Pipeline object itself.
     */
    public Pipeline withAnnotations(List annotations) {
        this.annotations = annotations;
        return this;
    }

    /**
     * Get the runDimensions property: Dimensions emitted by Pipeline.
     * 
     * @return the runDimensions value.
     */
    public Map runDimensions() {
        return this.runDimensions;
    }

    /**
     * Set the runDimensions property: Dimensions emitted by Pipeline.
     * 
     * @param runDimensions the runDimensions value to set.
     * @return the Pipeline object itself.
     */
    public Pipeline withRunDimensions(Map runDimensions) {
        this.runDimensions = runDimensions;
        return this;
    }

    /**
     * Get the folder property: The folder that this Pipeline is in. If not specified, Pipeline will appear at the root
     * level.
     * 
     * @return the folder value.
     */
    public PipelineFolder folder() {
        return this.folder;
    }

    /**
     * Set the folder property: The folder that this Pipeline is in. If not specified, Pipeline will appear at the root
     * level.
     * 
     * @param folder the folder value to set.
     * @return the Pipeline object itself.
     */
    public Pipeline withFolder(PipelineFolder folder) {
        this.folder = folder;
        return this;
    }

    /**
     * Get the policy property: Pipeline Policy.
     * 
     * @return the policy value.
     */
    public PipelinePolicy policy() {
        return this.policy;
    }

    /**
     * Set the policy property: Pipeline Policy.
     * 
     * @param policy the policy value to set.
     * @return the Pipeline object itself.
     */
    public Pipeline withPolicy(PipelinePolicy policy) {
        this.policy = policy;
        return this;
    }

    /**
     * Validates the instance.
     * 
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    public void validate() {
        if (activities() != null) {
            activities().forEach(e -> e.validate());
        }
        if (parameters() != null) {
            parameters().values().forEach(e -> {
                if (e != null) {
                    e.validate();
                }
            });
        }
        if (variables() != null) {
            variables().values().forEach(e -> {
                if (e != null) {
                    e.validate();
                }
            });
        }
        if (folder() != null) {
            folder().validate();
        }
        if (policy() != null) {
            policy().validate();
        }
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
        jsonWriter.writeStartObject();
        jsonWriter.writeStringField("description", this.description);
        jsonWriter.writeArrayField("activities", this.activities, (writer, element) -> writer.writeJson(element));
        jsonWriter.writeMapField("parameters", this.parameters, (writer, element) -> writer.writeJson(element));
        jsonWriter.writeMapField("variables", this.variables, (writer, element) -> writer.writeJson(element));
        jsonWriter.writeNumberField("concurrency", this.concurrency);
        jsonWriter.writeArrayField("annotations", this.annotations, (writer, element) -> writer.writeUntyped(element));
        jsonWriter.writeMapField("runDimensions", this.runDimensions,
            (writer, element) -> writer.writeUntyped(element));
        jsonWriter.writeJsonField("folder", this.folder);
        jsonWriter.writeJsonField("policy", this.policy);
        return jsonWriter.writeEndObject();
    }

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

                if ("description".equals(fieldName)) {
                    deserializedPipeline.description = reader.getString();
                } else if ("activities".equals(fieldName)) {
                    List activities = reader.readArray(reader1 -> Activity.fromJson(reader1));
                    deserializedPipeline.activities = activities;
                } else if ("parameters".equals(fieldName)) {
                    Map parameters
                        = reader.readMap(reader1 -> ParameterSpecification.fromJson(reader1));
                    deserializedPipeline.parameters = parameters;
                } else if ("variables".equals(fieldName)) {
                    Map variables
                        = reader.readMap(reader1 -> VariableSpecification.fromJson(reader1));
                    deserializedPipeline.variables = variables;
                } else if ("concurrency".equals(fieldName)) {
                    deserializedPipeline.concurrency = reader.getNullable(JsonReader::getInt);
                } else if ("annotations".equals(fieldName)) {
                    List annotations = reader.readArray(reader1 -> reader1.readUntyped());
                    deserializedPipeline.annotations = annotations;
                } else if ("runDimensions".equals(fieldName)) {
                    Map runDimensions = reader.readMap(reader1 -> reader1.readUntyped());
                    deserializedPipeline.runDimensions = runDimensions;
                } else if ("folder".equals(fieldName)) {
                    deserializedPipeline.folder = PipelineFolder.fromJson(reader);
                } else if ("policy".equals(fieldName)) {
                    deserializedPipeline.policy = PipelinePolicy.fromJson(reader);
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedPipeline;
        });
    }
}