// 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.models;

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

/** The parameters supplied to the create or update schedule operation. */
@Fluent
public final class ScheduleCreateOrUpdateParameters {
    /*
     * Gets or sets the name of the Schedule.
     */
    @JsonProperty(value = "name", required = true)
    private String name;

    /*
     * Gets or sets the list of schedule properties.
     */
    @JsonProperty(value = "properties", required = true)
    private ScheduleCreateOrUpdateProperties innerProperties = new ScheduleCreateOrUpdateProperties();

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

    /**
     * Set the name property: Gets or sets the name of the Schedule.
     *
     * @param name the name value to set.
     * @return the ScheduleCreateOrUpdateParameters object itself.
     */
    public ScheduleCreateOrUpdateParameters withName(String name) {
        this.name = name;
        return this;
    }

    /**
     * Get the innerProperties property: Gets or sets the list of schedule properties.
     *
     * @return the innerProperties value.
     */
    private ScheduleCreateOrUpdateProperties innerProperties() {
        return this.innerProperties;
    }

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

    /**
     * Set the description property: Gets or sets the description of the schedule.
     *
     * @param description the description value to set.
     * @return the ScheduleCreateOrUpdateParameters object itself.
     */
    public ScheduleCreateOrUpdateParameters withDescription(String description) {
        if (this.innerProperties() == null) {
            this.innerProperties = new ScheduleCreateOrUpdateProperties();
        }
        this.innerProperties().withDescription(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.innerProperties() == null ? null : this.innerProperties().startTime();
    }

    /**
     * Set the startTime property: Gets or sets the start time of the schedule.
     *
     * @param startTime the startTime value to set.
     * @return the ScheduleCreateOrUpdateParameters object itself.
     */
    public ScheduleCreateOrUpdateParameters withStartTime(OffsetDateTime startTime) {
        if (this.innerProperties() == null) {
            this.innerProperties = new ScheduleCreateOrUpdateProperties();
        }
        this.innerProperties().withStartTime(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.innerProperties() == null ? null : this.innerProperties().expiryTime();
    }

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

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

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

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

    /**
     * Set the frequency property: Gets or sets the frequency of the schedule.
     *
     * @param frequency the frequency value to set.
     * @return the ScheduleCreateOrUpdateParameters object itself.
     */
    public ScheduleCreateOrUpdateParameters withFrequency(ScheduleFrequency frequency) {
        if (this.innerProperties() == null) {
            this.innerProperties = new ScheduleCreateOrUpdateProperties();
        }
        this.innerProperties().withFrequency(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.innerProperties() == null ? null : this.innerProperties().timeZone();
    }

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

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

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

    /**
     * Validates the instance.
     *
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    public void validate() {
        if (name() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException(
                        "Missing required property name in model ScheduleCreateOrUpdateParameters"));
        }
        if (innerProperties() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException(
                        "Missing required property innerProperties in model ScheduleCreateOrUpdateParameters"));
        } else {
            innerProperties().validate();
        }
    }

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