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

com.azure.resourcemanager.storage.models.TriggerParametersUpdate Maven / Gradle / Ivy

There is a newer version: 2.44.0
Show newest version
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.

package com.azure.resourcemanager.storage.models;

import com.azure.core.annotation.Fluent;
import com.azure.core.util.CoreUtils;
import com.azure.json.JsonReader;
import com.azure.json.JsonSerializable;
import com.azure.json.JsonToken;
import com.azure.json.JsonWriter;
import java.io.IOException;
import java.time.OffsetDateTime;
import java.time.format.DateTimeFormatter;

/**
 * The trigger parameters update for the storage task assignment execution.
 */
@Fluent
public final class TriggerParametersUpdate implements JsonSerializable {
    /*
     * When to start task execution. This is a mutable field when ExecutionTrigger.properties.type is 'OnSchedule'; this
     * property should not be present when ExecutionTrigger.properties.type is 'RunOnce'
     */
    private OffsetDateTime startFrom;

    /*
     * Run interval of task execution. This is a mutable field when ExecutionTrigger.properties.type is 'OnSchedule';
     * this property should not be present when ExecutionTrigger.properties.type is 'RunOnce'
     */
    private Integer interval;

    /*
     * Run interval unit of task execution. This is a mutable field when ExecutionTrigger.properties.type is
     * 'OnSchedule'; this property should not be present when ExecutionTrigger.properties.type is 'RunOnce'
     */
    private IntervalUnit intervalUnit;

    /*
     * When to end task execution. This is a mutable field when ExecutionTrigger.properties.type is 'OnSchedule'; this
     * property should not be present when ExecutionTrigger.properties.type is 'RunOnce'
     */
    private OffsetDateTime endBy;

    /*
     * When to start task execution. This is a mutable field when ExecutionTrigger.properties.type is 'RunOnce'; this
     * property should not be present when ExecutionTrigger.properties.type is 'OnSchedule'
     */
    private OffsetDateTime startOn;

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

    /**
     * Get the startFrom property: When to start task execution. This is a mutable field when
     * ExecutionTrigger.properties.type is 'OnSchedule'; this property should not be present when
     * ExecutionTrigger.properties.type is 'RunOnce'.
     * 
     * @return the startFrom value.
     */
    public OffsetDateTime startFrom() {
        return this.startFrom;
    }

    /**
     * Set the startFrom property: When to start task execution. This is a mutable field when
     * ExecutionTrigger.properties.type is 'OnSchedule'; this property should not be present when
     * ExecutionTrigger.properties.type is 'RunOnce'.
     * 
     * @param startFrom the startFrom value to set.
     * @return the TriggerParametersUpdate object itself.
     */
    public TriggerParametersUpdate withStartFrom(OffsetDateTime startFrom) {
        this.startFrom = startFrom;
        return this;
    }

    /**
     * Get the interval property: Run interval of task execution. This is a mutable field when
     * ExecutionTrigger.properties.type is 'OnSchedule'; this property should not be present when
     * ExecutionTrigger.properties.type is 'RunOnce'.
     * 
     * @return the interval value.
     */
    public Integer interval() {
        return this.interval;
    }

    /**
     * Set the interval property: Run interval of task execution. This is a mutable field when
     * ExecutionTrigger.properties.type is 'OnSchedule'; this property should not be present when
     * ExecutionTrigger.properties.type is 'RunOnce'.
     * 
     * @param interval the interval value to set.
     * @return the TriggerParametersUpdate object itself.
     */
    public TriggerParametersUpdate withInterval(Integer interval) {
        this.interval = interval;
        return this;
    }

    /**
     * Get the intervalUnit property: Run interval unit of task execution. This is a mutable field when
     * ExecutionTrigger.properties.type is 'OnSchedule'; this property should not be present when
     * ExecutionTrigger.properties.type is 'RunOnce'.
     * 
     * @return the intervalUnit value.
     */
    public IntervalUnit intervalUnit() {
        return this.intervalUnit;
    }

    /**
     * Set the intervalUnit property: Run interval unit of task execution. This is a mutable field when
     * ExecutionTrigger.properties.type is 'OnSchedule'; this property should not be present when
     * ExecutionTrigger.properties.type is 'RunOnce'.
     * 
     * @param intervalUnit the intervalUnit value to set.
     * @return the TriggerParametersUpdate object itself.
     */
    public TriggerParametersUpdate withIntervalUnit(IntervalUnit intervalUnit) {
        this.intervalUnit = intervalUnit;
        return this;
    }

    /**
     * Get the endBy property: When to end task execution. This is a mutable field when ExecutionTrigger.properties.type
     * is 'OnSchedule'; this property should not be present when ExecutionTrigger.properties.type is 'RunOnce'.
     * 
     * @return the endBy value.
     */
    public OffsetDateTime endBy() {
        return this.endBy;
    }

    /**
     * Set the endBy property: When to end task execution. This is a mutable field when ExecutionTrigger.properties.type
     * is 'OnSchedule'; this property should not be present when ExecutionTrigger.properties.type is 'RunOnce'.
     * 
     * @param endBy the endBy value to set.
     * @return the TriggerParametersUpdate object itself.
     */
    public TriggerParametersUpdate withEndBy(OffsetDateTime endBy) {
        this.endBy = endBy;
        return this;
    }

    /**
     * Get the startOn property: When to start task execution. This is a mutable field when
     * ExecutionTrigger.properties.type is 'RunOnce'; this property should not be present when
     * ExecutionTrigger.properties.type is 'OnSchedule'.
     * 
     * @return the startOn value.
     */
    public OffsetDateTime startOn() {
        return this.startOn;
    }

    /**
     * Set the startOn property: When to start task execution. This is a mutable field when
     * ExecutionTrigger.properties.type is 'RunOnce'; this property should not be present when
     * ExecutionTrigger.properties.type is 'OnSchedule'.
     * 
     * @param startOn the startOn value to set.
     * @return the TriggerParametersUpdate object itself.
     */
    public TriggerParametersUpdate withStartOn(OffsetDateTime startOn) {
        this.startOn = startOn;
        return this;
    }

    /**
     * Validates the instance.
     * 
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    public void validate() {
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
        jsonWriter.writeStartObject();
        jsonWriter.writeStringField("startFrom",
            this.startFrom == null ? null : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(this.startFrom));
        jsonWriter.writeNumberField("interval", this.interval);
        jsonWriter.writeStringField("intervalUnit", this.intervalUnit == null ? null : this.intervalUnit.toString());
        jsonWriter.writeStringField("endBy",
            this.endBy == null ? null : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(this.endBy));
        jsonWriter.writeStringField("startOn",
            this.startOn == null ? null : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(this.startOn));
        return jsonWriter.writeEndObject();
    }

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

                if ("startFrom".equals(fieldName)) {
                    deserializedTriggerParametersUpdate.startFrom = reader
                        .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString()));
                } else if ("interval".equals(fieldName)) {
                    deserializedTriggerParametersUpdate.interval = reader.getNullable(JsonReader::getInt);
                } else if ("intervalUnit".equals(fieldName)) {
                    deserializedTriggerParametersUpdate.intervalUnit = IntervalUnit.fromString(reader.getString());
                } else if ("endBy".equals(fieldName)) {
                    deserializedTriggerParametersUpdate.endBy = reader
                        .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString()));
                } else if ("startOn".equals(fieldName)) {
                    deserializedTriggerParametersUpdate.startOn = reader
                        .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString()));
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedTriggerParametersUpdate;
        });
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy