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

com.azure.resourcemanager.datafactory.models.GetMetadataActivity 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 com.azure.resourcemanager.datafactory.fluent.models.GetMetadataActivityTypeProperties;
import java.io.IOException;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

/**
 * Activity to get metadata of dataset.
 */
@Fluent
public final class GetMetadataActivity extends ExecutionActivity {
    /*
     * Type of activity.
     */
    private String type = "GetMetadata";

    /*
     * GetMetadata activity properties.
     */
    private GetMetadataActivityTypeProperties innerTypeProperties = new GetMetadataActivityTypeProperties();

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

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

    /**
     * Get the innerTypeProperties property: GetMetadata activity properties.
     * 
     * @return the innerTypeProperties value.
     */
    private GetMetadataActivityTypeProperties innerTypeProperties() {
        return this.innerTypeProperties;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public GetMetadataActivity withLinkedServiceName(LinkedServiceReference linkedServiceName) {
        super.withLinkedServiceName(linkedServiceName);
        return this;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public GetMetadataActivity withPolicy(ActivityPolicy policy) {
        super.withPolicy(policy);
        return this;
    }

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

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

    /**
     * {@inheritDoc}
     */
    @Override
    public GetMetadataActivity withState(ActivityState state) {
        super.withState(state);
        return this;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public GetMetadataActivity withOnInactiveMarkAs(ActivityOnInactiveMarkAs onInactiveMarkAs) {
        super.withOnInactiveMarkAs(onInactiveMarkAs);
        return this;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public GetMetadataActivity withDependsOn(List dependsOn) {
        super.withDependsOn(dependsOn);
        return this;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public GetMetadataActivity withUserProperties(List userProperties) {
        super.withUserProperties(userProperties);
        return this;
    }

    /**
     * Get the dataset property: GetMetadata activity dataset reference.
     * 
     * @return the dataset value.
     */
    public DatasetReference dataset() {
        return this.innerTypeProperties() == null ? null : this.innerTypeProperties().dataset();
    }

    /**
     * Set the dataset property: GetMetadata activity dataset reference.
     * 
     * @param dataset the dataset value to set.
     * @return the GetMetadataActivity object itself.
     */
    public GetMetadataActivity withDataset(DatasetReference dataset) {
        if (this.innerTypeProperties() == null) {
            this.innerTypeProperties = new GetMetadataActivityTypeProperties();
        }
        this.innerTypeProperties().withDataset(dataset);
        return this;
    }

    /**
     * Get the fieldList property: Fields of metadata to get from dataset.
     * 
     * @return the fieldList value.
     */
    public List fieldList() {
        return this.innerTypeProperties() == null ? null : this.innerTypeProperties().fieldList();
    }

    /**
     * Set the fieldList property: Fields of metadata to get from dataset.
     * 
     * @param fieldList the fieldList value to set.
     * @return the GetMetadataActivity object itself.
     */
    public GetMetadataActivity withFieldList(List fieldList) {
        if (this.innerTypeProperties() == null) {
            this.innerTypeProperties = new GetMetadataActivityTypeProperties();
        }
        this.innerTypeProperties().withFieldList(fieldList);
        return this;
    }

    /**
     * Get the storeSettings property: GetMetadata activity store settings.
     * 
     * @return the storeSettings value.
     */
    public StoreReadSettings storeSettings() {
        return this.innerTypeProperties() == null ? null : this.innerTypeProperties().storeSettings();
    }

    /**
     * Set the storeSettings property: GetMetadata activity store settings.
     * 
     * @param storeSettings the storeSettings value to set.
     * @return the GetMetadataActivity object itself.
     */
    public GetMetadataActivity withStoreSettings(StoreReadSettings storeSettings) {
        if (this.innerTypeProperties() == null) {
            this.innerTypeProperties = new GetMetadataActivityTypeProperties();
        }
        this.innerTypeProperties().withStoreSettings(storeSettings);
        return this;
    }

    /**
     * Get the formatSettings property: GetMetadata activity format settings.
     * 
     * @return the formatSettings value.
     */
    public FormatReadSettings formatSettings() {
        return this.innerTypeProperties() == null ? null : this.innerTypeProperties().formatSettings();
    }

    /**
     * Set the formatSettings property: GetMetadata activity format settings.
     * 
     * @param formatSettings the formatSettings value to set.
     * @return the GetMetadataActivity object itself.
     */
    public GetMetadataActivity withFormatSettings(FormatReadSettings formatSettings) {
        if (this.innerTypeProperties() == null) {
            this.innerTypeProperties = new GetMetadataActivityTypeProperties();
        }
        this.innerTypeProperties().withFormatSettings(formatSettings);
        return this;
    }

    /**
     * Validates the instance.
     * 
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    @Override
    public void validate() {
        if (innerTypeProperties() == null) {
            throw LOGGER.atError()
                .log(new IllegalArgumentException(
                    "Missing required property innerTypeProperties in model GetMetadataActivity"));
        } else {
            innerTypeProperties().validate();
        }
        if (name() == null) {
            throw LOGGER.atError()
                .log(new IllegalArgumentException("Missing required property name in model GetMetadataActivity"));
        }
        if (dependsOn() != null) {
            dependsOn().forEach(e -> e.validate());
        }
        if (userProperties() != null) {
            userProperties().forEach(e -> e.validate());
        }
        if (linkedServiceName() != null) {
            linkedServiceName().validate();
        }
        if (policy() != null) {
            policy().validate();
        }
    }

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

    /**
     * {@inheritDoc}
     */
    @Override
    public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
        jsonWriter.writeStartObject();
        jsonWriter.writeStringField("name", name());
        jsonWriter.writeStringField("description", description());
        jsonWriter.writeStringField("state", state() == null ? null : state().toString());
        jsonWriter.writeStringField("onInactiveMarkAs",
            onInactiveMarkAs() == null ? null : onInactiveMarkAs().toString());
        jsonWriter.writeArrayField("dependsOn", dependsOn(), (writer, element) -> writer.writeJson(element));
        jsonWriter.writeArrayField("userProperties", userProperties(), (writer, element) -> writer.writeJson(element));
        jsonWriter.writeJsonField("linkedServiceName", linkedServiceName());
        jsonWriter.writeJsonField("policy", policy());
        jsonWriter.writeJsonField("typeProperties", this.innerTypeProperties);
        jsonWriter.writeStringField("type", this.type);
        if (additionalProperties() != null) {
            for (Map.Entry additionalProperty : additionalProperties().entrySet()) {
                jsonWriter.writeUntypedField(additionalProperty.getKey(), additionalProperty.getValue());
            }
        }
        return jsonWriter.writeEndObject();
    }

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

                if ("name".equals(fieldName)) {
                    deserializedGetMetadataActivity.withName(reader.getString());
                } else if ("description".equals(fieldName)) {
                    deserializedGetMetadataActivity.withDescription(reader.getString());
                } else if ("state".equals(fieldName)) {
                    deserializedGetMetadataActivity.withState(ActivityState.fromString(reader.getString()));
                } else if ("onInactiveMarkAs".equals(fieldName)) {
                    deserializedGetMetadataActivity
                        .withOnInactiveMarkAs(ActivityOnInactiveMarkAs.fromString(reader.getString()));
                } else if ("dependsOn".equals(fieldName)) {
                    List dependsOn
                        = reader.readArray(reader1 -> ActivityDependency.fromJson(reader1));
                    deserializedGetMetadataActivity.withDependsOn(dependsOn);
                } else if ("userProperties".equals(fieldName)) {
                    List userProperties = reader.readArray(reader1 -> UserProperty.fromJson(reader1));
                    deserializedGetMetadataActivity.withUserProperties(userProperties);
                } else if ("linkedServiceName".equals(fieldName)) {
                    deserializedGetMetadataActivity.withLinkedServiceName(LinkedServiceReference.fromJson(reader));
                } else if ("policy".equals(fieldName)) {
                    deserializedGetMetadataActivity.withPolicy(ActivityPolicy.fromJson(reader));
                } else if ("typeProperties".equals(fieldName)) {
                    deserializedGetMetadataActivity.innerTypeProperties
                        = GetMetadataActivityTypeProperties.fromJson(reader);
                } else if ("type".equals(fieldName)) {
                    deserializedGetMetadataActivity.type = reader.getString();
                } else {
                    if (additionalProperties == null) {
                        additionalProperties = new LinkedHashMap<>();
                    }

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

            return deserializedGetMetadataActivity;
        });
    }
}