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

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

/**
 * This activity verifies that an external resource exists.
 */
@Fluent
public final class ValidationActivity extends ControlActivity {
    /*
     * Type of activity.
     */
    private String type = "Validation";

    /*
     * Validation activity properties.
     */
    private ValidationActivityTypeProperties innerTypeProperties = new ValidationActivityTypeProperties();

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

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

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

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

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

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

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

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

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

    /**
     * Get the timeout property: Specifies the timeout for the activity to run. If there is no value specified, it takes
     * the value of TimeSpan.FromDays(7) which is 1 week as default. Type: string (or Expression with resultType
     * string), pattern: ((\d+)\.)?(\d\d):(60|([0-5][0-9])):(60|([0-5][0-9])).
     * 
     * @return the timeout value.
     */
    public Object timeout() {
        return this.innerTypeProperties() == null ? null : this.innerTypeProperties().timeout();
    }

    /**
     * Set the timeout property: Specifies the timeout for the activity to run. If there is no value specified, it takes
     * the value of TimeSpan.FromDays(7) which is 1 week as default. Type: string (or Expression with resultType
     * string), pattern: ((\d+)\.)?(\d\d):(60|([0-5][0-9])):(60|([0-5][0-9])).
     * 
     * @param timeout the timeout value to set.
     * @return the ValidationActivity object itself.
     */
    public ValidationActivity withTimeout(Object timeout) {
        if (this.innerTypeProperties() == null) {
            this.innerTypeProperties = new ValidationActivityTypeProperties();
        }
        this.innerTypeProperties().withTimeout(timeout);
        return this;
    }

    /**
     * Get the sleep property: A delay in seconds between validation attempts. If no value is specified, 10 seconds will
     * be used as the default. Type: integer (or Expression with resultType integer).
     * 
     * @return the sleep value.
     */
    public Object sleep() {
        return this.innerTypeProperties() == null ? null : this.innerTypeProperties().sleep();
    }

    /**
     * Set the sleep property: A delay in seconds between validation attempts. If no value is specified, 10 seconds will
     * be used as the default. Type: integer (or Expression with resultType integer).
     * 
     * @param sleep the sleep value to set.
     * @return the ValidationActivity object itself.
     */
    public ValidationActivity withSleep(Object sleep) {
        if (this.innerTypeProperties() == null) {
            this.innerTypeProperties = new ValidationActivityTypeProperties();
        }
        this.innerTypeProperties().withSleep(sleep);
        return this;
    }

    /**
     * Get the minimumSize property: Can be used if dataset points to a file. The file must be greater than or equal in
     * size to the value specified. Type: integer (or Expression with resultType integer).
     * 
     * @return the minimumSize value.
     */
    public Object minimumSize() {
        return this.innerTypeProperties() == null ? null : this.innerTypeProperties().minimumSize();
    }

    /**
     * Set the minimumSize property: Can be used if dataset points to a file. The file must be greater than or equal in
     * size to the value specified. Type: integer (or Expression with resultType integer).
     * 
     * @param minimumSize the minimumSize value to set.
     * @return the ValidationActivity object itself.
     */
    public ValidationActivity withMinimumSize(Object minimumSize) {
        if (this.innerTypeProperties() == null) {
            this.innerTypeProperties = new ValidationActivityTypeProperties();
        }
        this.innerTypeProperties().withMinimumSize(minimumSize);
        return this;
    }

    /**
     * Get the childItems property: Can be used if dataset points to a folder. If set to true, the folder must have at
     * least one file. If set to false, the folder must be empty. Type: boolean (or Expression with resultType boolean).
     * 
     * @return the childItems value.
     */
    public Object childItems() {
        return this.innerTypeProperties() == null ? null : this.innerTypeProperties().childItems();
    }

    /**
     * Set the childItems property: Can be used if dataset points to a folder. If set to true, the folder must have at
     * least one file. If set to false, the folder must be empty. Type: boolean (or Expression with resultType boolean).
     * 
     * @param childItems the childItems value to set.
     * @return the ValidationActivity object itself.
     */
    public ValidationActivity withChildItems(Object childItems) {
        if (this.innerTypeProperties() == null) {
            this.innerTypeProperties = new ValidationActivityTypeProperties();
        }
        this.innerTypeProperties().withChildItems(childItems);
        return this;
    }

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

    /**
     * Set the dataset property: Validation activity dataset reference.
     * 
     * @param dataset the dataset value to set.
     * @return the ValidationActivity object itself.
     */
    public ValidationActivity withDataset(DatasetReference dataset) {
        if (this.innerTypeProperties() == null) {
            this.innerTypeProperties = new ValidationActivityTypeProperties();
        }
        this.innerTypeProperties().withDataset(dataset);
        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 ValidationActivity"));
        } else {
            innerTypeProperties().validate();
        }
        if (name() == null) {
            throw LOGGER.atError()
                .log(new IllegalArgumentException("Missing required property name in model ValidationActivity"));
        }
        if (dependsOn() != null) {
            dependsOn().forEach(e -> e.validate());
        }
        if (userProperties() != null) {
            userProperties().forEach(e -> e.validate());
        }
    }

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

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

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

            return deserializedValidationActivity;
        });
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy