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

/** The workspace properties. */
@Fluent
public final class WorkspaceProperties {
    /*
     * The managed resource group Id.
     */
    @JsonProperty(value = "managedResourceGroupId", required = true)
    private String managedResourceGroupId;

    /*
     * The workspace's custom parameters.
     */
    @JsonProperty(value = "parameters")
    private WorkspaceCustomParameters parameters;

    /*
     * The workspace provisioning state.
     */
    @JsonProperty(value = "provisioningState", access = JsonProperty.Access.WRITE_ONLY)
    private ProvisioningState provisioningState;

    /*
     * The blob URI where the UI definition file is located.
     */
    @JsonProperty(value = "uiDefinitionUri")
    private String uiDefinitionUri;

    /*
     * The workspace provider authorizations.
     */
    @JsonProperty(value = "authorizations")
    private List<WorkspaceProviderAuthorization> authorizations;

    /*
     * Indicates the Object ID, PUID and Application ID of entity that created the workspace.
     */
    @JsonProperty(value = "createdBy")
    private CreatedBy createdBy;

    /*
     * Indicates the Object ID, PUID and Application ID of entity that last updated the workspace.
     */
    @JsonProperty(value = "updatedBy")
    private CreatedBy updatedBy;

    /*
     * Specifies the date and time when the workspace is created.
     */
    @JsonProperty(value = "createdDateTime", access = JsonProperty.Access.WRITE_ONLY)
    private OffsetDateTime createdDateTime;

    /*
     * The unique identifier of the databricks workspace in databricks control plane.
     */
    @JsonProperty(value = "workspaceId", access = JsonProperty.Access.WRITE_ONLY)
    private String workspaceId;

    /*
     * The workspace URL which is of the format 'adb-{workspaceId}.{random}.azuredatabricks.net'
     */
    @JsonProperty(value = "workspaceUrl", access = JsonProperty.Access.WRITE_ONLY)
    private String workspaceUrl;

    /*
     * The details of Managed Identity of Storage Account
     */
    @JsonProperty(value = "storageAccountIdentity")
    private ManagedIdentityConfiguration storageAccountIdentity;

    /*
     * The details of Managed Identity of Disk Encryption Set used for Managed Disk Encryption
     */
    @JsonProperty(value = "managedDiskIdentity")
    private ManagedIdentityConfiguration managedDiskIdentity;

    /*
     * The resource Id of the managed disk encryption set.
     */
    @JsonProperty(value = "diskEncryptionSetId", access = JsonProperty.Access.WRITE_ONLY)
    private String diskEncryptionSetId;

    /*
     * Encryption properties for databricks workspace
     */
    @JsonProperty(value = "encryption")
    private WorkspacePropertiesEncryption encryption;

    /*
     * Private endpoint connections created on the workspace
     */
    @JsonProperty(value = "privateEndpointConnections", access = JsonProperty.Access.WRITE_ONLY)
    private List<PrivateEndpointConnectionInner> privateEndpointConnections;

    /*
     * The network access type for accessing workspace. Set value to disabled to access workspace only via private
     * link.
     */
    @JsonProperty(value = "publicNetworkAccess")
    private PublicNetworkAccess publicNetworkAccess;

    /*
     * 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.
     */
    @JsonProperty(value = "requiredNsgRules")
    private RequiredNsgRules requiredNsgRules;

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

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

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

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

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

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

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

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

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

    /**
     * Set the authorizations property: The workspace provider authorizations.
     *
     * @param authorizations the authorizations value to set.
     * @return the WorkspaceProperties object itself.
     */
    public WorkspaceProperties withAuthorizations(List<WorkspaceProviderAuthorization> authorizations) {
        this.authorizations = 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.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 WorkspaceProperties object itself.
     */
    public WorkspaceProperties withCreatedBy(CreatedBy createdBy) {
        this.createdBy = 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.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 WorkspaceProperties object itself.
     */
    public WorkspaceProperties withUpdatedBy(CreatedBy updatedBy) {
        this.updatedBy = 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.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.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.workspaceUrl;
    }

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

    /**
     * Set the storageAccountIdentity property: The details of Managed Identity of Storage Account.
     *
     * @param storageAccountIdentity the storageAccountIdentity value to set.
     * @return the WorkspaceProperties object itself.
     */
    public WorkspaceProperties withStorageAccountIdentity(ManagedIdentityConfiguration storageAccountIdentity) {
        this.storageAccountIdentity = 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.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 WorkspaceProperties object itself.
     */
    public WorkspaceProperties withManagedDiskIdentity(ManagedIdentityConfiguration managedDiskIdentity) {
        this.managedDiskIdentity = 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.diskEncryptionSetId;
    }

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

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

    /**
     * Get the privateEndpointConnections property: Private endpoint connections created on the workspace.
     *
     * @return the privateEndpointConnections value.
     */
    public List<PrivateEndpointConnectionInner> privateEndpointConnections() {
        return this.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.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 WorkspaceProperties object itself.
     */
    public WorkspaceProperties withPublicNetworkAccess(PublicNetworkAccess publicNetworkAccess) {
        this.publicNetworkAccess = 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.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 WorkspaceProperties object itself.
     */
    public WorkspaceProperties withRequiredNsgRules(RequiredNsgRules requiredNsgRules) {
        this.requiredNsgRules = requiredNsgRules;
        return this;
    }

    /**
     * Validates the instance.
     *
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    public void validate() {
        if (managedResourceGroupId() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException(
                        "Missing required property managedResourceGroupId in model WorkspaceProperties"));
        }
        if (parameters() != null) {
            parameters().validate();
        }
        if (authorizations() != null) {
            authorizations().forEach(e -> e.validate());
        }
        if (createdBy() != null) {
            createdBy().validate();
        }
        if (updatedBy() != null) {
            updatedBy().validate();
        }
        if (storageAccountIdentity() != null) {
            storageAccountIdentity().validate();
        }
        if (managedDiskIdentity() != null) {
            managedDiskIdentity().validate();
        }
        if (encryption() != null) {
            encryption().validate();
        }
        if (privateEndpointConnections() != null) {
            privateEndpointConnections().forEach(e -> e.validate());
        }
    }

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