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

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

import com.azure.core.annotation.Fluent;
import com.azure.core.util.logging.ClientLogger;
import com.azure.resourcemanager.containerservicefleet.models.ManagedClusterUpdate;
import com.azure.resourcemanager.containerservicefleet.models.UpdateRunProvisioningState;
import com.azure.resourcemanager.containerservicefleet.models.UpdateRunStatus;
import com.azure.resourcemanager.containerservicefleet.models.UpdateRunStrategy;
import com.fasterxml.jackson.annotation.JsonProperty;

/** The properties of the UpdateRun. */
@Fluent
public final class UpdateRunProperties {
    /*
     * The provisioning state of the UpdateRun resource.
     */
    @JsonProperty(value = "provisioningState", access = JsonProperty.Access.WRITE_ONLY)
    private UpdateRunProvisioningState provisioningState;

    /*
     * The strategy defines the order in which the clusters will be updated.
     * If not set, all members will be updated sequentially. The UpdateRun status will show a single UpdateStage and a
     * single UpdateGroup targeting all members.
     * The strategy of the UpdateRun can be modified until the run is started.
     */
    @JsonProperty(value = "strategy")
    private UpdateRunStrategy strategy;

    /*
     * The update to be applied to all clusters in the UpdateRun. The managedClusterUpdate can be modified until the
     * run is started.
     */
    @JsonProperty(value = "managedClusterUpdate", required = true)
    private ManagedClusterUpdate managedClusterUpdate;

    /*
     * The status of the UpdateRun.
     */
    @JsonProperty(value = "status", access = JsonProperty.Access.WRITE_ONLY)
    private UpdateRunStatus status;

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

    /**
     * Get the provisioningState property: The provisioning state of the UpdateRun resource.
     *
     * @return the provisioningState value.
     */
    public UpdateRunProvisioningState provisioningState() {
        return this.provisioningState;
    }

    /**
     * Get the strategy property: The strategy defines the order in which the clusters will be updated. If not set, all
     * members will be updated sequentially. The UpdateRun status will show a single UpdateStage and a single
     * UpdateGroup targeting all members. The strategy of the UpdateRun can be modified until the run is started.
     *
     * @return the strategy value.
     */
    public UpdateRunStrategy strategy() {
        return this.strategy;
    }

    /**
     * Set the strategy property: The strategy defines the order in which the clusters will be updated. If not set, all
     * members will be updated sequentially. The UpdateRun status will show a single UpdateStage and a single
     * UpdateGroup targeting all members. The strategy of the UpdateRun can be modified until the run is started.
     *
     * @param strategy the strategy value to set.
     * @return the UpdateRunProperties object itself.
     */
    public UpdateRunProperties withStrategy(UpdateRunStrategy strategy) {
        this.strategy = strategy;
        return this;
    }

    /**
     * Get the managedClusterUpdate property: The update to be applied to all clusters in the UpdateRun. The
     * managedClusterUpdate can be modified until the run is started.
     *
     * @return the managedClusterUpdate value.
     */
    public ManagedClusterUpdate managedClusterUpdate() {
        return this.managedClusterUpdate;
    }

    /**
     * Set the managedClusterUpdate property: The update to be applied to all clusters in the UpdateRun. The
     * managedClusterUpdate can be modified until the run is started.
     *
     * @param managedClusterUpdate the managedClusterUpdate value to set.
     * @return the UpdateRunProperties object itself.
     */
    public UpdateRunProperties withManagedClusterUpdate(ManagedClusterUpdate managedClusterUpdate) {
        this.managedClusterUpdate = managedClusterUpdate;
        return this;
    }

    /**
     * Get the status property: The status of the UpdateRun.
     *
     * @return the status value.
     */
    public UpdateRunStatus status() {
        return this.status;
    }

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

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