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

package com.azure.resourcemanager.servicefabric.models;

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

/** The ApplicationUserAssignedIdentity model. */
@Fluent
public class ApplicationUserAssignedIdentity {
    /*
     * The friendly name of user assigned identity.
     */
    @JsonProperty(value = "name", required = true)
    private String name;

    /*
     * The principal id of user assigned identity.
     */
    @JsonProperty(value = "principalId", required = true)
    private String principalId;

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

    /**
     * Get the name property: The friendly name of user assigned identity.
     *
     * @return the name value.
     */
    public String name() {
        return this.name;
    }

    /**
     * Set the name property: The friendly name of user assigned identity.
     *
     * @param name the name value to set.
     * @return the ApplicationUserAssignedIdentity object itself.
     */
    public ApplicationUserAssignedIdentity withName(String name) {
        this.name = name;
        return this;
    }

    /**
     * Get the principalId property: The principal id of user assigned identity.
     *
     * @return the principalId value.
     */
    public String principalId() {
        return this.principalId;
    }

    /**
     * Set the principalId property: The principal id of user assigned identity.
     *
     * @param principalId the principalId value to set.
     * @return the ApplicationUserAssignedIdentity object itself.
     */
    public ApplicationUserAssignedIdentity withPrincipalId(String principalId) {
        this.principalId = principalId;
        return this;
    }

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

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