// 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.management.Resource;
import com.azure.resourcemanager.deploymentmanager.models.Identity;
import com.azure.resourcemanager.deploymentmanager.models.RolloutOperationInfo;
import com.azure.resourcemanager.deploymentmanager.models.Service;
import com.azure.resourcemanager.deploymentmanager.models.StepGroup;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;
import java.util.Map;

/** Defines the rollout. */
@Fluent
public final class RolloutInner extends Resource {
    /*
     * Identity for the resource.
     */
    @JsonProperty(value = "identity")
    private Identity identity;

    /*
     * The properties that define a rollout.
     */
    @JsonProperty(value = "properties")
    private RolloutProperties innerProperties;

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

    /**
     * Get the identity property: Identity for the resource.
     *
     * @return the identity value.
     */
    public Identity identity() {
        return this.identity;
    }

    /**
     * Set the identity property: Identity for the resource.
     *
     * @param identity the identity value to set.
     * @return the RolloutInner object itself.
     */
    public RolloutInner withIdentity(Identity identity) {
        this.identity = identity;
        return this;
    }

    /**
     * Get the innerProperties property: The properties that define a rollout.
     *
     * @return the innerProperties value.
     */
    private RolloutProperties innerProperties() {
        return this.innerProperties;
    }

    /** {@inheritDoc} */
    @Override
    public RolloutInner withLocation(String location) {
        super.withLocation(location);
        return this;
    }

    /** {@inheritDoc} */
    @Override
    public RolloutInner withTags(Map<String, String> tags) {
        super.withTags(tags);
        return this;
    }

    /**
     * Get the status property: The current status of the rollout.
     *
     * @return the status value.
     */
    public String status() {
        return this.innerProperties() == null ? null : this.innerProperties().status();
    }

    /**
     * Get the totalRetryAttempts property: The cardinal count of total number of retries performed on the rollout at a
     * given time.
     *
     * @return the totalRetryAttempts value.
     */
    public Integer totalRetryAttempts() {
        return this.innerProperties() == null ? null : this.innerProperties().totalRetryAttempts();
    }

    /**
     * Get the operationInfo property: Operational information of the rollout.
     *
     * @return the operationInfo value.
     */
    public RolloutOperationInfo operationInfo() {
        return this.innerProperties() == null ? null : this.innerProperties().operationInfo();
    }

    /**
     * Get the services property: The detailed information on the services being deployed.
     *
     * @return the services value.
     */
    public List<Service> services() {
        return this.innerProperties() == null ? null : this.innerProperties().services();
    }

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

    /**
     * Set the buildVersion property: The version of the build being deployed.
     *
     * @param buildVersion the buildVersion value to set.
     * @return the RolloutInner object itself.
     */
    public RolloutInner withBuildVersion(String buildVersion) {
        if (this.innerProperties() == null) {
            this.innerProperties = new RolloutProperties();
        }
        this.innerProperties().withBuildVersion(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.innerProperties() == null ? null : this.innerProperties().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 RolloutInner object itself.
     */
    public RolloutInner withArtifactSourceId(String artifactSourceId) {
        if (this.innerProperties() == null) {
            this.innerProperties = new RolloutProperties();
        }
        this.innerProperties().withArtifactSourceId(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.innerProperties() == null ? null : this.innerProperties().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 RolloutInner object itself.
     */
    public RolloutInner withTargetServiceTopologyId(String targetServiceTopologyId) {
        if (this.innerProperties() == null) {
            this.innerProperties = new RolloutProperties();
        }
        this.innerProperties().withTargetServiceTopologyId(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.innerProperties() == null ? null : this.innerProperties().stepGroups();
    }

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

    /**
     * Validates the instance.
     *
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    public void validate() {
        if (identity() != null) {
            identity().validate();
        }
        if (innerProperties() != null) {
            innerProperties().validate();
        }
    }
}
