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

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

import com.azure.core.annotation.Fluent;
import com.azure.core.management.Resource;
import com.azure.core.management.SystemData;
import com.azure.core.util.logging.ClientLogger;
import com.azure.resourcemanager.databricks.models.CreatedBy;
import com.azure.resourcemanager.databricks.models.ManagedIdentityConfiguration;
import com.azure.resourcemanager.databricks.models.ProvisioningState;
import com.azure.resourcemanager.databricks.models.PublicNetworkAccess;
import com.azure.resourcemanager.databricks.models.RequiredNsgRules;
import com.azure.resourcemanager.databricks.models.Sku;
import com.azure.resourcemanager.databricks.models.WorkspaceCustomParameters;
import com.azure.resourcemanager.databricks.models.WorkspacePropertiesEncryption;
import com.azure.resourcemanager.databricks.models.WorkspaceProviderAuthorization;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.time.OffsetDateTime;
import java.util.List;
import java.util.Map;

/** Information about workspace. */
@Fluent
public final class WorkspaceInner extends Resource {
    /*
     * The workspace properties.
     */
    @JsonProperty(value = "properties", required = true)
    private WorkspaceProperties innerProperties = new WorkspaceProperties();

    /*
     * The SKU of the resource.
     */
    @JsonProperty(value = "sku")
    private Sku sku;

    /*
     * The system metadata relating to this resource
     */
    @JsonProperty(value = "systemData", access = JsonProperty.Access.WRITE_ONLY)
    private SystemData systemData;

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

    /**
     * Get the innerProperties property: The workspace properties.
     *
     * @return the innerProperties value.
     */
    private WorkspaceProperties innerProperties() {
        return this.innerProperties;
    }

    /**
     * Get the sku property: The SKU of the resource.
     *
     * @return the sku value.
     */
    public Sku sku() {
        return this.sku;
    }

    /**
     * Set the sku property: The SKU of the resource.
     *
     * @param sku the sku value to set.
     * @return the WorkspaceInner object itself.
     */
    public WorkspaceInner withSku(Sku sku) {
        this.sku = sku;
        return this;
    }

    /**
     * Get the systemData property: The system metadata relating to this resource.
     *
     * @return the systemData value.
     */
    public SystemData systemData() {
        return this.systemData;
    }

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

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

    /**
     * Get the managedResourceGroupId property: The managed resource group Id.
     *
     * @return the managedResourceGroupId value.
     */
    public String managedResourceGroupId() {
        return this.innerProperties() == null ? null : this.innerProperties().managedResourceGroupId();
    }

    /**
     * Set the managedResourceGroupId property: The managed resource group Id.
     *
     * @param managedResourceGroupId the managedResourceGroupId value to set.
     * @return the WorkspaceInner object itself.
     */
    public WorkspaceInner withManagedResourceGroupId(String managedResourceGroupId) {
        if (this.innerProperties() == null) {
            this.innerProperties = new WorkspaceProperties();
        }
        this.innerProperties().withManagedResourceGroupId(managedResourceGroupId);
        return this;
    }

    /**
     * Get the parameters property: The workspace's custom parameters.
     *
     * @return the parameters value.
     */
    public WorkspaceCustomParameters parameters() {
        return this.innerProperties() == null ? null : this.innerProperties().parameters();
    }

    /**
     * Set the parameters property: The workspace's custom parameters.
     *
     * @param parameters the parameters value to set.
     * @return the WorkspaceInner object itself.
     */
    public WorkspaceInner withParameters(WorkspaceCustomParameters parameters) {
        if (this.innerProperties() == null) {
            this.innerProperties = new WorkspaceProperties();
        }
        this.innerProperties().withParameters(parameters);
        return this;
    }

    /**
     * Get the provisioningState property: The workspace provisioning state.
     *
     * @return the provisioningState value.
     */
    public ProvisioningState provisioningState() {
        return this.innerProperties() == null ? null : this.innerProperties().provisioningState();
    }

    /**
     * Get the uiDefinitionUri property: The blob URI where the UI definition file is located.
     *
     * @return the uiDefinitionUri value.
     */
    public String uiDefinitionUri() {
        return this.innerProperties() == null ? null : this.innerProperties().uiDefinitionUri();
    }

