// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.

package com.azure.resourcemanager.automation.fluent.models;

import com.azure.core.annotation.Fluent;
import com.azure.core.util.logging.ClientLogger;
import com.azure.resourcemanager.automation.models.AdvancedSchedule;
import com.azure.resourcemanager.automation.models.ScheduleFrequency;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.time.OffsetDateTime;

/** The parameters supplied to the create or update schedule operation. */
@Fluent
public final class ScheduleCreateOrUpdateProperties {
    /*
     * Gets or sets the description of the schedule.
     */
    @JsonProperty(value = "description")
    private String description;

    /*
     * Gets or sets the start time of the schedule.
     */
    @JsonProperty(value = "startTime", required = true)
    private OffsetDateTime startTime;

    /*
     * Gets or sets the end time of the schedule.
     */
    @JsonProperty(value = "expiryTime")
    private OffsetDateTime expiryTime;

    /*
     * Gets or sets the interval of the schedule.
     */
    @JsonProperty(value = "interval")
    private Object interval;

    /*
     * Gets or sets the frequency of the schedule.
     */
    @JsonProperty(value = "frequency", required = true)
    private ScheduleFrequency frequency;

    /*
     * Gets or sets the time zone of the schedule.
     */
    @JsonProperty(value = "timeZone")
    private String timeZone;

    /*
     * Gets or sets the AdvancedSchedule.
     */
    @JsonProperty(value = "advancedSchedule")
    private AdvancedSchedule advancedSchedule;

    /**
     * Get the description property: Gets or sets the description of the schedule.
     *
     * @return the description value.
     */
    public String description() {
        return this.description;
    }

    /**
     * Set the description property: Gets or sets the description of the schedule.
     *
     * @param description the description value to set.
     * @return the ScheduleCreateOrUpdateProperties object itself.
     */
    public ScheduleCreateOrUpdateProperties withDescription(String description) {
        this.description = description;
        return this;
    }

    /**
     * Get the startTime property: Gets or sets the start time of the schedule.
     *
     * @return the startTime value.
     */
    public OffsetDateTime startTime() {
        return this.startTime;
    }

    /**
     * Set the startTime property: Gets or sets the start time of the schedule.
     *
     * @param startTime the startTime value to set.
     * @return the ScheduleCreateOrUpdateProperties object itself.
     */
    public ScheduleCreateOrUpdateProperties withStartTime(OffsetDateTime startTime) {
        this.startTime = startTime;
        return this;
    }

    /**
     * Get the expiryTime property: Gets or sets the end time of the schedule.
     *
     * @return the expiryTime value.
     */
    public OffsetDateTime expiryTime() {
        return this.expiryTime;
    }

    /**
     * Set the expiryTime property: Gets or sets the end time of the schedule.
     *
     * @param expiryTime the expiryTime value to set.
     * @return the ScheduleCreateOrUpdateProperties object itself.
     */
    public ScheduleCreateOrUpdateProperties withExpiryTime(OffsetDateTime expiryTime) {
        this.expiryTime = expiryTime;
        return this;
    }

    /**
     * Get the interval property: Gets or sets the interval of the schedule.
     *
     * @return the interval value.
     */
    public Object interval() {
        return this.interval;
    }

    /**
     * Set the interval property: Gets or sets the interval of the schedule.
     *
     * @param interval the interval value to set.
     * @return the ScheduleCreateOrUpdateProperties object itself.
     */
    public ScheduleCreateOrUpdateProperties withInterval(Object interval) {
        this.interval = interval;
        return this;
    }

    /**
     * Get the frequency property: Gets or sets the frequency of the schedule.
     *
     * @return the frequency value.
     */
    public ScheduleFrequency frequency() {
        return this.frequency;
    }

    /**
     * Set the frequency property: Gets or sets the frequency of the schedule.
     *
     * @param frequency the frequency value to set.
     * @return the ScheduleCreateOrUpdateProperties object itself.
     */
    public ScheduleCreateOrUpdateProperties withFrequency(ScheduleFrequency frequency) {
        this.frequency = frequency;
        return this;
    }

    /**
     * Get the timeZone property: Gets or sets the time zone of the schedule.
     *
     * @return the timeZone value.
     */
    public String timeZone() {
        return this.timeZone;
    }

    /**
     * Set the timeZone property: Gets or sets the time zone of the schedule.
     *
     * @param timeZone the timeZone value to set.
     * @return the ScheduleCreateOrUpdateProperties object itself.
     */
    public ScheduleCreateOrUpdateProperties withTimeZone(String timeZone) {
        this.timeZone = timeZone;
        return this;
    }

    /**
     * Get the advancedSchedule property: Gets or sets the AdvancedSchedule.
     *
     * @return the advancedSchedule value.
     */
    public AdvancedSchedule advancedSchedule() {
        return this.advancedSchedule;
    }

    /**
     * Set the advancedSchedule property: Gets or sets the AdvancedSchedule.
     *
     * @param advancedSchedule the advancedSchedule value to set.
     * @return the ScheduleCreateOrUpdateProperties object itself.
     */
    public ScheduleCreateOrUpdateProperties withAdvancedSchedule(AdvancedSchedule advancedSchedule) {
        this.advancedSchedule = advancedSchedule;
        return this;
    }

    /**
     * Validates the instance.
     *
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    public void validate() {
        if (startTime() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException(
                        "Missing required property startTime in model ScheduleCreateOrUpdateProperties"));
        }
        if (frequency() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException(
                        "Missing required property frequency in model ScheduleCreateOrUpdateProperties"));
        }
        if (advancedSchedule() != null) {
            advancedSchedule().validate();
        }
    }

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