// 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.fluent.models;

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

/** The properties for defining a rollout. */
@Fluent
public class RolloutRequestProperties {
    /*
     * The version of the build being deployed.
     */
    @JsonProperty(value = "buildVersion", required = true)
    private String buildVersion;

    /*
     * The reference to the artifact source resource Id where the payload is located.
     */
    @JsonProperty(value = "artifactSourceId")
    private String artifactSourceId;

    /*
     * The resource Id of the service topology from which service units are being referenced in step groups to be
     * deployed.
     */
    @JsonProperty(value = "targetServiceTopologyId", required = true)
    private String targetServiceTopologyId;

    /*
     * The list of step groups that define the orchestration.
     */
    @JsonProperty(value = "stepGroups", required = true)
    private List<StepGroup> stepGroups;

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

    /**
     * Get the buildVersion property: The version of the build being deployed.
     *
     * @return the buildVersion value.
     */
    public String buildVersion() {
        return this.buildVersion;
    }

    /**
     * Set the buildVersion property: The version of the build being deployed.
     *
     * @param buildVersion the buildVersion value to set.
     * @return the RolloutRequestProperties object itself.
     */
    public RolloutRequestProperties withBuildVersion(String buildVersion) {
        this.buildVersion = buildVersion;
        return this;
    }

    /**
     * Get the artifactSourceId property: The reference to the artifact source resource Id where the payload is located.
     *
     * @return the artifactSourceId value.
     */
    public String artifactSourceId() {
        return this.artifactSourceId;
    }

    /**
     * Set the artifactSourceId property: The reference to the artifact source resource Id where the payload is located.
     *
     * @param artifactSourceId the artifactSourceId value to set.
     * @return the RolloutRequestProperties object itself.
     */
    public RolloutRequestProperties withArtifactSourceId(String artifactSourceId) {
        this.artifactSourceId = artifactSourceId;
        return this;
    }

    /**
     * Get the targetServiceTopologyId property: The resource Id of the service topology from which service units are
     * being referenced in step groups to be deployed.
     *
     * @return the targetServiceTopologyId value.
     */
    public String targetServiceTopologyId() {
        return this.targetServiceTopologyId;
    }

    /**
     * Set the targetServiceTopologyId property: The resource Id of the service topology from which service units are
     * being referenced in step groups to be deployed.
     *
     * @param targetServiceTopologyId the targetServiceTopologyId value to set.
     * @return the RolloutRequestProperties object itself.
     */
    public RolloutRequestProperties withTargetServiceTopologyId(String targetServiceTopologyId) {
        this.targetServiceTopologyId = targetServiceTopologyId;
        return this;
    }

    /**
     * Get the stepGroups property: The list of step groups that define the orchestration.
     *
     * @return the stepGroups value.
     */
    public List<StepGroup> stepGroups() {
        return this.stepGroups;
    }

    /**
     * Set the stepGroups property: The list of step groups that define the orchestration.
     *
     * @param stepGroups the stepGroups value to set.
     * @return the RolloutRequestProperties object itself.
     */
    public RolloutRequestProperties withStepGroups(List<StepGroup> stepGroups) {
        this.stepGroups = stepGroups;
        return this;
    }

    /**
     * Validates the instance.
     *
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    public void validate() {
        if (buildVersion() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException(
                        "Missing required property buildVersion in model RolloutRequestProperties"));
        }
        if (targetServiceTopologyId() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException(
                        "Missing required property targetServiceTopologyId in model RolloutRequestProperties"));
        }
        if (stepGroups() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException(
                        "Missing required property stepGroups in model RolloutRequestProperties"));
        } else {
            stepGroups().forEach(e -> e.validate());
        }
    }

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