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

import com.azure.core.annotation.Fluent;
import com.azure.core.util.logging.ClientLogger;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.UUID;

/** The workspace provider authorization. */
@Fluent
public final class WorkspaceProviderAuthorization {
    /*
     * The provider's principal identifier. This is the identity that the provider will use to call ARM to manage the
     * workspace resources.
     */
    @JsonProperty(value = "principalId", required = true)
    private UUID principalId;

    /*
     * The provider's role definition identifier. This role will define all the permissions that the provider must have
     * on the workspace's container resource group. This role definition cannot have permission to delete the resource
     * group.
     */
    @JsonProperty(value = "roleDefinitionId", required = true)
    private UUID roleDefinitionId;

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

    /**
     * Get the principalId property: The provider's principal identifier. This is the identity that the provider will
     * use to call ARM to manage the workspace resources.
     *
     * @return the principalId value.
     */
    public UUID principalId() {
        return this.principalId;
    }

    /**
     * Set the principalId property: The provider's principal identifier. This is the identity that the provider will
     * use to call ARM to manage the workspace resources.
     *
     * @param principalId the principalId value to set.
     * @return the WorkspaceProviderAuthorization object itself.
     */
    public WorkspaceProviderAuthorization withPrincipalId(UUID principalId) {
        this.principalId = principalId;
        return this;
    }

    /**
     * Get the roleDefinitionId property: The provider's role definition identifier. This role will define all the
     * permissions that the provider must have on the workspace's container resource group. This role definition cannot
     * have permission to delete the resource group.
     *
     * @return the roleDefinitionId value.
     */
    public UUID roleDefinitionId() {
        return this.roleDefinitionId;
    }

    /**
     * Set the roleDefinitionId property: The provider's role definition identifier. This role will define all the
     * permissions that the provider must have on the workspace's container resource group. This role definition cannot
     * have permission to delete the resource group.
     *
     * @param roleDefinitionId the roleDefinitionId value to set.
     * @return the WorkspaceProviderAuthorization object itself.
     */
    public WorkspaceProviderAuthorization withRoleDefinitionId(UUID roleDefinitionId) {
        this.roleDefinitionId = roleDefinitionId;
        return this;
    }

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

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