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

com.azure.resourcemanager.datafactory.fluent.models.PipelineResourceInner 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.core.management.SubResource;
import com.azure.core.util.logging.ClientLogger;
import com.azure.json.JsonReader;
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.LinkedHashMap;
import java.util.List;
import java.util.Map;

/**
 * Pipeline resource type.
 */
@Fluent
public final class PipelineResourceInner extends SubResource {
    /*
     * Properties of the pipeline.
     */
    private Pipeline innerProperties = new Pipeline();

    /*
     * The resource name.
     */
    private String name;

    /*
     * The resource type.
     */
    private String type;

    /*
     * Etag identifies change in the resource.
     */
    private String etag;

    /*
     * Pipeline resource type.
     */
    private Map additionalProperties;

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

    /**
     * Get the innerProperties property: Properties of the pipeline.
     * 
     * @return the innerProperties value.
     */
    private Pipeline innerProperties() {
        return this.innerProperties;
    }

    /**
     * Get the name property: The resource name.
     * 
     * @return the name value.
     */
    public String name() {
        return this.name;
    }

    /**
     * Get the type property: The resource type.
     * 
     * @return the type value.
     */
    public String type() {
        return this.type;
    }

    /**
     * Get the etag property: Etag identifies change in the resource.
     * 
     * @return the etag value.
     */
    public String etag() {
        return this.etag;
    }

    /**
     * Get the additionalProperties property: Pipeline resource type.
     * 
     * @return the additionalProperties value.
     */
    public Map additionalProperties() {
        return this.additionalProperties;
    }

    /**
     * Set the additionalProperties property: Pipeline resource type.
     * 
     * @param additionalProperties the additionalProperties value to set.
     * @return the PipelineResourceInner object itself.
     */
    public PipelineResourceInner withAdditionalProperties(Map additionalProperties) {
        this.additionalProperties = additionalProperties;
        return this;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public PipelineResourceInner withId(String id) {
        super.withId(id);
        return this;
    }

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

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

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

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

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

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

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

    /**
     * Set the variables property: List of variables for pipeline.
     * 
     * @param variables the variables value to set.
     * @return the PipelineResourceInner object itself.
     */
    public PipelineResourceInner withVariables(Map variables) {
        if (this.innerProperties() == null) {
            this.innerProperties = new Pipeline();
        }
        this.innerProperties().withVariables(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.innerProperties() == null ? null : this.innerProperties().concurrency();
    }

    /**
     * Set the concurrency property: The max number of concurrent runs for the pipeline.
     * 
     * @param concurrency the concurrency value to set.
     * @return the PipelineResourceInner object itself.
     */
    public PipelineResourceInner withConcurrency(Integer concurrency) {
        if (this.innerProperties() == null) {
            this.innerProperties = new Pipeline();
        }
        this.innerProperties().withConcurrency(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.innerProperties() == null ? null : this.innerProperties().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 PipelineResourceInner object itself.
     */
    public PipelineResourceInner withAnnotations(List annotations) {
        if (this.innerProperties() == null) {
            this.innerProperties = new Pipeline();
        }
        this.innerProperties().withAnnotations(annotations);
        return this;
    }

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

    /**
     * Set the runDimensions property: Dimensions emitted by Pipeline.
     * 
     * @param runDimensions the runDimensions value to set.
     * @return the PipelineResourceInner object itself.
     */
    public PipelineResourceInner withRunDimensions(Map runDimensions) {
        if (this.innerProperties() == null) {
            this.innerProperties = new Pipeline();
        }
        this.innerProperties().withRunDimensions(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.innerProperties() == null ? null : this.innerProperties().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 PipelineResourceInner object itself.
     */
    public PipelineResourceInner withFolder(PipelineFolder folder) {
        if (this.innerProperties() == null) {
            this.innerProperties = new Pipeline();
        }
        this.innerProperties().withFolder(folder);
        return this;
    }

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

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

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

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

    /**
     * {@inheritDoc}
     */
    @Override
    public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
        jsonWriter.writeStartObject();
        jsonWriter.writeStringField("id", id());
        jsonWriter.writeJsonField("properties", this.innerProperties);
        if (additionalProperties != null) {
            for (Map.Entry additionalProperty : additionalProperties.entrySet()) {
                jsonWriter.writeUntypedField(additionalProperty.getKey(), additionalProperty.getValue());
            }
        }
        return jsonWriter.writeEndObject();
    }

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

                if ("id".equals(fieldName)) {
                    deserializedPipelineResourceInner.withId(reader.getString());
                } else if ("properties".equals(fieldName)) {
                    deserializedPipelineResourceInner.innerProperties = Pipeline.fromJson(reader);
                } else if ("name".equals(fieldName)) {
                    deserializedPipelineResourceInner.name = reader.getString();
                } else if ("type".equals(fieldName)) {
                    deserializedPipelineResourceInner.type = reader.getString();
                } else if ("etag".equals(fieldName)) {
                    deserializedPipelineResourceInner.etag = reader.getString();
                } else {
                    if (additionalProperties == null) {
                        additionalProperties = new LinkedHashMap<>();
                    }

                    additionalProperties.put(fieldName, reader.readUntyped());
                }
            }
            deserializedPipelineResourceInner.additionalProperties = additionalProperties;

            return deserializedPipelineResourceInner;
        });
    }
}