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

package com.azure.resourcemanager.deploymentmanager.models;

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

/** Defines a specific step on a target service unit. */
@Fluent
public final class RolloutStep {
    /*
     * Name of the step.
     */
    @JsonProperty(value = "name", required = true)
    private String name;

    /*
     * Current state of the step.
     */
    @JsonProperty(value = "status", access = JsonProperty.Access.WRITE_ONLY)
    private String status;

    /*
     * The step group the current step is part of.
     */
    @JsonProperty(value = "stepGroup")
    private String stepGroup;

    /*
     * Detailed information of specific action execution.
     */
    @JsonProperty(value = "operationInfo", access = JsonProperty.Access.WRITE_ONLY)
    private StepOperationInfo operationInfo;

    /*
     * Set of resource operations that were performed, if any, on an Azure resource.
     */
    @JsonProperty(value = "resourceOperations", access = JsonProperty.Access.WRITE_ONLY)
    private List<ResourceOperation> resourceOperations;

    /*
     * Supplementary informative messages during rollout.
     */
    @JsonProperty(value = "messages", access = JsonProperty.Access.WRITE_ONLY)
    private List<Message> messages;

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

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

    /**
     * Set the name property: Name of the step.
     *
     * @param name the name value to set.
     * @return the RolloutStep object itself.
     */
    public RolloutStep withName(String name) {
        this.name = name;
        return this;
    }

    /**
     * Get the status property: Current state of the step.
     *
     * @return the status value.
     */
    public String status() {
        return this.status;
    }

    /**
     * Get the stepGroup property: The step group the current step is part of.
     *
     * @return the stepGroup value.
     */
    public String stepGroup() {
        return this.stepGroup;
    }

    /**
     * Set the stepGroup property: The step group the current step is part of.
     *
     * @param stepGroup the stepGroup value to set.
     * @return the RolloutStep object itself.
     */
    public RolloutStep withStepGroup(String stepGroup) {
        this.stepGroup = stepGroup;
        return this;
    }

    /**
     * Get the operationInfo property: Detailed information of specific action execution.
     *
     * @return the operationInfo value.
     */
    public StepOperationInfo operationInfo() {
        return this.operationInfo;
    }

    /**
     * Get the resourceOperations property: Set of resource operations that were performed, if any, on an Azure
     * resource.
     *
     * @return the resourceOperations value.
     */
    public List<ResourceOperation> resourceOperations() {
        return this.resourceOperations;
    }

    /**
     * Get the messages property: Supplementary informative messages during rollout.
     *
     * @return the messages value.
     */
    public List<Message> messages() {
        return this.messages;
    }

    /**
     * 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 RolloutStep"));
        }
        if (operationInfo() != null) {
            operationInfo().validate();
        }
        if (resourceOperations() != null) {
            resourceOperations().forEach(e -> e.validate());
        }
        if (messages() != null) {
            messages().forEach(e -> e.validate());
        }
    }

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