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

com.azure.resourcemanager.datafactory.models.RerunTumblingWindowTrigger 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.RerunTumblingWindowTriggerTypeProperties;
import java.io.IOException;
import java.time.OffsetDateTime;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

/**
 * Trigger that schedules pipeline reruns for all fixed time interval windows from a requested start time to requested
 * end time.
 */
@Fluent
public final class RerunTumblingWindowTrigger extends Trigger {
    /*
     * Trigger type.
     */
    private String type = "RerunTumblingWindowTrigger";

    /*
     * Rerun Trigger properties.
     */
    private RerunTumblingWindowTriggerTypeProperties innerTypeProperties
        = new RerunTumblingWindowTriggerTypeProperties();

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

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

    /**
     * Get the innerTypeProperties property: Rerun Trigger properties.
     * 
     * @return the innerTypeProperties value.
     */
    private RerunTumblingWindowTriggerTypeProperties innerTypeProperties() {
        return this.innerTypeProperties;
    }

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

    /**
     * {@inheritDoc}
     */
    @Override
    public RerunTumblingWindowTrigger withAnnotations(List annotations) {
        super.withAnnotations(annotations);
        return this;
    }

    /**
     * Get the parentTrigger property: The parent trigger reference.
     * 
     * @return the parentTrigger value.
     */
    public Object parentTrigger() {
        return this.innerTypeProperties() == null ? null : this.innerTypeProperties().parentTrigger();
    }

    /**
     * Set the parentTrigger property: The parent trigger reference.
     * 
     * @param parentTrigger the parentTrigger value to set.
     * @return the RerunTumblingWindowTrigger object itself.
     */
    public RerunTumblingWindowTrigger withParentTrigger(Object parentTrigger) {
        if (this.innerTypeProperties() == null) {
            this.innerTypeProperties = new RerunTumblingWindowTriggerTypeProperties();
        }
        this.innerTypeProperties().withParentTrigger(parentTrigger);
        return this;
    }

    /**
     * Get the requestedStartTime property: The start time for the time period for which restatement is initiated. Only
     * UTC time is currently supported.
     * 
     * @return the requestedStartTime value.
     */
    public OffsetDateTime requestedStartTime() {
        return this.innerTypeProperties() == null ? null : this.innerTypeProperties().requestedStartTime();
    }

    /**
     * Set the requestedStartTime property: The start time for the time period for which restatement is initiated. Only
     * UTC time is currently supported.
     * 
     * @param requestedStartTime the requestedStartTime value to set.
     * @return the RerunTumblingWindowTrigger object itself.
     */
    public RerunTumblingWindowTrigger withRequestedStartTime(OffsetDateTime requestedStartTime) {
        if (this.innerTypeProperties() == null) {
            this.innerTypeProperties = new RerunTumblingWindowTriggerTypeProperties();
        }
        this.innerTypeProperties().withRequestedStartTime(requestedStartTime);
        return this;
    }

    /**
     * Get the requestedEndTime property: The end time for the time period for which restatement is initiated. Only UTC
     * time is currently supported.
     * 
     * @return the requestedEndTime value.
     */
    public OffsetDateTime requestedEndTime() {
        return this.innerTypeProperties() == null ? null : this.innerTypeProperties().requestedEndTime();
    }

    /**
     * Set the requestedEndTime property: The end time for the time period for which restatement is initiated. Only UTC
     * time is currently supported.
     * 
     * @param requestedEndTime the requestedEndTime value to set.
     * @return the RerunTumblingWindowTrigger object itself.
     */
    public RerunTumblingWindowTrigger withRequestedEndTime(OffsetDateTime requestedEndTime) {
        if (this.innerTypeProperties() == null) {
            this.innerTypeProperties = new RerunTumblingWindowTriggerTypeProperties();
        }
        this.innerTypeProperties().withRequestedEndTime(requestedEndTime);
        return this;
    }

    /**
     * Get the rerunConcurrency property: The max number of parallel time windows (ready for execution) for which a
     * rerun is triggered.
     * 
     * @return the rerunConcurrency value.
     */
    public int rerunConcurrency() {
        return this.innerTypeProperties() == null ? 0 : this.innerTypeProperties().rerunConcurrency();
    }

    /**
     * Set the rerunConcurrency property: The max number of parallel time windows (ready for execution) for which a
     * rerun is triggered.
     * 
     * @param rerunConcurrency the rerunConcurrency value to set.
     * @return the RerunTumblingWindowTrigger object itself.
     */
    public RerunTumblingWindowTrigger withRerunConcurrency(int rerunConcurrency) {
        if (this.innerTypeProperties() == null) {
            this.innerTypeProperties = new RerunTumblingWindowTriggerTypeProperties();
        }
        this.innerTypeProperties().withRerunConcurrency(rerunConcurrency);
        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 RerunTumblingWindowTrigger"));
        } else {
            innerTypeProperties().validate();
        }
    }

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

    /**
     * {@inheritDoc}
     */
    @Override
    public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
        jsonWriter.writeStartObject();
        jsonWriter.writeStringField("description", description());
        jsonWriter.writeArrayField("annotations", annotations(), (writer, element) -> writer.writeUntyped(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 RerunTumblingWindowTrigger from the JsonReader.
     * 
     * @param jsonReader The JsonReader being read.
     * @return An instance of RerunTumblingWindowTrigger 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 RerunTumblingWindowTrigger.
     */
    public static RerunTumblingWindowTrigger fromJson(JsonReader jsonReader) throws IOException {
        return jsonReader.readObject(reader -> {
            RerunTumblingWindowTrigger deserializedRerunTumblingWindowTrigger = new RerunTumblingWindowTrigger();
            Map additionalProperties = null;
            while (reader.nextToken() != JsonToken.END_OBJECT) {
                String fieldName = reader.getFieldName();
                reader.nextToken();

                if ("description".equals(fieldName)) {
                    deserializedRerunTumblingWindowTrigger.withDescription(reader.getString());
                } else if ("runtimeState".equals(fieldName)) {
                    deserializedRerunTumblingWindowTrigger
                        .withRuntimeState(TriggerRuntimeState.fromString(reader.getString()));
                } else if ("annotations".equals(fieldName)) {
                    List annotations = reader.readArray(reader1 -> reader1.readUntyped());
                    deserializedRerunTumblingWindowTrigger.withAnnotations(annotations);
                } else if ("typeProperties".equals(fieldName)) {
                    deserializedRerunTumblingWindowTrigger.innerTypeProperties
                        = RerunTumblingWindowTriggerTypeProperties.fromJson(reader);
                } else if ("type".equals(fieldName)) {
                    deserializedRerunTumblingWindowTrigger.type = reader.getString();
                } else {
                    if (additionalProperties == null) {
                        additionalProperties = new LinkedHashMap<>();
                    }

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

            return deserializedRerunTumblingWindowTrigger;
        });
    }
}