    /**
     * Set the uiDefinitionUri property: The blob URI where the UI definition file is located.
     *
     * @param uiDefinitionUri the uiDefinitionUri value to set.
     * @return the WorkspaceInner object itself.
     */
    public WorkspaceInner withUiDefinitionUri(String uiDefinitionUri) {
        if (this.innerProperties() == null) {
            this.innerProperties = new WorkspaceProperties();
        }
        this.innerProperties().withUiDefinitionUri(uiDefinitionUri);
        return this;
    }

    /**
     * Get the authorizations property: The workspace provider authorizations.
     *
     * @return the authorizations value.
     */
    public List<WorkspaceProviderAuthorization> authorizations() {
        return this.innerProperties() == null ? null : this.innerProperties().authorizations();
    }

    /**
     * Set the authorizations property: The workspace provider authorizations.
     *
     * @param authorizations the authorizations value to set.
     * @return the WorkspaceInner object itself.
     */
    public WorkspaceInner withAuthorizations(List<WorkspaceProviderAuthorization> authorizations) {
        if (this.innerProperties() == null) {
            this.innerProperties = new WorkspaceProperties();
        }
        this.innerProperties().withAuthorizations(authorizations);
        return this;
    }

    /**
     * Get the createdBy property: Indicates the Object ID, PUID and Application ID of entity that created the
     * workspace.
     *
     * @return the createdBy value.
     */
    public CreatedBy createdBy() {
        return this.innerProperties() == null ? null : this.innerProperties().createdBy();
    }

    /**
     * Set the createdBy property: Indicates the Object ID, PUID and Application ID of entity that created the
     * workspace.
     *
     * @param createdBy the createdBy value to set.
     * @return the WorkspaceInner object itself.
     */
    public WorkspaceInner withCreatedBy(CreatedBy createdBy) {
        if (this.innerProperties() == null) {
            this.innerProperties = new WorkspaceProperties();
        }
        this.innerProperties().withCreatedBy(createdBy);
        return this;
    }

    /**
     * Get the updatedBy property: Indicates the Object ID, PUID and Application ID of entity that last updated the
     * workspace.
     *
     * @return the updatedBy value.
     */
    public CreatedBy updatedBy() {
        return this.innerProperties() == null ? null : this.innerProperties().updatedBy();
    }

    /**
     * Set the updatedBy property: Indicates the Object ID, PUID and Application ID of entity that last updated the
     * workspace.
     *
     * @param updatedBy the updatedBy value to set.
     * @return the WorkspaceInner object itself.
     */
    public WorkspaceInner withUpdatedBy(CreatedBy updatedBy) {
        if (this.innerProperties() == null) {
            this.innerProperties = new WorkspaceProperties();
        }
        this.innerProperties().withUpdatedBy(updatedBy);
        return this;
    }

    /**
     * Get the createdDateTime property: Specifies the date and time when the workspace is created.
     *
     * @return the createdDateTime value.
     */
    public OffsetDateTime createdDateTime() {
        return this.innerProperties() == null ? null : this.innerProperties().createdDateTime();
    }

    /**
     * Get the workspaceId property: The unique identifier of the databricks workspace in databricks control plane.
     *
     * @return the workspaceId value.
     */
    public String workspaceId() {
        return this.innerProperties() == null ? null : this.innerProperties().workspaceId();
    }

    /**
     * Get the workspaceUrl property: The workspace URL which is of the format
     * 'adb-{workspaceId}.{random}.azuredatabricks.net'.
     *
     * @return the workspaceUrl value.
     */
    public String workspaceUrl() {
        return this.innerProperties() == null ? null : this.innerProperties().workspaceUrl();
    }

    /**
     * Get the storageAccountIdentity property: The details of Managed Identity of Storage Account.
     *
     * @return the storageAccountIdentity value.
     */
    public ManagedIdentityConfiguration storageAccountIdentity() {
        return this.innerProperties() == null ? null : this.innerProperties().storageAccountIdentity();
    }

    /**
     * Set the storageAccountIdentity property: The details of Managed Identity of Storage Account.
     *
     * @param storageAccountIdentity the storageAccountIdentity value to set.
     * @return the WorkspaceInner object itself.
     */
    public WorkspaceInner withStorageAccountIdentity(ManagedIdentityConfiguration storageAccountIdentity) {
        if (this.innerProperties() == null) {
            this.innerProperties = new WorkspaceProperties();
        }
        this.innerProperties().withStorageAccountIdentity(storageAccountIdentity);
        return this;
    }

