// 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.SoftwareUpdateConfigurationCollectionItemProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.time.OffsetDateTime;

/** Software update configuration collection item properties. */
@Fluent
public final class SoftwareUpdateConfigurationCollectionItem {
    /*
     * Name of the software update configuration.
     */
    @JsonProperty(value = "name", access = JsonProperty.Access.WRITE_ONLY)
    private String name;

    /*
     * Resource Id of the software update configuration
     */
    @JsonProperty(value = "id", access = JsonProperty.Access.WRITE_ONLY)
    private String id;

    /*
     * Software update configuration properties.
     */
    @JsonProperty(value = "properties", required = true)
    private SoftwareUpdateConfigurationCollectionItemProperties innerProperties =
        new SoftwareUpdateConfigurationCollectionItemProperties();

    /**
     * Get the name property: Name of the software update configuration.
     *
     * @return the name value.
     */
    public String name() {
        return this.name;
    }

    /**
     * Get the id property: Resource Id of the software update configuration.
     *
     * @return the id value.
     */
    public String id() {
        return this.id;
    }

    /**
     * Get the innerProperties property: Software update configuration properties.
     *
     * @return the innerProperties value.
     */
    private SoftwareUpdateConfigurationCollectionItemProperties innerProperties() {
        return this.innerProperties;
    }

    /**
     * Get the updateConfiguration property: Update specific properties of the software update configuration.
     *
     * @return the updateConfiguration value.
     */
    public UpdateConfiguration updateConfiguration() {
        return this.innerProperties() == null ? null : this.innerProperties().updateConfiguration();
    }

    /**
     * Set the updateConfiguration property: Update specific properties of the software update configuration.
     *
     * @param updateConfiguration the updateConfiguration value to set.
     * @return the SoftwareUpdateConfigurationCollectionItem object itself.
     */
    public SoftwareUpdateConfigurationCollectionItem withUpdateConfiguration(UpdateConfiguration updateConfiguration) {
        if (this.innerProperties() == null) {
            this.innerProperties = new SoftwareUpdateConfigurationCollectionItemProperties();
        }
        this.innerProperties().withUpdateConfiguration(updateConfiguration);
        return this;
    }

    /**
     * Get the tasks property: Pre and Post Tasks defined.
     *
     * @return the tasks value.
     */
    public SoftwareUpdateConfigurationTasks tasks() {
        return this.innerProperties() == null ? null : this.innerProperties().tasks();
    }

    /**
     * Set the tasks property: Pre and Post Tasks defined.
     *
     * @param tasks the tasks value to set.
     * @return the SoftwareUpdateConfigurationCollectionItem object itself.
     */
    public SoftwareUpdateConfigurationCollectionItem withTasks(SoftwareUpdateConfigurationTasks tasks) {
        if (this.innerProperties() == null) {
            this.innerProperties = new SoftwareUpdateConfigurationCollectionItemProperties();
        }
        this.innerProperties().withTasks(tasks);
        return this;
    }

    /**
     * Get the frequency property: execution frequency of the schedule associated with the software update
     * configuration.
     *
     * @return the frequency value.
     */
    public ScheduleFrequency frequency() {
        return this.innerProperties() == null ? null : this.innerProperties().frequency();
    }

    /**
     * Set the frequency property: execution frequency of the schedule associated with the software update
     * configuration.
     *
     * @param frequency the frequency value to set.
     * @return the SoftwareUpdateConfigurationCollectionItem object itself.
     */
    public SoftwareUpdateConfigurationCollectionItem withFrequency(ScheduleFrequency frequency) {
        if (this.innerProperties() == null) {
            this.innerProperties = new SoftwareUpdateConfigurationCollectionItemProperties();
        }
        this.innerProperties().withFrequency(frequency);
        return this;
    }

    /**
     * Get the startTime property: the start time of the update.
     *
     * @return the startTime value.
     */
    public OffsetDateTime startTime() {
        return this.innerProperties() == null ? null : this.innerProperties().startTime();
    }

    /**
     * Set the startTime property: the start time of the update.
     *
     * @param startTime the startTime value to set.
     * @return the SoftwareUpdateConfigurationCollectionItem object itself.
     */
    public SoftwareUpdateConfigurationCollectionItem withStartTime(OffsetDateTime startTime) {
        if (this.innerProperties() == null) {
            this.innerProperties = new SoftwareUpdateConfigurationCollectionItemProperties();
        }
        this.innerProperties().withStartTime(startTime);
        return this;
    }

    /**
     * Get the creationTime property: Creation time of the software update configuration, which only appears in the
     * response.
     *
     * @return the creationTime value.
     */
    public OffsetDateTime creationTime() {
        return this.innerProperties() == null ? null : this.innerProperties().creationTime();
    }

    /**
     * Get the lastModifiedTime property: Last time software update configuration was modified, which only appears in
     * the response.
     *
     * @return the lastModifiedTime value.
     */
    public OffsetDateTime lastModifiedTime() {
        return this.innerProperties() == null ? null : this.innerProperties().lastModifiedTime();
    }

    /**
     * Get the provisioningState property: Provisioning state for the software update configuration, which only appears
     * in the response.
     *
     * @return the provisioningState value.
     */
    public String provisioningState() {
        return this.innerProperties() == null ? null : this.innerProperties().provisioningState();
    }

    /**
     * Get the nextRun property: ext run time of the update.
     *
     * @return the nextRun value.
     */
    public OffsetDateTime nextRun() {
        return this.innerProperties() == null ? null : this.innerProperties().nextRun();
    }

    /**
     * Set the nextRun property: ext run time of the update.
     *
     * @param nextRun the nextRun value to set.
     * @return the SoftwareUpdateConfigurationCollectionItem object itself.
     */
    public SoftwareUpdateConfigurationCollectionItem withNextRun(OffsetDateTime nextRun) {
        if (this.innerProperties() == null) {
            this.innerProperties = new SoftwareUpdateConfigurationCollectionItemProperties();
        }
        this.innerProperties().withNextRun(nextRun);
        return this;
    }

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

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