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

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

import com.azure.core.annotation.Fluent;
import com.azure.core.management.Resource;
import com.azure.core.util.logging.ClientLogger;
import com.azure.resourcemanager.streamanalytics.models.ClusterProvisioningState;
import com.azure.resourcemanager.streamanalytics.models.ClusterSku;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.time.OffsetDateTime;
import java.util.Map;

/** A Stream Analytics Cluster object. */
@Fluent
public final class ClusterInner extends Resource {
    @JsonIgnore private final ClientLogger logger = new ClientLogger(ClusterInner.class);

    /*
     * The SKU of the cluster. This determines the size/capacity of the
     * cluster. Required on PUT (CreateOrUpdate) requests.
     */
    @JsonProperty(value = "sku")
    private ClusterSku sku;

    /*
     * The current entity tag for the cluster. This is an opaque string. You
     * can use it to detect whether the resource has changed between requests.
     * You can also use it in the If-Match or If-None-Match headers for write
     * operations for optimistic concurrency.
     */
    @JsonProperty(value = "etag", access = JsonProperty.Access.WRITE_ONLY)
    private String etag;

    /*
     * The properties associated with a Stream Analytics cluster.
     */
    @JsonProperty(value = "properties")
    private ClusterProperties innerProperties;

    /**
     * Get the sku property: The SKU of the cluster. This determines the size/capacity of the cluster. Required on PUT
     * (CreateOrUpdate) requests.
     *
     * @return the sku value.
     */
    public ClusterSku sku() {
        return this.sku;
    }

    /**
     * Set the sku property: The SKU of the cluster. This determines the size/capacity of the cluster. Required on PUT
     * (CreateOrUpdate) requests.
     *
     * @param sku the sku value to set.
     * @return the ClusterInner object itself.
     */
    public ClusterInner withSku(ClusterSku sku) {
        this.sku = sku;
        return this;
    }

    /**
     * Get the etag property: The current entity tag for the cluster. This is an opaque string. You can use it to detect
     * whether the resource has changed between requests. You can also use it in the If-Match or If-None-Match headers
     * for write operations for optimistic concurrency.
     *
     * @return the etag value.
     */
    public String etag() {
        return this.etag;
    }

    /**
     * Get the innerProperties property: The properties associated with a Stream Analytics cluster.
     *
     * @return the innerProperties value.
     */
    private ClusterProperties innerProperties() {
        return this.innerProperties;
    }

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

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

    /**
     * Get the createdDate property: The date this cluster was created.
     *
     * @return the createdDate value.
     */
    public OffsetDateTime createdDate() {
        return this.innerProperties() == null ? null : this.innerProperties().createdDate();
    }

    /**
     * Get the clusterId property: Unique identifier for the cluster.
     *
     * @return the clusterId value.
     */
    public String clusterId() {
        return this.innerProperties() == null ? null : this.innerProperties().clusterId();
    }

    /**
     * Get the provisioningState property: The status of the cluster provisioning. The three terminal states are:
     * Succeeded, Failed and Canceled.
     *
     * @return the provisioningState value.
     */
    public ClusterProvisioningState provisioningState() {
        return this.innerProperties() == null ? null : this.innerProperties().provisioningState();
    }

    /**
     * Get the capacityAllocated property: Represents the number of streaming units currently being used on the cluster.
     *
     * @return the capacityAllocated value.
     */
    public Integer capacityAllocated() {
        return this.innerProperties() == null ? null : this.innerProperties().capacityAllocated();
    }

    /**
     * Get the capacityAssigned property: Represents the sum of the SUs of all streaming jobs associated with the
     * cluster. If all of the jobs were running, this would be the capacity allocated.
     *
     * @return the capacityAssigned value.
     */
    public Integer capacityAssigned() {
        return this.innerProperties() == null ? null : this.innerProperties().capacityAssigned();
    }

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