    /**
     * Get the managedDiskIdentity property: The details of Managed Identity of Disk Encryption Set used for Managed
     * Disk Encryption.
     *
     * @return the managedDiskIdentity value.
     */
    public ManagedIdentityConfiguration managedDiskIdentity() {
        return this.innerProperties() == null ? null : this.innerProperties().managedDiskIdentity();
    }

    /**
     * Set the managedDiskIdentity property: The details of Managed Identity of Disk Encryption Set used for Managed
     * Disk Encryption.
     *
     * @param managedDiskIdentity the managedDiskIdentity value to set.
     * @return the WorkspaceInner object itself.
     */
    public WorkspaceInner withManagedDiskIdentity(ManagedIdentityConfiguration managedDiskIdentity) {
        if (this.innerProperties() == null) {
            this.innerProperties = new WorkspaceProperties();
        }
        this.innerProperties().withManagedDiskIdentity(managedDiskIdentity);
        return this;
    }

    /**
     * Get the diskEncryptionSetId property: The resource Id of the managed disk encryption set.
     *
     * @return the diskEncryptionSetId value.
     */
    public String diskEncryptionSetId() {
        return this.innerProperties() == null ? null : this.innerProperties().diskEncryptionSetId();
    }

    /**
     * Get the encryption property: Encryption properties for databricks workspace.
     *
     * @return the encryption value.
     */
    public WorkspacePropertiesEncryption encryption() {
        return this.innerProperties() == null ? null : this.innerProperties().encryption();
    }

    /**
     * Set the encryption property: Encryption properties for databricks workspace.
     *
     * @param encryption the encryption value to set.
     * @return the WorkspaceInner object itself.
     */
    public WorkspaceInner withEncryption(WorkspacePropertiesEncryption encryption) {
        if (this.innerProperties() == null) {
            this.innerProperties = new WorkspaceProperties();
        }
        this.innerProperties().withEncryption(encryption);
        return this;
    }

    /**
     * Get the privateEndpointConnections property: Private endpoint connections created on the workspace.
     *
     * @return the privateEndpointConnections value.
     */
    public List<PrivateEndpointConnectionInner> privateEndpointConnections() {
        return this.innerProperties() == null ? null : this.innerProperties().privateEndpointConnections();
    }

    /**
     * Get the publicNetworkAccess property: The network access type for accessing workspace. Set value to disabled to
     * access workspace only via private link.
     *
     * @return the publicNetworkAccess value.
     */
    public PublicNetworkAccess publicNetworkAccess() {
        return this.innerProperties() == null ? null : this.innerProperties().publicNetworkAccess();
    }

    /**
     * Set the publicNetworkAccess property: The network access type for accessing workspace. Set value to disabled to
     * access workspace only via private link.
     *
     * @param publicNetworkAccess the publicNetworkAccess value to set.
     * @return the WorkspaceInner object itself.
     */
    public WorkspaceInner withPublicNetworkAccess(PublicNetworkAccess publicNetworkAccess) {
        if (this.innerProperties() == null) {
            this.innerProperties = new WorkspaceProperties();
        }
        this.innerProperties().withPublicNetworkAccess(publicNetworkAccess);
        return this;
    }

    /**
     * Get the requiredNsgRules property: Gets or sets a value indicating whether data plane (clusters) to control plane
     * communication happen over private endpoint. Supported values are 'AllRules' and 'NoAzureDatabricksRules'.
     * 'NoAzureServiceRules' value is for internal use only.
     *
     * @return the requiredNsgRules value.
     */
    public RequiredNsgRules requiredNsgRules() {
        return this.innerProperties() == null ? null : this.innerProperties().requiredNsgRules();
    }

    /**
     * Set the requiredNsgRules property: Gets or sets a value indicating whether data plane (clusters) to control plane
     * communication happen over private endpoint. Supported values are 'AllRules' and 'NoAzureDatabricksRules'.
     * 'NoAzureServiceRules' value is for internal use only.
     *
     * @param requiredNsgRules the requiredNsgRules value to set.
     * @return the WorkspaceInner object itself.
     */
    public WorkspaceInner withRequiredNsgRules(RequiredNsgRules requiredNsgRules) {
        if (this.innerProperties() == null) {
            this.innerProperties = new WorkspaceProperties();
        }
        this.innerProperties().withRequiredNsgRules(requiredNsgRules);
        return this;
    }

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

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