// 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.management.exception.ManagementError;
import com.azure.core.util.logging.ClientLogger;
import com.azure.resourcemanager.automation.models.SoftwareUpdateConfigurationTasks;
import com.azure.resourcemanager.automation.models.SucScheduleProperties;
import com.azure.resourcemanager.automation.models.UpdateConfiguration;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.time.OffsetDateTime;

/** Software update configuration properties. */
@Fluent
public final class SoftwareUpdateConfigurationProperties {
    /*
     * update specific properties for the Software update configuration
     */
    @JsonProperty(value = "updateConfiguration", required = true)
    private UpdateConfiguration updateConfiguration;

    /*
     * Schedule information for the Software update configuration
     */
    @JsonProperty(value = "scheduleInfo", required = true)
    private SucScheduleProperties scheduleInfo;

    /*
     * Provisioning state for the software update configuration, which only appears in the response.
     */
    @JsonProperty(value = "provisioningState", access = JsonProperty.Access.WRITE_ONLY)
    private String provisioningState;

    /*
     * Details of provisioning error
     */
    @JsonProperty(value = "error")
    private ManagementError error;

    /*
     * Creation time of the resource, which only appears in the response.
     */
    @JsonProperty(value = "creationTime", access = JsonProperty.Access.WRITE_ONLY)
    private OffsetDateTime creationTime;

    /*
     * CreatedBy property, which only appears in the response.
     */
    @JsonProperty(value = "createdBy", access = JsonProperty.Access.WRITE_ONLY)
    private String createdBy;

    /*
     * Last time resource was modified, which only appears in the response.
     */
    @JsonProperty(value = "lastModifiedTime", access = JsonProperty.Access.WRITE_ONLY)
    private OffsetDateTime lastModifiedTime;

    /*
     * LastModifiedBy property, which only appears in the response.
     */
    @JsonProperty(value = "lastModifiedBy", access = JsonProperty.Access.WRITE_ONLY)
    private String lastModifiedBy;

    /*
     * Tasks information for the Software update configuration.
     */
    @JsonProperty(value = "tasks")
    private SoftwareUpdateConfigurationTasks tasks;

    /**
     * Get the updateConfiguration property: update specific properties for the Software update configuration.
     *
     * @return the updateConfiguration value.
     */
    public UpdateConfiguration updateConfiguration() {
        return this.updateConfiguration;
    }

    /**
     * Set the updateConfiguration property: update specific properties for the Software update configuration.
     *
     * @param updateConfiguration the updateConfiguration value to set.
     * @return the SoftwareUpdateConfigurationProperties object itself.
     */
    public SoftwareUpdateConfigurationProperties withUpdateConfiguration(UpdateConfiguration updateConfiguration) {
        this.updateConfiguration = updateConfiguration;
        return this;
    }

    /**
     * Get the scheduleInfo property: Schedule information for the Software update configuration.
     *
     * @return the scheduleInfo value.
     */
    public SucScheduleProperties scheduleInfo() {
        return this.scheduleInfo;
    }

    /**
     * Set the scheduleInfo property: Schedule information for the Software update configuration.
     *
     * @param scheduleInfo the scheduleInfo value to set.
     * @return the SoftwareUpdateConfigurationProperties object itself.
     */
    public SoftwareUpdateConfigurationProperties withScheduleInfo(SucScheduleProperties scheduleInfo) {
        this.scheduleInfo = scheduleInfo;
        return this;
    }

    /**
     * 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.provisioningState;
    }

    /**
     * Get the error property: Details of provisioning error.
     *
     * @return the error value.
     */
    public ManagementError error() {
        return this.error;
    }

    /**
     * Set the error property: Details of provisioning error.
     *
     * @param error the error value to set.
     * @return the SoftwareUpdateConfigurationProperties object itself.
     */
    public SoftwareUpdateConfigurationProperties withError(ManagementError error) {
        this.error = error;
        return this;
    }

    /**
     * Get the creationTime property: Creation time of the resource, which only appears in the response.
     *
     * @return the creationTime value.
     */
    public OffsetDateTime creationTime() {
        return this.creationTime;
    }

    /**
     * Get the createdBy property: CreatedBy property, which only appears in the response.
     *
     * @return the createdBy value.
     */
    public String createdBy() {
        return this.createdBy;
    }

    /**
     * Get the lastModifiedTime property: Last time resource was modified, which only appears in the response.
     *
     * @return the lastModifiedTime value.
     */
    public OffsetDateTime lastModifiedTime() {
        return this.lastModifiedTime;
    }

    /**
     * Get the lastModifiedBy property: LastModifiedBy property, which only appears in the response.
     *
     * @return the lastModifiedBy value.
     */
    public String lastModifiedBy() {
        return this.lastModifiedBy;
    }

    /**
     * Get the tasks property: Tasks information for the Software update configuration.
     *
     * @return the tasks value.
     */
    public SoftwareUpdateConfigurationTasks tasks() {
        return this.tasks;
    }

    /**
     * Set the tasks property: Tasks information for the Software update configuration.
     *
     * @param tasks the tasks value to set.
     * @return the SoftwareUpdateConfigurationProperties object itself.
     */
    public SoftwareUpdateConfigurationProperties withTasks(SoftwareUpdateConfigurationTasks tasks) {
        this.tasks = tasks;
        return this;
    }

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

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