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

package com.azure.resourcemanager.machinelearning.models;

import com.azure.core.annotation.Fluent;
import com.azure.core.util.logging.ClientLogger;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.Map;

/** Base definition of a schedule. */
@Fluent
public final class ScheduleProperties extends ResourceBase {
    /*
     * [Required] Specifies the action of the schedule
     */
    @JsonProperty(value = "action", required = true)
    private ScheduleActionBase action;

    /*
     * Display name of schedule.
     */
    @JsonProperty(value = "displayName")
    private String displayName;

    /*
     * Is the schedule enabled?
     */
    @JsonProperty(value = "isEnabled")
    private Boolean isEnabled;

    /*
     * Provisioning state for the schedule.
     */
    @JsonProperty(value = "provisioningState", access = JsonProperty.Access.WRITE_ONLY)
    private ScheduleProvisioningStatus provisioningState;

    /*
     * [Required] Specifies the trigger details
     */
    @JsonProperty(value = "trigger", required = true)
    private TriggerBase trigger;

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

    /**
     * Get the action property: [Required] Specifies the action of the schedule.
     *
     * @return the action value.
     */
    public ScheduleActionBase action() {
        return this.action;
    }

    /**
     * Set the action property: [Required] Specifies the action of the schedule.
     *
     * @param action the action value to set.
     * @return the ScheduleProperties object itself.
     */
    public ScheduleProperties withAction(ScheduleActionBase action) {
        this.action = action;
        return this;
    }

    /**
     * Get the displayName property: Display name of schedule.
     *
     * @return the displayName value.
     */
    public String displayName() {
        return this.displayName;
    }

    /**
     * Set the displayName property: Display name of schedule.
     *
     * @param displayName the displayName value to set.
     * @return the ScheduleProperties object itself.
     */
    public ScheduleProperties withDisplayName(String displayName) {
        this.displayName = displayName;
        return this;
    }

    /**
     * Get the isEnabled property: Is the schedule enabled?.
     *
     * @return the isEnabled value.
     */
    public Boolean isEnabled() {
        return this.isEnabled;
    }

    /**
     * Set the isEnabled property: Is the schedule enabled?.
     *
     * @param isEnabled the isEnabled value to set.
     * @return the ScheduleProperties object itself.
     */
    public ScheduleProperties withIsEnabled(Boolean isEnabled) {
        this.isEnabled = isEnabled;
        return this;
    }

    /**
     * Get the provisioningState property: Provisioning state for the schedule.
     *
     * @return the provisioningState value.
     */
    public ScheduleProvisioningStatus provisioningState() {
        return this.provisioningState;
    }

    /**
     * Get the trigger property: [Required] Specifies the trigger details.
     *
     * @return the trigger value.
     */
    public TriggerBase trigger() {
        return this.trigger;
    }

    /**
     * Set the trigger property: [Required] Specifies the trigger details.
     *
     * @param trigger the trigger value to set.
     * @return the ScheduleProperties object itself.
     */
    public ScheduleProperties withTrigger(TriggerBase trigger) {
        this.trigger = trigger;
        return this;
    }

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

    /** {@inheritDoc} */
    @Override
    public ScheduleProperties withProperties(Map<String, String> properties) {
        super.withProperties(properties);
        return this;
    }

    /** {@inheritDoc} */
    @Override
    public ScheduleProperties withTags(Map<String, String> tags) {
        super.withTags(tags);
        return this;
    }

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

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